pub trait Aead {
type Tag: AsRef<[u8]>;
type Nonce: AsRef<[u8]>;
// Required methods
fn seal(&self, nonce: &Self::Nonce, plaintext: &[u8], ad: &[u8]) -> Vec<u8>;
fn seal_in_place(
&self,
nonce: &Self::Nonce,
plaintext: &mut [u8],
ad: &[u8],
) -> Self::Tag;
fn open(
&self,
nonce: &Self::Nonce,
ciphertext: &[u8],
ad: &[u8],
) -> Option<Vec<u8>>;
fn open_in_place(
&self,
nonce: &Self::Nonce,
ciphertext: &mut [u8],
tag: &Self::Tag,
ad: &[u8],
) -> Result<(), InvalidCiphertext>;
}Expand description
Authenticated Encryption with Associated Data (AEAD) algorithm trait.
Required Associated Types§
Required Methods§
Sourcefn seal(&self, nonce: &Self::Nonce, plaintext: &[u8], ad: &[u8]) -> Vec<u8>
fn seal(&self, nonce: &Self::Nonce, plaintext: &[u8], ad: &[u8]) -> Vec<u8>
Encrypt and authenticate plaintext, and authenticate ad, returning
the result as a freshly allocated Vec. The nonce must never
be used in any sealing operation with the same key, ever again.
Sourcefn seal_in_place(
&self,
nonce: &Self::Nonce,
plaintext: &mut [u8],
ad: &[u8],
) -> Self::Tag
fn seal_in_place( &self, nonce: &Self::Nonce, plaintext: &mut [u8], ad: &[u8], ) -> Self::Tag
Encrypt and authenticate plaintext, and authenticate ad, writing
the ciphertext over plaintext and additionally returning the calculated
tag, which is usually appended to the ciphertext. The nonce must never
be used in any sealing operation with the same key, ever again.
Sourcefn open(
&self,
nonce: &Self::Nonce,
ciphertext: &[u8],
ad: &[u8],
) -> Option<Vec<u8>>
fn open( &self, nonce: &Self::Nonce, ciphertext: &[u8], ad: &[u8], ) -> Option<Vec<u8>>
Authenticate ciphertext and ad and, if valid, decrypt ciphertext,
returning the original plaintext in a newly allocated Vec. The nonce
must be the same value as given to the sealing operation that produced
ciphertext.
Sourcefn open_in_place(
&self,
nonce: &Self::Nonce,
ciphertext: &mut [u8],
tag: &Self::Tag,
ad: &[u8],
) -> Result<(), InvalidCiphertext>
fn open_in_place( &self, nonce: &Self::Nonce, ciphertext: &mut [u8], tag: &Self::Tag, ad: &[u8], ) -> Result<(), InvalidCiphertext>
Authenticate ciphertext and ad using tag and, if valid, decrypt
ciphertext in place. The nonce must be the same value as given to
the sealing operation that produced ciphertext.