1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2020 Intel Corporation
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
20 #include <rte_string_fns.h>
24 #ifdef RTE_CRYPTO_SCHEDULER
25 #include <rte_cryptodev_scheduler.h>
26 #include <rte_cryptodev_scheduler_operations.h>
29 #include <rte_lcore.h>
32 #include "test_cryptodev.h"
34 #include "test_cryptodev_blockcipher.h"
35 #include "test_cryptodev_aes_test_vectors.h"
36 #include "test_cryptodev_des_test_vectors.h"
37 #include "test_cryptodev_hash_test_vectors.h"
38 #include "test_cryptodev_kasumi_test_vectors.h"
39 #include "test_cryptodev_kasumi_hash_test_vectors.h"
40 #include "test_cryptodev_snow3g_test_vectors.h"
41 #include "test_cryptodev_snow3g_hash_test_vectors.h"
42 #include "test_cryptodev_zuc_test_vectors.h"
43 #include "test_cryptodev_aead_test_vectors.h"
44 #include "test_cryptodev_hmac_test_vectors.h"
45 #include "test_cryptodev_mixed_test_vectors.h"
46 #ifdef RTE_LIB_SECURITY
47 #include "test_cryptodev_security_ipsec.h"
48 #include "test_cryptodev_security_ipsec_test_vectors.h"
49 #include "test_cryptodev_security_pdcp_test_vectors.h"
50 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
51 #include "test_cryptodev_security_pdcp_test_func.h"
52 #include "test_cryptodev_security_docsis_test_vectors.h"
54 #define SDAP_DISABLED 0
55 #define SDAP_ENABLED 1
58 #define VDEV_ARGS_SIZE 100
59 #define MAX_NB_SESSIONS 4
61 #define MAX_DRV_SERVICE_CTX_SIZE 256
63 #define MAX_RAW_DEQUEUE_COUNT 65535
66 #define OUT_OF_PLACE 1
68 static int gbl_driver_id;
70 static enum rte_security_session_action_type gbl_action_type =
71 RTE_SECURITY_ACTION_TYPE_NONE;
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
75 struct crypto_unittest_params {
76 struct rte_crypto_sym_xform cipher_xform;
77 struct rte_crypto_sym_xform auth_xform;
78 struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 struct rte_security_docsis_xform docsis_xform;
84 struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 struct rte_security_session *sec_session;
89 #ifdef RTE_LIB_SECURITY
90 enum rte_security_session_action_type type;
92 struct rte_crypto_op *op;
94 struct rte_mbuf *obuf, *ibuf;
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 (((num) + (align) - 1) & ~((align) - 1))
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts) \
103 for (j = 0; j < num_child_ts; index++, j++) \
104 parent_ts.unit_test_suites[index] = child_ts[j]
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types) \
107 for (j = 0; j < num_blk_types; index++, j++) \
108 parent_ts.unit_test_suites[index] = \
109 build_blockcipher_test_suite(blk_types[j])
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types) \
112 for (j = index; j < index + num_blk_types; j++) \
113 free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
116 * Forward declarations.
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 struct crypto_unittest_params *ut_params,
126 struct crypto_testsuite_params *ts_param,
127 const uint8_t *cipher,
128 const uint8_t *digest,
132 security_proto_supported(enum rte_security_session_action_type action,
133 enum rte_security_session_protocol proto);
136 dev_configure_and_start(uint64_t ff_disable);
138 static struct rte_mbuf *
139 setup_test_string(struct rte_mempool *mpool,
140 const char *string, size_t len, uint8_t blocksize)
142 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
143 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
148 memset(m->buf_addr, 0, m->buf_len);
149 dst = rte_pktmbuf_append(m, t_len);
155 rte_memcpy(dst, string, t_len);
157 memset(dst, 0, t_len);
163 /* Get number of bytes in X bits (rounding up) */
165 ceil_byte_length(uint32_t num_bits)
168 return ((num_bits >> 3) + 1);
170 return (num_bits >> 3);
174 post_process_raw_dp_op(void *user_data, uint32_t index __rte_unused,
175 uint8_t is_op_success)
177 struct rte_crypto_op *op = user_data;
178 op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
179 RTE_CRYPTO_OP_STATUS_ERROR;
182 static struct crypto_testsuite_params testsuite_params = { NULL };
183 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
184 static struct crypto_unittest_params unittest_params;
187 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
188 struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
189 uint8_t len_in_bits, uint8_t cipher_iv_len)
191 struct rte_crypto_sym_op *sop = op->sym;
192 struct rte_crypto_op *ret_op = NULL;
193 struct rte_crypto_vec data_vec[UINT8_MAX], dest_data_vec[UINT8_MAX];
194 struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
195 union rte_crypto_sym_ofs ofs;
196 struct rte_crypto_sym_vec vec;
197 struct rte_crypto_sgl sgl, dest_sgl;
199 union rte_cryptodev_session_ctx sess;
200 uint64_t auth_end_iova;
202 struct rte_crypto_raw_dp_ctx *ctx;
203 uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
207 int ctx_service_size;
209 int enqueue_status, dequeue_status;
210 struct crypto_unittest_params *ut_params = &unittest_params;
211 int is_sgl = sop->m_src->nb_segs > 1;
213 ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
214 if (ctx_service_size < 0) {
215 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
219 ctx = malloc(ctx_service_size);
221 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
225 /* Both are enums, setting crypto_sess will suit any session type */
226 sess.crypto_sess = op->sym->session;
228 if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
229 op->sess_type, sess, 0) < 0) {
230 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
236 aad_auth_iv.iova = 0;
237 aad_auth_iv.va = NULL;
244 vec.digest = &digest;
245 vec.aad = &aad_auth_iv;
246 vec.status = &status;
250 if (is_cipher && is_auth) {
251 cipher_offset = sop->cipher.data.offset;
252 cipher_len = sop->cipher.data.length;
253 auth_offset = sop->auth.data.offset;
254 auth_len = sop->auth.data.length;
255 max_len = RTE_MAX(cipher_offset + cipher_len,
256 auth_offset + auth_len);
258 max_len = max_len >> 3;
259 cipher_offset = cipher_offset >> 3;
260 auth_offset = auth_offset >> 3;
261 cipher_len = cipher_len >> 3;
262 auth_len = auth_len >> 3;
264 ofs.ofs.cipher.head = cipher_offset;
265 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
266 ofs.ofs.auth.head = auth_offset;
267 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
268 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
269 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
270 aad_auth_iv.va = rte_crypto_op_ctod_offset(
271 op, void *, IV_OFFSET + cipher_iv_len);
272 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
274 digest.va = (void *)sop->auth.digest.data;
275 digest.iova = sop->auth.digest.phys_addr;
278 uint32_t remaining_off = auth_offset + auth_len;
279 struct rte_mbuf *sgl_buf = sop->m_src;
281 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)
282 && sgl_buf->next != NULL) {
283 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
284 sgl_buf = sgl_buf->next;
287 auth_end_iova = (uint64_t)rte_pktmbuf_iova_offset(
288 sgl_buf, remaining_off);
290 auth_end_iova = rte_pktmbuf_iova(op->sym->m_src) +
291 auth_offset + auth_len;
293 /* Then check if digest-encrypted conditions are met */
294 if ((auth_offset + auth_len < cipher_offset + cipher_len) &&
295 (digest.iova == auth_end_iova) && is_sgl)
296 max_len = RTE_MAX(max_len, auth_offset + auth_len +
297 ut_params->auth_xform.auth.digest_length);
299 } else if (is_cipher) {
300 cipher_offset = sop->cipher.data.offset;
301 cipher_len = sop->cipher.data.length;
302 max_len = cipher_len + cipher_offset;
304 max_len = max_len >> 3;
305 cipher_offset = cipher_offset >> 3;
306 cipher_len = cipher_len >> 3;
308 ofs.ofs.cipher.head = cipher_offset;
309 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
310 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
311 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
313 } else if (is_auth) {
314 auth_offset = sop->auth.data.offset;
315 auth_len = sop->auth.data.length;
316 max_len = auth_len + auth_offset;
318 max_len = max_len >> 3;
319 auth_offset = auth_offset >> 3;
320 auth_len = auth_len >> 3;
322 ofs.ofs.auth.head = auth_offset;
323 ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
324 aad_auth_iv.va = rte_crypto_op_ctod_offset(
325 op, void *, IV_OFFSET + cipher_iv_len);
326 aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
328 digest.va = (void *)sop->auth.digest.data;
329 digest.iova = sop->auth.digest.phys_addr;
332 cipher_offset = sop->aead.data.offset;
333 cipher_len = sop->aead.data.length;
334 max_len = cipher_len + cipher_offset;
336 max_len = max_len >> 3;
337 cipher_offset = cipher_offset >> 3;
338 cipher_len = cipher_len >> 3;
340 ofs.ofs.cipher.head = cipher_offset;
341 ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
342 cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
343 cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
344 aad_auth_iv.va = (void *)sop->aead.aad.data;
345 aad_auth_iv.iova = sop->aead.aad.phys_addr;
346 digest.va = (void *)sop->aead.digest.data;
347 digest.iova = sop->aead.digest.phys_addr;
350 n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
351 data_vec, RTE_DIM(data_vec));
352 if (n < 0 || n > sop->m_src->nb_segs) {
353 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
359 if (sop->m_dst != NULL) {
360 dest_sgl.vec = dest_data_vec;
361 vec.dest_sgl = &dest_sgl;
362 n = rte_crypto_mbuf_to_vec(sop->m_dst, 0, max_len,
363 dest_data_vec, RTE_DIM(dest_data_vec));
364 if (n < 0 || n > sop->m_dst->nb_segs) {
365 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
372 if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
373 &enqueue_status) < 1) {
374 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
378 if (enqueue_status == 0) {
379 status = rte_cryptodev_raw_enqueue_done(ctx, 1);
381 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
384 } else if (enqueue_status < 0) {
385 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
390 while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
391 n = rte_cryptodev_raw_dequeue_burst(ctx,
392 NULL, 1, post_process_raw_dp_op,
393 (void **)&ret_op, 0, &n_success,
395 if (dequeue_status < 0) {
396 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
403 if (n == 1 && dequeue_status == 0) {
404 if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
405 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
410 op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
411 ret_op->status == RTE_CRYPTO_OP_STATUS_ERROR ||
412 n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
413 RTE_CRYPTO_OP_STATUS_SUCCESS;
420 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
423 struct rte_crypto_sym_op *sop;
424 union rte_crypto_sym_ofs ofs;
425 struct rte_crypto_sgl sgl;
426 struct rte_crypto_sym_vec symvec;
427 struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
428 struct rte_crypto_vec vec[UINT8_MAX];
432 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
433 sop->aead.data.length, vec, RTE_DIM(vec));
435 if (n < 0 || n != sop->m_src->nb_segs) {
436 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
442 symvec.src_sgl = &sgl;
444 symvec.digest = &digest_ptr;
445 symvec.aad = &aad_ptr;
449 /* for CPU crypto the IOVA address is not required */
450 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
451 digest_ptr.va = (void *)sop->aead.digest.data;
452 aad_ptr.va = (void *)sop->aead.aad.data;
456 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
460 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
462 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
466 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
469 struct rte_crypto_sym_op *sop;
470 union rte_crypto_sym_ofs ofs;
471 struct rte_crypto_sgl sgl;
472 struct rte_crypto_sym_vec symvec;
473 struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
474 struct rte_crypto_vec vec[UINT8_MAX];
478 n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
479 sop->auth.data.length, vec, RTE_DIM(vec));
481 if (n < 0 || n != sop->m_src->nb_segs) {
482 op->status = RTE_CRYPTO_OP_STATUS_ERROR;
488 symvec.src_sgl = &sgl;
490 symvec.digest = &digest_ptr;
494 iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
495 digest_ptr.va = (void *)sop->auth.digest.data;
498 ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
499 ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
500 (sop->cipher.data.offset + sop->cipher.data.length);
502 n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
506 op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
508 op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
511 static struct rte_crypto_op *
512 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
515 RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
517 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
518 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
524 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
527 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
528 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
536 testsuite_setup(void)
538 struct crypto_testsuite_params *ts_params = &testsuite_params;
539 struct rte_cryptodev_info info;
540 uint32_t i = 0, nb_devs, dev_id;
543 memset(ts_params, 0, sizeof(*ts_params));
545 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
546 if (ts_params->mbuf_pool == NULL) {
547 /* Not already created so create */
548 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
550 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
552 if (ts_params->mbuf_pool == NULL) {
553 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
558 ts_params->large_mbuf_pool = rte_mempool_lookup(
559 "CRYPTO_LARGE_MBUFPOOL");
560 if (ts_params->large_mbuf_pool == NULL) {
561 /* Not already created so create */
562 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
563 "CRYPTO_LARGE_MBUFPOOL",
566 if (ts_params->large_mbuf_pool == NULL) {
568 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
573 ts_params->op_mpool = rte_crypto_op_pool_create(
574 "MBUF_CRYPTO_SYM_OP_POOL",
575 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
576 NUM_MBUFS, MBUF_CACHE_SIZE,
578 sizeof(struct rte_crypto_sym_xform) +
581 if (ts_params->op_mpool == NULL) {
582 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
586 nb_devs = rte_cryptodev_count();
588 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
592 if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
593 RTE_LOG(WARNING, USER1, "No %s devices found?\n",
594 rte_cryptodev_driver_name_get(gbl_driver_id));
598 /* Create list of valid crypto devs */
599 for (i = 0; i < nb_devs; i++) {
600 rte_cryptodev_info_get(i, &info);
601 if (info.driver_id == gbl_driver_id)
602 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
605 if (ts_params->valid_dev_count < 1)
608 /* Set up all the qps on the first of the valid devices found */
610 dev_id = ts_params->valid_devs[0];
612 rte_cryptodev_info_get(dev_id, &info);
614 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
615 ts_params->conf.socket_id = SOCKET_ID_ANY;
616 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
618 unsigned int session_size =
619 rte_cryptodev_sym_get_private_session_size(dev_id);
621 #ifdef RTE_LIB_SECURITY
622 unsigned int security_session_size = rte_security_session_get_size(
623 rte_cryptodev_get_sec_ctx(dev_id));
625 if (session_size < security_session_size)
626 session_size = security_session_size;
629 * Create mempool with maximum number of sessions.
631 if (info.sym.max_nb_sessions != 0 &&
632 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
633 RTE_LOG(ERR, USER1, "Device does not support "
634 "at least %u sessions\n",
639 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
640 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
642 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
643 "session mempool allocation failed");
645 ts_params->session_priv_mpool = rte_mempool_create(
649 0, 0, NULL, NULL, NULL,
652 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
653 "session mempool allocation failed");
657 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
659 "Failed to configure cryptodev %u with %u qps",
660 dev_id, ts_params->conf.nb_queue_pairs);
662 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
663 ts_params->qp_conf.mp_session = ts_params->session_mpool;
664 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
666 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
667 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
668 dev_id, qp_id, &ts_params->qp_conf,
669 rte_cryptodev_socket_id(dev_id)),
670 "Failed to setup queue pair %u on cryptodev %u",
678 testsuite_teardown(void)
680 struct crypto_testsuite_params *ts_params = &testsuite_params;
683 if (ts_params->mbuf_pool != NULL) {
684 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
685 rte_mempool_avail_count(ts_params->mbuf_pool));
688 if (ts_params->op_mpool != NULL) {
689 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
690 rte_mempool_avail_count(ts_params->op_mpool));
693 /* Free session mempools */
694 if (ts_params->session_priv_mpool != NULL) {
695 rte_mempool_free(ts_params->session_priv_mpool);
696 ts_params->session_priv_mpool = NULL;
699 if (ts_params->session_mpool != NULL) {
700 rte_mempool_free(ts_params->session_mpool);
701 ts_params->session_mpool = NULL;
704 res = rte_cryptodev_close(ts_params->valid_devs[0]);
706 RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
710 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
711 const int *algs, uint16_t num_algs)
713 uint8_t dev_id = testsuite_params.valid_devs[0];
714 bool some_alg_supported = FALSE;
717 for (i = 0; i < num_algs && !some_alg_supported; i++) {
718 struct rte_cryptodev_sym_capability_idx alg = {
721 if (rte_cryptodev_sym_capability_get(dev_id,
723 some_alg_supported = TRUE;
725 if (!some_alg_supported)
732 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
733 uint16_t num_ciphers)
735 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
736 (const int *) ciphers, num_ciphers);
740 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
743 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
744 (const int *) auths, num_auths);
748 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
751 return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
752 (const int *) aeads, num_aeads);
756 null_testsuite_setup(void)
758 struct crypto_testsuite_params *ts_params = &testsuite_params;
759 uint8_t dev_id = ts_params->valid_devs[0];
760 struct rte_cryptodev_info dev_info;
761 const enum rte_crypto_cipher_algorithm ciphers[] = {
762 RTE_CRYPTO_CIPHER_NULL
764 const enum rte_crypto_auth_algorithm auths[] = {
768 rte_cryptodev_info_get(dev_id, &dev_info);
770 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
771 RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
772 "testsuite not met\n");
776 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
777 && check_auth_capabilities_supported(auths,
778 RTE_DIM(auths)) != 0) {
779 RTE_LOG(INFO, USER1, "Capability requirements for NULL "
780 "testsuite not met\n");
788 crypto_gen_testsuite_setup(void)
790 struct crypto_testsuite_params *ts_params = &testsuite_params;
791 uint8_t dev_id = ts_params->valid_devs[0];
792 struct rte_cryptodev_info dev_info;
794 rte_cryptodev_info_get(dev_id, &dev_info);
796 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
797 RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
798 "testsuite not met\n");
805 #ifdef RTE_LIB_SECURITY
807 ipsec_proto_testsuite_setup(void)
809 struct crypto_testsuite_params *ts_params = &testsuite_params;
810 struct crypto_unittest_params *ut_params = &unittest_params;
811 struct rte_cryptodev_info dev_info;
814 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
816 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SECURITY)) {
817 RTE_LOG(INFO, USER1, "Feature flag requirements for IPsec Proto "
818 "testsuite not met\n");
822 /* Reconfigure to enable security */
823 ret = dev_configure_and_start(0);
824 if (ret != TEST_SUCCESS)
827 /* Set action type */
828 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
830 if (security_proto_supported(
831 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
832 RTE_SECURITY_PROTOCOL_IPSEC) < 0) {
833 RTE_LOG(INFO, USER1, "Capability requirements for IPsec Proto "
838 test_ipsec_alg_list_populate();
841 * Stop the device. Device would be started again by individual test
842 * case setup routine.
844 rte_cryptodev_stop(ts_params->valid_devs[0]);
850 pdcp_proto_testsuite_setup(void)
852 struct crypto_testsuite_params *ts_params = &testsuite_params;
853 uint8_t dev_id = ts_params->valid_devs[0];
854 struct rte_cryptodev_info dev_info;
855 const enum rte_crypto_cipher_algorithm ciphers[] = {
856 RTE_CRYPTO_CIPHER_NULL,
857 RTE_CRYPTO_CIPHER_AES_CTR,
858 RTE_CRYPTO_CIPHER_ZUC_EEA3,
859 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
861 const enum rte_crypto_auth_algorithm auths[] = {
862 RTE_CRYPTO_AUTH_NULL,
863 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
864 RTE_CRYPTO_AUTH_AES_CMAC,
865 RTE_CRYPTO_AUTH_ZUC_EIA3
868 rte_cryptodev_info_get(dev_id, &dev_info);
870 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
871 !(dev_info.feature_flags &
872 RTE_CRYPTODEV_FF_SECURITY)) {
873 RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
874 "testsuite not met\n");
878 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
879 && check_auth_capabilities_supported(auths,
880 RTE_DIM(auths)) != 0) {
881 RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
882 "testsuite not met\n");
890 docsis_proto_testsuite_setup(void)
892 struct crypto_testsuite_params *ts_params = &testsuite_params;
893 uint8_t dev_id = ts_params->valid_devs[0];
894 struct rte_cryptodev_info dev_info;
895 const enum rte_crypto_cipher_algorithm ciphers[] = {
896 RTE_CRYPTO_CIPHER_AES_DOCSISBPI
899 rte_cryptodev_info_get(dev_id, &dev_info);
901 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
902 !(dev_info.feature_flags &
903 RTE_CRYPTODEV_FF_SECURITY)) {
904 RTE_LOG(INFO, USER1, "Feature flag requirements for DOCSIS "
905 "Proto testsuite not met\n");
909 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
910 RTE_LOG(INFO, USER1, "Capability requirements for DOCSIS Proto "
911 "testsuite not met\n");
920 aes_ccm_auth_testsuite_setup(void)
922 struct crypto_testsuite_params *ts_params = &testsuite_params;
923 uint8_t dev_id = ts_params->valid_devs[0];
924 struct rte_cryptodev_info dev_info;
925 const enum rte_crypto_aead_algorithm aeads[] = {
926 RTE_CRYPTO_AEAD_AES_CCM
929 rte_cryptodev_info_get(dev_id, &dev_info);
931 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
932 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
933 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
934 RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
935 "testsuite not met\n");
939 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
940 RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
941 "testsuite not met\n");
949 aes_gcm_auth_testsuite_setup(void)
951 struct crypto_testsuite_params *ts_params = &testsuite_params;
952 uint8_t dev_id = ts_params->valid_devs[0];
953 struct rte_cryptodev_info dev_info;
954 const enum rte_crypto_aead_algorithm aeads[] = {
955 RTE_CRYPTO_AEAD_AES_GCM
958 rte_cryptodev_info_get(dev_id, &dev_info);
960 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
961 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
962 "testsuite not met\n");
966 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
967 RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
968 "testsuite not met\n");
976 aes_gmac_auth_testsuite_setup(void)
978 struct crypto_testsuite_params *ts_params = &testsuite_params;
979 uint8_t dev_id = ts_params->valid_devs[0];
980 struct rte_cryptodev_info dev_info;
981 const enum rte_crypto_auth_algorithm auths[] = {
982 RTE_CRYPTO_AUTH_AES_GMAC
985 rte_cryptodev_info_get(dev_id, &dev_info);
987 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
988 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
989 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
990 RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
991 "testsuite not met\n");
995 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
996 RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
997 "testsuite not met\n");
1005 chacha20_poly1305_testsuite_setup(void)
1007 struct crypto_testsuite_params *ts_params = &testsuite_params;
1008 uint8_t dev_id = ts_params->valid_devs[0];
1009 struct rte_cryptodev_info dev_info;
1010 const enum rte_crypto_aead_algorithm aeads[] = {
1011 RTE_CRYPTO_AEAD_CHACHA20_POLY1305
1014 rte_cryptodev_info_get(dev_id, &dev_info);
1016 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1017 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1018 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1019 RTE_LOG(INFO, USER1, "Feature flag requirements for "
1020 "Chacha20-Poly1305 testsuite not met\n");
1021 return TEST_SKIPPED;
1024 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1025 RTE_LOG(INFO, USER1, "Capability requirements for "
1026 "Chacha20-Poly1305 testsuite not met\n");
1027 return TEST_SKIPPED;
1034 snow3g_testsuite_setup(void)
1036 struct crypto_testsuite_params *ts_params = &testsuite_params;
1037 uint8_t dev_id = ts_params->valid_devs[0];
1038 struct rte_cryptodev_info dev_info;
1039 const enum rte_crypto_cipher_algorithm ciphers[] = {
1040 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1043 const enum rte_crypto_auth_algorithm auths[] = {
1044 RTE_CRYPTO_AUTH_SNOW3G_UIA2
1047 rte_cryptodev_info_get(dev_id, &dev_info);
1049 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1050 RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
1051 "testsuite not met\n");
1052 return TEST_SKIPPED;
1055 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1056 && check_auth_capabilities_supported(auths,
1057 RTE_DIM(auths)) != 0) {
1058 RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
1059 "testsuite not met\n");
1060 return TEST_SKIPPED;
1067 zuc_testsuite_setup(void)
1069 struct crypto_testsuite_params *ts_params = &testsuite_params;
1070 uint8_t dev_id = ts_params->valid_devs[0];
1071 struct rte_cryptodev_info dev_info;
1072 const enum rte_crypto_cipher_algorithm ciphers[] = {
1073 RTE_CRYPTO_CIPHER_ZUC_EEA3
1075 const enum rte_crypto_auth_algorithm auths[] = {
1076 RTE_CRYPTO_AUTH_ZUC_EIA3
1079 rte_cryptodev_info_get(dev_id, &dev_info);
1081 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1082 RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
1083 "testsuite not met\n");
1084 return TEST_SKIPPED;
1087 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1088 && check_auth_capabilities_supported(auths,
1089 RTE_DIM(auths)) != 0) {
1090 RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1091 "testsuite not met\n");
1092 return TEST_SKIPPED;
1099 hmac_md5_auth_testsuite_setup(void)
1101 struct crypto_testsuite_params *ts_params = &testsuite_params;
1102 uint8_t dev_id = ts_params->valid_devs[0];
1103 struct rte_cryptodev_info dev_info;
1104 const enum rte_crypto_auth_algorithm auths[] = {
1105 RTE_CRYPTO_AUTH_MD5_HMAC
1108 rte_cryptodev_info_get(dev_id, &dev_info);
1110 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1111 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1112 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1113 RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1114 "Auth testsuite not met\n");
1115 return TEST_SKIPPED;
1118 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1119 RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1120 "testsuite not met\n");
1121 return TEST_SKIPPED;
1128 kasumi_testsuite_setup(void)
1130 struct crypto_testsuite_params *ts_params = &testsuite_params;
1131 uint8_t dev_id = ts_params->valid_devs[0];
1132 struct rte_cryptodev_info dev_info;
1133 const enum rte_crypto_cipher_algorithm ciphers[] = {
1134 RTE_CRYPTO_CIPHER_KASUMI_F8
1136 const enum rte_crypto_auth_algorithm auths[] = {
1137 RTE_CRYPTO_AUTH_KASUMI_F9
1140 rte_cryptodev_info_get(dev_id, &dev_info);
1142 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1143 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1144 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1145 RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1146 "testsuite not met\n");
1147 return TEST_SKIPPED;
1150 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1151 && check_auth_capabilities_supported(auths,
1152 RTE_DIM(auths)) != 0) {
1153 RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1154 "testsuite not met\n");
1155 return TEST_SKIPPED;
1162 negative_aes_gcm_testsuite_setup(void)
1164 struct crypto_testsuite_params *ts_params = &testsuite_params;
1165 uint8_t dev_id = ts_params->valid_devs[0];
1166 struct rte_cryptodev_info dev_info;
1167 const enum rte_crypto_aead_algorithm aeads[] = {
1168 RTE_CRYPTO_AEAD_AES_GCM
1171 rte_cryptodev_info_get(dev_id, &dev_info);
1173 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1174 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1175 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1176 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1177 "AES GCM testsuite not met\n");
1178 return TEST_SKIPPED;
1181 if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1182 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1183 "AES GCM testsuite not met\n");
1184 return TEST_SKIPPED;
1191 negative_aes_gmac_testsuite_setup(void)
1193 struct crypto_testsuite_params *ts_params = &testsuite_params;
1194 uint8_t dev_id = ts_params->valid_devs[0];
1195 struct rte_cryptodev_info dev_info;
1196 const enum rte_crypto_auth_algorithm auths[] = {
1197 RTE_CRYPTO_AUTH_AES_GMAC
1200 rte_cryptodev_info_get(dev_id, &dev_info);
1202 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1203 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1204 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1205 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1206 "AES GMAC testsuite not met\n");
1207 return TEST_SKIPPED;
1210 if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1211 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1212 "AES GMAC testsuite not met\n");
1213 return TEST_SKIPPED;
1220 mixed_cipher_hash_testsuite_setup(void)
1222 struct crypto_testsuite_params *ts_params = &testsuite_params;
1223 uint8_t dev_id = ts_params->valid_devs[0];
1224 struct rte_cryptodev_info dev_info;
1225 uint64_t feat_flags;
1226 const enum rte_crypto_cipher_algorithm ciphers[] = {
1227 RTE_CRYPTO_CIPHER_NULL,
1228 RTE_CRYPTO_CIPHER_AES_CTR,
1229 RTE_CRYPTO_CIPHER_ZUC_EEA3,
1230 RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1232 const enum rte_crypto_auth_algorithm auths[] = {
1233 RTE_CRYPTO_AUTH_NULL,
1234 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1235 RTE_CRYPTO_AUTH_AES_CMAC,
1236 RTE_CRYPTO_AUTH_ZUC_EIA3
1239 rte_cryptodev_info_get(dev_id, &dev_info);
1240 feat_flags = dev_info.feature_flags;
1242 if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1243 (global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1244 RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1245 "Cipher Hash testsuite not met\n");
1246 return TEST_SKIPPED;
1249 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1250 && check_auth_capabilities_supported(auths,
1251 RTE_DIM(auths)) != 0) {
1252 RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1253 "Cipher Hash testsuite not met\n");
1254 return TEST_SKIPPED;
1261 esn_testsuite_setup(void)
1263 struct crypto_testsuite_params *ts_params = &testsuite_params;
1264 uint8_t dev_id = ts_params->valid_devs[0];
1265 struct rte_cryptodev_info dev_info;
1266 const enum rte_crypto_cipher_algorithm ciphers[] = {
1267 RTE_CRYPTO_CIPHER_AES_CBC
1269 const enum rte_crypto_auth_algorithm auths[] = {
1270 RTE_CRYPTO_AUTH_SHA1_HMAC
1273 rte_cryptodev_info_get(dev_id, &dev_info);
1275 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1276 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1277 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1278 RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1279 "testsuite not met\n");
1280 return TEST_SKIPPED;
1283 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1284 && check_auth_capabilities_supported(auths,
1285 RTE_DIM(auths)) != 0) {
1286 RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1287 "testsuite not met\n");
1288 return TEST_SKIPPED;
1295 multi_session_testsuite_setup(void)
1297 struct crypto_testsuite_params *ts_params = &testsuite_params;
1298 uint8_t dev_id = ts_params->valid_devs[0];
1299 struct rte_cryptodev_info dev_info;
1300 const enum rte_crypto_cipher_algorithm ciphers[] = {
1301 RTE_CRYPTO_CIPHER_AES_CBC
1303 const enum rte_crypto_auth_algorithm auths[] = {
1304 RTE_CRYPTO_AUTH_SHA512_HMAC
1307 rte_cryptodev_info_get(dev_id, &dev_info);
1309 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1310 RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1311 "Session testsuite not met\n");
1312 return TEST_SKIPPED;
1315 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1316 && check_auth_capabilities_supported(auths,
1317 RTE_DIM(auths)) != 0) {
1318 RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1319 "Session testsuite not met\n");
1320 return TEST_SKIPPED;
1327 negative_hmac_sha1_testsuite_setup(void)
1329 struct crypto_testsuite_params *ts_params = &testsuite_params;
1330 uint8_t dev_id = ts_params->valid_devs[0];
1331 struct rte_cryptodev_info dev_info;
1332 const enum rte_crypto_cipher_algorithm ciphers[] = {
1333 RTE_CRYPTO_CIPHER_AES_CBC
1335 const enum rte_crypto_auth_algorithm auths[] = {
1336 RTE_CRYPTO_AUTH_SHA1_HMAC
1339 rte_cryptodev_info_get(dev_id, &dev_info);
1341 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1342 ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1343 !(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1344 RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1345 "HMAC SHA1 testsuite not met\n");
1346 return TEST_SKIPPED;
1349 if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1350 && check_auth_capabilities_supported(auths,
1351 RTE_DIM(auths)) != 0) {
1352 RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1353 "HMAC SHA1 testsuite not met\n");
1354 return TEST_SKIPPED;
1361 dev_configure_and_start(uint64_t ff_disable)
1363 struct crypto_testsuite_params *ts_params = &testsuite_params;
1364 struct crypto_unittest_params *ut_params = &unittest_params;
1368 /* Clear unit test parameters before running test */
1369 memset(ut_params, 0, sizeof(*ut_params));
1371 /* Reconfigure device to default parameters */
1372 ts_params->conf.socket_id = SOCKET_ID_ANY;
1373 ts_params->conf.ff_disable = ff_disable;
1374 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1375 ts_params->qp_conf.mp_session = ts_params->session_mpool;
1376 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1378 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1380 "Failed to configure cryptodev %u",
1381 ts_params->valid_devs[0]);
1383 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1384 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1385 ts_params->valid_devs[0], qp_id,
1386 &ts_params->qp_conf,
1387 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1388 "Failed to setup queue pair %u on cryptodev %u",
1389 qp_id, ts_params->valid_devs[0]);
1393 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1395 /* Start the device */
1396 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1397 "Failed to start cryptodev %u",
1398 ts_params->valid_devs[0]);
1400 return TEST_SUCCESS;
1406 /* Configure and start the device with security feature disabled */
1407 return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1411 ut_setup_security(void)
1413 /* Configure and start the device with no features disabled */
1414 return dev_configure_and_start(0);
1420 struct crypto_testsuite_params *ts_params = &testsuite_params;
1421 struct crypto_unittest_params *ut_params = &unittest_params;
1423 /* free crypto session structure */
1424 #ifdef RTE_LIB_SECURITY
1425 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1426 if (ut_params->sec_session) {
1427 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1428 (ts_params->valid_devs[0]),
1429 ut_params->sec_session);
1430 ut_params->sec_session = NULL;
1435 if (ut_params->sess) {
1436 rte_cryptodev_sym_session_clear(
1437 ts_params->valid_devs[0],
1439 rte_cryptodev_sym_session_free(ut_params->sess);
1440 ut_params->sess = NULL;
1444 /* free crypto operation structure */
1446 rte_crypto_op_free(ut_params->op);
1449 * free mbuf - both obuf and ibuf are usually the same,
1450 * so check if they point at the same address is necessary,
1451 * to avoid freeing the mbuf twice.
1453 if (ut_params->obuf) {
1454 rte_pktmbuf_free(ut_params->obuf);
1455 if (ut_params->ibuf == ut_params->obuf)
1456 ut_params->ibuf = 0;
1457 ut_params->obuf = 0;
1459 if (ut_params->ibuf) {
1460 rte_pktmbuf_free(ut_params->ibuf);
1461 ut_params->ibuf = 0;
1464 if (ts_params->mbuf_pool != NULL)
1465 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1466 rte_mempool_avail_count(ts_params->mbuf_pool));
1468 /* Stop the device */
1469 rte_cryptodev_stop(ts_params->valid_devs[0]);
1473 test_device_configure_invalid_dev_id(void)
1475 struct crypto_testsuite_params *ts_params = &testsuite_params;
1476 uint16_t dev_id, num_devs = 0;
1478 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1479 "Need at least %d devices for test", 1);
1481 /* valid dev_id values */
1482 dev_id = ts_params->valid_devs[0];
1484 /* Stop the device in case it's started so it can be configured */
1485 rte_cryptodev_stop(dev_id);
1487 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1488 "Failed test for rte_cryptodev_configure: "
1489 "invalid dev_num %u", dev_id);
1491 /* invalid dev_id values */
1494 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1495 "Failed test for rte_cryptodev_configure: "
1496 "invalid dev_num %u", dev_id);
1500 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1501 "Failed test for rte_cryptodev_configure:"
1502 "invalid dev_num %u", dev_id);
1504 return TEST_SUCCESS;
1508 test_device_configure_invalid_queue_pair_ids(void)
1510 struct crypto_testsuite_params *ts_params = &testsuite_params;
1511 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1513 /* Stop the device in case it's started so it can be configured */
1514 rte_cryptodev_stop(ts_params->valid_devs[0]);
1516 /* valid - max value queue pairs */
1517 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1519 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1521 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1522 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1524 /* valid - one queue pairs */
1525 ts_params->conf.nb_queue_pairs = 1;
1527 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1529 "Failed to configure cryptodev: dev_id %u, qp_id %u",
1530 ts_params->valid_devs[0],
1531 ts_params->conf.nb_queue_pairs);
1534 /* invalid - zero queue pairs */
1535 ts_params->conf.nb_queue_pairs = 0;
1537 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1539 "Failed test for rte_cryptodev_configure, dev_id %u,"
1541 ts_params->valid_devs[0],
1542 ts_params->conf.nb_queue_pairs);
1545 /* invalid - max value supported by field queue pairs */
1546 ts_params->conf.nb_queue_pairs = UINT16_MAX;
1548 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1550 "Failed test for rte_cryptodev_configure, dev_id %u,"
1552 ts_params->valid_devs[0],
1553 ts_params->conf.nb_queue_pairs);
1556 /* invalid - max value + 1 queue pairs */
1557 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1559 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1561 "Failed test for rte_cryptodev_configure, dev_id %u,"
1563 ts_params->valid_devs[0],
1564 ts_params->conf.nb_queue_pairs);
1566 /* revert to original testsuite value */
1567 ts_params->conf.nb_queue_pairs = orig_nb_qps;
1569 return TEST_SUCCESS;
1573 test_queue_pair_descriptor_setup(void)
1575 struct crypto_testsuite_params *ts_params = &testsuite_params;
1576 struct rte_cryptodev_qp_conf qp_conf = {
1577 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
1581 /* Stop the device in case it's started so it can be configured */
1582 rte_cryptodev_stop(ts_params->valid_devs[0]);
1584 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1586 "Failed to configure cryptodev %u",
1587 ts_params->valid_devs[0]);
1590 * Test various ring sizes on this device. memzones can't be
1591 * freed so are re-used if ring is released and re-created.
1593 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1594 qp_conf.mp_session = ts_params->session_mpool;
1595 qp_conf.mp_session_private = ts_params->session_priv_mpool;
1597 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1598 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1599 ts_params->valid_devs[0], qp_id, &qp_conf,
1600 rte_cryptodev_socket_id(
1601 ts_params->valid_devs[0])),
1603 "rte_cryptodev_queue_pair_setup: num_inflights "
1604 "%u on qp %u on cryptodev %u",
1605 qp_conf.nb_descriptors, qp_id,
1606 ts_params->valid_devs[0]);
1609 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1611 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1612 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1613 ts_params->valid_devs[0], qp_id, &qp_conf,
1614 rte_cryptodev_socket_id(
1615 ts_params->valid_devs[0])),
1617 " rte_cryptodev_queue_pair_setup: num_inflights"
1618 " %u on qp %u on cryptodev %u",
1619 qp_conf.nb_descriptors, qp_id,
1620 ts_params->valid_devs[0]);
1623 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1625 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1626 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1627 ts_params->valid_devs[0], qp_id, &qp_conf,
1628 rte_cryptodev_socket_id(
1629 ts_params->valid_devs[0])),
1631 "rte_cryptodev_queue_pair_setup: num_inflights"
1632 " %u on qp %u on cryptodev %u",
1633 qp_conf.nb_descriptors, qp_id,
1634 ts_params->valid_devs[0]);
1637 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1639 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1640 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1641 ts_params->valid_devs[0], qp_id, &qp_conf,
1642 rte_cryptodev_socket_id(
1643 ts_params->valid_devs[0])),
1645 " rte_cryptodev_queue_pair_setup:"
1646 "num_inflights %u on qp %u on cryptodev %u",
1647 qp_conf.nb_descriptors, qp_id,
1648 ts_params->valid_devs[0]);
1651 /* test invalid queue pair id */
1652 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
1654 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
1656 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1657 ts_params->valid_devs[0],
1659 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1660 "Failed test for rte_cryptodev_queue_pair_setup:"
1661 "invalid qp %u on cryptodev %u",
1662 qp_id, ts_params->valid_devs[0]);
1664 qp_id = 0xffff; /*invalid*/
1666 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1667 ts_params->valid_devs[0],
1669 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1670 "Failed test for rte_cryptodev_queue_pair_setup:"
1671 "invalid qp %u on cryptodev %u",
1672 qp_id, ts_params->valid_devs[0]);
1674 return TEST_SUCCESS;
1677 /* ***** Plaintext data for tests ***** */
1679 const char catch_22_quote_1[] =
1680 "There was only one catch and that was Catch-22, which "
1681 "specified that a concern for one's safety in the face of "
1682 "dangers that were real and immediate was the process of a "
1683 "rational mind. Orr was crazy and could be grounded. All he "
1684 "had to do was ask; and as soon as he did, he would no longer "
1685 "be crazy and would have to fly more missions. Orr would be "
1686 "crazy to fly more missions and sane if he didn't, but if he "
1687 "was sane he had to fly them. If he flew them he was crazy "
1688 "and didn't have to; but if he didn't want to he was sane and "
1689 "had to. Yossarian was moved very deeply by the absolute "
1690 "simplicity of this clause of Catch-22 and let out a "
1691 "respectful whistle. \"That's some catch, that Catch-22\", he "
1692 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
1694 const char catch_22_quote[] =
1695 "What a lousy earth! He wondered how many people were "
1696 "destitute that same night even in his own prosperous country, "
1697 "how many homes were shanties, how many husbands were drunk "
1698 "and wives socked, and how many children were bullied, abused, "
1699 "or abandoned. How many families hungered for food they could "
1700 "not afford to buy? How many hearts were broken? How many "
1701 "suicides would take place that same night, how many people "
1702 "would go insane? How many cockroaches and landlords would "
1703 "triumph? How many winners were losers, successes failures, "
1704 "and rich men poor men? How many wise guys were stupid? How "
1705 "many happy endings were unhappy endings? How many honest men "
1706 "were liars, brave men cowards, loyal men traitors, how many "
1707 "sainted men were corrupt, how many people in positions of "
1708 "trust had sold their souls to bodyguards, how many had never "
1709 "had souls? How many straight-and-narrow paths were crooked "
1710 "paths? How many best families were worst families and how "
1711 "many good people were bad people? When you added them all up "
1712 "and then subtracted, you might be left with only the children, "
1713 "and perhaps with Albert Einstein and an old violinist or "
1714 "sculptor somewhere.";
1716 #define QUOTE_480_BYTES (480)
1717 #define QUOTE_512_BYTES (512)
1718 #define QUOTE_768_BYTES (768)
1719 #define QUOTE_1024_BYTES (1024)
1723 /* ***** SHA1 Hash Tests ***** */
1725 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
1727 static uint8_t hmac_sha1_key[] = {
1728 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1729 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1730 0xDE, 0xF4, 0xDE, 0xAD };
1732 /* ***** SHA224 Hash Tests ***** */
1734 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
1737 /* ***** AES-CBC Cipher Tests ***** */
1739 #define CIPHER_KEY_LENGTH_AES_CBC (16)
1740 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
1742 static uint8_t aes_cbc_key[] = {
1743 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1744 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1746 static uint8_t aes_cbc_iv[] = {
1747 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1748 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1751 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1753 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1754 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1755 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1756 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1757 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1758 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1759 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1760 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1761 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1762 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1763 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1764 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1765 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1766 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1767 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1768 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1769 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1770 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1771 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1772 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1773 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1774 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1775 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1776 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1777 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1778 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1779 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1780 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1781 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1782 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1783 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1784 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1785 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1786 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1787 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1788 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1789 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1790 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1791 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1792 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1793 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1794 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1795 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1796 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1797 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1798 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1799 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1800 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1801 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1802 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1803 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1804 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1805 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1806 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1807 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1808 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1809 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1810 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1811 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1812 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1813 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1814 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1815 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1816 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1817 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1820 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1821 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1822 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1823 0x18, 0x8c, 0x1d, 0x32
1827 /* Multisession Vector context Test */
1828 /*Begin Session 0 */
1829 static uint8_t ms_aes_cbc_key0[] = {
1830 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1831 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1834 static uint8_t ms_aes_cbc_iv0[] = {
1835 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1836 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1839 static const uint8_t ms_aes_cbc_cipher0[] = {
1840 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1841 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1842 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1843 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1844 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1845 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1846 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1847 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1848 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1849 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1850 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1851 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1852 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1853 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1854 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1855 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1856 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1857 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1858 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1859 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1860 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1861 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1862 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1863 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1864 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1865 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1866 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1867 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1868 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1869 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1870 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1871 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1872 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1873 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1874 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1875 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1876 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1877 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1878 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1879 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1880 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1881 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1882 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1883 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1884 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1885 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1886 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1887 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1888 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1889 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1890 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1891 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1892 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1893 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1894 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1895 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1896 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1897 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1898 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1899 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1900 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1901 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1902 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1903 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1907 static uint8_t ms_hmac_key0[] = {
1908 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1909 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1910 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1911 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1912 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1913 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1914 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1915 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1918 static const uint8_t ms_hmac_digest0[] = {
1919 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1920 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1921 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1922 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1923 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1924 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1925 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1926 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1930 /* Begin session 1 */
1932 static uint8_t ms_aes_cbc_key1[] = {
1933 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1934 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1937 static uint8_t ms_aes_cbc_iv1[] = {
1938 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1939 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1942 static const uint8_t ms_aes_cbc_cipher1[] = {
1943 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1944 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1945 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1946 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1947 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1948 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1949 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1950 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1951 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1952 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1953 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1954 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1955 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1956 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1957 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1958 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1959 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1960 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1961 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1962 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1963 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1964 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1965 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1966 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1967 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1968 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1969 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1970 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1971 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1972 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1973 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1974 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1975 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1976 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1977 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1978 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1979 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1980 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1981 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1982 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1983 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1984 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1985 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1986 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1987 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1988 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1989 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1990 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1991 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1992 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1993 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1994 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1995 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1996 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1997 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1998 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1999 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
2000 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
2001 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
2002 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
2003 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
2004 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
2005 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
2006 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
2010 static uint8_t ms_hmac_key1[] = {
2011 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2012 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2013 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2014 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2015 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2016 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2017 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2018 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2021 static const uint8_t ms_hmac_digest1[] = {
2022 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
2023 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
2024 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
2025 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
2026 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
2027 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
2028 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
2029 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
2032 /* Begin Session 2 */
2033 static uint8_t ms_aes_cbc_key2[] = {
2034 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2035 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2038 static uint8_t ms_aes_cbc_iv2[] = {
2039 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
2040 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
2043 static const uint8_t ms_aes_cbc_cipher2[] = {
2044 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
2045 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
2046 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
2047 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
2048 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
2049 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
2050 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
2051 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
2052 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
2053 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
2054 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
2055 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
2056 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
2057 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
2058 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
2059 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
2060 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
2061 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
2062 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
2063 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
2064 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
2065 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
2066 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
2067 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
2068 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
2069 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
2070 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
2071 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
2072 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
2073 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
2074 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
2075 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
2076 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
2077 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
2078 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
2079 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
2080 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
2081 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
2082 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
2083 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
2084 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
2085 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
2086 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2087 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2088 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2089 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2090 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2091 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2092 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2093 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2094 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2095 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2096 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2097 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2098 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2099 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2100 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2101 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2102 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2103 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2104 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2105 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2106 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2107 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2110 static uint8_t ms_hmac_key2[] = {
2111 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2112 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2113 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2114 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2115 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2116 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2117 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2118 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2121 static const uint8_t ms_hmac_digest2[] = {
2122 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2123 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2124 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2125 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2126 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2127 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2128 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2129 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2136 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2138 struct crypto_testsuite_params *ts_params = &testsuite_params;
2139 struct crypto_unittest_params *ut_params = &unittest_params;
2142 /* Verify the capabilities */
2143 struct rte_cryptodev_sym_capability_idx cap_idx;
2144 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2145 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2146 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2148 return TEST_SKIPPED;
2149 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2150 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2151 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2153 return TEST_SKIPPED;
2155 /* Generate test mbuf data and space for digest */
2156 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2157 catch_22_quote, QUOTE_512_BYTES, 0);
2159 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2160 DIGEST_BYTE_LENGTH_SHA1);
2161 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2163 /* Setup Cipher Parameters */
2164 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2165 ut_params->cipher_xform.next = &ut_params->auth_xform;
2167 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2168 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2169 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2170 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2171 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2172 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2174 /* Setup HMAC Parameters */
2175 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2177 ut_params->auth_xform.next = NULL;
2179 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2180 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2181 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2182 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2183 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2185 ut_params->sess = rte_cryptodev_sym_session_create(
2186 ts_params->session_mpool);
2187 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2189 /* Create crypto session*/
2190 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2191 ut_params->sess, &ut_params->cipher_xform,
2192 ts_params->session_priv_mpool);
2194 if (status == -ENOTSUP)
2195 return TEST_SKIPPED;
2197 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
2199 /* Generate crypto op data structure */
2200 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2201 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2202 TEST_ASSERT_NOT_NULL(ut_params->op,
2203 "Failed to allocate symmetric crypto operation struct");
2205 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2207 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2209 /* set crypto operation source mbuf */
2210 sym_op->m_src = ut_params->ibuf;
2212 /* Set crypto operation authentication parameters */
2213 sym_op->auth.digest.data = ut_params->digest;
2214 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2215 ut_params->ibuf, QUOTE_512_BYTES);
2217 sym_op->auth.data.offset = 0;
2218 sym_op->auth.data.length = QUOTE_512_BYTES;
2220 /* Copy IV at the end of the crypto operation */
2221 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2222 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2224 /* Set crypto operation cipher parameters */
2225 sym_op->cipher.data.offset = 0;
2226 sym_op->cipher.data.length = QUOTE_512_BYTES;
2228 /* Process crypto operation */
2229 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2230 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2233 TEST_ASSERT_NOT_NULL(
2234 process_crypto_request(ts_params->valid_devs[0],
2236 "failed to process sym crypto op");
2238 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2239 "crypto op processing failed");
2242 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2245 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2246 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2248 "ciphertext data not as expected");
2250 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2252 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2253 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2254 gbl_driver_id == rte_cryptodev_driver_id_get(
2255 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2256 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2257 DIGEST_BYTE_LENGTH_SHA1,
2258 "Generated digest data not as expected");
2260 return TEST_SUCCESS;
2263 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2265 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
2267 static uint8_t hmac_sha512_key[] = {
2268 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2269 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2270 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2271 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2272 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2273 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2274 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2275 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2277 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2278 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2279 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2280 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2281 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2282 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2283 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2284 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2285 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2290 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2291 struct crypto_unittest_params *ut_params,
2292 uint8_t *cipher_key,
2296 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2297 struct crypto_unittest_params *ut_params,
2298 struct crypto_testsuite_params *ts_params,
2299 const uint8_t *cipher,
2300 const uint8_t *digest,
2305 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2306 struct crypto_unittest_params *ut_params,
2307 uint8_t *cipher_key,
2311 /* Setup Cipher Parameters */
2312 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2313 ut_params->cipher_xform.next = NULL;
2315 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2316 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2317 ut_params->cipher_xform.cipher.key.data = cipher_key;
2318 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2319 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2320 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2322 /* Setup HMAC Parameters */
2323 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2324 ut_params->auth_xform.next = &ut_params->cipher_xform;
2326 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2327 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2328 ut_params->auth_xform.auth.key.data = hmac_key;
2329 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2330 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2332 return TEST_SUCCESS;
2337 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2338 struct crypto_unittest_params *ut_params,
2339 struct crypto_testsuite_params *ts_params,
2340 const uint8_t *cipher,
2341 const uint8_t *digest,
2344 /* Generate test mbuf data and digest */
2345 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2348 QUOTE_512_BYTES, 0);
2350 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2351 DIGEST_BYTE_LENGTH_SHA512);
2352 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2354 rte_memcpy(ut_params->digest,
2356 DIGEST_BYTE_LENGTH_SHA512);
2358 /* Generate Crypto op data structure */
2359 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2360 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2361 TEST_ASSERT_NOT_NULL(ut_params->op,
2362 "Failed to allocate symmetric crypto operation struct");
2364 rte_crypto_op_attach_sym_session(ut_params->op, sess);
2366 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2368 /* set crypto operation source mbuf */
2369 sym_op->m_src = ut_params->ibuf;
2371 sym_op->auth.digest.data = ut_params->digest;
2372 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2373 ut_params->ibuf, QUOTE_512_BYTES);
2375 sym_op->auth.data.offset = 0;
2376 sym_op->auth.data.length = QUOTE_512_BYTES;
2378 /* Copy IV at the end of the crypto operation */
2379 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2380 iv, CIPHER_IV_LENGTH_AES_CBC);
2382 sym_op->cipher.data.offset = 0;
2383 sym_op->cipher.data.length = QUOTE_512_BYTES;
2385 /* Process crypto operation */
2386 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2387 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2389 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2390 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2391 ut_params->op, 1, 1, 0, 0);
2393 TEST_ASSERT_NOT_NULL(
2394 process_crypto_request(ts_params->valid_devs[0],
2396 "failed to process sym crypto op");
2398 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2399 "crypto op processing failed");
2401 ut_params->obuf = ut_params->op->sym->m_src;
2404 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2405 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2408 "Plaintext data not as expected");
2411 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2412 "Digest verification failed");
2414 return TEST_SUCCESS;
2417 /* ***** SNOW 3G Tests ***** */
2419 create_wireless_algo_hash_session(uint8_t dev_id,
2420 const uint8_t *key, const uint8_t key_len,
2421 const uint8_t iv_len, const uint8_t auth_len,
2422 enum rte_crypto_auth_operation op,
2423 enum rte_crypto_auth_algorithm algo)
2425 uint8_t hash_key[key_len];
2428 struct crypto_testsuite_params *ts_params = &testsuite_params;
2429 struct crypto_unittest_params *ut_params = &unittest_params;
2431 memcpy(hash_key, key, key_len);
2433 debug_hexdump(stdout, "key:", key, key_len);
2435 /* Setup Authentication Parameters */
2436 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2437 ut_params->auth_xform.next = NULL;
2439 ut_params->auth_xform.auth.op = op;
2440 ut_params->auth_xform.auth.algo = algo;
2441 ut_params->auth_xform.auth.key.length = key_len;
2442 ut_params->auth_xform.auth.key.data = hash_key;
2443 ut_params->auth_xform.auth.digest_length = auth_len;
2444 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2445 ut_params->auth_xform.auth.iv.length = iv_len;
2446 ut_params->sess = rte_cryptodev_sym_session_create(
2447 ts_params->session_mpool);
2449 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2450 &ut_params->auth_xform,
2451 ts_params->session_priv_mpool);
2452 if (status == -ENOTSUP)
2453 return TEST_SKIPPED;
2455 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2456 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2461 create_wireless_algo_cipher_session(uint8_t dev_id,
2462 enum rte_crypto_cipher_operation op,
2463 enum rte_crypto_cipher_algorithm algo,
2464 const uint8_t *key, const uint8_t key_len,
2467 uint8_t cipher_key[key_len];
2469 struct crypto_testsuite_params *ts_params = &testsuite_params;
2470 struct crypto_unittest_params *ut_params = &unittest_params;
2472 memcpy(cipher_key, key, key_len);
2474 /* Setup Cipher Parameters */
2475 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2476 ut_params->cipher_xform.next = NULL;
2478 ut_params->cipher_xform.cipher.algo = algo;
2479 ut_params->cipher_xform.cipher.op = op;
2480 ut_params->cipher_xform.cipher.key.data = cipher_key;
2481 ut_params->cipher_xform.cipher.key.length = key_len;
2482 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2483 ut_params->cipher_xform.cipher.iv.length = iv_len;
2485 debug_hexdump(stdout, "key:", key, key_len);
2487 /* Create Crypto session */
2488 ut_params->sess = rte_cryptodev_sym_session_create(
2489 ts_params->session_mpool);
2491 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2492 &ut_params->cipher_xform,
2493 ts_params->session_priv_mpool);
2494 if (status == -ENOTSUP)
2495 return TEST_SKIPPED;
2497 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2498 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2503 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2504 unsigned int cipher_len,
2505 unsigned int cipher_offset)
2507 struct crypto_testsuite_params *ts_params = &testsuite_params;
2508 struct crypto_unittest_params *ut_params = &unittest_params;
2510 /* Generate Crypto op data structure */
2511 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2512 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2513 TEST_ASSERT_NOT_NULL(ut_params->op,
2514 "Failed to allocate pktmbuf offload");
2516 /* Set crypto operation data parameters */
2517 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2519 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2521 /* set crypto operation source mbuf */
2522 sym_op->m_src = ut_params->ibuf;
2525 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2527 sym_op->cipher.data.length = cipher_len;
2528 sym_op->cipher.data.offset = cipher_offset;
2533 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2534 unsigned int cipher_len,
2535 unsigned int cipher_offset)
2537 struct crypto_testsuite_params *ts_params = &testsuite_params;
2538 struct crypto_unittest_params *ut_params = &unittest_params;
2540 /* Generate Crypto op data structure */
2541 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2542 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2543 TEST_ASSERT_NOT_NULL(ut_params->op,
2544 "Failed to allocate pktmbuf offload");
2546 /* Set crypto operation data parameters */
2547 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2549 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2551 /* set crypto operation source mbuf */
2552 sym_op->m_src = ut_params->ibuf;
2553 sym_op->m_dst = ut_params->obuf;
2556 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2558 sym_op->cipher.data.length = cipher_len;
2559 sym_op->cipher.data.offset = cipher_offset;
2564 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2565 enum rte_crypto_cipher_operation cipher_op,
2566 enum rte_crypto_auth_operation auth_op,
2567 enum rte_crypto_auth_algorithm auth_algo,
2568 enum rte_crypto_cipher_algorithm cipher_algo,
2569 const uint8_t *key, uint8_t key_len,
2570 uint8_t auth_iv_len, uint8_t auth_len,
2571 uint8_t cipher_iv_len)
2574 uint8_t cipher_auth_key[key_len];
2577 struct crypto_testsuite_params *ts_params = &testsuite_params;
2578 struct crypto_unittest_params *ut_params = &unittest_params;
2580 memcpy(cipher_auth_key, key, key_len);
2582 /* Setup Authentication Parameters */
2583 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2584 ut_params->auth_xform.next = NULL;
2586 ut_params->auth_xform.auth.op = auth_op;
2587 ut_params->auth_xform.auth.algo = auth_algo;
2588 ut_params->auth_xform.auth.key.length = key_len;
2589 /* Hash key = cipher key */
2590 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2591 ut_params->auth_xform.auth.digest_length = auth_len;
2592 /* Auth IV will be after cipher IV */
2593 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2594 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2596 /* Setup Cipher Parameters */
2597 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2598 ut_params->cipher_xform.next = &ut_params->auth_xform;
2600 ut_params->cipher_xform.cipher.algo = cipher_algo;
2601 ut_params->cipher_xform.cipher.op = cipher_op;
2602 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2603 ut_params->cipher_xform.cipher.key.length = key_len;
2604 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2605 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2607 debug_hexdump(stdout, "key:", key, key_len);
2609 /* Create Crypto session*/
2610 ut_params->sess = rte_cryptodev_sym_session_create(
2611 ts_params->session_mpool);
2612 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2614 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2615 &ut_params->cipher_xform,
2616 ts_params->session_priv_mpool);
2617 if (status == -ENOTSUP)
2618 return TEST_SKIPPED;
2620 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2625 create_wireless_cipher_auth_session(uint8_t dev_id,
2626 enum rte_crypto_cipher_operation cipher_op,
2627 enum rte_crypto_auth_operation auth_op,
2628 enum rte_crypto_auth_algorithm auth_algo,
2629 enum rte_crypto_cipher_algorithm cipher_algo,
2630 const struct wireless_test_data *tdata)
2632 const uint8_t key_len = tdata->key.len;
2633 uint8_t cipher_auth_key[key_len];
2636 struct crypto_testsuite_params *ts_params = &testsuite_params;
2637 struct crypto_unittest_params *ut_params = &unittest_params;
2638 const uint8_t *key = tdata->key.data;
2639 const uint8_t auth_len = tdata->digest.len;
2640 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2641 uint8_t auth_iv_len = tdata->auth_iv.len;
2643 memcpy(cipher_auth_key, key, key_len);
2645 /* Setup Authentication Parameters */
2646 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2647 ut_params->auth_xform.next = NULL;
2649 ut_params->auth_xform.auth.op = auth_op;
2650 ut_params->auth_xform.auth.algo = auth_algo;
2651 ut_params->auth_xform.auth.key.length = key_len;
2652 /* Hash key = cipher key */
2653 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2654 ut_params->auth_xform.auth.digest_length = auth_len;
2655 /* Auth IV will be after cipher IV */
2656 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2657 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2659 /* Setup Cipher Parameters */
2660 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2661 ut_params->cipher_xform.next = &ut_params->auth_xform;
2663 ut_params->cipher_xform.cipher.algo = cipher_algo;
2664 ut_params->cipher_xform.cipher.op = cipher_op;
2665 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2666 ut_params->cipher_xform.cipher.key.length = key_len;
2667 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2668 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2671 debug_hexdump(stdout, "key:", key, key_len);
2673 /* Create Crypto session*/
2674 ut_params->sess = rte_cryptodev_sym_session_create(
2675 ts_params->session_mpool);
2677 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2678 &ut_params->cipher_xform,
2679 ts_params->session_priv_mpool);
2680 if (status == -ENOTSUP)
2681 return TEST_SKIPPED;
2683 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2684 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2689 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2690 const struct wireless_test_data *tdata)
2692 return create_wireless_cipher_auth_session(dev_id,
2693 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2694 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2695 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2699 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2700 enum rte_crypto_cipher_operation cipher_op,
2701 enum rte_crypto_auth_operation auth_op,
2702 enum rte_crypto_auth_algorithm auth_algo,
2703 enum rte_crypto_cipher_algorithm cipher_algo,
2704 const uint8_t *key, const uint8_t key_len,
2705 uint8_t auth_iv_len, uint8_t auth_len,
2706 uint8_t cipher_iv_len)
2708 uint8_t auth_cipher_key[key_len];
2710 struct crypto_testsuite_params *ts_params = &testsuite_params;
2711 struct crypto_unittest_params *ut_params = &unittest_params;
2713 memcpy(auth_cipher_key, key, key_len);
2715 /* Setup Authentication Parameters */
2716 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2717 ut_params->auth_xform.auth.op = auth_op;
2718 ut_params->auth_xform.next = &ut_params->cipher_xform;
2719 ut_params->auth_xform.auth.algo = auth_algo;
2720 ut_params->auth_xform.auth.key.length = key_len;
2721 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2722 ut_params->auth_xform.auth.digest_length = auth_len;
2723 /* Auth IV will be after cipher IV */
2724 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2725 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2727 /* Setup Cipher Parameters */
2728 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2729 ut_params->cipher_xform.next = NULL;
2730 ut_params->cipher_xform.cipher.algo = cipher_algo;
2731 ut_params->cipher_xform.cipher.op = cipher_op;
2732 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2733 ut_params->cipher_xform.cipher.key.length = key_len;
2734 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2735 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2737 debug_hexdump(stdout, "key:", key, key_len);
2739 /* Create Crypto session*/
2740 ut_params->sess = rte_cryptodev_sym_session_create(
2741 ts_params->session_mpool);
2742 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2744 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2745 ut_params->auth_xform.next = NULL;
2746 ut_params->cipher_xform.next = &ut_params->auth_xform;
2747 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2748 &ut_params->cipher_xform,
2749 ts_params->session_priv_mpool);
2752 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2753 &ut_params->auth_xform,
2754 ts_params->session_priv_mpool);
2756 if (status == -ENOTSUP)
2757 return TEST_SKIPPED;
2759 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2765 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2766 unsigned int auth_tag_len,
2767 const uint8_t *iv, unsigned int iv_len,
2768 unsigned int data_pad_len,
2769 enum rte_crypto_auth_operation op,
2770 unsigned int auth_len, unsigned int auth_offset)
2772 struct crypto_testsuite_params *ts_params = &testsuite_params;
2774 struct crypto_unittest_params *ut_params = &unittest_params;
2776 /* Generate Crypto op data structure */
2777 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2778 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2779 TEST_ASSERT_NOT_NULL(ut_params->op,
2780 "Failed to allocate pktmbuf offload");
2782 /* Set crypto operation data parameters */
2783 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2785 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2787 /* set crypto operation source mbuf */
2788 sym_op->m_src = ut_params->ibuf;
2791 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2794 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2795 ut_params->ibuf, auth_tag_len);
2797 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2798 "no room to append auth tag");
2799 ut_params->digest = sym_op->auth.digest.data;
2800 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2801 ut_params->ibuf, data_pad_len);
2802 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2803 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2805 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2807 debug_hexdump(stdout, "digest:",
2808 sym_op->auth.digest.data,
2811 sym_op->auth.data.length = auth_len;
2812 sym_op->auth.data.offset = auth_offset;
2818 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2819 enum rte_crypto_auth_operation op)
2821 struct crypto_testsuite_params *ts_params = &testsuite_params;
2822 struct crypto_unittest_params *ut_params = &unittest_params;
2824 const uint8_t *auth_tag = tdata->digest.data;
2825 const unsigned int auth_tag_len = tdata->digest.len;
2826 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2827 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2829 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2830 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2831 const uint8_t *auth_iv = tdata->auth_iv.data;
2832 const uint8_t auth_iv_len = tdata->auth_iv.len;
2833 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2834 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2836 /* Generate Crypto op data structure */
2837 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2838 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2839 TEST_ASSERT_NOT_NULL(ut_params->op,
2840 "Failed to allocate pktmbuf offload");
2841 /* Set crypto operation data parameters */
2842 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2844 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2846 /* set crypto operation source mbuf */
2847 sym_op->m_src = ut_params->ibuf;
2850 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2851 ut_params->ibuf, auth_tag_len);
2853 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2854 "no room to append auth tag");
2855 ut_params->digest = sym_op->auth.digest.data;
2856 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2857 ut_params->ibuf, data_pad_len);
2858 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2859 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2861 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2863 debug_hexdump(stdout, "digest:",
2864 sym_op->auth.digest.data,
2867 /* Copy cipher and auth IVs at the end of the crypto operation */
2868 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2870 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2871 iv_ptr += cipher_iv_len;
2872 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2874 sym_op->cipher.data.length = cipher_len;
2875 sym_op->cipher.data.offset = 0;
2876 sym_op->auth.data.length = auth_len;
2877 sym_op->auth.data.offset = 0;
2883 create_zuc_cipher_hash_generate_operation(
2884 const struct wireless_test_data *tdata)
2886 return create_wireless_cipher_hash_operation(tdata,
2887 RTE_CRYPTO_AUTH_OP_GENERATE);
2891 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2892 const unsigned auth_tag_len,
2893 const uint8_t *auth_iv, uint8_t auth_iv_len,
2894 unsigned data_pad_len,
2895 enum rte_crypto_auth_operation op,
2896 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2897 const unsigned cipher_len, const unsigned cipher_offset,
2898 const unsigned auth_len, const unsigned auth_offset)
2900 struct crypto_testsuite_params *ts_params = &testsuite_params;
2901 struct crypto_unittest_params *ut_params = &unittest_params;
2903 enum rte_crypto_cipher_algorithm cipher_algo =
2904 ut_params->cipher_xform.cipher.algo;
2905 enum rte_crypto_auth_algorithm auth_algo =
2906 ut_params->auth_xform.auth.algo;
2908 /* Generate Crypto op data structure */
2909 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2910 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2911 TEST_ASSERT_NOT_NULL(ut_params->op,
2912 "Failed to allocate pktmbuf offload");
2913 /* Set crypto operation data parameters */
2914 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2916 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2918 /* set crypto operation source mbuf */
2919 sym_op->m_src = ut_params->ibuf;
2922 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2923 ut_params->ibuf, auth_tag_len);
2925 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2926 "no room to append auth tag");
2927 ut_params->digest = sym_op->auth.digest.data;
2929 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2930 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2931 ut_params->ibuf, data_pad_len);
2933 struct rte_mbuf *m = ut_params->ibuf;
2934 unsigned int offset = data_pad_len;
2936 while (offset > m->data_len && m->next != NULL) {
2937 offset -= m->data_len;
2940 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2944 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2945 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2947 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2949 debug_hexdump(stdout, "digest:",
2950 sym_op->auth.digest.data,
2953 /* Copy cipher and auth IVs at the end of the crypto operation */
2954 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2956 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2957 iv_ptr += cipher_iv_len;
2958 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2960 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2961 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2962 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2963 sym_op->cipher.data.length = cipher_len;
2964 sym_op->cipher.data.offset = cipher_offset;
2966 sym_op->cipher.data.length = cipher_len >> 3;
2967 sym_op->cipher.data.offset = cipher_offset >> 3;
2970 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2971 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2972 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2973 sym_op->auth.data.length = auth_len;
2974 sym_op->auth.data.offset = auth_offset;
2976 sym_op->auth.data.length = auth_len >> 3;
2977 sym_op->auth.data.offset = auth_offset >> 3;
2984 create_wireless_algo_auth_cipher_operation(
2985 const uint8_t *auth_tag, unsigned int auth_tag_len,
2986 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2987 const uint8_t *auth_iv, uint8_t auth_iv_len,
2988 unsigned int data_pad_len,
2989 unsigned int cipher_len, unsigned int cipher_offset,
2990 unsigned int auth_len, unsigned int auth_offset,
2991 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2993 struct crypto_testsuite_params *ts_params = &testsuite_params;
2994 struct crypto_unittest_params *ut_params = &unittest_params;
2996 enum rte_crypto_cipher_algorithm cipher_algo =
2997 ut_params->cipher_xform.cipher.algo;
2998 enum rte_crypto_auth_algorithm auth_algo =
2999 ut_params->auth_xform.auth.algo;
3001 /* Generate Crypto op data structure */
3002 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3003 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3004 TEST_ASSERT_NOT_NULL(ut_params->op,
3005 "Failed to allocate pktmbuf offload");
3007 /* Set crypto operation data parameters */
3008 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3010 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3012 /* set crypto operation mbufs */
3013 sym_op->m_src = ut_params->ibuf;
3014 if (op_mode == OUT_OF_PLACE)
3015 sym_op->m_dst = ut_params->obuf;
3019 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3020 (op_mode == IN_PLACE ?
3021 ut_params->ibuf : ut_params->obuf),
3022 uint8_t *, data_pad_len);
3023 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3024 (op_mode == IN_PLACE ?
3025 ut_params->ibuf : ut_params->obuf),
3027 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3029 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3030 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3031 sym_op->m_src : sym_op->m_dst);
3032 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3033 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3034 sgl_buf = sgl_buf->next;
3036 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3037 uint8_t *, remaining_off);
3038 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3040 memset(sym_op->auth.digest.data, 0, remaining_off);
3041 while (sgl_buf->next != NULL) {
3042 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3043 0, rte_pktmbuf_data_len(sgl_buf));
3044 sgl_buf = sgl_buf->next;
3048 /* Copy digest for the verification */
3050 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3052 /* Copy cipher and auth IVs at the end of the crypto operation */
3053 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3054 ut_params->op, uint8_t *, IV_OFFSET);
3056 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3057 iv_ptr += cipher_iv_len;
3058 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3060 /* Only copy over the offset data needed from src to dst in OOP,
3061 * if the auth and cipher offsets are not aligned
3063 if (op_mode == OUT_OF_PLACE) {
3064 if (cipher_offset > auth_offset)
3066 rte_pktmbuf_mtod_offset(
3068 uint8_t *, auth_offset >> 3),
3069 rte_pktmbuf_mtod_offset(
3071 uint8_t *, auth_offset >> 3),
3072 ((cipher_offset >> 3) - (auth_offset >> 3)));
3075 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3076 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3077 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3078 sym_op->cipher.data.length = cipher_len;
3079 sym_op->cipher.data.offset = cipher_offset;
3081 sym_op->cipher.data.length = cipher_len >> 3;
3082 sym_op->cipher.data.offset = cipher_offset >> 3;
3085 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3086 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3087 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3088 sym_op->auth.data.length = auth_len;
3089 sym_op->auth.data.offset = auth_offset;
3091 sym_op->auth.data.length = auth_len >> 3;
3092 sym_op->auth.data.offset = auth_offset >> 3;
3099 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3101 struct crypto_testsuite_params *ts_params = &testsuite_params;
3102 struct crypto_unittest_params *ut_params = &unittest_params;
3105 unsigned plaintext_pad_len;
3106 unsigned plaintext_len;
3108 struct rte_cryptodev_info dev_info;
3110 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3111 uint64_t feat_flags = dev_info.feature_flags;
3113 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3114 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3115 printf("Device doesn't support NON-Byte Aligned Data.\n");
3116 return TEST_SKIPPED;
3119 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3120 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3121 printf("Device doesn't support RAW data-path APIs.\n");
3122 return TEST_SKIPPED;
3125 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3126 return TEST_SKIPPED;
3128 /* Verify the capabilities */
3129 struct rte_cryptodev_sym_capability_idx cap_idx;
3130 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3131 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3132 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3134 return TEST_SKIPPED;
3136 /* Create SNOW 3G session */
3137 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3138 tdata->key.data, tdata->key.len,
3139 tdata->auth_iv.len, tdata->digest.len,
3140 RTE_CRYPTO_AUTH_OP_GENERATE,
3141 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3145 /* alloc mbuf and set payload */
3146 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3148 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3149 rte_pktmbuf_tailroom(ut_params->ibuf));
3151 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3152 /* Append data which is padded to a multiple of */
3153 /* the algorithms block size */
3154 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3155 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3157 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3159 /* Create SNOW 3G operation */
3160 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3161 tdata->auth_iv.data, tdata->auth_iv.len,
3162 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3163 tdata->validAuthLenInBits.len,
3168 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3169 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3170 ut_params->op, 0, 1, 1, 0);
3172 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3174 ut_params->obuf = ut_params->op->sym->m_src;
3175 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3176 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3177 + plaintext_pad_len;
3180 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3183 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3184 "SNOW 3G Generated auth tag not as expected");
3190 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3192 struct crypto_testsuite_params *ts_params = &testsuite_params;
3193 struct crypto_unittest_params *ut_params = &unittest_params;
3196 unsigned plaintext_pad_len;
3197 unsigned plaintext_len;
3199 struct rte_cryptodev_info dev_info;
3201 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3202 uint64_t feat_flags = dev_info.feature_flags;
3204 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3205 ((tdata->validAuthLenInBits.len % 8) != 0)) {
3206 printf("Device doesn't support NON-Byte Aligned Data.\n");
3207 return TEST_SKIPPED;
3210 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3211 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3212 printf("Device doesn't support RAW data-path APIs.\n");
3213 return TEST_SKIPPED;
3216 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3217 return TEST_SKIPPED;
3219 /* Verify the capabilities */
3220 struct rte_cryptodev_sym_capability_idx cap_idx;
3221 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3222 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3223 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3225 return TEST_SKIPPED;
3227 /* Create SNOW 3G session */
3228 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3229 tdata->key.data, tdata->key.len,
3230 tdata->auth_iv.len, tdata->digest.len,
3231 RTE_CRYPTO_AUTH_OP_VERIFY,
3232 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3235 /* alloc mbuf and set payload */
3236 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3238 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3239 rte_pktmbuf_tailroom(ut_params->ibuf));
3241 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3242 /* Append data which is padded to a multiple of */
3243 /* the algorithms block size */
3244 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3245 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3247 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3249 /* Create SNOW 3G operation */
3250 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3252 tdata->auth_iv.data, tdata->auth_iv.len,
3254 RTE_CRYPTO_AUTH_OP_VERIFY,
3255 tdata->validAuthLenInBits.len,
3260 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3261 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3262 ut_params->op, 0, 1, 1, 0);
3264 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3266 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3267 ut_params->obuf = ut_params->op->sym->m_src;
3268 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3269 + plaintext_pad_len;
3272 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3281 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3283 struct crypto_testsuite_params *ts_params = &testsuite_params;
3284 struct crypto_unittest_params *ut_params = &unittest_params;
3287 unsigned plaintext_pad_len;
3288 unsigned plaintext_len;
3290 struct rte_cryptodev_info dev_info;
3292 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3293 uint64_t feat_flags = dev_info.feature_flags;
3295 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3296 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3297 printf("Device doesn't support RAW data-path APIs.\n");
3298 return TEST_SKIPPED;
3301 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3302 return TEST_SKIPPED;
3304 /* Verify the capabilities */
3305 struct rte_cryptodev_sym_capability_idx cap_idx;
3306 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3307 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3308 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3310 return TEST_SKIPPED;
3312 /* Create KASUMI session */
3313 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3314 tdata->key.data, tdata->key.len,
3315 0, tdata->digest.len,
3316 RTE_CRYPTO_AUTH_OP_GENERATE,
3317 RTE_CRYPTO_AUTH_KASUMI_F9);
3321 /* alloc mbuf and set payload */
3322 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3324 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3325 rte_pktmbuf_tailroom(ut_params->ibuf));
3327 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3328 /* Append data which is padded to a multiple of */
3329 /* the algorithms block size */
3330 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3331 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3333 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3335 /* Create KASUMI operation */
3336 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3338 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3339 tdata->plaintext.len,
3344 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3345 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3347 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3348 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3349 ut_params->op, 0, 1, 1, 0);
3351 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3354 ut_params->obuf = ut_params->op->sym->m_src;
3355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3356 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3357 + plaintext_pad_len;
3360 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3363 DIGEST_BYTE_LENGTH_KASUMI_F9,
3364 "KASUMI Generated auth tag not as expected");
3370 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3372 struct crypto_testsuite_params *ts_params = &testsuite_params;
3373 struct crypto_unittest_params *ut_params = &unittest_params;
3376 unsigned plaintext_pad_len;
3377 unsigned plaintext_len;
3379 struct rte_cryptodev_info dev_info;
3381 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3382 uint64_t feat_flags = dev_info.feature_flags;
3384 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3385 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3386 printf("Device doesn't support RAW data-path APIs.\n");
3387 return TEST_SKIPPED;
3390 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3391 return TEST_SKIPPED;
3393 /* Verify the capabilities */
3394 struct rte_cryptodev_sym_capability_idx cap_idx;
3395 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3396 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3397 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3399 return TEST_SKIPPED;
3401 /* Create KASUMI session */
3402 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3403 tdata->key.data, tdata->key.len,
3404 0, tdata->digest.len,
3405 RTE_CRYPTO_AUTH_OP_VERIFY,
3406 RTE_CRYPTO_AUTH_KASUMI_F9);
3409 /* alloc mbuf and set payload */
3410 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3412 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3413 rte_pktmbuf_tailroom(ut_params->ibuf));
3415 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3416 /* Append data which is padded to a multiple */
3417 /* of the algorithms block size */
3418 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3419 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3421 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3423 /* Create KASUMI operation */
3424 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3428 RTE_CRYPTO_AUTH_OP_VERIFY,
3429 tdata->plaintext.len,
3434 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3435 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3436 ut_params->op, 0, 1, 1, 0);
3438 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3440 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3441 ut_params->obuf = ut_params->op->sym->m_src;
3442 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3443 + plaintext_pad_len;
3446 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3455 test_snow3g_hash_generate_test_case_1(void)
3457 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3461 test_snow3g_hash_generate_test_case_2(void)
3463 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3467 test_snow3g_hash_generate_test_case_3(void)
3469 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3473 test_snow3g_hash_generate_test_case_4(void)
3475 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3479 test_snow3g_hash_generate_test_case_5(void)
3481 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3485 test_snow3g_hash_generate_test_case_6(void)
3487 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3491 test_snow3g_hash_verify_test_case_1(void)
3493 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3498 test_snow3g_hash_verify_test_case_2(void)
3500 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3504 test_snow3g_hash_verify_test_case_3(void)
3506 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3510 test_snow3g_hash_verify_test_case_4(void)
3512 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3516 test_snow3g_hash_verify_test_case_5(void)
3518 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3522 test_snow3g_hash_verify_test_case_6(void)
3524 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3528 test_kasumi_hash_generate_test_case_1(void)
3530 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3534 test_kasumi_hash_generate_test_case_2(void)
3536 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3540 test_kasumi_hash_generate_test_case_3(void)
3542 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3546 test_kasumi_hash_generate_test_case_4(void)
3548 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3552 test_kasumi_hash_generate_test_case_5(void)
3554 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3558 test_kasumi_hash_generate_test_case_6(void)
3560 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3564 test_kasumi_hash_verify_test_case_1(void)
3566 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3570 test_kasumi_hash_verify_test_case_2(void)
3572 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3576 test_kasumi_hash_verify_test_case_3(void)
3578 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3582 test_kasumi_hash_verify_test_case_4(void)
3584 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3588 test_kasumi_hash_verify_test_case_5(void)
3590 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3594 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3596 struct crypto_testsuite_params *ts_params = &testsuite_params;
3597 struct crypto_unittest_params *ut_params = &unittest_params;
3600 uint8_t *plaintext, *ciphertext;
3601 unsigned plaintext_pad_len;
3602 unsigned plaintext_len;
3603 struct rte_cryptodev_info dev_info;
3605 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3606 uint64_t feat_flags = dev_info.feature_flags;
3608 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3609 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3610 printf("Device doesn't support RAW data-path APIs.\n");
3611 return TEST_SKIPPED;
3614 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3615 return TEST_SKIPPED;
3617 /* Verify the capabilities */
3618 struct rte_cryptodev_sym_capability_idx cap_idx;
3619 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3620 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3621 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3623 return TEST_SKIPPED;
3625 /* Create KASUMI session */
3626 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3627 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3628 RTE_CRYPTO_CIPHER_KASUMI_F8,
3629 tdata->key.data, tdata->key.len,
3630 tdata->cipher_iv.len);
3634 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3636 /* Clear mbuf payload */
3637 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3638 rte_pktmbuf_tailroom(ut_params->ibuf));
3640 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3641 /* Append data which is padded to a multiple */
3642 /* of the algorithms block size */
3643 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3644 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3648 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3650 /* Create KASUMI operation */
3651 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3652 tdata->cipher_iv.len,
3653 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3654 tdata->validCipherOffsetInBits.len);
3658 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3659 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3660 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3662 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3664 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3666 ut_params->obuf = ut_params->op->sym->m_dst;
3667 if (ut_params->obuf)
3668 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3670 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3672 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3674 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3675 (tdata->validCipherOffsetInBits.len >> 3);
3677 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3679 reference_ciphertext,
3680 tdata->validCipherLenInBits.len,
3681 "KASUMI Ciphertext data not as expected");
3686 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3688 struct crypto_testsuite_params *ts_params = &testsuite_params;
3689 struct crypto_unittest_params *ut_params = &unittest_params;
3693 unsigned int plaintext_pad_len;
3694 unsigned int plaintext_len;
3696 uint8_t buffer[10000];
3697 const uint8_t *ciphertext;
3699 struct rte_cryptodev_info dev_info;
3701 /* Verify the capabilities */
3702 struct rte_cryptodev_sym_capability_idx cap_idx;
3703 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3704 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3705 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3707 return TEST_SKIPPED;
3709 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3711 uint64_t feat_flags = dev_info.feature_flags;
3713 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3714 printf("Device doesn't support in-place scatter-gather. "
3716 return TEST_SKIPPED;
3719 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3720 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3721 printf("Device doesn't support RAW data-path APIs.\n");
3722 return TEST_SKIPPED;
3725 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3726 return TEST_SKIPPED;
3728 /* Create KASUMI session */
3729 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3730 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3731 RTE_CRYPTO_CIPHER_KASUMI_F8,
3732 tdata->key.data, tdata->key.len,
3733 tdata->cipher_iv.len);
3737 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3740 /* Append data which is padded to a multiple */
3741 /* of the algorithms block size */
3742 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3744 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3745 plaintext_pad_len, 10, 0);
3747 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3749 /* Create KASUMI operation */
3750 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3751 tdata->cipher_iv.len,
3752 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3753 tdata->validCipherOffsetInBits.len);
3757 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3758 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3759 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3763 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3765 ut_params->obuf = ut_params->op->sym->m_dst;
3767 if (ut_params->obuf)
3768 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3769 plaintext_len, buffer);
3771 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3772 tdata->validCipherOffsetInBits.len >> 3,
3773 plaintext_len, buffer);
3776 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3778 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3779 (tdata->validCipherOffsetInBits.len >> 3);
3781 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3783 reference_ciphertext,
3784 tdata->validCipherLenInBits.len,
3785 "KASUMI Ciphertext data not as expected");
3790 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3792 struct crypto_testsuite_params *ts_params = &testsuite_params;
3793 struct crypto_unittest_params *ut_params = &unittest_params;
3796 uint8_t *plaintext, *ciphertext;
3797 unsigned plaintext_pad_len;
3798 unsigned plaintext_len;
3800 /* Verify the capabilities */
3801 struct rte_cryptodev_sym_capability_idx cap_idx;
3802 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3803 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3804 /* Data-path service does not support OOP */
3805 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3807 return TEST_SKIPPED;
3809 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3810 return TEST_SKIPPED;
3812 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3813 return TEST_SKIPPED;
3815 /* Create KASUMI session */
3816 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3817 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3818 RTE_CRYPTO_CIPHER_KASUMI_F8,
3819 tdata->key.data, tdata->key.len,
3820 tdata->cipher_iv.len);
3824 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3825 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3827 /* Clear mbuf payload */
3828 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3829 rte_pktmbuf_tailroom(ut_params->ibuf));
3831 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3832 /* Append data which is padded to a multiple */
3833 /* of the algorithms block size */
3834 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3835 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3837 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3838 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3840 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3842 /* Create KASUMI operation */
3843 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3844 tdata->cipher_iv.len,
3845 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3846 tdata->validCipherOffsetInBits.len);
3850 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3852 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3854 ut_params->obuf = ut_params->op->sym->m_dst;
3855 if (ut_params->obuf)
3856 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3858 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3860 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3862 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3863 (tdata->validCipherOffsetInBits.len >> 3);
3865 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3867 reference_ciphertext,
3868 tdata->validCipherLenInBits.len,
3869 "KASUMI Ciphertext data not as expected");
3874 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3876 struct crypto_testsuite_params *ts_params = &testsuite_params;
3877 struct crypto_unittest_params *ut_params = &unittest_params;
3880 unsigned int plaintext_pad_len;
3881 unsigned int plaintext_len;
3883 const uint8_t *ciphertext;
3884 uint8_t buffer[2048];
3886 struct rte_cryptodev_info dev_info;
3888 /* Verify the capabilities */
3889 struct rte_cryptodev_sym_capability_idx cap_idx;
3890 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3891 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3892 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3894 return TEST_SKIPPED;
3896 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3897 return TEST_SKIPPED;
3899 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3900 return TEST_SKIPPED;
3902 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3904 uint64_t feat_flags = dev_info.feature_flags;
3905 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3906 printf("Device doesn't support out-of-place scatter-gather "
3907 "in both input and output mbufs. "
3909 return TEST_SKIPPED;
3912 /* Create KASUMI session */
3913 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3914 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3915 RTE_CRYPTO_CIPHER_KASUMI_F8,
3916 tdata->key.data, tdata->key.len,
3917 tdata->cipher_iv.len);
3921 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3922 /* Append data which is padded to a multiple */
3923 /* of the algorithms block size */
3924 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3926 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3927 plaintext_pad_len, 10, 0);
3928 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3929 plaintext_pad_len, 3, 0);
3931 /* Append data which is padded to a multiple */
3932 /* of the algorithms block size */
3933 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3935 /* Create KASUMI operation */
3936 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3937 tdata->cipher_iv.len,
3938 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3939 tdata->validCipherOffsetInBits.len);
3943 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3945 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3947 ut_params->obuf = ut_params->op->sym->m_dst;
3948 if (ut_params->obuf)
3949 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3950 plaintext_pad_len, buffer);
3952 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3953 tdata->validCipherOffsetInBits.len >> 3,
3954 plaintext_pad_len, buffer);
3956 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3957 (tdata->validCipherOffsetInBits.len >> 3);
3959 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3961 reference_ciphertext,
3962 tdata->validCipherLenInBits.len,
3963 "KASUMI Ciphertext data not as expected");
3969 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3971 struct crypto_testsuite_params *ts_params = &testsuite_params;
3972 struct crypto_unittest_params *ut_params = &unittest_params;
3975 uint8_t *ciphertext, *plaintext;
3976 unsigned ciphertext_pad_len;
3977 unsigned ciphertext_len;
3979 /* Verify the capabilities */
3980 struct rte_cryptodev_sym_capability_idx cap_idx;
3981 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3982 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3983 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3985 return TEST_SKIPPED;
3987 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3988 return TEST_SKIPPED;
3990 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3991 return TEST_SKIPPED;
3993 /* Create KASUMI session */
3994 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3995 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3996 RTE_CRYPTO_CIPHER_KASUMI_F8,
3997 tdata->key.data, tdata->key.len,
3998 tdata->cipher_iv.len);
4002 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4003 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4005 /* Clear mbuf payload */
4006 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4007 rte_pktmbuf_tailroom(ut_params->ibuf));
4009 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4010 /* Append data which is padded to a multiple */
4011 /* of the algorithms block size */
4012 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4013 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4014 ciphertext_pad_len);
4015 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4016 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4018 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4020 /* Create KASUMI operation */
4021 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4022 tdata->cipher_iv.len,
4023 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4024 tdata->validCipherOffsetInBits.len);
4028 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4030 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4032 ut_params->obuf = ut_params->op->sym->m_dst;
4033 if (ut_params->obuf)
4034 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4036 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4038 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4040 const uint8_t *reference_plaintext = tdata->plaintext.data +
4041 (tdata->validCipherOffsetInBits.len >> 3);
4043 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4045 reference_plaintext,
4046 tdata->validCipherLenInBits.len,
4047 "KASUMI Plaintext data not as expected");
4052 test_kasumi_decryption(const struct kasumi_test_data *tdata)
4054 struct crypto_testsuite_params *ts_params = &testsuite_params;
4055 struct crypto_unittest_params *ut_params = &unittest_params;
4058 uint8_t *ciphertext, *plaintext;
4059 unsigned ciphertext_pad_len;
4060 unsigned ciphertext_len;
4061 struct rte_cryptodev_info dev_info;
4063 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4064 uint64_t feat_flags = dev_info.feature_flags;
4066 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4067 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4068 printf("Device doesn't support RAW data-path APIs.\n");
4069 return TEST_SKIPPED;
4072 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4073 return TEST_SKIPPED;
4075 /* Verify the capabilities */
4076 struct rte_cryptodev_sym_capability_idx cap_idx;
4077 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4078 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
4079 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4081 return TEST_SKIPPED;
4083 /* Create KASUMI session */
4084 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4085 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4086 RTE_CRYPTO_CIPHER_KASUMI_F8,
4087 tdata->key.data, tdata->key.len,
4088 tdata->cipher_iv.len);
4092 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4094 /* Clear mbuf payload */
4095 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4096 rte_pktmbuf_tailroom(ut_params->ibuf));
4098 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4099 /* Append data which is padded to a multiple */
4100 /* of the algorithms block size */
4101 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4102 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4103 ciphertext_pad_len);
4104 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4106 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4108 /* Create KASUMI operation */
4109 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4110 tdata->cipher_iv.len,
4111 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4112 tdata->validCipherOffsetInBits.len);
4116 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4117 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4118 ut_params->op, 1, 0, 1, 0);
4120 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4122 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4124 ut_params->obuf = ut_params->op->sym->m_dst;
4125 if (ut_params->obuf)
4126 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4128 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4130 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4132 const uint8_t *reference_plaintext = tdata->plaintext.data +
4133 (tdata->validCipherOffsetInBits.len >> 3);
4135 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4137 reference_plaintext,
4138 tdata->validCipherLenInBits.len,
4139 "KASUMI Plaintext data not as expected");
4144 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4146 struct crypto_testsuite_params *ts_params = &testsuite_params;
4147 struct crypto_unittest_params *ut_params = &unittest_params;
4150 uint8_t *plaintext, *ciphertext;
4151 unsigned plaintext_pad_len;
4152 unsigned plaintext_len;
4153 struct rte_cryptodev_info dev_info;
4155 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4156 uint64_t feat_flags = dev_info.feature_flags;
4158 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4159 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4160 printf("Device doesn't support RAW data-path APIs.\n");
4161 return TEST_SKIPPED;
4164 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4165 return TEST_SKIPPED;
4167 /* Verify the capabilities */
4168 struct rte_cryptodev_sym_capability_idx cap_idx;
4169 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4170 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4171 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4173 return TEST_SKIPPED;
4175 /* Create SNOW 3G session */
4176 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4177 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4178 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4179 tdata->key.data, tdata->key.len,
4180 tdata->cipher_iv.len);
4184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4186 /* Clear mbuf payload */
4187 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4188 rte_pktmbuf_tailroom(ut_params->ibuf));
4190 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4191 /* Append data which is padded to a multiple of */
4192 /* the algorithms block size */
4193 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4194 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4196 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4198 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4200 /* Create SNOW 3G operation */
4201 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4202 tdata->cipher_iv.len,
4203 tdata->validCipherLenInBits.len,
4208 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4209 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4210 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4212 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4214 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4216 ut_params->obuf = ut_params->op->sym->m_dst;
4217 if (ut_params->obuf)
4218 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4220 ciphertext = plaintext;
4222 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4225 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4227 tdata->ciphertext.data,
4228 tdata->validDataLenInBits.len,
4229 "SNOW 3G Ciphertext data not as expected");
4235 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4237 struct crypto_testsuite_params *ts_params = &testsuite_params;
4238 struct crypto_unittest_params *ut_params = &unittest_params;
4239 uint8_t *plaintext, *ciphertext;
4242 unsigned plaintext_pad_len;
4243 unsigned plaintext_len;
4244 struct rte_cryptodev_info dev_info;
4246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4247 uint64_t feat_flags = dev_info.feature_flags;
4249 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4250 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4251 printf("Device does not support RAW data-path APIs.\n");
4255 /* Verify the capabilities */
4256 struct rte_cryptodev_sym_capability_idx cap_idx;
4257 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4258 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4259 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4261 return TEST_SKIPPED;
4263 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4264 return TEST_SKIPPED;
4266 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4267 return TEST_SKIPPED;
4269 /* Create SNOW 3G session */
4270 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4271 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4272 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4273 tdata->key.data, tdata->key.len,
4274 tdata->cipher_iv.len);
4278 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4279 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4281 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4282 "Failed to allocate input buffer in mempool");
4283 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4284 "Failed to allocate output buffer in mempool");
4286 /* Clear mbuf payload */
4287 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4288 rte_pktmbuf_tailroom(ut_params->ibuf));
4290 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4291 /* Append data which is padded to a multiple of */
4292 /* the algorithms block size */
4293 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4294 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4296 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4297 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4299 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4301 /* Create SNOW 3G operation */
4302 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4303 tdata->cipher_iv.len,
4304 tdata->validCipherLenInBits.len,
4309 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4310 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4311 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4313 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4315 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4317 ut_params->obuf = ut_params->op->sym->m_dst;
4318 if (ut_params->obuf)
4319 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4321 ciphertext = plaintext;
4323 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4326 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4328 tdata->ciphertext.data,
4329 tdata->validDataLenInBits.len,
4330 "SNOW 3G Ciphertext data not as expected");
4335 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4337 struct crypto_testsuite_params *ts_params = &testsuite_params;
4338 struct crypto_unittest_params *ut_params = &unittest_params;
4341 unsigned int plaintext_pad_len;
4342 unsigned int plaintext_len;
4343 uint8_t buffer[10000];
4344 const uint8_t *ciphertext;
4346 struct rte_cryptodev_info dev_info;
4348 /* Verify the capabilities */
4349 struct rte_cryptodev_sym_capability_idx cap_idx;
4350 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4351 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4352 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4354 return TEST_SKIPPED;
4356 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4357 return TEST_SKIPPED;
4359 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4360 return TEST_SKIPPED;
4362 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4364 uint64_t feat_flags = dev_info.feature_flags;
4366 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4367 printf("Device doesn't support out-of-place scatter-gather "
4368 "in both input and output mbufs. "
4370 return TEST_SKIPPED;
4373 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4374 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4375 printf("Device does not support RAW data-path APIs.\n");
4379 /* Create SNOW 3G session */
4380 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4381 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4382 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4383 tdata->key.data, tdata->key.len,
4384 tdata->cipher_iv.len);
4388 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4389 /* Append data which is padded to a multiple of */
4390 /* the algorithms block size */
4391 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4393 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4394 plaintext_pad_len, 10, 0);
4395 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4396 plaintext_pad_len, 3, 0);
4398 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4399 "Failed to allocate input buffer in mempool");
4400 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4401 "Failed to allocate output buffer in mempool");
4403 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4405 /* Create SNOW 3G operation */
4406 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4407 tdata->cipher_iv.len,
4408 tdata->validCipherLenInBits.len,
4413 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4414 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4415 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4417 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4419 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4421 ut_params->obuf = ut_params->op->sym->m_dst;
4422 if (ut_params->obuf)
4423 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4424 plaintext_len, buffer);
4426 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4427 plaintext_len, buffer);
4429 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4432 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4434 tdata->ciphertext.data,
4435 tdata->validDataLenInBits.len,
4436 "SNOW 3G Ciphertext data not as expected");
4441 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4443 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4445 uint8_t curr_byte, prev_byte;
4446 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4447 uint8_t lower_byte_mask = (1 << offset) - 1;
4450 prev_byte = buffer[0];
4451 buffer[0] >>= offset;
4453 for (i = 1; i < length_in_bytes; i++) {
4454 curr_byte = buffer[i];
4455 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4456 (curr_byte >> offset);
4457 prev_byte = curr_byte;
4462 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4464 struct crypto_testsuite_params *ts_params = &testsuite_params;
4465 struct crypto_unittest_params *ut_params = &unittest_params;
4466 uint8_t *plaintext, *ciphertext;
4468 uint32_t plaintext_len;
4469 uint32_t plaintext_pad_len;
4470 uint8_t extra_offset = 4;
4471 uint8_t *expected_ciphertext_shifted;
4472 struct rte_cryptodev_info dev_info;
4474 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4475 uint64_t feat_flags = dev_info.feature_flags;
4477 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4478 ((tdata->validDataLenInBits.len % 8) != 0)) {
4479 printf("Device doesn't support NON-Byte Aligned Data.\n");
4480 return TEST_SKIPPED;
4483 /* Verify the capabilities */
4484 struct rte_cryptodev_sym_capability_idx cap_idx;
4485 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4486 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4487 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4489 return TEST_SKIPPED;
4491 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4492 return TEST_SKIPPED;
4494 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4495 return TEST_SKIPPED;
4497 /* Create SNOW 3G session */
4498 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4499 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4500 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4501 tdata->key.data, tdata->key.len,
4502 tdata->cipher_iv.len);
4506 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4507 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4509 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4510 "Failed to allocate input buffer in mempool");
4511 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4512 "Failed to allocate output buffer in mempool");
4514 /* Clear mbuf payload */
4515 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4516 rte_pktmbuf_tailroom(ut_params->ibuf));
4518 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4520 * Append data which is padded to a
4521 * multiple of the algorithms block size
4523 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4525 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4528 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4530 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4531 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4533 #ifdef RTE_APP_TEST_DEBUG
4534 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4536 /* Create SNOW 3G operation */
4537 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4538 tdata->cipher_iv.len,
4539 tdata->validCipherLenInBits.len,
4544 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4545 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4546 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4548 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4550 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4552 ut_params->obuf = ut_params->op->sym->m_dst;
4553 if (ut_params->obuf)
4554 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4556 ciphertext = plaintext;
4558 #ifdef RTE_APP_TEST_DEBUG
4559 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4562 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4564 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4565 "failed to reserve memory for ciphertext shifted\n");
4567 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4568 ceil_byte_length(tdata->ciphertext.len));
4569 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4572 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4574 expected_ciphertext_shifted,
4575 tdata->validDataLenInBits.len,
4577 "SNOW 3G Ciphertext data not as expected");
4581 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4583 struct crypto_testsuite_params *ts_params = &testsuite_params;
4584 struct crypto_unittest_params *ut_params = &unittest_params;
4588 uint8_t *plaintext, *ciphertext;
4589 unsigned ciphertext_pad_len;
4590 unsigned ciphertext_len;
4591 struct rte_cryptodev_info dev_info;
4593 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4594 uint64_t feat_flags = dev_info.feature_flags;
4596 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4597 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4598 printf("Device doesn't support RAW data-path APIs.\n");
4599 return TEST_SKIPPED;
4602 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4603 return TEST_SKIPPED;
4605 /* Verify the capabilities */
4606 struct rte_cryptodev_sym_capability_idx cap_idx;
4607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4608 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4609 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4611 return TEST_SKIPPED;
4613 /* Create SNOW 3G session */
4614 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4615 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4616 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4617 tdata->key.data, tdata->key.len,
4618 tdata->cipher_iv.len);
4622 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4624 /* Clear mbuf payload */
4625 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4626 rte_pktmbuf_tailroom(ut_params->ibuf));
4628 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4629 /* Append data which is padded to a multiple of */
4630 /* the algorithms block size */
4631 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4632 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4633 ciphertext_pad_len);
4634 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4636 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4638 /* Create SNOW 3G operation */
4639 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4640 tdata->cipher_iv.len,
4641 tdata->validCipherLenInBits.len,
4642 tdata->cipher.offset_bits);
4646 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4647 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4648 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4650 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4652 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4653 ut_params->obuf = ut_params->op->sym->m_dst;
4654 if (ut_params->obuf)
4655 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4657 plaintext = ciphertext;
4659 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4662 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4663 tdata->plaintext.data,
4664 tdata->validDataLenInBits.len,
4665 "SNOW 3G Plaintext data not as expected");
4669 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4671 struct crypto_testsuite_params *ts_params = &testsuite_params;
4672 struct crypto_unittest_params *ut_params = &unittest_params;
4676 uint8_t *plaintext, *ciphertext;
4677 unsigned ciphertext_pad_len;
4678 unsigned ciphertext_len;
4679 struct rte_cryptodev_info dev_info;
4681 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4682 uint64_t feat_flags = dev_info.feature_flags;
4684 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4685 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4686 printf("Device does not support RAW data-path APIs.\n");
4689 /* Verify the capabilities */
4690 struct rte_cryptodev_sym_capability_idx cap_idx;
4691 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4692 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4693 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4695 return TEST_SKIPPED;
4697 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4698 return TEST_SKIPPED;
4700 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4701 return TEST_SKIPPED;
4703 /* Create SNOW 3G session */
4704 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4705 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4706 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4707 tdata->key.data, tdata->key.len,
4708 tdata->cipher_iv.len);
4712 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4713 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4715 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4716 "Failed to allocate input buffer");
4717 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4718 "Failed to allocate output buffer");
4720 /* Clear mbuf payload */
4721 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4722 rte_pktmbuf_tailroom(ut_params->ibuf));
4724 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4725 rte_pktmbuf_tailroom(ut_params->obuf));
4727 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4728 /* Append data which is padded to a multiple of */
4729 /* the algorithms block size */
4730 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4731 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4732 ciphertext_pad_len);
4733 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4734 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4736 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4738 /* Create SNOW 3G operation */
4739 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4740 tdata->cipher_iv.len,
4741 tdata->validCipherLenInBits.len,
4746 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4747 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4748 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4750 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4752 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4753 ut_params->obuf = ut_params->op->sym->m_dst;
4754 if (ut_params->obuf)
4755 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4757 plaintext = ciphertext;
4759 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4762 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4763 tdata->plaintext.data,
4764 tdata->validDataLenInBits.len,
4765 "SNOW 3G Plaintext data not as expected");
4770 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4772 struct crypto_testsuite_params *ts_params = &testsuite_params;
4773 struct crypto_unittest_params *ut_params = &unittest_params;
4777 uint8_t *plaintext, *ciphertext;
4778 unsigned int plaintext_pad_len;
4779 unsigned int plaintext_len;
4781 struct rte_cryptodev_info dev_info;
4782 struct rte_cryptodev_sym_capability_idx cap_idx;
4784 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4785 uint64_t feat_flags = dev_info.feature_flags;
4787 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4788 ((tdata->validAuthLenInBits.len % 8 != 0) ||
4789 (tdata->validDataLenInBits.len % 8 != 0))) {
4790 printf("Device doesn't support NON-Byte Aligned Data.\n");
4791 return TEST_SKIPPED;
4794 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4795 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4796 printf("Device doesn't support RAW data-path APIs.\n");
4797 return TEST_SKIPPED;
4800 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4801 return TEST_SKIPPED;
4803 /* Check if device supports ZUC EEA3 */
4804 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4805 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4807 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4809 return TEST_SKIPPED;
4811 /* Check if device supports ZUC EIA3 */
4812 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4813 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4815 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4817 return TEST_SKIPPED;
4819 /* Create ZUC session */
4820 retval = create_zuc_cipher_auth_encrypt_generate_session(
4821 ts_params->valid_devs[0],
4825 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4827 /* clear mbuf payload */
4828 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4829 rte_pktmbuf_tailroom(ut_params->ibuf));
4831 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4832 /* Append data which is padded to a multiple of */
4833 /* the algorithms block size */
4834 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4835 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4837 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4839 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4841 /* Create ZUC operation */
4842 retval = create_zuc_cipher_hash_generate_operation(tdata);
4846 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4847 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4848 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4850 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4852 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4853 ut_params->obuf = ut_params->op->sym->m_src;
4854 if (ut_params->obuf)
4855 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4857 ciphertext = plaintext;
4859 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4861 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4863 tdata->ciphertext.data,
4864 tdata->validDataLenInBits.len,
4865 "ZUC Ciphertext data not as expected");
4867 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4868 + plaintext_pad_len;
4871 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4875 "ZUC Generated auth tag not as expected");
4880 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4882 struct crypto_testsuite_params *ts_params = &testsuite_params;
4883 struct crypto_unittest_params *ut_params = &unittest_params;
4887 uint8_t *plaintext, *ciphertext;
4888 unsigned plaintext_pad_len;
4889 unsigned plaintext_len;
4890 struct rte_cryptodev_info dev_info;
4892 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4893 uint64_t feat_flags = dev_info.feature_flags;
4895 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4896 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4897 printf("Device doesn't support RAW data-path APIs.\n");
4898 return TEST_SKIPPED;
4901 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4902 return TEST_SKIPPED;
4904 /* Verify the capabilities */
4905 struct rte_cryptodev_sym_capability_idx cap_idx;
4906 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4907 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4908 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4910 return TEST_SKIPPED;
4911 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4912 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4913 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4915 return TEST_SKIPPED;
4917 /* Create SNOW 3G session */
4918 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4919 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4920 RTE_CRYPTO_AUTH_OP_GENERATE,
4921 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4922 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4923 tdata->key.data, tdata->key.len,
4924 tdata->auth_iv.len, tdata->digest.len,
4925 tdata->cipher_iv.len);
4928 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4930 /* clear mbuf payload */
4931 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4932 rte_pktmbuf_tailroom(ut_params->ibuf));
4934 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4935 /* Append data which is padded to a multiple of */
4936 /* the algorithms block size */
4937 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4938 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4940 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4942 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4944 /* Create SNOW 3G operation */
4945 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4946 tdata->digest.len, tdata->auth_iv.data,
4948 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4949 tdata->cipher_iv.data, tdata->cipher_iv.len,
4950 tdata->validCipherLenInBits.len,
4952 tdata->validAuthLenInBits.len,
4958 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4959 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4960 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4962 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4964 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4965 ut_params->obuf = ut_params->op->sym->m_src;
4966 if (ut_params->obuf)
4967 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4969 ciphertext = plaintext;
4971 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4973 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4975 tdata->ciphertext.data,
4976 tdata->validDataLenInBits.len,
4977 "SNOW 3G Ciphertext data not as expected");
4979 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4980 + plaintext_pad_len;
4983 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4986 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4987 "SNOW 3G Generated auth tag not as expected");
4992 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4993 uint8_t op_mode, uint8_t verify)
4995 struct crypto_testsuite_params *ts_params = &testsuite_params;
4996 struct crypto_unittest_params *ut_params = &unittest_params;
5000 uint8_t *plaintext = NULL, *ciphertext = NULL;
5001 unsigned int plaintext_pad_len;
5002 unsigned int plaintext_len;
5003 unsigned int ciphertext_pad_len;
5004 unsigned int ciphertext_len;
5006 struct rte_cryptodev_info dev_info;
5008 /* Verify the capabilities */
5009 struct rte_cryptodev_sym_capability_idx cap_idx;
5010 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5011 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5012 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5014 return TEST_SKIPPED;
5015 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5016 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5017 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5019 return TEST_SKIPPED;
5021 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5022 return TEST_SKIPPED;
5024 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5026 uint64_t feat_flags = dev_info.feature_flags;
5028 if (op_mode == OUT_OF_PLACE) {
5029 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5030 printf("Device doesn't support digest encrypted.\n");
5031 return TEST_SKIPPED;
5033 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5034 return TEST_SKIPPED;
5037 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5038 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5039 printf("Device doesn't support RAW data-path APIs.\n");
5040 return TEST_SKIPPED;
5043 /* Create SNOW 3G session */
5044 retval = create_wireless_algo_auth_cipher_session(
5045 ts_params->valid_devs[0],
5046 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5047 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5048 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5049 : RTE_CRYPTO_AUTH_OP_GENERATE),
5050 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5051 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5052 tdata->key.data, tdata->key.len,
5053 tdata->auth_iv.len, tdata->digest.len,
5054 tdata->cipher_iv.len);
5058 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5059 if (op_mode == OUT_OF_PLACE)
5060 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5062 /* clear mbuf payload */
5063 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5064 rte_pktmbuf_tailroom(ut_params->ibuf));
5065 if (op_mode == OUT_OF_PLACE)
5066 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5067 rte_pktmbuf_tailroom(ut_params->obuf));
5069 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5070 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5071 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5072 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5075 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5076 ciphertext_pad_len);
5077 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5078 if (op_mode == OUT_OF_PLACE)
5079 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5080 debug_hexdump(stdout, "ciphertext:", ciphertext,
5083 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5085 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5086 if (op_mode == OUT_OF_PLACE)
5087 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5088 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5091 /* Create SNOW 3G operation */
5092 retval = create_wireless_algo_auth_cipher_operation(
5093 tdata->digest.data, tdata->digest.len,
5094 tdata->cipher_iv.data, tdata->cipher_iv.len,
5095 tdata->auth_iv.data, tdata->auth_iv.len,
5096 (tdata->digest.offset_bytes == 0 ?
5097 (verify ? ciphertext_pad_len : plaintext_pad_len)
5098 : tdata->digest.offset_bytes),
5099 tdata->validCipherLenInBits.len,
5100 tdata->cipher.offset_bits,
5101 tdata->validAuthLenInBits.len,
5102 tdata->auth.offset_bits,
5103 op_mode, 0, verify);
5108 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5109 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5110 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5112 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5115 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5117 ut_params->obuf = (op_mode == IN_PLACE ?
5118 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5121 if (ut_params->obuf)
5122 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5125 plaintext = ciphertext +
5126 (tdata->cipher.offset_bits >> 3);
5128 debug_hexdump(stdout, "plaintext:", plaintext,
5129 (tdata->plaintext.len >> 3) - tdata->digest.len);
5130 debug_hexdump(stdout, "plaintext expected:",
5131 tdata->plaintext.data,
5132 (tdata->plaintext.len >> 3) - tdata->digest.len);
5134 if (ut_params->obuf)
5135 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5138 ciphertext = plaintext;
5140 debug_hexdump(stdout, "ciphertext:", ciphertext,
5142 debug_hexdump(stdout, "ciphertext expected:",
5143 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5145 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5146 + (tdata->digest.offset_bytes == 0 ?
5147 plaintext_pad_len : tdata->digest.offset_bytes);
5149 debug_hexdump(stdout, "digest:", ut_params->digest,
5151 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5157 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5159 tdata->plaintext.data,
5160 (tdata->plaintext.len - tdata->cipher.offset_bits -
5161 (tdata->digest.len << 3)),
5162 tdata->cipher.offset_bits,
5163 "SNOW 3G Plaintext data not as expected");
5165 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5167 tdata->ciphertext.data,
5168 (tdata->validDataLenInBits.len -
5169 tdata->cipher.offset_bits),
5170 tdata->cipher.offset_bits,
5171 "SNOW 3G Ciphertext data not as expected");
5173 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5176 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5177 "SNOW 3G Generated auth tag not as expected");
5183 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5184 uint8_t op_mode, uint8_t verify)
5186 struct crypto_testsuite_params *ts_params = &testsuite_params;
5187 struct crypto_unittest_params *ut_params = &unittest_params;
5191 const uint8_t *plaintext = NULL;
5192 const uint8_t *ciphertext = NULL;
5193 const uint8_t *digest = NULL;
5194 unsigned int plaintext_pad_len;
5195 unsigned int plaintext_len;
5196 unsigned int ciphertext_pad_len;
5197 unsigned int ciphertext_len;
5198 uint8_t buffer[10000];
5199 uint8_t digest_buffer[10000];
5201 struct rte_cryptodev_info dev_info;
5203 /* Verify the capabilities */
5204 struct rte_cryptodev_sym_capability_idx cap_idx;
5205 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5206 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5207 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5209 return TEST_SKIPPED;
5210 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5211 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5212 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5214 return TEST_SKIPPED;
5216 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5217 return TEST_SKIPPED;
5219 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5221 uint64_t feat_flags = dev_info.feature_flags;
5223 if (op_mode == IN_PLACE) {
5224 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5225 printf("Device doesn't support in-place scatter-gather "
5226 "in both input and output mbufs.\n");
5227 return TEST_SKIPPED;
5229 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5230 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5231 printf("Device doesn't support RAW data-path APIs.\n");
5232 return TEST_SKIPPED;
5235 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5236 return TEST_SKIPPED;
5237 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5238 printf("Device doesn't support out-of-place scatter-gather "
5239 "in both input and output mbufs.\n");
5240 return TEST_SKIPPED;
5242 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5243 printf("Device doesn't support digest encrypted.\n");
5244 return TEST_SKIPPED;
5248 /* Create SNOW 3G session */
5249 retval = create_wireless_algo_auth_cipher_session(
5250 ts_params->valid_devs[0],
5251 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5252 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5253 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5254 : RTE_CRYPTO_AUTH_OP_GENERATE),
5255 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5256 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5257 tdata->key.data, tdata->key.len,
5258 tdata->auth_iv.len, tdata->digest.len,
5259 tdata->cipher_iv.len);
5264 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5265 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5266 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5269 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5270 plaintext_pad_len, 15, 0);
5271 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5272 "Failed to allocate input buffer in mempool");
5274 if (op_mode == OUT_OF_PLACE) {
5275 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5276 plaintext_pad_len, 15, 0);
5277 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5278 "Failed to allocate output buffer in mempool");
5282 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5283 tdata->ciphertext.data);
5284 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5285 ciphertext_len, buffer);
5286 debug_hexdump(stdout, "ciphertext:", ciphertext,
5289 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5290 tdata->plaintext.data);
5291 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5292 plaintext_len, buffer);
5293 debug_hexdump(stdout, "plaintext:", plaintext,
5296 memset(buffer, 0, sizeof(buffer));
5298 /* Create SNOW 3G operation */
5299 retval = create_wireless_algo_auth_cipher_operation(
5300 tdata->digest.data, tdata->digest.len,
5301 tdata->cipher_iv.data, tdata->cipher_iv.len,
5302 tdata->auth_iv.data, tdata->auth_iv.len,
5303 (tdata->digest.offset_bytes == 0 ?
5304 (verify ? ciphertext_pad_len : plaintext_pad_len)
5305 : tdata->digest.offset_bytes),
5306 tdata->validCipherLenInBits.len,
5307 tdata->cipher.offset_bits,
5308 tdata->validAuthLenInBits.len,
5309 tdata->auth.offset_bits,
5310 op_mode, 1, verify);
5315 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5316 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5317 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5319 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5322 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5324 ut_params->obuf = (op_mode == IN_PLACE ?
5325 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5328 if (ut_params->obuf)
5329 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5330 plaintext_len, buffer);
5332 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5333 plaintext_len, buffer);
5335 debug_hexdump(stdout, "plaintext:", plaintext,
5336 (tdata->plaintext.len >> 3) - tdata->digest.len);
5337 debug_hexdump(stdout, "plaintext expected:",
5338 tdata->plaintext.data,
5339 (tdata->plaintext.len >> 3) - tdata->digest.len);
5341 if (ut_params->obuf)
5342 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5343 ciphertext_len, buffer);
5345 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5346 ciphertext_len, buffer);
5348 debug_hexdump(stdout, "ciphertext:", ciphertext,
5350 debug_hexdump(stdout, "ciphertext expected:",
5351 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5353 if (ut_params->obuf)
5354 digest = rte_pktmbuf_read(ut_params->obuf,
5355 (tdata->digest.offset_bytes == 0 ?
5356 plaintext_pad_len : tdata->digest.offset_bytes),
5357 tdata->digest.len, digest_buffer);
5359 digest = rte_pktmbuf_read(ut_params->ibuf,
5360 (tdata->digest.offset_bytes == 0 ?
5361 plaintext_pad_len : tdata->digest.offset_bytes),
5362 tdata->digest.len, digest_buffer);
5364 debug_hexdump(stdout, "digest:", digest,
5366 debug_hexdump(stdout, "digest expected:",
5367 tdata->digest.data, tdata->digest.len);
5372 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5374 tdata->plaintext.data,
5375 (tdata->plaintext.len - tdata->cipher.offset_bits -
5376 (tdata->digest.len << 3)),
5377 tdata->cipher.offset_bits,
5378 "SNOW 3G Plaintext data not as expected");
5380 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5382 tdata->ciphertext.data,
5383 (tdata->validDataLenInBits.len -
5384 tdata->cipher.offset_bits),
5385 tdata->cipher.offset_bits,
5386 "SNOW 3G Ciphertext data not as expected");
5388 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5391 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5392 "SNOW 3G Generated auth tag not as expected");
5398 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5399 uint8_t op_mode, uint8_t verify)
5401 struct crypto_testsuite_params *ts_params = &testsuite_params;
5402 struct crypto_unittest_params *ut_params = &unittest_params;
5406 uint8_t *plaintext = NULL, *ciphertext = NULL;
5407 unsigned int plaintext_pad_len;
5408 unsigned int plaintext_len;
5409 unsigned int ciphertext_pad_len;
5410 unsigned int ciphertext_len;
5412 struct rte_cryptodev_info dev_info;
5414 /* Verify the capabilities */
5415 struct rte_cryptodev_sym_capability_idx cap_idx;
5416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5417 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5418 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5420 return TEST_SKIPPED;
5421 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5422 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5423 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5425 return TEST_SKIPPED;
5427 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5429 uint64_t feat_flags = dev_info.feature_flags;
5431 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5432 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5433 printf("Device doesn't support RAW data-path APIs.\n");
5434 return TEST_SKIPPED;
5437 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5438 return TEST_SKIPPED;
5440 if (op_mode == OUT_OF_PLACE) {
5441 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5442 return TEST_SKIPPED;
5443 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5444 printf("Device doesn't support digest encrypted.\n");
5445 return TEST_SKIPPED;
5449 /* Create KASUMI session */
5450 retval = create_wireless_algo_auth_cipher_session(
5451 ts_params->valid_devs[0],
5452 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5453 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5454 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5455 : RTE_CRYPTO_AUTH_OP_GENERATE),
5456 RTE_CRYPTO_AUTH_KASUMI_F9,
5457 RTE_CRYPTO_CIPHER_KASUMI_F8,
5458 tdata->key.data, tdata->key.len,
5459 0, tdata->digest.len,
5460 tdata->cipher_iv.len);
5465 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5466 if (op_mode == OUT_OF_PLACE)
5467 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5469 /* clear mbuf payload */
5470 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5471 rte_pktmbuf_tailroom(ut_params->ibuf));
5472 if (op_mode == OUT_OF_PLACE)
5473 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5474 rte_pktmbuf_tailroom(ut_params->obuf));
5476 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5477 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5478 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5479 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5482 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5483 ciphertext_pad_len);
5484 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5485 if (op_mode == OUT_OF_PLACE)
5486 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5487 debug_hexdump(stdout, "ciphertext:", ciphertext,
5490 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5492 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5493 if (op_mode == OUT_OF_PLACE)
5494 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5495 debug_hexdump(stdout, "plaintext:", plaintext,
5499 /* Create KASUMI operation */
5500 retval = create_wireless_algo_auth_cipher_operation(
5501 tdata->digest.data, tdata->digest.len,
5502 tdata->cipher_iv.data, tdata->cipher_iv.len,
5504 (tdata->digest.offset_bytes == 0 ?
5505 (verify ? ciphertext_pad_len : plaintext_pad_len)
5506 : tdata->digest.offset_bytes),
5507 tdata->validCipherLenInBits.len,
5508 tdata->validCipherOffsetInBits.len,
5509 tdata->validAuthLenInBits.len,
5511 op_mode, 0, verify);
5516 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5517 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5518 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5520 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5523 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5525 ut_params->obuf = (op_mode == IN_PLACE ?
5526 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5530 if (ut_params->obuf)
5531 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5534 plaintext = ciphertext;
5536 debug_hexdump(stdout, "plaintext:", plaintext,
5537 (tdata->plaintext.len >> 3) - tdata->digest.len);
5538 debug_hexdump(stdout, "plaintext expected:",
5539 tdata->plaintext.data,
5540 (tdata->plaintext.len >> 3) - tdata->digest.len);
5542 if (ut_params->obuf)
5543 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5546 ciphertext = plaintext;
5548 debug_hexdump(stdout, "ciphertext:", ciphertext,
5550 debug_hexdump(stdout, "ciphertext expected:",
5551 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5553 ut_params->digest = rte_pktmbuf_mtod(
5554 ut_params->obuf, uint8_t *) +
5555 (tdata->digest.offset_bytes == 0 ?
5556 plaintext_pad_len : tdata->digest.offset_bytes);
5558 debug_hexdump(stdout, "digest:", ut_params->digest,
5560 debug_hexdump(stdout, "digest expected:",
5561 tdata->digest.data, tdata->digest.len);
5566 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5568 tdata->plaintext.data,
5569 tdata->plaintext.len >> 3,
5570 "KASUMI Plaintext data not as expected");
5572 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5574 tdata->ciphertext.data,
5575 tdata->ciphertext.len >> 3,
5576 "KASUMI Ciphertext data not as expected");
5578 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5581 DIGEST_BYTE_LENGTH_KASUMI_F9,
5582 "KASUMI Generated auth tag not as expected");
5588 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5589 uint8_t op_mode, uint8_t verify)
5591 struct crypto_testsuite_params *ts_params = &testsuite_params;
5592 struct crypto_unittest_params *ut_params = &unittest_params;
5596 const uint8_t *plaintext = NULL;
5597 const uint8_t *ciphertext = NULL;
5598 const uint8_t *digest = NULL;
5599 unsigned int plaintext_pad_len;
5600 unsigned int plaintext_len;
5601 unsigned int ciphertext_pad_len;
5602 unsigned int ciphertext_len;
5603 uint8_t buffer[10000];
5604 uint8_t digest_buffer[10000];
5606 struct rte_cryptodev_info dev_info;
5608 /* Verify the capabilities */
5609 struct rte_cryptodev_sym_capability_idx cap_idx;
5610 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5611 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5612 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5614 return TEST_SKIPPED;
5615 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5616 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5617 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5619 return TEST_SKIPPED;
5621 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5622 return TEST_SKIPPED;
5624 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5626 uint64_t feat_flags = dev_info.feature_flags;
5628 if (op_mode == IN_PLACE) {
5629 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5630 printf("Device doesn't support in-place scatter-gather "
5631 "in both input and output mbufs.\n");
5632 return TEST_SKIPPED;
5634 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5635 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5636 printf("Device doesn't support RAW data-path APIs.\n");
5637 return TEST_SKIPPED;
5640 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5641 return TEST_SKIPPED;
5642 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5643 printf("Device doesn't support out-of-place scatter-gather "
5644 "in both input and output mbufs.\n");
5645 return TEST_SKIPPED;
5647 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5648 printf("Device doesn't support digest encrypted.\n");
5649 return TEST_SKIPPED;
5653 /* Create KASUMI session */
5654 retval = create_wireless_algo_auth_cipher_session(
5655 ts_params->valid_devs[0],
5656 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5657 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5658 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5659 : RTE_CRYPTO_AUTH_OP_GENERATE),
5660 RTE_CRYPTO_AUTH_KASUMI_F9,
5661 RTE_CRYPTO_CIPHER_KASUMI_F8,
5662 tdata->key.data, tdata->key.len,
5663 0, tdata->digest.len,
5664 tdata->cipher_iv.len);
5669 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5670 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5671 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5672 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5674 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5675 plaintext_pad_len, 15, 0);
5676 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5677 "Failed to allocate input buffer in mempool");
5679 if (op_mode == OUT_OF_PLACE) {
5680 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5681 plaintext_pad_len, 15, 0);
5682 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5683 "Failed to allocate output buffer in mempool");
5687 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5688 tdata->ciphertext.data);
5689 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5690 ciphertext_len, buffer);
5691 debug_hexdump(stdout, "ciphertext:", ciphertext,
5694 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5695 tdata->plaintext.data);
5696 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5697 plaintext_len, buffer);
5698 debug_hexdump(stdout, "plaintext:", plaintext,
5701 memset(buffer, 0, sizeof(buffer));
5703 /* Create KASUMI operation */
5704 retval = create_wireless_algo_auth_cipher_operation(
5705 tdata->digest.data, tdata->digest.len,
5706 tdata->cipher_iv.data, tdata->cipher_iv.len,
5708 (tdata->digest.offset_bytes == 0 ?
5709 (verify ? ciphertext_pad_len : plaintext_pad_len)
5710 : tdata->digest.offset_bytes),
5711 tdata->validCipherLenInBits.len,
5712 tdata->validCipherOffsetInBits.len,
5713 tdata->validAuthLenInBits.len,
5715 op_mode, 1, verify);
5720 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5721 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5722 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5724 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5727 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5729 ut_params->obuf = (op_mode == IN_PLACE ?
5730 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5733 if (ut_params->obuf)
5734 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5735 plaintext_len, buffer);
5737 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5738 plaintext_len, buffer);
5740 debug_hexdump(stdout, "plaintext:", plaintext,
5741 (tdata->plaintext.len >> 3) - tdata->digest.len);
5742 debug_hexdump(stdout, "plaintext expected:",
5743 tdata->plaintext.data,
5744 (tdata->plaintext.len >> 3) - tdata->digest.len);
5746 if (ut_params->obuf)
5747 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5748 ciphertext_len, buffer);
5750 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5751 ciphertext_len, buffer);
5753 debug_hexdump(stdout, "ciphertext:", ciphertext,
5755 debug_hexdump(stdout, "ciphertext expected:",
5756 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5758 if (ut_params->obuf)
5759 digest = rte_pktmbuf_read(ut_params->obuf,
5760 (tdata->digest.offset_bytes == 0 ?
5761 plaintext_pad_len : tdata->digest.offset_bytes),
5762 tdata->digest.len, digest_buffer);
5764 digest = rte_pktmbuf_read(ut_params->ibuf,
5765 (tdata->digest.offset_bytes == 0 ?
5766 plaintext_pad_len : tdata->digest.offset_bytes),
5767 tdata->digest.len, digest_buffer);
5769 debug_hexdump(stdout, "digest:", digest,
5771 debug_hexdump(stdout, "digest expected:",
5772 tdata->digest.data, tdata->digest.len);
5777 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5779 tdata->plaintext.data,
5780 tdata->plaintext.len >> 3,
5781 "KASUMI Plaintext data not as expected");
5783 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5785 tdata->ciphertext.data,
5786 tdata->validDataLenInBits.len,
5787 "KASUMI Ciphertext data not as expected");
5789 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5792 DIGEST_BYTE_LENGTH_KASUMI_F9,
5793 "KASUMI Generated auth tag not as expected");
5799 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5801 struct crypto_testsuite_params *ts_params = &testsuite_params;
5802 struct crypto_unittest_params *ut_params = &unittest_params;
5806 uint8_t *plaintext, *ciphertext;
5807 unsigned plaintext_pad_len;
5808 unsigned plaintext_len;
5809 struct rte_cryptodev_info dev_info;
5811 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5812 uint64_t feat_flags = dev_info.feature_flags;
5814 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5815 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5816 printf("Device doesn't support RAW data-path APIs.\n");
5817 return TEST_SKIPPED;
5820 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5821 return TEST_SKIPPED;
5823 /* Verify the capabilities */
5824 struct rte_cryptodev_sym_capability_idx cap_idx;
5825 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5826 cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5827 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5829 return TEST_SKIPPED;
5830 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5831 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5832 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5834 return TEST_SKIPPED;
5836 /* Create KASUMI session */
5837 retval = create_wireless_algo_cipher_auth_session(
5838 ts_params->valid_devs[0],
5839 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5840 RTE_CRYPTO_AUTH_OP_GENERATE,
5841 RTE_CRYPTO_AUTH_KASUMI_F9,
5842 RTE_CRYPTO_CIPHER_KASUMI_F8,
5843 tdata->key.data, tdata->key.len,
5844 0, tdata->digest.len,
5845 tdata->cipher_iv.len);
5849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5851 /* clear mbuf payload */
5852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5853 rte_pktmbuf_tailroom(ut_params->ibuf));
5855 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5856 /* Append data which is padded to a multiple of */
5857 /* the algorithms block size */
5858 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5859 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5861 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5863 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5865 /* Create KASUMI operation */
5866 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5867 tdata->digest.len, NULL, 0,
5868 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5869 tdata->cipher_iv.data, tdata->cipher_iv.len,
5870 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5871 tdata->validCipherOffsetInBits.len,
5872 tdata->validAuthLenInBits.len,
5878 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5879 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5880 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5882 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5884 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5886 if (ut_params->op->sym->m_dst)
5887 ut_params->obuf = ut_params->op->sym->m_dst;
5889 ut_params->obuf = ut_params->op->sym->m_src;
5891 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5892 tdata->validCipherOffsetInBits.len >> 3);
5894 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5895 + plaintext_pad_len;
5897 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5898 (tdata->validCipherOffsetInBits.len >> 3);
5900 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5902 reference_ciphertext,
5903 tdata->validCipherLenInBits.len,
5904 "KASUMI Ciphertext data not as expected");
5907 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5910 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5911 "KASUMI Generated auth tag not as expected");
5916 check_cipher_capability(const struct crypto_testsuite_params *ts_params,
5917 const enum rte_crypto_cipher_algorithm cipher_algo,
5918 const uint16_t key_size, const uint16_t iv_size)
5920 struct rte_cryptodev_sym_capability_idx cap_idx;
5921 const struct rte_cryptodev_symmetric_capability *cap;
5923 /* Check if device supports the algorithm */
5924 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5925 cap_idx.algo.cipher = cipher_algo;
5927 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5933 /* Check if device supports key size and IV size */
5934 if (rte_cryptodev_sym_capability_check_cipher(cap, key_size,
5943 check_auth_capability(const struct crypto_testsuite_params *ts_params,
5944 const enum rte_crypto_auth_algorithm auth_algo,
5945 const uint16_t key_size, const uint16_t iv_size,
5946 const uint16_t tag_size)
5948 struct rte_cryptodev_sym_capability_idx cap_idx;
5949 const struct rte_cryptodev_symmetric_capability *cap;
5951 /* Check if device supports the algorithm */
5952 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5953 cap_idx.algo.auth = auth_algo;
5955 cap = rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5961 /* Check if device supports key size and IV size */
5962 if (rte_cryptodev_sym_capability_check_auth(cap, key_size,
5963 tag_size, iv_size) < 0) {
5971 test_zuc_encryption(const struct wireless_test_data *tdata)
5973 struct crypto_testsuite_params *ts_params = &testsuite_params;
5974 struct crypto_unittest_params *ut_params = &unittest_params;
5977 uint8_t *plaintext, *ciphertext;
5978 unsigned plaintext_pad_len;
5979 unsigned plaintext_len;
5980 struct rte_cryptodev_info dev_info;
5982 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5983 uint64_t feat_flags = dev_info.feature_flags;
5985 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5986 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5987 printf("Device doesn't support RAW data-path APIs.\n");
5988 return TEST_SKIPPED;
5991 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5992 return TEST_SKIPPED;
5994 /* Check if device supports ZUC EEA3 */
5995 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
5996 tdata->key.len, tdata->cipher_iv.len) < 0)
5997 return TEST_SKIPPED;
5999 /* Create ZUC session */
6000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6002 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6003 tdata->key.data, tdata->key.len,
6004 tdata->cipher_iv.len);
6008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6010 /* Clear mbuf payload */
6011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6012 rte_pktmbuf_tailroom(ut_params->ibuf));
6014 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6015 /* Append data which is padded to a multiple */
6016 /* of the algorithms block size */
6017 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6018 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6020 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6022 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6024 /* Create ZUC operation */
6025 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6026 tdata->cipher_iv.len,
6027 tdata->plaintext.len,
6032 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6033 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6034 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6036 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6038 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6040 ut_params->obuf = ut_params->op->sym->m_dst;
6041 if (ut_params->obuf)
6042 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
6044 ciphertext = plaintext;
6046 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6049 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6051 tdata->ciphertext.data,
6052 tdata->validCipherLenInBits.len,
6053 "ZUC Ciphertext data not as expected");
6058 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
6060 struct crypto_testsuite_params *ts_params = &testsuite_params;
6061 struct crypto_unittest_params *ut_params = &unittest_params;
6065 unsigned int plaintext_pad_len;
6066 unsigned int plaintext_len;
6067 const uint8_t *ciphertext;
6068 uint8_t ciphertext_buffer[2048];
6069 struct rte_cryptodev_info dev_info;
6071 /* Check if device supports ZUC EEA3 */
6072 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6073 tdata->key.len, tdata->cipher_iv.len) < 0)
6074 return TEST_SKIPPED;
6076 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6077 return TEST_SKIPPED;
6079 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6081 uint64_t feat_flags = dev_info.feature_flags;
6083 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6084 printf("Device doesn't support in-place scatter-gather. "
6086 return TEST_SKIPPED;
6089 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6090 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6091 printf("Device doesn't support RAW data-path APIs.\n");
6092 return TEST_SKIPPED;
6095 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6097 /* Append data which is padded to a multiple */
6098 /* of the algorithms block size */
6099 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6101 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6102 plaintext_pad_len, 10, 0);
6104 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6105 tdata->plaintext.data);
6107 /* Create ZUC session */
6108 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
6109 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6110 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6111 tdata->key.data, tdata->key.len,
6112 tdata->cipher_iv.len);
6116 /* Clear mbuf payload */
6118 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
6120 /* Create ZUC operation */
6121 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
6122 tdata->cipher_iv.len, tdata->plaintext.len,
6127 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6128 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6129 ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
6131 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6133 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6135 ut_params->obuf = ut_params->op->sym->m_dst;
6136 if (ut_params->obuf)
6137 ciphertext = rte_pktmbuf_read(ut_params->obuf,
6138 0, plaintext_len, ciphertext_buffer);
6140 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
6141 0, plaintext_len, ciphertext_buffer);
6144 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
6147 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6149 tdata->ciphertext.data,
6150 tdata->validCipherLenInBits.len,
6151 "ZUC Ciphertext data not as expected");
6157 test_zuc_authentication(const struct wireless_test_data *tdata)
6159 struct crypto_testsuite_params *ts_params = &testsuite_params;
6160 struct crypto_unittest_params *ut_params = &unittest_params;
6163 unsigned plaintext_pad_len;
6164 unsigned plaintext_len;
6167 struct rte_cryptodev_info dev_info;
6169 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6170 uint64_t feat_flags = dev_info.feature_flags;
6172 if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
6173 (tdata->validAuthLenInBits.len % 8 != 0)) {
6174 printf("Device doesn't support NON-Byte Aligned Data.\n");
6175 return TEST_SKIPPED;
6178 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6179 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6180 printf("Device doesn't support RAW data-path APIs.\n");
6181 return TEST_SKIPPED;
6184 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6185 return TEST_SKIPPED;
6187 /* Check if device supports ZUC EIA3 */
6188 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6189 tdata->key.len, tdata->auth_iv.len,
6190 tdata->digest.len) < 0)
6191 return TEST_SKIPPED;
6193 /* Create ZUC session */
6194 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6195 tdata->key.data, tdata->key.len,
6196 tdata->auth_iv.len, tdata->digest.len,
6197 RTE_CRYPTO_AUTH_OP_GENERATE,
6198 RTE_CRYPTO_AUTH_ZUC_EIA3);
6202 /* alloc mbuf and set payload */
6203 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6205 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6206 rte_pktmbuf_tailroom(ut_params->ibuf));
6208 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6209 /* Append data which is padded to a multiple of */
6210 /* the algorithms block size */
6211 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6212 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6214 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6216 /* Create ZUC operation */
6217 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6218 tdata->auth_iv.data, tdata->auth_iv.len,
6219 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6220 tdata->validAuthLenInBits.len,
6225 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6226 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6227 ut_params->op, 0, 1, 1, 0);
6229 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6231 ut_params->obuf = ut_params->op->sym->m_src;
6232 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6233 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6234 + plaintext_pad_len;
6237 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6241 "ZUC Generated auth tag not as expected");
6247 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6248 uint8_t op_mode, uint8_t verify)
6250 struct crypto_testsuite_params *ts_params = &testsuite_params;
6251 struct crypto_unittest_params *ut_params = &unittest_params;
6255 uint8_t *plaintext = NULL, *ciphertext = NULL;
6256 unsigned int plaintext_pad_len;
6257 unsigned int plaintext_len;
6258 unsigned int ciphertext_pad_len;
6259 unsigned int ciphertext_len;
6261 struct rte_cryptodev_info dev_info;
6263 /* Check if device supports ZUC EEA3 */
6264 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6265 tdata->key.len, tdata->cipher_iv.len) < 0)
6266 return TEST_SKIPPED;
6268 /* Check if device supports ZUC EIA3 */
6269 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6270 tdata->key.len, tdata->auth_iv.len,
6271 tdata->digest.len) < 0)
6272 return TEST_SKIPPED;
6274 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6276 uint64_t feat_flags = dev_info.feature_flags;
6278 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6279 printf("Device doesn't support digest encrypted.\n");
6280 return TEST_SKIPPED;
6282 if (op_mode == IN_PLACE) {
6283 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6284 printf("Device doesn't support in-place scatter-gather "
6285 "in both input and output mbufs.\n");
6286 return TEST_SKIPPED;
6289 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6290 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6291 printf("Device doesn't support RAW data-path APIs.\n");
6292 return TEST_SKIPPED;
6295 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6296 return TEST_SKIPPED;
6297 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6298 printf("Device doesn't support out-of-place scatter-gather "
6299 "in both input and output mbufs.\n");
6300 return TEST_SKIPPED;
6304 /* Create ZUC session */
6305 retval = create_wireless_algo_auth_cipher_session(
6306 ts_params->valid_devs[0],
6307 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6308 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6309 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6310 : RTE_CRYPTO_AUTH_OP_GENERATE),
6311 RTE_CRYPTO_AUTH_ZUC_EIA3,
6312 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6313 tdata->key.data, tdata->key.len,
6314 tdata->auth_iv.len, tdata->digest.len,
6315 tdata->cipher_iv.len);
6320 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6321 if (op_mode == OUT_OF_PLACE)
6322 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6324 /* clear mbuf payload */
6325 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6326 rte_pktmbuf_tailroom(ut_params->ibuf));
6327 if (op_mode == OUT_OF_PLACE)
6328 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6329 rte_pktmbuf_tailroom(ut_params->obuf));
6331 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6332 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6333 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6334 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6337 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6338 ciphertext_pad_len);
6339 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6340 debug_hexdump(stdout, "ciphertext:", ciphertext,
6343 /* make sure enough space to cover partial digest verify case */
6344 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6345 ciphertext_pad_len);
6346 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6347 debug_hexdump(stdout, "plaintext:", plaintext,
6351 if (op_mode == OUT_OF_PLACE)
6352 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6354 /* Create ZUC operation */
6355 retval = create_wireless_algo_auth_cipher_operation(
6356 tdata->digest.data, tdata->digest.len,
6357 tdata->cipher_iv.data, tdata->cipher_iv.len,
6358 tdata->auth_iv.data, tdata->auth_iv.len,
6359 (tdata->digest.offset_bytes == 0 ?
6360 (verify ? ciphertext_pad_len : plaintext_pad_len)
6361 : tdata->digest.offset_bytes),
6362 tdata->validCipherLenInBits.len,
6363 tdata->validCipherOffsetInBits.len,
6364 tdata->validAuthLenInBits.len,
6366 op_mode, 0, verify);
6371 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6372 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6373 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6375 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6378 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6380 ut_params->obuf = (op_mode == IN_PLACE ?
6381 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6385 if (ut_params->obuf)
6386 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6389 plaintext = ciphertext;
6391 debug_hexdump(stdout, "plaintext:", plaintext,
6392 (tdata->plaintext.len >> 3) - tdata->digest.len);
6393 debug_hexdump(stdout, "plaintext expected:",
6394 tdata->plaintext.data,
6395 (tdata->plaintext.len >> 3) - tdata->digest.len);
6397 if (ut_params->obuf)
6398 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6401 ciphertext = plaintext;
6403 debug_hexdump(stdout, "ciphertext:", ciphertext,
6405 debug_hexdump(stdout, "ciphertext expected:",
6406 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6408 ut_params->digest = rte_pktmbuf_mtod(
6409 ut_params->obuf, uint8_t *) +
6410 (tdata->digest.offset_bytes == 0 ?
6411 plaintext_pad_len : tdata->digest.offset_bytes);
6413 debug_hexdump(stdout, "digest:", ut_params->digest,
6415 debug_hexdump(stdout, "digest expected:",
6416 tdata->digest.data, tdata->digest.len);
6421 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6423 tdata->plaintext.data,
6424 tdata->plaintext.len >> 3,
6425 "ZUC Plaintext data not as expected");
6427 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6429 tdata->ciphertext.data,
6430 tdata->ciphertext.len >> 3,
6431 "ZUC Ciphertext data not as expected");
6433 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6436 DIGEST_BYTE_LENGTH_KASUMI_F9,
6437 "ZUC Generated auth tag not as expected");
6443 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6444 uint8_t op_mode, uint8_t verify)
6446 struct crypto_testsuite_params *ts_params = &testsuite_params;
6447 struct crypto_unittest_params *ut_params = &unittest_params;
6451 const uint8_t *plaintext = NULL;
6452 const uint8_t *ciphertext = NULL;
6453 const uint8_t *digest = NULL;
6454 unsigned int plaintext_pad_len;
6455 unsigned int plaintext_len;
6456 unsigned int ciphertext_pad_len;
6457 unsigned int ciphertext_len;
6458 uint8_t buffer[10000];
6459 uint8_t digest_buffer[10000];
6461 struct rte_cryptodev_info dev_info;
6463 /* Check if device supports ZUC EEA3 */
6464 if (check_cipher_capability(ts_params, RTE_CRYPTO_CIPHER_ZUC_EEA3,
6465 tdata->key.len, tdata->cipher_iv.len) < 0)
6466 return TEST_SKIPPED;
6468 /* Check if device supports ZUC EIA3 */
6469 if (check_auth_capability(ts_params, RTE_CRYPTO_AUTH_ZUC_EIA3,
6470 tdata->key.len, tdata->auth_iv.len,
6471 tdata->digest.len) < 0)
6472 return TEST_SKIPPED;
6474 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6476 uint64_t feat_flags = dev_info.feature_flags;
6478 if (op_mode == IN_PLACE) {
6479 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6480 printf("Device doesn't support in-place scatter-gather "
6481 "in both input and output mbufs.\n");
6482 return TEST_SKIPPED;
6485 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6486 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6487 printf("Device doesn't support RAW data-path APIs.\n");
6488 return TEST_SKIPPED;
6491 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6492 return TEST_SKIPPED;
6493 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6494 printf("Device doesn't support out-of-place scatter-gather "
6495 "in both input and output mbufs.\n");
6496 return TEST_SKIPPED;
6498 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6499 printf("Device doesn't support digest encrypted.\n");
6500 return TEST_SKIPPED;
6504 /* Create ZUC session */
6505 retval = create_wireless_algo_auth_cipher_session(
6506 ts_params->valid_devs[0],
6507 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6508 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6509 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6510 : RTE_CRYPTO_AUTH_OP_GENERATE),
6511 RTE_CRYPTO_AUTH_ZUC_EIA3,
6512 RTE_CRYPTO_CIPHER_ZUC_EEA3,
6513 tdata->key.data, tdata->key.len,
6514 tdata->auth_iv.len, tdata->digest.len,
6515 tdata->cipher_iv.len);
6520 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6521 plaintext_len = ceil_byte_length(tdata->plaintext.len);
6522 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6523 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6525 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6526 plaintext_pad_len, 15, 0);
6527 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6528 "Failed to allocate input buffer in mempool");
6530 if (op_mode == OUT_OF_PLACE) {
6531 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6532 plaintext_pad_len, 15, 0);
6533 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6534 "Failed to allocate output buffer in mempool");
6538 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6539 tdata->ciphertext.data);
6540 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6541 ciphertext_len, buffer);
6542 debug_hexdump(stdout, "ciphertext:", ciphertext,
6545 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6546 tdata->plaintext.data);
6547 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6548 plaintext_len, buffer);
6549 debug_hexdump(stdout, "plaintext:", plaintext,
6552 memset(buffer, 0, sizeof(buffer));
6554 /* Create ZUC operation */
6555 retval = create_wireless_algo_auth_cipher_operation(
6556 tdata->digest.data, tdata->digest.len,
6557 tdata->cipher_iv.data, tdata->cipher_iv.len,
6559 (tdata->digest.offset_bytes == 0 ?
6560 (verify ? ciphertext_pad_len : plaintext_pad_len)
6561 : tdata->digest.offset_bytes),
6562 tdata->validCipherLenInBits.len,
6563 tdata->validCipherOffsetInBits.len,
6564 tdata->validAuthLenInBits.len,
6566 op_mode, 1, verify);
6571 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6572 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6573 ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6575 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6578 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6580 ut_params->obuf = (op_mode == IN_PLACE ?
6581 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6584 if (ut_params->obuf)
6585 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6586 plaintext_len, buffer);
6588 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6589 plaintext_len, buffer);
6591 debug_hexdump(stdout, "plaintext:", plaintext,
6592 (tdata->plaintext.len >> 3) - tdata->digest.len);
6593 debug_hexdump(stdout, "plaintext expected:",
6594 tdata->plaintext.data,
6595 (tdata->plaintext.len >> 3) - tdata->digest.len);
6597 if (ut_params->obuf)
6598 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6599 ciphertext_len, buffer);
6601 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6602 ciphertext_len, buffer);
6604 debug_hexdump(stdout, "ciphertext:", ciphertext,
6606 debug_hexdump(stdout, "ciphertext expected:",
6607 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6609 if (ut_params->obuf)
6610 digest = rte_pktmbuf_read(ut_params->obuf,
6611 (tdata->digest.offset_bytes == 0 ?
6612 plaintext_pad_len : tdata->digest.offset_bytes),
6613 tdata->digest.len, digest_buffer);
6615 digest = rte_pktmbuf_read(ut_params->ibuf,
6616 (tdata->digest.offset_bytes == 0 ?
6617 plaintext_pad_len : tdata->digest.offset_bytes),
6618 tdata->digest.len, digest_buffer);
6620 debug_hexdump(stdout, "digest:", digest,
6622 debug_hexdump(stdout, "digest expected:",
6623 tdata->digest.data, tdata->digest.len);
6628 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6630 tdata->plaintext.data,
6631 tdata->plaintext.len >> 3,
6632 "ZUC Plaintext data not as expected");
6634 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6636 tdata->ciphertext.data,
6637 tdata->validDataLenInBits.len,
6638 "ZUC Ciphertext data not as expected");
6640 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6643 DIGEST_BYTE_LENGTH_KASUMI_F9,
6644 "ZUC Generated auth tag not as expected");
6650 test_kasumi_encryption_test_case_1(void)
6652 return test_kasumi_encryption(&kasumi_test_case_1);
6656 test_kasumi_encryption_test_case_1_sgl(void)
6658 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6662 test_kasumi_encryption_test_case_1_oop(void)
6664 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6668 test_kasumi_encryption_test_case_1_oop_sgl(void)
6670 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6674 test_kasumi_encryption_test_case_2(void)
6676 return test_kasumi_encryption(&kasumi_test_case_2);
6680 test_kasumi_encryption_test_case_3(void)
6682 return test_kasumi_encryption(&kasumi_test_case_3);
6686 test_kasumi_encryption_test_case_4(void)
6688 return test_kasumi_encryption(&kasumi_test_case_4);
6692 test_kasumi_encryption_test_case_5(void)
6694 return test_kasumi_encryption(&kasumi_test_case_5);
6698 test_kasumi_decryption_test_case_1(void)
6700 return test_kasumi_decryption(&kasumi_test_case_1);
6704 test_kasumi_decryption_test_case_1_oop(void)
6706 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6710 test_kasumi_decryption_test_case_2(void)
6712 return test_kasumi_decryption(&kasumi_test_case_2);
6716 test_kasumi_decryption_test_case_3(void)
6718 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6719 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6720 return TEST_SKIPPED;
6721 return test_kasumi_decryption(&kasumi_test_case_3);
6725 test_kasumi_decryption_test_case_4(void)
6727 return test_kasumi_decryption(&kasumi_test_case_4);
6731 test_kasumi_decryption_test_case_5(void)
6733 return test_kasumi_decryption(&kasumi_test_case_5);
6736 test_snow3g_encryption_test_case_1(void)
6738 return test_snow3g_encryption(&snow3g_test_case_1);
6742 test_snow3g_encryption_test_case_1_oop(void)
6744 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6748 test_snow3g_encryption_test_case_1_oop_sgl(void)
6750 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6755 test_snow3g_encryption_test_case_1_offset_oop(void)
6757 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6761 test_snow3g_encryption_test_case_2(void)
6763 return test_snow3g_encryption(&snow3g_test_case_2);
6767 test_snow3g_encryption_test_case_3(void)
6769 return test_snow3g_encryption(&snow3g_test_case_3);
6773 test_snow3g_encryption_test_case_4(void)
6775 return test_snow3g_encryption(&snow3g_test_case_4);
6779 test_snow3g_encryption_test_case_5(void)
6781 return test_snow3g_encryption(&snow3g_test_case_5);
6785 test_snow3g_decryption_test_case_1(void)
6787 return test_snow3g_decryption(&snow3g_test_case_1);
6791 test_snow3g_decryption_test_case_1_oop(void)
6793 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6797 test_snow3g_decryption_test_case_2(void)
6799 return test_snow3g_decryption(&snow3g_test_case_2);
6803 test_snow3g_decryption_test_case_3(void)
6805 return test_snow3g_decryption(&snow3g_test_case_3);
6809 test_snow3g_decryption_test_case_4(void)
6811 return test_snow3g_decryption(&snow3g_test_case_4);
6815 test_snow3g_decryption_test_case_5(void)
6817 return test_snow3g_decryption(&snow3g_test_case_5);
6821 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6822 * Pattern digest from snow3g_test_data must be allocated as
6823 * 4 last bytes in plaintext.
6826 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6827 struct snow3g_hash_test_data *output)
6829 if ((pattern != NULL) && (output != NULL)) {
6830 output->key.len = pattern->key.len;
6832 memcpy(output->key.data,
6833 pattern->key.data, pattern->key.len);
6835 output->auth_iv.len = pattern->auth_iv.len;
6837 memcpy(output->auth_iv.data,
6838 pattern->auth_iv.data, pattern->auth_iv.len);
6840 output->plaintext.len = pattern->plaintext.len;
6842 memcpy(output->plaintext.data,
6843 pattern->plaintext.data, pattern->plaintext.len >> 3);
6845 output->digest.len = pattern->digest.len;
6847 memcpy(output->digest.data,
6848 &pattern->plaintext.data[pattern->digest.offset_bytes],
6849 pattern->digest.len);
6851 output->validAuthLenInBits.len =
6852 pattern->validAuthLenInBits.len;
6857 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6860 test_snow3g_decryption_with_digest_test_case_1(void)
6862 struct snow3g_hash_test_data snow3g_hash_data;
6863 struct rte_cryptodev_info dev_info;
6864 struct crypto_testsuite_params *ts_params = &testsuite_params;
6866 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6867 uint64_t feat_flags = dev_info.feature_flags;
6869 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6870 printf("Device doesn't support encrypted digest operations.\n");
6871 return TEST_SKIPPED;
6875 * Function prepare data for hash verification test case.
6876 * Digest is allocated in 4 last bytes in plaintext, pattern.
6878 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6880 return test_snow3g_decryption(&snow3g_test_case_7) &
6881 test_snow3g_authentication_verify(&snow3g_hash_data);
6885 test_snow3g_cipher_auth_test_case_1(void)
6887 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6891 test_snow3g_auth_cipher_test_case_1(void)
6893 return test_snow3g_auth_cipher(
6894 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6898 test_snow3g_auth_cipher_test_case_2(void)
6900 return test_snow3g_auth_cipher(
6901 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6905 test_snow3g_auth_cipher_test_case_2_oop(void)
6907 return test_snow3g_auth_cipher(
6908 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6912 test_snow3g_auth_cipher_part_digest_enc(void)
6914 return test_snow3g_auth_cipher(
6915 &snow3g_auth_cipher_partial_digest_encryption,
6920 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6922 return test_snow3g_auth_cipher(
6923 &snow3g_auth_cipher_partial_digest_encryption,
6928 test_snow3g_auth_cipher_test_case_3_sgl(void)
6930 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6931 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6932 return TEST_SKIPPED;
6933 return test_snow3g_auth_cipher_sgl(
6934 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6938 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6940 return test_snow3g_auth_cipher_sgl(
6941 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6945 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6947 /* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6948 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6949 return TEST_SKIPPED;
6950 return test_snow3g_auth_cipher_sgl(
6951 &snow3g_auth_cipher_partial_digest_encryption,
6956 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6958 return test_snow3g_auth_cipher_sgl(
6959 &snow3g_auth_cipher_partial_digest_encryption,
6964 test_snow3g_auth_cipher_verify_test_case_1(void)
6966 return test_snow3g_auth_cipher(
6967 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6971 test_snow3g_auth_cipher_verify_test_case_2(void)
6973 return test_snow3g_auth_cipher(
6974 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6978 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6980 return test_snow3g_auth_cipher(
6981 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6985 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6987 return test_snow3g_auth_cipher(
6988 &snow3g_auth_cipher_partial_digest_encryption,
6993 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6995 return test_snow3g_auth_cipher(
6996 &snow3g_auth_cipher_partial_digest_encryption,
7001 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
7003 return test_snow3g_auth_cipher_sgl(
7004 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
7008 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
7010 return test_snow3g_auth_cipher_sgl(
7011 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
7015 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
7017 return test_snow3g_auth_cipher_sgl(
7018 &snow3g_auth_cipher_partial_digest_encryption,
7023 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
7025 return test_snow3g_auth_cipher_sgl(
7026 &snow3g_auth_cipher_partial_digest_encryption,
7031 test_snow3g_auth_cipher_with_digest_test_case_1(void)
7033 return test_snow3g_auth_cipher(
7034 &snow3g_test_case_7, IN_PLACE, 0);
7038 test_kasumi_auth_cipher_test_case_1(void)
7040 return test_kasumi_auth_cipher(
7041 &kasumi_test_case_3, IN_PLACE, 0);
7045 test_kasumi_auth_cipher_test_case_2(void)
7047 return test_kasumi_auth_cipher(
7048 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7052 test_kasumi_auth_cipher_test_case_2_oop(void)
7054 return test_kasumi_auth_cipher(
7055 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7059 test_kasumi_auth_cipher_test_case_2_sgl(void)
7061 return test_kasumi_auth_cipher_sgl(
7062 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
7066 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
7068 return test_kasumi_auth_cipher_sgl(
7069 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
7073 test_kasumi_auth_cipher_verify_test_case_1(void)
7075 return test_kasumi_auth_cipher(
7076 &kasumi_test_case_3, IN_PLACE, 1);
7080 test_kasumi_auth_cipher_verify_test_case_2(void)
7082 return test_kasumi_auth_cipher(
7083 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7087 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
7089 return test_kasumi_auth_cipher(
7090 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7094 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
7096 return test_kasumi_auth_cipher_sgl(
7097 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
7101 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
7103 return test_kasumi_auth_cipher_sgl(
7104 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
7108 test_kasumi_cipher_auth_test_case_1(void)
7110 return test_kasumi_cipher_auth(&kasumi_test_case_6);
7114 test_zuc_encryption_test_case_1(void)
7116 return test_zuc_encryption(&zuc_test_case_cipher_193b);
7120 test_zuc_encryption_test_case_2(void)
7122 return test_zuc_encryption(&zuc_test_case_cipher_800b);
7126 test_zuc_encryption_test_case_3(void)
7128 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
7132 test_zuc_encryption_test_case_4(void)
7134 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
7138 test_zuc_encryption_test_case_5(void)
7140 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
7144 test_zuc_encryption_test_case_6_sgl(void)
7146 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
7150 test_zuc_hash_generate_test_case_1(void)
7152 return test_zuc_authentication(&zuc_test_case_auth_1b);
7156 test_zuc_hash_generate_test_case_2(void)
7158 return test_zuc_authentication(&zuc_test_case_auth_90b);
7162 test_zuc_hash_generate_test_case_3(void)
7164 return test_zuc_authentication(&zuc_test_case_auth_577b);
7168 test_zuc_hash_generate_test_case_4(void)
7170 return test_zuc_authentication(&zuc_test_case_auth_2079b);
7174 test_zuc_hash_generate_test_case_5(void)
7176 return test_zuc_authentication(&zuc_test_auth_5670b);
7180 test_zuc_hash_generate_test_case_6(void)
7182 return test_zuc_authentication(&zuc_test_case_auth_128b);
7186 test_zuc_hash_generate_test_case_7(void)
7188 return test_zuc_authentication(&zuc_test_case_auth_2080b);
7192 test_zuc_hash_generate_test_case_8(void)
7194 return test_zuc_authentication(&zuc_test_case_auth_584b);
7198 test_zuc_hash_generate_test_case_9(void)
7200 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_32b);
7204 test_zuc_hash_generate_test_case_10(void)
7206 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_64b);
7210 test_zuc_hash_generate_test_case_11(void)
7212 return test_zuc_authentication(&zuc_test_case_auth_4000b_mac_128b);
7216 test_zuc_cipher_auth_test_case_1(void)
7218 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7222 test_zuc_cipher_auth_test_case_2(void)
7224 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7228 test_zuc_auth_cipher_test_case_1(void)
7230 return test_zuc_auth_cipher(
7231 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7235 test_zuc_auth_cipher_test_case_1_oop(void)
7237 return test_zuc_auth_cipher(
7238 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7242 test_zuc_auth_cipher_test_case_1_sgl(void)
7244 return test_zuc_auth_cipher_sgl(
7245 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7249 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7251 return test_zuc_auth_cipher_sgl(
7252 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7256 test_zuc_auth_cipher_verify_test_case_1(void)
7258 return test_zuc_auth_cipher(
7259 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7263 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7265 return test_zuc_auth_cipher(
7266 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7270 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7272 return test_zuc_auth_cipher_sgl(
7273 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7277 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7279 return test_zuc_auth_cipher_sgl(
7280 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7284 test_zuc256_encryption_test_case_1(void)
7286 return test_zuc_encryption(&zuc256_test_case_cipher_1);
7290 test_zuc256_encryption_test_case_2(void)
7292 return test_zuc_encryption(&zuc256_test_case_cipher_2);
7296 test_zuc256_authentication_test_case_1(void)
7298 return test_zuc_authentication(&zuc256_test_case_auth_1);
7302 test_zuc256_authentication_test_case_2(void)
7304 return test_zuc_authentication(&zuc256_test_case_auth_2);
7308 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7310 uint8_t dev_id = testsuite_params.valid_devs[0];
7312 struct rte_cryptodev_sym_capability_idx cap_idx;
7314 /* Check if device supports particular cipher algorithm */
7315 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7316 cap_idx.algo.cipher = tdata->cipher_algo;
7317 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7318 return TEST_SKIPPED;
7320 /* Check if device supports particular hash algorithm */
7321 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7322 cap_idx.algo.auth = tdata->auth_algo;
7323 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7324 return TEST_SKIPPED;
7330 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7331 uint8_t op_mode, uint8_t verify)
7333 struct crypto_testsuite_params *ts_params = &testsuite_params;
7334 struct crypto_unittest_params *ut_params = &unittest_params;
7338 uint8_t *plaintext = NULL, *ciphertext = NULL;
7339 unsigned int plaintext_pad_len;
7340 unsigned int plaintext_len;
7341 unsigned int ciphertext_pad_len;
7342 unsigned int ciphertext_len;
7344 struct rte_cryptodev_info dev_info;
7345 struct rte_crypto_op *op;
7347 /* Check if device supports particular algorithms separately */
7348 if (test_mixed_check_if_unsupported(tdata))
7349 return TEST_SKIPPED;
7350 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7351 return TEST_SKIPPED;
7353 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7355 uint64_t feat_flags = dev_info.feature_flags;
7357 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7358 printf("Device doesn't support digest encrypted.\n");
7359 return TEST_SKIPPED;
7362 /* Create the session */
7364 retval = create_wireless_algo_cipher_auth_session(
7365 ts_params->valid_devs[0],
7366 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7367 RTE_CRYPTO_AUTH_OP_VERIFY,
7370 tdata->auth_key.data, tdata->auth_key.len,
7371 tdata->auth_iv.len, tdata->digest_enc.len,
7372 tdata->cipher_iv.len);
7374 retval = create_wireless_algo_auth_cipher_session(
7375 ts_params->valid_devs[0],
7376 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7377 RTE_CRYPTO_AUTH_OP_GENERATE,
7380 tdata->auth_key.data, tdata->auth_key.len,
7381 tdata->auth_iv.len, tdata->digest_enc.len,
7382 tdata->cipher_iv.len);
7386 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7387 if (op_mode == OUT_OF_PLACE)
7388 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7390 /* clear mbuf payload */
7391 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7392 rte_pktmbuf_tailroom(ut_params->ibuf));
7393 if (op_mode == OUT_OF_PLACE) {
7395 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7396 rte_pktmbuf_tailroom(ut_params->obuf));
7399 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7400 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7401 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7402 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7405 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7406 ciphertext_pad_len);
7407 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7408 debug_hexdump(stdout, "ciphertext:", ciphertext,
7411 /* make sure enough space to cover partial digest verify case */
7412 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7413 ciphertext_pad_len);
7414 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7415 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7418 if (op_mode == OUT_OF_PLACE)
7419 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7421 /* Create the operation */
7422 retval = create_wireless_algo_auth_cipher_operation(
7423 tdata->digest_enc.data, tdata->digest_enc.len,
7424 tdata->cipher_iv.data, tdata->cipher_iv.len,
7425 tdata->auth_iv.data, tdata->auth_iv.len,
7426 (tdata->digest_enc.offset == 0 ?
7428 : tdata->digest_enc.offset),
7429 tdata->validCipherLen.len_bits,
7430 tdata->cipher.offset_bits,
7431 tdata->validAuthLen.len_bits,
7432 tdata->auth.offset_bits,
7433 op_mode, 0, verify);
7438 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7440 /* Check if the op failed because the device doesn't */
7441 /* support this particular combination of algorithms */
7442 if (op == NULL && ut_params->op->status ==
7443 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7444 printf("Device doesn't support this mixed combination. "
7446 return TEST_SKIPPED;
7450 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7452 ut_params->obuf = (op_mode == IN_PLACE ?
7453 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7456 if (ut_params->obuf)
7457 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7460 plaintext = ciphertext +
7461 (tdata->cipher.offset_bits >> 3);
7463 debug_hexdump(stdout, "plaintext:", plaintext,
7464 tdata->plaintext.len_bits >> 3);
7465 debug_hexdump(stdout, "plaintext expected:",
7466 tdata->plaintext.data,
7467 tdata->plaintext.len_bits >> 3);
7469 if (ut_params->obuf)
7470 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7473 ciphertext = plaintext;
7475 debug_hexdump(stdout, "ciphertext:", ciphertext,
7477 debug_hexdump(stdout, "ciphertext expected:",
7478 tdata->ciphertext.data,
7479 tdata->ciphertext.len_bits >> 3);
7481 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7482 + (tdata->digest_enc.offset == 0 ?
7483 plaintext_pad_len : tdata->digest_enc.offset);
7485 debug_hexdump(stdout, "digest:", ut_params->digest,
7486 tdata->digest_enc.len);
7487 debug_hexdump(stdout, "digest expected:",
7488 tdata->digest_enc.data,
7489 tdata->digest_enc.len);
7493 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7495 tdata->digest_enc.data,
7496 tdata->digest_enc.len,
7497 "Generated auth tag not as expected");
7500 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7502 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7504 tdata->plaintext.data,
7505 tdata->plaintext.len_bits >> 3,
7506 "Plaintext data not as expected");
7508 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7510 tdata->ciphertext.data,
7511 tdata->validDataLen.len_bits,
7512 "Ciphertext data not as expected");
7516 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7517 "crypto op processing failed");
7523 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7524 uint8_t op_mode, uint8_t verify)
7526 struct crypto_testsuite_params *ts_params = &testsuite_params;
7527 struct crypto_unittest_params *ut_params = &unittest_params;
7531 const uint8_t *plaintext = NULL;
7532 const uint8_t *ciphertext = NULL;
7533 const uint8_t *digest = NULL;
7534 unsigned int plaintext_pad_len;
7535 unsigned int plaintext_len;
7536 unsigned int ciphertext_pad_len;
7537 unsigned int ciphertext_len;
7538 uint8_t buffer[10000];
7539 uint8_t digest_buffer[10000];
7541 struct rte_cryptodev_info dev_info;
7542 struct rte_crypto_op *op;
7544 /* Check if device supports particular algorithms */
7545 if (test_mixed_check_if_unsupported(tdata))
7546 return TEST_SKIPPED;
7547 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7548 return TEST_SKIPPED;
7550 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7552 uint64_t feat_flags = dev_info.feature_flags;
7554 if (op_mode == IN_PLACE) {
7555 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7556 printf("Device doesn't support in-place scatter-gather "
7557 "in both input and output mbufs.\n");
7558 return TEST_SKIPPED;
7561 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7562 printf("Device doesn't support out-of-place scatter-gather "
7563 "in both input and output mbufs.\n");
7564 return TEST_SKIPPED;
7566 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7567 printf("Device doesn't support digest encrypted.\n");
7568 return TEST_SKIPPED;
7572 /* Create the session */
7574 retval = create_wireless_algo_cipher_auth_session(
7575 ts_params->valid_devs[0],
7576 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7577 RTE_CRYPTO_AUTH_OP_VERIFY,
7580 tdata->auth_key.data, tdata->auth_key.len,
7581 tdata->auth_iv.len, tdata->digest_enc.len,
7582 tdata->cipher_iv.len);
7584 retval = create_wireless_algo_auth_cipher_session(
7585 ts_params->valid_devs[0],
7586 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7587 RTE_CRYPTO_AUTH_OP_GENERATE,
7590 tdata->auth_key.data, tdata->auth_key.len,
7591 tdata->auth_iv.len, tdata->digest_enc.len,
7592 tdata->cipher_iv.len);
7596 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7597 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7598 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7599 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7601 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7602 ciphertext_pad_len, 15, 0);
7603 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7604 "Failed to allocate input buffer in mempool");
7606 if (op_mode == OUT_OF_PLACE) {
7607 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7608 plaintext_pad_len, 15, 0);
7609 TEST_ASSERT_NOT_NULL(ut_params->obuf,
7610 "Failed to allocate output buffer in mempool");
7614 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7615 tdata->ciphertext.data);
7616 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7617 ciphertext_len, buffer);
7618 debug_hexdump(stdout, "ciphertext:", ciphertext,
7621 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7622 tdata->plaintext.data);
7623 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7624 plaintext_len, buffer);
7625 debug_hexdump(stdout, "plaintext:", plaintext,
7628 memset(buffer, 0, sizeof(buffer));
7630 /* Create the operation */
7631 retval = create_wireless_algo_auth_cipher_operation(
7632 tdata->digest_enc.data, tdata->digest_enc.len,
7633 tdata->cipher_iv.data, tdata->cipher_iv.len,
7634 tdata->auth_iv.data, tdata->auth_iv.len,
7635 (tdata->digest_enc.offset == 0 ?
7637 : tdata->digest_enc.offset),
7638 tdata->validCipherLen.len_bits,
7639 tdata->cipher.offset_bits,
7640 tdata->validAuthLen.len_bits,
7641 tdata->auth.offset_bits,
7642 op_mode, 1, verify);
7647 op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7649 /* Check if the op failed because the device doesn't */
7650 /* support this particular combination of algorithms */
7651 if (op == NULL && ut_params->op->status ==
7652 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7653 printf("Device doesn't support this mixed combination. "
7655 return TEST_SKIPPED;
7659 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7661 ut_params->obuf = (op_mode == IN_PLACE ?
7662 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7665 if (ut_params->obuf)
7666 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7667 plaintext_len, buffer);
7669 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7670 plaintext_len, buffer);
7672 debug_hexdump(stdout, "plaintext:", plaintext,
7673 (tdata->plaintext.len_bits >> 3) -
7674 tdata->digest_enc.len);
7675 debug_hexdump(stdout, "plaintext expected:",
7676 tdata->plaintext.data,
7677 (tdata->plaintext.len_bits >> 3) -
7678 tdata->digest_enc.len);
7680 if (ut_params->obuf)
7681 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7682 ciphertext_len, buffer);
7684 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7685 ciphertext_len, buffer);
7687 debug_hexdump(stdout, "ciphertext:", ciphertext,
7689 debug_hexdump(stdout, "ciphertext expected:",
7690 tdata->ciphertext.data,
7691 tdata->ciphertext.len_bits >> 3);
7693 if (ut_params->obuf)
7694 digest = rte_pktmbuf_read(ut_params->obuf,
7695 (tdata->digest_enc.offset == 0 ?
7697 tdata->digest_enc.offset),
7698 tdata->digest_enc.len, digest_buffer);
7700 digest = rte_pktmbuf_read(ut_params->ibuf,
7701 (tdata->digest_enc.offset == 0 ?
7703 tdata->digest_enc.offset),
7704 tdata->digest_enc.len, digest_buffer);
7706 debug_hexdump(stdout, "digest:", digest,
7707 tdata->digest_enc.len);
7708 debug_hexdump(stdout, "digest expected:",
7709 tdata->digest_enc.data, tdata->digest_enc.len);
7713 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7715 tdata->digest_enc.data,
7716 tdata->digest_enc.len,
7717 "Generated auth tag not as expected");
7720 if (tdata->cipher_algo != RTE_CRYPTO_CIPHER_NULL) {
7722 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7724 tdata->plaintext.data,
7725 tdata->plaintext.len_bits >> 3,
7726 "Plaintext data not as expected");
7728 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7730 tdata->ciphertext.data,
7731 tdata->validDataLen.len_bits,
7732 "Ciphertext data not as expected");
7736 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7737 "crypto op processing failed");
7742 /** AUTH AES CMAC + CIPHER AES CTR */
7745 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7747 return test_mixed_auth_cipher(
7748 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7752 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7754 return test_mixed_auth_cipher(
7755 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7759 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7761 return test_mixed_auth_cipher_sgl(
7762 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7766 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7768 return test_mixed_auth_cipher_sgl(
7769 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7773 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7775 return test_mixed_auth_cipher(
7776 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7780 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7782 return test_mixed_auth_cipher(
7783 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7787 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7789 return test_mixed_auth_cipher_sgl(
7790 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7794 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7796 return test_mixed_auth_cipher_sgl(
7797 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7800 /** MIXED AUTH + CIPHER */
7803 test_auth_zuc_cipher_snow_test_case_1(void)
7805 return test_mixed_auth_cipher(
7806 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7810 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7812 return test_mixed_auth_cipher(
7813 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7817 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7819 return test_mixed_auth_cipher(
7820 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7824 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7826 return test_mixed_auth_cipher(
7827 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7831 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7833 return test_mixed_auth_cipher(
7834 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7838 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7840 return test_mixed_auth_cipher(
7841 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7845 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7847 return test_mixed_auth_cipher(
7848 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7852 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7854 return test_mixed_auth_cipher(
7855 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7859 test_auth_snow_cipher_zuc_test_case_1(void)
7861 return test_mixed_auth_cipher(
7862 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7866 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7868 return test_mixed_auth_cipher(
7869 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7873 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7875 return test_mixed_auth_cipher(
7876 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7880 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7882 return test_mixed_auth_cipher(
7883 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7887 test_auth_null_cipher_snow_test_case_1(void)
7889 return test_mixed_auth_cipher(
7890 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7894 test_verify_auth_null_cipher_snow_test_case_1(void)
7896 return test_mixed_auth_cipher(
7897 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7901 test_auth_null_cipher_zuc_test_case_1(void)
7903 return test_mixed_auth_cipher(
7904 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7908 test_verify_auth_null_cipher_zuc_test_case_1(void)
7910 return test_mixed_auth_cipher(
7911 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7915 test_auth_snow_cipher_null_test_case_1(void)
7917 return test_mixed_auth_cipher(
7918 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7922 test_verify_auth_snow_cipher_null_test_case_1(void)
7924 return test_mixed_auth_cipher(
7925 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7929 test_auth_zuc_cipher_null_test_case_1(void)
7931 return test_mixed_auth_cipher(
7932 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7936 test_verify_auth_zuc_cipher_null_test_case_1(void)
7938 return test_mixed_auth_cipher(
7939 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7943 test_auth_null_cipher_aes_ctr_test_case_1(void)
7945 return test_mixed_auth_cipher(
7946 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7950 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7952 return test_mixed_auth_cipher(
7953 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7957 test_auth_aes_cmac_cipher_null_test_case_1(void)
7959 return test_mixed_auth_cipher(
7960 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7964 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7966 return test_mixed_auth_cipher(
7967 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7970 /* ***** AEAD algorithm Tests ***** */
7973 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7974 enum rte_crypto_aead_operation op,
7975 const uint8_t *key, const uint8_t key_len,
7976 const uint16_t aad_len, const uint8_t auth_len,
7979 uint8_t aead_key[key_len];
7982 struct crypto_testsuite_params *ts_params = &testsuite_params;
7983 struct crypto_unittest_params *ut_params = &unittest_params;
7985 memcpy(aead_key, key, key_len);
7987 /* Setup AEAD Parameters */
7988 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7989 ut_params->aead_xform.next = NULL;
7990 ut_params->aead_xform.aead.algo = algo;
7991 ut_params->aead_xform.aead.op = op;
7992 ut_params->aead_xform.aead.key.data = aead_key;
7993 ut_params->aead_xform.aead.key.length = key_len;
7994 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7995 ut_params->aead_xform.aead.iv.length = iv_len;
7996 ut_params->aead_xform.aead.digest_length = auth_len;
7997 ut_params->aead_xform.aead.aad_length = aad_len;
7999 debug_hexdump(stdout, "key:", key, key_len);
8001 /* Create Crypto session*/
8002 ut_params->sess = rte_cryptodev_sym_session_create(
8003 ts_params->session_mpool);
8004 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8006 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8007 &ut_params->aead_xform,
8008 ts_params->session_priv_mpool);
8014 create_aead_xform(struct rte_crypto_op *op,
8015 enum rte_crypto_aead_algorithm algo,
8016 enum rte_crypto_aead_operation aead_op,
8017 uint8_t *key, const uint8_t key_len,
8018 const uint8_t aad_len, const uint8_t auth_len,
8021 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
8022 "failed to allocate space for crypto transform");
8024 struct rte_crypto_sym_op *sym_op = op->sym;
8026 /* Setup AEAD Parameters */
8027 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
8028 sym_op->xform->next = NULL;
8029 sym_op->xform->aead.algo = algo;
8030 sym_op->xform->aead.op = aead_op;
8031 sym_op->xform->aead.key.data = key;
8032 sym_op->xform->aead.key.length = key_len;
8033 sym_op->xform->aead.iv.offset = IV_OFFSET;
8034 sym_op->xform->aead.iv.length = iv_len;
8035 sym_op->xform->aead.digest_length = auth_len;
8036 sym_op->xform->aead.aad_length = aad_len;
8038 debug_hexdump(stdout, "key:", key, key_len);
8044 create_aead_operation(enum rte_crypto_aead_operation op,
8045 const struct aead_test_data *tdata)
8047 struct crypto_testsuite_params *ts_params = &testsuite_params;
8048 struct crypto_unittest_params *ut_params = &unittest_params;
8050 uint8_t *plaintext, *ciphertext;
8051 unsigned int aad_pad_len, plaintext_pad_len;
8053 /* Generate Crypto op data structure */
8054 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8055 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8056 TEST_ASSERT_NOT_NULL(ut_params->op,
8057 "Failed to allocate symmetric crypto operation struct");
8059 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8061 /* Append aad data */
8062 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8063 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
8064 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8066 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8067 "no room to append aad");
8069 sym_op->aead.aad.phys_addr =
8070 rte_pktmbuf_iova(ut_params->ibuf);
8071 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8072 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
8073 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8076 /* Append IV at the end of the crypto operation*/
8077 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8078 uint8_t *, IV_OFFSET);
8080 /* Copy IV 1 byte after the IV pointer, according to the API */
8081 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
8082 debug_hexdump(stdout, "iv:", iv_ptr,
8085 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
8086 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8088 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8089 "no room to append aad");
8091 sym_op->aead.aad.phys_addr =
8092 rte_pktmbuf_iova(ut_params->ibuf);
8093 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
8094 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
8097 /* Append IV at the end of the crypto operation*/
8098 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8099 uint8_t *, IV_OFFSET);
8101 if (tdata->iv.len == 0) {
8102 rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
8103 debug_hexdump(stdout, "iv:", iv_ptr,
8106 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8107 debug_hexdump(stdout, "iv:", iv_ptr,
8112 /* Append plaintext/ciphertext */
8113 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8114 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8115 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8117 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8119 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8120 debug_hexdump(stdout, "plaintext:", plaintext,
8121 tdata->plaintext.len);
8123 if (ut_params->obuf) {
8124 ciphertext = (uint8_t *)rte_pktmbuf_append(
8126 plaintext_pad_len + aad_pad_len);
8127 TEST_ASSERT_NOT_NULL(ciphertext,
8128 "no room to append ciphertext");
8130 memset(ciphertext + aad_pad_len, 0,
8131 tdata->ciphertext.len);
8134 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
8135 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8137 TEST_ASSERT_NOT_NULL(ciphertext,
8138 "no room to append ciphertext");
8140 memcpy(ciphertext, tdata->ciphertext.data,
8141 tdata->ciphertext.len);
8142 debug_hexdump(stdout, "ciphertext:", ciphertext,
8143 tdata->ciphertext.len);
8145 if (ut_params->obuf) {
8146 plaintext = (uint8_t *)rte_pktmbuf_append(
8148 plaintext_pad_len + aad_pad_len);
8149 TEST_ASSERT_NOT_NULL(plaintext,
8150 "no room to append plaintext");
8152 memset(plaintext + aad_pad_len, 0,
8153 tdata->plaintext.len);
8157 /* Append digest data */
8158 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
8159 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8160 ut_params->obuf ? ut_params->obuf :
8162 tdata->auth_tag.len);
8163 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8164 "no room to append digest");
8165 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
8166 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8167 ut_params->obuf ? ut_params->obuf :
8172 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
8173 ut_params->ibuf, tdata->auth_tag.len);
8174 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8175 "no room to append digest");
8176 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
8178 plaintext_pad_len + aad_pad_len);
8180 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8181 tdata->auth_tag.len);
8182 debug_hexdump(stdout, "digest:",
8183 sym_op->aead.digest.data,
8184 tdata->auth_tag.len);
8187 sym_op->aead.data.length = tdata->plaintext.len;
8188 sym_op->aead.data.offset = aad_pad_len;
8194 test_authenticated_encryption(const struct aead_test_data *tdata)
8196 struct crypto_testsuite_params *ts_params = &testsuite_params;
8197 struct crypto_unittest_params *ut_params = &unittest_params;
8200 uint8_t *ciphertext, *auth_tag;
8201 uint16_t plaintext_pad_len;
8203 struct rte_cryptodev_info dev_info;
8205 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8206 uint64_t feat_flags = dev_info.feature_flags;
8208 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8209 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8210 printf("Device doesn't support RAW data-path APIs.\n");
8211 return TEST_SKIPPED;
8214 /* Verify the capabilities */
8215 struct rte_cryptodev_sym_capability_idx cap_idx;
8216 const struct rte_cryptodev_symmetric_capability *capability;
8217 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8218 cap_idx.algo.aead = tdata->algo;
8219 capability = rte_cryptodev_sym_capability_get(
8220 ts_params->valid_devs[0], &cap_idx);
8221 if (capability == NULL)
8222 return TEST_SKIPPED;
8223 if (rte_cryptodev_sym_capability_check_aead(
8224 capability, tdata->key.len, tdata->auth_tag.len,
8225 tdata->aad.len, tdata->iv.len))
8226 return TEST_SKIPPED;
8228 /* Create AEAD session */
8229 retval = create_aead_session(ts_params->valid_devs[0],
8231 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8232 tdata->key.data, tdata->key.len,
8233 tdata->aad.len, tdata->auth_tag.len,
8238 if (tdata->aad.len > MBUF_SIZE) {
8239 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8240 /* Populate full size of add data */
8241 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8242 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8246 /* clear mbuf payload */
8247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8248 rte_pktmbuf_tailroom(ut_params->ibuf));
8250 /* Create AEAD operation */
8251 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8255 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8257 ut_params->op->sym->m_src = ut_params->ibuf;
8259 /* Process crypto operation */
8260 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8261 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8262 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8263 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8264 ut_params->op, 0, 0, 0, 0);
8266 TEST_ASSERT_NOT_NULL(
8267 process_crypto_request(ts_params->valid_devs[0],
8268 ut_params->op), "failed to process sym crypto op");
8270 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8271 "crypto op processing failed");
8273 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8275 if (ut_params->op->sym->m_dst) {
8276 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8278 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8279 uint8_t *, plaintext_pad_len);
8281 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8283 ut_params->op->sym->cipher.data.offset);
8284 auth_tag = ciphertext + plaintext_pad_len;
8287 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8288 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8291 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8293 tdata->ciphertext.data,
8294 tdata->ciphertext.len,
8295 "Ciphertext data not as expected");
8297 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8299 tdata->auth_tag.data,
8300 tdata->auth_tag.len,
8301 "Generated auth tag not as expected");
8307 #ifdef RTE_LIB_SECURITY
8309 security_proto_supported(enum rte_security_session_action_type action,
8310 enum rte_security_session_protocol proto)
8312 struct crypto_testsuite_params *ts_params = &testsuite_params;
8314 const struct rte_security_capability *capabilities;
8315 const struct rte_security_capability *capability;
8318 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8319 rte_cryptodev_get_sec_ctx(
8320 ts_params->valid_devs[0]);
8323 capabilities = rte_security_capabilities_get(ctx);
8325 if (capabilities == NULL)
8328 while ((capability = &capabilities[i++])->action !=
8329 RTE_SECURITY_ACTION_TYPE_NONE) {
8330 if (capability->action == action &&
8331 capability->protocol == proto)
8338 /* Basic algorithm run function for async inplace mode.
8339 * Creates a session from input parameters and runs one operation
8340 * on input_vec. Checks the output of the crypto operation against
8343 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8344 enum rte_crypto_auth_operation opa,
8345 const uint8_t *input_vec, unsigned int input_vec_len,
8346 const uint8_t *output_vec,
8347 unsigned int output_vec_len,
8348 enum rte_crypto_cipher_algorithm cipher_alg,
8349 const uint8_t *cipher_key, uint32_t cipher_key_len,
8350 enum rte_crypto_auth_algorithm auth_alg,
8351 const uint8_t *auth_key, uint32_t auth_key_len,
8352 uint8_t bearer, enum rte_security_pdcp_domain domain,
8353 uint8_t packet_direction, uint8_t sn_size,
8354 uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8356 struct crypto_testsuite_params *ts_params = &testsuite_params;
8357 struct crypto_unittest_params *ut_params = &unittest_params;
8359 int ret = TEST_SUCCESS;
8360 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8361 rte_cryptodev_get_sec_ctx(
8362 ts_params->valid_devs[0]);
8364 /* Verify the capabilities */
8365 struct rte_security_capability_idx sec_cap_idx;
8367 sec_cap_idx.action = ut_params->type;
8368 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8369 sec_cap_idx.pdcp.domain = domain;
8370 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8371 return TEST_SKIPPED;
8373 /* Generate test mbuf data */
8374 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8376 /* clear mbuf payload */
8377 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8378 rte_pktmbuf_tailroom(ut_params->ibuf));
8380 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8382 memcpy(plaintext, input_vec, input_vec_len);
8384 /* Out of place support */
8387 * For out-op-place we need to alloc another mbuf
8389 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8390 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8393 /* Setup Cipher Parameters */
8394 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8395 ut_params->cipher_xform.cipher.algo = cipher_alg;
8396 ut_params->cipher_xform.cipher.op = opc;
8397 ut_params->cipher_xform.cipher.key.data = cipher_key;
8398 ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8399 ut_params->cipher_xform.cipher.iv.length =
8400 packet_direction ? 4 : 0;
8401 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8403 /* Setup HMAC Parameters if ICV header is required */
8404 if (auth_alg != 0) {
8405 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8406 ut_params->auth_xform.next = NULL;
8407 ut_params->auth_xform.auth.algo = auth_alg;
8408 ut_params->auth_xform.auth.op = opa;
8409 ut_params->auth_xform.auth.key.data = auth_key;
8410 ut_params->auth_xform.auth.key.length = auth_key_len;
8412 ut_params->cipher_xform.next = &ut_params->auth_xform;
8414 ut_params->cipher_xform.next = NULL;
8417 struct rte_security_session_conf sess_conf = {
8418 .action_type = ut_params->type,
8419 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8423 .pkt_dir = packet_direction,
8425 .hfn = packet_direction ? 0 : hfn,
8427 * hfn can be set as pdcp_test_hfn[i]
8428 * if hfn_ovrd is not set. Here, PDCP
8429 * packet direction is just used to
8430 * run half of the cases with session
8431 * HFN and other half with per packet
8434 .hfn_threshold = hfn_threshold,
8435 .hfn_ovrd = packet_direction ? 1 : 0,
8436 .sdap_enabled = sdap,
8438 .crypto_xform = &ut_params->cipher_xform
8441 /* Create security session */
8442 ut_params->sec_session = rte_security_session_create(ctx,
8443 &sess_conf, ts_params->session_mpool,
8444 ts_params->session_priv_mpool);
8446 if (!ut_params->sec_session) {
8447 printf("TestCase %s()-%d line %d failed %s: ",
8448 __func__, i, __LINE__, "Failed to allocate session");
8453 /* Generate crypto op data structure */
8454 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8455 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8456 if (!ut_params->op) {
8457 printf("TestCase %s()-%d line %d failed %s: ",
8458 __func__, i, __LINE__,
8459 "Failed to allocate symmetric crypto operation struct");
8464 uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8465 uint32_t *, IV_OFFSET);
8466 *per_pkt_hfn = packet_direction ? hfn : 0;
8468 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8470 /* set crypto operation source mbuf */
8471 ut_params->op->sym->m_src = ut_params->ibuf;
8473 ut_params->op->sym->m_dst = ut_params->obuf;
8475 /* Process crypto operation */
8476 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8478 printf("TestCase %s()-%d line %d failed %s: ",
8479 __func__, i, __LINE__,
8480 "failed to process sym crypto op");
8485 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8486 printf("TestCase %s()-%d line %d failed %s: ",
8487 __func__, i, __LINE__, "crypto op processing failed");
8493 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8496 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8500 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8501 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8502 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8503 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8509 rte_crypto_op_free(ut_params->op);
8510 ut_params->op = NULL;
8512 if (ut_params->sec_session)
8513 rte_security_session_destroy(ctx, ut_params->sec_session);
8514 ut_params->sec_session = NULL;
8516 rte_pktmbuf_free(ut_params->ibuf);
8517 ut_params->ibuf = NULL;
8519 rte_pktmbuf_free(ut_params->obuf);
8520 ut_params->obuf = NULL;
8527 test_pdcp_proto_SGL(int i, int oop,
8528 enum rte_crypto_cipher_operation opc,
8529 enum rte_crypto_auth_operation opa,
8531 unsigned int input_vec_len,
8532 uint8_t *output_vec,
8533 unsigned int output_vec_len,
8535 uint32_t fragsz_oop)
8537 struct crypto_testsuite_params *ts_params = &testsuite_params;
8538 struct crypto_unittest_params *ut_params = &unittest_params;
8540 struct rte_mbuf *buf, *buf_oop = NULL;
8541 int ret = TEST_SUCCESS;
8545 unsigned int trn_data = 0;
8546 struct rte_cryptodev_info dev_info;
8547 uint64_t feat_flags;
8548 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8549 rte_cryptodev_get_sec_ctx(
8550 ts_params->valid_devs[0]);
8551 struct rte_mbuf *temp_mbuf;
8553 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8554 feat_flags = dev_info.feature_flags;
8556 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
8557 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
8558 printf("Device does not support RAW data-path APIs.\n");
8561 /* Verify the capabilities */
8562 struct rte_security_capability_idx sec_cap_idx;
8564 sec_cap_idx.action = ut_params->type;
8565 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8566 sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8567 if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8568 return TEST_SKIPPED;
8570 if (fragsz > input_vec_len)
8571 fragsz = input_vec_len;
8573 uint16_t plaintext_len = fragsz;
8574 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8576 if (fragsz_oop > output_vec_len)
8577 frag_size_oop = output_vec_len;
8580 if (input_vec_len % fragsz != 0) {
8581 if (input_vec_len / fragsz + 1 > 16)
8583 } else if (input_vec_len / fragsz > 16)
8586 /* Out of place support */
8589 * For out-op-place we need to alloc another mbuf
8591 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8592 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8593 buf_oop = ut_params->obuf;
8596 /* Generate test mbuf data */
8597 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8599 /* clear mbuf payload */
8600 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8601 rte_pktmbuf_tailroom(ut_params->ibuf));
8603 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8605 memcpy(plaintext, input_vec, plaintext_len);
8606 trn_data += plaintext_len;
8608 buf = ut_params->ibuf;
8611 * Loop until no more fragments
8614 while (trn_data < input_vec_len) {
8616 to_trn = (input_vec_len - trn_data < fragsz) ?
8617 (input_vec_len - trn_data) : fragsz;
8619 to_trn_tbl[ecx++] = to_trn;
8621 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8624 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8625 rte_pktmbuf_tailroom(buf));
8628 if (oop && !fragsz_oop) {
8630 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8631 buf_oop = buf_oop->next;
8632 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8633 0, rte_pktmbuf_tailroom(buf_oop));
8634 rte_pktmbuf_append(buf_oop, to_trn);
8637 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8640 memcpy(plaintext, input_vec + trn_data, to_trn);
8644 ut_params->ibuf->nb_segs = segs;
8647 if (fragsz_oop && oop) {
8651 trn_data = frag_size_oop;
8652 while (trn_data < output_vec_len) {
8655 (output_vec_len - trn_data <
8657 (output_vec_len - trn_data) :
8660 to_trn_tbl[ecx++] = to_trn;
8663 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8664 buf_oop = buf_oop->next;
8665 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8666 0, rte_pktmbuf_tailroom(buf_oop));
8667 rte_pktmbuf_append(buf_oop, to_trn);
8671 ut_params->obuf->nb_segs = segs;
8674 /* Setup Cipher Parameters */
8675 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8676 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8677 ut_params->cipher_xform.cipher.op = opc;
8678 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8679 ut_params->cipher_xform.cipher.key.length =
8680 pdcp_test_params[i].cipher_key_len;
8681 ut_params->cipher_xform.cipher.iv.length = 0;
8683 /* Setup HMAC Parameters if ICV header is required */
8684 if (pdcp_test_params[i].auth_alg != 0) {
8685 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8686 ut_params->auth_xform.next = NULL;
8687 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8688 ut_params->auth_xform.auth.op = opa;
8689 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8690 ut_params->auth_xform.auth.key.length =
8691 pdcp_test_params[i].auth_key_len;
8693 ut_params->cipher_xform.next = &ut_params->auth_xform;
8695 ut_params->cipher_xform.next = NULL;
8698 struct rte_security_session_conf sess_conf = {
8699 .action_type = ut_params->type,
8700 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8702 .bearer = pdcp_test_bearer[i],
8703 .domain = pdcp_test_params[i].domain,
8704 .pkt_dir = pdcp_test_packet_direction[i],
8705 .sn_size = pdcp_test_data_sn_size[i],
8706 .hfn = pdcp_test_hfn[i],
8707 .hfn_threshold = pdcp_test_hfn_threshold[i],
8710 .crypto_xform = &ut_params->cipher_xform
8713 /* Create security session */
8714 ut_params->sec_session = rte_security_session_create(ctx,
8715 &sess_conf, ts_params->session_mpool,
8716 ts_params->session_priv_mpool);
8718 if (!ut_params->sec_session) {
8719 printf("TestCase %s()-%d line %d failed %s: ",
8720 __func__, i, __LINE__, "Failed to allocate session");
8725 /* Generate crypto op data structure */
8726 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8727 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8728 if (!ut_params->op) {
8729 printf("TestCase %s()-%d line %d failed %s: ",
8730 __func__, i, __LINE__,
8731 "Failed to allocate symmetric crypto operation struct");
8736 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8738 /* set crypto operation source mbuf */
8739 ut_params->op->sym->m_src = ut_params->ibuf;
8741 ut_params->op->sym->m_dst = ut_params->obuf;
8743 /* Process crypto operation */
8744 temp_mbuf = ut_params->op->sym->m_src;
8745 if (global_api_test_type == CRYPTODEV_RAW_API_TEST) {
8746 /* filling lengths */
8748 ut_params->op->sym->cipher.data.length
8749 += temp_mbuf->pkt_len;
8750 ut_params->op->sym->auth.data.length
8751 += temp_mbuf->pkt_len;
8752 temp_mbuf = temp_mbuf->next;
8754 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8755 ut_params->op, 1, 1, 0, 0);
8757 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8760 if (ut_params->op == NULL) {
8761 printf("TestCase %s()-%d line %d failed %s: ",
8762 __func__, i, __LINE__,
8763 "failed to process sym crypto op");
8768 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8769 printf("TestCase %s()-%d line %d failed %s: ",
8770 __func__, i, __LINE__, "crypto op processing failed");
8776 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8779 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8783 fragsz = frag_size_oop;
8784 if (memcmp(ciphertext, output_vec, fragsz)) {
8785 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8786 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8787 rte_hexdump(stdout, "reference", output_vec, fragsz);
8792 buf = ut_params->op->sym->m_src->next;
8794 buf = ut_params->op->sym->m_dst->next;
8796 unsigned int off = fragsz;
8800 ciphertext = rte_pktmbuf_mtod(buf,
8802 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8803 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8804 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8805 rte_hexdump(stdout, "reference", output_vec + off,
8810 off += to_trn_tbl[ecx++];
8814 rte_crypto_op_free(ut_params->op);
8815 ut_params->op = NULL;
8817 if (ut_params->sec_session)
8818 rte_security_session_destroy(ctx, ut_params->sec_session);
8819 ut_params->sec_session = NULL;
8821 rte_pktmbuf_free(ut_params->ibuf);
8822 ut_params->ibuf = NULL;
8824 rte_pktmbuf_free(ut_params->obuf);
8825 ut_params->obuf = NULL;
8832 test_pdcp_proto_cplane_encap(int i)
8834 return test_pdcp_proto(
8835 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8836 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8837 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8838 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8839 pdcp_test_params[i].cipher_key_len,
8840 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8841 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8842 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8843 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8844 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8848 test_pdcp_proto_uplane_encap(int i)
8850 return test_pdcp_proto(
8851 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8852 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8853 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8854 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8855 pdcp_test_params[i].cipher_key_len,
8856 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8857 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8858 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8859 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8860 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8864 test_pdcp_proto_uplane_encap_with_int(int i)
8866 return test_pdcp_proto(
8867 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8868 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8869 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8870 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8871 pdcp_test_params[i].cipher_key_len,
8872 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8873 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8874 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8875 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8876 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8880 test_pdcp_proto_cplane_decap(int i)
8882 return test_pdcp_proto(
8883 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8884 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8885 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8886 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8887 pdcp_test_params[i].cipher_key_len,
8888 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8889 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8890 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8891 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8892 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8896 test_pdcp_proto_uplane_decap(int i)
8898 return test_pdcp_proto(
8899 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8900 pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8901 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8902 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8903 pdcp_test_params[i].cipher_key_len,
8904 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8905 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8906 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8907 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8908 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8912 test_pdcp_proto_uplane_decap_with_int(int i)
8914 return test_pdcp_proto(
8915 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8916 pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8917 pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8918 pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8919 pdcp_test_params[i].cipher_key_len,
8920 pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8921 pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8922 pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8923 pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8924 pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8928 test_PDCP_PROTO_SGL_in_place_32B(void)
8930 /* i can be used for running any PDCP case
8931 * In this case it is uplane 12-bit AES-SNOW DL encap
8933 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8934 return test_pdcp_proto_SGL(i, IN_PLACE,
8935 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8936 RTE_CRYPTO_AUTH_OP_GENERATE,
8937 pdcp_test_data_in[i],
8938 pdcp_test_data_in_len[i],
8939 pdcp_test_data_out[i],
8940 pdcp_test_data_in_len[i]+4,
8944 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8946 /* i can be used for running any PDCP case
8947 * In this case it is uplane 18-bit NULL-NULL DL encap
8949 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8950 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8951 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8952 RTE_CRYPTO_AUTH_OP_GENERATE,
8953 pdcp_test_data_in[i],
8954 pdcp_test_data_in_len[i],
8955 pdcp_test_data_out[i],
8956 pdcp_test_data_in_len[i]+4,
8960 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8962 /* i can be used for running any PDCP case
8963 * In this case it is uplane 18-bit AES DL encap
8965 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8967 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8968 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8969 RTE_CRYPTO_AUTH_OP_GENERATE,
8970 pdcp_test_data_in[i],
8971 pdcp_test_data_in_len[i],
8972 pdcp_test_data_out[i],
8973 pdcp_test_data_in_len[i],
8977 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8979 /* i can be used for running any PDCP case
8980 * In this case it is cplane 12-bit AES-ZUC DL encap
8982 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8983 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8984 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8985 RTE_CRYPTO_AUTH_OP_GENERATE,
8986 pdcp_test_data_in[i],
8987 pdcp_test_data_in_len[i],
8988 pdcp_test_data_out[i],
8989 pdcp_test_data_in_len[i]+4,
8994 test_PDCP_SDAP_PROTO_encap_all(void)
8996 int i = 0, size = 0;
8997 int err, all_err = TEST_SUCCESS;
8998 const struct pdcp_sdap_test *cur_test;
9000 size = RTE_DIM(list_pdcp_sdap_tests);
9002 for (i = 0; i < size; i++) {
9003 cur_test = &list_pdcp_sdap_tests[i];
9004 err = test_pdcp_proto(
9005 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9006 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9007 cur_test->in_len, cur_test->data_out,
9008 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9009 cur_test->param.cipher_alg, cur_test->cipher_key,
9010 cur_test->param.cipher_key_len,
9011 cur_test->param.auth_alg,
9012 cur_test->auth_key, cur_test->param.auth_key_len,
9013 cur_test->bearer, cur_test->param.domain,
9014 cur_test->packet_direction, cur_test->sn_size,
9016 cur_test->hfn_threshold, SDAP_ENABLED);
9018 printf("\t%d) %s: Encapsulation failed\n",
9020 cur_test->param.name);
9023 printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
9024 cur_test->param.name);
9030 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9032 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9036 test_PDCP_PROTO_short_mac(void)
9038 int i = 0, size = 0;
9039 int err, all_err = TEST_SUCCESS;
9040 const struct pdcp_short_mac_test *cur_test;
9042 size = RTE_DIM(list_pdcp_smac_tests);
9044 for (i = 0; i < size; i++) {
9045 cur_test = &list_pdcp_smac_tests[i];
9046 err = test_pdcp_proto(
9047 i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
9048 RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
9049 cur_test->in_len, cur_test->data_out,
9050 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9051 RTE_CRYPTO_CIPHER_NULL, NULL,
9052 0, cur_test->param.auth_alg,
9053 cur_test->auth_key, cur_test->param.auth_key_len,
9054 0, cur_test->param.domain, 0, 0,
9057 printf("\t%d) %s: Short MAC test failed\n",
9059 cur_test->param.name);
9062 printf("\t%d) %s: Short MAC test PASS\n",
9064 cur_test->param.name);
9065 rte_hexdump(stdout, "MAC I",
9066 cur_test->data_out + cur_test->in_len + 2,
9073 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9075 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9080 test_PDCP_SDAP_PROTO_decap_all(void)
9082 int i = 0, size = 0;
9083 int err, all_err = TEST_SUCCESS;
9084 const struct pdcp_sdap_test *cur_test;
9086 size = RTE_DIM(list_pdcp_sdap_tests);
9088 for (i = 0; i < size; i++) {
9089 cur_test = &list_pdcp_sdap_tests[i];
9090 err = test_pdcp_proto(
9091 i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
9092 RTE_CRYPTO_AUTH_OP_VERIFY,
9094 cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
9095 cur_test->data_in, cur_test->in_len,
9096 cur_test->param.cipher_alg,
9097 cur_test->cipher_key, cur_test->param.cipher_key_len,
9098 cur_test->param.auth_alg, cur_test->auth_key,
9099 cur_test->param.auth_key_len, cur_test->bearer,
9100 cur_test->param.domain, cur_test->packet_direction,
9101 cur_test->sn_size, cur_test->hfn,
9102 cur_test->hfn_threshold, SDAP_ENABLED);
9104 printf("\t%d) %s: Decapsulation failed\n",
9106 cur_test->param.name);
9109 printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
9110 cur_test->param.name);
9116 printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
9118 return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
9122 test_ipsec_proto_process(const struct ipsec_test_data td[],
9123 struct ipsec_test_data res_d[],
9126 const struct ipsec_test_flags *flags)
9128 uint16_t v6_src[8] = {0x2607, 0xf8b0, 0x400c, 0x0c03, 0x0000, 0x0000,
9130 uint16_t v6_dst[8] = {0x2001, 0x0470, 0xe5bf, 0xdead, 0x4957, 0x2174,
9132 struct crypto_testsuite_params *ts_params = &testsuite_params;
9133 struct crypto_unittest_params *ut_params = &unittest_params;
9134 struct rte_security_capability_idx sec_cap_idx;
9135 const struct rte_security_capability *sec_cap;
9136 struct rte_security_ipsec_xform ipsec_xform;
9137 uint8_t dev_id = ts_params->valid_devs[0];
9138 enum rte_security_ipsec_sa_direction dir;
9139 struct ipsec_test_data *res_d_tmp = NULL;
9140 uint32_t src = RTE_IPV4(192, 168, 1, 0);
9141 uint32_t dst = RTE_IPV4(192, 168, 1, 1);
9142 int salt_len, i, ret = TEST_SUCCESS;
9143 struct rte_security_ctx *ctx;
9144 uint8_t *input_text;
9147 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9148 gbl_action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
9150 /* Use first test data to create session */
9152 /* Copy IPsec xform */
9153 memcpy(&ipsec_xform, &td[0].ipsec_xform, sizeof(ipsec_xform));
9155 dir = ipsec_xform.direction;
9156 verify = flags->tunnel_hdr_verify;
9158 if ((dir == RTE_SECURITY_IPSEC_SA_DIR_INGRESS) && verify) {
9159 if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR)
9161 else if (verify == RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR)
9165 if (td->ipsec_xform.mode == RTE_SECURITY_IPSEC_SA_MODE_TUNNEL) {
9166 if (td->ipsec_xform.tunnel.type ==
9167 RTE_SECURITY_IPSEC_TUNNEL_IPV4) {
9168 memcpy(&ipsec_xform.tunnel.ipv4.src_ip, &src,
9170 memcpy(&ipsec_xform.tunnel.ipv4.dst_ip, &dst,
9173 if (flags->df == TEST_IPSEC_SET_DF_0_INNER_1)
9174 ipsec_xform.tunnel.ipv4.df = 0;
9176 if (flags->df == TEST_IPSEC_SET_DF_1_INNER_0)
9177 ipsec_xform.tunnel.ipv4.df = 1;
9180 memcpy(&ipsec_xform.tunnel.ipv6.src_addr, &v6_src,
9182 memcpy(&ipsec_xform.tunnel.ipv6.dst_addr, &v6_dst,
9187 ctx = rte_cryptodev_get_sec_ctx(dev_id);
9189 sec_cap_idx.action = ut_params->type;
9190 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_IPSEC;
9191 sec_cap_idx.ipsec.proto = ipsec_xform.proto;
9192 sec_cap_idx.ipsec.mode = ipsec_xform.mode;
9193 sec_cap_idx.ipsec.direction = ipsec_xform.direction;
9195 if (flags->udp_encap)
9196 ipsec_xform.options.udp_encap = 1;
9198 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9199 if (sec_cap == NULL)
9200 return TEST_SKIPPED;
9202 /* Copy cipher session parameters */
9204 memcpy(&ut_params->aead_xform, &td[0].xform.aead,
9205 sizeof(ut_params->aead_xform));
9206 ut_params->aead_xform.aead.key.data = td[0].key.data;
9207 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
9209 /* Verify crypto capabilities */
9210 if (test_ipsec_crypto_caps_aead_verify(
9212 &ut_params->aead_xform) != 0) {
9214 RTE_LOG(INFO, USER1,
9215 "Crypto capabilities not supported\n");
9216 return TEST_SKIPPED;
9219 memcpy(&ut_params->cipher_xform, &td[0].xform.chain.cipher,
9220 sizeof(ut_params->cipher_xform));
9221 memcpy(&ut_params->auth_xform, &td[0].xform.chain.auth,
9222 sizeof(ut_params->auth_xform));
9223 ut_params->cipher_xform.cipher.key.data = td[0].key.data;
9224 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9225 ut_params->auth_xform.auth.key.data = td[0].auth_key.data;
9227 /* Verify crypto capabilities */
9229 if (test_ipsec_crypto_caps_cipher_verify(
9231 &ut_params->cipher_xform) != 0) {
9233 RTE_LOG(INFO, USER1,
9234 "Cipher crypto capabilities not supported\n");
9235 return TEST_SKIPPED;
9238 if (test_ipsec_crypto_caps_auth_verify(
9240 &ut_params->auth_xform) != 0) {
9242 RTE_LOG(INFO, USER1,
9243 "Auth crypto capabilities not supported\n");
9244 return TEST_SKIPPED;
9248 if (test_ipsec_sec_caps_verify(&ipsec_xform, sec_cap, silent) != 0)
9249 return TEST_SKIPPED;
9251 struct rte_security_session_conf sess_conf = {
9252 .action_type = ut_params->type,
9253 .protocol = RTE_SECURITY_PROTOCOL_IPSEC,
9257 salt_len = RTE_MIN(sizeof(ipsec_xform.salt), td[0].salt.len);
9258 memcpy(&ipsec_xform.salt, td[0].salt.data, salt_len);
9259 sess_conf.ipsec = ipsec_xform;
9260 sess_conf.crypto_xform = &ut_params->aead_xform;
9262 sess_conf.ipsec = ipsec_xform;
9263 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS) {
9264 sess_conf.crypto_xform = &ut_params->cipher_xform;
9265 ut_params->cipher_xform.next = &ut_params->auth_xform;
9267 sess_conf.crypto_xform = &ut_params->auth_xform;
9268 ut_params->auth_xform.next = &ut_params->cipher_xform;
9272 /* Create security session */
9273 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9274 ts_params->session_mpool,
9275 ts_params->session_priv_mpool);
9277 if (ut_params->sec_session == NULL)
9278 return TEST_SKIPPED;
9280 for (i = 0; i < nb_td; i++) {
9281 /* Setup source mbuf payload */
9282 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9283 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9284 rte_pktmbuf_tailroom(ut_params->ibuf));
9286 input_text = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9287 td[i].input_text.len);
9289 memcpy(input_text, td[i].input_text.data,
9290 td[i].input_text.len);
9292 if (test_ipsec_pkt_update(input_text, flags))
9295 /* Generate crypto op data structure */
9296 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9297 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9298 if (!ut_params->op) {
9299 printf("TestCase %s line %d: %s\n",
9301 "failed to allocate crypto op");
9303 goto crypto_op_free;
9306 /* Attach session to operation */
9307 rte_security_attach_session(ut_params->op,
9308 ut_params->sec_session);
9310 /* Set crypto operation mbufs */
9311 ut_params->op->sym->m_src = ut_params->ibuf;
9312 ut_params->op->sym->m_dst = NULL;
9314 /* Copy IV in crypto operation when IV generation is disabled */
9315 if (dir == RTE_SECURITY_IPSEC_SA_DIR_EGRESS &&
9316 ipsec_xform.options.iv_gen_disable == 1) {
9317 uint8_t *iv = rte_crypto_op_ctod_offset(ut_params->op,
9323 len = td[i].xform.aead.aead.iv.length;
9325 len = td[i].xform.chain.cipher.cipher.iv.length;
9327 memcpy(iv, td[i].iv.data, len);
9330 /* Process crypto operation */
9331 process_crypto_request(dev_id, ut_params->op);
9333 ret = test_ipsec_status_check(ut_params->op, flags, dir, i + 1);
9334 if (ret != TEST_SUCCESS)
9335 goto crypto_op_free;
9338 res_d_tmp = &res_d[i];
9340 ret = test_ipsec_post_process(ut_params->ibuf, &td[i],
9341 res_d_tmp, silent, flags);
9342 if (ret != TEST_SUCCESS)
9343 goto crypto_op_free;
9345 ret = test_ipsec_stats_verify(ctx, ut_params->sec_session,
9347 if (ret != TEST_SUCCESS)
9348 goto crypto_op_free;
9350 rte_crypto_op_free(ut_params->op);
9351 ut_params->op = NULL;
9353 rte_pktmbuf_free(ut_params->ibuf);
9354 ut_params->ibuf = NULL;
9358 rte_crypto_op_free(ut_params->op);
9359 ut_params->op = NULL;
9361 rte_pktmbuf_free(ut_params->ibuf);
9362 ut_params->ibuf = NULL;
9364 if (ut_params->sec_session)
9365 rte_security_session_destroy(ctx, ut_params->sec_session);
9366 ut_params->sec_session = NULL;
9372 test_ipsec_proto_known_vec(const void *test_data)
9374 struct ipsec_test_data td_outb;
9375 struct ipsec_test_flags flags;
9377 memset(&flags, 0, sizeof(flags));
9379 memcpy(&td_outb, test_data, sizeof(td_outb));
9382 td_outb.xform.chain.cipher.cipher.algo != RTE_CRYPTO_CIPHER_NULL) {
9383 /* Disable IV gen to be able to test with known vectors */
9384 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9387 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9391 test_ipsec_proto_known_vec_inb(const void *test_data)
9393 const struct ipsec_test_data *td = test_data;
9394 struct ipsec_test_flags flags;
9395 struct ipsec_test_data td_inb;
9397 memset(&flags, 0, sizeof(flags));
9399 if (td->ipsec_xform.direction == RTE_SECURITY_IPSEC_SA_DIR_EGRESS)
9400 test_ipsec_td_in_from_out(td, &td_inb);
9402 memcpy(&td_inb, td, sizeof(td_inb));
9404 return test_ipsec_proto_process(&td_inb, NULL, 1, false, &flags);
9408 test_ipsec_proto_known_vec_fragmented(const void *test_data)
9410 struct ipsec_test_data td_outb;
9411 struct ipsec_test_flags flags;
9413 memset(&flags, 0, sizeof(flags));
9414 flags.fragment = true;
9416 memcpy(&td_outb, test_data, sizeof(td_outb));
9418 /* Disable IV gen to be able to test with known vectors */
9419 td_outb.ipsec_xform.options.iv_gen_disable = 1;
9421 return test_ipsec_proto_process(&td_outb, NULL, 1, false, &flags);
9425 test_ipsec_proto_all(const struct ipsec_test_flags *flags)
9427 struct ipsec_test_data td_outb[IPSEC_TEST_PACKETS_MAX];
9428 struct ipsec_test_data td_inb[IPSEC_TEST_PACKETS_MAX];
9429 unsigned int i, nb_pkts = 1, pass_cnt = 0;
9432 if (flags->iv_gen ||
9433 flags->sa_expiry_pkts_soft ||
9434 flags->sa_expiry_pkts_hard)
9435 nb_pkts = IPSEC_TEST_PACKETS_MAX;
9437 for (i = 0; i < RTE_DIM(alg_list); i++) {
9438 test_ipsec_td_prepare(alg_list[i].param1,
9444 if (!td_outb->aead) {
9445 enum rte_crypto_cipher_algorithm cipher_alg;
9446 enum rte_crypto_auth_algorithm auth_alg;
9448 cipher_alg = td_outb->xform.chain.cipher.cipher.algo;
9449 auth_alg = td_outb->xform.chain.auth.auth.algo;
9451 /* ICV is not applicable for NULL auth */
9452 if (flags->icv_corrupt &&
9453 auth_alg == RTE_CRYPTO_AUTH_NULL)
9456 /* IV is not applicable for NULL cipher */
9457 if (flags->iv_gen &&
9458 cipher_alg == RTE_CRYPTO_CIPHER_NULL)
9462 ret = test_ipsec_proto_process(td_outb, td_inb, nb_pkts, true,
9464 if (ret == TEST_SKIPPED)
9467 if (ret == TEST_FAILED)
9470 test_ipsec_td_update(td_inb, td_outb, nb_pkts, flags);
9472 ret = test_ipsec_proto_process(td_inb, NULL, nb_pkts, true,
9474 if (ret == TEST_SKIPPED)
9477 if (ret == TEST_FAILED)
9480 if (flags->display_alg)
9481 test_ipsec_display_alg(alg_list[i].param1,
9482 alg_list[i].param2);
9488 return TEST_SUCCESS;
9490 return TEST_SKIPPED;
9494 test_ipsec_proto_display_list(const void *data __rte_unused)
9496 struct ipsec_test_flags flags;
9498 memset(&flags, 0, sizeof(flags));
9500 flags.display_alg = true;
9502 return test_ipsec_proto_all(&flags);
9506 test_ipsec_proto_iv_gen(const void *data __rte_unused)
9508 struct ipsec_test_flags flags;
9510 memset(&flags, 0, sizeof(flags));
9512 flags.iv_gen = true;
9514 return test_ipsec_proto_all(&flags);
9518 test_ipsec_proto_sa_exp_pkts_soft(const void *data __rte_unused)
9520 struct ipsec_test_flags flags;
9522 memset(&flags, 0, sizeof(flags));
9524 flags.sa_expiry_pkts_soft = true;
9526 return test_ipsec_proto_all(&flags);
9530 test_ipsec_proto_sa_exp_pkts_hard(const void *data __rte_unused)
9532 struct ipsec_test_flags flags;
9534 memset(&flags, 0, sizeof(flags));
9536 flags.sa_expiry_pkts_hard = true;
9538 return test_ipsec_proto_all(&flags);
9542 test_ipsec_proto_err_icv_corrupt(const void *data __rte_unused)
9544 struct ipsec_test_flags flags;
9546 memset(&flags, 0, sizeof(flags));
9548 flags.icv_corrupt = true;
9550 return test_ipsec_proto_all(&flags);
9554 test_ipsec_proto_udp_encap(const void *data __rte_unused)
9556 struct ipsec_test_flags flags;
9558 memset(&flags, 0, sizeof(flags));
9560 flags.udp_encap = true;
9562 return test_ipsec_proto_all(&flags);
9566 test_ipsec_proto_tunnel_src_dst_addr_verify(const void *data __rte_unused)
9568 struct ipsec_test_flags flags;
9570 memset(&flags, 0, sizeof(flags));
9572 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_SRC_DST_ADDR;
9574 return test_ipsec_proto_all(&flags);
9578 test_ipsec_proto_tunnel_dst_addr_verify(const void *data __rte_unused)
9580 struct ipsec_test_flags flags;
9582 memset(&flags, 0, sizeof(flags));
9584 flags.tunnel_hdr_verify = RTE_SECURITY_IPSEC_TUNNEL_VERIFY_DST_ADDR;
9586 return test_ipsec_proto_all(&flags);
9590 test_ipsec_proto_udp_ports_verify(const void *data __rte_unused)
9592 struct ipsec_test_flags flags;
9594 memset(&flags, 0, sizeof(flags));
9596 flags.udp_encap = true;
9597 flags.udp_ports_verify = true;
9599 return test_ipsec_proto_all(&flags);
9603 test_ipsec_proto_inner_ip_csum(const void *data __rte_unused)
9605 struct ipsec_test_flags flags;
9607 memset(&flags, 0, sizeof(flags));
9609 flags.ip_csum = true;
9611 return test_ipsec_proto_all(&flags);
9615 test_ipsec_proto_inner_l4_csum(const void *data __rte_unused)
9617 struct ipsec_test_flags flags;
9619 memset(&flags, 0, sizeof(flags));
9621 flags.l4_csum = true;
9623 return test_ipsec_proto_all(&flags);
9627 test_ipsec_proto_tunnel_v4_in_v4(const void *data __rte_unused)
9629 struct ipsec_test_flags flags;
9631 memset(&flags, 0, sizeof(flags));
9634 flags.tunnel_ipv6 = false;
9636 return test_ipsec_proto_all(&flags);
9640 test_ipsec_proto_tunnel_v6_in_v6(const void *data __rte_unused)
9642 struct ipsec_test_flags flags;
9644 memset(&flags, 0, sizeof(flags));
9647 flags.tunnel_ipv6 = true;
9649 return test_ipsec_proto_all(&flags);
9653 test_ipsec_proto_tunnel_v4_in_v6(const void *data __rte_unused)
9655 struct ipsec_test_flags flags;
9657 memset(&flags, 0, sizeof(flags));
9660 flags.tunnel_ipv6 = true;
9662 return test_ipsec_proto_all(&flags);
9666 test_ipsec_proto_tunnel_v6_in_v4(const void *data __rte_unused)
9668 struct ipsec_test_flags flags;
9670 memset(&flags, 0, sizeof(flags));
9673 flags.tunnel_ipv6 = false;
9675 return test_ipsec_proto_all(&flags);
9679 test_ipsec_proto_transport_v4(const void *data __rte_unused)
9681 struct ipsec_test_flags flags;
9683 memset(&flags, 0, sizeof(flags));
9686 flags.transport = true;
9688 return test_ipsec_proto_all(&flags);
9692 test_ipsec_proto_stats(const void *data __rte_unused)
9694 struct ipsec_test_flags flags;
9696 memset(&flags, 0, sizeof(flags));
9698 flags.stats_success = true;
9700 return test_ipsec_proto_all(&flags);
9704 test_ipsec_proto_pkt_fragment(const void *data __rte_unused)
9706 struct ipsec_test_flags flags;
9708 memset(&flags, 0, sizeof(flags));
9710 flags.fragment = true;
9712 return test_ipsec_proto_all(&flags);
9717 test_ipsec_proto_copy_df_inner_0(const void *data __rte_unused)
9719 struct ipsec_test_flags flags;
9721 memset(&flags, 0, sizeof(flags));
9723 flags.df = TEST_IPSEC_COPY_DF_INNER_0;
9725 return test_ipsec_proto_all(&flags);
9729 test_ipsec_proto_copy_df_inner_1(const void *data __rte_unused)
9731 struct ipsec_test_flags flags;
9733 memset(&flags, 0, sizeof(flags));
9735 flags.df = TEST_IPSEC_COPY_DF_INNER_1;
9737 return test_ipsec_proto_all(&flags);
9741 test_ipsec_proto_set_df_0_inner_1(const void *data __rte_unused)
9743 struct ipsec_test_flags flags;
9745 memset(&flags, 0, sizeof(flags));
9747 flags.df = TEST_IPSEC_SET_DF_0_INNER_1;
9749 return test_ipsec_proto_all(&flags);
9753 test_ipsec_proto_set_df_1_inner_0(const void *data __rte_unused)
9755 struct ipsec_test_flags flags;
9757 memset(&flags, 0, sizeof(flags));
9759 flags.df = TEST_IPSEC_SET_DF_1_INNER_0;
9761 return test_ipsec_proto_all(&flags);
9765 test_PDCP_PROTO_all(void)
9767 struct crypto_testsuite_params *ts_params = &testsuite_params;
9768 struct crypto_unittest_params *ut_params = &unittest_params;
9769 struct rte_cryptodev_info dev_info;
9772 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9773 uint64_t feat_flags = dev_info.feature_flags;
9775 if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9776 return TEST_SKIPPED;
9778 /* Set action type */
9779 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9780 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9783 if (security_proto_supported(ut_params->type,
9784 RTE_SECURITY_PROTOCOL_PDCP) < 0)
9785 return TEST_SKIPPED;
9787 status = test_PDCP_PROTO_cplane_encap_all();
9788 status += test_PDCP_PROTO_cplane_decap_all();
9789 status += test_PDCP_PROTO_uplane_encap_all();
9790 status += test_PDCP_PROTO_uplane_decap_all();
9791 status += test_PDCP_PROTO_SGL_in_place_32B();
9792 status += test_PDCP_PROTO_SGL_oop_32B_128B();
9793 status += test_PDCP_PROTO_SGL_oop_32B_40B();
9794 status += test_PDCP_PROTO_SGL_oop_128B_32B();
9795 status += test_PDCP_SDAP_PROTO_encap_all();
9796 status += test_PDCP_SDAP_PROTO_decap_all();
9797 status += test_PDCP_PROTO_short_mac();
9802 return TEST_SUCCESS;
9806 test_docsis_proto_uplink(const void *data)
9808 const struct docsis_test_data *d_td = data;
9809 struct crypto_testsuite_params *ts_params = &testsuite_params;
9810 struct crypto_unittest_params *ut_params = &unittest_params;
9811 uint8_t *plaintext = NULL;
9812 uint8_t *ciphertext = NULL;
9814 int32_t cipher_len, crc_len;
9815 uint32_t crc_data_len;
9816 int ret = TEST_SUCCESS;
9818 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9819 rte_cryptodev_get_sec_ctx(
9820 ts_params->valid_devs[0]);
9822 /* Verify the capabilities */
9823 struct rte_security_capability_idx sec_cap_idx;
9824 const struct rte_security_capability *sec_cap;
9825 const struct rte_cryptodev_capabilities *crypto_cap;
9826 const struct rte_cryptodev_symmetric_capability *sym_cap;
9829 /* Set action type */
9830 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9831 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9834 if (security_proto_supported(ut_params->type,
9835 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9836 return TEST_SKIPPED;
9838 sec_cap_idx.action = ut_params->type;
9839 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9840 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
9842 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9843 if (sec_cap == NULL)
9844 return TEST_SKIPPED;
9846 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9847 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9848 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9849 crypto_cap->sym.xform_type ==
9850 RTE_CRYPTO_SYM_XFORM_CIPHER &&
9851 crypto_cap->sym.cipher.algo ==
9852 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9853 sym_cap = &crypto_cap->sym;
9854 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9861 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9862 return TEST_SKIPPED;
9864 /* Setup source mbuf payload */
9865 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9866 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9867 rte_pktmbuf_tailroom(ut_params->ibuf));
9869 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9870 d_td->ciphertext.len);
9872 memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
9874 /* Setup cipher session parameters */
9875 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9876 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9877 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
9878 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9879 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9880 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9881 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9882 ut_params->cipher_xform.next = NULL;
9884 /* Setup DOCSIS session parameters */
9885 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
9887 struct rte_security_session_conf sess_conf = {
9888 .action_type = ut_params->type,
9889 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9890 .docsis = ut_params->docsis_xform,
9891 .crypto_xform = &ut_params->cipher_xform,
9894 /* Create security session */
9895 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9896 ts_params->session_mpool,
9897 ts_params->session_priv_mpool);
9899 if (!ut_params->sec_session) {
9900 printf("Test function %s line %u: failed to allocate session\n",
9901 __func__, __LINE__);
9906 /* Generate crypto op data structure */
9907 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9908 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9909 if (!ut_params->op) {
9910 printf("Test function %s line %u: failed to allocate symmetric "
9911 "crypto operation\n", __func__, __LINE__);
9916 /* Setup CRC operation parameters */
9917 crc_len = d_td->ciphertext.no_crc == false ?
9918 (d_td->ciphertext.len -
9919 d_td->ciphertext.crc_offset -
9920 RTE_ETHER_CRC_LEN) :
9922 crc_len = crc_len > 0 ? crc_len : 0;
9923 crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
9924 ut_params->op->sym->auth.data.length = crc_len;
9925 ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
9927 /* Setup cipher operation parameters */
9928 cipher_len = d_td->ciphertext.no_cipher == false ?
9929 (d_td->ciphertext.len -
9930 d_td->ciphertext.cipher_offset) :
9932 cipher_len = cipher_len > 0 ? cipher_len : 0;
9933 ut_params->op->sym->cipher.data.length = cipher_len;
9934 ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
9936 /* Setup cipher IV */
9937 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9938 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9940 /* Attach session to operation */
9941 rte_security_attach_session(ut_params->op, ut_params->sec_session);
9943 /* Set crypto operation mbufs */
9944 ut_params->op->sym->m_src = ut_params->ibuf;
9945 ut_params->op->sym->m_dst = NULL;
9947 /* Process crypto operation */
9948 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9950 printf("Test function %s line %u: failed to process security "
9951 "crypto op\n", __func__, __LINE__);
9956 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9957 printf("Test function %s line %u: failed to process crypto op\n",
9958 __func__, __LINE__);
9963 /* Validate plaintext */
9964 plaintext = ciphertext;
9966 if (memcmp(plaintext, d_td->plaintext.data,
9967 d_td->plaintext.len - crc_data_len)) {
9968 printf("Test function %s line %u: plaintext not as expected\n",
9969 __func__, __LINE__);
9970 rte_hexdump(stdout, "expected", d_td->plaintext.data,
9971 d_td->plaintext.len);
9972 rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9978 rte_crypto_op_free(ut_params->op);
9979 ut_params->op = NULL;
9981 if (ut_params->sec_session)
9982 rte_security_session_destroy(ctx, ut_params->sec_session);
9983 ut_params->sec_session = NULL;
9985 rte_pktmbuf_free(ut_params->ibuf);
9986 ut_params->ibuf = NULL;
9992 test_docsis_proto_downlink(const void *data)
9994 const struct docsis_test_data *d_td = data;
9995 struct crypto_testsuite_params *ts_params = &testsuite_params;
9996 struct crypto_unittest_params *ut_params = &unittest_params;
9997 uint8_t *plaintext = NULL;
9998 uint8_t *ciphertext = NULL;
10000 int32_t cipher_len, crc_len;
10001 int ret = TEST_SUCCESS;
10003 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
10004 rte_cryptodev_get_sec_ctx(
10005 ts_params->valid_devs[0]);
10007 /* Verify the capabilities */
10008 struct rte_security_capability_idx sec_cap_idx;
10009 const struct rte_security_capability *sec_cap;
10010 const struct rte_cryptodev_capabilities *crypto_cap;
10011 const struct rte_cryptodev_symmetric_capability *sym_cap;
10014 /* Set action type */
10015 ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
10016 RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
10019 if (security_proto_supported(ut_params->type,
10020 RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
10021 return TEST_SKIPPED;
10023 sec_cap_idx.action = ut_params->type;
10024 sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
10025 sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10027 sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
10028 if (sec_cap == NULL)
10029 return TEST_SKIPPED;
10031 while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
10032 RTE_CRYPTO_OP_TYPE_UNDEFINED) {
10033 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
10034 crypto_cap->sym.xform_type ==
10035 RTE_CRYPTO_SYM_XFORM_CIPHER &&
10036 crypto_cap->sym.cipher.algo ==
10037 RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
10038 sym_cap = &crypto_cap->sym;
10039 if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
10041 d_td->iv.len) == 0)
10046 if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
10047 return TEST_SKIPPED;
10049 /* Setup source mbuf payload */
10050 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10051 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10052 rte_pktmbuf_tailroom(ut_params->ibuf));
10054 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10055 d_td->plaintext.len);
10057 memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
10059 /* Setup cipher session parameters */
10060 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10061 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
10062 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10063 ut_params->cipher_xform.cipher.key.data = d_td->key.data;
10064 ut_params->cipher_xform.cipher.key.length = d_td->key.len;
10065 ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
10066 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10067 ut_params->cipher_xform.next = NULL;
10069 /* Setup DOCSIS session parameters */
10070 ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
10072 struct rte_security_session_conf sess_conf = {
10073 .action_type = ut_params->type,
10074 .protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
10075 .docsis = ut_params->docsis_xform,
10076 .crypto_xform = &ut_params->cipher_xform,
10079 /* Create security session */
10080 ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
10081 ts_params->session_mpool,
10082 ts_params->session_priv_mpool);
10084 if (!ut_params->sec_session) {
10085 printf("Test function %s line %u: failed to allocate session\n",
10086 __func__, __LINE__);
10091 /* Generate crypto op data structure */
10092 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10093 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10094 if (!ut_params->op) {
10095 printf("Test function %s line %u: failed to allocate symmetric "
10096 "crypto operation\n", __func__, __LINE__);
10101 /* Setup CRC operation parameters */
10102 crc_len = d_td->plaintext.no_crc == false ?
10103 (d_td->plaintext.len -
10104 d_td->plaintext.crc_offset -
10105 RTE_ETHER_CRC_LEN) :
10107 crc_len = crc_len > 0 ? crc_len : 0;
10108 ut_params->op->sym->auth.data.length = crc_len;
10109 ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
10111 /* Setup cipher operation parameters */
10112 cipher_len = d_td->plaintext.no_cipher == false ?
10113 (d_td->plaintext.len -
10114 d_td->plaintext.cipher_offset) :
10116 cipher_len = cipher_len > 0 ? cipher_len : 0;
10117 ut_params->op->sym->cipher.data.length = cipher_len;
10118 ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
10120 /* Setup cipher IV */
10121 iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
10122 rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
10124 /* Attach session to operation */
10125 rte_security_attach_session(ut_params->op, ut_params->sec_session);
10127 /* Set crypto operation mbufs */
10128 ut_params->op->sym->m_src = ut_params->ibuf;
10129 ut_params->op->sym->m_dst = NULL;
10131 /* Process crypto operation */
10132 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
10134 printf("Test function %s line %u: failed to process crypto op\n",
10135 __func__, __LINE__);
10140 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
10141 printf("Test function %s line %u: crypto op processing failed\n",
10142 __func__, __LINE__);
10147 /* Validate ciphertext */
10148 ciphertext = plaintext;
10150 if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
10151 printf("Test function %s line %u: plaintext not as expected\n",
10152 __func__, __LINE__);
10153 rte_hexdump(stdout, "expected", d_td->ciphertext.data,
10154 d_td->ciphertext.len);
10155 rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
10161 rte_crypto_op_free(ut_params->op);
10162 ut_params->op = NULL;
10164 if (ut_params->sec_session)
10165 rte_security_session_destroy(ctx, ut_params->sec_session);
10166 ut_params->sec_session = NULL;
10168 rte_pktmbuf_free(ut_params->ibuf);
10169 ut_params->ibuf = NULL;
10176 test_AES_GCM_authenticated_encryption_test_case_1(void)
10178 return test_authenticated_encryption(&gcm_test_case_1);
10182 test_AES_GCM_authenticated_encryption_test_case_2(void)
10184 return test_authenticated_encryption(&gcm_test_case_2);
10188 test_AES_GCM_authenticated_encryption_test_case_3(void)
10190 return test_authenticated_encryption(&gcm_test_case_3);
10194 test_AES_GCM_authenticated_encryption_test_case_4(void)
10196 return test_authenticated_encryption(&gcm_test_case_4);
10200 test_AES_GCM_authenticated_encryption_test_case_5(void)
10202 return test_authenticated_encryption(&gcm_test_case_5);
10206 test_AES_GCM_authenticated_encryption_test_case_6(void)
10208 return test_authenticated_encryption(&gcm_test_case_6);
10212 test_AES_GCM_authenticated_encryption_test_case_7(void)
10214 return test_authenticated_encryption(&gcm_test_case_7);
10218 test_AES_GCM_authenticated_encryption_test_case_8(void)
10220 return test_authenticated_encryption(&gcm_test_case_8);
10224 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
10226 return test_authenticated_encryption(&gcm_J0_test_case_1);
10230 test_AES_GCM_auth_encryption_test_case_192_1(void)
10232 return test_authenticated_encryption(&gcm_test_case_192_1);
10236 test_AES_GCM_auth_encryption_test_case_192_2(void)
10238 return test_authenticated_encryption(&gcm_test_case_192_2);
10242 test_AES_GCM_auth_encryption_test_case_192_3(void)
10244 return test_authenticated_encryption(&gcm_test_case_192_3);
10248 test_AES_GCM_auth_encryption_test_case_192_4(void)
10250 return test_authenticated_encryption(&gcm_test_case_192_4);
10254 test_AES_GCM_auth_encryption_test_case_192_5(void)
10256 return test_authenticated_encryption(&gcm_test_case_192_5);
10260 test_AES_GCM_auth_encryption_test_case_192_6(void)
10262 return test_authenticated_encryption(&gcm_test_case_192_6);
10266 test_AES_GCM_auth_encryption_test_case_192_7(void)
10268 return test_authenticated_encryption(&gcm_test_case_192_7);
10272 test_AES_GCM_auth_encryption_test_case_256_1(void)
10274 return test_authenticated_encryption(&gcm_test_case_256_1);
10278 test_AES_GCM_auth_encryption_test_case_256_2(void)
10280 return test_authenticated_encryption(&gcm_test_case_256_2);
10284 test_AES_GCM_auth_encryption_test_case_256_3(void)
10286 return test_authenticated_encryption(&gcm_test_case_256_3);
10290 test_AES_GCM_auth_encryption_test_case_256_4(void)
10292 return test_authenticated_encryption(&gcm_test_case_256_4);
10296 test_AES_GCM_auth_encryption_test_case_256_5(void)
10298 return test_authenticated_encryption(&gcm_test_case_256_5);
10302 test_AES_GCM_auth_encryption_test_case_256_6(void)
10304 return test_authenticated_encryption(&gcm_test_case_256_6);
10308 test_AES_GCM_auth_encryption_test_case_256_7(void)
10310 return test_authenticated_encryption(&gcm_test_case_256_7);
10314 test_AES_GCM_auth_encryption_test_case_aad_1(void)
10316 return test_authenticated_encryption(&gcm_test_case_aad_1);
10320 test_AES_GCM_auth_encryption_test_case_aad_2(void)
10322 return test_authenticated_encryption(&gcm_test_case_aad_2);
10326 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
10328 struct aead_test_data tdata;
10331 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10332 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10333 tdata.iv.data[0] += 1;
10334 res = test_authenticated_encryption(&tdata);
10335 if (res == TEST_SKIPPED)
10337 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10338 return TEST_SUCCESS;
10342 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
10344 struct aead_test_data tdata;
10347 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10348 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10349 tdata.plaintext.data[0] += 1;
10350 res = test_authenticated_encryption(&tdata);
10351 if (res == TEST_SKIPPED)
10353 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10354 return TEST_SUCCESS;
10358 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
10360 struct aead_test_data tdata;
10363 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10364 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10365 tdata.ciphertext.data[0] += 1;
10366 res = test_authenticated_encryption(&tdata);
10367 if (res == TEST_SKIPPED)
10369 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10370 return TEST_SUCCESS;
10374 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
10376 struct aead_test_data tdata;
10379 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10380 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10381 tdata.aad.len += 1;
10382 res = test_authenticated_encryption(&tdata);
10383 if (res == TEST_SKIPPED)
10385 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10386 return TEST_SUCCESS;
10390 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
10392 struct aead_test_data tdata;
10393 uint8_t aad[gcm_test_case_7.aad.len];
10396 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10397 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10398 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10400 tdata.aad.data = aad;
10401 res = test_authenticated_encryption(&tdata);
10402 if (res == TEST_SKIPPED)
10404 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10405 return TEST_SUCCESS;
10409 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
10411 struct aead_test_data tdata;
10414 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10415 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10416 tdata.auth_tag.data[0] += 1;
10417 res = test_authenticated_encryption(&tdata);
10418 if (res == TEST_SKIPPED)
10420 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
10421 return TEST_SUCCESS;
10425 test_authenticated_decryption(const struct aead_test_data *tdata)
10427 struct crypto_testsuite_params *ts_params = &testsuite_params;
10428 struct crypto_unittest_params *ut_params = &unittest_params;
10431 uint8_t *plaintext;
10433 struct rte_cryptodev_info dev_info;
10435 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10436 uint64_t feat_flags = dev_info.feature_flags;
10438 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10439 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10440 printf("Device doesn't support RAW data-path APIs.\n");
10441 return TEST_SKIPPED;
10444 /* Verify the capabilities */
10445 struct rte_cryptodev_sym_capability_idx cap_idx;
10446 const struct rte_cryptodev_symmetric_capability *capability;
10447 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10448 cap_idx.algo.aead = tdata->algo;
10449 capability = rte_cryptodev_sym_capability_get(
10450 ts_params->valid_devs[0], &cap_idx);
10451 if (capability == NULL)
10452 return TEST_SKIPPED;
10453 if (rte_cryptodev_sym_capability_check_aead(
10454 capability, tdata->key.len, tdata->auth_tag.len,
10455 tdata->aad.len, tdata->iv.len))
10456 return TEST_SKIPPED;
10458 /* Create AEAD session */
10459 retval = create_aead_session(ts_params->valid_devs[0],
10461 RTE_CRYPTO_AEAD_OP_DECRYPT,
10462 tdata->key.data, tdata->key.len,
10463 tdata->aad.len, tdata->auth_tag.len,
10468 /* alloc mbuf and set payload */
10469 if (tdata->aad.len > MBUF_SIZE) {
10470 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10471 /* Populate full size of add data */
10472 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
10473 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
10475 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10477 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10478 rte_pktmbuf_tailroom(ut_params->ibuf));
10480 /* Create AEAD operation */
10481 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10485 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10487 ut_params->op->sym->m_src = ut_params->ibuf;
10489 /* Process crypto operation */
10490 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10491 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
10492 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10493 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10494 ut_params->op, 0, 0, 0, 0);
10496 TEST_ASSERT_NOT_NULL(
10497 process_crypto_request(ts_params->valid_devs[0],
10498 ut_params->op), "failed to process sym crypto op");
10500 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10501 "crypto op processing failed");
10503 if (ut_params->op->sym->m_dst)
10504 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
10507 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10509 ut_params->op->sym->cipher.data.offset);
10511 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10513 /* Validate obuf */
10514 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10516 tdata->plaintext.data,
10517 tdata->plaintext.len,
10518 "Plaintext data not as expected");
10520 TEST_ASSERT_EQUAL(ut_params->op->status,
10521 RTE_CRYPTO_OP_STATUS_SUCCESS,
10522 "Authentication failed");
10528 test_AES_GCM_authenticated_decryption_test_case_1(void)
10530 return test_authenticated_decryption(&gcm_test_case_1);
10534 test_AES_GCM_authenticated_decryption_test_case_2(void)
10536 return test_authenticated_decryption(&gcm_test_case_2);
10540 test_AES_GCM_authenticated_decryption_test_case_3(void)
10542 return test_authenticated_decryption(&gcm_test_case_3);
10546 test_AES_GCM_authenticated_decryption_test_case_4(void)
10548 return test_authenticated_decryption(&gcm_test_case_4);
10552 test_AES_GCM_authenticated_decryption_test_case_5(void)
10554 return test_authenticated_decryption(&gcm_test_case_5);
10558 test_AES_GCM_authenticated_decryption_test_case_6(void)
10560 return test_authenticated_decryption(&gcm_test_case_6);
10564 test_AES_GCM_authenticated_decryption_test_case_7(void)
10566 return test_authenticated_decryption(&gcm_test_case_7);
10570 test_AES_GCM_authenticated_decryption_test_case_8(void)
10572 return test_authenticated_decryption(&gcm_test_case_8);
10576 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
10578 return test_authenticated_decryption(&gcm_J0_test_case_1);
10582 test_AES_GCM_auth_decryption_test_case_192_1(void)
10584 return test_authenticated_decryption(&gcm_test_case_192_1);
10588 test_AES_GCM_auth_decryption_test_case_192_2(void)
10590 return test_authenticated_decryption(&gcm_test_case_192_2);
10594 test_AES_GCM_auth_decryption_test_case_192_3(void)
10596 return test_authenticated_decryption(&gcm_test_case_192_3);
10600 test_AES_GCM_auth_decryption_test_case_192_4(void)
10602 return test_authenticated_decryption(&gcm_test_case_192_4);
10606 test_AES_GCM_auth_decryption_test_case_192_5(void)
10608 return test_authenticated_decryption(&gcm_test_case_192_5);
10612 test_AES_GCM_auth_decryption_test_case_192_6(void)
10614 return test_authenticated_decryption(&gcm_test_case_192_6);
10618 test_AES_GCM_auth_decryption_test_case_192_7(void)
10620 return test_authenticated_decryption(&gcm_test_case_192_7);
10624 test_AES_GCM_auth_decryption_test_case_256_1(void)
10626 return test_authenticated_decryption(&gcm_test_case_256_1);
10630 test_AES_GCM_auth_decryption_test_case_256_2(void)
10632 return test_authenticated_decryption(&gcm_test_case_256_2);
10636 test_AES_GCM_auth_decryption_test_case_256_3(void)
10638 return test_authenticated_decryption(&gcm_test_case_256_3);
10642 test_AES_GCM_auth_decryption_test_case_256_4(void)
10644 return test_authenticated_decryption(&gcm_test_case_256_4);
10648 test_AES_GCM_auth_decryption_test_case_256_5(void)
10650 return test_authenticated_decryption(&gcm_test_case_256_5);
10654 test_AES_GCM_auth_decryption_test_case_256_6(void)
10656 return test_authenticated_decryption(&gcm_test_case_256_6);
10660 test_AES_GCM_auth_decryption_test_case_256_7(void)
10662 return test_authenticated_decryption(&gcm_test_case_256_7);
10666 test_AES_GCM_auth_decryption_test_case_aad_1(void)
10668 return test_authenticated_decryption(&gcm_test_case_aad_1);
10672 test_AES_GCM_auth_decryption_test_case_aad_2(void)
10674 return test_authenticated_decryption(&gcm_test_case_aad_2);
10678 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
10680 struct aead_test_data tdata;
10683 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10684 tdata.iv.data[0] += 1;
10685 res = test_authenticated_decryption(&tdata);
10686 if (res == TEST_SKIPPED)
10688 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10689 return TEST_SUCCESS;
10693 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
10695 struct aead_test_data tdata;
10698 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
10699 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10700 tdata.plaintext.data[0] += 1;
10701 res = test_authenticated_decryption(&tdata);
10702 if (res == TEST_SKIPPED)
10704 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10705 return TEST_SUCCESS;
10709 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
10711 struct aead_test_data tdata;
10714 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10715 tdata.ciphertext.data[0] += 1;
10716 res = test_authenticated_decryption(&tdata);
10717 if (res == TEST_SKIPPED)
10719 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10720 return TEST_SUCCESS;
10724 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
10726 struct aead_test_data tdata;
10729 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10730 tdata.aad.len += 1;
10731 res = test_authenticated_decryption(&tdata);
10732 if (res == TEST_SKIPPED)
10734 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10735 return TEST_SUCCESS;
10739 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
10741 struct aead_test_data tdata;
10742 uint8_t aad[gcm_test_case_7.aad.len];
10745 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10746 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
10748 tdata.aad.data = aad;
10749 res = test_authenticated_decryption(&tdata);
10750 if (res == TEST_SKIPPED)
10752 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
10753 return TEST_SUCCESS;
10757 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
10759 struct aead_test_data tdata;
10762 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
10763 tdata.auth_tag.data[0] += 1;
10764 res = test_authenticated_decryption(&tdata);
10765 if (res == TEST_SKIPPED)
10767 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
10768 return TEST_SUCCESS;
10772 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
10774 struct crypto_testsuite_params *ts_params = &testsuite_params;
10775 struct crypto_unittest_params *ut_params = &unittest_params;
10778 uint8_t *ciphertext, *auth_tag;
10779 uint16_t plaintext_pad_len;
10780 struct rte_cryptodev_info dev_info;
10782 /* Verify the capabilities */
10783 struct rte_cryptodev_sym_capability_idx cap_idx;
10784 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10785 cap_idx.algo.aead = tdata->algo;
10786 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10788 return TEST_SKIPPED;
10790 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10791 uint64_t feat_flags = dev_info.feature_flags;
10793 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10794 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP)))
10795 return TEST_SKIPPED;
10797 /* not supported with CPU crypto */
10798 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10799 return TEST_SKIPPED;
10801 /* Create AEAD session */
10802 retval = create_aead_session(ts_params->valid_devs[0],
10804 RTE_CRYPTO_AEAD_OP_ENCRYPT,
10805 tdata->key.data, tdata->key.len,
10806 tdata->aad.len, tdata->auth_tag.len,
10811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10812 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10814 /* clear mbuf payload */
10815 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10816 rte_pktmbuf_tailroom(ut_params->ibuf));
10817 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10818 rte_pktmbuf_tailroom(ut_params->obuf));
10820 /* Create AEAD operation */
10821 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10825 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10827 ut_params->op->sym->m_src = ut_params->ibuf;
10828 ut_params->op->sym->m_dst = ut_params->obuf;
10830 /* Process crypto operation */
10831 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10832 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10833 ut_params->op, 0, 0, 0, 0);
10835 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10836 ut_params->op), "failed to process sym crypto op");
10838 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10839 "crypto op processing failed");
10841 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10843 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10844 ut_params->op->sym->cipher.data.offset);
10845 auth_tag = ciphertext + plaintext_pad_len;
10847 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10848 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10850 /* Validate obuf */
10851 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10853 tdata->ciphertext.data,
10854 tdata->ciphertext.len,
10855 "Ciphertext data not as expected");
10857 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10859 tdata->auth_tag.data,
10860 tdata->auth_tag.len,
10861 "Generated auth tag not as expected");
10868 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10870 return test_authenticated_encryption_oop(&gcm_test_case_5);
10874 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10876 struct crypto_testsuite_params *ts_params = &testsuite_params;
10877 struct crypto_unittest_params *ut_params = &unittest_params;
10880 uint8_t *plaintext;
10881 struct rte_cryptodev_info dev_info;
10883 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10884 uint64_t feat_flags = dev_info.feature_flags;
10886 /* Verify the capabilities */
10887 struct rte_cryptodev_sym_capability_idx cap_idx;
10888 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10889 cap_idx.algo.aead = tdata->algo;
10890 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10892 return TEST_SKIPPED;
10894 /* not supported with CPU crypto and raw data-path APIs*/
10895 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10896 global_api_test_type == CRYPTODEV_RAW_API_TEST)
10897 return TEST_SKIPPED;
10899 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10900 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10901 printf("Device does not support RAW data-path APIs.\n");
10902 return TEST_SKIPPED;
10905 /* Create AEAD session */
10906 retval = create_aead_session(ts_params->valid_devs[0],
10908 RTE_CRYPTO_AEAD_OP_DECRYPT,
10909 tdata->key.data, tdata->key.len,
10910 tdata->aad.len, tdata->auth_tag.len,
10915 /* alloc mbuf and set payload */
10916 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10917 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10919 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10920 rte_pktmbuf_tailroom(ut_params->ibuf));
10921 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10922 rte_pktmbuf_tailroom(ut_params->obuf));
10924 /* Create AEAD operation */
10925 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10929 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10931 ut_params->op->sym->m_src = ut_params->ibuf;
10932 ut_params->op->sym->m_dst = ut_params->obuf;
10934 /* Process crypto operation */
10935 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10936 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10937 ut_params->op, 0, 0, 0, 0);
10939 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10940 ut_params->op), "failed to process sym crypto op");
10942 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10943 "crypto op processing failed");
10945 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10946 ut_params->op->sym->cipher.data.offset);
10948 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10950 /* Validate obuf */
10951 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10953 tdata->plaintext.data,
10954 tdata->plaintext.len,
10955 "Plaintext data not as expected");
10957 TEST_ASSERT_EQUAL(ut_params->op->status,
10958 RTE_CRYPTO_OP_STATUS_SUCCESS,
10959 "Authentication failed");
10964 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10966 return test_authenticated_decryption_oop(&gcm_test_case_5);
10970 test_authenticated_encryption_sessionless(
10971 const struct aead_test_data *tdata)
10973 struct crypto_testsuite_params *ts_params = &testsuite_params;
10974 struct crypto_unittest_params *ut_params = &unittest_params;
10977 uint8_t *ciphertext, *auth_tag;
10978 uint16_t plaintext_pad_len;
10979 uint8_t key[tdata->key.len + 1];
10980 struct rte_cryptodev_info dev_info;
10982 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10983 uint64_t feat_flags = dev_info.feature_flags;
10985 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10986 printf("Device doesn't support Sessionless ops.\n");
10987 return TEST_SKIPPED;
10990 /* not supported with CPU crypto */
10991 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10992 return TEST_SKIPPED;
10994 /* Verify the capabilities */
10995 struct rte_cryptodev_sym_capability_idx cap_idx;
10996 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10997 cap_idx.algo.aead = tdata->algo;
10998 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11000 return TEST_SKIPPED;
11002 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11004 /* clear mbuf payload */
11005 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11006 rte_pktmbuf_tailroom(ut_params->ibuf));
11008 /* Create AEAD operation */
11009 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
11013 /* Create GCM xform */
11014 memcpy(key, tdata->key.data, tdata->key.len);
11015 retval = create_aead_xform(ut_params->op,
11017 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11018 key, tdata->key.len,
11019 tdata->aad.len, tdata->auth_tag.len,
11024 ut_params->op->sym->m_src = ut_params->ibuf;
11026 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11027 RTE_CRYPTO_OP_SESSIONLESS,
11028 "crypto op session type not sessionless");
11030 /* Process crypto operation */
11031 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11032 ut_params->op), "failed to process sym crypto op");
11034 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11036 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11037 "crypto op status not success");
11039 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11041 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11042 ut_params->op->sym->cipher.data.offset);
11043 auth_tag = ciphertext + plaintext_pad_len;
11045 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
11046 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
11048 /* Validate obuf */
11049 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11051 tdata->ciphertext.data,
11052 tdata->ciphertext.len,
11053 "Ciphertext data not as expected");
11055 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11057 tdata->auth_tag.data,
11058 tdata->auth_tag.len,
11059 "Generated auth tag not as expected");
11066 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
11068 return test_authenticated_encryption_sessionless(
11073 test_authenticated_decryption_sessionless(
11074 const struct aead_test_data *tdata)
11076 struct crypto_testsuite_params *ts_params = &testsuite_params;
11077 struct crypto_unittest_params *ut_params = &unittest_params;
11080 uint8_t *plaintext;
11081 uint8_t key[tdata->key.len + 1];
11082 struct rte_cryptodev_info dev_info;
11084 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11085 uint64_t feat_flags = dev_info.feature_flags;
11087 if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
11088 printf("Device doesn't support Sessionless ops.\n");
11089 return TEST_SKIPPED;
11092 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11093 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11094 printf("Device doesn't support RAW data-path APIs.\n");
11095 return TEST_SKIPPED;
11098 /* not supported with CPU crypto */
11099 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11100 return TEST_SKIPPED;
11102 /* Verify the capabilities */
11103 struct rte_cryptodev_sym_capability_idx cap_idx;
11104 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
11105 cap_idx.algo.aead = tdata->algo;
11106 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11108 return TEST_SKIPPED;
11110 /* alloc mbuf and set payload */
11111 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11113 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11114 rte_pktmbuf_tailroom(ut_params->ibuf));
11116 /* Create AEAD operation */
11117 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
11121 /* Create AEAD xform */
11122 memcpy(key, tdata->key.data, tdata->key.len);
11123 retval = create_aead_xform(ut_params->op,
11125 RTE_CRYPTO_AEAD_OP_DECRYPT,
11126 key, tdata->key.len,
11127 tdata->aad.len, tdata->auth_tag.len,
11132 ut_params->op->sym->m_src = ut_params->ibuf;
11134 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
11135 RTE_CRYPTO_OP_SESSIONLESS,
11136 "crypto op session type not sessionless");
11138 /* Process crypto operation */
11139 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11140 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11141 ut_params->op, 0, 0, 0, 0);
11143 TEST_ASSERT_NOT_NULL(process_crypto_request(
11144 ts_params->valid_devs[0], ut_params->op),
11145 "failed to process sym crypto op");
11147 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11149 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11150 "crypto op status not success");
11152 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11153 ut_params->op->sym->cipher.data.offset);
11155 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
11157 /* Validate obuf */
11158 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11160 tdata->plaintext.data,
11161 tdata->plaintext.len,
11162 "Plaintext data not as expected");
11164 TEST_ASSERT_EQUAL(ut_params->op->status,
11165 RTE_CRYPTO_OP_STATUS_SUCCESS,
11166 "Authentication failed");
11171 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
11173 return test_authenticated_decryption_sessionless(
11178 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
11180 return test_authenticated_encryption(&ccm_test_case_128_1);
11184 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
11186 return test_authenticated_encryption(&ccm_test_case_128_2);
11190 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
11192 return test_authenticated_encryption(&ccm_test_case_128_3);
11196 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
11198 return test_authenticated_decryption(&ccm_test_case_128_1);
11202 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
11204 return test_authenticated_decryption(&ccm_test_case_128_2);
11208 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
11210 return test_authenticated_decryption(&ccm_test_case_128_3);
11214 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
11216 return test_authenticated_encryption(&ccm_test_case_192_1);
11220 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
11222 return test_authenticated_encryption(&ccm_test_case_192_2);
11226 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
11228 return test_authenticated_encryption(&ccm_test_case_192_3);
11232 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
11234 return test_authenticated_decryption(&ccm_test_case_192_1);
11238 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
11240 return test_authenticated_decryption(&ccm_test_case_192_2);
11244 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
11246 return test_authenticated_decryption(&ccm_test_case_192_3);
11250 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
11252 return test_authenticated_encryption(&ccm_test_case_256_1);
11256 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
11258 return test_authenticated_encryption(&ccm_test_case_256_2);
11262 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
11264 return test_authenticated_encryption(&ccm_test_case_256_3);
11268 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
11270 return test_authenticated_decryption(&ccm_test_case_256_1);
11274 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
11276 return test_authenticated_decryption(&ccm_test_case_256_2);
11280 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
11282 return test_authenticated_decryption(&ccm_test_case_256_3);
11288 struct crypto_testsuite_params *ts_params = &testsuite_params;
11289 struct rte_cryptodev_stats stats;
11291 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11292 return TEST_SKIPPED;
11294 /* Verify the capabilities */
11295 struct rte_cryptodev_sym_capability_idx cap_idx;
11296 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11297 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
11298 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11300 return TEST_SKIPPED;
11301 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11302 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11303 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11305 return TEST_SKIPPED;
11307 if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
11309 return TEST_SKIPPED;
11311 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11312 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
11313 &stats) == -ENODEV),
11314 "rte_cryptodev_stats_get invalid dev failed");
11315 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
11316 "rte_cryptodev_stats_get invalid Param failed");
11318 /* Test expected values */
11319 test_AES_CBC_HMAC_SHA1_encrypt_digest();
11320 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11322 "rte_cryptodev_stats_get failed");
11323 TEST_ASSERT((stats.enqueued_count == 1),
11324 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11325 TEST_ASSERT((stats.dequeued_count == 1),
11326 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11327 TEST_ASSERT((stats.enqueue_err_count == 0),
11328 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11329 TEST_ASSERT((stats.dequeue_err_count == 0),
11330 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11332 /* invalid device but should ignore and not reset device stats*/
11333 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
11334 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11336 "rte_cryptodev_stats_get failed");
11337 TEST_ASSERT((stats.enqueued_count == 1),
11338 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11340 /* check that a valid reset clears stats */
11341 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
11342 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
11344 "rte_cryptodev_stats_get failed");
11345 TEST_ASSERT((stats.enqueued_count == 0),
11346 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11347 TEST_ASSERT((stats.dequeued_count == 0),
11348 "rte_cryptodev_stats_get returned unexpected enqueued stat");
11350 return TEST_SUCCESS;
11353 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
11354 struct crypto_unittest_params *ut_params,
11355 enum rte_crypto_auth_operation op,
11356 const struct HMAC_MD5_vector *test_case)
11361 memcpy(key, test_case->key.data, test_case->key.len);
11363 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11364 ut_params->auth_xform.next = NULL;
11365 ut_params->auth_xform.auth.op = op;
11367 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
11369 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
11370 ut_params->auth_xform.auth.key.length = test_case->key.len;
11371 ut_params->auth_xform.auth.key.data = key;
11373 ut_params->sess = rte_cryptodev_sym_session_create(
11374 ts_params->session_mpool);
11375 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11376 if (ut_params->sess == NULL)
11377 return TEST_FAILED;
11379 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11380 ut_params->sess, &ut_params->auth_xform,
11381 ts_params->session_priv_mpool);
11382 if (status == -ENOTSUP)
11383 return TEST_SKIPPED;
11385 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11387 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11388 rte_pktmbuf_tailroom(ut_params->ibuf));
11393 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
11394 const struct HMAC_MD5_vector *test_case,
11395 uint8_t **plaintext)
11397 uint16_t plaintext_pad_len;
11399 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11401 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11404 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11405 plaintext_pad_len);
11406 memcpy(*plaintext, test_case->plaintext.data,
11407 test_case->plaintext.len);
11409 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11410 ut_params->ibuf, MD5_DIGEST_LEN);
11411 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11412 "no room to append digest");
11413 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11414 ut_params->ibuf, plaintext_pad_len);
11416 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11417 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
11418 test_case->auth_tag.len);
11421 sym_op->auth.data.offset = 0;
11422 sym_op->auth.data.length = test_case->plaintext.len;
11424 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11425 ut_params->op->sym->m_src = ut_params->ibuf;
11431 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
11433 uint16_t plaintext_pad_len;
11434 uint8_t *plaintext, *auth_tag;
11436 struct crypto_testsuite_params *ts_params = &testsuite_params;
11437 struct crypto_unittest_params *ut_params = &unittest_params;
11438 struct rte_cryptodev_info dev_info;
11440 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11441 uint64_t feat_flags = dev_info.feature_flags;
11443 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11444 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11445 printf("Device doesn't support RAW data-path APIs.\n");
11446 return TEST_SKIPPED;
11449 /* Verify the capabilities */
11450 struct rte_cryptodev_sym_capability_idx cap_idx;
11451 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11452 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11453 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11455 return TEST_SKIPPED;
11457 if (MD5_HMAC_create_session(ts_params, ut_params,
11458 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
11459 return TEST_FAILED;
11461 /* Generate Crypto op data structure */
11462 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11463 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11464 TEST_ASSERT_NOT_NULL(ut_params->op,
11465 "Failed to allocate symmetric crypto operation struct");
11467 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
11470 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11471 return TEST_FAILED;
11473 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11474 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11476 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11477 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11478 ut_params->op, 0, 1, 0, 0);
11480 TEST_ASSERT_NOT_NULL(
11481 process_crypto_request(ts_params->valid_devs[0],
11483 "failed to process sym crypto op");
11485 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11486 "crypto op processing failed");
11488 if (ut_params->op->sym->m_dst) {
11489 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11490 uint8_t *, plaintext_pad_len);
11492 auth_tag = plaintext + plaintext_pad_len;
11495 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11497 test_case->auth_tag.data,
11498 test_case->auth_tag.len,
11499 "HMAC_MD5 generated tag not as expected");
11501 return TEST_SUCCESS;
11505 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
11507 uint8_t *plaintext;
11509 struct crypto_testsuite_params *ts_params = &testsuite_params;
11510 struct crypto_unittest_params *ut_params = &unittest_params;
11511 struct rte_cryptodev_info dev_info;
11513 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11514 uint64_t feat_flags = dev_info.feature_flags;
11516 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11517 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11518 printf("Device doesn't support RAW data-path APIs.\n");
11519 return TEST_SKIPPED;
11522 /* Verify the capabilities */
11523 struct rte_cryptodev_sym_capability_idx cap_idx;
11524 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11525 cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
11526 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11528 return TEST_SKIPPED;
11530 if (MD5_HMAC_create_session(ts_params, ut_params,
11531 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
11532 return TEST_FAILED;
11535 /* Generate Crypto op data structure */
11536 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11537 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11538 TEST_ASSERT_NOT_NULL(ut_params->op,
11539 "Failed to allocate symmetric crypto operation struct");
11541 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
11542 return TEST_FAILED;
11544 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11545 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11547 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11548 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11549 ut_params->op, 0, 1, 0, 0);
11551 TEST_ASSERT_NOT_NULL(
11552 process_crypto_request(ts_params->valid_devs[0],
11554 "failed to process sym crypto op");
11556 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11557 "HMAC_MD5 crypto op processing failed");
11559 return TEST_SUCCESS;
11563 test_MD5_HMAC_generate_case_1(void)
11565 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
11569 test_MD5_HMAC_verify_case_1(void)
11571 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
11575 test_MD5_HMAC_generate_case_2(void)
11577 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
11581 test_MD5_HMAC_verify_case_2(void)
11583 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
11587 test_multi_session(void)
11589 struct crypto_testsuite_params *ts_params = &testsuite_params;
11590 struct crypto_unittest_params *ut_params = &unittest_params;
11592 struct rte_cryptodev_info dev_info;
11593 struct rte_cryptodev_sym_session **sessions;
11598 /* Verify the capabilities */
11599 struct rte_cryptodev_sym_capability_idx cap_idx;
11600 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11601 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11602 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11604 return TEST_SKIPPED;
11605 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11606 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11607 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11609 return TEST_SKIPPED;
11611 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
11612 aes_cbc_key, hmac_sha512_key);
11615 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11617 sessions = rte_malloc(NULL,
11618 sizeof(struct rte_cryptodev_sym_session *) *
11619 (MAX_NB_SESSIONS + 1), 0);
11621 /* Create multiple crypto sessions*/
11622 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11624 sessions[i] = rte_cryptodev_sym_session_create(
11625 ts_params->session_mpool);
11626 TEST_ASSERT_NOT_NULL(sessions[i],
11627 "Session creation failed at session number %u",
11630 status = rte_cryptodev_sym_session_init(
11631 ts_params->valid_devs[0],
11632 sessions[i], &ut_params->auth_xform,
11633 ts_params->session_priv_mpool);
11634 if (status == -ENOTSUP)
11635 return TEST_SKIPPED;
11637 /* Attempt to send a request on each session */
11638 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
11642 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
11643 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
11645 "Failed to perform decrypt on request number %u.", i);
11646 /* free crypto operation structure */
11648 rte_crypto_op_free(ut_params->op);
11651 * free mbuf - both obuf and ibuf are usually the same,
11652 * so check if they point at the same address is necessary,
11653 * to avoid freeing the mbuf twice.
11655 if (ut_params->obuf) {
11656 rte_pktmbuf_free(ut_params->obuf);
11657 if (ut_params->ibuf == ut_params->obuf)
11658 ut_params->ibuf = 0;
11659 ut_params->obuf = 0;
11661 if (ut_params->ibuf) {
11662 rte_pktmbuf_free(ut_params->ibuf);
11663 ut_params->ibuf = 0;
11667 sessions[i] = NULL;
11668 /* Next session create should fail */
11669 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11670 sessions[i], &ut_params->auth_xform,
11671 ts_params->session_priv_mpool);
11672 TEST_ASSERT_NULL(sessions[i],
11673 "Session creation succeeded unexpectedly!");
11675 for (i = 0; i < MAX_NB_SESSIONS; i++) {
11676 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11678 rte_cryptodev_sym_session_free(sessions[i]);
11681 rte_free(sessions);
11683 return TEST_SUCCESS;
11686 struct multi_session_params {
11687 struct crypto_unittest_params ut_params;
11688 uint8_t *cipher_key;
11690 const uint8_t *cipher;
11691 const uint8_t *digest;
11695 #define MB_SESSION_NUMBER 3
11698 test_multi_session_random_usage(void)
11700 struct crypto_testsuite_params *ts_params = &testsuite_params;
11701 struct rte_cryptodev_info dev_info;
11702 struct rte_cryptodev_sym_session **sessions;
11704 struct multi_session_params ut_paramz[] = {
11707 .cipher_key = ms_aes_cbc_key0,
11708 .hmac_key = ms_hmac_key0,
11709 .cipher = ms_aes_cbc_cipher0,
11710 .digest = ms_hmac_digest0,
11711 .iv = ms_aes_cbc_iv0
11714 .cipher_key = ms_aes_cbc_key1,
11715 .hmac_key = ms_hmac_key1,
11716 .cipher = ms_aes_cbc_cipher1,
11717 .digest = ms_hmac_digest1,
11718 .iv = ms_aes_cbc_iv1
11721 .cipher_key = ms_aes_cbc_key2,
11722 .hmac_key = ms_hmac_key2,
11723 .cipher = ms_aes_cbc_cipher2,
11724 .digest = ms_hmac_digest2,
11725 .iv = ms_aes_cbc_iv2
11731 /* Verify the capabilities */
11732 struct rte_cryptodev_sym_capability_idx cap_idx;
11733 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11734 cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
11735 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11737 return TEST_SKIPPED;
11738 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11739 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
11740 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11742 return TEST_SKIPPED;
11744 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11746 sessions = rte_malloc(NULL,
11747 (sizeof(struct rte_cryptodev_sym_session *)
11748 * MAX_NB_SESSIONS) + 1, 0);
11750 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11751 sessions[i] = rte_cryptodev_sym_session_create(
11752 ts_params->session_mpool);
11753 TEST_ASSERT_NOT_NULL(sessions[i],
11754 "Session creation failed at session number %u",
11757 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
11758 sizeof(struct crypto_unittest_params));
11760 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
11761 &ut_paramz[i].ut_params,
11762 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
11764 /* Create multiple crypto sessions*/
11765 status = rte_cryptodev_sym_session_init(
11766 ts_params->valid_devs[0],
11768 &ut_paramz[i].ut_params.auth_xform,
11769 ts_params->session_priv_mpool);
11771 if (status == -ENOTSUP)
11772 return TEST_SKIPPED;
11774 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11778 for (i = 0; i < 40000; i++) {
11780 j = rand() % MB_SESSION_NUMBER;
11782 TEST_ASSERT_SUCCESS(
11783 test_AES_CBC_HMAC_SHA512_decrypt_perform(
11785 &ut_paramz[j].ut_params,
11786 ts_params, ut_paramz[j].cipher,
11787 ut_paramz[j].digest,
11789 "Failed to perform decrypt on request number %u.", i);
11791 if (ut_paramz[j].ut_params.op)
11792 rte_crypto_op_free(ut_paramz[j].ut_params.op);
11795 * free mbuf - both obuf and ibuf are usually the same,
11796 * so check if they point at the same address is necessary,
11797 * to avoid freeing the mbuf twice.
11799 if (ut_paramz[j].ut_params.obuf) {
11800 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
11801 if (ut_paramz[j].ut_params.ibuf
11802 == ut_paramz[j].ut_params.obuf)
11803 ut_paramz[j].ut_params.ibuf = 0;
11804 ut_paramz[j].ut_params.obuf = 0;
11806 if (ut_paramz[j].ut_params.ibuf) {
11807 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
11808 ut_paramz[j].ut_params.ibuf = 0;
11812 for (i = 0; i < MB_SESSION_NUMBER; i++) {
11813 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
11815 rte_cryptodev_sym_session_free(sessions[i]);
11818 rte_free(sessions);
11820 return TEST_SUCCESS;
11823 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
11824 0xab, 0xab, 0xab, 0xab,
11825 0xab, 0xab, 0xab, 0xab,
11826 0xab, 0xab, 0xab, 0xab};
11829 test_null_invalid_operation(void)
11831 struct crypto_testsuite_params *ts_params = &testsuite_params;
11832 struct crypto_unittest_params *ut_params = &unittest_params;
11835 /* This test is for NULL PMD only */
11836 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11837 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11838 return TEST_SKIPPED;
11840 /* Setup Cipher Parameters */
11841 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11842 ut_params->cipher_xform.next = NULL;
11844 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
11845 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11847 ut_params->sess = rte_cryptodev_sym_session_create(
11848 ts_params->session_mpool);
11850 /* Create Crypto session*/
11851 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11852 ut_params->sess, &ut_params->cipher_xform,
11853 ts_params->session_priv_mpool);
11854 TEST_ASSERT(ret < 0,
11855 "Session creation succeeded unexpectedly");
11858 /* Setup HMAC Parameters */
11859 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11860 ut_params->auth_xform.next = NULL;
11862 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
11863 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11865 ut_params->sess = rte_cryptodev_sym_session_create(
11866 ts_params->session_mpool);
11868 /* Create Crypto session*/
11869 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11870 ut_params->sess, &ut_params->auth_xform,
11871 ts_params->session_priv_mpool);
11872 TEST_ASSERT(ret < 0,
11873 "Session creation succeeded unexpectedly");
11875 return TEST_SUCCESS;
11879 #define NULL_BURST_LENGTH (32)
11882 test_null_burst_operation(void)
11884 struct crypto_testsuite_params *ts_params = &testsuite_params;
11885 struct crypto_unittest_params *ut_params = &unittest_params;
11888 unsigned i, burst_len = NULL_BURST_LENGTH;
11890 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11891 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11893 /* This test is for NULL PMD only */
11894 if (gbl_driver_id != rte_cryptodev_driver_id_get(
11895 RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11896 return TEST_SKIPPED;
11898 /* Setup Cipher Parameters */
11899 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11900 ut_params->cipher_xform.next = &ut_params->auth_xform;
11902 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11903 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11905 /* Setup HMAC Parameters */
11906 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11907 ut_params->auth_xform.next = NULL;
11909 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11910 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11912 ut_params->sess = rte_cryptodev_sym_session_create(
11913 ts_params->session_mpool);
11914 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11916 /* Create Crypto session*/
11917 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11918 ut_params->sess, &ut_params->cipher_xform,
11919 ts_params->session_priv_mpool);
11921 if (status == -ENOTSUP)
11922 return TEST_SKIPPED;
11924 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
11926 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11927 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11928 burst_len, "failed to generate burst of crypto ops");
11930 /* Generate an operation for each mbuf in burst */
11931 for (i = 0; i < burst_len; i++) {
11932 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11934 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11936 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11940 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11942 burst[i]->sym->m_src = m;
11945 /* Process crypto operation */
11946 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11947 0, burst, burst_len),
11949 "Error enqueuing burst");
11951 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11952 0, burst_dequeued, burst_len),
11954 "Error dequeuing burst");
11957 for (i = 0; i < burst_len; i++) {
11959 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11960 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11962 "data not as expected");
11964 rte_pktmbuf_free(burst[i]->sym->m_src);
11965 rte_crypto_op_free(burst[i]);
11968 return TEST_SUCCESS;
11972 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11973 uint16_t nb_ops, void *user_param)
11975 RTE_SET_USED(dev_id);
11976 RTE_SET_USED(qp_id);
11978 RTE_SET_USED(user_param);
11980 printf("crypto enqueue callback called\n");
11985 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11986 uint16_t nb_ops, void *user_param)
11988 RTE_SET_USED(dev_id);
11989 RTE_SET_USED(qp_id);
11991 RTE_SET_USED(user_param);
11993 printf("crypto dequeue callback called\n");
11998 * Thread using enqueue/dequeue callback with RCU.
12001 test_enqdeq_callback_thread(void *arg)
12004 /* DP thread calls rte_cryptodev_enqueue_burst()/
12005 * rte_cryptodev_dequeue_burst() and invokes callback.
12007 test_null_burst_operation();
12012 test_enq_callback_setup(void)
12014 struct crypto_testsuite_params *ts_params = &testsuite_params;
12015 struct rte_cryptodev_info dev_info;
12016 struct rte_cryptodev_qp_conf qp_conf = {
12017 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12020 struct rte_cryptodev_cb *cb;
12021 uint16_t qp_id = 0;
12023 /* Stop the device in case it's started so it can be configured */
12024 rte_cryptodev_stop(ts_params->valid_devs[0]);
12026 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12028 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12030 "Failed to configure cryptodev %u",
12031 ts_params->valid_devs[0]);
12033 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12034 qp_conf.mp_session = ts_params->session_mpool;
12035 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12037 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12038 ts_params->valid_devs[0], qp_id, &qp_conf,
12039 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12041 "rte_cryptodev_queue_pair_setup: num_inflights "
12042 "%u on qp %u on cryptodev %u",
12043 qp_conf.nb_descriptors, qp_id,
12044 ts_params->valid_devs[0]);
12046 /* Test with invalid crypto device */
12047 cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
12048 qp_id, test_enq_callback, NULL);
12049 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12050 "cryptodev %u did not fail",
12051 qp_id, RTE_CRYPTO_MAX_DEVS);
12053 /* Test with invalid queue pair */
12054 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12055 dev_info.max_nb_queue_pairs + 1,
12056 test_enq_callback, NULL);
12057 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12058 "cryptodev %u did not fail",
12059 dev_info.max_nb_queue_pairs + 1,
12060 ts_params->valid_devs[0]);
12062 /* Test with NULL callback */
12063 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12064 qp_id, NULL, NULL);
12065 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12066 "cryptodev %u did not fail",
12067 qp_id, ts_params->valid_devs[0]);
12069 /* Test with valid configuration */
12070 cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
12071 qp_id, test_enq_callback, NULL);
12072 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12073 "qp %u on cryptodev %u",
12074 qp_id, ts_params->valid_devs[0]);
12076 rte_cryptodev_start(ts_params->valid_devs[0]);
12078 /* Launch a thread */
12079 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12080 rte_get_next_lcore(-1, 1, 0));
12082 /* Wait until reader exited. */
12083 rte_eal_mp_wait_lcore();
12085 /* Test with invalid crypto device */
12086 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12087 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12088 "Expected call to fail as crypto device is invalid");
12090 /* Test with invalid queue pair */
12091 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12092 ts_params->valid_devs[0],
12093 dev_info.max_nb_queue_pairs + 1, cb),
12094 "Expected call to fail as queue pair is invalid");
12096 /* Test with NULL callback */
12097 TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
12098 ts_params->valid_devs[0], qp_id, NULL),
12099 "Expected call to fail as callback is NULL");
12101 /* Test with valid configuration */
12102 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
12103 ts_params->valid_devs[0], qp_id, cb),
12104 "Failed test to remove callback on "
12105 "qp %u on cryptodev %u",
12106 qp_id, ts_params->valid_devs[0]);
12108 return TEST_SUCCESS;
12112 test_deq_callback_setup(void)
12114 struct crypto_testsuite_params *ts_params = &testsuite_params;
12115 struct rte_cryptodev_info dev_info;
12116 struct rte_cryptodev_qp_conf qp_conf = {
12117 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
12120 struct rte_cryptodev_cb *cb;
12121 uint16_t qp_id = 0;
12123 /* Stop the device in case it's started so it can be configured */
12124 rte_cryptodev_stop(ts_params->valid_devs[0]);
12126 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12128 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
12130 "Failed to configure cryptodev %u",
12131 ts_params->valid_devs[0]);
12133 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
12134 qp_conf.mp_session = ts_params->session_mpool;
12135 qp_conf.mp_session_private = ts_params->session_priv_mpool;
12137 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
12138 ts_params->valid_devs[0], qp_id, &qp_conf,
12139 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
12141 "rte_cryptodev_queue_pair_setup: num_inflights "
12142 "%u on qp %u on cryptodev %u",
12143 qp_conf.nb_descriptors, qp_id,
12144 ts_params->valid_devs[0]);
12146 /* Test with invalid crypto device */
12147 cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
12148 qp_id, test_deq_callback, NULL);
12149 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12150 "cryptodev %u did not fail",
12151 qp_id, RTE_CRYPTO_MAX_DEVS);
12153 /* Test with invalid queue pair */
12154 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12155 dev_info.max_nb_queue_pairs + 1,
12156 test_deq_callback, NULL);
12157 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12158 "cryptodev %u did not fail",
12159 dev_info.max_nb_queue_pairs + 1,
12160 ts_params->valid_devs[0]);
12162 /* Test with NULL callback */
12163 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12164 qp_id, NULL, NULL);
12165 TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
12166 "cryptodev %u did not fail",
12167 qp_id, ts_params->valid_devs[0]);
12169 /* Test with valid configuration */
12170 cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
12171 qp_id, test_deq_callback, NULL);
12172 TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
12173 "qp %u on cryptodev %u",
12174 qp_id, ts_params->valid_devs[0]);
12176 rte_cryptodev_start(ts_params->valid_devs[0]);
12178 /* Launch a thread */
12179 rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
12180 rte_get_next_lcore(-1, 1, 0));
12182 /* Wait until reader exited. */
12183 rte_eal_mp_wait_lcore();
12185 /* Test with invalid crypto device */
12186 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12187 RTE_CRYPTO_MAX_DEVS, qp_id, cb),
12188 "Expected call to fail as crypto device is invalid");
12190 /* Test with invalid queue pair */
12191 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12192 ts_params->valid_devs[0],
12193 dev_info.max_nb_queue_pairs + 1, cb),
12194 "Expected call to fail as queue pair is invalid");
12196 /* Test with NULL callback */
12197 TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
12198 ts_params->valid_devs[0], qp_id, NULL),
12199 "Expected call to fail as callback is NULL");
12201 /* Test with valid configuration */
12202 TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
12203 ts_params->valid_devs[0], qp_id, cb),
12204 "Failed test to remove callback on "
12205 "qp %u on cryptodev %u",
12206 qp_id, ts_params->valid_devs[0]);
12208 return TEST_SUCCESS;
12212 generate_gmac_large_plaintext(uint8_t *data)
12216 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
12217 memcpy(&data[i], &data[0], 32);
12221 create_gmac_operation(enum rte_crypto_auth_operation op,
12222 const struct gmac_test_data *tdata)
12224 struct crypto_testsuite_params *ts_params = &testsuite_params;
12225 struct crypto_unittest_params *ut_params = &unittest_params;
12226 struct rte_crypto_sym_op *sym_op;
12228 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12230 /* Generate Crypto op data structure */
12231 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12232 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12233 TEST_ASSERT_NOT_NULL(ut_params->op,
12234 "Failed to allocate symmetric crypto operation struct");
12236 sym_op = ut_params->op->sym;
12238 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12239 ut_params->ibuf, tdata->gmac_tag.len);
12240 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12241 "no room to append digest");
12243 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12244 ut_params->ibuf, plaintext_pad_len);
12246 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12247 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12248 tdata->gmac_tag.len);
12249 debug_hexdump(stdout, "digest:",
12250 sym_op->auth.digest.data,
12251 tdata->gmac_tag.len);
12254 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12255 uint8_t *, IV_OFFSET);
12257 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12259 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12261 sym_op->cipher.data.length = 0;
12262 sym_op->cipher.data.offset = 0;
12264 sym_op->auth.data.offset = 0;
12265 sym_op->auth.data.length = tdata->plaintext.len;
12271 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
12272 const struct gmac_test_data *tdata,
12273 void *digest_mem, uint64_t digest_phys)
12275 struct crypto_testsuite_params *ts_params = &testsuite_params;
12276 struct crypto_unittest_params *ut_params = &unittest_params;
12277 struct rte_crypto_sym_op *sym_op;
12279 /* Generate Crypto op data structure */
12280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12282 TEST_ASSERT_NOT_NULL(ut_params->op,
12283 "Failed to allocate symmetric crypto operation struct");
12285 sym_op = ut_params->op->sym;
12287 sym_op->auth.digest.data = digest_mem;
12288 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12289 "no room to append digest");
12291 sym_op->auth.digest.phys_addr = digest_phys;
12293 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
12294 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
12295 tdata->gmac_tag.len);
12296 debug_hexdump(stdout, "digest:",
12297 sym_op->auth.digest.data,
12298 tdata->gmac_tag.len);
12301 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12302 uint8_t *, IV_OFFSET);
12304 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
12306 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
12308 sym_op->cipher.data.length = 0;
12309 sym_op->cipher.data.offset = 0;
12311 sym_op->auth.data.offset = 0;
12312 sym_op->auth.data.length = tdata->plaintext.len;
12317 static int create_gmac_session(uint8_t dev_id,
12318 const struct gmac_test_data *tdata,
12319 enum rte_crypto_auth_operation auth_op)
12321 uint8_t auth_key[tdata->key.len];
12324 struct crypto_testsuite_params *ts_params = &testsuite_params;
12325 struct crypto_unittest_params *ut_params = &unittest_params;
12327 memcpy(auth_key, tdata->key.data, tdata->key.len);
12329 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12330 ut_params->auth_xform.next = NULL;
12332 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
12333 ut_params->auth_xform.auth.op = auth_op;
12334 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
12335 ut_params->auth_xform.auth.key.length = tdata->key.len;
12336 ut_params->auth_xform.auth.key.data = auth_key;
12337 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12338 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
12341 ut_params->sess = rte_cryptodev_sym_session_create(
12342 ts_params->session_mpool);
12343 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12345 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12346 &ut_params->auth_xform,
12347 ts_params->session_priv_mpool);
12353 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
12355 struct crypto_testsuite_params *ts_params = &testsuite_params;
12356 struct crypto_unittest_params *ut_params = &unittest_params;
12357 struct rte_cryptodev_info dev_info;
12359 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12360 uint64_t feat_flags = dev_info.feature_flags;
12362 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12363 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12364 printf("Device doesn't support RAW data-path APIs.\n");
12365 return TEST_SKIPPED;
12370 uint8_t *auth_tag, *plaintext;
12371 uint16_t plaintext_pad_len;
12373 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12374 "No GMAC length in the source data");
12376 /* Verify the capabilities */
12377 struct rte_cryptodev_sym_capability_idx cap_idx;
12378 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12379 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12380 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12382 return TEST_SKIPPED;
12384 retval = create_gmac_session(ts_params->valid_devs[0],
12385 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12387 if (retval == -ENOTSUP)
12388 return TEST_SKIPPED;
12392 if (tdata->plaintext.len > MBUF_SIZE)
12393 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12395 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12396 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12397 "Failed to allocate input buffer in mempool");
12399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12400 rte_pktmbuf_tailroom(ut_params->ibuf));
12402 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12404 * Runtime generate the large plain text instead of use hard code
12405 * plain text vector. It is done to avoid create huge source file
12406 * with the test vector.
12408 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12409 generate_gmac_large_plaintext(tdata->plaintext.data);
12411 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12412 plaintext_pad_len);
12413 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12415 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12416 debug_hexdump(stdout, "plaintext:", plaintext,
12417 tdata->plaintext.len);
12419 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
12425 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12427 ut_params->op->sym->m_src = ut_params->ibuf;
12429 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12430 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12432 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12433 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12434 ut_params->op, 0, 1, 0, 0);
12436 TEST_ASSERT_NOT_NULL(
12437 process_crypto_request(ts_params->valid_devs[0],
12438 ut_params->op), "failed to process sym crypto op");
12440 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12441 "crypto op processing failed");
12443 if (ut_params->op->sym->m_dst) {
12444 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
12445 uint8_t *, plaintext_pad_len);
12447 auth_tag = plaintext + plaintext_pad_len;
12450 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12452 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12454 tdata->gmac_tag.data,
12455 tdata->gmac_tag.len,
12456 "GMAC Generated auth tag not as expected");
12462 test_AES_GMAC_authentication_test_case_1(void)
12464 return test_AES_GMAC_authentication(&gmac_test_case_1);
12468 test_AES_GMAC_authentication_test_case_2(void)
12470 return test_AES_GMAC_authentication(&gmac_test_case_2);
12474 test_AES_GMAC_authentication_test_case_3(void)
12476 return test_AES_GMAC_authentication(&gmac_test_case_3);
12480 test_AES_GMAC_authentication_test_case_4(void)
12482 return test_AES_GMAC_authentication(&gmac_test_case_4);
12486 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
12488 struct crypto_testsuite_params *ts_params = &testsuite_params;
12489 struct crypto_unittest_params *ut_params = &unittest_params;
12491 uint32_t plaintext_pad_len;
12492 uint8_t *plaintext;
12493 struct rte_cryptodev_info dev_info;
12495 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12496 uint64_t feat_flags = dev_info.feature_flags;
12498 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12499 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12500 printf("Device doesn't support RAW data-path APIs.\n");
12501 return TEST_SKIPPED;
12504 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12505 "No GMAC length in the source data");
12507 /* Verify the capabilities */
12508 struct rte_cryptodev_sym_capability_idx cap_idx;
12509 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12510 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12511 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12513 return TEST_SKIPPED;
12515 retval = create_gmac_session(ts_params->valid_devs[0],
12516 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
12518 if (retval == -ENOTSUP)
12519 return TEST_SKIPPED;
12523 if (tdata->plaintext.len > MBUF_SIZE)
12524 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
12526 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12527 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12528 "Failed to allocate input buffer in mempool");
12530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12531 rte_pktmbuf_tailroom(ut_params->ibuf));
12533 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
12536 * Runtime generate the large plain text instead of use hard code
12537 * plain text vector. It is done to avoid create huge source file
12538 * with the test vector.
12540 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
12541 generate_gmac_large_plaintext(tdata->plaintext.data);
12543 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12544 plaintext_pad_len);
12545 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12547 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
12548 debug_hexdump(stdout, "plaintext:", plaintext,
12549 tdata->plaintext.len);
12551 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
12557 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12559 ut_params->op->sym->m_src = ut_params->ibuf;
12561 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12562 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12564 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12565 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12566 ut_params->op, 0, 1, 0, 0);
12568 TEST_ASSERT_NOT_NULL(
12569 process_crypto_request(ts_params->valid_devs[0],
12570 ut_params->op), "failed to process sym crypto op");
12572 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12573 "crypto op processing failed");
12580 test_AES_GMAC_authentication_verify_test_case_1(void)
12582 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
12586 test_AES_GMAC_authentication_verify_test_case_2(void)
12588 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
12592 test_AES_GMAC_authentication_verify_test_case_3(void)
12594 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
12598 test_AES_GMAC_authentication_verify_test_case_4(void)
12600 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
12604 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
12607 struct crypto_testsuite_params *ts_params = &testsuite_params;
12608 struct crypto_unittest_params *ut_params = &unittest_params;
12609 struct rte_cryptodev_info dev_info;
12610 uint64_t feature_flags;
12611 unsigned int trn_data = 0;
12612 void *digest_mem = NULL;
12614 unsigned int to_trn = 0;
12615 struct rte_mbuf *buf = NULL;
12616 uint8_t *auth_tag, *plaintext;
12619 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
12620 "No GMAC length in the source data");
12622 /* Verify the capabilities */
12623 struct rte_cryptodev_sym_capability_idx cap_idx;
12624 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12625 cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
12626 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12628 return TEST_SKIPPED;
12630 /* Check for any input SGL support */
12631 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12632 feature_flags = dev_info.feature_flags;
12634 if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
12635 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
12636 (!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
12637 return TEST_SKIPPED;
12639 if (fragsz > tdata->plaintext.len)
12640 fragsz = tdata->plaintext.len;
12642 uint16_t plaintext_len = fragsz;
12644 retval = create_gmac_session(ts_params->valid_devs[0],
12645 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
12647 if (retval == -ENOTSUP)
12648 return TEST_SKIPPED;
12652 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12653 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12654 "Failed to allocate input buffer in mempool");
12656 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12657 rte_pktmbuf_tailroom(ut_params->ibuf));
12659 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12661 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12663 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
12665 trn_data += plaintext_len;
12667 buf = ut_params->ibuf;
12670 * Loop until no more fragments
12673 while (trn_data < tdata->plaintext.len) {
12675 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
12676 (tdata->plaintext.len - trn_data) : fragsz;
12678 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12681 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
12682 rte_pktmbuf_tailroom(buf));
12684 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
12687 memcpy(plaintext, tdata->plaintext.data + trn_data,
12689 trn_data += to_trn;
12690 if (trn_data == tdata->plaintext.len)
12691 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
12692 tdata->gmac_tag.len);
12694 ut_params->ibuf->nb_segs = segs;
12697 * Place digest at the end of the last buffer
12699 uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
12702 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12703 + tdata->gmac_tag.len);
12704 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
12705 tdata->plaintext.len);
12708 retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
12709 tdata, digest_mem, digest_phys);
12714 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12716 ut_params->op->sym->m_src = ut_params->ibuf;
12718 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12719 return TEST_SKIPPED;
12721 TEST_ASSERT_NOT_NULL(
12722 process_crypto_request(ts_params->valid_devs[0],
12723 ut_params->op), "failed to process sym crypto op");
12725 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12726 "crypto op processing failed");
12728 auth_tag = digest_mem;
12729 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
12730 TEST_ASSERT_BUFFERS_ARE_EQUAL(
12732 tdata->gmac_tag.data,
12733 tdata->gmac_tag.len,
12734 "GMAC Generated auth tag not as expected");
12739 /* Segment size not multiple of block size (16B) */
12741 test_AES_GMAC_authentication_SGL_40B(void)
12743 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
12747 test_AES_GMAC_authentication_SGL_80B(void)
12749 return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
12753 test_AES_GMAC_authentication_SGL_2048B(void)
12755 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
12758 /* Segment size not multiple of block size (16B) */
12760 test_AES_GMAC_authentication_SGL_2047B(void)
12762 return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
12765 struct test_crypto_vector {
12766 enum rte_crypto_cipher_algorithm crypto_algo;
12767 unsigned int cipher_offset;
12768 unsigned int cipher_len;
12781 const uint8_t *data;
12786 const uint8_t *data;
12790 enum rte_crypto_auth_algorithm auth_algo;
12791 unsigned int auth_offset;
12799 const uint8_t *data;
12809 static const struct test_crypto_vector
12810 hmac_sha1_test_crypto_vector = {
12811 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12813 .data = plaintext_hash,
12818 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12819 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12820 0xDE, 0xF4, 0xDE, 0xAD
12826 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
12827 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
12828 0x3F, 0x91, 0x64, 0x59
12834 static const struct test_crypto_vector
12835 aes128_gmac_test_vector = {
12836 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
12838 .data = plaintext_hash,
12843 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12844 0x08, 0x09, 0x0A, 0x0B
12850 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12851 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
12857 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
12858 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
12864 static const struct test_crypto_vector
12865 aes128cbc_hmac_sha1_test_vector = {
12866 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12867 .cipher_offset = 0,
12871 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12872 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12878 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12879 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12884 .data = plaintext_hash,
12888 .data = ciphertext512_aes128cbc,
12891 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12895 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12896 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12897 0xDE, 0xF4, 0xDE, 0xAD
12903 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12904 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12905 0x18, 0x8C, 0x1D, 0x32
12911 static const struct test_crypto_vector
12912 aes128cbc_hmac_sha1_aad_test_vector = {
12913 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12914 .cipher_offset = 8,
12918 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12919 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12925 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12926 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12931 .data = plaintext_hash,
12935 .data = ciphertext512_aes128cbc_aad,
12938 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12942 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12943 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12944 0xDE, 0xF4, 0xDE, 0xAD
12950 0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12951 0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12952 0x62, 0x0F, 0xFB, 0x10
12959 data_corruption(uint8_t *data)
12965 tag_corruption(uint8_t *data, unsigned int tag_offset)
12967 data[tag_offset] += 1;
12971 create_auth_session(struct crypto_unittest_params *ut_params,
12973 const struct test_crypto_vector *reference,
12974 enum rte_crypto_auth_operation auth_op)
12976 struct crypto_testsuite_params *ts_params = &testsuite_params;
12977 uint8_t auth_key[reference->auth_key.len + 1];
12980 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12982 /* Setup Authentication Parameters */
12983 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12984 ut_params->auth_xform.auth.op = auth_op;
12985 ut_params->auth_xform.next = NULL;
12986 ut_params->auth_xform.auth.algo = reference->auth_algo;
12987 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12988 ut_params->auth_xform.auth.key.data = auth_key;
12989 ut_params->auth_xform.auth.digest_length = reference->digest.len;
12991 /* Create Crypto session*/
12992 ut_params->sess = rte_cryptodev_sym_session_create(
12993 ts_params->session_mpool);
12994 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12996 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12997 &ut_params->auth_xform,
12998 ts_params->session_priv_mpool);
13004 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
13006 const struct test_crypto_vector *reference,
13007 enum rte_crypto_auth_operation auth_op,
13008 enum rte_crypto_cipher_operation cipher_op)
13010 struct crypto_testsuite_params *ts_params = &testsuite_params;
13011 uint8_t cipher_key[reference->cipher_key.len + 1];
13012 uint8_t auth_key[reference->auth_key.len + 1];
13015 memcpy(cipher_key, reference->cipher_key.data,
13016 reference->cipher_key.len);
13017 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13019 /* Setup Authentication Parameters */
13020 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13021 ut_params->auth_xform.auth.op = auth_op;
13022 ut_params->auth_xform.auth.algo = reference->auth_algo;
13023 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13024 ut_params->auth_xform.auth.key.data = auth_key;
13025 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13027 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
13028 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
13029 ut_params->auth_xform.auth.iv.length = reference->iv.len;
13031 ut_params->auth_xform.next = &ut_params->cipher_xform;
13033 /* Setup Cipher Parameters */
13034 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13035 ut_params->cipher_xform.next = NULL;
13036 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13037 ut_params->cipher_xform.cipher.op = cipher_op;
13038 ut_params->cipher_xform.cipher.key.data = cipher_key;
13039 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13040 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13041 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13044 /* Create Crypto session*/
13045 ut_params->sess = rte_cryptodev_sym_session_create(
13046 ts_params->session_mpool);
13047 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13049 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
13050 &ut_params->auth_xform,
13051 ts_params->session_priv_mpool);
13057 create_auth_operation(struct crypto_testsuite_params *ts_params,
13058 struct crypto_unittest_params *ut_params,
13059 const struct test_crypto_vector *reference,
13060 unsigned int auth_generate)
13062 /* Generate Crypto op data structure */
13063 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13064 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13065 TEST_ASSERT_NOT_NULL(ut_params->op,
13066 "Failed to allocate pktmbuf offload");
13068 /* Set crypto operation data parameters */
13069 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13071 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13073 /* set crypto operation source mbuf */
13074 sym_op->m_src = ut_params->ibuf;
13077 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13078 ut_params->ibuf, reference->digest.len);
13080 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13081 "no room to append auth tag");
13083 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13084 ut_params->ibuf, reference->plaintext.len);
13087 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13089 memcpy(sym_op->auth.digest.data,
13090 reference->digest.data,
13091 reference->digest.len);
13093 debug_hexdump(stdout, "digest:",
13094 sym_op->auth.digest.data,
13095 reference->digest.len);
13097 sym_op->auth.data.length = reference->plaintext.len;
13098 sym_op->auth.data.offset = 0;
13104 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
13105 struct crypto_unittest_params *ut_params,
13106 const struct test_crypto_vector *reference,
13107 unsigned int auth_generate)
13109 /* Generate Crypto op data structure */
13110 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13111 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13112 TEST_ASSERT_NOT_NULL(ut_params->op,
13113 "Failed to allocate pktmbuf offload");
13115 /* Set crypto operation data parameters */
13116 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13118 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13120 /* set crypto operation source mbuf */
13121 sym_op->m_src = ut_params->ibuf;
13124 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13125 ut_params->ibuf, reference->digest.len);
13127 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13128 "no room to append auth tag");
13130 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13131 ut_params->ibuf, reference->ciphertext.len);
13134 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13136 memcpy(sym_op->auth.digest.data,
13137 reference->digest.data,
13138 reference->digest.len);
13140 debug_hexdump(stdout, "digest:",
13141 sym_op->auth.digest.data,
13142 reference->digest.len);
13144 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13145 reference->iv.data, reference->iv.len);
13147 sym_op->cipher.data.length = 0;
13148 sym_op->cipher.data.offset = 0;
13150 sym_op->auth.data.length = reference->plaintext.len;
13151 sym_op->auth.data.offset = 0;
13157 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
13158 struct crypto_unittest_params *ut_params,
13159 const struct test_crypto_vector *reference,
13160 unsigned int auth_generate)
13162 /* Generate Crypto op data structure */
13163 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13164 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13165 TEST_ASSERT_NOT_NULL(ut_params->op,
13166 "Failed to allocate pktmbuf offload");
13168 /* Set crypto operation data parameters */
13169 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13171 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13173 /* set crypto operation source mbuf */
13174 sym_op->m_src = ut_params->ibuf;
13177 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
13178 ut_params->ibuf, reference->digest.len);
13180 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
13181 "no room to append auth tag");
13183 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
13184 ut_params->ibuf, reference->ciphertext.len);
13187 memset(sym_op->auth.digest.data, 0, reference->digest.len);
13189 memcpy(sym_op->auth.digest.data,
13190 reference->digest.data,
13191 reference->digest.len);
13193 debug_hexdump(stdout, "digest:",
13194 sym_op->auth.digest.data,
13195 reference->digest.len);
13197 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
13198 reference->iv.data, reference->iv.len);
13200 sym_op->cipher.data.length = reference->cipher_len;
13201 sym_op->cipher.data.offset = reference->cipher_offset;
13203 sym_op->auth.data.length = reference->plaintext.len;
13204 sym_op->auth.data.offset = reference->auth_offset;
13210 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13211 struct crypto_unittest_params *ut_params,
13212 const struct test_crypto_vector *reference)
13214 return create_auth_operation(ts_params, ut_params, reference, 0);
13218 create_auth_verify_GMAC_operation(
13219 struct crypto_testsuite_params *ts_params,
13220 struct crypto_unittest_params *ut_params,
13221 const struct test_crypto_vector *reference)
13223 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
13227 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
13228 struct crypto_unittest_params *ut_params,
13229 const struct test_crypto_vector *reference)
13231 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
13235 test_authentication_verify_fail_when_data_corruption(
13236 struct crypto_testsuite_params *ts_params,
13237 struct crypto_unittest_params *ut_params,
13238 const struct test_crypto_vector *reference,
13239 unsigned int data_corrupted)
13243 uint8_t *plaintext;
13244 struct rte_cryptodev_info dev_info;
13246 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13247 uint64_t feat_flags = dev_info.feature_flags;
13249 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13250 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13251 printf("Device doesn't support RAW data-path APIs.\n");
13252 return TEST_SKIPPED;
13255 /* Verify the capabilities */
13256 struct rte_cryptodev_sym_capability_idx cap_idx;
13257 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13258 cap_idx.algo.auth = reference->auth_algo;
13259 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13261 return TEST_SKIPPED;
13264 /* Create session */
13265 retval = create_auth_session(ut_params,
13266 ts_params->valid_devs[0],
13268 RTE_CRYPTO_AUTH_OP_VERIFY);
13270 if (retval == -ENOTSUP)
13271 return TEST_SKIPPED;
13275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13276 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13277 "Failed to allocate input buffer in mempool");
13279 /* clear mbuf payload */
13280 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13281 rte_pktmbuf_tailroom(ut_params->ibuf));
13283 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13284 reference->plaintext.len);
13285 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13286 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13288 debug_hexdump(stdout, "plaintext:", plaintext,
13289 reference->plaintext.len);
13291 /* Create operation */
13292 retval = create_auth_verify_operation(ts_params, ut_params, reference);
13297 if (data_corrupted)
13298 data_corruption(plaintext);
13300 tag_corruption(plaintext, reference->plaintext.len);
13302 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13303 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13305 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13306 RTE_CRYPTO_OP_STATUS_SUCCESS,
13307 "authentication not failed");
13308 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13309 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13310 ut_params->op, 0, 1, 0, 0);
13312 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13315 if (ut_params->op == NULL)
13317 else if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS)
13324 test_authentication_verify_GMAC_fail_when_corruption(
13325 struct crypto_testsuite_params *ts_params,
13326 struct crypto_unittest_params *ut_params,
13327 const struct test_crypto_vector *reference,
13328 unsigned int data_corrupted)
13331 uint8_t *plaintext;
13332 struct rte_cryptodev_info dev_info;
13334 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13335 uint64_t feat_flags = dev_info.feature_flags;
13337 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13338 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13339 printf("Device doesn't support RAW data-path APIs.\n");
13340 return TEST_SKIPPED;
13343 /* Verify the capabilities */
13344 struct rte_cryptodev_sym_capability_idx cap_idx;
13345 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13346 cap_idx.algo.auth = reference->auth_algo;
13347 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13349 return TEST_SKIPPED;
13351 /* Create session */
13352 retval = create_auth_cipher_session(ut_params,
13353 ts_params->valid_devs[0],
13355 RTE_CRYPTO_AUTH_OP_VERIFY,
13356 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13360 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13361 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13362 "Failed to allocate input buffer in mempool");
13364 /* clear mbuf payload */
13365 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13366 rte_pktmbuf_tailroom(ut_params->ibuf));
13368 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13369 reference->plaintext.len);
13370 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13371 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13373 debug_hexdump(stdout, "plaintext:", plaintext,
13374 reference->plaintext.len);
13376 /* Create operation */
13377 retval = create_auth_verify_GMAC_operation(ts_params,
13384 if (data_corrupted)
13385 data_corruption(plaintext);
13387 tag_corruption(plaintext, reference->aad.len);
13389 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13390 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13392 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13393 RTE_CRYPTO_OP_STATUS_SUCCESS,
13394 "authentication not failed");
13395 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13396 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13397 ut_params->op, 0, 1, 0, 0);
13399 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13401 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13408 test_authenticated_decryption_fail_when_corruption(
13409 struct crypto_testsuite_params *ts_params,
13410 struct crypto_unittest_params *ut_params,
13411 const struct test_crypto_vector *reference,
13412 unsigned int data_corrupted)
13416 uint8_t *ciphertext;
13417 struct rte_cryptodev_info dev_info;
13419 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13420 uint64_t feat_flags = dev_info.feature_flags;
13422 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13423 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13424 printf("Device doesn't support RAW data-path APIs.\n");
13425 return TEST_SKIPPED;
13428 /* Verify the capabilities */
13429 struct rte_cryptodev_sym_capability_idx cap_idx;
13430 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13431 cap_idx.algo.auth = reference->auth_algo;
13432 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13434 return TEST_SKIPPED;
13435 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13436 cap_idx.algo.cipher = reference->crypto_algo;
13437 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13439 return TEST_SKIPPED;
13441 /* Create session */
13442 retval = create_auth_cipher_session(ut_params,
13443 ts_params->valid_devs[0],
13445 RTE_CRYPTO_AUTH_OP_VERIFY,
13446 RTE_CRYPTO_CIPHER_OP_DECRYPT);
13448 if (retval == -ENOTSUP)
13449 return TEST_SKIPPED;
13453 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13454 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13455 "Failed to allocate input buffer in mempool");
13457 /* clear mbuf payload */
13458 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13459 rte_pktmbuf_tailroom(ut_params->ibuf));
13461 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13462 reference->ciphertext.len);
13463 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13464 memcpy(ciphertext, reference->ciphertext.data,
13465 reference->ciphertext.len);
13467 /* Create operation */
13468 retval = create_cipher_auth_verify_operation(ts_params,
13475 if (data_corrupted)
13476 data_corruption(ciphertext);
13478 tag_corruption(ciphertext, reference->ciphertext.len);
13480 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
13481 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13483 TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
13484 RTE_CRYPTO_OP_STATUS_SUCCESS,
13485 "authentication not failed");
13486 } else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13487 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13488 ut_params->op, 1, 1, 0, 0);
13490 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13492 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
13499 test_authenticated_encrypt_with_esn(
13500 struct crypto_testsuite_params *ts_params,
13501 struct crypto_unittest_params *ut_params,
13502 const struct test_crypto_vector *reference)
13506 uint8_t *authciphertext, *plaintext, *auth_tag;
13507 uint16_t plaintext_pad_len;
13508 uint8_t cipher_key[reference->cipher_key.len + 1];
13509 uint8_t auth_key[reference->auth_key.len + 1];
13510 struct rte_cryptodev_info dev_info;
13513 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13514 uint64_t feat_flags = dev_info.feature_flags;
13516 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13517 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13518 printf("Device doesn't support RAW data-path APIs.\n");
13519 return TEST_SKIPPED;
13522 /* Verify the capabilities */
13523 struct rte_cryptodev_sym_capability_idx cap_idx;
13524 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13525 cap_idx.algo.auth = reference->auth_algo;
13526 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13528 return TEST_SKIPPED;
13529 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13530 cap_idx.algo.cipher = reference->crypto_algo;
13531 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13533 return TEST_SKIPPED;
13535 /* Create session */
13536 memcpy(cipher_key, reference->cipher_key.data,
13537 reference->cipher_key.len);
13538 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13540 /* Setup Cipher Parameters */
13541 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13542 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13543 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
13544 ut_params->cipher_xform.cipher.key.data = cipher_key;
13545 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13546 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13547 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13549 ut_params->cipher_xform.next = &ut_params->auth_xform;
13551 /* Setup Authentication Parameters */
13552 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13553 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
13554 ut_params->auth_xform.auth.algo = reference->auth_algo;
13555 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13556 ut_params->auth_xform.auth.key.data = auth_key;
13557 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13558 ut_params->auth_xform.next = NULL;
13560 /* Create Crypto session*/
13561 ut_params->sess = rte_cryptodev_sym_session_create(
13562 ts_params->session_mpool);
13563 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13565 status = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13567 &ut_params->cipher_xform,
13568 ts_params->session_priv_mpool);
13570 if (status == -ENOTSUP)
13571 return TEST_SKIPPED;
13573 TEST_ASSERT_EQUAL(status, 0, "Session init failed");
13575 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13576 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13577 "Failed to allocate input buffer in mempool");
13579 /* clear mbuf payload */
13580 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13581 rte_pktmbuf_tailroom(ut_params->ibuf));
13583 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13584 reference->plaintext.len);
13585 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
13586 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
13588 /* Create operation */
13589 retval = create_cipher_auth_operation(ts_params,
13596 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13597 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13599 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13600 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13601 ut_params->op, 1, 1, 0, 0);
13603 ut_params->op = process_crypto_request(
13604 ts_params->valid_devs[0], ut_params->op);
13606 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
13608 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13609 "crypto op processing failed");
13611 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
13613 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
13614 ut_params->op->sym->auth.data.offset);
13615 auth_tag = authciphertext + plaintext_pad_len;
13616 debug_hexdump(stdout, "ciphertext:", authciphertext,
13617 reference->ciphertext.len);
13618 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
13620 /* Validate obuf */
13621 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13623 reference->ciphertext.data,
13624 reference->ciphertext.len,
13625 "Ciphertext data not as expected");
13627 TEST_ASSERT_BUFFERS_ARE_EQUAL(
13629 reference->digest.data,
13630 reference->digest.len,
13631 "Generated digest not as expected");
13633 return TEST_SUCCESS;
13638 test_authenticated_decrypt_with_esn(
13639 struct crypto_testsuite_params *ts_params,
13640 struct crypto_unittest_params *ut_params,
13641 const struct test_crypto_vector *reference)
13645 uint8_t *ciphertext;
13646 uint8_t cipher_key[reference->cipher_key.len + 1];
13647 uint8_t auth_key[reference->auth_key.len + 1];
13648 struct rte_cryptodev_info dev_info;
13650 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13651 uint64_t feat_flags = dev_info.feature_flags;
13653 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13654 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13655 printf("Device doesn't support RAW data-path APIs.\n");
13656 return TEST_SKIPPED;
13659 /* Verify the capabilities */
13660 struct rte_cryptodev_sym_capability_idx cap_idx;
13661 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13662 cap_idx.algo.auth = reference->auth_algo;
13663 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13665 return TEST_SKIPPED;
13666 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13667 cap_idx.algo.cipher = reference->crypto_algo;
13668 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13670 return TEST_SKIPPED;
13672 /* Create session */
13673 memcpy(cipher_key, reference->cipher_key.data,
13674 reference->cipher_key.len);
13675 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
13677 /* Setup Authentication Parameters */
13678 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
13679 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
13680 ut_params->auth_xform.auth.algo = reference->auth_algo;
13681 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
13682 ut_params->auth_xform.auth.key.data = auth_key;
13683 ut_params->auth_xform.auth.digest_length = reference->digest.len;
13684 ut_params->auth_xform.next = &ut_params->cipher_xform;
13686 /* Setup Cipher Parameters */
13687 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
13688 ut_params->cipher_xform.next = NULL;
13689 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
13690 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
13691 ut_params->cipher_xform.cipher.key.data = cipher_key;
13692 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
13693 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
13694 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
13696 /* Create Crypto session*/
13697 ut_params->sess = rte_cryptodev_sym_session_create(
13698 ts_params->session_mpool);
13699 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
13701 retval = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
13703 &ut_params->auth_xform,
13704 ts_params->session_priv_mpool);
13706 if (retval == -ENOTSUP)
13707 return TEST_SKIPPED;
13709 TEST_ASSERT_EQUAL(retval, 0, "Session init failed");
13711 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13712 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
13713 "Failed to allocate input buffer in mempool");
13715 /* clear mbuf payload */
13716 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13717 rte_pktmbuf_tailroom(ut_params->ibuf));
13719 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13720 reference->ciphertext.len);
13721 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
13722 memcpy(ciphertext, reference->ciphertext.data,
13723 reference->ciphertext.len);
13725 /* Create operation */
13726 retval = create_cipher_auth_verify_operation(ts_params,
13733 if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13734 process_cpu_crypt_auth_op(ts_params->valid_devs[0],
13736 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13737 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13738 ut_params->op, 1, 1, 0, 0);
13740 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
13743 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
13744 TEST_ASSERT_EQUAL(ut_params->op->status,
13745 RTE_CRYPTO_OP_STATUS_SUCCESS,
13746 "crypto op processing passed");
13748 ut_params->obuf = ut_params->op->sym->m_src;
13749 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
13755 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
13756 const struct aead_test_data *tdata,
13757 void *digest_mem, uint64_t digest_phys)
13759 struct crypto_testsuite_params *ts_params = &testsuite_params;
13760 struct crypto_unittest_params *ut_params = &unittest_params;
13762 const unsigned int auth_tag_len = tdata->auth_tag.len;
13763 const unsigned int iv_len = tdata->iv.len;
13764 unsigned int aad_len = tdata->aad.len;
13765 unsigned int aad_len_pad = 0;
13767 /* Generate Crypto op data structure */
13768 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
13769 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
13770 TEST_ASSERT_NOT_NULL(ut_params->op,
13771 "Failed to allocate symmetric crypto operation struct");
13773 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
13775 sym_op->aead.digest.data = digest_mem;
13777 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
13778 "no room to append digest");
13780 sym_op->aead.digest.phys_addr = digest_phys;
13782 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
13783 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
13785 debug_hexdump(stdout, "digest:",
13786 sym_op->aead.digest.data,
13790 /* Append aad data */
13791 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
13792 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13793 uint8_t *, IV_OFFSET);
13795 /* Copy IV 1 byte after the IV pointer, according to the API */
13796 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
13798 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
13800 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13801 ut_params->ibuf, aad_len);
13802 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13803 "no room to prepend aad");
13804 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13807 memset(sym_op->aead.aad.data, 0, aad_len);
13808 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
13809 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13811 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13812 debug_hexdump(stdout, "aad:",
13813 sym_op->aead.aad.data, aad_len);
13815 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
13816 uint8_t *, IV_OFFSET);
13818 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
13820 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
13822 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
13823 ut_params->ibuf, aad_len_pad);
13824 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
13825 "no room to prepend aad");
13826 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
13829 memset(sym_op->aead.aad.data, 0, aad_len);
13830 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
13832 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
13833 debug_hexdump(stdout, "aad:",
13834 sym_op->aead.aad.data, aad_len);
13837 sym_op->aead.data.length = tdata->plaintext.len;
13838 sym_op->aead.data.offset = aad_len_pad;
13843 #define SGL_MAX_NO 16
13846 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
13847 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
13849 struct crypto_testsuite_params *ts_params = &testsuite_params;
13850 struct crypto_unittest_params *ut_params = &unittest_params;
13851 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
13854 int to_trn_tbl[SGL_MAX_NO];
13856 unsigned int trn_data = 0;
13857 uint8_t *plaintext, *ciphertext, *auth_tag;
13858 struct rte_cryptodev_info dev_info;
13860 /* Verify the capabilities */
13861 struct rte_cryptodev_sym_capability_idx cap_idx;
13862 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
13863 cap_idx.algo.aead = tdata->algo;
13864 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
13866 return TEST_SKIPPED;
13868 /* OOP not supported with CPU crypto */
13869 if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13870 return TEST_SKIPPED;
13872 /* Detailed check for the particular SGL support flag */
13873 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
13875 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13876 if (sgl_in && (!(dev_info.feature_flags &
13877 RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
13878 return TEST_SKIPPED;
13880 uint64_t feat_flags = dev_info.feature_flags;
13882 if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
13883 (!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
13884 printf("Device doesn't support RAW data-path APIs.\n");
13885 return TEST_SKIPPED;
13888 unsigned int sgl_in = fragsz < tdata->plaintext.len;
13889 unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
13890 tdata->plaintext.len;
13891 /* Raw data path API does not support OOP */
13892 if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13893 return TEST_SKIPPED;
13894 if (sgl_in && !sgl_out) {
13895 if (!(dev_info.feature_flags &
13896 RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
13897 return TEST_SKIPPED;
13898 } else if (!sgl_in && sgl_out) {
13899 if (!(dev_info.feature_flags &
13900 RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
13901 return TEST_SKIPPED;
13902 } else if (sgl_in && sgl_out) {
13903 if (!(dev_info.feature_flags &
13904 RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13905 return TEST_SKIPPED;
13909 if (fragsz > tdata->plaintext.len)
13910 fragsz = tdata->plaintext.len;
13912 uint16_t plaintext_len = fragsz;
13913 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13915 if (fragsz_oop > tdata->plaintext.len)
13916 frag_size_oop = tdata->plaintext.len;
13919 void *digest_mem = NULL;
13921 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13923 if (tdata->plaintext.len % fragsz != 0) {
13924 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13927 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13932 * For out-op-place we need to alloc another mbuf
13935 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13936 rte_pktmbuf_append(ut_params->obuf,
13937 frag_size_oop + prepend_len);
13938 buf_oop = ut_params->obuf;
13941 /* Create AEAD session */
13942 retval = create_aead_session(ts_params->valid_devs[0],
13944 RTE_CRYPTO_AEAD_OP_ENCRYPT,
13945 tdata->key.data, tdata->key.len,
13946 tdata->aad.len, tdata->auth_tag.len,
13951 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13953 /* clear mbuf payload */
13954 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13955 rte_pktmbuf_tailroom(ut_params->ibuf));
13957 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13960 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13962 trn_data += plaintext_len;
13964 buf = ut_params->ibuf;
13967 * Loop until no more fragments
13970 while (trn_data < tdata->plaintext.len) {
13972 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13973 (tdata->plaintext.len - trn_data) : fragsz;
13975 to_trn_tbl[ecx++] = to_trn;
13977 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13980 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13981 rte_pktmbuf_tailroom(buf));
13984 if (oop && !fragsz_oop) {
13985 buf_last_oop = buf_oop->next =
13986 rte_pktmbuf_alloc(ts_params->mbuf_pool);
13987 buf_oop = buf_oop->next;
13988 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13989 0, rte_pktmbuf_tailroom(buf_oop));
13990 rte_pktmbuf_append(buf_oop, to_trn);
13993 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13996 memcpy(plaintext, tdata->plaintext.data + trn_data,
13998 trn_data += to_trn;
13999 if (trn_data == tdata->plaintext.len) {
14002 digest_mem = rte_pktmbuf_append(buf_oop,
14003 tdata->auth_tag.len);
14005 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
14006 tdata->auth_tag.len);
14010 uint64_t digest_phys = 0;
14012 ut_params->ibuf->nb_segs = segs;
14015 if (fragsz_oop && oop) {
14019 if (frag_size_oop == tdata->plaintext.len) {
14020 digest_mem = rte_pktmbuf_append(ut_params->obuf,
14021 tdata->auth_tag.len);
14023 digest_phys = rte_pktmbuf_iova_offset(
14025 tdata->plaintext.len + prepend_len);
14028 trn_data = frag_size_oop;
14029 while (trn_data < tdata->plaintext.len) {
14032 (tdata->plaintext.len - trn_data <
14034 (tdata->plaintext.len - trn_data) :
14037 to_trn_tbl[ecx++] = to_trn;
14039 buf_last_oop = buf_oop->next =
14040 rte_pktmbuf_alloc(ts_params->mbuf_pool);
14041 buf_oop = buf_oop->next;
14042 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
14043 0, rte_pktmbuf_tailroom(buf_oop));
14044 rte_pktmbuf_append(buf_oop, to_trn);
14046 trn_data += to_trn;
14048 if (trn_data == tdata->plaintext.len) {
14049 digest_mem = rte_pktmbuf_append(buf_oop,
14050 tdata->auth_tag.len);
14054 ut_params->obuf->nb_segs = segs;
14058 * Place digest at the end of the last buffer
14061 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
14062 if (oop && buf_last_oop)
14063 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
14065 if (!digest_mem && !oop) {
14066 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
14067 + tdata->auth_tag.len);
14068 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
14069 tdata->plaintext.len);
14072 /* Create AEAD operation */
14073 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
14074 tdata, digest_mem, digest_phys);
14079 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
14081 ut_params->op->sym->m_src = ut_params->ibuf;
14083 ut_params->op->sym->m_dst = ut_params->obuf;
14085 /* Process crypto operation */
14086 if (oop == IN_PLACE &&
14087 gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
14088 process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
14089 else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
14090 process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
14091 ut_params->op, 0, 0, 0, 0);
14093 TEST_ASSERT_NOT_NULL(
14094 process_crypto_request(ts_params->valid_devs[0],
14095 ut_params->op), "failed to process sym crypto op");
14097 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
14098 "crypto op processing failed");
14101 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
14102 uint8_t *, prepend_len);
14104 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
14105 uint8_t *, prepend_len);
14109 fragsz = fragsz_oop;
14111 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14113 tdata->ciphertext.data,
14115 "Ciphertext data not as expected");
14117 buf = ut_params->op->sym->m_src->next;
14119 buf = ut_params->op->sym->m_dst->next;
14121 unsigned int off = fragsz;
14125 ciphertext = rte_pktmbuf_mtod(buf,
14128 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14130 tdata->ciphertext.data + off,
14132 "Ciphertext data not as expected");
14134 off += to_trn_tbl[ecx++];
14138 auth_tag = digest_mem;
14139 TEST_ASSERT_BUFFERS_ARE_EQUAL(
14141 tdata->auth_tag.data,
14142 tdata->auth_tag.len,
14143 "Generated auth tag not as expected");
14149 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
14151 return test_authenticated_encryption_SGL(
14152 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
14156 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
14158 return test_authenticated_encryption_SGL(
14159 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
14163 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
14165 return test_authenticated_encryption_SGL(
14166 &gcm_test_case_8, OUT_OF_PLACE, 400,
14167 gcm_test_case_8.plaintext.len);
14171 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
14173 /* This test is not for OPENSSL PMD */
14174 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14175 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
14176 return TEST_SKIPPED;
14178 return test_authenticated_encryption_SGL(
14179 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
14183 test_authentication_verify_fail_when_data_corrupted(
14184 struct crypto_testsuite_params *ts_params,
14185 struct crypto_unittest_params *ut_params,
14186 const struct test_crypto_vector *reference)
14188 return test_authentication_verify_fail_when_data_corruption(
14189 ts_params, ut_params, reference, 1);
14193 test_authentication_verify_fail_when_tag_corrupted(
14194 struct crypto_testsuite_params *ts_params,
14195 struct crypto_unittest_params *ut_params,
14196 const struct test_crypto_vector *reference)
14198 return test_authentication_verify_fail_when_data_corruption(
14199 ts_params, ut_params, reference, 0);
14203 test_authentication_verify_GMAC_fail_when_data_corrupted(
14204 struct crypto_testsuite_params *ts_params,
14205 struct crypto_unittest_params *ut_params,
14206 const struct test_crypto_vector *reference)
14208 return test_authentication_verify_GMAC_fail_when_corruption(
14209 ts_params, ut_params, reference, 1);
14213 test_authentication_verify_GMAC_fail_when_tag_corrupted(
14214 struct crypto_testsuite_params *ts_params,
14215 struct crypto_unittest_params *ut_params,
14216 const struct test_crypto_vector *reference)
14218 return test_authentication_verify_GMAC_fail_when_corruption(
14219 ts_params, ut_params, reference, 0);
14223 test_authenticated_decryption_fail_when_data_corrupted(
14224 struct crypto_testsuite_params *ts_params,
14225 struct crypto_unittest_params *ut_params,
14226 const struct test_crypto_vector *reference)
14228 return test_authenticated_decryption_fail_when_corruption(
14229 ts_params, ut_params, reference, 1);
14233 test_authenticated_decryption_fail_when_tag_corrupted(
14234 struct crypto_testsuite_params *ts_params,
14235 struct crypto_unittest_params *ut_params,
14236 const struct test_crypto_vector *reference)
14238 return test_authenticated_decryption_fail_when_corruption(
14239 ts_params, ut_params, reference, 0);
14243 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
14245 return test_authentication_verify_fail_when_data_corrupted(
14246 &testsuite_params, &unittest_params,
14247 &hmac_sha1_test_crypto_vector);
14251 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
14253 return test_authentication_verify_fail_when_tag_corrupted(
14254 &testsuite_params, &unittest_params,
14255 &hmac_sha1_test_crypto_vector);
14259 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
14261 return test_authentication_verify_GMAC_fail_when_data_corrupted(
14262 &testsuite_params, &unittest_params,
14263 &aes128_gmac_test_vector);
14267 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
14269 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
14270 &testsuite_params, &unittest_params,
14271 &aes128_gmac_test_vector);
14275 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
14277 return test_authenticated_decryption_fail_when_data_corrupted(
14280 &aes128cbc_hmac_sha1_test_vector);
14284 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
14286 return test_authenticated_decryption_fail_when_tag_corrupted(
14289 &aes128cbc_hmac_sha1_test_vector);
14293 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14295 return test_authenticated_encrypt_with_esn(
14298 &aes128cbc_hmac_sha1_aad_test_vector);
14302 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
14304 return test_authenticated_decrypt_with_esn(
14307 &aes128cbc_hmac_sha1_aad_test_vector);
14311 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
14313 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
14317 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
14319 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
14323 test_chacha20_poly1305_encrypt_SGL_out_of_place(void)
14325 return test_authenticated_encryption_SGL(
14326 &chacha20_poly1305_case_2, OUT_OF_PLACE, 32,
14327 chacha20_poly1305_case_2.plaintext.len);
14330 #ifdef RTE_CRYPTO_SCHEDULER
14332 /* global AESNI worker IDs for the scheduler test */
14333 uint8_t aesni_ids[2];
14336 scheduler_testsuite_setup(void)
14339 int32_t nb_devs, ret;
14340 char vdev_args[VDEV_ARGS_SIZE] = {""};
14341 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
14342 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
14343 uint16_t worker_core_count = 0;
14344 uint16_t socket_id = 0;
14346 if (gbl_driver_id == rte_cryptodev_driver_id_get(
14347 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
14349 /* Identify the Worker Cores
14350 * Use 2 worker cores for the device args
14352 RTE_LCORE_FOREACH_WORKER(i) {
14353 if (worker_core_count > 1)
14355 snprintf(vdev_args, sizeof(vdev_args),
14356 "%s%d", temp_str, i);
14357 strcpy(temp_str, vdev_args);
14358 strlcat(temp_str, ";", sizeof(temp_str));
14359 worker_core_count++;
14360 socket_id = rte_lcore_to_socket_id(i);
14362 if (worker_core_count != 2) {
14363 RTE_LOG(ERR, USER1,
14364 "Cryptodev scheduler test require at least "
14365 "two worker cores to run. "
14366 "Please use the correct coremask.\n");
14367 return TEST_FAILED;
14369 strcpy(temp_str, vdev_args);
14370 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
14371 temp_str, socket_id);
14372 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
14373 nb_devs = rte_cryptodev_device_count_by_driver(
14374 rte_cryptodev_driver_id_get(
14375 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
14377 ret = rte_vdev_init(
14378 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
14380 TEST_ASSERT(ret == 0,
14381 "Failed to create instance %u of pmd : %s",
14382 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14385 return testsuite_setup();
14389 test_scheduler_attach_worker_op(void)
14391 struct crypto_testsuite_params *ts_params = &testsuite_params;
14392 uint8_t sched_id = ts_params->valid_devs[0];
14393 uint32_t i, nb_devs_attached = 0;
14395 char vdev_name[32];
14396 unsigned int count = rte_cryptodev_count();
14398 /* create 2 AESNI_MB vdevs on top of existing devices */
14399 for (i = count; i < count + 2; i++) {
14400 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
14401 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
14403 ret = rte_vdev_init(vdev_name, NULL);
14405 TEST_ASSERT(ret == 0,
14406 "Failed to create instance %u of"
14408 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14411 RTE_LOG(ERR, USER1,
14412 "Failed to create 2 AESNI MB PMDs.\n");
14413 return TEST_SKIPPED;
14417 /* attach 2 AESNI_MB cdevs */
14418 for (i = count; i < count + 2; i++) {
14419 struct rte_cryptodev_info info;
14420 unsigned int session_size;
14422 rte_cryptodev_info_get(i, &info);
14423 if (info.driver_id != rte_cryptodev_driver_id_get(
14424 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
14427 session_size = rte_cryptodev_sym_get_private_session_size(i);
14429 * Create the session mempool again, since now there are new devices
14430 * to use the mempool.
14432 if (ts_params->session_mpool) {
14433 rte_mempool_free(ts_params->session_mpool);
14434 ts_params->session_mpool = NULL;
14436 if (ts_params->session_priv_mpool) {
14437 rte_mempool_free(ts_params->session_priv_mpool);
14438 ts_params->session_priv_mpool = NULL;
14441 if (info.sym.max_nb_sessions != 0 &&
14442 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
14443 RTE_LOG(ERR, USER1,
14444 "Device does not support "
14445 "at least %u sessions\n",
14447 return TEST_FAILED;
14450 * Create mempool with maximum number of sessions,
14451 * to include the session headers
14453 if (ts_params->session_mpool == NULL) {
14454 ts_params->session_mpool =
14455 rte_cryptodev_sym_session_pool_create(
14457 MAX_NB_SESSIONS, 0, 0, 0,
14459 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
14460 "session mempool allocation failed");
14464 * Create mempool with maximum number of sessions,
14465 * to include device specific session private data
14467 if (ts_params->session_priv_mpool == NULL) {
14468 ts_params->session_priv_mpool = rte_mempool_create(
14469 "test_sess_mp_priv",
14472 0, 0, NULL, NULL, NULL,
14473 NULL, SOCKET_ID_ANY,
14476 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
14477 "session mempool allocation failed");
14480 ts_params->qp_conf.mp_session = ts_params->session_mpool;
14481 ts_params->qp_conf.mp_session_private =
14482 ts_params->session_priv_mpool;
14484 ret = rte_cryptodev_scheduler_worker_attach(sched_id,
14487 TEST_ASSERT(ret == 0,
14488 "Failed to attach device %u of pmd : %s", i,
14489 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14491 aesni_ids[nb_devs_attached] = (uint8_t)i;
14493 nb_devs_attached++;
14500 test_scheduler_detach_worker_op(void)
14502 struct crypto_testsuite_params *ts_params = &testsuite_params;
14503 uint8_t sched_id = ts_params->valid_devs[0];
14507 for (i = 0; i < 2; i++) {
14508 ret = rte_cryptodev_scheduler_worker_detach(sched_id,
14510 TEST_ASSERT(ret == 0,
14511 "Failed to detach device %u", aesni_ids[i]);
14518 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
14520 struct crypto_testsuite_params *ts_params = &testsuite_params;
14521 uint8_t sched_id = ts_params->valid_devs[0];
14523 return rte_cryptodev_scheduler_mode_set(sched_id,
14528 test_scheduler_mode_roundrobin_op(void)
14530 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
14531 0, "Failed to set roundrobin mode");
14537 test_scheduler_mode_multicore_op(void)
14539 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
14540 0, "Failed to set multicore mode");
14546 test_scheduler_mode_failover_op(void)
14548 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
14549 0, "Failed to set failover mode");
14555 test_scheduler_mode_pkt_size_distr_op(void)
14557 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
14558 0, "Failed to set pktsize mode");
14564 scheduler_multicore_testsuite_setup(void)
14566 if (test_scheduler_attach_worker_op() < 0)
14567 return TEST_SKIPPED;
14568 if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
14569 return TEST_SKIPPED;
14574 scheduler_roundrobin_testsuite_setup(void)
14576 if (test_scheduler_attach_worker_op() < 0)
14577 return TEST_SKIPPED;
14578 if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
14579 return TEST_SKIPPED;
14584 scheduler_failover_testsuite_setup(void)
14586 if (test_scheduler_attach_worker_op() < 0)
14587 return TEST_SKIPPED;
14588 if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
14589 return TEST_SKIPPED;
14594 scheduler_pkt_size_distr_testsuite_setup(void)
14596 if (test_scheduler_attach_worker_op() < 0)
14597 return TEST_SKIPPED;
14598 if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
14599 return TEST_SKIPPED;
14604 scheduler_mode_testsuite_teardown(void)
14606 test_scheduler_detach_worker_op();
14609 #endif /* RTE_CRYPTO_SCHEDULER */
14611 static struct unit_test_suite end_testsuite = {
14612 .suite_name = NULL,
14615 .unit_test_suites = NULL
14618 #ifdef RTE_LIB_SECURITY
14619 static struct unit_test_suite ipsec_proto_testsuite = {
14620 .suite_name = "IPsec Proto Unit Test Suite",
14621 .setup = ipsec_proto_testsuite_setup,
14622 .unit_test_cases = {
14623 TEST_CASE_NAMED_WITH_DATA(
14624 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14625 ut_setup_security, ut_teardown,
14626 test_ipsec_proto_known_vec, &pkt_aes_128_gcm),
14627 TEST_CASE_NAMED_WITH_DATA(
14628 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14629 ut_setup_security, ut_teardown,
14630 test_ipsec_proto_known_vec, &pkt_aes_192_gcm),
14631 TEST_CASE_NAMED_WITH_DATA(
14632 "Outbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14633 ut_setup_security, ut_teardown,
14634 test_ipsec_proto_known_vec, &pkt_aes_256_gcm),
14635 TEST_CASE_NAMED_WITH_DATA(
14636 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14637 ut_setup_security, ut_teardown,
14638 test_ipsec_proto_known_vec,
14639 &pkt_aes_128_cbc_hmac_sha256),
14640 TEST_CASE_NAMED_WITH_DATA(
14641 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14642 ut_setup_security, ut_teardown,
14643 test_ipsec_proto_known_vec,
14644 &pkt_aes_128_cbc_hmac_sha384),
14645 TEST_CASE_NAMED_WITH_DATA(
14646 "Outbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14647 ut_setup_security, ut_teardown,
14648 test_ipsec_proto_known_vec,
14649 &pkt_aes_128_cbc_hmac_sha512),
14650 TEST_CASE_NAMED_WITH_DATA(
14651 "Outbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14652 ut_setup_security, ut_teardown,
14653 test_ipsec_proto_known_vec, &pkt_aes_256_gcm_v6),
14654 TEST_CASE_NAMED_WITH_DATA(
14655 "Outbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14656 ut_setup_security, ut_teardown,
14657 test_ipsec_proto_known_vec,
14658 &pkt_aes_128_cbc_hmac_sha256_v6),
14659 TEST_CASE_NAMED_WITH_DATA(
14660 "Outbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14661 ut_setup_security, ut_teardown,
14662 test_ipsec_proto_known_vec,
14663 &pkt_null_aes_xcbc),
14664 TEST_CASE_NAMED_WITH_DATA(
14665 "Outbound fragmented packet",
14666 ut_setup_security, ut_teardown,
14667 test_ipsec_proto_known_vec_fragmented,
14668 &pkt_aes_128_gcm_frag),
14669 TEST_CASE_NAMED_WITH_DATA(
14670 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 128)",
14671 ut_setup_security, ut_teardown,
14672 test_ipsec_proto_known_vec_inb, &pkt_aes_128_gcm),
14673 TEST_CASE_NAMED_WITH_DATA(
14674 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 192)",
14675 ut_setup_security, ut_teardown,
14676 test_ipsec_proto_known_vec_inb, &pkt_aes_192_gcm),
14677 TEST_CASE_NAMED_WITH_DATA(
14678 "Inbound known vector (ESP tunnel mode IPv4 AES-GCM 256)",
14679 ut_setup_security, ut_teardown,
14680 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm),
14681 TEST_CASE_NAMED_WITH_DATA(
14682 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128)",
14683 ut_setup_security, ut_teardown,
14684 test_ipsec_proto_known_vec_inb, &pkt_aes_128_cbc_null),
14685 TEST_CASE_NAMED_WITH_DATA(
14686 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14687 ut_setup_security, ut_teardown,
14688 test_ipsec_proto_known_vec_inb,
14689 &pkt_aes_128_cbc_hmac_sha256),
14690 TEST_CASE_NAMED_WITH_DATA(
14691 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA384 [24B ICV])",
14692 ut_setup_security, ut_teardown,
14693 test_ipsec_proto_known_vec_inb,
14694 &pkt_aes_128_cbc_hmac_sha384),
14695 TEST_CASE_NAMED_WITH_DATA(
14696 "Inbound known vector (ESP tunnel mode IPv4 AES-CBC 128 HMAC-SHA512 [32B ICV])",
14697 ut_setup_security, ut_teardown,
14698 test_ipsec_proto_known_vec_inb,
14699 &pkt_aes_128_cbc_hmac_sha512),
14700 TEST_CASE_NAMED_WITH_DATA(
14701 "Inbound known vector (ESP tunnel mode IPv6 AES-GCM 128)",
14702 ut_setup_security, ut_teardown,
14703 test_ipsec_proto_known_vec_inb, &pkt_aes_256_gcm_v6),
14704 TEST_CASE_NAMED_WITH_DATA(
14705 "Inbound known vector (ESP tunnel mode IPv6 AES-CBC 128 HMAC-SHA256 [16B ICV])",
14706 ut_setup_security, ut_teardown,
14707 test_ipsec_proto_known_vec_inb,
14708 &pkt_aes_128_cbc_hmac_sha256_v6),
14709 TEST_CASE_NAMED_WITH_DATA(
14710 "Inbound known vector (ESP tunnel mode IPv4 NULL AES-XCBC-MAC [12B ICV])",
14711 ut_setup_security, ut_teardown,
14712 test_ipsec_proto_known_vec_inb,
14713 &pkt_null_aes_xcbc),
14714 TEST_CASE_NAMED_ST(
14715 "Combined test alg list",
14716 ut_setup_security, ut_teardown,
14717 test_ipsec_proto_display_list),
14718 TEST_CASE_NAMED_ST(
14720 ut_setup_security, ut_teardown,
14721 test_ipsec_proto_iv_gen),
14722 TEST_CASE_NAMED_ST(
14723 "UDP encapsulation",
14724 ut_setup_security, ut_teardown,
14725 test_ipsec_proto_udp_encap),
14726 TEST_CASE_NAMED_ST(
14727 "UDP encapsulation ports verification test",
14728 ut_setup_security, ut_teardown,
14729 test_ipsec_proto_udp_ports_verify),
14730 TEST_CASE_NAMED_ST(
14731 "SA expiry packets soft",
14732 ut_setup_security, ut_teardown,
14733 test_ipsec_proto_sa_exp_pkts_soft),
14734 TEST_CASE_NAMED_ST(
14735 "SA expiry packets hard",
14736 ut_setup_security, ut_teardown,
14737 test_ipsec_proto_sa_exp_pkts_hard),
14738 TEST_CASE_NAMED_ST(
14739 "Negative test: ICV corruption",
14740 ut_setup_security, ut_teardown,
14741 test_ipsec_proto_err_icv_corrupt),
14742 TEST_CASE_NAMED_ST(
14743 "Tunnel dst addr verification",
14744 ut_setup_security, ut_teardown,
14745 test_ipsec_proto_tunnel_dst_addr_verify),
14746 TEST_CASE_NAMED_ST(
14747 "Tunnel src and dst addr verification",
14748 ut_setup_security, ut_teardown,
14749 test_ipsec_proto_tunnel_src_dst_addr_verify),
14750 TEST_CASE_NAMED_ST(
14751 "Inner IP checksum",
14752 ut_setup_security, ut_teardown,
14753 test_ipsec_proto_inner_ip_csum),
14754 TEST_CASE_NAMED_ST(
14755 "Inner L4 checksum",
14756 ut_setup_security, ut_teardown,
14757 test_ipsec_proto_inner_l4_csum),
14758 TEST_CASE_NAMED_ST(
14759 "Tunnel IPv4 in IPv4",
14760 ut_setup_security, ut_teardown,
14761 test_ipsec_proto_tunnel_v4_in_v4),
14762 TEST_CASE_NAMED_ST(
14763 "Tunnel IPv6 in IPv6",
14764 ut_setup_security, ut_teardown,
14765 test_ipsec_proto_tunnel_v6_in_v6),
14766 TEST_CASE_NAMED_ST(
14767 "Tunnel IPv4 in IPv6",
14768 ut_setup_security, ut_teardown,
14769 test_ipsec_proto_tunnel_v4_in_v6),
14770 TEST_CASE_NAMED_ST(
14771 "Tunnel IPv6 in IPv4",
14772 ut_setup_security, ut_teardown,
14773 test_ipsec_proto_tunnel_v6_in_v4),
14774 TEST_CASE_NAMED_ST(
14776 ut_setup_security, ut_teardown,
14777 test_ipsec_proto_transport_v4),
14778 TEST_CASE_NAMED_ST(
14779 "Statistics: success",
14780 ut_setup_security, ut_teardown,
14781 test_ipsec_proto_stats),
14782 TEST_CASE_NAMED_ST(
14783 "Fragmented packet",
14784 ut_setup_security, ut_teardown,
14785 test_ipsec_proto_pkt_fragment),
14786 TEST_CASE_NAMED_ST(
14787 "Tunnel header copy DF (inner 0)",
14788 ut_setup_security, ut_teardown,
14789 test_ipsec_proto_copy_df_inner_0),
14790 TEST_CASE_NAMED_ST(
14791 "Tunnel header copy DF (inner 1)",
14792 ut_setup_security, ut_teardown,
14793 test_ipsec_proto_copy_df_inner_1),
14794 TEST_CASE_NAMED_ST(
14795 "Tunnel header set DF 0 (inner 1)",
14796 ut_setup_security, ut_teardown,
14797 test_ipsec_proto_set_df_0_inner_1),
14798 TEST_CASE_NAMED_ST(
14799 "Tunnel header set DF 1 (inner 0)",
14800 ut_setup_security, ut_teardown,
14801 test_ipsec_proto_set_df_1_inner_0),
14802 TEST_CASES_END() /**< NULL terminate unit test array */
14806 static struct unit_test_suite pdcp_proto_testsuite = {
14807 .suite_name = "PDCP Proto Unit Test Suite",
14808 .setup = pdcp_proto_testsuite_setup,
14809 .unit_test_cases = {
14810 TEST_CASE_ST(ut_setup_security, ut_teardown,
14811 test_PDCP_PROTO_all),
14812 TEST_CASES_END() /**< NULL terminate unit test array */
14816 #define ADD_UPLINK_TESTCASE(data) \
14817 TEST_CASE_NAMED_WITH_DATA(data.test_descr_uplink, ut_setup_security, \
14818 ut_teardown, test_docsis_proto_uplink, (const void *) &data), \
14820 #define ADD_DOWNLINK_TESTCASE(data) \
14821 TEST_CASE_NAMED_WITH_DATA(data.test_descr_downlink, ut_setup_security, \
14822 ut_teardown, test_docsis_proto_downlink, (const void *) &data), \
14824 static struct unit_test_suite docsis_proto_testsuite = {
14825 .suite_name = "DOCSIS Proto Unit Test Suite",
14826 .setup = docsis_proto_testsuite_setup,
14827 .unit_test_cases = {
14829 ADD_UPLINK_TESTCASE(docsis_test_case_1)
14830 ADD_UPLINK_TESTCASE(docsis_test_case_2)
14831 ADD_UPLINK_TESTCASE(docsis_test_case_3)
14832 ADD_UPLINK_TESTCASE(docsis_test_case_4)
14833 ADD_UPLINK_TESTCASE(docsis_test_case_5)
14834 ADD_UPLINK_TESTCASE(docsis_test_case_6)
14835 ADD_UPLINK_TESTCASE(docsis_test_case_7)
14836 ADD_UPLINK_TESTCASE(docsis_test_case_8)
14837 ADD_UPLINK_TESTCASE(docsis_test_case_9)
14838 ADD_UPLINK_TESTCASE(docsis_test_case_10)
14839 ADD_UPLINK_TESTCASE(docsis_test_case_11)
14840 ADD_UPLINK_TESTCASE(docsis_test_case_12)
14841 ADD_UPLINK_TESTCASE(docsis_test_case_13)
14842 ADD_UPLINK_TESTCASE(docsis_test_case_14)
14843 ADD_UPLINK_TESTCASE(docsis_test_case_15)
14844 ADD_UPLINK_TESTCASE(docsis_test_case_16)
14845 ADD_UPLINK_TESTCASE(docsis_test_case_17)
14846 ADD_UPLINK_TESTCASE(docsis_test_case_18)
14847 ADD_UPLINK_TESTCASE(docsis_test_case_19)
14848 ADD_UPLINK_TESTCASE(docsis_test_case_20)
14849 ADD_UPLINK_TESTCASE(docsis_test_case_21)
14850 ADD_UPLINK_TESTCASE(docsis_test_case_22)
14851 ADD_UPLINK_TESTCASE(docsis_test_case_23)
14852 ADD_UPLINK_TESTCASE(docsis_test_case_24)
14853 ADD_UPLINK_TESTCASE(docsis_test_case_25)
14854 ADD_UPLINK_TESTCASE(docsis_test_case_26)
14856 ADD_DOWNLINK_TESTCASE(docsis_test_case_1)
14857 ADD_DOWNLINK_TESTCASE(docsis_test_case_2)
14858 ADD_DOWNLINK_TESTCASE(docsis_test_case_3)
14859 ADD_DOWNLINK_TESTCASE(docsis_test_case_4)
14860 ADD_DOWNLINK_TESTCASE(docsis_test_case_5)
14861 ADD_DOWNLINK_TESTCASE(docsis_test_case_6)
14862 ADD_DOWNLINK_TESTCASE(docsis_test_case_7)
14863 ADD_DOWNLINK_TESTCASE(docsis_test_case_8)
14864 ADD_DOWNLINK_TESTCASE(docsis_test_case_9)
14865 ADD_DOWNLINK_TESTCASE(docsis_test_case_10)
14866 ADD_DOWNLINK_TESTCASE(docsis_test_case_11)
14867 ADD_DOWNLINK_TESTCASE(docsis_test_case_12)
14868 ADD_DOWNLINK_TESTCASE(docsis_test_case_13)
14869 ADD_DOWNLINK_TESTCASE(docsis_test_case_14)
14870 ADD_DOWNLINK_TESTCASE(docsis_test_case_15)
14871 ADD_DOWNLINK_TESTCASE(docsis_test_case_16)
14872 ADD_DOWNLINK_TESTCASE(docsis_test_case_17)
14873 ADD_DOWNLINK_TESTCASE(docsis_test_case_18)
14874 ADD_DOWNLINK_TESTCASE(docsis_test_case_19)
14875 ADD_DOWNLINK_TESTCASE(docsis_test_case_20)
14876 ADD_DOWNLINK_TESTCASE(docsis_test_case_21)
14877 ADD_DOWNLINK_TESTCASE(docsis_test_case_22)
14878 ADD_DOWNLINK_TESTCASE(docsis_test_case_23)
14879 ADD_DOWNLINK_TESTCASE(docsis_test_case_24)
14880 ADD_DOWNLINK_TESTCASE(docsis_test_case_25)
14881 ADD_DOWNLINK_TESTCASE(docsis_test_case_26)
14882 TEST_CASES_END() /**< NULL terminate unit test array */
14887 static struct unit_test_suite cryptodev_gen_testsuite = {
14888 .suite_name = "Crypto General Unit Test Suite",
14889 .setup = crypto_gen_testsuite_setup,
14890 .unit_test_cases = {
14891 TEST_CASE_ST(ut_setup, ut_teardown,
14892 test_device_configure_invalid_dev_id),
14893 TEST_CASE_ST(ut_setup, ut_teardown,
14894 test_queue_pair_descriptor_setup),
14895 TEST_CASE_ST(ut_setup, ut_teardown,
14896 test_device_configure_invalid_queue_pair_ids),
14897 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
14898 TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
14899 TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
14900 TEST_CASES_END() /**< NULL terminate unit test array */
14904 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
14905 .suite_name = "Negative HMAC SHA1 Unit Test Suite",
14906 .setup = negative_hmac_sha1_testsuite_setup,
14907 .unit_test_cases = {
14908 /** Negative tests */
14909 TEST_CASE_ST(ut_setup, ut_teardown,
14910 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14911 TEST_CASE_ST(ut_setup, ut_teardown,
14912 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14913 TEST_CASE_ST(ut_setup, ut_teardown,
14914 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14915 TEST_CASE_ST(ut_setup, ut_teardown,
14916 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14918 TEST_CASES_END() /**< NULL terminate unit test array */
14922 static struct unit_test_suite cryptodev_multi_session_testsuite = {
14923 .suite_name = "Multi Session Unit Test Suite",
14924 .setup = multi_session_testsuite_setup,
14925 .unit_test_cases = {
14926 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14927 TEST_CASE_ST(ut_setup, ut_teardown,
14928 test_multi_session_random_usage),
14930 TEST_CASES_END() /**< NULL terminate unit test array */
14934 static struct unit_test_suite cryptodev_null_testsuite = {
14935 .suite_name = "NULL Test Suite",
14936 .setup = null_testsuite_setup,
14937 .unit_test_cases = {
14938 TEST_CASE_ST(ut_setup, ut_teardown,
14939 test_null_invalid_operation),
14940 TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
14945 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite = {
14946 .suite_name = "AES CCM Authenticated Test Suite",
14947 .setup = aes_ccm_auth_testsuite_setup,
14948 .unit_test_cases = {
14949 /** AES CCM Authenticated Encryption 128 bits key*/
14950 TEST_CASE_ST(ut_setup, ut_teardown,
14951 test_AES_CCM_authenticated_encryption_test_case_128_1),
14952 TEST_CASE_ST(ut_setup, ut_teardown,
14953 test_AES_CCM_authenticated_encryption_test_case_128_2),
14954 TEST_CASE_ST(ut_setup, ut_teardown,
14955 test_AES_CCM_authenticated_encryption_test_case_128_3),
14957 /** AES CCM Authenticated Decryption 128 bits key*/
14958 TEST_CASE_ST(ut_setup, ut_teardown,
14959 test_AES_CCM_authenticated_decryption_test_case_128_1),
14960 TEST_CASE_ST(ut_setup, ut_teardown,
14961 test_AES_CCM_authenticated_decryption_test_case_128_2),
14962 TEST_CASE_ST(ut_setup, ut_teardown,
14963 test_AES_CCM_authenticated_decryption_test_case_128_3),
14965 /** AES CCM Authenticated Encryption 192 bits key */
14966 TEST_CASE_ST(ut_setup, ut_teardown,
14967 test_AES_CCM_authenticated_encryption_test_case_192_1),
14968 TEST_CASE_ST(ut_setup, ut_teardown,
14969 test_AES_CCM_authenticated_encryption_test_case_192_2),
14970 TEST_CASE_ST(ut_setup, ut_teardown,
14971 test_AES_CCM_authenticated_encryption_test_case_192_3),
14973 /** AES CCM Authenticated Decryption 192 bits key*/
14974 TEST_CASE_ST(ut_setup, ut_teardown,
14975 test_AES_CCM_authenticated_decryption_test_case_192_1),
14976 TEST_CASE_ST(ut_setup, ut_teardown,
14977 test_AES_CCM_authenticated_decryption_test_case_192_2),
14978 TEST_CASE_ST(ut_setup, ut_teardown,
14979 test_AES_CCM_authenticated_decryption_test_case_192_3),
14981 /** AES CCM Authenticated Encryption 256 bits key */
14982 TEST_CASE_ST(ut_setup, ut_teardown,
14983 test_AES_CCM_authenticated_encryption_test_case_256_1),
14984 TEST_CASE_ST(ut_setup, ut_teardown,
14985 test_AES_CCM_authenticated_encryption_test_case_256_2),
14986 TEST_CASE_ST(ut_setup, ut_teardown,
14987 test_AES_CCM_authenticated_encryption_test_case_256_3),
14989 /** AES CCM Authenticated Decryption 256 bits key*/
14990 TEST_CASE_ST(ut_setup, ut_teardown,
14991 test_AES_CCM_authenticated_decryption_test_case_256_1),
14992 TEST_CASE_ST(ut_setup, ut_teardown,
14993 test_AES_CCM_authenticated_decryption_test_case_256_2),
14994 TEST_CASE_ST(ut_setup, ut_teardown,
14995 test_AES_CCM_authenticated_decryption_test_case_256_3),
15000 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite = {
15001 .suite_name = "AES GCM Authenticated Test Suite",
15002 .setup = aes_gcm_auth_testsuite_setup,
15003 .unit_test_cases = {
15004 /** AES GCM Authenticated Encryption */
15005 TEST_CASE_ST(ut_setup, ut_teardown,
15006 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
15007 TEST_CASE_ST(ut_setup, ut_teardown,
15008 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
15009 TEST_CASE_ST(ut_setup, ut_teardown,
15010 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
15011 TEST_CASE_ST(ut_setup, ut_teardown,
15012 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
15013 TEST_CASE_ST(ut_setup, ut_teardown,
15014 test_AES_GCM_authenticated_encryption_test_case_1),
15015 TEST_CASE_ST(ut_setup, ut_teardown,
15016 test_AES_GCM_authenticated_encryption_test_case_2),
15017 TEST_CASE_ST(ut_setup, ut_teardown,
15018 test_AES_GCM_authenticated_encryption_test_case_3),
15019 TEST_CASE_ST(ut_setup, ut_teardown,
15020 test_AES_GCM_authenticated_encryption_test_case_4),
15021 TEST_CASE_ST(ut_setup, ut_teardown,
15022 test_AES_GCM_authenticated_encryption_test_case_5),
15023 TEST_CASE_ST(ut_setup, ut_teardown,
15024 test_AES_GCM_authenticated_encryption_test_case_6),
15025 TEST_CASE_ST(ut_setup, ut_teardown,
15026 test_AES_GCM_authenticated_encryption_test_case_7),
15027 TEST_CASE_ST(ut_setup, ut_teardown,
15028 test_AES_GCM_authenticated_encryption_test_case_8),
15029 TEST_CASE_ST(ut_setup, ut_teardown,
15030 test_AES_GCM_J0_authenticated_encryption_test_case_1),
15032 /** AES GCM Authenticated Decryption */
15033 TEST_CASE_ST(ut_setup, ut_teardown,
15034 test_AES_GCM_authenticated_decryption_test_case_1),
15035 TEST_CASE_ST(ut_setup, ut_teardown,
15036 test_AES_GCM_authenticated_decryption_test_case_2),
15037 TEST_CASE_ST(ut_setup, ut_teardown,
15038 test_AES_GCM_authenticated_decryption_test_case_3),
15039 TEST_CASE_ST(ut_setup, ut_teardown,
15040 test_AES_GCM_authenticated_decryption_test_case_4),
15041 TEST_CASE_ST(ut_setup, ut_teardown,
15042 test_AES_GCM_authenticated_decryption_test_case_5),
15043 TEST_CASE_ST(ut_setup, ut_teardown,
15044 test_AES_GCM_authenticated_decryption_test_case_6),
15045 TEST_CASE_ST(ut_setup, ut_teardown,
15046 test_AES_GCM_authenticated_decryption_test_case_7),
15047 TEST_CASE_ST(ut_setup, ut_teardown,
15048 test_AES_GCM_authenticated_decryption_test_case_8),
15049 TEST_CASE_ST(ut_setup, ut_teardown,
15050 test_AES_GCM_J0_authenticated_decryption_test_case_1),
15052 /** AES GCM Authenticated Encryption 192 bits key */
15053 TEST_CASE_ST(ut_setup, ut_teardown,
15054 test_AES_GCM_auth_encryption_test_case_192_1),
15055 TEST_CASE_ST(ut_setup, ut_teardown,
15056 test_AES_GCM_auth_encryption_test_case_192_2),
15057 TEST_CASE_ST(ut_setup, ut_teardown,
15058 test_AES_GCM_auth_encryption_test_case_192_3),
15059 TEST_CASE_ST(ut_setup, ut_teardown,
15060 test_AES_GCM_auth_encryption_test_case_192_4),
15061 TEST_CASE_ST(ut_setup, ut_teardown,
15062 test_AES_GCM_auth_encryption_test_case_192_5),
15063 TEST_CASE_ST(ut_setup, ut_teardown,
15064 test_AES_GCM_auth_encryption_test_case_192_6),
15065 TEST_CASE_ST(ut_setup, ut_teardown,
15066 test_AES_GCM_auth_encryption_test_case_192_7),
15068 /** AES GCM Authenticated Decryption 192 bits key */
15069 TEST_CASE_ST(ut_setup, ut_teardown,
15070 test_AES_GCM_auth_decryption_test_case_192_1),
15071 TEST_CASE_ST(ut_setup, ut_teardown,
15072 test_AES_GCM_auth_decryption_test_case_192_2),
15073 TEST_CASE_ST(ut_setup, ut_teardown,
15074 test_AES_GCM_auth_decryption_test_case_192_3),
15075 TEST_CASE_ST(ut_setup, ut_teardown,
15076 test_AES_GCM_auth_decryption_test_case_192_4),
15077 TEST_CASE_ST(ut_setup, ut_teardown,
15078 test_AES_GCM_auth_decryption_test_case_192_5),
15079 TEST_CASE_ST(ut_setup, ut_teardown,
15080 test_AES_GCM_auth_decryption_test_case_192_6),
15081 TEST_CASE_ST(ut_setup, ut_teardown,
15082 test_AES_GCM_auth_decryption_test_case_192_7),
15084 /** AES GCM Authenticated Encryption 256 bits key */
15085 TEST_CASE_ST(ut_setup, ut_teardown,
15086 test_AES_GCM_auth_encryption_test_case_256_1),
15087 TEST_CASE_ST(ut_setup, ut_teardown,
15088 test_AES_GCM_auth_encryption_test_case_256_2),
15089 TEST_CASE_ST(ut_setup, ut_teardown,
15090 test_AES_GCM_auth_encryption_test_case_256_3),
15091 TEST_CASE_ST(ut_setup, ut_teardown,
15092 test_AES_GCM_auth_encryption_test_case_256_4),
15093 TEST_CASE_ST(ut_setup, ut_teardown,
15094 test_AES_GCM_auth_encryption_test_case_256_5),
15095 TEST_CASE_ST(ut_setup, ut_teardown,
15096 test_AES_GCM_auth_encryption_test_case_256_6),
15097 TEST_CASE_ST(ut_setup, ut_teardown,
15098 test_AES_GCM_auth_encryption_test_case_256_7),
15100 /** AES GCM Authenticated Decryption 256 bits key */
15101 TEST_CASE_ST(ut_setup, ut_teardown,
15102 test_AES_GCM_auth_decryption_test_case_256_1),
15103 TEST_CASE_ST(ut_setup, ut_teardown,
15104 test_AES_GCM_auth_decryption_test_case_256_2),
15105 TEST_CASE_ST(ut_setup, ut_teardown,
15106 test_AES_GCM_auth_decryption_test_case_256_3),
15107 TEST_CASE_ST(ut_setup, ut_teardown,
15108 test_AES_GCM_auth_decryption_test_case_256_4),
15109 TEST_CASE_ST(ut_setup, ut_teardown,
15110 test_AES_GCM_auth_decryption_test_case_256_5),
15111 TEST_CASE_ST(ut_setup, ut_teardown,
15112 test_AES_GCM_auth_decryption_test_case_256_6),
15113 TEST_CASE_ST(ut_setup, ut_teardown,
15114 test_AES_GCM_auth_decryption_test_case_256_7),
15116 /** AES GCM Authenticated Encryption big aad size */
15117 TEST_CASE_ST(ut_setup, ut_teardown,
15118 test_AES_GCM_auth_encryption_test_case_aad_1),
15119 TEST_CASE_ST(ut_setup, ut_teardown,
15120 test_AES_GCM_auth_encryption_test_case_aad_2),
15122 /** AES GCM Authenticated Decryption big aad size */
15123 TEST_CASE_ST(ut_setup, ut_teardown,
15124 test_AES_GCM_auth_decryption_test_case_aad_1),
15125 TEST_CASE_ST(ut_setup, ut_teardown,
15126 test_AES_GCM_auth_decryption_test_case_aad_2),
15128 /** Out of place tests */
15129 TEST_CASE_ST(ut_setup, ut_teardown,
15130 test_AES_GCM_authenticated_encryption_oop_test_case_1),
15131 TEST_CASE_ST(ut_setup, ut_teardown,
15132 test_AES_GCM_authenticated_decryption_oop_test_case_1),
15134 /** Session-less tests */
15135 TEST_CASE_ST(ut_setup, ut_teardown,
15136 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
15137 TEST_CASE_ST(ut_setup, ut_teardown,
15138 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
15144 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite = {
15145 .suite_name = "AES GMAC Authentication Test Suite",
15146 .setup = aes_gmac_auth_testsuite_setup,
15147 .unit_test_cases = {
15148 TEST_CASE_ST(ut_setup, ut_teardown,
15149 test_AES_GMAC_authentication_test_case_1),
15150 TEST_CASE_ST(ut_setup, ut_teardown,
15151 test_AES_GMAC_authentication_verify_test_case_1),
15152 TEST_CASE_ST(ut_setup, ut_teardown,
15153 test_AES_GMAC_authentication_test_case_2),
15154 TEST_CASE_ST(ut_setup, ut_teardown,
15155 test_AES_GMAC_authentication_verify_test_case_2),
15156 TEST_CASE_ST(ut_setup, ut_teardown,
15157 test_AES_GMAC_authentication_test_case_3),
15158 TEST_CASE_ST(ut_setup, ut_teardown,
15159 test_AES_GMAC_authentication_verify_test_case_3),
15160 TEST_CASE_ST(ut_setup, ut_teardown,
15161 test_AES_GMAC_authentication_test_case_4),
15162 TEST_CASE_ST(ut_setup, ut_teardown,
15163 test_AES_GMAC_authentication_verify_test_case_4),
15164 TEST_CASE_ST(ut_setup, ut_teardown,
15165 test_AES_GMAC_authentication_SGL_40B),
15166 TEST_CASE_ST(ut_setup, ut_teardown,
15167 test_AES_GMAC_authentication_SGL_80B),
15168 TEST_CASE_ST(ut_setup, ut_teardown,
15169 test_AES_GMAC_authentication_SGL_2048B),
15170 TEST_CASE_ST(ut_setup, ut_teardown,
15171 test_AES_GMAC_authentication_SGL_2047B),
15177 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite = {
15178 .suite_name = "Chacha20-Poly1305 Test Suite",
15179 .setup = chacha20_poly1305_testsuite_setup,
15180 .unit_test_cases = {
15181 TEST_CASE_ST(ut_setup, ut_teardown,
15182 test_chacha20_poly1305_encrypt_test_case_rfc8439),
15183 TEST_CASE_ST(ut_setup, ut_teardown,
15184 test_chacha20_poly1305_decrypt_test_case_rfc8439),
15185 TEST_CASE_ST(ut_setup, ut_teardown,
15186 test_chacha20_poly1305_encrypt_SGL_out_of_place),
15191 static struct unit_test_suite cryptodev_snow3g_testsuite = {
15192 .suite_name = "SNOW 3G Test Suite",
15193 .setup = snow3g_testsuite_setup,
15194 .unit_test_cases = {
15195 /** SNOW 3G encrypt only (UEA2) */
15196 TEST_CASE_ST(ut_setup, ut_teardown,
15197 test_snow3g_encryption_test_case_1),
15198 TEST_CASE_ST(ut_setup, ut_teardown,
15199 test_snow3g_encryption_test_case_2),
15200 TEST_CASE_ST(ut_setup, ut_teardown,
15201 test_snow3g_encryption_test_case_3),
15202 TEST_CASE_ST(ut_setup, ut_teardown,
15203 test_snow3g_encryption_test_case_4),
15204 TEST_CASE_ST(ut_setup, ut_teardown,
15205 test_snow3g_encryption_test_case_5),
15207 TEST_CASE_ST(ut_setup, ut_teardown,
15208 test_snow3g_encryption_test_case_1_oop),
15209 TEST_CASE_ST(ut_setup, ut_teardown,
15210 test_snow3g_encryption_test_case_1_oop_sgl),
15211 TEST_CASE_ST(ut_setup, ut_teardown,
15212 test_snow3g_encryption_test_case_1_offset_oop),
15213 TEST_CASE_ST(ut_setup, ut_teardown,
15214 test_snow3g_decryption_test_case_1_oop),
15216 /** SNOW 3G generate auth, then encrypt (UEA2) */
15217 TEST_CASE_ST(ut_setup, ut_teardown,
15218 test_snow3g_auth_cipher_test_case_1),
15219 TEST_CASE_ST(ut_setup, ut_teardown,
15220 test_snow3g_auth_cipher_test_case_2),
15221 TEST_CASE_ST(ut_setup, ut_teardown,
15222 test_snow3g_auth_cipher_test_case_2_oop),
15223 TEST_CASE_ST(ut_setup, ut_teardown,
15224 test_snow3g_auth_cipher_part_digest_enc),
15225 TEST_CASE_ST(ut_setup, ut_teardown,
15226 test_snow3g_auth_cipher_part_digest_enc_oop),
15227 TEST_CASE_ST(ut_setup, ut_teardown,
15228 test_snow3g_auth_cipher_test_case_3_sgl),
15229 TEST_CASE_ST(ut_setup, ut_teardown,
15230 test_snow3g_auth_cipher_test_case_3_oop_sgl),
15231 TEST_CASE_ST(ut_setup, ut_teardown,
15232 test_snow3g_auth_cipher_part_digest_enc_sgl),
15233 TEST_CASE_ST(ut_setup, ut_teardown,
15234 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
15236 /** SNOW 3G decrypt (UEA2), then verify auth */
15237 TEST_CASE_ST(ut_setup, ut_teardown,
15238 test_snow3g_auth_cipher_verify_test_case_1),
15239 TEST_CASE_ST(ut_setup, ut_teardown,
15240 test_snow3g_auth_cipher_verify_test_case_2),
15241 TEST_CASE_ST(ut_setup, ut_teardown,
15242 test_snow3g_auth_cipher_verify_test_case_2_oop),
15243 TEST_CASE_ST(ut_setup, ut_teardown,
15244 test_snow3g_auth_cipher_verify_part_digest_enc),
15245 TEST_CASE_ST(ut_setup, ut_teardown,
15246 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
15247 TEST_CASE_ST(ut_setup, ut_teardown,
15248 test_snow3g_auth_cipher_verify_test_case_3_sgl),
15249 TEST_CASE_ST(ut_setup, ut_teardown,
15250 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
15251 TEST_CASE_ST(ut_setup, ut_teardown,
15252 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
15253 TEST_CASE_ST(ut_setup, ut_teardown,
15254 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
15256 /** SNOW 3G decrypt only (UEA2) */
15257 TEST_CASE_ST(ut_setup, ut_teardown,
15258 test_snow3g_decryption_test_case_1),
15259 TEST_CASE_ST(ut_setup, ut_teardown,
15260 test_snow3g_decryption_test_case_2),
15261 TEST_CASE_ST(ut_setup, ut_teardown,
15262 test_snow3g_decryption_test_case_3),
15263 TEST_CASE_ST(ut_setup, ut_teardown,
15264 test_snow3g_decryption_test_case_4),
15265 TEST_CASE_ST(ut_setup, ut_teardown,
15266 test_snow3g_decryption_test_case_5),
15267 TEST_CASE_ST(ut_setup, ut_teardown,
15268 test_snow3g_decryption_with_digest_test_case_1),
15269 TEST_CASE_ST(ut_setup, ut_teardown,
15270 test_snow3g_hash_generate_test_case_1),
15271 TEST_CASE_ST(ut_setup, ut_teardown,
15272 test_snow3g_hash_generate_test_case_2),
15273 TEST_CASE_ST(ut_setup, ut_teardown,
15274 test_snow3g_hash_generate_test_case_3),
15276 /* Tests with buffers which length is not byte-aligned */
15277 TEST_CASE_ST(ut_setup, ut_teardown,
15278 test_snow3g_hash_generate_test_case_4),
15279 TEST_CASE_ST(ut_setup, ut_teardown,
15280 test_snow3g_hash_generate_test_case_5),
15281 TEST_CASE_ST(ut_setup, ut_teardown,
15282 test_snow3g_hash_generate_test_case_6),
15283 TEST_CASE_ST(ut_setup, ut_teardown,
15284 test_snow3g_hash_verify_test_case_1),
15285 TEST_CASE_ST(ut_setup, ut_teardown,
15286 test_snow3g_hash_verify_test_case_2),
15287 TEST_CASE_ST(ut_setup, ut_teardown,
15288 test_snow3g_hash_verify_test_case_3),
15290 /* Tests with buffers which length is not byte-aligned */
15291 TEST_CASE_ST(ut_setup, ut_teardown,
15292 test_snow3g_hash_verify_test_case_4),
15293 TEST_CASE_ST(ut_setup, ut_teardown,
15294 test_snow3g_hash_verify_test_case_5),
15295 TEST_CASE_ST(ut_setup, ut_teardown,
15296 test_snow3g_hash_verify_test_case_6),
15297 TEST_CASE_ST(ut_setup, ut_teardown,
15298 test_snow3g_cipher_auth_test_case_1),
15299 TEST_CASE_ST(ut_setup, ut_teardown,
15300 test_snow3g_auth_cipher_with_digest_test_case_1),
15305 static struct unit_test_suite cryptodev_zuc_testsuite = {
15306 .suite_name = "ZUC Test Suite",
15307 .setup = zuc_testsuite_setup,
15308 .unit_test_cases = {
15309 /** ZUC encrypt only (EEA3) */
15310 TEST_CASE_ST(ut_setup, ut_teardown,
15311 test_zuc_encryption_test_case_1),
15312 TEST_CASE_ST(ut_setup, ut_teardown,
15313 test_zuc_encryption_test_case_2),
15314 TEST_CASE_ST(ut_setup, ut_teardown,
15315 test_zuc_encryption_test_case_3),
15316 TEST_CASE_ST(ut_setup, ut_teardown,
15317 test_zuc_encryption_test_case_4),
15318 TEST_CASE_ST(ut_setup, ut_teardown,
15319 test_zuc_encryption_test_case_5),
15320 TEST_CASE_ST(ut_setup, ut_teardown,
15321 test_zuc_encryption_test_case_6_sgl),
15323 /** ZUC authenticate (EIA3) */
15324 TEST_CASE_ST(ut_setup, ut_teardown,
15325 test_zuc_hash_generate_test_case_1),
15326 TEST_CASE_ST(ut_setup, ut_teardown,
15327 test_zuc_hash_generate_test_case_2),
15328 TEST_CASE_ST(ut_setup, ut_teardown,
15329 test_zuc_hash_generate_test_case_3),
15330 TEST_CASE_ST(ut_setup, ut_teardown,
15331 test_zuc_hash_generate_test_case_4),
15332 TEST_CASE_ST(ut_setup, ut_teardown,
15333 test_zuc_hash_generate_test_case_5),
15334 TEST_CASE_ST(ut_setup, ut_teardown,
15335 test_zuc_hash_generate_test_case_6),
15336 TEST_CASE_ST(ut_setup, ut_teardown,
15337 test_zuc_hash_generate_test_case_7),
15338 TEST_CASE_ST(ut_setup, ut_teardown,
15339 test_zuc_hash_generate_test_case_8),
15340 TEST_CASE_ST(ut_setup, ut_teardown,
15341 test_zuc_hash_generate_test_case_9),
15342 TEST_CASE_ST(ut_setup, ut_teardown,
15343 test_zuc_hash_generate_test_case_10),
15344 TEST_CASE_ST(ut_setup, ut_teardown,
15345 test_zuc_hash_generate_test_case_11),
15348 /** ZUC alg-chain (EEA3/EIA3) */
15349 TEST_CASE_ST(ut_setup, ut_teardown,
15350 test_zuc_cipher_auth_test_case_1),
15351 TEST_CASE_ST(ut_setup, ut_teardown,
15352 test_zuc_cipher_auth_test_case_2),
15354 /** ZUC generate auth, then encrypt (EEA3) */
15355 TEST_CASE_ST(ut_setup, ut_teardown,
15356 test_zuc_auth_cipher_test_case_1),
15357 TEST_CASE_ST(ut_setup, ut_teardown,
15358 test_zuc_auth_cipher_test_case_1_oop),
15359 TEST_CASE_ST(ut_setup, ut_teardown,
15360 test_zuc_auth_cipher_test_case_1_sgl),
15361 TEST_CASE_ST(ut_setup, ut_teardown,
15362 test_zuc_auth_cipher_test_case_1_oop_sgl),
15364 /** ZUC decrypt (EEA3), then verify auth */
15365 TEST_CASE_ST(ut_setup, ut_teardown,
15366 test_zuc_auth_cipher_verify_test_case_1),
15367 TEST_CASE_ST(ut_setup, ut_teardown,
15368 test_zuc_auth_cipher_verify_test_case_1_oop),
15369 TEST_CASE_ST(ut_setup, ut_teardown,
15370 test_zuc_auth_cipher_verify_test_case_1_sgl),
15371 TEST_CASE_ST(ut_setup, ut_teardown,
15372 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
15374 /** ZUC-256 encrypt only **/
15375 TEST_CASE_ST(ut_setup, ut_teardown,
15376 test_zuc256_encryption_test_case_1),
15377 TEST_CASE_ST(ut_setup, ut_teardown,
15378 test_zuc256_encryption_test_case_2),
15380 /** ZUC-256 authentication only **/
15381 TEST_CASE_ST(ut_setup, ut_teardown,
15382 test_zuc256_authentication_test_case_1),
15383 TEST_CASE_ST(ut_setup, ut_teardown,
15384 test_zuc256_authentication_test_case_2),
15390 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite = {
15391 .suite_name = "HMAC_MD5 Authentication Test Suite",
15392 .setup = hmac_md5_auth_testsuite_setup,
15393 .unit_test_cases = {
15394 TEST_CASE_ST(ut_setup, ut_teardown,
15395 test_MD5_HMAC_generate_case_1),
15396 TEST_CASE_ST(ut_setup, ut_teardown,
15397 test_MD5_HMAC_verify_case_1),
15398 TEST_CASE_ST(ut_setup, ut_teardown,
15399 test_MD5_HMAC_generate_case_2),
15400 TEST_CASE_ST(ut_setup, ut_teardown,
15401 test_MD5_HMAC_verify_case_2),
15406 static struct unit_test_suite cryptodev_kasumi_testsuite = {
15407 .suite_name = "Kasumi Test Suite",
15408 .setup = kasumi_testsuite_setup,
15409 .unit_test_cases = {
15410 /** KASUMI hash only (UIA1) */
15411 TEST_CASE_ST(ut_setup, ut_teardown,
15412 test_kasumi_hash_generate_test_case_1),
15413 TEST_CASE_ST(ut_setup, ut_teardown,
15414 test_kasumi_hash_generate_test_case_2),
15415 TEST_CASE_ST(ut_setup, ut_teardown,
15416 test_kasumi_hash_generate_test_case_3),
15417 TEST_CASE_ST(ut_setup, ut_teardown,
15418 test_kasumi_hash_generate_test_case_4),
15419 TEST_CASE_ST(ut_setup, ut_teardown,
15420 test_kasumi_hash_generate_test_case_5),
15421 TEST_CASE_ST(ut_setup, ut_teardown,
15422 test_kasumi_hash_generate_test_case_6),
15424 TEST_CASE_ST(ut_setup, ut_teardown,
15425 test_kasumi_hash_verify_test_case_1),
15426 TEST_CASE_ST(ut_setup, ut_teardown,
15427 test_kasumi_hash_verify_test_case_2),
15428 TEST_CASE_ST(ut_setup, ut_teardown,
15429 test_kasumi_hash_verify_test_case_3),
15430 TEST_CASE_ST(ut_setup, ut_teardown,
15431 test_kasumi_hash_verify_test_case_4),
15432 TEST_CASE_ST(ut_setup, ut_teardown,
15433 test_kasumi_hash_verify_test_case_5),
15435 /** KASUMI encrypt only (UEA1) */
15436 TEST_CASE_ST(ut_setup, ut_teardown,
15437 test_kasumi_encryption_test_case_1),
15438 TEST_CASE_ST(ut_setup, ut_teardown,
15439 test_kasumi_encryption_test_case_1_sgl),
15440 TEST_CASE_ST(ut_setup, ut_teardown,
15441 test_kasumi_encryption_test_case_1_oop),
15442 TEST_CASE_ST(ut_setup, ut_teardown,
15443 test_kasumi_encryption_test_case_1_oop_sgl),
15444 TEST_CASE_ST(ut_setup, ut_teardown,
15445 test_kasumi_encryption_test_case_2),
15446 TEST_CASE_ST(ut_setup, ut_teardown,
15447 test_kasumi_encryption_test_case_3),
15448 TEST_CASE_ST(ut_setup, ut_teardown,
15449 test_kasumi_encryption_test_case_4),
15450 TEST_CASE_ST(ut_setup, ut_teardown,
15451 test_kasumi_encryption_test_case_5),
15453 /** KASUMI decrypt only (UEA1) */
15454 TEST_CASE_ST(ut_setup, ut_teardown,
15455 test_kasumi_decryption_test_case_1),
15456 TEST_CASE_ST(ut_setup, ut_teardown,
15457 test_kasumi_decryption_test_case_2),
15458 TEST_CASE_ST(ut_setup, ut_teardown,
15459 test_kasumi_decryption_test_case_3),
15460 TEST_CASE_ST(ut_setup, ut_teardown,
15461 test_kasumi_decryption_test_case_4),
15462 TEST_CASE_ST(ut_setup, ut_teardown,
15463 test_kasumi_decryption_test_case_5),
15464 TEST_CASE_ST(ut_setup, ut_teardown,
15465 test_kasumi_decryption_test_case_1_oop),
15466 TEST_CASE_ST(ut_setup, ut_teardown,
15467 test_kasumi_cipher_auth_test_case_1),
15469 /** KASUMI generate auth, then encrypt (F8) */
15470 TEST_CASE_ST(ut_setup, ut_teardown,
15471 test_kasumi_auth_cipher_test_case_1),
15472 TEST_CASE_ST(ut_setup, ut_teardown,
15473 test_kasumi_auth_cipher_test_case_2),
15474 TEST_CASE_ST(ut_setup, ut_teardown,
15475 test_kasumi_auth_cipher_test_case_2_oop),
15476 TEST_CASE_ST(ut_setup, ut_teardown,
15477 test_kasumi_auth_cipher_test_case_2_sgl),
15478 TEST_CASE_ST(ut_setup, ut_teardown,
15479 test_kasumi_auth_cipher_test_case_2_oop_sgl),
15481 /** KASUMI decrypt (F8), then verify auth */
15482 TEST_CASE_ST(ut_setup, ut_teardown,
15483 test_kasumi_auth_cipher_verify_test_case_1),
15484 TEST_CASE_ST(ut_setup, ut_teardown,
15485 test_kasumi_auth_cipher_verify_test_case_2),
15486 TEST_CASE_ST(ut_setup, ut_teardown,
15487 test_kasumi_auth_cipher_verify_test_case_2_oop),
15488 TEST_CASE_ST(ut_setup, ut_teardown,
15489 test_kasumi_auth_cipher_verify_test_case_2_sgl),
15490 TEST_CASE_ST(ut_setup, ut_teardown,
15491 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
15497 static struct unit_test_suite cryptodev_esn_testsuite = {
15498 .suite_name = "ESN Test Suite",
15499 .setup = esn_testsuite_setup,
15500 .unit_test_cases = {
15501 TEST_CASE_ST(ut_setup, ut_teardown,
15502 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
15503 TEST_CASE_ST(ut_setup, ut_teardown,
15504 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
15509 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite = {
15510 .suite_name = "Negative AES GCM Test Suite",
15511 .setup = negative_aes_gcm_testsuite_setup,
15512 .unit_test_cases = {
15513 TEST_CASE_ST(ut_setup, ut_teardown,
15514 test_AES_GCM_auth_encryption_fail_iv_corrupt),
15515 TEST_CASE_ST(ut_setup, ut_teardown,
15516 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
15517 TEST_CASE_ST(ut_setup, ut_teardown,
15518 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
15519 TEST_CASE_ST(ut_setup, ut_teardown,
15520 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
15521 TEST_CASE_ST(ut_setup, ut_teardown,
15522 test_AES_GCM_auth_encryption_fail_aad_corrupt),
15523 TEST_CASE_ST(ut_setup, ut_teardown,
15524 test_AES_GCM_auth_encryption_fail_tag_corrupt),
15525 TEST_CASE_ST(ut_setup, ut_teardown,
15526 test_AES_GCM_auth_decryption_fail_iv_corrupt),
15527 TEST_CASE_ST(ut_setup, ut_teardown,
15528 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
15529 TEST_CASE_ST(ut_setup, ut_teardown,
15530 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
15531 TEST_CASE_ST(ut_setup, ut_teardown,
15532 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
15533 TEST_CASE_ST(ut_setup, ut_teardown,
15534 test_AES_GCM_auth_decryption_fail_aad_corrupt),
15535 TEST_CASE_ST(ut_setup, ut_teardown,
15536 test_AES_GCM_auth_decryption_fail_tag_corrupt),
15542 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite = {
15543 .suite_name = "Negative AES GMAC Test Suite",
15544 .setup = negative_aes_gmac_testsuite_setup,
15545 .unit_test_cases = {
15546 TEST_CASE_ST(ut_setup, ut_teardown,
15547 authentication_verify_AES128_GMAC_fail_data_corrupt),
15548 TEST_CASE_ST(ut_setup, ut_teardown,
15549 authentication_verify_AES128_GMAC_fail_tag_corrupt),
15555 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite = {
15556 .suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
15557 .setup = mixed_cipher_hash_testsuite_setup,
15558 .unit_test_cases = {
15559 /** AUTH AES CMAC + CIPHER AES CTR */
15560 TEST_CASE_ST(ut_setup, ut_teardown,
15561 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
15562 TEST_CASE_ST(ut_setup, ut_teardown,
15563 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15564 TEST_CASE_ST(ut_setup, ut_teardown,
15565 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15566 TEST_CASE_ST(ut_setup, ut_teardown,
15567 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15568 TEST_CASE_ST(ut_setup, ut_teardown,
15569 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
15570 TEST_CASE_ST(ut_setup, ut_teardown,
15571 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
15572 TEST_CASE_ST(ut_setup, ut_teardown,
15573 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
15574 TEST_CASE_ST(ut_setup, ut_teardown,
15575 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
15577 /** AUTH ZUC + CIPHER SNOW3G */
15578 TEST_CASE_ST(ut_setup, ut_teardown,
15579 test_auth_zuc_cipher_snow_test_case_1),
15580 TEST_CASE_ST(ut_setup, ut_teardown,
15581 test_verify_auth_zuc_cipher_snow_test_case_1),
15582 /** AUTH AES CMAC + CIPHER SNOW3G */
15583 TEST_CASE_ST(ut_setup, ut_teardown,
15584 test_auth_aes_cmac_cipher_snow_test_case_1),
15585 TEST_CASE_ST(ut_setup, ut_teardown,
15586 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
15587 /** AUTH ZUC + CIPHER AES CTR */
15588 TEST_CASE_ST(ut_setup, ut_teardown,
15589 test_auth_zuc_cipher_aes_ctr_test_case_1),
15590 TEST_CASE_ST(ut_setup, ut_teardown,
15591 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
15592 /** AUTH SNOW3G + CIPHER AES CTR */
15593 TEST_CASE_ST(ut_setup, ut_teardown,
15594 test_auth_snow_cipher_aes_ctr_test_case_1),
15595 TEST_CASE_ST(ut_setup, ut_teardown,
15596 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
15597 /** AUTH SNOW3G + CIPHER ZUC */
15598 TEST_CASE_ST(ut_setup, ut_teardown,
15599 test_auth_snow_cipher_zuc_test_case_1),
15600 TEST_CASE_ST(ut_setup, ut_teardown,
15601 test_verify_auth_snow_cipher_zuc_test_case_1),
15602 /** AUTH AES CMAC + CIPHER ZUC */
15603 TEST_CASE_ST(ut_setup, ut_teardown,
15604 test_auth_aes_cmac_cipher_zuc_test_case_1),
15605 TEST_CASE_ST(ut_setup, ut_teardown,
15606 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
15608 /** AUTH NULL + CIPHER SNOW3G */
15609 TEST_CASE_ST(ut_setup, ut_teardown,
15610 test_auth_null_cipher_snow_test_case_1),
15611 TEST_CASE_ST(ut_setup, ut_teardown,
15612 test_verify_auth_null_cipher_snow_test_case_1),
15613 /** AUTH NULL + CIPHER ZUC */
15614 TEST_CASE_ST(ut_setup, ut_teardown,
15615 test_auth_null_cipher_zuc_test_case_1),
15616 TEST_CASE_ST(ut_setup, ut_teardown,
15617 test_verify_auth_null_cipher_zuc_test_case_1),
15618 /** AUTH SNOW3G + CIPHER NULL */
15619 TEST_CASE_ST(ut_setup, ut_teardown,
15620 test_auth_snow_cipher_null_test_case_1),
15621 TEST_CASE_ST(ut_setup, ut_teardown,
15622 test_verify_auth_snow_cipher_null_test_case_1),
15623 /** AUTH ZUC + CIPHER NULL */
15624 TEST_CASE_ST(ut_setup, ut_teardown,
15625 test_auth_zuc_cipher_null_test_case_1),
15626 TEST_CASE_ST(ut_setup, ut_teardown,
15627 test_verify_auth_zuc_cipher_null_test_case_1),
15628 /** AUTH NULL + CIPHER AES CTR */
15629 TEST_CASE_ST(ut_setup, ut_teardown,
15630 test_auth_null_cipher_aes_ctr_test_case_1),
15631 TEST_CASE_ST(ut_setup, ut_teardown,
15632 test_verify_auth_null_cipher_aes_ctr_test_case_1),
15633 /** AUTH AES CMAC + CIPHER NULL */
15634 TEST_CASE_ST(ut_setup, ut_teardown,
15635 test_auth_aes_cmac_cipher_null_test_case_1),
15636 TEST_CASE_ST(ut_setup, ut_teardown,
15637 test_verify_auth_aes_cmac_cipher_null_test_case_1),
15643 run_cryptodev_testsuite(const char *pmd_name)
15645 uint8_t ret, j, i = 0, blk_start_idx = 0;
15646 const enum blockcipher_test_type blk_suites[] = {
15647 BLKCIPHER_AES_CHAIN_TYPE,
15648 BLKCIPHER_AES_CIPHERONLY_TYPE,
15649 BLKCIPHER_AES_DOCSIS_TYPE,
15650 BLKCIPHER_3DES_CHAIN_TYPE,
15651 BLKCIPHER_3DES_CIPHERONLY_TYPE,
15652 BLKCIPHER_DES_CIPHERONLY_TYPE,
15653 BLKCIPHER_DES_DOCSIS_TYPE,
15654 BLKCIPHER_AUTHONLY_TYPE};
15655 struct unit_test_suite *static_suites[] = {
15656 &cryptodev_multi_session_testsuite,
15657 &cryptodev_null_testsuite,
15658 &cryptodev_aes_ccm_auth_testsuite,
15659 &cryptodev_aes_gcm_auth_testsuite,
15660 &cryptodev_aes_gmac_auth_testsuite,
15661 &cryptodev_snow3g_testsuite,
15662 &cryptodev_chacha20_poly1305_testsuite,
15663 &cryptodev_zuc_testsuite,
15664 &cryptodev_hmac_md5_auth_testsuite,
15665 &cryptodev_kasumi_testsuite,
15666 &cryptodev_esn_testsuite,
15667 &cryptodev_negative_aes_gcm_testsuite,
15668 &cryptodev_negative_aes_gmac_testsuite,
15669 &cryptodev_mixed_cipher_hash_testsuite,
15670 &cryptodev_negative_hmac_sha1_testsuite,
15671 &cryptodev_gen_testsuite,
15672 #ifdef RTE_LIB_SECURITY
15673 &ipsec_proto_testsuite,
15674 &pdcp_proto_testsuite,
15675 &docsis_proto_testsuite,
15679 static struct unit_test_suite ts = {
15680 .suite_name = "Cryptodev Unit Test Suite",
15681 .setup = testsuite_setup,
15682 .teardown = testsuite_teardown,
15683 .unit_test_cases = {TEST_CASES_END()}
15686 gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
15688 if (gbl_driver_id == -1) {
15689 RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
15690 return TEST_SKIPPED;
15693 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15694 (RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
15696 ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
15697 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15698 ret = unit_test_suite_runner(&ts);
15700 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
15701 free(ts.unit_test_suites);
15706 require_feature_flag(const char *pmd_name, uint64_t flag, const char *flag_name)
15708 struct rte_cryptodev_info dev_info;
15709 uint8_t i, nb_devs;
15712 driver_id = rte_cryptodev_driver_id_get(pmd_name);
15713 if (driver_id == -1) {
15714 RTE_LOG(WARNING, USER1, "%s PMD must be loaded.\n", pmd_name);
15715 return TEST_SKIPPED;
15718 nb_devs = rte_cryptodev_count();
15720 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
15721 return TEST_SKIPPED;
15724 for (i = 0; i < nb_devs; i++) {
15725 rte_cryptodev_info_get(i, &dev_info);
15726 if (dev_info.driver_id == driver_id) {
15727 if (!(dev_info.feature_flags & flag)) {
15728 RTE_LOG(INFO, USER1, "%s not supported\n",
15730 return TEST_SKIPPED;
15732 return 0; /* found */
15736 RTE_LOG(INFO, USER1, "%s not supported\n", flag_name);
15737 return TEST_SKIPPED;
15741 test_cryptodev_qat(void)
15743 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
15747 test_cryptodev_virtio(void)
15749 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
15753 test_cryptodev_aesni_mb(void)
15755 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15759 test_cryptodev_cpu_aesni_mb(void)
15762 enum rte_security_session_action_type at = gbl_action_type;
15763 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15764 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
15765 gbl_action_type = at;
15770 test_cryptodev_chacha_poly_mb(void)
15773 enum rte_security_session_action_type at = gbl_action_type;
15774 rc = run_cryptodev_testsuite(
15775 RTE_STR(CRYPTODEV_NAME_CHACHA20_POLY1305_PMD));
15776 gbl_action_type = at;
15781 test_cryptodev_openssl(void)
15783 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
15787 test_cryptodev_aesni_gcm(void)
15789 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15793 test_cryptodev_cpu_aesni_gcm(void)
15796 enum rte_security_session_action_type at = gbl_action_type;
15797 gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
15798 rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
15799 gbl_action_type = at;
15804 test_cryptodev_mlx5(void)
15806 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MLX5_PMD));
15810 test_cryptodev_null(void)
15812 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
15816 test_cryptodev_sw_snow3g(void)
15818 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
15822 test_cryptodev_sw_kasumi(void)
15824 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
15828 test_cryptodev_sw_zuc(void)
15830 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
15834 test_cryptodev_armv8(void)
15836 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
15840 test_cryptodev_mrvl(void)
15842 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
15845 #ifdef RTE_CRYPTO_SCHEDULER
15848 test_cryptodev_scheduler(void)
15850 uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
15851 const enum blockcipher_test_type blk_suites[] = {
15852 BLKCIPHER_AES_CHAIN_TYPE,
15853 BLKCIPHER_AES_CIPHERONLY_TYPE,
15854 BLKCIPHER_AUTHONLY_TYPE
15856 static struct unit_test_suite scheduler_multicore = {
15857 .suite_name = "Scheduler Multicore Unit Test Suite",
15858 .setup = scheduler_multicore_testsuite_setup,
15859 .teardown = scheduler_mode_testsuite_teardown,
15860 .unit_test_cases = {TEST_CASES_END()}
15862 static struct unit_test_suite scheduler_round_robin = {
15863 .suite_name = "Scheduler Round Robin Unit Test Suite",
15864 .setup = scheduler_roundrobin_testsuite_setup,
15865 .teardown = scheduler_mode_testsuite_teardown,
15866 .unit_test_cases = {TEST_CASES_END()}
15868 static struct unit_test_suite scheduler_failover = {
15869 .suite_name = "Scheduler Failover Unit Test Suite",
15870 .setup = scheduler_failover_testsuite_setup,
15871 .teardown = scheduler_mode_testsuite_teardown,
15872 .unit_test_cases = {TEST_CASES_END()}
15874 static struct unit_test_suite scheduler_pkt_size_distr = {
15875 .suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
15876 .setup = scheduler_pkt_size_distr_testsuite_setup,
15877 .teardown = scheduler_mode_testsuite_teardown,
15878 .unit_test_cases = {TEST_CASES_END()}
15880 struct unit_test_suite *sched_mode_suites[] = {
15881 &scheduler_multicore,
15882 &scheduler_round_robin,
15883 &scheduler_failover,
15884 &scheduler_pkt_size_distr
15886 static struct unit_test_suite scheduler_config = {
15887 .suite_name = "Crypto Device Scheduler Config Unit Test Suite",
15888 .unit_test_cases = {
15889 TEST_CASE(test_scheduler_attach_worker_op),
15890 TEST_CASE(test_scheduler_mode_multicore_op),
15891 TEST_CASE(test_scheduler_mode_roundrobin_op),
15892 TEST_CASE(test_scheduler_mode_failover_op),
15893 TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
15894 TEST_CASE(test_scheduler_detach_worker_op),
15896 TEST_CASES_END() /**< NULL terminate array */
15899 struct unit_test_suite *static_suites[] = {
15903 static struct unit_test_suite ts = {
15904 .suite_name = "Scheduler Unit Test Suite",
15905 .setup = scheduler_testsuite_setup,
15906 .teardown = testsuite_teardown,
15907 .unit_test_cases = {TEST_CASES_END()}
15910 gbl_driver_id = rte_cryptodev_driver_id_get(
15911 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
15913 if (gbl_driver_id == -1) {
15914 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
15915 return TEST_SKIPPED;
15918 if (rte_cryptodev_driver_id_get(
15919 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
15920 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
15921 return TEST_SKIPPED;
15924 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15926 sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
15927 (struct unit_test_suite *) *
15928 (RTE_DIM(blk_suites) + 1));
15929 ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
15930 blk_suites, RTE_DIM(blk_suites));
15931 sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
15934 ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
15935 (RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
15936 ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
15937 RTE_DIM(sched_mode_suites));
15938 ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
15939 ret = unit_test_suite_runner(&ts);
15941 for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
15942 FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
15943 (*sched_mode_suites[sched_i]),
15944 RTE_DIM(blk_suites));
15945 free(sched_mode_suites[sched_i]->unit_test_suites);
15947 free(ts.unit_test_suites);
15951 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
15956 test_cryptodev_dpaa2_sec(void)
15958 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
15962 test_cryptodev_dpaa_sec(void)
15964 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
15968 test_cryptodev_ccp(void)
15970 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
15974 test_cryptodev_octeontx(void)
15976 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
15980 test_cryptodev_caam_jr(void)
15982 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
15986 test_cryptodev_nitrox(void)
15988 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
15992 test_cryptodev_bcmfs(void)
15994 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
15998 test_cryptodev_qat_raw_api(void)
16000 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD);
16003 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16008 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16009 ret = run_cryptodev_testsuite(pmd_name);
16010 global_api_test_type = CRYPTODEV_API_TEST;
16016 test_cryptodev_cn9k(void)
16018 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN9K_PMD));
16022 test_cryptodev_cn10k(void)
16024 return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CN10K_PMD));
16028 test_cryptodev_dpaa2_sec_raw_api(void)
16030 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16033 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16038 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16039 ret = run_cryptodev_testsuite(pmd_name);
16040 global_api_test_type = CRYPTODEV_API_TEST;
16046 test_cryptodev_dpaa_sec_raw_api(void)
16048 static const char *pmd_name = RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD);
16051 ret = require_feature_flag(pmd_name, RTE_CRYPTODEV_FF_SYM_RAW_DP,
16056 global_api_test_type = CRYPTODEV_RAW_API_TEST;
16057 ret = run_cryptodev_testsuite(pmd_name);
16058 global_api_test_type = CRYPTODEV_API_TEST;
16063 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_raw_api_autotest,
16064 test_cryptodev_dpaa2_sec_raw_api);
16065 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_raw_api_autotest,
16066 test_cryptodev_dpaa_sec_raw_api);
16067 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
16068 test_cryptodev_qat_raw_api);
16069 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
16070 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
16071 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
16072 test_cryptodev_cpu_aesni_mb);
16073 REGISTER_TEST_COMMAND(cryptodev_chacha_poly_mb_autotest,
16074 test_cryptodev_chacha_poly_mb);
16075 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
16076 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
16077 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
16078 test_cryptodev_cpu_aesni_gcm);
16079 REGISTER_TEST_COMMAND(cryptodev_mlx5_autotest, test_cryptodev_mlx5);
16080 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
16081 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
16082 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
16083 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
16084 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
16085 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
16086 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
16087 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
16088 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
16089 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
16090 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
16091 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
16092 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
16093 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
16094 REGISTER_TEST_COMMAND(cryptodev_cn9k_autotest, test_cryptodev_cn9k);
16095 REGISTER_TEST_COMMAND(cryptodev_cn10k_autotest, test_cryptodev_cn10k);