Struct sarkara::aead::General
[−]
[src]
pub struct General<C, M, H> { /* fields omitted */ }
General Authenticated Encryption.
Example(encrypt/decrypt)
use rand::{ Rng, thread_rng }; use sarkara::aead::{ General, AeadCipher }; use sarkara::stream::HC256; use sarkara::auth::HMAC; use sarkara::hash::Blake2b; type HHBB = General<HC256, HMAC<Blake2b>, Blake2b>; let mut rng = thread_rng(); let mut pass = vec![0; HHBB::key_length()]; let mut nonce = vec![0; HHBB::nonce_length()]; let mut data = vec![0; 1024]; rng.fill_bytes(&mut pass); rng.fill_bytes(&mut nonce); rng.fill_bytes(&mut data); let ciphertext = HHBB::new(&pass) .with_aad(&nonce) .encrypt(&nonce, &data); let plaintext = HHBB::new(&pass) .with_aad(&nonce) .decrypt(&nonce, &ciphertext) .unwrap(); assert_eq!(plaintext, data);
Trait Implementations
impl<C: Debug, M: Debug, H: Debug> Debug for General<C, M, H>
[src]
impl<C: Clone, M: Clone, H: Clone> Clone for General<C, M, H>
[src]
fn clone(&self) -> General<C, M, H>
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<C, M, H> AeadCipher for General<C, M, H> where C: StreamCipher, M: NonceMac, H: GenericHash
[src]
fn new(key: &[u8]) -> Self
Create a new AeadCipher.
fn key_length() -> usize
Key length.
fn tag_length() -> usize
Tag length.
fn nonce_length() -> usize
Nonce length.
fn with_aad(&mut self, aad: &[u8]) -> &mut Self
Set associated data.
fn encrypt(&mut self, nonce: &[u8], data: &[u8]) -> Vec<u8>
Encryption.
fn decrypt(&mut self, nonce: &[u8], data: &[u8]) -> Result<Vec<u8>, DecryptFail>
Decryption Read more