pub struct SimpleStreamCipher(/* private fields */);
Expand description
Simple stream cipher wrapper
Use new
and apply
(or apply_copy
) to XOR the keystream on the plaintext or ciphertext.
Currently this instance is using ChaCha20.
Implementations§
Source§impl SimpleStreamCipher
impl SimpleStreamCipher
Sourcepub fn new(key: [u8; 32], iv: [u8; 12]) -> Self
pub fn new(key: [u8; 32], iv: [u8; 12]) -> Self
Create new instance of the stream cipher initialized with the given secret key and IV.
Sourcepub fn set_block_counter(&mut self, counter: u32)
pub fn set_block_counter(&mut self, counter: u32)
Seeks the keystream to the given block position
Sourcepub fn apply_copy(&mut self, data: &[u8]) -> Box<[u8]>
pub fn apply_copy(&mut self, data: &[u8]) -> Box<[u8]>
Creates copy of the given data and applies the keystream to it.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SimpleStreamCipher
impl RefUnwindSafe for SimpleStreamCipher
impl Send for SimpleStreamCipher
impl Sync for SimpleStreamCipher
impl Unpin for SimpleStreamCipher
impl UnwindSafe for SimpleStreamCipher
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more