diff options
| author | Egor Tensin <egor@tensin.name> | 2026-07-23 15:17:35 +0200 |
|---|---|---|
| committer | Egor Tensin <egor@tensin.name> | 2026-07-23 15:20:39 +0200 |
| commit | b0e15c7d9a0cc5ca31809b01254bca5f3a72f047 (patch) | |
| tree | a4b702ca4a3717827fc3637a0709589cc85eed4d /aes/include | |
| parent | aes/error: add static asserts to prevent missing error messages (diff) | |
| download | aes-tools-b0e15c7d9a0cc5ca31809b01254bca5f3a72f047.tar.gz aes-tools-b0e15c7d9a0cc5ca31809b01254bca5f3a72f047.zip | |
make buildable on Linux
Diffstat (limited to 'aes/include')
| -rw-r--r-- | aes/include/aes/aes.h | 13 | ||||
| -rw-r--r-- | aes/include/aes/round_keys.h | 23 | ||||
| -rw-r--r-- | aes/include/aes/workarounds.h | 9 |
3 files changed, 25 insertions, 20 deletions
diff --git a/aes/include/aes/aes.h b/aes/include/aes/aes.h index 8f1e511..3cfaf8a 100644 --- a/aes/include/aes/aes.h +++ b/aes/include/aes/aes.h @@ -9,6 +9,7 @@ #include "block.h" #include "round_keys.h" +#include "workarounds.h" #include <assert.h> @@ -16,13 +17,13 @@ extern "C" { #endif -AES_Block __fastcall aes128_encrypt_block_internal(AES_Block, const AES128_RoundKeys*); -AES_Block __fastcall aes192_encrypt_block_internal(AES_Block, const AES192_RoundKeys*); -AES_Block __fastcall aes256_encrypt_block_internal(AES_Block, const AES256_RoundKeys*); +AES_Block AES_ASM_ATTR aes128_encrypt_block_internal(AES_Block, const AES128_RoundKeys*); +AES_Block AES_ASM_ATTR aes192_encrypt_block_internal(AES_Block, const AES192_RoundKeys*); +AES_Block AES_ASM_ATTR aes256_encrypt_block_internal(AES_Block, const AES256_RoundKeys*); -AES_Block __fastcall aes128_decrypt_block_internal(AES_Block, const AES128_RoundKeys*); -AES_Block __fastcall aes192_decrypt_block_internal(AES_Block, const AES192_RoundKeys*); -AES_Block __fastcall aes256_decrypt_block_internal(AES_Block, const AES256_RoundKeys*); +AES_Block AES_ASM_ATTR aes128_decrypt_block_internal(AES_Block, const AES128_RoundKeys*); +AES_Block AES_ASM_ATTR aes192_decrypt_block_internal(AES_Block, const AES192_RoundKeys*); +AES_Block AES_ASM_ATTR aes256_decrypt_block_internal(AES_Block, const AES256_RoundKeys*); static inline AES_Block aes128_encrypt_block(AES_Block plaintext, const AES128_RoundKeys* keys) { assert(keys); diff --git a/aes/include/aes/round_keys.h b/aes/include/aes/round_keys.h index be35f24..4d9af69 100644 --- a/aes/include/aes/round_keys.h +++ b/aes/include/aes/round_keys.h @@ -10,6 +10,7 @@ #include "block.h" #include "error.h" #include "key.h" +#include "workarounds.h" #include <assert.h> @@ -29,31 +30,25 @@ typedef struct { AES_Block keys[15]; } AES256_RoundKeys; -void __fastcall aes128_expand_key_internal(AES_Block key, AES128_RoundKeys* encryption_keys); +void AES_ASM_ATTR aes128_expand_key_internal(AES_Block key, AES128_RoundKeys* encryption_keys); -void __fastcall aes192_expand_key_internal( - AES_Block key_lo, - AES_Block key_hi, - AES192_RoundKeys* encryption_keys -); +void AES_ASM_ATTR +aes192_expand_key_internal(AES_Block key_lo, AES_Block key_hi, AES192_RoundKeys* encryption_keys); -void __fastcall aes256_expand_key_internal( - AES_Block key_lo, - AES_Block key_hi, - AES256_RoundKeys* encryption_keys -); +void AES_ASM_ATTR +aes256_expand_key_internal(AES_Block key_lo, AES_Block key_hi, AES256_RoundKeys* encryption_keys); -void __fastcall aes128_derive_decryption_keys_internal( +void AES_ASM_ATTR aes128_derive_decryption_keys_internal( const AES128_RoundKeys* encryption_keys, AES128_RoundKeys* decryption_keys ); -void __fastcall aes192_derive_decryption_keys_internal( +void AES_ASM_ATTR aes192_derive_decryption_keys_internal( const AES192_RoundKeys* encryption_keys, AES192_RoundKeys* decryption_keys ); -void __fastcall aes256_derive_decryption_keys_internal( +void AES_ASM_ATTR aes256_derive_decryption_keys_internal( const AES256_RoundKeys* encryption_keys, AES256_RoundKeys* decryption_keys ); diff --git a/aes/include/aes/workarounds.h b/aes/include/aes/workarounds.h index 4a728c4..084a689 100644 --- a/aes/include/aes/workarounds.h +++ b/aes/include/aes/workarounds.h @@ -16,3 +16,12 @@ #endif #define AES_UNUSED_PARAMETER(...) (void)(__VA_ARGS__) + +/* Targetting 32-bit Windows, match the existing ASM implementation's behavior + * (__fastcall). Otherwise, do nothing, using the standard calling convention + * by default. */ +#if defined(_MSC_VER) && !defined(_WIN64) +#define AES_ASM_ATTR __fastcall +#else +#define AES_ASM_ATTR +#endif |
