Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/aes_hardware.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,13 @@

#if (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 4)) && (defined(__x86_64__) || defined(__i386))
#define HAS_AES_HARDWARE AES_HARDWARE_NI

#elif (__GNUC__ >= 6) && defined(__aarch64__)
#define HAS_AES_HARDWARE AES_HARDWARE_NEON

/* Crypto extension in AArch64 can be enabled using __attribute__((target)) */
#define USE_GCC_ATTR_TARGET_AARCH64

#endif


Expand Down Expand Up @@ -461,6 +468,10 @@ aesDecryptCBC(const unsigned char* in,
#define FUNC_ISA __attribute__ ((target("neon,crypto")))
#endif /* USE_CLANG_ATTR_TARGET_AARCH64 */

#ifdef USE_GCC_ATTR_TARGET_AARCH64
#define FUNC_ISA __attribute__ ((target("+crypto")))
#endif /* USE_GCC_ATTR_TARGET_AARCH64 */

/* FUNCtion attributes for ISA (Instruction Set Architecture) */
#ifndef FUNC_ISA
#define FUNC_ISA
Expand Down Expand Up @@ -497,6 +508,18 @@ aesHardwareAvailableOnPlatform()
return (int) IsProcessorFeaturePresent(PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
}

#elif defined(__APPLE__) && (defined(__aarch64__) || defined(__arm64__))

/*
** All 64-bit ARM processors used by Apple (A7 and later, M1 and later)
** implement the ARMv8 cryptographic extensions
*/
static int
aesHardwareAvailableOnPlatform()
{
return 1;
}

#else

static int
Expand Down
Loading