docs.rs failed to build cfb-mode-0.3.0
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Visit the last successful build:
cfb-mode-0.8.2
Generic Cipher Feedback (CFB) mode implementation.
This crate implements CFB as a self-synchronizing stream cipher.
Warning
This crate does not provide any authentification! Thus ciphertext integrity is not verified, which can lead to serious vulnerabilities!
Examples
extern crate aes;
extern crate cfb_mode;
#[macro_use] extern crate hex_literal;
use aes::Aes128;
use cfb_mode::Cfb;
use cfb_mode::stream_cipher::{NewStreamCipher, StreamCipher};
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 buffer = plaintext.to_vec();
// encrypt plaintext
AesCfb::new_var(key, iv).unwrap().encrypt(&mut buffer);
assert_eq!(buffer, &ciphertext[..]);
// and decrypt it back
AesCfb::new_var(key, iv).unwrap().decrypt(&mut buffer);
assert_eq!(buffer, &plaintext[..]);
// CFB mode can be used with streaming messages
let mut cipher = AesCfb::new_var(key, iv).unwrap();
for chunk in buffer.chunks_mut(3) {
cipher.encrypt(chunk);
}
assert_eq!(buffer, &ciphertext[..]);