Merge pull request #1101 from vector-im/feature/bma/fixGoogleCryptoCrash

Use alpha version of the library `androidx.security:security-crypto`
This commit is contained in:
Benoit Marty 2023-08-21 16:10:45 +02:00 committed by GitHub
commit af04cefb89
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 5 deletions

1
changelog.d/1101.bugfix Normal file
View file

@ -0,0 +1 @@
Fix crash RuntimeException "No matching key found for the ciphertext in the stream"

View file

@ -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" }

View file

@ -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()
}