Crate aes[−][src]
This crate is a wrapper around different implementations of AES block ciphers.
Currently it uses:
aes-soft
hardware independent bit-sliced implementationaesni
implementation using AES-NI instruction set. Used for x86-64 and x86 target architectures with enabled "aes" target feature.
Crate switches between implementations automatically at compile time.
(i.e. it does not use run-time feature detection) If enforce_soft
crate
feature is enabled software implementation will be used regardless of target
architecture and enabled target features.
Usage example
use aes::{Aes128, BlockCipher}; let key = GenericArray::from_slice(&[0u8; 16]); let mut block = GenericArray::clone_from_slice(&[0u8; 16]); let mut block8 = GenericArray::clone_from_slice(&[block; 8]); // Initialize cipher let cipher = Aes128::new(&key); let block_copy = block.clone(); // Encrypt block in-place cipher.encrypt_block(&mut block); // And decrypt it back cipher.decrypt_block(&mut block); assert_eq!(block, block_copy); // We can encrypt 8 blocks simultaneously using // instruction-level parallelism let block8_copy = block8.clone(); cipher.encrypt_blocks(&mut block8); cipher.decrypt_blocks(&mut block8); assert_eq!(block8, block8_copy);
For implementations of block cipher modes of operation see
block-modes
crate.
Re-exports
pub extern crate block_cipher_trait; |
Structs
Aes128 |
AES-128 block cipher instance |
Aes192 |
AES-192 block cipher instance |
Aes256 |
AES-256 block cipher instance |
Traits
BlockCipher |
The trait which defines in-place encryption and decryption over single block or several blocks in parallel. |