Skip to content

Commit

Permalink
Fix Mbed-TLS#8372 - Error compiling AESNI in Mbed-TLS with clang on W…
Browse files Browse the repository at this point in the history
…indows

It can successfully compile w/ or w/o the clang options -maes -mpclmul.

Signed-off-by: Sergey Markelov <sergey@solidstatenetworks.com>
  • Loading branch information
sergio-nsk committed Oct 17, 2023
1 parent 47e8cc9 commit 33d9e55
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions include/mbedtls/aesni.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,15 +58,15 @@
* macros that may change in future releases.
*/
#undef MBEDTLS_AESNI_HAVE_INTRINSICS
#if defined(_MSC_VER)
#if defined(_MSC_VER) && !defined(__clang__)
/* Visual Studio supports AESNI intrinsics since VS 2008 SP1. We only support
* VS 2013 and up for other reasons anyway, so no need to check the version. */
#define MBEDTLS_AESNI_HAVE_INTRINSICS
#endif
/* GCC-like compilers: currently, we only support intrinsics if the requisite
* target flag is enabled when building the library (e.g. `gcc -mpclmul -msse2`
* or `clang -maes -mpclmul`). */
#if defined(__GNUC__) && defined(__AES__) && defined(__PCLMUL__)
#if (defined(__GNUC__) || defined(__clang__)) && defined(__AES__) && defined(__PCLMUL__)
#define MBEDTLS_AESNI_HAVE_INTRINSICS
#endif

Expand Down
4 changes: 2 additions & 2 deletions library/aesni.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ int mbedtls_aesni_has_support(unsigned int what)

if (!done) {
#if MBEDTLS_AESNI_HAVE_CODE == 2
static unsigned info[4] = { 0, 0, 0, 0 };
static int info[4] = { 0, 0, 0, 0 };
#if defined(_MSC_VER)
__cpuid(info, 1);
#else
Expand Down Expand Up @@ -191,7 +191,7 @@ void mbedtls_aesni_gcm_mult(unsigned char c[16],
const unsigned char a[16],
const unsigned char b[16])
{
__m128i aa, bb, cc, dd;
__m128i aa = { 0 }, bb = { 0 }, cc, dd;

/* The inputs are in big-endian order, so byte-reverse them */
for (size_t i = 0; i < 16; i++) {
Expand Down

0 comments on commit 33d9e55

Please sign in to comment.