From 9049ed14402a4139b8cab63cbccec9a9e02996c6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 21 Aug 2023 12:27:33 +0200 Subject: [PATCH 1/3] Use alpha version of the library `androidx.security:security-crypto` to fix crash `RuntimeException "No matching key found for the ciphertext in the stream" - RandomSecretPassphraseProvider`. #1099 --- gradle/libs.versions.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index c8751b9bb3..941cae3e3e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -82,7 +82,7 @@ androidx_browser = { module = "androidx.browser:browser", version.ref = "browser androidx_lifecycle_runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" } androidx_lifecycle_process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycle" } androidx_splash = "androidx.core:core-splashscreen:1.0.1" -androidx_security_crypto = "androidx.security:security-crypto:1.0.0" +androidx_security_crypto = "androidx.security:security-crypto:1.1.0-alpha06" androidx_media3_exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3" } androidx_media3_ui = { module = "androidx.media3:media3-ui", version.ref = "media3" } From 1f9bdaa91ea3254081524adb88d08d7fed957193 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 21 Aug 2023 12:59:40 +0200 Subject: [PATCH 2/3] Changelog --- changelog.d/1101.bugfix | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/1101.bugfix diff --git a/changelog.d/1101.bugfix b/changelog.d/1101.bugfix new file mode 100644 index 0000000000..79c25ffaf6 --- /dev/null +++ b/changelog.d/1101.bugfix @@ -0,0 +1 @@ +Fix crash RuntimeException "No matching key found for the ciphertext in the stream" From 8fea775e2aff6b226ab37c52be810f5666ced7b6 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Mon, 21 Aug 2023 14:33:47 +0200 Subject: [PATCH 3/3] Fix deprecated API usage. --- .../androidutils/file/EncryptedFileFactory.kt | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/file/EncryptedFileFactory.kt b/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/file/EncryptedFileFactory.kt index 815c5fad6e..16cd641c8f 100644 --- a/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/file/EncryptedFileFactory.kt +++ b/libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/file/EncryptedFileFactory.kt @@ -18,7 +18,7 @@ package io.element.android.libraries.androidutils.file import android.content.Context import androidx.security.crypto.EncryptedFile -import androidx.security.crypto.MasterKeys +import androidx.security.crypto.MasterKey import java.io.File class EncryptedFileFactory( @@ -26,11 +26,13 @@ class EncryptedFileFactory( ) { fun create(file: File): EncryptedFile { // We need to use the same key for all the encrypted files. - val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC) + val masterKey = MasterKey.Builder(context) + .setKeyScheme(MasterKey.KeyScheme.AES256_GCM) + .build() return EncryptedFile.Builder( - file, context, - masterKeyAlias, + file, + masterKey, EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB ).build() }