pub struct ChaCha12 { /* private fields */ }Expand description
ChaCha12: ChaCha with 12 rounds.
Stream cipher with a 256-bit key, a 96-bit nonce and a 32-bit block counter. Encryption and decryption are the same operation. Data of any length is accepted, in any number of calls: the keystream position is kept across calls. The (key, nonce) pair must never be reused.
Implementations§
Source§impl ChaCha12
impl ChaCha12
Sourcepub const NONCE_SIZE: usize = 12
pub const NONCE_SIZE: usize = 12
Size of the nonce, in bytes.
Sourcepub fn new(key: &[u8; 32], nonce: &[u8; 12]) -> Self
pub fn new(key: &[u8; 32], nonce: &[u8; 12]) -> Self
Initialize with key and nonce, starting at block counter 0.
Sourcepub fn with_counter(key: &[u8; 32], nonce: &[u8; 12], counter: u32) -> Self
pub fn with_counter(key: &[u8; 32], nonce: &[u8; 12], counter: u32) -> Self
Initialize with key and nonce, starting at block counter.
Sourcepub fn apply_keystream(&mut self, buf: &mut [u8])
pub fn apply_keystream(&mut self, buf: &mut [u8])
XOR the keystream into buf.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for ChaCha12
impl !Unpin for ChaCha12
impl !UnwindSafe for ChaCha12
impl Freeze for ChaCha12
impl Send for ChaCha12
impl Sync for ChaCha12
impl UnsafeUnpin for ChaCha12
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