Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
5d9fdd8
feat: Add `RoomKeyWithheldEntry` to wrap to-device and bundle payloads.
kaylendog Oct 1, 2025
e635219
feat: Append withheld info from room key bundle to store.
kaylendog Oct 1, 2025
7ef47d2
fix: Clippy lints, copy over clone, `to_owned`.
kaylendog Oct 1, 2025
a98f852
docs: Update CHANGELOGs.
kaylendog Oct 1, 2025
20246ba
feat(crypto): Store `sender` in `RoomKeyWithheldEntry::Bundle`.
kaylendog Oct 2, 2025
fd3943c
feat: Use struct for `RoomKeyWithheldEntry`, move to store.
kaylendog Oct 2, 2025
e10a1e6
tests: Test deserializing `m.room_key.withheld` to withheld entry.
kaylendog Oct 2, 2025
55c005d
tests: Use `serde_json::json!()` in test over invoking `Serialize`.
kaylendog Oct 3, 2025
cc74a92
fix(crypto): Re-restrict `OlmMachine::add_withheld_info` visibility.
kaylendog Oct 6, 2025
c7cbca5
docs(crypto): Clarify doc comments for RoomKeyWithheldEntry.
kaylendog Oct 6, 2025
a581fdd
refactor(cryptor): Split `receive_room_key_bundle` to helper methods.
kaylendog Oct 6, 2025
948402f
test(crypto): Add fix for `experimental-algorithms` feature.
kaylendog Oct 6, 2025
88e0dfb
test(crypto): Redact algorithm field in room key bundle snapshot.
kaylendog Oct 6, 2025
0d56345
feat(crypto): Add all withheld types (with room ID) to store.
kaylendog Oct 7, 2025
869007e
docs(crypto): Point URLs to correct MSC.
kaylendog Oct 9, 2025
48f87a4
docs(crypto): Clarify session algorithm dependency on feature flag.
kaylendog Oct 9, 2025
1510108
feat(crypto): Explicit `RoomKeyWithheldContent::Unknown` match case.
kaylendog Oct 9, 2025
741505d
fix(crypto): Remove unnecessary inverted feature flag.
kaylendog Oct 9, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions crates/matrix-sdk-crypto/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ All notable changes to this project will be documented in this file.

## [Unreleased] - ReleaseDate

### Features

