+static int
+create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
+ enum rte_crypto_auth_operation op,
+ enum rte_crypto_auth_algorithm auth_algo)
+{
+ struct crypto_testsuite_params *ts_params = &testsuite_params;
+ struct crypto_unittest_params *ut_params = &unittest_params;
+
+ const uint8_t *auth_tag = tdata->digest.data;
+ const unsigned int auth_tag_len = tdata->digest.len;
+ const uint8_t *aad = tdata->aad.data;
+ const uint8_t aad_len = tdata->aad.len;
+ unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
+ unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
+
+ const uint8_t *iv = tdata->iv.data;
+ const uint8_t iv_len = tdata->iv.len;
+ const unsigned int cipher_len = tdata->validCipherLenInBits.len;
+ const unsigned int cipher_offset = 0;
+ const unsigned int auth_len = tdata->validAuthLenInBits.len;
+ const unsigned int auth_offset = tdata->aad.len << 3;
+
+ unsigned int aad_buffer_len;
+
+ /* Generate Crypto op data structure */
+ ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
+ RTE_CRYPTO_OP_TYPE_SYMMETRIC);
+ TEST_ASSERT_NOT_NULL(ut_params->op,
+ "Failed to allocate pktmbuf offload");
+ /* Set crypto operation data parameters */
+ rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
+
+ struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
+
+ /* set crypto operation source mbuf */
+ sym_op->m_src = ut_params->ibuf;
+
+ /* digest */
+ sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
+ ut_params->ibuf, auth_tag_len);
+
+ TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
+ "no room to append auth tag");
+ ut_params->digest = sym_op->auth.digest.data;
+ sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
+ ut_params->ibuf, data_pad_len);
+ sym_op->auth.digest.length = auth_tag_len;
+ if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
+ memset(sym_op->auth.digest.data, 0, auth_tag_len);
+ else
+ rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
+
+ TEST_HEXDUMP(stdout, "digest:",
+ sym_op->auth.digest.data,
+ sym_op->auth.digest.length);
+
+ /* aad */
+ /*
+ * Always allocate the aad up to the block size.
+ * The cryptodev API calls out -
+ * - the array must be big enough to hold the AAD, plus any
+ * space to round this up to the nearest multiple of the
+ * block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
+ */
+ if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
+ aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
+ else
+ aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
+ sym_op->auth.aad.data =
+ (uint8_t *)rte_pktmbuf_prepend(
+ ut_params->ibuf, aad_buffer_len);
+ TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
+ "no room to prepend aad");
+ sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
+ ut_params->ibuf);
+ sym_op->auth.aad.length = aad_len;
+ memset(sym_op->auth.aad.data, 0, aad_buffer_len);
+ rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
+ TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
+
+ /* iv */
+ sym_op->cipher.iv.data = rte_crypto_op_ctod_offset(ut_params->op,
+ uint8_t *, IV_OFFSET);
+ sym_op->cipher.iv.phys_addr = rte_crypto_op_ctophys_offset(ut_params->op,
+ IV_OFFSET);
+ sym_op->cipher.iv.length = iv_len;
+
+ rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
+ sym_op->cipher.data.length = cipher_len;
+ sym_op->cipher.data.offset = cipher_offset + auth_offset;
+ sym_op->auth.data.length = auth_len;
+ sym_op->auth.data.offset = auth_offset + cipher_offset;
+
+ return 0;
+}
+
+static int
+create_zuc_cipher_hash_generate_operation(
+ const struct wireless_test_data *tdata)
+{
+ return create_wireless_cipher_hash_operation(tdata,
+ RTE_CRYPTO_AUTH_OP_GENERATE,
+ RTE_CRYPTO_AUTH_ZUC_EIA3);
+}
+