From: Chenghai Huang huangchenghai2@huawei.com
The alg options and alg name structure are duplicated and combined into one.
Signed-off-by: Chenghai Huang huangchenghai2@huawei.com --- uadk_tool/benchmark/uadk_benchmark.c | 276 +++++++++------------------ 1 file changed, 92 insertions(+), 184 deletions(-)
diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index 1262a2a..1bf9fee 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -60,195 +60,103 @@ static struct acc_sva_item sys_name_item[] = { };
struct acc_alg_item { + char *type; char *name; int alg; };
static struct acc_alg_item alg_options[] = { - {"zlib", ZLIB}, - {"gzip", GZIP}, - {"deflate", DEFLATE}, - {"lz77_zstd", LZ77_ZSTD}, - {"rsa-1024", RSA_1024}, - {"rsa-2048", RSA_2048}, - {"rsa-3072", RSA_3072}, - {"rsa-4096", RSA_4096}, - {"rsa-1024-crt", RSA_1024_CRT}, - {"rsa-2048-crt", RSA_2048_CRT}, - {"rsa-3072-crt", RSA_3072_CRT}, - {"rsa-4096-crt", RSA_4096_CRT}, - {"dh-768", DH_768}, - {"dh-1024", DH_1024}, - {"dh-1536", DH_1536}, - {"dh-2048", DH_2048}, - {"dh-3072", DH_3072}, - {"dh-4096", DH_4096}, - {"ecdh-256", ECDH_256}, - {"ecdh-384", ECDH_384}, - {"ecdh-521", ECDH_521}, - {"ecdsa-256", ECDSA_256}, - {"ecdsa-384", ECDSA_384}, - {"ecdsa-521", ECDSA_521}, - {"sm2", SM2_ALG}, - {"x25519", X25519_ALG}, - {"x448", X448_ALG}, - {"aes-128-ecb", AES_128_ECB}, - {"aes-192-ecb", AES_192_ECB}, - {"aes-256-ecb", AES_256_ECB}, - {"aes-128-cbc", AES_128_CBC}, - {"aes-192-cbc", AES_192_CBC}, - {"aes-256-cbc", AES_256_CBC}, - {"aes-128-cbc-cs1", AES_128_CBC_CS1}, - {"aes-128-cbc-cs2", AES_128_CBC_CS2}, - {"aes-128-cbc-cs3", AES_128_CBC_CS3}, - {"aes-192-cbc-cs1", AES_192_CBC_CS1}, - {"aes-192-cbc-cs2", AES_192_CBC_CS2}, - {"aes-192-cbc-cs3", AES_192_CBC_CS3}, - {"aes-256-cbc-cs1", AES_256_CBC_CS1}, - {"aes-256-cbc-cs2", AES_256_CBC_CS2}, - {"aes-256-cbc-cs3", AES_256_CBC_CS3}, - {"aes-128-ctr", AES_128_CTR}, - {"aes-192-ctr", AES_192_CTR}, - {"aes-256-ctr", AES_256_CTR}, - {"aes-128-ofb", AES_128_OFB}, - {"aes-192-ofb", AES_192_OFB}, - {"aes-256-ofb", AES_256_OFB}, - {"aes-128-cfb", AES_128_CFB}, - {"aes-192-cfb", AES_192_CFB}, - {"aes-256-cfb", AES_256_CFB}, - {"aes-256-xts", AES_256_XTS}, - {"aes-512-xts", AES_512_XTS}, - {"3des-128-ecb", DES3_128_ECB}, - {"3des-192-ecb", DES3_192_ECB}, - {"3des-128-cbc", DES3_128_CBC}, - {"3des-192-cbc", DES3_192_CBC}, - {"sm4-128-ecb", SM4_128_ECB}, - {"sm4-128-cbc", SM4_128_CBC}, - {"sm4-128-cbc-cs1", SM4_128_CBC_CS1}, - {"sm4-128-cbc-cs2", SM4_128_CBC_CS2}, - {"sm4-128-cbc-cs3", SM4_128_CBC_CS3}, - {"sm4-128-ctr", SM4_128_CTR}, - {"sm4-128-ofb", SM4_128_OFB}, - {"sm4-128-cfb", SM4_128_CFB}, - {"sm4-128-xts", SM4_128_XTS}, - {"sm4-128-xts-gb", SM4_128_XTS_GB}, - {"aes-128-ccm", AES_128_CCM}, - {"aes-192-ccm", AES_192_CCM}, - {"aes-256-ccm", AES_256_CCM}, - {"aes-128-gcm", AES_128_GCM}, - {"aes-192-gcm", AES_192_GCM}, - {"aes-256-gcm", AES_256_GCM}, - {"aes-128-cbc-sha256-hmac", AES_128_CBC_SHA256_HMAC}, - {"aes-192-cbc-sha256-hmac", AES_192_CBC_SHA256_HMAC}, - {"aes-256-cbc-sha256-hmac", AES_256_CBC_SHA256_HMAC}, - {"sm4-128-ccm", SM4_128_CCM}, - {"sm4-128-gcm", SM4_128_GCM}, - {"sm3", SM3_ALG}, - {"md5", MD5_ALG}, - {"sha1", SHA1_ALG}, - {"sha256", SHA256_ALG}, - {"sha224", SHA224_ALG}, - {"sha384", SHA384_ALG}, - {"sha512", SHA512_ALG}, - {"sha512-224", SHA512_224}, - {"sha512-256", SHA512_256}, - {"trng", TRNG}, - {"", ALG_MAX} + {"zlib", "zlib", ZLIB}, + {"gzip", "gzip", GZIP}, + {"deflate", "deflate", DEFLATE}, + {"lz77_zstd", "lz77_zstd", LZ77_ZSTD}, + {"rsa", "rsa-1024", RSA_1024}, + {"rsa", "rsa-2048", RSA_2048}, + {"rsa", "rsa-3072", RSA_3072}, + {"rsa", "rsa-4096", RSA_4096}, + {"rsa", "rsa-1024-crt", RSA_1024_CRT}, + {"rsa", "rsa-2048-crt", RSA_2048_CRT}, + {"rsa", "rsa-3072-crt", RSA_3072_CRT}, + {"rsa", "rsa-4096-crt", RSA_4096_CRT}, + {"dh", "dh-768", DH_768}, + {"dh", "dh-1024", DH_1024}, + {"dh", "dh-1536", DH_1536}, + {"dh", "dh-2048", DH_2048}, + {"dh", "dh-3072", DH_3072}, + {"dh", "dh-4096", DH_4096}, + {"ecdh", "ecdh-256", ECDH_256}, + {"ecdh", "ecdh-384", ECDH_384}, + {"ecdh", "ecdh-521", ECDH_521}, + {"ecdsa", "ecdsa-256", ECDSA_256}, + {"ecdsa", "ecdsa-384", ECDSA_384}, + {"ecdsa", "ecdsa-521", ECDSA_521}, + {"sm2", "sm2", SM2_ALG}, + {"x25519", "x25519", X25519_ALG}, + {"x448", "x448", X448_ALG}, + {"ecb(aes)", "aes-128-ecb", AES_128_ECB}, + {"ecb(aes)", "aes-192-ecb", AES_192_ECB}, + {"ecb(aes)", "aes-256-ecb", AES_256_ECB}, + {"cbc(aes)", "aes-128-cbc", AES_128_CBC}, + {"cbc(aes)", "aes-192-cbc", AES_192_CBC}, + {"cbc(aes)", "aes-256-cbc", AES_256_CBC}, + {"cbc-cs1(aes)", "aes-128-cbc-cs1", AES_128_CBC_CS1}, + {"cbc-cs2(aes)", "aes-128-cbc-cs2", AES_128_CBC_CS2}, + {"cbc-cs3(aes)", "aes-128-cbc-cs3", AES_128_CBC_CS3}, + {"cbc-cs1(aes)", "aes-192-cbc-cs1", AES_192_CBC_CS1}, + {"cbc-cs2(aes)", "aes-192-cbc-cs2", AES_192_CBC_CS2}, + {"cbc-cs3(aes)", "aes-192-cbc-cs3", AES_192_CBC_CS3}, + {"cbc-cs1(aes)", "aes-256-cbc-cs1", AES_256_CBC_CS1}, + {"cbc-cs2(aes)", "aes-256-cbc-cs2", AES_256_CBC_CS2}, + {"cbc-cs3(aes)", "aes-256-cbc-cs3", AES_256_CBC_CS3}, + {"ctr(aes)", "aes-128-ctr", AES_128_CTR}, + {"ctr(aes)", "aes-192-ctr", AES_192_CTR}, + {"ctr(aes)", "aes-256-ctr", AES_256_CTR}, + {"ofb(aes)", "aes-128-ofb", AES_128_OFB}, + {"ofb(aes)", "aes-192-ofb", AES_192_OFB}, + {"ofb(aes)", "aes-256-ofb", AES_256_OFB}, + {"cfb(aes)", "aes-128-cfb", AES_128_CFB}, + {"cfb(aes)", "aes-192-cfb", AES_192_CFB}, + {"cfb(aes)", "aes-256-cfb", AES_256_CFB}, + {"xts(aes)", "aes-256-xts", AES_256_XTS}, + {"xts(aes)", "aes-512-xts", AES_512_XTS}, + {"ecb(des3_ede)", "3des-128-ecb", DES3_128_ECB}, + {"ecb(des3_ede)", "3des-192-ecb", DES3_192_ECB}, + {"cbc(des3_ede)", "3des-128-cbc", DES3_128_CBC}, + {"cbc(des3_ede)", "3des-192-cbc", DES3_192_CBC}, + {"ecb(sm4)", "sm4-128-ecb", SM4_128_ECB}, + {"cbc(sm4)", "sm4-128-cbc", SM4_128_CBC}, + {"cbc-cs1(sm4)", "sm4-128-cbc-cs1", SM4_128_CBC_CS1}, + {"cbc-cs2(sm4)", "sm4-128-cbc-cs2", SM4_128_CBC_CS2}, + {"cbc-cs3(sm4)", "sm4-128-cbc-cs3", SM4_128_CBC_CS3}, + {"ctr(sm4)", "sm4-128-ctr", SM4_128_CTR}, + {"ofb(sm4)", "sm4-128-ofb", SM4_128_OFB}, + {"cfb(sm4)", "sm4-128-cfb", SM4_128_CFB}, + {"xts(sm4)", "sm4-128-xts", SM4_128_XTS}, + {"xts(sm4)", "sm4-128-xts-gb", SM4_128_XTS_GB}, + {"ccm(aes)", "aes-128-ccm", AES_128_CCM}, + {"ccm(aes)", "aes-192-ccm", AES_192_CCM}, + {"ccm(aes)", "aes-256-ccm", AES_256_CCM}, + {"gcm(aes)", "aes-128-gcm", AES_128_GCM}, + {"gcm(aes)", "aes-192-gcm", AES_192_GCM}, + {"gcm(aes)", "aes-256-gcm", AES_256_GCM}, + {"authenc(hmac(sha256),cbc(aes))", "aes-128-cbc-sha256-hmac", AES_128_CBC_SHA256_HMAC}, + {"authenc(hmac(sha256),cbc(aes))", "aes-192-cbc-sha256-hmac", AES_192_CBC_SHA256_HMAC}, + {"authenc(hmac(sha256),cbc(aes))", "aes-256-cbc-sha256-hmac", AES_256_CBC_SHA256_HMAC}, + {"ccm(sm4)", "sm4-128-ccm", SM4_128_CCM}, + {"gcm(sm4)", "sm4-128-gcm", SM4_128_GCM}, + {"sm3", "sm3", SM3_ALG}, + {"md5", "md5", MD5_ALG}, + {"sha1", "sha1", SHA1_ALG}, + {"sha256", "sha256", SHA256_ALG}, + {"sha224", "sha224", SHA224_ALG}, + {"sha384", "sha384", SHA384_ALG}, + {"sha512", "sha512", SHA512_ALG}, + {"sha512-224", "sha512-224", SHA512_224}, + {"sha512-256", "sha512-256", SHA512_256}, + {"trng", "trng", TRNG}, + {"", "", ALG_MAX} };
-static struct acc_alg_item alg_name_options[] = { - {"zlib", ZLIB}, - {"gzip", GZIP}, - {"deflate", DEFLATE}, - {"lz77_zstd", LZ77_ZSTD}, - {"rsa", RSA_1024}, - {"rsa", RSA_2048}, - {"rsa", RSA_3072}, - {"rsa", RSA_4096}, - {"rsa", RSA_1024_CRT}, - {"rsa", RSA_2048_CRT}, - {"rsa", RSA_3072_CRT}, - {"rsa", RSA_4096_CRT}, - {"dh", DH_768}, - {"dh", DH_1024}, - {"dh", DH_1536}, - {"dh", DH_2048}, - {"dh", DH_3072}, - {"dh", DH_4096}, - {"ecdh", ECDH_256}, - {"ecdh", ECDH_384}, - {"ecdh", ECDH_521}, - {"ecdsa", ECDSA_256}, - {"ecdsa", ECDSA_384}, - {"ecdsa", ECDSA_521}, - {"sm2", SM2_ALG}, - {"x25519", X25519_ALG}, - {"x448", X448_ALG}, - {"ecb(aes)", AES_128_ECB}, - {"ecb(aes)", AES_192_ECB}, - {"ecb(aes)", AES_256_ECB}, - {"cbc(aes)", AES_128_CBC}, - {"cbc(aes)", AES_192_CBC}, - {"cbc(aes)", AES_256_CBC}, - {"cbc-cs1(aes)", AES_128_CBC_CS1}, - {"cbc-cs2(aes)", AES_128_CBC_CS2}, - {"cbc-cs3(aes)", AES_128_CBC_CS3}, - {"cbc-cs1(aes)", AES_192_CBC_CS1}, - {"cbc-cs2(aes)", AES_192_CBC_CS2}, - {"cbc-cs3(aes)", AES_192_CBC_CS3}, - {"cbc-cs1(aes)", AES_256_CBC_CS1}, - {"cbc-cs2(aes)", AES_256_CBC_CS2}, - {"cbc-cs3(aes)", AES_256_CBC_CS3}, - {"ctr(aes)", AES_128_CTR}, - {"ctr(aes)", AES_192_CTR}, - {"ctr(aes)", AES_256_CTR}, - {"ofb(aes)", AES_128_OFB}, - {"ofb(aes)", AES_192_OFB}, - {"ofb(aes)", AES_256_OFB}, - {"cfb(aes)", AES_128_CFB}, - {"cfb(aes)", AES_192_CFB}, - {"cfb(aes)", AES_256_CFB}, - {"xts(aes)", AES_256_XTS}, - {"xts(aes)", AES_512_XTS}, - {"ecb(des3_ede)", DES3_128_ECB}, - {"ecb(des3_ede)", DES3_192_ECB}, - {"cbc(des3_ede)", DES3_128_CBC}, - {"cbc(des3_ede)", DES3_192_CBC}, - {"ecb(sm4)", SM4_128_ECB}, - {"cbc(sm4)", SM4_128_CBC}, - {"cbc-cs1(sm4)", SM4_128_CBC_CS1}, - {"cbc-cs2(sm4)", SM4_128_CBC_CS2}, - {"cbc-cs3(sm4)", SM4_128_CBC_CS3}, - {"ctr(sm4)", SM4_128_CTR}, - {"ofb(sm4)", SM4_128_OFB}, - {"cfb(sm4)", SM4_128_CFB}, - {"xts(sm4)", SM4_128_XTS}, - {"xts(sm4)", SM4_128_XTS_GB}, - {"ccm(aes)", AES_128_CCM}, - {"ccm(aes)", AES_192_CCM}, - {"ccm(aes)", AES_256_CCM}, - {"gcm(aes)", AES_128_GCM}, - {"gcm(aes)", AES_192_GCM}, - {"gcm(aes)", AES_256_GCM}, - {"authenc(hmac(sha256),cbc(aes))", AES_128_CBC_SHA256_HMAC}, - {"authenc(hmac(sha256),cbc(aes))", AES_192_CBC_SHA256_HMAC}, - {"authenc(hmac(sha256),cbc(aes))", AES_256_CBC_SHA256_HMAC}, - {"ccm(sm4)", SM4_128_CCM}, - {"gcm(sm4)", SM4_128_GCM}, - {"sm3", SM3_ALG}, - {"md5", MD5_ALG}, - {"sha1", SHA1_ALG}, - {"sha256", SHA256_ALG}, - {"sha224", SHA224_ALG}, - {"sha384", SHA384_ALG}, - {"sha512", SHA512_ALG}, - {"sha512-224", SHA512_224}, - {"sha512-256", SHA512_256}, - {"trng", TRNG}, - {"", ALG_MAX} -}; - - /*-------------------------------------tool code------------------------------------------------------*/ void add_send_complete(void) { @@ -311,8 +219,8 @@ int get_alg_name(int alg, char *alg_name) int i;
for (i = 0; i < ALG_MAX; i++) { - if (alg == alg_name_options[i].alg) { - strcpy(alg_name, alg_name_options[i].name); + if (alg == alg_options[i].alg) { + strcpy(alg_name, alg_options[i].type); return 0; } }