pub trait BlockCipher {
type Algorithm: CipherAlgorithm;
type Key: AsRef<[u8]> + AsMut<[u8]> + Clone + Zeroize;
// Required methods
fn new(key: &Self::Key) -> Self;
fn encrypt_block(&self, block: &mut [u8]) -> Result<()>;
fn decrypt_block(&self, block: &mut [u8]) -> Result<()>;
fn generate_key<R: RngCore + CryptoRng>(rng: &mut R) -> Self::Key;
// Provided methods
fn key_size() -> usize { ... }
fn block_size() -> usize { ... }
fn name() -> &'static str { ... }
}
Expand description
Trait for block ciphers with type-level constraints
Required Associated Types§
Sourcetype Algorithm: CipherAlgorithm
type Algorithm: CipherAlgorithm
The algorithm this cipher implements
Required Methods§
Sourcefn encrypt_block(&self, block: &mut [u8]) -> Result<()>
fn encrypt_block(&self, block: &mut [u8]) -> Result<()>
Encrypts a single block in place
Sourcefn decrypt_block(&self, block: &mut [u8]) -> Result<()>
fn decrypt_block(&self, block: &mut [u8]) -> Result<()>
Decrypts a single block in place
Provided Methods§
Sourcefn block_size() -> usize
fn block_size() -> usize
Returns the block size in bytes
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.