Module aead

Module aead 

Source
Expand description

Authenticated Encryption with Associated Data (AEAD) with operation pattern

This module provides implementations of authenticated encryption algorithms with an ergonomic operation pattern for operations.

§Example usage

use dcrypt_algorithms::aead::{ChaCha20Poly1305Cipher, AeadCipher, AeadEncryptOperation, AeadDecryptOperation};
use rand::rngs::OsRng;

// Generate key and nonce
let key = ChaCha20Poly1305Cipher::generate_key(&mut OsRng).unwrap();
let nonce = ChaCha20Poly1305Cipher::generate_nonce(&mut OsRng).unwrap();

// Create cipher instance
let cipher = ChaCha20Poly1305Cipher::new(&key).unwrap();

// Encrypt with operation pattern
let ciphertext = cipher.encrypt()
    .with_nonce(&nonce)
    .with_aad(b"additional data")
    .encrypt(b"secret message").unwrap();

// Decrypt with operation pattern
let plaintext = cipher.decrypt()
    .with_nonce(&nonce)
    .with_aad(b"additional data")
    .decrypt(&ciphertext).unwrap();

assert_eq!(plaintext, b"secret message");

Re-exports§

pub use self::gcm::Gcm;
pub use self::chacha20poly1305::ChaCha20Poly1305;
pub use self::xchacha20poly1305::XChaCha20Poly1305;

Modules§

chacha20poly1305
ChaCha20-Poly1305 authenticated encryption
gcm
Galois/Counter Mode (GCM) for authenticated encryption
xchacha20poly1305
XChaCha20Poly1305 authenticated encryption with proper error handling

Structs§

ChaCha20Poly1305Cipher
Implementation of ChaCha20-Poly1305 with enhanced type safety
ChaCha20Poly1305DecryptOperation
ChaCha20-Poly1305 decryption operation
ChaCha20Poly1305EncryptOperation
ChaCha20-Poly1305 encryption operation

Enums§

ChaCha20Poly1305Algorithm
Type-level constants for ChaCha20-Poly1305

Traits§

AeadAlgorithm
Marker trait for AEAD algorithms
AeadCipher
Trait for AEAD ciphers with improved type safety
AeadDecryptOperation
Trait for decryption operations with AEAD algorithms
AeadEncryptOperation
Trait for encryption operations with AEAD algorithms
Operation
Base trait for operations