Add Google Tink dependency, replacing androidx.security.crypto (#4405)

* Add Google Tink dependency, replacing `androidx.security.crypto`

* Replace the `EncryptedFile` implementation too

* Extract constants, add some more docs
This commit is contained in:
Jorge Martin Espinosa 2025-03-17 10:04:21 +01:00 committed by GitHub
parent 27299607f9
commit e2afa9a691
10 changed files with 171 additions and 38 deletions

View file

@ -8,8 +8,7 @@
package io.element.encrypteddb.passphrase
import android.content.Context
import androidx.security.crypto.EncryptedFile
import io.element.android.libraries.androidutils.file.EncryptedFileFactory
import io.element.encrypteddb.crypto.EncryptedFile
import java.io.File
import java.security.SecureRandom
@ -25,7 +24,7 @@ class RandomSecretPassphraseProvider(
private val secretSize: Int = 256,
) : PassphraseProvider {
override fun getPassphrase(): ByteArray {
val encryptedFile = EncryptedFileFactory(context).create(file)
val encryptedFile = EncryptedFile(context, file)
return if (!file.exists()) {
val secret = generateSecret()
encryptedFile.openFileOutput().use { it.write(secret) }