Skip to main content

CipherPlugin

Trait CipherPlugin 

Source
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§

Source

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.

Source

fn block_size(&self) -> u32

Block size in bytes for this instance.

Source

fn key_size(&self) -> u32

Key length in bytes for this instance’s algorithm.

Source

fn iv_size(&self) -> u32

IV / nonce length in bytes for this instance’s algorithm.

Source

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.

Source

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.

Source

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".

Implementors§