Struct core_crypto::CoreCrypto
source · pub struct CoreCrypto { /* private fields */ }
Expand description
Wrapper superstruct for both mls::MlsCentral and proteus::ProteusCentral
As std::ops::Deref is implemented, this struct is automatically dereferred to mls::MlsCentral apart from proteus_*
calls
Implementations§
source§impl CoreCrypto
impl CoreCrypto
sourcepub async fn proteus_init(&self) -> CryptoResult<()>
pub async fn proteus_init(&self) -> CryptoResult<()>
Initializes the proteus client
source§impl CoreCrypto
impl CoreCrypto
sourcepub async fn proteus_session(
&self,
session_id: &str,
) -> CryptoResult<Option<Arc<RwLock<ProteusConversationSession>>>>
pub async fn proteus_session( &self, session_id: &str, ) -> CryptoResult<Option<Arc<RwLock<ProteusConversationSession>>>>
Proteus session accessor
Warning: The Proteus client MUST be initialized with CoreCrypto::proteus_init first or an error will be returned
sourcepub async fn proteus_session_exists(
&self,
session_id: &str,
) -> CryptoResult<bool>
pub async fn proteus_session_exists( &self, session_id: &str, ) -> CryptoResult<bool>
Proteus session exists
Warning: The Proteus client MUST be initialized with CoreCrypto::proteus_init first or an error will be returned
sourcepub fn proteus_last_resort_prekey_id() -> u16
pub fn proteus_last_resort_prekey_id() -> u16
Returns the proteus last resort prekey id (u16::MAX = 65535)
sourcepub async fn proteus_fingerprint(&self) -> CryptoResult<String>
pub async fn proteus_fingerprint(&self) -> CryptoResult<String>
Returns the proteus identity’s public key fingerprint
Warning: The Proteus client MUST be initialized with CoreCrypto::proteus_init first or an error will be returned
sourcepub async fn proteus_fingerprint_local(
&self,
session_id: &str,
) -> CryptoResult<String>
pub async fn proteus_fingerprint_local( &self, session_id: &str, ) -> CryptoResult<String>
Returns the proteus identity’s public key fingerprint
Warning: The Proteus client MUST be initialized with CoreCrypto::proteus_init first or an error will be returned
sourcepub async fn proteus_fingerprint_remote(
&self,
session_id: &str,
) -> CryptoResult<String>
pub async fn proteus_fingerprint_remote( &self, session_id: &str, ) -> CryptoResult<String>
Returns the proteus identity’s public key fingerprint
Warning: The Proteus client MUST be initialized with CoreCrypto::proteus_init first or an error will be returned
source§impl CoreCrypto
impl CoreCrypto
sourcepub async fn new_transaction(&self) -> CryptoResult<CentralContext>
pub async fn new_transaction(&self) -> CryptoResult<CentralContext>
Creates a new transaction. All operations that persist data will be buffered in memory and when CentralContext::finish is called, the data will be persisted in a single database transaction.
source§impl CoreCrypto
impl CoreCrypto
sourcepub fn take(self) -> MlsCentral
pub fn take(self) -> MlsCentral
Allows to extract the MLS Client from the wrapper superstruct
Methods from Deref<Target = MlsCentral>§
sourcepub async fn export_secret_key(
&self,
conversation_id: &ConversationId,
key_length: usize,
) -> CryptoResult<Vec<u8>>
pub async fn export_secret_key( &self, conversation_id: &ConversationId, key_length: usize, ) -> CryptoResult<Vec<u8>>
Derives a new key from the one in the group, allowing it to be use elsewehere.
§Arguments
conversation_id
- the group/conversation idkey_length
- the length of the key to be derived. If the value is higher than the bounds ofu16
or the context hash * 255, an error will be returned
§Errors
OpenMls secret generation error or conversation not found
sourcepub async fn get_client_ids(
&self,
conversation_id: &ConversationId,
) -> CryptoResult<Vec<ClientId>>
pub async fn get_client_ids( &self, conversation_id: &ConversationId, ) -> CryptoResult<Vec<ClientId>>
sourcepub async fn get_external_sender(
&self,
id: &ConversationId,
) -> CryptoResult<Vec<u8>>
pub async fn get_external_sender( &self, id: &ConversationId, ) -> CryptoResult<Vec<u8>>
Returns the raw public key of the single external sender present in this group. This should be used to initialize a subconversation
sourcepub async fn callbacks(&self, callbacks: Arc<dyn CoreCryptoCallbacks>)
pub async fn callbacks(&self, callbacks: Arc<dyn CoreCryptoCallbacks>)
Sets the consumer callbacks (i.e authorization callbacks for CoreCrypto to perform authorization calls when needed)
§Arguments
callbacks
- a callback to be called to perform authorization
sourcepub async fn client_public_key(
&self,
ciphersuite: MlsCiphersuite,
credential_type: MlsCredentialType,
) -> CryptoResult<Vec<u8>>
pub async fn client_public_key( &self, ciphersuite: MlsCiphersuite, credential_type: MlsCredentialType, ) -> CryptoResult<Vec<u8>>
Returns the client’s most recent public signature key as a buffer. Used to upload a public key to the server in order to verify client’s messages signature.
§Arguments
ciphersuite
- a callback to be called to perform authorizationcredential_type
- of the credential to look for
sourcepub async fn client_id(&self) -> CryptoResult<ClientId>
pub async fn client_id(&self) -> CryptoResult<ClientId>
Returns the client’s id as a buffer
sourcepub async fn conversation_exists(
&self,
id: &ConversationId,
) -> CryptoResult<bool>
pub async fn conversation_exists( &self, id: &ConversationId, ) -> CryptoResult<bool>
Checks if a given conversation id exists locally
sourcepub async fn conversation_epoch(&self, id: &ConversationId) -> CryptoResult<u64>
pub async fn conversation_epoch(&self, id: &ConversationId) -> CryptoResult<u64>
sourcepub async fn conversation_ciphersuite(
&self,
id: &ConversationId,
) -> CryptoResult<MlsCiphersuite>
pub async fn conversation_ciphersuite( &self, id: &ConversationId, ) -> CryptoResult<MlsCiphersuite>
sourcepub fn random_bytes(&self, len: usize) -> CryptoResult<Vec<u8>>
pub fn random_bytes(&self, len: usize) -> CryptoResult<Vec<u8>>
Generates a random byte array of the specified size
sourcepub async fn reseed(&self, seed: Option<EntropySeed>) -> CryptoResult<()>
pub async fn reseed(&self, seed: Option<EntropySeed>) -> CryptoResult<()>
sourcepub async fn e2ei_verify_group_state(
&self,
group_info: VerifiableGroupInfo,
) -> CryptoResult<E2eiConversationState>
pub async fn e2ei_verify_group_state( &self, group_info: VerifiableGroupInfo, ) -> CryptoResult<E2eiConversationState>
Verifies a Group state before joining it
sourcepub async fn get_credential_in_use(
&self,
group_info: VerifiableGroupInfo,
credential_type: MlsCredentialType,
) -> CryptoResult<E2eiConversationState>
pub async fn get_credential_in_use( &self, group_info: VerifiableGroupInfo, credential_type: MlsCredentialType, ) -> CryptoResult<E2eiConversationState>
Gets the e2ei conversation state from a GroupInfo
. Useful to check if the group has e2ei
turned on or not before joining it.
sourcepub async fn e2ei_is_enabled(
&self,
signature_scheme: SignatureScheme,
) -> CryptoResult<bool>
pub async fn e2ei_is_enabled( &self, signature_scheme: SignatureScheme, ) -> CryptoResult<bool>
Returns true when end-to-end-identity is enabled for the given SignatureScheme
sourcepub async fn get_device_identities(
&self,
conversation_id: &ConversationId,
client_ids: &[ClientId],
) -> CryptoResult<Vec<WireIdentity>>
pub async fn get_device_identities( &self, conversation_id: &ConversationId, client_ids: &[ClientId], ) -> CryptoResult<Vec<WireIdentity>>
From a given conversation, get the identity of the members supplied. Identity is only present for members with a Certificate Credential (after turning on end-to-end identity). If no member has a x509 certificate, it will return an empty Vec
sourcepub async fn get_user_identities(
&self,
conversation_id: &ConversationId,
user_ids: &[String],
) -> CryptoResult<HashMap<String, Vec<WireIdentity>>>
pub async fn get_user_identities( &self, conversation_id: &ConversationId, user_ids: &[String], ) -> CryptoResult<HashMap<String, Vec<WireIdentity>>>
From a given conversation, get the identity of the users (device holders) supplied. Identity is only present for devices with a Certificate Credential (after turning on end-to-end identity). If no member has a x509 certificate, it will return an empty Vec.
Returns a Map with all the identities for a given users. Consumers are then recommended to reduce those identities to determine the actual status of a user.
sourcepub async fn e2ei_is_pki_env_setup(&self) -> bool
pub async fn e2ei_is_pki_env_setup(&self) -> bool
Returns whether the E2EI PKI environment is setup (i.e. Root CA, Intermediates, CRLs)
sourcepub async fn e2ei_dump_pki_env(&self) -> CryptoResult<Option<E2eiDumpedPkiEnv>>
pub async fn e2ei_dump_pki_env(&self) -> CryptoResult<Option<E2eiDumpedPkiEnv>>
Dumps the PKI environment as PEM
Trait Implementations§
source§impl Debug for CoreCrypto
impl Debug for CoreCrypto
source§impl Deref for CoreCrypto
impl Deref for CoreCrypto
source§impl DerefMut for CoreCrypto
impl DerefMut for CoreCrypto
source§impl From<MlsCentral> for CoreCrypto
impl From<MlsCentral> for CoreCrypto
source§fn from(mls: MlsCentral) -> Self
fn from(mls: MlsCentral) -> Self
Auto Trait Implementations§
impl Freeze for CoreCrypto
impl !RefUnwindSafe for CoreCrypto
impl Send for CoreCrypto
impl Sync for CoreCrypto
impl Unpin for CoreCrypto
impl !UnwindSafe for CoreCrypto
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