diff --git a/crc-simd.cpp b/crc-simd.cpp index bda4b2d2..bf6f1828 100644 --- a/crc-simd.cpp +++ b/crc-simd.cpp @@ -20,6 +20,9 @@ # ifndef HWCAP_CRC32 # define HWCAP_CRC32 (1 << 7) # endif +# ifndef HWCAP2_CRC32 +# define HWCAP2_CRC32 (1 << 4) +# endif #endif #if (CRYPTOPP_SSE42_AVAILABLE) @@ -78,9 +81,13 @@ bool CPU_TryCRC32_ARMV8() } return result; #else -# if defined(__linux__) && (defined(__aarch32__) || defined(__aarch64__)) + // https://sourceware.org/ml/libc-help/2017-08/msg00012.html +# if defined(__linux__) && defined(__aarch64__) if (getauxval(AT_HWCAP) & HWCAP_CRC32) return true; +# elif defined(__linux__) && defined(__aarch32__) + if (getauxval(AT_HWCAP2) & HWCAP2_CRC32) + return true; # endif // longjmp and clobber warnings. Volatile is required. diff --git a/gcm-simd.cpp b/gcm-simd.cpp index d42307d3..57ba9319 100644 --- a/gcm-simd.cpp +++ b/gcm-simd.cpp @@ -20,6 +20,9 @@ # ifndef HWCAP_PMULL # define HWCAP_PMULL (1 << 4) # endif +# ifndef HWCAP2_PMULL +# define HWCAP2_PMULL (1 << 1) +# endif #endif #if (CRYPTOPP_CLMUL_AVAILABLE) @@ -211,9 +214,13 @@ bool CPU_TryPMULL_ARMV8() } return result; # else -# if defined(__linux__) && (defined(__aarch32__) || defined(__aarch64__)) + // https://sourceware.org/ml/libc-help/2017-08/msg00012.html +# if defined(__linux__) && defined(__aarch64__) if (getauxval(AT_HWCAP) & HWCAP_PMULL) return true; +# elif defined(__linux__) && defined(__aarch32__) + if (getauxval(AT_HWCAP2) & HWCAP2_PMULL) + return true; # endif // longjmp and clobber warnings. Volatile is required. diff --git a/rijndael-simd.cpp b/rijndael-simd.cpp index 74b2e1b2..7ab393a5 100644 --- a/rijndael-simd.cpp +++ b/rijndael-simd.cpp @@ -25,6 +25,9 @@ # ifndef HWCAP_AES # define HWCAP_AES (1 << 3) # endif +# ifndef HWCAP2_AES +# define HWCAP2_AES (1 << 0) +# endif #endif #if (CRYPTOPP_SSE41_AVAILABLE) @@ -101,9 +104,13 @@ bool CPU_TryAES_ARMV8() } return result; # else -# if defined(__linux__) && (defined(__aarch32__) || defined(__aarch64__)) + // https://sourceware.org/ml/libc-help/2017-08/msg00012.html +# if defined(__linux__) && defined(__aarch64__) if (getauxval(AT_HWCAP) & HWCAP_AES) return true; +# elif defined(__linux__) && defined(__aarch32__) + if (getauxval(AT_HWCAP2) & HWCAP2_AES) + return true; # endif // longjmp and clobber warnings. Volatile is required. diff --git a/sha-simd.cpp b/sha-simd.cpp index 07ee69e1..e7a8708a 100644 --- a/sha-simd.cpp +++ b/sha-simd.cpp @@ -23,6 +23,12 @@ # ifndef HWCAP_SHA2 # define HWCAP_SHA2 (1 << 6) # endif +# ifndef HWCAP2_SHA1 +# define HWCAP2_SHA1 (1 << 2) +# endif +# ifndef HWCAP2_SHA2 +# define HWCAP2_SHA2 (1 << 3) +# endif #endif #if (CRYPTOPP_SSE42_AVAILABLE) @@ -85,9 +91,13 @@ bool CPU_TrySHA1_ARMV8() } return result; # else -# if defined(__linux__) && (defined(__aarch32__) || defined(__aarch64__)) + // https://sourceware.org/ml/libc-help/2017-08/msg00012.html +# if defined(__linux__) && defined(__aarch64__) if (getauxval(AT_HWCAP) & HWCAP_SHA1) return true; +# elif defined(__linux__) && defined(__aarch32__) + if (getauxval(AT_HWCAP2) & HWCAP2_SHA1) + return true; # endif // longjmp and clobber warnings. Volatile is required. @@ -148,7 +158,10 @@ bool CPU_TrySHA2_ARMV8() } return result; #else -# if defined(__linux__) && (defined(__aarch32__) || defined(__aarch64__)) +# if defined(__linux__) && defined(__aarch64__) + if (getauxval(AT_HWCAP) & HWCAP_SHA2) + return true; +# elif defined(__linux__) && defined(__aarch32__) if (getauxval(AT_HWCAP) & HWCAP_SHA2) return true; # endif