Skip to content

Commit 0b7e44d

Browse files
uudiinherbertx
authored andcommitted
integrity: Asymmetric digsig supports SM2-with-SM3 algorithm
Asymmetric digsig supports SM2-with-SM3 algorithm combination, so that IMA can also verify SM2's signature data. Signed-off-by: Tianjia Zhang <tianjia.zhang@linux.alibaba.com> Tested-by: Xufeng Zhang <yunbo.xufeng@linux.alibaba.com> Reviewed-by: Mimi Zohar <zohar@linux.ibm.com> Reviewed-by: Vitaly Chikunov <vt@altlinux.org> Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
1 parent 2155256 commit 0b7e44d

1 file changed

Lines changed: 11 additions & 3 deletions

File tree

‎security/integrity/digsig_asymmetric.c‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,14 +99,22 @@ int asymmetric_verify(struct key *keyring, const char *sig,
9999
memset(&pks, 0, sizeof(pks));
100100

101101
pks.hash_algo = hash_algo_name[hdr->hash_algo];
102-
if (hdr->hash_algo == HASH_ALGO_STREEBOG_256 ||
103-
hdr->hash_algo == HASH_ALGO_STREEBOG_512) {
102+
switch (hdr->hash_algo) {
103+
case HASH_ALGO_STREEBOG_256:
104+
case HASH_ALGO_STREEBOG_512:
104105
/* EC-RDSA and Streebog should go together. */
105106
pks.pkey_algo = "ecrdsa";
106107
pks.encoding = "raw";
107-
} else {
108+
break;
109+
case HASH_ALGO_SM3_256:
110+
/* SM2 and SM3 should go together. */
111+
pks.pkey_algo = "sm2";
112+
pks.encoding = "raw";
113+
break;
114+
default:
108115
pks.pkey_algo = "rsa";
109116
pks.encoding = "pkcs1";
117+
break;
110118
}
111119
pks.digest = (u8 *)data;
112120
pks.digest_size = datalen;

0 commit comments

Comments
 (0)