pub trait Aead: SymmetricCipher {
type Nonce;
// Required methods
fn encrypt(
&self,
nonce: &Self::Nonce,
plaintext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>>;
fn decrypt(
&self,
nonce: &Self::Nonce,
ciphertext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>>;
fn generate_nonce() -> Self::Nonce;
}Expand description
Trait for Authenticated Encryption with Associated Data
Required Associated Types§
Required Methods§
Sourcefn encrypt(
&self,
nonce: &Self::Nonce,
plaintext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>>
fn encrypt( &self, nonce: &Self::Nonce, plaintext: &[u8], aad: Option<&[u8]>, ) -> Result<Vec<u8>>
Encrypts plaintext with associated data
Sourcefn decrypt(
&self,
nonce: &Self::Nonce,
ciphertext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>>
fn decrypt( &self, nonce: &Self::Nonce, ciphertext: &[u8], aad: Option<&[u8]>, ) -> Result<Vec<u8>>
Decrypts ciphertext with associated data Returns an error if authentication fails
Sourcefn generate_nonce() -> Self::Nonce
fn generate_nonce() -> Self::Nonce
Generates a secure random nonce
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.