From b0e15c7d9a0cc5ca31809b01254bca5f3a72f047 Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Thu, 23 Jul 2026 15:17:35 +0200 Subject: make buildable on Linux --- aes/src/c/aes128.c | 18 +++++++----------- aes/src/c/aes192.c | 28 +++++++++------------------- aes/src/c/aes256.c | 28 +++++++++------------------- 3 files changed, 25 insertions(+), 49 deletions(-) (limited to 'aes/src/c') diff --git a/aes/src/c/aes128.c b/aes/src/c/aes128.c index 80892ad..379c4cb 100644 --- a/aes/src/c/aes128.c +++ b/aes/src/c/aes128.c @@ -10,10 +10,8 @@ #include #include -AES_Block __fastcall aes128_encrypt_block_internal( - AES_Block plaintext, - const AES128_RoundKeys* encryption_keys -) { +AES_Block AES_ASM_ATTR +aes128_encrypt_block_internal(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]); plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[2]); @@ -27,10 +25,8 @@ AES_Block __fastcall aes128_encrypt_block_internal( return _mm_aesenclast_si128(plaintext, encryption_keys->keys[10]); } -AES_Block __fastcall aes128_decrypt_block_internal( - AES_Block ciphertext, - const AES128_RoundKeys* decryption_keys -) { +AES_Block AES_ASM_ATTR +aes128_decrypt_block_internal(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]); ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[2]); @@ -44,7 +40,7 @@ AES_Block __fastcall aes128_decrypt_block_internal( return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[10]); } -static AES_Block __fastcall aes128_expand_key_assist(AES_Block prev, AES_Block hwgen) { +static AES_Block AES_ASM_ATTR aes128_expand_key_assist(AES_Block prev, AES_Block hwgen) { AES_Block tmp = prev; tmp = _mm_slli_si128(tmp, 4); @@ -60,7 +56,7 @@ static AES_Block __fastcall aes128_expand_key_assist(AES_Block prev, AES_Block h return prev; } -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) { AES_Block prev = encryption_keys->keys[0] = key; prev = encryption_keys->keys[1] = aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x01)); @@ -84,7 +80,7 @@ void __fastcall aes128_expand_key_internal(AES_Block key, AES128_RoundKeys* encr aes128_expand_key_assist(prev, _mm_aeskeygenassist_si128(prev, 0x36)); } -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 ) { diff --git a/aes/src/c/aes192.c b/aes/src/c/aes192.c index d3f83fc..83ee354 100644 --- a/aes/src/c/aes192.c +++ b/aes/src/c/aes192.c @@ -10,10 +10,8 @@ #include #include -AES_Block __fastcall aes192_encrypt_block_internal( - AES_Block plaintext, - const AES192_RoundKeys* encryption_keys -) { +AES_Block AES_ASM_ATTR +aes192_encrypt_block_internal(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]); plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[2]); @@ -29,10 +27,8 @@ AES_Block __fastcall aes192_encrypt_block_internal( return _mm_aesenclast_si128(plaintext, encryption_keys->keys[12]); } -AES_Block __fastcall aes192_decrypt_block_internal( - AES_Block ciphertext, - const AES192_RoundKeys* decryption_keys -) { +AES_Block AES_ASM_ATTR +aes192_decrypt_block_internal(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]); ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[2]); @@ -48,11 +44,8 @@ AES_Block __fastcall aes192_decrypt_block_internal( return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[12]); } -static void __fastcall aes192_expand_key_assist( - AES_Block* prev_lo, - AES_Block* prev_hi, - AES_Block hwgen -) { +static void AES_ASM_ATTR +aes192_expand_key_assist(AES_Block* prev_lo, AES_Block* prev_hi, AES_Block hwgen) { AES_Block tmp = *prev_lo; tmp = _mm_slli_si128(tmp, 4); @@ -73,11 +66,8 @@ static void __fastcall aes192_expand_key_assist( *prev_hi = _mm_xor_si128(*prev_hi, tmp); } -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) { encryption_keys->keys[0] = key_lo; encryption_keys->keys[1] = key_hi; @@ -125,7 +115,7 @@ void __fastcall aes192_expand_key_internal( encryption_keys->keys[12] = key_lo; } -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 ) { diff --git a/aes/src/c/aes256.c b/aes/src/c/aes256.c index 8a86f40..5a57761 100644 --- a/aes/src/c/aes256.c +++ b/aes/src/c/aes256.c @@ -10,10 +10,8 @@ #include #include -AES_Block __fastcall aes256_encrypt_block_internal( - AES_Block plaintext, - const AES256_RoundKeys* encryption_keys -) { +AES_Block AES_ASM_ATTR +aes256_encrypt_block_internal(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]); plaintext = _mm_aesenc_si128(plaintext, encryption_keys->keys[2]); @@ -31,10 +29,8 @@ AES_Block __fastcall aes256_encrypt_block_internal( return _mm_aesenclast_si128(plaintext, encryption_keys->keys[14]); } -AES_Block __fastcall aes256_decrypt_block_internal( - AES_Block ciphertext, - const AES256_RoundKeys* decryption_keys -) { +AES_Block AES_ASM_ATTR +aes256_decrypt_block_internal(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]); ciphertext = _mm_aesdec_si128(ciphertext, decryption_keys->keys[2]); @@ -52,11 +48,8 @@ AES_Block __fastcall aes256_decrypt_block_internal( return _mm_aesdeclast_si128(ciphertext, decryption_keys->keys[14]); } -static AES_Block __fastcall aes256_expand_key_assist( - AES_Block* prev_lo, - AES_Block* prev_hi, - AES_Block hwgen -) { +static AES_Block AES_ASM_ATTR +aes256_expand_key_assist(AES_Block* prev_lo, AES_Block* prev_hi, AES_Block hwgen) { AES_Block tmp = *prev_lo; tmp = _mm_slli_si128(tmp, 4); @@ -75,11 +68,8 @@ static AES_Block __fastcall aes256_expand_key_assist( return *prev_hi; } -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) { AES_Block prev_lo, prev_hi; AES_Block hwgen; @@ -139,7 +129,7 @@ void __fastcall aes256_expand_key_internal( encryption_keys->keys[14] = aes256_expand_key_assist(&prev_lo, &prev_hi, hwgen); } -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 ) { -- cgit v1.3