From 6a79d022c35723a6869129d4ccd74a9f35820d8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 24 Jun 2021 13:57:13 +0200 Subject: [PATCH] crypto: Expose the trust state of our devices --- .../android/sdk/internal/crypto/RustSasVerification.kt | 2 ++ rust-sdk/Cargo.toml | 6 ++++-- rust-sdk/src/device.rs | 7 +++++++ rust-sdk/src/machine.rs | 6 +++++- rust-sdk/src/olm.udl | 4 ++++ 5 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustSasVerification.kt diff --git a/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustSasVerification.kt b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustSasVerification.kt new file mode 100644 index 0000000000..4ae9ccbcc0 --- /dev/null +++ b/matrix-sdk-android/src/main/java/org/matrix/android/sdk/internal/crypto/RustSasVerification.kt @@ -0,0 +1,2 @@ +package org.matrix.android.sdk.internal.crypto + diff --git a/rust-sdk/Cargo.toml b/rust-sdk/Cargo.toml index a311211950..86e3645dab 100644 --- a/rust-sdk/Cargo.toml +++ b/rust-sdk/Cargo.toml @@ -23,10 +23,12 @@ version = "0.2.0" features = ["lax_deserialize"] [dependencies.matrix-sdk-common] -version = "0.3.0" +git = "https://github.com/matrix-org/matrix-rust-sdk/" +rev = "43583c292644e0e9bdaa6c83b2af35721416a263" [dependencies.matrix-sdk-crypto] -version = "0.3.0" +git = "https://github.com/matrix-org/matrix-rust-sdk/" +rev = "43583c292644e0e9bdaa6c83b2af35721416a263" features = ["sled_cryptostore"] [dependencies.tokio] diff --git a/rust-sdk/src/device.rs b/rust-sdk/src/device.rs index 606db76d61..5aa36bd5bb 100644 --- a/rust-sdk/src/device.rs +++ b/rust-sdk/src/device.rs @@ -19,6 +19,11 @@ pub struct Device { /// A flag indicating if the device has been blocked, blocked devices don't /// receive any room keys from us. pub is_blocked: bool, + /// Is the device locally trusted + pub locally_trusted: bool, + /// Is our cross signing identity trusted and does the identity trust the + /// device. + pub cross_signing_trusted: bool, } impl From for Device { @@ -34,6 +39,8 @@ impl From for Device { algorithms: d.algorithms().iter().map(|a| a.to_string()).collect(), display_name: d.display_name().clone(), is_blocked: d.is_blacklisted(), + locally_trusted: d.is_locally_trusted(), + cross_signing_trusted: d.is_cross_signing_trusted(), } } } diff --git a/rust-sdk/src/machine.rs b/rust-sdk/src/machine.rs index 47dd74c95b..a730884d28 100644 --- a/rust-sdk/src/machine.rs +++ b/rust-sdk/src/machine.rs @@ -50,8 +50,10 @@ pub struct Sas { pub other_user_id: String, pub other_device_id: String, pub flow_id: String, + pub have_we_confirmed: bool, pub is_cancelled: bool, pub is_done: bool, + pub cancel_code: Option, pub can_be_presented: bool, pub supports_emoji: bool, pub timed_out: bool, @@ -73,6 +75,8 @@ impl From for Sas { can_be_presented: sas.can_be_presented(), timed_out: sas.timed_out(), supports_emoji: sas.supports_emoji(), + have_we_confirmed: sas.have_we_confirmed(), + cancel_code: sas.cancel_code().map(|c| c.into()), } } } @@ -102,7 +106,7 @@ impl From for VerificationRequest { is_done: v.is_done(), is_ready: v.is_ready(), room_id: v.room_id().map(|r| r.to_string()), - cancel_code: v.cancel_code().map(|c| c.clone().into()), + cancel_code: v.cancel_code().map(|c| c.into()), we_started: v.we_started(), is_passive: v.is_passive(), their_methods: v diff --git a/rust-sdk/src/olm.udl b/rust-sdk/src/olm.udl index 0986c87450..fb17755e8d 100644 --- a/rust-sdk/src/olm.udl +++ b/rust-sdk/src/olm.udl @@ -61,6 +61,8 @@ dictionary Device { sequence algorithms; string? display_name; boolean is_blocked; + boolean locally_trusted; + boolean cross_signing_trusted; }; dictionary StartSasResult { @@ -72,6 +74,8 @@ dictionary Sas { string other_user_id; string other_device_id; string flow_id; + CancelCode? cancel_code; + boolean have_we_confirmed; boolean is_done; boolean is_cancelled; boolean can_be_presented;