process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
{
if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
- printf("Error sending packet for encryption");
+ RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
return NULL;
}
while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
rte_pause();
+ if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
+ RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
+ return NULL;
+ }
+
return op;
}
ut_params->sess = rte_cryptodev_sym_session_create(
ts_params->session_mpool);
- status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
- &ut_params->auth_xform,
- ts_params->session_priv_mpool);
+ if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
+ ut_params->auth_xform.next = NULL;
+ ut_params->cipher_xform.next = &ut_params->auth_xform;
+ status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->cipher_xform,
+ ts_params->session_priv_mpool);
+
+ } else
+ status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
+ &ut_params->auth_xform,
+ ts_params->session_priv_mpool);
+
TEST_ASSERT_EQUAL(status, 0, "session init failed");
TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
}
static int
-create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
+create_wireless_algo_auth_cipher_operation(
+ const uint8_t *auth_tag, unsigned int auth_tag_len,
const uint8_t *cipher_iv, uint8_t cipher_iv_len,
const uint8_t *auth_iv, uint8_t auth_iv_len,
unsigned int data_pad_len,
unsigned int cipher_len, unsigned int cipher_offset,
unsigned int auth_len, unsigned int auth_offset,
- uint8_t op_mode, uint8_t do_sgl)
+ uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
{
struct crypto_testsuite_params *ts_params = &testsuite_params;
struct crypto_unittest_params *ut_params = &unittest_params;
}
}
+ /* Copy digest for the verification */
+ if (verify)
+ memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
+
/* Copy cipher and auth IVs at the end of the crypto operation */
uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
ut_params->op, uint8_t *, IV_OFFSET);
/* Create SNOW 3G operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest.len,
+ tdata->digest.data, tdata->digest.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->auth_iv.data, tdata->auth_iv.len,
(tdata->digest.offset_bytes == 0 ?
tdata->cipher.offset_bits,
tdata->validAuthLenInBits.len,
tdata->auth.offset_bits,
- op_mode, 0);
+ op_mode, 0, verify);
if (retval < 0)
return retval;
/* Create SNOW 3G operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest.len,
+ tdata->digest.data, tdata->digest.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->auth_iv.data, tdata->auth_iv.len,
(tdata->digest.offset_bytes == 0 ?
tdata->cipher.offset_bits,
tdata->validAuthLenInBits.len,
tdata->auth.offset_bits,
- op_mode, 1);
+ op_mode, 1, verify);
if (retval < 0)
return retval;
/* Create KASUMI operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest.len,
+ tdata->digest.data, tdata->digest.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
NULL, 0,
(tdata->digest.offset_bytes == 0 ?
tdata->validCipherOffsetInBits.len,
tdata->validAuthLenInBits.len,
0,
- op_mode, 0);
+ op_mode, 0, verify);
if (retval < 0)
return retval;
/* Create KASUMI operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest.len,
+ tdata->digest.data, tdata->digest.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
NULL, 0,
(tdata->digest.offset_bytes == 0 ?
tdata->validCipherOffsetInBits.len,
tdata->validAuthLenInBits.len,
0,
- op_mode, 1);
+ op_mode, 1, verify);
if (retval < 0)
return retval;
/* Create ZUC operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest.len,
+ tdata->digest.data, tdata->digest.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->auth_iv.data, tdata->auth_iv.len,
(tdata->digest.offset_bytes == 0 ?
tdata->validCipherOffsetInBits.len,
tdata->validAuthLenInBits.len,
0,
- op_mode, 0);
+ op_mode, 0, verify);
if (retval < 0)
return retval;
/* Create ZUC operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest.len,
+ tdata->digest.data, tdata->digest.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
NULL, 0,
(tdata->digest.offset_bytes == 0 ?
tdata->validCipherOffsetInBits.len,
tdata->validAuthLenInBits.len,
0,
- op_mode, 1);
+ op_mode, 1, verify);
if (retval < 0)
return retval;
/* Create the operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest_enc.len,
+ tdata->digest_enc.data, tdata->digest_enc.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->auth_iv.data, tdata->auth_iv.len,
(tdata->digest_enc.offset == 0 ?
tdata->cipher.offset_bits,
tdata->validAuthLen.len_bits,
tdata->auth.offset_bits,
- op_mode, 0);
+ op_mode, 0, verify);
if (retval < 0)
return retval;
/* Create the operation */
retval = create_wireless_algo_auth_cipher_operation(
- tdata->digest_enc.len,
+ tdata->digest_enc.data, tdata->digest_enc.len,
tdata->cipher_iv.data, tdata->cipher_iv.len,
tdata->auth_iv.data, tdata->auth_iv.len,
(tdata->digest_enc.offset == 0 ?
tdata->cipher.offset_bits,
tdata->validAuthLen.len_bits,
tdata->auth.offset_bits,
- op_mode, 1);
+ op_mode, 1, verify);
if (retval < 0)
return retval;
ut_params->op = process_crypto_request(ts_params->valid_devs[0],
ut_params->op);
- TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
- TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
- RTE_CRYPTO_OP_STATUS_SUCCESS,
- "authentication not failed");
- ut_params->obuf = ut_params->op->sym->m_src;
- TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
+ TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
return 0;
}
ut_params->op = process_crypto_request(ts_params->valid_devs[0],
ut_params->op);
- TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
- TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
- RTE_CRYPTO_OP_STATUS_SUCCESS,
- "authentication not failed");
- ut_params->obuf = ut_params->op->sym->m_src;
- TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
+ TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
return 0;
}
ut_params->op = process_crypto_request(ts_params->valid_devs[0],
ut_params->op);
- TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
- TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
- RTE_CRYPTO_OP_STATUS_SUCCESS,
- "authentication not failed");
-
- ut_params->obuf = ut_params->op->sym->m_src;
- TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
+ TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
return 0;
}
const unsigned int auth_tag_len = tdata->auth_tag.len;
const unsigned int iv_len = tdata->iv.len;
unsigned int aad_len = tdata->aad.len;
+ unsigned int aad_len_pad = 0;
/* Generate Crypto op data structure */
ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
+ aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
+
sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
- ut_params->ibuf, aad_len);
+ ut_params->ibuf, aad_len_pad);
TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
"no room to prepend aad");
sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
}
sym_op->aead.data.length = tdata->plaintext.len;
- sym_op->aead.data.offset = aad_len;
+ sym_op->aead.data.offset = aad_len_pad;
return 0;
}
int ecx = 0;
void *digest_mem = NULL;
- uint32_t prepend_len = tdata->aad.len;
+ uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
if (tdata->plaintext.len % fragsz != 0) {
if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
TEST_CASE_ST(ut_setup, ut_teardown,
test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
+ TEST_CASE_ST(ut_setup, ut_teardown,
+ test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
TEST_CASE_ST(ut_setup, ut_teardown,
test_AES_GCM_authenticated_encryption_test_case_1),
TEST_CASE_ST(ut_setup, ut_teardown,