Skip to main content

CryptoProvider

Struct CryptoProvider 

Source
pub struct CryptoProvider { /* private fields */ }
Expand description

The MLS crypto provider

Implementations§

Source§

impl CryptoProvider

Source

pub fn new(key_store: Arc<Database>) -> Self

Construct a crypto provider with defaults and a given Database.

See also:

Source

pub fn new_with_pki_env( key_store: Arc<Database>, pki_env: Option<Arc<PkiEnvironment>>, ) -> Self

Construct a crypto provider with the given database and the PKI environment.

Source

pub async fn set_pki_environment( &mut self, pki_env: Option<Arc<PkiEnvironment>>, )

Set pki_env to a new shared pki environment provider

Source

pub async fn is_pki_env_setup(&self) -> bool

Returns whether we have a PKI env setup

Source

pub fn reseed(&self, entropy_seed: Option<EntropySeed>) -> Result<(), Error>

Reseeds the internal CSPRNG.

If None is provided, the new seed is pulled from the current OS target’s capabilities.

Note that this replaces the generator’s state rather than mixing the new seed into it, so the output after this call depends only on the seed given here.

Source

pub fn hpke_seal_psk( &self, config: HpkeConfig, pk_r: &[u8], info: &[u8], aad: &[u8], psk: &[u8], psk_id: &[u8], ptxt: &[u8], ) -> Result<HpkeCiphertext, CryptoError>

Encrypt ptxt via HPKE PSK mode.

Source

pub fn hpke_open_psk( &self, config: HpkeConfig, input: &HpkeCiphertext, sk_r: &[u8], info: &[u8], aad: &[u8], psk: &[u8], psk_id: &[u8], ) -> Result<Vec<u8>, CryptoError>

Decrypt input via HPKE PSK mode.

Trait Implementations§

Source§

impl Clone for CryptoProvider

Source§

fn clone(&self) -> CryptoProvider

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CryptoProvider

Source§

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

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

impl OpenMlsCrypto for &CryptoProvider

Passthrough implementation of crypto functionality for references to MlsCryptoProvider.

Source§

fn supports(&self, ciphersuite: Ciphersuite) -> Result<(), CryptoError>

Check whether the Ciphersuite is supported by the backend or not. Read more
Source§

fn supported_ciphersuites(&self) -> Vec<Ciphersuite>

Returns the list of supported Ciphersuites.
Source§

fn hkdf_extract( &self, hash_type: HashType, salt: &[u8], ikm: &[u8], ) -> Result<SecretVLBytes, CryptoError>

HKDF extract. Read more
Source§

fn hkdf_expand( &self, hash_type: HashType, prk: &[u8], info: &[u8], okm_len: usize, ) -> Result<SecretVLBytes, CryptoError>

HKDF expand. Read more
Source§

fn hash(&self, hash_type: HashType, data: &[u8]) -> Result<Vec<u8>, CryptoError>

Hash the data. Read more
Source§

fn aead_encrypt( &self, alg: AeadType, key: &[u8], data: &[u8], nonce: &[u8], aad: &[u8], ) -> Result<Vec<u8>, CryptoError>

AEAD encrypt with the given parameters. Read more
Source§

fn aead_decrypt( &self, alg: AeadType, key: &[u8], ct_tag: &[u8], nonce: &[u8], aad: &[u8], ) -> Result<Vec<u8>, CryptoError>

AEAD decrypt with the given parameters. Read more
Source§

fn signature_key_gen( &self, alg: SignatureScheme, ) -> Result<(Vec<u8>, Vec<u8>), CryptoError>

Generate a signature key. Read more
Source§

fn signature_public_key_len(&self, alg: SignatureScheme) -> usize

Gives the length of a signature public key, in bytes
Source§

fn validate_signature_key( &self, alg: SignatureScheme, key: &[u8], ) -> Result<(), CryptoError>

Parses and validate a signature public key
Source§

fn verify_signature( &self, alg: SignatureScheme, data: &[u8], pk: &[u8], signature: &[u8], ) -> Result<(), CryptoError>

Verify the signature Read more
Source§

fn sign( &self, alg: SignatureScheme, data: &[u8], key: &[u8], ) -> Result<Vec<u8>, CryptoError>

Sign with the given parameters. Read more
Source§

fn hpke_seal( &self, config: HpkeConfig, pk_r: &[u8], info: &[u8], aad: &[u8], ptxt: &[u8], ) -> Result<HpkeCiphertext, CryptoError>

HPKE single-shot encryption of ptxt to pk_r, using info and aad.
Source§

fn hpke_open( &self, config: HpkeConfig, input: &HpkeCiphertext, sk_r: &[u8], info: &[u8], aad: &[u8], ) -> Result<Vec<u8>, CryptoError>

HPKE single-shot decryption of input with sk_r, using info and aad.
Source§

fn hpke_setup_sender_and_export( &self, config: HpkeConfig, pk_r: &[u8], info: &[u8], exporter_context: &[u8], exporter_length: usize, ) -> Result<(KemOutput, ExporterSecret), CryptoError>

HPKE single-shot setup of a sender and immediate export a secret. Read more
Source§

fn hpke_setup_receiver_and_export( &self, config: HpkeConfig, enc: &[u8], sk_r: &[u8], info: &[u8], exporter_context: &[u8], exporter_length: usize, ) -> Result<ExporterSecret, CryptoError>

HPKE single-shot setup of a receiver and immediate export a secret. Read more
Source§

fn derive_hpke_keypair( &self, config: HpkeConfig, ikm: &[u8], ) -> Result<HpkeKeyPair, CryptoError>

Derive a new HPKE keypair from a given input key material.
Source§

impl OpenMlsCryptoProvider for CryptoProvider

Source§

type CryptoProvider = RustCrypto

Source§

type RandProvider = RustCrypto

Source§

type KeyStoreProvider = Database

Source§

type AuthenticationServiceProvider = AuthenticationService

Source§

fn crypto(&self) -> &Self::CryptoProvider

Get the crypto provider.
Source§

fn rand(&self) -> &Self::RandProvider

Get the randomness provider.
Source§

fn key_store(&self) -> &Self::KeyStoreProvider

Get the key store provider.
Source§

fn authentication_service(&self) -> &Self::AuthenticationServiceProvider

Get the authentication service

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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
§

impl<T> MaybeSendSync for T

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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