All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
@ 2023-03-16  3:10 Sunyang Wu
  2023-03-16  3:10 ` [PATCH 2/2] test/crypto: Add SM3/SM4 test vectors for verification in test app Sunyang Wu
                   ` (2 more replies)
  0 siblings, 3 replies; 12+ messages in thread
From: Sunyang Wu @ 2023-03-16  3:10 UTC (permalink / raw)
  To: dev; +Cc: kai.ji, gakhil

Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.

Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
---
 lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h
index 2cfe66530c..c4572106dc 100644
--- a/lib/cryptodev/rte_crypto_sym.h
+++ b/lib/cryptodev/rte_crypto_sym.h
@@ -172,8 +172,12 @@ enum rte_crypto_cipher_algorithm {
 	/**< ShangMi 4 (SM4) algorithm in ECB mode */
 	RTE_CRYPTO_CIPHER_SM4_CBC,
 	/**< ShangMi 4 (SM4) algorithm in CBC mode */
-	RTE_CRYPTO_CIPHER_SM4_CTR
+	RTE_CRYPTO_CIPHER_SM4_CTR,
 	/**< ShangMi 4 (SM4) algorithm in CTR mode */
+	RTE_CRYPTO_CIPHER_SM4_OFB,
+	/**< ShangMi 4 (SM4) algorithm in OFB mode */
+	RTE_CRYPTO_CIPHER_SM4_CFB
+	/**< ShangMi 4 (SM4) algorithm in CFB mode */
 };
 
 /** Cipher algorithm name strings */
