Skip to content

Commit b1eefa2

Browse files
author
Matthew Wheatley
committed
version 1.3.0
* Fixed issue #85 No token returned when using PIN backup
1 parent b9cfb37 commit b1eefa2

File tree

5 files changed

+31
-25
lines changed

5 files changed

+31
-25
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Update to Version 1.2.0
1+
# Update to Version 1.3.0
22
Please consult the [changelog](https://github.com/mjwheatley/cordova-plugin-android-fingerprint-auth/blob/master/changelog.md).
33

44
# About

changelog.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
# Version 1.3.0
2+
### What's New
3+
* Fixed issue #85 No token returned when using PIN backup
4+
* Authentication with backup credentials will now use cryptography to encrypt or decrypt a token.
5+
16
# Version 1.2.8
27
### What's New
38
* Updates to README

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cordova-plugin-android-fingerprint-auth",
3-
"version": "1.2.8",
3+
"version": "1.3.0",
44
"description": "Cordova plugin to use Android fingerprint authentication API",
55
"cordova": {
66
"id": "cordova-plugin-android-fingerprint-auth",

plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
33
xmlns:android="http://schemas.android.com/apk/res/android"
44
id="cordova-plugin-android-fingerprint-auth"
5-
version="1.2.8">
5+
version="1.3.0">
66
<name>FingerprintAuth</name>
77
<description>Cordova plugin to use Android fingerprint authentication API</description>
88
<license>Apache 2.0</license>

src/android/FingerprintAuth.java

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -574,38 +574,39 @@ public static void onAuthenticated(boolean withFingerprint,
574574
boolean createdResultJson = false;
575575

576576
try {
577+
byte[] bytes;
578+
FingerprintManager.CryptoObject cryptoObject;
579+
577580
if (withFingerprint) {
578-
// If the user has authenticated with fingerprint, verify that using cryptography and
579-
// then return the encrypted (in Base 64) or decrypted mClientSecret
580-
byte[] bytes;
581-
if (mCipherModeCrypt) {
582-
bytes = result.getCryptoObject().getCipher()
583-
.doFinal(mClientSecret.getBytes("UTF-8"));
584-
String encodedBytes = Base64.encodeToString(bytes, Base64.NO_WRAP);
585-
resultJson.put("token", encodedBytes);
586-
} else {
587-
bytes = result.getCryptoObject().getCipher()
588-
.doFinal(Base64.decode(mClientSecret, Base64.NO_WRAP));
589-
String credentialString = new String(bytes, "UTF-8");
590-
String[] credentialArray = credentialString.split(":");
591-
if (credentialArray.length == 2) {
592-
String username = credentialArray[0];
593-
String password = credentialArray[1];
594-
if (username.equalsIgnoreCase(mClientId + mUsername)) {
595-
resultJson.put("password", credentialArray[1]);
596-
}
597-
}
598-
}
599581
resultJson.put("withFingerprint", true);
582+
cryptoObject = result.getCryptoObject();
600583
} else {
601-
// Authentication happened with backup password.
602584
resultJson.put("withBackup", true);
585+
cryptoObject= new FingerprintManager.CryptoObject(mCipher);
603586

604587
// If failed to init cipher because of InvalidKeyException, create new key
605588
if (!initCipher()) {
606589
createKey();
607590
}
608591
}
592+
593+
if (mCipherModeCrypt) {
594+
bytes = cryptoObject.getCipher().doFinal(mClientSecret.getBytes("UTF-8"));
595+
String encodedBytes = Base64.encodeToString(bytes, Base64.NO_WRAP);
596+
resultJson.put("token", encodedBytes);
597+
} else {
598+
bytes = cryptoObject.getCipher()
599+
.doFinal(Base64.decode(mClientSecret, Base64.NO_WRAP));
600+
String credentialString = new String(bytes, "UTF-8");
601+
String[] credentialArray = credentialString.split(":");
602+
if (credentialArray.length == 2) {
603+
String username = credentialArray[0];
604+
String password = credentialArray[1];
605+
if (username.equalsIgnoreCase(mClientId + mUsername)) {
606+
resultJson.put("password", credentialArray[1]);
607+
}
608+
}
609+
}
609610
createdResultJson = true;
610611
} catch (BadPaddingException e) {
611612
Log.e(TAG, "Failed to encrypt the data with the generated key:"

0 commit comments

Comments
 (0)