Skip to main content

Aead

Trait Aead 

Source
pub trait Aead<const KEY_LEN: usize, const NONCE_LEN: usize> {
    // Required methods
    fn encrypt_in_place<'a>(
        &mut self,
        key: CryptoSensitiveRef<'_, KEY_LEN>,
        nonce: CryptoSensitiveRef<'_, NONCE_LEN>,
        aad: &[u8],
        data: &'a mut [u8],
        data_len: usize,
    ) -> Result<&'a [u8], Error>;
    fn decrypt_in_place<'a>(
        &mut self,
        key: CryptoSensitiveRef<'_, KEY_LEN>,
        nonce: CryptoSensitiveRef<'_, NONCE_LEN>,
        aad: &[u8],
        data: &'a mut [u8],
    ) -> Result<&'a [u8], Error>;
}
Expand description

Trait representing an Authenticated Encryption with Associated Data (AEAD) algorithm.

Required Methods§

Source

fn encrypt_in_place<'a>( &mut self, key: CryptoSensitiveRef<'_, KEY_LEN>, nonce: CryptoSensitiveRef<'_, NONCE_LEN>, aad: &[u8], data: &'a mut [u8], data_len: usize, ) -> Result<&'a [u8], Error>

Encrypt the given data in place, using the given key, nonce and additional authenticated data (AAD).

§Arguments
  • key: The AEAD key.
  • nonce: The AEAD nonce.
  • aad: The additional authenticated data.
  • data: The data to encrypt, which will be modified in place to contain the ciphertext and tag.
  • data_len: The length of the plaintext data in data.
§Returns
  • On success, returns a slice containing the ciphertext and tag.
  • On failure, returns an Error.
Source

fn decrypt_in_place<'a>( &mut self, key: CryptoSensitiveRef<'_, KEY_LEN>, nonce: CryptoSensitiveRef<'_, NONCE_LEN>, aad: &[u8], data: &'a mut [u8], ) -> Result<&'a [u8], Error>

Decrypt the given data in place, using the given key, nonce and additional authenticated data (AAD).

§Arguments
  • key: The AEAD key.
  • nonce: The AEAD nonce.
  • aad: The additional authenticated data.
  • data: The data to decrypt, which will be modified in place to contain the plaintext.
§Returns
  • On success, returns a slice containing the plaintext.
  • On failure, returns an Error.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<const KEY_LEN: usize, const NONCE_LEN: usize, T> Aead<KEY_LEN, NONCE_LEN> for &mut T
where T: Aead<KEY_LEN, NONCE_LEN>,

Source§

fn encrypt_in_place<'a>( &mut self, key: CryptoSensitiveRef<'_, KEY_LEN>, nonce: CryptoSensitiveRef<'_, NONCE_LEN>, aad: &[u8], data: &'a mut [u8], data_len: usize, ) -> Result<&'a [u8], Error>

Source§

fn decrypt_in_place<'a>( &mut self, key: CryptoSensitiveRef<'_, KEY_LEN>, nonce: CryptoSensitiveRef<'_, NONCE_LEN>, aad: &[u8], data: &'a mut [u8], ) -> Result<&'a [u8], Error>

Implementors§

Source§

impl<const KEY_LEN: usize, const NONCE_LEN: usize> Aead<KEY_LEN, NONCE_LEN> for DummyCrypto