KeyManager

Struct KeyManager 

Source
pub struct KeyManager;
Expand description

Key manager to maintain secret key material (like our identity key) and to generate signed public pre-key bundles.

Implementations§

Source§

impl KeyManager

Source

pub fn init( identity_secret: &SecretKey, ) -> Result<KeyManagerState, KeyManagerError>

Returns newly initialised key-manager state, holding our identity secret.

Source

pub fn init_from_prekey_bundles( identity_secret: &SecretKey, prekeys: PreKeyBundlesState, ) -> Result<KeyManagerState, KeyManagerError>

Returns newly initialised key-manager state, holding our identity secret with existing pre-key bundles.

Source

pub fn init_and_generate_prekey( identity_secret: &SecretKey, lifetime: Lifetime, rng: &Rng, ) -> Result<KeyManagerState, KeyManagerError>

Returns newly initialised key-manager state, holding our identity secret and an automatically generated, first pre-key secret which can be used to generate key-bundles.

Source

pub fn remove_expired(y: KeyManagerState) -> KeyManagerState

Remove all expired pre-key bundles from manager.

Trait Implementations§

Source§

impl Clone for KeyManager

Source§

fn clone(&self) -> KeyManager

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for KeyManager

Source§

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

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

impl IdentityManager<KeyManagerState> for KeyManager

Source§

fn identity_secret(y: &KeyManagerState) -> &SecretKey

Returns identity key secret.

Source§

impl PreKeyManager for KeyManager

Source§

fn prekey_secret<'a>( y: &'a Self::State, id: &'a PreKeyId, ) -> Result<&'a SecretKey, Self::Error>

Returns long-term pre-key secret by id.

Throws an error if pre-key was not found (for example because it expired and was removed).

Source§

fn rotate_prekey( y: Self::State, lifetime: Lifetime, rng: &Rng, ) -> Result<Self::State, Self::Error>

Generates a new long-term pre-key secret with the given lifetime.

Source§

fn prekey_bundle(y: &Self::State) -> Result<LongTermKeyBundle, Self::Error>

Returns latest, public long-term key-bundle which can be published on the network.

Note that key bundles can be expired and thus invalid, this method will return an error in this case and applications need to generate new ones when necessary.

Source§

fn generate_onetime_bundle( y: Self::State, rng: &Rng, ) -> Result<(Self::State, OneTimeKeyBundle), Self::Error>

Creates a new public one-time key-bundle.

Source§

fn use_onetime_secret( y: Self::State, id: OneTimePreKeyId, ) -> Result<(Self::State, Option<SecretKey>), Self::Error>

Returns one-time pre-key secret used by a sender during X3DH.

Throws an error when requested pre-key secret is unknown (and thus probably was already used once).

Returns none when this key-manager doesn’t have any one-time pre-keys. New ones can be created by calling generate_onetime_bundle.

Source§

type State = KeyManagerState

Source§

type Error = KeyManagerError

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
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> 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.
Source§

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

Source§

fn vzip(self) -> V