From 2aacc7cd872d60f385b95386b23f451cc942e8c2 Mon Sep 17 00:00:00 2001 From: Sean Parkinson Date: Fri, 13 Dec 2024 08:25:39 +1000 Subject: [PATCH] MacOS: allow SHA-3 instructions to be explicitly not used Some iPads and iPhones don't support SHA-3 instructions. Allow SHA-3 instructions to explicitly not be used for these devices. --- configure.ac | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index 16af3bb243..259174976e 100644 --- a/configure.ac +++ b/configure.ac @@ -2973,7 +2973,7 @@ fi ENABLED_ARMASM_INLINE="no" -ENABLED_ARMASM_SHA3="no" +ENABLED_ARMASM_SHA3="unknown" ENABLED_ARMASM_CRYPTO_SM4="no" # ARM Assembly # Both SHA3 and SHA512 instructions available with ARMV8.2-a @@ -3004,6 +3004,16 @@ then ENABLED_ARMASM_SHA3=yes ENABLED_ARMASM_PLUS=yes ;; + no-sha512-crypto | no-sha3-crypto) + case $host_cpu in + *aarch64*) + ;; + *) + AC_MSG_ERROR([SHA512/SHA3 instructions only available on Aarch64 CPU.]) + break;; + esac + ENABLED_ARMASM_SHA3=no + ;; sm4) case $host_cpu in *aarch64*) @@ -3048,8 +3058,10 @@ then *aarch64*) case $host_os in *darwin*) - # All known Aarch64 Mac computers support SHA-512 instructions - ENABLED_ARMASM_SHA3=yes + # Turn it on unless explicitly turned off. + if test "$ENABLED_ARMASM_SHA3" = "unknown"; then + ENABLED_ARMASM_SHA3="yes" + fi ;; *) # +crypto needed for hardware acceleration @@ -3163,6 +3175,9 @@ if test "$ENABLED_ARMASM_SHA3" = "yes"; then AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_CRYPTO_SHA512 -DWOLFSSL_ARMASM_CRYPTO_SHA3" AM_CCASFLAGS="$AM_CCASFLAGS -DWOLFSSL_ARMASM_CRYPTO_SHA512 -DWOLFSSL_ARMASM_CRYPTO_SHA3" fi +if test "$ENABLED_ARMASM_SHA3" = "unknown"; then + ENABLED_ARMASM_SHA3="no" +fi if test "$ENABLED_ARMASM_SM3" = "yes"; then AM_CFLAGS="$AM_CFLAGS -DWOLFSSL_ARMASM_CRYPTO_SM3" fi