element-hq / element-android

A Matrix collaboration client for Android.
https://element.io/
GNU Affero General Public License v3.0
3.39k stars 735 forks source link

crashes on every start on changed ROM #2588

Open 2011 opened 3 years ago

2011 commented 3 years ago

Describe the bug

Worked fine for several months. Changed ROM on my phone and restored Element from backup (Titanium Backup). Element now crashes on every attempted start.

msg: android.security.KeyStoreException: Signature/MAC verification failed stacktrace: java.lang.RuntimeException: Unable to create application im.vector.app.VectorApplication: javax.crypto.AEADBadTagException at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6465) at android.app.ActivityThread.access$1300(ActivityThread.java:219) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1859) at android.os.Handler.dispatchMessage(Handler.java:107) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7356) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:940) Caused by: javax.crypto.AEADBadTagException at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:517) at javax.crypto.Cipher.doFinal(Cipher.java:2055) at org.matrix.android.sdk.internal.database.RealmKeysUtils.getRealmEncryptionKey(RealmKeysUtils.kt:20) at org.matrix.android.sdk.internal.database.RealmKeysUtils.configureEncryption(RealmKeysUtils.kt:1) at org.matrix.android.sdk.internal.auth.AuthModule_ProvidesRealmConfigurationFactory.providesRealmConfiguration(AuthModule_ProvidesRealmConfigurationFactory.java:7) at org.matrix.android.sdk.internal.di.DaggerMatrixComponent.realmSessionParamsStore(DaggerMatrixComponent.java:7) at org.matrix.android.sdk.api.Matrix.<init>(Matrix.kt:12) at org.matrix.android.sdk.api.Matrix.getInstance(Matrix.kt:6) at im.vector.app.core.di.DaggerVectorComponent.matrix(DaggerVectorComponent.java:3) at im.vector.app.VectorApplication.onCreate(VectorApplication.kt:6) at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1190) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6460) ... 8 more Caused by: android.security.KeyStoreException: Signature/MAC verification failed at android.security.KeyStore.getKeyStoreException(KeyStore.java:1303) at android.security.keystore.KeyStoreCryptoOperationChunkedStreamer.doFinal(KeyStoreCryptoOperationChunkedStreamer.java:224) at android.security.keystore.AndroidKeyStoreAuthenticatedAESCipherSpi$BufferAllOutputUntilDoFinalStreamer.doFinal(AndroidKeyStoreAuthenticatedAESCipherSpi.java:373) at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal(AndroidKeyStoreCipherSpiBase.java:506) ... 19 more

Smartphone (please complete the following information):

Additional context

bmarty commented 3 years ago

I'm not surprised that backing up Element does not work, as it stores private key in the keystore, which I guess will be removed when changing ROM. Clearing storage of the app and log in again should fix the pb.

opusforlife2 commented 3 years ago

@bmarty Then please provide an option to back up app settings (nothing related to the user's account) so that we don't have to keep changing them back again on changing/upgrading ROMs. There is currently no way to save app settings without also saving the account/session information. I could open a new issue for this if you are amenable.

Also, the app should allow changing settings without having to sign in first (those settings could be greyed out).

Ideally, an Element Android backup file should be usable with Element Desktop as well, so that you can migrate settings from one platform to the other.

WGH- commented 3 years ago

It's annoying that backups simply don't work with some apps, and you can't even tell before you try to restore one :(

Maybe give the user an option to not use the keystore? I personally trust full disk encryption, and if someone has a root access on my phone, it's already game over. And when I do a backup, I know what I'm doing.