pub struct ChaCha20 { /* private fields */ }Expand description
ChaCha20 (RFC 8439).
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 ChaCha20
impl ChaCha20
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 ChaCha20
impl !Unpin for ChaCha20
impl !UnwindSafe for ChaCha20
impl Freeze for ChaCha20
impl Send for ChaCha20
impl Sync for ChaCha20
impl UnsafeUnpin for ChaCha20
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