MCPcopy Create free account
hub / github.com/F-Stack/f-stack / test_zuc_cipher

Function test_zuc_cipher

dpdk/app/test/test_cryptodev.c:6120–6243  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6118}
6119
6120static int
6121test_zuc_cipher(const struct wireless_test_data *tdata,
6122 enum rte_crypto_cipher_operation direction)
6123{
6124 struct crypto_testsuite_params *ts_params = &testsuite_params;
6125 struct crypto_unittest_params *ut_params = &unittest_params;
6126
6127 int retval;
6128 uint8_t *plaintext = NULL;
6129 uint8_t *ciphertext = NULL;
6130 unsigned int plaintext_pad_len, ciphertext_pad_len;
6131 unsigned int plaintext_len = 0;
6132 unsigned int ciphertext_len = 0;
6133 struct rte_cryptodev_info dev_info;
6134
6135 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6136 uint64_t feat_flags = dev_info.feature_flags;
6137
6138 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6139 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6140 printf("Device doesn't support RAW data-path APIs.\n");
6141 return TEST_SKIPPED;
6142 }
6143
6144 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6145 return TEST_SKIPPED;
6146
6147 /* Check if device supports ZUC EEA3 */
6148 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6149 tdata->key.len, tdata->cipher_iv.len) < 0)
6150 return TEST_SKIPPED;
6151
6152 /* Create ZUC session */
6153 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6154 direction,
6155 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6156 tdata->key.data, tdata->key.len,
6157 tdata->cipher_iv.len);
6158 if (retval != 0)
6159 return retval;
6160
6161 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6162
6163 /* Clear mbuf payload */
6164 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6165 rte_pktmbuf_tailroom(ut_params->ibuf));
6166
6167 if (direction == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
6168 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6169 /* Append data which is padded to a multiple */
6170 /* of the algorithms block size */
6171 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6172 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6173 plaintext_pad_len);
6174 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6175
6176 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6177 } else {

Calls 14

rte_cryptodev_info_getFunction · 0.85
check_cipher_capabilityFunction · 0.85
rte_pktmbuf_allocFunction · 0.85
memsetFunction · 0.85
rte_pktmbuf_tailroomFunction · 0.85
ceil_byte_lengthFunction · 0.85
rte_pktmbuf_appendFunction · 0.85
debug_hexdumpFunction · 0.85
process_sym_raw_dp_opFunction · 0.85
process_crypto_requestFunction · 0.70

Tested by

no test coverage detected