aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/include/aesni
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/aesni/aes.h503
-rw-r--r--include/aesni/box_data.h20
-rw-r--r--include/aesni/mode.h160
3 files changed, 411 insertions, 272 deletions
diff --git a/include/aesni/aes.h b/include/aesni/aes.h
index 427ca85..ea859a3 100644
--- a/include/aesni/aes.h
+++ b/include/aesni/aes.h
@@ -19,276 +19,415 @@ extern "C"
{
#endif
-typedef AesNI_Block128 AesNI_Aes_Block;
+typedef AesNI_Block128 AesNI_AES_Block;
+typedef AesNI_AES_Block AesNI_AES128_Block;
+typedef AesNI_AES_Block AesNI_AES192_Block;
+typedef AesNI_AES_Block AesNI_AES256_Block;
typedef struct
{
- AesNI_Aes_Block key;
+ AesNI_AES_Block key;
}
-AesNI_Aes128_Key;
+AesNI_AES128_Key;
typedef struct
{
- AesNI_Aes_Block hi;
- AesNI_Aes_Block lo;
+ AesNI_AES_Block hi;
+ AesNI_AES_Block lo;
}
-AesNI_Aes192_Key;
+AesNI_AES192_Key;
typedef struct
{
- AesNI_Aes_Block hi;
- AesNI_Aes_Block lo;
+ AesNI_AES_Block hi;
+ AesNI_AES_Block lo;
}
-AesNI_Aes256_Key;
+AesNI_AES256_Key;
-static __inline void aesni_aes_make_block(AesNI_Aes_Block* dest, int hi3, int hi2, int lo1, int lo0)
+static __inline void aesni_AES_make_block(AesNI_AES_Block* dest, int hi3, int hi2, int lo1, int lo0)
{
*dest = aesni_make_block128(hi3, hi2, lo1, lo0);
}
-static __inline void aesni_aes128_make_key(AesNI_Aes128_Key* dest, int hi3, int hi2, int lo1, int lo0)
+static __inline void aesni_AES128_make_block(AesNI_AES128_Block* dest, int hi3, int hi2, int lo1, int lo0)
{
- dest->key = aesni_make_block128(hi3, hi2, lo1, lo0);
+ aesni_AES_make_block(dest, hi3, hi2, lo1, lo0);
}
-static __inline void aesni_aes192_make_key(AesNI_Aes192_Key* dest, int hi5, int hi4, int lo3, int lo2, int lo1, int lo0)
+static __inline void aesni_AES192_make_block(AesNI_AES192_Block* dest, int hi3, int hi2, int lo1, int lo0)
{
- dest->hi = aesni_make_block128(0, 0, hi5, hi4);
- dest->lo = aesni_make_block128(lo3, lo2, lo1, lo0);
+ aesni_AES_make_block(dest, hi3, hi2, lo1, lo0);
}
-static __inline void aesni_aes256_make_key(AesNI_Aes256_Key* dest, int hi7, int hi6, int hi5, int hi4, int lo3, int lo2, int lo1, int lo0)
+static __inline void aesni_AES256_make_block(AesNI_AES256_Block* dest, int hi3, int hi2, int lo1, int lo0)
{
- dest->hi = aesni_make_block128(hi7, hi6, hi5, hi4);
- dest->lo = aesni_make_block128(lo3, lo2, lo1, lo0);
+ aesni_AES_make_block(dest, hi3, hi2, lo1, lo0);
}
-typedef struct { char str[33]; } AesNI_Aes_BlockString;
-typedef struct { char str[49]; } AesNI_Aes_BlockMatrixString;
+static __inline void aesni_AES128_make_key(AesNI_AES128_Key* dest, int hi3, int hi2, int lo1, int lo0)
+{
+ aesni_AES_make_block(&dest->key, hi3, hi2, lo1, lo0);
+}
+
+static __inline void aesni_AES192_make_key(AesNI_AES192_Key* dest, int hi5, int hi4, int lo3, int lo2, int lo1, int lo0)
+{
+ aesni_AES_make_block(&dest->hi, 0, 0, hi5, hi4);
+ aesni_AES_make_block(&dest->lo, lo3, lo2, lo1, lo0);
+}
+
+static __inline void aesni_AES256_make_key(AesNI_AES256_Key* dest, int hi7, int hi6, int hi5, int hi4, int lo3, int lo2, int lo1, int lo0)
+{
+ aesni_AES_make_block(&dest->hi, hi7, hi6, hi5, hi4);
+ aesni_AES_make_block(&dest->lo, lo3, lo2, lo1, lo0);
+}
-AesNI_StatusCode aesni_aes_format_block(
- AesNI_Aes_BlockString*,
- const AesNI_Aes_Block*,
+typedef struct { char str[33]; } AesNI_AES_BlockString;
+typedef AesNI_AES_BlockString AesNI_AES128_BlockString;
+typedef AesNI_AES_BlockString AesNI_AES192_BlockString;
+typedef AesNI_AES_BlockString AesNI_AES256_BlockString;
+
+typedef struct { char str[49]; } AesNI_AES_BlockMatrixString;
+typedef AesNI_AES_BlockMatrixString AesNI_AES128_BlockMatrixString;
+typedef AesNI_AES_BlockMatrixString AesNI_AES192_BlockMatrixString;
+typedef AesNI_AES_BlockMatrixString AesNI_AES256_BlockMatrixString;
+
+AesNI_StatusCode aesni_AES_format_block(
+ AesNI_AES_BlockString*,
+ const AesNI_AES_Block*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes_format_block_as_matrix(
- AesNI_Aes_BlockMatrixString*,
- const AesNI_Aes_Block*,
+static __inline AesNI_StatusCode aesni_AES128_format_block(
+ AesNI_AES128_BlockString* dest,
+ const AesNI_AES128_Block* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_format_block(dest, src, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES192_format_block(
+ AesNI_AES192_BlockString* dest,
+ const AesNI_AES192_Block* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_format_block(dest, src, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES256_format_block(
+ AesNI_AES256_BlockString* dest,
+ const AesNI_AES256_Block* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_format_block(dest, src, err_details);
+}
+
+AesNI_StatusCode aesni_AES_format_block_as_matrix(
+ AesNI_AES_BlockMatrixString*,
+ const AesNI_AES_Block*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes_print_block(
- const AesNI_Aes_Block*,
+static __inline AesNI_StatusCode aesni_AES128_format_block_as_matrix(
+ AesNI_AES128_BlockMatrixString* dest,
+ const AesNI_AES128_Block* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_format_block_as_matrix(dest, src, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES192_format_block_as_matrix(
+ AesNI_AES192_BlockMatrixString* dest,
+ const AesNI_AES192_Block* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_format_block_as_matrix(dest, src, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES256_format_block_as_matrix(
+ AesNI_AES256_BlockMatrixString* dest,
+ const AesNI_AES256_Block* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_format_block_as_matrix(dest, src, err_details);
+}
+
+AesNI_StatusCode aesni_AES_print_block(
+ const AesNI_AES_Block*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes_print_block_as_matrix(
- const AesNI_Aes_Block*,
+static __inline AesNI_StatusCode aesni_AES128_print_block(
+ const AesNI_AES128_Block* block,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_print_block(block, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES192_print_block(
+ const AesNI_AES192_Block* block,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_print_block(block, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES256_print_block(
+ const AesNI_AES256_Block* block,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_print_block(block, err_details);
+}
+
+AesNI_StatusCode aesni_AES_print_block_as_matrix(
+ const AesNI_AES_Block*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes_parse_block(
- AesNI_Aes_Block* dest,
+static __inline AesNI_StatusCode aesni_AES128_print_block_as_matrix(
+ const AesNI_AES128_Block* block,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_print_block_as_matrix(block, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES192_print_block_as_matrix(
+ const AesNI_AES192_Block* block,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_print_block_as_matrix(block, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES256_print_block_as_matrix(
+ const AesNI_AES256_Block* block,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_print_block_as_matrix(block, err_details);
+}
+
+AesNI_StatusCode aesni_AES_parse_block(
+ AesNI_AES_Block* dest,
const char* src,
AesNI_ErrorDetails* err_details);
-typedef AesNI_Aes_BlockString AesNI_Aes128_KeyString;
-typedef struct { char str[49]; } AesNI_Aes192_KeyString;
-typedef struct { char str[65]; } AesNI_Aes256_KeyString;
+static __inline AesNI_StatusCode aesni_AES128_parse_block(
+ AesNI_AES128_Block* dest,
+ const char* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_parse_block(dest, src, err_details);
+}
+
+static __inline AesNI_StatusCode aesni_AES192_parse_block(
+ AesNI_AES192_Block* dest,
+ const char* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_parse_block(dest, src, err_details);
+}
-AesNI_StatusCode aesni_aes128_format_key(
- AesNI_Aes128_KeyString*,
- const AesNI_Aes128_Key*,
+static __inline AesNI_StatusCode aesni_AES256_parse_block(
+ AesNI_AES256_Block* dest,
+ const char* src,
+ AesNI_ErrorDetails* err_details)
+{
+ return aesni_AES_parse_block(dest, src, err_details);
+}
+
+typedef struct { char str[33]; } AesNI_AES128_KeyString;
+typedef struct { char str[49]; } AesNI_AES192_KeyString;
+typedef struct { char str[65]; } AesNI_AES256_KeyString;
+
+AesNI_StatusCode aesni_AES128_format_key(
+ AesNI_AES128_KeyString*,
+ const AesNI_AES128_Key*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes192_format_key(
- AesNI_Aes192_KeyString*,
- const AesNI_Aes192_Key*,
+AesNI_StatusCode aesni_AES192_format_key(
+ AesNI_AES192_KeyString*,
+ const AesNI_AES192_Key*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes256_format_key(
- AesNI_Aes256_KeyString*,
- const AesNI_Aes256_Key*,
+AesNI_StatusCode aesni_AES256_format_key(
+ AesNI_AES256_KeyString*,
+ const AesNI_AES256_Key*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes128_print_key(
- const AesNI_Aes128_Key*,
+AesNI_StatusCode aesni_AES128_print_key(
+ const AesNI_AES128_Key*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes192_print_key(
- const AesNI_Aes192_Key*,
+AesNI_StatusCode aesni_AES192_print_key(
+ const AesNI_AES192_Key*,
AesNI_ErrorDetails*);
-AesNI_StatusCode aesni_aes256_print_key(
- const AesNI_Aes256_Key*,
+AesNI_StatusCode aesni_AES256_print_key(
+ const AesNI_AES256_Key*,
AesNI_ErrorDetails*);
-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);
-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);
-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);
typedef struct
{
- AesNI_Aes_Block keys[11];
+ AesNI_AES_Block keys[11];
}
-AesNI_Aes128_RoundKeys;
+AesNI_AES128_RoundKeys;
typedef struct
{
- AesNI_Aes_Block keys[13];
+ AesNI_AES_Block keys[13];
}
-AesNI_Aes192_RoundKeys;
+AesNI_AES192_RoundKeys;
typedef struct
{
- AesNI_Aes_Block keys[15];
+ AesNI_AES_Block keys[15];
}
-AesNI_Aes256_RoundKeys;
+AesNI_AES256_RoundKeys;
-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);
-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);
-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);
-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);
-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);
-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);
-AesNI_Aes_Block __fastcall aesni_aes128_encrypt_block_(
- AesNI_Aes_Block plaintext,
- const AesNI_Aes128_RoundKeys*);
+AesNI_AES_Block __fastcall aesni_AES128_encrypt_block_(
+ AesNI_AES_Block plaintext,
+ const AesNI_AES128_RoundKeys*);
-AesNI_Aes_Block __fastcall aesni_aes192_encrypt_block_(
- AesNI_Aes_Block plaintext,
- const AesNI_Aes192_RoundKeys*);
+AesNI_AES_Block __fastcall aesni_AES192_encrypt_block_(
+ AesNI_AES_Block plaintext,
+ const AesNI_AES192_RoundKeys*);
-AesNI_Aes_Block __fastcall aesni_aes256_encrypt_block_(
- AesNI_Aes_Block plaintext,
- const AesNI_Aes256_RoundKeys*);
+AesNI_AES_Block __fastcall aesni_AES256_encrypt_block_(
+ AesNI_AES_Block plaintext,
+ const AesNI_AES256_RoundKeys*);
-AesNI_Aes_Block __fastcall aesni_aes128_decrypt_block_(
- AesNI_Aes_Block ciphertext,
- const AesNI_Aes128_RoundKeys*);
+AesNI_AES_Block __fastcall aesni_AES128_decrypt_block_(
+ AesNI_AES_Block ciphertext,
+ const AesNI_AES128_RoundKeys*);
-AesNI_Aes_Block __fastcall aesni_aes192_decrypt_block_(
- AesNI_Aes_Block ciphertext,
- const AesNI_Aes192_RoundKeys*);
+AesNI_AES_Block __fastcall aesni_AES192_decrypt_block_(
+ AesNI_AES_Block ciphertext,
+ const AesNI_AES192_RoundKeys*);
-AesNI_Aes_Block __fastcall aesni_aes256_decrypt_block_(
- AesNI_Aes_Block ciphertext,
- const AesNI_Aes256_RoundKeys*);
+AesNI_AES_Block __fastcall aesni_AES256_decrypt_block_(
+ AesNI_AES_Block ciphertext,
+ const AesNI_AES256_RoundKeys*);
-static __inline AesNI_Aes_Block __fastcall aesni_aes_xor_blocks(
- AesNI_Aes_Block a,
- AesNI_Aes_Block b)
+static __inline AesNI_AES_Block __fastcall aesni_AES_xor_blocks(
+ AesNI_AES_Block a,
+ AesNI_AES_Block b)
{
return aesni_xor_block128(a, b);
}
-static __inline AesNI_Aes_Block __fastcall aesni_aes128_xor_blocks(
- AesNI_Aes_Block a,
- AesNI_Aes_Block b)
+static __inline AesNI_AES_Block __fastcall aesni_AES128_xor_blocks(
+ AesNI_AES128_Block a,
+ AesNI_AES128_Block b)
{
- return aesni_aes_xor_blocks(a, b);
+ return aesni_AES_xor_blocks(a, b);
}
-static __inline AesNI_Aes_Block __fastcall aesni_aes192_xor_blocks(
- AesNI_Aes_Block a,
- AesNI_Aes_Block b)
+static __inline AesNI_AES_Block __fastcall aesni_AES192_xor_blocks(
+ AesNI_AES192_Block a,
+ AesNI_AES192_Block b)
{
- return aesni_aes_xor_blocks(a, b);
+ return aesni_AES_xor_blocks(a, b);
}
-static __inline AesNI_Aes_Block __fastcall aesni_aes256_xor_blocks(
- AesNI_Aes_Block a,
- AesNI_Aes_Block b)
+static __inline AesNI_AES_Block __fastcall aesni_AES256_xor_blocks(
+ AesNI_AES256_Block a,
+ AesNI_AES256_Block b)
{
- return aesni_aes_xor_blocks(a, b);
+ return aesni_AES_xor_blocks(a, b);
}
-static __inline AesNI_Aes_Block __fastcall aesni_aes_inc_block(
- AesNI_Aes_Block block)
+static __inline AesNI_AES_Block __fastcall aesni_AES_inc_block(
+ AesNI_AES_Block block)
{
block = aesni_reverse_byte_order_block128(block);
block = aesni_inc_block128(block);
return aesni_reverse_byte_order_block128(block);
}
-static __inline AesNI_Aes_Block __fastcall aesni_aes128_inc_block(
- AesNI_Aes_Block block)
+static __inline AesNI_AES_Block __fastcall aesni_AES128_inc_block(
+ AesNI_AES128_Block block)
{
- return aesni_aes_inc_block(block);
+ return aesni_AES_inc_block(block);
}
-static __inline AesNI_Aes_Block __fastcall aesni_aes192_inc_block(
- AesNI_Aes_Block block)
+static __inline AesNI_AES_Block __fastcall aesni_AES192_inc_block(
+ AesNI_AES192_Block block)
{
- return aesni_aes_inc_block(block);
+ return aesni_AES_inc_block(block);
}
-static __inline AesNI_Aes_Block __fastcall aesni_aes256_inc_block(
- AesNI_Aes_Block block)
+static __inline AesNI_AES_Block __fastcall aesni_AES256_inc_block(
+ AesNI_AES256_Block block)
{
- return aesni_aes_inc_block(block);
+ return aesni_AES_inc_block(block);
}
-AESNI_ENCRYPT_BLOCK_ECB(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_DECRYPT_BLOCK_ECB(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CBC(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_DECRYPT_BLOCK_CBC(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CFB(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_DECRYPT_BLOCK_CFB(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_ENCRYPT_BLOCK_OFB(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_DECRYPT_BLOCK_OFB(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CTR(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-AESNI_DECRYPT_BLOCK_CTR(aes128, AesNI_Aes_Block, AesNI_Aes128_RoundKeys);
-
-AESNI_ENCRYPT_BLOCK_ECB(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_DECRYPT_BLOCK_ECB(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CBC(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_DECRYPT_BLOCK_CBC(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CFB(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_DECRYPT_BLOCK_CFB(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_ENCRYPT_BLOCK_OFB(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_DECRYPT_BLOCK_OFB(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CTR(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-AESNI_DECRYPT_BLOCK_CTR(aes192, AesNI_Aes_Block, AesNI_Aes192_RoundKeys);
-
-AESNI_ENCRYPT_BLOCK_ECB(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_DECRYPT_BLOCK_ECB(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CBC(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_DECRYPT_BLOCK_CBC(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CFB(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_DECRYPT_BLOCK_CFB(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_ENCRYPT_BLOCK_OFB(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_DECRYPT_BLOCK_OFB(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_ENCRYPT_BLOCK_CTR(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
-AESNI_DECRYPT_BLOCK_CTR(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
+AESNI_ENCRYPT_BLOCK_ECB(AES128);
+AESNI_DECRYPT_BLOCK_ECB(AES128);
+AESNI_ENCRYPT_BLOCK_CBC(AES128);
+AESNI_DECRYPT_BLOCK_CBC(AES128);
+AESNI_ENCRYPT_BLOCK_CFB(AES128);
+AESNI_DECRYPT_BLOCK_CFB(AES128);
+AESNI_ENCRYPT_BLOCK_OFB(AES128);
+AESNI_DECRYPT_BLOCK_OFB(AES128);
+AESNI_ENCRYPT_BLOCK_CTR(AES128);
+AESNI_DECRYPT_BLOCK_CTR(AES128);
+
+AESNI_ENCRYPT_BLOCK_ECB(AES192);
+AESNI_DECRYPT_BLOCK_ECB(AES192);
+AESNI_ENCRYPT_BLOCK_CBC(AES192);
+AESNI_DECRYPT_BLOCK_CBC(AES192);
+AESNI_ENCRYPT_BLOCK_CFB(AES192);
+AESNI_DECRYPT_BLOCK_CFB(AES192);
+AESNI_ENCRYPT_BLOCK_OFB(AES192);
+AESNI_DECRYPT_BLOCK_OFB(AES192);
+AESNI_ENCRYPT_BLOCK_CTR(AES192);
+AESNI_DECRYPT_BLOCK_CTR(AES192);
+
+AESNI_ENCRYPT_BLOCK_ECB(AES256);
+AESNI_DECRYPT_BLOCK_ECB(AES256);
+AESNI_ENCRYPT_BLOCK_CBC(AES256);
+AESNI_DECRYPT_BLOCK_CBC(AES256);
+AESNI_ENCRYPT_BLOCK_CFB(AES256);
+AESNI_DECRYPT_BLOCK_CFB(AES256);
+AESNI_ENCRYPT_BLOCK_OFB(AES256);
+AESNI_DECRYPT_BLOCK_OFB(AES256);
+AESNI_ENCRYPT_BLOCK_CTR(AES256);
+AESNI_DECRYPT_BLOCK_CTR(AES256);
/**
* \brief Expands an AES-128 key into 10 encryption round keys.
@@ -296,13 +435,13 @@ AESNI_DECRYPT_BLOCK_CTR(aes256, AesNI_Aes_Block, AesNI_Aes256_RoundKeys);
* \param[in] key The AES-128 key.
* \param[out] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
*/
-static __inline void __fastcall aesni_aes128_expand_key(
- const AesNI_Aes128_Key* key,
- AesNI_Aes128_RoundKeys* encryption_keys)
+static __inline void __fastcall aesni_AES128_expand_key(
+ const AesNI_AES128_Key* key,
+ AesNI_AES128_RoundKeys* encryption_keys)
{
assert(encryption_keys);
- aesni_aes128_expand_key_(key->key, encryption_keys);
+ aesni_AES128_expand_key_(key->key, encryption_keys);
}
/**
@@ -311,14 +450,14 @@ static __inline void __fastcall aesni_aes128_expand_key(
* \param[in] encryption_keys The AES-128 encryption round keys. Must not be `NULL`.
* \param[out] decryption_keys The AES-128 decryption round keys. Must not be `NULL`.
*/
-static __inline void __fastcall aesni_aes128_derive_decryption_keys(
- const AesNI_Aes128_RoundKeys* encryption_keys,
- AesNI_Aes128_RoundKeys* decryption_keys)
+static __inline void __fastcall aesni_AES128_derive_decryption_keys(
+ const AesNI_AES128_RoundKeys* encryption_keys,
+ AesNI_AES128_RoundKeys* decryption_keys)
{
assert(encryption_keys);
assert(decryption_keys);
- aesni_aes128_derive_decryption_keys_(encryption_keys, decryption_keys);
+ aesni_AES128_derive_decryption_keys_(encryption_keys, decryption_keys);
}
/**
@@ -327,14 +466,14 @@ static __inline void __fastcall aesni_aes128_derive_decryption_keys(
* \param[in] key The AES-192 key.
* \param[out] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
*/
-static __inline void __fastcall aesni_aes192_expand_key(
- const AesNI_Aes192_Key* key,
- AesNI_Aes192_RoundKeys* encryption_keys)
+static __inline void __fastcall aesni_AES192_expand_key(
+ const AesNI_AES192_Key* key,
+ AesNI_AES192_RoundKeys* encryption_keys)
{
assert(key);
assert(encryption_keys);
- aesni_aes192_expand_key_(key->lo, key->hi, encryption_keys);
+ aesni_AES192_expand_key_(key->lo, key->hi, encryption_keys);
}
/**
@@ -343,14 +482,14 @@ static __inline void __fastcall aesni_aes192_expand_key(
* \param[in] encryption_keys The AES-192 encryption round keys. Must not be `NULL`.
* \param[out] decryption_keys The AES-192 decryption round keys. Must not be `NULL`.
*/
-static __inline void __fastcall aesni_aes192_derive_decryption_keys(
- const AesNI_Aes192_RoundKeys* encryption_keys,
- AesNI_Aes192_RoundKeys* decryption_keys)
+static __inline void __fastcall aesni_AES192_derive_decryption_keys(
+ const AesNI_AES192_RoundKeys* encryption_keys,
+ AesNI_AES192_RoundKeys* decryption_keys)
{
assert(encryption_keys);
assert(decryption_keys);
- aesni_aes192_derive_decryption_keys_(encryption_keys, decryption_keys);
+ aesni_AES192_derive_decryption_keys_(encryption_keys, decryption_keys);
}
/**
@@ -359,14 +498,14 @@ static __inline void __fastcall aesni_aes192_derive_decryption_keys(
* \param[in] key The AES-256 key.
* \param[out] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
*/
-static __inline void __fastcall aesni_aes256_expand_key(
- const AesNI_Aes256_Key* key,
- AesNI_Aes256_RoundKeys* encryption_keys)
+static __inline void __fastcall aesni_AES256_expand_key(
+ const AesNI_AES256_Key* key,
+ AesNI_AES256_RoundKeys* encryption_keys)
{
assert(key);
assert(encryption_keys);
- aesni_aes256_expand_key_(key->lo, key->hi, encryption_keys);
+ aesni_AES256_expand_key_(key->lo, key->hi, encryption_keys);
}
/**
@@ -375,14 +514,14 @@ static __inline void __fastcall aesni_aes256_expand_key(
* \param[in] encryption_keys The AES-256 encryption round keys. Must not be `NULL`.
* \param[out] decryption_keys The AES-256 decryption round keys. Must not be `NULL`.
*/
-static __inline void __fastcall aesni_aes256_derive_decryption_keys(
- const AesNI_Aes256_RoundKeys* encryption_keys,
- AesNI_Aes256_RoundKeys* decryption_keys)
+static __inline void __fastcall aesni_AES256_derive_decryption_keys(
+ const AesNI_AES256_RoundKeys* encryption_keys,
+ AesNI_AES256_RoundKeys* decryption_keys)
{
assert(encryption_keys);
assert(decryption_keys);
- aesni_aes256_derive_decryption_keys_(encryption_keys, decryption_keys);
+ aesni_AES256_derive_decryption_keys_(encryption_keys, decryption_keys);
}
#ifdef __cplusplus
diff --git a/include/aesni/box_data.h b/include/aesni/box_data.h
index ff36885..5d27641 100644
--- a/include/aesni/box_data.h
+++ b/include/aesni/box_data.h
@@ -21,31 +21,31 @@ extern "C"
typedef union
{
- AesNI_Aes128_Key aes128_key;
- AesNI_Aes192_Key aes192_key;
- AesNI_Aes256_Key aes256_key;
+ AesNI_AES128_Key aes128_key;
+ AesNI_AES192_Key aes192_key;
+ AesNI_AES256_Key aes256_key;
}
AesNI_BoxAlgorithmParams;
typedef union
{
- AesNI_Aes128_RoundKeys aes128_encryption_keys;
- AesNI_Aes192_RoundKeys aes192_encryption_keys;
- AesNI_Aes256_RoundKeys aes256_encryption_keys;
+ AesNI_AES128_RoundKeys aes128_encryption_keys;
+ AesNI_AES192_RoundKeys aes192_encryption_keys;
+ AesNI_AES256_RoundKeys aes256_encryption_keys;
}
AesNI_BoxEncryptionParams;
typedef union
{
- AesNI_Aes128_RoundKeys aes128_decryption_keys;
- AesNI_Aes192_RoundKeys aes192_decryption_keys;
- AesNI_Aes256_RoundKeys aes256_decryption_keys;
+ AesNI_AES128_RoundKeys aes128_decryption_keys;
+ AesNI_AES192_RoundKeys aes192_decryption_keys;
+ AesNI_AES256_RoundKeys aes256_decryption_keys;
}
AesNI_BoxDecryptionParams;
typedef union
{
- AesNI_Aes_Block aes_block;
+ AesNI_AES_Block aes_block;
}
AesNI_BoxBlock;
diff --git a/include/aesni/mode.h b/include/aesni/mode.h
index 831183c..81e6c5c 100644
--- a/include/aesni/mode.h
+++ b/include/aesni/mode.h
@@ -25,137 +25,137 @@ typedef enum
}
AesNI_Mode;
-#define AESNI_ENCRYPT_BLOCK_ECB(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_encrypt_block_ecb( \
- BlockT plaintext, \
- const KeyT* key) \
+#define AESNI_ENCRYPT_BLOCK_ECB(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_ECB( \
+ AesNI_## prefix ##_Block plaintext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys) \
{ \
- assert(key); \
+ assert(encryption_keys); \
\
- return aesni_## prefix ##_encrypt_block_(plaintext, key); \
+ return aesni_## prefix ##_encrypt_block_(plaintext, encryption_keys); \
}
-#define AESNI_DECRYPT_BLOCK_ECB(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_decrypt_block_ecb( \
- BlockT ciphertext, \
- const KeyT* key) \
+#define AESNI_DECRYPT_BLOCK_ECB(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_ECB( \
+ AesNI_## prefix ##_Block ciphertext, \
+ const AesNI_## prefix ##_RoundKeys* decryption_keys) \
{ \
- assert(key); \
+ assert(decryption_keys); \
\
- return aesni_## prefix ##_decrypt_block_(ciphertext, key); \
+ return aesni_## prefix ##_decrypt_block_(ciphertext, decryption_keys); \
}
-#define AESNI_ENCRYPT_BLOCK_CBC(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_encrypt_block_cbc( \
- BlockT plaintext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_ENCRYPT_BLOCK_CBC(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_CBC( \
+ AesNI_## prefix ##_Block plaintext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- assert(key); \
+ assert(encryption_keys); \
assert(next_init_vector); \
\
- return *next_init_vector = aesni_## prefix ##_encrypt_block_ecb( \
- aesni_## prefix ##_xor_blocks(plaintext, init_vector), key); \
+ return *next_init_vector = aesni_## prefix ##_encrypt_block_( \
+ aesni_## prefix ##_xor_blocks(plaintext, init_vector), encryption_keys); \
}
-#define AESNI_DECRYPT_BLOCK_CBC(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_decrypt_block_cbc( \
- BlockT ciphertext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_DECRYPT_BLOCK_CBC(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_CBC( \
+ AesNI_## prefix ##_Block ciphertext, \
+ const AesNI_## prefix ##_RoundKeys* decryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- assert(key); \
+ assert(decryption_keys); \
assert(next_init_vector); \
\
- BlockT plaintext = aesni_## prefix ##_xor_blocks( \
- aesni_## prefix ##_decrypt_block_ecb(ciphertext, key), init_vector); \
+ AesNI_## prefix ##_Block plaintext = aesni_## prefix ##_xor_blocks( \
+ aesni_## prefix ##_decrypt_block_(ciphertext, decryption_keys), init_vector); \
*next_init_vector = ciphertext; \
return plaintext; \
}
-#define AESNI_ENCRYPT_BLOCK_CFB(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_encrypt_block_cfb( \
- BlockT plaintext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_ENCRYPT_BLOCK_CFB(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_CFB( \
+ AesNI_## prefix ##_Block plaintext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- assert(key); \
+ assert(encryption_keys); \
assert(next_init_vector); \
\
return *next_init_vector = aesni_## prefix ##_xor_blocks( \
- aesni_## prefix ##_encrypt_block_ecb(init_vector, key), plaintext); \
+ aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys), plaintext); \
}
-#define AESNI_DECRYPT_BLOCK_CFB(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_decrypt_block_cfb( \
- BlockT ciphertext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_DECRYPT_BLOCK_CFB(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_CFB( \
+ AesNI_## prefix ##_Block ciphertext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- assert(key); \
+ assert(encryption_keys); \
assert(next_init_vector); \
\
- BlockT plaintext = aesni_## prefix ##_xor_blocks( \
- aesni_## prefix ##_encrypt_block_ecb(init_vector, key), ciphertext); \
+ AesNI_## prefix ##_Block plaintext = aesni_## prefix ##_xor_blocks( \
+ aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys), ciphertext); \
*next_init_vector = ciphertext; \
return plaintext; \
}
-#define AESNI_ENCRYPT_BLOCK_OFB(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_encrypt_block_ofb( \
- BlockT plaintext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_ENCRYPT_BLOCK_OFB(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_OFB( \
+ AesNI_## prefix ##_Block plaintext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- assert(key); \
+ assert(encryption_keys); \
assert(next_init_vector); \
\
- BlockT tmp = aesni_## prefix ##_encrypt_block_ecb(init_vector, key); \
+ AesNI_## prefix ##_Block tmp = aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys); \
*next_init_vector = tmp; \
return aesni_## prefix ##_xor_blocks(tmp, plaintext); \
}
-#define AESNI_DECRYPT_BLOCK_OFB(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_decrypt_block_ofb( \
- BlockT ciphertext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_DECRYPT_BLOCK_OFB(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_OFB( \
+ AesNI_## prefix ##_Block ciphertext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- return aesni_## prefix ##_encrypt_block_ofb( \
- ciphertext, key, init_vector, next_init_vector); \
+ return aesni_## prefix ##_encrypt_block_OFB( \
+ ciphertext, encryption_keys, init_vector, next_init_vector); \
}
-#define AESNI_ENCRYPT_BLOCK_CTR(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_encrypt_block_ctr( \
- BlockT plaintext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_ENCRYPT_BLOCK_CTR(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_encrypt_block_CTR( \
+ AesNI_## prefix ##_Block plaintext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- assert(key); \
+ assert(encryption_keys); \
assert(next_init_vector); \
\
- BlockT ciphertext = aesni_## prefix ##_xor_blocks( \
- plaintext, aesni_## prefix ##_encrypt_block_ecb(init_vector, key)); \
+ AesNI_## prefix ##_Block ciphertext = aesni_## prefix ##_xor_blocks( \
+ plaintext, aesni_## prefix ##_encrypt_block_(init_vector, encryption_keys)); \
*next_init_vector = aesni_## prefix ##_inc_block(init_vector); \
return ciphertext; \
}
-#define AESNI_DECRYPT_BLOCK_CTR(prefix, BlockT, KeyT) \
-static __inline BlockT __fastcall aesni_## prefix ##_decrypt_block_ctr( \
- BlockT ciphertext, \
- const KeyT* key, \
- BlockT init_vector, \
- BlockT* next_init_vector) \
+#define AESNI_DECRYPT_BLOCK_CTR(prefix) \
+static __inline AesNI_## prefix ##_Block __fastcall aesni_## prefix ##_decrypt_block_CTR( \
+ AesNI_## prefix ##_Block ciphertext, \
+ const AesNI_## prefix ##_RoundKeys* encryption_keys, \
+ AesNI_## prefix ##_Block init_vector, \
+ AesNI_## prefix ##_Block* next_init_vector) \
{ \
- return aesni_## prefix ##_encrypt_block_ctr( \
- ciphertext, key, init_vector, next_init_vector); \
+ return aesni_## prefix ##_encrypt_block_CTR( \
+ ciphertext, encryption_keys, init_vector, next_init_vector); \
}
#ifdef __cplusplus