pub trait StreamCipher<const KEY_LEN: usize, const INIT_DATA_LEN: usize>: SymmetricCipher<KEY_LEN, INIT_DATA_LEN> + Sized {
// Required methods
fn do_stream_encrypt_init(
key: &KeyMaterial<KEY_LEN>,
) -> Result<(Self, [u8; INIT_DATA_LEN]), SymmetricCipherError>;
fn do_stream_encrypt_block<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>;
fn do_stream_encrypt_block_out<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
ciphertext: &mut [u8; BLOCK_LEN],
) -> Result<usize, SymmetricCipherError>;
fn do_stream_encrypt_final<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>;
fn do_stream_encrypt_final_out<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
ciphertext: &mut [u8; BLOCK_LEN],
) -> Result<usize, SymmetricCipherError>;
fn do_stream_decrypt_init(
key: &KeyMaterial<KEY_LEN>,
init_data: &[u8; INIT_DATA_LEN],
) -> Result<Self, SymmetricCipherError>;
fn do_stream_decrypt_block<const BLOCK_LEN: usize>(
&mut self,
ciphertext: &[u8; BLOCK_LEN],
) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>;
fn do_stream_decrypt_block_out<const BLOCK_LEN: usize>(
&mut self,
ciphertext: &[u8; BLOCK_LEN],
plaintext: &mut [u8; BLOCK_LEN],
) -> Result<usize, SymmetricCipherError>;
}Expand description
The basic functions of a stream cipher, which differ from those of a block cipher only in that a stream cipher is assumed to have no underlying block size tied to the implementation, and so the caller gets to specify the block size for the streaming APIs.
Required Methods§
Sourcefn do_stream_encrypt_init(
key: &KeyMaterial<KEY_LEN>,
) -> Result<(Self, [u8; INIT_DATA_LEN]), SymmetricCipherError>
fn do_stream_encrypt_init( key: &KeyMaterial<KEY_LEN>, ) -> Result<(Self, [u8; INIT_DATA_LEN]), SymmetricCipherError>
Constructor that begins a flow of the streaming API for encrypting one block at a time. Allows for the implementation to return init data such as an IV which is generated prior to encrypting the first block.
Sourcefn do_stream_encrypt_block<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>
fn do_stream_encrypt_block<const BLOCK_LEN: usize>( &mut self, plaintext: &[u8; BLOCK_LEN], ) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>
Encrypts a single block of plaintext.
Sourcefn do_stream_encrypt_block_out<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
ciphertext: &mut [u8; BLOCK_LEN],
) -> Result<usize, SymmetricCipherError>
fn do_stream_encrypt_block_out<const BLOCK_LEN: usize>( &mut self, plaintext: &[u8; BLOCK_LEN], ciphertext: &mut [u8; BLOCK_LEN], ) -> Result<usize, SymmetricCipherError>
Encrypts a single block of plaintext and writes the ciphertext to the provided buffer.
Sourcefn do_stream_encrypt_final<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>
fn do_stream_encrypt_final<const BLOCK_LEN: usize>( &mut self, plaintext: &[u8; BLOCK_LEN], ) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>
Encrypts the final block of plaintext.
Sourcefn do_stream_encrypt_final_out<const BLOCK_LEN: usize>(
&mut self,
plaintext: &[u8; BLOCK_LEN],
ciphertext: &mut [u8; BLOCK_LEN],
) -> Result<usize, SymmetricCipherError>
fn do_stream_encrypt_final_out<const BLOCK_LEN: usize>( &mut self, plaintext: &[u8; BLOCK_LEN], ciphertext: &mut [u8; BLOCK_LEN], ) -> Result<usize, SymmetricCipherError>
Encrypts the final block of plaintext and writes the ciphertext to the provided buffer.
Sourcefn do_stream_decrypt_init(
key: &KeyMaterial<KEY_LEN>,
init_data: &[u8; INIT_DATA_LEN],
) -> Result<Self, SymmetricCipherError>
fn do_stream_decrypt_init( key: &KeyMaterial<KEY_LEN>, init_data: &[u8; INIT_DATA_LEN], ) -> Result<Self, SymmetricCipherError>
Constructor that begins a flow of the streaming API for decryption one block at a time.
Sourcefn do_stream_decrypt_block<const BLOCK_LEN: usize>(
&mut self,
ciphertext: &[u8; BLOCK_LEN],
) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>
fn do_stream_decrypt_block<const BLOCK_LEN: usize>( &mut self, ciphertext: &[u8; BLOCK_LEN], ) -> Result<[u8; BLOCK_LEN], SymmetricCipherError>
Decrypts a single block of ciphertext.
Sourcefn do_stream_decrypt_block_out<const BLOCK_LEN: usize>(
&mut self,
ciphertext: &[u8; BLOCK_LEN],
plaintext: &mut [u8; BLOCK_LEN],
) -> Result<usize, SymmetricCipherError>
fn do_stream_decrypt_block_out<const BLOCK_LEN: usize>( &mut self, ciphertext: &[u8; BLOCK_LEN], plaintext: &mut [u8; BLOCK_LEN], ) -> Result<usize, SymmetricCipherError>
Decrypts a single block of ciphertext and writes the plaintext to the provided buffer.
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.