-
-
Notifications
You must be signed in to change notification settings - Fork 53
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: support system keystore #127
Comments
One thing to note is that the https://android-developers.googleblog.com/2017/07/seccomp-filter-in-android-o.html |
It might work since it seems the init process uses |
I think I like the simplicity of just using the native app filesystem, which seems sufficiently protected in the same way that the typical gnome keyring is (by the user's login). But I don't really have time to work on this now, as it would require me to understand Android app development (which I've never tried). So if someone wants to take a shot at this, please do! |
Have any of you tried this crate https://github.com/dodorare/android-tools-rs , I think in combination with |
https://github.com/dodorare/android-tools-rs/tree/main runs |
This can be done if we add a java module named keystore and it would have to be bridged manually in android studio as a new module, in rust we'd use |
Hello, I'm wondering if there's any open source solution for using the Android keyring yet? I'm building an app which needs to store an encryption key in the system's native keyring, but it also needs to work on all of MacOS/Windows/Linux/iOS/Android. |
@Rigidity Here you go this is the library I have developed and been using. Be cautious re using this in production cause have not tested this and its security implications rigorously enough. You can then use jni bindings from your rust project to call the functions in Java, hit me up if you need any help and if you see anything that can be improved of which there is a lot feel free to contribute. |
@Rigidity have any idea if this library support biometrics for iOS ? |
@Zack-Xb Are you asking whether the keychain rust crate supports biometrics for iOS? If so, the answer is yes - it uses the iOS native keychain and so supports biometrics. |
I would also like to see support for Android, another perhaps simpler option we could try is the https://developer.android.com/reference/androidx/security/crypto/EncryptedSharedPreferences It's available from Android 6.0 (Marshmallow) - minSdkVersion 23. What do you think? |
At a glance, the |
Thanks for taking a look @brotskydotcom , I am not an Android developer either but do have some experience with the platform as I am developing an app that works across all 5 major platforms. That's a good observation about the binary data, maybe we could use data: URLs for the encoding? We can use the MIME type to distinguish between string and binary types and base64 encode the binary data. I would be willing to do the work (JNI bindings) to see this happen as it is important for my app to have a cohesive interface to the platform keyring. Would you be interested in a PR for this? |
This would be great for Tauri apps :) |
Very! I suggest you start with either the mock keystore or the macOS keystore and see if you can cut in the Android storage APIs instead of the mechanisms they are using. |
Overview
Currently
keyring-rs
supports iOS but not Android. If we can extend support to Android, thenkeyring-rs
handles all major platforms, desktop and mobile, which would be pretty cool : )Issues
Sadly Android doesn't appear to expose any access to the platform keystore via the ndk ffi bindings. Any solution would have to go through the Java interface. I'm not super familiar with how this works, but the approach taken in
app_dirs2
would probably work: https://github.com/app-dirs-rs/app_dirs2/blob/main/src/imp/platform/android.rs.Options
(1) Platform KeyStore/TEE/enclave
Safest, but annoying implementation.
After a cursory scan of the Android docs, it seems the main interface to the platform TEE is something called
KeyStore
. You can configure an instance that stores key material in the platform enclave. Secrets in the enclave are not exportable, so you need an extra layer of indirection to get a keyring entry in memory.My guess is that they expect most users to use the
EncryptedFile
API, which stores a single "master key" in the platformKeyStore
and then stores master-key-encrypted per-file (?) keys in the app'sSharedPreferences
. These sub-keys are then used to actually encrypt/decrypt a file on-disk.The
EncryptedFile
API docs look like they have some sharp edges though:Challenges
androidx
.(2) Just stick files in the application data directory
A simpler approach is to just dump
keyring-rs
entries into the application's data directory. I believe each application's data directory files are sandboxed and inaccessible to any other applications (unless the device is rooted of course).The internal storage filesystem (where apps store their data) is also encrypted and only accessible after the user unlocks the device.
Challenges
This approach is definitely easier--we can probably reuse the approach in
app_dirs2
verbatim.The text was updated successfully, but these errors were encountered: