pub trait CipherPlugin: Sized {
// Required methods
fn create_with_key(
algorithm: &str,
key: &[u8],
iv: &[u8],
opts: Option<OptionView<'_>>,
) -> PluginResult<Self>;
fn block_size(&self) -> u32;
fn key_size(&self) -> u32;
fn iv_size(&self) -> u32;
fn update(&mut self, input: &[u8], output: &mut [u8]) -> PluginResult<usize>;
fn finalize(&mut self, output: &mut [u8]) -> PluginResult<usize>;
fn reset(&mut self) -> PluginResult<()>;
}Expand description
Trait implemented by symmetric cipher plugins. The macro-generated
cfmp_cipher_create calls CipherPlugin::create_with_key; all
other symbols dispatch through OpaqueHandle::<Self>::borrow_raw
and the corresponding trait method.
Required Methods§
Sourcefn create_with_key(
algorithm: &str,
key: &[u8],
iv: &[u8],
opts: Option<OptionView<'_>>,
) -> PluginResult<Self>
fn create_with_key( algorithm: &str, key: &[u8], iv: &[u8], opts: Option<OptionView<'_>>, ) -> PluginResult<Self>
Construct a new cipher instance for the named algorithm with the
given key and IV. Either key or iv may be empty when the
algorithm does not require them.
Sourcefn block_size(&self) -> u32
fn block_size(&self) -> u32
Block size in bytes for this instance.
Sourcefn update(&mut self, input: &[u8], output: &mut [u8]) -> PluginResult<usize>
fn update(&mut self, input: &[u8], output: &mut [u8]) -> PluginResult<usize>
Process input and write as many output bytes as fit into
output. Returns the number of bytes written. The caller
guarantees output.len() is large enough to hold one block of
ciphertext per block of input.
Sourcefn finalize(&mut self, output: &mut [u8]) -> PluginResult<usize>
fn finalize(&mut self, output: &mut [u8]) -> PluginResult<usize>
Flush any buffered output (e.g. the final partial block after
padding) into output. Returns the number of bytes written.
Sourcefn reset(&mut self) -> PluginResult<()>
fn reset(&mut self) -> PluginResult<()>
Reset to the initial state (post-create).
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".