Merge pull request #12 from poljar/fga/feature/finish_backup_recovery_key

Use backup key directly on olmMachine.
This commit is contained in:
ganfra 2022-06-08 12:29:43 +02:00 committed by GitHub
commit 52ed7c019b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 8 deletions

View File

@ -140,7 +140,7 @@ dependencies {
implementation libs.jetbrains.coroutinesCore implementation libs.jetbrains.coroutinesCore
implementation libs.jetbrains.coroutinesAndroid implementation libs.jetbrains.coroutinesAndroid
implementation 'org.matrix.rustcomponents:crypto-android:0.1.0' implementation 'org.matrix.rustcomponents:crypto-android:0.2.1-SNAPSHOT'
//implementation files('libs/crypto-android-release.aar') //implementation files('libs/crypto-android-release.aar')
// implementation(name: 'crypto-android-release', ext: 'aar') // implementation(name: 'crypto-android-release', ext: 'aar')

View File

@ -59,6 +59,7 @@ import org.matrix.android.sdk.internal.network.parsing.CheckNumberType
import org.matrix.android.sdk.internal.session.SessionScope import org.matrix.android.sdk.internal.session.SessionScope
import timber.log.Timber import timber.log.Timber
import uniffi.olm.BackupKeys import uniffi.olm.BackupKeys
import uniffi.olm.BackupRecoveryKey
import uniffi.olm.CrossSigningKeyExport import uniffi.olm.CrossSigningKeyExport
import uniffi.olm.CrossSigningStatus import uniffi.olm.CrossSigningStatus
import uniffi.olm.CryptoStoreException import uniffi.olm.CryptoStoreException
@ -769,7 +770,7 @@ internal class OlmMachine @Inject constructor(
} }
@Throws(CryptoStoreException::class) @Throws(CryptoStoreException::class)
suspend fun saveRecoveryKey(key: String?, version: String?) { suspend fun saveRecoveryKey(key: BackupRecoveryKey?, version: String?) {
withContext(coroutineDispatchers.computation) { withContext(coroutineDispatchers.computation) {
inner.saveRecoveryKey(key, version) inner.saveRecoveryKey(key, version)
} }

View File

@ -189,9 +189,7 @@ internal class RustKeyBackupService @Inject constructor(
override fun saveBackupRecoveryKey(recoveryKey: BackupRecoveryKey?, version: String?) { override fun saveBackupRecoveryKey(recoveryKey: BackupRecoveryKey?, version: String?) {
cryptoCoroutineScope.launch { cryptoCoroutineScope.launch {
val recoveryKeyStr = recoveryKey?.toBase64() olmMachine.saveRecoveryKey(recoveryKey?.inner, version)
// TODO : change rust API to use BackupRecoveryKey
olmMachine.saveRecoveryKey(recoveryKeyStr, version)
} }
} }
@ -727,9 +725,8 @@ internal class RustKeyBackupService @Inject constructor(
override suspend fun getKeyBackupRecoveryKeyInfo(): SavedKeyBackupKeyInfo? { override suspend fun getKeyBackupRecoveryKeyInfo(): SavedKeyBackupKeyInfo? {
val info = olmMachine.getBackupKeys() ?: return null val info = olmMachine.getBackupKeys() ?: return null
// TODO change rust ffi to return BackupRecoveryKey instead of base64 string val backupRecoveryKey = BackupRecoveryKey(info.recoveryKey())
val backupRecoveryKey = BackupRecoveryKey.fromBase64(info.recoveryKey) return SavedKeyBackupKeyInfo(backupRecoveryKey, info.backupVersion())
return SavedKeyBackupKeyInfo(backupRecoveryKey, info.backupVersion)
} }
/** /**