Trait cosmian_crypto_core::Dem

source ·
pub trait Dem<const KEY_LENGTH: usize, const NONCE_LENGTH: usize, const MAC_LENGTH: usize, RustCryptoBackend>: Instantiable<KEY_LENGTH> + Deref<Target = RustCryptoBackend>
where RustCryptoBackend: Aead + KeyInit,
{ type Nonce: RandomFixedSizeCBytes<NONCE_LENGTH>; // Provided methods fn encrypt( &self, nonce: &Self::Nonce, plaintext: &[u8], aad: Option<&[u8]>, ) -> Result<Vec<u8>, CryptoCoreError> { ... } fn decrypt( &self, nonce: &Self::Nonce, ciphertext: &[u8], aad: Option<&[u8]>, ) -> Result<Vec<u8>, CryptoCoreError> { ... } }
Expand description

Defines a DEM based on a symmetric scheme as defined in section 9.1 of the ISO 2004.

Required Associated Types§

Provided Methods§

source

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

Encrypts a plaintext using the given symmetric key.

The authentication tag is appended to the ciphertext.

  • nonce : the Nonce to use
  • plaintext : plaintext message
  • aad : optional data to use in the authentication method, must use the same for decryption
source

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

Decrypts a ciphertext using the given symmetric key.

The authentication tag must be appended to the ciphertext.

  • nonce : the Nonce to use
  • ciphertext : ciphertext message
  • aad : optional data to use in the authentication method, must use the same for encryption

Object Safety§

This trait is not object safe.

Implementors§

source§

impl Dem<{ Self::KEY_LENGTH }, { Self::NONCE_LENGTH }, { Self::MAC_LENGTH }, AesGcm<Aes128, UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>>> for Aes128Gcm

§

type Nonce = Nonce<{ Self::NONCE_LENGTH }>

source§

impl Dem<{ Self::KEY_LENGTH }, { Self::NONCE_LENGTH }, { Self::MAC_LENGTH }, AesGcm<Aes256, UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>>> for Aes256Gcm

§

type Nonce = Nonce<{ Self::NONCE_LENGTH }>

source§

impl Dem<{ Self::KEY_LENGTH }, { Self::NONCE_LENGTH }, { Self::MAC_LENGTH }, ChaChaPoly1305<StreamCipherCoreWrapper<ChaChaCore<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B0>>>>> for ChaCha20Poly1305

§

type Nonce = Nonce<{ Self::NONCE_LENGTH }>

source§

impl Dem<{ Self::KEY_LENGTH }, { Self::NONCE_LENGTH }, { Self::MAC_LENGTH }, ChaChaPoly1305<StreamCipherCoreWrapper<XChaChaCore<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B1>, B0>>>, UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B1>, B0>, B0>, B0>>> for XChaCha20Poly1305

§

type Nonce = Nonce<{ Self::NONCE_LENGTH }>