From 7de002b128f7a5f4390234ea2d5acf07c59fdff2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Thu, 22 Oct 2020 16:40:05 +0200 Subject: [PATCH] crypto: Fix some lint issues. --- matrix_sdk_crypto/src/olm/mod.rs | 2 +- matrix_sdk_crypto/src/olm/signing.rs | 13 ++++++------- matrix_sdk_crypto/src/store/memorystore.rs | 6 ++++-- matrix_sdk_crypto/src/store/mod.rs | 3 +-- matrix_sdk_crypto/src/store/sqlite.rs | 14 +++++++------- 5 files changed, 19 insertions(+), 19 deletions(-) diff --git a/matrix_sdk_crypto/src/olm/mod.rs b/matrix_sdk_crypto/src/olm/mod.rs index d87b1092..116f9b82 100644 --- a/matrix_sdk_crypto/src/olm/mod.rs +++ b/matrix_sdk_crypto/src/olm/mod.rs @@ -32,7 +32,7 @@ pub use group_sessions::{ pub(crate) use group_sessions::{GroupSessionKey, OutboundGroupSession}; pub use olm_rs::{account::IdentityKeys, PicklingMode}; pub use session::{PickledSession, Session, SessionPickle}; -pub use signing::{PrivateCrossSigningIdentity, PickledCrossSigningIdentity}; +pub use signing::{PickledCrossSigningIdentity, PrivateCrossSigningIdentity}; pub(crate) use utility::Utility; #[cfg(test)] diff --git a/matrix_sdk_crypto/src/olm/signing.rs b/matrix_sdk_crypto/src/olm/signing.rs index f92f1246..dfde208b 100644 --- a/matrix_sdk_crypto/src/olm/signing.rs +++ b/matrix_sdk_crypto/src/olm/signing.rs @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -#![allow(dead_code,missing_docs)] +#![allow(dead_code, missing_docs)] use aes_gcm::{ aead::{generic_array::GenericArray, Aead, NewAead}, @@ -410,7 +410,10 @@ impl PrivateCrossSigningIdentity { self.shared.load(Ordering::SeqCst) } - pub async fn pickle(&self, pickle_key: &[u8]) -> Result { + pub async fn pickle( + &self, + pickle_key: &[u8], + ) -> Result { let master_key = if let Some(m) = self.master_key.lock().await.as_ref() { Some(m.pickle(pickle_key).await) } else { @@ -435,10 +438,8 @@ impl PrivateCrossSigningIdentity { self_signing_key, }; - println!("HELOOO {:#?}", pickle); - let pickle = serde_json::to_string(&pickle)?; - + Ok(PickledCrossSigningIdentity { user_id: self.user_id.as_ref().to_owned(), shared: self.shared(), @@ -455,10 +456,8 @@ impl PrivateCrossSigningIdentity { pickle: PickledCrossSigningIdentity, pickle_key: &[u8], ) -> Result { - println!("HELOOO UNPICKLED {:#?}", pickle.pickle); let signings: PickledSignings = serde_json::from_str(&pickle.pickle)?; - let master = if let Some(m) = signings.master_key { Some(MasterSigning::from_pickle(m, pickle_key)?) } else { diff --git a/matrix_sdk_crypto/src/store/memorystore.rs b/matrix_sdk_crypto/src/store/memorystore.rs index 487f1d24..952522e5 100644 --- a/matrix_sdk_crypto/src/store/memorystore.rs +++ b/matrix_sdk_crypto/src/store/memorystore.rs @@ -28,8 +28,10 @@ use super::{ caches::{DeviceStore, GroupSessionStore, SessionStore}, Changes, CryptoStore, InboundGroupSession, ReadOnlyAccount, Result, Session, }; -use crate::identities::{ReadOnlyDevice, UserIdentities}; -use crate::olm::PrivateCrossSigningIdentity; +use crate::{ + identities::{ReadOnlyDevice, UserIdentities}, + olm::PrivateCrossSigningIdentity, +}; /// An in-memory only store that will forget all the E2EE key once it's dropped. #[derive(Debug, Clone)] diff --git a/matrix_sdk_crypto/src/store/mod.rs b/matrix_sdk_crypto/src/store/mod.rs index c4e4365a..b19e3b07 100644 --- a/matrix_sdk_crypto/src/store/mod.rs +++ b/matrix_sdk_crypto/src/store/mod.rs @@ -79,11 +79,10 @@ use matrix_sdk_common_macros::async_trait; #[cfg(not(target_arch = "wasm32"))] use matrix_sdk_common_macros::send_sync; -use crate::olm::PrivateCrossSigningIdentity; use crate::{ error::SessionUnpicklingError, identities::{Device, ReadOnlyDevice, UserDevices, UserIdentities}, - olm::{InboundGroupSession, ReadOnlyAccount, Session}, + olm::{InboundGroupSession, PrivateCrossSigningIdentity, ReadOnlyAccount, Session}, verification::VerificationMachine, }; diff --git a/matrix_sdk_crypto/src/store/sqlite.rs b/matrix_sdk_crypto/src/store/sqlite.rs index d4182bad..3df06ab2 100644 --- a/matrix_sdk_crypto/src/store/sqlite.rs +++ b/matrix_sdk_crypto/src/store/sqlite.rs @@ -38,14 +38,12 @@ use super::{ pickle_key::{EncryptedPickleKey, PickleKey}, Changes, CryptoStore, CryptoStoreError, Result, }; -use crate::olm::PickledCrossSigningIdentity; -use crate::olm::PrivateCrossSigningIdentity; use crate::{ identities::{LocalTrust, OwnUserIdentity, ReadOnlyDevice, UserIdentities, UserIdentity}, olm::{ AccountPickle, IdentityKeys, InboundGroupSession, InboundGroupSessionPickle, - PickledAccount, PickledInboundGroupSession, PickledSession, PicklingMode, ReadOnlyAccount, - Session, SessionPickle, + PickledAccount, PickledCrossSigningIdentity, PickledInboundGroupSession, PickledSession, + PicklingMode, PrivateCrossSigningIdentity, ReadOnlyAccount, Session, SessionPickle, }, }; @@ -1615,7 +1613,7 @@ impl CryptoStore for SqliteStore { query( "INSERT INTO private_identities ( - account_id, user_id, pickle, shared + account_id, user_id, pickle, shared ) VALUES (?1, ?2, ?3, ?4) ON CONFLICT(account_id, user_id) DO UPDATE SET pickle = excluded.pickle, @@ -1813,13 +1811,15 @@ impl std::fmt::Debug for SqliteStore { #[cfg(test)] mod test { - use crate::olm::PrivateCrossSigningIdentity; use crate::{ identities::{ device::test::get_device, user::test::{get_other_identity, get_own_identity}, }, - olm::{GroupSessionKey, InboundGroupSession, ReadOnlyAccount, Session}, + olm::{ + GroupSessionKey, InboundGroupSession, PrivateCrossSigningIdentity, ReadOnlyAccount, + Session, + }, store::{Changes, DeviceChanges, IdentityChanges}, }; use matrix_sdk_common::{