From 5b76d4b68217e2d161bac3056833a037638eee29 Mon Sep 17 00:00:00 2001 From: Valere Date: Wed, 10 Nov 2021 16:55:34 +0100 Subject: [PATCH 1/2] Fix fallback otk support --- changelog.d/4446.bugfix | 1 + .../android/sdk/internal/crypto/model/MXKey.kt | 12 +++++++++--- 2 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 changelog.d/4446.bugfix diff --git a/changelog.d/4446.bugfix b/changelog.d/4446.bugfix new file mode 100644 index 0000000000..140e18a3ba --- /dev/null +++ b/changelog.d/4446.bugfix @@ -0,0 +1 @@ +Unable to establish Olm outbound session from fallback key \ No newline at end of file diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt index f71c5079b3..01c71550f3 100755 --- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt @@ -38,14 +38,18 @@ data class MXKey( /** * signature user Id to [deviceid][signature] */ - private val signatures: Map> + private val signatures: Map>, + + private val rawMap: JsonDict ) { /** * @return the signed data map */ fun signalableJSONDictionary(): Map { - return mapOf("key" to value) + return rawMap.filter { + it.key != "signatures" && it.key != "unsigned" + } } /** @@ -82,6 +86,7 @@ data class MXKey( *
          *   "signed_curve25519:AAAAFw": {
          *     "key": "IjwIcskng7YjYcn0tS8TUOT2OHHtBSfMpcfIczCgXj4",
+         *     "fallback" : true|false
          *     "signatures": {
          *       "@userId:matrix.org": {
          *         "ed25519:GMJRREOASV": "EUjp6pXzK9u3SDFR\/qLbzpOi3bEREeI6qMnKzXu992HsfuDDZftfJfiUXv9b\/Hqq1og4qM\/vCQJGTHAWMmgkCg"
@@ -107,7 +112,8 @@ data class MXKey(
                                     type = components[0],
                                     keyId = components[1],
                                     value = params["key"] as String,
-                                    signatures = params["signatures"] as Map>
+                                    signatures = params["signatures"] as Map>,
+                                    rawMap = params
                             )
                         }
                     }

From b304ef82fc6bfbc4ba5318dd59cbf8bc6ac45dd8 Mon Sep 17 00:00:00 2001
From: Valere 
Date: Wed, 10 Nov 2021 17:41:06 +0100
Subject: [PATCH 2/2] add comments

---
 .../org/matrix/android/sdk/internal/crypto/model/MXKey.kt     | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt
index 01c71550f3..9f425eee7f 100755
--- a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt
+++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/model/MXKey.kt
@@ -40,6 +40,10 @@ data class MXKey(
          */
         private val signatures: Map>,
 
+        /**
+         * We have to store the original json because it can contain other fields
+         * that we don't support yet but they would be needed to check signatures
+         */
         private val rawMap: JsonDict
 ) {