Commit Graph

1661 Commits

Author SHA1 Message Date
Damir Jelić
4c1f80faf7 chore: Release matrix-sdk version 0.14.0 2025-09-04 16:05:48 +02:00
multi prise
bcabf1bda4 Improve perfomance of build_room_key_bundle 2025-09-03 14:18:40 +02:00
Benjamin Bouvier
0b3345f592 feat(sdk): add more timers to sync processing 2025-09-03 12:46:09 +02:00
multisme
ea59bc8955 Implement querying inboundgroupsessions by room_id (#5534)
History sharing: improve efficiency of building key bundle

Signed-off-by: multi
[multiestunhappydev@gmail.com](mailto:multiestunhappydev@gmail.com)

Partially Implement
https://github.com/matrix-org/matrix-rust-sdk/issues/5513

---------

Signed-off-by: multisme <korokoko.toi@gmail.com>
Co-authored-by: Richard van der Hoff <richard@matrix.org>
2025-09-02 12:07:07 +01:00
Richard van der Hoff
a161dfa9a0 crypto: log message index for megolm sessions received over olm
When we receive a to-device message that contains a megolm decryption key, log
the ratchet index of the received key, for debugging.
2025-09-01 17:42:33 +01:00
Damir Jelić
1e30916754 chore: Bump most of our deps 2025-09-01 16:33:10 +02:00
Skye Elliot
99af951d7a feat(crypto): Add EncryptionSettings::encrypt_state_events
This will be used inside the WASM SDK to introduce a similar field to
its EncryptionSettings struct.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2025-08-28 14:00:23 +02:00
Skye Elliot
e44b01cbe5 feat(sdk): Support room key downloading using JsonCastable<EncryptedEvent>
Allows `Backups::maybe_download_room_key` to accept any T:
JsonCastable<EncryptedEvent>, which will be required for state events to
trigger fetching the room key.

Implements JsonCastable<EncryptedEvent> for
OriginalSyncStateRoomEncryptedEventContent.

Implements JsonCastable<AnyStateEvent> for RoomEncryptedEventContent.
2025-08-19 14:47:44 +01:00
Skye Elliot
13ee4c8098 tests(crypto): Document introduced tests and helper
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2025-08-19 10:17:14 +01:00
Skye Elliot
84ebbd913c feat: Add naive state key verification to OlmMachine
Modifies `OlmMachine::decrypt_room_event_inner` to call a new method
`OlmMachine::verify_packed_state_key` which, if the event is a state
event, verifies that the original event's state key, when unpacked,
matches the state key and event type in the decrypted event content.

Introduces MegolmError::StateKeyVerificationFailed and
UnableToDecryptReason::StateKeyVerificationFailed which are thrown when
the verification fails.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2025-08-18 15:56:48 +01:00
Skye Elliot
756d50737e feat(crypto): Add state event encryption methods to OlmMachine
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2025-08-18 15:56:45 +01:00
Skye Elliot
c32877284c feat(crypto): Add GroupSessionManager::encrypt_state
Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2025-08-18 15:56:44 +01:00
Skye Elliot
6260811ea5 feat(crypto): Add OutboundGroupSession::encrypt_state
This commit also refactors out what would be common code between
::encrypt and ::encrypt_state to a helper ::encrypt_inner.

Signed-off-by: Skye Elliot <actuallyori@gmail.com>
2025-08-18 15:56:38 +01:00
Skye Elliot
ae7f0fe022 feat: Experimental encrypted state feature flag with CI support (#5537)
This PR makes some non-domain-specific changes across multiple crates
that are required for proper testing of features implemented for #5397.

* Adds a `experimental-encrypted-state-events` feature flag across the
SDK.
* Introduces a feature set into xtask to ensure feature-gated tests are
run during CI.
* Minor fix to a test that would otherwise fail with the newly
introduced CI.
2025-08-15 12:54:41 +00:00
Skye Elliot
d9f4e7c426 Merge pull request #5511 from kaylendog/kaylendog/room-settings
feat(crypto): Add RoomSettings::encrypt_state_events
2025-08-14 15:51:19 +01:00
Skye Elliot
ca8b64e041 feat: Change type of DecryptedRoomEvent::event to Raw<AnyTimelineEvent> (#5512)
- [x] Change `DecryptedRoomEvent::event` to `Raw<AnyTimelineEvent>`
- [x] Update usages to pattern match on `AnyTimelineEvent::MessageLike`
where necessary

---------

Signed-off-by: kaylendog <actuallyori@gmail.com>
2025-08-14 08:53:56 +02:00
multisme
a66b2c5123 feat(test): add a test utils crate to make log initialization possible everywhere
This PR allows `init_tracing_for_test` to be called by any other crate in the sdk

Signed-off-by: multi [multiestunhappydev@gmail.com](mailto:multiestunhappydev@gmail.com)
2025-08-14 05:24:03 +00:00
Kévin Commaille
1cf3477ada feat(crypto): Implement Default for SecretStorageKey
For the new_without_default clippy lint.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-08-13 12:31:22 +01:00
Kévin Commaille
c586812159 refactor(crypto): Remove dead code
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-08-13 12:31:22 +01:00
Damir Jelić
6c944a9b39 Add a changelog entry for the sender data check when accepting historic room keys 2025-08-08 15:56:13 +02:00
Damir Jelić
536ba518bb feat(crypto): Check sender data before accepting room key bundles 2025-08-08 15:56:13 +02:00
Damir Jelić
360c2d7f32 refactor(crypto): Turn should_recalculate function into an associated function for SenderData
This allows us to use the function in more places where SenderData is
used.
2025-08-08 15:56:13 +02:00
Damir Jelić
139673810f Remember the public Curve25519 key of the sender of the historic room key bundle 2025-08-08 09:19:19 +02:00
Kévin Commaille
feb22d4370 Move serde functions to module and use #[serde(with = "")]
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-08-06 16:44:51 +02:00
Kévin Commaille
6520c9b16e Add changelog
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-08-06 16:44:51 +02:00
Kévin Commaille
cd6fe271ba refactor(crypto): Make deprecated sender_key and device_id optional in RoomEncryptedEventContent and RoomKeyRequestContent
They were deprecated in Matrix 1.3 and are now optional.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-08-06 16:44:51 +02:00
Kévin Commaille
787861eb35 fix: Upgrade Ruma
This brings 2 important bug fixes:

- Make deprecated fields of `m.room.encrypted` optional: it seems that there are events without these fields in the wild.
- Fix deserialization of `RedactedRoomJoinRulesEventContent`. This was found by a bug report in Fractal that caused the same error as #3557 when restoring the client. So maybe we could consider that this bug is fixed? It is still possible that there is another deserialization error. 

There is also a breaking change in the format of the `state` field in response to `GET /v3/sync`.
2025-08-05 16:04:34 +02:00
Hubert Chathi
a4da6ba7c8 Exclude insecure devices on Olm encryption (#5457)
Fixes the encrypting part of
https://github.com/matrix-org/matrix-rust-sdk/issues/4147

Probably easiest to review commit-by-commit

<!-- description of the changes in this PR -->

- [x] Public API changes documented in changelogs (optional)

<!-- Sign-off, if not part of the commits -->
<!-- See CONTRIBUTING.md if you don't know what this is -->
Signed-off-by:
2025-08-04 08:50:32 +01:00
Andy Balaam
def1fedea3 feat(crypto): Refuse to decrypt to-device messages from unverified devices (when in exclude insecure mode) 2025-07-24 15:08:13 +01:00
Andy Balaam
d061e7a5b2 refactor(tests): Pass decryption_settings in to send_and_receive_encrypted_to_device_test_helper
To allow passing in different values in future tests.
2025-07-24 15:08:13 +01:00
Andy Balaam
f4619c91d3 refactor(tests): Re-use send_and_receive_encrypted_to_device_test_helper in 2 more tests 2025-07-24 15:08:13 +01:00
Andy Balaam
227f6eab85 refactor(tests): Take a reference to content in send_and_receive_encrypted_to_device_test_helper
This will allow us to re-use it in more tests.
2025-07-24 15:08:13 +01:00
Andy Balaam
16d7c3c094 refactor(crypto): Extract a method to check for to-device events from dehydrated devices 2025-07-24 15:08:13 +01:00
Andy Balaam
c238a0edb8 refactor(crypto): Pass DecryptionSettings in to OlmMachine::decrypt_to_device_event
This will be used in the next commit, but it was very noisy, so I
separated it out into this commit to make the next one easier to read.
2025-07-24 15:08:13 +01:00
Kévin Commaille
4931c0749e Upgrade Ruma again
This patch updates our `Raw` API usage since the newly added `JsonCastable` that disallows Raw casts that are known to fail deserialization. 

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-07-22 12:59:26 +00:00
Kévin Commaille
37626b5ad9 Bump Ruma
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-07-22 14:00:53 +02:00
Kévin Commaille
1e568efbb5 refactor: Remove unnecessary Raw casting
The types are already correct so there is no need for casting.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-07-18 16:01:07 +02:00
Damir Jelić
18b169ca7e chore: Release matrix-sdk version 0.13.0 2025-07-10 15:15:04 +02:00
Tobias Fella
52090bb199 docs(crypto): Remove wrong statement about encryption keys for OlmMachine::with_store
When using this function, whether encryption keys are dropped depends on the crypto store implementation used.
2025-07-09 08:32:31 +02:00
Jonas Platte
07808b4301 refactor: Enable extra code style clippy lints 2025-07-05 21:20:34 +02:00
Andy Balaam
c2f50fd8a5 doc(crypto): Attempt to explain what handle_to_device_event does and make all types explicit 2025-07-01 11:25:03 +02:00
Damir Jelić
3c7683ea53 chore(sdk): Add a missing dot 2025-06-30 09:53:47 +02:00
Jonas Platte
3d642356c6 refactor: Clean up formatting in many places
Process:
- set style_edition to 2024 in .rustfmt.toml
- run `cargo fmt`
- undo .rustfmt.toml change
- run `cargo fmt` again
- manually rewrap some strings
2025-06-27 19:54:13 +02:00
Kévin Commaille
96119f9a30 crypto: Use Ord implementation of SequenceNumber for its PartialOrd implementation
Detected by lint clippy::non_canonical_partial_ord_impl.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-06-27 19:04:00 +02:00
Damir Jelić
737e06b581 Add a missing changelog entry for PR 5177 2025-06-27 14:54:21 +02:00
Damir Jelić
3a98d46bfa feat: Add a stream to listen for historic room key bundles 2025-06-26 13:22:24 +02:00
Damir Jelić
1558858bde chore: Add a TODO item reminding us that we should zeroize room key bundle contents 2025-06-26 13:22:24 +02:00
Damir Jelić
e4d2f62d48 docs: Document the store/types module properly 2025-06-26 12:11:16 +02:00
Andy Balaam
3c1d0b37e5 refactor(crypto): Provide a specific error type for to-device events from dehydrated devices
This will get more usage soon, when we add a variant for events with
unverified senders.
2025-06-25 12:05:14 +01:00
Richard van der Hoff
0722ed9d8f Indexeddb: support for received room key bundles
Add a new store to keep track of the information we have received about room
key bundles.
2025-06-25 10:26:11 +02:00