check for encoded pw (#280)

This commit is contained in:
m2049r 2018-05-10 15:26:44 +02:00 committed by GitHub
parent cb12d64e5f
commit f50629ff81
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 1 deletions

View File

@ -70,12 +70,12 @@ public class KeyStoreHelper {
try {
KeyStoreHelper.createKeys(context, RSA_ALIAS);
sig = KeyStoreHelper.signData(RSA_ALIAS, data);
return CrazyPassEncoder.encode(cnSlowHash(sig));
} catch (NoSuchProviderException | NoSuchAlgorithmException |
InvalidAlgorithmParameterException | KeyStoreException |
InvalidKeyException | SignatureException ex) {
throw new IllegalStateException(ex);
}
return CrazyPassEncoder.encode(cnSlowHash(sig));
}
public static boolean saveWalletUserPass(@NonNull Context context, String wallet, String password) {
@ -110,6 +110,7 @@ public class KeyStoreHelper {
String walletKeyAlias = SecurityConstants.WALLET_PASS_KEY_PREFIX + wallet;
String encoded = context.getSharedPreferences(SecurityConstants.WALLET_PASS_PREFS_NAME, Context.MODE_PRIVATE)
.getString(wallet, "");
if (encoded.isEmpty()) throw new BrokenPasswordStoreException();
byte[] data = Base64.decode(encoded, Base64.DEFAULT);
byte[] decrypted = KeyStoreHelper.decrypt(walletKeyAlias, data);
if (decrypted == null) throw new BrokenPasswordStoreException();