add support for sm3 hash algorithm

This commit is contained in:
Huaxin Lu 2022-11-11 17:35:13 +08:00
parent 726bb8031b
commit 7797be8e85
2 changed files with 53 additions and 1 deletions

View File

@ -0,0 +1,48 @@
From f609cb5185acb0955d66795cb297e9fe9d83405a Mon Sep 17 00:00:00 2001
From: HuaxinLu <luhuaxin1@huawei.com>
Date: Thu, 30 Jun 2022 14:36:05 +0800
Subject: [PATCH] libkmod: Support SM3 hash algorithm
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>
Signed-off-by: HuaxinLu <luhuaxin1@huawei.com>
---
libkmod/libkmod-signature.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/libkmod/libkmod-signature.c b/libkmod/libkmod-signature.c
index 4e8748c..4ae5af6 100644
--- a/libkmod/libkmod-signature.c
+++ b/libkmod/libkmod-signature.c
@@ -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;
}
--
2.33.0

View File

@ -1,6 +1,6 @@
Name: kmod
Version: 29
Release: 4
Release: 5
Summary: Kernel module management
# GPLv2+ is used by programs, LGPLv2+ is used for libraries.
License: GPLv2+ and LGPLv2+
@ -13,6 +13,7 @@ Patch1: 0001-libkmod-module-check-new_from_name-return-value-in-g.patch
Patch2: 0002-Module-replace-the-module-with-new-module.patch
Patch3: 0003-Module-suspend-the-module-by-rmmod-r-option.patch
Patch4: 0004-don-t-check-module-s-refcnt-when-rmmod-with-r.patch
Patch5: backport-libkmod-Support-SM3-hash-algorithm.patch
BuildRequires: gcc chrpath zlib-devel xz-devel libxslt openssl-devel
@ -120,6 +121,9 @@ install -m 0644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/depmod.d/dist.conf
%doc TODO NEWS README
%changelog
* Fri Nov 18 2022 luhuaxin <luhuaxin1@huawei.com> - 29-5
- add support for sm3 hash algorithm.
* Thu Feb 24 2022 Yang Yanchao <yangyanchao6@huawei.com> - 29-4
- add package python3-kmod.