https://github.com/Legrandin/pycryptodome/issues/787 https://github.com/Legrandin/pycryptodome/commit/b4083688fde0580de6c2a4d36d84da31a2549a2c https://github.com/Legrandin/pycryptodome/commit/3f6a86e072ef0e650f04eebf086940e6d8b33c03 From b4083688fde0580de6c2a4d36d84da31a2549a2c Mon Sep 17 00:00:00 2001 From: Helder Eijs Date: Fri, 29 Dec 2023 14:36:19 +0100 Subject: [PATCH] Better autodetect of AES support, in case of aggressive optimization --- a/compiler_opt.py +++ b/compiler_opt.py @@ -140,7 +140,7 @@ def compiler_has_intrin_h(): { int a, b[4]; __cpuid(b, a); - return 0; + return a; } """ return test_compilation(source, msg="intrin.h header") @@ -154,7 +154,7 @@ def compiler_has_cpuid_h(): { unsigned int eax, ebx, ecx, edx; __get_cpuid(1, &eax, &ebx, &ecx, &edx); - return 0; + return eax; } """ return test_compilation(source, msg="cpuid.h header") @@ -163,11 +163,16 @@ def compiler_has_cpuid_h(): def compiler_supports_aesni(): source = """ #include + #include __m128i f(__m128i x, __m128i y) { return _mm_aesenc_si128(x, y); } int main(void) { - return 0; + int ret; + __m128i x = _mm_setzero_si128(); + x = f(x, x); + memcpy(&ret, &x, sizeof(ret)); + return ret; } """ From 3f6a86e072ef0e650f04eebf086940e6d8b33c03 Mon Sep 17 00:00:00 2001 From: Helder Eijs Date: Fri, 29 Dec 2023 14:52:15 +0100 Subject: [PATCH] Use memset, to avoid emmintrin.h --- compiler_opt.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/compiler_opt.py b/compiler_opt.py index 57db0a6f..a2711c09 100644 --- a/compiler_opt.py +++ b/compiler_opt.py @@ -169,7 +169,8 @@ def compiler_supports_aesni(): } int main(void) { int ret; - __m128i x = _mm_setzero_si128(); + __m128i x; + memset(&x, 0, sizeof(x)); x = f(x, x); memcpy(&ret, &x, sizeof(ret)); return ret;