Support HashML-DSA on Windows#117613
Merged
vcsjones merged 9 commits intodotnet:mainfrom Jul 16, 2025
Merged
Conversation
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for HashML-DSA (Hash-based ML-DSA) on Windows through CNG (Cryptography Next Generation) APIs. The implementation introduces platform-specific restrictions on hash algorithm and ML-DSA parameter combinations that Windows enforces, unlike the more permissive OpenSSL implementation.
Key changes include:
- Implementation of HashML-DSA signing and verification for Windows using BCrypt and NCrypt APIs
- Addition of hash algorithm mapping with Windows-specific restrictions
- Updated test infrastructure to handle platform-specific algorithm combinations
Reviewed Changes
Copilot reviewed 13 out of 13 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 |
Added reference to new MLDsa.Windows.cs file |
src/libraries/System.Security.Cryptography/src/Resources/Strings.resx |
Added error message for unsupported hash/ML-DSA combinations |
src/libraries/Microsoft.Bcl.Cryptography/src/System/Security/Cryptography/HashAlgorithmNames.cs |
Added constants for MD5, SHAKE128, and SHAKE256 hash algorithms |
src/libraries/Microsoft.Bcl.Cryptography/src/Resources/Strings.resx |
Added error message for unsupported hash/ML-DSA combinations |
src/libraries/Microsoft.Bcl.Cryptography/src/Microsoft.Bcl.Cryptography.csproj |
Moved HashAlgorithmNames.cs to be available for all target frameworks |
src/libraries/Common/tests/System/Security/Cryptography/HashInfo.cs |
Updated hash algorithm names from "BOGUS-" prefixed to actual names |
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsData.cs |
Updated test cases to handle Windows-specific restrictions |
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs |
Updated tests to use SHA-512 instead of SHA-256 and added Windows-specific restriction tests |
src/libraries/Common/src/System/Security/Cryptography/MLDsaImplementation.Windows.cs |
Implemented HashML-DSA signing and verification using BCrypt APIs |
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs |
Implemented HashML-DSA signing and verification using NCrypt APIs |
src/libraries/Common/src/System/Security/Cryptography/MLDsa.Windows.cs |
Added hash algorithm OID to CNG identifier mapping with Windows restrictions |
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptVerifySignature.cs |
Added BCrypt signature verification method for pre-hashed data |
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptSignHash.cs |
Added BCrypt signature creation method for pre-hashed data |
src/libraries/Common/src/System/Security/Cryptography/MLDsa.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLDsa.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLDsa.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLDsa.Windows.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <[email protected]>
bartonjs
reviewed
Jul 14, 2025
src/libraries/Common/src/System/Security/Cryptography/MLDsa.Windows.cs
Outdated
Show resolved
Hide resolved
bartonjs
reviewed
Jul 14, 2025
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs
Outdated
Show resolved
Hide resolved
bartonjs
reviewed
Jul 14, 2025
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs
Show resolved
Hide resolved
vcsjones
commented
Jul 14, 2025
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptSignHash.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLDsa.Windows.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs
Outdated
Show resolved
Hide resolved
This was referenced Jul 15, 2025
Open
bartonjs
reviewed
Jul 15, 2025
...s/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsData.cs
Outdated
Show resolved
Hide resolved
bartonjs
reviewed
Jul 15, 2025
src/libraries/System.Security.Cryptography/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
bartonjs
approved these changes
Jul 15, 2025
Member
Author
|
@bartonjs I think this can be |
Member
|
/ba-g None of the failures are relevant; the OSes applicable to this change all ran successfully. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This introduces HashML-DSA on Windows through CNG ncrypt and bcrypt.
This also restricts what hash algorithms can be used by which ML-DSA parameter set. Windows currently enforces this, which has been brought to the base class for consistency. Windows may relax this requirement in the future.
Contributes to #113502