pub struct SenderKeyReceiver { /* private fields */ }Expand description
The receiving side of one sender in the sender-keys scheme.
It decrypts with the keys it holds, and when the sender signals a ratchet step by a KID with a higher step, derives the keys up to it. The KID is not authenticated until a key has been derived from it, so the ratchet moves only once a ciphertext has authenticated under the new key: a forged KID costs a bounded number of derivations and changes nothing.
Old keys stay for out-of-order delivery, a bounded number of them; an application that
wants them gone sooner calls forget_old_keys.
Implementations§
Source§impl SenderKeyReceiver
impl SenderKeyReceiver
Sourcepub fn new(
suite: CipherSuite,
provider: Arc<dyn RTCCryptoProvider>,
layout: SenderKeyIdLayout,
) -> Self
pub fn new( suite: CipherSuite, provider: Arc<dyn RTCCryptoProvider>, layout: SenderKeyIdLayout, ) -> Self
A receiver for one sender whose KIDs follow layout, with no key yet.
Sourcepub fn with_config(
suite: CipherSuite,
provider: Arc<dyn RTCCryptoProvider>,
layout: SenderKeyIdLayout,
config: SFrameConfig,
) -> Self
pub fn with_config( suite: CipherSuite, provider: Arc<dyn RTCCryptoProvider>, layout: SenderKeyIdLayout, config: SFrameConfig, ) -> Self
new with explicit options for the underlying SFrameContext.
Sourcepub fn set_max_ratchet_steps(&mut self, steps: u64)
pub fn set_max_ratchet_steps(&mut self, steps: u64)
Sets how many ratchet steps one ciphertext may make the receiver follow. A KID further ahead is treated as unknown.
Sourcepub fn set_retained_old_keys(&mut self, keys: usize)
pub fn set_retained_old_keys(&mut self, keys: usize)
Sets how many keys older than the current one are kept for late ciphertexts.
Sourcepub fn context(&self) -> &SFrameContext
pub fn context(&self) -> &SFrameContext
The underlying context: its cipher suite, statistics and stored keys.
Sourcepub fn current_key_id(&self) -> Option<u64>
pub fn current_key_id(&self) -> Option<u64>
The KID of the newest key held, if any.
Sourcepub fn set_key(&mut self, kid: u64, base_key: &[u8]) -> Result<()>
pub fn set_key(&mut self, kid: u64, base_key: &[u8]) -> Result<()>
Installs the base_key the sender distributed, for the KID it is used under: the first
key, a new key generation, or the current key of a session joined midway.
Sourcepub fn forget_old_keys(&mut self)
pub fn forget_old_keys(&mut self)
Removes every key but the current one.