Skip to main content

SenderKeyRatchet

Struct SenderKeyRatchet 

Source
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

Source

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.

Source

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.

Source

pub fn layout(&self) -> SenderKeyIdLayout

The KID layout.

Source

pub fn key_generation(&self) -> u64

The key generation.

Source

pub fn ratchet_step(&self) -> u64

The ratchet step. After at_key_id it counts from the low bits the KID carried.

Source

pub fn key_id(&self) -> u64

The KID of the current key.

Source

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.

Source

pub fn advance(&mut self) -> Result<u64>

Ratchets one step forward and returns the new KID. The previous base_key is erased.

Source

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.

Trait Implementations§

Source§

impl Debug for SenderKeyRatchet

Source§

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

Formats the value using the given formatter. Read more

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.