Skip to main content

Aead

Trait Aead 

Source
pub trait Aead {
    type Tag;

    // Required methods
    fn encrypt_in_place(
        &self,
        nonce: &[u8],
        aad: &[u8],
        data: &mut [u8],
    ) -> Self::Tag;
    fn decrypt_in_place(
        &self,
        nonce: &[u8],
        aad: &[u8],
        data: &mut [u8],
        tag: &Self::Tag,
    ) -> bool;

    // Provided methods
    fn encrypt(
        &self,
        nonce: &[u8],
        aad: &[u8],
        plaintext: &[u8],
    ) -> (Vec<u8>, Self::Tag) { ... }
    fn decrypt(
        &self,
        nonce: &[u8],
        aad: &[u8],
        ciphertext: &[u8],
        tag: &Self::Tag,
    ) -> Option<Vec<u8>> { ... }
}
Expand description

Common interface for AEAD constructions with detached tags.

Required Associated Types§

Source

type Tag

Detached authentication tag type.

Required Methods§

Source

fn encrypt_in_place( &self, nonce: &[u8], aad: &[u8], data: &mut [u8], ) -> Self::Tag

Encrypt data in place and return its authentication tag.

Source

fn decrypt_in_place( &self, nonce: &[u8], aad: &[u8], data: &mut [u8], tag: &Self::Tag, ) -> bool

Decrypt data in place after authenticating tag.

Provided Methods§

Source

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

Encrypt plaintext and return (ciphertext, tag).

Source

fn decrypt( &self, nonce: &[u8], aad: &[u8], ciphertext: &[u8], tag: &Self::Tag, ) -> Option<Vec<u8>>

Decrypt ciphertext and return plaintext on successful authentication.

Implementors§

Source§

impl Aead for ChaCha20Poly1305

Source§

type Tag = [u8; 16]

Source§

impl Aead for Aes128GcmSiv

Source§

type Tag = [u8; 16]

Source§

impl Aead for Aes256GcmSiv

Source§

type Tag = [u8; 16]

Source§

impl<C: BlockCipher> Aead for Eax<C>

Source§

type Tag = [u8; 16]

Source§

impl<C: BlockCipher> Aead for Ocb<C>

Source§

type Tag = [u8; 16]

Source§

impl<C: BlockCipher> Aead for Siv<C>

Source§

type Tag = [u8; 16]

Source§

impl<C: BlockCipher> Aead for Gcm<C>

Source§

type Tag = [u8; 16]

Source§

impl<C: BlockCipher> Aead for GcmVt<C>

Source§

type Tag = [u8; 16]

Source§

impl<C: BlockCipher, const TAG_LEN: usize> Aead for Ccm<C, TAG_LEN>