-
Notifications
You must be signed in to change notification settings - Fork 5.2k
ML-KEM: Change parameter from ReadOnlySpan to array #115016
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
Conversation
Note regarding the
|
Note regarding the
|
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 changes the signature of ImportEncryptedPkcs8PrivateKey to accept a byte array for the source parameter when a string password is provided, aligning its shape with related overloads.
- Updated the managed API in System.Security.Cryptography.cs to use byte[] for the source parameter.
- Adjusted tests in MLKemTests.cs to use the new overload and added tests for null argument handling.
- Modified the implementation in MLKem.cs to perform an argument null check on the source parameter.
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs | Updated the method signature to accept a byte array for the source parameter. |
src/libraries/Common/tests/System/Security/Cryptography/MLKemTests.cs | Updated test calls to use the new overload and added null argument tests. |
src/libraries/Common/src/System/Security/Cryptography/MLKem.cs | Updated the string overload to use byte[] and added a null check for the source parameter. |
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
|
||
Assert.Throws<CryptographicException>(() => | ||
MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER", new ReadOnlySpan<byte>(ecP256Key))); | ||
MLKem.ImportEncryptedPkcs8PrivateKey("PLACEHOLDER", ecP256Key)); |
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.
I didn't have to change that many tests because most of the tests used a string
for the password
parameter forces binding to a specific overload. I just changed this one since the span-wrapping served no purpose anymore.
After some backchanneling we discussed that the
ImportEncryptedPkcs8PrivateKey(string, ReadOnlySpan<byte>)
didn't have the same shape asImportFromEncryptedPem(string, byte[])
.We decided that since the
string
overloads forpassword
exist purely for ease-of-use for other downlevel platforms, theImportEncryptedPkcs8PrivateKey
one should take a byte array instead of aReadOnlySpan
. There is already an overload that acceptsReadOnlySpan<char>, ReadOnlySpan<byte>
, so modern targets still have access to all the span APIs that they want.Contributes to #113508