Fix MLDsaImplementation on Windows to throw a more clear exception#117150
Merged
vcsjones merged 1 commit intodotnet:mainfrom Jun 30, 2025
Merged
Fix MLDsaImplementation on Windows to throw a more clear exception#117150vcsjones merged 1 commit intodotnet:mainfrom
vcsjones merged 1 commit intodotnet:mainfrom
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR addresses issue #117107 by ensuring that when a public key–only MLDsa instance is used to sign data on Windows, a clear and specific exception is thrown.
- Adds a new test, SignData_PublicKeyOnlyThrows, to validate the exception message clarity when signing data with a public key only.
- Updates the SignDataCore method in the Windows implementation to throw CryptographicException with a clearer error message when no secret key is available.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs | Adds a new test to verify that invoking SignData with a public key only throws a clear exception. |
| src/libraries/Common/src/System/Security/Cryptography/MLDsaImplementation.Windows.cs | Updates SignDataCore to perform an early check for the secret key and throw a clear exception message. |
Comments suppressed due to low confidence (2)
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs:284
- [nitpick] Consider renaming the test method to something more descriptive such as 'SignData_WithPublicKeyOnly_ThrowsClearException' to better communicate its purpose.
public void SignData_PublicKeyOnlyThrows(MLDsaKeyInfo info)
src/libraries/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs:291
- [nitpick] Consider asserting the exact expected exception message rather than only verifying that it doesn't contain 'unknown' to further ensure the exception is as clear as intended.
Assert.DoesNotContain("unknown", ce.Message, StringComparison.OrdinalIgnoreCase);
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
vcsjones
commented
Jun 30, 2025
...s/Common/tests/System/Security/Cryptography/AlgorithmImplementations/MLDsa/MLDsaTestsBase.cs
Show resolved
Hide resolved
bartonjs
approved these changes
Jun 30, 2025
This was referenced Jun 30, 2025
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.
Fixes #117107