Merge pull request #8679 from vector-im/feature/bca/bump_crypto_sdk_version

bump crypto sdk to 0.3.16
This commit is contained in:
Valere 2023-11-14 22:26:32 +01:00 committed by GitHub
commit 1a941149ab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 16 deletions

1
changelog.d/8679.misc Normal file
View File

@ -0,0 +1 @@
Bump crypto sdk bindings to v0.3.16

View File

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

View File

@ -240,7 +240,8 @@ interface CryptoService {
toDevice: ToDeviceSyncResponse?, toDevice: ToDeviceSyncResponse?,
deviceChanges: DeviceListResponse?, deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?, keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?) deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?)
suspend fun onLiveEvent(roomId: String, event: Event, isInitialSync: Boolean, cryptoStoreAggregator: CryptoStoreAggregator?) suspend fun onLiveEvent(roomId: String, event: Event, isInitialSync: Boolean, cryptoStoreAggregator: CryptoStoreAggregator?)
suspend fun onStateEvent(roomId: String, event: Event, cryptoStoreAggregator: CryptoStoreAggregator?) {} suspend fun onStateEvent(roomId: String, event: Event, cryptoStoreAggregator: CryptoStoreAggregator?) {}

View File

@ -19,7 +19,6 @@ package org.matrix.android.sdk.internal.crypto
import androidx.lifecycle.LiveData import androidx.lifecycle.LiveData
import androidx.lifecycle.asLiveData import androidx.lifecycle.asLiveData
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow import kotlinx.coroutines.flow.channelFlow
import kotlinx.coroutines.runBlocking import kotlinx.coroutines.runBlocking
@ -254,6 +253,8 @@ internal class OlmMachine @Inject constructor(
* *
* @param deviceUnusedFallbackKeyTypes The key algorithms for which the server has an unused fallback key for the device. * @param deviceUnusedFallbackKeyTypes The key algorithms for which the server has an unused fallback key for the device.
* *
* @param nextBatch The batch token to pass in the next sync request.
*
* @return The handled events, decrypted if needed (secrets are zeroised). * @return The handled events, decrypted if needed (secrets are zeroised).
*/ */
@Throws(CryptoStoreException::class) @Throws(CryptoStoreException::class)
@ -262,6 +263,7 @@ internal class OlmMachine @Inject constructor(
deviceChanges: DeviceListResponse?, deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?, keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?, deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?
): ToDeviceSyncResponse { ): ToDeviceSyncResponse {
val response = withContext(coroutineDispatchers.io) { val response = withContext(coroutineDispatchers.io) {
val counts: MutableMap<String, Int> = mutableMapOf() val counts: MutableMap<String, Int> = mutableMapOf()
@ -281,18 +283,16 @@ internal class OlmMachine @Inject constructor(
val events = adapter.toJson(toDevice ?: ToDeviceSyncResponse()) val events = adapter.toJson(toDevice ?: ToDeviceSyncResponse())
// field pass in the list of unused fallback keys here // field pass in the list of unused fallback keys here
val receiveSyncChanges = inner.receiveSyncChanges(events, devices, counts, deviceUnusedFallbackKeyTypes) val receiveSyncChanges = inner.receiveSyncChanges(events, devices, counts, deviceUnusedFallbackKeyTypes, nextBatch ?: "")
val outAdapter = moshi.adapter<List<Event>>( val outAdapter = moshi.adapter(Event::class.java)
Types.newParameterizedType(
List::class.java, // we don't need to use `roomKeyInfos` as for now we are manually
Event::class.java, // checking the returned to devices to check for room keys.
String::class.java, // XXX Anyhow there is now proper signaling we should soon stop parsing them manually
Integer::class.java, receiveSyncChanges.toDeviceEvents.map {
Any::class.java, outAdapter.fromJson(it) ?: Event()
) }
)
outAdapter.fromJson(receiveSyncChanges) ?: emptyList()
} }
// We may get cross signing keys over a to-device event, update our listeners. // We may get cross signing keys over a to-device event, update our listeners.

View File

@ -618,9 +618,10 @@ internal class RustCryptoService @Inject constructor(
deviceChanges: DeviceListResponse?, deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?, keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?, deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?,
) { ) {
// Decrypt and handle our to-device events // Decrypt and handle our to-device events
val toDeviceEvents = this.olmMachine.receiveSyncChanges(toDevice, deviceChanges, keyCounts, deviceUnusedFallbackKeyTypes) val toDeviceEvents = this.olmMachine.receiveSyncChanges(toDevice, deviceChanges, keyCounts, deviceUnusedFallbackKeyTypes, nextBatch)
// Notify the our listeners about room keys so decryption is retried. // Notify the our listeners about room keys so decryption is retried.
toDeviceEvents.events.orEmpty().forEach { event -> toDeviceEvents.events.orEmpty().forEach { event ->

View File

@ -184,7 +184,8 @@ internal class SyncResponseHandler @Inject constructor(
syncResponse.toDevice, syncResponse.toDevice,
syncResponse.deviceLists, syncResponse.deviceLists,
syncResponse.deviceOneTimeKeysCount, syncResponse.deviceOneTimeKeysCount,
syncResponse.deviceUnusedFallbackKeyTypes syncResponse.deviceUnusedFallbackKeyTypes,
syncResponse.nextBatch
) )
}.also { }.also {
Timber.v("Finish handling toDevice in $it ms") Timber.v("Finish handling toDevice in $it ms")