Fix ML-DSA PKCS8 copying bug#117847
Merged
PranavSenthilnathan merged 1 commit intodotnet:mainfrom Jul 21, 2025
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a critical bug in ML-DSA PKCS8 key export functionality where the entire backing array was being copied instead of just the relevant segment. Additionally, it addresses test failures related to unsupported hash algorithms on the .NET Framework platform by adding proper platform checks and adjusting test data generation.
- Fixed ArraySegment copying bug in ML-DSA PKCS8 export that could cause buffer overruns
- Added platform-specific hash algorithm support checks for ML-DSA tests
- Updated test data generation to avoid unsupported hash algorithms on netfx
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| MLDsaCng.Windows.cs | Fixed PKCS8 export bug by copying span instead of entire array |
| HashInfo.cs | Added helper property to identify supported hash algorithms |
| MLDsaTestsBase.cs | Added platform checks and fixed test data generation for unsupported algorithms |
Comments suppressed due to low confidence (1)
src/libraries/Common/tests/System/Security/Cryptography/HashInfo.cs:104
- The variable name 'field' is ambiguous and unclear. Consider using a more descriptive name like '_knownHashAlgorithmOids' to follow the backing field naming convention.
internal static HashSet<string> KnownHashAlgorithmOids => field ??= AllHashInfos().Select(h => h.Oid).ToHashSet();
Contributor
|
Tagging subscribers to this area: @dotnet/area-system-security, @bartonjs, @vcsjones |
vcsjones
approved these changes
Jul 19, 2025
This was referenced Jul 20, 2025
Open
bartonjs
approved these changes
Jul 21, 2025
Member
Author
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.
While I was fixing test failures, this bug was sometimes surfacing as an exception from CopyTo. We were copying the entire
ArraySegment<byte>.Arraywhen we should be only copying the relevant span.The rest of the PR changes are the test failures I was fixing, but otherwise unrelated to the above bug. SHAKE and SHA3 are not supported in netfx.