Implement KeySizeInBytes on AesGcm and AesCcm.#129770
Merged
Merged
Conversation
Co-authored-by: vcsjones <361677+vcsjones@users.noreply.github.com>
Co-authored-by: vcsjones <361677+vcsjones@users.noreply.github.com>
Co-authored-by: vcsjones <361677+vcsjones@users.noreply.github.com>
Copilot created this pull request from a session on behalf of
vcsjones
June 23, 2026 21:21
View session
vcsjones
approved these changes
Jun 23, 2026
Contributor
|
Tagging subscribers to this area: @bartonjs, @vcsjones, @dotnet/area-system-security |
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a new public instance property, KeySizeInBytes, to AesGcm and AesCcm, allowing callers to query the key length used to construct an instance.
Changes:
- Introduces
KeySizeInBytesas a public property onAesGcmandAesCcm. - Initializes
KeySizeInBytesin all relevant constructors (including obsoleteAesGcmctors). - Adds unit tests validating
KeySizeInBytesfor 128/192/256-bit keys and updates the ref assembly surface.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Security.Cryptography/tests/AesCcmTests.cs | Adds coverage asserting AesCcm.KeySizeInBytes matches the provided key length. |
| src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesGcm.cs | Ensures the obsolete AesGcm(ReadOnlySpan<byte>) constructor populates KeySizeInBytes. |
| src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesCcm.cs | Adds KeySizeInBytes API and sets it in both constructors. |
| src/libraries/System.Security.Cryptography/ref/System.Security.Cryptography.cs | Exposes KeySizeInBytes in the public ref contract for both AesGcm and AesCcm. |
| src/libraries/Common/tests/System/Security/Cryptography/AesGcmTests.cs | Adds coverage asserting AesGcm.KeySizeInBytes across both obsolete and tag-size ctors (as applicable). |
| src/libraries/Common/src/System/Security/Cryptography/AesGcm.cs | Adds KeySizeInBytes API and sets it in the tag-size constructor. |
Copilot's findings
- Files reviewed: 6/6 changed files
- Comments generated: 0
bartonjs
approved these changes
Jun 23, 2026
This was referenced Jun 24, 2026
Open
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 join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Implements #72191