Skip to content
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

Refactor Rfc2898DeriveBytes to support spans #71888

Merged
merged 2 commits into from Jul 12, 2022

Conversation

vcsjones
Copy link
Member

@vcsjones vcsjones commented Jul 9, 2022

Since the managed Rfc2898DeriveBytes is used to implement the one-shots on some platforms, this changes the internals of it to better support spans.

I took this approach as an alternative to a pure one-shot managed PBKDF2 implementation to use as much existing, battle tested code as possible to increase the chances that it will be taken in time for .NET 7.


I investigated using the native PBKDF2 capabilities for Android and determined that unfortunately Android's APIs are not suitable for our needs for two reasons. First, it requires API Level 26 for SHA2 PBKDF2, which means we would still need the managed fallback since we support older Android versions. Second, it operates entirely on Char[] passwords, not Byte[]. We can't feed arbitrary bytes in to Java character arrays.

@ghost
Copy link

ghost commented Jul 9, 2022

Tagging subscribers to this area: @dotnet/area-system-security, @vcsjones
See info in area-owners.md if you want to be subscribed.

Issue Details

Since the managed Rfc2898DeriveBytes is used to implement the one-shots on some platforms, this changes the internals of it to better support spans.

I took this approach as an alternative to a pure one-shot managed PBKDF2 implementation to use as much existing, battle tested code as possible to increase the chances that it will be taken in time for .NET 7.


I investigated using the native PBKDF2 capabilities for Android and determined that unfortunately Android's APIs are not suitable for our needs for two reasons. First, it requires API Level 26 for SHA2 PBKDF2, which means we would still need the managed fallback since we support older Android versions. Second, it operates entirely on Char[] passwords, not Byte[]. We can't feed arbitrary bytes in to Java character arrays.

Author: vcsjones
Assignees: -
Labels:

area-System.Security

Milestone: -

@vcsjones
Copy link
Member Author

WASM failures are #71986. Merging.

@vcsjones vcsjones merged commit c7613b6 into dotnet:main Jul 12, 2022
@vcsjones vcsjones deleted the pbkdf2-managed-less-alloc branch July 12, 2022 02:11
@dotnet dotnet locked as resolved and limited conversation to collaborators Aug 11, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants