Aead

Trait Aead 

Source
pub trait Aead<const KEY_LEN: usize, const TAG_LEN: usize, const NONCE_LEN: usize> {
    // Required methods
    fn keygen(
        key: &mut [U8; KEY_LEN],
        rand: &[U8; KEY_LEN],
    ) -> Result<(), KeyGenError>;
    fn encrypt(
        ciphertext: &mut [u8],
        tag: &mut [U8; TAG_LEN],
        key: &[U8; KEY_LEN],
        nonce: &[U8; NONCE_LEN],
        aad: &[u8],
        plaintext: &[U8],
    ) -> Result<(), EncryptError>;
    fn decrypt(
        plaintext: &mut [U8],
        key: &[U8; KEY_LEN],
        nonce: &[U8; NONCE_LEN],
        aad: &[u8],
        ciphertext: &[u8],
        tag: &[U8; TAG_LEN],
    ) -> Result<(), DecryptError>;
}
Expand description

An Authenticated Encryption with Associated Data (AEAD) scheme. This trait is low-level and is mostly used for implementing other, more usable APIs.

Some implementors of this trait may impose stronger restrictions on the inputs than described here. Check the documentation of the types implementing this trait to make sure which inputs are valid.

Required Methods§

Source

fn keygen( key: &mut [U8; KEY_LEN], rand: &[U8; KEY_LEN], ) -> Result<(), KeyGenError>

Generate a new key. Consumes the entire randomnes.

Source

fn encrypt( ciphertext: &mut [u8], tag: &mut [U8; TAG_LEN], key: &[U8; KEY_LEN], nonce: &[U8; NONCE_LEN], aad: &[u8], plaintext: &[U8], ) -> Result<(), EncryptError>

Encrypt a plaintext message, producing a ciphertext and an authentication tag. The arguments plaintext and ciphertext must have the same length.

Source

fn decrypt( plaintext: &mut [U8], key: &[U8; KEY_LEN], nonce: &[U8; NONCE_LEN], aad: &[u8], ciphertext: &[u8], tag: &[U8; TAG_LEN], ) -> Result<(), DecryptError>

Decrypt a ciphertext, verifying its authenticity. The arguments plaintext and ciphertext must have the same length.

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§