aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src/c
diff options
context:
space:
mode:
Diffstat (limited to 'src/c')
-rw-r--r--src/c/aes128.c54
-rw-r--r--src/c/aes192.c52
-rw-r--r--src/c/aes256.c66
3 files changed, 86 insertions, 86 deletions
diff --git a/src/c/aes128.c b/src/c/aes128.c
index 94e8a05..3a797a9 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)
+AES_AES_Block __fastcall aes_AES128_encrypt_block_(
+ AES_AES_Block plaintext,
+ const AES_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)
+AES_AES_Block __fastcall aes_AES128_decrypt_block_(
+ AES_AES_Block ciphertext,
+ const AES_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 AES_AES_Block __fastcall aes_aes128_expand_key_assist(
+ AES_AES_Block prev,
+ AES_AES_Block hwgen)
{
- AesNI_AES_Block tmp = prev;
+ AES_AES_Block tmp = prev;
tmp = _mm_slli_si128(tmp, 4);
prev = _mm_xor_si128(prev, tmp);
@@ -64,26 +64,26 @@ 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 aes_AES128_expand_key_(
+ AES_AES_Block key,
+ AES_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));
- prev = encryption_keys->keys[2] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x02));
- prev = encryption_keys->keys[3] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x04));
- prev = encryption_keys->keys[4] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x08));
- prev = encryption_keys->keys[5] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x10));
- prev = encryption_keys->keys[6] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x20));
- prev = encryption_keys->keys[7] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x40));
- prev = encryption_keys->keys[8] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x80));
- prev = encryption_keys->keys[9] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x1b));
- prev = encryption_keys->keys[10] = aesni_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36));
+ AES_Block128 prev = encryption_keys->keys[0] = key;
+ prev = encryption_keys->keys[1] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01));
+ prev = encryption_keys->keys[2] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x02));
+ prev = encryption_keys->keys[3] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x04));
+ prev = encryption_keys->keys[4] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x08));
+ prev = encryption_keys->keys[5] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x10));
+ prev = encryption_keys->keys[6] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x20));
+ prev = encryption_keys->keys[7] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x40));
+ prev = encryption_keys->keys[8] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x80));
+ prev = encryption_keys->keys[9] = aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x1b));
+ prev = encryption_keys->keys[10] = aes_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 aes_AES128_derive_decryption_keys_(
+ const AES_AES128_RoundKeys* encryption_keys,
+ AES_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 570ab0e..4c2d4f4 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)
+AES_AES_Block __fastcall aes_AES192_encrypt_block_(
+ AES_AES_Block plaintext,
+ const AES_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)
+AES_AES_Block __fastcall aes_AES192_decrypt_block_(
+ AES_AES_Block ciphertext,
+ const AES_AES192_RoundKeys* decryption_keys)
{
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
@@ -49,12 +49,12 @@ AesNI_AES_Block __fastcall aesni_AES192_decrypt_block_(
return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[12]);
}
-static void __fastcall aesni_aes192_expand_key_assist(
- AesNI_AES_Block* prev_lo,
- AesNI_AES_Block* prev_hi,
- AesNI_AES_Block hwgen)
+static void __fastcall aes_aes192_expand_key_assist(
+ AES_AES_Block* prev_lo,
+ AES_AES_Block* prev_hi,
+ AES_AES_Block hwgen)
{
- AesNI_AES_Block tmp = *prev_lo;
+ AES_AES_Block tmp = *prev_lo;
tmp = _mm_slli_si128(tmp, 4);
*prev_lo = _mm_xor_si128(*prev_lo, tmp);
@@ -74,49 +74,49 @@ 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 aes_AES192_expand_key_(
+ AES_AES_Block key_lo,
+ AES_AES_Block key_hi,
+ AES_AES192_RoundKeys* encryption_keys)
{
encryption_keys->keys[0] = key_lo;
encryption_keys->keys[1] = key_hi;
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x01));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x01));
encryption_keys->keys[1] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[1]), _mm_castsi128_pd(key_lo), 0));
encryption_keys->keys[2] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x02));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x02));
encryption_keys->keys[3] = key_lo;
encryption_keys->keys[4] = key_hi;
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x04));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x04));
encryption_keys->keys[4] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[4]), _mm_castsi128_pd(key_lo), 0));
encryption_keys->keys[5] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x08));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x08));
encryption_keys->keys[6] = key_lo;
encryption_keys->keys[7] = key_hi;
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x10));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x10));
encryption_keys->keys[7] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[7]), _mm_castsi128_pd(key_lo), 0));
encryption_keys->keys[8] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x20));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x20));
encryption_keys->keys[9] = key_lo;
encryption_keys->keys[10] = key_hi;
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x40));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x40));
encryption_keys->keys[10] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(encryption_keys->keys[10]), _mm_castsi128_pd(key_lo), 0));
encryption_keys->keys[11] = _mm_castpd_si128(_mm_shuffle_pd(_mm_castsi128_pd(key_lo), _mm_castsi128_pd(key_hi), 1));
- aesni_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x80));
+ aes_aes192_expand_key_assist(&key_lo, &key_hi, _mm_aeskeygenassist_si128(key_hi, 0x80));
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 aes_AES192_derive_decryption_keys_(
+ const AES_AES192_RoundKeys* encryption_keys,
+ AES_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 23ac9ca..da81f7a 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)
+AES_AES_Block __fastcall aes_AES256_encrypt_block_(
+ AES_AES_Block plaintext,
+ const AES_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)
+AES_AES_Block __fastcall aes_AES256_decrypt_block_(
+ AES_AES_Block ciphertext,
+ const AES_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 AES_AES_Block __fastcall aes_aes256_expand_key_assist(
+ AES_AES_Block* prev_lo,
+ AES_AES_Block* prev_hi,
+ AES_AES_Block hwgen)
{
- AesNI_AES_Block tmp = *prev_lo;
+ AES_AES_Block tmp = *prev_lo;
tmp = _mm_slli_si128(tmp, 4);
*prev_lo = _mm_xor_si128(*prev_lo, tmp);
@@ -76,73 +76,73 @@ 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 aes_AES256_expand_key_(
+ AES_AES_Block key_lo,
+ AES_AES_Block key_hi,
+ AES_AES256_RoundKeys* encryption_keys)
{
- AesNI_AES_Block prev_lo, prev_hi;
- AesNI_AES_Block hwgen;
+ AES_AES_Block prev_lo, prev_hi;
+ AES_AES_Block hwgen;
prev_lo = encryption_keys->keys[0] = key_lo;
prev_hi = encryption_keys->keys[1] = key_hi;
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x01);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- encryption_keys->keys[2] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[2] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0);
hwgen = _mm_shuffle_epi32(hwgen, 0xaa);
- encryption_keys->keys[3] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[3] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x02);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- encryption_keys->keys[4] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[4] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0);
hwgen = _mm_shuffle_epi32(hwgen, 0xaa);
- encryption_keys->keys[5] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[5] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x04);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- encryption_keys->keys[6] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[6] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0);
hwgen = _mm_shuffle_epi32(hwgen, 0xaa);
- encryption_keys->keys[7] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[7] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x08);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- encryption_keys->keys[8] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[8] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0);
hwgen = _mm_shuffle_epi32(hwgen, 0xaa);
- encryption_keys->keys[9] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[9] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x10);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- encryption_keys->keys[10] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[10] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0);
hwgen = _mm_shuffle_epi32(hwgen, 0xaa);
- encryption_keys->keys[11] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[11] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x20);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- encryption_keys->keys[12] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[12] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0);
hwgen = _mm_shuffle_epi32(hwgen, 0xaa);
- encryption_keys->keys[13] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[13] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
hwgen = _mm_aeskeygenassist_si128(prev_hi, 0x40);
hwgen = _mm_shuffle_epi32(hwgen, 0xff);
- encryption_keys->keys[14] = aesni_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
+ encryption_keys->keys[14] = aes_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 aes_AES256_derive_decryption_keys_(
+ const AES_AES256_RoundKeys* encryption_keys,
+ AES_AES256_RoundKeys* decryption_keys)
{
decryption_keys->keys[0] = encryption_keys->keys[14];
decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[13]);