pub trait StreamCipherCore: BlockSizeUser + Sized {
// Required methods
fn remaining_blocks(&self) -> Option<usize>;
fn process_with_backend(
&mut self,
f: impl StreamCipherClosure<BlockSize = Self::BlockSize>,
);
// Provided methods
fn write_keystream_block(&mut self, block: &mut Block<Self>) { ... }
fn write_keystream_blocks(&mut self, blocks: &mut [Block<Self>]) { ... }
fn apply_keystream_block_inout(&mut self, block: InOut<'_, '_, Block<Self>>) { ... }
fn apply_keystream_blocks(&mut self, blocks: &mut [Block<Self>]) { ... }
fn apply_keystream_blocks_inout(
&mut self,
blocks: InOutBuf<'_, '_, Block<Self>>,
) { ... }
fn try_apply_keystream_partial(
self,
buf: InOutBuf<'_, '_, u8>,
) -> Result<(), StreamCipherError> { ... }
fn apply_keystream_partial(self, buf: InOutBuf<'_, '_, u8>) { ... }
}Expand description
Block-level synchronous stream ciphers.
Required Methods§
Sourcefn remaining_blocks(&self) -> Option<usize>
fn remaining_blocks(&self) -> Option<usize>
Return number of remaining blocks before the cipher wraps around.
Returns None if number of remaining blocks can not be computed
(e.g. in the case of sponge-based stream ciphers) or it’s too big to fit into usize.
Sourcefn process_with_backend(
&mut self,
f: impl StreamCipherClosure<BlockSize = Self::BlockSize>,
)
fn process_with_backend( &mut self, f: impl StreamCipherClosure<BlockSize = Self::BlockSize>, )
Process data using backend provided to the rank-2 closure.
Provided Methods§
Sourcefn write_keystream_block(&mut self, block: &mut Block<Self>)
fn write_keystream_block(&mut self, block: &mut Block<Self>)
Write keystream block.
WARNING: this method does not check number of remaining blocks!
Sourcefn write_keystream_blocks(&mut self, blocks: &mut [Block<Self>])
fn write_keystream_blocks(&mut self, blocks: &mut [Block<Self>])
Write keystream blocks.
WARNING: this method does not check number of remaining blocks!
Sourcefn apply_keystream_block_inout(&mut self, block: InOut<'_, '_, Block<Self>>)
fn apply_keystream_block_inout(&mut self, block: InOut<'_, '_, Block<Self>>)
Apply keystream block.
WARNING: this method does not check number of remaining blocks!
Sourcefn apply_keystream_blocks(&mut self, blocks: &mut [Block<Self>])
fn apply_keystream_blocks(&mut self, blocks: &mut [Block<Self>])
Apply keystream blocks.
WARNING: this method does not check number of remaining blocks!
Sourcefn apply_keystream_blocks_inout(
&mut self,
blocks: InOutBuf<'_, '_, Block<Self>>,
)
fn apply_keystream_blocks_inout( &mut self, blocks: InOutBuf<'_, '_, Block<Self>>, )
Apply keystream blocks.
WARNING: this method does not check number of remaining blocks!
Sourcefn try_apply_keystream_partial(
self,
buf: InOutBuf<'_, '_, u8>,
) -> Result<(), StreamCipherError>
fn try_apply_keystream_partial( self, buf: InOutBuf<'_, '_, u8>, ) -> Result<(), StreamCipherError>
Try to apply keystream to data not divided into blocks.
Consumes cipher since it may consume the final keystream block only partially.
§Errors
Returns StreamCipherError if the number of remaining blocks is not sufficient
for processing of the input data.
Sourcefn apply_keystream_partial(self, buf: InOutBuf<'_, '_, u8>)
fn apply_keystream_partial(self, buf: InOutBuf<'_, '_, u8>)
Try to apply keystream to data not divided into blocks.
Consumes cipher since it may consume final keystream block only partially.
§Panics
If number of remaining blocks is not sufficient for processing the input data.
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.