From: Wenkai Lin linwenkai6@hisilicon.com
Currently, the algorithm name of the aead cbc mode is designed only for sha256, but it is not suitable any more when other algorithms are added, such as hmac(sm3)-cbc(aes). Now a common name is used, authenc(generic,cbc(aes)), the actual algorithm and mode are still specified by dalg and dmode in the session setup.
Signed-off-by: Wenkai Lin linwenkai6@hisilicon.com --- drv/hisi_sec.c | 6 +++++- uadk_tool/benchmark/uadk_benchmark.c | 6 +++--- uadk_tool/test/test_sec.c | 4 ++-- wd_aead.c | 4 ++-- wd_util.c | 4 ++-- 5 files changed, 14 insertions(+), 10 deletions(-)
diff --git a/drv/hisi_sec.c b/drv/hisi_sec.c index 9ad2eb2b..473d4b1a 100644 --- a/drv/hisi_sec.c +++ b/drv/hisi_sec.c @@ -661,7 +661,8 @@ static struct wd_alg_driver digest_alg_driver[] = { static struct wd_alg_driver aead_alg_driver[] = { GEN_SEC_ALG_DRIVER("ccm(aes)", aead), GEN_SEC_ALG_DRIVER("gcm(aes)", aead), - GEN_SEC_ALG_DRIVER("authenc(hmac(sha256),cbc(aes))", aead), + GEN_SEC_ALG_DRIVER("authenc(generic,cbc(aes))", aead), + GEN_SEC_ALG_DRIVER("authenc(generic,cbc(sm4))", aead), GEN_SEC_ALG_DRIVER("ccm(sm4)", aead), GEN_SEC_ALG_DRIVER("gcm(sm4)", aead), }; @@ -2755,6 +2756,9 @@ static int fill_aead_bd3_alg(struct wd_aead_msg *msg, case WD_DIGEST_SHA512: d_alg = A_ALG_HMAC_SHA512 << SEC_AUTH_ALG_OFFSET_V3; break; + case WD_DIGEST_SM3: + d_alg = A_ALG_HMAC_SM3 << SEC_AUTH_ALG_OFFSET_V3; + break; default: WD_ERR("failed to check aead dalg type, dalg = %u\n", msg->dalg); diff --git a/uadk_tool/benchmark/uadk_benchmark.c b/uadk_tool/benchmark/uadk_benchmark.c index 0f01fdf5..dd2b22da 100644 --- a/uadk_tool/benchmark/uadk_benchmark.c +++ b/uadk_tool/benchmark/uadk_benchmark.c @@ -139,9 +139,9 @@ static struct acc_alg_item alg_options[] = { {"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}, + {"authenc(generic,cbc(aes))", "aes-128-cbc-sha256-hmac", AES_128_CBC_SHA256_HMAC}, + {"authenc(generic,cbc(aes))", "aes-192-cbc-sha256-hmac", AES_192_CBC_SHA256_HMAC}, + {"authenc(generic,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}, diff --git a/uadk_tool/test/test_sec.c b/uadk_tool/test/test_sec.c index 87fc7184..462ba7a5 100644 --- a/uadk_tool/test/test_sec.c +++ b/uadk_tool/test/test_sec.c @@ -110,10 +110,10 @@ char *digest_names[MAX_ALGO_PER_TYPE] = { char *aead_names[MAX_ALGO_PER_TYPE] = { "ccm(aes)", "gcm(aes)", - "authenc(hmac(sha256),cbc(aes))", + "authenc(generic,cbc(aes))", "ccm(sm4)", "gcm(sm4)", - "authenc(hmac(sha256),cbc(sm4))", + "authenc(generic,cbc(sm4))", "sm3", /*--aead 6: for error alg test */ "authenc(hmac(sha3),cbc(aes))", /* --aead 7: for error alg test */ }; diff --git a/wd_aead.c b/wd_aead.c index 061e768e..11fee5a6 100644 --- a/wd_aead.c +++ b/wd_aead.c @@ -22,9 +22,9 @@ static int g_aead_mac_len[WD_DIGEST_TYPE_MAX] = {
/* These algs's name need correct match with alg/mode type */ static const char *wd_aead_alg_name[WD_CIPHER_ALG_TYPE_MAX][WD_CIPHER_MODE_TYPE_MAX] = { - {"", "authenc(hmac(sha256),cbc(sm4))", "", "", "", "", "", "", "", + {"", "authenc(generic,cbc(sm4))", "", "", "", "", "", "", "", "ccm(sm4)", "gcm(sm4)"}, - {"", "authenc(hmac(sha256),cbc(aes))", "", "", "", "", "", "", "", + {"", "authenc(generic,cbc(aes))", "", "", "", "", "", "", "", "ccm(aes)", "gcm(aes)"} };
diff --git a/wd_util.c b/wd_util.c index b25e79f4..93249a3f 100644 --- a/wd_util.c +++ b/wd_util.c @@ -143,8 +143,8 @@ static struct acc_alg_item alg_options[] = { {"gcm(aes)", "aead"}, {"ccm(sm4)", "aead"}, {"gcm(sm4)", "aead"}, - {"authenc(hmac(sha256),cbc(aes))", "aead"}, - {"authenc(hmac(sha256),cbc(sm4))", "aead"}, + {"authenc(generic,cbc(aes))", "aead"}, + {"authenc(generic,cbc(sm4))", "aead"},
{"sm3", "digest"}, {"md5", "digest"},