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

Function create_wireless_cipher_hash_operation

dpdk/app/test/test_cryptodev.c:2902–2965  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2900}
2901
2902static int
2903create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2904 enum rte_crypto_auth_operation op)
2905{
2906 struct crypto_testsuite_params *ts_params = &testsuite_params;
2907 struct crypto_unittest_params *ut_params = &unittest_params;
2908
2909 const uint8_t *auth_tag = tdata->digest.data;
2910 const unsigned int auth_tag_len = tdata->digest.len;
2911 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2912 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2913
2914 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2915 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2916 const uint8_t *auth_iv = tdata->auth_iv.data;
2917 const uint8_t auth_iv_len = tdata->auth_iv.len;
2918 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2919 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2920
2921 /* Generate Crypto op data structure */
2922 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2923 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2924 TEST_ASSERT_NOT_NULL(ut_params->op,
2925 "Failed to allocate pktmbuf offload");
2926 /* Set crypto operation data parameters */
2927 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2928
2929 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2930
2931 /* set crypto operation source mbuf */
2932 sym_op->m_src = ut_params->ibuf;
2933
2934 /* digest */
2935 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2936 ut_params->ibuf, auth_tag_len);
2937
2938 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2939 "no room to append auth tag");
2940 ut_params->digest = sym_op->auth.digest.data;
2941 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2942 ut_params->ibuf, data_pad_len);
2943 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2944 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2945 else
2946 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2947
2948 debug_hexdump(stdout, "digest:",
2949 sym_op->auth.digest.data,
2950 auth_tag_len);
2951
2952 /* Copy cipher and auth IVs at the end of the crypto operation */
2953 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2954 IV_OFFSET);
2955 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2956 iv_ptr += cipher_iv_len;
2957 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2958
2959 sym_op->cipher.data.length = cipher_len;

Calls 7

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

Tested by

no test coverage detected