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

Function create_aead_operation

dpdk/app/test/test_cryptodev.c:8774–8922  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8772}
8773
8774static int
8775create_aead_operation(enum rte_crypto_aead_operation op,
8776 const struct aead_test_data *tdata)
8777{
8778 struct crypto_testsuite_params *ts_params = &testsuite_params;
8779 struct crypto_unittest_params *ut_params = &unittest_params;
8780
8781 uint8_t *plaintext, *ciphertext;
8782 unsigned int aad_pad_len, plaintext_pad_len;
8783
8784 /* Generate Crypto op data structure */
8785 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8786 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8787 TEST_ASSERT_NOT_NULL(ut_params->op,
8788 "Failed to allocate symmetric crypto operation struct");
8789
8790 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8791
8792 /* Append aad data */
8793 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8794 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8795 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8796 aad_pad_len);
8797 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8798 "no room to append aad");
8799
8800 sym_op->aead.aad.phys_addr =
8801 rte_pktmbuf_iova(ut_params->ibuf);
8802 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8803 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8804 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data + 18,
8805 tdata->aad.len);
8806
8807 /* Append IV at the end of the crypto operation*/
8808 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8809 uint8_t *, IV_OFFSET);
8810
8811 /* Copy IV 1 byte after the IV pointer, according to the API */
8812 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8813 debug_hexdump(stdout, "iv:", iv_ptr + 1,
8814 tdata->iv.len);
8815 } else {
8816 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8817 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8818 aad_pad_len);
8819 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8820 "no room to append aad");
8821
8822 sym_op->aead.aad.phys_addr =
8823 rte_pktmbuf_iova(ut_params->ibuf);
8824 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8825 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8826 tdata->aad.len);
8827
8828 /* Append IV at the end of the crypto operation*/
8829 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8830 uint8_t *, IV_OFFSET);
8831

Calls 6

rte_crypto_op_allocFunction · 0.85
rte_pktmbuf_appendFunction · 0.85
debug_hexdumpFunction · 0.85
memsetFunction · 0.85
memcpyFunction · 0.50
rte_memcpyFunction · 0.50

Tested by

no test coverage detected