-
Notifications
You must be signed in to change notification settings - Fork 5.1k
Support HashML-DSA on Windows #117613
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
Support HashML-DSA on Windows #117613
Conversation
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
There was a problem hiding this 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 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 <175728472+Copilot@users.noreply.github.com>
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
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs
Show resolved
Hide resolved
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
...s/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsData.cs
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/src/Resources/Strings.resx
Outdated
Show resolved
Hide resolved
@bartonjs I think this can be |
/ba-g None of the failures are relevant; the OSes applicable to this change all ran successfully. |
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