c2_chacha::stream_cipher

Trait SyncStreamCipher

Source
pub trait SyncStreamCipher {
    // Required method
    fn try_apply_keystream(&mut self, data: &mut [u8]) -> Result<(), LoopError>;

    // Provided method
    fn apply_keystream(&mut self, data: &mut [u8]) { ... }
}
Expand description

Synchronous stream cipher core trait.

Required Methods§

Source

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

Apply keystream to the data, but return an error if end of a keystream will be reached.

If end of the keystream will be achieved with the given data length, method will return Err(LoopError) without modifying provided data.

Provided Methods§

Source

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

Apply keystream to the data.

It will XOR generated keystream with the data, which can be both encryption and decryption.

§Panics

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

Implementations on Foreign Types§

Source§

impl<C> SyncStreamCipher for &mut C

Source§

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

Source§

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

Implementors§