bc-java icon indicating copy to clipboard operation
bc-java copied to clipboard

Improve comparison logic during signature joining

Open vanitasvitae opened this issue 5 months ago • 0 comments

While playing with some tooling I built on top of BC/PGPainless, I noticed crashes when processing my whole GPG key ring (350+ keys).

Apparently the comparison code in PGPSignature.join() / PGPPublicKey.join() that checks, whether two signature objects represent the same signature is not specific enough. I stumbled across a key, which carried two signatures with the same RSA signature value, but different signature versions (one was version 3, the other one version 4).

As a result, PGPSignature.join() failed when trying to merge the subpacket areas, due to v3 sigs not having subpackets, resulting in an NPE.

This patch hardens signature comparison by also taking the version number into account, and by preventing to join v2/v3 signatures.

vanitasvitae avatar Sep 19 '24 22:09 vanitasvitae