-
Notifications
You must be signed in to change notification settings - Fork 16
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
Introducing a new KeyStoreManager to handle BRKeyStore related #291
Conversation
@@ -45,6 +34,8 @@ public class BreadApp extends Application { | |||
public static long backgroundedTime; | |||
private static Activity currentActivity; | |||
|
|||
public static KeyStoreManager keyStoreManager; |
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.
for now we just use this, maybe in the future we can use dependency injection like koin
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.
Lets. Feel free to add a spike issue in litewallet-engineering
for us to study Koin
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.
sure, will add Koin later
|
||
try { | ||
lock.lock(); | ||
return BreadApp.keyStoreManager.getDataBlocking(new AliasObject(alias, alias_file, alias_iv)); |
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.
calling new method from KeyStoreManager
return BreadApp.keyStoreManager.getDataBlocking(new AliasObject(alias, alias_file, alias_iv)); | ||
} catch (UserNotAuthenticatedException e) { | ||
Timber.e(e, "timber:_getData: showAuthenticationScreen: %s", alias); | ||
showAuthenticationScreen(context, request_code, alias); |
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.
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.
I have questions @kcw-grunt, our Android app will still need user's pin lock screen?
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.
still thinking about this how to migrate without the device lock, since the key (for phrase and canary) that created before need to do device unlock first. related with link above
ref:
litewallet-android/app/src/main/java/com/breadwallet/tools/security/BRKeyStore.java
Line 220 in 7b5a20d
.setUserAuthenticationRequired(auth_required) litewallet-android/app/src/main/java/com/breadwallet/tools/security/BRKeyStore.java
Line 156 in 7b5a20d
secretKey = createKeys(alias, auth_required); litewallet-android/app/src/main/java/com/breadwallet/tools/security/BRKeyStore.java
Line 384 in 7b5a20d
return !(strToStore == null || strToStore.length == 0) && _setData(context, strToStore, obj.alias, obj.datafileName, obj.ivFileName, requestCode, true); litewallet-android/app/src/main/java/com/breadwallet/tools/security/BRKeyStore.java
Line 409 in 7b5a20d
return strBytes.length != 0 && _setData(context, strBytes, obj.alias, obj.datafileName, obj.ivFileName, requestCode, true);
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.
LGTM just need rebase / resolve conflicts.
Also, @andhikayuana please confirm this is no-op at this time
@@ -45,6 +34,8 @@ public class BreadApp extends Application { | |||
public static long backgroundedTime; | |||
private static Activity currentActivity; | |||
|
|||
public static KeyStoreManager keyStoreManager; |
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.
Lets. Feel free to add a spike issue in litewallet-engineering
for us to study Koin
@@ -55,16 +46,23 @@ public void onCreate() { | |||
AnalyticsManager.init(this); | |||
AnalyticsManager.logCustomEvent(BRConstants._20191105_AL); | |||
|
|||
if(BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree()); | |||
if (BuildConfig.DEBUG) Timber.plant(new Timber.DebugTree()); |
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.
Was this the linter or Andhika manual @andhikayuana ?
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.
8bad496
to
6770f7c
Compare
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.
That's good you want to separate the classes so will be easy to maintain
return BreadApp.keyStoreManager.getDataBlocking(new AliasObject(alias, alias_file, alias_iv)); | ||
} catch (UserNotAuthenticatedException e) { | ||
Timber.e(e, "timber:_getData: showAuthenticationScreen: %s", alias); | ||
showAuthenticationScreen(context, request_code, alias); |
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.
I have questions @kcw-grunt, our Android app will still need user's pin lock screen?
…toreManager to handle keystore related
…_pin.xml" This reverts commit 04b02ac.
6770f7c
to
cf3952a
Compare
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.
Just holding until pairing
@josikie We ultimately want to completely remove the device PIN...then later let user choose from Biometric or app 6 digit PIN |
Ok, noted! @kcw-grunt Does it mean when user choose biometric they should already have biometric lock in their phone? I think we've tried to implement biometric in the past for our new Android UI. When we wanted to implement biometric on our new UI Android, Android phone need user to set their biometric in their phone first, then they can use it in our new UI Android |
@andhikayuana matched the logic of iOS 👍 |
* chore: remove forgot_seed_phrase_or_pin_text text at activity_pin.xml * fix: [#288] catch all exception and return null * chore: wip keystore related * chore: wip keystore related for CipherBox * chore: wip keystore related for CipherBox * feat: add new CipherBox, CipherStorage, KeyStoreKeyGenerator and KeyStoreManager to handle keystore related * feat: add keyStoreManager to BreadApp and change _getData method at BRKeyStore * Revert "chore: remove forgot_seed_phrase_or_pin_text text at activity_pin.xml" This reverts commit 04b02ac. * chore: resolve conflict and implement toggle for new KeyStoreManager
Overview
To get better understanding of the codebase, we are need to refactor the
BRKeyStore
into separate class, it can be easier for maintaining the codebase. Now, we are introducing a newKeyStoreManager
that aim to replace theBRKeyStore
. currently it only called fromBRKeyStore._getData
.Key Classes
com.loafwallet.util.cryptography.CipherBox
: this will be responsible to encrypt/decrypt the datacom.loafwallet.util.cryptography.CipherStorage
: which location the encrypted data can will be storedcom.loafwallet.util.cryptography.KeyStoreKeyGenerator
: to generate the secret keycom.loafwallet.util.cryptography.KeyStoreManager
: this will be used as a replacement forBRKeyStore
laterNext Plan