Skip to main content

SenderKeyReceiver

Struct SenderKeyReceiver 

Source
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

Source

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.

Source

pub fn with_config( suite: CipherSuite, provider: Arc<dyn RTCCryptoProvider>, layout: SenderKeyIdLayout, config: SFrameConfig, ) -> Self

new with explicit options for the underlying SFrameContext.

Source

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.

Source

pub fn set_retained_old_keys(&mut self, keys: usize)

Sets how many keys older than the current one are kept for late ciphertexts.

Source

pub fn context(&self) -> &SFrameContext

The underlying context: its cipher suite, statistics and stored keys.

Source

pub fn current_key_id(&self) -> Option<u64>

The KID of the newest key held, if any.

Source

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.

Source

pub fn forget_old_keys(&mut self)

Removes every key but the current one.

Source

pub fn decrypt(&mut self, metadata: &[u8], ciphertext: &[u8]) -> Result<Vec<u8>>

Decrypts an SFrame ciphertext from this sender and returns the plaintext.

Source

pub fn decrypt_into( &mut self, metadata: &[u8], ciphertext: &[u8], out: &mut Vec<u8>, ) -> Result<Header>

decrypt, appending the plaintext to out. On an error out is as it was.

Trait Implementations§

Source§

impl Debug for SenderKeyReceiver

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !RefUnwindSafe for SenderKeyReceiver

§

impl !Sync for SenderKeyReceiver

§

impl !UnwindSafe for SenderKeyReceiver

§

impl Forget for SenderKeyReceiver

§

impl Freeze for SenderKeyReceiver
where *const ArcInner<dyn RTCCryptoProvider> is !null: Freeze, PhantomData<ArcInner<dyn RTCCryptoProvider>>: Freeze, *const u8 is !null: Freeze, PhantomData<(u64, Box<KeyContext>)>: Freeze, *const KeyContext is !null: Freeze, PhantomData<KeyContext>: Freeze, PhantomData<u8>: Freeze, PhantomData<u64>: Freeze,

§

impl Move for SenderKeyReceiver

§

impl Send for SenderKeyReceiver
where Arc<dyn RTCCryptoProvider>: Send, RawTable<(u64, Box<KeyContext>)>: Send, BoxRaw<KeyContext>: Send, RawVecInner: Send,

§

impl Unpin for SenderKeyReceiver
where Arc<dyn RTCCryptoProvider>: Unpin, *const u8 is !null: Unpin, Box<KeyContext>: Unpin,

§

impl UnsafeUnpin for SenderKeyReceiver

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.