pub struct ChaCha20Ietf;Expand description
An implementation of ChaCha20 (IETF-version)
Implementations§
Source§impl ChaCha20Ietf
impl ChaCha20Ietf
Sourcepub fn cipher() -> Box<dyn Cipher>
pub fn cipher() -> Box<dyn Cipher>
Creates a Cipher instance with ChaCha20Ietf as underlying cipher
Sourcepub fn xor(key: &[u8], nonce: &[u8], n: u32, data: &mut [u8])
pub fn xor(key: &[u8], nonce: &[u8], n: u32, data: &mut [u8])
XORs the bytes in data with the ChaCha20 keystream for key and nonce starting at the
nth block
§Warning:
This function panics if
keyis smaller or larger than 32 bytes/256 bitsnonceis smaller or larger than 12 bytes/96 bitsnexceeds2^32 - 1(which means thatdatamust be smaller than(2^32 - n) * 64)
Consider using the crypto_api-interface instead of calling this function directly
Trait Implementations§
Source§impl Cipher for ChaCha20Ietf
impl Cipher for ChaCha20Ietf
Source§fn info(&self) -> CipherInfo
fn info(&self) -> CipherInfo
Returns information about the cipher
Source§fn encrypted_len_max(&self, plaintext_len: usize) -> usize
fn encrypted_len_max(&self, plaintext_len: usize) -> usize
Predicts the maximum encrypted length for
plaintext_len bytesSource§fn encrypt(
&self,
buf: &mut [u8],
plaintext_len: usize,
key: &[u8],
nonce: &[u8],
) -> Result<usize, Box<dyn Error + 'static>>
fn encrypt( &self, buf: &mut [u8], plaintext_len: usize, key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>
Encrypts
plaintext_len bytes in-place in buf using key and nonce and returns the
ciphertext lengthSource§fn encrypt_to(
&self,
buf: &mut [u8],
plaintext: &[u8],
key: &[u8],
nonce: &[u8],
) -> Result<usize, Box<dyn Error + 'static>>
fn encrypt_to( &self, buf: &mut [u8], plaintext: &[u8], key: &[u8], nonce: &[u8], ) -> Result<usize, Box<dyn Error + 'static>>
Encrypts
plaintext into buf using key and nonce and returns the ciphertext lengthAuto Trait Implementations§
impl Freeze for ChaCha20Ietf
impl RefUnwindSafe for ChaCha20Ietf
impl Send for ChaCha20Ietf
impl Sync for ChaCha20Ietf
impl Unpin for ChaCha20Ietf
impl UnwindSafe for ChaCha20Ietf
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