johanw666 / Signal-Android

Fork from a private messenger for Android with extra options added: full backup and (partial, ony text) xml backup of messages. Restore can happen at any time, not only after a fresh install. Import SMS database. Import of (unencrypted) WhatsApp databases. Removed apk expire. Choose between passphrase protection and the Android screenlock. Choice for the backup location (internal or removable storage on Android < 11 (on 11 and higher this is already possible)). Set the maptype in the place picker. Option to treat view-once media as normal media. Option to ignore remote deletion. Choose between FCM or websocket notification delivery.
https://johanw.home.xs4all.nl/Signal/signal-jw.html
GNU Affero General Public License v3.0
246 stars 16 forks source link

Startup crash on 7.0.0 #94

Closed Terrance closed 4 months ago

Terrance commented 4 months ago

Bug description

The app is now crashing on launch:

FATAL EXCEPTION: main
Process: org.thoughtcrime.securesms, PID: 11242
java.lang.AssertionError: javax.crypto.IllegalBlockSizeException
    at org.thoughtcrime.securesms.crypto.KeyStoreHelper.unseal(KeyStoreHelper.java:76)
    at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getEncryptedDatabaseSecret(DatabaseSecretProvider.java:71)
    at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getOrCreate(DatabaseSecretProvider.java:42)
    at org.thoughtcrime.securesms.crypto.DatabaseSecretProvider.getOrCreateDatabaseSecret(DatabaseSecretProvider.java:26)
    at org.thoughtcrime.securesms.ApplicationContext.lambda$onCreate$0(ApplicationContext.java:151)
    at org.thoughtcrime.securesms.ApplicationContext.$r8$lambda$VPmvaBBdqqvvVsnAcF1XPhfNAwg(ApplicationContext.java:0)
    at org.thoughtcrime.securesms.ApplicationContext$$ExternalSyntheticLambda1.run(R8$$SyntheticClass:0)
    at org.thoughtcrime.securesms.util.AppStartup.execute(AppStartup.java:145)
    at org.thoughtcrime.securesms.ApplicationContext.onCreate(ApplicationContext.java:219)
    at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1285)
    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:7231)
    at android.app.ActivityThread.-$$Nest$mhandleBindApplication(Unknown Source:0)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2288)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loopOnce(Looper.java:240)
    at android.os.Looper.loop(Looper.java:351)
    at android.app.ActivityThread.main(ActivityThread.java:8381)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:584)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1013)
Caused by: javax.crypto.IllegalBlockSizeException
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:613)
    at javax.crypto.Cipher.doFinal(Cipher.java:2056)
    at org.thoughtcrime.securesms.crypto.KeyStoreHelper.unseal(KeyStoreHelper.java:74)
    ... 19 more
Caused by: android.security.KeyStoreException: Memory allocation failed (internal Keystore code: -41 message: In KeystoreOperation::update
Caused by:
    0: In update: KeyMint::update failed.
    1: Error::Km(ErrorCode(-41))) (public error code: 10 internal Keystore code: -41)
    at android.security.KeyStore2.getKeyStoreException(KeyStore2.java:369)
    at android.security.KeyStoreOperation.handleExceptions(KeyStoreOperation.java:78)
    at android.security.KeyStoreOperation.update(KeyStoreOperation.java:115)
    at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer$MainDataStream.update(KeyStoreCryptoOperationChunkedStreamer.java:222)
    at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer.update(KeyStoreCryptoOperationChunkedStreamer.java:156)
    at android.security.keystore2.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:179)
    at android.security.keystore2.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:396)
    at android.security.keystore2.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:603)
    ... 21 more

Device info

Device: OnePlus Nord CE Android version: 13 Signal version: 7.0.0.0-JW

Terrance commented 4 months ago

Looks like this was a device issue (resolved by rebooting) and related to biometric unlock -- caught another app throwing the same error in the same place, and it seemed to be specific to preventing fallback to PIN for the unlock. I assume the stock Signal app handles this in the same way, so if it happens again I'll report upstream in case there's a way to permit PIN fallback (though I imagine the Android UI is a side-effect of the type of security feature being used, rather than a deliberate choice).