Trait cipher::StreamCipherCore
source · pub trait StreamCipherCore: BlockSizeUser + Sized {
// Required methods
fn remaining_blocks(&self) -> Option<usize>;
fn process_with_backend(
&mut self,
f: impl StreamClosure<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 cipher wraps around.
Returns None
if number of remaining blocks can not be computed
(e.g. in ciphers based on the sponge construction) or it’s too big
to fit into usize
.
sourcefn process_with_backend(
&mut self,
f: impl StreamClosure<BlockSize = Self::BlockSize>,
)
fn process_with_backend( &mut self, f: impl StreamClosure<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 final keystream block only partially.
Returns an error if number of remaining blocks is not sufficient for processing 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.