pub struct SenderKeyRatchet { /* private fields */ }Expand description
One sender’s key at a point of its ratchet: the key generation, the ratchet step and the
base_key there.
The sender holds one and advances it, installing each new base_key
under the new KID as its encryption key and removing the previous one. A receiver gets the
sender’s current base_key and KID over the secure channel and follows with a
SenderKeyReceiver.
Implementations§
Source§impl SenderKeyRatchet
impl SenderKeyRatchet
Sourcepub fn new(
suite: CipherSuite,
provider: Arc<dyn RTCCryptoProvider>,
layout: SenderKeyIdLayout,
key_generation: u64,
base_key: &[u8],
) -> Result<Self>
pub fn new( suite: CipherSuite, provider: Arc<dyn RTCCryptoProvider>, layout: SenderKeyIdLayout, key_generation: u64, base_key: &[u8], ) -> Result<Self>
A freshly distributed key: generation key_generation, ratchet step 0.
Sourcepub fn at_key_id(
suite: CipherSuite,
provider: Arc<dyn RTCCryptoProvider>,
layout: SenderKeyIdLayout,
kid: u64,
base_key: &[u8],
) -> Result<Self>
pub fn at_key_id( suite: CipherSuite, provider: Arc<dyn RTCCryptoProvider>, layout: SenderKeyIdLayout, kid: u64, base_key: &[u8], ) -> Result<Self>
The key a sender is at when it uses kid, as a participant joining mid-session learns
it: the sender’s current base_key together with its current KID.
The KID carries only the low bits of the ratchet step; they are all a receiver needs to follow.
Sourcepub fn layout(&self) -> SenderKeyIdLayout
pub fn layout(&self) -> SenderKeyIdLayout
The KID layout.
Sourcepub fn key_generation(&self) -> u64
pub fn key_generation(&self) -> u64
The key generation.
Sourcepub fn ratchet_step(&self) -> u64
pub fn ratchet_step(&self) -> u64
The ratchet step. After at_key_id it counts from the low bits the
KID carried.
Sourcepub fn base_key(&self) -> &[u8] ⓘ
pub fn base_key(&self) -> &[u8] ⓘ
The current base_key: what goes into the SFrame context under
key_id, and what a new participant is sent.
Sourcepub fn advance(&mut self) -> Result<u64>
pub fn advance(&mut self) -> Result<u64>
Ratchets one step forward and returns the new KID. The previous base_key is erased.
Sourcepub fn steps_to(&self, kid: u64) -> Option<u64>
pub fn steps_to(&self, kid: u64) -> Option<u64>
How many steps forward kid is from the current key, or None when it belongs to
another key generation (the sender distributed, or will distribute, a new key).
The count is modulo 1 << R: a KID from before the current step reads as far ahead. A
receiver therefore keeps its recent keys installed and bounds how far it follows.