Repository navigation
Add ML-DSA (FIPS 204, RFC 9964) signature algorithms - #830
Open
SameerSinghhh wants to merge 1 commit into
Open
SameerSinghhh wants to merge 1 commit into
SameerSinghhh wants to merge 1 commit into
Conversation
Adds Algorithm.MLDSA44, MLDSA65 and MLDSA87 for the ML-DSA-44, ML-DSA-65 and ML-DSA-87 JWS algorithms defined in RFC 9964, with an MLDSAKeyProvider interface. The library still compiles for Java 8; ML-DSA itself comes from the JVM (Java 24+) or a registered provider such as BouncyCastle.
This branch has not been deployed
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.
Changes
Adds the ML-DSA post-quantum signature algorithms (FIPS 204), using the JWS algorithm names from RFC 9964:
ML-DSA-44,ML-DSA-65andML-DSA-87.Algorithm.MLDSA44,Algorithm.MLDSA65,Algorithm.MLDSA87, each with a(MLDSAKeyProvider)and a(PublicKey, PrivateKey)overload, following the existing RSA and ECDSA factories.MLDSAKeyProvider(new public interface incom.auth0.jwt.interfaces). ML-DSA keys have no dedicated type injava.security.interfaceson the Java versions this library supports, so it usesPublicKeyandPrivateKey.MLDSAAlgorithm(package-private). Signs the JWS signing input with pure ML-DSA and an empty context, as RFC 9964 requires. The signature goes into the token as is (no DER conversion as in ECDSA).No dependency is added and the library still compiles with
--release 8. ML-DSA comes from the JVM (Java 24 and later, JEP 497) or from a registered provider such as BouncyCastle, the same approach as the RSASSA-PSS note in the README. Without a provider, signing and verifying fail with the usualSignatureGenerationException/SignatureVerificationExceptionwrappingNoSuchAlgorithmException.Two checks are made before the provider is called:
ML-DSA-65, the JDK reports the familyML-DSA), so the check accepts the parameter set, the family or the OID, and the provider enforces the parameter set in the family case;Usage:
Alternative considered: accepting any
java.security.Keytype through a generic "custom JCA algorithm" factory. I kept to named factories so the algorithm in the token header is always tied to one parameter set.Not included: JWK (
AKPkey type) handling, since this library does not parse JWKs.References
Testing
MLDSAAlgorithmTest(17 tests, BouncyCastle registered so it runs on every Java version): sign and verify for all three parameter sets, agreement with the plain JCA API in both directions, tampered payload and signature, wrong-length signatures, another key, a key from another parameter set, an RSA key, an RSA token relabelled as ML-DSA, missing keys, key ids, and the no-provider case.MLDSAInteropTest(3 tests, skipped unless the JVM has native ML-DSA): tokens signed on the JDK's implementation verify with BouncyCastle and the reverse, and the JDK rejects keys from another parameter set.What I ran:
./gradlew assemble apiDiff checkstyleMain teston Java 11 (727 tests, 0 failures, the 3 interop tests skipped), and both new test classes on Java 24 (20 of 20). I did not run thetestInJava-8,-17and-21tasks locally.Checklist