-
Notifications
You must be signed in to change notification settings - Fork 56
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support "pure" ML-DSA #422
Conversation
4def8b6
to
152c285
Compare
csrc/mldsa_gen.cpp
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Checked through EVP logic - lgtm
e8314cc
to
bf10d99
Compare
bf10d99
to
9f6a4ea
Compare
715ba18
to
3b871e5
Compare
4951135
to
dee52a5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor comments, but would like to get those cleaned up before a merge.
Not that I necessarily agree with the stance, but lately we've been including complete KAT suites for every new algorithm to the library.
benchmarks/lib/src/jmh/java/com/amazon/corretto/crypto/provider/benchmarks/SignatureMlDSA.java
Outdated
Show resolved
Hide resolved
benchmarks/lib/src/jmh/java/com/amazon/corretto/crypto/provider/benchmarks/KeyGenMlDSA.java
Outdated
Show resolved
Hide resolved
tst/com/amazon/corretto/crypto/provider/test/KeyReuseThreadStormTest.java
Show resolved
Hide resolved
src/com/amazon/corretto/crypto/provider/AmazonCorrettoCryptoProvider.java
Outdated
Show resolved
Hide resolved
a2c1578
to
0b41aa7
Compare
0b41aa7
to
7f004fd
Compare
I would've included some KATs if it were straightforward. However, because ML-DSA introduces distinct randomness into each signature, signatures produced with identical parameters are unique. Since ACCP/JCA doesn't have a clean way of exposing AWS-LC's ML-DSA derandomization APIs, KATs for this PR are currently infeasible. |
A [recent AWS-LC change][1], coupled with [ACCP's recent ML-DSA support][2], induces [failures][3] in AWS-LC's tip-of-ACCP-main integration test. This is ultimately due to ACCP's current lack of support for deserializing BouncyCastle's ML-DSA private key encoding; ACCP expects the full key while BouncyCastle encodes only the 32 bytes seed. We're actively working on supporting both formats, but until that lands we modify `EvpKeyFactoryTest` to use ACCP for all ML-DSA keypairs. This was caught upstream in AWS-LC instead of ACCP's CI because: 1. ACCP pins AWS-LC version and doesn't currently test against AWS-LC tip-of-main 2. ACCP's EvpKeyFactoryTest cases for ML-DSA previously succeeded only because the de/serialized keys were never used. We were "successfully" deserializing BouncyCastle "keys" represented as a 32-byte seed, but never used them cryptographically in EvpKeyFactoryTest. Doing so results in verification failures as documented [here][4]. With AWS-LC's [recent change][1], the cryptographic properties of raw private key material are exercised and thus deserialization of seeds fails. We also bump AWS-LC tracking version to include above in tests. [1]: aws/aws-lc@695c3a0 [2]: #422 [3]: https://github.com/aws/aws-lc/actions/runs/13084244974/job/36513185053 [4]: https://github.com/corretto/amazon-corretto-crypto-provider/blob/aa9bfd2acc1c3539e2fe21630685b704930b9f74/tst/com/amazon/corretto/crypto/provider/test/MLDSATest.java#L239-L245
Issue #, if available: i/ACCP-100
Description of changes:
Overview
This PR exposes ML-DSA functionality through the Signature, KeyPairGenerator, and KeyFactory JCA interfaces. The implementation closely follows our Ed25519 implementation, as both algorithms are currently used through AWS-LC's
EVP_DigestSign
API initialized with aNULL
message digest (these newer algorithms use a fixed, non-parameterizable digest function per spec).We also provide benchmarks for key generation, signing, and verifying.
Interoperability
This change has been written to be interoperable and forwards-compatible with other JCA provider ML-DSA implementations, such as BouncyCastle's and OpenJDK's JEP 497.
This means that ACCP callers cannot use JDK's NamedParameterSpec classes or BouncyCastle's MLDSAParameterSpec, but allows ACCP to provide ML-DSA on supported LTS JDK versions, independent of other providers. Instead of using ParameterSpec classes, callers can request a specific security level via the algorithm name passed into
KeyPairGenerator.getInstance
(if no level is specified,"ML-DSA-44"
is the default, conforming to JEP 497):We also update our BouncyCastle test dependency to 1.80, allowing us to pefrorm interoperability tests with BouncyCastle's ML-DSA implementation.
Limitations
As mentioned above, ACCP does not currently support ParameterSpec-based initialization on
KeyPairGenerator
instances. We also don't supportkeysize
-based initialization as it is somewhat ambiguous for ML-DSA. These limitations may change in the future.ACCP's ML-DSA keys cannot be used directly with BouncyCastle KeyFactory or Signature instances, as BouncyCastle only supports its own keys today. To use ACCP keys with BouncyCastle, callers will need to serialize them into
X509EncodedKeySpec
orPKCS8EncodedKeySpec
instances and pass those to BouncyCastle'sKeyFactory
for conversion.Finally, ACCP cannot yet deserialize ML-DSA private keys serialized by BouncyCastle. BouncyCastle currently encodes the private key's 32 byte seed upon serialization, while ACCP expects the fully expanded private key material.
Future Work
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.