2222#include < sys/auxv.h>
2323#endif // __linux__
2424
25+ #if defined(__FreeBSD__)
26+ #include < machine/elf.h>
27+ #include < sys/auxv.h>
28+ #endif // __FreeBSD__
29+
2530#if defined(_WIN32)
2631#include < processthreadsapi.h>
2732#include < winnt.h>
@@ -41,6 +46,9 @@ void Round(uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3,
4146void RoundKeyless (uint32_t x0, uint32_t x1, uint32_t x2, uint32_t x3,
4247 uint32_t & y0, uint32_t & y1, uint32_t & y2, uint32_t & y3);
4348} // namespace arm_crypto_aes
49+ namespace arm_crypto_echo {
50+ void FullStateRound (uint64_t W[16 ][2 ], uint32_t & k0, uint32_t & k1, uint32_t & k2, uint32_t & k3);
51+ } // namespace arm_crypto_echo
4452#endif // ENABLE_ARM_AES
4553
4654#if defined(ENABLE_SSSE3)
@@ -139,13 +147,24 @@ void SapphireAutoDetect()
139147#endif // __aarch64__
140148#endif // __linux__
141149
150+ #if defined(__FreeBSD__)
151+ [[maybe_unused]] unsigned long hwcap{0 };
152+ #if defined(__arm__)
153+ have_arm_aes = ((::elf_aux_info (AT_HWCAP2, &hwcap, sizeof (hwcap)) == 0 ) && ((hwcap & HWCAP2_AES) != 0 ));
154+ #endif // __arm__
155+ #if defined(__aarch64__)
156+ have_arm_aes = ((::elf_aux_info (AT_HWCAP, &hwcap, sizeof (hwcap)) == 0 ) && ((hwcap & HWCAP_AES) != 0 ));
157+ #endif // __aarch64__
158+ #endif // __FreeBSD__
159+
142160#if defined(_WIN32)
143161 have_arm_aes = ::IsProcessorFeaturePresent (PF_ARM_V8_CRYPTO_INSTRUCTIONS_AVAILABLE);
144162#endif // _WIN32
145163
146164 if (have_arm_aes) {
147165 aes_round = sapphire::arm_crypto_aes::Round;
148166 aes_round_nk = sapphire::arm_crypto_aes::RoundKeyless;
167+ echo_round = sapphire::arm_crypto_echo::FullStateRound;
149168 }
150169#endif // ENABLE_ARM_AES
151170#endif // !DISABLE_OPTIMIZED_SHA256
0 commit comments