diff options
| author | Egor Tensin <egor@tensin.name> | 2026-07-20 19:51:27 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-07-20 19:51:27 +0200 |
| commit | 98ca7859140a681d8745a595e3c49bf2987a4d79 (patch) | |
| tree | 725540ad0b90c150abf79edf8048e97eba463a89 | |
| parent | aesxx: use if constexpr for get_number_of_rounds (diff) | |
| download | aes-tools-98ca7859140a681d8745a595e3c49bf2987a4d79.tar.gz aes-tools-98ca7859140a681d8745a595e3c49bf2987a4d79.zip | |
get rid of outdated __inline
| -rw-r--r-- | aes/include/aes/aes.h | 72 | ||||
| -rw-r--r-- | aes/include/aes/data.h | 16 | ||||
| -rw-r--r-- | aes/include/aes/error.h | 4 | ||||
| -rw-r--r-- | aes/include/aes/mode.h | 152 |
4 files changed, 122 insertions, 122 deletions
diff --git a/aes/include/aes/aes.h b/aes/include/aes/aes.h index 9203841..956496d 100644 --- a/aes/include/aes/aes.h +++ b/aes/include/aes/aes.h @@ -34,29 +34,29 @@ typedef struct { AES_AES_Block lo; } AES_AES256_Key; -static __inline AES_AES_Block aes_AES_make_block(int hi3, int hi2, int lo1, int lo0) { +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) { +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) { +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); } -static __inline AES_AES256_Block aes_AES256_make_block(int hi3, int hi2, int lo1, int lo0) { +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) { +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); return key; } -static __inline AES_AES192_Key aes_AES192_make_key( +static inline AES_AES192_Key aes_AES192_make_key( int hi5, int hi4, int lo3, @@ -70,7 +70,7 @@ static __inline AES_AES192_Key aes_AES192_make_key( return key; } -static __inline AES_AES256_Key aes_AES256_make_key( +static inline AES_AES256_Key aes_AES256_make_key( int hi7, int hi6, int hi5, @@ -104,7 +104,7 @@ typedef AES_AES_BlockMatrixString AES_AES256_BlockMatrixString; AES_StatusCode aes_AES_format_block(AES_AES_BlockString*, const AES_AES_Block*, AES_ErrorDetails*); -static __inline AES_StatusCode aes_AES128_format_block( +static inline AES_StatusCode aes_AES128_format_block( AES_AES128_BlockString* dest, const AES_AES128_Block* src, AES_ErrorDetails* err_details @@ -112,7 +112,7 @@ static __inline AES_StatusCode aes_AES128_format_block( return aes_AES_format_block(dest, src, err_details); } -static __inline AES_StatusCode aes_AES192_format_block( +static inline AES_StatusCode aes_AES192_format_block( AES_AES192_BlockString* dest, const AES_AES192_Block* src, AES_ErrorDetails* err_details @@ -120,7 +120,7 @@ static __inline AES_StatusCode aes_AES192_format_block( return aes_AES_format_block(dest, src, err_details); } -static __inline AES_StatusCode aes_AES256_format_block( +static inline AES_StatusCode aes_AES256_format_block( AES_AES256_BlockString* dest, const AES_AES256_Block* src, AES_ErrorDetails* err_details @@ -134,7 +134,7 @@ AES_StatusCode aes_AES_format_block_as_matrix( AES_ErrorDetails* ); -static __inline AES_StatusCode aes_AES128_format_block_as_matrix( +static inline AES_StatusCode aes_AES128_format_block_as_matrix( AES_AES128_BlockMatrixString* dest, const AES_AES128_Block* src, AES_ErrorDetails* err_details @@ -142,7 +142,7 @@ static __inline AES_StatusCode aes_AES128_format_block_as_matrix( return aes_AES_format_block_as_matrix(dest, src, err_details); } -static __inline AES_StatusCode aes_AES192_format_block_as_matrix( +static inline AES_StatusCode aes_AES192_format_block_as_matrix( AES_AES192_BlockMatrixString* dest, const AES_AES192_Block* src, AES_ErrorDetails* err_details @@ -150,7 +150,7 @@ static __inline AES_StatusCode aes_AES192_format_block_as_matrix( return aes_AES_format_block_as_matrix(dest, src, err_details); } -static __inline AES_StatusCode aes_AES256_format_block_as_matrix( +static inline AES_StatusCode aes_AES256_format_block_as_matrix( AES_AES256_BlockMatrixString* dest, const AES_AES256_Block* src, AES_ErrorDetails* err_details @@ -160,21 +160,21 @@ static __inline AES_StatusCode aes_AES256_format_block_as_matrix( AES_StatusCode aes_AES_print_block(const AES_AES_Block*, AES_ErrorDetails*); -static __inline AES_StatusCode aes_AES128_print_block( +static inline AES_StatusCode aes_AES128_print_block( const AES_AES128_Block* block, AES_ErrorDetails* err_details ) { return aes_AES_print_block(block, err_details); } -static __inline AES_StatusCode aes_AES192_print_block( +static inline AES_StatusCode aes_AES192_print_block( const AES_AES192_Block* block, AES_ErrorDetails* err_details ) { return aes_AES_print_block(block, err_details); } -static __inline AES_StatusCode aes_AES256_print_block( +static inline AES_StatusCode aes_AES256_print_block( const AES_AES256_Block* block, AES_ErrorDetails* err_details ) { @@ -183,21 +183,21 @@ static __inline AES_StatusCode aes_AES256_print_block( AES_StatusCode aes_AES_print_block_as_matrix(const AES_AES_Block*, AES_ErrorDetails*); -static __inline AES_StatusCode aes_AES128_print_block_as_matrix( +static inline AES_StatusCode aes_AES128_print_block_as_matrix( const AES_AES128_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( +static inline AES_StatusCode aes_AES192_print_block_as_matrix( const AES_AES192_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( +static inline AES_StatusCode aes_AES256_print_block_as_matrix( const AES_AES256_Block* block, AES_ErrorDetails* err_details ) { @@ -210,7 +210,7 @@ AES_StatusCode aes_AES_parse_block( AES_ErrorDetails* err_details ); -static __inline AES_StatusCode aes_AES128_parse_block( +static inline AES_StatusCode aes_AES128_parse_block( AES_AES128_Block* dest, const char* src, AES_ErrorDetails* err_details @@ -218,7 +218,7 @@ static __inline AES_StatusCode aes_AES128_parse_block( return aes_AES_parse_block(dest, src, err_details); } -static __inline AES_StatusCode aes_AES192_parse_block( +static inline AES_StatusCode aes_AES192_parse_block( AES_AES192_Block* dest, const char* src, AES_ErrorDetails* err_details @@ -226,7 +226,7 @@ static __inline AES_StatusCode aes_AES192_parse_block( return aes_AES_parse_block(dest, src, err_details); } -static __inline AES_StatusCode aes_AES256_parse_block( +static inline AES_StatusCode aes_AES256_parse_block( AES_AES256_Block* dest, const char* src, AES_ErrorDetails* err_details @@ -359,46 +359,46 @@ AES_AES_Block __fastcall aes_AES256_decrypt_block_( const AES_AES256_RoundKeys* ); -static __inline AES_AES_Block __fastcall aes_AES_xor_blocks(AES_AES_Block a, AES_AES_Block b) { +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( +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( +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( +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) { +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) { +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) { +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) { +static inline AES_AES_Block __fastcall aes_AES256_inc_block(AES_AES256_Block block) { return aes_AES_inc_block(block); } @@ -441,7 +441,7 @@ 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( +static inline void __fastcall aes_AES128_expand_key( const AES_AES128_Key* key, AES_AES128_RoundKeys* encryption_keys ) { @@ -456,7 +456,7 @@ 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( +static inline void __fastcall aes_AES128_derive_decryption_keys( const AES_AES128_RoundKeys* encryption_keys, AES_AES128_RoundKeys* decryption_keys ) { @@ -472,7 +472,7 @@ 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( +static inline void __fastcall aes_AES192_expand_key( const AES_AES192_Key* key, AES_AES192_RoundKeys* encryption_keys ) { @@ -488,7 +488,7 @@ 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( +static inline void __fastcall aes_AES192_derive_decryption_keys( const AES_AES192_RoundKeys* encryption_keys, AES_AES192_RoundKeys* decryption_keys ) { @@ -504,7 +504,7 @@ 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( +static inline void __fastcall aes_AES256_expand_key( const AES_AES256_Key* key, AES_AES256_RoundKeys* encryption_keys ) { @@ -520,7 +520,7 @@ 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( +static inline void __fastcall aes_AES256_derive_decryption_keys( const AES_AES256_RoundKeys* encryption_keys, AES_AES256_RoundKeys* decryption_keys ) { diff --git a/aes/include/aes/data.h b/aes/include/aes/data.h index 7665c82..1aec404 100644 --- a/aes/include/aes/data.h +++ b/aes/include/aes/data.h @@ -24,7 +24,7 @@ typedef __m128i AES_Block128; * * \return The loaded 128-bit block. */ -static __inline AES_Block128 aes_load_block128(const void* src) { +static inline AES_Block128 aes_load_block128(const void* src) { return _mm_loadu_si128((AES_Block128*)src); } @@ -35,7 +35,7 @@ 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) { +static inline AES_Block128 aes_load_block128_aligned(const void* src) { return _mm_load_si128((AES_Block128*)src); } @@ -46,7 +46,7 @@ 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) { +static inline void __fastcall aes_store_block128(void* dest, AES_Block128 block) { _mm_storeu_si128((AES_Block128*)dest, block); } @@ -57,7 +57,7 @@ static __inline void __fastcall aes_store_block128(void* dest, AES_Block128 bloc * * \param[in] block The block to be stored. */ -static __inline void __fastcall aes_store_block128_aligned(void* dest, AES_Block128 block) { +static inline void __fastcall aes_store_block128_aligned(void* dest, AES_Block128 block) { _mm_store_si128((AES_Block128*)dest, block); } @@ -69,7 +69,7 @@ static __inline void __fastcall aes_store_block128_aligned(void* dest, AES_Block * * \return `a^b`. */ -static __inline AES_Block128 __fastcall aes_xor_block128(AES_Block128 a, AES_Block128 b) { +static inline AES_Block128 __fastcall aes_xor_block128(AES_Block128 a, AES_Block128 b) { return _mm_xor_si128(a, b); } @@ -90,17 +90,17 @@ static __inline AES_Block128 __fastcall aes_xor_block128(AES_Block128 a, AES_Blo * * \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_Block128 __fastcall aes_make_block128(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) { +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_Block128 __fastcall aes_inc_block128(AES_Block128 x) { +static inline AES_Block128 __fastcall aes_inc_block128(AES_Block128 x) { return _mm_add_epi32(x, aes_make_block128(0, 0, 0, 1)); } diff --git a/aes/include/aes/error.h b/aes/include/aes/error.h index 2c93ab0..d3822de 100644 --- a/aes/include/aes/error.h +++ b/aes/include/aes/error.h @@ -21,7 +21,7 @@ typedef enum { AES_MEMORY_ALLOCATION_ERROR, } AES_StatusCode; -static __inline int aes_is_error(AES_StatusCode ec) { +static inline int aes_is_error(AES_StatusCode ec) { return ec != AES_SUCCESS; } @@ -49,7 +49,7 @@ typedef struct { size_t call_stack_len; } AES_ErrorDetails; -static __inline AES_StatusCode aes_get_error_code(const AES_ErrorDetails* err_details) { +static inline AES_StatusCode aes_get_error_code(const AES_ErrorDetails* err_details) { return err_details->ec; } diff --git a/aes/include/aes/mode.h b/aes/include/aes/mode.h index 49b6b4f..0974281 100644 --- a/aes/include/aes/mode.h +++ b/aes/include/aes/mode.h @@ -20,7 +20,7 @@ typedef enum { } AES_Mode; #define AES_ENCRYPT_BLOCK_ECB(prefix) \ - static __inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_ECB( \ + static inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_ECB( \ AES_##prefix##_Block plaintext, const AES_##prefix##_RoundKeys* encryption_keys \ ) { \ assert(encryption_keys); \ @@ -29,7 +29,7 @@ typedef enum { } #define AES_DECRYPT_BLOCK_ECB(prefix) \ - static __inline AES_##prefix##_Block __fastcall aes_##prefix##_decrypt_block_ECB( \ + static inline AES_##prefix##_Block __fastcall aes_##prefix##_decrypt_block_ECB( \ AES_##prefix##_Block ciphertext, const AES_##prefix##_RoundKeys* decryption_keys \ ) { \ assert(decryption_keys); \ @@ -38,7 +38,7 @@ typedef enum { } #define AES_ENCRYPT_BLOCK_CBC(prefix) \ - static __inline AES_##prefix##_Block __fastcall aes_##prefix##_encrypt_block_CBC( \ + 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, \ @@ -52,25 +52,25 @@ typedef enum { ); \ } -#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 \ - ) { \ - assert(decryption_keys); \ - assert(next_init_vector); \ - \ - AES_##prefix##_Block plaintext = aes_##prefix##_xor_blocks( \ - aes_##prefix##_decrypt_block_(ciphertext, decryption_keys), init_vector \ - ); \ - *next_init_vector = ciphertext; \ - return plaintext; \ +#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 \ + ) { \ + assert(decryption_keys); \ + assert(next_init_vector); \ + \ + AES_##prefix##_Block plaintext = aes_##prefix##_xor_blocks( \ + aes_##prefix##_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( \ + 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, \ @@ -84,25 +84,25 @@ typedef enum { ); \ } -#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 \ - ) { \ - assert(encryption_keys); \ - assert(next_init_vector); \ - \ - AES_##prefix##_Block plaintext = aes_##prefix##_xor_blocks( \ - aes_##prefix##_encrypt_block_(init_vector, encryption_keys), ciphertext \ - ); \ - *next_init_vector = ciphertext; \ - return 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 \ + ) { \ + assert(encryption_keys); \ + assert(next_init_vector); \ + \ + AES_##prefix##_Block plaintext = aes_##prefix##_xor_blocks( \ + aes_##prefix##_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( \ + 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, \ @@ -116,51 +116,51 @@ typedef enum { return aes_##prefix##_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(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_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(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_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(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 \ + ); \ } #ifdef __cplusplus |
