Aead

Trait Aead 

Source
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§

Source

type Nonce

The nonce/IV type used by this cipher

Required Methods§

Source

fn encrypt( &self, nonce: &Self::Nonce, plaintext: &[u8], aad: Option<&[u8]>, ) -> Result<Vec<u8>>

Encrypts plaintext with associated data

Source

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

Source

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.

Implementors§