]> git.ipfire.org Git - thirdparty/kmod.git/commitdiff
libkmod: Support SM3 hash algorithm
authorHuaxinLu <luhuaxin1@huawei.com>
Thu, 30 Jun 2022 06:36:05 +0000 (14:36 +0800)
committerLucas De Marchi <lucas.de.marchi@gmail.com>
Thu, 30 Jun 2022 14:44:32 +0000 (07:44 -0700)
SM3 has been supported in kernel and cryptographic libraries like openssl.
This patch adds support for the SM3 algorithm of kmod.

Signed-off-by: HuaxinLu <luhuaxin1@huawei.com>
libkmod/libkmod-signature.c

index 4e8748c26c1c8b1b440b9fa48b1420ffa452a5fb..4ae5af63ac22772f769508d179a78ef7fa419db8 100644 (file)
@@ -56,6 +56,7 @@ enum pkey_hash_algo {
        PKEY_HASH_SHA384,
        PKEY_HASH_SHA512,
        PKEY_HASH_SHA224,
+       PKEY_HASH_SM3,
        PKEY_HASH__LAST
 };
 
@@ -68,6 +69,7 @@ const char *const pkey_hash_algo[PKEY_HASH__LAST] = {
        [PKEY_HASH_SHA384]      = "sha384",
        [PKEY_HASH_SHA512]      = "sha512",
        [PKEY_HASH_SHA224]      = "sha224",
+       [PKEY_HASH_SM3]         = "sm3",
 };
 
 enum pkey_id_type {
@@ -161,6 +163,10 @@ static int obj_to_hash_algo(const ASN1_OBJECT *o)
                return PKEY_HASH_SHA512;
        case NID_sha224:
                return PKEY_HASH_SHA224;
+# ifndef OPENSSL_NO_SM3
+       case NID_sm3:
+               return PKEY_HASH_SM3;
+# endif
        default:
                return -1;
        }