Skip to content

BCrypt Composite ML-DSA#129612

Open
PranavSenthilnathan wants to merge 3 commits into
dotnet:mainfrom
PranavSenthilnathan:cmldsa-bcrypt
Open

BCrypt Composite ML-DSA#129612
PranavSenthilnathan wants to merge 3 commits into
dotnet:mainfrom
PranavSenthilnathan:cmldsa-bcrypt

Conversation

@PranavSenthilnathan

@PranavSenthilnathan PranavSenthilnathan commented Jun 19, 2026

Copy link
Copy Markdown
Member

Windows Insider builds support Composite ML-DSA in BCrypt. Documentation of public API can be found here.

Note this changes the default implementation on Windows from managed to BCrypt. On versions that support Composite ML-DSA, this reduces the number of supported algorithms to the 4 listed in the docs above. And for Windows versions that don't support Composite ML-DSA, our default implementation also doesn't support it now.

Fixes #116999

@dotnet-policy-service

Copy link
Copy Markdown
Contributor

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

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 wires up Windows support for Composite ML-DSA via the BCrypt “single key”/PQDSA blob mechanism (including new parameter-set identifiers and blob magic values), and updates platform-support expectations in tests.

Changes:

  • Add Composite ML-DSA PQDSA blob encode/decode support and parameter-set mapping for Windows composite algorithms.
  • Implement Windows CompositeMLDsa operations (keygen/import/export/sign/verify) using BCrypt Composite-ML-DSA provider and PQDSA blobs.
  • Update Windows algorithm identifiers / magic numbers and adjust support-detection tests accordingly.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
src/libraries/System.Security.Cryptography/src/System.Security.Cryptography.csproj Removes managed Composite ML-DSA sources from the Windows build item group.
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/CompositeMLDsa/CompositeMLDsaFactoryTests.cs Updates platform support expectations for IsAlgorithmSupported on Windows.
src/libraries/Common/src/System/Security/Cryptography/PqcBlobHelpers.cs Adds composite parameter-set strings plus composite PQDSA blob encode/decode helpers; adjusts stackalloc threshold.
src/libraries/Common/src/System/Security/Cryptography/CompositeMLDsaImplementation.Windows.cs Replaces Windows PNSE stub with a BCrypt-backed implementation for composite keygen/import/export/sign/verify.
src/libraries/Common/src/System/Security/Cryptography/CompositeMLDsa.cs Adds an algorithm support check during PKCS#8 private-key import.
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.Blobs.cs Adds composite ML-DSA public/private magic numbers for PQDSA blobs.
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptSignHash.cs Changes PQC “pure” signing helper to return bytesWritten and relaxes debug assertion.
src/libraries/Common/src/Interop/Windows/BCrypt/Cng.cs Adds BCrypt algorithm name constant for Composite-ML-DSA.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 9 out of 9 changed files in this pull request and generated 4 comments.

Comment thread src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptSignHash.cs Outdated
Comment thread src/libraries/Common/tests/TestUtilities/System/PlatformDetection.Windows.cs Outdated

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Copilot AI review requested due to automatic review settings June 24, 2026 03:50

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

@PranavSenthilnathan PranavSenthilnathan changed the title [WIP] BCrypt Composite ML-DSA BCrypt Composite ML-DSA Jun 24, 2026
@PranavSenthilnathan PranavSenthilnathan marked this pull request as ready for review June 24, 2026 04:14

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

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

Comment on lines +47 to +48
int written = Interop.BCrypt.BCryptSignHashPqcPure(_key, data, context, destination);
Debug.Assert(written == destination.Length);
Comment on lines +580 to +582
if (!CompositeMLDsa.IsSupported ||
CompositeMLDsa.IsAlgorithmSupported(CompositeMLDsaAlgorithm.MLDsa87WithEd448))
throw new SkipTestException("Algorithm is supported on this platform.");

@vcsjones vcsjones Jun 24, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks odd. Consider using braces. I generally don't recommend we use braceless ifs if the if condition itself spans multiple lines. (Repeat feedback to other places)

internal const string BCRYPT_MLKEM_PARAMETER_SET_768 = "768";
internal const string BCRYPT_MLKEM_PARAMETER_SET_1024 = "1024";

internal const string BCRYPT_COMPOSITE_MLDSA_PARAMETER_SET_44_ECDSA_P256_SHA256 = "44-ECDSA-P256-SHA256";

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This basically hardcodes our list of supported composite algorithms. I think that's fine, but just noting that if Windows gets around to adding other things like RSA then we will have to do work to enable them.

Comment on lines +173 to +175
return ExportKey(
Interop.BCrypt.KeyBlobType.BCRYPT_PQDSA_PRIVATE_BLOB,
destination);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't have to be wrapped and can be a single line.

throw new PlatformNotSupportedException();
}

internal static bool TryGetCompositeMLDsaParameterSet(CompositeMLDsaAlgorithm algorithm, [NotNullWhen(true)] out string? parameterSet)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method signature should wrap.

throw new PlatformNotSupportedException();
}

internal static bool TryGetCompositeMLDsaParameterSet(CompositeMLDsaAlgorithm algorithm, [NotNullWhen(true)] out string? parameterSet)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the parameterSet just be a nullable property on CompositeMLDsaAlgorithm like MaxPublicKeySizeInBytes? That way this doesn't really even need to exist.

CompositeMLDsaAlgorithm alg = GetTheAlg();

if (alg.CngParameterSetName is null)
{
    throw new NotSupportedException();
}

string parameterSet = alg.CngParameterSetName;

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.

Support Composite ML-DSA with Windows BCrypt

3 participants