pub struct AsconAead128 { /* private fields */ }Expand description
Ascon-AEAD128 authenticated encryption with associated data (NIST SP 800-232).
§Parameters
- Key: 128 bits (16 bytes)
- Nonce: 128 bits (16 bytes)
- Tag: 128 bits (16 bytes)
- Rate: 128 bits, capacity: 192 bits
- Initialization/finalization rounds: 12
- Data processing rounds: 8
§Example
ⓘ
use crypto::{Aead, ascon::AsconAead128};
let key = [0x42u8; 16];
let nonce = [0xABu8; 16];
let aad = b"example metadata";
let plaintext = b"hello, world!";
let cipher = AsconAead128::new(&key);
let mut ct = plaintext.to_vec();
let tag = cipher.encrypt_in_place(&mut ct, &nonce, aad);
let mut pt = ct.clone();
cipher.decrypt_in_place(&mut pt, &nonce, aad, tag.as_ref()).unwrap();
assert_eq!(&pt, plaintext);§Usage limits (NIST SP 800-232 §4.3)
- Max data per key: 2^54 bytes
- Nonces must be distinct per key (up to 2^8 repetitions tolerated)
- Max decryption failures: 2^(tag_len - 32) before key rotation
Implementations§
Trait Implementations§
Source§impl Aead for AsconAead128
impl Aead for AsconAead128
const TAG_SIZE: usize = 16
const NONCE_SIZE: usize = 16
fn encrypt_in_place(&self, in_out: &mut [u8], nonce: &[u8], aad: &[u8]) -> Hash
fn decrypt_in_place( &self, in_out: &mut [u8], nonce: &[u8], aad: &[u8], tag: &[u8], ) -> Result<(), AeadError>
fn encrypt(&self, plaintext: &[u8], nonce: &[u8], aad: &[u8]) -> Vec<u8> ⓘ
fn decrypt( &self, ciphertext: &[u8], nonce: &[u8], aad: &[u8], ) -> Result<Vec<u8>, AeadError>
Source§impl Drop for AsconAead128
impl Drop for AsconAead128
Auto Trait Implementations§
impl Freeze for AsconAead128
impl RefUnwindSafe for AsconAead128
impl Send for AsconAead128
impl Sync for AsconAead128
impl Unpin for AsconAead128
impl UnsafeUnpin for AsconAead128
impl UnwindSafe for AsconAead128
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