pub struct ChaChaStream<const ROUNDS: u32> { /* private fields */ }
Expand description
The Osom imlementation of ChaCha
algorithm, as defined
in RFC 8439.
ChaChaStream
is cryptographically secure block stream.
Note that the recommended ROUNDS
value is 20.
Implementations§
Source§impl<const ROUNDS: u32> ChaChaStream<ROUNDS>
impl<const ROUNDS: u32> ChaChaStream<ROUNDS>
Sourcepub fn from_seed(seed: u128) -> Self
pub fn from_seed(seed: u128) -> Self
Creates a new ChaChaStream
from a given seed. This method
puts the seed into the key, and passes 0 as the nonce.
For better control use Self::from_arrays
or Self::from_slices
.
Sourcepub fn from_arrays(key: [u8; 32], nonce: [u8; 12]) -> Self
pub fn from_arrays(key: [u8; 32], nonce: [u8; 12]) -> Self
Creates a new ChaChaStream
from a given key and nonce.
Sourcepub fn from_slices(key: &[u8], nonce: &[u8]) -> Self
pub fn from_slices(key: &[u8], nonce: &[u8]) -> Self
Creates a new ChaChaStream
from a given key and nonce slices.
Sourcepub fn from_slices_and_counter(key: &[u8], nonce: &[u8], counter: u32) -> Self
pub fn from_slices_and_counter(key: &[u8], nonce: &[u8], counter: u32) -> Self
Creates a new ChaChaStream
from a given key, nonce slices
and internal counter.
§Panics
Panics if the key or nonce is not of size 32 or 8 respectively.
Also when counter is u32::MAX
.
Sourcepub fn next_u32_block(&mut self) -> [u32; 16]
pub fn next_u32_block(&mut self) -> [u32; 16]
Generates the next chacha block.
§Panics
When the internal counter overflows, i.e. when this function
is called more than u32::MAX
times.
Trait Implementations§
Source§impl<const ROUNDS: u32> BlockStream for ChaChaStream<ROUNDS>
impl<const ROUNDS: u32> BlockStream for ChaChaStream<ROUNDS>
Source§impl<const ROUNDS: u32> Clone for ChaChaStream<ROUNDS>
impl<const ROUNDS: u32> Clone for ChaChaStream<ROUNDS>
Source§fn clone(&self) -> ChaChaStream<ROUNDS>
fn clone(&self) -> ChaChaStream<ROUNDS>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more