Skip to content

Conversation

vcsjones
Copy link
Member

Fixes #117107

@vcsjones vcsjones added this to the 10.0.0 milestone Jun 30, 2025
@vcsjones vcsjones self-assigned this Jun 30, 2025
@Copilot Copilot AI review requested due to automatic review settings June 30, 2025 14:57
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 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);

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[ML-DSA]: Windows MLDsaImplementation throws unclear error for missing private key while signing
3 participants