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

Android: prefer CharArray over String #14

Merged
merged 2 commits into from
Feb 29, 2024
Merged

Conversation

lambdapioneer
Copy link
Owner

@lambdapioneer lambdapioneer commented Feb 23, 2024

Summary

It is general best practise to minimize the exposure of secrets in memory. As such, Strings are not great, as they are immutable and we have to hope for the GC to collect them eventually. On the other hand, CharArrays allow us (even if not guaranteed by the spec) to overwrite their content after usage.

This PR changes the API to allow for passing in the user password as a CharArray instead of Strings. If your code currently uses String, you can simply call toCharArray which will result in identical behaviour.

Whether this makes a difference in practise, e.g. against a root-level adversary that can already read memory, is a valid discussion to have. However, there exist at least some people who believe that this is a worthwhile defence-in-depth.

Testplan

Run all tests on a physical device (Pixel 6a) and added a test that ensures we maintain backwards-compatibility.

@lambdapioneer lambdapioneer self-assigned this Feb 23, 2024
@lambdapioneer lambdapioneer added the enhancement New feature or request label Feb 23, 2024
@lambdapioneer lambdapioneer changed the title [WIP] Android: prefer CharArray over String Android: prefer CharArray over String Feb 29, 2024
@lambdapioneer lambdapioneer merged commit 958c09a into main Feb 29, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant