pub trait AeadCipher {
type Algorithm: AeadAlgorithm;
type Key: AsRef<[u8]> + AsMut<[u8]> + Clone + Zeroize;
// Required methods
fn new(key: &Self::Key) -> Result<Self>
where Self: Sized;
fn encrypt(&self) -> impl AeadEncryptOperation<'_, Self::Algorithm>;
fn decrypt(&self) -> impl AeadDecryptOperation<'_, Self::Algorithm>;
fn generate_key<R: RngCore + CryptoRng>(rng: &mut R) -> Result<Self::Key>;
fn generate_nonce<R: RngCore + CryptoRng>(rng: &mut R) -> Result<Nonce<12>>;
// Provided methods
fn name() -> &'static str { ... }
fn key_size() -> usize { ... }
fn tag_size() -> usize { ... }
}
Expand description
Trait for AEAD ciphers with improved type safety
Required Associated Types§
Sourcetype Algorithm: AeadAlgorithm
type Algorithm: AeadAlgorithm
The algorithm this cipher implements
Required Methods§
Sourcefn encrypt(&self) -> impl AeadEncryptOperation<'_, Self::Algorithm>
fn encrypt(&self) -> impl AeadEncryptOperation<'_, Self::Algorithm>
Begin encryption operation with operation pattern
Sourcefn decrypt(&self) -> impl AeadDecryptOperation<'_, Self::Algorithm>
fn decrypt(&self) -> impl AeadDecryptOperation<'_, Self::Algorithm>
Begin decryption operation with operation pattern
Provided Methods§
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.