Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit b583107

Browse files
committedOct 19, 2023
Fix Mbed-TLS#8372 - Error compiling AESNI in Mbed-TLS with clang on Windows
It can successfully compile w/ or w/o the clang options -maes -mpclmul. Signed-off-by: Sergey Markelov <sergey@solidstatenetworks.com>
1 parent 47e8cc9 commit b583107

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed
 

‎ChangeLog

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
Mbed TLS ChangeLog (Sorted per branch, date)
22

3+
Bugfix
4+
* Fix compile errors in the AES-NI support functions when using clang or
5+
clang-cl on Windows. Fixes #8372.
6+
37
= Mbed TLS 2.28.5 branch released 2023-10-05
48

59
Features

‎include/mbedtls/aesni.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,15 @@
5858
* macros that may change in future releases.
5959
*/
6060
#undef MBEDTLS_AESNI_HAVE_INTRINSICS
61-
#if defined(_MSC_VER)
61+
#if defined(_MSC_VER) && !defined(__clang__)
6262
/* Visual Studio supports AESNI intrinsics since VS 2008 SP1. We only support
6363
* VS 2013 and up for other reasons anyway, so no need to check the version. */
6464
#define MBEDTLS_AESNI_HAVE_INTRINSICS
6565
#endif
6666
/* GCC-like compilers: currently, we only support intrinsics if the requisite
6767
* target flag is enabled when building the library (e.g. `gcc -mpclmul -msse2`
6868
* or `clang -maes -mpclmul`). */
69-
#if defined(__GNUC__) && defined(__AES__) && defined(__PCLMUL__)
69+
#if (defined(__GNUC__) || defined(__clang__)) && defined(__AES__) && defined(__PCLMUL__)
7070
#define MBEDTLS_AESNI_HAVE_INTRINSICS
7171
#endif
7272

‎library/aesni.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ int mbedtls_aesni_has_support(unsigned int what)
5757

5858
if (!done) {
5959
#if MBEDTLS_AESNI_HAVE_CODE == 2
60-
static unsigned info[4] = { 0, 0, 0, 0 };
60+
static int info[4] = { 0, 0, 0, 0 };
6161
#if defined(_MSC_VER)
6262
__cpuid(info, 1);
6363
#else
@@ -191,7 +191,7 @@ void mbedtls_aesni_gcm_mult(unsigned char c[16],
191191
const unsigned char a[16],
192192
const unsigned char b[16])
193193
{
194-
__m128i aa, bb, cc, dd;
194+
__m128i aa = { 0 }, bb = { 0 }, cc, dd;
195195

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

0 commit comments

Comments
 (0)
Please sign in to comment.