use chacha20::cipher::{KeyIvInit, StreamCipher};
use crate::symm_encr::KeySecret;
pub struct UnauthEncryptionStream {
cipher: chacha20::ChaCha20,
}
impl UnauthEncryptionStream {
pub fn new(key: KeySecret, nonce: chacha20::Nonce) -> Self {
let cipher = chacha20::ChaCha20::new(key.as_slice().into(), &nonce);
UnauthEncryptionStream { cipher }
}
pub fn xor_chunk(&mut self, chunk: &mut [u8]) {
self.cipher.apply_keystream(chunk)
}
}