Open sdrapkin opened 2 years ago
Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones See info in area-owners.md if you want to be subscribed.
Author: | sdrapkin |
---|---|
Assignees: | - |
Labels: | `api-suggestion`, `area-System.Security` |
Milestone: | - |
The reason for providing the NonceSizeBytes and TagSizeBytes is mainly to bring up that these have variability of implementation in the ecosystem at large; we've generally not found evidence that anyone actually ever reads them.
We intentionally don't allow retrieving the key itself from these new types, but adding an instance KeySize property seems reasonable to me.
Can this be added to .NET 8?
Background and motivation
System.Security.Cryptography:
Proposal-1:
AesGcm
andAesCcm
currently expose.NonceByteSizes
and.TagByteSizes
. However they do not expose allowed.KeyByteSizes
.AesGcm
andAesCcm
currently each support 3 key sizes: 16, 24, and 32 bytes. This proposal is for a public static property exposing these supported key sizes. Note: an instance ofAes
already provides.LegalKeySizes
property.Proposal-2: Add
.KeySize
public property to instances ofAesGcm
andAesCcm
. The purpose is to validate the externally-provided instance of each of these classes for adherence to specific key-strength level (ex. API requiresAesGcm
instance with 256-bit key strength only). Note that instance ofAes
already provides.KeySize
property precisely for that purpose.API Proposal
API Usage
Alternative Designs
No response
Risks
New APIs. No breaking changes/risks. No performance regressions/impacts.