Fix deprecated API usage.
This commit is contained in:
parent
50689d59d5
commit
035a3da417
1 changed files with 6 additions and 4 deletions
|
|
@ -18,7 +18,7 @@ package io.element.android.libraries.androidutils.file
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import androidx.security.crypto.EncryptedFile
|
import androidx.security.crypto.EncryptedFile
|
||||||
import androidx.security.crypto.MasterKeys
|
import androidx.security.crypto.MasterKey
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class EncryptedFileFactory(
|
class EncryptedFileFactory(
|
||||||
|
|
@ -26,11 +26,13 @@ class EncryptedFileFactory(
|
||||||
) {
|
) {
|
||||||
fun create(file: File): EncryptedFile {
|
fun create(file: File): EncryptedFile {
|
||||||
// We need to use the same key for all the encrypted files.
|
// 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(
|
return EncryptedFile.Builder(
|
||||||
file,
|
|
||||||
context,
|
context,
|
||||||
masterKeyAlias,
|
file,
|
||||||
|
masterKey,
|
||||||
EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB
|
EncryptedFile.FileEncryptionScheme.AES256_GCM_HKDF_4KB
|
||||||
).build()
|
).build()
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue