From 44184fd7fe180a26eef38e4d308dfa58819dc563 Mon Sep 17 00:00:00 2001 From: Danny McClanahan <1305167+cosmicexplorer@users.noreply.github.com> Date: Thu, 13 May 2021 01:41:13 -0700 Subject: [PATCH] respond to review comments --- rust/bridge/shared/src/ffi/storage.rs | 2 +- rust/bridge/shared/src/jni/storage.rs | 2 +- rust/bridge/shared/src/node/storage.rs | 2 +- rust/protocol/src/group_cipher.rs | 2 +- rust/protocol/src/lib.rs | 2 +- rust/protocol/src/storage.rs | 2 +- rust/protocol/src/storage/inmem.rs | 12 ++++++------ rust/protocol/src/storage/traits.rs | 10 +++++----- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/rust/bridge/shared/src/ffi/storage.rs b/rust/bridge/shared/src/ffi/storage.rs index 5884256ccc..c3b95c0493 100644 --- a/rust/bridge/shared/src/ffi/storage.rs +++ b/rust/bridge/shared/src/ffi/storage.rs @@ -80,7 +80,7 @@ impl IdentityKeyStore for &FfiIdentityKeyStoreStruct { async fn get_local_registration_id( &self, ctx: Context, - ) -> Result { + ) -> Result { let ctx = ctx.unwrap_or(std::ptr::null_mut()); let mut id = 0; let result = (self.get_local_registration_id)(self.ctx, &mut id, ctx); diff --git a/rust/bridge/shared/src/jni/storage.rs b/rust/bridge/shared/src/jni/storage.rs index f078c91f70..b9f75f85a8 100644 --- a/rust/bridge/shared/src/jni/storage.rs +++ b/rust/bridge/shared/src/jni/storage.rs @@ -183,7 +183,7 @@ impl<'a> IdentityKeyStore for JniIdentityKeyStore<'a> { async fn get_local_registration_id( &self, _ctx: Context, - ) -> Result { + ) -> Result { Ok(self.do_get_local_registration_id()?.into()) } diff --git a/rust/bridge/shared/src/node/storage.rs b/rust/bridge/shared/src/node/storage.rs index 80170737fa..babde29575 100644 --- a/rust/bridge/shared/src/node/storage.rs +++ b/rust/bridge/shared/src/node/storage.rs @@ -516,7 +516,7 @@ impl IdentityKeyStore for NodeIdentityKeyStore { async fn get_local_registration_id( &self, _ctx: libsignal_protocol::Context, - ) -> Result { + ) -> Result { Ok(self .do_get_local_registration_id() .await diff --git a/rust/protocol/src/group_cipher.rs b/rust/protocol/src/group_cipher.rs index f115c6a785..2e757ada91 100644 --- a/rust/protocol/src/group_cipher.rs +++ b/rust/protocol/src/group_cipher.rs @@ -145,7 +145,7 @@ pub async fn process_sender_key_distribution_message( .unwrap_or_else(SenderKeyRecord::new_empty); sender_key_record.add_sender_key_state( - skdm.message_version(), + skdm.message_version().into(), skdm.chain_id()?, skdm.iteration()?, skdm.chain_key()?, diff --git a/rust/protocol/src/lib.rs b/rust/protocol/src/lib.rs index a56ce532f0..df9ac72cea 100644 --- a/rust/protocol/src/lib.rs +++ b/rust/protocol/src/lib.rs @@ -64,6 +64,6 @@ pub use { storage::{ Context, Direction, IdentityKeyStore, InMemIdentityKeyStore, InMemPreKeyStore, InMemSenderKeyStore, InMemSessionStore, InMemSignalProtocolStore, InMemSignedPreKeyStore, - PreKeyStore, ProtocolStore, SenderKeyStore, SessionSeed, SessionStore, SignedPreKeyStore, + PreKeyStore, ProtocolStore, SenderKeyStore, RegistrationId, SessionStore, SignedPreKeyStore, }, }; diff --git a/rust/protocol/src/storage.rs b/rust/protocol/src/storage.rs index f6b4f8af51..1cdbf31de0 100644 --- a/rust/protocol/src/storage.rs +++ b/rust/protocol/src/storage.rs @@ -13,6 +13,6 @@ pub use { }, traits::{ Context, Direction, IdentityKeyStore, PreKeyStore, ProtocolStore, SenderKeyStore, - SessionSeed, SessionStore, SignedPreKeyStore, + RegistrationId, SessionStore, SignedPreKeyStore, }, }; diff --git a/rust/protocol/src/storage/inmem.rs b/rust/protocol/src/storage/inmem.rs index f5d0201ddb..36b7d7e470 100644 --- a/rust/protocol/src/storage/inmem.rs +++ b/rust/protocol/src/storage/inmem.rs @@ -5,7 +5,7 @@ use crate::{ IdentityKey, IdentityKeyPair, PreKeyId, PreKeyRecord, ProtocolAddress, Result, SenderKeyRecord, - SessionRecord, SessionSeed, SignalProtocolError, SignedPreKeyId, SignedPreKeyRecord, + SessionRecord, RegistrationId, SignalProtocolError, SignedPreKeyId, SignedPreKeyRecord, }; use crate::storage::traits; @@ -19,12 +19,12 @@ use uuid::Uuid; #[derive(Clone)] pub struct InMemIdentityKeyStore { key_pair: IdentityKeyPair, - id: SessionSeed, + id: RegistrationId, known_keys: HashMap, } impl InMemIdentityKeyStore { - pub fn new(key_pair: IdentityKeyPair, id: SessionSeed) -> Self { + pub fn new(key_pair: IdentityKeyPair, id: RegistrationId) -> Self { Self { key_pair, id, @@ -39,7 +39,7 @@ impl traits::IdentityKeyStore for InMemIdentityKeyStore { Ok(self.key_pair) } - async fn get_local_registration_id(&self, _ctx: Context) -> Result { + async fn get_local_registration_id(&self, _ctx: Context) -> Result { Ok(self.id) } @@ -286,7 +286,7 @@ pub struct InMemSignalProtocolStore { } impl InMemSignalProtocolStore { - pub fn new(key_pair: IdentityKeyPair, registration_id: SessionSeed) -> Result { + pub fn new(key_pair: IdentityKeyPair, registration_id: RegistrationId) -> Result { Ok(Self { session_store: InMemSessionStore::new(), pre_key_store: InMemPreKeyStore::new(), @@ -303,7 +303,7 @@ impl traits::IdentityKeyStore for InMemSignalProtocolStore { self.identity_store.get_identity_key_pair(ctx).await } - async fn get_local_registration_id(&self, ctx: Context) -> Result { + async fn get_local_registration_id(&self, ctx: Context) -> Result { self.identity_store.get_local_registration_id(ctx).await } diff --git a/rust/protocol/src/storage/traits.rs b/rust/protocol/src/storage/traits.rs index 4526c1debf..040e9ade7c 100644 --- a/rust/protocol/src/storage/traits.rs +++ b/rust/protocol/src/storage/traits.rs @@ -22,16 +22,16 @@ pub enum Direction { /// A locally-generated random number used to construct the initial value of a message chain. #[derive(Copy, Clone, Debug, Hash, Eq, PartialEq, PartialOrd, Ord)] -pub struct SessionSeed(u32); +pub struct RegistrationId(u32); -impl From for SessionSeed { +impl From for RegistrationId { fn from(value: u32) -> Self { Self(value) } } -impl From for u32 { - fn from(value: SessionSeed) -> Self { +impl From for u32 { + fn from(value: RegistrationId) -> Self { value.0 } } @@ -40,7 +40,7 @@ impl From for u32 { pub trait IdentityKeyStore { async fn get_identity_key_pair(&self, ctx: Context) -> Result; - async fn get_local_registration_id(&self, ctx: Context) -> Result; + async fn get_local_registration_id(&self, ctx: Context) -> Result; async fn save_identity( &mut self,