[−][src]Crate eme_mode
ECB-Mix-ECB (EME) block cipher mode implementation.
Usage example
use aes::Aes128; use eme_mode::{block_modes::BlockMode, block_padding::Pkcs7, Eme}; type Aes128Eme = Eme<Aes128, Pkcs7>; let key = [0; 16]; let iv = [1; 16]; let plaintext = b"Hello world!"; let cipher = Aes128Eme::new_var(&key, &iv).unwrap(); // buffer must have enough space for message+padding let mut buffer = [0u8; 16]; // copy message to the buffer let pos = plaintext.len(); buffer[..pos].copy_from_slice(plaintext); let ciphertext = cipher.encrypt(&mut buffer, pos).unwrap(); assert_eq!( ciphertext, [147, 227, 119, 228, 187, 150, 249, 88, 176, 145, 53, 209, 217, 99, 70, 245] ); // re-create cipher mode instance let cipher = Aes128Eme::new_var(&key, &iv).unwrap(); let mut buf = ciphertext.to_vec(); let decrypted_ciphertext = cipher.decrypt(&mut buf).unwrap(); assert_eq!(decrypted_ciphertext, plaintext);
Re-exports
pub use block_cipher; |
pub use block_modes; |
pub use block_padding; |
Structs
Eme | ECB-Mix-ECB (EME) block cipher mode instance. |