Skip to content

ML-KEM: Windows ephemeral implementation #116440

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 13 commits into from
Jun 12, 2025

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Jun 9, 2025

This implements MLKem's ephemeral implementation (MLKemImplementation) on Windows using bcrypt CNG.

Contributes to #116304

@Copilot Copilot AI review requested due to automatic review settings June 9, 2025 19:57
@vcsjones vcsjones requested a review from bartonjs June 9, 2025 19:58
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 adds a Windows‐specific ephemeral implementation of ML-KEM via BCrypt CNG and updates tests to use a unified platform check.

  • Introduces MLKemImplementation.Windows and corresponding interop layers for key generation, import/export, and encapsulation/decapsulation.
  • Extends PqcBlobHelpers with ML-KEM parameter‐set support and updates the Common and BCL projects to include new CNG interop files.
  • Changes X509 and PFX tests to use PlatformSupport.IsPqcMLKemX509Supported for gating, and adds a new resource string for invalid private keys.

Reviewed Changes

Copilot reviewed 17 out of 17 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/libraries/Common/src/System/Security/Cryptography/MLKemImplementation.Windows.cs New Windows CNG–based ML-KEM implementation subclasses MLKem.
src/libraries/Common/src/System/Security/Cryptography/PqcBlobHelpers.MLKem.cs Added ML-KEM blob‐magic mapping and parameter‐set helpers.
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDecapsulateEncapsulate.cs Declared BCryptEncapsulate/BCryptDecapsulate P/Invoke wrappers.
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.Blobs.cs Added BCRYPT_MLKEM_KEY_BLOB struct and magic‐number constants.
src/libraries/Common/tests/System/Security/Cryptography/PlatformSupport.cs Introduced IsPqcMLKemX509Supported to gate ML-KEM X509 tests.
src/libraries/System.Security.Cryptography/tests/X509Certificates/* Switched ML-KEM test attributes to use PlatformSupport.
src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj Included new interop and helper files for ML-KEM Windows support.
src/libraries/Microsoft.Bcl.Cryptography/src/Resources/Strings.resx Added Cryptography_NotValidPrivateKey resource string.
src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.csproj Adjusted ItemGroup conditions to include Windows PQC support.
Comments suppressed due to low confidence (1)

src/libraries/Microsoft.Bcl.Cryptography/src/Resources/Strings.resx:159

  • [nitpick] The new resource 'Cryptography_NotValidPrivateKey' isn't referenced anywhere. Either remove this dead entry or wire it up to the appropriate exception paths to avoid unused localization strings.
<data name="Cryptography_NotValidPrivateKey" xml:space="preserve">

@vcsjones vcsjones added this to the 10.0.0 milestone Jun 11, 2025
@vcsjones vcsjones enabled auto-merge (squash) June 11, 2025 23:55
@vcsjones vcsjones merged commit 8a35055 into dotnet:main Jun 12, 2025
84 of 86 checks passed
@vcsjones vcsjones deleted the ml-kem-windows-bcrypt branch June 12, 2025 19:03
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