Skip to content

Commit

Permalink
Fingerprint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
bpellin committed Nov 20, 2017
1 parent 780a0cd commit b7aec35
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 8 deletions.
7 changes: 4 additions & 3 deletions app/src/main/java/com/keepassdroid/PasswordActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -268,10 +268,9 @@ private void errorMessage(int resId) {
}

// fingerprint related code here

private void initForFingerprint() {
fingerPrintHelper = new FingerPrintHelper(this, this);
if (fingerPrintHelper.isFingerprintInitialized()) {
if (fingerPrintHelper.hasEnrolledFingerprints()) {

// when text entered we can enable the logon/purchase button and if required update encryption/decryption mode
passwordView.addTextChangedListener(new TextWatcher() {
Expand Down Expand Up @@ -373,7 +372,9 @@ private int toggleMode(final int newMode) {
break;
case Cipher.DECRYPT_MODE:
final String ivSpecValue = prefsNoBackup.getString(getPreferenceKeyIvSpec(), null);
fingerPrintHelper.initDecryptData(ivSpecValue);
if (ivSpecValue != null) {
fingerPrintHelper.initDecryptData(ivSpecValue);
}
break;
}
return newMode;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public class KeyGenParameterSpecCompat {

static {
try {
builder = Class.forName("android.security.keystore.KeyGenParameterSpec.Builder");
builder = Class.forName("android.security.keystore.KeyGenParameterSpec$Builder");
buildConst = builder.getConstructor(String.class, int.class);
builderBuild = builder.getMethod("build", (Class [])null);
setBlockModes = builder.getMethod("setBlockModes", String[].class);
Expand All @@ -59,9 +59,9 @@ public static AlgorithmParameterSpec build(String keystoreAlias, int purpose, St

try {
Object inst = buildConst.newInstance(keystoreAlias, purpose);
inst = setBlockModes.invoke(inst, new Object[] {blockMode});
inst = setBlockModes.invoke(inst, new Object[] {new String[] {blockMode}});
inst = setUserAuthReq.invoke(inst, userAuthReq);
inst = setEncPad.invoke(inst, new Object[] {encPadding});
inst = setEncPad.invoke(inst, new Object[] {new String[] {encPadding}});

return (AlgorithmParameterSpec) builderBuild.invoke(inst, null);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public boolean isFingerprintInitialized() {
public void initEncryptData() {

if (!isFingerprintInitialized()) {
if (fingerPrintCallback != null) {
if (fingerPrintCallback != null && hasEnrolledFingerprints()) {
fingerPrintCallback.onException();
}
return;
Expand All @@ -166,7 +166,7 @@ public void initEncryptData() {
public void encryptData(final String value) {

if (!isFingerprintInitialized()) {
if (fingerPrintCallback != null) {
if (fingerPrintCallback != null && hasEnrolledFingerprints()) {
fingerPrintCallback.onException();
}
return;
Expand Down Expand Up @@ -194,6 +194,8 @@ public void initDecryptData(final String ivSpecValue) {
fingerPrintCallback.onException(false);
}
return;
} else if (!hasEnrolledFingerprints()) {
return;
}
try {
createNewKeyIfNeeded(false);
Expand Down

0 comments on commit b7aec35

Please sign in to comment.