Struct hpke::aead::AeadCtxR

source ·
pub struct AeadCtxR<A: Aead, Kdf: KdfTrait, Kem: KemTrait>(_);
Expand description

The HPKE receiver’s context. This is what you use to open ciphertexts and export secrets.

Implementations§

source§

impl<A: Aead, Kdf: KdfTrait, Kem: KemTrait> AeadCtxR<A, Kdf, Kem>

source

pub fn open_in_place_detached( &mut self, ciphertext: &mut [u8], aad: &[u8], tag: &AeadTag<A> ) -> Result<(), HpkeError>

Does a “detached open in place”, meaning it overwrites ciphertext with the resulting plaintext, and takes the tag as a separate input.

Return Value

Returns Ok(()) on success. If this context has been used for so many encryptions that the sequence number overflowed, returns Err(HpkeError::MessageLimitReached). If this happens, ciphertext will be unmodified. If the tag fails to validate, returns Err(HpkeError::OpenError). If this happens, ciphertext is in an undefined state.

source

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

Opens the given ciphertext and returns a plaintext

Return Value

Returns Ok(()) on success. If this context has been used for so many encryptions that the sequence number overflowed, returns Err(HpkeError::MessageLimitReached). If the tag fails to validate, returns Err(HpkeError::OpenError).

source

pub fn export(&self, info: &[u8], out_buf: &mut [u8]) -> Result<(), HpkeError>

Fills a given buffer with secret bytes derived from this encryption context. This value does not depend on sequence number, so it is constant for the lifetime of this context.

Return Value

Returns Ok(()) on success. If the buffer length is more than about 255x the digest size (in bytes) of the underlying hash function, returns an Err(HpkeError::KdfOutputTooLong). The exact number is given in the “Input Length Restrictions” section of the spec. Just don’t use to fill massive buffers and you’ll be fine.

Auto Trait Implementations§

§

impl<A, Kdf, Kem> RefUnwindSafe for AeadCtxR<A, Kdf, Kem>where Kem: RefUnwindSafe, <A as Aead>::AeadImpl: RefUnwindSafe, <<<A as Aead>::AeadImpl as AeadCore>::NonceSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe, <<<Kdf as Kdf>::HashImpl as OutputSizeUser>::OutputSize as ArrayLength<u8>>::ArrayType: RefUnwindSafe,

§

impl<A, Kdf, Kem> Send for AeadCtxR<A, Kdf, Kem>where Kem: Send, <A as Aead>::AeadImpl: Send,

§

impl<A, Kdf, Kem> Sync for AeadCtxR<A, Kdf, Kem>where Kem: Sync, <A as Aead>::AeadImpl: Sync,

§

impl<A, Kdf, Kem> Unpin for AeadCtxR<A, Kdf, Kem>where Kem: Unpin, <A as Aead>::AeadImpl: Unpin, <<<A as Aead>::AeadImpl as AeadCore>::NonceSize as ArrayLength<u8>>::ArrayType: Unpin, <<<Kdf as Kdf>::HashImpl as OutputSizeUser>::OutputSize as ArrayLength<u8>>::ArrayType: Unpin,

§

impl<A, Kdf, Kem> UnwindSafe for AeadCtxR<A, Kdf, Kem>where Kem: UnwindSafe, <A as Aead>::AeadImpl: UnwindSafe, <<<A as Aead>::AeadImpl as AeadCore>::NonceSize as ArrayLength<u8>>::ArrayType: UnwindSafe, <<<Kdf as Kdf>::HashImpl as OutputSizeUser>::OutputSize as ArrayLength<u8>>::ArrayType: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.