pub struct ChaCha20 { /* private fields */ }
Expand description
ChaCha20 stream cipher
Implementations§
Source§impl ChaCha20
impl ChaCha20
Sourcepub fn new<const N: usize>(key: &[u8; 32], nonce: &Nonce<N>) -> Selfwhere
Nonce<N>: ChaCha20Compatible,
pub fn new<const N: usize>(key: &[u8; 32], nonce: &Nonce<N>) -> Selfwhere
Nonce<N>: ChaCha20Compatible,
Creates a new ChaCha20 instance with the specified key and nonce
Sourcepub fn with_counter<const N: usize>(
key: &[u8; 32],
nonce: &Nonce<N>,
counter: u32,
) -> Selfwhere
Nonce<N>: ChaCha20Compatible,
pub fn with_counter<const N: usize>(
key: &[u8; 32],
nonce: &Nonce<N>,
counter: u32,
) -> Selfwhere
Nonce<N>: ChaCha20Compatible,
Creates a new ChaCha20 instance with the specified key, nonce, and counter
Sourcepub fn process(&mut self, data: &mut [u8])
pub fn process(&mut self, data: &mut [u8])
Encrypt or decrypt data in place using the ChaCha20 stream cipher
Sourcepub fn keystream(&mut self, output: &mut [u8])
pub fn keystream(&mut self, output: &mut [u8])
Generate keystream directly into an output buffer
Trait Implementations§
Source§impl StreamCipher for ChaCha20
impl StreamCipher for ChaCha20
Source§const NONCE_SIZE: usize = 12usize
const NONCE_SIZE: usize = 12usize
The nonce size in bytes
Source§const BLOCK_SIZE: usize = 64usize
const BLOCK_SIZE: usize = 64usize
The internal block size in bytes (if applicable)
Source§fn process(&mut self, data: &mut [u8]) -> Result<()>
fn process(&mut self, data: &mut [u8]) -> Result<()>
Process data in place (encrypts for encryption, decrypts for decryption)
Source§fn keystream(&mut self, output: &mut [u8]) -> Result<()>
fn keystream(&mut self, output: &mut [u8]) -> Result<()>
Generate keystream directly into an output buffer
Auto Trait Implementations§
impl Freeze for ChaCha20
impl RefUnwindSafe for ChaCha20
impl Send for ChaCha20
impl Sync for ChaCha20
impl Unpin for ChaCha20
impl UnwindSafe 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