Bump rust sdk crypto to 0.4.1

This commit is contained in:
Valere 2024-05-27 09:48:20 +02:00
parent 4acbe4e582
commit 5ac70dac2b
5 changed files with 21 additions and 11 deletions

View File

@ -215,7 +215,7 @@ dependencies {
implementation libs.google.phonenumber implementation libs.google.phonenumber
implementation("org.matrix.rustcomponents:crypto-android:0.3.16") implementation("org.matrix.rustcomponents:crypto-android:0.4.1")
// api project(":library:rustCrypto") // api project(":library:rustCrypto")
testImplementation libs.tests.junit testImplementation libs.tests.junit

View File

@ -31,8 +31,8 @@ import org.matrix.android.sdk.internal.crypto.verification.SasVerification
import org.matrix.android.sdk.internal.crypto.verification.VerificationRequest import org.matrix.android.sdk.internal.crypto.verification.VerificationRequest
import org.matrix.android.sdk.internal.crypto.verification.prepareMethods import org.matrix.android.sdk.internal.crypto.verification.prepareMethods
import org.matrix.rustcomponents.sdk.crypto.CryptoStoreException import org.matrix.rustcomponents.sdk.crypto.CryptoStoreException
import org.matrix.rustcomponents.sdk.crypto.LocalTrust
import org.matrix.rustcomponents.sdk.crypto.SignatureException import org.matrix.rustcomponents.sdk.crypto.SignatureException
import uniffi.matrix_sdk_crypto.LocalTrust
import org.matrix.rustcomponents.sdk.crypto.Device as InnerDevice import org.matrix.rustcomponents.sdk.crypto.Device as InnerDevice
/** Class representing a device that supports E2EE in the Matrix world /** Class representing a device that supports E2EE in the Matrix world

View File

@ -75,7 +75,6 @@ import org.matrix.rustcomponents.sdk.crypto.DeviceLists
import org.matrix.rustcomponents.sdk.crypto.EncryptionSettings import org.matrix.rustcomponents.sdk.crypto.EncryptionSettings
import org.matrix.rustcomponents.sdk.crypto.KeyRequestPair import org.matrix.rustcomponents.sdk.crypto.KeyRequestPair
import org.matrix.rustcomponents.sdk.crypto.KeysImportResult import org.matrix.rustcomponents.sdk.crypto.KeysImportResult
import org.matrix.rustcomponents.sdk.crypto.LocalTrust
import org.matrix.rustcomponents.sdk.crypto.Logger import org.matrix.rustcomponents.sdk.crypto.Logger
import org.matrix.rustcomponents.sdk.crypto.MegolmV1BackupKey import org.matrix.rustcomponents.sdk.crypto.MegolmV1BackupKey
import org.matrix.rustcomponents.sdk.crypto.Request import org.matrix.rustcomponents.sdk.crypto.Request
@ -86,6 +85,7 @@ import org.matrix.rustcomponents.sdk.crypto.ShieldState
import org.matrix.rustcomponents.sdk.crypto.SignatureVerification import org.matrix.rustcomponents.sdk.crypto.SignatureVerification
import org.matrix.rustcomponents.sdk.crypto.setLogger import org.matrix.rustcomponents.sdk.crypto.setLogger
import timber.log.Timber import timber.log.Timber
import uniffi.matrix_sdk_crypto.LocalTrust
import java.io.File import java.io.File
import java.nio.charset.Charset import java.nio.charset.Charset
import javax.inject.Inject import javax.inject.Inject
@ -828,8 +828,14 @@ internal class OlmMachine @Inject constructor(
val requests = withContext(coroutineDispatchers.io) { val requests = withContext(coroutineDispatchers.io) {
inner.bootstrapCrossSigning() inner.bootstrapCrossSigning()
} }
(requests.uploadKeysRequest)?.let {
when (it) {
is Request.KeysUpload -> requestSender.uploadKeys(it)
else -> {}
}
}
requestSender.uploadCrossSigningKeys(requests.uploadSigningKeysRequest, uiaInterceptor) requestSender.uploadCrossSigningKeys(requests.uploadSigningKeysRequest, uiaInterceptor)
requestSender.sendSignatureUpload(requests.signatureRequest) requestSender.sendSignatureUpload(requests.uploadSignatureRequest)
} }
/** /**

View File

@ -68,9 +68,9 @@ import org.matrix.android.sdk.internal.util.JsonCanonicalizer
import org.matrix.olm.OlmException import org.matrix.olm.OlmException
import org.matrix.rustcomponents.sdk.crypto.Request import org.matrix.rustcomponents.sdk.crypto.Request
import org.matrix.rustcomponents.sdk.crypto.RequestType import org.matrix.rustcomponents.sdk.crypto.RequestType
import org.matrix.rustcomponents.sdk.crypto.SignatureState
import org.matrix.rustcomponents.sdk.crypto.SignatureVerification import org.matrix.rustcomponents.sdk.crypto.SignatureVerification
import timber.log.Timber import timber.log.Timber
import uniffi.matrix_sdk_crypto.SignatureState
import java.security.InvalidParameterException import java.security.InvalidParameterException
import javax.inject.Inject import javax.inject.Inject
import kotlin.random.Random import kotlin.random.Random

View File

@ -100,7 +100,7 @@ fun RealmToMigrate.getPickledAccount(pickleKey: ByteArray): MigrationData {
) )
MigrationData( MigrationData(
account = pickledAccount, account = pickledAccount,
pickleKey = pickleKey.map { it.toUByte() }, pickleKey = pickleKey,
crossSigning = CrossSigningKeyExport( crossSigning = CrossSigningKeyExport(
masterKey = masterKey, masterKey = masterKey,
selfSigningKey = selfSignedKey, selfSigningKey = selfSignedKey,
@ -153,7 +153,7 @@ fun RealmToMigrate.getPickledAccount(pickleKey: ByteArray): MigrationData {
migrationData = MigrationData( migrationData = MigrationData(
account = pickledAccount, account = pickledAccount,
pickleKey = pickleKey.map { it.toUByte() }, pickleKey = pickleKey,
crossSigning = CrossSigningKeyExport( crossSigning = CrossSigningKeyExport(
masterKey = masterKey, masterKey = masterKey,
selfSigningKey = selfSignedKey, selfSigningKey = selfSignedKey,
@ -222,8 +222,10 @@ fun RealmToMigrate.pickledOlmSessions(pickleKey: ByteArray, chunkSize: Int, onCh
pickle = pickle, pickle = pickle,
senderKey = deviceKey, senderKey = deviceKey,
createdUsingFallbackKey = false, createdUsingFallbackKey = false,
creationTime = lastReceivedMessageTs.toString(), // / Unix timestamp (in seconds) when the session was created.
lastUseTime = lastReceivedMessageTs.toString() creationTime = (lastReceivedMessageTs / 1000).toULong(),
// / Unix timestamp (in seconds) when the session was last used.
lastUseTime = (lastReceivedMessageTs / 1000).toULong(),
) )
// should we check the tracking status? // should we check the tracking status?
pickledSessions.add(pickledSession) pickledSessions.add(pickledSession)
@ -323,8 +325,10 @@ private fun OlmSessionEntity.toPickledSession(pickleKey: ByteArray): PickledSess
pickle = pickledOlmSession, pickle = pickledOlmSession,
senderKey = deviceKey, senderKey = deviceKey,
createdUsingFallbackKey = false, createdUsingFallbackKey = false,
creationTime = lastReceivedMessageTs.toString(), // Rust expect in seconds
lastUseTime = lastReceivedMessageTs.toString() creationTime = (lastReceivedMessageTs / 1000).toULong(),
// Rust expect in seconds
lastUseTime = (lastReceivedMessageTs / 1000).toULong(),
) )
} }