[PATCH 1/2] hwf-arm: add ARMv8.2 optional crypto extension HW features

Tianjia Zhang tianjia.zhang at linux.alibaba.com
Fri Feb 25 08:41:18 CET 2022


* src/g10lib.h (HWF_ARM_SHA3, HWF_ARM_SM3, HWF_ARM_SM4)
(HWF_ARM_SHA512): New.
* src/hwf-arm.c (arm_features): Add sha3, sm3, sm4, sha512 HW features.
* src/hwfeatures.c (hwflist): Add sha3, sm3, sm4, sha512 HW features.
--

Signed-off-by: Tianjia Zhang <tianjia.zhang at linux.alibaba.com>
---
 src/g10lib.h     |  4 ++++
 src/hwf-arm.c    | 16 ++++++++++++++++
 src/hwfeatures.c |  4 ++++
 3 files changed, 24 insertions(+)

diff --git a/src/g10lib.h b/src/g10lib.h
index 22c0f0c2..985e75c6 100644
--- a/src/g10lib.h
+++ b/src/g10lib.h
@@ -245,6 +245,10 @@ char **_gcry_strtokenize (const char *string, const char *delim);
 #define HWF_ARM_SHA1            (1 << 2)
 #define HWF_ARM_SHA2            (1 << 3)
 #define HWF_ARM_PMULL           (1 << 4)
+#define HWF_ARM_SHA3            (1 << 5)
+#define HWF_ARM_SM3             (1 << 6)
+#define HWF_ARM_SM4             (1 << 7)
+#define HWF_ARM_SHA512          (1 << 8)
 
 #elif defined(HAVE_CPU_ARCH_PPC)
 
diff --git a/src/hwf-arm.c b/src/hwf-arm.c
index 60107f36..70d375b2 100644
--- a/src/hwf-arm.c
+++ b/src/hwf-arm.c
@@ -137,6 +137,18 @@ static const struct feature_map_s arm_features[] =
 #ifndef HWCAP_SHA2
 # define HWCAP_SHA2  64
 #endif
+#ifndef HWCAP_SHA3
+# define HWCAP_SHA3  (1 << 17)
+#endif
+#ifndef HWCAP_SM3
+# define HWCAP_SM3   (1 << 18)
+#endif
+#ifndef HWCAP_SM4
+# define HWCAP_SM4   (1 << 19)
+#endif
+#ifndef HWCAP_SHA512
+# define HWCAP_SHA512 (1 << 21)
+#endif
 
 static const struct feature_map_s arm_features[] =
   {
@@ -148,6 +160,10 @@ static const struct feature_map_s arm_features[] =
     { HWCAP_SHA1, 0, " sha1", HWF_ARM_SHA1 },
     { HWCAP_SHA2, 0, " sha2", HWF_ARM_SHA2 },
     { HWCAP_PMULL, 0, " pmull", HWF_ARM_PMULL },
+    { HWCAP_SHA3, 0, " sha3",  HWF_ARM_SHA3 },
+    { HWCAP_SM3, 0, " sm3",  HWF_ARM_SM3 },
+    { HWCAP_SM4, 0, " sm4",  HWF_ARM_SM4 },
+    { HWCAP_SHA512, 0, " sha512",  HWF_ARM_SHA512 },
 #endif
   };
 
diff --git a/src/hwfeatures.c b/src/hwfeatures.c
index 97e67b3c..7060d995 100644
--- a/src/hwfeatures.c
+++ b/src/hwfeatures.c
@@ -68,6 +68,10 @@ static struct
     { HWF_ARM_SHA1,            "arm-sha1" },
     { HWF_ARM_SHA2,            "arm-sha2" },
     { HWF_ARM_PMULL,           "arm-pmull" },
+    { HWF_ARM_SHA3,            "arm-sha3" },
+    { HWF_ARM_SM3,             "arm-sm3" },
+    { HWF_ARM_SM4,             "arm-sm4" },
+    { HWF_ARM_SHA512,          "arm-sha512" },
 #elif defined(HAVE_CPU_ARCH_PPC)
     { HWF_PPC_VCRYPTO,         "ppc-vcrypto" },
     { HWF_PPC_ARCH_3_00,       "ppc-arch_3_00" },
-- 
2.34.1




More information about the Gcrypt-devel mailing list