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
impl KeyManager
Sourcepub fn init(
identity_secret: &SecretKey,
) -> Result<KeyManagerState, KeyManagerError>
pub fn init( identity_secret: &SecretKey, ) -> Result<KeyManagerState, KeyManagerError>
Returns newly initialised key-manager state, holding our identity secret.
Sourcepub fn init_from_prekey_bundles(
identity_secret: &SecretKey,
prekeys: PreKeyBundlesState,
) -> Result<KeyManagerState, KeyManagerError>
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.
Sourcepub fn init_and_generate_prekey(
identity_secret: &SecretKey,
lifetime: Lifetime,
rng: &Rng,
) -> Result<KeyManagerState, KeyManagerError>
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.
Sourcepub fn remove_expired(y: KeyManagerState) -> KeyManagerState
pub fn remove_expired(y: KeyManagerState) -> KeyManagerState
Remove all expired pre-key bundles from manager.
Trait Implementations§
Source§impl Clone for KeyManager
impl Clone for KeyManager
Source§fn clone(&self) -> KeyManager
fn clone(&self) -> KeyManager
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for KeyManager
impl Debug for KeyManager
Source§impl IdentityManager<KeyManagerState> for KeyManager
impl IdentityManager<KeyManagerState> for KeyManager
Source§fn identity_secret(y: &KeyManagerState) -> &SecretKey
fn identity_secret(y: &KeyManagerState) -> &SecretKey
Returns identity key secret.
Source§impl PreKeyManager for KeyManager
impl PreKeyManager for KeyManager
Source§fn prekey_secret<'a>(
y: &'a Self::State,
id: &'a PreKeyId,
) -> Result<&'a SecretKey, Self::Error>
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>
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>
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>
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>
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.