From 5595e9651aca39af945931c73eb524a0f8bd130d Mon Sep 17 00:00:00 2001
From: Alexander Kanavin <alex.kanavin@gmail.com>
Date: Wed, 18 Dec 2019 12:29:50 +0100
Subject: [PATCH] freebl: add a configure option to disable ARM HW crypto

Not all current hardware supports it, particularly anything
prior to armv8 does not.

Upstream-Status: Pending
Signed-off-by: Alexander Kanavin <alex.kanavin@gmail.com>
---
 nss/lib/freebl/Makefile | 3 +++
 1 file changed, 3 insertions(+)

--- a/nss/lib/freebl/Makefile
+++ b/nss/lib/freebl/Makefile
@@ -125,6 +125,9 @@ else
         DEFINES += -DNSS_X86
 endif
 endif
+
+ifdef NSS_USE_ARM_HW_CRYPTO
+    DEFINES += -DNSS_USE_ARM_HW_CRYPTO
 ifeq ($(CPU_ARCH),aarch64)
     DEFINES += -DUSE_HW_AES
     EXTRA_SRCS += aes-armv8.c gcm-aarch64.c
@@ -146,6 +149,7 @@ ifeq ($(CPU_ARCH),arm)
         endif
     endif
 endif
+endif
 
 ifeq ($(OS_TARGET),OSF1)
     DEFINES += -DMP_ASSEMBLY_MULTIPLY -DMP_NO_MP_WORD
--- a/nss/lib/freebl/gcm.c
+++ b/nss/lib/freebl/gcm.c
@@ -17,6 +17,7 @@
 
 #include <limits.h>
 
+#ifdef NSS_USE_ARM_HW_CRYPTO
 /* old gcc doesn't support some poly64x2_t intrinsic */
 #if defined(__aarch64__) && defined(IS_LITTLE_ENDIAN) && \
     (defined(__clang__) || defined(__GNUC__) && __GNUC__ > 6)
@@ -25,6 +26,7 @@
 /* We don't test on big endian platform, so disable this on big endian. */
 #define USE_ARM_GCM
 #endif
+#endif
 
 /* Forward declarations */
 SECStatus gcm_HashInit_hw(gcmHashContext *ghash);
