mirror of
https://github.com/Mbed-TLS/mbedtls.git
synced 2025-07-29 11:41:15 +03:00
Merge pull request #7630 from daverodgman/prefer-intrinsics
Prefer intrinsics over asm for AES-NI
This commit is contained in:
@ -1824,6 +1824,13 @@ int mbedtls_aes_self_test(int verbose)
|
||||
} else
|
||||
#endif
|
||||
#if defined(MBEDTLS_AESNI_HAVE_CODE)
|
||||
#if MBEDTLS_AESNI_HAVE_CODE == 1
|
||||
mbedtls_printf(" AES note: AESNI code present (assembly implementation).\n");
|
||||
#elif MBEDTLS_AESNI_HAVE_CODE == 2
|
||||
mbedtls_printf(" AES note: AESNI code present (intrinsics implementation).\n");
|
||||
#else
|
||||
#error Unrecognised value for MBEDTLS_AESNI_HAVE_CODE
|
||||
#endif
|
||||
if (mbedtls_aesni_has_support(MBEDTLS_AESNI_AES)) {
|
||||
mbedtls_printf(" AES note: using AESNI.\n");
|
||||
} else
|
||||
|
@ -59,16 +59,16 @@
|
||||
#define MBEDTLS_AESNI_HAVE_INTRINSICS
|
||||
#endif
|
||||
|
||||
/* Choose the implementation of AESNI, if one is available. */
|
||||
#undef MBEDTLS_AESNI_HAVE_CODE
|
||||
/* To minimize disruption when releasing the intrinsics-based implementation,
|
||||
* favor the assembly-based implementation if it's available. We intend to
|
||||
* revise this in a later release of Mbed TLS 3.x. In the long run, we will
|
||||
* likely remove the assembly implementation. */
|
||||
#if defined(MBEDTLS_HAVE_X86_64)
|
||||
#define MBEDTLS_AESNI_HAVE_CODE 1 // via assembly
|
||||
#elif defined(MBEDTLS_AESNI_HAVE_INTRINSICS)
|
||||
/* Choose the implementation of AESNI, if one is available.
|
||||
*
|
||||
* Favor the intrinsics-based implementation if it's available, for better
|
||||
* maintainability.
|
||||
* Performance is about the same (see #7380).
|
||||
* In the long run, we will likely remove the assembly implementation. */
|
||||
#if defined(MBEDTLS_AESNI_HAVE_INTRINSICS)
|
||||
#define MBEDTLS_AESNI_HAVE_CODE 2 // via intrinsics
|
||||
#elif defined(MBEDTLS_HAVE_X86_64)
|
||||
#define MBEDTLS_AESNI_HAVE_CODE 1 // via assembly
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_AESNI_HAVE_CODE)
|
||||
|
Reference in New Issue
Block a user