Struct hpke::aead::AeadCtxS

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

The HPKE senders’s context. This is what you use to seal plaintexts and export secrets.

Implementations§

source§

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

source

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

Does a “detached seal in place”, meaning it overwrites plaintext with the resulting ciphertext, and returns the resulting authentication tag

Return Value

Returns Ok(tag) on success. If this context has been used for so many encryptions that the sequence number overflowed, returns Err(HpkeError::MessageLimitReached). If this happens, plaintext will be unmodified. If an error happened during encryption, returns Err(HpkeError::SealError). If this happens, the contents of plaintext is undefined.

source

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

Seals the given plaintext and returns the ciphertext

Return Value

Returns Ok(ciphertext) on success. If this context has been used for so many encryptions that the sequence number overflowed, returns Err(HpkeError::MessageLimitReached). If an error happened during encryption, returns Err(HpkeError::SealError).

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 255x the digest size (in bytes) of the underlying hash function, returns an Err(HpkeError::KdfOutputTooLong). Just don’t use to fill massive buffers and you’ll be fine.

Auto Trait Implementations§

§

impl<A, Kdf, Kem> RefUnwindSafe for AeadCtxS<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 AeadCtxS<A, Kdf, Kem>where Kem: Send, <A as Aead>::AeadImpl: Send,

§

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

§

impl<A, Kdf, Kem> Unpin for AeadCtxS<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 AeadCtxS<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.