From 5dbee7dcdc2bfd0a46ec883ba1b88faa412582e3 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Tue, 31 Jan 2023 15:59:22 +0000 Subject: [PATCH] fix(indexeddb): correctly encode Olm session keys When we store an Olm session in the database, we encode the sender key and session ID using the store cipher. That means that we also need to encode them when we look them up, otherwise we won't find them. --- crates/matrix-sdk-indexeddb/src/crypto_store.rs | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/crates/matrix-sdk-indexeddb/src/crypto_store.rs b/crates/matrix-sdk-indexeddb/src/crypto_store.rs index 757a40807..3e8860d6f 100644 --- a/crates/matrix-sdk-indexeddb/src/crypto_store.rs +++ b/crates/matrix-sdk-indexeddb/src/crypto_store.rs @@ -639,13 +639,7 @@ impl IndexeddbCryptoStore { let account_info = self.get_account_info().ok_or(CryptoStoreError::AccountUnset)?; if self.session_cache.get(sender_key).is_none() { - let range = sender_key.encode_to_range().map_err(|e| { - IndexeddbCryptoStoreError::DomException { - code: 0, - name: "IdbKeyRangeMakeError".to_owned(), - message: e, - } - })?; + let range = self.encode_to_range(KEYS::SESSION, sender_key)?; let sessions: Vec = self .inner .transaction_on_one_with_mode(KEYS::SESSION, IdbTransactionMode::Readonly)?