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]

Formats the value using the given formatter.

impl<C: Clone, M: Clone, H: Clone> Clone for General<C, M, H>
[src]

Returns a copy of the value. Read more

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]

Create a new AeadCipher.

Key length.

Tag length.

Nonce length.

Set associated data.

Encryption.

Decryption Read more