Trait StreamCipher

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§

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§

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.

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.

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.

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§

§

impl<C> StreamCipher for &mut C
where C: StreamCipher,

§

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

Implementors§

§

impl<T> StreamCipher for StreamCipherCoreWrapper<T>
where T: StreamCipherCore, <T as BlockSizeUser>::BlockSize: IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>, <<T as BlockSizeUser>::BlockSize as IsLess<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>, B0>, B0>, B0>>>::Output: NonZero,