use CrAzYpass for send verification as well (#249)
This commit is contained in:
parent
2ca7b41982
commit
7879f31f63
|
@ -550,41 +550,12 @@ public class LoginActivity extends SecureActivity
|
||||||
openDialog.show();
|
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 {
|
interface PasswordAction {
|
||||||
void action(String walletName, String password);
|
void action(String walletName, String password);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean processPasswordEntry(String walletName, String pass, PasswordAction action) {
|
private boolean processPasswordEntry(String walletName, String pass, PasswordAction action) {
|
||||||
String walletPassword = getWalletPassword(walletName, pass);
|
String walletPassword = Helper.getWalletPassword(getApplicationContext(), walletName, pass);
|
||||||
if (walletPassword != null) {
|
if (walletPassword != null) {
|
||||||
action.action(walletName, walletPassword);
|
action.action(walletName, walletPassword);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -828,9 +828,8 @@ public class WalletActivity extends SecureActivity implements WalletFragment.Lis
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean verifyWalletPassword(String password) {
|
public boolean verifyWalletPassword(String password) {
|
||||||
String walletPath = new File(Helper.getWalletRoot(this),
|
String walletPassword = Helper.getWalletPassword(getApplicationContext(), getWalletName(), password);
|
||||||
getWalletName() + ".keys").getAbsolutePath();
|
return walletPassword != null;
|
||||||
return WalletManager.getInstance().verifyWalletPassword(walletPath, password, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -312,4 +312,32 @@ public class Helper {
|
||||||
if (level >= WalletManager.LOGLEVEL_SILENT)
|
if (level >= WalletManager.LOGLEVEL_SILENT)
|
||||||
WalletManager.setLogLevel(level);
|
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…
Reference in New Issue