aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorEgor Tensin <egor@tensin.name>2026-07-20 21:32:29 +0200
committerEgor Tensin <egor@tensin.name>2026-07-20 21:32:29 +0200
commitf2c9b2934b9be0f93105c411f5dbea564800fc3f (patch)
tree1fd5b3d68904e44768273ee52598acd09dc04b14
parentget rid of outdated __inline (diff)
downloadaes-tools-f2c9b2934b9be0f93105c411f5dbea564800fc3f.tar.gz
aes-tools-f2c9b2934b9be0f93105c411f5dbea564800fc3f.zip
remove a few levels of stupid indirection
-rw-r--r--aes/include/aes/aes.h447
-rw-r--r--aes/include/aes/box_data.h28
-rw-r--r--aes/include/aes/data.h41
-rw-r--r--aes/include/aes/mode.h210
-rw-r--r--aes/src/aes.c92
-rw-r--r--aes/src/asm/aes128.asm16
-rw-r--r--aes/src/asm/aes192.asm16
-rw-r--r--aes/src/asm/aes256.asm16
-rw-r--r--aes/src/box_aes.c52
-rw-r--r--aes/src/c/aes128.c29
-rw-r--r--aes/src/c/aes192.c34
-rw-r--r--aes/src/c/aes256.c40
-rw-r--r--aesxx/include/aesxx/aes.hpp138
-rw-r--r--aesxx/include/aesxx/data.hpp18
-rw-r--r--aesxx/include/aesxx/mode.hpp140
15 files changed, 592 insertions, 725 deletions
diff --git a/aes/include/aes/aes.h b/aes/include/aes/aes.h
index 956496d..99e5f4b 100644
--- a/aes/include/aes/aes.h
+++ b/aes/include/aes/aes.h
@@ -15,62 +15,34 @@
extern "C" {
#endif
-typedef AES_Block128 AES_AES_Block;
-typedef AES_AES_Block AES_AES128_Block;
-typedef AES_AES_Block AES_AES192_Block;
-typedef AES_AES_Block AES_AES256_Block;
-
typedef struct {
- AES_AES_Block key;
-} AES_AES128_Key;
+ AES_Block key;
+} AES128_Key;
typedef struct {
- AES_AES_Block hi;
- AES_AES_Block lo;
-} AES_AES192_Key;
+ AES_Block hi;
+ AES_Block lo;
+} AES192_Key;
typedef struct {
- AES_AES_Block hi;
- AES_AES_Block lo;
-} AES_AES256_Key;
-
-static inline AES_AES_Block aes_AES_make_block(int hi3, int hi2, int lo1, int lo0) {
- return aes_make_block128(hi3, hi2, lo1, lo0);
-}
-
-static inline AES_AES128_Block aes_AES128_make_block(int hi3, int hi2, int lo1, int lo0) {
- return aes_AES_make_block(hi3, hi2, lo1, lo0);
-}
-
-static inline AES_AES192_Block aes_AES192_make_block(int hi3, int hi2, int lo1, int lo0) {
- return aes_AES_make_block(hi3, hi2, lo1, lo0);
-}
+ AES_Block hi;
+ AES_Block lo;
+} AES256_Key;
-static inline AES_AES256_Block aes_AES256_make_block(int hi3, int hi2, int lo1, int lo0) {
- return aes_AES_make_block(hi3, hi2, lo1, lo0);
-}
-
-static inline AES_AES128_Key aes_AES128_make_key(int hi3, int hi2, int lo1, int lo0) {
- AES_AES128_Key key;
- key.key = aes_AES_make_block(hi3, hi2, lo1, lo0);
+static inline AES128_Key aes128_make_key(int hi3, int hi2, int lo1, int lo0) {
+ AES128_Key key;
+ key.key = aes_make_block(hi3, hi2, lo1, lo0);
return key;
}
-static inline AES_AES192_Key aes_AES192_make_key(
- int hi5,
- int hi4,
- int lo3,
- int lo2,
- int lo1,
- int lo0
-) {
- AES_AES192_Key key;
- key.hi = aes_AES_make_block(0, 0, hi5, hi4);
- key.lo = aes_AES_make_block(lo3, lo2, lo1, lo0);
+static inline AES192_Key aes192_make_key(int hi5, int hi4, int lo3, int lo2, int lo1, int lo0) {
+ AES192_Key key;
+ key.hi = aes_make_block(0, 0, hi5, hi4);
+ key.lo = aes_make_block(lo3, lo2, lo1, lo0);
return key;
}
-static inline AES_AES256_Key aes_AES256_make_key(
+static inline AES256_Key aes256_make_key(
int hi7,
int hi6,
int hi5,
@@ -80,154 +52,150 @@ static inline AES_AES256_Key aes_AES256_make_key(
int lo1,
int lo0
) {
- AES_AES256_Key key;
- key.hi = aes_AES_make_block(hi7, hi6, hi5, hi4);
- key.lo = aes_AES_make_block(lo3, lo2, lo1, lo0);
+ AES256_Key key;
+ key.hi = aes_make_block(hi7, hi6, hi5, hi4);
+ key.lo = aes_make_block(lo3, lo2, lo1, lo0);
return key;
}
typedef struct {
char str[33];
-} AES_AES_BlockString;
+} AES_BlockString;
-typedef AES_AES_BlockString AES_AES128_BlockString;
-typedef AES_AES_BlockString AES_AES192_BlockString;
-typedef AES_AES_BlockString AES_AES256_BlockString;
+typedef AES_BlockString AES128_BlockString;
+typedef AES_BlockString AES192_BlockString;
+typedef AES_BlockString AES256_BlockString;
typedef struct {
char str[49];
-} AES_AES_BlockMatrixString;
+} AES_BlockMatrixString;
-typedef AES_AES_BlockMatrixString AES_AES128_BlockMatrixString;
-typedef AES_AES_BlockMatrixString AES_AES192_BlockMatrixString;
-typedef AES_AES_BlockMatrixString AES_AES256_BlockMatrixString;
+typedef AES_BlockMatrixString AES128_BlockMatrixString;
+typedef AES_BlockMatrixString AES192_BlockMatrixString;
+typedef AES_BlockMatrixString AES256_BlockMatrixString;
-AES_StatusCode aes_AES_format_block(AES_AES_BlockString*, const AES_AES_Block*, AES_ErrorDetails*);
+AES_StatusCode aes_AES_format_block(AES_BlockString*, const AES_Block*, AES_ErrorDetails*);
-static inline AES_StatusCode aes_AES128_format_block(
- AES_AES128_BlockString* dest,
- const AES_AES128_Block* src,
+static inline AES_StatusCode aes128_format_block(
+ AES128_BlockString* dest,
+ const AES_Block* src,
AES_ErrorDetails* err_details
) {
return aes_AES_format_block(dest, src, err_details);
}
-static inline AES_StatusCode aes_AES192_format_block(
- AES_AES192_BlockString* dest,
- const AES_AES192_Block* src,
+static inline AES_StatusCode aes192_format_block(
+ AES192_BlockString* dest,
+ const AES_Block* src,
AES_ErrorDetails* err_details
) {
return aes_AES_format_block(dest, src, err_details);
}
-static inline AES_StatusCode aes_AES256_format_block(
- AES_AES256_BlockString* dest,
- const AES_AES256_Block* src,
+static inline AES_StatusCode aes256_format_block(
+ AES256_BlockString* dest,
+ const AES_Block* src,
AES_ErrorDetails* err_details
) {
return aes_AES_format_block(dest, src, err_details);
}
AES_StatusCode aes_AES_format_block_as_matrix(
- AES_AES_BlockMatrixString*,
- const AES_AES_Block*,
+ AES_BlockMatrixString*,
+ const AES_Block*,
AES_ErrorDetails*
);
-static inline AES_StatusCode aes_AES128_format_block_as_matrix(
- AES_AES128_BlockMatrixString* dest,
- const AES_AES128_Block* src,
+static inline AES_StatusCode aes128_format_block_as_matrix(
+ AES128_BlockMatrixString* dest,
+ const AES_Block* src,
AES_ErrorDetails* err_details
) {
return aes_AES_format_block_as_matrix(dest, src, err_details);
}
-static inline AES_StatusCode aes_AES192_format_block_as_matrix(
- AES_AES192_BlockMatrixString* dest,
- const AES_AES192_Block* src,
+static inline AES_StatusCode aes192_format_block_as_matrix(
+ AES192_BlockMatrixString* dest,
+ const AES_Block* src,
AES_ErrorDetails* err_details
) {
return aes_AES_format_block_as_matrix(dest, src, err_details);
}
-static inline AES_StatusCode aes_AES256_format_block_as_matrix(
- AES_AES256_BlockMatrixString* dest,
- const AES_AES256_Block* src,
+static inline AES_StatusCode aes256_format_block_as_matrix(
+ AES256_BlockMatrixString* dest,
+ const AES_Block* src,
AES_ErrorDetails* err_details
) {
return aes_AES_format_block_as_matrix(dest, src, err_details);
}
-AES_StatusCode aes_AES_print_block(const AES_AES_Block*, AES_ErrorDetails*);
+AES_StatusCode aes_AES_print_block(const AES_Block*, AES_ErrorDetails*);
-static inline AES_StatusCode aes_AES128_print_block(
- const AES_AES128_Block* block,
+static inline AES_StatusCode aes128_print_block(
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
return aes_AES_print_block(block, err_details);
}
-static inline AES_StatusCode aes_AES192_print_block(
- const AES_AES192_Block* block,
+static inline AES_StatusCode aes192_print_block(
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
return aes_AES_print_block(block, err_details);
}
-static inline AES_StatusCode aes_AES256_print_block(
- const AES_AES256_Block* block,
+static inline AES_StatusCode aes256_print_block(
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
return aes_AES_print_block(block, err_details);
}
-AES_StatusCode aes_AES_print_block_as_matrix(const AES_AES_Block*, AES_ErrorDetails*);
+AES_StatusCode aes_AES_print_block_as_matrix(const AES_Block*, AES_ErrorDetails*);
-static inline AES_StatusCode aes_AES128_print_block_as_matrix(
- const AES_AES128_Block* block,
+static inline AES_StatusCode aes128_print_block_as_matrix(
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
return aes_AES_print_block_as_matrix(block, err_details);
}
-static inline AES_StatusCode aes_AES192_print_block_as_matrix(
- const AES_AES192_Block* block,
+static inline AES_StatusCode aes192_print_block_as_matrix(
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
return aes_AES_print_block_as_matrix(block, err_details);
}
-static inline AES_StatusCode aes_AES256_print_block_as_matrix(
- const AES_AES256_Block* block,
+static inline AES_StatusCode aes256_print_block_as_matrix(
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
return aes_AES_print_block_as_matrix(block, err_details);
}
-AES_StatusCode aes_AES_parse_block(
- AES_AES_Block* dest,
- const char* src,
- AES_ErrorDetails* err_details
-);
+AES_StatusCode aes_AES_parse_block(AES_Block* dest, const char* src, AES_ErrorDetails* err_details);
-static inline AES_StatusCode aes_AES128_parse_block(
- AES_AES128_Block* dest,
+static inline AES_StatusCode aes128_parse_block(
+ AES_Block* dest,
const char* src,
AES_ErrorDetails* err_details
) {
return aes_AES_parse_block(dest, src, err_details);
}
-static inline AES_StatusCode aes_AES192_parse_block(
- AES_AES192_Block* dest,
+static inline AES_StatusCode aes192_parse_block(
+ AES_Block* dest,
const char* src,
AES_ErrorDetails* err_details
) {
return aes_AES_parse_block(dest, src, err_details);
}
-static inline AES_StatusCode aes_AES256_parse_block(
- AES_AES256_Block* dest,
+static inline AES_StatusCode aes256_parse_block(
+ AES_Block* dest,
const char* src,
AES_ErrorDetails* err_details
) {
@@ -236,204 +204,119 @@ static inline AES_StatusCode aes_AES256_parse_block(
typedef struct {
char str[33];
-} AES_AES128_KeyString;
+} AES128_KeyString;
typedef struct {
char str[49];
-} AES_AES192_KeyString;
+} AES192_KeyString;
typedef struct {
char str[65];
-} AES_AES256_KeyString;
+} AES256_KeyString;
-AES_StatusCode aes_AES128_format_key(
- AES_AES128_KeyString*,
- const AES_AES128_Key*,
- AES_ErrorDetails*
-);
+AES_StatusCode aes128_format_key(AES128_KeyString*, const AES128_Key*, AES_ErrorDetails*);
-AES_StatusCode aes_AES192_format_key(
- AES_AES192_KeyString*,
- const AES_AES192_Key*,
- AES_ErrorDetails*
-);
+AES_StatusCode aes192_format_key(AES192_KeyString*, const AES192_Key*, AES_ErrorDetails*);
-AES_StatusCode aes_AES256_format_key(
- AES_AES256_KeyString*,
- const AES_AES256_Key*,
- AES_ErrorDetails*
-);
+AES_StatusCode aes256_format_key(AES256_KeyString*, const AES256_Key*, AES_ErrorDetails*);
-AES_StatusCode aes_AES128_print_key(const AES_AES128_Key*, AES_ErrorDetails*);
+AES_StatusCode aes128_print_key(const AES128_Key*, AES_ErrorDetails*);
-AES_StatusCode aes_AES192_print_key(const AES_AES192_Key*, AES_ErrorDetails*);
+AES_StatusCode aes192_print_key(const AES192_Key*, AES_ErrorDetails*);
-AES_StatusCode aes_AES256_print_key(const AES_AES256_Key*, AES_ErrorDetails*);
+AES_StatusCode aes256_print_key(const AES256_Key*, AES_ErrorDetails*);
-AES_StatusCode aes_AES128_parse_key(
- AES_AES128_Key* dest,
- const char* src,
- AES_ErrorDetails* err_details
-);
+AES_StatusCode aes128_parse_key(AES128_Key* dest, const char* src, AES_ErrorDetails* err_details);
-AES_StatusCode aes_AES192_parse_key(
- AES_AES192_Key* dest,
- const char* src,
- AES_ErrorDetails* err_details
-);
+AES_StatusCode aes192_parse_key(AES192_Key* dest, const char* src, AES_ErrorDetails* err_details);
-AES_StatusCode aes_AES256_parse_key(
- AES_AES256_Key* dest,
- const char* src,
- AES_ErrorDetails* err_details
-);
+AES_StatusCode aes256_parse_key(AES256_Key* dest, const char* src, AES_ErrorDetails* err_details);
typedef struct {
- AES_AES_Block keys[11];
-} AES_AES128_RoundKeys;
+ AES_Block keys[11];
+} AES128_RoundKeys;
typedef struct {
- AES_AES_Block keys[13];
-} AES_AES192_RoundKeys;
+ AES_Block keys[13];
+} AES192_RoundKeys;
typedef struct {
- AES_AES_Block keys[15];
-} AES_AES256_RoundKeys;
+ AES_Block keys[15];
+} AES256_RoundKeys;
-void __fastcall aes_AES128_expand_key_(AES_AES_Block key, AES_AES128_RoundKeys* encryption_keys);
+void __fastcall aes128_expand_key_(AES_Block key, AES128_RoundKeys* encryption_keys);
-void __fastcall aes_AES192_expand_key_(
- AES_AES_Block key_lo,
- AES_AES_Block key_hi,
- AES_AES192_RoundKeys* encryption_keys
+void __fastcall aes192_expand_key_(
+ AES_Block key_lo,
+ AES_Block key_hi,
+ AES192_RoundKeys* encryption_keys
);
-void __fastcall aes_AES256_expand_key_(
- AES_AES_Block key_lo,
- AES_AES_Block key_hi,
- AES_AES256_RoundKeys* encryption_keys
+void __fastcall aes256_expand_key_(
+ AES_Block key_lo,
+ AES_Block key_hi,
+ AES256_RoundKeys* encryption_keys
);
-void __fastcall aes_AES128_derive_decryption_keys_(
- const AES_AES128_RoundKeys* encryption_keys,
- AES_AES128_RoundKeys* decryption_keys
+void __fastcall aes128_derive_decryption_keys_(
+ const AES128_RoundKeys* encryption_keys,
+ AES128_RoundKeys* decryption_keys
);
-void __fastcall aes_AES192_derive_decryption_keys_(
- const AES_AES192_RoundKeys* encryption_keys,
- AES_AES192_RoundKeys* decryption_keys
+void __fastcall aes192_derive_decryption_keys_(
+ const AES192_RoundKeys* encryption_keys,
+ AES192_RoundKeys* decryption_keys
);
-void __fastcall aes_AES256_derive_decryption_keys_(
- const AES_AES256_RoundKeys* encryption_keys,
- AES_AES256_RoundKeys* decryption_keys
+void __fastcall aes256_derive_decryption_keys_(
+ const AES256_RoundKeys* encryption_keys,
+ AES256_RoundKeys* decryption_keys
);
-AES_AES_Block __fastcall aes_AES128_encrypt_block_(
- AES_AES_Block plaintext,
- const AES_AES128_RoundKeys*
-);
+AES_Block __fastcall aes128_encrypt_block_(AES_Block plaintext, const AES128_RoundKeys*);
-AES_AES_Block __fastcall aes_AES192_encrypt_block_(
- AES_AES_Block plaintext,
- const AES_AES192_RoundKeys*
-);
+AES_Block __fastcall aes192_encrypt_block_(AES_Block plaintext, const AES192_RoundKeys*);
-AES_AES_Block __fastcall aes_AES256_encrypt_block_(
- AES_AES_Block plaintext,
- const AES_AES256_RoundKeys*
-);
+AES_Block __fastcall aes256_encrypt_block_(AES_Block plaintext, const AES256_RoundKeys*);
-AES_AES_Block __fastcall aes_AES128_decrypt_block_(
- AES_AES_Block ciphertext,
- const AES_AES128_RoundKeys*
-);
+AES_Block __fastcall aes128_decrypt_block_(AES_Block ciphertext, const AES128_RoundKeys*);
-AES_AES_Block __fastcall aes_AES192_decrypt_block_(
- AES_AES_Block ciphertext,
- const AES_AES192_RoundKeys*
-);
-
-AES_AES_Block __fastcall aes_AES256_decrypt_block_(
- AES_AES_Block ciphertext,
- const AES_AES256_RoundKeys*
-);
+AES_Block __fastcall aes192_decrypt_block_(AES_Block ciphertext, const AES192_RoundKeys*);
-static inline AES_AES_Block __fastcall aes_AES_xor_blocks(AES_AES_Block a, AES_AES_Block b) {
- return aes_xor_block128(a, b);
-}
-
-static inline AES_AES_Block __fastcall aes_AES128_xor_blocks(
- AES_AES128_Block a,
- AES_AES128_Block b
-) {
- return aes_AES_xor_blocks(a, b);
-}
-
-static inline AES_AES_Block __fastcall aes_AES192_xor_blocks(
- AES_AES192_Block a,
- AES_AES192_Block b
-) {
- return aes_AES_xor_blocks(a, b);
-}
-
-static inline AES_AES_Block __fastcall aes_AES256_xor_blocks(
- AES_AES256_Block a,
- AES_AES256_Block b
-) {
- return aes_AES_xor_blocks(a, b);
-}
-
-static inline AES_AES_Block __fastcall aes_AES_inc_block(AES_AES_Block block) {
- block = aes_reverse_byte_order_block128(block);
- block = aes_inc_block128(block);
- return aes_reverse_byte_order_block128(block);
-}
-
-static inline AES_AES_Block __fastcall aes_AES128_inc_block(AES_AES128_Block block) {
- return aes_AES_inc_block(block);
-}
-
-static inline AES_AES_Block __fastcall aes_AES192_inc_block(AES_AES192_Block block) {
- return aes_AES_inc_block(block);
-}
-
-static inline AES_AES_Block __fastcall aes_AES256_inc_block(AES_AES256_Block block) {
- return aes_AES_inc_block(block);
-}
+AES_Block __fastcall aes256_decrypt_block_(AES_Block ciphertext, const AES256_RoundKeys*);
-AES_ENCRYPT_BLOCK_ECB(AES128)
-AES_DECRYPT_BLOCK_ECB(AES128)
-AES_ENCRYPT_BLOCK_CBC(AES128)
-AES_DECRYPT_BLOCK_CBC(AES128)
-AES_ENCRYPT_BLOCK_CFB(AES128)
-AES_DECRYPT_BLOCK_CFB(AES128)
-AES_ENCRYPT_BLOCK_OFB(AES128)
-AES_DECRYPT_BLOCK_OFB(AES128)
-AES_ENCRYPT_BLOCK_CTR(AES128)
-AES_DECRYPT_BLOCK_CTR(AES128)
+AES_ENCRYPT_BLOCK_ECB(128)
+AES_DECRYPT_BLOCK_ECB(128)
+AES_ENCRYPT_BLOCK_CBC(128)
+AES_DECRYPT_BLOCK_CBC(128)
+AES_ENCRYPT_BLOCK_CFB(128)
+AES_DECRYPT_BLOCK_CFB(128)
+AES_ENCRYPT_BLOCK_OFB(128)
+AES_DECRYPT_BLOCK_OFB(128)
+AES_ENCRYPT_BLOCK_CTR(128)
+AES_DECRYPT_BLOCK_CTR(128)
-AES_ENCRYPT_BLOCK_ECB(AES192)
-AES_DECRYPT_BLOCK_ECB(AES192)
-AES_ENCRYPT_BLOCK_CBC(AES192)
-AES_DECRYPT_BLOCK_CBC(AES192)
-AES_ENCRYPT_BLOCK_CFB(AES192)
-AES_DECRYPT_BLOCK_CFB(AES192)
-AES_ENCRYPT_BLOCK_OFB(AES192)
-AES_DECRYPT_BLOCK_OFB(AES192)
-AES_ENCRYPT_BLOCK_CTR(AES192)
-AES_DECRYPT_BLOCK_CTR(AES192)
+AES_ENCRYPT_BLOCK_ECB(192)
+AES_DECRYPT_BLOCK_ECB(192)
+AES_ENCRYPT_BLOCK_CBC(192)
+AES_DECRYPT_BLOCK_CBC(192)
+AES_ENCRYPT_BLOCK_CFB(192)
+AES_DECRYPT_BLOCK_CFB(192)
+AES_ENCRYPT_BLOCK_OFB(192)
+AES_DECRYPT_BLOCK_OFB(192)
+AES_ENCRYPT_BLOCK_CTR(192)
+AES_DECRYPT_BLOCK_CTR(192)
-AES_ENCRYPT_BLOCK_ECB(AES256)
-AES_DECRYPT_BLOCK_ECB(AES256)
-AES_ENCRYPT_BLOCK_CBC(AES256)
-AES_DECRYPT_BLOCK_CBC(AES256)
-AES_ENCRYPT_BLOCK_CFB(AES256)
-AES_DECRYPT_BLOCK_CFB(AES256)
-AES_ENCRYPT_BLOCK_OFB(AES256)
-AES_DECRYPT_BLOCK_OFB(AES256)
-AES_ENCRYPT_BLOCK_CTR(AES256)
-AES_DECRYPT_BLOCK_CTR(AES256)
+AES_ENCRYPT_BLOCK_ECB(256)
+AES_DECRYPT_BLOCK_ECB(256)
+AES_ENCRYPT_BLOCK_CBC(256)
+AES_DECRYPT_BLOCK_CBC(256)
+AES_ENCRYPT_BLOCK_CFB(256)
+AES_DECRYPT_BLOCK_CFB(256)
+AES_ENCRYPT_BLOCK_OFB(256)
+AES_DECRYPT_BLOCK_OFB(256)
+AES_ENCRYPT_BLOCK_CTR(256)
+AES_DECRYPT_BLOCK_CTR(256)
/**
* \brief Expands an AES-128 key into 10 encryption round keys.
@@ -441,13 +324,13 @@ AES_DECRYPT_BLOCK_CTR(AES256)
* \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 aes_AES128_expand_key(
- const AES_AES128_Key* key,
- AES_AES128_RoundKeys* encryption_keys
+static inline void __fastcall aes128_expand_key(
+ const AES128_Key* key,
+ AES128_RoundKeys* encryption_keys
) {
assert(encryption_keys);
- aes_AES128_expand_key_(key->key, encryption_keys);
+ aes128_expand_key_(key->key, encryption_keys);
}
/**
@@ -456,14 +339,14 @@ static inline void __fastcall aes_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 aes_AES128_derive_decryption_keys(
- const AES_AES128_RoundKeys* encryption_keys,
- AES_AES128_RoundKeys* decryption_keys
+static inline void __fastcall aes128_derive_decryption_keys(
+ const AES128_RoundKeys* encryption_keys,
+ AES128_RoundKeys* decryption_keys
) {
assert(encryption_keys);
assert(decryption_keys);
- aes_AES128_derive_decryption_keys_(encryption_keys, decryption_keys);
+ aes128_derive_decryption_keys_(encryption_keys, decryption_keys);
}
/**
@@ -472,14 +355,14 @@ static inline void __fastcall aes_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 aes_AES192_expand_key(
- const AES_AES192_Key* key,
- AES_AES192_RoundKeys* encryption_keys
+static inline void __fastcall aes192_expand_key(
+ const AES192_Key* key,
+ AES192_RoundKeys* encryption_keys
) {
assert(key);
assert(encryption_keys);
- aes_AES192_expand_key_(key->lo, key->hi, encryption_keys);
+ aes192_expand_key_(key->lo, key->hi, encryption_keys);
}
/**
@@ -488,14 +371,14 @@ static inline void __fastcall aes_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 aes_AES192_derive_decryption_keys(
- const AES_AES192_RoundKeys* encryption_keys,
- AES_AES192_RoundKeys* decryption_keys
+static inline void __fastcall aes192_derive_decryption_keys(
+ const AES192_RoundKeys* encryption_keys,
+ AES192_RoundKeys* decryption_keys
) {
assert(encryption_keys);
assert(decryption_keys);
- aes_AES192_derive_decryption_keys_(encryption_keys, decryption_keys);
+ aes192_derive_decryption_keys_(encryption_keys, decryption_keys);
}
/**
@@ -504,14 +387,14 @@ static inline void __fastcall aes_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 aes_AES256_expand_key(
- const AES_AES256_Key* key,
- AES_AES256_RoundKeys* encryption_keys
+static inline void __fastcall aes256_expand_key(
+ const AES256_Key* key,
+ AES256_RoundKeys* encryption_keys
) {
assert(key);
assert(encryption_keys);
- aes_AES256_expand_key_(key->lo, key->hi, encryption_keys);
+ aes256_expand_key_(key->lo, key->hi, encryption_keys);
}
/**
@@ -520,14 +403,14 @@ static inline void __fastcall aes_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 aes_AES256_derive_decryption_keys(
- const AES_AES256_RoundKeys* encryption_keys,
- AES_AES256_RoundKeys* decryption_keys
+static inline void __fastcall aes256_derive_decryption_keys(
+ const AES256_RoundKeys* encryption_keys,
+ AES256_RoundKeys* decryption_keys
) {
assert(encryption_keys);
assert(decryption_keys);
- aes_AES256_derive_decryption_keys_(encryption_keys, decryption_keys);
+ aes256_derive_decryption_keys_(encryption_keys, decryption_keys);
}
#ifdef __cplusplus
diff --git a/aes/include/aes/box_data.h b/aes/include/aes/box_data.h
index a95a742..5e5ab98 100644
--- a/aes/include/aes/box_data.h
+++ b/aes/include/aes/box_data.h
@@ -16,35 +16,35 @@ extern "C" {
#endif
typedef union {
- AES_AES128_Key aes128_key;
- AES_AES192_Key aes192_key;
- AES_AES256_Key aes256_key;
+ AES128_Key aes128_key;
+ AES192_Key aes192_key;
+ AES256_Key aes256_key;
} AES_BoxKey;
typedef union {
- AES_AES128_RoundKeys aes128_encryption_keys;
- AES_AES192_RoundKeys aes192_encryption_keys;
- AES_AES256_RoundKeys aes256_encryption_keys;
+ AES128_RoundKeys aes128_encryption_keys;
+ AES192_RoundKeys aes192_encryption_keys;
+ AES256_RoundKeys aes256_encryption_keys;
} AES_BoxEncryptionRoundKeys;
typedef union {
- AES_AES128_RoundKeys aes128_decryption_keys;
- AES_AES192_RoundKeys aes192_decryption_keys;
- AES_AES256_RoundKeys aes256_decryption_keys;
+ AES128_RoundKeys aes128_decryption_keys;
+ AES192_RoundKeys aes192_decryption_keys;
+ AES256_RoundKeys aes256_decryption_keys;
} AES_BoxDecryptionRoundKeys;
typedef union {
- AES_AES128_KeyString aes128;
- AES_AES192_KeyString aes192;
- AES_AES256_KeyString aes256;
+ AES128_KeyString aes128;
+ AES192_KeyString aes192;
+ AES256_KeyString aes256;
} AES_BoxKeyString;
typedef union {
- AES_AES_Block aes_block;
+ AES_Block aes_block;
} AES_BoxBlock;
typedef union {
- AES_AES_BlockString aes;
+ AES_BlockString aes;
} AES_BoxBlockString;
typedef AES_StatusCode (*AES_BoxCalculateRoundKeys)(
diff --git a/aes/include/aes/data.h b/aes/include/aes/data.h
index 1aec404..b83cb1d 100644
--- a/aes/include/aes/data.h
+++ b/aes/include/aes/data.h
@@ -13,9 +13,9 @@ extern "C" {
#endif
/**
- * \brief Represents a 128-bit block.
+ * \brief Represents a 128-bit AES block.
*/
-typedef __m128i AES_Block128;
+typedef __m128i AES_Block;
/**
* \brief Loads a 128-bit block from a memory location.
@@ -24,8 +24,8 @@ typedef __m128i AES_Block128;
*
* \return The loaded 128-bit block.
*/
-static inline AES_Block128 aes_load_block128(const void* src) {
- return _mm_loadu_si128((AES_Block128*)src);
+static inline AES_Block aes_load_block(const void* src) {
+ return _mm_loadu_si128((AES_Block*)src);
}
/**
@@ -35,8 +35,8 @@ static inline AES_Block128 aes_load_block128(const void* src) {
*
* \return The loaded 128-bit block.
*/
-static inline AES_Block128 aes_load_block128_aligned(const void* src) {
- return _mm_load_si128((AES_Block128*)src);
+static inline AES_Block aes_load_block_aligned(const void* src) {
+ return _mm_load_si128((AES_Block*)src);
}
/**
@@ -46,8 +46,8 @@ static inline AES_Block128 aes_load_block128_aligned(const void* src) {
*
* \param[in] block The block to be stored.
*/
-static inline void __fastcall aes_store_block128(void* dest, AES_Block128 block) {
- _mm_storeu_si128((AES_Block128*)dest, block);
+static inline void __fastcall aes_store_block(void* dest, AES_Block block) {
+ _mm_storeu_si128((AES_Block*)dest, block);
}
/**
@@ -57,8 +57,8 @@ static inline void __fastcall aes_store_block128(void* dest, AES_Block128 block)
*
* \param[in] block The block to be stored.
*/
-static inline void __fastcall aes_store_block128_aligned(void* dest, AES_Block128 block) {
- _mm_store_si128((AES_Block128*)dest, block);
+static inline void __fastcall aes_store_block_aligned(void* dest, AES_Block block) {
+ _mm_store_si128((AES_Block*)dest, block);
}
/**
@@ -69,7 +69,7 @@ static inline void __fastcall aes_store_block128_aligned(void* dest, AES_Block12
*
* \return `a^b`.
*/
-static inline AES_Block128 __fastcall aes_xor_block128(AES_Block128 a, AES_Block128 b) {
+static inline AES_Block __fastcall aes_xor_blocks(AES_Block a, AES_Block b) {
return _mm_xor_si128(a, b);
}
@@ -90,18 +90,23 @@ static inline AES_Block128 __fastcall aes_xor_block128(AES_Block128 a, AES_Block
*
* \return The built 128-bit block.
*/
-static inline AES_Block128 __fastcall aes_make_block128(int hi3, int hi2, int lo1, int lo0) {
+static inline AES_Block __fastcall aes_make_block(int hi3, int hi2, int lo1, int lo0) {
return _mm_set_epi32(hi3, hi2, lo1, lo0);
}
-static inline AES_Block128 __fastcall aes_reverse_byte_order_block128(AES_Block128 block) {
- return _mm_shuffle_epi8(
- block, aes_make_block128(0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f)
- );
+static inline AES_Block __fastcall aes_reverse_byte_order_block(AES_Block block) {
+ return _mm_shuffle_epi8(block, aes_make_block(0x00010203, 0x04050607, 0x08090a0b, 0x0c0d0e0f));
}
-static inline AES_Block128 __fastcall aes_inc_block128(AES_Block128 x) {
- return _mm_add_epi32(x, aes_make_block128(0, 0, 0, 1));
+static inline AES_Block __fastcall _aes_inc_block(AES_Block x) {
+ return _mm_add_epi32(x, aes_make_block(0, 0, 0, 1));
+}
+
+static inline AES_Block __fastcall aes_inc_block(AES_Block x) {
+ x = aes_reverse_byte_order_block(x);
+ x = _aes_inc_block(x);
+ x = aes_reverse_byte_order_block(x);
+ return x;
}
#ifdef __cplusplus
diff --git a/aes/include/aes/mode.h b/aes/include/aes/mode.h
index 0974281..656388f 100644
--- a/aes/include/aes/mode.h
+++ b/aes/include/aes/mode.h
@@ -19,148 +19,148 @@ typedef enum {
AES_CTR,
} AES_Mode;
-#define AES_ENCRYPT_BLOCK_ECB(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_ECB( \
- AES_##prefix##_Block plaintext, const AES_##prefix##_RoundKeys* encryption_keys \
- ) { \
- assert(encryption_keys); \
- \
- return aes_##prefix##_encrypt_block_(plaintext, encryption_keys); \
+#define AES_ENCRYPT_BLOCK_ECB(version) \
+ static inline AES_Block __fastcall aes##version##_encrypt_block_ECB( \
+ AES_Block plaintext, const AES##version##_RoundKeys* encryption_keys \
+ ) { \
+ assert(encryption_keys); \
+ \
+ return aes##version##_encrypt_block_(plaintext, encryption_keys); \
}
-#define AES_DECRYPT_BLOCK_ECB(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_decrypt_block_ECB( \
- AES_##prefix##_Block ciphertext, const AES_##prefix##_RoundKeys* decryption_keys \
- ) { \
- assert(decryption_keys); \
- \
- return aes_##prefix##_decrypt_block_(ciphertext, decryption_keys); \
+#define AES_DECRYPT_BLOCK_ECB(version) \
+ static inline AES_Block __fastcall aes##version##_decrypt_block_ECB( \
+ AES_Block ciphertext, const AES##version##_RoundKeys* decryption_keys \
+ ) { \
+ assert(decryption_keys); \
+ \
+ return aes##version##_decrypt_block_(ciphertext, decryption_keys); \
}
-#define AES_ENCRYPT_BLOCK_CBC(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_CBC( \
- AES_##prefix##_Block plaintext, \
- const AES_##prefix##_RoundKeys* encryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
- ) { \
- assert(encryption_keys); \
- assert(next_init_vector); \
- \
- return *next_init_vector = aes_##prefix##_encrypt_block_( \
- aes_##prefix##_xor_blocks(plaintext, init_vector), encryption_keys \
- ); \
+#define AES_ENCRYPT_BLOCK_CBC(version) \
+ static inline AES_Block __fastcall aes##version##_encrypt_block_CBC( \
+ AES_Block plaintext, \
+ const AES##version##_RoundKeys* encryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
+ ) { \
+ assert(encryption_keys); \
+ assert(next_init_vector); \
+ \
+ return *next_init_vector = aes##version##_encrypt_block_( \
+ aes_xor_blocks(plaintext, init_vector), encryption_keys \
+ ); \
}
-#define AES_DECRYPT_BLOCK_CBC(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_decrypt_block_CBC( \
- AES_##prefix##_Block ciphertext, \
- const AES_##prefix##_RoundKeys* decryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
+#define AES_DECRYPT_BLOCK_CBC(version) \
+ static inline AES_Block __fastcall aes##version##_decrypt_block_CBC( \
+ AES_Block ciphertext, \
+ const AES##version##_RoundKeys* decryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
) { \
assert(decryption_keys); \
assert(next_init_vector); \
\
- AES_##prefix##_Block plaintext = aes_##prefix##_xor_blocks( \
- aes_##prefix##_decrypt_block_(ciphertext, decryption_keys), init_vector \
+ AES_Block plaintext = aes_xor_blocks( \
+ aes##version##_decrypt_block_(ciphertext, decryption_keys), init_vector \
); \
*next_init_vector = ciphertext; \
return plaintext; \
}
-#define AES_ENCRYPT_BLOCK_CFB(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_CFB( \
- AES_##prefix##_Block plaintext, \
- const AES_##prefix##_RoundKeys* encryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
+#define AES_ENCRYPT_BLOCK_CFB(version) \
+ static inline AES_Block __fastcall aes##version##_encrypt_block_CFB( \
+ AES_Block plaintext, \
+ const AES##version##_RoundKeys* encryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
) { \
assert(encryption_keys); \
assert(next_init_vector); \
\
- return *next_init_vector = aes_##prefix##_xor_blocks( \
- aes_##prefix##_encrypt_block_(init_vector, encryption_keys), plaintext \
+ return *next_init_vector = aes_xor_blocks( \
+ aes##version##_encrypt_block_(init_vector, encryption_keys), plaintext \
); \
}
-#define AES_DECRYPT_BLOCK_CFB(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_decrypt_block_CFB( \
- AES_##prefix##_Block ciphertext, \
- const AES_##prefix##_RoundKeys* encryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
+#define AES_DECRYPT_BLOCK_CFB(version) \
+ static inline AES_Block __fastcall aes##version##_decrypt_block_CFB( \
+ AES_Block ciphertext, \
+ const AES##version##_RoundKeys* encryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
) { \
assert(encryption_keys); \
assert(next_init_vector); \
\
- AES_##prefix##_Block plaintext = aes_##prefix##_xor_blocks( \
- aes_##prefix##_encrypt_block_(init_vector, encryption_keys), ciphertext \
+ AES_Block plaintext = aes_xor_blocks( \
+ aes##version##_encrypt_block_(init_vector, encryption_keys), ciphertext \
); \
*next_init_vector = ciphertext; \
return plaintext; \
}
-#define AES_ENCRYPT_BLOCK_OFB(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_OFB( \
- AES_##prefix##_Block plaintext, \
- const AES_##prefix##_RoundKeys* encryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
- ) { \
- assert(encryption_keys); \
- assert(next_init_vector); \
- \
- AES_##prefix##_Block tmp = aes_##prefix##_encrypt_block_(init_vector, encryption_keys); \
- *next_init_vector = tmp; \
- return aes_##prefix##_xor_blocks(tmp, plaintext); \
+#define AES_ENCRYPT_BLOCK_OFB(version) \
+ static inline AES_Block __fastcall aes##version##_encrypt_block_OFB( \
+ AES_Block plaintext, \
+ const AES##version##_RoundKeys* encryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
+ ) { \
+ assert(encryption_keys); \
+ assert(next_init_vector); \
+ \
+ AES_Block tmp = aes##version##_encrypt_block_(init_vector, encryption_keys); \
+ *next_init_vector = tmp; \
+ return aes_xor_blocks(tmp, plaintext); \
}
-#define AES_DECRYPT_BLOCK_OFB(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_decrypt_block_OFB( \
- AES_##prefix##_Block ciphertext, \
- const AES_##prefix##_RoundKeys* encryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
- ) { \
- assert(encryption_keys); \
- assert(next_init_vector); \
- \
- return aes_##prefix##_encrypt_block_OFB( \
- ciphertext, encryption_keys, init_vector, next_init_vector \
- ); \
+#define AES_DECRYPT_BLOCK_OFB(version) \
+ static inline AES_Block __fastcall aes##version##_decrypt_block_OFB( \
+ AES_Block ciphertext, \
+ const AES##version##_RoundKeys* encryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
+ ) { \
+ assert(encryption_keys); \
+ assert(next_init_vector); \
+ \
+ return aes##version##_encrypt_block_OFB( \
+ ciphertext, encryption_keys, init_vector, next_init_vector \
+ ); \
}
-#define AES_ENCRYPT_BLOCK_CTR(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_CTR( \
- AES_##prefix##_Block plaintext, \
- const AES_##prefix##_RoundKeys* encryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
- ) { \
- assert(encryption_keys); \
- assert(next_init_vector); \
- \
- AES_##prefix##_Block ciphertext = aes_##prefix##_xor_blocks( \
- plaintext, aes_##prefix##_encrypt_block_(init_vector, encryption_keys) \
- ); \
- *next_init_vector = aes_##prefix##_inc_block(init_vector); \
- return ciphertext; \
+#define AES_ENCRYPT_BLOCK_CTR(version) \
+ static inline AES_Block __fastcall aes##version##_encrypt_block_CTR( \
+ AES_Block plaintext, \
+ const AES##version##_RoundKeys* encryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
+ ) { \
+ assert(encryption_keys); \
+ assert(next_init_vector); \
+ \
+ AES_Block ciphertext = aes_xor_blocks( \
+ plaintext, aes##version##_encrypt_block_(init_vector, encryption_keys) \
+ ); \
+ *next_init_vector = aes_inc_block(init_vector); \
+ return ciphertext; \
}
-#define AES_DECRYPT_BLOCK_CTR(prefix) \
- static inline AES_##prefix##_Block __fastcall aes_##prefix##_decrypt_block_CTR( \
- AES_##prefix##_Block ciphertext, \
- const AES_##prefix##_RoundKeys* encryption_keys, \
- AES_##prefix##_Block init_vector, \
- AES_##prefix##_Block* next_init_vector \
- ) { \
- assert(encryption_keys); \
- assert(next_init_vector); \
- \
- return aes_##prefix##_encrypt_block_CTR( \
- ciphertext, encryption_keys, init_vector, next_init_vector \
- ); \
+#define AES_DECRYPT_BLOCK_CTR(version) \
+ static inline AES_Block __fastcall aes##version##_decrypt_block_CTR( \
+ AES_Block ciphertext, \
+ const AES##version##_RoundKeys* encryption_keys, \
+ AES_Block init_vector, \
+ AES_Block* next_init_vector \
+ ) { \
+ assert(encryption_keys); \
+ assert(next_init_vector); \
+ \
+ return aes##version##_encrypt_block_CTR( \
+ ciphertext, encryption_keys, init_vector, next_init_vector \
+ ); \
}
#ifdef __cplusplus
diff --git a/aes/src/aes.c b/aes/src/aes.c
index 95b532d..e2db120 100644
--- a/aes/src/aes.c
+++ b/aes/src/aes.c
@@ -12,8 +12,8 @@
#include <string.h>
AES_StatusCode aes_AES_format_block(
- AES_AES_BlockString* str,
- const AES_AES_Block* block,
+ AES_BlockString* str,
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
assert(str);
@@ -27,7 +27,7 @@ AES_StatusCode aes_AES_format_block(
char* cursor = str->str;
AES_ALIGN(unsigned char, 16) bytes[16];
- aes_store_block128_aligned(bytes, *block);
+ aes_store_block_aligned(bytes, *block);
for (int i = 0; i < 16; ++i, cursor += 2)
sprintf(cursor, "%02x", bytes[i]);
@@ -37,8 +37,8 @@ AES_StatusCode aes_AES_format_block(
}
AES_StatusCode aes_AES_format_block_as_matrix(
- AES_AES_BlockMatrixString* str,
- const AES_AES_Block* block,
+ AES_BlockMatrixString* str,
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
assert(str);
@@ -52,7 +52,7 @@ AES_StatusCode aes_AES_format_block_as_matrix(
char* cursor = str->str;
AES_ALIGN(unsigned char, 16) bytes[4][4];
- aes_store_block128_aligned(bytes, *block);
+ aes_store_block_aligned(bytes, *block);
for (int i = 0; i < 4; ++i, cursor += 3) {
for (int j = 0; j < 3; ++j, cursor += 3)
@@ -64,14 +64,14 @@ AES_StatusCode aes_AES_format_block_as_matrix(
return AES_SUCCESS;
}
-AES_StatusCode aes_AES_print_block(const AES_AES_Block* block, AES_ErrorDetails* err_details) {
+AES_StatusCode aes_AES_print_block(const AES_Block* block, AES_ErrorDetails* err_details) {
assert(block);
if (block == NULL)
return aes_error_null_argument(err_details, "block");
AES_StatusCode ec = AES_SUCCESS;
- AES_AES_BlockString str;
+ AES_BlockString str;
if (aes_is_error(ec = aes_AES_format_block(&str, block, err_details)))
return ec;
@@ -81,7 +81,7 @@ AES_StatusCode aes_AES_print_block(const AES_AES_Block* block, AES_ErrorDetails*
}
AES_StatusCode aes_AES_print_block_as_matrix(
- const AES_AES_Block* block,
+ const AES_Block* block,
AES_ErrorDetails* err_details
) {
assert(block);
@@ -90,7 +90,7 @@ AES_StatusCode aes_AES_print_block_as_matrix(
return aes_error_null_argument(err_details, "block");
AES_StatusCode ec = AES_SUCCESS;
- AES_AES_BlockMatrixString str;
+ AES_BlockMatrixString str;
if (aes_is_error(ec = aes_AES_format_block_as_matrix(&str, block, err_details)))
return ec;
@@ -100,7 +100,7 @@ AES_StatusCode aes_AES_print_block_as_matrix(
}
AES_StatusCode aes_AES_parse_block(
- AES_AES_Block* dest,
+ AES_Block* dest,
const char* src,
AES_ErrorDetails* err_details
) {
@@ -125,13 +125,13 @@ AES_StatusCode aes_AES_parse_block(
cursor += n;
}
- *dest = aes_load_block128_aligned(bytes);
+ *dest = aes_load_block_aligned(bytes);
return AES_SUCCESS;
}
-AES_StatusCode aes_AES128_format_key(
- AES_AES128_KeyString* str,
- const AES_AES128_Key* key,
+AES_StatusCode aes128_format_key(
+ AES128_KeyString* str,
+ const AES128_Key* key,
AES_ErrorDetails* err_details
) {
assert(str);
@@ -145,7 +145,7 @@ AES_StatusCode aes_AES128_format_key(
char* cursor = str->str;
AES_ALIGN(unsigned char, 16) bytes[16];
- aes_store_block128_aligned(bytes, key->key);
+ aes_store_block_aligned(bytes, key->key);
for (int i = 0; i < 16; ++i, cursor += 2)
sprintf(cursor, "%02x", bytes[i]);
@@ -154,9 +154,9 @@ AES_StatusCode aes_AES128_format_key(
return AES_SUCCESS;
}
-AES_StatusCode aes_AES192_format_key(
- AES_AES192_KeyString* str,
- const AES_AES192_Key* key,
+AES_StatusCode aes192_format_key(
+ AES192_KeyString* str,
+ const AES192_Key* key,
AES_ErrorDetails* err_details
) {
assert(str);
@@ -171,7 +171,7 @@ AES_StatusCode aes_AES192_format_key(
{
AES_ALIGN(unsigned char, 16) bytes[16];
- aes_store_block128_aligned(bytes, key->lo);
+ aes_store_block_aligned(bytes, key->lo);
for (int i = 0; i < 16; ++i, cursor += 2)
sprintf(cursor, "%02x", bytes[i]);
@@ -179,7 +179,7 @@ AES_StatusCode aes_AES192_format_key(
{
AES_ALIGN(unsigned char, 16) bytes[16];
- aes_store_block128_aligned(bytes, key->hi);
+ aes_store_block_aligned(bytes, key->hi);
for (int i = 0; i < 8; ++i, cursor += 2)
sprintf(cursor, "%02x", bytes[i]);
@@ -189,9 +189,9 @@ AES_StatusCode aes_AES192_format_key(
return AES_SUCCESS;
}
-AES_StatusCode aes_AES256_format_key(
- AES_AES256_KeyString* str,
- const AES_AES256_Key* key,
+AES_StatusCode aes256_format_key(
+ AES256_KeyString* str,
+ const AES256_Key* key,
AES_ErrorDetails* err_details
) {
assert(str);
@@ -206,7 +206,7 @@ AES_StatusCode aes_AES256_format_key(
{
AES_ALIGN(unsigned char, 16) bytes[16];
- aes_store_block128_aligned(bytes, key->lo);
+ aes_store_block_aligned(bytes, key->lo);
for (int i = 0; i < 16; ++i, cursor += 2)
sprintf(cursor, "%02x", bytes[i]);
@@ -214,7 +214,7 @@ AES_StatusCode aes_AES256_format_key(
{
AES_ALIGN(unsigned char, 16) bytes[16];
- aes_store_block128_aligned(bytes, key->hi);
+ aes_store_block_aligned(bytes, key->hi);
for (int i = 0; i < 16; ++i, cursor += 2)
sprintf(cursor, "%02x", bytes[i]);
@@ -224,55 +224,47 @@ AES_StatusCode aes_AES256_format_key(
return AES_SUCCESS;
}
-AES_StatusCode aes_AES128_print_key(const AES_AES128_Key* key, AES_ErrorDetails* err_details) {
+AES_StatusCode aes128_print_key(const AES128_Key* key, AES_ErrorDetails* err_details) {
return aes_AES_print_block(&key->key, err_details);
}
-AES_StatusCode aes_AES192_print_key(const AES_AES192_Key* key, AES_ErrorDetails* err_details) {
+AES_StatusCode aes192_print_key(const AES192_Key* key, AES_ErrorDetails* err_details) {
assert(key);
if (key == NULL)
return aes_error_null_argument(err_details, "key");
AES_StatusCode ec = AES_SUCCESS;
- AES_AES192_KeyString str;
+ AES192_KeyString str;
- if (aes_is_error(ec = aes_AES192_format_key(&str, key, err_details)))
+ if (aes_is_error(ec = aes192_format_key(&str, key, err_details)))
return ec;
printf("%s\n", str.str);
return ec;
}
-AES_StatusCode aes_AES256_print_key(const AES_AES256_Key* key, AES_ErrorDetails* err_details) {
+AES_StatusCode aes256_print_key(const AES256_Key* key, AES_ErrorDetails* err_details) {
assert(key);
if (key == NULL)
return aes_error_null_argument(err_details, "key");
AES_StatusCode ec = AES_SUCCESS;
- AES_AES256_KeyString str;
+ AES256_KeyString str;
- if (aes_is_error(ec = aes_AES256_format_key(&str, key, err_details)))
+ if (aes_is_error(ec = aes256_format_key(&str, key, err_details)))
return ec;
printf("%s\n", str.str);
return ec;
}
-AES_StatusCode aes_AES128_parse_key(
- AES_AES128_Key* dest,
- const char* src,
- AES_ErrorDetails* err_details
-) {
+AES_StatusCode aes128_parse_key(AES128_Key* dest, const char* src, AES_ErrorDetails* err_details) {
return aes_AES_parse_block(&dest->key, src, err_details);
}
-AES_StatusCode aes_AES192_parse_key(
- AES_AES192_Key* dest,
- const char* src,
- AES_ErrorDetails* err_details
-) {
+AES_StatusCode aes192_parse_key(AES192_Key* dest, const char* src, AES_ErrorDetails* err_details) {
assert(dest);
assert(src);
@@ -295,7 +287,7 @@ AES_StatusCode aes_AES192_parse_key(
cursor += n;
}
- dest->lo = aes_load_block128_aligned(bytes);
+ dest->lo = aes_load_block_aligned(bytes);
}
{
@@ -311,17 +303,13 @@ AES_StatusCode aes_AES192_parse_key(
}
memset(bytes + 8, 0x00, 8);
- dest->hi = aes_load_block128_aligned(bytes);
+ dest->hi = aes_load_block_aligned(bytes);
}
return AES_SUCCESS;
}
-AES_StatusCode aes_AES256_parse_key(
- AES_AES256_Key* dest,
- const char* src,
- AES_ErrorDetails* err_details
-) {
+AES_StatusCode aes256_parse_key(AES256_Key* dest, const char* src, AES_ErrorDetails* err_details) {
assert(dest);
assert(src);
@@ -344,7 +332,7 @@ AES_StatusCode aes_AES256_parse_key(
cursor += n;
}
- dest->lo = aes_load_block128_aligned(bytes);
+ dest->lo = aes_load_block_aligned(bytes);
}
{
@@ -359,7 +347,7 @@ AES_StatusCode aes_AES256_parse_key(
cursor += n;
}
- dest->hi = aes_load_block128_aligned(bytes);
+ dest->hi = aes_load_block_aligned(bytes);
}
return AES_SUCCESS;
diff --git a/aes/src/asm/aes128.asm b/aes/src/asm/aes128.asm
index 80be57c..abf5063 100644
--- a/aes/src/asm/aes128.asm
+++ b/aes/src/asm/aes128.asm
@@ -9,7 +9,7 @@
.code
-@aes_AES128_encrypt_block_@20 proc
+@aes128_encrypt_block_@20 proc
pxor xmm0, [ecx]
aesenc xmm0, [ecx + 10h]
aesenc xmm0, [ecx + 20h]
@@ -22,9 +22,9 @@
aesenc xmm0, [ecx + 90h]
aesenclast xmm0, [ecx + 0A0h]
ret
-@aes_AES128_encrypt_block_@20 endp
+@aes128_encrypt_block_@20 endp
-@aes_AES128_decrypt_block_@20 proc
+@aes128_decrypt_block_@20 proc
pxor xmm0, [ecx]
aesdec xmm0, [ecx + 10h]
aesdec xmm0, [ecx + 20h]
@@ -37,9 +37,9 @@
aesdec xmm0, [ecx + 90h]
aesdeclast xmm0, [ecx + 0A0h]
ret
-@aes_AES128_decrypt_block_@20 endp
+@aes128_decrypt_block_@20 endp
-@aes_AES128_expand_key_@20 proc
+@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]`.
;
@@ -166,9 +166,9 @@ aes128_keygen_assist:
add ecx, 10h ; ecx = &w[i+8]
ret
-@aes_AES128_expand_key_@20 endp
+@aes128_expand_key_@20 endp
-@aes_AES128_derive_decryption_keys_@8 proc
+@aes128_derive_decryption_keys_@8 proc
movdqa xmm5, [ecx]
movdqa xmm4, [ecx + 0A0h]
movdqa [edx], xmm4
@@ -198,6 +198,6 @@ aes128_keygen_assist:
movdqa [edx + 50h], xmm5
ret
-@aes_AES128_derive_decryption_keys_@8 endp
+@aes128_derive_decryption_keys_@8 endp
end
diff --git a/aes/src/asm/aes192.asm b/aes/src/asm/aes192.asm
index 6a41243..5411419 100644
--- a/aes/src/asm/aes192.asm
+++ b/aes/src/asm/aes192.asm
@@ -9,7 +9,7 @@
.code
-@aes_AES192_encrypt_block_@20 proc
+@aes192_encrypt_block_@20 proc
pxor xmm0, [ecx]
aesenc xmm0, [ecx + 10h]
aesenc xmm0, [ecx + 20h]
@@ -24,9 +24,9 @@
aesenc xmm0, [ecx + 0B0h]
aesenclast xmm0, [ecx + 0C0h]
ret
-@aes_AES192_encrypt_block_@20 endp
+@aes192_encrypt_block_@20 endp
-@aes_AES192_decrypt_block_@20 proc
+@aes192_decrypt_block_@20 proc
pxor xmm0, [ecx]
aesdec xmm0, [ecx + 10h]
aesdec xmm0, [ecx + 20h]
@@ -41,9 +41,9 @@
aesdec xmm0, [ecx + 0B0h]
aesdeclast xmm0, [ecx + 0C0h]
ret
-@aes_AES192_decrypt_block_@20 endp
+@aes192_decrypt_block_@20 endp
-@aes_AES192_expand_key_@36 proc
+@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]`.
;
@@ -207,9 +207,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
-@aes_AES192_expand_key_@36 endp
+@aes192_expand_key_@36 endp
-@aes_AES192_derive_decryption_keys_@8 proc
+@aes192_derive_decryption_keys_@8 proc
movdqa xmm5, [ecx]
movdqa xmm4, [ecx + 0C0h]
movdqa [edx], xmm4
@@ -244,6 +244,6 @@ aes192_keygen_assist:
movdqa [edx + 60h], xmm5
ret
-@aes_AES192_derive_decryption_keys_@8 endp
+@aes192_derive_decryption_keys_@8 endp
end
diff --git a/aes/src/asm/aes256.asm b/aes/src/asm/aes256.asm
index 82f5f6f..4c6c07c 100644
--- a/aes/src/asm/aes256.asm
+++ b/aes/src/asm/aes256.asm
@@ -9,7 +9,7 @@
.code
-@aes_AES256_encrypt_block_@20 proc
+@aes256_encrypt_block_@20 proc
pxor xmm0, [ecx]
aesenc xmm0, [ecx + 10h]
aesenc xmm0, [ecx + 20h]
@@ -26,9 +26,9 @@
aesenc xmm0, [ecx + 0D0h]
aesenclast xmm0, [ecx + 0E0h]
ret
-@aes_AES256_encrypt_block_@20 endp
+@aes256_encrypt_block_@20 endp
-@aes_AES256_decrypt_block_@20 proc
+@aes256_decrypt_block_@20 proc
pxor xmm0, [ecx]
aesdec xmm0, [ecx + 10h]
aesdec xmm0, [ecx + 20h]
@@ -45,9 +45,9 @@
aesdec xmm0, [ecx + 0D0h]
aesdeclast xmm0, [ecx + 0E0h]
ret
-@aes_AES256_decrypt_block_@20 endp
+@aes256_decrypt_block_@20 endp
-@aes_AES256_expand_key_@36 proc
+@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]`.
;
@@ -240,9 +240,9 @@ aes256_keygen_assist:
pxor xmm0, xmm1
ret
-@aes_AES256_expand_key_@36 endp
+@aes256_expand_key_@36 endp
-@aes_AES256_derive_decryption_keys_@8 proc
+@aes256_derive_decryption_keys_@8 proc
movdqa xmm5, [ecx]
movdqa xmm4, [ecx + 0E0h]
movdqa [edx], xmm4
@@ -282,6 +282,6 @@ aes256_keygen_assist:
movdqa [edx + 70h], xmm5
ret
-@aes_AES256_derive_decryption_keys_@8 endp
+@aes256_derive_decryption_keys_@8 endp
end
diff --git a/aes/src/box_aes.c b/aes/src/box_aes.c
index 4a91e97..fb858f0 100644
--- a/aes/src/box_aes.c
+++ b/aes/src/box_aes.c
@@ -17,8 +17,8 @@ static AES_StatusCode aes_box_derive_params_aes128(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- aes_AES128_expand_key_(box_key->aes128_key.key, &encryption_keys->aes128_encryption_keys);
- aes_AES128_derive_decryption_keys_(
+ aes128_expand_key_(box_key->aes128_key.key, &encryption_keys->aes128_encryption_keys);
+ aes128_derive_decryption_keys_(
&encryption_keys->aes128_encryption_keys, &decryption_keys->aes128_decryption_keys
);
return AES_SUCCESS;
@@ -31,10 +31,10 @@ static AES_StatusCode aes_box_derive_params_aes192(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- aes_AES192_expand_key_(
+ aes192_expand_key_(
box_key->aes192_key.lo, box_key->aes192_key.hi, &encryption_keys->aes192_encryption_keys
);
- aes_AES192_derive_decryption_keys_(
+ aes192_derive_decryption_keys_(
&encryption_keys->aes192_encryption_keys, &decryption_keys->aes192_decryption_keys
);
return AES_SUCCESS;
@@ -47,10 +47,10 @@ static AES_StatusCode aes_box_derive_params_aes256(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- aes_AES256_expand_key_(
+ aes256_expand_key_(
box_key->aes256_key.lo, box_key->aes256_key.hi, &encryption_keys->aes256_encryption_keys
);
- aes_AES256_derive_decryption_keys_(
+ aes256_derive_decryption_keys_(
&encryption_keys->aes256_encryption_keys, &decryption_keys->aes256_decryption_keys
);
return AES_SUCCESS;
@@ -75,7 +75,7 @@ static AES_StatusCode aes_box_parse_key_aes128(
if (dest == NULL)
return aes_error_null_argument(err_details, "dest");
- return aes_AES128_parse_key(&dest->aes128_key, src, err_details);
+ return aes128_parse_key(&dest->aes128_key, src, err_details);
}
static AES_StatusCode aes_box_parse_key_aes192(
@@ -86,7 +86,7 @@ static AES_StatusCode aes_box_parse_key_aes192(
if (dest == NULL)
return aes_error_null_argument(err_details, "dest");
- return aes_AES192_parse_key(&dest->aes192_key, src, err_details);
+ return aes192_parse_key(&dest->aes192_key, src, err_details);
}
static AES_StatusCode aes_box_parse_key_aes256(
@@ -97,7 +97,7 @@ static AES_StatusCode aes_box_parse_key_aes256(
if (dest == NULL)
return aes_error_null_argument(err_details, "dest");
- return aes_AES256_parse_key(&dest->aes256_key, src, err_details);
+ return aes256_parse_key(&dest->aes256_key, src, err_details);
}
static AES_StatusCode aes_box_format_block_aes(
@@ -110,7 +110,7 @@ static AES_StatusCode aes_box_format_block_aes(
if (src == NULL)
return aes_error_null_argument(err_details, "src");
- return aes_AES128_format_block(&dest->aes, &src->aes_block, err_details);
+ return aes128_format_block(&dest->aes, &src->aes_block, err_details);
}
static AES_StatusCode aes_box_format_key_aes128(
@@ -123,7 +123,7 @@ static AES_StatusCode aes_box_format_key_aes128(
if (src == NULL)
return aes_error_null_argument(err_details, "src");
- return aes_AES128_format_key(&dest->aes128, &src->aes128_key, err_details);
+ return aes128_format_key(&dest->aes128, &src->aes128_key, err_details);
}
static AES_StatusCode aes_box_format_key_aes192(
@@ -136,7 +136,7 @@ static AES_StatusCode aes_box_format_key_aes192(
if (src == NULL)
return aes_error_null_argument(err_details, "src");
- return aes_AES192_format_key(&dest->aes192, &src->aes192_key, err_details);
+ return aes192_format_key(&dest->aes192, &src->aes192_key, err_details);
}
static AES_StatusCode aes_box_format_key_aes256(
@@ -149,7 +149,7 @@ static AES_StatusCode aes_box_format_key_aes256(
if (src == NULL)
return aes_error_null_argument(err_details, "src");
- return aes_AES256_format_key(&dest->aes256, &src->aes256_key, err_details);
+ return aes256_format_key(&dest->aes256, &src->aes256_key, err_details);
}
static AES_StatusCode aes_box_xor_block_aes(
@@ -158,13 +158,13 @@ static AES_StatusCode aes_box_xor_block_aes(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- dest->aes_block = aes_AES_xor_blocks(dest->aes_block, src->aes_block);
+ dest->aes_block = aes_xor_blocks(dest->aes_block, src->aes_block);
return AES_SUCCESS;
}
static AES_StatusCode aes_box_inc_block_aes(AES_BoxBlock* ctr, AES_ErrorDetails* err_details) {
AES_UNUSED_PARAMETER(err_details);
- ctr->aes_block = aes_AES_inc_block(ctr->aes_block);
+ ctr->aes_block = aes_inc_block(ctr->aes_block);
return AES_SUCCESS;
}
@@ -183,7 +183,7 @@ static AES_StatusCode aes_box_store_block_aes(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- aes_store_block128(dest, src->aes_block);
+ aes_store_block(dest, src->aes_block);
return AES_SUCCESS;
}
@@ -193,7 +193,7 @@ static AES_StatusCode aes_box_load_block_aes(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- dest->aes_block = aes_load_block128(src);
+ dest->aes_block = aes_load_block(src);
return AES_SUCCESS;
}
@@ -204,8 +204,7 @@ static AES_StatusCode aes_box_encrypt_block_aes128(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- output->aes_block =
- aes_AES128_encrypt_block_(input->aes_block, &params->aes128_encryption_keys);
+ output->aes_block = aes128_encrypt_block_(input->aes_block, &params->aes128_encryption_keys);
return AES_SUCCESS;
}
@@ -216,8 +215,7 @@ static AES_StatusCode aes_box_decrypt_block_aes128(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- output->aes_block =
- aes_AES128_decrypt_block_(input->aes_block, &params->aes128_decryption_keys);
+ output->aes_block = aes128_decrypt_block_(input->aes_block, &params->aes128_decryption_keys);
return AES_SUCCESS;
}
@@ -228,8 +226,7 @@ static AES_StatusCode aes_box_encrypt_block_aes192(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- output->aes_block =
- aes_AES192_encrypt_block_(input->aes_block, &params->aes192_encryption_keys);
+ output->aes_block = aes192_encrypt_block_(input->aes_block, &params->aes192_encryption_keys);
return AES_SUCCESS;
}
@@ -240,8 +237,7 @@ static AES_StatusCode aes_box_decrypt_block_aes192(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- output->aes_block =
- aes_AES192_decrypt_block_(input->aes_block, &params->aes192_decryption_keys);
+ output->aes_block = aes192_decrypt_block_(input->aes_block, &params->aes192_decryption_keys);
return AES_SUCCESS;
}
@@ -252,8 +248,7 @@ static AES_StatusCode aes_box_encrypt_block_aes256(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- output->aes_block =
- aes_AES256_encrypt_block_(input->aes_block, &params->aes256_encryption_keys);
+ output->aes_block = aes256_encrypt_block_(input->aes_block, &params->aes256_encryption_keys);
return AES_SUCCESS;
}
@@ -264,8 +259,7 @@ static AES_StatusCode aes_box_decrypt_block_aes256(
AES_ErrorDetails* err_details
) {
AES_UNUSED_PARAMETER(err_details);
- output->aes_block =
- aes_AES256_decrypt_block_(input->aes_block, &params->aes256_decryption_keys);
+ output->aes_block = aes256_decrypt_block_(input->aes_block, &params->aes256_decryption_keys);
return AES_SUCCESS;
}
diff --git a/aes/src/c/aes128.c b/aes/src/c/aes128.c
index d7b7243..cf78722 100644
--- a/aes/src/c/aes128.c
+++ b/aes/src/c/aes128.c
@@ -10,9 +10,9 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AES_AES_Block __fastcall aes_AES128_encrypt_block_(
- AES_AES_Block plaintext,
- const AES_AES128_RoundKeys* encryption_keys
+AES_Block __fastcall aes128_encrypt_block_(
+ AES_Block plaintext,
+ const AES128_RoundKeys* encryption_keys
) {
plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
@@ -27,9 +27,9 @@ AES_AES_Block __fastcall aes_AES128_encrypt_block_(
return _mm_aesenclast_si128(plaintext, encryption_keys->keys[10]);
}
-AES_AES_Block __fastcall aes_AES128_decrypt_block_(
- AES_AES_Block ciphertext,
- const AES_AES128_RoundKeys* decryption_keys
+AES_Block __fastcall aes128_decrypt_block_(
+ AES_Block ciphertext,
+ const AES128_RoundKeys* decryption_keys
) {
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
@@ -44,11 +44,8 @@ AES_AES_Block __fastcall aes_AES128_decrypt_block_(
return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[10]);
}
-static AES_AES_Block __fastcall aes_aes128_expand_key_assist(
- AES_AES_Block prev,
- AES_AES_Block hwgen
-) {
- AES_AES_Block tmp = prev;
+static AES_Block __fastcall aes_aes128_expand_key_assist(AES_Block prev, AES_Block hwgen) {
+ AES_Block tmp = prev;
tmp = _mm_slli_si128(tmp, 4);
prev = _mm_xor_si128(prev, tmp);
@@ -63,8 +60,8 @@ static AES_AES_Block __fastcall aes_aes128_expand_key_assist(
return prev;
}
-void __fastcall aes_AES128_expand_key_(AES_AES_Block key, AES_AES128_RoundKeys* encryption_keys) {
- AES_Block128 prev = encryption_keys->keys[0] = key;
+void __fastcall aes128_expand_key_(AES_Block key, AES128_RoundKeys* encryption_keys) {
+ AES_Block 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] =
@@ -87,9 +84,9 @@ void __fastcall aes_AES128_expand_key_(AES_AES_Block key, AES_AES128_RoundKeys*
aes_aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36));
}
-void __fastcall aes_AES128_derive_decryption_keys_(
- const AES_AES128_RoundKeys* encryption_keys,
- AES_AES128_RoundKeys* decryption_keys
+void __fastcall aes128_derive_decryption_keys_(
+ const AES128_RoundKeys* encryption_keys,
+ 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/aes/src/c/aes192.c b/aes/src/c/aes192.c
index 901b548..d257df7 100644
--- a/aes/src/c/aes192.c
+++ b/aes/src/c/aes192.c
@@ -10,9 +10,9 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AES_AES_Block __fastcall aes_AES192_encrypt_block_(
- AES_AES_Block plaintext,
- const AES_AES192_RoundKeys* encryption_keys
+AES_Block __fastcall aes192_encrypt_block_(
+ AES_Block plaintext,
+ const AES192_RoundKeys* encryption_keys
) {
plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
@@ -29,9 +29,9 @@ AES_AES_Block __fastcall aes_AES192_encrypt_block_(
return _mm_aesenclast_si128(plaintext, encryption_keys->keys[12]);
}
-AES_AES_Block __fastcall aes_AES192_decrypt_block_(
- AES_AES_Block ciphertext,
- const AES_AES192_RoundKeys* decryption_keys
+AES_Block __fastcall aes192_decrypt_block_(
+ AES_Block ciphertext,
+ const AES192_RoundKeys* decryption_keys
) {
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
@@ -49,11 +49,11 @@ AES_AES_Block __fastcall aes_AES192_decrypt_block_(
}
static void __fastcall aes_aes192_expand_key_assist(
- AES_AES_Block* prev_lo,
- AES_AES_Block* prev_hi,
- AES_AES_Block hwgen
+ AES_Block* prev_lo,
+ AES_Block* prev_hi,
+ AES_Block hwgen
) {
- AES_AES_Block tmp = *prev_lo;
+ AES_Block tmp = *prev_lo;
tmp = _mm_slli_si128(tmp, 4);
*prev_lo = _mm_xor_si128(*prev_lo, tmp);
@@ -73,10 +73,10 @@ static void __fastcall aes_aes192_expand_key_assist(
*prev_hi = _mm_xor_si128(*prev_hi, tmp);
}
-void __fastcall aes_AES192_expand_key_(
- AES_AES_Block key_lo,
- AES_AES_Block key_hi,
- AES_AES192_RoundKeys* encryption_keys
+void __fastcall aes192_expand_key_(
+ AES_Block key_lo,
+ AES_Block key_hi,
+ AES192_RoundKeys* encryption_keys
) {
encryption_keys->keys[0] = key_lo;
encryption_keys->keys[1] = key_hi;
@@ -125,9 +125,9 @@ void __fastcall aes_AES192_expand_key_(
encryption_keys->keys[12] = key_lo;
}
-void __fastcall aes_AES192_derive_decryption_keys_(
- const AES_AES192_RoundKeys* encryption_keys,
- AES_AES192_RoundKeys* decryption_keys
+void __fastcall aes192_derive_decryption_keys_(
+ const AES192_RoundKeys* encryption_keys,
+ 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/aes/src/c/aes256.c b/aes/src/c/aes256.c
index 5bce5b5..f1b5aef 100644
--- a/aes/src/c/aes256.c
+++ b/aes/src/c/aes256.c
@@ -10,9 +10,9 @@
#include <emmintrin.h>
#include <wmmintrin.h>
-AES_AES_Block __fastcall aes_AES256_encrypt_block_(
- AES_AES_Block plaintext,
- const AES_AES256_RoundKeys* encryption_keys
+AES_Block __fastcall aes256_encrypt_block_(
+ AES_Block plaintext,
+ const AES256_RoundKeys* encryption_keys
) {
plaintext = _mm_xor_si128(plaintext, encryption_keys->keys[0]);
plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[1]);
@@ -31,9 +31,9 @@ AES_AES_Block __fastcall aes_AES256_encrypt_block_(
return _mm_aesenclast_si128(plaintext, encryption_keys->keys[14]);
}
-AES_AES_Block __fastcall aes_AES256_decrypt_block_(
- AES_AES_Block ciphertext,
- const AES_AES256_RoundKeys* decryption_keys
+AES_Block __fastcall aes256_decrypt_block_(
+ AES_Block ciphertext,
+ const AES256_RoundKeys* decryption_keys
) {
ciphertext = _mm_xor_si128(ciphertext, decryption_keys->keys[0]);
ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[1]);
@@ -52,12 +52,12 @@ AES_AES_Block __fastcall aes_AES256_decrypt_block_(
return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[14]);
}
-static AES_AES_Block __fastcall aes_aes256_expand_key_assist(
- AES_AES_Block* prev_lo,
- AES_AES_Block* prev_hi,
- AES_AES_Block hwgen
+static AES_Block __fastcall aes_aes256_expand_key_assist(
+ AES_Block* prev_lo,
+ AES_Block* prev_hi,
+ AES_Block hwgen
) {
- AES_AES_Block tmp = *prev_lo;
+ AES_Block tmp = *prev_lo;
tmp = _mm_slli_si128(tmp, 4);
*prev_lo = _mm_xor_si128(*prev_lo, tmp);
@@ -75,13 +75,13 @@ static AES_AES_Block __fastcall aes_aes256_expand_key_assist(
return *prev_hi;
}
-void __fastcall aes_AES256_expand_key_(
- AES_AES_Block key_lo,
- AES_AES_Block key_hi,
- AES_AES256_RoundKeys* encryption_keys
+void __fastcall aes256_expand_key_(
+ AES_Block key_lo,
+ AES_Block key_hi,
+ AES256_RoundKeys* encryption_keys
) {
- AES_AES_Block prev_lo, prev_hi;
- AES_AES_Block hwgen;
+ AES_Block prev_lo, prev_hi;
+ AES_Block hwgen;
prev_lo = encryption_keys->keys[0] = key_lo;
prev_hi = encryption_keys->keys[1] = key_hi;
@@ -139,9 +139,9 @@ void __fastcall aes_AES256_expand_key_(
encryption_keys->keys[14] = aes_aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen);
}
-void __fastcall aes_AES256_derive_decryption_keys_(
- const AES_AES256_RoundKeys* encryption_keys,
- AES_AES256_RoundKeys* decryption_keys
+void __fastcall aes256_derive_decryption_keys_(
+ const AES256_RoundKeys* encryption_keys,
+ AES256_RoundKeys* decryption_keys
) {
decryption_keys->keys[0] = encryption_keys->keys[14];
decryption_keys->keys[1] = _mm_aesimc_si128(encryption_keys->keys[13]);
diff --git a/aesxx/include/aesxx/aes.hpp b/aesxx/include/aesxx/aes.hpp
index 1b5aefa..6271b24 100644
--- a/aesxx/include/aesxx/aes.hpp
+++ b/aesxx/include/aesxx/aes.hpp
@@ -19,9 +19,9 @@
namespace aes {
namespace aes128 {
-typedef AES_AES128_Block Block;
-typedef AES_AES128_RoundKeys RoundKeys;
-typedef AES_AES128_Key Key;
+typedef AES_Block Block;
+typedef AES128_RoundKeys RoundKeys;
+typedef AES128_Key Key;
} // namespace aes128
@@ -34,38 +34,38 @@ struct Types<AES_AES128> {
template <>
inline void from_string<AES_AES128>(aes128::Block& dest, std::string_view src) {
- aes_AES128_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
+ aes128_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
}
template <>
inline std::string to_string<AES_AES128>(const aes128::Block& src) {
- AES_AES128_BlockString str;
- aes_AES128_format_block(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES128_BlockString str;
+ aes128_format_block(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline std::string to_matrix_string<AES_AES128>(const aes128::Block& src) {
- AES_AES128_BlockMatrixString str;
- aes_AES128_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES128_BlockMatrixString str;
+ aes128_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline void from_string<AES_AES128>(aes128::Key& dest, std::string_view src) {
- aes_AES128_parse_key(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
+ aes128_parse_key(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
}
template <>
inline std::string to_string<AES_AES128>(const aes128::Key& src) {
- AES_AES128_KeyString str;
- aes_AES128_format_key(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES128_KeyString str;
+ aes128_format_key(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline void expand_key<AES_AES128>(const aes128::Key& key, aes128::RoundKeys& encryption_keys) {
- aes_AES128_expand_key(&key, &encryption_keys);
+ aes128_expand_key(&key, &encryption_keys);
}
template <>
@@ -73,25 +73,25 @@ inline void derive_decryption_keys<AES_AES128>(
const aes128::RoundKeys& encryption_keys,
aes128::RoundKeys& decryption_keys
) {
- aes_AES128_derive_decryption_keys(&encryption_keys, &decryption_keys);
+ aes128_derive_decryption_keys(&encryption_keys, &decryption_keys);
}
-AESXX_ENCRYPT_BLOCK_ECB(AES128);
-AESXX_DECRYPT_BLOCK_ECB(AES128);
-AESXX_ENCRYPT_BLOCK_CBC(AES128);
-AESXX_DECRYPT_BLOCK_CBC(AES128);
-AESXX_ENCRYPT_BLOCK_CFB(AES128);
-AESXX_DECRYPT_BLOCK_CFB(AES128);
-AESXX_ENCRYPT_BLOCK_OFB(AES128);
-AESXX_DECRYPT_BLOCK_OFB(AES128);
-AESXX_ENCRYPT_BLOCK_CTR(AES128);
-AESXX_DECRYPT_BLOCK_CTR(AES128);
+AESXX_ENCRYPT_BLOCK_ECB(128);
+AESXX_DECRYPT_BLOCK_ECB(128);
+AESXX_ENCRYPT_BLOCK_CBC(128);
+AESXX_DECRYPT_BLOCK_CBC(128);
+AESXX_ENCRYPT_BLOCK_CFB(128);
+AESXX_DECRYPT_BLOCK_CFB(128);
+AESXX_ENCRYPT_BLOCK_OFB(128);
+AESXX_DECRYPT_BLOCK_OFB(128);
+AESXX_ENCRYPT_BLOCK_CTR(128);
+AESXX_DECRYPT_BLOCK_CTR(128);
namespace aes192 {
-typedef AES_AES192_Block Block;
-typedef AES_AES192_RoundKeys RoundKeys;
-typedef AES_AES192_Key Key;
+typedef AES_Block Block;
+typedef AES192_RoundKeys RoundKeys;
+typedef AES192_Key Key;
} // namespace aes192
@@ -104,38 +104,38 @@ struct Types<AES_AES192> {
template <>
inline void from_string<AES_AES192>(aes192::Block& dest, std::string_view src) {
- aes_AES192_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
+ aes192_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
}
template <>
inline std::string to_string<AES_AES192>(const aes192::Block& src) {
- AES_AES192_BlockString str;
- aes_AES192_format_block(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES192_BlockString str;
+ aes192_format_block(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline std::string to_matrix_string<AES_AES192>(const aes192::Block& src) {
- AES_AES192_BlockMatrixString str;
- aes_AES192_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES192_BlockMatrixString str;
+ aes192_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline void from_string<AES_AES192>(aes192::Key& dest, std::string_view src) {
- aes_AES192_parse_key(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
+ aes192_parse_key(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
}
template <>
inline std::string to_string<AES_AES192>(const aes192::Key& src) {
- AES_AES192_KeyString str;
- aes_AES192_format_key(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES192_KeyString str;
+ aes192_format_key(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline void expand_key<AES_AES192>(const aes192::Key& key, aes192::RoundKeys& encryption_keys) {
- aes_AES192_expand_key(&key, &encryption_keys);
+ aes192_expand_key(&key, &encryption_keys);
}
template <>
@@ -143,25 +143,25 @@ inline void derive_decryption_keys<AES_AES192>(
const aes192::RoundKeys& encryption_keys,
aes192::RoundKeys& decryption_keys
) {
- aes_AES192_derive_decryption_keys(&encryption_keys, &decryption_keys);
+ aes192_derive_decryption_keys(&encryption_keys, &decryption_keys);
}
-AESXX_ENCRYPT_BLOCK_ECB(AES192);
-AESXX_DECRYPT_BLOCK_ECB(AES192);
-AESXX_ENCRYPT_BLOCK_CBC(AES192);
-AESXX_DECRYPT_BLOCK_CBC(AES192);
-AESXX_ENCRYPT_BLOCK_CFB(AES192);
-AESXX_DECRYPT_BLOCK_CFB(AES192);
-AESXX_ENCRYPT_BLOCK_OFB(AES192);
-AESXX_DECRYPT_BLOCK_OFB(AES192);
-AESXX_ENCRYPT_BLOCK_CTR(AES192);
-AESXX_DECRYPT_BLOCK_CTR(AES192);
+AESXX_ENCRYPT_BLOCK_ECB(192);
+AESXX_DECRYPT_BLOCK_ECB(192);
+AESXX_ENCRYPT_BLOCK_CBC(192);
+AESXX_DECRYPT_BLOCK_CBC(192);
+AESXX_ENCRYPT_BLOCK_CFB(192);
+AESXX_DECRYPT_BLOCK_CFB(192);
+AESXX_ENCRYPT_BLOCK_OFB(192);
+AESXX_DECRYPT_BLOCK_OFB(192);
+AESXX_ENCRYPT_BLOCK_CTR(192);
+AESXX_DECRYPT_BLOCK_CTR(192);
namespace aes256 {
-typedef AES_AES256_Block Block;
-typedef AES_AES256_RoundKeys RoundKeys;
-typedef AES_AES256_Key Key;
+typedef AES_Block Block;
+typedef AES256_RoundKeys RoundKeys;
+typedef AES256_Key Key;
} // namespace aes256
@@ -174,38 +174,38 @@ struct Types<AES_AES256> {
template <>
inline void from_string<AES_AES256>(aes256::Block& dest, std::string_view src) {
- aes_AES256_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
+ aes256_parse_block(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
}
template <>
inline std::string to_string<AES_AES256>(const aes256::Block& src) {
- AES_AES256_BlockString str;
- aes_AES256_format_block(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES256_BlockString str;
+ aes256_format_block(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline std::string to_matrix_string<AES_AES256>(const aes256::Block& src) {
- AES_AES256_BlockMatrixString str;
- aes_AES256_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES256_BlockMatrixString str;
+ aes256_format_block_as_matrix(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline void from_string<AES_AES256>(aes256::Key& dest, std::string_view src) {
- aes_AES256_parse_key(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
+ aes256_parse_key(&dest, src.data(), ErrorDetailsThrowsInDestructor{});
}
template <>
inline std::string to_string<AES_AES256>(const aes256::Key& src) {
- AES_AES256_KeyString str;
- aes_AES256_format_key(&str, &src, ErrorDetailsThrowsInDestructor{});
+ AES256_KeyString str;
+ aes256_format_key(&str, &src, ErrorDetailsThrowsInDestructor{});
return {str.str};
}
template <>
inline void expand_key<AES_AES256>(const aes256::Key& key, aes256::RoundKeys& encryption_keys) {
- aes_AES256_expand_key(&key, &encryption_keys);
+ aes256_expand_key(&key, &encryption_keys);
}
template <>
@@ -213,18 +213,18 @@ inline void derive_decryption_keys<AES_AES256>(
const aes256::RoundKeys& encryption_keys,
aes256::RoundKeys& decryption_keys
) {
- aes_AES256_derive_decryption_keys(&encryption_keys, &decryption_keys);
+ aes256_derive_decryption_keys(&encryption_keys, &decryption_keys);
}
-AESXX_ENCRYPT_BLOCK_ECB(AES256);
-AESXX_DECRYPT_BLOCK_ECB(AES256);
-AESXX_ENCRYPT_BLOCK_CBC(AES256);
-AESXX_DECRYPT_BLOCK_CBC(AES256);
-AESXX_ENCRYPT_BLOCK_CFB(AES256);
-AESXX_DECRYPT_BLOCK_CFB(AES256);
-AESXX_ENCRYPT_BLOCK_OFB(AES256);
-AESXX_DECRYPT_BLOCK_OFB(AES256);
-AESXX_ENCRYPT_BLOCK_CTR(AES256);
-AESXX_DECRYPT_BLOCK_CTR(AES256);
+AESXX_ENCRYPT_BLOCK_ECB(256);
+AESXX_DECRYPT_BLOCK_ECB(256);
+AESXX_ENCRYPT_BLOCK_CBC(256);
+AESXX_DECRYPT_BLOCK_CBC(256);
+AESXX_ENCRYPT_BLOCK_CFB(256);
+AESXX_DECRYPT_BLOCK_CFB(256);
+AESXX_ENCRYPT_BLOCK_OFB(256);
+AESXX_DECRYPT_BLOCK_OFB(256);
+AESXX_ENCRYPT_BLOCK_CTR(256);
+AESXX_DECRYPT_BLOCK_CTR(256);
} // namespace aes
diff --git a/aesxx/include/aesxx/data.hpp b/aesxx/include/aesxx/data.hpp
index e381995..a93a781 100644
--- a/aesxx/include/aesxx/data.hpp
+++ b/aesxx/include/aesxx/data.hpp
@@ -11,38 +11,38 @@
namespace aes {
-typedef AES_Block128 Block128;
+typedef AES_Block Block128;
inline void make_block(Block128& dest, int hi3, int hi2, int lo1, int lo0) {
- dest = aes_make_block128(hi3, hi2, lo1, lo0);
+ dest = aes_make_block(hi3, hi2, lo1, lo0);
}
inline void load_block(Block128& dest, const void* src) {
- dest = aes_load_block128(src);
+ dest = aes_load_block(src);
}
inline void load_block_aligned(Block128& dest, const void* src) {
- dest = aes_load_block128_aligned(src);
+ dest = aes_load_block_aligned(src);
}
inline void store_block(void* dest, Block128& src) {
- aes_store_block128(dest, src);
+ aes_store_block(dest, src);
}
inline void store_block_aligned(void* dest, Block128& src) {
- aes_store_block128_aligned(dest, src);
+ aes_store_block_aligned(dest, src);
}
inline Block128 xor_blocks(Block128& a, Block128& b) {
- return aes_xor_block128(a, b);
+ return aes_xor_blocks(a, b);
}
inline Block128 reverse_byte_order(Block128& block) {
- return aes_reverse_byte_order_block128(block);
+ return aes_reverse_byte_order_block(block);
}
inline Block128 inc_block(Block128& block) {
- return aes_inc_block128(block);
+ return aes_inc_block(block);
}
} // namespace aes
diff --git a/aesxx/include/aesxx/mode.hpp b/aesxx/include/aesxx/mode.hpp
index 9fbcaae..d6f282a 100644
--- a/aesxx/include/aesxx/mode.hpp
+++ b/aesxx/include/aesxx/mode.hpp
@@ -21,114 +21,114 @@ inline constexpr bool mode_uses_encryption_keys_only(Mode mode) {
return mode != AES_ECB && mode != AES_CBC;
}
-#define AESXX_ENCRYPT_BLOCK_ECB(prefix) \
+#define AESXX_ENCRYPT_BLOCK_ECB(version) \
template <> \
- inline void encrypt_block<AES_##prefix, AES_ECB>( \
- const typename Types<AES_##prefix>::Block& plaintext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block&, \
- typename Types<AES_##prefix>::Block& ciphertext \
+ inline void encrypt_block<AES_AES##version, AES_ECB>( \
+ const typename Types<AES_AES##version>::Block& plaintext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block&, \
+ typename Types<AES_AES##version>::Block& ciphertext \
) { \
- ciphertext = aes_##prefix##_encrypt_block_ECB(plaintext, &encryption_keys); \
+ ciphertext = aes##version##_encrypt_block_ECB(plaintext, &encryption_keys); \
}
-#define AESXX_DECRYPT_BLOCK_ECB(prefix) \
+#define AESXX_DECRYPT_BLOCK_ECB(version) \
template <> \
- inline void decrypt_block<AES_##prefix, AES_ECB>( \
- const typename Types<AES_##prefix>::Block& ciphertext, \
- const typename Types<AES_##prefix>::RoundKeys& decryption_keys, \
- typename Types<AES_##prefix>::Block&, \
- typename Types<AES_##prefix>::Block& plaintext \
+ inline void decrypt_block<AES_AES##version, AES_ECB>( \
+ const typename Types<AES_AES##version>::Block& ciphertext, \
+ const typename Types<AES_AES##version>::RoundKeys& decryption_keys, \
+ typename Types<AES_AES##version>::Block&, \
+ typename Types<AES_AES##version>::Block& plaintext \
) { \
- plaintext = aes_##prefix##_decrypt_block_ECB(ciphertext, &decryption_keys); \
+ plaintext = aes##version##_decrypt_block_ECB(ciphertext, &decryption_keys); \
}
-#define AESXX_ENCRYPT_BLOCK_CBC(prefix) \
+#define AESXX_ENCRYPT_BLOCK_CBC(version) \
template <> \
- inline void encrypt_block<AES_##prefix, AES_CBC>( \
- const typename Types<AES_##prefix>::Block& plaintext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& ciphertext \
+ inline void encrypt_block<AES_AES##version, AES_CBC>( \
+ const typename Types<AES_AES##version>::Block& plaintext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& ciphertext \
) { \
- ciphertext = aes_##prefix##_encrypt_block_CBC(plaintext, &encryption_keys, iv, &iv); \
+ ciphertext = aes##version##_encrypt_block_CBC(plaintext, &encryption_keys, iv, &iv); \
}
-#define AESXX_DECRYPT_BLOCK_CBC(prefix) \
+#define AESXX_DECRYPT_BLOCK_CBC(version) \
template <> \
- inline void decrypt_block<AES_##prefix, AES_CBC>( \
- const typename Types<AES_##prefix>::Block& ciphertext, \
- const typename Types<AES_##prefix>::RoundKeys& decryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& plaintext \
+ inline void decrypt_block<AES_AES##version, AES_CBC>( \
+ const typename Types<AES_AES##version>::Block& ciphertext, \
+ const typename Types<AES_AES##version>::RoundKeys& decryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& plaintext \
) { \
- plaintext = aes_##prefix##_decrypt_block_CBC(ciphertext, &decryption_keys, iv, &iv); \
+ plaintext = aes##version##_decrypt_block_CBC(ciphertext, &decryption_keys, iv, &iv); \
}
-#define AESXX_ENCRYPT_BLOCK_CFB(prefix) \
+#define AESXX_ENCRYPT_BLOCK_CFB(version) \
template <> \
- inline void encrypt_block<AES_##prefix, AES_CFB>( \
- const typename Types<AES_##prefix>::Block& plaintext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& ciphertext \
+ inline void encrypt_block<AES_AES##version, AES_CFB>( \
+ const typename Types<AES_AES##version>::Block& plaintext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& ciphertext \
) { \
- ciphertext = aes_##prefix##_encrypt_block_CFB(plaintext, &encryption_keys, iv, &iv); \
+ ciphertext = aes##version##_encrypt_block_CFB(plaintext, &encryption_keys, iv, &iv); \
}
-#define AESXX_DECRYPT_BLOCK_CFB(prefix) \
+#define AESXX_DECRYPT_BLOCK_CFB(version) \
template <> \
- inline void decrypt_block<AES_##prefix, AES_CFB>( \
- const typename Types<AES_##prefix>::Block& ciphertext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& plaintext \
+ inline void decrypt_block<AES_AES##version, AES_CFB>( \
+ const typename Types<AES_AES##version>::Block& ciphertext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& plaintext \
) { \
- plaintext = aes_##prefix##_decrypt_block_CFB(ciphertext, &encryption_keys, iv, &iv); \
+ plaintext = aes##version##_decrypt_block_CFB(ciphertext, &encryption_keys, iv, &iv); \
}
-#define AESXX_ENCRYPT_BLOCK_OFB(prefix) \
+#define AESXX_ENCRYPT_BLOCK_OFB(version) \
template <> \
- inline void encrypt_block<AES_##prefix, AES_OFB>( \
- const typename Types<AES_##prefix>::Block& plaintext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& ciphertext \
+ inline void encrypt_block<AES_AES##version, AES_OFB>( \
+ const typename Types<AES_AES##version>::Block& plaintext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& ciphertext \
) { \
- ciphertext = aes_##prefix##_encrypt_block_OFB(plaintext, &encryption_keys, iv, &iv); \
+ ciphertext = aes##version##_encrypt_block_OFB(plaintext, &encryption_keys, iv, &iv); \
}
-#define AESXX_DECRYPT_BLOCK_OFB(prefix) \
+#define AESXX_DECRYPT_BLOCK_OFB(version) \
template <> \
- inline void decrypt_block<AES_##prefix, AES_OFB>( \
- const typename Types<AES_##prefix>::Block& ciphertext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& plaintext \
+ inline void decrypt_block<AES_AES##version, AES_OFB>( \
+ const typename Types<AES_AES##version>::Block& ciphertext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& plaintext \
) { \
- plaintext = aes_##prefix##_decrypt_block_OFB(ciphertext, &encryption_keys, iv, &iv); \
+ plaintext = aes##version##_decrypt_block_OFB(ciphertext, &encryption_keys, iv, &iv); \
}
-#define AESXX_ENCRYPT_BLOCK_CTR(prefix) \
+#define AESXX_ENCRYPT_BLOCK_CTR(version) \
template <> \
- inline void encrypt_block<AES_##prefix, AES_CTR>( \
- const typename Types<AES_##prefix>::Block& plaintext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& ciphertext \
+ inline void encrypt_block<AES_AES##version, AES_CTR>( \
+ const typename Types<AES_AES##version>::Block& plaintext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& ciphertext \
) { \
- ciphertext = aes_##prefix##_encrypt_block_CTR(plaintext, &encryption_keys, iv, &iv); \
+ ciphertext = aes##version##_encrypt_block_CTR(plaintext, &encryption_keys, iv, &iv); \
}
-#define AESXX_DECRYPT_BLOCK_CTR(prefix) \
+#define AESXX_DECRYPT_BLOCK_CTR(version) \
template <> \
- inline void decrypt_block<AES_##prefix, AES_CTR>( \
- const typename Types<AES_##prefix>::Block& ciphertext, \
- const typename Types<AES_##prefix>::RoundKeys& encryption_keys, \
- typename Types<AES_##prefix>::Block& iv, \
- typename Types<AES_##prefix>::Block& plaintext \
+ inline void decrypt_block<AES_AES##version, AES_CTR>( \
+ const typename Types<AES_AES##version>::Block& ciphertext, \
+ const typename Types<AES_AES##version>::RoundKeys& encryption_keys, \
+ typename Types<AES_AES##version>::Block& iv, \
+ typename Types<AES_AES##version>::Block& plaintext \
) { \
- plaintext = aes_##prefix##_decrypt_block_CTR(ciphertext, &encryption_keys, iv, &iv); \
+ plaintext = aes##version##_decrypt_block_CTR(ciphertext, &encryption_keys, iv, &iv); \
}
} // namespace aes