crypto/ipsec_mb: add SM4 GCM support
PATCH 1/2 crypto/ipsec_mb: add SM4 GCM support
This patch introduces SM4 GCM algorithm support to the AESNI_MB PMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.
--- doc/guides/cryptodevs/aesni_mb.rst | 1 + doc/guides/cryptodevs/features/aesni_mb.ini | 1 + doc/guides/cryptodevs/features/default.ini | 2 ++ doc/guides/rel_notes/release_25_03.rst | 4 +++ drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 37 +++++++++++++++++++-- drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h | 30 +++++++++++++++++ lib/cryptodev/rte_crypto_sym.h | 4 ++- lib/cryptodev/rte_cryptodev.c | 3 +- 8 files changed, 78 insertions(+), 4 deletions(-)
doc/guides/cryptodevs/aesni_mb.rst +1 -0
@@ -67,6 +67,7 @@ AEAD algorithms: * RTE_CRYPTO_AEAD_AES_CCM * RTE_CRYPTO_AEAD_AES_GCM * RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +* RTE_CRYPTO_AEAD_SM4_GCM Protocol offloads:
doc/guides/cryptodevs/features/aesni_mb.ini +1 -0
@@ -80,6 +80,7 @@ AES GCM (128) = Y AES GCM (192) = Y AES GCM (256) = Y CHACHA20-POLY1305 = Y +SM4 GCM = Y ; ; Supported Asymmetric algorithms of the 'aesni_mb' crypto driver. ;
doc/guides/cryptodevs/features/default.ini +2 -0
@@ -118,6 +118,8 @@ AES CCM (128) = AES CCM (192) = AES CCM (256) = CHACHA20-POLY1305 = +SM4 GCM = + ; ; Supported Asymmetric algorithms of a default crypto driver. ;
doc/guides/rel_notes/release_25_03.rst +4 -0
@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +**Updated IPsec_MB crypto driver.** + + * Added support for the SM4 GCM algorithm. + Removed Items -------------
drivers/crypto/ipsec_mb/pmd_aesni_mb.c +35 -2
@@ -20,7 +20,8 @@ is_aead_algo(IMB_HASH_ALG hash_alg, IMB_CIPHER_MODE cipher_mode) {return (hash_alg ==IMB_AUTH_CHACHA20_POLY1305 || hash_alg ==IMB_AUTH_AES_CCM || - cipher_mode ==IMB_CIPHER_GCM ); + cipher_mode ==IMB_CIPHER_GCM || + cipher_mode ==IMB_CIPHER_SM4_GCM ); }/** Set session authentication parameters */
@@ -602,7 +603,7 @@ aesni_mb_set_session_cipher_parameters(const IMB_MGR *mb_mgr, }static int -aesni_mb_set_session_aead_parameters (const IMB_MGR *mb_mgr, +aesni_mb_set_session_aead_parameters (IMB_MGR *mb_mgr,struct aesni_mb_session *sess,const struct rte_crypto_sym_xform *xform) {
@@ -720,6 +721,21 @@ aesni_mb_set_session_aead_parameters(const IMB_MGR *mb_mgr,return -EINVAL ; }break ; + +case RTE_CRYPTO_AEAD_SM4_GCM : + sess->template_job.cipher_mode =IMB_CIPHER_SM4_GCM ; + sess->template_job.hash_alg =IMB_AUTH_SM4_GCM ; + sess->template_job.u.GCM.aad_len_in_bytes = xform->aead.aad_length; + +if (xform->aead.key.length !=16 ) { +IPSEC_MB_LOG (ERR ,"Invalid key length" ); +return -EINVAL ; + } + sess->template_job.key_len_in_bytes =16 ; +imb_sm4_gcm_pre (mb_mgr, xform->aead.key.data, &sess->cipher.gcm_key); + sess->template_job.enc_keys = &sess->cipher.gcm_key; + sess->template_job.dec_keys = &sess->cipher.gcm_key; +break ;default :IPSEC_MB_LOG (ERR ,"Unsupported aead mode parameter" );return -ENOTSUP ;
@@ -1559,6 +1575,9 @@ set_mb_job_params(IMB_JOB *job, struct ipsec_mb_qp *qp,imb_set_session (mb_mgr, job); }break ; +case IMB_AUTH_SM4_GCM : + job->u.GCM.aad = op->sym->aead.aad.data; +break ;default :break ; }
@@ -1687,6 +1706,17 @@ set_mb_job_params(IMB_JOB *job, struct ipsec_mb_qp *qp, job->iv = rte_crypto_op_ctod_offset(op, uint8_t *, session->iv.offset);break ; +case IMB_AUTH_SM4_GCM : + job->hash_start_src_offset_in_bytes =0 ; +/* +* Adding offset here as there is a bug in the ipsec mb library +*/ + job->src += op->sym->aead.data.offset; + job->msg_len_to_hash_in_bytes = + op->sym->aead.data.length; + job->iv = rte_crypto_op_ctod_offset(op, uint8_t *, + session->iv.offset); +break ;default : job->hash_start_src_offset_in_bytes = auth_start_offset(op,
@@ -1732,6 +1762,9 @@ set_mb_job_params(IMB_JOB *job, struct ipsec_mb_qp *qp, job->msg_len_to_cipher_in_bytes =0 ; job->cipher_start_src_offset_in_bytes =0 ;break ; +case IMB_CIPHER_SM4_GCM : + job->msg_len_to_cipher_in_bytes = op->sym->aead.data.length; +break ;default : job->cipher_start_src_offset_in_bytes = op->sym->cipher.data.offset;
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +30 -0
@@ -826,6 +826,36 @@ static const struct rte_cryptodev_capabilities aesni_mb_capabilities[] = { }, } }, } }, + { /* SM4 GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD, + {.aead = { + .algo = RTE_CRYPTO_AEAD_SM4_GCM, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .aad_size = { + .min = 0, + .max = 65535, + .increment = 1, + }, + .iv_size = { + .min = 12, + .max = 12, + .increment = 0, + } + }, } + }, } + }, #endif RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() };
lib/cryptodev/rte_crypto_sym.h +3 -1
@@ -482,8 +482,10 @@ enum rte_crypto_aead_algorithm {/**< AES algorithm in CCM mode. */ RTE_CRYPTO_AEAD_AES_GCM ,/**< AES algorithm in GCM mode. */ -RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ,/**< Chacha20 cipher with poly1305 authenticator */ +RTE_CRYPTO_AEAD_SM4_GCM + /**< SM4 cipher with GCM mode */ };/** Symmetric AEAD Operations */
lib/cryptodev/rte_cryptodev.c +2 -1
@@ -168,7 +168,8 @@ static const char * crypto_aead_algorithm_strings[] = { [RTE_CRYPTO_AEAD_AES_CCM ] ="aes-ccm" , [RTE_CRYPTO_AEAD_AES_GCM ] ="aes-gcm" , - [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" + [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" , + [RTE_CRYPTO_AEAD_SM4_GCM ] ="sm4-gcm" };
Signature · 1 line
2.25.1
PATCH 2/2 app/test: add SM4 GCM tests
Added SM4-GCM tests for the AESNI MB PMD.
--- app/test/test_cryptodev.c | 158 +++++ app/test/test_cryptodev_aead_test_vectors.h | 708 ++++++++++++++++++++ 2 files changed, 866 insertions(+)
app/test/test_cryptodev.c +158 -0
@@ -1143,6 +1143,35 @@ chacha20_poly1305_testsuite_setup(void)return 0 ; } +static int +sm4_gcm_testsuite_setup (void ) +{ +struct crypto_testsuite_params *ts_params = &testsuite_params; +uint8_t dev_id = ts_params->valid_devs[0 ]; +struct rte_cryptodev_info dev_info; +const enum rte_crypto_aead_algorithm aeads[] = { +RTE_CRYPTO_AEAD_SM4_GCM + }; + +rte_cryptodev_info_get (dev_id, &dev_info); + +if (!(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO ) || + ((global_api_test_type ==CRYPTODEV_RAW_API_TEST ) && + !(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYM_RAW_DP ))) { +RTE_LOG (INFO ,USER1 ,"Feature flag requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +if (check_aead_capabilities_supported (aeads,RTE_DIM (aeads)) !=0 ) { +RTE_LOG (INFO ,USER1 ,"Capability requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +return 0 ; +} +static int snow3g_testsuite_setup (void ) {
@@ -17490,6 +17519,96 @@ test_chacha20_poly1305_encrypt_SGL_out_of_place(void) chacha20_poly1305_case_2.plaintext.len); } +static int +test_SM4_GCM_case_1 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_1); +} + +static int +test_SM4_GCM_case_2 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_2); +} + +static int +test_SM4_GCM_case_3 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_3); +} + +static int +test_SM4_GCM_case_4 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_4); +} + +static int +test_SM4_GCM_case_5 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_5); +} + +static int +test_SM4_GCM_case_6 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_6); +} + +static int +test_SM4_GCM_case_7 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_7); +} + +static int +test_SM4_GCM_case_8 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_8); +} + +static int +test_SM4_GCM_case_9 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_9); +} + +static int +test_SM4_GCM_case_10 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_10); +} + +static int +test_SM4_GCM_case_11 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_11); +} + +static int +test_SM4_GCM_case_12 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_12); +} + +static int +test_SM4_GCM_case_13 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_13); +} + +static int +test_SM4_GCM_case_14 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_14); +} + +static int +test_SM4_GCM_case_15 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_15); +} +#ifdef RTE_CRYPTO_SCHEDULER /* global AESNI worker IDs for the scheduler test */
@@ -19598,6 +19717,44 @@ static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = { } }; +static struct unit_test_suite cryptodev_sm4_gcm_testsuite = { + .suite_name ="SM4 GCM Test Suite" , + .setup = sm4_gcm_testsuite_setup, + .unit_test_cases = { +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_1), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_2), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_3), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_4), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_5), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_6), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_7), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_8), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_9), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_10), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_11), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_12), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_13), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_14), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_15), +TEST_CASES_END () + } +}; +static int run_cryptodev_testsuite (const char *pmd_name) {
@@ -19630,6 +19787,7 @@ run_cryptodev_testsuite(const char *pmd_name) &cryptodev_mixed_cipher_hash_testsuite, &cryptodev_negative_hmac_sha1_testsuite, &cryptodev_gen_testsuite, + &cryptodev_sm4_gcm_testsuite, #ifdef RTE_LIB_SECURITY &ipsec_proto_testsuite, &pdcp_proto_testsuite,
app/test/test_cryptodev_aead_test_vectors.h +708 -0
718 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v2 1/2 crypto/ipsec_mb: add SM4 GCM support
In reply to Brian DooleyThis patch introduces SM4 GCM algorithm support to the AESNI_MB PMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.
---
v2:
Added aad to cpu job params
Added ipsec mb version checks
--- doc/guides/cryptodevs/aesni_mb.rst | 1 + doc/guides/cryptodevs/features/aesni_mb.ini | 1 + doc/guides/cryptodevs/features/default.ini | 2 + doc/guides/rel_notes/release_25_03.rst | 4 ++ drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 54 ++++++++++++++++++++- drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h | 30 ++++++++++++ lib/cryptodev/rte_crypto_sym.h | 4 +- lib/cryptodev/rte_cryptodev.c | 3 +- 8 files changed, 95 insertions(+), 4 deletions(-)
doc/guides/cryptodevs/aesni_mb.rst +1 -0
@@ -67,6 +67,7 @@ AEAD algorithms: * RTE_CRYPTO_AEAD_AES_CCM * RTE_CRYPTO_AEAD_AES_GCM * RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +* RTE_CRYPTO_AEAD_SM4_GCM Protocol offloads:
doc/guides/cryptodevs/features/aesni_mb.ini +1 -0
@@ -80,6 +80,7 @@ AES GCM (128) = Y AES GCM (192) = Y AES GCM (256) = Y CHACHA20-POLY1305 = Y +SM4 GCM = Y ; ; Supported Asymmetric algorithms of the 'aesni_mb' crypto driver. ;
doc/guides/cryptodevs/features/default.ini +2 -0
@@ -118,6 +118,8 @@ AES CCM (128) = AES CCM (192) = AES CCM (256) = CHACHA20-POLY1305 = +SM4 GCM = + ; ; Supported Asymmetric algorithms of a default crypto driver. ;
doc/guides/rel_notes/release_25_03.rst +4 -0
@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +**Updated IPsec_MB crypto driver.** + + * Added support for the SM4 GCM algorithm. + Removed Items -------------
drivers/crypto/ipsec_mb/pmd_aesni_mb.c +52 -2
96 lines not on this page · raw message
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +30 -0
@@ -826,6 +826,36 @@ static const struct rte_cryptodev_capabilities aesni_mb_capabilities[] = { }, } }, } }, + { /* SM4 GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD, + {.aead = { + .algo = RTE_CRYPTO_AEAD_SM4_GCM, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .aad_size = { + .min = 0, + .max = 65535, + .increment = 1, + }, + .iv_size = { + .min = 12, + .max = 12, + .increment = 0, + } + }, } + }, } + }, #endif RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() };
lib/cryptodev/rte_crypto_sym.h +3 -1
@@ -482,8 +482,10 @@ enum rte_crypto_aead_algorithm {/**< AES algorithm in CCM mode. */ RTE_CRYPTO_AEAD_AES_GCM ,/**< AES algorithm in GCM mode. */ -RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ,/**< Chacha20 cipher with poly1305 authenticator */ +RTE_CRYPTO_AEAD_SM4_GCM + /**< SM4 cipher with GCM mode */ };/** Symmetric AEAD Operations */
lib/cryptodev/rte_cryptodev.c +2 -1
@@ -168,7 +168,8 @@ static const char * crypto_aead_algorithm_strings[] = { [RTE_CRYPTO_AEAD_AES_CCM ] ="aes-ccm" , [RTE_CRYPTO_AEAD_AES_GCM ] ="aes-gcm" , - [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" + [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" , + [RTE_CRYPTO_AEAD_SM4_GCM ] ="sm4-gcm" };
Signature · 1 line
2.25.1
PATCH v2 1/2 crypto/ipsec_mb: add SM4 GCM support
Added SM4-GCM tests for the AESNI MB PMD.
--- app/test/test_cryptodev.c | 158 +++++ app/test/test_cryptodev_aead_test_vectors.h | 708 ++++++++++++++++++++ 2 files changed, 866 insertions(+)
app/test/test_cryptodev.c +158 -0
@@ -1143,6 +1143,35 @@ chacha20_poly1305_testsuite_setup(void)return 0 ; } +static int +sm4_gcm_testsuite_setup (void ) +{ +struct crypto_testsuite_params *ts_params = &testsuite_params; +uint8_t dev_id = ts_params->valid_devs[0 ]; +struct rte_cryptodev_info dev_info; +const enum rte_crypto_aead_algorithm aeads[] = { +RTE_CRYPTO_AEAD_SM4_GCM + }; + +rte_cryptodev_info_get (dev_id, &dev_info); + +if (!(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO ) || + ((global_api_test_type ==CRYPTODEV_RAW_API_TEST ) && + !(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYM_RAW_DP ))) { +RTE_LOG (INFO ,USER1 ,"Feature flag requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +if (check_aead_capabilities_supported (aeads,RTE_DIM (aeads)) !=0 ) { +RTE_LOG (INFO ,USER1 ,"Capability requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +return 0 ; +} +static int snow3g_testsuite_setup (void ) {
@@ -17508,6 +17537,96 @@ test_chacha20_poly1305_encrypt_SGL_out_of_place(void) chacha20_poly1305_case_2.plaintext.len); } +static int +test_SM4_GCM_case_1 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_1); +} + +static int +test_SM4_GCM_case_2 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_2); +} + +static int +test_SM4_GCM_case_3 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_3); +} + +static int +test_SM4_GCM_case_4 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_4); +} + +static int +test_SM4_GCM_case_5 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_5); +} + +static int +test_SM4_GCM_case_6 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_6); +} + +static int +test_SM4_GCM_case_7 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_7); +} + +static int +test_SM4_GCM_case_8 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_8); +} + +static int +test_SM4_GCM_case_9 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_9); +} + +static int +test_SM4_GCM_case_10 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_10); +} + +static int +test_SM4_GCM_case_11 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_11); +} + +static int +test_SM4_GCM_case_12 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_12); +} + +static int +test_SM4_GCM_case_13 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_13); +} + +static int +test_SM4_GCM_case_14 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_14); +} + +static int +test_SM4_GCM_case_15 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_15); +} +#ifdef RTE_CRYPTO_SCHEDULER /* global AESNI worker IDs for the scheduler test */
@@ -19616,6 +19735,44 @@ static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = { } }; +static struct unit_test_suite cryptodev_sm4_gcm_testsuite = { + .suite_name ="SM4 GCM Test Suite" , + .setup = sm4_gcm_testsuite_setup, + .unit_test_cases = { +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_1), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_2), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_3), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_4), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_5), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_6), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_7), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_8), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_9), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_10), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_11), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_12), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_13), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_14), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_15), +TEST_CASES_END () + } +}; +static int run_cryptodev_testsuite (const char *pmd_name) {
@@ -19648,6 +19805,7 @@ run_cryptodev_testsuite(const char *pmd_name) &cryptodev_mixed_cipher_hash_testsuite, &cryptodev_negative_hmac_sha1_testsuite, &cryptodev_gen_testsuite, + &cryptodev_sm4_gcm_testsuite, #ifdef RTE_LIB_SECURITY &ipsec_proto_testsuite, &pdcp_proto_testsuite,
app/test/test_cryptodev_aead_test_vectors.h +708 -0
718 lines not on this page · raw message
Signature · 1 line
2.25.1
PATCH v3 1/2 crypto/ipsec_mb: add SM4 GCM support
In reply to Brian DooleyThis patch introduces SM4 GCM algorithm support to the AESNI_MB PMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.
---
v2:
Added aad to cpu job params
Added ipsec mb version checks
v3:
Fix naming for patchwork
--- doc/guides/cryptodevs/aesni_mb.rst | 1 + doc/guides/cryptodevs/features/aesni_mb.ini | 1 + doc/guides/cryptodevs/features/default.ini | 2 + doc/guides/rel_notes/release_25_03.rst | 4 ++ drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 54 ++++++++++++++++++++- drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h | 30 ++++++++++++ lib/cryptodev/rte_crypto_sym.h | 4 +- lib/cryptodev/rte_cryptodev.c | 3 +- 8 files changed, 95 insertions(+), 4 deletions(-)
doc/guides/cryptodevs/aesni_mb.rst +1 -0
@@ -67,6 +67,7 @@ AEAD algorithms: * RTE_CRYPTO_AEAD_AES_CCM * RTE_CRYPTO_AEAD_AES_GCM * RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +* RTE_CRYPTO_AEAD_SM4_GCM Protocol offloads:
doc/guides/cryptodevs/features/aesni_mb.ini +1 -0
@@ -80,6 +80,7 @@ AES GCM (128) = Y AES GCM (192) = Y AES GCM (256) = Y CHACHA20-POLY1305 = Y +SM4 GCM = Y ; ; Supported Asymmetric algorithms of the 'aesni_mb' crypto driver. ;
doc/guides/cryptodevs/features/default.ini +2 -0
@@ -118,6 +118,8 @@ AES CCM (128) = AES CCM (192) = AES CCM (256) = CHACHA20-POLY1305 = +SM4 GCM = + ; ; Supported Asymmetric algorithms of a default crypto driver. ;
doc/guides/rel_notes/release_25_03.rst +4 -0
@@ -55,6 +55,10 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +**Updated IPsec_MB crypto driver.** + + * Added support for the SM4 GCM algorithm. + Removed Items -------------
drivers/crypto/ipsec_mb/pmd_aesni_mb.c +52 -2
96 lines not on this page · raw message
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +30 -0
@@ -826,6 +826,36 @@ static const struct rte_cryptodev_capabilities aesni_mb_capabilities[] = { }, } }, } }, + { /* SM4 GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD, + {.aead = { + .algo = RTE_CRYPTO_AEAD_SM4_GCM, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .aad_size = { + .min = 0, + .max = 65535, + .increment = 1, + }, + .iv_size = { + .min = 12, + .max = 12, + .increment = 0, + } + }, } + }, } + }, #endif RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() };
lib/cryptodev/rte_crypto_sym.h +3 -1
@@ -482,8 +482,10 @@ enum rte_crypto_aead_algorithm {/**< AES algorithm in CCM mode. */ RTE_CRYPTO_AEAD_AES_GCM ,/**< AES algorithm in GCM mode. */ -RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ,/**< Chacha20 cipher with poly1305 authenticator */ +RTE_CRYPTO_AEAD_SM4_GCM + /**< SM4 cipher with GCM mode */ };/** Symmetric AEAD Operations */
lib/cryptodev/rte_cryptodev.c +2 -1
@@ -168,7 +168,8 @@ static const char * crypto_aead_algorithm_strings[] = { [RTE_CRYPTO_AEAD_AES_CCM ] ="aes-ccm" , [RTE_CRYPTO_AEAD_AES_GCM ] ="aes-gcm" , - [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" + [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" , + [RTE_CRYPTO_AEAD_SM4_GCM ] ="sm4-gcm" };
Signature · 1 line
2.25.1
PATCH v3 2/2 app/test: add SM4 GCM tests
Added SM4-GCM tests for the AESNI MB PMD.
--- app/test/test_cryptodev.c | 158 +++++ app/test/test_cryptodev_aead_test_vectors.h | 708 ++++++++++++++++++++ 2 files changed, 866 insertions(+)
app/test/test_cryptodev.c +158 -0
@@ -1143,6 +1143,35 @@ chacha20_poly1305_testsuite_setup(void)return 0 ; } +static int +sm4_gcm_testsuite_setup (void ) +{ +struct crypto_testsuite_params *ts_params = &testsuite_params; +uint8_t dev_id = ts_params->valid_devs[0 ]; +struct rte_cryptodev_info dev_info; +const enum rte_crypto_aead_algorithm aeads[] = { +RTE_CRYPTO_AEAD_SM4_GCM + }; + +rte_cryptodev_info_get (dev_id, &dev_info); + +if (!(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO ) || + ((global_api_test_type ==CRYPTODEV_RAW_API_TEST ) && + !(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYM_RAW_DP ))) { +RTE_LOG (INFO ,USER1 ,"Feature flag requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +if (check_aead_capabilities_supported (aeads,RTE_DIM (aeads)) !=0 ) { +RTE_LOG (INFO ,USER1 ,"Capability requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +return 0 ; +} +static int snow3g_testsuite_setup (void ) {
@@ -17508,6 +17537,96 @@ test_chacha20_poly1305_encrypt_SGL_out_of_place(void) chacha20_poly1305_case_2.plaintext.len); } +static int +test_SM4_GCM_case_1 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_1); +} + +static int +test_SM4_GCM_case_2 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_2); +} + +static int +test_SM4_GCM_case_3 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_3); +} + +static int +test_SM4_GCM_case_4 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_4); +} + +static int +test_SM4_GCM_case_5 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_5); +} + +static int +test_SM4_GCM_case_6 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_6); +} + +static int +test_SM4_GCM_case_7 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_7); +} + +static int +test_SM4_GCM_case_8 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_8); +} + +static int +test_SM4_GCM_case_9 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_9); +} + +static int +test_SM4_GCM_case_10 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_10); +} + +static int +test_SM4_GCM_case_11 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_11); +} + +static int +test_SM4_GCM_case_12 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_12); +} + +static int +test_SM4_GCM_case_13 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_13); +} + +static int +test_SM4_GCM_case_14 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_14); +} + +static int +test_SM4_GCM_case_15 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_15); +} +#ifdef RTE_CRYPTO_SCHEDULER /* global AESNI worker IDs for the scheduler test */
@@ -19616,6 +19735,44 @@ static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = { } }; +static struct unit_test_suite cryptodev_sm4_gcm_testsuite = { + .suite_name ="SM4 GCM Test Suite" , + .setup = sm4_gcm_testsuite_setup, + .unit_test_cases = { +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_1), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_2), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_3), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_4), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_5), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_6), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_7), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_8), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_9), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_10), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_11), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_12), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_13), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_14), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_15), +TEST_CASES_END () + } +}; +static int run_cryptodev_testsuite (const char *pmd_name) {
@@ -19648,6 +19805,7 @@ run_cryptodev_testsuite(const char *pmd_name) &cryptodev_mixed_cipher_hash_testsuite, &cryptodev_negative_hmac_sha1_testsuite, &cryptodev_gen_testsuite, + &cryptodev_sm4_gcm_testsuite, #ifdef RTE_LIB_SECURITY &ipsec_proto_testsuite, &pdcp_proto_testsuite,
app/test/test_cryptodev_aead_test_vectors.h +708 -0
718 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH v3 2/2] app/test: add SM4 GCM tests
Quoted 9 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Monday 13 January 2025 17:10
Cc: [email protected]; [email protected]; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v3 2/2] app/test: add SM4 GCM tests
Quoted 3 lines
Added SM4-GCM tests for the AESNI MB PMD.
Signed-off-by Brian Dooley <[email protected]>
Recheck-request: iol-compile-amd64-testing
RE: [PATCH v3 2/2] app/test: add SM4 GCM tests
In reply to Brian DooleyHi Pablo,
Quoted 8 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Monday, January 13, 2025 6:10 PM
Cc: [email protected]; [email protected]; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v3 2/2] app/test: add SM4 GCM tests
Quoted 9 lines
Added SM4-GCM tests for the AESNI MB PMD.
Signed-off-by Brian Dooley <[email protected]>--- app/test/test_cryptodev.c | 158 +++++ app/test/test_cryptodev_aead_test_vectors.h | 708 ++++++++++++++++++++ 2 files changed, 866 insertions(+)
Just one comment below.
Thanks,
Pablo
...
app/test/test_cryptodev_aead_test_vectors.h static uint8_t ccm_aad_test_2[22] = { · line 55
Quoted 11 lines
b/app/test/test_cryptodev_aead_test_vectors.h
index73bfb8dad4..aacefe5ea4100644app/test/test_cryptodev_aead_test_vectors.h +3
-0@@ -50,6 +50,54 @@ static uint8_t ccm_aad_test_2[22] = { 0xA5, 0xB8, 0xFC, 0xBA, 0x00, 0x00 }; +static uint8_t sm4_gcm_aad_test_2[MAX_AAD_LENGTH ] = { +0x3f ,0x89 ,0x42 ,0x20 +};
MAX_AAD_LENGTH is pretty much 64KB. This is allocating too much memory unnecessarily, so I would limit to the actual size . You could use [] with no defined size, and that should work.
Quoted 1 line
app/test/test_cryptodev_aead_test_vectors.h +1
-0+
...
Hi Brian,
Quoted 19 lines
This patch introduces SM4 GCM algorithm support to the
AESNI_MBPMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.Signed-off-by Brian Dooley <[email protected]>---
v2:
Added aad to cpu job params
Added ipsec mb version checks
v3:
Fix naming for patchwork--- doc/guides/cryptodevs/aesni_mb.rst | 1 + doc/guides/cryptodevs/features/aesni_mb.ini | 1 + doc/guides/cryptodevs/features/default.ini | 2 + doc/guides/rel_notes/release_25_03.rst | 4 ++ drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 54 ++++++++++++++++++++- drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h | 30 ++++++++++++
Quoted 3 lines
lib/cryptodev/rte_crypto_sym.h | 4 +- lib/cryptodev/rte_cryptodev.c | 3 +- 8 files changed, 95 insertions(+), 4 deletions(-)
Split the cryptodev changes in a separate patch along with default.ini update.
Hi Brian,
Quoted 8 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Monday, January 13, 2025 6:10 PM
Cc: [email protected]; [email protected]; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v3 1/2]crypto/ipsec_mb: add SM4 GCM support
Quoted 5 lines
This patch introduces SM4 GCM algorithm support to the
AESNI_MBPMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.Signed-off-by Brian Dooley <[email protected]>---
A couple of comments below.
Thanks,
Pablo
...
Quoted 13 lines
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +6
-0@@ -826,6 +826,36 @@ static const struct rte_cryptodev_capabilities aesni_mb_capabilities[] = { }, } }, } }, + {/* SM4 GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type =RTE_CRYPTO_SYM_XFORM_AEAD , + {.aead = { + .algo = RTE_CRYPTO_AEAD_SM4_GCM,
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h static const struct rte_cryptodev_capabilities · line 845
Quoted 10 lines
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +10
-0+ .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0,
Digest size can be 1 to 16 bytes.
Quoted 22 lines
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +14
-0+ }, + .aad_size = { + .min = 0, + .max = 65535, + .increment = 1, + }, + .iv_size = { + .min = 12, + .max = 12, + .increment = 0, + } + }, } + }, } + },#endif RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST ()};
lib/cryptodev/rte_crypto_sym.h +0
-0
lib/cryptodev/rte_crypto_sym.h enum rte_crypto_aead_algorithm { · line 488
Quoted 8 lines
lib/cryptodev/rte_crypto_sym.h +3
-1@@ -482,8 +482,10 @@ enum rte_crypto_aead_algorithm {/**< AES algorithm in CCM mode. */ RTE_CRYPTO_AEAD_AES_GCM ,/**< AES algorithm in GCM mode. */ -RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ,/**< Chacha20 cipher with poly1305 authenticator */ +RTE_CRYPTO_AEAD_SM4_GCM +/**< SM4 cipher with GCM mode */
To keep consistency, "in GCM mode".
Quoted 1 line
lib/cryptodev/rte_crypto_sym.h +0
-0};
PATCH v4 1/3 crypto/ipsec_mb: add SM4 GCM support
In reply to Brian DooleyThis patch introduces SM4 GCM algorithm support to the AESNI_MB PMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.
---
v2:
Added aad to cpu job params
Added ipsec mb version checks
v3:
Fix naming for patchwork
v4:
Remove cryptodev changes to separate patch
--- doc/guides/cryptodevs/aesni_mb.rst | 1 + doc/guides/cryptodevs/features/aesni_mb.ini | 1 + doc/guides/rel_notes/release_25_03.rst | 4 ++ drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 54 ++++++++++++++++++++- drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h | 30 ++++++++++++ 5 files changed, 88 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/aesni_mb.rst +1 -0
@@ -67,6 +67,7 @@ AEAD algorithms: * RTE_CRYPTO_AEAD_AES_CCM * RTE_CRYPTO_AEAD_AES_GCM * RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +* RTE_CRYPTO_AEAD_SM4_GCM Protocol offloads:
doc/guides/cryptodevs/features/aesni_mb.ini +1 -0
@@ -80,6 +80,7 @@ AES GCM (128) = Y AES GCM (192) = Y AES GCM (256) = Y CHACHA20-POLY1305 = Y +SM4 GCM = Y ; ; Supported Asymmetric algorithms of the 'aesni_mb' crypto driver. ;
doc/guides/rel_notes/release_25_03.rst +4 -0
@@ -133,6 +133,10 @@ New Features See the :doc:`../compressdevs/zsda` guide for more details on the new driver. +* **Updated IPsec_MB crypto driver.** + + * Added support for the SM4 GCM algorithm. + Removed Items -------------
drivers/crypto/ipsec_mb/pmd_aesni_mb.c +52 -2
96 lines not on this page · raw message
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +30 -0
@@ -826,6 +826,36 @@ static const struct rte_cryptodev_capabilities aesni_mb_capabilities[] = { }, } }, } }, + { /* SM4 GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD, + {.aead = { + .algo = RTE_CRYPTO_AEAD_SM4_GCM, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .aad_size = { + .min = 0, + .max = 65535, + .increment = 1, + }, + .iv_size = { + .min = 12, + .max = 12, + .increment = 0, + } + }, } + }, } + }, #endif RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() };
Signature · 1 line
2.25.1
PATCH v4 2/3 cryptodev: add SM4 GCM
Added support for symmetric algorithm SM4 GCM in cryptodev.
--- doc/guides/cryptodevs/features/default.ini | 2 ++ lib/cryptodev/rte_crypto_sym.h | 4 +++- lib/cryptodev/rte_cryptodev.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/features/default.ini +2 -0
@@ -118,6 +118,8 @@ AES CCM (128) = AES CCM (192) = AES CCM (256) = CHACHA20-POLY1305 = +SM4 GCM = + ; ; Supported Asymmetric algorithms of a default crypto driver. ;
lib/cryptodev/rte_crypto_sym.h +3 -1
@@ -482,8 +482,10 @@ enum rte_crypto_aead_algorithm {/**< AES algorithm in CCM mode. */ RTE_CRYPTO_AEAD_AES_GCM ,/**< AES algorithm in GCM mode. */ -RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ,/**< Chacha20 cipher with poly1305 authenticator */ +RTE_CRYPTO_AEAD_SM4_GCM + /**< SM4 cipher with GCM mode */ };/** Symmetric AEAD Operations */
lib/cryptodev/rte_cryptodev.c +2 -1
@@ -168,7 +168,8 @@ static const char * crypto_aead_algorithm_strings[] = { [RTE_CRYPTO_AEAD_AES_CCM ] ="aes-ccm" , [RTE_CRYPTO_AEAD_AES_GCM ] ="aes-gcm" , - [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" + [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" , + [RTE_CRYPTO_AEAD_SM4_GCM ] ="sm4-gcm" };
Signature · 1 line
2.25.1
RE: [PATCH v4 2/3] cryptodev: add SM4 GCM
Quoted 38 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Wednesday, February 19, 2025 12:50 PM
To: Akhil Goyal <[email protected]>; Fan Zhang <[email protected]>
Cc: [email protected]; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v4 2/3] cryptodev: add SM4 GCMAdded support for symmetric algorithm SM4 GCM in cryptodev.
Signed-off-by Brian Dooley <[email protected]>--- doc/guides/cryptodevs/features/default.ini | 2 ++ lib/cryptodev/rte_crypto_sym.h | 4 +++- lib/cryptodev/rte_cryptodev.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-)doc/guides/cryptodevs/features/default.ini +2
-0@@ -118,6 +118,8 @@ AES CCM (128) = AES CCM (192) = AES CCM (256) = CHACHA20-POLY1305 = +SM4 GCM = + ; ; Supported Asymmetric algorithms of a default crypto driver. ;lib/cryptodev/rte_crypto_sym.h +0
-0
lib/cryptodev/rte_crypto_sym.h enum rte_crypto_aead_algorithm { · line 488
Quoted 8 lines
lib/cryptodev/rte_crypto_sym.h +3
-1@@ -482,8 +482,10 @@ enum rte_crypto_aead_algorithm {/**< AES algorithm in CCM mode. */ RTE_CRYPTO_AEAD_AES_GCM ,/**< AES algorithm in GCM mode. */ -RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ,/**< Chacha20 cipher with poly1305 authenticator */ +RTE_CRYPTO_AEAD_SM4_GCM +/**< SM4 cipher with GCM mode */
In GCM mode.
PATCH v4 3/3 app/test: add SM4 GCM tests
In reply to Brian DooleyAdded SM4-GCM tests for the AESNI MB PMD.
---
v4:
Remove MAX_AAD_LENGTH array length from test vectors
--- app/test/test_cryptodev.c | 158 +++++ app/test/test_cryptodev_aead_test_vectors.h | 708 ++++++++++++++++++++ 2 files changed, 866 insertions(+)
app/test/test_cryptodev.c +158 -0
@@ -1143,6 +1143,35 @@ chacha20_poly1305_testsuite_setup(void)return 0 ; } +static int +sm4_gcm_testsuite_setup (void ) +{ +struct crypto_testsuite_params *ts_params = &testsuite_params; +uint8_t dev_id = ts_params->valid_devs[0 ]; +struct rte_cryptodev_info dev_info; +const enum rte_crypto_aead_algorithm aeads[] = { +RTE_CRYPTO_AEAD_SM4_GCM + }; + +rte_cryptodev_info_get (dev_id, &dev_info); + +if (!(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO ) || + ((global_api_test_type ==CRYPTODEV_RAW_API_TEST ) && + !(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYM_RAW_DP ))) { +RTE_LOG (INFO ,USER1 ,"Feature flag requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +if (check_aead_capabilities_supported (aeads,RTE_DIM (aeads)) !=0 ) { +RTE_LOG (INFO ,USER1 ,"Capability requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +return 0 ; +} +static int snow3g_testsuite_setup (void ) {
@@ -17508,6 +17537,96 @@ test_chacha20_poly1305_encrypt_SGL_out_of_place(void) chacha20_poly1305_case_2.plaintext.len); } +static int +test_SM4_GCM_case_1 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_1); +} + +static int +test_SM4_GCM_case_2 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_2); +} + +static int +test_SM4_GCM_case_3 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_3); +} + +static int +test_SM4_GCM_case_4 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_4); +} + +static int +test_SM4_GCM_case_5 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_5); +} + +static int +test_SM4_GCM_case_6 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_6); +} + +static int +test_SM4_GCM_case_7 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_7); +} + +static int +test_SM4_GCM_case_8 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_8); +} + +static int +test_SM4_GCM_case_9 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_9); +} + +static int +test_SM4_GCM_case_10 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_10); +} + +static int +test_SM4_GCM_case_11 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_11); +} + +static int +test_SM4_GCM_case_12 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_12); +} + +static int +test_SM4_GCM_case_13 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_13); +} + +static int +test_SM4_GCM_case_14 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_14); +} + +static int +test_SM4_GCM_case_15 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_15); +} +#ifdef RTE_CRYPTO_SCHEDULER /* global AESNI worker IDs for the scheduler test */
@@ -19616,6 +19735,44 @@ static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = { } }; +static struct unit_test_suite cryptodev_sm4_gcm_testsuite = { + .suite_name ="SM4 GCM Test Suite" , + .setup = sm4_gcm_testsuite_setup, + .unit_test_cases = { +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_1), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_2), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_3), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_4), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_5), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_6), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_7), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_8), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_9), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_10), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_11), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_12), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_13), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_14), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_15), +TEST_CASES_END () + } +}; +static int run_cryptodev_testsuite (const char *pmd_name) {
@@ -19648,6 +19805,7 @@ run_cryptodev_testsuite(const char *pmd_name) &cryptodev_mixed_cipher_hash_testsuite, &cryptodev_negative_hmac_sha1_testsuite, &cryptodev_gen_testsuite, + &cryptodev_sm4_gcm_testsuite, #ifdef RTE_LIB_SECURITY &ipsec_proto_testsuite, &pdcp_proto_testsuite,
app/test/test_cryptodev_aead_test_vectors.h +708 -0
718 lines not on this page · raw message
Signature · 1 line
2.25.1
Hi Brian,
Quoted 9 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Wednesday, February 19, 2025 12:50 PM
To: Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Cc: [email protected]; [email protected]; Dooley, Brian <[email protected]>
Subject: [PATCH v4 1/3]crypto/ipsec_mb: add SM4 GCM support
Quoted 3 lines
This patch introduces SM4 GCM algorithm support to the
AESNI_MBPMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.
The first patch of this patchset should be the one adding SM4-GCM in cryptodev, so compilation is not broken between commits.
Quoted 10 lines
Signed-off-by Brian Dooley <[email protected]>---
v2:
Added aad to cpu job params
Added ipsec mb version checks
v3:
Fix naming for patchwork
v4:
Remove cryptodev changes to separate patch
---
...
Quoted 12 lines
+++
b/drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.hdrivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +6
-0@@ -826,6 +826,36 @@ static const struct rte_cryptodev_capabilities aesni_mb_capabilities[] = { }, } }, } }, + {/* SM4 GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type =RTE_CRYPTO_SYM_XFORM_AEAD , + {.aead = { + .algo = RTE_CRYPTO_AEAD_SM4_GCM,
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h static const struct rte_cryptodev_capabilities · line 845
Quoted 10 lines
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +10
-0+ .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .digest_size = { + .min = 16, + .max = 16, + .increment = 0,
Digest can be between 1 and 16 bytes.
PATCH v5 1/3 cryptodev: add SM4 GCM
In reply to Brian DooleyAdded support for symmetric algorithm SM4 GCM in cryptodev.
---
v5:
Change with GCM mode to in GCM mode
--- doc/guides/cryptodevs/features/default.ini | 2 ++ lib/cryptodev/rte_crypto_sym.h | 4 +++- lib/cryptodev/rte_cryptodev.c | 3 ++- 3 files changed, 7 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/features/default.ini +2 -0
@@ -118,6 +118,8 @@ AES CCM (128) = AES CCM (192) = AES CCM (256) = CHACHA20-POLY1305 = +SM4 GCM = + ; ; Supported Asymmetric algorithms of a default crypto driver. ;
lib/cryptodev/rte_crypto_sym.h +3 -1
@@ -482,8 +482,10 @@ enum rte_crypto_aead_algorithm {/**< AES algorithm in CCM mode. */ RTE_CRYPTO_AEAD_AES_GCM ,/**< AES algorithm in GCM mode. */ -RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ,/**< Chacha20 cipher with poly1305 authenticator */ +RTE_CRYPTO_AEAD_SM4_GCM + /**< SM4 cipher in GCM mode */ };/** Symmetric AEAD Operations */
lib/cryptodev/rte_cryptodev.c +2 -1
@@ -168,7 +168,8 @@ static const char * crypto_aead_algorithm_strings[] = { [RTE_CRYPTO_AEAD_AES_CCM ] ="aes-ccm" , [RTE_CRYPTO_AEAD_AES_GCM ] ="aes-gcm" , - [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" + [RTE_CRYPTO_AEAD_CHACHA20_POLY1305 ] ="chacha20-poly1305" , + [RTE_CRYPTO_AEAD_SM4_GCM ] ="sm4-gcm" };
Signature · 1 line
2.25.1
PATCH v5 2/3 crypto/ipsec_mb: add SM4 GCM support
This patch introduces SM4 GCM algorithm support to the AESNI_MB PMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.
---
v2:
Added aad to cpu job params
Added ipsec mb version checks
v3:
Fix naming for patchwork
v4:
Remove cryptodev changes to separate patch
v5:
Change digest_size min value and increment value
--- doc/guides/cryptodevs/aesni_mb.rst | 1 + doc/guides/cryptodevs/features/aesni_mb.ini | 1 + doc/guides/rel_notes/release_25_03.rst | 4 ++ drivers/crypto/ipsec_mb/pmd_aesni_mb.c | 55 ++++++++++++++++++++- drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h | 30 +++++++++++ 5 files changed, 89 insertions(+), 2 deletions(-)
doc/guides/cryptodevs/aesni_mb.rst +1 -0
@@ -67,6 +67,7 @@ AEAD algorithms: * RTE_CRYPTO_AEAD_AES_CCM * RTE_CRYPTO_AEAD_AES_GCM * RTE_CRYPTO_AEAD_CHACHA20_POLY1305 +* RTE_CRYPTO_AEAD_SM4_GCM Protocol offloads:
doc/guides/cryptodevs/features/aesni_mb.ini +1 -0
@@ -80,6 +80,7 @@ AES GCM (128) = Y AES GCM (192) = Y AES GCM (256) = Y CHACHA20-POLY1305 = Y +SM4 GCM = Y ; ; Supported Asymmetric algorithms of the 'aesni_mb' crypto driver. ;
doc/guides/rel_notes/release_25_03.rst +4 -0
@@ -133,6 +133,10 @@ New Features See the :doc:`../compressdevs/zsda` guide for more details on the new driver. +* **Updated IPsec_MB crypto driver.** + + * Added support for the SM4 GCM algorithm. + Removed Items -------------
drivers/crypto/ipsec_mb/pmd_aesni_mb.c +53 -2
97 lines not on this page · raw message
drivers/crypto/ipsec_mb/pmd_aesni_mb_priv.h +30 -0
@@ -826,6 +826,36 @@ static const struct rte_cryptodev_capabilities aesni_mb_capabilities[] = { }, } }, } }, + { /* SM4 GCM */ + .op = RTE_CRYPTO_OP_TYPE_SYMMETRIC, + {.sym = { + .xform_type = RTE_CRYPTO_SYM_XFORM_AEAD, + {.aead = { + .algo = RTE_CRYPTO_AEAD_SM4_GCM, + .block_size = 16, + .key_size = { + .min = 16, + .max = 16, + .increment = 0, + }, + .digest_size = { + .min = 1, + .max = 16, + .increment = 1, + }, + .aad_size = { + .min = 0, + .max = 65535, + .increment = 1, + }, + .iv_size = { + .min = 12, + .max = 12, + .increment = 0, + } + }, } + }, } + }, #endif RTE_CRYPTODEV_END_OF_CAPABILITIES_LIST() };
Signature · 1 line
2.25.1
Quoted 11 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Monday, February 24, 2025 6:00 PM
To: Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>
Cc: [email protected]; [email protected]; Dooley, Brian <[email protected]>
Subject: [PATCH v5 2/3]crypto/ipsec_mb: add SM4 GCM support
Quoted 4 lines
This patch introduces SM4 GCM algorithm support to the
AESNI_MBPMD. SM4 GCM is available in the v2.0 release of Intel IPsec MB.Signed-off-by Brian Dooley <[email protected]>
PATCH v5 3/3 app/test: add SM4 GCM tests
In reply to Brian DooleyAdded SM4-GCM tests for the AESNI MB PMD.
---
v4:
Remove MAX_AAD_LENGTH array length from test vectors
--- app/test/test_cryptodev.c | 158 +++++ app/test/test_cryptodev_aead_test_vectors.h | 708 ++++++++++++++++++++ 2 files changed, 866 insertions(+)
app/test/test_cryptodev.c +158 -0
@@ -1143,6 +1143,35 @@ chacha20_poly1305_testsuite_setup(void)return 0 ; } +static int +sm4_gcm_testsuite_setup (void ) +{ +struct crypto_testsuite_params *ts_params = &testsuite_params; +uint8_t dev_id = ts_params->valid_devs[0 ]; +struct rte_cryptodev_info dev_info; +const enum rte_crypto_aead_algorithm aeads[] = { +RTE_CRYPTO_AEAD_SM4_GCM + }; + +rte_cryptodev_info_get (dev_id, &dev_info); + +if (!(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO ) || + ((global_api_test_type ==CRYPTODEV_RAW_API_TEST ) && + !(dev_info.feature_flags &RTE_CRYPTODEV_FF_SYM_RAW_DP ))) { +RTE_LOG (INFO ,USER1 ,"Feature flag requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +if (check_aead_capabilities_supported (aeads,RTE_DIM (aeads)) !=0 ) { +RTE_LOG (INFO ,USER1 ,"Capability requirements for " +"SM4 GCM testsuite not met\n" ); +return TEST_SKIPPED ; + } + +return 0 ; +} +static int snow3g_testsuite_setup (void ) {
@@ -17508,6 +17537,96 @@ test_chacha20_poly1305_encrypt_SGL_out_of_place(void) chacha20_poly1305_case_2.plaintext.len); } +static int +test_SM4_GCM_case_1 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_1); +} + +static int +test_SM4_GCM_case_2 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_2); +} + +static int +test_SM4_GCM_case_3 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_3); +} + +static int +test_SM4_GCM_case_4 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_4); +} + +static int +test_SM4_GCM_case_5 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_5); +} + +static int +test_SM4_GCM_case_6 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_6); +} + +static int +test_SM4_GCM_case_7 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_7); +} + +static int +test_SM4_GCM_case_8 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_8); +} + +static int +test_SM4_GCM_case_9 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_9); +} + +static int +test_SM4_GCM_case_10 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_10); +} + +static int +test_SM4_GCM_case_11 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_11); +} + +static int +test_SM4_GCM_case_12 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_12); +} + +static int +test_SM4_GCM_case_13 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_13); +} + +static int +test_SM4_GCM_case_14 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_14); +} + +static int +test_SM4_GCM_case_15 (void ) +{ +return test_authenticated_encryption (&sm4_gcm_case_15); +} +#ifdef RTE_CRYPTO_SCHEDULER /* global AESNI worker IDs for the scheduler test */
@@ -19616,6 +19735,44 @@ static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = { } }; +static struct unit_test_suite cryptodev_sm4_gcm_testsuite = { + .suite_name ="SM4 GCM Test Suite" , + .setup = sm4_gcm_testsuite_setup, + .unit_test_cases = { +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_1), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_2), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_3), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_4), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_5), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_6), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_7), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_8), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_9), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_10), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_11), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_12), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_13), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_14), +TEST_CASE_ST (ut_setup, ut_teardown, + test_SM4_GCM_case_15), +TEST_CASES_END () + } +}; +static int run_cryptodev_testsuite (const char *pmd_name) {
@@ -19648,6 +19805,7 @@ run_cryptodev_testsuite(const char *pmd_name) &cryptodev_mixed_cipher_hash_testsuite, &cryptodev_negative_hmac_sha1_testsuite, &cryptodev_gen_testsuite, + &cryptodev_sm4_gcm_testsuite, #ifdef RTE_LIB_SECURITY &ipsec_proto_testsuite, &pdcp_proto_testsuite,
app/test/test_cryptodev_aead_test_vectors.h +708 -0
718 lines not on this page · raw message
Signature · 1 line
2.25.1
RE: [PATCH v5 3/3] app/test: add SM4 GCM tests
Quoted 10 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Monday, February 24, 2025 6:00 PM
To: Akhil Goyal <[email protected]>; Fan Zhang <[email protected]>
Cc: [email protected]; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v5 3/3] app/test: add SM4 GCM tests
Quoted 3 lines
Added SM4-GCM tests for the AESNI MB PMD.
Signed-off-by Brian Dooley <[email protected]>
RE: [PATCH v5 1/3] cryptodev: add SM4 GCM
In reply to Brian DooleyQuoted 10 lines
-----Original Message-----
From: Dooley, Brian <[email protected]>
Sent: Monday, February 24, 2025 6:00 PM
To: Akhil Goyal <[email protected]>; Fan Zhang <[email protected]>
Cc: [email protected]; Ji, Kai <[email protected]>; De Lara Guarch, Pablo <[email protected]>; Dooley, Brian <[email protected]>
Subject: [PATCH v5 1/3] cryptodev: add SM4 GCM
Quoted 3 lines
Added support for symmetric algorithm SM4 GCM in cryptodev.
Signed-off-by Brian Dooley <[email protected]>
RE: [EXTERNAL] [PATCH v5 1/3] cryptodev: add SM4 GCM
In reply to Brian DooleyQuoted 6 lines
Added support for symmetric algorithm SM4 GCM in cryptodev.
Signed-off-by Brian Dooley <[email protected]>---
v5:
Change with GCM mode to in GCM mode
Series applied to dpdk-next-crypto
Thanks.