- Improves feedback support for shared history when downloading room key bundles.
([#5737](https://github.com/matrix-org/matrix-rust-sdk/pull/5737))
- Add `RoomKeyWithheldEntry` enum, wrapping either a received to-device `m.room_key.withheld` event or
its content, if derived from a downloaded room key bundle.
- `OlmMachine::receive_room_key_bundle` now appends withheld key information to the store.
- [**breaking**] `Changes::withheld_session_info` now stores a `RookKeyWithheldEntry` in each `room-id`-`session-id` entry.
- [**breaking**] `CryptoStore::get_withheld_info` now returns `Result<Option<RookKeyWithheldEntry>>`. This change also affects `MemoryStore`.

### Bug Fixes

- Fix a bug introduced in 0.14.0 which meant that the serialization of the value returned by `OtherUserIdentity::verification_request_content` did not include a `msgtype` field.
Expand Down
6 changes: 4 additions & 2 deletions crates/matrix-sdk-crypto/src/machine/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1003,14 +1003,16 @@ impl OlmMachine {

if let RoomKeyWithheldContent::MegolmV1AesSha2(
MegolmV1AesSha2WithheldContent::BlackListed(c)
| MegolmV1AesSha2WithheldContent::Unverified(c),
| MegolmV1AesSha2WithheldContent::Unverified(c)
| MegolmV1AesSha2WithheldContent::Unauthorised(c)
| MegolmV1AesSha2WithheldContent::Unavailable(c),
) = &event.content
{
changes
.withheld_session_info
.entry(c.room_id.to_owned())
.or_default()
.insert(c.session_id.to_owned(), event.to_owned());
.insert(c.session_id.to_owned(), event.to_owned().into());
}
}

Expand Down
9 changes: 5 additions & 4 deletions crates/matrix-sdk-crypto/src/store/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ macro_rules! cryptostore_integration_tests {
store::{
types::{
BackupDecryptionKey, Changes, DehydratedDeviceKey, DeviceChanges,
IdentityChanges, PendingChanges, StoredRoomKeyBundleData, RoomSettings,
IdentityChanges, PendingChanges, StoredRoomKeyBundleData, RoomKeyWithheldEntry,
RoomSettings
},
CryptoStore, GossipRequest,
},
Expand Down Expand Up @@ -1138,7 +1139,7 @@ macro_rules! cryptostore_integration_tests {
async fn test_withheld_info_storage() {
let (account, store) = get_loaded_store("withheld_info_storage").await;

let mut info_list: BTreeMap<_, BTreeMap<_, _>> = BTreeMap::new();
let mut info_list: BTreeMap<_, BTreeMap<_, RoomKeyWithheldEntry>> = BTreeMap::new();

let user_id = account.user_id().to_owned();
let room_id = room_id!("!DwLygpkclUAfQNnfva:example.com");
Expand All @@ -1163,7 +1164,7 @@ macro_rules! cryptostore_integration_tests {
info_list
.entry(room_id.to_owned())
.or_default()
.insert(session_id_1.to_owned(), event);
.insert(session_id_1.to_owned(), event.into());

let content = RoomKeyWithheldContent::MegolmV1AesSha2(
MegolmV1AesSha2WithheldContent::BlackListed(
Expand All @@ -1183,7 +1184,7 @@ macro_rules! cryptostore_integration_tests {
info_list
.entry(room_id.to_owned())
.or_default()
.insert(session_id_2.to_owned(), event);
.insert(session_id_2.to_owned(), event.into());

let changes = Changes { withheld_session_info: info_list, ..Default::default() };
store.save_changes(changes).await.unwrap();
Expand Down
11 changes: 5 additions & 6 deletions crates/matrix-sdk-crypto/src/store/memorystore.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ use crate::{
OutboundGroupSession, PickledAccount, PickledInboundGroupSession, PickledSession,
PrivateCrossSigningIdentity, SenderDataType, StaticAccountData,
},
types::events::room_key_withheld::RoomKeyWithheldEvent,
store::types::RoomKeyWithheldEntry,
};

fn encode_key_info(info: &SecretInfo) -> String {
Expand Down Expand Up @@ -97,7 +97,7 @@ pub struct MemoryStore {
identities: StdRwLock<HashMap<OwnedUserId, String>>,
outgoing_key_requests: StdRwLock<HashMap<OwnedTransactionId, GossipRequest>>,
key_requests_by_info: StdRwLock<HashMap<String, OwnedTransactionId>>,
direct_withheld_info: StdRwLock<HashMap<OwnedRoomId, HashMap<String, RoomKeyWithheldEvent>>>,
direct_withheld_info: StdRwLock<HashMap<OwnedRoomId, HashMap<String, RoomKeyWithheldEntry>>>,
custom_values: StdRwLock<HashMap<String, Vec<u8>>>,
leases: StdRwLock<HashMap<String, (String, Instant)>>,
secret_inbox: StdRwLock<HashMap<String, Vec<GossippedSecret>>>,
Expand Down Expand Up @@ -420,7 +420,7 @@ impl CryptoStore for MemoryStore {
&self,
room_id: &RoomId,
session_id: &str,
) -> Result<Option<RoomKeyWithheldEvent>> {
) -> Result<Option<RoomKeyWithheldEntry>> {
Ok(self
.direct_withheld_info
.read()
Expand Down Expand Up @@ -1272,11 +1272,10 @@ mod integration_tests {
store::{
types::{
BackupKeys, Changes, DehydratedDeviceKey, PendingChanges, RoomKeyCounts,
RoomSettings, StoredRoomKeyBundleData, TrackedUser,
RoomKeyWithheldEntry, RoomSettings, StoredRoomKeyBundleData, TrackedUser,
},
CryptoStore,
},
types::events::room_key_withheld::RoomKeyWithheldEvent,
Account, DeviceData, GossipRequest, GossippedSecret, SecretInfo, Session, UserIdentityData,
};

Expand Down Expand Up @@ -1372,7 +1371,7 @@ mod integration_tests {
&self,
room_id: &RoomId,
session_id: &str,
) -> Result<Option<RoomKeyWithheldEvent>, Self::Error> {
) -> Result<Option<RoomKeyWithheldEntry>, Self::Error> {
self.0.get_withheld_info(room_id, session_id).await
}

Expand Down
Loading
Loading