Struct core_crypto::proteus::ProteusCentral
source · pub struct ProteusCentral { /* private fields */ }
Expand description
Proteus counterpart of crate::mls::MlsCentral The big difference is that ProteusCentral doesn’t own its own keystore but must borrow it from the outside. Whether it’s exclusively for this struct’s purposes or it’s shared with our main struct, crate::mls::MlsCentral
Implementations§
source§impl ProteusCentral
impl ProteusCentral
sourcepub async fn try_new(keystore: &CryptoKeystore) -> CryptoResult<Self>
pub async fn try_new(keystore: &CryptoKeystore) -> CryptoResult<Self>
Initializes the ProteusCentral
sourcepub async fn reload_sessions(
&mut self,
keystore: &CryptoKeystore,
) -> CryptoResult<()>
pub async fn reload_sessions( &mut self, keystore: &CryptoKeystore, ) -> CryptoResult<()>
Restore proteus sessions from disk
sourcepub async fn session_from_prekey(
&mut self,
session_id: &str,
key: &[u8],
) -> CryptoResult<Arc<RwLock<ProteusConversationSession>>>
pub async fn session_from_prekey( &mut self, session_id: &str, key: &[u8], ) -> CryptoResult<Arc<RwLock<ProteusConversationSession>>>
Creates a new session from a prekey
sourcepub async fn session_from_message(
&mut self,
keystore: &mut CryptoKeystore,
session_id: &str,
envelope: &[u8],
) -> CryptoResult<(Arc<RwLock<ProteusConversationSession>>, Vec<u8>)>
pub async fn session_from_message( &mut self, keystore: &mut CryptoKeystore, session_id: &str, envelope: &[u8], ) -> CryptoResult<(Arc<RwLock<ProteusConversationSession>>, Vec<u8>)>
Creates a new proteus Session from a received message
sourcepub async fn session_save(
&mut self,
keystore: &mut CryptoKeystore,
session_id: &str,
) -> CryptoResult<()>
pub async fn session_save( &mut self, keystore: &mut CryptoKeystore, session_id: &str, ) -> CryptoResult<()>
Persists a session in store
Note: This isn’t usually needed as persisting sessions happens automatically when decrypting/encrypting messages and initializing Sessions
sourcepub async fn session_delete(
&mut self,
keystore: &CryptoKeystore,
session_id: &str,
) -> CryptoResult<()>
pub async fn session_delete( &mut self, keystore: &CryptoKeystore, session_id: &str, ) -> CryptoResult<()>
Deletes a session in the store
sourcepub async fn session(
&mut self,
session_id: &str,
keystore: &mut CryptoKeystore,
) -> CryptoResult<Option<Arc<RwLock<ProteusConversationSession>>>>
pub async fn session( &mut self, session_id: &str, keystore: &mut CryptoKeystore, ) -> CryptoResult<Option<Arc<RwLock<ProteusConversationSession>>>>
Session accessor
sourcepub async fn session_exists(
&mut self,
session_id: &str,
keystore: &mut CryptoKeystore,
) -> bool
pub async fn session_exists( &mut self, session_id: &str, keystore: &mut CryptoKeystore, ) -> bool
Session exists
sourcepub async fn decrypt(
&mut self,
keystore: &mut CryptoKeystore,
session_id: &str,
ciphertext: &[u8],
) -> CryptoResult<Vec<u8>>
pub async fn decrypt( &mut self, keystore: &mut CryptoKeystore, session_id: &str, ciphertext: &[u8], ) -> CryptoResult<Vec<u8>>
Decrypt a proteus message for an already existing session Note: This cannot be used for handshake messages, see ProteusCentral::session_from_message
sourcepub async fn encrypt(
&mut self,
keystore: &mut CryptoKeystore,
session_id: &str,
plaintext: &[u8],
) -> CryptoResult<Vec<u8>>
pub async fn encrypt( &mut self, keystore: &mut CryptoKeystore, session_id: &str, plaintext: &[u8], ) -> CryptoResult<Vec<u8>>
Encrypt a message for a session
sourcepub async fn encrypt_batched(
&mut self,
keystore: &mut CryptoKeystore,
sessions: &[impl AsRef<str>],
plaintext: &[u8],
) -> CryptoResult<HashMap<String, Vec<u8>>>
pub async fn encrypt_batched( &mut self, keystore: &mut CryptoKeystore, sessions: &[impl AsRef<str>], plaintext: &[u8], ) -> CryptoResult<HashMap<String, Vec<u8>>>
Encrypts a message for a list of sessions This is mainly used for conversations with multiple clients, this allows to minimize FFI roundtrips
sourcepub async fn new_prekey(
&self,
id: u16,
keystore: &CryptoKeystore,
) -> CryptoResult<Vec<u8>>
pub async fn new_prekey( &self, id: u16, keystore: &CryptoKeystore, ) -> CryptoResult<Vec<u8>>
Generates a new Proteus PreKey, stores it in the keystore and returns a serialized PreKeyBundle to be consumed externally
sourcepub async fn new_prekey_auto(
&self,
keystore: &CryptoKeystore,
) -> CryptoResult<(u16, Vec<u8>)>
pub async fn new_prekey_auto( &self, keystore: &CryptoKeystore, ) -> CryptoResult<(u16, Vec<u8>)>
Generates a new Proteus Prekey, with an automatically auto-incremented ID.
sourcepub fn last_resort_prekey_id() -> u16
pub fn last_resort_prekey_id() -> u16
Returns the Proteus last resort prekey ID (u16::MAX = 65535 = 0xFFFF)
sourcepub async fn last_resort_prekey(
&self,
keystore: &CryptoKeystore,
) -> CryptoResult<Vec<u8>>
pub async fn last_resort_prekey( &self, keystore: &CryptoKeystore, ) -> CryptoResult<Vec<u8>>
Returns the Proteus last resort prekey If it cannot be found, one will be created.
sourcepub fn fingerprint(&self) -> String
pub fn fingerprint(&self) -> String
Proteus Public key hex-encoded fingerprint
sourcepub async fn fingerprint_local(
&mut self,
session_id: &str,
keystore: &mut CryptoKeystore,
) -> CryptoResult<String>
pub async fn fingerprint_local( &mut self, session_id: &str, keystore: &mut CryptoKeystore, ) -> CryptoResult<String>
sourcepub async fn fingerprint_remote(
&mut self,
session_id: &str,
keystore: &mut CryptoKeystore,
) -> CryptoResult<String>
pub async fn fingerprint_remote( &mut self, session_id: &str, keystore: &mut CryptoKeystore, ) -> CryptoResult<String>
sourcepub fn fingerprint_prekeybundle(prekey: &[u8]) -> CryptoResult<String>
pub fn fingerprint_prekeybundle(prekey: &[u8]) -> CryptoResult<String>
sourcepub async fn cryptobox_migrate(
keystore: &CryptoKeystore,
path: &str,
) -> CryptoResult<()>
pub async fn cryptobox_migrate( keystore: &CryptoKeystore, path: &str, ) -> CryptoResult<()>
Cryptobox -> CoreCrypto migration
Trait Implementations§
Auto Trait Implementations§
impl Freeze for ProteusCentral
impl !RefUnwindSafe for ProteusCentral
impl Send for ProteusCentral
impl Sync for ProteusCentral
impl Unpin for ProteusCentral
impl !UnwindSafe for ProteusCentral
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T, UT> HandleAlloc<UT> for T
impl<T, UT> HandleAlloc<UT> for T
§fn new_handle(value: Arc<T>) -> Handle
fn new_handle(value: Arc<T>) -> Handle
§unsafe fn clone_handle(handle: Handle) -> Handle
unsafe fn clone_handle(handle: Handle) -> Handle
§unsafe fn consume_handle(handle: Handle) -> Arc<T>
unsafe fn consume_handle(handle: Handle) -> Arc<T>
Arc<>
Read moresource§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more