Skip to main content

RecipientContext

Struct RecipientContext 

Source
pub struct RecipientContext(/* private fields */);
Expand description

HPKE recipient context. Callers may use open() to decrypt messages from the sender.

Implementations§

Source§

impl RecipientContext

Source

pub fn new( params: &Params, recipient_priv_key: &[u8], encapsulated_key: &[u8], info: &[u8], ) -> Option<Self>

New implements the SetupBaseR HPKE operation, which decapsulates the shared secret in encapsulated_key with recipient_priv_key and sets up a recipient context. These are stored and returned in the newly created RecipientContext.

Note that encapsulated_key may be invalid, in which case this function will return an error.

On success, callers may use open() to decrypt messages from the sender.

Source

pub fn open(&mut self, ciphertext: &[u8], aad: &[u8]) -> Option<Vec<u8>>

Open authenticates aad and decrypts ciphertext. It returns an error on failure.

Note that HPKE encryption is stateful and ordered. The sender’s first call to seal() must correspond to the recipient’s first call to open(), etc.

Source

pub fn export(&mut self, context: &[u8], out_len: usize) -> Vec<u8>

Exports a secret of length out_len from the HPKE context using context as the context string.

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

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.