Struct sarkara::aead::Ascon
[−]
[src]
pub struct Ascon { /* fields omitted */ }
Ascon.
Example(encrypt/decrypt)
use rand::{ Rng, thread_rng }; use sarkara::aead::{ Ascon, AeadCipher }; let mut rng = thread_rng(); let mut pass = vec![0; Ascon::key_length()]; let mut nonce = vec![0; Ascon::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 = Ascon::new(&pass) .with_aad(&nonce) .encrypt(&nonce, &data); let plaintext = Ascon::new(&pass) .with_aad(&nonce) .decrypt(&nonce, &ciphertext) .unwrap(); assert_eq!(plaintext, data);
Trait Implementations
impl Debug for Ascon
[src]
impl Clone for Ascon
[src]
fn clone(&self) -> Ascon
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 AeadCipher for Ascon
[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