From 792400240bdaa862bed2528df76dff08b3de1f7b Mon Sep 17 00:00:00 2001 From: 4f77616973 <0x4f@tuta.io> Date: Tue, 27 Dec 2022 17:38:59 +0530 Subject: [PATCH] attempted fix for #23 --- .../main/kotlin/cloud/keyspace/android/CryptoUtilities.kt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/src/main/kotlin/cloud/keyspace/android/CryptoUtilities.kt b/app/src/main/kotlin/cloud/keyspace/android/CryptoUtilities.kt index b8cfe2b..c3f2bef 100644 --- a/app/src/main/kotlin/cloud/keyspace/android/CryptoUtilities.kt +++ b/app/src/main/kotlin/cloud/keyspace/android/CryptoUtilities.kt @@ -18,6 +18,7 @@ import androidx.biometric.BiometricManager.Authenticators.DEVICE_CREDENTIAL import androidx.biometric.BiometricManager.BIOMETRIC_SUCCESS import androidx.biometric.BiometricPrompt import androidx.core.content.ContextCompat +import androidx.core.hardware.fingerprint.FingerprintManagerCompat import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKey import cash.z.ecc.android.bip39.Mnemonics @@ -529,7 +530,11 @@ class CryptoUtilities( } if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) { // Ask for authentication when loading keys, must be larger than 0 - setUserAuthenticationParameters(DEFAULT_AUTHENTICATION_DELAY, KeyProperties.AUTH_DEVICE_CREDENTIAL or KeyProperties.AUTH_BIOMETRIC_STRONG) + if (FingerprintManagerCompat.from(context).isHardwareDetected && FingerprintManagerCompat.from(context).hasEnrolledFingerprints()) { + setUserAuthenticationParameters(DEFAULT_AUTHENTICATION_DELAY, KeyProperties.AUTH_DEVICE_CREDENTIAL or KeyProperties.AUTH_BIOMETRIC_STRONG) + } else { + setUserAuthenticationParameters(DEFAULT_AUTHENTICATION_DELAY, KeyProperties.AUTH_DEVICE_CREDENTIAL) + } } else { setUserAuthenticationValidityDurationSeconds(DEFAULT_AUTHENTICATION_DELAY) }