use aes::*; use cfb8::{Decryptor, Encryptor}; use cipher::{block_mode_dec_test, block_mode_enc_test, iv_state_test}; iv_state_test!(aes128_cfb8_enc_iv_state, Encryptor, encrypt); iv_state_test!(aes128_cfb8_dec_iv_state, Decryptor, decrypt); iv_state_test!(aes192_cfb8_enc_iv_state, Encryptor, encrypt); iv_state_test!(aes192_cfb8_dec_iv_state, Decryptor, decrypt); iv_state_test!(aes256_cfb8_enc_iv_state, Encryptor, encrypt); iv_state_test!(aes256_cfb8_dec_iv_state, Decryptor, decrypt); // Test vectors from CVAP "AES Multiblock Message Test (MMT) Sample Vectors": // block_mode_enc_test!(aes128_cfb8_enc_test, "aes128", Encryptor); block_mode_dec_test!(aes128_cfb8_dec_test, "aes128", Decryptor); block_mode_enc_test!(aes128enc_cfb8_enc_test, "aes128", Encryptor); block_mode_dec_test!(aes128enc_cfb8_dec_test, "aes128", Decryptor); block_mode_enc_test!(aes192_cfb8_enc_test, "aes192", Encryptor); block_mode_dec_test!(aes192_cfb8_dec_test, "aes192", Decryptor); block_mode_enc_test!(aes192enc_cfb8_enc_test, "aes192", Encryptor); block_mode_dec_test!(aes192dec_cfb8_dec_test, "aes192", Decryptor); block_mode_enc_test!(aes256_cfb8_enc_test, "aes256", Encryptor); block_mode_dec_test!(aes256_cfb8_dec_test, "aes256", Decryptor); block_mode_enc_test!(aes256enc_cfb8_enc_test, "aes256", Encryptor); block_mode_dec_test!(aes256dec_cfb8_dec_test, "aes256", Decryptor); /// Test methods from the `AsyncStreamCipher` trait. #[test] fn aes128_cfb8_async_test() { use cipher::{AsyncStreamCipher, KeyIvInit}; type Enc = Encryptor; type Dec = Decryptor; let key = [42; 16]; let iv = [24; 16]; let mut pt = [0u8; 101]; for (i, b) in pt.iter_mut().enumerate() { *b = (i % 11) as u8; } let enc = Enc::new_from_slices(&key, &iv).unwrap(); let mut ct = pt.clone(); enc.encrypt(&mut ct); for i in 1..100 { let enc = Enc::new_from_slices(&key, &iv).unwrap(); let mut t = pt.clone(); let t = &mut t[..i]; enc.encrypt(t); assert_eq!(t, &ct[..i]); let dec = Dec::new_from_slices(&key, &iv).unwrap(); dec.decrypt(t); assert_eq!(t, &pt[..i]); } }