common/cnxk: set key length setting for PDCP algos
PATCH 1/3 common/cnxk: set key length setting for PDCP algos
Set proper bits in the context based on key length for PDCP
drivers/common/cnxk/roc_se.c +10 -0
@@ -160,6 +160,13 @@ cpt_pdcp_mac_len_set(struct roc_se_zuc_snow3g_ctx *zs_ctx, uint16_t mac_len) {roc_se_pdcp_mac_len_type mac_type =0 ; +if (roc_model_is_cn9k ()) { +if (mac_len !=4 ) { +plt_err ("Only mac len 4 is supported on cn9k" ); +return -ENOTSUP ; + } + } +switch (mac_len) {case 4 : mac_type =ROC_SE_PDCP_MAC_LEN_32_BIT ;
@@ -230,6 +237,9 @@ roc_se_auth_key_set(struct roc_se_ctx *se_ctx, roc_se_auth_type type,case ROC_SE_ZUC_EIA3 : zs_ctx->zuc.otk_ctx.w0.s.alg_type =ROC_SE_PDCP_ALG_TYPE_ZUC ; + ret =cpt_pdcp_key_type_set (zs_ctx, key_len); +if (ret) +return ret; ret =cpt_pdcp_mac_len_set (zs_ctx, mac_len);if (ret)return ret;
Signature · 1 line
2.31.1
PATCH 2/3 crypto/cnxk: support for 256 bit key length in ZUC
Add support for 256 bit key length for ZUC in crpto_cn10k PMD. Add support for digest length of 8 and 16 bytes for ZUC with 256 bit key length.
doc/guides/rel_notes/release_21_11.rst +1 -0
@@ -68,6 +68,7 @@ New Features * Added Transport mode support in lookaside protocol (IPsec) for CN10K. * Added UDP encapsulation support in lookaside protocol (IPsec) for CN10K. * Added support for lookaside protocol (IPsec) offload for CN9K. + * Added support for ZUC algorithm with 256 bit key length for CN10K. * **Added support for event crypto adapter on Marvell CN10K and CN9K.**
drivers/crypto/cnxk/cnxk_cryptodev_capabilities.c +35 -0
@@ -860,6 +860,38 @@ cpt_caps_add(struct rte_cryptodev_capabilities cnxk_caps[], int *cur_pos, *cur_pos += nb_caps; } +static void +cn10k_crypto_caps_update (struct rte_cryptodev_capabilities cnxk_caps[]) +{ + +struct rte_cryptodev_capabilities *caps; +int i =0 ; + +while ((caps = &cnxk_caps[i++])->op !=RTE_CRYPTO_OP_TYPE_UNDEFINED ) { +if ((caps->op ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) && + (caps->sym.xform_type ==RTE_CRYPTO_SYM_XFORM_CIPHER ) && + (caps->sym.cipher.algo ==RTE_CRYPTO_CIPHER_ZUC_EEA3 )) { + + caps->sym.cipher.key_size.max =32 ; + caps->sym.cipher.key_size.increment =16 ; + caps->sym.cipher.iv_size.max =24 ; + caps->sym.cipher.iv_size.increment =8 ; + } + +if ((caps->op ==RTE_CRYPTO_OP_TYPE_SYMMETRIC ) && + (caps->sym.xform_type ==RTE_CRYPTO_SYM_XFORM_AUTH ) && + (caps->sym.auth.algo ==RTE_CRYPTO_AUTH_ZUC_EIA3 )) { + + caps->sym.auth.key_size.max =32 ; + caps->sym.auth.key_size.increment =16 ; + caps->sym.auth.digest_size.max =16 ; + caps->sym.auth.digest_size.increment =4 ; + caps->sym.auth.iv_size.max =24 ; + caps->sym.auth.iv_size.increment =8 ; + } + } +} +static void crypto_caps_populate (struct rte_cryptodev_capabilities cnxk_caps[],union cpt_eng_caps *hw_caps)
@@ -876,6 +908,9 @@ crypto_caps_populate(struct rte_cryptodev_capabilities cnxk_caps[],cpt_caps_add (cnxk_caps, &cur_pos, caps_null,RTE_DIM (caps_null));cpt_caps_add (cnxk_caps, &cur_pos, caps_end,RTE_DIM (caps_end)); + +if (roc_model_is_cn10k ()) +cn10k_crypto_caps_update (cnxk_caps); } const struct rte_cryptodev_capabilities *
drivers/crypto/cnxk/cnxk_se.h +12 -6
@@ -980,7 +980,7 @@ cpt_zuc_snow3g_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens,uint8_t pdcp_alg_type;uint32_t encr_offset, auth_offset;uint32_t encr_data_len, auth_data_len; -int flags, iv_len =16 ; +int flags, iv_len;uint64_t offset_ctrl;uint64_t *offset_vaddr;uint8_t *iv_s;
@@ -996,6 +996,9 @@ cpt_zuc_snow3g_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, cpt_inst_w4.s.opcode_minor = se_ctx->template_w4.s.opcode_minor;if (flags ==0x1 ) { + iv_s = params->auth_iv_buf; + iv_len = params->auth_iv_len; +/* * Microcode expects offsets in bytes * TODO: Rounding off
@@ -1016,9 +1019,10 @@ cpt_zuc_snow3g_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, encr_data_len =0 ; encr_offset =0 ; - - iv_s = params->auth_iv_buf; }else { + iv_s = params->iv_buf; + iv_len = params->cipher_iv_len; +/* EEA3 or UEA2 */ /* * Microcode expects offsets in bytes
@@ -1039,8 +1043,6 @@ cpt_zuc_snow3g_prep(uint32_t req_flags, uint64_t d_offs, uint64_t d_lens, auth_data_len =0 ; auth_offset =0 ; - - iv_s = params->iv_buf; }if (unlikely ((encr_offset >>16 ) || (auth_offset >>8 ))) {
@@ -1719,7 +1721,7 @@ fill_sess_cipher(struct rte_crypto_sym_xform *xform, struct cnxk_se_sess *sess)break ;case RTE_CRYPTO_CIPHER_ZUC_EEA3 : enc_type =ROC_SE_ZUC_EEA3 ; - cipher_key_len =16 ; + cipher_key_len = c_form->key.length; zsk_flag =ROC_SE_ZS_EA ;break ;case RTE_CRYPTO_CIPHER_AES_XTS :
@@ -2069,6 +2071,9 @@ fill_fc_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess,uint32_t iv_buf[4 ];int ret; + fc_params.cipher_iv_len = sess->iv_length; + fc_params.auth_iv_len = sess->auth_iv_length; +if (likely (sess->iv_length)) { flags |=ROC_SE_VALID_IV_BUF ; fc_params.iv_buf = rte_crypto_op_ctod_offset(cop, uint8_t *,
@@ -2379,6 +2384,7 @@ fill_digest_params(struct rte_crypto_op *cop, struct cnxk_se_sess *sess,*/ d_offs = auth_range_off; auth_range_off =0 ; + params.auth_iv_len = sess->auth_iv_length; params.auth_iv_buf =rte_crypto_op_ctod_offset ( cop, uint8_t *, sess->auth_iv_offset);if (sess->zsk_flag ==ROC_SE_K_F9 ) {
Signature · 1 line
2.31.1
PATCH 3/3 test/crypto: add ZUC test cases for 256 bit key
In reply to Vidya Sagar VelumuriAdd test cases for zuc 256 bit key.
Add test case for zuc 8 and 16 byte digest with 256 bit key mode
app/test/test_cryptodev.c +33 -2
@@ -2352,6 +2352,9 @@ create_wireless_algo_hash_session(uint8_t dev_id, status =rte_cryptodev_sym_session_init (dev_id, ut_params->sess, &ut_params->auth_xform, ts_params->session_priv_mpool); +if (status == -ENOTSUP ) +return TEST_SKIPPED ; +TEST_ASSERT_EQUAL (status,0 ,"session init failed" );TEST_ASSERT_NOT_NULL (ut_params->sess,"Session creation failed" );return 0 ;
@@ -2391,6 +2394,9 @@ create_wireless_algo_cipher_session(uint8_t dev_id, status =rte_cryptodev_sym_session_init (dev_id, ut_params->sess, &ut_params->cipher_xform, ts_params->session_priv_mpool); +if (status == -ENOTSUP ) +return TEST_SKIPPED ; +TEST_ASSERT_EQUAL (status,0 ,"session init failed" );TEST_ASSERT_NOT_NULL (ut_params->sess,"Session creation failed" );return 0 ;
@@ -5808,7 +5814,7 @@ test_zuc_encryption(const struct wireless_test_data *tdata)RTE_CRYPTO_CIPHER_ZUC_EEA3 , tdata->key.data, tdata->key.len, tdata->cipher_iv.len); -if (retval <0 ) +if (retval !=0 )return retval; ut_params->ibuf =rte_pktmbuf_alloc (ts_params->mbuf_pool);
@@ -6010,7 +6016,7 @@ test_zuc_authentication(const struct wireless_test_data *tdata) tdata->auth_iv.len, tdata->digest.len,RTE_CRYPTO_AUTH_OP_GENERATE , RTE_CRYPTO_AUTH_ZUC_EIA3); -if (retval <0 ) +if (retval !=0 )return retval;/* alloc mbuf and set payload */
@@ -6956,6 +6962,12 @@ test_zuc_encryption_test_case_6_sgl(void)return test_zuc_encryption_sgl (&zuc_test_case_cipher_193b); } +static int +test_zuc_encryption_test_case_7 (void ) +{ +return test_zuc_encryption (&zuc_test_case_cipher_800b_key_256b); +} +static int test_zuc_hash_generate_test_case_1 (void ) {
@@ -7004,6 +7016,18 @@ test_zuc_hash_generate_test_case_8(void)return test_zuc_authentication (&zuc_test_case_auth_584b); } +static int +test_zuc_hash_generate_test_case_9 (void ) +{ +return test_zuc_authentication (&zuc_test_case_auth_584b_mac_64b); +} + +static int +test_zuc_hash_generate_test_case_10 (void ) +{ +return test_zuc_authentication (&zuc_test_case_auth_2080b_mac_128b); +} +static int test_zuc_cipher_auth_test_case_1 (void ) {
@@ -14200,6 +14224,8 @@ static struct unit_test_suite cryptodev_zuc_testsuite = { test_zuc_encryption_test_case_5),TEST_CASE_ST (ut_setup, ut_teardown, test_zuc_encryption_test_case_6_sgl), +TEST_CASE_ST (ut_setup, ut_teardown, + test_zuc_encryption_test_case_7),/** ZUC authenticate (EIA3) */ TEST_CASE_ST(ut_setup, ut_teardown,
@@ -14218,6 +14244,11 @@ static struct unit_test_suite cryptodev_zuc_testsuite = { test_zuc_hash_generate_test_case_7),TEST_CASE_ST (ut_setup, ut_teardown, test_zuc_hash_generate_test_case_8), +TEST_CASE_ST (ut_setup, ut_teardown, + test_zuc_hash_generate_test_case_9), +TEST_CASE_ST (ut_setup, ut_teardown, + test_zuc_hash_generate_test_case_10), +/** ZUC alg-chain (EEA3/EIA3) */ TEST_CASE_ST(ut_setup, ut_teardown,
app/test/test_cryptodev_zuc_test_vectors.h +170 -0
182 lines not on this page · raw message
Signature · 1 line
2.31.1
Re: [dpdk-dev] [PATCH v1 3/3] test/crypto: add ZUC test cases for 256 bit key
Hi Vidya,
Quoted 11 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Vidya Sagar Velumuri
Sent: Wednesday, September 15, 2021 7:11 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Doherty, Declan <[email protected]>
Cc: [email protected]
Subject: [dpdk-dev] [PATCH v1 3/3] test/crypto: add ZUC test cases for 256 bit key
Quoted 4 lines
Add test cases for zuc 256 bit key.
Add test case for zuc 8 and 16 byte digest with 256 bit key modeSigned-off-by Vidya Sagar Velumuri <[email protected]>
I see you added some test vectors for ZUC-256 and they all contain 24 bytes of IV.
From the specs, I see that the IV is actually comprised of 23 full bytes or 25 bytes (where the first 17 are full and the last 8 contain 6 least significant bits each). Could you tell me where those 24 bytes are coming from? I think there could be a conflict here with other implementations.
Thanks,
Pablo
Re: [dpdk-dev] [PATCH v1 3/3] test/crypto: add ZUC test cases for 256 bit key
Hi Pablo,
________________________________
From: De Lara Guarch, Pablo <[email protected]>
Sent: 01 October 2021 17:38
To: Vidya Sagar Velumuri <[email protected]>; Ankur Dwivedi <[email protected]>; Anoob Joseph <[email protected]>; Tejasree Kondoj <[email protected]>; Nithin Kumar Dabilpuram <[email protected]>; Kiran Kumar Kokkilagadda <[email protected]>; Sunil Kumar Kori <[email protected]>; Satha Koteswara Rao Kottidi <[email protected]>; Akhil Goyal <[email protected]>; Doherty, Declan <[email protected]>
Cc: [email protected] <[email protected]>
Subject: [EXT] RE: [dpdk-dev] [PATCH v1 3/3] test/crypto: add ZUC test cases for 256 bit key
External Email
----------------------------------------------------------------------
Hi Vidya,
Quoted 11 lines
-----Original Message-----
From: dev <[email protected]> On Behalf Of Vidya Sagar Velumuri
Sent: Wednesday, September 15, 2021 7:11 AM
To: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Doherty, Declan <[email protected]>
Cc: [email protected]
Subject: [dpdk-dev] [PATCH v1 3/3] test/crypto: add ZUC test cases for 256 bit key
Quoted 4 lines
Add test cases for zuc 256 bit key.
Add test case for zuc 8 and 16 byte digest with 256 bit key modeSigned-off-by Vidya Sagar Velumuri <[email protected]>
I see you added some test vectors for ZUC-256 and they all contain 24 bytes of IV.
From the specs, I see that the IV is actually comprised of 23 full bytes or 25 bytes (where the first 17 are full and the last 8 contain 6 least significant bits each). Could you tell me where those 24 bytes are coming from? I think there could be a conflict here with other implementations.
[sagar]: yes, the IV should be 25 bytes. Will update the vectors with IV as per spec and push a new patch.
Thanks,
Pablo
Quoted 6 lines
Subject: [PATCH v1 1/3] common/cnxk: set key length setting for PDCP algos
Set proper bits in the context based on key length for PDCP
Signed-off-by Vidya Sagar Velumuri <[email protected]>
Series
Applied to dpdk-next-crypto
Thanks.