Skip to content

Commit

Permalink
libkmod: Support SM3 hash algorithm
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
HuaxinLu authored and lucasdemarchi committed Jun 30, 2022
1 parent edc7f3a commit f609cb5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions libkmod/libkmod-signature.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ enum pkey_hash_algo {
PKEY_HASH_SHA384,
PKEY_HASH_SHA512,
PKEY_HASH_SHA224,
PKEY_HASH_SM3,
PKEY_HASH__LAST
};

Expand All @@ -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 {
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit f609cb5

Please sign in to comment.