diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/asm/aes128.asm | 16 | ||||
-rw-r--r-- | src/asm/aes192.asm | 16 | ||||
-rw-r--r-- | src/asm/aes256.asm | 16 | ||||
-rw-r--r-- | src/box.c | 24 | ||||
-rw-r--r-- | src/buffer.c | 12 | ||||
-rw-r--r-- | src/c/aes128.c | 40 | ||||
-rw-r--r-- | src/c/aes192.c | 36 | ||||
-rw-r--r-- | src/c/aes256.c | 46 |
8 files changed, 103 insertions, 103 deletions
diff --git a/src/asm/aes128.asm b/src/asm/aes128.asm index 4f88f09..03a9ace 100644 --- a/src/asm/aes128.asm +++ b/src/asm/aes128.asm @@ -8,7 +8,7 @@ .code -@aesni_raw_encrypt_block128@20 proc +@aesni_aes128_encrypt_block_@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -21,9 +21,9 @@ aesenc xmm0, [ecx + 90h] aesenclast xmm0, [ecx + 0A0h] ret -@aesni_raw_encrypt_block128@20 endp +@aesni_aes128_encrypt_block_@20 endp -@aesni_raw_decrypt_block128@20 proc +@aesni_aes128_decrypt_block_@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -36,9 +36,9 @@ aesdec xmm0, [ecx + 90h] aesdeclast xmm0, [ecx + 0A0h] ret -@aesni_raw_decrypt_block128@20 endp +@aesni_aes128_decrypt_block_@20 endp -@aesni_raw_expand_key_schedule128@20 proc +@aesni_aes128_expand_key_@20 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. ; Words are denoted by `w[N]`. ; @@ -165,9 +165,9 @@ aes128_keygen_assist: add ecx, 10h ; ecx = &w[i+8] ret -@aesni_raw_expand_key_schedule128@20 endp +@aesni_aes128_expand_key_@20 endp -@aesni_raw_invert_key_schedule128@8 proc +@aesni_aes128_derive_decryption_keys_raw@8 proc movdqa xmm5, [ecx] movdqa xmm4, [ecx + 0A0h] movdqa [edx], xmm4 @@ -197,6 +197,6 @@ aes128_keygen_assist: movdqa [edx + 50h], xmm5 ret -@aesni_raw_invert_key_schedule128@8 endp +@aesni_aes128_derive_decryption_keys_raw@8 endp end diff --git a/src/asm/aes192.asm b/src/asm/aes192.asm index e045910..cd28143 100644 --- a/src/asm/aes192.asm +++ b/src/asm/aes192.asm @@ -8,7 +8,7 @@ .code -@aesni_raw_encrypt_block192@20 proc +@aesni_aes192_encrypt_block_@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -23,9 +23,9 @@ aesenc xmm0, [ecx + 0B0h] aesenclast xmm0, [ecx + 0C0h] ret -@aesni_raw_encrypt_block192@20 endp +@aesni_aes192_encrypt_block_@20 endp -@aesni_raw_decrypt_block192@20 proc +@aesni_aes192_decrypt_block_@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -40,9 +40,9 @@ aesdec xmm0, [ecx + 0B0h] aesdeclast xmm0, [ecx + 0C0h] ret -@aesni_raw_decrypt_block192@20 endp +@aesni_aes192_decrypt_block_@20 endp -@aesni_raw_expand_key_schedule192@36 proc +@aesni_aes192_expand_key_@36 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. ; Words are denoted by `w[N]`. ; @@ -206,9 +206,9 @@ aes192_keygen_assist: ; xmm1[31:0] == w[i+10] == RotWord(SubWord(w[i+5]))^Rcon^w[i+4]^w[i+3]^w[i+2]^w[i+1]^w[i] ret -@aesni_raw_expand_key_schedule192@36 endp +@aesni_aes192_expand_key_@36 endp -@aesni_raw_invert_key_schedule192@8 proc +@aesni_aes192_derive_decryption_keys_@8 proc movdqa xmm5, [ecx] movdqa xmm4, [ecx + 0C0h] movdqa [edx], xmm4 @@ -243,6 +243,6 @@ aes192_keygen_assist: movdqa [edx + 60h], xmm5 ret -@aesni_raw_invert_key_schedule192@8 endp +@aesni_aes192_derive_decryption_keys_@8 endp end diff --git a/src/asm/aes256.asm b/src/asm/aes256.asm index 285cf69..f1c3eaf 100644 --- a/src/asm/aes256.asm +++ b/src/asm/aes256.asm @@ -8,7 +8,7 @@ .code -@aesni_raw_encrypt_block256@20 proc +@aesni_aes256_encrypt_block_@20 proc pxor xmm0, [ecx] aesenc xmm0, [ecx + 10h] aesenc xmm0, [ecx + 20h] @@ -25,9 +25,9 @@ aesenc xmm0, [ecx + 0D0h] aesenclast xmm0, [ecx + 0E0h] ret -@aesni_raw_encrypt_block256@20 endp +@aesni_aes256_encrypt_block_@20 endp -@aesni_raw_decrypt_block256@20 proc +@aesni_aes256_decrypt_block_@20 proc pxor xmm0, [ecx] aesdec xmm0, [ecx + 10h] aesdec xmm0, [ecx + 20h] @@ -44,9 +44,9 @@ aesdec xmm0, [ecx + 0D0h] aesdeclast xmm0, [ecx + 0E0h] ret -@aesni_raw_decrypt_block256@20 endp +@aesni_aes256_decrypt_block_@20 endp -@aesni_raw_expand_key_schedule256@36 proc +@aesni_aes256_expand_key_@36 proc ; A "word" (in terms of the FIPS 187 standard) is a 32-bit block. ; Words are denoted by `w[N]`. ; @@ -239,9 +239,9 @@ aes256_keygen_assist: pxor xmm0, xmm1 ret -@aesni_raw_expand_key_schedule256@36 endp +@aesni_aes256_expand_key_@36 endp -@aesni_raw_invert_key_schedule256@8 proc +@aesni_aes256_derive_decryption_keys_raw@8 proc movdqa xmm5, [ecx] movdqa xmm4, [ecx + 0E0h] movdqa [edx], xmm4 @@ -281,6 +281,6 @@ aes256_keygen_assist: movdqa [edx + 70h], xmm5 ret -@aesni_raw_invert_key_schedule256@8 endp +@aesni_aes256_derive_decryption_keys_raw@8 endp end @@ -23,7 +23,7 @@ static AesNI_StatusCode aesni_box_encrypt_aes128( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_encrypt_block128( + output->aes_block = aesni_aes128_encrypt_block_( input->aes_block, ¶ms->aes128_key_schedule); return AESNI_SUCCESS; @@ -35,7 +35,7 @@ static AesNI_StatusCode aesni_box_decrypt_aes128( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_decrypt_block128( + output->aes_block = aesni_aes128_decrypt_block_( input->aes_block, ¶ms->aes128_key_schedule); return AESNI_SUCCESS; @@ -47,7 +47,7 @@ static AesNI_StatusCode aesni_box_encrypt_aes192( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_encrypt_block192( + output->aes_block = aesni_aes192_encrypt_block_( input->aes_block, ¶ms->aes192_key_schedule); return AESNI_SUCCESS; @@ -59,7 +59,7 @@ static AesNI_StatusCode aesni_box_decrypt_aes192( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_decrypt_block192( + output->aes_block = aesni_aes192_decrypt_block_( input->aes_block, ¶ms->aes192_key_schedule); return AESNI_SUCCESS; @@ -71,7 +71,7 @@ static AesNI_StatusCode aesni_box_encrypt_aes256( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_encrypt_block256( + output->aes_block = aesni_aes256_encrypt_block_( input->aes_block, ¶ms->aes256_key_schedule); return AESNI_SUCCESS; @@ -83,7 +83,7 @@ static AesNI_StatusCode aesni_box_decrypt_aes256( AesNI_State* output, AesNI_ErrorDetails* err_details) { - output->aes_block = aesni_raw_decrypt_block256( + output->aes_block = aesni_aes256_decrypt_block_( input->aes_block, ¶ms->aes256_key_schedule); return AESNI_SUCCESS; @@ -132,10 +132,10 @@ static AesNI_StatusCode aesni_box_init_aes128( const AesNI_AlgorithmParams* algorithm_params, AesNI_ErrorDetails* err_details) { - aesni_raw_expand_key_schedule128( + aesni_aes128_expand_key_( algorithm_params->aes128_key, &box->encrypt_params.aes128_key_schedule); - aesni_raw_invert_key_schedule128( + aesni_aes128_derive_decryption_keys_( &box->encrypt_params.aes128_key_schedule, &box->decrypt_params.aes128_key_schedule); return AESNI_SUCCESS; @@ -146,11 +146,11 @@ static AesNI_StatusCode aesni_box_init_aes192( const AesNI_AlgorithmParams* algorithm_params, AesNI_ErrorDetails* err_details) { - aesni_raw_expand_key_schedule192( + aesni_aes192_expand_key_( algorithm_params->aes192_key.lo, algorithm_params->aes192_key.hi, &box->encrypt_params.aes192_key_schedule); - aesni_raw_invert_key_schedule192( + aesni_aes192_derive_decryption_keys_( &box->encrypt_params.aes192_key_schedule, &box->decrypt_params.aes192_key_schedule); return AESNI_SUCCESS; @@ -161,11 +161,11 @@ static AesNI_StatusCode aesni_box_init_aes256( const AesNI_AlgorithmParams* algorithm_params, AesNI_ErrorDetails* err_details) { - aesni_raw_expand_key_schedule256( + aesni_aes256_expand_key_( algorithm_params->aes256_key.lo, algorithm_params->aes256_key.hi, &box->encrypt_params.aes256_key_schedule); - aesni_raw_invert_key_schedule256( + aesni_aes256_derive_decryption_keys_( &box->encrypt_params.aes256_key_schedule, &box->decrypt_params.aes256_key_schedule); return AESNI_SUCCESS; diff --git a/src/buffer.c b/src/buffer.c index a4aed96..983c5cf 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -18,7 +18,7 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128( size_t src_size, void* dest, size_t* dest_size, - AesNI_KeySchedule128* key_schedule, + AesNI_Aes128_RoundKeys* key_schedule, AesNI_ErrorDetails* err_details) { if (dest_size == NULL) @@ -40,7 +40,7 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128( for (size_t i = 0; i < src_len; ++i, (char*) src += 16, (char*) dest += 16) { AesNI_Block128 plaintext = aesni_load_block128(src); - AesNI_Block128 ciphertext = aesni_encrypt_block_ecb128(plaintext, key_schedule); + AesNI_Block128 ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, key_schedule); aesni_store_block128(dest, ciphertext); } @@ -57,7 +57,7 @@ AesNI_StatusCode aesni_encrypt_buffer_ecb128( } AesNI_Block128 plaintext = aesni_load_block128(padding); - AesNI_Block128 ciphertext = aesni_encrypt_block_ecb128(plaintext, key_schedule); + AesNI_Block128 ciphertext = aesni_aes128_encrypt_block_ecb(plaintext, key_schedule); aesni_store_block128(dest, ciphertext); return AESNI_SUCCESS; @@ -80,7 +80,7 @@ AesNI_StatusCode aesni_decrypt_buffer_ecb128( size_t src_size, void* dest, size_t* dest_size, - AesNI_KeySchedule128* inverted_schedule, + AesNI_Aes128_RoundKeys* inverted_schedule, AesNI_ErrorDetails* err_details) { if (dest_size == NULL) @@ -100,12 +100,12 @@ AesNI_StatusCode aesni_decrypt_buffer_ecb128( for (size_t i = 0; i < src_len - 1; ++i, (char*) src += 16, (char*) dest += 16) { AesNI_Block128 ciphertext = aesni_load_block128(src); - AesNI_Block128 plaintext = aesni_decrypt_block_ecb128(ciphertext, inverted_schedule); + AesNI_Block128 plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, inverted_schedule); aesni_store_block128(dest, plaintext); } AesNI_Block128 ciphertext = aesni_load_block128(src); - AesNI_Block128 plaintext = aesni_decrypt_block_ecb128(ciphertext, inverted_schedule); + AesNI_Block128 plaintext = aesni_aes128_decrypt_block_ecb(ciphertext, inverted_schedule); unsigned char padding[16]; aesni_store_block128(padding, plaintext); diff --git a/src/c/aes128.c b/src/c/aes128.c index 92bc4a6..49ebc4a 100644 --- a/src/c/aes128.c +++ b/src/c/aes128.c @@ -11,9 +11,9 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesNI_Block128 __fastcall aesni_raw_encrypt_block128( +AesNI_Block128 __fastcall aesni_aes128_encrypt_block_( AesNI_Block128 plain, - const AesNI_KeySchedule128* key_schedule) + const AesNI_Aes128_RoundKeys* key_schedule) { plain = _mm_xor_si128(plain, key_schedule->keys[0]); plain = _mm_aesenc_si128(plain, key_schedule->keys[1]); @@ -28,9 +28,9 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block128( return _mm_aesenclast_si128(plain, key_schedule->keys[10]); } -AesNI_Block128 __fastcall aesni_raw_decrypt_block128( +AesNI_Block128 __fastcall aesni_aes128_decrypt_block_( AesNI_Block128 cipher, - const AesNI_KeySchedule128* inverted_schedule) + const AesNI_Aes128_RoundKeys* inverted_schedule) { cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]); cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]); @@ -45,7 +45,7 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block128( return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[10]); } -static AesNI_Block128 __fastcall aes128_keygen_assist( +static AesNI_Block128 __fastcall aesni_aes128_expand_key_assist( AesNI_Block128 prev, AesNI_Block128 hwgen) { @@ -64,26 +64,26 @@ static AesNI_Block128 __fastcall aes128_keygen_assist( return prev; } -void __fastcall aesni_raw_expand_key_schedule128( +void __fastcall aesni_aes128_expand_key_( AesNI_Block128 key, - AesNI_KeySchedule128* key_schedule) + AesNI_Aes128_RoundKeys* key_schedule) { AesNI_Block128 prev = key_schedule->keys[0] = key; - prev = key_schedule->keys[1] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01)); - prev = key_schedule->keys[2] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x02)); - prev = key_schedule->keys[3] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x04)); - prev = key_schedule->keys[4] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x08)); - prev = key_schedule->keys[5] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x10)); - prev = key_schedule->keys[6] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x20)); - prev = key_schedule->keys[7] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x40)); - prev = key_schedule->keys[8] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x80)); - prev = key_schedule->keys[9] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x1b)); - prev = key_schedule->keys[10] = aes128_keygen_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36)); + prev = key_schedule->keys[1] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01)); + prev = key_schedule->keys[2] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x02)); + prev = key_schedule->keys[3] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x04)); + prev = key_schedule->keys[4] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x08)); + prev = key_schedule->keys[5] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x10)); + prev = key_schedule->keys[6] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x20)); + prev = key_schedule->keys[7] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x40)); + prev = key_schedule->keys[8] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x80)); + prev = key_schedule->keys[9] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x1b)); + prev = key_schedule->keys[10] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36)); } -void __fastcall aesni_raw_invert_key_schedule128( - const AesNI_KeySchedule128* key_schedule, - AesNI_KeySchedule128* inverted_schedule) +void __fastcall aesni_aes128_derive_decryption_keys_( + const AesNI_Aes128_RoundKeys* key_schedule, + AesNI_Aes128_RoundKeys* inverted_schedule) { inverted_schedule->keys[0] = key_schedule->keys[10]; inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[9]); diff --git a/src/c/aes192.c b/src/c/aes192.c index b3a7e9f..d6ecea1 100644 --- a/src/c/aes192.c +++ b/src/c/aes192.c @@ -11,9 +11,9 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesNI_Block128 __fastcall aesni_raw_encrypt_block192( +AesNI_Block128 __fastcall aesni_aes192_encrypt_block_( AesNI_Block128 plain, - const AesNI_KeySchedule192* key_schedule) + const AesNI_Aes192_RoundKeys* key_schedule) { plain = _mm_xor_si128(plain, key_schedule->keys[0]); plain = _mm_aesenc_si128(plain, key_schedule->keys[1]); @@ -30,9 +30,9 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block192( return _mm_aesenclast_si128(plain, key_schedule->keys[12]); } -AesNI_Block128 __fastcall aesni_raw_decrypt_block192( +AesNI_Block128 __fastcall aesni_aes192_decrypt_block_( AesNI_Block128 cipher, - const AesNI_KeySchedule192* inverted_schedule) + const AesNI_Aes192_RoundKeys* inverted_schedule) { cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]); cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]); @@ -49,7 +49,7 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block192( return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[12]); } -static void __fastcall aes192_keygen_assist( +static void __fastcall aesni_aes192_expand_key_assist( AesNI_Block128* prev_lo, AesNI_Block128* prev_hi, AesNI_Block128 hwgen) @@ -74,49 +74,49 @@ static void __fastcall aes192_keygen_assist( *prev_hi = _mm_xor_si128(*prev_hi, tmp); } -void __fastcall aesni_raw_expand_key_schedule192( +void __fastcall aesni_aes192_expand_key_( AesNI_Block128 key_lo, AesNI_Block128 key_hi, - AesNI_KeySchedule192* key_schedule) + AesNI_Aes192_RoundKeys* key_schedule) { key_schedule->keys[0] = key_lo; key_schedule->keys[1] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x01)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x01)); key_schedule->keys[1] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[1]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[2] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x02)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x02)); key_schedule->keys[3] = key_lo; key_schedule->keys[4] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x04)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x04)); key_schedule->keys[4] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[4]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[5] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x08)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x08)); key_schedule->keys[6] = key_lo; key_schedule->keys[7] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x10)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x10)); key_schedule->keys[7] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[7]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[8] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x20)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x20)); key_schedule->keys[9] = key_lo; key_schedule->keys[10] = key_hi; - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x40)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x40)); key_schedule->keys[10] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_schedule->keys[10]), _mm_castsi128_pd(key_lo), 0)); key_schedule->keys[11] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1)); - aes192_keygen_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x80)); + aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x80)); key_schedule->keys[12] = key_lo; } -void __fastcall aesni_raw_invert_key_schedule192( - const AesNI_KeySchedule192* key_schedule, - AesNI_KeySchedule192* inverted_schedule) +void __fastcall aesni_aes192_derive_decryption_keys_( + const AesNI_Aes192_RoundKeys* key_schedule, + AesNI_Aes192_RoundKeys* inverted_schedule) { inverted_schedule->keys[0] = key_schedule->keys[12]; inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[11]); diff --git a/src/c/aes256.c b/src/c/aes256.c index cd48d0d..05e643e 100644 --- a/src/c/aes256.c +++ b/src/c/aes256.c @@ -11,9 +11,9 @@ #include <emmintrin.h> #include <wmmintrin.h> -AesNI_Block128 __fastcall aesni_raw_encrypt_block256( +AesNI_Block128 __fastcall aesni_aes256_encrypt_block_( AesNI_Block128 plain, - const AesNI_KeySchedule256* key_schedule) + const AesNI_Aes256_RoundKeys* key_schedule) { plain = _mm_xor_si128(plain, key_schedule->keys[0]); plain = _mm_aesenc_si128(plain, key_schedule->keys[1]); @@ -32,9 +32,9 @@ AesNI_Block128 __fastcall aesni_raw_encrypt_block256( return _mm_aesenclast_si128(plain, key_schedule->keys[14]); } -AesNI_Block128 __fastcall aesni_raw_decrypt_block256( +AesNI_Block128 __fastcall aesni_aes256_decrypt_block_( AesNI_Block128 cipher, - const AesNI_KeySchedule256* inverted_schedule) + const AesNI_Aes256_RoundKeys* inverted_schedule) { cipher = _mm_xor_si128(cipher, inverted_schedule->keys[0]); cipher = _mm_aesdec_si128(cipher, inverted_schedule->keys[1]); @@ -53,7 +53,7 @@ AesNI_Block128 __fastcall aesni_raw_decrypt_block256( return _mm_aesdeclast_si128(cipher, inverted_schedule->keys[14]); } -static AesNI_Block128 __fastcall aes256_keygen_assist( +static AesNI_Block128 __fastcall aesni_aes256_expand_key_assist( AesNI_Block128* prev_lo, AesNI_Block128* prev_hi, AesNI_Block128 hwgen) @@ -76,10 +76,10 @@ static AesNI_Block128 __fastcall aes256_keygen_assist( return *prev_hi; } -void __fastcall aesni_raw_expand_key_schedule256( +void __fastcall aesni_aes256_expand_key_( AesNI_Block128 key_lo, AesNI_Block128 key_hi, - AesNI_KeySchedule256* key_schedule) + AesNI_Aes256_RoundKeys* key_schedule) { AesNI_Block128 prev_lo, prev_hi; AesNI_Block128 hwgen; @@ -89,60 +89,60 @@ void __fastcall aesni_raw_expand_key_schedule256( hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x01); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[2] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[2] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[3] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[3] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x02); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[4] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[4] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[5] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[5] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x04); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[6] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[6] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[7] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[7] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x08); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[8] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[8] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[9] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[9] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x10); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[10] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[10] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[11] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[11] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x20); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[12] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[12] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0); hwgen = _mm_shuffle_epi32(hwgen, 0xaa); - key_schedule->keys[13] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[13] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x40); hwgen = _mm_shuffle_epi32(hwgen, 0xff); - key_schedule->keys[14] = aes256_keygen_assist(&prev_lo, &prev_hi, hwgen); + key_schedule->keys[14] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); } -void __fastcall aesni_raw_invert_key_schedule256( - const AesNI_KeySchedule256* key_schedule, - AesNI_KeySchedule256* inverted_schedule) +void __fastcall aesni_aes256_derive_decryption_keys_( + const AesNI_Aes256_RoundKeys* key_schedule, + AesNI_Aes256_RoundKeys* inverted_schedule) { inverted_schedule->keys[0] = key_schedule->keys[14]; inverted_schedule->keys[1] = _mm_aesimc_si128(key_schedule->keys[13]); |