element-hq / element-hq/element-android
Biometric auth gets incorrectly disabled on Samsung devices
- Dominant language
- Kotlin
- Stars
- 3.7k
- Forks
- 917
- PR merge metrics
- No merged PRs in 30d
Description
### Steps to reproduce
1. Open the app when pin code and biometric authentication are enabled.
### Outcome
#### What did you expect?
Biometric authentication should work out of the box.
#### What happened instead?
We get an incorrect "biometric authentication has been disabled because a new biometric method has been added" error message, biometric authentication gets disabled. According to the logs, the issue seems to be:
```
android.security.keystore.UserNotAuthenticatedException: User not authenticated
at android.security.keystore2.KeyStoreCryptoOperationUtils.getInvalidKeyException(KeyStoreCryptoOperationUtils.java:128)
at android.security.keystore2.KeyStoreCryptoOperationUtils.getExceptionForCipherInit(KeyStoreCryptoOperationUtils.java:154)
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.ensureKeystoreOperationInitialized(AndroidKeyStoreCipherSpiBase.java:345)
at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineInit(AndroidKeyStoreCipherSpiBase.java:177)
at javax.crypto.Cipher.tryTransformWithProvider(Cipher.java:2985)
at javax.crypto.Cipher.tryCombinations(Cipher.java:2892)
at javax.crypto.Cipher$SpiAndProviderUpdater.updateAndGetSpiAndProvider(Cipher.java:2797)
at javax.crypto.Cipher.chooseProvider(Cipher.java:774)
at javax.crypto.Cipher.init(Cipher.java:1144)
at javax.crypto.Cipher.init(Cipher.java:1085)
at org.matrix.android.sdk.api.securestorage.SecretStoringUtils.getEncryptCipher(SecretStoringUtils.kt:6)
at im.vector.app.features.pin.lockscreen.crypto.KeyStoreCrypto.ensureKey(KeyStoreCrypto.kt:2)
at im.vector.app.features.pin.lockscreen.crypto.KeyStoreCrypto.hasValidKey(KeyStoreCrypto.kt:3)
at im.vector.app.features.pin.lockscreen.crypto.LockScreenKeyRepository.isSystemKeyValid(LockScreenKeyRepository.kt:1)
at im.vector.app.features.pin.lockscreen.biometrics.BiometricHelper.isSystemKeyValid(BiometricHelper.kt:1)
at im.vector.app.features.pin.lockscreen.ui.LockScreenViewModel$updateStateWithBiometricInfo$2.invoke(LockScreenViewModel.kt:2)
at im.vector.app.features.pin.lockscreen.ui.LockScreenViewModel$updateStateWithBiometricInfo$2.invoke(LockScreenViewModel.kt:1)
```
It might be related to trying to authenticate the user from 2 different components, or maybe checking the CryptoObject validity from one and authenticating from another.
There are also some reports of this happening on a Pixel 4 device.
### Your phone model
Samsung SM-A716V
### Operating system version
12
### Application version and app store
1.4.36 [40104362] (G-6cada8f6-2022-09-10 08:13:58 +0200)
### Homeserver
_No response_
### Will you send logs?
Yes
### Are you willing to provide a PR?
Yes
Contributor guide
Assessment
This issue has not been assessed yet.