[−][src]Crate cfb_mode
Generic Cipher Feedback (CFB) mode implementation.
This crate implements CFB as a self-synchronizing stream cipher.
Security Warning
This crate does not ensure ciphertexts are authentic! Thus ciphertext integrity is not verified, which can lead to serious vulnerabilities!
Examples
use aes::Aes128; use cfb_mode::Cfb; use cfb_mode::cipher::{NewStreamCipher, StreamCipher}; use hex_literal::hex; type AesCfb = Cfb<Aes128>; let key = b"very secret key."; let iv = b"unique init vect"; let plaintext = b"The quick brown fox jumps over the lazy dog."; let ciphertext = hex!(" 8f0cb6e8 9286cd02 09c95da4 fa663269 bf7f286d 76820a4a f6cd3794 64cb6765 8c764fa2 ce107f96 e1cf1dcd "); let mut data = plaintext.to_vec(); // encrypt plaintext AesCfb::new_var(key, iv).unwrap().encrypt(&mut data); assert_eq!(data, &ciphertext[..]); // and decrypt it back AesCfb::new_var(key, iv).unwrap().decrypt(&mut data); assert_eq!(data, &plaintext[..]); // CFB mode can be used with streaming messages let mut cipher = AesCfb::new_var(key, iv).unwrap(); for chunk in data.chunks_mut(3) { cipher.encrypt(chunk); } assert_eq!(data, &ciphertext[..]);
Re-exports
pub use cipher; |
Structs
Cfb | CFB self-synchronizing stream cipher instance. |