crypto: Expose the trust state of our devices

This commit is contained in:
Damir Jelić 2021-06-24 13:57:13 +02:00
parent 6649aaca2e
commit 6a79d022c3
5 changed files with 22 additions and 3 deletions

View File

@ -0,0 +1,2 @@
package org.matrix.android.sdk.internal.crypto

View File

@ -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]

View File

@ -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<InnerDevice> for Device {
@ -34,6 +39,8 @@ impl From<InnerDevice> 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(),
}
}
}

View File

@ -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<CancelCode>,
pub can_be_presented: bool,
pub supports_emoji: bool,
pub timed_out: bool,
@ -73,6 +75,8 @@ impl From<InnerSas> 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<InnerVerificationRequest> 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

View File

@ -61,6 +61,8 @@ dictionary Device {
sequence<string> 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;