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§
- ChaCha20
Poly1305 Cipher - Implementation of ChaCha20-Poly1305 with enhanced type safety
- ChaCha20
Poly1305 Decrypt Operation - ChaCha20-Poly1305 decryption operation
- ChaCha20
Poly1305 Encrypt Operation - ChaCha20-Poly1305 encryption operation
Enums§
- ChaCha20
Poly1305 Algorithm - Type-level constants for ChaCha20-Poly1305
Traits§
- Aead
Algorithm - Marker trait for AEAD algorithms
- Aead
Cipher - Trait for AEAD ciphers with improved type safety
- Aead
Decrypt Operation - Trait for decryption operations with AEAD algorithms
- Aead
Encrypt Operation - Trait for encryption operations with AEAD algorithms
- Operation
- Base trait for operations