Trait cipher::StreamCipher

source ·
pub trait StreamCipher {
    // Required method
    fn try_apply_keystream_inout(
        &mut self,
        buf: InOutBuf<'_, '_, u8>,
    ) -> Result<(), StreamCipherError>;

    // Provided methods
    fn try_apply_keystream(
        &mut self,
        buf: &mut [u8],
    ) -> Result<(), StreamCipherError> { ... }
    fn apply_keystream_inout(&mut self, buf: InOutBuf<'_, '_, u8>) { ... }
    fn apply_keystream(&mut self, buf: &mut [u8]) { ... }
    fn apply_keystream_b2b(
        &mut self,
        input: &[u8],
        output: &mut [u8],
    ) -> Result<(), StreamCipherError> { ... }
}
Expand description

Synchronous stream cipher core trait.

Required Methods§

source

fn try_apply_keystream_inout( &mut self, buf: InOutBuf<'_, '_, u8>, ) -> Result<(), StreamCipherError>

Apply keystream to inout data.

If end of the keystream will be achieved with the given data length, method will return StreamCipherError without modifying provided data.

Provided Methods§

source

fn try_apply_keystream( &mut self, buf: &mut [u8], ) -> Result<(), StreamCipherError>

Apply keystream to data behind buf.

If end of the keystream will be achieved with the given data length, method will return StreamCipherError without modifying provided data.

source

fn apply_keystream_inout(&mut self, buf: InOutBuf<'_, '_, u8>)

Apply keystream to inout data.

It will XOR generated keystream with the data behind in pointer and will write result to out pointer.

§Panics

If end of the keystream will be reached with the given data length, method will panic without modifying the provided data.

source

fn apply_keystream(&mut self, buf: &mut [u8])

Apply keystream to data in-place.

It will XOR generated keystream with data and will write result to the same buffer.

§Panics

If end of the keystream will be reached with the given data length, method will panic without modifying the provided data.

source

fn apply_keystream_b2b( &mut self, input: &[u8], output: &mut [u8], ) -> Result<(), StreamCipherError>

Apply keystream to data buffer-to-buffer.

It will XOR generated keystream with data from the input buffer and will write result to the output buffer.

Returns StreamCipherError if provided in_blocks and out_blocks have different lengths or if end of the keystream will be reached with the given input data length.

Implementations on Foreign Types§

source§

impl<C: StreamCipher> StreamCipher for &mut C

Implementors§