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("org.matrix.rustcomponents:crypto-android:0.3.15")
implementation("org.matrix.rustcomponents:crypto-android:0.3.16")
// api project(":library:rustCrypto")
testImplementation libs.tests.junit

View file

@ -240,7 +240,8 @@ interface CryptoService {
toDevice: ToDeviceSyncResponse?,
deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?)
deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?)
suspend fun onLiveEvent(roomId: String, event: Event, isInitialSync: Boolean, 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.asLiveData
import com.squareup.moshi.Moshi
import com.squareup.moshi.Types
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.channelFlow
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 nextBatch The batch token to pass in the next sync request.
*
* @return The handled events, decrypted if needed (secrets are zeroised).
*/
@Throws(CryptoStoreException::class)
@ -262,6 +263,7 @@ internal class OlmMachine @Inject constructor(
deviceChanges: DeviceListResponse?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?
): ToDeviceSyncResponse {
val response = withContext(coroutineDispatchers.io) {
val counts: MutableMap<String, Int> = mutableMapOf()
@ -281,18 +283,16 @@ internal class OlmMachine @Inject constructor(
val events = adapter.toJson(toDevice ?: ToDeviceSyncResponse())
// 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>>(
Types.newParameterizedType(
List::class.java,
Event::class.java,
String::class.java,
Integer::class.java,
Any::class.java,
)
)
outAdapter.fromJson(receiveSyncChanges) ?: emptyList()
val outAdapter = moshi.adapter(Event::class.java)
// we don't need to use `roomKeyInfos` as for now we are manually
// checking the returned to devices to check for room keys.
// XXX Anyhow there is now proper signaling we should soon stop parsing them manually
receiveSyncChanges.toDeviceEvents.map {
outAdapter.fromJson(it) ?: Event()
}
}
// 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?,
keyCounts: DeviceOneTimeKeysCountSyncResponse?,
deviceUnusedFallbackKeyTypes: List<String>?,
nextBatch: String?,
) {
// 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.
toDeviceEvents.events.orEmpty().forEach { event ->

View file

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