Repository navigation
Support AES-256 and post-quantum ML-KEM certificate encryption - #1815
Merged
andreasrosdalw merged 3 commits intoDec 3, 2026
Merged
andreasrosdalw merged 3 commits into
andreasrosdalw merged 3 commits into
Conversation
Documents encrypted for certificates can use ENCRYPTION_AES_256_V3, the AES-256 public-key security handler of ISO 32000-2 (V 5, AESV3, SHA-256 key derivation), for writing and reading. Before, this mode wrote a broken V 4 dictionary with the RC4 crypt filter. A recipient certificate with an ML-KEM (FIPS 203) public key gets a CMS KEMRecipientInfo (RFC 9629, RFC 9936) that wraps the content key with AES-256, so the document key is protected against quantum attacks. RSA recipients still use key transport, and both can share one document. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 27 |
| Duplication | 1 |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
…he test Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Stronger encryption for documents that are encrypted for certificates (the public-key security handler):
setEncryption(Certificate[], int[], PdfWriter.ENCRYPTION_AES_256_V3)onPdfWriterandPdfStampernow writes the AES-256 public-key security handler of ISO 32000-2 (/V 5,/SubFilter /adbe.pkcs7.s5,/CFM /AESV3, SHA-256 key derivation).PdfReaderdecrypts these documents. Before, this mode wrote a broken/V 4dictionary with the RC4 crypt filter.KEMRecipientInfo(RFC 9629, RFC 9936) that wraps the content key with AES-256-WRAP. This replaces RSA key transport, which a quantum computer could break. RSA recipients keep using key transport, and RSA and ML-KEM recipients can share one document. Decryption chooses the KEM or key transport recipient automatically./Recipientsarray or a too-short decrypted seed now raisesInvalidPdfException/UnsupportedPdfExceptioninstead of an NPE or anArrayIndexOutOfBoundsException.The Bouncy Castle provider used for ML-KEM is created privately and is not registered with
java.security.Security.API changes
No new public methods except
BouncyCastleHelper.getProvider().ENCRYPTION_AES_256_V3with certificates now produces a valid AES-256 document.Interoperability
AES-256 certificate encryption follows ISO 32000-2. ML-KEM recipients are read by OpenPDF and other CMS implementations with ML-KEM support. Adobe Acrobat does not support ML-KEM recipients yet.
Tests
PdfPublicKeyEncryptionTest: AES-256 round trips with RSA, ML-KEM-768 with AES-256 and AES-128, mixed RSA + ML-KEM recipients,PdfStamper, wrong-key rejection for RSA and ML-KEM, CMS structure checks. The fullopenpdf-coresuite passes (2593 tests) andcheckstyle:checkis clean.