@@ -376,6 +380,8 @@ enum rte_crypto_auth_algorithm {
 	/**< HMAC using 512 bit SHA3 algorithm. */
 	RTE_CRYPTO_AUTH_SM3,
 	/**< ShangMi 3 (SM3) algorithm */
+	RTE_CRYPTO_AUTH_SM3_HMAC,
+	/** < HMAC using Chinese SM3 algorithm */
 
 	RTE_CRYPTO_AUTH_SHAKE_128,
 	/**< 128 bit SHAKE algorithm. */
-- 
2.19.0.rc0.windows.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* [PATCH 2/2] test/crypto: Add SM3/SM4 test vectors for verification in test app
  2023-03-16  3:10 [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Sunyang Wu
@ 2023-03-16  3:10 ` Sunyang Wu
  2023-03-16 10:42 ` [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Akhil Goyal
  2023-05-17  7:04 ` Akhil Goyal
  2 siblings, 0 replies; 12+ messages in thread
From: Sunyang Wu @ 2023-03-16  3:10 UTC (permalink / raw)
  To: dev; +Cc: kai.ji, gakhil

Add SM3/SM4 test vectors for verification in test app.

Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>

---
The test results of using openssl are as follows:
 + SM4 Chain : 24/24 passed, 0/24 skipped, 0/24 failed, 0/24 unsupported
 + SM4 Cipher Only : 10/10 passed, 0/10 skipped, 0/10 failed, 0/10 unsupported
 + Auth Only : 36/62 passed, 26/62 skipped, 0/62 failed, 0/62 unsupported
---
 app/test/test_cryptodev.c                   |   3 +
 app/test/test_cryptodev_blockcipher.c       |  81 +++
 app/test/test_cryptodev_blockcipher.h       |   4 +-
 app/test/test_cryptodev_hash_test_vectors.h |  82 +++
 app/test/test_cryptodev_sm4_test_vectors.h  | 710 ++++++++++++++++++++
 5 files changed, 879 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_cryptodev_sm4_test_vectors.h

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index aa831d79a2..abc2bc30f5 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -44,6 +44,7 @@
 #include "test_cryptodev_aead_test_vectors.h"
 #include "test_cryptodev_hmac_test_vectors.h"
 #include "test_cryptodev_mixed_test_vectors.h"
+#include "test_cryptodev_sm4_test_vectors.h"
 #ifdef RTE_LIB_SECURITY
 #include "test_cryptodev_security_ipsec.h"
 #include "test_cryptodev_security_ipsec_test_vectors.h"
@@ -16803,6 +16804,8 @@ run_cryptodev_testsuite(const char *pmd_name)
 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
 		BLKCIPHER_DES_CIPHERONLY_TYPE,
 		BLKCIPHER_DES_DOCSIS_TYPE,
+		BLKCIPHER_SM4_CHAIN_TYPE,
+		BLKCIPHER_SM4_CIPHERONLY_TYPE,
 		BLKCIPHER_AUTHONLY_TYPE};
 	struct unit_test_suite *static_suites[] = {
 		&cryptodev_multi_session_testsuite,
diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c
index 6c9a5964ea..341cf1a54b 100644
--- a/app/test/test_cryptodev_blockcipher.c
+++ b/app/test/test_cryptodev_blockcipher.c
@@ -18,6 +18,7 @@
 #include "test_cryptodev_aes_test_vectors.h"
 #include "test_cryptodev_des_test_vectors.h"
 #include "test_cryptodev_hash_test_vectors.h"
+#include "test_cryptodev_sm4_test_vectors.h"
 
 static int
 verify_algo_support(const struct blockcipher_test_case *t,
@@ -1119,6 +1120,74 @@ authonly_setup(void)
 	return 0;
 }
 
+static int
+sm4_chain_setup(void)
+{
+	uint8_t dev_id = p_testsuite_params->valid_devs[0];
+	struct rte_cryptodev_info dev_info;
+	uint64_t feat_flags;
+	const enum rte_crypto_cipher_algorithm ciphers[] = {
+		RTE_CRYPTO_CIPHER_SM4_CTR,
+		RTE_CRYPTO_CIPHER_SM4_CBC,
+		RTE_CRYPTO_CIPHER_SM4_OFB,
+		RTE_CRYPTO_CIPHER_SM4_CFB
+	};
+	const enum rte_crypto_auth_algorithm auths[] = {
+		RTE_CRYPTO_AUTH_SM3,
+		RTE_CRYPTO_AUTH_SM3_HMAC,
+	};
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	feat_flags = dev_info.feature_flags;
+
+	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
+	    (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
+	    !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
+		RTE_LOG(INFO, USER1, "Feature flag for SM4 Chain testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0 &&
+	    check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
+		RTE_LOG(INFO, USER1, "Capability for SM4 Chain testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	return 0;
+}
+
+static int
+sm4_cipheronly_setup(void)
+{
+	uint8_t dev_id = p_testsuite_params->valid_devs[0];
+	struct rte_cryptodev_info dev_info;
+	uint64_t feat_flags;
+	const enum rte_crypto_cipher_algorithm ciphers[] = {
+		RTE_CRYPTO_CIPHER_SM4_CBC,
+		RTE_CRYPTO_CIPHER_SM4_ECB,
+		RTE_CRYPTO_CIPHER_SM4_CTR,
+		RTE_CRYPTO_CIPHER_SM4_OFB,
+		RTE_CRYPTO_CIPHER_SM4_CFB
+	};
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	feat_flags = dev_info.feature_flags;
+
+	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
+	    (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
+	    !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
+		RTE_LOG(INFO, USER1, "Feature flag for SM4 Cipheronly not met\n");
+		return TEST_SKIPPED;
+	}
+
+	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
+		RTE_LOG(INFO, USER1, "Capability for SM4 Cipheronly not met\n");
+		return TEST_SKIPPED;
+	}
+
+	return 0;
+}
+
 struct unit_test_suite *
 build_blockcipher_test_suite(enum blockcipher_test_type test_type)
 {
@@ -1172,6 +1241,18 @@ build_blockcipher_test_suite(enum blockcipher_test_type test_type)
 		ts_name = "DES Docsis";
 		ts_setup = des_docsis_setup;
 		break;
+	case BLKCIPHER_SM4_CHAIN_TYPE:
+		n_test_cases = RTE_DIM(sm4_chain_test_cases);
+		blk_tcs = sm4_chain_test_cases;
+		ts_name = "SM4 Chain";
+		ts_setup = sm4_chain_setup;
+		break;
+	case BLKCIPHER_SM4_CIPHERONLY_TYPE:
+		n_test_cases = RTE_DIM(sm4_cipheronly_test_cases);
+		blk_tcs = sm4_cipheronly_test_cases;
+		ts_name = "SM4 Cipher Only";
+		ts_setup = sm4_cipheronly_setup;
+		break;
 	case BLKCIPHER_AUTHONLY_TYPE:
 		n_test_cases = RTE_DIM(hash_test_cases);
 		blk_tcs = hash_test_cases;
diff --git a/app/test/test_cryptodev_blockcipher.h b/app/test/test_cryptodev_blockcipher.h
index bad93a5ec1..e6f6c18067 100644
--- a/app/test/test_cryptodev_blockcipher.h
+++ b/app/test/test_cryptodev_blockcipher.h
@@ -49,7 +49,9 @@ enum blockcipher_test_type {
 	BLKCIPHER_3DES_CIPHERONLY_TYPE,	/* triple_des_cipheronly_test_cases[] */
 	BLKCIPHER_AUTHONLY_TYPE,	/* use hash_test_cases[] */
 	BLKCIPHER_DES_CIPHERONLY_TYPE,	/* use des_cipheronly_test_cases[] */
-	BLKCIPHER_DES_DOCSIS_TYPE	/* use des_docsis_test_cases[] */
+	BLKCIPHER_DES_DOCSIS_TYPE,	/* use des_docsis_test_cases[] */
+	BLKCIPHER_SM4_CHAIN_TYPE,	/* use sm4_chain_test_cases[] */
+	BLKCIPHER_SM4_CIPHERONLY_TYPE	/* use sm4_cipheronly_test_cases[] */
 };
 
 struct blockcipher_test_case {
diff --git a/app/test/test_cryptodev_hash_test_vectors.h b/app/test/test_cryptodev_hash_test_vectors.h
index fa9986a4da..65dd6bf81b 100644
--- a/app/test/test_cryptodev_hash_test_vectors.h
+++ b/app/test/test_cryptodev_hash_test_vectors.h
@@ -682,6 +682,56 @@ cmac_test_vector_12 = {
 	}
 };
 
+static const struct blockcipher_test_data
+sm3_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SM3,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.digest = {
+		.data =  {
+			0x9E, 0x86, 0xAB, 0x68, 0xD7, 0x8F, 0xD6, 0xFF,
+			0x1C, 0x57, 0x12, 0x48, 0xC4, 0xA8, 0x26, 0xDE,
+			0x9E, 0x53, 0xE9, 0xC4, 0xA6, 0xBB, 0xE7, 0x52,
+			0x53, 0x9C, 0xDE, 0xC1, 0xD5, 0x7C, 0x43, 0xAB
+		},
+		.len = 32
+	}
+};
+
+static const struct blockcipher_test_data
+hmac_sm3_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.auth_key = {
+		.data = {
+			0x12, 0x70, 0x87, 0xd9, 0x76, 0x9e, 0xe0, 0xf0,
+			0x14, 0xfb, 0xca, 0x5a, 0xb6, 0xcb, 0x8f, 0x9d,
+			0x42, 0xd3, 0x1e, 0x09, 0x9a, 0x25, 0x9a, 0x3c,
+			0x87, 0xee, 0x55, 0x63, 0x56, 0x33, 0x75, 0x69,
+			0xa3, 0xfc, 0x42, 0x19, 0x9a, 0x22, 0x09, 0xae,
+			0x1d, 0xd3, 0x09, 0xd3, 0x9e, 0x98, 0x71, 0xe1,
+			0x6b, 0x8f, 0xea, 0x05, 0xb4, 0x85, 0x41, 0x3b,
+			0x73, 0x97, 0x9e, 0xc9, 0xca, 0x13, 0x32, 0x6d
+		},
+		.len = 64
+	},
+	.digest = {
+		.data = {
+			0xBC, 0x71, 0xF5, 0x3B, 0x43, 0x28, 0x11, 0x7A,
+			0x32, 0xD2, 0xC9, 0x2D, 0x3B, 0xFA, 0xE0, 0x47,
+			0xA4, 0xD5, 0xEC, 0x81, 0xFB, 0x86, 0x6A, 0x11,
+			0x64, 0xF3, 0xF5, 0x82, 0x3B, 0x8E, 0x0A, 0xBB
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
 static const struct blockcipher_test_case hash_test_cases[] = {
 	{
 		.test_descr = "MD5 Digest",
@@ -971,6 +1021,38 @@ static const struct blockcipher_test_case hash_test_cases[] = {
 		.test_data = &aes_xcbc_mac_test_vector,
 		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
 	},
+	{
+		.test_descr = "SM3 Digest",
+		.test_data = &sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM3 Digest Verify",
+		.test_data = &sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest Scatter Gather",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest Verify",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest Verify Scatter Gather",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
 
 };
 
diff --git a/app/test/test_cryptodev_sm4_test_vectors.h b/app/test/test_cryptodev_sm4_test_vectors.h
new file mode 100644
index 0000000000..582b333296
--- /dev/null
+++ b/app/test/test_cryptodev_sm4_test_vectors.h
@@ -0,0 +1,710 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2019 Intel Corporation
+ */
+
+#ifndef TEST_CRYPTODEV_SM4_TEST_VECTORS_H_
+#define TEST_CRYPTODEV_SM4_TEST_VECTORS_H_
+
+static const uint8_t plaintext_sm4[] = {
+	0x81, 0x70, 0x99, 0x44, 0xE0, 0xCB, 0x2E, 0x1D,
+	0xB5, 0xB0, 0xA4, 0x77, 0xD1, 0xA8, 0x53, 0x9B,
+	0x0A, 0x87, 0x86, 0xE3, 0x4E, 0xAA, 0xED, 0x99,
+	0x30, 0x3E, 0xA6, 0x97, 0x55, 0x95, 0xB2, 0x45,
+	0x4D, 0x5D, 0x7F, 0x91, 0xEB, 0xBD, 0x4A, 0xCD,
+	0x72, 0x6C, 0x0E, 0x0E, 0x5E, 0x3E, 0xB5, 0x5E,
+	0xF6, 0xB1, 0x5A, 0x13, 0x8E, 0x22, 0x6E, 0xCD,
+	0x1B, 0x23, 0x5A, 0xB5, 0xBB, 0x52, 0x51, 0xC1,
+	0x33, 0x76, 0xB2, 0x64, 0x48, 0xA9, 0xAC, 0x1D,
+	0xE8, 0xBD, 0x52, 0x64, 0x8C, 0x0B, 0x5F, 0xFA,
+	0x94, 0x44, 0x86, 0x82, 0xE3, 0xCB, 0x4D, 0xE9,
+	0xCB, 0x8A, 0xE7, 0xF4, 0xBD, 0x41, 0x0E, 0xD5,
+	0x02, 0xB1, 0x25, 0x3A, 0xD0, 0x8B, 0xB2, 0x79,
+	0x69, 0xB5, 0xF0, 0x2B, 0x10, 0x02, 0x9D, 0x67,
+	0xD0, 0x7E, 0x18, 0x64, 0xD9, 0x4D, 0x4F, 0xCA,
+	0x20, 0x81, 0x51, 0xE2, 0x6F, 0x5F, 0xEE, 0x26
+};
+
+static const uint8_t ciphertext_sm4_ecb[] = {
+	0xCC, 0x62, 0x37, 0xA6, 0xA1, 0x35, 0x39, 0x75,
+	0xFF, 0xF5, 0xEE, 0x6A, 0xFD, 0xD7, 0x70, 0x15,
+	0xE1, 0x32, 0x23, 0x1F, 0x18, 0xB8, 0xC9, 0x16,
+	0x07, 0x27, 0x9C, 0x6C, 0x7F, 0x8F, 0x7F, 0xF6,
+	0xFD, 0xF1, 0xE4, 0x01, 0xEC, 0x7E, 0xD2, 0x60,
+	0xFD, 0xE7, 0x5C, 0xE5, 0xCF, 0x6E, 0xE7, 0x87,
+	0x97, 0x13, 0xCC, 0x01, 0x92, 0x1A, 0xC5, 0x62,
+	0xB5, 0x0C, 0x45, 0xE4, 0xDC, 0x9A, 0x30, 0xC2,
+	0x35, 0xED, 0x7D, 0x1A, 0x93, 0x0D, 0x33, 0x96,
+	0xD6, 0xE1, 0x8B, 0x77, 0x64, 0x40, 0x25, 0x3D,
+	0x9F, 0x4B, 0x8E, 0xFF, 0x3F, 0x11, 0x41, 0x58,
+	0x3B, 0x55, 0x4F, 0x59, 0x38, 0x2E, 0xAA, 0xBB,
+	0x8B, 0x42, 0xFA, 0x30, 0x38, 0x0D, 0x05, 0x3B,
+	0x86, 0x7C, 0xB0, 0xF2, 0x77, 0xCE, 0xEE, 0x1B,
+	0x78, 0xE8, 0x64, 0x7D, 0x59, 0xE3, 0xDA, 0x61,
+	0x05, 0x27, 0x56, 0x12, 0x95, 0x6D, 0x34, 0x9C
+};
+
+static const uint8_t ciphertext_sm4_cbc[] = {
+	0x60, 0x7A, 0xBE, 0xC9, 0xDA, 0xD7, 0x90, 0x73,
+	0xC7, 0x96, 0xDB, 0x34, 0x26, 0xFD, 0x2C, 0x2F,
+	0x8E, 0x39, 0xC7, 0x0B, 0x60, 0xB2, 0x3D, 0xBE,
+	0xF3, 0xA9, 0xA5, 0x46, 0x65, 0x26, 0x41, 0xB7,
+	0xAE, 0xC9, 0xC3, 0xAD, 0x8C, 0x9B, 0x95, 0x8D,
+	0x17, 0x53, 0x15, 0x35, 0x40, 0x2A, 0x8C, 0x6B,
+	0x02, 0x5C, 0xBD, 0x13, 0xA6, 0x7E, 0xB7, 0x63,
+	0xC0, 0x3F, 0xA8, 0xBC, 0x73, 0xDD, 0x0B, 0x7A,
+	0x88, 0x0E, 0xF8, 0xC5, 0x5B, 0x00, 0x07, 0xFF,
+	0x53, 0x7B, 0xF1, 0x6A, 0xA0, 0xFD, 0x0B, 0x89,
+	0x03, 0x91, 0x4D, 0xD8, 0xC4, 0xB3, 0xC0, 0x12,
+	0x41, 0xEB, 0xF7, 0xCB, 0x0A, 0xFB, 0x68, 0xE7,
+	0x8E, 0x0C, 0x14, 0x33, 0x1A, 0x34, 0x55, 0xDA,
+	0x04, 0xE2, 0xA3, 0xFC, 0xBE, 0xB6, 0xDF, 0x2B,
+	0x61, 0x33, 0x05, 0xBD, 0xBC, 0x0A, 0xB5, 0x8B,
+	0x6D, 0x0F, 0x1B, 0x7D, 0x5F, 0x24, 0x46, 0x0E
+};
+
+static const uint8_t ciphertext_sm4_cfb[] = {
+	0xC1, 0x27, 0x47, 0xC7, 0x44, 0x0C, 0x9A, 0x5C,
+	0x7D, 0x51, 0x26, 0x0D, 0x1B, 0xDB, 0x0D, 0x9D,
+	0x52, 0x59, 0xAD, 0x56, 0x05, 0xBE, 0x92, 0xD2,
+	0xB7, 0x62, 0xF5, 0xD7, 0x53, 0xD3, 0x12, 0x2A,
+	0x3C, 0x9A, 0x6E, 0x75, 0x80, 0xAB, 0x18, 0xE5,
+	0x72, 0x49, 0x9A, 0xD9, 0x80, 0x99, 0xC2, 0xE7,
+	0xCA, 0xD9, 0xDC, 0xD1, 0x45, 0x2F, 0xDD, 0xFC,
+	0x01, 0x7F, 0xB8, 0x01, 0x51, 0xCF, 0x43, 0x74,
+	0xC0, 0xBA, 0xFE, 0xB0, 0x28, 0xFE, 0xA4, 0xCD,
+	0x35, 0x0E, 0xEC, 0xE5, 0x70, 0xA2, 0x7F, 0x5D,
+	0x38, 0x1B, 0x50, 0xEB, 0x46, 0xBE, 0x61, 0x6E,
+	0x6C, 0x76, 0xF3, 0x65, 0x75, 0xCD, 0xA1, 0xBB,
+	0x9F, 0xFA, 0x7B, 0x86, 0x12, 0x87, 0x04, 0xEB,
+	0x00, 0x24, 0x81, 0xE7, 0x91, 0xFC, 0x1B, 0xC7,
+	0xA6, 0xB2, 0x67, 0xE2, 0x6E, 0x88, 0x8F, 0xB6,
+	0x4C, 0x45, 0x96, 0xEF, 0xBF, 0x4C, 0x26, 0x69
+};
+
+static const uint8_t ciphertext_sm4_ofb[] = {
+	0xC1, 0x27, 0x47, 0xC7, 0x44, 0x0C, 0x9A, 0x5C,
+	0x7D, 0x51, 0x26, 0x0D, 0x1B, 0xDB, 0x0D, 0x9D,
+	0x0F, 0x0C, 0xAD, 0xA0, 0x2D, 0x18, 0x0B, 0x3C,
+	0x54, 0xA9, 0x87, 0x86, 0xBC, 0x6B, 0xF9, 0xFB,
+	0x18, 0x68, 0x51, 0x1E, 0xB2, 0x53, 0x1D, 0xD5,
+	0x7F, 0x4B, 0xED, 0xB8, 0xCA, 0x8E, 0x81, 0xCE,
+	0xE1, 0x16, 0x7F, 0x84, 0x69, 0xD1, 0x15, 0xCE,
+	0x84, 0xF0, 0xB0, 0x3A, 0x21, 0xF2, 0x85, 0xA2,
+	0xEB, 0x2F, 0xDF, 0x34, 0x52, 0x62, 0x42, 0x87,
+	0xFA, 0x7F, 0x02, 0x2A, 0xC2, 0xD9, 0xE4, 0xB0,
+	0x8D, 0xC5, 0x52, 0xEC, 0x3D, 0x96, 0x3F, 0xD3,
+	0x8C, 0x39, 0x9C, 0x0F, 0xD9, 0x66, 0xDD, 0x29,
+	0x90, 0x00, 0x5D, 0x4F, 0x4D, 0x82, 0x2A, 0x47,
+	0x9E, 0x7E, 0x46, 0x87, 0x84, 0xE8, 0xDD, 0xAE,
+	0xB3, 0x03, 0xF8, 0xE8, 0x7B, 0xA6, 0xC9, 0x9A,
+	0x56, 0x9C, 0xC7, 0x82, 0x1E, 0x9A, 0x9D, 0x13
+};
+
+static const uint8_t ciphertext_sm4_ctr[] = {
+	0xC1, 0x27, 0x47, 0xC7, 0x44, 0x0C, 0x9A, 0x5C,
+	0x7D, 0x51, 0x26, 0x0D, 0x1B, 0xDB, 0x0D, 0x9D,
+	0xC3, 0x75, 0xCE, 0xBB, 0x63, 0x9A, 0x5B, 0x0C,
+	0xED, 0x64, 0x3F, 0x33, 0x80, 0x8F, 0x97, 0x40,
+	0xB7, 0x5C, 0xA7, 0xFE, 0x2F, 0x7F, 0xFB, 0x20,
+	0x13, 0xEC, 0xDC, 0xBC, 0x96, 0xC8, 0x05, 0xF0,
+	0xA4, 0x95, 0xC4, 0x0A, 0xB7, 0x1B, 0x18, 0xB4,
+	0xDA, 0x35, 0xFF, 0xA5, 0xB5, 0x90, 0x1B, 0x07,
+	0x5C, 0x5B, 0x91, 0x36, 0xF0, 0xC9, 0xFE, 0xFB,
+	0xC4, 0x71, 0xD6, 0x3B, 0x03, 0x28, 0x62, 0xB9,
+	0x22, 0x7A, 0x97, 0xC9, 0x54, 0xC0, 0x8C, 0x71,
+	0xEC, 0x8F, 0xE1, 0xBB, 0x56, 0xAE, 0xAB, 0x16,
+	0xF6, 0x57, 0x76, 0x65, 0xC2, 0x4B, 0xE0, 0x46,
+	0x4E, 0x13, 0x77, 0x50, 0x91, 0x24, 0x76, 0xD9,
+	0xB7, 0x16, 0xFF, 0x9E, 0xD0, 0x2E, 0x14, 0x23,
+	0x27, 0xF4, 0x99, 0x03, 0xDA, 0x1C, 0x52, 0x04
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_cbc = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CBC,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_cbc,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_ctr = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CTR,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_ctr,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_ecb = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_ECB,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_ecb,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_ofb = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_OFB,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_ofb,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_cfb = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CFB,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_cfb,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_case sm4_cipheronly_test_cases[] = {
+	{
+		.test_descr = "SM4-CBC Encryption",
+		.test_data = &sm4_test_data_cbc,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-CBC Decryption",
+		.test_data = &sm4_test_data_cbc,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-CTR Encryption",
+		.test_data = &sm4_test_data_ctr,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-CTR Decryption",
+		.test_data = &sm4_test_data_ctr,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-ECB Encryption",
+		.test_data = &sm4_test_data_ecb,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-ECB Decryption",
+		.test_data = &sm4_test_data_ecb,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-OFB Encryption",
+		.test_data = &sm4_test_data_ofb,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-OFB Decryption",
+		.test_data = &sm4_test_data_ofb,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-CFB Encryption",
+		.test_data = &sm4_test_data_cfb,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-CFB Decryption",
+		.test_data = &sm4_test_data_cfb,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+};
+
+static const uint8_t plaintext_sm4_common[] = {
+	"What a lousy earth! He wondered how many people were destitute that"
+};
+
+static const uint8_t ciphertext64_sm4_cbc[] = {
+	0x5D, 0x93, 0x4E, 0x50, 0xDC, 0x26, 0x03, 0xB5,
+	0x6C, 0xFC, 0xB7, 0x09, 0x11, 0x28, 0x2F, 0xF7,
+	0x6C, 0xB6, 0xE6, 0xCC, 0xB8, 0xC5, 0x01, 0x5F,
+	0xBE, 0x89, 0xF8, 0xD3, 0xE8, 0xCD, 0x51, 0xC6,
+	0x17, 0x31, 0x07, 0xDE, 0xA5, 0x8F, 0xFD, 0x79,
+	0x2A, 0xAC, 0xAC, 0x90, 0x47, 0x8D, 0x0F, 0x16,
+	0x66, 0xCF, 0x16, 0xF1, 0xE2, 0x4C, 0x79, 0x4A,
+	0x6B, 0x5D, 0x6C, 0xAB, 0x98, 0x2B, 0xDB, 0xF8
+};
+
+/* test vectors */
+static const uint8_t plaintext64_sm4_ctr[] = {
+	0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
+	0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
+	0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C,
+	0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51,
+	0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11,
+	0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF,
+	0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17,
+	0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10
+};
+
+static const uint8_t ciphertext64_sm4_ctr[] = {
+	0x14, 0xAE, 0x4A, 0x72, 0xB9, 0x7A, 0x93, 0xCE,
+	0x12, 0x16, 0xCC, 0xD9, 0x98, 0xE3, 0x71, 0xC1,
+	0x60, 0xF7, 0xEF, 0x8B, 0x63, 0x44, 0xBD, 0x6D,
+	0xA1, 0x99, 0x25, 0x05, 0xE5, 0xFC, 0x21, 0x9B,
+	0x0B, 0xF0, 0x57, 0xF8, 0x6C, 0x5D, 0x75, 0x10,
+	0x3C, 0x0F, 0x46, 0x51, 0x9C, 0x7F, 0xB2, 0xE7,
+	0x29, 0x28, 0x05, 0x03, 0x5A, 0xDB, 0x9A, 0x90,
+	0xEC, 0xEF, 0x14, 0x53, 0x59, 0xD7, 0xCF, 0x0E
+};
+
+static const struct blockcipher_test_data sm4_test_data_1 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CTR,
+	.cipher_key = {
+		.data = {
+			0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+			0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+			0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext64_sm4_ctr,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_ctr,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0x3A, 0x90, 0x8E, 0x9E, 0x07, 0x48, 0xBE, 0xFE,
+			0x29, 0xB9, 0x61, 0xD8, 0x1A, 0x01, 0x5E, 0x34,
+			0x98, 0x1A, 0x35, 0xE5, 0x26, 0x1A, 0x28, 0x1E,
+			0xB1, 0xDC, 0xDB, 0xEB, 0xC7, 0x16, 0xF9, 0x9E
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+/* test vectors */
+static const uint8_t plaintext64_sm4_cfb[] = {
+	0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
+	0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
+	0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C,
+	0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51,
+	0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11,
+	0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF,
+	0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17,
+	0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10
+};
+
+static const uint8_t ciphertext64_sm4_cfb[] = {
+	0x14, 0xAE, 0x4A, 0x72, 0xB9, 0x7A, 0x93, 0xCE,
+	0x12, 0x16, 0xCC, 0xD9, 0x98, 0xE3, 0x71, 0xC1,
+	0xAA, 0x8A, 0x2C, 0x8C, 0x61, 0x89, 0x6B, 0x8B,
+	0x7C, 0xF8, 0x32, 0x6A, 0xEB, 0xAC, 0xD4, 0x0C,
+	0xD1, 0x5D, 0xFA, 0x1D, 0xFD, 0x17, 0x67, 0x02,
+	0x06, 0xCD, 0x38, 0x2C, 0x4D, 0x04, 0xF3, 0x96,
+	0x2F, 0x85, 0x5C, 0x3F, 0xBB, 0x79, 0x56, 0xA9,
+	0xC4, 0x6F, 0x34, 0xB3, 0xBE, 0xEC, 0xCA, 0x40
+};
+
+static const struct blockcipher_test_data sm4_test_data_2 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CFB,
+	.cipher_key = {
+		.data = {
+			0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+			0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+			0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext64_sm4_cfb,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_cfb,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0x6F, 0x7C, 0xFA, 0x6D, 0x02, 0x5D, 0xE2, 0x4B,
+			0x4A, 0xEE, 0xC6, 0x67, 0x0B, 0xD3, 0xCF, 0xBD,
+			0x64, 0x8F, 0x01, 0x17, 0x19, 0xD6, 0xFB, 0xEC,
+			0x3A, 0x27, 0xE8, 0x0F, 0x51, 0xA3, 0xE2, 0x3F
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+/* test vectors */
+static const uint8_t plaintext64_sm4_ofb[] = {
+	0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
+	0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
+	0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C,
+	0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51,
+	0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11,
+	0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF,
+	0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17,
+	0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10
+};
+
+static const uint8_t ciphertext64_sm4_ofb[] = {
+	0x14, 0xAE, 0x4A, 0x72, 0xB9, 0x7A, 0x93, 0xCE,
+	0x12, 0x16, 0xCC, 0xD9, 0x98, 0xE3, 0x71, 0xC1,
+	0x94, 0x54, 0x3E, 0x9A, 0x3A, 0x0A, 0x22, 0x63,
+	0x22, 0xE8, 0xA5, 0xF3, 0x82, 0xB9, 0x14, 0x2D,
+	0xEF, 0x5F, 0x94, 0xCB, 0x49, 0x17, 0xEF, 0xA4,
+	0xD9, 0xCF, 0x3F, 0xC3, 0x32, 0x30, 0x90, 0x11,
+	0x12, 0x61, 0x52, 0xCC, 0xEC, 0x43, 0x61, 0xF2,
+	0x6F, 0x1E, 0x1A, 0x8D, 0xB4, 0x9D, 0x2F, 0xC4
+};
+
+static const struct blockcipher_test_data sm4_test_data_3 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_OFB,
+	.cipher_key = {
+		.data = {
+			0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+			0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+			0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext64_sm4_ofb,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_ofb,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0xA7, 0x6F, 0x7D, 0xB5, 0xFB, 0x35, 0x92, 0x82,
+			0x97, 0xB7, 0x9B, 0xBF, 0xA9, 0xCE, 0xA8, 0x4C,
+			0x5A, 0xC5, 0x53, 0x62, 0x9F, 0x03, 0x54, 0x88,
+			0x7D, 0xFE, 0x2D, 0xD3, 0x9C, 0xFB, 0x56, 0xED
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+static const struct blockcipher_test_data sm4_test_data_4 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CBC,
+	.cipher_key = {
+		.data = {
+			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
+			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4_common,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_cbc,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0xA7, 0x87, 0x94, 0x53, 0x17, 0xAE, 0xF9, 0xCD,
+			0x8A, 0x60, 0x34, 0xFB, 0x9F, 0x07, 0xED, 0x28,
+			0x04, 0x13, 0x8C, 0xD4, 0x48, 0x83, 0x4A, 0xBA,
+			0xB8, 0xE8, 0x45, 0xDB, 0xE0, 0x66, 0xF9, 0xDA
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+static const struct blockcipher_test_case sm4_chain_test_cases[] = {
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+};
+
+#endif
-- 
2.19.0.rc0.windows.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

* RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-03-16  3:10 [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Sunyang Wu
  2023-03-16  3:10 ` [PATCH 2/2] test/crypto: Add SM3/SM4 test vectors for verification in test app Sunyang Wu
@ 2023-03-16 10:42 ` Akhil Goyal
  2023-03-18 13:00   ` 回复: " Sunyang Wu
  2023-05-17  7:04 ` Akhil Goyal
  2 siblings, 1 reply; 12+ messages in thread
From: Akhil Goyal @ 2023-03-16 10:42 UTC (permalink / raw)
  To: Sunyang Wu, dev; +Cc: kai.ji

> Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> 

Can you give reference to some documentation for each of these modes.
Cannot find RFCs for SM3_HMAC etc.

> Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> ---
>  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* 回复: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-03-16 10:42 ` [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Akhil Goyal
@ 2023-03-18 13:00   ` Sunyang Wu
  2023-04-19 19:41     ` Kusztal, ArkadiuszX
  0 siblings, 1 reply; 12+ messages in thread
From: Sunyang Wu @ 2023-03-18 13:00 UTC (permalink / raw)
  To: Akhil Goyal, dev; +Cc: kai.ji

Hi all:
SM3 and SM4 are widely used in China, and they are Chinese national standards. I'm very to tell you that I didn't find the relevant RFC documents for SM3 and SM4, 
but I found the national standards for SM3 and SM4 in the full text disclosure system of Chinese national standards, but they are all in Chinese. The links are shown below:
SM3: http://c.gb688.cn/bzgk/gb/showGb?type=online&hcno=45B1A67F20F3BF339211C391E9278F5E
SM4: http://c.gb688.cn/bzgk/gb/showGb?type=online&hcno=7803DE42D3BC5E80B0C3E5D8E873D56A
If these modes(SM3_HMAC / SM4_OFB / SM4_CFB) are not necessary, I can resubmit a patch, delete the corresponding test cases for these modes,
and retain only the test cases for the mods currently supported by DPdK.

-----邮件原件-----
发件人: Akhil Goyal <gakhil@marvell.com> 
发送时间: 2023年3月16日 18:43
收件人: Sunyang Wu <sunyang.wu@jaguarmicro.com>; dev@dpdk.org
抄送: kai.ji@intel.com
主题: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK

> Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> 

Can you give reference to some documentation for each of these modes.
Cannot find RFCs for SM3_HMAC etc.

> Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> ---
>  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-03-18 13:00   ` 回复: " Sunyang Wu
@ 2023-04-19 19:41     ` Kusztal, ArkadiuszX
  0 siblings, 0 replies; 12+ messages in thread
From: Kusztal, ArkadiuszX @ 2023-04-19 19:41 UTC (permalink / raw)
  To: Sunyang Wu, Akhil Goyal, dev; +Cc: Ji, Kai



> -----Original Message-----
> From: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> Sent: Saturday, March 18, 2023 2:00 PM
> To: Akhil Goyal <gakhil@marvell.com>; dev@dpdk.org
> Cc: Ji, Kai <kai.ji@intel.com>
> Subject: 回复: [EXT] [PATCH 1/2] lib/cryptodev/: Add
> SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> 
> Hi all:
> SM3 and SM4 are widely used in China, and they are Chinese national standards.
> I'm very to tell you that I didn't find the relevant RFC documents for SM3 and
> SM4, but I found the national standards for SM3 and SM4 in the full text
> disclosure system of Chinese national standards, but they are all in Chinese. The
> links are shown below:
> SM3:
> http://c.gb688.cn/bzgk/gb/showGb?type=online&hcno=45B1A67F20F3BF33921
> 1C391E9278F5E
> SM4:
> http://c.gb688.cn/bzgk/gb/showGb?type=online&hcno=7803DE42D3BC5E80B0
> C3E5D8E873D56A
> If these modes(SM3_HMAC / SM4_OFB / SM4_CFB) are not necessary, I can
> resubmit a patch, delete the corresponding test cases for these modes, and
> retain only the test cases for the mods currently supported by DPdK.
> 
> -----邮件原件-----
> 发件人: Akhil Goyal <gakhil@marvell.com>
> 发送时间: 2023年3月16日 18:43
> 收件人: Sunyang Wu <sunyang.wu@jaguarmicro.com>; dev@dpdk.org
> 抄送: kai.ji@intel.com
> 主题: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add
> SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> 
> > Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> >
> 
> Can you give reference to some documentation for each of these modes.
> Cannot find RFCs for SM3_HMAC etc.

HMAC is supposed to work with any iterated hash function. Since we already have SM3 in the API, I would not worry about lack of RFC for specific SM3 + HMAC combination.

> 
> > Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> > ---
> >  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-03-16  3:10 [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Sunyang Wu
  2023-03-16  3:10 ` [PATCH 2/2] test/crypto: Add SM3/SM4 test vectors for verification in test app Sunyang Wu
  2023-03-16 10:42 ` [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Akhil Goyal
@ 2023-05-17  7:04 ` Akhil Goyal
  2023-05-25  8:27   ` Akhil Goyal
  2 siblings, 1 reply; 12+ messages in thread
From: Akhil Goyal @ 2023-05-17  7:04 UTC (permalink / raw)
  To: Sunyang Wu, dev; +Cc: kai.ji

> Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> 
> Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> ---
>  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 

Please add release notes and update doc/guides/cryptodevs/features/default.ini.

The update to crypto_auth/cipher_algorithm_strings is also missing.

> diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h
> index 2cfe66530c..c4572106dc 100644
> --- a/lib/cryptodev/rte_crypto_sym.h
> +++ b/lib/cryptodev/rte_crypto_sym.h
> @@ -172,8 +172,12 @@ enum rte_crypto_cipher_algorithm {
>  	/**< ShangMi 4 (SM4) algorithm in ECB mode */
>  	RTE_CRYPTO_CIPHER_SM4_CBC,
>  	/**< ShangMi 4 (SM4) algorithm in CBC mode */
> -	RTE_CRYPTO_CIPHER_SM4_CTR
> +	RTE_CRYPTO_CIPHER_SM4_CTR,
>  	/**< ShangMi 4 (SM4) algorithm in CTR mode */
> +	RTE_CRYPTO_CIPHER_SM4_OFB,
> +	/**< ShangMi 4 (SM4) algorithm in OFB mode */
> +	RTE_CRYPTO_CIPHER_SM4_CFB
> +	/**< ShangMi 4 (SM4) algorithm in CFB mode */
>  };
> 
>  /** Cipher algorithm name strings */
> @@ -376,6 +380,8 @@ enum rte_crypto_auth_algorithm {
>  	/**< HMAC using 512 bit SHA3 algorithm. */
>  	RTE_CRYPTO_AUTH_SM3,
>  	/**< ShangMi 3 (SM3) algorithm */
> +	RTE_CRYPTO_AUTH_SM3_HMAC,
> +	/** < HMAC using Chinese SM3 algorithm */
> 
>  	RTE_CRYPTO_AUTH_SHAKE_128,
>  	/**< 128 bit SHAKE algorithm. */
> --
> 2.19.0.rc0.windows.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-05-17  7:04 ` Akhil Goyal
@ 2023-05-25  8:27   ` Akhil Goyal
  2023-05-25  9:00     ` 回复: " Sunyang Wu
  0 siblings, 1 reply; 12+ messages in thread
From: Akhil Goyal @ 2023-05-25  8:27 UTC (permalink / raw)
  To: Akhil Goyal, Sunyang Wu, dev; +Cc: kai.ji

Hi Sunyang,

Can you send the next version for this patch?
We need to merge in RC1 (31st May).


> Subject: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add
> SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> 
> > Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> >
> > Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> > ---
> >  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> 
> Please add release notes and update
> doc/guides/cryptodevs/features/default.ini.
> 
> The update to crypto_auth/cipher_algorithm_strings is also missing.
> 
> > diff --git a/lib/cryptodev/rte_crypto_sym.h b/lib/cryptodev/rte_crypto_sym.h
> > index 2cfe66530c..c4572106dc 100644
> > --- a/lib/cryptodev/rte_crypto_sym.h
> > +++ b/lib/cryptodev/rte_crypto_sym.h
> > @@ -172,8 +172,12 @@ enum rte_crypto_cipher_algorithm {
> >  	/**< ShangMi 4 (SM4) algorithm in ECB mode */
> >  	RTE_CRYPTO_CIPHER_SM4_CBC,
> >  	/**< ShangMi 4 (SM4) algorithm in CBC mode */
> > -	RTE_CRYPTO_CIPHER_SM4_CTR
> > +	RTE_CRYPTO_CIPHER_SM4_CTR,
> >  	/**< ShangMi 4 (SM4) algorithm in CTR mode */
> > +	RTE_CRYPTO_CIPHER_SM4_OFB,
> > +	/**< ShangMi 4 (SM4) algorithm in OFB mode */
> > +	RTE_CRYPTO_CIPHER_SM4_CFB
> > +	/**< ShangMi 4 (SM4) algorithm in CFB mode */
> >  };
> >
> >  /** Cipher algorithm name strings */
> > @@ -376,6 +380,8 @@ enum rte_crypto_auth_algorithm {
> >  	/**< HMAC using 512 bit SHA3 algorithm. */
> >  	RTE_CRYPTO_AUTH_SM3,
> >  	/**< ShangMi 3 (SM3) algorithm */
> > +	RTE_CRYPTO_AUTH_SM3_HMAC,
> > +	/** < HMAC using Chinese SM3 algorithm */
> >
> >  	RTE_CRYPTO_AUTH_SHAKE_128,
> >  	/**< 128 bit SHAKE algorithm. */
> > --
> > 2.19.0.rc0.windows.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* 回复: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-05-25  8:27   ` Akhil Goyal
@ 2023-05-25  9:00     ` Sunyang Wu
  2023-05-25  9:04       ` Akhil Goyal
  0 siblings, 1 reply; 12+ messages in thread
From: Sunyang Wu @ 2023-05-25  9:00 UTC (permalink / raw)
  To: Akhil Goyal, dev; +Cc: kai.ji

Hi Akhil,
The patches have been resubmitted.

Best wishes
sunyang

-----Original Message-----
From: Akhil Goyal <gakhil@marvell.com>
Send: 2023.5.25 16:27 PM
To: Akhil Goyal <gakhil@marvell.com>; Sunyang Wu <sunyang.wu@jaguarmicro.com>; dev@dpdk.org
Cc: kai.ji@intel.com
Subject: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK

Hi Sunyang,

Can you send the next version for this patch?
We need to merge in RC1 (31st May).


> Subject: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add 
> SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> 
> > Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> >
> > Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> > ---
> >  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> 
> Please add release notes and update
> doc/guides/cryptodevs/features/default.ini.
> 
> The update to crypto_auth/cipher_algorithm_strings is also missing.
> 
> > diff --git a/lib/cryptodev/rte_crypto_sym.h 
> > b/lib/cryptodev/rte_crypto_sym.h index 2cfe66530c..c4572106dc 100644
> > --- a/lib/cryptodev/rte_crypto_sym.h
> > +++ b/lib/cryptodev/rte_crypto_sym.h
> > @@ -172,8 +172,12 @@ enum rte_crypto_cipher_algorithm {
> >  	/**< ShangMi 4 (SM4) algorithm in ECB mode */
> >  	RTE_CRYPTO_CIPHER_SM4_CBC,
> >  	/**< ShangMi 4 (SM4) algorithm in CBC mode */
> > -	RTE_CRYPTO_CIPHER_SM4_CTR
> > +	RTE_CRYPTO_CIPHER_SM4_CTR,
> >  	/**< ShangMi 4 (SM4) algorithm in CTR mode */
> > +	RTE_CRYPTO_CIPHER_SM4_OFB,
> > +	/**< ShangMi 4 (SM4) algorithm in OFB mode */
> > +	RTE_CRYPTO_CIPHER_SM4_CFB
> > +	/**< ShangMi 4 (SM4) algorithm in CFB mode */
> >  };
> >
> >  /** Cipher algorithm name strings */ @@ -376,6 +380,8 @@ enum 
> > rte_crypto_auth_algorithm {
> >  	/**< HMAC using 512 bit SHA3 algorithm. */
> >  	RTE_CRYPTO_AUTH_SM3,
> >  	/**< ShangMi 3 (SM3) algorithm */
> > +	RTE_CRYPTO_AUTH_SM3_HMAC,
> > +	/** < HMAC using Chinese SM3 algorithm */
> >
> >  	RTE_CRYPTO_AUTH_SHAKE_128,
> >  	/**< 128 bit SHAKE algorithm. */
> > --
> > 2.19.0.rc0.windows.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-05-25  9:00     ` 回复: " Sunyang Wu
@ 2023-05-25  9:04       ` Akhil Goyal
  2023-05-25  9:25         ` 回复: " Sunyang Wu
  0 siblings, 1 reply; 12+ messages in thread
From: Akhil Goyal @ 2023-05-25  9:04 UTC (permalink / raw)
  To: Sunyang Wu, dev; +Cc: kai.ji

Hi Sunyang,
> Hi Akhil,
> The patches have been resubmitted.

Yeah they are resubmitted, but you should mark them as v2
And mention the changelog as well.

I can see that all the comments were not addressed.
Please add release notes.
The update to crypto_auth/cipher_algorithm_strings is also missing.

> 
> Best wishes
> sunyang
> 
> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Send: 2023.5.25 16:27 PM
> To: Akhil Goyal <gakhil@marvell.com>; Sunyang Wu
> <sunyang.wu@jaguarmicro.com>; dev@dpdk.org
> Cc: kai.ji@intel.com
> Subject: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add
> SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> 
> Hi Sunyang,
> 
> Can you send the next version for this patch?
> We need to merge in RC1 (31st May).
> 
> 
> > Subject: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add
> > SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> >
> > > Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> > >
> > > Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> > > ---
> > >  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
> > >  1 file changed, 7 insertions(+), 1 deletion(-)
> > >
> >
> > Please add release notes and update
> > doc/guides/cryptodevs/features/default.ini.
> >
> > The update to crypto_auth/cipher_algorithm_strings is also missing.
> >
> > > diff --git a/lib/cryptodev/rte_crypto_sym.h
> > > b/lib/cryptodev/rte_crypto_sym.h index 2cfe66530c..c4572106dc 100644
> > > --- a/lib/cryptodev/rte_crypto_sym.h
> > > +++ b/lib/cryptodev/rte_crypto_sym.h
> > > @@ -172,8 +172,12 @@ enum rte_crypto_cipher_algorithm {
> > >  	/**< ShangMi 4 (SM4) algorithm in ECB mode */
> > >  	RTE_CRYPTO_CIPHER_SM4_CBC,
> > >  	/**< ShangMi 4 (SM4) algorithm in CBC mode */
> > > -	RTE_CRYPTO_CIPHER_SM4_CTR
> > > +	RTE_CRYPTO_CIPHER_SM4_CTR,
> > >  	/**< ShangMi 4 (SM4) algorithm in CTR mode */
> > > +	RTE_CRYPTO_CIPHER_SM4_OFB,
> > > +	/**< ShangMi 4 (SM4) algorithm in OFB mode */
> > > +	RTE_CRYPTO_CIPHER_SM4_CFB
> > > +	/**< ShangMi 4 (SM4) algorithm in CFB mode */
> > >  };
> > >
> > >  /** Cipher algorithm name strings */ @@ -376,6 +380,8 @@ enum
> > > rte_crypto_auth_algorithm {
> > >  	/**< HMAC using 512 bit SHA3 algorithm. */
> > >  	RTE_CRYPTO_AUTH_SM3,
> > >  	/**< ShangMi 3 (SM3) algorithm */
> > > +	RTE_CRYPTO_AUTH_SM3_HMAC,
> > > +	/** < HMAC using Chinese SM3 algorithm */
> > >
> > >  	RTE_CRYPTO_AUTH_SHAKE_128,
> > >  	/**< 128 bit SHAKE algorithm. */
> > > --
> > > 2.19.0.rc0.windows.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* 回复: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-05-25  9:04       ` Akhil Goyal
@ 2023-05-25  9:25         ` Sunyang Wu
  2023-05-25  9:45           ` Akhil Goyal
  0 siblings, 1 reply; 12+ messages in thread
From: Sunyang Wu @ 2023-05-25  9:25 UTC (permalink / raw)
  To: Akhil Goyal, dev; +Cc: kai.ji

Hi Akhil,

I'm so sorry, I don't quite understand your request.
Please tell me how to update the crypto_auth/cipher_algorithm_strings.

-----邮件原件-----
发件人: Akhil Goyal <gakhil@marvell.com> 
发送时间: 2023年5月25日 17:04
收件人: Sunyang Wu <sunyang.wu@jaguarmicro.com>; dev@dpdk.org
抄送: kai.ji@intel.com
主题: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK

Hi Sunyang,
> Hi Akhil,
> The patches have been resubmitted.

Yeah they are resubmitted, but you should mark them as v2 And mention the changelog as well.

I can see that all the comments were not addressed.
Please add release notes.
The update to crypto_auth/cipher_algorithm_strings is also missing.

> 
> Best wishes
> sunyang
> 
> -----Original Message-----
> From: Akhil Goyal <gakhil@marvell.com>
> Send: 2023.5.25 16:27 PM
> To: Akhil Goyal <gakhil@marvell.com>; Sunyang Wu 
> <sunyang.wu@jaguarmicro.com>; dev@dpdk.org
> Cc: kai.ji@intel.com
> Subject: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add 
> SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> 
> Hi Sunyang,
> 
> Can you send the next version for this patch?
> We need to merge in RC1 (31st May).
> 
> 
> > Subject: RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add 
> > SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
> >
> > > Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK.
> > >
> > > Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>
> > > ---
> > >  lib/cryptodev/rte_crypto_sym.h | 8 +++++++-
> > >  1 file changed, 7 insertions(+), 1 deletion(-)
> > >
> >
> > Please add release notes and update
> > doc/guides/cryptodevs/features/default.ini.
> >
> > The update to crypto_auth/cipher_algorithm_strings is also missing.
> >
> > > diff --git a/lib/cryptodev/rte_crypto_sym.h 
> > > b/lib/cryptodev/rte_crypto_sym.h index 2cfe66530c..c4572106dc 
> > > 100644
> > > --- a/lib/cryptodev/rte_crypto_sym.h
> > > +++ b/lib/cryptodev/rte_crypto_sym.h
> > > @@ -172,8 +172,12 @@ enum rte_crypto_cipher_algorithm {
> > >  	/**< ShangMi 4 (SM4) algorithm in ECB mode */
> > >  	RTE_CRYPTO_CIPHER_SM4_CBC,
> > >  	/**< ShangMi 4 (SM4) algorithm in CBC mode */
> > > -	RTE_CRYPTO_CIPHER_SM4_CTR
> > > +	RTE_CRYPTO_CIPHER_SM4_CTR,
> > >  	/**< ShangMi 4 (SM4) algorithm in CTR mode */
> > > +	RTE_CRYPTO_CIPHER_SM4_OFB,
> > > +	/**< ShangMi 4 (SM4) algorithm in OFB mode */
> > > +	RTE_CRYPTO_CIPHER_SM4_CFB
> > > +	/**< ShangMi 4 (SM4) algorithm in CFB mode */
> > >  };
> > >
> > >  /** Cipher algorithm name strings */ @@ -376,6 +380,8 @@ enum 
> > > rte_crypto_auth_algorithm {
> > >  	/**< HMAC using 512 bit SHA3 algorithm. */
> > >  	RTE_CRYPTO_AUTH_SM3,
> > >  	/**< ShangMi 3 (SM3) algorithm */
> > > +	RTE_CRYPTO_AUTH_SM3_HMAC,
> > > +	/** < HMAC using Chinese SM3 algorithm */
> > >
> > >  	RTE_CRYPTO_AUTH_SHAKE_128,
> > >  	/**< 128 bit SHAKE algorithm. */
> > > --
> > > 2.19.0.rc0.windows.1


^ permalink raw reply	[flat|nested] 12+ messages in thread

* RE: [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK
  2023-05-25  9:25         ` 回复: " Sunyang Wu
@ 2023-05-25  9:45           ` Akhil Goyal
  0 siblings, 0 replies; 12+ messages in thread
From: Akhil Goyal @ 2023-05-25  9:45 UTC (permalink / raw)
  To: Sunyang Wu, dev; +Cc: kai.ji


> Hi Akhil,
> 
> I'm so sorry, I don't quite understand your request.
> Please tell me how to update the crypto_auth/cipher_algorithm_strings.
> 
You need to update the arrays
crypto_auth_algorithm_strings and crypto_cipher_algorithm_strings
 in "lib/cryptodev/rte_cryptodev.c"

Also update the release notes similar to
https://patches.dpdk.org/project/dpdk/patch/40827e1b2765526202e3aaf7716a695842891fc7.1682652719.git.gmuthukrishn@marvell.com/

Also update the title as 
cryptodev: support SM3_HMAC,SM4_CFB and SM4_OFB

^ permalink raw reply	[flat|nested] 12+ messages in thread

* [PATCH 2/2] test/crypto: Add SM3/SM4 test vectors for verification in test app
  2023-05-25  8:52 Sunyang Wu
@ 2023-05-25  8:52 ` Sunyang Wu
  0 siblings, 0 replies; 12+ messages in thread
From: Sunyang Wu @ 2023-05-25  8:52 UTC (permalink / raw)
  To: dev; +Cc: kai.ji, gakhil

Add SM3/SM4 test vectors for verification in test app.

Signed-off-by: Sunyang Wu <sunyang.wu@jaguarmicro.com>

---
The test results of using lib-openssl are as follows:
+ SM4 Chain : 24/24 passed, 0/24 skipped, 0/24 failed, 0/24 unsupported
+ SM4 Cipher Only : 10/10 passed, 0/10 skipped, 0/10 failed, 0/10
unsupported
+ Auth Only : 36/62 passed, 26/62 skipped, 0/62 failed, 0/62 unsupported
---
 app/test/test_cryptodev.c                   |   3 +
 app/test/test_cryptodev_blockcipher.c       |  81 +++
 app/test/test_cryptodev_blockcipher.h       |   4 +-
 app/test/test_cryptodev_hash_test_vectors.h |  82 +++
 app/test/test_cryptodev_sm4_test_vectors.h  | 710 ++++++++++++++++++++
 5 files changed, 879 insertions(+), 1 deletion(-)
 create mode 100644 app/test/test_cryptodev_sm4_test_vectors.h

diff --git a/app/test/test_cryptodev.c b/app/test/test_cryptodev.c
index 9c670e9a35..73238a447d 100644
--- a/app/test/test_cryptodev.c
+++ b/app/test/test_cryptodev.c
@@ -44,6 +44,7 @@
 #include "test_cryptodev_aead_test_vectors.h"
 #include "test_cryptodev_hmac_test_vectors.h"
 #include "test_cryptodev_mixed_test_vectors.h"
+#include "test_cryptodev_sm4_test_vectors.h"
 #ifdef RTE_LIB_SECURITY
 #include "test_cryptodev_security_ipsec.h"
 #include "test_cryptodev_security_ipsec_test_vectors.h"
@@ -16928,6 +16929,8 @@ run_cryptodev_testsuite(const char *pmd_name)
 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
 		BLKCIPHER_DES_CIPHERONLY_TYPE,
 		BLKCIPHER_DES_DOCSIS_TYPE,
+		BLKCIPHER_SM4_CHAIN_TYPE,
+		BLKCIPHER_SM4_CIPHERONLY_TYPE,
 		BLKCIPHER_AUTHONLY_TYPE};
 	struct unit_test_suite *static_suites[] = {
 		&cryptodev_multi_session_testsuite,
diff --git a/app/test/test_cryptodev_blockcipher.c b/app/test/test_cryptodev_blockcipher.c
index 6c9a5964ea..341cf1a54b 100644
--- a/app/test/test_cryptodev_blockcipher.c
+++ b/app/test/test_cryptodev_blockcipher.c
@@ -18,6 +18,7 @@
 #include "test_cryptodev_aes_test_vectors.h"
 #include "test_cryptodev_des_test_vectors.h"
 #include "test_cryptodev_hash_test_vectors.h"
+#include "test_cryptodev_sm4_test_vectors.h"
 
 static int
 verify_algo_support(const struct blockcipher_test_case *t,
@@ -1119,6 +1120,74 @@ authonly_setup(void)
 	return 0;
 }
 
+static int
+sm4_chain_setup(void)
+{
+	uint8_t dev_id = p_testsuite_params->valid_devs[0];
+	struct rte_cryptodev_info dev_info;
+	uint64_t feat_flags;
+	const enum rte_crypto_cipher_algorithm ciphers[] = {
+		RTE_CRYPTO_CIPHER_SM4_CTR,
+		RTE_CRYPTO_CIPHER_SM4_CBC,
+		RTE_CRYPTO_CIPHER_SM4_OFB,
+		RTE_CRYPTO_CIPHER_SM4_CFB
+	};
+	const enum rte_crypto_auth_algorithm auths[] = {
+		RTE_CRYPTO_AUTH_SM3,
+		RTE_CRYPTO_AUTH_SM3_HMAC,
+	};
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	feat_flags = dev_info.feature_flags;
+
+	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
+	    (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
+	    !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
+		RTE_LOG(INFO, USER1, "Feature flag for SM4 Chain testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0 &&
+	    check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
+		RTE_LOG(INFO, USER1, "Capability for SM4 Chain testsuite not met\n");
+		return TEST_SKIPPED;
+	}
+
+	return 0;
+}
+
+static int
+sm4_cipheronly_setup(void)
+{
+	uint8_t dev_id = p_testsuite_params->valid_devs[0];
+	struct rte_cryptodev_info dev_info;
+	uint64_t feat_flags;
+	const enum rte_crypto_cipher_algorithm ciphers[] = {
+		RTE_CRYPTO_CIPHER_SM4_CBC,
+		RTE_CRYPTO_CIPHER_SM4_ECB,
+		RTE_CRYPTO_CIPHER_SM4_CTR,
+		RTE_CRYPTO_CIPHER_SM4_OFB,
+		RTE_CRYPTO_CIPHER_SM4_CFB
+	};
+
+	rte_cryptodev_info_get(dev_id, &dev_info);
+	feat_flags = dev_info.feature_flags;
+
+	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
+	    (global_api_test_type == CRYPTODEV_RAW_API_TEST &&
+	    !(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
+		RTE_LOG(INFO, USER1, "Feature flag for SM4 Cipheronly not met\n");
+		return TEST_SKIPPED;
+	}
+
+	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
+		RTE_LOG(INFO, USER1, "Capability for SM4 Cipheronly not met\n");
+		return TEST_SKIPPED;
+	}
+
+	return 0;
+}
+
 struct unit_test_suite *
 build_blockcipher_test_suite(enum blockcipher_test_type test_type)
 {
@@ -1172,6 +1241,18 @@ build_blockcipher_test_suite(enum blockcipher_test_type test_type)
 		ts_name = "DES Docsis";
 		ts_setup = des_docsis_setup;
 		break;
+	case BLKCIPHER_SM4_CHAIN_TYPE:
+		n_test_cases = RTE_DIM(sm4_chain_test_cases);
+		blk_tcs = sm4_chain_test_cases;
+		ts_name = "SM4 Chain";
+		ts_setup = sm4_chain_setup;
+		break;
+	case BLKCIPHER_SM4_CIPHERONLY_TYPE:
+		n_test_cases = RTE_DIM(sm4_cipheronly_test_cases);
+		blk_tcs = sm4_cipheronly_test_cases;
+		ts_name = "SM4 Cipher Only";
+		ts_setup = sm4_cipheronly_setup;
+		break;
 	case BLKCIPHER_AUTHONLY_TYPE:
 		n_test_cases = RTE_DIM(hash_test_cases);
 		blk_tcs = hash_test_cases;
diff --git a/app/test/test_cryptodev_blockcipher.h b/app/test/test_cryptodev_blockcipher.h
index bad93a5ec1..e6f6c18067 100644
--- a/app/test/test_cryptodev_blockcipher.h
+++ b/app/test/test_cryptodev_blockcipher.h
@@ -49,7 +49,9 @@ enum blockcipher_test_type {
 	BLKCIPHER_3DES_CIPHERONLY_TYPE,	/* triple_des_cipheronly_test_cases[] */
 	BLKCIPHER_AUTHONLY_TYPE,	/* use hash_test_cases[] */
 	BLKCIPHER_DES_CIPHERONLY_TYPE,	/* use des_cipheronly_test_cases[] */
-	BLKCIPHER_DES_DOCSIS_TYPE	/* use des_docsis_test_cases[] */
+	BLKCIPHER_DES_DOCSIS_TYPE,	/* use des_docsis_test_cases[] */
+	BLKCIPHER_SM4_CHAIN_TYPE,	/* use sm4_chain_test_cases[] */
+	BLKCIPHER_SM4_CIPHERONLY_TYPE	/* use sm4_cipheronly_test_cases[] */
 };
 
 struct blockcipher_test_case {
diff --git a/app/test/test_cryptodev_hash_test_vectors.h b/app/test/test_cryptodev_hash_test_vectors.h
index fa9986a4da..65dd6bf81b 100644
--- a/app/test/test_cryptodev_hash_test_vectors.h
+++ b/app/test/test_cryptodev_hash_test_vectors.h
@@ -682,6 +682,56 @@ cmac_test_vector_12 = {
 	}
 };
 
+static const struct blockcipher_test_data
+sm3_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SM3,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.digest = {
+		.data =  {
+			0x9E, 0x86, 0xAB, 0x68, 0xD7, 0x8F, 0xD6, 0xFF,
+			0x1C, 0x57, 0x12, 0x48, 0xC4, 0xA8, 0x26, 0xDE,
+			0x9E, 0x53, 0xE9, 0xC4, 0xA6, 0xBB, 0xE7, 0x52,
+			0x53, 0x9C, 0xDE, 0xC1, 0xD5, 0x7C, 0x43, 0xAB
+		},
+		.len = 32
+	}
+};
+
+static const struct blockcipher_test_data
+hmac_sm3_test_vector = {
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.ciphertext = {
+		.data = plaintext_hash,
+		.len = 512
+	},
+	.auth_key = {
+		.data = {
+			0x12, 0x70, 0x87, 0xd9, 0x76, 0x9e, 0xe0, 0xf0,
+			0x14, 0xfb, 0xca, 0x5a, 0xb6, 0xcb, 0x8f, 0x9d,
+			0x42, 0xd3, 0x1e, 0x09, 0x9a, 0x25, 0x9a, 0x3c,
+			0x87, 0xee, 0x55, 0x63, 0x56, 0x33, 0x75, 0x69,
+			0xa3, 0xfc, 0x42, 0x19, 0x9a, 0x22, 0x09, 0xae,
+			0x1d, 0xd3, 0x09, 0xd3, 0x9e, 0x98, 0x71, 0xe1,
+			0x6b, 0x8f, 0xea, 0x05, 0xb4, 0x85, 0x41, 0x3b,
+			0x73, 0x97, 0x9e, 0xc9, 0xca, 0x13, 0x32, 0x6d
+		},
+		.len = 64
+	},
+	.digest = {
+		.data = {
+			0xBC, 0x71, 0xF5, 0x3B, 0x43, 0x28, 0x11, 0x7A,
+			0x32, 0xD2, 0xC9, 0x2D, 0x3B, 0xFA, 0xE0, 0x47,
+			0xA4, 0xD5, 0xEC, 0x81, 0xFB, 0x86, 0x6A, 0x11,
+			0x64, 0xF3, 0xF5, 0x82, 0x3B, 0x8E, 0x0A, 0xBB
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
 static const struct blockcipher_test_case hash_test_cases[] = {
 	{
 		.test_descr = "MD5 Digest",
@@ -971,6 +1021,38 @@ static const struct blockcipher_test_case hash_test_cases[] = {
 		.test_data = &aes_xcbc_mac_test_vector,
 		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
 	},
+	{
+		.test_descr = "SM3 Digest",
+		.test_data = &sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM3 Digest Verify",
+		.test_data = &sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest Scatter Gather",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest Verify",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+	},
+	{
+		.test_descr = "HMAC-SM3 Digest Verify Scatter Gather",
+		.test_data = &hmac_sm3_test_vector,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
 
 };
 
diff --git a/app/test/test_cryptodev_sm4_test_vectors.h b/app/test/test_cryptodev_sm4_test_vectors.h
new file mode 100644
index 0000000000..582b333296
--- /dev/null
+++ b/app/test/test_cryptodev_sm4_test_vectors.h
@@ -0,0 +1,710 @@
+/* SPDX-License-Identifier: BSD-3-Clause
+ * Copyright(c) 2016-2019 Intel Corporation
+ */
+
+#ifndef TEST_CRYPTODEV_SM4_TEST_VECTORS_H_
+#define TEST_CRYPTODEV_SM4_TEST_VECTORS_H_
+
+static const uint8_t plaintext_sm4[] = {
+	0x81, 0x70, 0x99, 0x44, 0xE0, 0xCB, 0x2E, 0x1D,
+	0xB5, 0xB0, 0xA4, 0x77, 0xD1, 0xA8, 0x53, 0x9B,
+	0x0A, 0x87, 0x86, 0xE3, 0x4E, 0xAA, 0xED, 0x99,
+	0x30, 0x3E, 0xA6, 0x97, 0x55, 0x95, 0xB2, 0x45,
+	0x4D, 0x5D, 0x7F, 0x91, 0xEB, 0xBD, 0x4A, 0xCD,
+	0x72, 0x6C, 0x0E, 0x0E, 0x5E, 0x3E, 0xB5, 0x5E,
+	0xF6, 0xB1, 0x5A, 0x13, 0x8E, 0x22, 0x6E, 0xCD,
+	0x1B, 0x23, 0x5A, 0xB5, 0xBB, 0x52, 0x51, 0xC1,
+	0x33, 0x76, 0xB2, 0x64, 0x48, 0xA9, 0xAC, 0x1D,
+	0xE8, 0xBD, 0x52, 0x64, 0x8C, 0x0B, 0x5F, 0xFA,
+	0x94, 0x44, 0x86, 0x82, 0xE3, 0xCB, 0x4D, 0xE9,
+	0xCB, 0x8A, 0xE7, 0xF4, 0xBD, 0x41, 0x0E, 0xD5,
+	0x02, 0xB1, 0x25, 0x3A, 0xD0, 0x8B, 0xB2, 0x79,
+	0x69, 0xB5, 0xF0, 0x2B, 0x10, 0x02, 0x9D, 0x67,
+	0xD0, 0x7E, 0x18, 0x64, 0xD9, 0x4D, 0x4F, 0xCA,
+	0x20, 0x81, 0x51, 0xE2, 0x6F, 0x5F, 0xEE, 0x26
+};
+
+static const uint8_t ciphertext_sm4_ecb[] = {
+	0xCC, 0x62, 0x37, 0xA6, 0xA1, 0x35, 0x39, 0x75,
+	0xFF, 0xF5, 0xEE, 0x6A, 0xFD, 0xD7, 0x70, 0x15,
+	0xE1, 0x32, 0x23, 0x1F, 0x18, 0xB8, 0xC9, 0x16,
+	0x07, 0x27, 0x9C, 0x6C, 0x7F, 0x8F, 0x7F, 0xF6,
+	0xFD, 0xF1, 0xE4, 0x01, 0xEC, 0x7E, 0xD2, 0x60,
+	0xFD, 0xE7, 0x5C, 0xE5, 0xCF, 0x6E, 0xE7, 0x87,
+	0x97, 0x13, 0xCC, 0x01, 0x92, 0x1A, 0xC5, 0x62,
+	0xB5, 0x0C, 0x45, 0xE4, 0xDC, 0x9A, 0x30, 0xC2,
+	0x35, 0xED, 0x7D, 0x1A, 0x93, 0x0D, 0x33, 0x96,
+	0xD6, 0xE1, 0x8B, 0x77, 0x64, 0x40, 0x25, 0x3D,
+	0x9F, 0x4B, 0x8E, 0xFF, 0x3F, 0x11, 0x41, 0x58,
+	0x3B, 0x55, 0x4F, 0x59, 0x38, 0x2E, 0xAA, 0xBB,
+	0x8B, 0x42, 0xFA, 0x30, 0x38, 0x0D, 0x05, 0x3B,
+	0x86, 0x7C, 0xB0, 0xF2, 0x77, 0xCE, 0xEE, 0x1B,
+	0x78, 0xE8, 0x64, 0x7D, 0x59, 0xE3, 0xDA, 0x61,
+	0x05, 0x27, 0x56, 0x12, 0x95, 0x6D, 0x34, 0x9C
+};
+
+static const uint8_t ciphertext_sm4_cbc[] = {
+	0x60, 0x7A, 0xBE, 0xC9, 0xDA, 0xD7, 0x90, 0x73,
+	0xC7, 0x96, 0xDB, 0x34, 0x26, 0xFD, 0x2C, 0x2F,
+	0x8E, 0x39, 0xC7, 0x0B, 0x60, 0xB2, 0x3D, 0xBE,
+	0xF3, 0xA9, 0xA5, 0x46, 0x65, 0x26, 0x41, 0xB7,
+	0xAE, 0xC9, 0xC3, 0xAD, 0x8C, 0x9B, 0x95, 0x8D,
+	0x17, 0x53, 0x15, 0x35, 0x40, 0x2A, 0x8C, 0x6B,
+	0x02, 0x5C, 0xBD, 0x13, 0xA6, 0x7E, 0xB7, 0x63,
+	0xC0, 0x3F, 0xA8, 0xBC, 0x73, 0xDD, 0x0B, 0x7A,
+	0x88, 0x0E, 0xF8, 0xC5, 0x5B, 0x00, 0x07, 0xFF,
+	0x53, 0x7B, 0xF1, 0x6A, 0xA0, 0xFD, 0x0B, 0x89,
+	0x03, 0x91, 0x4D, 0xD8, 0xC4, 0xB3, 0xC0, 0x12,
+	0x41, 0xEB, 0xF7, 0xCB, 0x0A, 0xFB, 0x68, 0xE7,
+	0x8E, 0x0C, 0x14, 0x33, 0x1A, 0x34, 0x55, 0xDA,
+	0x04, 0xE2, 0xA3, 0xFC, 0xBE, 0xB6, 0xDF, 0x2B,
+	0x61, 0x33, 0x05, 0xBD, 0xBC, 0x0A, 0xB5, 0x8B,
+	0x6D, 0x0F, 0x1B, 0x7D, 0x5F, 0x24, 0x46, 0x0E
+};
+
+static const uint8_t ciphertext_sm4_cfb[] = {
+	0xC1, 0x27, 0x47, 0xC7, 0x44, 0x0C, 0x9A, 0x5C,
+	0x7D, 0x51, 0x26, 0x0D, 0x1B, 0xDB, 0x0D, 0x9D,
+	0x52, 0x59, 0xAD, 0x56, 0x05, 0xBE, 0x92, 0xD2,
+	0xB7, 0x62, 0xF5, 0xD7, 0x53, 0xD3, 0x12, 0x2A,
+	0x3C, 0x9A, 0x6E, 0x75, 0x80, 0xAB, 0x18, 0xE5,
+	0x72, 0x49, 0x9A, 0xD9, 0x80, 0x99, 0xC2, 0xE7,
+	0xCA, 0xD9, 0xDC, 0xD1, 0x45, 0x2F, 0xDD, 0xFC,
+	0x01, 0x7F, 0xB8, 0x01, 0x51, 0xCF, 0x43, 0x74,
+	0xC0, 0xBA, 0xFE, 0xB0, 0x28, 0xFE, 0xA4, 0xCD,
+	0x35, 0x0E, 0xEC, 0xE5, 0x70, 0xA2, 0x7F, 0x5D,
+	0x38, 0x1B, 0x50, 0xEB, 0x46, 0xBE, 0x61, 0x6E,
+	0x6C, 0x76, 0xF3, 0x65, 0x75, 0xCD, 0xA1, 0xBB,
+	0x9F, 0xFA, 0x7B, 0x86, 0x12, 0x87, 0x04, 0xEB,
+	0x00, 0x24, 0x81, 0xE7, 0x91, 0xFC, 0x1B, 0xC7,
+	0xA6, 0xB2, 0x67, 0xE2, 0x6E, 0x88, 0x8F, 0xB6,
+	0x4C, 0x45, 0x96, 0xEF, 0xBF, 0x4C, 0x26, 0x69
+};
+
+static const uint8_t ciphertext_sm4_ofb[] = {
+	0xC1, 0x27, 0x47, 0xC7, 0x44, 0x0C, 0x9A, 0x5C,
+	0x7D, 0x51, 0x26, 0x0D, 0x1B, 0xDB, 0x0D, 0x9D,
+	0x0F, 0x0C, 0xAD, 0xA0, 0x2D, 0x18, 0x0B, 0x3C,
+	0x54, 0xA9, 0x87, 0x86, 0xBC, 0x6B, 0xF9, 0xFB,
+	0x18, 0x68, 0x51, 0x1E, 0xB2, 0x53, 0x1D, 0xD5,
+	0x7F, 0x4B, 0xED, 0xB8, 0xCA, 0x8E, 0x81, 0xCE,
+	0xE1, 0x16, 0x7F, 0x84, 0x69, 0xD1, 0x15, 0xCE,
+	0x84, 0xF0, 0xB0, 0x3A, 0x21, 0xF2, 0x85, 0xA2,
+	0xEB, 0x2F, 0xDF, 0x34, 0x52, 0x62, 0x42, 0x87,
+	0xFA, 0x7F, 0x02, 0x2A, 0xC2, 0xD9, 0xE4, 0xB0,
+	0x8D, 0xC5, 0x52, 0xEC, 0x3D, 0x96, 0x3F, 0xD3,
+	0x8C, 0x39, 0x9C, 0x0F, 0xD9, 0x66, 0xDD, 0x29,
+	0x90, 0x00, 0x5D, 0x4F, 0x4D, 0x82, 0x2A, 0x47,
+	0x9E, 0x7E, 0x46, 0x87, 0x84, 0xE8, 0xDD, 0xAE,
+	0xB3, 0x03, 0xF8, 0xE8, 0x7B, 0xA6, 0xC9, 0x9A,
+	0x56, 0x9C, 0xC7, 0x82, 0x1E, 0x9A, 0x9D, 0x13
+};
+
+static const uint8_t ciphertext_sm4_ctr[] = {
+	0xC1, 0x27, 0x47, 0xC7, 0x44, 0x0C, 0x9A, 0x5C,
+	0x7D, 0x51, 0x26, 0x0D, 0x1B, 0xDB, 0x0D, 0x9D,
+	0xC3, 0x75, 0xCE, 0xBB, 0x63, 0x9A, 0x5B, 0x0C,
+	0xED, 0x64, 0x3F, 0x33, 0x80, 0x8F, 0x97, 0x40,
+	0xB7, 0x5C, 0xA7, 0xFE, 0x2F, 0x7F, 0xFB, 0x20,
+	0x13, 0xEC, 0xDC, 0xBC, 0x96, 0xC8, 0x05, 0xF0,
+	0xA4, 0x95, 0xC4, 0x0A, 0xB7, 0x1B, 0x18, 0xB4,
+	0xDA, 0x35, 0xFF, 0xA5, 0xB5, 0x90, 0x1B, 0x07,
+	0x5C, 0x5B, 0x91, 0x36, 0xF0, 0xC9, 0xFE, 0xFB,
+	0xC4, 0x71, 0xD6, 0x3B, 0x03, 0x28, 0x62, 0xB9,
+	0x22, 0x7A, 0x97, 0xC9, 0x54, 0xC0, 0x8C, 0x71,
+	0xEC, 0x8F, 0xE1, 0xBB, 0x56, 0xAE, 0xAB, 0x16,
+	0xF6, 0x57, 0x76, 0x65, 0xC2, 0x4B, 0xE0, 0x46,
+	0x4E, 0x13, 0x77, 0x50, 0x91, 0x24, 0x76, 0xD9,
+	0xB7, 0x16, 0xFF, 0x9E, 0xD0, 0x2E, 0x14, 0x23,
+	0x27, 0xF4, 0x99, 0x03, 0xDA, 0x1C, 0x52, 0x04
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_cbc = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CBC,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_cbc,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_ctr = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CTR,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_ctr,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_ecb = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_ECB,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_ecb,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_ofb = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_OFB,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_ofb,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_data
+sm4_test_data_cfb = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CFB,
+	.cipher_key = {
+		.data = {
+			0xE0, 0x70, 0x99, 0xF1, 0xBF, 0xAF, 0xFD, 0x7F,
+			0x24, 0x0C, 0xD7, 0x90, 0xCA, 0x4F, 0xE1, 0x34
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xC7, 0x2B, 0x65, 0x91, 0xA0, 0xD7, 0xDE, 0x8F,
+			0x6B, 0x40, 0x72, 0x33, 0xAD, 0x35, 0x81, 0xD6
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4,
+		.len = 128
+	},
+	.ciphertext = {
+		.data = ciphertext_sm4_cfb,
+		.len = 128
+	},
+};
+
+static const struct blockcipher_test_case sm4_cipheronly_test_cases[] = {
+	{
+		.test_descr = "SM4-CBC Encryption",
+		.test_data = &sm4_test_data_cbc,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-CBC Decryption",
+		.test_data = &sm4_test_data_cbc,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-CTR Encryption",
+		.test_data = &sm4_test_data_ctr,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-CTR Decryption",
+		.test_data = &sm4_test_data_ctr,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-ECB Encryption",
+		.test_data = &sm4_test_data_ecb,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-ECB Decryption",
+		.test_data = &sm4_test_data_ecb,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-OFB Encryption",
+		.test_data = &sm4_test_data_ofb,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-OFB Decryption",
+		.test_data = &sm4_test_data_ofb,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+	{
+		.test_descr = "SM4-CFB Encryption",
+		.test_data = &sm4_test_data_cfb,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENCRYPT,
+	},
+	{
+		.test_descr = "SM4-CFB Decryption",
+		.test_data = &sm4_test_data_cfb,
+		.op_mask = BLOCKCIPHER_TEST_OP_DECRYPT,
+	},
+};
+
+static const uint8_t plaintext_sm4_common[] = {
+	"What a lousy earth! He wondered how many people were destitute that"
+};
+
+static const uint8_t ciphertext64_sm4_cbc[] = {
+	0x5D, 0x93, 0x4E, 0x50, 0xDC, 0x26, 0x03, 0xB5,
+	0x6C, 0xFC, 0xB7, 0x09, 0x11, 0x28, 0x2F, 0xF7,
+	0x6C, 0xB6, 0xE6, 0xCC, 0xB8, 0xC5, 0x01, 0x5F,
+	0xBE, 0x89, 0xF8, 0xD3, 0xE8, 0xCD, 0x51, 0xC6,
+	0x17, 0x31, 0x07, 0xDE, 0xA5, 0x8F, 0xFD, 0x79,
+	0x2A, 0xAC, 0xAC, 0x90, 0x47, 0x8D, 0x0F, 0x16,
+	0x66, 0xCF, 0x16, 0xF1, 0xE2, 0x4C, 0x79, 0x4A,
+	0x6B, 0x5D, 0x6C, 0xAB, 0x98, 0x2B, 0xDB, 0xF8
+};
+
+/* test vectors */
+static const uint8_t plaintext64_sm4_ctr[] = {
+	0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
+	0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
+	0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C,
+	0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51,
+	0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11,
+	0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF,
+	0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17,
+	0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10
+};
+
+static const uint8_t ciphertext64_sm4_ctr[] = {
+	0x14, 0xAE, 0x4A, 0x72, 0xB9, 0x7A, 0x93, 0xCE,
+	0x12, 0x16, 0xCC, 0xD9, 0x98, 0xE3, 0x71, 0xC1,
+	0x60, 0xF7, 0xEF, 0x8B, 0x63, 0x44, 0xBD, 0x6D,
+	0xA1, 0x99, 0x25, 0x05, 0xE5, 0xFC, 0x21, 0x9B,
+	0x0B, 0xF0, 0x57, 0xF8, 0x6C, 0x5D, 0x75, 0x10,
+	0x3C, 0x0F, 0x46, 0x51, 0x9C, 0x7F, 0xB2, 0xE7,
+	0x29, 0x28, 0x05, 0x03, 0x5A, 0xDB, 0x9A, 0x90,
+	0xEC, 0xEF, 0x14, 0x53, 0x59, 0xD7, 0xCF, 0x0E
+};
+
+static const struct blockcipher_test_data sm4_test_data_1 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CTR,
+	.cipher_key = {
+		.data = {
+			0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+			0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+			0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext64_sm4_ctr,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_ctr,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0x3A, 0x90, 0x8E, 0x9E, 0x07, 0x48, 0xBE, 0xFE,
+			0x29, 0xB9, 0x61, 0xD8, 0x1A, 0x01, 0x5E, 0x34,
+			0x98, 0x1A, 0x35, 0xE5, 0x26, 0x1A, 0x28, 0x1E,
+			0xB1, 0xDC, 0xDB, 0xEB, 0xC7, 0x16, 0xF9, 0x9E
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+/* test vectors */
+static const uint8_t plaintext64_sm4_cfb[] = {
+	0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
+	0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
+	0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C,
+	0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51,
+	0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11,
+	0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF,
+	0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17,
+	0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10
+};
+
+static const uint8_t ciphertext64_sm4_cfb[] = {
+	0x14, 0xAE, 0x4A, 0x72, 0xB9, 0x7A, 0x93, 0xCE,
+	0x12, 0x16, 0xCC, 0xD9, 0x98, 0xE3, 0x71, 0xC1,
+	0xAA, 0x8A, 0x2C, 0x8C, 0x61, 0x89, 0x6B, 0x8B,
+	0x7C, 0xF8, 0x32, 0x6A, 0xEB, 0xAC, 0xD4, 0x0C,
+	0xD1, 0x5D, 0xFA, 0x1D, 0xFD, 0x17, 0x67, 0x02,
+	0x06, 0xCD, 0x38, 0x2C, 0x4D, 0x04, 0xF3, 0x96,
+	0x2F, 0x85, 0x5C, 0x3F, 0xBB, 0x79, 0x56, 0xA9,
+	0xC4, 0x6F, 0x34, 0xB3, 0xBE, 0xEC, 0xCA, 0x40
+};
+
+static const struct blockcipher_test_data sm4_test_data_2 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CFB,
+	.cipher_key = {
+		.data = {
+			0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+			0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+			0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext64_sm4_cfb,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_cfb,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0x6F, 0x7C, 0xFA, 0x6D, 0x02, 0x5D, 0xE2, 0x4B,
+			0x4A, 0xEE, 0xC6, 0x67, 0x0B, 0xD3, 0xCF, 0xBD,
+			0x64, 0x8F, 0x01, 0x17, 0x19, 0xD6, 0xFB, 0xEC,
+			0x3A, 0x27, 0xE8, 0x0F, 0x51, 0xA3, 0xE2, 0x3F
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+/* test vectors */
+static const uint8_t plaintext64_sm4_ofb[] = {
+	0x6B, 0xC1, 0xBE, 0xE2, 0x2E, 0x40, 0x9F, 0x96,
+	0xE9, 0x3D, 0x7E, 0x11, 0x73, 0x93, 0x17, 0x2A,
+	0xAE, 0x2D, 0x8A, 0x57, 0x1E, 0x03, 0xAC, 0x9C,
+	0x9E, 0xB7, 0x6F, 0xAC, 0x45, 0xAF, 0x8E, 0x51,
+	0x30, 0xC8, 0x1C, 0x46, 0xA3, 0x5C, 0xE4, 0x11,
+	0xE5, 0xFB, 0xC1, 0x19, 0x1A, 0x0A, 0x52, 0xEF,
+	0xF6, 0x9F, 0x24, 0x45, 0xDF, 0x4F, 0x9B, 0x17,
+	0xAD, 0x2B, 0x41, 0x7B, 0xE6, 0x6C, 0x37, 0x10
+};
+
+static const uint8_t ciphertext64_sm4_ofb[] = {
+	0x14, 0xAE, 0x4A, 0x72, 0xB9, 0x7A, 0x93, 0xCE,
+	0x12, 0x16, 0xCC, 0xD9, 0x98, 0xE3, 0x71, 0xC1,
+	0x94, 0x54, 0x3E, 0x9A, 0x3A, 0x0A, 0x22, 0x63,
+	0x22, 0xE8, 0xA5, 0xF3, 0x82, 0xB9, 0x14, 0x2D,
+	0xEF, 0x5F, 0x94, 0xCB, 0x49, 0x17, 0xEF, 0xA4,
+	0xD9, 0xCF, 0x3F, 0xC3, 0x32, 0x30, 0x90, 0x11,
+	0x12, 0x61, 0x52, 0xCC, 0xEC, 0x43, 0x61, 0xF2,
+	0x6F, 0x1E, 0x1A, 0x8D, 0xB4, 0x9D, 0x2F, 0xC4
+};
+
+static const struct blockcipher_test_data sm4_test_data_3 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_OFB,
+	.cipher_key = {
+		.data = {
+			0x2B, 0x7E, 0x15, 0x16, 0x28, 0xAE, 0xD2, 0xA6,
+			0xAB, 0xF7, 0x15, 0x88, 0x09, 0xCF, 0x4F, 0x3C
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0xF0, 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7,
+			0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext64_sm4_ofb,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_ofb,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0xA7, 0x6F, 0x7D, 0xB5, 0xFB, 0x35, 0x92, 0x82,
+			0x97, 0xB7, 0x9B, 0xBF, 0xA9, 0xCE, 0xA8, 0x4C,
+			0x5A, 0xC5, 0x53, 0x62, 0x9F, 0x03, 0x54, 0x88,
+			0x7D, 0xFE, 0x2D, 0xD3, 0x9C, 0xFB, 0x56, 0xED
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+static const struct blockcipher_test_data sm4_test_data_4 = {
+	.crypto_algo = RTE_CRYPTO_CIPHER_SM4_CBC,
+	.cipher_key = {
+		.data = {
+			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
+			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
+		},
+		.len = 16
+	},
+	.iv = {
+		.data = {
+			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
+			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
+		},
+		.len = 16
+	},
+	.plaintext = {
+		.data = plaintext_sm4_common,
+		.len = 64
+	},
+	.ciphertext = {
+		.data = ciphertext64_sm4_cbc,
+		.len = 64
+	},
+	.auth_algo = RTE_CRYPTO_AUTH_SM3_HMAC,
+	.auth_key = {
+		.data = {
+			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
+			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
+			0xDE, 0xF4, 0xDE, 0xAD
+		},
+		.len = 20
+	},
+	.digest = {
+		.data = {
+			0xA7, 0x87, 0x94, 0x53, 0x17, 0xAE, 0xF9, 0xCD,
+			0x8A, 0x60, 0x34, 0xFB, 0x9F, 0x07, 0xED, 0x28,
+			0x04, 0x13, 0x8C, 0xD4, 0x48, 0x83, 0x4A, 0xBA,
+			0xB8, 0xE8, 0x45, 0xDB, 0xE0, 0x66, 0xF9, 0xDA
+		},
+		.len = 32,
+		.truncated_len = 16
+	}
+};
+
+static const struct blockcipher_test_case sm4_chain_test_cases[] = {
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CBC HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_4,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CTR HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_1,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-CFB HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_2,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Encryption Digest",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Decryption Digest Verify",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Encryption Digest Scatter Gather",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG |
+			BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Decryption Digest Verify Scatter Gather",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_SG,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Encryption Digest OOP",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_ENC_AUTH_GEN,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+	{
+		.test_descr = "SM4-OFB HMAC-SM3 Decryption Digest Verify OOP",
+		.test_data = &sm4_test_data_3,
+		.op_mask = BLOCKCIPHER_TEST_OP_AUTH_VERIFY_DEC,
+		.feature_mask = BLOCKCIPHER_TEST_FEATURE_OOP,
+	},
+};
+
+#endif
-- 
2.19.0.rc0.windows.1


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2023-05-25  9:46 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-03-16  3:10 [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Sunyang Wu
2023-03-16  3:10 ` [PATCH 2/2] test/crypto: Add SM3/SM4 test vectors for verification in test app Sunyang Wu
2023-03-16 10:42 ` [EXT] [PATCH 1/2] lib/cryptodev/: Add SM3_HMAC/SM4_CFB/SM4_OFB support in DPDK Akhil Goyal
2023-03-18 13:00   ` 回复: " Sunyang Wu
2023-04-19 19:41     ` Kusztal, ArkadiuszX
2023-05-17  7:04 ` Akhil Goyal
2023-05-25  8:27   ` Akhil Goyal
2023-05-25  9:00     ` 回复: " Sunyang Wu
2023-05-25  9:04       ` Akhil Goyal
2023-05-25  9:25         ` 回复: " Sunyang Wu
2023-05-25  9:45           ` Akhil Goyal
2023-05-25  8:52 Sunyang Wu
2023-05-25  8:52 ` [PATCH 2/2] test/crypto: Add SM3/SM4 test vectors for verification in test app Sunyang Wu

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.