Skip to content

ML-KEM: X.509 private keys #114743

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

Merged
merged 6 commits into from
Apr 17, 2025
Merged

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Apr 16, 2025

This adds X509Certificate2.GetMLKemPrivateKey and X509Certificate2.CopyWithPrivateKey(MLKem). Additionally, this enlightens X509Certificate2.CreateFromPem and some of its related functions to support importing PEM aggregates of certificates and ML-KEM PKCS#8 keys.

Contributes to #113508.

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.

1 similar comment
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.

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.

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 PR introduces support for ML-KEM private keys in X509Certificate2 by adding GetMLKemPrivateKey and CopyWithPrivateKey(MLKem) along with corresponding tests and test data updates. Key changes include:

  • New APIs and error handling paths for ML-KEM private key extraction and association.
  • Updated test coverage in multiple test files to validate ML-KEM PEM import/export and key matching.
  • Adjustments in underlying PAL and implementation classes across platforms to support or explicitly reject ML-KEM operations.

Reviewed Changes

Copilot reviewed 14 out of 15 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
X509Certificate2PemTests.cs Added new tests for CreateFromPem and CreateFromEncryptedPem with ML-KEM keys; modified AssertKeysMatch.
PrivateKeyAssociationTests.cs Added ML-KEM specific tests for certificate private key association.
CertTests.cs Added tests to validate exporting ML-KEM private keys.
X509Certificate2.cs Introduced ML-KEM API methods and updated key extraction methods to include ML-KEM.
OpenSslX509CertificateReader.cs, ICertificatePal.cs, CertificatePal.Windows.PrivateKey.cs, AppleCertificatePal.cs, AndroidCertificatePal.cs Added ML-KEM support (or explicit not supported exceptions) in platform-specific implementations.
MLKemImplementation.* Updated ML-KEM implementations and test data to support the new ML-KEM functionality.
Files not reviewed (1)
  • src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj: Language not supported

@vcsjones vcsjones merged commit 760e8e9 into dotnet:main Apr 17, 2025
77 of 85 checks passed
@vcsjones vcsjones deleted the ml-kem-x509-private-key branch April 17, 2025 21:04
@vcsjones vcsjones added this to the 10.0.0 milestone Apr 19, 2025
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