pub struct XChaCha20;Expand description
An implementation of XChaCha20
Implementations§
Source§impl XChaCha20
impl XChaCha20
Sourcepub fn cipher() -> Box<dyn Cipher>
pub fn cipher() -> Box<dyn Cipher>
Creates a Cipher instance with XChaCha20 as underlying cipher
Sourcepub fn xor(key: &[u8], nonce: &[u8], n: u64, data: &mut [u8])
pub fn xor(key: &[u8], nonce: &[u8], n: u64, data: &mut [u8])
XORs the bytes in data with the XChaCha20 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 24 bytes/192 bitsnexceeds2^64 - 1(which means thatdatamust be smaller than(2^64 - n) * 64)
Consider using the crypto_api-interface instead of calling this function directly
Trait Implementations§
Source§impl Cipher for XChaCha20
impl Cipher for XChaCha20
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 XChaCha20
impl RefUnwindSafe for XChaCha20
impl Send for XChaCha20
impl Sync for XChaCha20
impl Unpin for XChaCha20
impl UnwindSafe for XChaCha20
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