davsclaus opened a new pull request, #30659: URL: https://github.com/apache/camel/pull/30659
[CAMEL-27449](https://issues.apache.org/jira/browse/CAMEL-27449) `PGPKeyAccessDataFormat.unmarshal` refused an OCB (AEAD) encrypted message, packet tag 20, with "PGP message is not integrity protected" when `requireIntegrityProtection` is on, which is the default. GnuPG 2.4 and later write OCB by default for keys made with GnuPG 2.4+. So out of the box, Camel could not decrypt what current GnuPG users send. OCB is authenticated encryption, so the message is integrity protected. In Bouncy Castle 1.87, `isIntegrityProtected()` covers SEIPD v1 and v2 (v2 already passed), and `isAEAD()` covers the OCB packet and SEIPD v2. `verify()` does not apply to the OCB packet: the decrypting stream checks the tag of every chunk and the final tag, and throws on a mismatch. ### Changes - `unmarshal` accepts a message for which `pbe.isAEAD()` is true. It reads the decrypted stream to its end, so the final tag is always checked. A message without any protection is still refused while `requireIntegrityProtection` is on. - Javadoc of `setRequireIntegrityProtection` updated. - Docs: replaced the wrong sentence "This data format implements only symmetric (shared-key) encryption" with a short explanation of PGP public-key encryption and signing, and of which messages count as integrity protected. ### Tests New `PGPOcbEncryptedMessageTest` (5 tests), with a key pair and messages made by GnuPG 2.5.24; the commands are in the test's Javadoc. `gpg --list-packets` shows `tag=20` / `:ocb encrypted packet: cipher=9 aead=2`. - A signed OCB message decrypts with the integrity check on and `signatureVerificationOption=required`. - A message in 64-byte OCB chunks decrypts. - A changed byte in a chunk or in the final tag is rejected. - Without the fix, the decrypt test fails with "PGP message is not integrity protected". - `PGPRequireIntegrityProtectionTest` still covers refusing a message without protection. - `mvn test` in camel-crypto-pgp: 76 run, 0 failures, 22 skipped (the already disabled ElGamal test). This is a bug fix, so it can be backported. The change of default algorithms is a separate PR (CAMEL-27450), which is not backported. _Claude Code on behalf of Claus Ibsen_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
