diff --git a/configure.ac b/configure.ac index d94f7bdb..548b1a08 100644 --- a/configure.ac +++ b/configure.ac @@ -313,7 +313,10 @@ AS_IF([test "x$EMSCRIPTEN" = "x"],[ ]], [[ __m128i x = _mm_aesimc_si128(_mm_setzero_si128()); __m128i y = _mm_clmulepi64_si128(_mm_setzero_si128(), _mm_setzero_si128(), 0);]])], [AC_MSG_RESULT(yes) - AC_DEFINE([HAVE_WMMINTRIN_H], [1], [aesni is available])], + AC_DEFINE([HAVE_WMMINTRIN_H], [1], [aesni is available]) + AX_CHECK_COMPILE_FLAG([-maes], [CFLAGS="$CFLAGS -maes"]) + AX_CHECK_COMPILE_FLAG([-mpclmul], [CFLAGS="$CFLAGS -mpclmul"]) + ], [AC_MSG_RESULT(no)]) ]) diff --git a/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c b/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c index e17c78c0..bc1780f1 100644 --- a/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c +++ b/src/libsodium/crypto_aead/aes256gcm/aesni/aead_aes256gcm_aesni.c @@ -3,6 +3,16 @@ * AES256-GCM, based on original code by Romain Dolbeau */ +#include +#include +#include + +#include "crypto_aead_aes256gcm_aesni.h" +#include "export.h" +#include "utils.h" + +#ifdef HAVE_WMMINTRIN_H + #pragma GCC target("sse") #pragma GCC target("sse2") #pragma GCC target("ssse3") @@ -19,15 +29,7 @@ #ifndef __PCLMUL__ # define __PCLMUL__ #endif - #include -#include -#include -#include - -#include "crypto_aead_aes256gcm_aesni.h" -#include "export.h" -#include "utils.h" #if defined(__INTEL_COMPILER) || defined(_bswap64) #elif defined(_MSC_VER) @@ -807,7 +809,7 @@ size_t crypto_aead_aes256gcm_aesni_abytes(void) size_t crypto_aead_aes256gcm_aesni_statebytes(void) { - (void) sizeof(int[(sizeof(crypto_aead_aes256gcm_aesni_state) >= - sizeof(context)) ? 1 : -1]); return sizeof(crypto_aead_aes256gcm_aesni_state); } + +#endif