-
Notifications
You must be signed in to change notification settings - Fork 5.1k
ML-DSA add byte array APIs #117044
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
ML-DSA add byte array APIs #117044
Conversation
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.
Pull Request Overview
This PR adds new byte[]-based overloads for ML-DSA export and signing APIs and updates existing code/tests to adopt these simpler overloads, replacing manual buffer management.
- Introduces
byte[] ExportMLDsaPublicKey()
,ExportMLDsaSecretKey()
,ExportMLDsaPrivateSeed()
,SignData(byte[], byte[]?)
andVerifyData(byte[], byte[], byte[]?)
overloads. - Updates all X509, PFX, COSE, OpenSSL, and common tests to use the new overloads and removes manual buffer length assertions.
- Extends the reference assembly (
ref/System.Security.Cryptography.cs
) and implementation (MLDsa.cs
,MLDsaImplementation.cs
,X509Certificate2.cs
,MLDsaX509SignatureGenerator.cs
) to support these overloads.
Reviewed Changes
Copilot reviewed 19 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/libraries/System.Security.Cryptography/tests/X509Certificates/X509Certificate2PemTests.cs | Use new SignData(data) overload instead of manual buffer |
src/libraries/System.Security.Cryptography/tests/X509Certificates/PfxTests.cs | Switch to ExportMLDsaPrivateSeed() /ExportMLDsaSecretKey() overloads |
src/libraries/System.Security.Cryptography/tests/X509Certificates/ExportTests.cs | Use ExportMLDsaSecretKey() overload |
src/libraries/System.Security.Cryptography/tests/X509Certificates/CertificateCreation/PrivateKeyAssociationTests.cs | Use ExportMLDsaPublicKey() and SignData(data) overloads |
src/libraries/System.Security.Cryptography/tests/X509Certificates/CertTests.cs | Use ExportMLDsaSecretKey() overload |
src/libraries/System.Security.Cryptography/tests/MLDsaOpenSslTests.Unix.cs | Use SignData(data, context) and ExportMLDsa*() overloads |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/X509Certificate2.cs | Simplify public key comparison using new ExportMLDsaPublicKey() |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/X509Certificates/MLDsaX509SignatureGenerator.cs | Return SignData(data) directly |
src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs | Add and reorder new byte[] overloads for export and signing APIs |
src/libraries/System.Security.Cryptography.Cose/tests/TestKeyRing.cs | Add centralized helper for ECDsa/RSA/MLDsa test keys |
src/libraries/System.Security.Cryptography.Cose/tests/System.Security.Cryptography.Cose.Tests.csproj | Include new TestKeyRing.cs in test project |
src/libraries/System.Security.Cryptography.Cose/tests/CoseTestHelpers.cs | Delegate to TestKeyRing and remove thread-static duplications |
src/libraries/Common/tests/.../MLDsa/MLDsaTestsBase.cs | Update tests to use SignData overloads |
src/libraries/Common/tests/.../MLDsa/MLDsaTests.cs | Add null-argument validation for new overloads |
src/libraries/Common/tests/.../MLDsa/MLDsaTestHelpers.cs | Cover default ReadOnlySpan<byte> in import tests |
src/libraries/Common/tests/.../MLDsa/MLDsaImplementationTests.cs | Add tests for null byte[] source imports |
src/libraries/Common/src/System/Security/Cryptography/SlhDsaImplementation.cs | Minor formatting around secret-key export |
src/libraries/Common/src/System/Security/Cryptography/MLDsaImplementation.cs | Adapt DuplicatePrivateKey to new export APIs |
src/libraries/Common/src/System/Security/Cryptography/MLDsa.cs | Implement new byte[] overloads and strengthen span overload checks |
Comments suppressed due to low confidence (1)
src/libraries/System.Security.Cryptography.Cose/tests/TestKeyRing.cs:23
- The property references an undeclared backing variable 'field', which will not compile. You should declare a private ECDsa? field for each property (e.g. '_es256') or use auto-properties with initialization.
internal ECDsa ES256 => field ??= CreateECDsa(_ec256Parameters, true);
...libraries/System.Security.Cryptography.Cose/src/System/Security/Cryptography/Cose/CoseKey.cs
Show resolved
Hide resolved
...ryptography/src/System/Security/Cryptography/X509Certificates/MLDsaX509SignatureGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/tests/MLDsaOpenSslTests.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/tests/MLDsaOpenSslTests.Unix.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLDsaImplementation.cs
Show resolved
Hide resolved
...Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestHelpers.cs
Show resolved
Hide resolved
...aries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTests.cs
Outdated
Show resolved
Hide resolved
...ryptography/src/System/Security/Cryptography/X509Certificates/MLDsaX509SignatureGenerator.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/tests/MLDsaOpenSslTests.Unix.cs
Outdated
Show resolved
Hide resolved
/ba-g all these seem unrelated and matched by Build Analysis |
This also addresses optional feedback from my last COSE PR.