Expand description
Block cipher implementations with advanced type-level guarantees
This module contains implementations of various block ciphers and related algorithms with improved type-safety through compile-time constraints.
§Example usage
use dcrypt_algorithms::block::{TypedAes128, TypedCbc, BlockCipher, BlockCipherMode, CipherAlgorithm};
use rand::rngs::OsRng;
// Generate a random key and nonce
let key = TypedAes128::generate_key(&mut OsRng);
let nonce = TypedCbc::<TypedAes128>::generate_nonce(&mut OsRng);
// Create cipher and mode instances
let cipher = TypedAes128::new(&key);
let mode = TypedCbc::new(cipher, &nonce).unwrap();
// Encrypt and decrypt
let plaintext = b"secret message with padding...!!"; // Exactly 32 bytes (multiple of 16)
let ciphertext = mode.encrypt(plaintext).unwrap();
let decrypted = mode.decrypt(&ciphertext).unwrap();
assert_eq!(plaintext, &decrypted[..]);
Re-exports§
pub use aes::Aes128;
pub use aes::Aes192;
pub use aes::Aes256;
pub use modes::cbc::Cbc;
pub use modes::ctr::Ctr;
Modules§
Structs§
- Typed
Aes128 - Enhanced AES-128 implementation with type-level guarantees
- Typed
Cbc - Enhanced CBC mode implementation with type parameters
Enums§
- Aes128
Algorithm - Type-level constants for AES-128
- CbcMode
- Type-level constants for CBC mode
Traits§
- AesVariant
- Marker trait for specific AES key sizes
- Authenticated
Cipher Mode - Trait for authenticated block cipher modes
- Block
Cipher - Trait for block ciphers with type-level constraints
- Block
Cipher Mode - Trait for block cipher modes with type parameters
- Cipher
Algorithm - Marker trait for cipher algorithms with compile-time properties
- Cipher
Mode - Marker trait for block cipher operating modes