-
Notifications
You must be signed in to change notification settings - Fork 4.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PBKDF2 one-shot #48107
PBKDF2 one-shot #48107
Conversation
Note regarding the This serves as a reminder for when your PR is modifying a ref *.cs file and adding/modifying public APIs, to please make sure the API implementation in the src *.cs file is documented with triple slash comments, so the PR reviewers can sign off that change. |
Tagging subscribers to this area: @bartonjs, @vcsjones, @krwq, @GrabYourPitchforks Issue DetailsThis is a draft for PBKDF2 one-shots (an API that is yet-to-be-approved). Opening as a draft to get some feedback from the CI system. Work left to be done:
Implementation notes:
|
Unrelated but exciting: All of the macOS work was done on a M1 Mac Mini without Rosetta (running as ARM64). Very cool to see dotnet/runtime in good shape for Apple Silicon. |
...aries/System.Security.Cryptography.Algorithms/ref/System.Security.Cryptography.Algorithms.cs
Show resolved
Hide resolved
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Outdated
Show resolved
Hide resolved
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Outdated
Show resolved
Hide resolved
src/libraries/Native/Unix/System.Security.Cryptography.Native/pal_evp.h
Outdated
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Algorithms/tests/Rfc2898OneShotTests.cs
Outdated
Show resolved
Hide resolved
Hm. Trying to use the pseudo handles in Windows 7 actually crashes the process with an access violation, so we can't even get an NTSTATUS back saying it failed. Do we just do an OS version check? |
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Outdated
Show resolved
Hide resolved
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Outdated
Show resolved
Hide resolved
src/libraries/Native/Unix/System.Security.Cryptography.Native/entrypoints.c
Outdated
Show resolved
Hide resolved
Reorder to keep alphabetic consistency. Add comment documentation. Tighten validation between password and salt inputs and their length. NULL input requires a zero length.
While here, use a stack allocation for small password inputs, which seems likely.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bartonjs @GrabYourPitchforks I think this is at a point where it can be looked at in more scrutiny and might nearly resemble something complete, barring some self-review questions.
...m.Security.Cryptography.Algorithms/src/Internal/Cryptography/Pbkdf2Implementation.Windows.cs
Show resolved
Hide resolved
...m.Security.Cryptography.Algorithms/src/Internal/Cryptography/Pbkdf2Implementation.Windows.cs
Show resolved
Hide resolved
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Show resolved
Hide resolved
Apology in advance for changing the PR title and breaking email inbox threading. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed the Windows implementation and skimmed the non-Windows implementations. Generally LGTM. Some open questions about whether avoiding the allocation is worth it in the Windows case.
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptAlgPseudoHandle.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptDeriveKeyPBKDF2.cs
Outdated
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.BCryptGenerateSymmetricKey.cs
Show resolved
Hide resolved
...stem.Security.Cryptography.Algorithms/src/Internal/Cryptography/Pbkdf2Implementation.Unix.cs
Show resolved
Hide resolved
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Outdated
Show resolved
Hide resolved
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Algorithms/tests/Rfc2898OneShotTests.cs
Show resolved
Hide resolved
src/libraries/System.Security.Cryptography.Algorithms/tests/Rfc2898OneShotTests.cs
Show resolved
Hide resolved
src/libraries/Common/src/Interop/Windows/BCrypt/Interop.Blobs.cs
Outdated
Show resolved
Hide resolved
...m.Security.Cryptography.Algorithms/src/Internal/Cryptography/Pbkdf2Implementation.Windows.cs
Show resolved
Hide resolved
...m.Security.Cryptography.Algorithms/src/Internal/Cryptography/Pbkdf2Implementation.Windows.cs
Show resolved
Hide resolved
...m.Security.Cryptography.Algorithms/src/Internal/Cryptography/Pbkdf2Implementation.Windows.cs
Show resolved
Hide resolved
...urity.Cryptography.Algorithms/src/System/Security/Cryptography/Rfc2898DeriveBytes.OneShot.cs
Outdated
Show resolved
Hide resolved
Checks that inputs are valid before doing any allocations.
Work left to be done:
BCryptKeyDerivation
for Windows 8+.Implementation notes:
PKCS5_PBKDF2_HMAC
. This was a PEBCAK error while reading documentation. So no shimming required.Closes #24897