Skip to content
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: EncryptedPrivateKeyInfo exports #114304

Merged
merged 6 commits into from
Apr 8, 2025

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Apr 6, 2025

This pull request adds PKCS#8 EncryptedPrivateKeyInfo exports.

Contributes to #113508

@Copilot Copilot bot review requested due to automatic review settings April 6, 2025 02:29
Copy link

Note regarding the new-api-needs-documentation label:

This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change.

This comment was marked as duplicate.

Copy link
Contributor

@Copilot Copilot AI left a 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 pull request adds new APIs to export ML-KEM keys in the PKCS#8 EncryptedPrivateKeyInfo format, along with comprehensive tests to validate the new functionality.

  • Introduces overloads for ExportEncryptedPkcs8PrivateKey and TryExportEncryptedPkcs8PrivateKey accepting both char- and byte-based passwords.
  • Adds validation tests for proper handling of PBE parameters, disposal states, and buffer size scenarios.
  • Extends test coverage in MLKemContractTests and MLKemBaseTests to verify roundtrip key export and import behaviors.

Reviewed Changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 1 comment.

File Description
src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs Added API declarations for exporting encrypted PKCS#8 private keys.
src/libraries/Common/tests/System/Security/Cryptography/MLKemContractTests.cs Added tests for disposal and parameter validation regarding encrypted PKCS#8 export.
src/libraries/Common/tests/System/Security/Cryptography/MLKemBaseTests.cs Extended tests to cover roundtrip and failure cases for encrypted PKCS#8 exports.
src/libraries/Common/src/System/Security/Cryptography/MLKem.cs Implemented encryption export functionality and helper method for buffer sizing and ASN.1 encoding.
Files not reviewed (1)
  • src/libraries/Microsoft.Bcl.Cryptography/tests/Microsoft.Bcl.Cryptography.Tests.csproj: Language not supported
Comments suppressed due to low confidence (1)

src/libraries/Common/tests/System/Security/Cryptography/MLKemBaseTests.cs:593

  • [nitpick] Consider separating the tests for TryExportPkcs8PrivateKey and ExportPkcs8PrivateKey into distinct test cases to provide clearer isolation of failures and improve maintainability.
callback(pkcs8); callback(kem.ExportPkcs8PrivateKey());

Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. Learn more

Copy link
Contributor

Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones
See info in area-owners.md if you want to be subscribed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants