Skip to content

Commit 6464d21

Browse files
andybalaampoljar
andauthored
crypto: Storage changes for keeping sender data with InboundGroupSessions (#3556)
Signed-off-by: Andy Balaam <[email protected]> Co-authored-by: Damir Jelić <[email protected]>
1 parent cb4c575 commit 6464d21

File tree

15 files changed

+397
-20
lines changed

15 files changed

+397
-20
lines changed

.typos.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,5 @@ extend-exclude = [
3636
"crates/matrix-sdk-ui/tests/integration/room_list_service.rs",
3737
# Hand-crafted base64 session keys that are understood as typos.
3838
"crates/matrix-sdk-indexeddb/src/crypto_store/migrations/mod.rs",
39+
"crates/matrix-sdk-crypto/src/olm/group_sessions/inbound.rs",
3940
]

bindings/matrix-sdk-crypto-ffi/src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ pub use logger::{set_logger, Logger};
3535
pub use machine::{KeyRequestPair, OlmMachine, SignatureVerification};
3636
use matrix_sdk_common::deserialized_responses::ShieldState as RustShieldState;
3737
use matrix_sdk_crypto::{
38-
olm::{IdentityKeys, InboundGroupSession, Session},
38+
olm::{IdentityKeys, InboundGroupSession, SenderData, Session},
3939
store::{Changes, CryptoStore, PendingChanges, RoomSettings as RustRoomSettings},
4040
types::{
4141
DeviceKey, DeviceKeys, EventEncryptionAlgorithm as RustEventEncryptionAlgorithm, SigningKey,
@@ -501,6 +501,7 @@ fn collect_sessions(
501501
Ok((algorithm, key))
502502
})
503503
.collect::<anyhow::Result<_>>()?,
504+
sender_data: SenderData::legacy(),
504505
room_id: RoomId::parse(session.room_id)?,
505506
imported: session.imported,
506507
backed_up: session.backed_up,

crates/matrix-sdk-crypto/src/machine.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ use crate::{
6666
identities::{user::UserIdentities, Device, IdentityManager, UserDevices},
6767
olm::{
6868
Account, CrossSigningStatus, EncryptionSettings, IdentityKeys, InboundGroupSession,
69-
OlmDecryptionInfo, PrivateCrossSigningIdentity, SessionType, StaticAccountData,
69+
OlmDecryptionInfo, PrivateCrossSigningIdentity, SenderData, SessionType, StaticAccountData,
7070
},
7171
requests::{IncomingResponse, OutgoingRequest, UploadSigningKeysRequest},
7272
session_manager::{GroupSessionManager, SessionManager},
@@ -816,11 +816,14 @@ impl OlmMachine {
816816
event: &DecryptedRoomKeyEvent,
817817
content: &MegolmV1AesSha2Content,
818818
) -> OlmResult<Option<InboundGroupSession>> {
819+
let sender_data = SenderData::unknown();
820+
819821
let session = InboundGroupSession::new(
820822
sender_key,
821823
event.keys.ed25519,
822824
&content.room_id,
823825
&content.session_key,
826+
sender_data,
824827
event.content.algorithm(),
825828
None,
826829
);
@@ -2417,7 +2420,8 @@ pub(crate) mod tests {
24172420
error::{EventError, SetRoomSettingsError},
24182421
machine::{EncryptionSyncChanges, OlmMachine},
24192422
olm::{
2420-
BackedUpRoomKey, ExportedRoomKey, InboundGroupSession, OutboundGroupSession, VerifyJson,
2423+
BackedUpRoomKey, ExportedRoomKey, InboundGroupSession, OutboundGroupSession,
2424+
SenderData, VerifyJson,
24212425
},
24222426
session_manager::CollectStrategy,
24232427
store::{BackupDecryptionKey, Changes, CryptoStore, MemoryStore, RoomSettings},
@@ -3713,6 +3717,7 @@ pub(crate) mod tests {
37133717
Ed25519PublicKey::from_base64("loz5i40dP+azDtWvsD0L/xpnCjNkmrcvtXVXzCHX8Vw").unwrap(),
37143718
fake_room_id,
37153719
&olm,
3720+
SenderData::unknown(),
37163721
EventEncryptionAlgorithm::MegolmV1AesSha2,
37173722
None,
37183723
)
@@ -3730,6 +3735,7 @@ pub(crate) mod tests {
37303735
Ed25519PublicKey::from_base64("48f3WQAMGwYLBg5M5qUhqnEVA8yeibjZpPsShoWMFT8").unwrap(),
37313736
fake_room_id,
37323737
&olm,
3738+
SenderData::unknown(),
37333739
EventEncryptionAlgorithm::MegolmV1AesSha2,
37343740
None,
37353741
)

crates/matrix-sdk-crypto/src/olm/account.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ use crate::{
6161
dehydrated_devices::DehydrationError,
6262
error::{EventError, OlmResult, SessionCreationError},
6363
identities::ReadOnlyDevice,
64+
olm::SenderData,
6465
requests::UploadSigningKeysRequest,
6566
store::{Changes, DeviceChanges, Store},
6667
types::{
@@ -220,6 +221,7 @@ impl StaticAccountData {
220221
signing_key,
221222
room_id,
222223
&outbound.session_key().await,
224+
SenderData::unknown(),
223225
algorithm,
224226
Some(visibility),
225227
)?;

0 commit comments

Comments
 (0)