element-hq / element-android

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

[ANR] RealmKeysUtils.configureEncryption #4348

Open ouchadam opened 3 years ago

ouchadam commented 3 years ago

Looks like SecretStoringUtils.rsaDecrypt should be executed off of the main thread

  at com.android.org.conscrypt.NativeCrypto.RSA_private_decrypt (Native method)
  at com.android.org.conscrypt.OpenSSLCipherRSA.engineDoFinal (OpenSSLCipherRSA.java:273)
  at com.android.org.conscrypt.OpenSSLCipherRSA.engineDoFinal (OpenSSLCipherRSA.java:297)
  at javax.crypto.Cipher.doFinal (Cipher.java:1314)
  at javax.crypto.CipherInputStream.fillBuffer (CipherInputStream.java:102)
  at javax.crypto.CipherInputStream.read (CipherInputStream.java:155)
  at org.matrix.android.sdk.internal.session.securestorage.SecretStoringUtils.rsaDecrypt (SecretStoringUtils.kt:4)
  at org.matrix.android.sdk.internal.session.securestorage.SecretStoringUtils.decryptString (SecretStoringUtils.kt:2)
  at org.matrix.android.sdk.internal.database.RealmKeysUtils.getRealmEncryptionKey (RealmKeysUtils.kt:10)
  at org.matrix.android.sdk.internal.database.RealmKeysUtils.configureEncryption (RealmKeysUtils.kt:1)
  at org.matrix.android.sdk.internal.util.TemporaryFileCreator_Factory.get (TemporaryFileCreator_Factory.java:43)
  at dagger.internal.DoubleCheck.get (DoubleCheck.java:5)
  at org.matrix.android.sdk.internal.session.DefaultSession_Factory.get (DefaultSession_Factory.java:1)
  at dagger.internal.DoubleCheck.get (DoubleCheck.java:5)
  at org.matrix.android.sdk.internal.session.DaggerSessionComponent.session (DaggerSessionComponent.java:1)
  at org.matrix.android.sdk.internal.auth.DefaultAuthenticationService.getLastAuthenticatedSession (DefaultAuthenticationService.kt:3)
  at im.vector.app.VectorApplication.onCreate (VectorApplication.kt:109)
ouchadam commented 3 years ago

also manifests as

  at android.security.keystore.AndroidKeyStoreCipherSpiBase.engineDoFinal (AndroidKeyStoreCipherSpiBase.java:506)
  at javax.crypto.Cipher.doFinal (Cipher.java:2055)
  at org.matrix.android.sdk.internal.session.securestorage.SecretStoringUtils.decryptStringM (SecretStoringUtils.kt:11)
  at org.matrix.android.sdk.internal.database.RealmKeysUtils.getRealmEncryptionKey (RealmKeysUtils.kt:9)
  at org.matrix.android.sdk.internal.database.RealmKeysUtils.configureEncryption (RealmKeysUtils.kt:1)
  at im.vector.app.AppStateHandler_Factory.get (AppStateHandler_Factory.java:73)
  at im.vector.app.core.resources.LocaleProvider_Factory.get (LocaleProvider_Factory.java:5)
  at org.matrix.android.sdk.internal.session.identity.DefaultIdentityService_Factory.get (DefaultIdentityService_Factory.java:1)
  at org.matrix.android.sdk.internal.session.DefaultSession_Factory.get (DefaultSession_Factory.java:1)
  at org.matrix.android.sdk.internal.session.DaggerSessionComponent.session (DaggerSessionComponent.java:1)
  at org.matrix.android.sdk.internal.auth.DefaultAuthenticationService.getLastAuthenticatedSession (DefaultAuthenticationService.kt:3)
  at im.vector.app.VectorApplication.onCreate (VectorApplication.kt:109)