diff --git a/src/crypto/machine.rs b/src/crypto/machine.rs index b3ace511..16089ed2 100644 --- a/src/crypto/machine.rs +++ b/src/crypto/machine.rs @@ -20,8 +20,7 @@ use std::result::Result as StdResult; use std::sync::Arc; use super::error::{OlmError, Result, SignatureError, VerificationResult}; -use super::memory_stores::SessionStore; -use super::olm::{Account, InboundGroupSession, Session}; +use super::olm::{Account, InboundGroupSession}; use super::store::memorystore::MemoryStore; #[cfg(feature = "sqlite-cryptostore")] use super::store::sqlite::SqliteStore; @@ -364,15 +363,16 @@ impl OlmMachine { continue; } - let curve_key_id = - AlgorithmAndDeviceId(KeyAlgorithm::Curve25519, device_id.to_owned()); + // let curve_key_id = + // AlgorithmAndDeviceId(KeyAlgorithm::Curve25519, device_id.to_owned()); let ed_key_id = AlgorithmAndDeviceId(KeyAlgorithm::Ed25519, device_id.to_owned()); - let sender_key = if let Some(k) = device_keys.keys.get(&curve_key_id) { - k - } else { - continue; - }; + // TODO check if the curve key changed for an existing device. + // let sender_key = if let Some(k) = device_keys.keys.get(&curve_key_id) { + // k + // } else { + // continue; + // }; let signing_key = if let Some(k) = device_keys.keys.get(&ed_key_id) { k @@ -397,7 +397,7 @@ impl OlmMachine { .await .expect("Can't load device"); - if let Some(d) = device { + if let Some(_d) = device { // TODO check what and if anything changed for the device. } else { let device = Device::from(device_keys); @@ -412,7 +412,7 @@ impl OlmMachine { let deleted_devices = stored_devices_set.difference(¤t_devices); - for device_id in deleted_devices { + for _device_id in deleted_devices { // TODO delete devices here. } } @@ -680,7 +680,7 @@ impl OlmMachine { async fn decrypt_olm_message( &mut self, - sender: &str, + _sender: &str, sender_key: &str, message: OlmMessage, ) -> Result> { @@ -785,8 +785,8 @@ impl OlmMachine { fn add_forwarded_room_key( &self, - sender_key: &str, - event: &ToDeviceForwardedRoomKey, + _sender_key: &str, + _event: &ToDeviceForwardedRoomKey, ) -> Result<()> { Ok(()) // TODO diff --git a/src/crypto/memory_stores.rs b/src/crypto/memory_stores.rs index e2d9a2d2..cffd5187 100644 --- a/src/crypto/memory_stores.rs +++ b/src/crypto/memory_stores.rs @@ -40,7 +40,7 @@ impl SessionStore { Arc::new(Mutex::new(Vec::new())), ); } - let mut sessions = self.entries.get_mut(&session.sender_key).unwrap(); + let sessions = self.entries.get_mut(&session.sender_key).unwrap(); let session = Arc::new(Mutex::new(session)); sessions.lock().await.push(session.clone()); @@ -75,13 +75,13 @@ impl GroupSessionStore { .insert(session.room_id.to_owned(), HashMap::new()); } - let mut room_map = self.entries.get_mut(&session.room_id).unwrap(); + let room_map = self.entries.get_mut(&session.room_id).unwrap(); if !room_map.contains_key(&session.sender_key) { room_map.insert(session.sender_key.to_owned(), HashMap::new()); } - let mut sender_map = room_map.get_mut(&session.sender_key).unwrap(); + let sender_map = room_map.get_mut(&session.sender_key).unwrap(); let ret = sender_map.insert(session.session_id(), Arc::new(Mutex::new(session))); ret.is_some() @@ -134,7 +134,7 @@ impl DeviceStore { self.entries .insert(device.user_id().to_owned(), DashMap::new()); } - let mut device_map = self.entries.get_mut(device.user_id()).unwrap(); + let device_map = self.entries.get_mut(device.user_id()).unwrap(); device_map .insert(device.device_id().to_owned(), device) diff --git a/src/crypto/olm.rs b/src/crypto/olm.rs index 7302c339..9ea5b3fe 100644 --- a/src/crypto/olm.rs +++ b/src/crypto/olm.rs @@ -259,7 +259,7 @@ impl InboundGroupSession { self.inner.first_known_index() } - pub fn decrypt(&self, mut message: String) -> Result<(String, u32), OlmGroupSessionError> { + pub fn decrypt(&self, message: String) -> Result<(String, u32), OlmGroupSessionError> { self.inner.decrypt(message) } } diff --git a/src/crypto/store/memorystore.rs b/src/crypto/store/memorystore.rs index 9c40764f..9932e060 100644 --- a/src/crypto/store/memorystore.rs +++ b/src/crypto/store/memorystore.rs @@ -18,7 +18,7 @@ use std::sync::Arc; use async_trait::async_trait; use tokio::sync::Mutex; -use super::{Account, CryptoStore, CryptoStoreError, InboundGroupSession, Result, Session}; +use super::{Account, CryptoStore, InboundGroupSession, Result, Session}; use crate::crypto::device::Device; use crate::crypto::memory_stores::{DeviceStore, GroupSessionStore, SessionStore, UserDevices}; @@ -47,11 +47,11 @@ impl CryptoStore for MemoryStore { Ok(None) } - async fn save_account(&mut self, account: Arc>) -> Result<()> { + async fn save_account(&mut self, _: Arc>) -> Result<()> { Ok(()) } - async fn save_session(&mut self, session: Arc>) -> Result<()> { + async fn save_session(&mut self, _: Arc>) -> Result<()> { Ok(()) } diff --git a/src/crypto/store/mod.rs b/src/crypto/store/mod.rs index 5f764944..e4367c80 100644 --- a/src/crypto/store/mod.rs +++ b/src/crypto/store/mod.rs @@ -13,9 +13,8 @@ // limitations under the License. use core::fmt::Debug; -use std::collections::{HashMap, HashSet}; +use std::collections::HashSet; use std::io::Error as IoError; -use std::result::Result as StdResult; use std::sync::Arc; use url::ParseError; @@ -28,7 +27,6 @@ use super::device::Device; use super::memory_stores::UserDevices; use super::olm::{Account, InboundGroupSession, Session}; use olm_rs::errors::{OlmAccountError, OlmGroupSessionError, OlmSessionError}; -use olm_rs::PicklingMode; pub mod memorystore; #[cfg(feature = "sqlite-cryptostore")] diff --git a/src/crypto/store/sqlite.rs b/src/crypto/store/sqlite.rs index 386a9785..3bc3e7cb 100644 --- a/src/crypto/store/sqlite.rs +++ b/src/crypto/store/sqlite.rs @@ -410,15 +410,15 @@ impl CryptoStore for SqliteStore { Ok(self.tracked_users.insert(user.to_string())) } - async fn get_device(&self, user_id: &str, device_id: &str) -> Result> { + async fn get_device(&self, _user_id: &str, _device_id: &str) -> Result> { todo!() } - async fn get_user_devices(&self, user_id: &str) -> Result { + async fn get_user_devices(&self, _user_id: &str) -> Result { todo!() } - async fn save_device(&self, device: Device) -> Result<()> { + async fn save_device(&self, _device: Device) -> Result<()> { todo!() } } diff --git a/src/models/room.rs b/src/models/room.rs index e23adb0b..222f720b 100644 --- a/src/models/room.rs +++ b/src/models/room.rs @@ -31,14 +31,6 @@ use crate::identifiers::RoomAliasId; use js_int::UInt; -#[cfg(feature = "encryption")] -use tokio::sync::Mutex; - -#[cfg(feature = "encryption")] -use crate::crypto::{OlmMachine, OneTimeKeys}; -#[cfg(feature = "encryption")] -use ruma_client_api::r0::keys::{upload_keys::Response as KeysUploadResponse, DeviceKeys}; - #[derive(Debug, Default)] /// `RoomName` allows the calculation of a text room name. pub struct RoomName { diff --git a/src/models/room_member.rs b/src/models/room_member.rs index 51c7f48f..4390f5e8 100644 --- a/src/models/room_member.rs +++ b/src/models/room_member.rs @@ -24,13 +24,6 @@ use crate::events::room::{ use crate::identifiers::UserId; use js_int::Int; -#[cfg(feature = "encryption")] -use tokio::sync::Mutex; - -#[cfg(feature = "encryption")] -use crate::crypto::{OlmMachine, OneTimeKeys}; -#[cfg(feature = "encryption")] -use ruma_client_api::r0::keys::{upload_keys::Response as KeysUploadResponse, DeviceKeys}; // Notes: if Alice invites Bob into a room we will get an event with the sender as Alice and the state key as Bob. diff --git a/src/models/user.rs b/src/models/user.rs index 93221235..e6a042a6 100644 --- a/src/models/user.rs +++ b/src/models/user.rs @@ -18,13 +18,6 @@ use crate::events::presence::{PresenceEvent, PresenceEventContent, PresenceState use crate::events::room::member::MemberEvent; use js_int::UInt; -#[cfg(feature = "encryption")] -use tokio::sync::Mutex; - -#[cfg(feature = "encryption")] -use crate::crypto::{OlmMachine, OneTimeKeys}; -#[cfg(feature = "encryption")] -use ruma_client_api::r0::keys::{upload_keys::Response as KeysUploadResponse, DeviceKeys}; #[derive(Debug)] /// A Matrix room member.