pub trait BlockCipher: Algorithm {
const BLOCK_LEN: usize;
const KEY_LEN: usize;
// Required methods
fn new(key: &[u8]) -> Result<Self>
where Self: Sized;
fn encrypt_block(&self, block: &mut [u8]) -> Result<()>;
fn decrypt_block(&self, block: &mut [u8]) -> Result<()>;
// Provided method
fn encrypt_blocks(&self, data: &mut [u8]) -> Result<()> { ... }
}Expand description
A fixed-width block cipher primitive (raw ECB core, for use inside modes).
Required Associated Constants§
Required Methods§
Sourcefn encrypt_block(&self, block: &mut [u8]) -> Result<()>
fn encrypt_block(&self, block: &mut [u8]) -> Result<()>
Encrypt a single block in place.
Sourcefn decrypt_block(&self, block: &mut [u8]) -> Result<()>
fn decrypt_block(&self, block: &mut [u8]) -> Result<()>
Decrypt a single block in place.
Provided Methods§
Sourcefn encrypt_blocks(&self, data: &mut [u8]) -> Result<()>
fn encrypt_blocks(&self, data: &mut [u8]) -> Result<()>
Encrypt a whole number of blocks in place.
The default implementation loops over encrypt_block.
Backends with instruction-level parallelism override it: AES-NI has a
pipelined round instruction, so encrypting eight independent blocks at
once is several times faster than eight sequential calls. Counter-based
modes route through here for exactly that reason.
Returns crate::ErrorKind::InvalidLength if data is not a whole
number of blocks.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".