Skip to content

Commit

Permalink
Restore aesni for i386
Browse files Browse the repository at this point in the history
intrinsic code can be work on i386 also

Signed-off-by: Jerry Yu <[email protected]>
  • Loading branch information
yuhaoth committed Aug 16, 2023
1 parent 240bb11 commit e62ff09
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
9 changes: 5 additions & 4 deletions library/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,16 @@
#endif
#endif

#if defined(__amd64__) || defined(__x86_64__)
#if defined(__amd64__) || defined(__x86_64__) || \
defined(_M_X64) || defined(_M_AMD64)
#if !defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
#error "MBEDTLS_AES_USE_HARDWARE_ONLY defined, but not all prerequisites"
#endif
#endif

#if defined(__i386__)
#if defined(MBEDTLS_AES_USE_HARDWARE_ONLY)
#error "MBEDTLS_AES_USE_HARDWARE_ONLY not supported yet for i386."
#if defined(__i386__) || defined(_M_IX86)
#if defined(MBEDTLS_AES_USE_HARDWARE_ONLY) && !defined(MBEDTLS_AESNI_C)
#error "MBEDTLS_AES_USE_HARDWARE_ONLY defined, but not all prerequisites"
#endif

#if defined(MBEDTLS_PADLOCK_C) && !defined(MBEDTLS_HAVE_ASM)
Expand Down
11 changes: 9 additions & 2 deletions library/aesni.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@
#define MBEDTLS_HAVE_X86_64
#endif

#if defined(MBEDTLS_AESNI_C) && defined(MBEDTLS_HAVE_X86_64)
#if !defined(MBEDTLS_HAVE_X86) && \
(defined(__i386__) || defined(_M_IX86))
#define MBEDTLS_HAVE_X86
#endif

#if defined(MBEDTLS_AESNI_C) && \
(defined(MBEDTLS_HAVE_X86_64) || defined(MBEDTLS_HAVE_X86))

/* Can we do AESNI with intrinsics?
* (Only implemented with certain compilers, only for certain targets.)
Expand All @@ -67,7 +73,8 @@
* 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_ASM) && defined(__GNUC__)
#elif defined(MBEDTLS_HAVE_ASM) && \
defined(__GNUC__) && defined(MBEDTLS_HAVE_X86_64)
#define MBEDTLS_AESNI_HAVE_CODE 1 // via assembly
#else
#error "MBEDTLS_AESNI_C defined, but neither intrinsics nor assembly available"
Expand Down

0 comments on commit e62ff09

Please sign in to comment.