aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2015-07-28 21:34:15 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2015-07-28 21:34:15 +0300
commit53dfe511dc29beb8d399e95dfa93b6d3baed6b57 (patch)
treea0069dba9da96fe6cfc415b4c4fdc2d914cbd593 /src
parentcode style (diff)
downloadaes-tools-53dfe511dc29beb8d399e95dfa93b6d3baed6b57.tar.gz
aes-tools-53dfe511dc29beb8d399e95dfa93b6d3baed6b57.zip
refactoring
Namely, rename API functions to facilitate metaprogramming using preprocessor macros.
Diffstat (limited to '')
-rw-r--r--src/aes.c105
-rw-r--r--src/asm/aes128.asm16
-rw-r--r--src/asm/aes192.asm16
-rw-r--r--src/asm/aes256.asm16
-rw-r--r--src/box_aes.c28
-rw-r--r--src/c/aes128.c32
-rw-r--r--src/c/aes192.c34
-rw-r--r--src/c/aes256.c40
8 files changed, 152 insertions, 135 deletions
diff --git a/src/aes.c b/src/aes.c
index 7f21925..82db7cc 100644
--- a/src/aes.c
+++ b/src/aes.c
@@ -12,9 +12,9 @@
#include <stdio.h>
#include <string.h>
-AesNI_StatusCode aesni_aes_format_block(
- AesNI_Aes_BlockString* str,
- const AesNI_Aes_Block* block,
+AesNI_StatusCode aesni_AES_format_block(
+ AesNI_AES_BlockString* str,
+ const AesNI_AES_Block* block,
AesNI_ErrorDetails* err_details)
{
assert(str);
@@ -37,9 +37,9 @@ AesNI_StatusCode aesni_aes_format_block(
return AESNI_SUCCESS;
}
-AesNI_StatusCode aesni_aes_format_block_as_matrix(
- AesNI_Aes_BlockMatrixString* str,
- const AesNI_Aes_Block* block,
+AesNI_StatusCode aesni_AES_format_block_as_matrix(
+ AesNI_AES_BlockMatrixString* str,
+ const AesNI_AES_Block* block,
AesNI_ErrorDetails* err_details)
{
assert(str);
@@ -66,8 +66,8 @@ AesNI_StatusCode aesni_aes_format_block_as_matrix(
return AESNI_SUCCESS;
}
-AesNI_StatusCode aesni_aes_print_block(
- const AesNI_Aes_Block* block,
+AesNI_StatusCode aesni_AES_print_block(
+ const AesNI_AES_Block* block,
AesNI_ErrorDetails* err_details)
{
assert(block);
@@ -76,17 +76,17 @@ AesNI_StatusCode aesni_aes_print_block(
return aesni_error_null_argument(err_details, "block");
AesNI_StatusCode ec = AESNI_SUCCESS;
- AesNI_Aes_BlockString str;
+ AesNI_AES_BlockString str;
- if (aesni_is_error(ec = aesni_aes_format_block(&str, block, err_details)))
+ if (aesni_is_error(ec = aesni_AES_format_block(&str, block, err_details)))
return ec;
printf("%s\n", str.str);
return ec;
}
-AesNI_StatusCode aesni_aes_print_block_as_matrix(
- const AesNI_Aes_Block* block,
+AesNI_StatusCode aesni_AES_print_block_as_matrix(
+ const AesNI_AES_Block* block,
AesNI_ErrorDetails* err_details)
{
assert(block);
@@ -95,17 +95,17 @@ AesNI_StatusCode aesni_aes_print_block_as_matrix(
return aesni_error_null_argument(err_details, "block");
AesNI_StatusCode ec = AESNI_SUCCESS;
- AesNI_Aes_BlockMatrixString str;
+ AesNI_AES_BlockMatrixString str;
- if (aesni_is_error(ec = aesni_aes_format_block_as_matrix(&str, block, err_details)))
+ if (aesni_is_error(ec = aesni_AES_format_block_as_matrix(&str, block, err_details)))
return ec;
printf("%s", str.str);
return ec;
}
-AesNI_StatusCode aesni_aes_parse_block(
- AesNI_Aes_Block* dest,
+AesNI_StatusCode aesni_AES_parse_block(
+ AesNI_AES_Block* dest,
const char* src,
AesNI_ErrorDetails* err_details)
{
@@ -135,17 +135,34 @@ AesNI_StatusCode aesni_aes_parse_block(
return AESNI_SUCCESS;
}
-AesNI_StatusCode aesni_aes128_format_key(
- AesNI_Aes128_KeyString* str,
- const AesNI_Aes128_Key* key,
+AesNI_StatusCode aesni_AES128_format_key(
+ AesNI_AES128_KeyString* str,
+ const AesNI_AES128_Key* key,
AesNI_ErrorDetails* err_details)
{
- return aesni_aes_format_block(str, &key->key, err_details);
+ assert(str);
+ assert(key);
+
+ if (str == NULL)
+ return aesni_error_null_argument(err_details, "str");
+ if (key == NULL)
+ return aesni_error_null_argument(err_details, "key");
+
+ char* cursor = str->str;
+
+ __declspec(align(16)) unsigned char bytes[16];
+ aesni_store_block128_aligned(bytes, key->key);
+
+ for (int i = 0; i < 16; ++i, cursor += 2)
+ sprintf(cursor, "%02x", bytes[i]);
+
+ *cursor = '\0';
+ return AESNI_SUCCESS;
}
-AesNI_StatusCode aesni_aes192_format_key(
- AesNI_Aes192_KeyString* str,
- const AesNI_Aes192_Key* key,
+AesNI_StatusCode aesni_AES192_format_key(
+ AesNI_AES192_KeyString* str,
+ const AesNI_AES192_Key* key,
AesNI_ErrorDetails* err_details)
{
assert(str);
@@ -178,9 +195,9 @@ AesNI_StatusCode aesni_aes192_format_key(
return AESNI_SUCCESS;
}
-AesNI_StatusCode aesni_aes256_format_key(
- AesNI_Aes256_KeyString* str,
- const AesNI_Aes256_Key* key,
+AesNI_StatusCode aesni_AES256_format_key(
+ AesNI_AES256_KeyString* str,
+ const AesNI_AES256_Key* key,
AesNI_ErrorDetails* err_details)
{
assert(str);
@@ -213,15 +230,15 @@ AesNI_StatusCode aesni_aes256_format_key(
return AESNI_SUCCESS;
}
-AesNI_StatusCode aesni_aes128_print_key(
- const AesNI_Aes128_Key* key,
+AesNI_StatusCode aesni_AES128_print_key(
+ const AesNI_AES128_Key* key,
AesNI_ErrorDetails* err_details)
{
- return aesni_aes_print_block(&key->key, err_details);
+ return aesni_AES_print_block(&key->key, err_details);
}
-AesNI_StatusCode aesni_aes192_print_key(
- const AesNI_Aes192_Key* key,
+AesNI_StatusCode aesni_AES192_print_key(
+ const AesNI_AES192_Key* key,
AesNI_ErrorDetails* err_details)
{
assert(key);
@@ -230,17 +247,17 @@ AesNI_StatusCode aesni_aes192_print_key(
return aesni_error_null_argument(err_details, "key");
AesNI_StatusCode ec = AESNI_SUCCESS;
- AesNI_Aes192_KeyString str;
+ AesNI_AES192_KeyString str;
- if (aesni_is_error(ec = aesni_aes192_format_key(&str, key, err_details)))
+ if (aesni_is_error(ec = aesni_AES192_format_key(&str, key, err_details)))
return ec;
printf("%s\n", str.str);
return ec;
}
-AesNI_StatusCode aesni_aes256_print_key(
- const AesNI_Aes256_Key* key,
+AesNI_StatusCode aesni_AES256_print_key(
+ const AesNI_AES256_Key* key,
AesNI_ErrorDetails* err_details)
{
assert(key);
@@ -249,25 +266,25 @@ AesNI_StatusCode aesni_aes256_print_key(
return aesni_error_null_argument(err_details, "key");
AesNI_StatusCode ec = AESNI_SUCCESS;
- AesNI_Aes256_KeyString str;
+ AesNI_AES256_KeyString str;
- if (aesni_is_error(ec = aesni_aes256_format_key(&str, key, err_details)))
+ if (aesni_is_error(ec = aesni_AES256_format_key(&str, key, err_details)))
return ec;
printf("%s\n", str.str);
return ec;
}
-AesNI_StatusCode aesni_aes128_parse_key(
- AesNI_Aes128_Key* dest,
+AesNI_StatusCode aesni_AES128_parse_key(
+ AesNI_AES128_Key* dest,
const char* src,
AesNI_ErrorDetails* err_details)
{
- return aesni_aes_parse_block(&dest->key, src, err_details);
+ return aesni_AES_parse_block(&dest->key, src, err_details);
}
-AesNI_StatusCode aesni_aes192_parse_key(
- AesNI_Aes192_Key* dest,
+AesNI_StatusCode aesni_AES192_parse_key(
+ AesNI_AES192_Key* dest,
const char* src,
AesNI_ErrorDetails* err_details)
{
@@ -317,8 +334,8 @@ AesNI_StatusCode aesni_aes192_parse_key(
return AESNI_SUCCESS;
}
-AesNI_StatusCode aesni_aes256_parse_key(
- AesNI_Aes256_Key* dest,
+AesNI_StatusCode aesni_AES256_parse_key(
+ AesNI_AES256_Key* dest,
const char* src,
AesNI_ErrorDetails* err_details)
{
diff --git a/src/asm/aes128.asm b/src/asm/aes128.asm
index 70d2010..af9c839 100644
--- a/src/asm/aes128.asm
+++ b/src/asm/aes128.asm
@@ -8,7 +8,7 @@
.code
-@aesni_aes128_encrypt_block_@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_aes128_encrypt_block_@20 endp
+@aesni_AES128_encrypt_block_@20 endp
-@aesni_aes128_decrypt_block_@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_aes128_decrypt_block_@20 endp
+@aesni_AES128_decrypt_block_@20 endp
-@aesni_aes128_expand_key_@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_aes128_expand_key_@20 endp
+@aesni_AES128_expand_key_@20 endp
-@aesni_aes128_derive_decryption_keys_@8 proc
+@aesni_AES128_derive_decryption_keys_@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_aes128_derive_decryption_keys_@8 endp
+@aesni_AES128_derive_decryption_keys_@8 endp
end
diff --git a/src/asm/aes192.asm b/src/asm/aes192.asm
index cd28143..05e4f08 100644
--- a/src/asm/aes192.asm
+++ b/src/asm/aes192.asm
@@ -8,7 +8,7 @@
.code
-@aesni_aes192_encrypt_block_@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_aes192_encrypt_block_@20 endp
+@aesni_AES192_encrypt_block_@20 endp
-@aesni_aes192_decrypt_block_@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_aes192_decrypt_block_@20 endp
+@aesni_AES192_decrypt_block_@20 endp
-@aesni_aes192_expand_key_@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_aes192_expand_key_@36 endp
+@aesni_AES192_expand_key_@36 endp
-@aesni_aes192_derive_decryption_keys_@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_aes192_derive_decryption_keys_@8 endp
+@aesni_AES192_derive_decryption_keys_@8 endp
end
diff --git a/src/asm/aes256.asm b/src/asm/aes256.asm
index 9f1e735..0d19c26 100644
--- a/src/asm/aes256.asm
+++ b/src/asm/aes256.asm
@@ -8,7 +8,7 @@
.code
-@aesni_aes256_encrypt_block_@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_aes256_encrypt_block_@20 endp
+@aesni_AES256_encrypt_block_@20 endp
-@aesni_aes256_decrypt_block_@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_aes256_decrypt_block_@20 endp
+@aesni_AES256_decrypt_block_@20 endp
-@aesni_aes256_expand_key_@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_aes256_expand_key_@36 endp
+@aesni_AES256_expand_key_@36 endp
-@aesni_aes256_derive_decryption_keys_@8 proc
+@aesni_AES256_derive_decryption_keys_@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_aes256_derive_decryption_keys_@8 endp
+@aesni_AES256_derive_decryption_keys_@8 endp
end
diff --git a/src/box_aes.c b/src/box_aes.c
index 4e32aea..8642f31 100644
--- a/src/box_aes.c
+++ b/src/box_aes.c
@@ -17,10 +17,10 @@ static AesNI_StatusCode aesni_box_derive_params_aes128(
AesNI_BoxDecryptionParams* decrypt_params,
AesNI_ErrorDetails* err_details)
{
- aesni_aes128_expand_key_(
+ aesni_AES128_expand_key_(
algorithm_params->aes128_key.key,
&encrypt_params->aes128_encryption_keys);
- aesni_aes128_derive_decryption_keys_(
+ aesni_AES128_derive_decryption_keys_(
&encrypt_params->aes128_encryption_keys,
&decrypt_params->aes128_decryption_keys);
return AESNI_SUCCESS;
@@ -32,11 +32,11 @@ static AesNI_StatusCode aesni_box_derive_params_aes192(
AesNI_BoxDecryptionParams* decrypt_params,
AesNI_ErrorDetails* err_details)
{
- aesni_aes192_expand_key_(
+ aesni_AES192_expand_key_(
algorithm_params->aes192_key.lo,
algorithm_params->aes192_key.hi,
&encrypt_params->aes192_encryption_keys);
- aesni_aes192_derive_decryption_keys_(
+ aesni_AES192_derive_decryption_keys_(
&encrypt_params->aes192_encryption_keys,
&decrypt_params->aes192_decryption_keys);
return AESNI_SUCCESS;
@@ -48,11 +48,11 @@ static AesNI_StatusCode aesni_box_derive_params_aes256(
AesNI_BoxDecryptionParams* decrypt_params,
AesNI_ErrorDetails* err_details)
{
- aesni_aes256_expand_key_(
+ aesni_AES256_expand_key_(
algorithm_params->aes256_key.lo,
algorithm_params->aes256_key.hi,
&encrypt_params->aes256_encryption_keys);
- aesni_aes256_derive_decryption_keys_(
+ aesni_AES256_derive_decryption_keys_(
&encrypt_params->aes256_encryption_keys,
&decrypt_params->aes256_decryption_keys);
return AESNI_SUCCESS;
@@ -63,7 +63,7 @@ static AesNI_StatusCode aesni_box_xor_block_aes(
const AesNI_BoxBlock* src,
AesNI_ErrorDetails* err_details)
{
- dest->aes_block = aesni_aes_xor_blocks(dest->aes_block, src->aes_block);
+ dest->aes_block = aesni_AES_xor_blocks(dest->aes_block, src->aes_block);
return AESNI_SUCCESS;
}
@@ -71,7 +71,7 @@ static AesNI_StatusCode aesni_box_inc_block_aes(
AesNI_BoxBlock* ctr,
AesNI_ErrorDetails* err_details)
{
- ctr->aes_block = aesni_aes_inc_block(ctr->aes_block);
+ ctr->aes_block = aesni_AES_inc_block(ctr->aes_block);
return AESNI_SUCCESS;
}
@@ -107,7 +107,7 @@ static AesNI_StatusCode aesni_box_encrypt_block_aes128(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- output->aes_block = aesni_aes128_encrypt_block_(
+ output->aes_block = aesni_AES128_encrypt_block_(
input->aes_block,
&params->aes128_encryption_keys);
return AESNI_SUCCESS;
@@ -119,7 +119,7 @@ static AesNI_StatusCode aesni_box_decrypt_block_aes128(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- output->aes_block = aesni_aes128_decrypt_block_(
+ output->aes_block = aesni_AES128_decrypt_block_(
input->aes_block,
&params->aes128_decryption_keys);
return AESNI_SUCCESS;
@@ -131,7 +131,7 @@ static AesNI_StatusCode aesni_box_encrypt_block_aes192(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- output->aes_block = aesni_aes192_encrypt_block_(
+ output->aes_block = aesni_AES192_encrypt_block_(
input->aes_block,
&params->aes192_encryption_keys);
return AESNI_SUCCESS;
@@ -143,7 +143,7 @@ static AesNI_StatusCode aesni_box_decrypt_block_aes192(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- output->aes_block = aesni_aes192_decrypt_block_(
+ output->aes_block = aesni_AES192_decrypt_block_(
input->aes_block,
&params->aes192_decryption_keys);
return AESNI_SUCCESS;
@@ -155,7 +155,7 @@ static AesNI_StatusCode aesni_box_encrypt_block_aes256(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- output->aes_block = aesni_aes256_encrypt_block_(
+ output->aes_block = aesni_AES256_encrypt_block_(
input->aes_block,
&params->aes256_encryption_keys);
return AESNI_SUCCESS;
@@ -167,7 +167,7 @@ static AesNI_StatusCode aesni_box_decrypt_block_aes256(
AesNI_BoxBlock* output,
AesNI_ErrorDetails* err_details)
{
- output->aes_block = aesni_aes256_decrypt_block_(
+ output->aes_block = aesni_AES256_decrypt_block_(
input->aes_block,
&params->aes256_decryption_keys);
return AESNI_SUCCESS;
diff --git a/src/c/aes128.c b/src/c/aes128.c
index b2e37ba..a99c8a7 100644
--- a/src/c/aes128.c
+++ b/src/c/aes128.c
@@ -11,9 +11,9 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AesNI_Aes_Block __fastcall aesni_aes128_encrypt_block_(
- AesNI_Aes_Block plaintext,
- const AesNI_Aes128_RoundKeys* encryption_keys)
+AesNI_AES_Block __fastcall aesni_AES128_encrypt_block_(
+ AesNI_AES_Block plaintext,
+ const AesNI_AES128_RoundKeys* encryption_keys)
{
plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
@@ -28,9 +28,9 @@ AesNI_Aes_Block __fastcall aesni_aes128_encrypt_block_(
return _mm_aesenclast_si128(plaintext, encryption_keys->keys[10]);
}
-AesNI_Aes_Block __fastcall aesni_aes128_decrypt_block_(
- AesNI_Aes_Block ciphertext,
- const AesNI_Aes128_RoundKeys* decryption_keys)
+AesNI_AES_Block __fastcall aesni_AES128_decrypt_block_(
+ AesNI_AES_Block ciphertext,
+ const AesNI_AES128_RoundKeys* decryption_keys)
{
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
@@ -45,11 +45,11 @@ AesNI_Aes_Block __fastcall aesni_aes128_decrypt_block_(
return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[10]);
}
-static AesNI_Aes_Block __fastcall aesni_aes128_expand_key_assist(
- AesNI_Aes_Block prev,
- AesNI_Aes_Block hwgen)
+static AesNI_AES_Block __fastcall aesni_aes128_expand_key_assist(
+ AesNI_AES_Block prev,
+ AesNI_AES_Block hwgen)
{
- AesNI_Aes_Block tmp = prev;
+ AesNI_AES_Block tmp = prev;
tmp = _mm_slli_si128(tmp, 4);
prev = _mm_xor_si128(prev, tmp);
@@ -64,9 +64,9 @@ static AesNI_Aes_Block __fastcall aesni_aes128_expand_key_assist(
return prev;
}
-void __fastcall aesni_aes128_expand_key_(
- AesNI_Aes_Block key,
- AesNI_Aes128_RoundKeys* encryption_keys)
+void __fastcall aesni_AES128_expand_key_(
+ AesNI_AES_Block key,
+ AesNI_AES128_RoundKeys* encryption_keys)
{
AesNI_Block128 prev = encryption_keys->keys[0] = key;
prev = encryption_keys->keys[1] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01));
@@ -81,9 +81,9 @@ void __fastcall aesni_aes128_expand_key_(
prev = encryption_keys->keys[10] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36));
}
-void __fastcall aesni_aes128_derive_decryption_keys_(
- const AesNI_Aes128_RoundKeys* encryption_keys,
- AesNI_Aes128_RoundKeys* decryption_keys)
+void __fastcall aesni_AES128_derive_decryption_keys_(
+ const AesNI_AES128_RoundKeys* encryption_keys,
+ AesNI_AES128_RoundKeys* decryption_keys)
{
decryption_keys->keys[0] = encryption_keys->keys[10];
decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[9]);
diff --git a/src/c/aes192.c b/src/c/aes192.c
index 702ee5e..a8ae6cf 100644
--- a/src/c/aes192.c
+++ b/src/c/aes192.c
@@ -11,9 +11,9 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AesNI_Aes_Block __fastcall aesni_aes192_encrypt_block_(
- AesNI_Aes_Block plaintext,
- const AesNI_Aes192_RoundKeys* encryption_keys)
+AesNI_AES_Block __fastcall aesni_AES192_encrypt_block_(
+ AesNI_AES_Block plaintext,
+ const AesNI_AES192_RoundKeys* encryption_keys)
{
plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
@@ -30,9 +30,9 @@ AesNI_Aes_Block __fastcall aesni_aes192_encrypt_block_(
return _mm_aesenclast_si128(plaintext, encryption_keys->keys[12]);
}
-AesNI_Aes_Block __fastcall aesni_aes192_decrypt_block_(
- AesNI_Aes_Block ciphertext,
- const AesNI_Aes192_RoundKeys* decryption_keys)
+AesNI_AES_Block __fastcall aesni_AES192_decrypt_block_(
+ AesNI_AES_Block ciphertext,
+ const AesNI_AES192_RoundKeys* decryption_keys)
{
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
@@ -50,11 +50,11 @@ AesNI_Aes_Block __fastcall aesni_aes192_decrypt_block_(
}
static void __fastcall aesni_aes192_expand_key_assist(
- AesNI_Aes_Block* prev_lo,
- AesNI_Aes_Block* prev_hi,
- AesNI_Aes_Block hwgen)
+ AesNI_AES_Block* prev_lo,
+ AesNI_AES_Block* prev_hi,
+ AesNI_AES_Block hwgen)
{
- AesNI_Aes_Block tmp = *prev_lo;
+ AesNI_AES_Block tmp = *prev_lo;
tmp = _mm_slli_si128(tmp, 4);
*prev_lo = _mm_xor_si128(*prev_lo, tmp);
@@ -74,10 +74,10 @@ static void __fastcall aesni_aes192_expand_key_assist(
*prev_hi = _mm_xor_si128(*prev_hi, tmp);
}
-void __fastcall aesni_aes192_expand_key_(
- AesNI_Aes_Block key_lo,
- AesNI_Aes_Block key_hi,
- AesNI_Aes192_RoundKeys* encryption_keys)
+void __fastcall aesni_AES192_expand_key_(
+ AesNI_AES_Block key_lo,
+ AesNI_AES_Block key_hi,
+ AesNI_AES192_RoundKeys* encryption_keys)
{
encryption_keys->keys[0] = key_lo;
encryption_keys->keys[1] = key_hi;
@@ -114,9 +114,9 @@ void __fastcall aesni_aes192_expand_key_(
encryption_keys->keys[12] = key_lo;
}
-void __fastcall aesni_aes192_derive_decryption_keys_(
- const AesNI_Aes192_RoundKeys* encryption_keys,
- AesNI_Aes192_RoundKeys* decryption_keys)
+void __fastcall aesni_AES192_derive_decryption_keys_(
+ const AesNI_AES192_RoundKeys* encryption_keys,
+ AesNI_AES192_RoundKeys* decryption_keys)
{
decryption_keys->keys[0] = encryption_keys->keys[12];
decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[11]);
diff --git a/src/c/aes256.c b/src/c/aes256.c
index 243ec03..6099204 100644
--- a/src/c/aes256.c
+++ b/src/c/aes256.c
@@ -11,9 +11,9 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AesNI_Aes_Block __fastcall aesni_aes256_encrypt_block_(
- AesNI_Aes_Block plaintext,
- const AesNI_Aes256_RoundKeys* encryption_keys)
+AesNI_AES_Block __fastcall aesni_AES256_encrypt_block_(
+ AesNI_AES_Block plaintext,
+ const AesNI_AES256_RoundKeys* encryption_keys)
{
plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
@@ -32,9 +32,9 @@ AesNI_Aes_Block __fastcall aesni_aes256_encrypt_block_(
return _mm_aesenclast_si128(plaintext, encryption_keys->keys[14]);
}
-AesNI_Aes_Block __fastcall aesni_aes256_decrypt_block_(
- AesNI_Aes_Block ciphertext,
- const AesNI_Aes256_RoundKeys* decryption_keys)
+AesNI_AES_Block __fastcall aesni_AES256_decrypt_block_(
+ AesNI_AES_Block ciphertext,
+ const AesNI_AES256_RoundKeys* decryption_keys)
{
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
@@ -53,12 +53,12 @@ AesNI_Aes_Block __fastcall aesni_aes256_decrypt_block_(
return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[14]);
}
-static AesNI_Aes_Block __fastcall aesni_aes256_expand_key_assist(
- AesNI_Aes_Block* prev_lo,
- AesNI_Aes_Block* prev_hi,
- AesNI_Aes_Block hwgen)
+static AesNI_AES_Block __fastcall aesni_aes256_expand_key_assist(
+ AesNI_AES_Block* prev_lo,
+ AesNI_AES_Block* prev_hi,
+ AesNI_AES_Block hwgen)
{
- AesNI_Aes_Block tmp = *prev_lo;
+ AesNI_AES_Block tmp = *prev_lo;
tmp = _mm_slli_si128(tmp, 4);
*prev_lo = _mm_xor_si128(*prev_lo, tmp);
@@ -76,13 +76,13 @@ static AesNI_Aes_Block __fastcall aesni_aes256_expand_key_assist(
return *prev_hi;
}
-void __fastcall aesni_aes256_expand_key_(
- AesNI_Aes_Block key_lo,
- AesNI_Aes_Block key_hi,
- AesNI_Aes256_RoundKeys* encryption_keys)
+void __fastcall aesni_AES256_expand_key_(
+ AesNI_AES_Block key_lo,
+ AesNI_AES_Block key_hi,
+ AesNI_AES256_RoundKeys* encryption_keys)
{
- AesNI_Aes_Block prev_lo, prev_hi;
- AesNI_Aes_Block hwgen;
+ AesNI_AES_Block prev_lo, prev_hi;
+ AesNI_AES_Block hwgen;
prev_lo = encryption_keys->keys[0] = key_lo;
prev_hi = encryption_keys->keys[1] = key_hi;
@@ -140,9 +140,9 @@ void __fastcall aesni_aes256_expand_key_(
encryption_keys->keys[14] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
}
-void __fastcall aesni_aes256_derive_decryption_keys_(
- const AesNI_Aes256_RoundKeys* encryption_keys,
- AesNI_Aes256_RoundKeys* decryption_keys)
+void __fastcall aesni_AES256_derive_decryption_keys_(
+ const AesNI_AES256_RoundKeys* encryption_keys,
+ AesNI_AES256_RoundKeys* decryption_keys)
{
decryption_keys->keys[0] = encryption_keys->keys[14];
decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[13]);