Skip to content

Commit

Permalink
integrity: Asymmetric digsig supports SM2-with-SM3 algorithm
Browse files Browse the repository at this point in the history
Asymmetric digsig supports SM2-with-SM3 algorithm combination,
so that IMA can also verify SM2's signature data.

Signed-off-by: Tianjia Zhang <[email protected]>
Tested-by: Xufeng Zhang <[email protected]>
Reviewed-by: Mimi Zohar <[email protected]>
Reviewed-by: Vitaly Chikunov <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
uudiin authored and herbertx committed Sep 25, 2020
1 parent 2155256 commit 0b7e44d
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions security/integrity/digsig_asymmetric.c
Original file line number Diff line number Diff line change
Expand Up @@ -99,14 +99,22 @@ int asymmetric_verify(struct key *keyring, const char *sig,
memset(&pks, 0, sizeof(pks));

pks.hash_algo = hash_algo_name[hdr->hash_algo];
if (hdr->hash_algo == HASH_ALGO_STREEBOG_256 ||
hdr->hash_algo == HASH_ALGO_STREEBOG_512) {
switch (hdr->hash_algo) {
case HASH_ALGO_STREEBOG_256:
case HASH_ALGO_STREEBOG_512:
/* EC-RDSA and Streebog should go together. */
pks.pkey_algo = "ecrdsa";
pks.encoding = "raw";
} else {
break;
case HASH_ALGO_SM3_256:
/* SM2 and SM3 should go together. */
pks.pkey_algo = "sm2";
pks.encoding = "raw";
break;
default:
pks.pkey_algo = "rsa";
pks.encoding = "pkcs1";
break;
}
pks.digest = (u8 *)data;
pks.digest_size = datalen;
Expand Down

0 comments on commit 0b7e44d

Please sign in to comment.