authpass / biometric_storage

Flutter plugin to store data behind biometric authentication (ie. fingerprint)
https://pub.dev/packages/biometric_storage
MIT License
184 stars 107 forks source link

Issue with saving to biometric storage on android #123

Closed rorokimdim closed 2 months ago

rorokimdim commented 2 months ago

Seeing this issue on Samsung Galaxy s24 Ultra.

Android version 14 (6.1.25-android14-11-28243294-abS928USQS3AXFJ)

Perhaps related to strongbox.

PlatformException(Unexpected Error, Failed to generate key, android.security.keystore.StrongBoxUnavailableException: Failed to generate key
android.security.keystore.StrongBoxUnavailableException: Failed to generate key
    at android.security.keystore2.AndroidKeyStoreKeyGeneratorSpi.engineGenerateKey(AndroidKeyStoreKeyGeneratorSpi.java:411)
    at javax.crypto.KeyGenerator.generateKey(KeyGenerator.java:612)
    at design.codeux.biometric_storage.CryptographyManagerImpl.getOrCreateSecretKey(CryptographyManager.kt:180)
    at design.codeux.biometric_storage.CryptographyManagerImpl.getInitializedCipherForEncryption(CryptographyManager.kt:93)
    at design.codeux.biometric_storage.BiometricStorageFile.cipherForEncrypt(BiometricStorageFile.kt:82)
    at design.codeux.biometric_storage.BiometricStoragePlugin.onMethodCall$withAuth$cipherForMode(BiometricStoragePlugin.kt:176)
    at design.codeux.biometric_storage.BiometricStoragePlugin.onMethodCall$withAuth(BiometricStoragePlugin.kt:183)
    at design.codeux.biometric_storage.BiometricStoragePlugin.access$onMethodCall$withAuth(BiometricStoragePlugin.kt:93)
    at design.codeux.biometric_storage.BiometricStoragePlugin$onMethodCall$5.invoke(BiometricStoragePlugin.kt:265)
    at design.codeux.biometric_storage.BiometricStoragePlugin$onMethodCall$5.invoke(BiometricStoragePlugin.kt:264)
    at design.codeux.biometric_storage.BiometricStoragePlugin.onMethodCall$withStorage(BiometricStoragePlugin.kt:149)
    at design.codeux.biometric_storage.BiometricStoragePlugin.onMethodCall(BiometricStoragePlugin.kt:264)
    at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:267)
    at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
    at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
    at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
    at android.os.Handler.handleCallback(Handler.java:958)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:230)
    at android.os.Looper.loop(Looper.java:319)
    at android.app.ActivityThread.main(ActivityThread.java:8918)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
Caused by: android.security.KeyStoreException: No StrongBox available (public error code: 12 internal Keystore code: -68)
    ... 24 more
, null)
rorokimdim commented 2 months ago

my apologies. Looks like the fix is to restart my phone. got the hint from here https://github.com/Kunzisoft/KeePassDX/issues/1824