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>{
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§
type Nonce: RandomFixedSizeCBytes<NONCE_LENGTH>
Provided Methods§
sourcefn encrypt(
&self,
nonce: &Self::Nonce,
plaintext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>, CryptoCoreError>
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 useplaintext
: plaintext messageaad
: optional data to use in the authentication method, must use the same for decryption
sourcefn decrypt(
&self,
nonce: &Self::Nonce,
ciphertext: &[u8],
aad: Option<&[u8]>,
) -> Result<Vec<u8>, CryptoCoreError>
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 useciphertext
: ciphertext messageaad
: optional data to use in the authentication method, must use the same for encryption
Object Safety§
This trait is not object safe.