Crate aesni [] [src]

AES block cipher implementation using AES-NI instruction set.

This crate does not implement any software fallback and does not automatically check CPUID, so if you are using this crate make sure to run software on appropriate hardware or to check AES-NI availability using check_aesni() function with appropriate software fallback in case of its unavailability.

Additionally this crate currently requires nigthly Rust compiler due to the usage of unstable asm and simd features.

Usage example

let key = [0u8; 16];
let mut block = [0u8; 16];
let mut block8 = [0u8; 16*8];
// Initialize cipher
let cipher = aesni::Aes128::new(&key);
// Encrypt block in-place
cipher.encrypt(&mut block);
// And decrypt it back
cipher.decrypt(&mut block);
assert_eq!(block, [0u8; 16]);
// We can encrypt 8 blocks simultaneously using instruction-level parallelism
cipher.encrypt8(&mut block8);
cipher.decrypt8(&mut block8);

Related documents

Structs

Aes128

AES-128 block cipher instance

Aes192

AES-192 block cipher instance

Aes256

AES-256 block cipher instance

Functions

check_aesni

Check if CPU has AES-NI using CPUID instruction.