Merge branch 'typos'
commit
6f11244017
|
@ -40,7 +40,7 @@ async fn bootstrap(client: Client, user_id: UserId, password: String) {
|
||||||
.await
|
.await
|
||||||
.expect("Couldn't bootstrap cross signing")
|
.expect("Couldn't bootstrap cross signing")
|
||||||
} else {
|
} else {
|
||||||
panic!("Error durign cross signing bootstrap {:#?}", e);
|
panic!("Error during cross-signing bootstrap {:#?}", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -215,7 +215,7 @@ impl Handler {
|
||||||
|
|
||||||
pub(crate) async fn handle_stripped_state_event(
|
pub(crate) async fn handle_stripped_state_event(
|
||||||
&self,
|
&self,
|
||||||
// TODO these events are only handleted in invited rooms.
|
// TODO these events are only handled in invited rooms.
|
||||||
room: Room,
|
room: Room,
|
||||||
event: &AnyStrippedStateEvent,
|
event: &AnyStrippedStateEvent,
|
||||||
) {
|
) {
|
||||||
|
|
|
@ -12,7 +12,7 @@ use matrix_sdk_common::{
|
||||||
|
|
||||||
use crate::{BaseRoom, Client, Result, RoomMember};
|
use crate::{BaseRoom, Client, Result, RoomMember};
|
||||||
|
|
||||||
/// A struct containing methodes that are common for Joined, Invited and Left
|
/// A struct containing methods that are common for Joined, Invited and Left
|
||||||
/// Rooms
|
/// Rooms
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Common {
|
pub struct Common {
|
||||||
|
@ -55,7 +55,7 @@ impl Common {
|
||||||
/// Only invited and left rooms can be joined via this method
|
/// Only invited and left rooms can be joined via this method
|
||||||
pub(crate) async fn join(&self) -> Result<()> {
|
pub(crate) async fn join(&self) -> Result<()> {
|
||||||
let request = join_room_by_id::Request::new(self.inner.room_id());
|
let request = join_room_by_id::Request::new(self.inner.room_id());
|
||||||
let _resposne = self.client.send(request, None).await?;
|
let _response = self.client.send(request, None).await?;
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{room::Common, BaseRoom, Client, Result, RoomType};
|
||||||
|
|
||||||
/// A room in the invited state.
|
/// A room in the invited state.
|
||||||
///
|
///
|
||||||
/// This struct contains all methodes specific to a `Room` with type
|
/// This struct contains all methods specific to a `Room` with type
|
||||||
/// `RoomType::Invited`. Operations may fail once the underlying `Room` changes
|
/// `RoomType::Invited`. Operations may fail once the underlying `Room` changes
|
||||||
/// `RoomType`.
|
/// `RoomType`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -47,7 +47,7 @@ const TYPING_NOTICE_RESEND_TIMEOUT: Duration = Duration::from_secs(3);
|
||||||
|
|
||||||
/// A room in the joined state.
|
/// A room in the joined state.
|
||||||
///
|
///
|
||||||
/// The `JoinedRoom` contains all methodes specific to a `Room` with type
|
/// The `JoinedRoom` contains all methods specific to a `Room` with type
|
||||||
/// `RoomType::Joined`. Operations may fail once the underlying `Room` changes
|
/// `RoomType::Joined`. Operations may fail once the underlying `Room` changes
|
||||||
/// `RoomType`.
|
/// `RoomType`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -6,7 +6,7 @@ use crate::{room::Common, BaseRoom, Client, Result, RoomType};
|
||||||
|
|
||||||
/// A room in the left state.
|
/// A room in the left state.
|
||||||
///
|
///
|
||||||
/// This struct contains all methodes specific to a `Room` with type
|
/// This struct contains all methods specific to a `Room` with type
|
||||||
/// `RoomType::Left`. Operations may fail once the underlying `Room` changes
|
/// `RoomType::Left`. Operations may fail once the underlying `Room` changes
|
||||||
/// `RoomType`.
|
/// `RoomType`.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -137,7 +137,7 @@ impl Sas {
|
||||||
self.inner.is_cancelled()
|
self.inner.is_cancelled()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Get the other users device that we're veryfying.
|
/// Get the other users device that we're verifying.
|
||||||
pub fn other_device(&self) -> &ReadOnlyDevice {
|
pub fn other_device(&self) -> &ReadOnlyDevice {
|
||||||
self.inner.other_device()
|
self.inner.other_device()
|
||||||
}
|
}
|
||||||
|
|
|
@ -214,7 +214,7 @@ impl Appservice {
|
||||||
/// * `server_name` - The server name to use when constructing user ids from
|
/// * `server_name` - The server name to use when constructing user ids from
|
||||||
/// the localpart.
|
/// the localpart.
|
||||||
/// * `registration` - The [Appservice Registration] to use when interacting
|
/// * `registration` - The [Appservice Registration] to use when interacting
|
||||||
/// with the homserver.
|
/// with the homeserver.
|
||||||
///
|
///
|
||||||
/// [Appservice Registration]: https://matrix.org/docs/spec/application_service/r0.1.2#registration
|
/// [Appservice Registration]: https://matrix.org/docs/spec/application_service/r0.1.2#registration
|
||||||
pub async fn new(
|
pub async fn new(
|
||||||
|
|
|
@ -749,8 +749,8 @@ impl BaseClient {
|
||||||
|
|
||||||
if let Some(o) = &*olm {
|
if let Some(o) = &*olm {
|
||||||
// Let the crypto machine handle the sync response, this
|
// Let the crypto machine handle the sync response, this
|
||||||
// decryptes to-device events, but leaves room events alone.
|
// decrypts to-device events, but leaves room events alone.
|
||||||
// This makes sure that we have the deryption keys for the room
|
// This makes sure that we have the decryption keys for the room
|
||||||
// events at hand.
|
// events at hand.
|
||||||
o.receive_sync_changes(to_device, &device_lists, &device_one_time_keys_count)
|
o.receive_sync_changes(to_device, &device_lists, &device_one_time_keys_count)
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -46,7 +46,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
|
|
||||||
/// The underlying room data structure collecting state for joined, left and
|
/// The underlying room data structure collecting state for joined, left and
|
||||||
/// invtied rooms.
|
/// invited rooms.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Room {
|
pub struct Room {
|
||||||
room_id: Arc<RoomId>,
|
room_id: Arc<RoomId>,
|
||||||
|
@ -178,7 +178,7 @@ impl Room {
|
||||||
/// If this room is a direct message, get the member that we're sharing the
|
/// If this room is a direct message, get the member that we're sharing the
|
||||||
/// room with.
|
/// room with.
|
||||||
///
|
///
|
||||||
/// *Note*: The member list might have been moddified in the meantime and
|
/// *Note*: The member list might have been modified in the meantime and
|
||||||
/// the target might not even be in the room anymore. This setting should
|
/// the target might not even be in the room anymore. This setting should
|
||||||
/// only be considered as guidance.
|
/// only be considered as guidance.
|
||||||
pub fn direct_target(&self) -> Option<UserId> {
|
pub fn direct_target(&self) -> Option<UserId> {
|
||||||
|
|
|
@ -120,7 +120,7 @@ pub struct SyncResponse {
|
||||||
pub presence: Presence,
|
pub presence: Presence,
|
||||||
/// The global private data created by this user.
|
/// The global private data created by this user.
|
||||||
pub account_data: GlobalAccountData,
|
pub account_data: GlobalAccountData,
|
||||||
/// Messages sent dirrectly between devices.
|
/// Messages sent directly between devices.
|
||||||
pub to_device: ToDevice,
|
pub to_device: ToDevice,
|
||||||
/// Information on E2E device updates.
|
/// Information on E2E device updates.
|
||||||
///
|
///
|
||||||
|
@ -129,7 +129,7 @@ pub struct SyncResponse {
|
||||||
/// For each key algorithm, the number of unclaimed one-time keys
|
/// For each key algorithm, the number of unclaimed one-time keys
|
||||||
/// currently held on the server for a device.
|
/// currently held on the server for a device.
|
||||||
pub device_one_time_keys_count: BTreeMap<DeviceKeyAlgorithm, u64>,
|
pub device_one_time_keys_count: BTreeMap<DeviceKeyAlgorithm, u64>,
|
||||||
/// Collection of ambiguioty changes that room member events trigger.
|
/// Collection of ambiguity changes that room member events trigger.
|
||||||
pub ambiguity_changes: AmbiguityChanges,
|
pub ambiguity_changes: AmbiguityChanges,
|
||||||
/// New notifications per room.
|
/// New notifications per room.
|
||||||
pub notifications: BTreeMap<RoomId, Vec<Notification>>,
|
pub notifications: BTreeMap<RoomId, Vec<Notification>>,
|
||||||
|
@ -343,6 +343,6 @@ impl From<StrippedMemberEvent> for StrippedStateEvent<MemberEventContent> {
|
||||||
pub struct MembersResponse {
|
pub struct MembersResponse {
|
||||||
/// The list of members events.
|
/// The list of members events.
|
||||||
pub chunk: Vec<MemberEvent>,
|
pub chunk: Vec<MemberEvent>,
|
||||||
/// Collection of ambiguioty changes that room member events trigger.
|
/// Collection of ambiguity changes that room member events trigger.
|
||||||
pub ambiguity_changes: AmbiguityChanges,
|
pub ambiguity_changes: AmbiguityChanges,
|
||||||
}
|
}
|
||||||
|
|
|
@ -197,7 +197,7 @@ impl<'a, R: Read + 'a> AttachmentEncryptor<'a, R> {
|
||||||
let mut iv = Zeroizing::new([0u8; IV_SIZE]);
|
let mut iv = Zeroizing::new([0u8; IV_SIZE]);
|
||||||
|
|
||||||
getrandom(&mut *key).expect("Can't generate randomness");
|
getrandom(&mut *key).expect("Can't generate randomness");
|
||||||
// Only populate the the first 8 bits with randomness, the rest is 0
|
// Only populate the first 8 bits with randomness, the rest is 0
|
||||||
// initialized.
|
// initialized.
|
||||||
getrandom(&mut iv[0..8]).expect("Can't generate randomness");
|
getrandom(&mut iv[0..8]).expect("Can't generate randomness");
|
||||||
|
|
||||||
|
|
|
@ -115,7 +115,7 @@ pub fn decrypt_key_export(
|
||||||
///
|
///
|
||||||
/// * `rounds` - The number of rounds that should be used for the key
|
/// * `rounds` - The number of rounds that should be used for the key
|
||||||
/// derivation when the passphrase gets turned into an AES key. More rounds are
|
/// derivation when the passphrase gets turned into an AES key. More rounds are
|
||||||
/// increasingly computationally intensive and as such help against bruteforce
|
/// increasingly computationally intensive and as such help against brute-force
|
||||||
/// attacks. Should be at least `10000`, while values in the `100000` ranges
|
/// attacks. Should be at least `10000`, while values in the `100000` ranges
|
||||||
/// should be preferred.
|
/// should be preferred.
|
||||||
///
|
///
|
||||||
|
|
|
@ -385,7 +385,7 @@ impl ReadOnlyDevice {
|
||||||
// only the identity is trusted, if the identity and the device are
|
// only the identity is trusted, if the identity and the device are
|
||||||
// trusted.
|
// trusted.
|
||||||
if self.is_trusted() {
|
if self.is_trusted() {
|
||||||
// If the device is localy marked as verified just return so, no
|
// If the device is locally marked as verified just return so, no
|
||||||
// need to check signatures.
|
// need to check signatures.
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -320,7 +320,7 @@ impl IdentityManager {
|
||||||
|
|
||||||
/// Get a key query request if one is needed.
|
/// Get a key query request if one is needed.
|
||||||
///
|
///
|
||||||
/// Returns a key query reqeust if the client should query E2E keys,
|
/// Returns a key query request if the client should query E2E keys,
|
||||||
/// otherwise None.
|
/// otherwise None.
|
||||||
///
|
///
|
||||||
/// The response of a successful key query requests needs to be passed to
|
/// The response of a successful key query requests needs to be passed to
|
||||||
|
|
|
@ -38,7 +38,7 @@
|
||||||
//! additional public keys for other users, while it will give us access to all
|
//! additional public keys for other users, while it will give us access to all
|
||||||
//! 3 for our own user.
|
//! 3 for our own user.
|
||||||
//!
|
//!
|
||||||
//! Both identity sets need to reqularly fetched from the server using the
|
//! Both identity sets need to regularly fetched from the server using the
|
||||||
//! `/keys/query` API call.
|
//! `/keys/query` API call.
|
||||||
pub(crate) mod device;
|
pub(crate) mod device;
|
||||||
mod manager;
|
mod manager;
|
||||||
|
|
|
@ -161,7 +161,7 @@ impl OutgoingKeyRequest {
|
||||||
wrap_key_request_content(self.request_recipient.clone(), self.request_id, &content)
|
wrap_key_request_content(self.request_recipient.clone(), self.request_id, &content)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn to_cancelation(
|
fn to_cancellation(
|
||||||
&self,
|
&self,
|
||||||
own_device_id: &DeviceId,
|
own_device_id: &DeviceId,
|
||||||
) -> Result<OutgoingRequest, serde_json::Error> {
|
) -> Result<OutgoingRequest, serde_json::Error> {
|
||||||
|
@ -594,7 +594,7 @@ impl KeyRequestMachine {
|
||||||
let request = self.store.get_key_request_by_info(&key_info).await?;
|
let request = self.store.get_key_request_by_info(&key_info).await?;
|
||||||
|
|
||||||
if let Some(request) = request {
|
if let Some(request) = request {
|
||||||
let cancel = request.to_cancelation(self.device_id())?;
|
let cancel = request.to_cancellation(self.device_id())?;
|
||||||
let request = request.to_request(self.device_id())?;
|
let request = request.to_request(self.device_id())?;
|
||||||
|
|
||||||
Ok((Some(cancel), request))
|
Ok((Some(cancel), request))
|
||||||
|
@ -707,7 +707,7 @@ impl KeyRequestMachine {
|
||||||
|
|
||||||
/// Mark the given outgoing key info as done.
|
/// Mark the given outgoing key info as done.
|
||||||
///
|
///
|
||||||
/// This will queue up a request cancelation.
|
/// This will queue up a request cancellation.
|
||||||
async fn mark_as_done(&self, key_info: OutgoingKeyRequest) -> Result<(), CryptoStoreError> {
|
async fn mark_as_done(&self, key_info: OutgoingKeyRequest) -> Result<(), CryptoStoreError> {
|
||||||
// TODO perhaps only remove the key info if the first known index is 0.
|
// TODO perhaps only remove the key info if the first known index is 0.
|
||||||
trace!("Successfully received a forwarded room key for {:#?}", key_info);
|
trace!("Successfully received a forwarded room key for {:#?}", key_info);
|
||||||
|
@ -717,7 +717,7 @@ impl KeyRequestMachine {
|
||||||
// can delete it in one transaction.
|
// can delete it in one transaction.
|
||||||
self.delete_key_info(&key_info).await?;
|
self.delete_key_info(&key_info).await?;
|
||||||
|
|
||||||
let request = key_info.to_cancelation(self.device_id())?;
|
let request = key_info.to_cancellation(self.device_id())?;
|
||||||
self.outgoing_to_device_requests.insert(request.request_id, request);
|
self.outgoing_to_device_requests.insert(request.request_id, request);
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -1351,7 +1351,7 @@ mod test {
|
||||||
// Receive the room key request from alice.
|
// Receive the room key request from alice.
|
||||||
bob_machine.receive_incoming_key_request(&event);
|
bob_machine.receive_incoming_key_request(&event);
|
||||||
bob_machine.collect_incoming_key_requests().await.unwrap();
|
bob_machine.collect_incoming_key_requests().await.unwrap();
|
||||||
// Bob doens't have an outgoing requests since we're lacking a session.
|
// Bob doesn't have an outgoing requests since we're lacking a session.
|
||||||
assert!(bob_machine.outgoing_to_device_requests().await.unwrap().is_empty());
|
assert!(bob_machine.outgoing_to_device_requests().await.unwrap().is_empty());
|
||||||
assert!(!bob_machine.users_for_key_claim.is_empty());
|
assert!(!bob_machine.users_for_key_claim.is_empty());
|
||||||
assert!(!bob_machine.wait_queue.is_empty());
|
assert!(!bob_machine.wait_queue.is_empty());
|
||||||
|
|
|
@ -76,7 +76,7 @@ pub struct OlmMachine {
|
||||||
account: Account,
|
account: Account,
|
||||||
/// The private part of our cross signing identity.
|
/// The private part of our cross signing identity.
|
||||||
/// Used to sign devices and other users, might be missing if some other
|
/// Used to sign devices and other users, might be missing if some other
|
||||||
/// device bootstraped cross signing or cross signing isn't bootstrapped at
|
/// device bootstrapped cross signing or cross signing isn't bootstrapped at
|
||||||
/// all.
|
/// all.
|
||||||
user_identity: Arc<Mutex<PrivateCrossSigningIdentity>>,
|
user_identity: Arc<Mutex<PrivateCrossSigningIdentity>>,
|
||||||
/// Store for the encryption keys.
|
/// Store for the encryption keys.
|
||||||
|
@ -735,7 +735,7 @@ impl OlmMachine {
|
||||||
self.account.update_uploaded_key_count(key_count).await;
|
self.account.update_uploaded_key_count(key_count).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn handle_to_device_evnet(&self, event: &AnyToDeviceEvent) {
|
async fn handle_to_device_event(&self, event: &AnyToDeviceEvent) {
|
||||||
match event {
|
match event {
|
||||||
AnyToDeviceEvent::RoomKeyRequest(e) => {
|
AnyToDeviceEvent::RoomKeyRequest(e) => {
|
||||||
self.key_request_machine.receive_incoming_key_request(&e)
|
self.key_request_machine.receive_incoming_key_request(&e)
|
||||||
|
@ -771,7 +771,7 @@ impl OlmMachine {
|
||||||
/// response.
|
/// response.
|
||||||
///
|
///
|
||||||
/// * `changed_devices` - The list of devices that changed in this sync
|
/// * `changed_devices` - The list of devices that changed in this sync
|
||||||
/// resopnse.
|
/// response.
|
||||||
///
|
///
|
||||||
/// * `one_time_keys_count` - The current one-time keys counts that the sync
|
/// * `one_time_keys_count` - The current one-time keys counts that the sync
|
||||||
/// response returned.
|
/// response returned.
|
||||||
|
@ -855,12 +855,12 @@ impl OlmMachine {
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(event) = decrypted.deserialized_event {
|
if let Some(event) = decrypted.deserialized_event {
|
||||||
self.handle_to_device_evnet(&event).await;
|
self.handle_to_device_event(&event).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
raw_event = decrypted.event;
|
raw_event = decrypted.event;
|
||||||
}
|
}
|
||||||
e => self.handle_to_device_evnet(&e).await,
|
e => self.handle_to_device_event(&e).await,
|
||||||
}
|
}
|
||||||
|
|
||||||
events.push(raw_event);
|
events.push(raw_event);
|
||||||
|
@ -880,11 +880,11 @@ impl OlmMachine {
|
||||||
|
|
||||||
/// Request a room key from our devices.
|
/// Request a room key from our devices.
|
||||||
///
|
///
|
||||||
/// This method will return a request cancelation and a new key request if
|
/// This method will return a request cancellation and a new key request if
|
||||||
/// the key was already requested, otherwise it will return just the key
|
/// the key was already requested, otherwise it will return just the key
|
||||||
/// request.
|
/// request.
|
||||||
///
|
///
|
||||||
/// The request cancelation *must* be sent out before the request is sent
|
/// The request cancellation *must* be sent out before the request is sent
|
||||||
/// out, otherwise devices will ignore the key request.
|
/// out, otherwise devices will ignore the key request.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -942,7 +942,7 @@ impl OlmMachine {
|
||||||
algorithm_info: AlgorithmInfo::MegolmV1AesSha2 {
|
algorithm_info: AlgorithmInfo::MegolmV1AesSha2 {
|
||||||
curve25519_key: session.sender_key().to_owned(),
|
curve25519_key: session.sender_key().to_owned(),
|
||||||
sender_claimed_keys: session.signing_keys().to_owned(),
|
sender_claimed_keys: session.signing_keys().to_owned(),
|
||||||
forwarding_curve25519_key_chain: session.forwading_key_chain().to_vec(),
|
forwarding_curve25519_key_chain: session.forwarding_key_chain().to_vec(),
|
||||||
},
|
},
|
||||||
verification_state,
|
verification_state,
|
||||||
})
|
})
|
||||||
|
@ -1167,7 +1167,7 @@ impl OlmMachine {
|
||||||
///
|
///
|
||||||
/// * `predicate` - A closure that will be called for every known
|
/// * `predicate` - A closure that will be called for every known
|
||||||
/// `InboundGroupSession`, which represents a room key. If the closure
|
/// `InboundGroupSession`, which represents a room key. If the closure
|
||||||
/// returns `true` the `InboundGroupSessoin` will be included in the export,
|
/// returns `true` the `InboundGroupSession` will be included in the export,
|
||||||
/// if the closure returns `false` it will not be included.
|
/// if the closure returns `false` it will not be included.
|
||||||
///
|
///
|
||||||
/// # Panics
|
/// # Panics
|
||||||
|
@ -1318,10 +1318,10 @@ pub(crate) mod test {
|
||||||
let alice_device = alice_device_id();
|
let alice_device = alice_device_id();
|
||||||
let alice = OlmMachine::new(&alice_id, &alice_device);
|
let alice = OlmMachine::new(&alice_id, &alice_device);
|
||||||
|
|
||||||
let alice_deivce = ReadOnlyDevice::from_machine(&alice).await;
|
let alice_device = ReadOnlyDevice::from_machine(&alice).await;
|
||||||
let bob_device = ReadOnlyDevice::from_machine(&bob).await;
|
let bob_device = ReadOnlyDevice::from_machine(&bob).await;
|
||||||
alice.store.save_devices(&[bob_device]).await.unwrap();
|
alice.store.save_devices(&[bob_device]).await.unwrap();
|
||||||
bob.store.save_devices(&[alice_deivce]).await.unwrap();
|
bob.store.save_devices(&[alice_device]).await.unwrap();
|
||||||
|
|
||||||
(alice, bob, otk)
|
(alice, bob, otk)
|
||||||
}
|
}
|
||||||
|
|
|
@ -99,7 +99,7 @@ pub struct OlmDecryptionInfo {
|
||||||
pub inbound_group_session: Option<InboundGroupSession>,
|
pub inbound_group_session: Option<InboundGroupSession>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A hash of a succesfully decrypted Olm message.
|
/// A hash of a successfully decrypted Olm message.
|
||||||
///
|
///
|
||||||
/// Can be used to check if a message has been replayed to us.
|
/// Can be used to check if a message has been replayed to us.
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
@ -378,11 +378,11 @@ impl Account {
|
||||||
// TODO make the errors a bit more specific.
|
// TODO make the errors a bit more specific.
|
||||||
let decrypted_json: Value = serde_json::from_str(&plaintext)?;
|
let decrypted_json: Value = serde_json::from_str(&plaintext)?;
|
||||||
|
|
||||||
let encrytped_sender = decrypted_json
|
let encrypted_sender = decrypted_json
|
||||||
.get("sender")
|
.get("sender")
|
||||||
.cloned()
|
.cloned()
|
||||||
.ok_or_else(|| EventError::MissingField("sender".to_string()))?;
|
.ok_or_else(|| EventError::MissingField("sender".to_string()))?;
|
||||||
let encrytped_sender: UserId = serde_json::from_value(encrytped_sender)?;
|
let encrypted_sender: UserId = serde_json::from_value(encrypted_sender)?;
|
||||||
let recipient = decrypted_json
|
let recipient = decrypted_json
|
||||||
.get("recipient")
|
.get("recipient")
|
||||||
.cloned()
|
.cloned()
|
||||||
|
@ -402,7 +402,7 @@ impl Account {
|
||||||
.ok_or_else(|| EventError::MissingField("keys".to_string()))?,
|
.ok_or_else(|| EventError::MissingField("keys".to_string()))?,
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if &recipient != self.user_id() || sender != &encrytped_sender {
|
if &recipient != self.user_id() || sender != &encrypted_sender {
|
||||||
return Err(EventError::MissmatchedSender.into());
|
return Err(EventError::MissmatchedSender.into());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,9 +42,9 @@ use zeroize::Zeroizing;
|
||||||
use super::{ExportedGroupSessionKey, ExportedRoomKey, GroupSessionKey};
|
use super::{ExportedGroupSessionKey, ExportedRoomKey, GroupSessionKey};
|
||||||
use crate::error::{EventError, MegolmResult};
|
use crate::error::{EventError, MegolmResult};
|
||||||
|
|
||||||
// TODO add creation times to the inbound grop sessions so we can export
|
// TODO add creation times to the inbound group sessions so we can export
|
||||||
// sessions that were created between some time period, this should only be set
|
// sessions that were created between some time period, this should only be set
|
||||||
// for non-imported sessoins.
|
// for non-imported sessions.
|
||||||
|
|
||||||
/// Inbound group session.
|
/// Inbound group session.
|
||||||
///
|
///
|
||||||
|
@ -172,7 +172,7 @@ impl InboundGroupSession {
|
||||||
sender_key: self.sender_key.to_string(),
|
sender_key: self.sender_key.to_string(),
|
||||||
signing_key: (&*self.signing_keys).clone(),
|
signing_key: (&*self.signing_keys).clone(),
|
||||||
room_id: (&*self.room_id).clone(),
|
room_id: (&*self.room_id).clone(),
|
||||||
forwarding_chains: self.forwading_key_chain().to_vec(),
|
forwarding_chains: self.forwarding_key_chain().to_vec(),
|
||||||
imported: *self.imported,
|
imported: *self.imported,
|
||||||
history_visibility: self.history_visibility.as_ref().clone(),
|
history_visibility: self.history_visibility.as_ref().clone(),
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ impl InboundGroupSession {
|
||||||
/// Each ed25519 key represents a single device. If device A forwards the
|
/// Each ed25519 key represents a single device. If device A forwards the
|
||||||
/// session to device B and device B to C this list will contain the ed25519
|
/// session to device B and device B to C this list will contain the ed25519
|
||||||
/// keys of A and B.
|
/// keys of A and B.
|
||||||
pub fn forwading_key_chain(&self) -> &[String] {
|
pub fn forwarding_key_chain(&self) -> &[String] {
|
||||||
&self.forwarding_chains
|
&self.forwarding_chains
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ impl InboundGroupSession {
|
||||||
room_id: (&*self.room_id).clone(),
|
room_id: (&*self.room_id).clone(),
|
||||||
sender_key: (&*self.sender_key).to_owned(),
|
sender_key: (&*self.sender_key).to_owned(),
|
||||||
session_id: self.session_id().to_owned(),
|
session_id: self.session_id().to_owned(),
|
||||||
forwarding_curve25519_key_chain: self.forwading_key_chain().to_vec(),
|
forwarding_curve25519_key_chain: self.forwarding_key_chain().to_vec(),
|
||||||
sender_claimed_keys: (&*self.signing_keys).clone(),
|
sender_claimed_keys: (&*self.signing_keys).clone(),
|
||||||
session_key,
|
session_key,
|
||||||
}
|
}
|
||||||
|
@ -361,10 +361,10 @@ pub struct PickledInboundGroupSession {
|
||||||
/// The id of the room that the session is used in.
|
/// The id of the room that the session is used in.
|
||||||
pub room_id: RoomId,
|
pub room_id: RoomId,
|
||||||
/// The list of claimed ed25519 that forwarded us this key. Will be None if
|
/// The list of claimed ed25519 that forwarded us this key. Will be None if
|
||||||
/// we dirrectly received this session.
|
/// we directly received this session.
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
pub forwarding_chains: Vec<String>,
|
pub forwarding_chains: Vec<String>,
|
||||||
/// Flag remembering if the session was dirrectly sent to us by the sender
|
/// Flag remembering if the session was directly sent to us by the sender
|
||||||
/// or if it was imported.
|
/// or if it was imported.
|
||||||
pub imported: bool,
|
pub imported: bool,
|
||||||
/// History visibility of the room when the session was created.
|
/// History visibility of the room when the session was created.
|
||||||
|
|
|
@ -53,7 +53,7 @@ where
|
||||||
let now = Instant::now();
|
let now = Instant::now();
|
||||||
let instant = now
|
let instant = now
|
||||||
.checked_sub(duration)
|
.checked_sub(duration)
|
||||||
.ok_or_else(|| serde::de::Error::custom("Can't substract the the current instant"))?;
|
.ok_or_else(|| serde::de::Error::custom("Can't subtract the current instant"))?;
|
||||||
Ok(instant)
|
Ok(instant)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -265,8 +265,8 @@ pub struct PickledSession {
|
||||||
pub struct SessionPickle(String);
|
pub struct SessionPickle(String);
|
||||||
|
|
||||||
impl From<String> for SessionPickle {
|
impl From<String> for SessionPickle {
|
||||||
fn from(picle_string: String) -> Self {
|
fn from(pickle_string: String) -> Self {
|
||||||
SessionPickle(picle_string)
|
SessionPickle(pickle_string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -503,7 +503,7 @@ impl GroupSessionManager {
|
||||||
.collect();
|
.collect();
|
||||||
|
|
||||||
for result in join_all(tasks).await {
|
for result in join_all(tasks).await {
|
||||||
let used_sessions: OlmResult<Vec<Session>> = result.expect("Encryption task paniced");
|
let used_sessions: OlmResult<Vec<Session>> = result.expect("Encryption task panicked");
|
||||||
|
|
||||||
changes.sessions.extend(used_sessions?);
|
changes.sessions.extend(used_sessions?);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ impl SessionStore {
|
||||||
|
|
||||||
/// Add a session to the store.
|
/// Add a session to the store.
|
||||||
///
|
///
|
||||||
/// Returns true if the the session was added, false if the session was
|
/// Returns true if the session was added, false if the session was
|
||||||
/// already in the store.
|
/// already in the store.
|
||||||
pub async fn add(&self, session: Session) -> bool {
|
pub async fn add(&self, session: Session) -> bool {
|
||||||
let sessions_lock = self
|
let sessions_lock = self
|
||||||
|
@ -89,7 +89,7 @@ impl GroupSessionStore {
|
||||||
|
|
||||||
/// Add an inbound group session to the store.
|
/// Add an inbound group session to the store.
|
||||||
///
|
///
|
||||||
/// Returns true if the the session was added, false if the session was
|
/// Returns true if the session was added, false if the session was
|
||||||
/// already in the store.
|
/// already in the store.
|
||||||
pub fn add(&self, session: InboundGroupSession) -> bool {
|
pub fn add(&self, session: InboundGroupSession) -> bool {
|
||||||
self.entries
|
self.entries
|
||||||
|
|
|
@ -279,7 +279,7 @@ pub enum CryptoStoreError {
|
||||||
#[error("An object failed to be decrypted while unpickling")]
|
#[error("An object failed to be decrypted while unpickling")]
|
||||||
UnpicklingError,
|
UnpicklingError,
|
||||||
|
|
||||||
/// A Matirx identifier failed to be validated.
|
/// A Matrix identifier failed to be validated.
|
||||||
#[error(transparent)]
|
#[error(transparent)]
|
||||||
IdentifierValidation(#[from] IdentifierValidationError),
|
IdentifierValidation(#[from] IdentifierValidationError),
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ pub trait CryptoStore: AsyncTraitDeps {
|
||||||
/// Get all the inbound group sessions we have stored.
|
/// Get all the inbound group sessions we have stored.
|
||||||
async fn get_inbound_group_sessions(&self) -> Result<Vec<InboundGroupSession>>;
|
async fn get_inbound_group_sessions(&self) -> Result<Vec<InboundGroupSession>>;
|
||||||
|
|
||||||
/// Get the outobund group sessions we have stored that is used for the
|
/// Get the outbound group sessions we have stored that is used for the
|
||||||
/// given room.
|
/// given room.
|
||||||
async fn get_outbound_group_sessions(
|
async fn get_outbound_group_sessions(
|
||||||
&self,
|
&self,
|
||||||
|
@ -399,7 +399,7 @@ pub trait CryptoStore: AsyncTraitDeps {
|
||||||
/// Check if a hash for an Olm message stored in the database.
|
/// Check if a hash for an Olm message stored in the database.
|
||||||
async fn is_message_known(&self, message_hash: &OlmMessageHash) -> Result<bool>;
|
async fn is_message_known(&self, message_hash: &OlmMessageHash) -> Result<bool>;
|
||||||
|
|
||||||
/// Get an outoing key request that we created that matches the given
|
/// Get an outgoing key request that we created that matches the given
|
||||||
/// request id.
|
/// request id.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -411,7 +411,7 @@ pub trait CryptoStore: AsyncTraitDeps {
|
||||||
request_id: Uuid,
|
request_id: Uuid,
|
||||||
) -> Result<Option<OutgoingKeyRequest>>;
|
) -> Result<Option<OutgoingKeyRequest>>;
|
||||||
|
|
||||||
/// Get an outoing key request that we created that matches the given
|
/// Get an outgoing key request that we created that matches the given
|
||||||
/// requested key info.
|
/// requested key info.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
@ -425,7 +425,7 @@ pub trait CryptoStore: AsyncTraitDeps {
|
||||||
/// Get all outgoing key requests that we have in the store.
|
/// Get all outgoing key requests that we have in the store.
|
||||||
async fn get_unsent_key_requests(&self) -> Result<Vec<OutgoingKeyRequest>>;
|
async fn get_unsent_key_requests(&self) -> Result<Vec<OutgoingKeyRequest>>;
|
||||||
|
|
||||||
/// Delete an outoing key request that we created that matches the given
|
/// Delete an outgoing key request that we created that matches the given
|
||||||
/// request id.
|
/// request id.
|
||||||
///
|
///
|
||||||
/// # Arguments
|
/// # Arguments
|
||||||
|
|
|
@ -167,7 +167,7 @@ impl VerificationMachine {
|
||||||
return Ok(());
|
return Ok(());
|
||||||
};
|
};
|
||||||
|
|
||||||
let flow_id_missmatch = || {
|
let flow_id_mismatch = || {
|
||||||
warn!(
|
warn!(
|
||||||
sender = event.sender().as_str(),
|
sender = event.sender().as_str(),
|
||||||
flow_id = flow_id.as_str(),
|
flow_id = flow_id.as_str(),
|
||||||
|
@ -215,7 +215,7 @@ impl VerificationMachine {
|
||||||
// TODO remove this unwrap.
|
// TODO remove this unwrap.
|
||||||
request.receive_ready(event.sender(), c).unwrap();
|
request.receive_ready(event.sender(), c).unwrap();
|
||||||
} else {
|
} else {
|
||||||
flow_id_missmatch();
|
flow_id_mismatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -224,7 +224,7 @@ impl VerificationMachine {
|
||||||
if request.flow_id() == &flow_id {
|
if request.flow_id() == &flow_id {
|
||||||
request.receive_start(event.sender(), &c).await?
|
request.receive_start(event.sender(), &c).await?
|
||||||
} else {
|
} else {
|
||||||
flow_id_missmatch();
|
flow_id_mismatch();
|
||||||
}
|
}
|
||||||
} else if let FlowId::ToDevice(_) = flow_id {
|
} else if let FlowId::ToDevice(_) = flow_id {
|
||||||
// TODO remove this soon, this has been deprecated by
|
// TODO remove this soon, this has been deprecated by
|
||||||
|
@ -268,7 +268,7 @@ impl VerificationMachine {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
flow_id_missmatch();
|
flow_id_mismatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -281,7 +281,7 @@ impl VerificationMachine {
|
||||||
self.mark_sas_as_done(s, content).await?;
|
self.mark_sas_as_done(s, content).await?;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
flow_id_missmatch();
|
flow_id_mismatch();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -484,7 +484,7 @@ impl RequestState<Requested> {
|
||||||
flow_id: &FlowId,
|
flow_id: &FlowId,
|
||||||
content: &RequestContent,
|
content: &RequestContent,
|
||||||
) -> RequestState<Requested> {
|
) -> RequestState<Requested> {
|
||||||
// TODO only create this if we suport the methods
|
// TODO only create this if we support the methods
|
||||||
RequestState {
|
RequestState {
|
||||||
account,
|
account,
|
||||||
private_cross_signing_identity: private_identity,
|
private_cross_signing_identity: private_identity,
|
||||||
|
@ -617,7 +617,7 @@ impl RequestState<Ready> {
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
m => {
|
m => {
|
||||||
warn!(method =? m, "Received a key verificaton start event with an unsupported method")
|
warn!(method =? m, "Received a key verification start event with an unsupported method")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -274,7 +274,7 @@ pub struct MacReceived {
|
||||||
|
|
||||||
/// The SAS state we're going to be in after we receive a MAC event in a DM. DMs
|
/// The SAS state we're going to be in after we receive a MAC event in a DM. DMs
|
||||||
/// require a final message `m.key.verification.done` message to conclude the
|
/// require a final message `m.key.verification.done` message to conclude the
|
||||||
/// verificaton. This state waits for such a message.
|
/// verification. This state waits for such a message.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct WaitingForDone {
|
pub struct WaitingForDone {
|
||||||
verified_devices: Arc<[ReadOnlyDevice]>,
|
verified_devices: Arc<[ReadOnlyDevice]>,
|
||||||
|
|
Loading…
Reference in New Issue