AESNI

hardware accelerated aes implementation makes use of intel AESNI

This code relies on intel AES and SSE2 instruction sets. If the CPU does not support all of these, an error will be thrown. Consider using checkHardwareAES() to check if aesni is supported.

version(AESNI) @safe
struct AESNI {
enum blockSize;
enum name;
}

Members

Functions

start
void start(bool forEncryption, in ubyte[] userKey, in ubyte[] iv = null)

Examples

Test AES encryption and decryption with different key sizes.

1 // test vectors from http://www.inconteam.com/software-development/41-encryption/55-aes-test-vectors
2 
3 static string[] test_keys = [
4 	x"2b7e151628aed2a6abf7158809cf4f3c",
5 	x"8e73b0f7da0e6452c810f32b809079e562f8ead2522c6b7b",
6 	x"603deb1015ca71be2b73aef0857d77811f352c073b6108d72d9810a30914dff4"
7 ];
8 
9 static string[] test_plaintexts = [
10 	x"6bc1bee22e409f96e93d7e117393172a",
11 	x"6bc1bee22e409f96e93d7e117393172a",
12 	x"6bc1bee22e409f96e93d7e117393172a"
13 ];
14 
15 static string[] test_ciphertexts = [
16 	x"3ad77bb40d7a3660a89ecaf32466ef97",
17 	x"bd334f1d6e45f25ff712a214571fa5cc",
18 	x"f3eed1bdb5d2a03c064b5a7e3db181f8"
19 
20 ];
21 
22 AESNIEngine t = new AESNIEngine();
23 
24 blockCipherTest(t, test_keys, test_plaintexts, test_ciphertexts);
25 

Meta