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

Function test_snow3g_encryption

dpdk/app/test/test_cryptodev.c:4252–4342  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4250}
4251
4252static int
4253test_snow3g_encryption(const struct snow3g_test_data *tdata)
4254{
4255 struct crypto_testsuite_params *ts_params = &testsuite_params;
4256 struct crypto_unittest_params *ut_params = &unittest_params;
4257
4258 int retval;
4259 uint8_t *plaintext, *ciphertext;
4260 unsigned plaintext_pad_len;
4261 unsigned plaintext_len;
4262 struct rte_cryptodev_info dev_info;
4263
4264 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4265 uint64_t feat_flags = dev_info.feature_flags;
4266
4267 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4268 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4269 printf("Device doesn't support RAW data-path APIs.\n");
4270 return TEST_SKIPPED;
4271 }
4272
4273 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4274 return TEST_SKIPPED;
4275
4276 /* Verify the capabilities */
4277 struct rte_cryptodev_sym_capability_idx cap_idx;
4278 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4279 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4280 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4281 &cap_idx) == NULL)
4282 return TEST_SKIPPED;
4283
4284 /* Create SNOW 3G session */
4285 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4286 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4287 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4288 tdata->key.data, tdata->key.len,
4289 tdata->cipher_iv.len);
4290 if (retval < 0)
4291 return retval;
4292
4293 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4294
4295 /* Clear mbuf payload */
4296 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4297 rte_pktmbuf_tailroom(ut_params->ibuf));
4298
4299 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4300 /* Append data which is padded to a multiple of */
4301 /* the algorithms block size */
4302 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4303 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4304 plaintext_pad_len);
4305 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4306
4307 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4308
4309 /* Create SNOW 3G operation */

Calls 14

rte_cryptodev_info_getFunction · 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