From 583abda56792a1df5ee778718544452fab721b0d Mon Sep 17 00:00:00 2001 From: Yoan Pintas Date: Fri, 6 Oct 2023 23:51:03 +0200 Subject: [PATCH 1/3] Upgrade version number (#978) --- towncrier.toml | 2 +- vector-app/build.gradle | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/towncrier.toml b/towncrier.toml index 1c6ce194b6..5f5e9fc135 100644 --- a/towncrier.toml +++ b/towncrier.toml @@ -1,5 +1,5 @@ [tool.towncrier] - version = "2.9.4" + version = "2.9.5" directory = "changelog.d" filename = "TCHAP_CHANGES.md" name = "Changes in Tchap" diff --git a/vector-app/build.gradle b/vector-app/build.gradle index 0c1d2883ee..65b4c0bf4c 100644 --- a/vector-app/build.gradle +++ b/vector-app/build.gradle @@ -37,7 +37,7 @@ ext.versionMinor = 9 // Note: even values are reserved for regular release, odd values for hotfix release. // When creating a hotfix, you should decrease the value, since the current value // is the value for the next regular release. -ext.versionPatch = 4 +ext.versionPatch = 5 static def getGitTimestamp() { def cmd = 'git show -s --format=%ct' From 2b50f0932201288020c2cda735a1583121a2f634 Mon Sep 17 00:00:00 2001 From: Yoan Pintas Date: Fri, 6 Oct 2023 23:51:27 +0200 Subject: [PATCH 2/3] Fix crypto migration for mono session (#979) --- changelog.d/979.bugfix | 1 + .../sdk/internal/crypto/RustCryptoService.kt | 27 ++++++++++++++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 changelog.d/979.bugfix diff --git a/changelog.d/979.bugfix b/changelog.d/979.bugfix new file mode 100644 index 0000000000..832cb06bd8 --- /dev/null +++ b/changelog.d/979.bugfix @@ -0,0 +1 @@ +Correction des messages chiffrés quand il existe qu'une seule session \ No newline at end of file diff --git a/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt b/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt index 57f81ef592..e7bfb93895 100755 --- a/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt +++ b/matrix-sdk-android/src/rustCrypto/java/org/matrix/android/sdk/internal/crypto/RustCryptoService.kt @@ -54,6 +54,7 @@ import org.matrix.android.sdk.api.session.crypto.model.MXUsersDevicesMap import org.matrix.android.sdk.api.session.events.model.Content import org.matrix.android.sdk.api.session.events.model.Event import org.matrix.android.sdk.api.session.events.model.EventType +import org.matrix.android.sdk.api.session.events.model.content.EncryptedEventContent import org.matrix.android.sdk.api.session.events.model.content.EncryptionEventContent import org.matrix.android.sdk.api.session.events.model.content.RoomKeyContent import org.matrix.android.sdk.api.session.events.model.content.RoomKeyWithHeldContent @@ -133,6 +134,7 @@ internal class RustCryptoService @Inject constructor( private val getRoomUserIds: GetRoomUserIdsUseCase, private val outgoingRequestsProcessor: OutgoingRequestsProcessor, private val matrixConfiguration: MatrixConfiguration, + private val rateLimiter: PerSessionBackupQueryRateLimiter, ) : CryptoService { private val isStarting = AtomicBoolean(false) @@ -493,7 +495,30 @@ internal class RustCryptoService @Inject constructor( */ @Throws(MXCryptoError::class) override suspend fun decryptEvent(event: Event, timeline: String): MXEventDecryptionResult { - return olmMachine.decryptRoomEvent(event) + return try { + olmMachine.decryptRoomEvent(event) + } catch (mxCryptoError: MXCryptoError) { + // Tchap: try to perform a lazy migration from legacy store if there is no other session. + if (mxCryptoError is MXCryptoError.Base && mxCryptoError.errorType == MXCryptoError.ErrorType.UNKNOWN_INBOUND_SESSION_ID) { + Timber.v("Try to perform a lazy migration from legacy store") + /** + * It's a bit hacky, check how this can be better integrated with rust? + */ + val content = event.content?.toModel() ?: throw mxCryptoError + val roomId = event.roomId + val sessionId = content.sessionId + val senderKey = content.senderKey + if (roomId != null && sessionId != null) { + val legacy = tryOrNull("Failed to access legacy crypto store") { + cryptoStore.getInboundGroupSession(sessionId, senderKey.orEmpty()) + } + if (legacy == null || olmMachine.importRoomKey(legacy).isFailure) { + rateLimiter.tryFromBackupIfPossible(sessionId, roomId) + } + } + } + throw mxCryptoError + } } /** From fb63f246505aacc1abe5f177ccd5cac58d1bad36 Mon Sep 17 00:00:00 2001 From: yostyle Date: Fri, 6 Oct 2023 23:58:58 +0200 Subject: [PATCH 3/3] Update changes --- TCHAP_CHANGES.md | 8 ++++++++ changelog.d/979.bugfix | 1 - 2 files changed, 8 insertions(+), 1 deletion(-) delete mode 100644 changelog.d/979.bugfix diff --git a/TCHAP_CHANGES.md b/TCHAP_CHANGES.md index 926c597d60..6336b14b24 100644 --- a/TCHAP_CHANGES.md +++ b/TCHAP_CHANGES.md @@ -1,3 +1,11 @@ +Changes in Tchap 2.9.5 (2023-10-06) +=================================== + +Bugfixes 🐛 +---------- + - Correction des messages chiffrés quand il existe qu'une seule session ([#979](https://github.com/tchapgouv/tchap-android/issues/979)) + + Changes in Tchap 2.9.4 (2023-10-06) =================================== diff --git a/changelog.d/979.bugfix b/changelog.d/979.bugfix deleted file mode 100644 index 832cb06bd8..0000000000 --- a/changelog.d/979.bugfix +++ /dev/null @@ -1 +0,0 @@ -Correction des messages chiffrés quand il existe qu'une seule session \ No newline at end of file