Skip to content

Commit 1370cd6

Browse files
committed
feat(crypto): Add RoomSettings::encrypt_state_events and feature gate
Signed-off-by: Skye Elliot <[email protected]>
1 parent 6c944a9 commit 1370cd6

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

crates/matrix-sdk-crypto/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ rustdoc-args = ["--cfg", "docsrs", "--generate-link-to-definition"]
1818
default = []
1919
automatic-room-key-forwarding = []
2020
experimental-send-custom-to-device = []
21+
experimental-encrypted-state-events = []
2122
js = ["ruma/js", "vodozemac/js", "matrix-sdk-common/js"]
2223
qrcode = ["dep:matrix-sdk-qrcode"]
2324
experimental-algorithms = []

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ async fn test_stores_and_returns_room_settings() {
2323

2424
let settings = RoomSettings {
2525
algorithm: EventEncryptionAlgorithm::MegolmV1AesSha2,
26+
#[cfg(feature = "experimental-encrypted-state-events")]
27+
encrypt_state_events: false,
2628
only_allow_trusted_devices: true,
2729
session_rotation_period: Some(Duration::from_secs(10)),
2830
session_rotation_period_messages: Some(1234),

crates/matrix-sdk-crypto/src/store/integration_tests.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1163,6 +1163,8 @@ macro_rules! cryptostore_integration_tests {
11631163
let room_1 = room_id!("!test_1:localhost");
11641164
let settings_1 = RoomSettings {
11651165
algorithm: EventEncryptionAlgorithm::MegolmV1AesSha2,
1166+
#[cfg(feature = "experimental-encrypted-state-events")]
1167+
encrypt_state_events: false,
11661168
only_allow_trusted_devices: true,
11671169
session_rotation_period: Some(Duration::from_secs(10)),
11681170
session_rotation_period_messages: Some(123),

crates/matrix-sdk-crypto/src/store/types.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,6 +414,11 @@ pub struct RoomSettings {
414414
/// The encryption algorithm that should be used in the room.
415415
pub algorithm: EventEncryptionAlgorithm,
416416

417+
/// Whether state event encryption is enabled.
418+
#[cfg(feature = "experimental-encrypted-state-events")]
419+
#[serde(default)]
420+
pub encrypt_state_events: bool,
421+
417422
/// Should untrusted devices receive the room key, or should they be
418423
/// excluded from the conversation.
419424
pub only_allow_trusted_devices: bool,
@@ -431,6 +436,8 @@ impl Default for RoomSettings {
431436
fn default() -> Self {
432437
Self {
433438
algorithm: EventEncryptionAlgorithm::MegolmV1AesSha2,
439+
#[cfg(feature = "experimental-encrypted-state-events")]
440+
encrypt_state_events: false,
434441
only_allow_trusted_devices: false,
435442
session_rotation_period: None,
436443
session_rotation_period_messages: None,

0 commit comments

Comments
 (0)