-
Notifications
You must be signed in to change notification settings - Fork 5k
ML-KEM: PKCS#8 Exports #114266
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-KEM: PKCS#8 Exports #114266
Conversation
Note regarding the
|
1 similar comment
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 adds support for PKCS#8 key exports to MLKem and MLKemOpenSsl by updating the native interop functions, managed API, and test coverage. Key changes include modifications in the native lib functions for extracting key parameters, updates to MLKemOpenSsl and MLKem implementation to propagate seed and decapsulation key information, and new tests for PKCS#8 exporting functionality.
Reviewed Changes
Copilot reviewed 15 out of 16 changed files in this pull request and generated no comments.
Show a summary per file
File | Description |
---|---|
src/native/libs/System.Security.Cryptography.Native/pal_evp_pkey.[ch] | Added a new function to check for an octet string parameter in EVP_PKEY. |
src/native/libs/System.Security.Cryptography.Native/pal_evp_kem.[ch] | Updated the KEM functions to report additional key attribute information. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/MLKemOpenSsl*.cs | Modified MLKemOpenSsl to consume the additional outputs for seed and decapsulation key. |
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/MLKemImplementation.OpenSsl.cs | Updated key generation and import methods to pass constant attribute values. |
src/libraries/System/Security/Cryptography/MLKem.cs and ref/System.Security.Cryptography.cs | Added the TryExportPkcs8PrivateKey API and expanded buffer export logic. |
src/libraries/Common/* | Added the MLKemPkcs8 helper and updated tests to cover the new PKCS#8 key export functionality. |
Files not reviewed (1)
- src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj: Language not supported
Comments suppressed due to low confidence (2)
src/libraries/Common/src/System/Security/Cryptography/MLKemPkcs8.cs:30
- If both 'hasSeed' and 'hasDecapsulationKey' are true, the current logic prioritizes using the seed for PKCS#8 export. Please document this precedence explicitly to improve clarity for future maintainers.
if (hasSeed)
src/libraries/Common/src/System/Security/Cryptography/MLKem.cs:808
- [nitpick] Consider replacing the magic number with a more descriptive constant name or adding a clarifying comment that explains why 86 bytes is the minimum size required for a PKCS#8 ML-KEM key export.
const int MinimumPossiblePkcs8MLKemKey = 86;
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
This adds PKCS#8 exports to
MLKem
andMLKemOpenSsl
.Contributes to #113508