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>
This commit is contained in:
HuaxinLu 2022-06-30 14:36:05 +08:00 committed by Lucas De Marchi
parent edc7f3a2d3
commit f609cb5185
1 changed files with 6 additions and 0 deletions

View 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;
}