Change Key on MLDsaCng to GetKey method#117741
Merged
vcsjones merged 1 commit intodotnet:mainfrom Jul 17, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR changes the Key property in the MLDsaCng class to a GetKey() method that returns a duplicated CNG key handle, following the same pattern previously implemented for MLKemCng. The change improves resource management by ensuring callers receive their own handle copy instead of sharing the internal handle.
Key changes:
- Property-to-method conversion for better handle management
- Addition of internal
KeyNoDuplicateproperty for internal use - Test coverage for the new
GetKey()method behavior
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
MLDsaCng.cs |
Updates API documentation and signature from property to method |
MLDsaCng.Windows.cs |
Implements GetKey() method with handle duplication logic and adds internal KeyNoDuplicate property |
Cng.NotSupported.cs |
Updates not-supported implementation and improves error message consistency |
System.Security.Cryptography.cs |
Updates public API reference from property to method |
CertificatePal.Windows.PrivateKey.cs |
Updates callers to use internal KeyNoDuplicate property |
MLDsaCngTests.Windows.cs |
Adds test to verify GetKey() returns distinct duplicated handles |
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
vcsjones
commented
Jul 17, 2025
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Cng.NotSupported.cs
Show resolved
Hide resolved
src/libraries/Common/src/System/Security/Cryptography/MLDsaCng.Windows.cs
Show resolved
Hide resolved
PranavSenthilnathan
approved these changes
Jul 17, 2025
This was referenced Jul 17, 2025
bartonjs
approved these changes
Jul 17, 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.
As we did for MLKemCng, this changes the
CngKey Keyproperty toCngKey GetKey()method that returns a duplicated handle.