Skip to content

Add ML-DSA (FIPS 204, RFC 9964) signature algorithms - #830

Open
SameerSinghhh wants to merge 1 commit into
auth0:masterfrom
SameerSinghhh:feat/ml-dsa
Open

SameerSinghhh wants to merge 1 commit into
auth0:masterfrom
SameerSinghhh:feat/ml-dsa

Conversation

@SameerSinghhh

Copy link
Copy Markdown

Changes

Adds the ML-DSA post-quantum signature algorithms (FIPS 204), using the JWS algorithm names from RFC 9964: ML-DSA-44, ML-DSA-65 and ML-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 in com.auth0.jwt.interfaces). ML-DSA keys have no dedicated type in java.security.interfaces on the Java versions this library supports, so it uses PublicKey and PrivateKey.
  • 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).
  • README: three rows in the algorithms table and a note on provider requirements.

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 usual SignatureGenerationException / SignatureVerificationException wrapping NoSuchAlgorithmException.

Two checks are made before the provider is called:

  • the key must be an ML-DSA key of the same parameter set. Providers name these keys differently (BouncyCastle reports ML-DSA-65, the JDK reports the family ML-DSA), so the check accepts the parameter set, the family or the OID, and the provider enforces the parameter set in the family case;
  • the signature must have the exact length for the parameter set (2420, 3309 or 4627 bytes).

Usage:

KeyPair keys = KeyPairGenerator.getInstance("ML-DSA-65").generateKeyPair(); // Java 24+, or BouncyCastle
Algorithm algorithm = Algorithm.MLDSA65(keys.getPublic(), keys.getPrivate());
String token = JWT.create().withIssuer("auth0").sign(algorithm);
JWT.require(algorithm).withIssuer("auth0").build().verify(token);

Alternative considered: accepting any java.security.Key type 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 (AKP key 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 test on 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 the testInJava-8, -17 and -21 tasks locally.

  • This change adds test coverage
  • This change has been tested on the latest version of Java or why not (tested on Java 11 and Java 24)

Checklist

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.
@SameerSinghhh
SameerSinghhh requested a review from a team as a code owner December 4, 2026 01:01

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant