core_crypto

Struct 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

source

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

source

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

source

pub fn proteus_last_resort_prekey_id() -> u16

Returns the proteus last resort prekey id (u16::MAX = 65535)

source

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

source

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

source

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

source

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

source

pub fn take(self) -> MlsCentral

Allows to extract the MLS Client from the wrapper superstruct

Methods from Deref<Target = MlsCentral>§

source

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 id
  • key_length - the length of the key to be derived. If the value is higher than the bounds of u16 or the context hash * 255, an error will be returned
§Errors

OpenMls secret generation error or conversation not found

source

pub async fn get_client_ids( &self, conversation_id: &ConversationId, ) -> CryptoResult<Vec<ClientId>>

Exports the clients from a conversation

§Arguments
  • conversation_id - the group/conversation id
§Errors

if the conversation can’t be found

source

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

source

pub async fn provide_transport(&self, transport: Arc<dyn MlsTransport>)

Provide the implementation of functions to communicate with the delivery service (see MlsTransport).

source

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 authorization
  • credential_type - of the credential to look for
source

pub async fn client_id(&self) -> CryptoResult<ClientId>

Returns the client’s id as a buffer

source

pub async fn conversation_exists( &self, id: &ConversationId, ) -> CryptoResult<bool>

Checks if a given conversation id exists locally

source

pub async fn conversation_epoch(&self, id: &ConversationId) -> CryptoResult<u64>

Returns the epoch of a given conversation

§Errors

If the conversation can’t be found

source

pub async fn conversation_ciphersuite( &self, id: &ConversationId, ) -> CryptoResult<MlsCiphersuite>

Returns the ciphersuite of a given conversation

§Errors

If the conversation can’t be found

source

pub fn random_bytes(&self, len: usize) -> CryptoResult<Vec<u8>>

Generates a random byte array of the specified size

source

pub async fn reseed(&self, seed: Option<EntropySeed>) -> CryptoResult<()>

source

pub async fn e2ei_verify_group_state( &self, group_info: VerifiableGroupInfo, ) -> CryptoResult<E2eiConversationState>

Verifies a Group state before joining it

source

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.

source

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

source

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

source

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.

source

pub async fn e2ei_is_pki_env_setup(&self) -> bool

Returns whether the E2EI PKI environment is setup (i.e. Root CA, Intermediates, CRLs)

source

pub async fn e2ei_dump_pki_env(&self) -> CryptoResult<Option<E2eiDumpedPkiEnv>>

Dumps the PKI environment as PEM

Trait Implementations§

source§

impl Debug for CoreCrypto

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for CoreCrypto

source§

type Target = MlsCentral

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl DerefMut for CoreCrypto

source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
source§

impl From<MlsCentral> for CoreCrypto

source§

fn from(mls: MlsCentral) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T, UT> HandleAlloc<UT> for T
where T: Send + Sync,

§

fn new_handle(value: Arc<T>) -> Handle

Create a new handle for an Arc value Read more
§

unsafe fn clone_handle(handle: Handle) -> Handle

Clone a handle Read more
§

unsafe fn consume_handle(handle: Handle) -> Arc<T>

Consume a handle, getting back the initial Arc<> Read more
§

unsafe fn get_arc(handle: Handle) -> Arc<Self>

Get a clone of the Arc<> using a “borrowed” handle. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T