提交 dd4bf0f9 编写于 作者: 沈子俊 提交者: Zheng Zengkai

crypto: tcrypt - add GCM/CCM mode test for SM4 algorithm

mainline inclusion
from mainline-v5.15-rc1
commit 357a753f
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I4A82T?from=project-issue
CVE: NA

---------------------------------------------------

tcrypt supports GCM/CCM mode, CMAC, CBCMAC, and speed test of
SM4 algorithm.
Signed-off-by: NTianjia Zhang <tianjia.zhang@linux.alibaba.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Signed-off-by: N沈子俊 <shenzijun@kylinos.cn>
Reviewed-by: Nweiyang wang <wangweiyang2@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 2c424313
...@@ -1929,6 +1929,14 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) ...@@ -1929,6 +1929,14 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
case 54: case 54:
ret += tcrypt_test("streebog512"); ret += tcrypt_test("streebog512");
break; break;
case 55:
ret += tcrypt_test("gcm(sm4)");
break;
case 56:
ret += tcrypt_test("ccm(sm4)");
break;
case 100: case 100:
ret += tcrypt_test("hmac(md5)"); ret += tcrypt_test("hmac(md5)");
...@@ -2025,6 +2033,15 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) ...@@ -2025,6 +2033,15 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
case 157: case 157:
ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))"); ret += tcrypt_test("authenc(hmac(sha1),ecb(cipher_null))");
break; break;
case 158:
ret += tcrypt_test("cbcmac(sm4)");
break;
case 159:
ret += tcrypt_test("cmac(sm4)");
break;
case 181: case 181:
ret += tcrypt_test("authenc(hmac(sha1),cbc(des))"); ret += tcrypt_test("authenc(hmac(sha1),cbc(des))");
break; break;
...@@ -2354,6 +2371,34 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb) ...@@ -2354,6 +2371,34 @@ static int do_test(const char *alg, u32 type, u32 mask, int m, u32 num_mb)
NULL, 0, 16, 8, speed_template_16); NULL, 0, 16, 8, speed_template_16);
break; 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: case 300:
if (alg) { if (alg) {
test_hash_speed(alg, sec, generic_hash_speed_template); test_hash_speed(alg, sec, generic_hash_speed_template);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册