Conversation
|
@GrabYourPitchforks for the crypto @dotnet/aspnet-build for adding a new algorithms dependency, @dotnet/aspnet-blazor-eng for fyi/review |
src/DataProtection/DataProtection/src/Cng/GcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Cng/GcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
| bytesA = new ReadOnlySpan<byte>(bufA, byteCount); | ||
| bytesB = new ReadOnlySpan<byte>(bufB, byteCount); | ||
| } | ||
| return CryptographicOperations.FixedTimeEquals(bytesA, bytesB); |
There was a problem hiding this comment.
❤️
There are a bunch of places in data protection where we could leverage new primitives introduced to the framework in the past few releases. Might be interesting to have an issue for that. Identity likely can also benefit from it.
Co-authored-by: Pranav K <prkrishn@hotmail.com>
Co-authored-by: Pranav K <prkrishn@hotmail.com>
src/DataProtection/DataProtection/src/Cng/GcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
|
@GrabYourPitchforks when you get a chance could you review the new managed implementation and the test I added to make sure it looks legit? |
GrabYourPitchforks
left a comment
There was a problem hiding this comment.
Only thing that really needs fixed is the comment on AuthenticatedEncryptorDescriptorTests.cs. Approved once that's done. Everything else is at your discretion.
Thanks for getting to this! 👍
| Assert(countA == countB, "countA == countB"); | ||
|
|
||
| #if NETCOREAPP | ||
| unsafe |
There was a problem hiding this comment.
Extreme nits: No need to use unsafe here. If desired, you can also put the NoInlining | NoOptimization attribute within an #if !NETCOREAPP block. Maybe those can come with the spanification PR so as not to cause noise here.
There was a problem hiding this comment.
Will address this in the span PR
src/DataProtection/DataProtection/src/AuthenticatedEncryption/AuthenticatedEncryptorFactory.cs
Outdated
Show resolved
Hide resolved
...ion/test/AuthenticatedEncryption/ConfigurationModel/AuthenticatedEncryptorDescriptorTests.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
src/DataProtection/DataProtection/src/Managed/AesGcmAuthenticatedEncryptor.cs
Outdated
Show resolved
Hide resolved
|
|
||
| // Use the KDF to generate a new symmetric block cipher key | ||
| // We'll need a temporary buffer to hold the symmetric encryption subkey | ||
| var decryptedKdk = new byte[_keyDerivationKey.Length]; |
There was a problem hiding this comment.
@GrabYourPitchforks would it be unwise to use the shared ArrayPool here?
There was a problem hiding this comment.
Going to merge this as is, can make this switch in the follow up / spanification PR if needed
There was a problem hiding this comment.
Correct, because it's a cryptographic secret. Within the runtime, our crypto libraries use an internal CryptoPool type instead of the public singleton ArrayPool<T>.Shared instance.
During the spanification work, this can be switched to using stackalloc (the common case) or the pinned object heap. Then no pooling will be needed at all.
…tedEncryptor.cs Co-authored-by: Pranav K <prkrishn@hotmail.com>
|
I finished reviewing again through the commit a752598 and everything looks great. Thanks so much Hao! |
|
Hi @GrabYourPitchforks. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
Fixes #20689
Use new framework crypto apis now that they are available, this enable these apis on non windows for non net461/netcore2.