// TODO: This method should be private
/// Encrypts or decrypts data using the combination of self.cipher_key and nonce.
/// First derives an encryption key using HMAC-SHA-512 (cipher_key, nonce)
/// and then performs ChaCha20 (derived_key, data).
This method should be private
Encrypts or decrypts data using the combination of self.cipher_key and nonce.
First derives an encryption key using HMAC-SHA-512 (cipher_key, nonce)
and then performs ChaCha20 (derived_key, data).
This method should be private Encrypts or decrypts data using the combination of self . cipher_key and nonce . First derives an encryption key using HMAC - SHA - 512 ( cipher_key nonce ) and then performs ChaCha20 ( derived_key data ) .
fn cipher(&self, nonce: &SIV, data: &[u8]) -> Vec<u8> {
		let big_key = {
			let mut hmac = Hmac::new(Sha512::new(), &self.cipher_key[..]);
			hmac.input(&nonce[..]);
			hmac.result()
		};
		let (chacha_key, chacha_nonce) = big_key.code().split_at(32);
		// Using slice notation here so this code panics in case we accidentally didn't derive the right size big_key
		let mut encryptor = ChaCha20::new(&chacha_key[..32], &chacha_nonce[..8]);
		let mut output = vec!(0u8; data.len());
		encryptor.process(data, &mut output);
		output
	}
fn cipher ( & self , nonce : & SIV , data : & [ u8 ] ) -> Vec < u8 > { let big_key = { let mut hmac = Hmac :: new ( Sha512 :: new ( ) , & self . cipher_key [ .. ] ) ; hmac . input ( & nonce [ .. ] ) ; hmac . result ( ) } ; let ( chacha_key , chacha_nonce ) = big_key . code ( ) . split_at ( 32 ) ; // Using slice notation here so this code panics in case we accidentally didn't derive the right size big_key let mut encryptor = ChaCha20 :: new ( & chacha_key [ .. 32 ] , & chacha_nonce [ .. 8 ] ) ; let mut output = vec ! ( 0u8 data len ( ) ) ; encryptor . process ( data , & mut output ) ; output }
TODO: This method should be private
Encrypts or decrypts data using the combination of self.cipher_key and nonce.
TODO : This method should be private Encrypts or decrypts data using the combination of self . cipher_key and nonce .
&self
nonce
&SIV
data
&[u8]