diff --git a/src/Crypto/cpu.c b/src/Crypto/cpu.c index 3934107d..653869d9 100644 --- a/src/Crypto/cpu.c +++ b/src/Crypto/cpu.c @@ -479,7 +479,7 @@ void DisableCPUExtendedFeatures () #endif #if CRYPTOPP_BOOL_ARMV8 -#if defined(__linux__) && defined(__aarch64__) +#if (defined(__linux__) || defined(__FreeBSD__)) && defined(__aarch64__) #include #ifndef HWCAP_AES # define HWCAP_AES (1 << 3) @@ -498,6 +498,10 @@ VC_INLINE int CPU_QueryAES() #if defined(__linux__) && defined(__aarch64__) if ((getauxval(AT_HWCAP) & HWCAP_AES) != 0) return 1; +#elif defined(__FreeBSD__) && defined(__aarch64__) + unsigned long hwcap = 0; + if (elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)) == 0 && (hwcap & HWCAP_AES) != 0) + return 1; #elif defined(__APPLE__) && defined(__aarch64__) // Apple Sillcon (M1) and later return 1; @@ -522,6 +526,10 @@ VC_INLINE int CPU_QuerySHA2() #if defined(__linux__) && defined(__aarch64__) if ((getauxval(AT_HWCAP) & HWCAP_SHA2) != 0) return 1; +#elif defined(__FreeBSD__) && defined(__aarch64__) + unsigned long hwcap = 0; + if (elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)) == 0 && (hwcap & HWCAP_SHA2) != 0) + return 1; #elif defined(__APPLE__) && defined(__aarch64__) // Apple Sillcon (M1) and later return 1;