Skip to content

Commit af04cef

Browse files
authored
Merge pull request #1101 from vector-im/feature/bma/fixGoogleCryptoCrash
Use alpha version of the library `androidx.security:security-crypto`
2 parents a562bd2 + 8fea775 commit af04cef

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

changelog.d/1101.bugfix

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix crash RuntimeException "No matching key found for the ciphertext in the stream"

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ androidx_browser = { module = "androidx.browser:browser", version.ref = "browser
8282
androidx_lifecycle_runtime = { module = "androidx.lifecycle:lifecycle-runtime-ktx", version.ref = "lifecycle" }
8383
androidx_lifecycle_process = { module = "androidx.lifecycle:lifecycle-process", version.ref = "lifecycle" }
8484
androidx_splash = "androidx.core:core-splashscreen:1.0.1"
85-
androidx_security_crypto = "androidx.security:security-crypto:1.0.0"
85+
androidx_security_crypto = "androidx.security:security-crypto:1.1.0-alpha06"
8686
androidx_media3_exoplayer = { module = "androidx.media3:media3-exoplayer", version.ref = "media3" }
8787
androidx_media3_ui = { module = "androidx.media3:media3-ui", version.ref = "media3" }
8888

libraries/androidutils/src/main/kotlin/io/element/android/libraries/androidutils/file/EncryptedFileFactory.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,21 @@ package io.element.android.libraries.androidutils.file
1818

1919
import android.content.Context
2020
import androidx.security.crypto.EncryptedFile
21-
import androidx.security.crypto.MasterKeys
21+
import androidx.security.crypto.MasterKey
2222
import java.io.File
2323

2424
class EncryptedFileFactory(
2525
private val context: Context,
2626
) {
2727
fun create(file: File): EncryptedFile {
2828
// We need to use the same key for all the encrypted files.
29-
val masterKeyAlias = MasterKeys.getOrCreate(MasterKeys.AES256_GCM_SPEC)
29+
val masterKey = MasterKey.Builder(context)
30+
.setKeyScheme(MasterKey.KeyScheme.AES256_GCM)
31+
.build()
3032
return EncryptedFile.Builder(
31-
file,
3233
context,
33-
masterKeyAlias,
34+
file,
35+
masterKey,
3436
EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB
3537
).build()
3638
}

0 commit comments

Comments
 (0)