Generic implementation of CTR mode for block cipher with 128-bit block size.
Mode functionality is accessed using traits from re-exported
stream-cipher crate.
Warning
This crate does not provide any authentification! Thus ciphertext integrity
is not verified, which can lead to serious vulnerabilities!
Usage example
extern crate aes;
extern crate ctr;
use ctr::stream_cipher::generic_array::GenericArray;
use ctr::stream_cipher::{
NewStreamCipher, SyncStreamCipher, SyncStreamCipherSeek
};
type Aes128Ctr = ctr::Ctr128<aes::Aes128>;
# fn main() {
let mut data = [1, 2, 3, 4, 5, 6, 7];
let key = GenericArray::from_slice(b"very secret key.");
let nonce = GenericArray::from_slice(b"and secret nonce");
let mut cipher = Aes128Ctr::new(&key, &nonce);
cipher.apply_keystream(&mut data);
assert_eq!(data, [6, 245, 126, 124, 180, 146, 37]);
cipher.seek(0);
cipher.apply_keystream(&mut data);
assert_eq!(data, [1, 2, 3, 4, 5, 6, 7]);
# }