Skip to content

Commit

Permalink
Merge pull request #8838 from element-hq/feature/bca/bump_crypto_sdk_…
Browse files Browse the repository at this point in the history
…0.4.1

Bump rust sdk crypto to 0.4.1
  • Loading branch information
bmarty authored May 28, 2024
2 parents 4acbe4e + 0bf3350 commit 204244b
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
1 change: 1 addition & 0 deletions changelog.d/8838.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Update Rust crypto SDK to version 0.4.1
2 changes: 1 addition & 1 deletion matrix-sdk-android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ dependencies {

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")

testImplementation libs.tests.junit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.prepareMethods
import org.matrix.rustcomponents.sdk.crypto.CryptoStoreException
import org.matrix.rustcomponents.sdk.crypto.LocalTrust
import org.matrix.rustcomponents.sdk.crypto.SignatureException
import uniffi.matrix_sdk_crypto.LocalTrust
import org.matrix.rustcomponents.sdk.crypto.Device as InnerDevice

/** Class representing a device that supports E2EE in the Matrix world
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ import org.matrix.rustcomponents.sdk.crypto.DeviceLists
import org.matrix.rustcomponents.sdk.crypto.EncryptionSettings
import org.matrix.rustcomponents.sdk.crypto.KeyRequestPair
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.MegolmV1BackupKey
import org.matrix.rustcomponents.sdk.crypto.Request
Expand All @@ -86,6 +85,7 @@ import org.matrix.rustcomponents.sdk.crypto.ShieldState
import org.matrix.rustcomponents.sdk.crypto.SignatureVerification
import org.matrix.rustcomponents.sdk.crypto.setLogger
import timber.log.Timber
import uniffi.matrix_sdk_crypto.LocalTrust
import java.io.File
import java.nio.charset.Charset
import javax.inject.Inject
Expand Down Expand Up @@ -828,8 +828,14 @@ internal class OlmMachine @Inject constructor(
val requests = withContext(coroutineDispatchers.io) {
inner.bootstrapCrossSigning()
}
(requests.uploadKeysRequest)?.let {
when (it) {
is Request.KeysUpload -> requestSender.uploadKeys(it)
else -> {}
}
}
requestSender.uploadCrossSigningKeys(requests.uploadSigningKeysRequest, uiaInterceptor)
requestSender.sendSignatureUpload(requests.signatureRequest)
requestSender.sendSignatureUpload(requests.uploadSignatureRequest)
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,9 @@ import org.matrix.android.sdk.internal.util.JsonCanonicalizer
import org.matrix.olm.OlmException
import org.matrix.rustcomponents.sdk.crypto.Request
import org.matrix.rustcomponents.sdk.crypto.RequestType
import org.matrix.rustcomponents.sdk.crypto.SignatureState
import org.matrix.rustcomponents.sdk.crypto.SignatureVerification
import timber.log.Timber
import uniffi.matrix_sdk_crypto.SignatureState
import java.security.InvalidParameterException
import javax.inject.Inject
import kotlin.random.Random
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ fun RealmToMigrate.getPickledAccount(pickleKey: ByteArray): MigrationData {
)
MigrationData(
account = pickledAccount,
pickleKey = pickleKey.map { it.toUByte() },
pickleKey = pickleKey,
crossSigning = CrossSigningKeyExport(
masterKey = masterKey,
selfSigningKey = selfSignedKey,
Expand Down Expand Up @@ -153,7 +153,7 @@ fun RealmToMigrate.getPickledAccount(pickleKey: ByteArray): MigrationData {

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

Expand Down

0 comments on commit 204244b

Please sign in to comment.