pub trait Cipher<'c> {
const BLOCK_SIZE: usize;
const REQUIRES_PADDING: bool = false;
// Required methods
fn key(&self) -> &[u8];
fn iv(&self) -> &[u8];
fn set_algomode(&self, p: Cryp);
// Provided methods
fn prepare_key(&self, _p: Cryp, _dir: Direction) { ... }
fn init_phase_blocking<T: Instance, M: Mode>(
&self,
_p: Cryp,
_cryp: &Cryp<'_, T, M>,
) { ... }
async fn init_phase<T: Instance>(
&self,
_p: Cryp,
_cryp: &mut Cryp<'_, T, Async>,
) { ... }
fn pre_final(
&self,
_p: Cryp,
_dir: Direction,
_padding_len: usize,
) -> [u32; 4] { ... }
fn post_final_blocking<T: Instance, M: Mode>(
&self,
_p: Cryp,
_cryp: &Cryp<'_, T, M>,
_dir: Direction,
_int_data: &mut [u8; 16],
_temp1: [u32; 4],
_padding_mask: [u8; 16],
) { ... }
async fn post_final<T: Instance>(
&self,
_p: Cryp,
_cryp: &mut Cryp<'_, T, Async>,
_dir: Direction,
_int_data: &mut [u8; 16],
_temp1: [u32; 4],
_padding_mask: [u8; 16],
) { ... }
fn get_header_block(&self) -> &[u8] { ... }
}Expand description
This trait encapsulates all cipher-specific behavior/
Required Associated Constants§
Sourceconst BLOCK_SIZE: usize
const BLOCK_SIZE: usize
Processing block size. Determined by the processor and the algorithm.
Provided Associated Constants§
Sourceconst REQUIRES_PADDING: bool = false
const REQUIRES_PADDING: bool = false
Indicates whether the cipher requires the application to provide padding.
If true, no partial blocks will be accepted (a panic will occur).
Required Methods§
Sourcefn set_algomode(&self, p: Cryp)
fn set_algomode(&self, p: Cryp)
Sets the processor algorithm mode according to the associated cipher.
Provided Methods§
Sourcefn prepare_key(&self, _p: Cryp, _dir: Direction)
fn prepare_key(&self, _p: Cryp, _dir: Direction)
Performs any key preparation within the processor, if necessary.
Sourcefn init_phase_blocking<T: Instance, M: Mode>(
&self,
_p: Cryp,
_cryp: &Cryp<'_, T, M>,
)
fn init_phase_blocking<T: Instance, M: Mode>( &self, _p: Cryp, _cryp: &Cryp<'_, T, M>, )
Performs any cipher-specific initialization.
Sourceasync fn init_phase<T: Instance>(
&self,
_p: Cryp,
_cryp: &mut Cryp<'_, T, Async>,
)
async fn init_phase<T: Instance>( &self, _p: Cryp, _cryp: &mut Cryp<'_, T, Async>, )
Performs any cipher-specific initialization.
Sourcefn pre_final(&self, _p: Cryp, _dir: Direction, _padding_len: usize) -> [u32; 4]
fn pre_final(&self, _p: Cryp, _dir: Direction, _padding_len: usize) -> [u32; 4]
Called prior to processing the last data block for cipher-specific operations.
Sourcefn post_final_blocking<T: Instance, M: Mode>(
&self,
_p: Cryp,
_cryp: &Cryp<'_, T, M>,
_dir: Direction,
_int_data: &mut [u8; 16],
_temp1: [u32; 4],
_padding_mask: [u8; 16],
)
fn post_final_blocking<T: Instance, M: Mode>( &self, _p: Cryp, _cryp: &Cryp<'_, T, M>, _dir: Direction, _int_data: &mut [u8; 16], _temp1: [u32; 4], _padding_mask: [u8; 16], )
Called after processing the last data block for cipher-specific operations.
Sourceasync fn post_final<T: Instance>(
&self,
_p: Cryp,
_cryp: &mut Cryp<'_, T, Async>,
_dir: Direction,
_int_data: &mut [u8; 16],
_temp1: [u32; 4],
_padding_mask: [u8; 16],
)
async fn post_final<T: Instance>( &self, _p: Cryp, _cryp: &mut Cryp<'_, T, Async>, _dir: Direction, _int_data: &mut [u8; 16], _temp1: [u32; 4], _padding_mask: [u8; 16], )
Called after processing the last data block for cipher-specific operations.
Sourcefn get_header_block(&self) -> &[u8]
fn get_header_block(&self) -> &[u8]
Returns the AAD header block as required by the cipher.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".