pub struct XChaCha<const ROUNDS: usize> { /* private fields */ }Expand description
XChaCha20 stream cipher with 24-byte (192-bit) nonce (draft-irtf-cfrg-xchacha-03).
Internally uses HChaCha20 to derive a subkey from the first 16 bytes of the nonce, then uses the IETF ChaCha20 variant with the remaining 8 nonce bytes.
Implementations§
Source§impl<const ROUNDS: usize> XChaCha<ROUNDS>
impl<const ROUNDS: usize> XChaCha<ROUNDS>
Sourcepub fn new(key: &[u8; 32], nonce: &[u8; 24]) -> XChaCha<ROUNDS>
pub fn new(key: &[u8; 32], nonce: &[u8; 24]) -> XChaCha<ROUNDS>
Creates a new XChaCha stream cipher from a 32-byte key and a 24-byte nonce.
The first 16 bytes of the nonce are used with HChaCha20 to derive a subkey. The last 8 bytes of the nonce become the ChaCha20 IETF nonce (prefixed with 4 zero bytes).
Sourcepub fn set_counter(&mut self, counter: u32)
pub fn set_counter(&mut self, counter: u32)
Sets the ChaCha20 block counter. Counter is a u32.
Trait Implementations§
Source§impl<const ROUNDS: usize> StreamCipher for XChaCha<ROUNDS>
impl<const ROUNDS: usize> StreamCipher for XChaCha<ROUNDS>
fn xor_keystream(&mut self, in_out: &mut [u8])
Auto Trait Implementations§
impl<const ROUNDS: usize> Freeze for XChaCha<ROUNDS>
impl<const ROUNDS: usize> RefUnwindSafe for XChaCha<ROUNDS>
impl<const ROUNDS: usize> Send for XChaCha<ROUNDS>
impl<const ROUNDS: usize> Sync for XChaCha<ROUNDS>
impl<const ROUNDS: usize> Unpin for XChaCha<ROUNDS>
impl<const ROUNDS: usize> UnsafeUnpin for XChaCha<ROUNDS>
impl<const ROUNDS: usize> UnwindSafe for XChaCha<ROUNDS>
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