Trait cipher::stream_core::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§

source

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.

source

fn process_with_backend( &mut self, f: impl StreamClosure<BlockSize = Self::BlockSize>, )

Process data using backend provided to the rank-2 closure.

Provided Methods§

source

fn write_keystream_block(&mut self, block: &mut Block<Self>)

Write keystream block.

WARNING: this method does not check number of remaining blocks!

source

fn write_keystream_blocks(&mut self, blocks: &mut [Block<Self>])

Write keystream blocks.

WARNING: this method does not check number of remaining blocks!

source

fn apply_keystream_block_inout(&mut self, block: InOut<'_, '_, Block<Self>>)

Apply keystream block.

WARNING: this method does not check number of remaining blocks!

source

fn apply_keystream_blocks(&mut self, blocks: &mut [Block<Self>])

Apply keystream blocks.

WARNING: this method does not check number of remaining blocks!

source

fn apply_keystream_blocks_inout( &mut self, blocks: InOutBuf<'_, '_, Block<Self>>, )

Apply keystream blocks.

WARNING: this method does not check number of remaining blocks!

source

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.

source

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.

Object Safety§

This trait is not object safe.

Implementors§