Skip to main content

Mode

Enum Mode 

Source
pub enum Mode<'a> {
    Base,
    PreSharedKey {
        pre_shared_key: &'a [u8],
        pre_shared_key_id: &'a [u8],
    },
}
Expand description

The HPKE session mode, shared by the sender and recipient roles.

The mode selects whether the key schedule is bound to a pre-shared key (Mode::PreSharedKey) or not (Mode::Base).

Pre-shared key bytes and their identifier are carried together, so the inconsistent inputs rejected by the specification cannot be expressed.

draft-ietf-hpke-hpke-05 removed the asymmetric authenticated modes of RFC 9180 (mode_auth and mode_auth_psk). For sender identity authentication, sign the (encapped_key, ciphertext) tuple (see the crate documentation); a pre-shared key only proves possession of the key.

Variants§

§

Base

No sender authentication.

§

PreSharedKey

Pre-shared key mode: the shared key is mixed into the key schedule, proving possession of it. This does not authenticate a sender identity.

Fields

§pre_shared_key: &'a [u8]

The pre-shared key. MUST contain at least 32 bytes of entropy.

§pre_shared_key_id: &'a [u8]

A public identifier for the pre-shared key.

It’s purpose is let a recipient pick which PSK to use out of several it holds, and to be bound into the key schedule so a wrong id yields a different key.

As per the spec, pre_shared_key_id MUST not be empty in pre-shared key mode. We recommend the Nil UUID (00000000-0000-0000-0000-000000000000) if you don’t have a relevant identifier for the pre-shared key.

Auto Trait Implementations§

§

impl<'a> Freeze for Mode<'a>

§

impl<'a> RefUnwindSafe for Mode<'a>

§

impl<'a> Send for Mode<'a>

§

impl<'a> Sync for Mode<'a>

§

impl<'a> Unpin for Mode<'a>

§

impl<'a> UnsafeUnpin for Mode<'a>

§

impl<'a> UnwindSafe for Mode<'a>

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, 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.