Skip to content

Commit

Permalink
crypto: tcrypt - add GCM/CCM mode test for SM4 algorithm
Browse files Browse the repository at this point in the history
tcrypt supports GCM/CCM mode, CMAC, CBCMAC, and speed test of
SM4 algorithm.

Signed-off-by: Tianjia Zhang <[email protected]>
Signed-off-by: Herbert Xu <[email protected]>
  • Loading branch information
uudiin authored and herbertx committed Aug 21, 2021
1 parent 68039d6 commit 357a753
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions crypto/tcrypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1916,6 +1916,14 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
ret += tcrypt_test("streebog512");
break;

case 55:
ret += tcrypt_test("gcm(sm4)");
break;

case 56:
ret += tcrypt_test("ccm(sm4)");
break;

case 100:
ret += tcrypt_test("hmac(md5)");
break;
Expand Down Expand Up @@ -2007,6 +2015,15 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
case 157:
ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
break;

case 158:
ret += tcrypt_test("cbcmac(sm4)");
break;

case 159:
ret += tcrypt_test("cmac(sm4)");
break;

case 181:
ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
break;
Expand Down Expand Up @@ -2336,6 +2353,34 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
NULL, 0, 16, 8, speed_template_16);
break;

case 222:
test_aead_speed("gcm(sm4)", ENCRYPT, sec,
NULL, 0, 16, 8, speed_template_16);
test_aead_speed("gcm(sm4)", DECRYPT, sec,
NULL, 0, 16, 8, speed_template_16);
break;

case 223:
test_aead_speed("rfc4309(ccm(sm4))", ENCRYPT, sec,
NULL, 0, 16, 16, aead_speed_template_19);
test_aead_speed("rfc4309(ccm(sm4))", DECRYPT, sec,
NULL, 0, 16, 16, aead_speed_template_19);
break;

case 224:
test_mb_aead_speed("gcm(sm4)", ENCRYPT, sec, NULL, 0, 16, 8,
speed_template_16, num_mb);
test_mb_aead_speed("gcm(sm4)", DECRYPT, sec, NULL, 0, 16, 8,
speed_template_16, num_mb);
break;

case 225:
test_mb_aead_speed("rfc4309(ccm(sm4))", ENCRYPT, sec, NULL, 0,
16, 16, aead_speed_template_19, num_mb);
test_mb_aead_speed("rfc4309(ccm(sm4))", DECRYPT, sec, NULL, 0,
16, 16, aead_speed_template_19, num_mb);
break;

case 300:
if (alg) {
test_hash_speed(alg, sec, generic_hash_speed_template);
Expand Down

0 comments on commit 357a753

Please sign in to comment.