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>
impl<A: Aead, Kdf: KdfTrait, Kem: KemTrait> AeadCtxR<A, Kdf, Kem>
sourcepub fn open_in_place_detached(
&mut self,
ciphertext: &mut [u8],
aad: &[u8],
tag: &AeadTag<A>
) -> Result<(), HpkeError>
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.
sourcepub fn open(
&mut self,
ciphertext: &[u8],
aad: &[u8]
) -> Result<Vec<u8>, HpkeError>
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)
.
sourcepub fn export(&self, info: &[u8], out_buf: &mut [u8]) -> Result<(), HpkeError>
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.