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>
impl<A: Aead, Kdf: KdfTrait, Kem: KemTrait> AeadCtxS<A, Kdf, Kem>
sourcepub fn seal_in_place_detached(
&mut self,
plaintext: &mut [u8],
aad: &[u8]
) -> Result<AeadTag<A>, HpkeError>
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.
sourcepub fn seal(
&mut self,
plaintext: &[u8],
aad: &[u8]
) -> Result<Vec<u8>, HpkeError>
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)
.
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 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.