pub trait Cipher: Send + Sync {
// Required methods
fn encrypt(
&self,
plaintext: &[u8],
associated_data: Option<&[u8]>,
) -> CryptoResult<Vec<u8>>;
fn decrypt(
&self,
ciphertext: &[u8],
associated_data: Option<&[u8]>,
) -> CryptoResult<Vec<u8>>;
fn algorithm(&self) -> &'static str;
fn key_size(&self) -> usize;
fn nonce_size(&self) -> usize;
fn tag_size(&self) -> usize;
}Expand description
Trait for symmetric encryption ciphers.
Implementors provide authenticated encryption with associated data (AEAD).
Required Methods§
Sourcefn encrypt(
&self,
plaintext: &[u8],
associated_data: Option<&[u8]>,
) -> CryptoResult<Vec<u8>>
fn encrypt( &self, plaintext: &[u8], associated_data: Option<&[u8]>, ) -> CryptoResult<Vec<u8>>
Encrypt plaintext with optional associated data.
Returns the ciphertext with embedded nonce and authentication tag.
Sourcefn decrypt(
&self,
ciphertext: &[u8],
associated_data: Option<&[u8]>,
) -> CryptoResult<Vec<u8>>
fn decrypt( &self, ciphertext: &[u8], associated_data: Option<&[u8]>, ) -> CryptoResult<Vec<u8>>
Decrypt ciphertext with optional associated data.
The ciphertext must include the nonce and authentication tag.
Sourcefn nonce_size(&self) -> usize
fn nonce_size(&self) -> usize
Get the nonce size in bytes.
Implementors§
impl Cipher for Aes256GcmCipher
Available on crate feature
aes only.