pub trait Cipher<'c> {
const BLOCK_SIZE: usize = 16usize;
const REQUIRES_PADDING: bool = false;
// Required methods
fn key(&self) -> &[u8];
fn iv(&self) -> &[u8];
// Provided methods
fn key_size(&self) -> KeySize { ... }
fn datatype(&self) -> u8 { ... }
fn chmod_bits(&self) -> u8 { ... }
fn set_mode(&self, p: Aes) { ... }
fn prepare_key(&self, _p: Aes, _dir: Direction) { ... }
fn init_phase_blocking(&self, _p: Aes) { ... }
fn uses_gcm_phases(&self) -> bool { ... }
fn is_ccm_mode(&self) -> bool { ... }
}Expand description
This trait encapsulates all cipher-specific behavior.
Provided Associated Constants§
Sourceconst BLOCK_SIZE: usize = 16usize
const BLOCK_SIZE: usize = 16usize
Processing block size (always 16 bytes for AES).
Sourceconst REQUIRES_PADDING: bool = false
const REQUIRES_PADDING: bool = false
Indicates whether the cipher requires the application to provide padding.
Required Methods§
Provided Methods§
Sourcefn datatype(&self) -> u8
fn datatype(&self) -> u8
Returns the data type setting for this cipher mode.
This driver uses NO_SWAP (0) consistently with big-endian byte
conversion (from_be_bytes/to_be_bytes) for direct NIST test-vector
compatibility.
Sourcefn chmod_bits(&self) -> u8
fn chmod_bits(&self) -> u8
Returns the raw CHMOD field value for this cipher mode.
Sourcefn prepare_key(&self, _p: Aes, _dir: Direction)
fn prepare_key(&self, _p: Aes, _dir: Direction)
Performs any key preparation within the processor, if necessary.
Sourcefn init_phase_blocking(&self, _p: Aes)
fn init_phase_blocking(&self, _p: Aes)
Performs any cipher-specific initialization (blocking).
Sourcefn uses_gcm_phases(&self) -> bool
fn uses_gcm_phases(&self) -> bool
Indicates whether this cipher mode uses GCM/CCM phases (init, header, payload, final).
Sourcefn is_ccm_mode(&self) -> bool
fn is_ccm_mode(&self) -> bool
Indicates whether this is CCM mode (which has different final phase handling).
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.