Skip to main content

DryocAeadEnvelope

Type Alias DryocAeadEnvelope 

Source
pub type DryocAeadEnvelope<Nonce, Mac, Data> = AeadEnvelope<XChaCha20Poly1305Ietf, Nonce, Mac, Data>;
Expand description

XChaCha20-Poly1305-IETF AEAD envelope with stored nonce.

Aliased Type§

pub struct DryocAeadEnvelope<Nonce, Mac, Data> { /* private fields */ }

Implementations§

Source§

impl DryocAeadEnvelope<Nonce, Mac, Vec<u8>>

Source

pub fn seal_to_vec<Message: Bytes + ?Sized, SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>( message: &Message, associated_data: Option<&[u8]>, key: &SecretKey, ) -> Result<Self, Error>

Encrypts a message with a generated nonce and returns a VecEnvelope.

§Errors

Returns an error if the message exceeds the construction’s maximum length.

§Panics

Panics if the operating system’s random number generator fails.

Source

pub fn open_to_vec<SecretKey: ByteArray<CRYPTO_AEAD_XCHACHA20POLY1305_IETF_KEYBYTES>>( &self, associated_data: Option<&[u8]>, key: &SecretKey, ) -> Result<Vec<u8>, Error>

Decrypts this envelope and returns the plaintext as a Vec.

§Errors

Returns an error if the ciphertext exceeds the construction’s maximum length or authentication fails because the key, associated data, stored nonce, ciphertext, or tag does not match.

Source

pub fn into_vec(self) -> Vec<u8>

Consumes this envelope and returns it as nonce || ciphertext || tag.