osom_lib_prng/prngs/
chacha.rs1use crate::{
2 block_prng::BlockPRNG,
3 block_streams::ChaChaStream,
4 traits::{CryptographicallySecure, PRNGenerator, Splittable}
5};
6
7pub type ChaCha<const ROUNDS: u32> = BlockPRNG<ChaChaStream<ROUNDS>>;
15
16unsafe impl<const ROUNDS: u32> CryptographicallySecure for ChaCha<ROUNDS> { }
17
18impl<const ROUNDS: u32> Splittable for ChaCha<ROUNDS> {
19 fn split(&mut self) -> Self {
20 let new_key = self.generate::<[u8; 32]>();
21 let new_nonce = self.generate::<[u8; 12]>();
22 let new_chacha_stream = ChaChaStream::from_arrays(new_key, new_nonce);
23 BlockPRNG::new(new_chacha_stream)
24 }
25}
26
27pub type DefaultChaCha = ChaCha<20>;