pub struct CoreCrypto { /* private fields */ }
Expand description
Wrapper superstruct for both [mls::Client] and proteus::ProteusCentral
As std::ops::Deref is implemented, this struct is automatically dereferred to [mls::Client] apart from proteus_*
calls
This is cheap to clone as all internal members have Arc
wrappers or are Copy
.
Implementations§
Source§impl CoreCrypto
impl CoreCrypto
Sourcepub async fn register_epoch_observer(
&self,
epoch_observer: Arc<dyn EpochObserver>,
) -> Result<(), Error>
pub async fn register_epoch_observer( &self, epoch_observer: Arc<dyn EpochObserver>, ) -> Result<(), Error>
Add an epoch observer to this session.
This function should be called 0 or 1 times in a session’s lifetime. If called when an epoch observer already exists, this will return an error.
Source§impl CoreCrypto
impl CoreCrypto
Sourcepub async fn proteus_session(
&self,
session_id: &str,
) -> Result<Option<Arc<RwLock<ProteusConversationSession>>>>
pub async fn proteus_session( &self, session_id: &str, ) -> Result<Option<Arc<RwLock<ProteusConversationSession>>>>
Proteus session accessor
Warning: The Proteus client MUST be initialized with TransactionContext::proteus_init first or an error will be returned
Sourcepub async fn proteus_session_exists(&self, session_id: &str) -> Result<bool>
pub async fn proteus_session_exists(&self, session_id: &str) -> Result<bool>
Proteus session exists
Warning: The Proteus client MUST be initialized with TransactionContext::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) -> Result<String>
pub async fn proteus_fingerprint(&self) -> Result<String>
Returns the proteus identity’s public key fingerprint
Warning: The Proteus client MUST be initialized with TransactionContext::proteus_init first or an error will be returned
Sourcepub async fn proteus_fingerprint_local(
&self,
session_id: &str,
) -> Result<String>
pub async fn proteus_fingerprint_local( &self, session_id: &str, ) -> Result<String>
Returns the proteus identity’s public key fingerprint
Warning: The Proteus client MUST be initialized with TransactionContext::proteus_init first or an error will be returned
Sourcepub async fn proteus_fingerprint_remote(
&self,
session_id: &str,
) -> Result<String>
pub async fn proteus_fingerprint_remote( &self, session_id: &str, ) -> Result<String>
Returns the proteus identity’s public key fingerprint
Warning: The Proteus client MUST be initialized with TransactionContext::proteus_init first or an error will be returned
Source§impl CoreCrypto
impl CoreCrypto
Sourcepub async fn new_transaction(&self) -> Result<TransactionContext>
pub async fn new_transaction(&self) -> Result<TransactionContext>
Creates a new transaction. All operations that persist data will be buffered in memory and when TransactionContext::finish is called, the data will be persisted in a single database transaction.
Methods from Deref<Target = Session>§
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) -> Result<Option<E2eiDumpedPkiEnv>, Error>
pub async fn e2ei_dump_pki_env(&self) -> Result<Option<E2eiDumpedPkiEnv>, Error>
Dumps the PKI environment as PEM
Sourcepub async fn e2ei_is_enabled(
&self,
signature_scheme: SignatureScheme,
) -> Result<bool, Error>
pub async fn e2ei_is_enabled( &self, signature_scheme: SignatureScheme, ) -> Result<bool, Error>
Returns true when end-to-end-identity is enabled for the given SignatureScheme
Sourcepub async fn e2ei_verify_group_state(
&self,
group_info: VerifiableGroupInfo,
) -> Result<E2eiConversationState, Error>
pub async fn e2ei_verify_group_state( &self, group_info: VerifiableGroupInfo, ) -> Result<E2eiConversationState, Error>
Verifies a Group state before joining it
Sourcepub async fn get_credential_in_use(
&self,
group_info: VerifiableGroupInfo,
credential_type: MlsCredentialType,
) -> Result<E2eiConversationState, Error>
pub async fn get_credential_in_use( &self, group_info: VerifiableGroupInfo, credential_type: MlsCredentialType, ) -> Result<E2eiConversationState, Error>
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 generate_one_keypackage_from_credential_bundle(
&self,
backend: &MlsCryptoProvider,
cs: MlsCiphersuite,
cb: &CredentialBundle,
) -> Result<KeyPackage, Error>
pub async fn generate_one_keypackage_from_credential_bundle( &self, backend: &MlsCryptoProvider, cs: MlsCiphersuite, cb: &CredentialBundle, ) -> Result<KeyPackage, Error>
Sourcepub async fn request_key_packages(
&self,
count: usize,
ciphersuite: MlsCiphersuite,
credential_type: MlsCredentialType,
backend: &MlsCryptoProvider,
) -> Result<Vec<KeyPackage>, Error>
pub async fn request_key_packages( &self, count: usize, ciphersuite: MlsCiphersuite, credential_type: MlsCredentialType, backend: &MlsCryptoProvider, ) -> Result<Vec<KeyPackage>, Error>
Requests count
keying material to be present and returns
a reference to it for the consumer to copy/clone.
§Arguments
count
- number of openmls::key_packages::KeyPackage to generateciphersuite
- of openmls::key_packages::KeyPackage to generatebackend
- the KeyStorage to load the keypackages from
§Errors
KeyStore and OpenMls errors
Sourcepub async fn valid_keypackages_count(
&self,
backend: &MlsCryptoProvider,
ciphersuite: MlsCiphersuite,
credential_type: MlsCredentialType,
) -> Result<usize, Error>
pub async fn valid_keypackages_count( &self, backend: &MlsCryptoProvider, ciphersuite: MlsCiphersuite, credential_type: MlsCredentialType, ) -> Result<usize, Error>
Returns the count of valid, non-expired, unclaimed keypackages in store
Sourcepub async fn prune_keypackages(
&self,
backend: &MlsCryptoProvider,
refs: &[KeyPackageRef],
) -> Result<(), Error>
pub async fn prune_keypackages( &self, backend: &MlsCryptoProvider, refs: &[KeyPackageRef], ) -> Result<(), Error>
Prune the provided KeyPackageRefs from the keystore
Warning: Despite this API being public, the caller should know what they’re doing. Provided KeypackageRefs will be purged regardless of their expiration state, so please be wary of what you are doing if you directly call this API. This could result in still valid, uploaded keypackages being pruned from the system and thus being impossible to find when referenced in a future Welcome message.
Sourcepub async fn provide_transport(&self, transport: Arc<dyn MlsTransport>)
pub async fn provide_transport(&self, transport: Arc<dyn MlsTransport>)
Provide the implementation of functions to communicate with the delivery service (see MlsTransport).
Sourcepub async fn init(
&self,
identifier: ClientIdentifier,
ciphersuites: &[MlsCiphersuite],
backend: &MlsCryptoProvider,
nb_key_package: usize,
) -> Result<(), Error>
pub async fn init( &self, identifier: ClientIdentifier, ciphersuites: &[MlsCiphersuite], backend: &MlsCryptoProvider, nb_key_package: usize, ) -> Result<(), Error>
Initializes the client. If the client’s cryptographic material is already stored in the keystore, it loads it Otherwise, it is being created.
§Arguments
identifier
- client identifier ; either a ClientId or a x509 certificate chainciphersuites
- all ciphersuites this client is supposed to supportbackend
- the KeyStore and crypto provider to read identities from
§Errors
KeyStore and OpenMls errors can happen
Sourcepub async fn get_raw_conversation(
&self,
id: &ConversationId,
) -> Result<ImmutableConversation, Error>
pub async fn get_raw_conversation( &self, id: &ConversationId, ) -> Result<ImmutableConversation, Error>
Get an immutable view of an MlsConversation
.
Because it operates on the raw conversation type, this may be faster than crate::mls::TransactionContext::conversation. for transient and immutable purposes. For long-lived or mutable purposes, prefer the other method.
Sourcepub async fn public_key(
&self,
ciphersuite: MlsCiphersuite,
credential_type: MlsCredentialType,
) -> Result<Vec<u8>>
pub async fn public_key( &self, ciphersuite: MlsCiphersuite, credential_type: MlsCredentialType, ) -> Result<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 conversation_exists(
&self,
id: &ConversationId,
) -> Result<bool, Error>
pub async fn conversation_exists( &self, id: &ConversationId, ) -> Result<bool, Error>
Checks if a given conversation id exists locally
Sourcepub fn random_bytes(&self, len: usize) -> Result<Vec<u8>>
pub fn random_bytes(&self, len: usize) -> Result<Vec<u8>>
Generates a random byte array of the specified size
Sourcepub async fn can_close(&self) -> bool
pub async fn can_close(&self) -> bool
Reports whether the local KeyStore believes that it can currently close.
Beware TOCTOU!
Sourcepub async fn generate_raw_keypairs(
&self,
ciphersuites: &[MlsCiphersuite],
backend: &MlsCryptoProvider,
) -> Result<Vec<ClientId>, Error>
pub async fn generate_raw_keypairs( &self, ciphersuites: &[MlsCiphersuite], backend: &MlsCryptoProvider, ) -> Result<Vec<ClientId>, Error>
Initializes a raw MLS keypair without an associated client ID Returns a random ClientId to bind later in [Client::init_with_external_client_id]
§Arguments
ciphersuites
- all ciphersuites this client is supposed to supportbackend
- the KeyStore and crypto provider to read identities from
§Errors
KeyStore and OpenMls errors can happen
Sourcepub async fn init_with_external_client_id(
&self,
client_id: ClientId,
tmp_ids: Vec<ClientId>,
ciphersuites: &[MlsCiphersuite],
backend: &MlsCryptoProvider,
) -> Result<(), Error>
pub async fn init_with_external_client_id( &self, client_id: ClientId, tmp_ids: Vec<ClientId>, ciphersuites: &[MlsCiphersuite], backend: &MlsCryptoProvider, ) -> Result<(), Error>
Finalizes initialization using a 2-step process of uploading first a public key and then associating a new Client ID to that keypair
§Arguments
client_id
- The client ID you have fetched from the MLS Authentication Servicetmp_ids
- The temporary random client ids generated in the previous step [Client::generate_raw_keypairs]ciphersuites
- To initialize the Client withbackend
- the KeyStore and crypto provider to read identities from
WARNING: You have absolutely NO reason to call this if you didn’t call [Client::generate_raw_keypairs] first. You have been warned!
Sourcepub async fn id(&self) -> Result<ClientId, Error>
pub async fn id(&self) -> Result<ClientId, Error>
Retrieves the client’s client id. This is free-form and not inspected.
Sourcepub async fn is_e2ei_capable(&self) -> bool
pub async fn is_e2ei_capable(&self) -> bool
Returns whether this client is E2EI capable
Trait Implementations§
Source§impl Clone for CoreCrypto
impl Clone for CoreCrypto
Source§fn clone(&self) -> CoreCrypto
fn clone(&self) -> CoreCrypto
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§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
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§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