Repository navigation
Reject legacy Dilithium keys instead of signing them as ML-DSA - #1813
Merged
andreasrosdalw merged 1 commit intoDec 3, 2026
Merged
Conversation
PdfPKCS7 mapped Dilithium2, Dilithium3 and Dilithium5 to the ML-DSA-44, ML-DSA-65 and ML-DSA-87 OIDs. CRYSTALS-Dilithium is a different algorithm, so its signatures were labelled as ML-DSA. Dilithium names are now rejected as unknown key algorithms, for internal and external signing. Fixes LibrePDF#1812 Co-Authored-By: Claude Opus 5.5 <[email protected]>
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 8 |
| Duplication | 4 |
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.
|
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.



Description of the new Feature/Bugfix
PdfPKCS7treated the legacy CRYSTALS-Dilithium namesDilithium2,Dilithium3andDilithium5as aliases of ML-DSA-44, ML-DSA-65 and ML-DSA-87. Dilithium is a different algorithm with its own OIDs, so a Dilithium signature could be written into a SignerInfo under an ML-DSA OID.isMlDsaNamenow accepts onlyML-DSAnames, and the parameter-set mapping knows only the ML-DSA names. A Dilithium key passed to the constructor, or a Dilithium name passed tosetExternalDigest, is now rejected as an unknown key algorithm. OpenPDF does not support signing with legacy Dilithium.Why reject Dilithium instead of supporting it
Rejecting Dilithium with a clear error is the safe choice. Verifying PDFs that were signed with Dilithium during the experimental years could be added on request, and only for verification, never for signing.
Related Issue: Fixes #1812
Unit-Tests for the new Feature/Bugfix
Added to
PdfPKCS7MlDsaTest:rejectsDilithiumKeys:Dilithium2,Dilithium3,Dilithium5andDILITHIUM3keys are rejected.rejectsExternalDilithiumSignatures:setExternalDigestwith a Dilithium name throws, even when the certificate holds an ML-DSA key.externalSignatureNamedWithItsParameterSet: external signatures namedML-DSA-44,ML-DSA-65andML-DSA-87are encoded with the matching OID and verify.Compatibilities Issues
Behaviour change: code that signed with a key named
Dilithium*, or calledsetExternalDigestwith such a name, now gets an exception instead of a signature labelled as ML-DSA. No method signatures change. The 4.0.0 changelog has an entry under Upgrade Notes. The ML-DSA support is only onmaster, so3.0-java21is not affected.Your real name
Andreas Røsdal
Testing details
./mvnw -pl openpdf-core test -Dtest=PdfPKCS7MlDsaTest(needs Java 25). Checkstyle passes locally. I could not run the tests locally because there is no JDK 25 on this machine, so this relies on CI.