use CrAzYpass for send verification as well (#249)

merge-requests/3/head
m2049r 6 years ago committed by GitHub
parent 2ca7b41982
commit 7879f31f63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -550,41 +550,12 @@ public class LoginActivity extends SecureActivity
openDialog.show();
}
// try to figure out what the real wallet password is given the user password
// which could be the actual wallet password or a (maybe malformed) CrAzYpass
// or the password used to derive the CrAzYpass for the wallet
private String getWalletPassword(String walletName, String password) {
String walletPath = new File(Helper.getWalletRoot(getApplicationContext()),
walletName + ".keys").getAbsolutePath();
// try with entered password (which could be a legacy password or a CrAzYpass)
if (WalletManager.getInstance().verifyWalletPassword(walletPath, password, true)) {
return password;
}
// maybe this is a malformed CrAzYpass?
String possibleCrazyPass = CrazyPassEncoder.reformat(password);
if (possibleCrazyPass != null) { // looks like a CrAzYpass
if (WalletManager.getInstance().verifyWalletPassword(walletPath, possibleCrazyPass, true)) {
return possibleCrazyPass;
}
}
// generate & try with CrAzYpass
String crazyPass = KeyStoreHelper.getCrazyPass(this, password);
if (WalletManager.getInstance().verifyWalletPassword(walletPath, crazyPass, true)) {
return crazyPass;
}
return null;
}
interface PasswordAction {
void action(String walletName, String password);
}
private boolean processPasswordEntry(String walletName, String pass, PasswordAction action) {
String walletPassword = getWalletPassword(walletName, pass);
String walletPassword = Helper.getWalletPassword(getApplicationContext(), walletName, pass);
if (walletPassword != null) {
action.action(walletName, walletPassword);
return true;

@ -828,9 +828,8 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
@Override
public boolean verifyWalletPassword(String password) {
String walletPath = new File(Helper.getWalletRoot(this),
getWalletName() + ".keys").getAbsolutePath();
return WalletManager.getInstance().verifyWalletPassword(walletPath, password, true);
String walletPassword = Helper.getWalletPassword(getApplicationContext(), getWalletName(), password);
return walletPassword != null;
}
@Override

@ -312,4 +312,32 @@ public class Helper {
if (level >= WalletManager.LOGLEVEL_SILENT)
WalletManager.setLogLevel(level);
}
// try to figure out what the real wallet password is given the user password
// which could be the actual wallet password or a (maybe malformed) CrAzYpass
// or the password used to derive the CrAzYpass for the wallet
static public String getWalletPassword(Context context, String walletName, String password) {
String walletPath = new File(getWalletRoot(context), walletName + ".keys").getAbsolutePath();
// try with entered password (which could be a legacy password or a CrAzYpass)
if (WalletManager.getInstance().verifyWalletPassword(walletPath, password, true)) {
return password;
}
// maybe this is a malformed CrAzYpass?
String possibleCrazyPass = CrazyPassEncoder.reformat(password);
if (possibleCrazyPass != null) { // looks like a CrAzYpass
if (WalletManager.getInstance().verifyWalletPassword(walletPath, possibleCrazyPass, true)) {
return possibleCrazyPass;
}
}
// generate & try with CrAzYpass
String crazyPass = KeyStoreHelper.getCrazyPass(context, password);
if (WalletManager.getInstance().verifyWalletPassword(walletPath, crazyPass, true)) {
return crazyPass;
}
return null;
}
}

Loading…
Cancel
Save