Improve AES-KWP for Windows#129921
Open
vcsjones wants to merge 1 commit into
Open
Conversation
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 updates the Windows AesImplementation to use a reusable “lite” ECB cipher for RFC 5649 AES Key Wrap with Padding (AES-KWP), avoiding repeated handle setup/teardown during the wrap/unwrap loops. It also simplifies the internal helper plumbing in Aes by replacing a bespoke delegate type with Func<...> for the ECB transform callback.
Changes:
- Add Windows overrides for
EncryptKeyWrapPaddedCore/DecryptKeyWrapPaddedCorethat route AES-KWP throughILiteSymmetricCipher.Transform. - Remove the
KeyWrapEcbTransform<TState>helper delegate and useFunc<TState, ReadOnlySpan<byte>, Span<byte>, int>instead.
Show a summary per file
| File | Description |
|---|---|
| src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/AesImplementation.Windows.cs | Adds Windows AES-KWP fast-path using BasicSymmetricCipherLiteBCrypt (ECB) via GetKey().UseKey(...) and ILiteSymmetricCipher.Transform. |
| src/libraries/System.Security.Cryptography/src/System/Security/Cryptography/Aes.cs | Replaces the internal custom delegate used by AES-KWP helpers with Func<...> and updates the helper method signatures accordingly. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 0
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.
This is the follow up to #129911.
This is the Windows "Implementation" counterpart to AES-KWP. Like Apple, the performance improvements are 5x-20x faster and allocations go from input-length aligned to constant.
This makes also one other small improvement I noticed after I merged the apple changes - we don't need a custom delegate type. We only need
Func. Originally I had the delegate signature have anout, but it went away, so the need for a custom delegate went away too.Benchmark: