xref: /f-stack/dpdk/app/test/test_cryptodev.c (revision ebf5cedb)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2019 Intel Corporation
3  */
4 
5 #include <time.h>
6 
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
9 #include <rte_mbuf.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
14 
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
19 
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
23 #endif
24 
25 #include <rte_lcore.h>
26 
27 #include "test.h"
28 #include "test_cryptodev.h"
29 
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
45 #endif
46 
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
49 
50 #define IN_PLACE 0
51 #define OUT_OF_PLACE 1
52 
53 static int gbl_driver_id;
54 
55 struct crypto_testsuite_params {
56 	struct rte_mempool *mbuf_pool;
57 	struct rte_mempool *large_mbuf_pool;
58 	struct rte_mempool *op_mpool;
59 	struct rte_mempool *session_mpool;
60 	struct rte_mempool *session_priv_mpool;
61 	struct rte_cryptodev_config conf;
62 	struct rte_cryptodev_qp_conf qp_conf;
63 
64 	uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
65 	uint8_t valid_dev_count;
66 };
67 
68 struct crypto_unittest_params {
69 	struct rte_crypto_sym_xform cipher_xform;
70 	struct rte_crypto_sym_xform auth_xform;
71 	struct rte_crypto_sym_xform aead_xform;
72 
73 	union {
74 		struct rte_cryptodev_sym_session *sess;
75 #ifdef RTE_LIBRTE_SECURITY
76 		struct rte_security_session *sec_session;
77 #endif
78 	};
79 #ifdef RTE_LIBRTE_SECURITY
80 	enum rte_security_session_action_type type;
81 #endif
82 	struct rte_crypto_op *op;
83 
84 	struct rte_mbuf *obuf, *ibuf;
85 
86 	uint8_t *digest;
87 };
88 
89 #define ALIGN_POW2_ROUNDUP(num, align) \
90 	(((num) + (align) - 1) & ~((align) - 1))
91 
92 /*
93  * Forward declarations.
94  */
95 static int
96 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
97 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
98 		uint8_t *hmac_key);
99 
100 static int
101 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
102 		struct crypto_unittest_params *ut_params,
103 		struct crypto_testsuite_params *ts_param,
104 		const uint8_t *cipher,
105 		const uint8_t *digest,
106 		const uint8_t *iv);
107 
108 static struct rte_mbuf *
109 setup_test_string(struct rte_mempool *mpool,
110 		const char *string, size_t len, uint8_t blocksize)
111 {
112 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
113 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
114 
115 	memset(m->buf_addr, 0, m->buf_len);
116 	if (m) {
117 		char *dst = rte_pktmbuf_append(m, t_len);
118 
119 		if (!dst) {
120 			rte_pktmbuf_free(m);
121 			return NULL;
122 		}
123 		if (string != NULL)
124 			rte_memcpy(dst, string, t_len);
125 		else
126 			memset(dst, 0, t_len);
127 	}
128 
129 	return m;
130 }
131 
132 /* Get number of bytes in X bits (rounding up) */
133 static uint32_t
134 ceil_byte_length(uint32_t num_bits)
135 {
136 	if (num_bits % 8)
137 		return ((num_bits >> 3) + 1);
138 	else
139 		return (num_bits >> 3);
140 }
141 
142 static struct rte_crypto_op *
143 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
144 {
145 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
146 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
147 		return NULL;
148 	}
149 
150 	op = NULL;
151 
152 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
153 		rte_pause();
154 
155 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
156 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
157 		return NULL;
158 	}
159 
160 	return op;
161 }
162 
163 static struct crypto_testsuite_params testsuite_params = { NULL };
164 static struct crypto_unittest_params unittest_params;
165 
166 static int
167 testsuite_setup(void)
168 {
169 	struct crypto_testsuite_params *ts_params = &testsuite_params;
170 	struct rte_cryptodev_info info;
171 	uint32_t i = 0, nb_devs, dev_id;
172 	int ret;
173 	uint16_t qp_id;
174 
175 	memset(ts_params, 0, sizeof(*ts_params));
176 
177 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
178 	if (ts_params->mbuf_pool == NULL) {
179 		/* Not already created so create */
180 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
181 				"CRYPTO_MBUFPOOL",
182 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
183 				rte_socket_id());
184 		if (ts_params->mbuf_pool == NULL) {
185 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
186 			return TEST_FAILED;
187 		}
188 	}
189 
190 	ts_params->large_mbuf_pool = rte_mempool_lookup(
191 			"CRYPTO_LARGE_MBUFPOOL");
192 	if (ts_params->large_mbuf_pool == NULL) {
193 		/* Not already created so create */
194 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
195 				"CRYPTO_LARGE_MBUFPOOL",
196 				1, 0, 0, UINT16_MAX,
197 				rte_socket_id());
198 		if (ts_params->large_mbuf_pool == NULL) {
199 			RTE_LOG(ERR, USER1,
200 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
201 			return TEST_FAILED;
202 		}
203 	}
204 
205 	ts_params->op_mpool = rte_crypto_op_pool_create(
206 			"MBUF_CRYPTO_SYM_OP_POOL",
207 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
208 			NUM_MBUFS, MBUF_CACHE_SIZE,
209 			DEFAULT_NUM_XFORMS *
210 			sizeof(struct rte_crypto_sym_xform) +
211 			MAXIMUM_IV_LENGTH,
212 			rte_socket_id());
213 	if (ts_params->op_mpool == NULL) {
214 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
215 		return TEST_FAILED;
216 	}
217 
218 	/* Create an AESNI MB device if required */
219 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
220 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
221 		nb_devs = rte_cryptodev_device_count_by_driver(
222 				rte_cryptodev_driver_id_get(
223 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
224 		if (nb_devs < 1) {
225 			ret = rte_vdev_init(
226 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 
228 			TEST_ASSERT(ret == 0,
229 				"Failed to create instance of"
230 				" pmd : %s",
231 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
232 		}
233 	}
234 
235 	/* Create an AESNI GCM device if required */
236 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
237 			RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
238 		nb_devs = rte_cryptodev_device_count_by_driver(
239 				rte_cryptodev_driver_id_get(
240 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
241 		if (nb_devs < 1) {
242 			TEST_ASSERT_SUCCESS(rte_vdev_init(
243 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
244 				"Failed to create instance of"
245 				" pmd : %s",
246 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
247 		}
248 	}
249 
250 	/* Create a SNOW 3G device if required */
251 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
252 			RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
253 		nb_devs = rte_cryptodev_device_count_by_driver(
254 				rte_cryptodev_driver_id_get(
255 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
256 		if (nb_devs < 1) {
257 			TEST_ASSERT_SUCCESS(rte_vdev_init(
258 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
259 				"Failed to create instance of"
260 				" pmd : %s",
261 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
262 		}
263 	}
264 
265 	/* Create a KASUMI device if required */
266 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
267 			RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
268 		nb_devs = rte_cryptodev_device_count_by_driver(
269 				rte_cryptodev_driver_id_get(
270 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
271 		if (nb_devs < 1) {
272 			TEST_ASSERT_SUCCESS(rte_vdev_init(
273 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
274 				"Failed to create instance of"
275 				" pmd : %s",
276 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
277 		}
278 	}
279 
280 	/* Create a ZUC device if required */
281 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
282 			RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
283 		nb_devs = rte_cryptodev_device_count_by_driver(
284 				rte_cryptodev_driver_id_get(
285 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
286 		if (nb_devs < 1) {
287 			TEST_ASSERT_SUCCESS(rte_vdev_init(
288 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
289 				"Failed to create instance of"
290 				" pmd : %s",
291 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
292 		}
293 	}
294 
295 	/* Create a NULL device if required */
296 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
297 			RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
298 		nb_devs = rte_cryptodev_device_count_by_driver(
299 				rte_cryptodev_driver_id_get(
300 				RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
301 		if (nb_devs < 1) {
302 			ret = rte_vdev_init(
303 				RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
304 
305 			TEST_ASSERT(ret == 0,
306 				"Failed to create instance of"
307 				" pmd : %s",
308 				RTE_STR(CRYPTODEV_NAME_NULL_PMD));
309 		}
310 	}
311 
312 	/* Create an OPENSSL device if required */
313 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
314 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
315 		nb_devs = rte_cryptodev_device_count_by_driver(
316 				rte_cryptodev_driver_id_get(
317 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
318 		if (nb_devs < 1) {
319 			ret = rte_vdev_init(
320 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
321 				NULL);
322 
323 			TEST_ASSERT(ret == 0, "Failed to create "
324 				"instance of pmd : %s",
325 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
326 		}
327 	}
328 
329 	/* Create a ARMv8 device if required */
330 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
331 			RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
332 		nb_devs = rte_cryptodev_device_count_by_driver(
333 				rte_cryptodev_driver_id_get(
334 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
335 		if (nb_devs < 1) {
336 			ret = rte_vdev_init(
337 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
338 				NULL);
339 
340 			TEST_ASSERT(ret == 0, "Failed to create "
341 				"instance of pmd : %s",
342 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
343 		}
344 	}
345 
346 	/* Create a MVSAM device if required */
347 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
348 			RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
349 		nb_devs = rte_cryptodev_device_count_by_driver(
350 				rte_cryptodev_driver_id_get(
351 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
352 		if (nb_devs < 1) {
353 			ret = rte_vdev_init(
354 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
355 				NULL);
356 
357 			TEST_ASSERT(ret == 0, "Failed to create "
358 				"instance of pmd : %s",
359 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
360 		}
361 	}
362 
363 	/* Create an CCP device if required */
364 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 			RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
366 		nb_devs = rte_cryptodev_device_count_by_driver(
367 				rte_cryptodev_driver_id_get(
368 				RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
369 		if (nb_devs < 1) {
370 			ret = rte_vdev_init(
371 				RTE_STR(CRYPTODEV_NAME_CCP_PMD),
372 				NULL);
373 
374 			TEST_ASSERT(ret == 0, "Failed to create "
375 				"instance of pmd : %s",
376 				RTE_STR(CRYPTODEV_NAME_CCP_PMD));
377 		}
378 	}
379 
380 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
381 	char vdev_args[VDEV_ARGS_SIZE] = {""};
382 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
383 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
384 	uint16_t slave_core_count = 0;
385 	uint16_t socket_id = 0;
386 
387 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
388 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
389 
390 		/* Identify the Slave Cores
391 		 * Use 2 slave cores for the device args
392 		 */
393 		RTE_LCORE_FOREACH_SLAVE(i) {
394 			if (slave_core_count > 1)
395 				break;
396 			snprintf(vdev_args, sizeof(vdev_args),
397 					"%s%d", temp_str, i);
398 			strcpy(temp_str, vdev_args);
399 			strlcat(temp_str, ";", sizeof(temp_str));
400 			slave_core_count++;
401 			socket_id = rte_lcore_to_socket_id(i);
402 		}
403 		if (slave_core_count != 2) {
404 			RTE_LOG(ERR, USER1,
405 				"Cryptodev scheduler test require at least "
406 				"two slave cores to run. "
407 				"Please use the correct coremask.\n");
408 			return TEST_FAILED;
409 		}
410 		strcpy(temp_str, vdev_args);
411 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
412 				temp_str, socket_id);
413 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
414 		nb_devs = rte_cryptodev_device_count_by_driver(
415 				rte_cryptodev_driver_id_get(
416 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
417 		if (nb_devs < 1) {
418 			ret = rte_vdev_init(
419 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
420 					vdev_args);
421 			TEST_ASSERT(ret == 0,
422 				"Failed to create instance %u of"
423 				" pmd : %s",
424 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
425 		}
426 	}
427 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
428 
429 	nb_devs = rte_cryptodev_count();
430 	if (nb_devs < 1) {
431 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
432 		return TEST_SKIPPED;
433 	}
434 
435 	/* Create list of valid crypto devs */
436 	for (i = 0; i < nb_devs; i++) {
437 		rte_cryptodev_info_get(i, &info);
438 		if (info.driver_id == gbl_driver_id)
439 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
440 	}
441 
442 	if (ts_params->valid_dev_count < 1)
443 		return TEST_FAILED;
444 
445 	/* Set up all the qps on the first of the valid devices found */
446 
447 	dev_id = ts_params->valid_devs[0];
448 
449 	rte_cryptodev_info_get(dev_id, &info);
450 
451 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
452 	ts_params->conf.socket_id = SOCKET_ID_ANY;
453 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
454 
455 	unsigned int session_size =
456 		rte_cryptodev_sym_get_private_session_size(dev_id);
457 
458 	/*
459 	 * Create mempool with maximum number of sessions * 2,
460 	 * to include the session headers
461 	 */
462 	if (info.sym.max_nb_sessions != 0 &&
463 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
464 		RTE_LOG(ERR, USER1, "Device does not support "
465 				"at least %u sessions\n",
466 				MAX_NB_SESSIONS);
467 		return TEST_FAILED;
468 	}
469 
470 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
471 			"test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
472 			SOCKET_ID_ANY);
473 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
474 			"session mempool allocation failed");
475 
476 	ts_params->session_priv_mpool = rte_mempool_create(
477 			"test_sess_mp_priv",
478 			MAX_NB_SESSIONS,
479 			session_size,
480 			0, 0, NULL, NULL, NULL,
481 			NULL, SOCKET_ID_ANY,
482 			0);
483 	TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
484 			"session mempool allocation failed");
485 
486 
487 
488 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
489 			&ts_params->conf),
490 			"Failed to configure cryptodev %u with %u qps",
491 			dev_id, ts_params->conf.nb_queue_pairs);
492 
493 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
494 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
495 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
496 
497 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
498 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
499 			dev_id, qp_id, &ts_params->qp_conf,
500 			rte_cryptodev_socket_id(dev_id)),
501 			"Failed to setup queue pair %u on cryptodev %u",
502 			qp_id, dev_id);
503 	}
504 
505 	return TEST_SUCCESS;
506 }
507 
508 static void
509 testsuite_teardown(void)
510 {
511 	struct crypto_testsuite_params *ts_params = &testsuite_params;
512 
513 	if (ts_params->mbuf_pool != NULL) {
514 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
515 		rte_mempool_avail_count(ts_params->mbuf_pool));
516 	}
517 
518 	if (ts_params->op_mpool != NULL) {
519 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
520 		rte_mempool_avail_count(ts_params->op_mpool));
521 	}
522 
523 	/* Free session mempools */
524 	if (ts_params->session_priv_mpool != NULL) {
525 		rte_mempool_free(ts_params->session_priv_mpool);
526 		ts_params->session_priv_mpool = NULL;
527 	}
528 
529 	if (ts_params->session_mpool != NULL) {
530 		rte_mempool_free(ts_params->session_mpool);
531 		ts_params->session_mpool = NULL;
532 	}
533 }
534 
535 static int
536 ut_setup(void)
537 {
538 	struct crypto_testsuite_params *ts_params = &testsuite_params;
539 	struct crypto_unittest_params *ut_params = &unittest_params;
540 
541 	uint16_t qp_id;
542 
543 	/* Clear unit test parameters before running test */
544 	memset(ut_params, 0, sizeof(*ut_params));
545 
546 	/* Reconfigure device to default parameters */
547 	ts_params->conf.socket_id = SOCKET_ID_ANY;
548 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
549 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
550 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
551 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
552 
553 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
554 			&ts_params->conf),
555 			"Failed to configure cryptodev %u",
556 			ts_params->valid_devs[0]);
557 
558 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
559 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
560 			ts_params->valid_devs[0], qp_id,
561 			&ts_params->qp_conf,
562 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
563 			"Failed to setup queue pair %u on cryptodev %u",
564 			qp_id, ts_params->valid_devs[0]);
565 	}
566 
567 
568 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
569 
570 	/* Start the device */
571 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
572 			"Failed to start cryptodev %u",
573 			ts_params->valid_devs[0]);
574 
575 	return TEST_SUCCESS;
576 }
577 
578 static void
579 ut_teardown(void)
580 {
581 	struct crypto_testsuite_params *ts_params = &testsuite_params;
582 	struct crypto_unittest_params *ut_params = &unittest_params;
583 	struct rte_cryptodev_stats stats;
584 
585 	/* free crypto session structure */
586 #ifdef RTE_LIBRTE_SECURITY
587 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
588 		if (ut_params->sec_session) {
589 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
590 						(ts_params->valid_devs[0]),
591 						ut_params->sec_session);
592 			ut_params->sec_session = NULL;
593 		}
594 	} else
595 #endif
596 	{
597 		if (ut_params->sess) {
598 			rte_cryptodev_sym_session_clear(
599 					ts_params->valid_devs[0],
600 					ut_params->sess);
601 			rte_cryptodev_sym_session_free(ut_params->sess);
602 			ut_params->sess = NULL;
603 		}
604 	}
605 
606 	/* free crypto operation structure */
607 	if (ut_params->op)
608 		rte_crypto_op_free(ut_params->op);
609 
610 	/*
611 	 * free mbuf - both obuf and ibuf are usually the same,
612 	 * so check if they point at the same address is necessary,
613 	 * to avoid freeing the mbuf twice.
614 	 */
615 	if (ut_params->obuf) {
616 		rte_pktmbuf_free(ut_params->obuf);
617 		if (ut_params->ibuf == ut_params->obuf)
618 			ut_params->ibuf = 0;
619 		ut_params->obuf = 0;
620 	}
621 	if (ut_params->ibuf) {
622 		rte_pktmbuf_free(ut_params->ibuf);
623 		ut_params->ibuf = 0;
624 	}
625 
626 	if (ts_params->mbuf_pool != NULL)
627 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
628 			rte_mempool_avail_count(ts_params->mbuf_pool));
629 
630 	rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
631 
632 	/* Stop the device */
633 	rte_cryptodev_stop(ts_params->valid_devs[0]);
634 }
635 
636 static int
637 test_device_configure_invalid_dev_id(void)
638 {
639 	struct crypto_testsuite_params *ts_params = &testsuite_params;
640 	uint16_t dev_id, num_devs = 0;
641 
642 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
643 			"Need at least %d devices for test", 1);
644 
645 	/* valid dev_id values */
646 	dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
647 
648 	/* Stop the device in case it's started so it can be configured */
649 	rte_cryptodev_stop(dev_id);
650 
651 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
652 			"Failed test for rte_cryptodev_configure: "
653 			"invalid dev_num %u", dev_id);
654 
655 	/* invalid dev_id values */
656 	dev_id = num_devs;
657 
658 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
659 			"Failed test for rte_cryptodev_configure: "
660 			"invalid dev_num %u", dev_id);
661 
662 	dev_id = 0xff;
663 
664 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
665 			"Failed test for rte_cryptodev_configure:"
666 			"invalid dev_num %u", dev_id);
667 
668 	return TEST_SUCCESS;
669 }
670 
671 static int
672 test_device_configure_invalid_queue_pair_ids(void)
673 {
674 	struct crypto_testsuite_params *ts_params = &testsuite_params;
675 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
676 
677 	/* Stop the device in case it's started so it can be configured */
678 	rte_cryptodev_stop(ts_params->valid_devs[0]);
679 
680 	/* valid - one queue pairs */
681 	ts_params->conf.nb_queue_pairs = 1;
682 
683 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
684 			&ts_params->conf),
685 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
686 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
687 
688 
689 	/* valid - max value queue pairs */
690 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
691 
692 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
693 			&ts_params->conf),
694 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
695 			ts_params->valid_devs[0],
696 			ts_params->conf.nb_queue_pairs);
697 
698 
699 	/* invalid - zero queue pairs */
700 	ts_params->conf.nb_queue_pairs = 0;
701 
702 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
703 			&ts_params->conf),
704 			"Failed test for rte_cryptodev_configure, dev_id %u,"
705 			" invalid qps: %u",
706 			ts_params->valid_devs[0],
707 			ts_params->conf.nb_queue_pairs);
708 
709 
710 	/* invalid - max value supported by field queue pairs */
711 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
712 
713 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
714 			&ts_params->conf),
715 			"Failed test for rte_cryptodev_configure, dev_id %u,"
716 			" invalid qps: %u",
717 			ts_params->valid_devs[0],
718 			ts_params->conf.nb_queue_pairs);
719 
720 
721 	/* invalid - max value + 1 queue pairs */
722 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
723 
724 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
725 			&ts_params->conf),
726 			"Failed test for rte_cryptodev_configure, dev_id %u,"
727 			" invalid qps: %u",
728 			ts_params->valid_devs[0],
729 			ts_params->conf.nb_queue_pairs);
730 
731 	/* revert to original testsuite value */
732 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
733 
734 	return TEST_SUCCESS;
735 }
736 
737 static int
738 test_queue_pair_descriptor_setup(void)
739 {
740 	struct crypto_testsuite_params *ts_params = &testsuite_params;
741 	struct rte_cryptodev_info dev_info;
742 	struct rte_cryptodev_qp_conf qp_conf = {
743 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
744 	};
745 
746 	uint16_t qp_id;
747 
748 	/* Stop the device in case it's started so it can be configured */
749 	rte_cryptodev_stop(ts_params->valid_devs[0]);
750 
751 
752 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
753 
754 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
755 			&ts_params->conf),
756 			"Failed to configure cryptodev %u",
757 			ts_params->valid_devs[0]);
758 
759 	/*
760 	 * Test various ring sizes on this device. memzones can't be
761 	 * freed so are re-used if ring is released and re-created.
762 	 */
763 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
764 	qp_conf.mp_session = ts_params->session_mpool;
765 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
766 
767 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
768 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
769 				ts_params->valid_devs[0], qp_id, &qp_conf,
770 				rte_cryptodev_socket_id(
771 						ts_params->valid_devs[0])),
772 				"Failed test for "
773 				"rte_cryptodev_queue_pair_setup: num_inflights "
774 				"%u on qp %u on cryptodev %u",
775 				qp_conf.nb_descriptors, qp_id,
776 				ts_params->valid_devs[0]);
777 	}
778 
779 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
780 
781 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
782 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
783 				ts_params->valid_devs[0], qp_id, &qp_conf,
784 				rte_cryptodev_socket_id(
785 						ts_params->valid_devs[0])),
786 				"Failed test for"
787 				" rte_cryptodev_queue_pair_setup: num_inflights"
788 				" %u on qp %u on cryptodev %u",
789 				qp_conf.nb_descriptors, qp_id,
790 				ts_params->valid_devs[0]);
791 	}
792 
793 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
794 
795 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
796 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
797 				ts_params->valid_devs[0], qp_id, &qp_conf,
798 				rte_cryptodev_socket_id(
799 						ts_params->valid_devs[0])),
800 				"Failed test for "
801 				"rte_cryptodev_queue_pair_setup: num_inflights"
802 				" %u on qp %u on cryptodev %u",
803 				qp_conf.nb_descriptors, qp_id,
804 				ts_params->valid_devs[0]);
805 	}
806 
807 	/* invalid number of descriptors - max supported + 2 */
808 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
809 
810 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
811 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
812 				ts_params->valid_devs[0], qp_id, &qp_conf,
813 				rte_cryptodev_socket_id(
814 						ts_params->valid_devs[0])),
815 				"Unexpectedly passed test for "
816 				"rte_cryptodev_queue_pair_setup:"
817 				"num_inflights %u on qp %u on cryptodev %u",
818 				qp_conf.nb_descriptors, qp_id,
819 				ts_params->valid_devs[0]);
820 	}
821 
822 	/* invalid number of descriptors - max value of parameter */
823 	qp_conf.nb_descriptors = UINT32_MAX-1;
824 
825 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
826 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
827 				ts_params->valid_devs[0], qp_id, &qp_conf,
828 				rte_cryptodev_socket_id(
829 						ts_params->valid_devs[0])),
830 				"Unexpectedly passed test for "
831 				"rte_cryptodev_queue_pair_setup:"
832 				"num_inflights %u on qp %u on cryptodev %u",
833 				qp_conf.nb_descriptors, qp_id,
834 				ts_params->valid_devs[0]);
835 	}
836 
837 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
838 
839 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
840 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
841 				ts_params->valid_devs[0], qp_id, &qp_conf,
842 				rte_cryptodev_socket_id(
843 						ts_params->valid_devs[0])),
844 				"Failed test for"
845 				" rte_cryptodev_queue_pair_setup:"
846 				"num_inflights %u on qp %u on cryptodev %u",
847 				qp_conf.nb_descriptors, qp_id,
848 				ts_params->valid_devs[0]);
849 	}
850 
851 	/* invalid number of descriptors - max supported + 1 */
852 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
853 
854 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
855 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
856 				ts_params->valid_devs[0], qp_id, &qp_conf,
857 				rte_cryptodev_socket_id(
858 						ts_params->valid_devs[0])),
859 				"Unexpectedly passed test for "
860 				"rte_cryptodev_queue_pair_setup:"
861 				"num_inflights %u on qp %u on cryptodev %u",
862 				qp_conf.nb_descriptors, qp_id,
863 				ts_params->valid_devs[0]);
864 	}
865 
866 	/* test invalid queue pair id */
867 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
868 
869 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
870 
871 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
872 			ts_params->valid_devs[0],
873 			qp_id, &qp_conf,
874 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
875 			"Failed test for rte_cryptodev_queue_pair_setup:"
876 			"invalid qp %u on cryptodev %u",
877 			qp_id, ts_params->valid_devs[0]);
878 
879 	qp_id = 0xffff; /*invalid*/
880 
881 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
882 			ts_params->valid_devs[0],
883 			qp_id, &qp_conf,
884 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
885 			"Failed test for rte_cryptodev_queue_pair_setup:"
886 			"invalid qp %u on cryptodev %u",
887 			qp_id, ts_params->valid_devs[0]);
888 
889 	return TEST_SUCCESS;
890 }
891 
892 /* ***** Plaintext data for tests ***** */
893 
894 const char catch_22_quote_1[] =
895 		"There was only one catch and that was Catch-22, which "
896 		"specified that a concern for one's safety in the face of "
897 		"dangers that were real and immediate was the process of a "
898 		"rational mind. Orr was crazy and could be grounded. All he "
899 		"had to do was ask; and as soon as he did, he would no longer "
900 		"be crazy and would have to fly more missions. Orr would be "
901 		"crazy to fly more missions and sane if he didn't, but if he "
902 		"was sane he had to fly them. If he flew them he was crazy "
903 		"and didn't have to; but if he didn't want to he was sane and "
904 		"had to. Yossarian was moved very deeply by the absolute "
905 		"simplicity of this clause of Catch-22 and let out a "
906 		"respectful whistle. \"That's some catch, that Catch-22\", he "
907 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
908 
909 const char catch_22_quote[] =
910 		"What a lousy earth! He wondered how many people were "
911 		"destitute that same night even in his own prosperous country, "
912 		"how many homes were shanties, how many husbands were drunk "
913 		"and wives socked, and how many children were bullied, abused, "
914 		"or abandoned. How many families hungered for food they could "
915 		"not afford to buy? How many hearts were broken? How many "
916 		"suicides would take place that same night, how many people "
917 		"would go insane? How many cockroaches and landlords would "
918 		"triumph? How many winners were losers, successes failures, "
919 		"and rich men poor men? How many wise guys were stupid? How "
920 		"many happy endings were unhappy endings? How many honest men "
921 		"were liars, brave men cowards, loyal men traitors, how many "
922 		"sainted men were corrupt, how many people in positions of "
923 		"trust had sold their souls to bodyguards, how many had never "
924 		"had souls? How many straight-and-narrow paths were crooked "
925 		"paths? How many best families were worst families and how "
926 		"many good people were bad people? When you added them all up "
927 		"and then subtracted, you might be left with only the children, "
928 		"and perhaps with Albert Einstein and an old violinist or "
929 		"sculptor somewhere.";
930 
931 #define QUOTE_480_BYTES		(480)
932 #define QUOTE_512_BYTES		(512)
933 #define QUOTE_768_BYTES		(768)
934 #define QUOTE_1024_BYTES	(1024)
935 
936 
937 
938 /* ***** SHA1 Hash Tests ***** */
939 
940 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
941 
942 static uint8_t hmac_sha1_key[] = {
943 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
944 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
945 	0xDE, 0xF4, 0xDE, 0xAD };
946 
947 /* ***** SHA224 Hash Tests ***** */
948 
949 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
950 
951 
952 /* ***** AES-CBC Cipher Tests ***** */
953 
954 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
955 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
956 
957 static uint8_t aes_cbc_key[] = {
958 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
959 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
960 
961 static uint8_t aes_cbc_iv[] = {
962 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
963 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
964 
965 
966 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
967 
968 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
969 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
970 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
971 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
972 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
973 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
974 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
975 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
976 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
977 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
978 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
979 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
980 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
981 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
982 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
983 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
984 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
985 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
986 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
987 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
988 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
989 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
990 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
991 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
992 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
993 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
994 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
995 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
996 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
997 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
998 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
999 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1000 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1001 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1002 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1003 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1004 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1005 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1006 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1007 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1008 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1009 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1010 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1011 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1012 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1013 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1014 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1015 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1016 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1017 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1018 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1019 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1020 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1021 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1022 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1023 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1024 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1025 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1026 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1027 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1028 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1029 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1030 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1031 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1032 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1033 };
1034 
1035 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1036 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1037 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1038 	0x18, 0x8c, 0x1d, 0x32
1039 };
1040 
1041 
1042 /* Multisession Vector context Test */
1043 /*Begin Session 0 */
1044 static uint8_t ms_aes_cbc_key0[] = {
1045 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1046 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1047 };
1048 
1049 static uint8_t ms_aes_cbc_iv0[] = {
1050 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1052 };
1053 
1054 static const uint8_t ms_aes_cbc_cipher0[] = {
1055 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1056 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1057 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1058 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1059 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1060 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1061 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1062 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1063 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1064 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1065 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1066 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1067 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1068 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1069 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1070 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1071 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1072 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1073 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1074 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1075 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1076 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1077 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1078 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1079 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1080 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1081 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1082 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1083 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1084 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1085 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1086 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1087 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1088 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1089 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1090 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1091 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1092 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1093 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1094 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1095 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1096 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1097 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1098 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1099 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1100 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1101 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1102 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1103 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1104 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1105 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1106 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1107 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1108 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1109 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1110 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1111 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1112 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1113 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1114 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1115 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1116 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1117 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1118 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1119 };
1120 
1121 
1122 static  uint8_t ms_hmac_key0[] = {
1123 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1124 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1125 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1126 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1127 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1128 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1129 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1130 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1131 };
1132 
1133 static const uint8_t ms_hmac_digest0[] = {
1134 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1135 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1136 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1137 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1138 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1139 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1140 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1141 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1142 		};
1143 
1144 /* End Session 0 */
1145 /* Begin session 1 */
1146 
1147 static  uint8_t ms_aes_cbc_key1[] = {
1148 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1149 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1150 };
1151 
1152 static  uint8_t ms_aes_cbc_iv1[] = {
1153 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1154 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1155 };
1156 
1157 static const uint8_t ms_aes_cbc_cipher1[] = {
1158 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1159 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1160 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1161 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1162 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1163 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1164 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1165 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1166 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1167 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1168 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1169 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1170 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1171 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1172 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1173 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1174 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1175 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1176 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1177 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1178 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1179 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1180 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1181 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1182 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1183 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1184 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1185 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1186 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1187 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1188 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1189 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1190 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1191 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1192 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1193 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1194 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1195 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1196 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1197 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1198 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1199 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1200 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1201 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1202 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1203 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1204 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1205 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1206 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1207 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1208 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1209 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1210 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1211 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1212 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1213 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1214 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1215 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1216 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1217 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1218 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1219 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1220 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1221 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1222 
1223 };
1224 
1225 static uint8_t ms_hmac_key1[] = {
1226 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1234 };
1235 
1236 static const uint8_t ms_hmac_digest1[] = {
1237 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1238 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1239 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1240 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1241 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1242 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1243 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1244 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1245 };
1246 /* End Session 1  */
1247 /* Begin Session 2 */
1248 static  uint8_t ms_aes_cbc_key2[] = {
1249 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1250 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1251 };
1252 
1253 static  uint8_t ms_aes_cbc_iv2[] = {
1254 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1255 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1256 };
1257 
1258 static const uint8_t ms_aes_cbc_cipher2[] = {
1259 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1260 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1261 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1262 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1263 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1264 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1265 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1266 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1267 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1268 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1269 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1270 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1271 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1272 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1273 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1274 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1275 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1276 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1277 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1278 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1279 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1280 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1281 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1282 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1283 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1284 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1285 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1286 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1287 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1288 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1289 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1290 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1291 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1292 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1293 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1294 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1295 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1296 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1297 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1298 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1299 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1300 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1301 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1302 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1303 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1304 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1305 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1306 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1307 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1308 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1309 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1310 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1311 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1312 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1313 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1314 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1315 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1316 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1317 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1318 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1319 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1320 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1321 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1322 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1323 };
1324 
1325 static  uint8_t ms_hmac_key2[] = {
1326 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1327 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1328 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1329 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1330 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1331 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1332 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1333 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1334 };
1335 
1336 static const uint8_t ms_hmac_digest2[] = {
1337 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1338 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1339 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1340 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1341 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1342 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1343 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1344 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1345 };
1346 
1347 /* End Session 2 */
1348 
1349 
1350 static int
1351 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1352 {
1353 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1354 	struct crypto_unittest_params *ut_params = &unittest_params;
1355 
1356 	/* Generate test mbuf data and space for digest */
1357 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1358 			catch_22_quote,	QUOTE_512_BYTES, 0);
1359 
1360 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1361 			DIGEST_BYTE_LENGTH_SHA1);
1362 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1363 
1364 	/* Setup Cipher Parameters */
1365 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1366 	ut_params->cipher_xform.next = &ut_params->auth_xform;
1367 
1368 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1369 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1370 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1371 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1372 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1373 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1374 
1375 	/* Setup HMAC Parameters */
1376 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1377 
1378 	ut_params->auth_xform.next = NULL;
1379 
1380 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1381 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1382 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1383 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1384 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1385 
1386 	ut_params->sess = rte_cryptodev_sym_session_create(
1387 			ts_params->session_mpool);
1388 
1389 	/* Create crypto session*/
1390 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1391 			ut_params->sess, &ut_params->cipher_xform,
1392 			ts_params->session_priv_mpool);
1393 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1394 
1395 	/* Generate crypto op data structure */
1396 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1397 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1398 	TEST_ASSERT_NOT_NULL(ut_params->op,
1399 			"Failed to allocate symmetric crypto operation struct");
1400 
1401 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1402 
1403 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1404 
1405 	/* set crypto operation source mbuf */
1406 	sym_op->m_src = ut_params->ibuf;
1407 
1408 	/* Set crypto operation authentication parameters */
1409 	sym_op->auth.digest.data = ut_params->digest;
1410 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1411 			ut_params->ibuf, QUOTE_512_BYTES);
1412 
1413 	sym_op->auth.data.offset = 0;
1414 	sym_op->auth.data.length = QUOTE_512_BYTES;
1415 
1416 	/* Copy IV at the end of the crypto operation */
1417 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1418 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1419 
1420 	/* Set crypto operation cipher parameters */
1421 	sym_op->cipher.data.offset = 0;
1422 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1423 
1424 	/* Process crypto operation */
1425 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1426 			ut_params->op), "failed to process sym crypto op");
1427 
1428 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1429 			"crypto op processing failed");
1430 
1431 	/* Validate obuf */
1432 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1433 			uint8_t *);
1434 
1435 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1436 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1437 			QUOTE_512_BYTES,
1438 			"ciphertext data not as expected");
1439 
1440 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1441 
1442 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1443 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1444 			gbl_driver_id == rte_cryptodev_driver_id_get(
1445 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1446 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1447 					DIGEST_BYTE_LENGTH_SHA1,
1448 			"Generated digest data not as expected");
1449 
1450 	return TEST_SUCCESS;
1451 }
1452 
1453 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1454 
1455 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
1456 
1457 static uint8_t hmac_sha512_key[] = {
1458 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1459 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1460 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1461 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1462 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1463 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1464 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1465 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1466 
1467 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1468 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1469 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1470 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1471 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1472 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1473 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1474 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1475 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1476 
1477 
1478 
1479 static int
1480 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1481 		struct crypto_unittest_params *ut_params,
1482 		uint8_t *cipher_key,
1483 		uint8_t *hmac_key);
1484 
1485 static int
1486 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1487 		struct crypto_unittest_params *ut_params,
1488 		struct crypto_testsuite_params *ts_params,
1489 		const uint8_t *cipher,
1490 		const uint8_t *digest,
1491 		const uint8_t *iv);
1492 
1493 
1494 static int
1495 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1496 		struct crypto_unittest_params *ut_params,
1497 		uint8_t *cipher_key,
1498 		uint8_t *hmac_key)
1499 {
1500 
1501 	/* Setup Cipher Parameters */
1502 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1503 	ut_params->cipher_xform.next = NULL;
1504 
1505 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1506 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1507 	ut_params->cipher_xform.cipher.key.data = cipher_key;
1508 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1509 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1510 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1511 
1512 	/* Setup HMAC Parameters */
1513 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1514 	ut_params->auth_xform.next = &ut_params->cipher_xform;
1515 
1516 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1517 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1518 	ut_params->auth_xform.auth.key.data = hmac_key;
1519 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1520 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1521 
1522 	return TEST_SUCCESS;
1523 }
1524 
1525 
1526 static int
1527 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1528 		struct crypto_unittest_params *ut_params,
1529 		struct crypto_testsuite_params *ts_params,
1530 		const uint8_t *cipher,
1531 		const uint8_t *digest,
1532 		const uint8_t *iv)
1533 {
1534 	/* Generate test mbuf data and digest */
1535 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1536 			(const char *)
1537 			cipher,
1538 			QUOTE_512_BYTES, 0);
1539 
1540 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1541 			DIGEST_BYTE_LENGTH_SHA512);
1542 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1543 
1544 	rte_memcpy(ut_params->digest,
1545 			digest,
1546 			DIGEST_BYTE_LENGTH_SHA512);
1547 
1548 	/* Generate Crypto op data structure */
1549 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1550 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1551 	TEST_ASSERT_NOT_NULL(ut_params->op,
1552 			"Failed to allocate symmetric crypto operation struct");
1553 
1554 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
1555 
1556 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1557 
1558 	/* set crypto operation source mbuf */
1559 	sym_op->m_src = ut_params->ibuf;
1560 
1561 	sym_op->auth.digest.data = ut_params->digest;
1562 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1563 			ut_params->ibuf, QUOTE_512_BYTES);
1564 
1565 	sym_op->auth.data.offset = 0;
1566 	sym_op->auth.data.length = QUOTE_512_BYTES;
1567 
1568 	/* Copy IV at the end of the crypto operation */
1569 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1570 			iv, CIPHER_IV_LENGTH_AES_CBC);
1571 
1572 	sym_op->cipher.data.offset = 0;
1573 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1574 
1575 	/* Process crypto operation */
1576 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1577 			ut_params->op), "failed to process sym crypto op");
1578 
1579 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1580 			"crypto op processing failed");
1581 
1582 	ut_params->obuf = ut_params->op->sym->m_src;
1583 
1584 	/* Validate obuf */
1585 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
1586 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1587 			catch_22_quote,
1588 			QUOTE_512_BYTES,
1589 			"Plaintext data not as expected");
1590 
1591 	/* Validate obuf */
1592 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1593 			"Digest verification failed");
1594 
1595 	return TEST_SUCCESS;
1596 }
1597 
1598 static int
1599 test_AES_cipheronly_mb_all(void)
1600 {
1601 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 	int status;
1603 
1604 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1605 		ts_params->op_mpool,
1606 		ts_params->session_mpool, ts_params->session_priv_mpool,
1607 		ts_params->valid_devs[0],
1608 		rte_cryptodev_driver_id_get(
1609 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1610 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1611 
1612 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1613 
1614 	return TEST_SUCCESS;
1615 }
1616 
1617 static int
1618 test_AES_docsis_mb_all(void)
1619 {
1620 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1621 	int status;
1622 
1623 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1624 		ts_params->op_mpool,
1625 		ts_params->session_mpool, ts_params->session_priv_mpool,
1626 		ts_params->valid_devs[0],
1627 		rte_cryptodev_driver_id_get(
1628 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1629 		BLKCIPHER_AES_DOCSIS_TYPE);
1630 
1631 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1632 
1633 	return TEST_SUCCESS;
1634 }
1635 
1636 static int
1637 test_AES_docsis_qat_all(void)
1638 {
1639 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1640 	int status;
1641 
1642 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1643 		ts_params->op_mpool,
1644 		ts_params->session_mpool, ts_params->session_priv_mpool,
1645 		ts_params->valid_devs[0],
1646 		rte_cryptodev_driver_id_get(
1647 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1648 		BLKCIPHER_AES_DOCSIS_TYPE);
1649 
1650 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1651 
1652 	return TEST_SUCCESS;
1653 }
1654 
1655 static int
1656 test_DES_docsis_qat_all(void)
1657 {
1658 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1659 	int status;
1660 
1661 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1662 		ts_params->op_mpool,
1663 		ts_params->session_mpool, ts_params->session_priv_mpool,
1664 		ts_params->valid_devs[0],
1665 		rte_cryptodev_driver_id_get(
1666 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1667 		BLKCIPHER_DES_DOCSIS_TYPE);
1668 
1669 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1670 
1671 	return TEST_SUCCESS;
1672 }
1673 
1674 static int
1675 test_authonly_mb_all(void)
1676 {
1677 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1678 	int status;
1679 
1680 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1681 		ts_params->op_mpool,
1682 		ts_params->session_mpool, ts_params->session_priv_mpool,
1683 		ts_params->valid_devs[0],
1684 		rte_cryptodev_driver_id_get(
1685 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1686 		BLKCIPHER_AUTHONLY_TYPE);
1687 
1688 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1689 
1690 	return TEST_SUCCESS;
1691 }
1692 
1693 static int
1694 test_authonly_qat_all(void)
1695 {
1696 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1697 	int status;
1698 
1699 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1700 		ts_params->op_mpool,
1701 		ts_params->session_mpool, ts_params->session_priv_mpool,
1702 		ts_params->valid_devs[0],
1703 		rte_cryptodev_driver_id_get(
1704 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1705 		BLKCIPHER_AUTHONLY_TYPE);
1706 
1707 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1708 
1709 	return TEST_SUCCESS;
1710 }
1711 
1712 static int
1713 test_AES_chain_null_all(void)
1714 {
1715 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 	int status;
1717 
1718 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1719 		ts_params->op_mpool,
1720 		ts_params->session_mpool, ts_params->session_priv_mpool,
1721 		ts_params->valid_devs[0],
1722 		rte_cryptodev_driver_id_get(
1723 		RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1724 		BLKCIPHER_AES_CHAIN_TYPE);
1725 
1726 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1727 
1728 	return TEST_SUCCESS;
1729 }
1730 
1731 static int
1732 test_AES_cipheronly_null_all(void)
1733 {
1734 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1735 	int status;
1736 
1737 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1738 		ts_params->op_mpool,
1739 		ts_params->session_mpool, ts_params->session_priv_mpool,
1740 		ts_params->valid_devs[0],
1741 		rte_cryptodev_driver_id_get(
1742 		RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1743 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1744 
1745 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1746 
1747 	return TEST_SUCCESS;
1748 }
1749 
1750 static int
1751 test_authonly_null_all(void)
1752 {
1753 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1754 	int status;
1755 
1756 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1757 		ts_params->op_mpool,
1758 		ts_params->session_mpool, ts_params->session_priv_mpool,
1759 		ts_params->valid_devs[0],
1760 		rte_cryptodev_driver_id_get(
1761 		RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1762 		BLKCIPHER_AUTHONLY_TYPE);
1763 
1764 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1765 
1766 	return TEST_SUCCESS;
1767 }
1768 
1769 static int
1770 test_AES_chain_mb_all(void)
1771 {
1772 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1773 	int status;
1774 
1775 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1776 		ts_params->op_mpool,
1777 		ts_params->session_mpool, ts_params->session_priv_mpool,
1778 		ts_params->valid_devs[0],
1779 		rte_cryptodev_driver_id_get(
1780 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1781 		BLKCIPHER_AES_CHAIN_TYPE);
1782 
1783 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1784 
1785 	return TEST_SUCCESS;
1786 }
1787 
1788 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1789 
1790 static int
1791 test_AES_cipheronly_scheduler_all(void)
1792 {
1793 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1794 	int status;
1795 
1796 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1797 		ts_params->op_mpool,
1798 		ts_params->session_mpool, ts_params->session_priv_mpool,
1799 		ts_params->valid_devs[0],
1800 		rte_cryptodev_driver_id_get(
1801 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1802 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1803 
1804 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1805 
1806 	return TEST_SUCCESS;
1807 }
1808 
1809 static int
1810 test_AES_chain_scheduler_all(void)
1811 {
1812 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1813 	int status;
1814 
1815 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1816 		ts_params->op_mpool,
1817 		ts_params->session_mpool, ts_params->session_priv_mpool,
1818 		ts_params->valid_devs[0],
1819 		rte_cryptodev_driver_id_get(
1820 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1821 		BLKCIPHER_AES_CHAIN_TYPE);
1822 
1823 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1824 
1825 	return TEST_SUCCESS;
1826 }
1827 
1828 static int
1829 test_authonly_scheduler_all(void)
1830 {
1831 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1832 	int status;
1833 
1834 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1835 		ts_params->op_mpool,
1836 		ts_params->session_mpool, ts_params->session_priv_mpool,
1837 		ts_params->valid_devs[0],
1838 		rte_cryptodev_driver_id_get(
1839 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1840 		BLKCIPHER_AUTHONLY_TYPE);
1841 
1842 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1843 
1844 	return TEST_SUCCESS;
1845 }
1846 
1847 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1848 
1849 static int
1850 test_AES_chain_openssl_all(void)
1851 {
1852 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1853 	int status;
1854 
1855 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1856 		ts_params->op_mpool,
1857 		ts_params->session_mpool, ts_params->session_priv_mpool,
1858 		ts_params->valid_devs[0],
1859 		rte_cryptodev_driver_id_get(
1860 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1861 		BLKCIPHER_AES_CHAIN_TYPE);
1862 
1863 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1864 
1865 	return TEST_SUCCESS;
1866 }
1867 
1868 static int
1869 test_AES_cipheronly_openssl_all(void)
1870 {
1871 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1872 	int status;
1873 
1874 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1875 		ts_params->op_mpool,
1876 		ts_params->session_mpool, ts_params->session_priv_mpool,
1877 		ts_params->valid_devs[0],
1878 		rte_cryptodev_driver_id_get(
1879 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1880 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1881 
1882 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1883 
1884 	return TEST_SUCCESS;
1885 }
1886 
1887 static int
1888 test_AES_chain_ccp_all(void)
1889 {
1890 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1891 	int status;
1892 
1893 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1894 		ts_params->op_mpool,
1895 		ts_params->session_mpool, ts_params->session_priv_mpool,
1896 		ts_params->valid_devs[0],
1897 		rte_cryptodev_driver_id_get(
1898 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1899 		BLKCIPHER_AES_CHAIN_TYPE);
1900 
1901 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1902 
1903 	return TEST_SUCCESS;
1904 }
1905 
1906 static int
1907 test_AES_cipheronly_ccp_all(void)
1908 {
1909 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1910 	int status;
1911 
1912 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1913 		ts_params->op_mpool,
1914 		ts_params->session_mpool, ts_params->session_priv_mpool,
1915 		ts_params->valid_devs[0],
1916 		rte_cryptodev_driver_id_get(
1917 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1918 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1919 
1920 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1921 
1922 	return TEST_SUCCESS;
1923 }
1924 
1925 static int
1926 test_AES_chain_qat_all(void)
1927 {
1928 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1929 	int status;
1930 
1931 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1932 		ts_params->op_mpool,
1933 		ts_params->session_mpool, ts_params->session_priv_mpool,
1934 		ts_params->valid_devs[0],
1935 		rte_cryptodev_driver_id_get(
1936 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1937 		BLKCIPHER_AES_CHAIN_TYPE);
1938 
1939 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1940 
1941 	return TEST_SUCCESS;
1942 }
1943 
1944 static int
1945 test_AES_cipheronly_qat_all(void)
1946 {
1947 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1948 	int status;
1949 
1950 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1951 		ts_params->op_mpool,
1952 		ts_params->session_mpool, ts_params->session_priv_mpool,
1953 		ts_params->valid_devs[0],
1954 		rte_cryptodev_driver_id_get(
1955 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1956 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1957 
1958 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1959 
1960 	return TEST_SUCCESS;
1961 }
1962 
1963 static int
1964 test_AES_cipheronly_virtio_all(void)
1965 {
1966 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1967 	int status;
1968 
1969 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1970 		ts_params->op_mpool,
1971 		ts_params->session_mpool, ts_params->session_priv_mpool,
1972 		ts_params->valid_devs[0],
1973 		rte_cryptodev_driver_id_get(
1974 		RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1975 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1976 
1977 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1978 
1979 	return TEST_SUCCESS;
1980 }
1981 
1982 static int
1983 test_AES_chain_caam_jr_all(void)
1984 {
1985 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1986 	int status;
1987 
1988 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1989 		ts_params->op_mpool,
1990 		ts_params->session_mpool, ts_params->session_priv_mpool,
1991 		ts_params->valid_devs[0],
1992 		rte_cryptodev_driver_id_get(
1993 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1994 		BLKCIPHER_AES_CHAIN_TYPE);
1995 
1996 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1997 
1998 	return TEST_SUCCESS;
1999 }
2000 
2001 static int
2002 test_AES_cipheronly_caam_jr_all(void)
2003 {
2004 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2005 	int status;
2006 
2007 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2008 		ts_params->op_mpool,
2009 		ts_params->session_mpool, ts_params->session_priv_mpool,
2010 		ts_params->valid_devs[0],
2011 		rte_cryptodev_driver_id_get(
2012 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2013 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2014 
2015 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2016 
2017 	return TEST_SUCCESS;
2018 }
2019 
2020 static int
2021 test_authonly_caam_jr_all(void)
2022 {
2023 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2024 	int status;
2025 
2026 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2027 		ts_params->op_mpool,
2028 		ts_params->session_mpool, ts_params->session_priv_mpool,
2029 		ts_params->valid_devs[0],
2030 		rte_cryptodev_driver_id_get(
2031 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2032 		BLKCIPHER_AUTHONLY_TYPE);
2033 
2034 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2035 
2036 	return TEST_SUCCESS;
2037 }
2038 
2039 
2040 static int
2041 test_AES_chain_dpaa_sec_all(void)
2042 {
2043 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2044 	int status;
2045 
2046 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2047 		ts_params->op_mpool,
2048 		ts_params->session_mpool, ts_params->session_priv_mpool,
2049 		ts_params->valid_devs[0],
2050 		rte_cryptodev_driver_id_get(
2051 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2052 		BLKCIPHER_AES_CHAIN_TYPE);
2053 
2054 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2055 
2056 	return TEST_SUCCESS;
2057 }
2058 
2059 static int
2060 test_AES_cipheronly_dpaa_sec_all(void)
2061 {
2062 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2063 	int status;
2064 
2065 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2066 		ts_params->op_mpool,
2067 		ts_params->session_mpool, ts_params->session_priv_mpool,
2068 		ts_params->valid_devs[0],
2069 		rte_cryptodev_driver_id_get(
2070 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2071 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2072 
2073 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2074 
2075 	return TEST_SUCCESS;
2076 }
2077 
2078 static int
2079 test_authonly_dpaa_sec_all(void)
2080 {
2081 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2082 	int status;
2083 
2084 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2085 		ts_params->op_mpool,
2086 		ts_params->session_mpool, ts_params->session_priv_mpool,
2087 		ts_params->valid_devs[0],
2088 		rte_cryptodev_driver_id_get(
2089 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2090 		BLKCIPHER_AUTHONLY_TYPE);
2091 
2092 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2093 
2094 	return TEST_SUCCESS;
2095 }
2096 
2097 static int
2098 test_AES_chain_dpaa2_sec_all(void)
2099 {
2100 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2101 	int status;
2102 
2103 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2104 		ts_params->op_mpool,
2105 		ts_params->session_mpool, ts_params->session_priv_mpool,
2106 		ts_params->valid_devs[0],
2107 		rte_cryptodev_driver_id_get(
2108 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2109 		BLKCIPHER_AES_CHAIN_TYPE);
2110 
2111 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2112 
2113 	return TEST_SUCCESS;
2114 }
2115 
2116 static int
2117 test_AES_cipheronly_dpaa2_sec_all(void)
2118 {
2119 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2120 	int status;
2121 
2122 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2123 		ts_params->op_mpool,
2124 		ts_params->session_mpool, ts_params->session_priv_mpool,
2125 		ts_params->valid_devs[0],
2126 		rte_cryptodev_driver_id_get(
2127 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2128 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2129 
2130 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2131 
2132 	return TEST_SUCCESS;
2133 }
2134 
2135 static int
2136 test_authonly_dpaa2_sec_all(void)
2137 {
2138 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2139 	int status;
2140 
2141 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2142 		ts_params->op_mpool,
2143 		ts_params->session_mpool, ts_params->session_priv_mpool,
2144 		ts_params->valid_devs[0],
2145 		rte_cryptodev_driver_id_get(
2146 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2147 		BLKCIPHER_AUTHONLY_TYPE);
2148 
2149 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2150 
2151 	return TEST_SUCCESS;
2152 }
2153 
2154 static int
2155 test_authonly_openssl_all(void)
2156 {
2157 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2158 	int status;
2159 
2160 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2161 		ts_params->op_mpool,
2162 		ts_params->session_mpool, ts_params->session_priv_mpool,
2163 		ts_params->valid_devs[0],
2164 		rte_cryptodev_driver_id_get(
2165 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2166 		BLKCIPHER_AUTHONLY_TYPE);
2167 
2168 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2169 
2170 	return TEST_SUCCESS;
2171 }
2172 
2173 static int
2174 test_authonly_ccp_all(void)
2175 {
2176 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2177 	int status;
2178 
2179 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2180 		ts_params->op_mpool,
2181 		ts_params->session_mpool, ts_params->session_priv_mpool,
2182 		ts_params->valid_devs[0],
2183 		rte_cryptodev_driver_id_get(
2184 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2185 		BLKCIPHER_AUTHONLY_TYPE);
2186 
2187 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2188 
2189 	return TEST_SUCCESS;
2190 }
2191 
2192 static int
2193 test_AES_chain_armv8_all(void)
2194 {
2195 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2196 	int status;
2197 
2198 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2199 		ts_params->op_mpool,
2200 		ts_params->session_mpool, ts_params->session_priv_mpool,
2201 		ts_params->valid_devs[0],
2202 		rte_cryptodev_driver_id_get(
2203 		RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2204 		BLKCIPHER_AES_CHAIN_TYPE);
2205 
2206 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2207 
2208 	return TEST_SUCCESS;
2209 }
2210 
2211 static int
2212 test_AES_chain_mrvl_all(void)
2213 {
2214 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2215 	int status;
2216 
2217 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2218 		ts_params->op_mpool,
2219 		ts_params->session_mpool, ts_params->session_priv_mpool,
2220 		ts_params->valid_devs[0],
2221 		rte_cryptodev_driver_id_get(
2222 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2223 		BLKCIPHER_AES_CHAIN_TYPE);
2224 
2225 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2226 
2227 	return TEST_SUCCESS;
2228 }
2229 
2230 static int
2231 test_AES_cipheronly_mrvl_all(void)
2232 {
2233 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2234 	int status;
2235 
2236 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2237 		ts_params->op_mpool,
2238 		ts_params->session_mpool, ts_params->session_priv_mpool,
2239 		ts_params->valid_devs[0],
2240 		rte_cryptodev_driver_id_get(
2241 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2242 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2243 
2244 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2245 
2246 	return TEST_SUCCESS;
2247 }
2248 
2249 static int
2250 test_authonly_mrvl_all(void)
2251 {
2252 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2253 	int status;
2254 
2255 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2256 		ts_params->op_mpool,
2257 		ts_params->session_mpool, ts_params->session_priv_mpool,
2258 		ts_params->valid_devs[0],
2259 		rte_cryptodev_driver_id_get(
2260 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2261 		BLKCIPHER_AUTHONLY_TYPE);
2262 
2263 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2264 
2265 	return TEST_SUCCESS;
2266 }
2267 
2268 static int
2269 test_3DES_chain_mrvl_all(void)
2270 {
2271 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2272 	int status;
2273 
2274 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2275 		ts_params->op_mpool,
2276 		ts_params->session_mpool, ts_params->session_priv_mpool,
2277 		ts_params->valid_devs[0],
2278 		rte_cryptodev_driver_id_get(
2279 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2280 		BLKCIPHER_3DES_CHAIN_TYPE);
2281 
2282 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2283 
2284 	return TEST_SUCCESS;
2285 }
2286 
2287 static int
2288 test_3DES_cipheronly_mrvl_all(void)
2289 {
2290 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2291 	int status;
2292 
2293 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2294 		ts_params->op_mpool,
2295 		ts_params->session_mpool, ts_params->session_priv_mpool,
2296 		ts_params->valid_devs[0],
2297 		rte_cryptodev_driver_id_get(
2298 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2299 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2300 
2301 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2302 
2303 	return TEST_SUCCESS;
2304 }
2305 
2306 static int
2307 test_AES_chain_octeontx_all(void)
2308 {
2309 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2310 	int status;
2311 
2312 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2313 		ts_params->op_mpool, ts_params->session_mpool,
2314 		ts_params->session_priv_mpool,
2315 		ts_params->valid_devs[0],
2316 		rte_cryptodev_driver_id_get(
2317 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2318 		BLKCIPHER_AES_CHAIN_TYPE);
2319 
2320 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2321 
2322 	return TEST_SUCCESS;
2323 }
2324 
2325 static int
2326 test_AES_cipheronly_octeontx_all(void)
2327 {
2328 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2329 	int status;
2330 
2331 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2332 		ts_params->op_mpool, ts_params->session_mpool,
2333 		ts_params->session_priv_mpool,
2334 		ts_params->valid_devs[0],
2335 		rte_cryptodev_driver_id_get(
2336 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2337 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2338 
2339 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2340 
2341 	return TEST_SUCCESS;
2342 }
2343 
2344 static int
2345 test_3DES_chain_octeontx_all(void)
2346 {
2347 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2348 	int status;
2349 
2350 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2351 		ts_params->op_mpool, ts_params->session_mpool,
2352 		ts_params->session_priv_mpool,
2353 		ts_params->valid_devs[0],
2354 		rte_cryptodev_driver_id_get(
2355 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2356 		BLKCIPHER_3DES_CHAIN_TYPE);
2357 
2358 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2359 
2360 	return TEST_SUCCESS;
2361 }
2362 
2363 static int
2364 test_AES_chain_nitrox_all(void)
2365 {
2366 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2367 	int status;
2368 
2369 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2370 		ts_params->op_mpool,
2371 		ts_params->session_mpool, ts_params->session_priv_mpool,
2372 		ts_params->valid_devs[0],
2373 		rte_cryptodev_driver_id_get(
2374 		RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2375 		BLKCIPHER_AES_CHAIN_TYPE);
2376 
2377 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2378 
2379 	return TEST_SUCCESS;
2380 }
2381 
2382 static int
2383 test_3DES_cipheronly_octeontx_all(void)
2384 {
2385 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2386 	int status;
2387 
2388 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2389 		ts_params->op_mpool, ts_params->session_mpool,
2390 		ts_params->session_priv_mpool,
2391 		ts_params->valid_devs[0],
2392 		rte_cryptodev_driver_id_get(
2393 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2394 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2395 
2396 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2397 
2398 	return TEST_SUCCESS;
2399 }
2400 
2401 static int
2402 test_authonly_octeontx_all(void)
2403 {
2404 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2405 	int status;
2406 
2407 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2408 		ts_params->op_mpool, ts_params->session_mpool,
2409 		ts_params->session_priv_mpool,
2410 		ts_params->valid_devs[0],
2411 		rte_cryptodev_driver_id_get(
2412 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2413 		BLKCIPHER_AUTHONLY_TYPE);
2414 
2415 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2416 
2417 	return TEST_SUCCESS;
2418 }
2419 
2420 static int
2421 test_AES_chain_octeontx2_all(void)
2422 {
2423 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2424 	int status;
2425 
2426 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2427 		ts_params->op_mpool, ts_params->session_mpool,
2428 		ts_params->session_priv_mpool,
2429 		ts_params->valid_devs[0],
2430 		rte_cryptodev_driver_id_get(
2431 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2432 		BLKCIPHER_AES_CHAIN_TYPE);
2433 
2434 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2435 
2436 	return TEST_SUCCESS;
2437 }
2438 
2439 static int
2440 test_AES_cipheronly_octeontx2_all(void)
2441 {
2442 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2443 	int status;
2444 
2445 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2446 		ts_params->op_mpool, ts_params->session_mpool,
2447 		ts_params->session_priv_mpool,
2448 		ts_params->valid_devs[0],
2449 		rte_cryptodev_driver_id_get(
2450 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2451 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2452 
2453 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2454 
2455 	return TEST_SUCCESS;
2456 }
2457 
2458 static int
2459 test_3DES_chain_octeontx2_all(void)
2460 {
2461 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2462 	int status;
2463 
2464 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2465 		ts_params->op_mpool, ts_params->session_mpool,
2466 		ts_params->session_priv_mpool,
2467 		ts_params->valid_devs[0],
2468 		rte_cryptodev_driver_id_get(
2469 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2470 		BLKCIPHER_3DES_CHAIN_TYPE);
2471 
2472 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2473 
2474 	return TEST_SUCCESS;
2475 }
2476 
2477 static int
2478 test_3DES_cipheronly_octeontx2_all(void)
2479 {
2480 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2481 	int status;
2482 
2483 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2484 		ts_params->op_mpool, ts_params->session_mpool,
2485 		ts_params->session_priv_mpool,
2486 		ts_params->valid_devs[0],
2487 		rte_cryptodev_driver_id_get(
2488 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2489 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2490 
2491 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2492 
2493 	return TEST_SUCCESS;
2494 }
2495 
2496 static int
2497 test_authonly_octeontx2_all(void)
2498 {
2499 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2500 	int status;
2501 
2502 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2503 		ts_params->op_mpool, ts_params->session_mpool,
2504 		ts_params->session_priv_mpool,
2505 		ts_params->valid_devs[0],
2506 		rte_cryptodev_driver_id_get(
2507 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2508 		BLKCIPHER_AUTHONLY_TYPE);
2509 
2510 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2511 
2512 	return TEST_SUCCESS;
2513 }
2514 
2515 /* ***** SNOW 3G Tests ***** */
2516 static int
2517 create_wireless_algo_hash_session(uint8_t dev_id,
2518 	const uint8_t *key, const uint8_t key_len,
2519 	const uint8_t iv_len, const uint8_t auth_len,
2520 	enum rte_crypto_auth_operation op,
2521 	enum rte_crypto_auth_algorithm algo)
2522 {
2523 	uint8_t hash_key[key_len];
2524 	int status;
2525 
2526 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2527 	struct crypto_unittest_params *ut_params = &unittest_params;
2528 
2529 	memcpy(hash_key, key, key_len);
2530 
2531 	debug_hexdump(stdout, "key:", key, key_len);
2532 
2533 	/* Setup Authentication Parameters */
2534 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2535 	ut_params->auth_xform.next = NULL;
2536 
2537 	ut_params->auth_xform.auth.op = op;
2538 	ut_params->auth_xform.auth.algo = algo;
2539 	ut_params->auth_xform.auth.key.length = key_len;
2540 	ut_params->auth_xform.auth.key.data = hash_key;
2541 	ut_params->auth_xform.auth.digest_length = auth_len;
2542 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2543 	ut_params->auth_xform.auth.iv.length = iv_len;
2544 	ut_params->sess = rte_cryptodev_sym_session_create(
2545 			ts_params->session_mpool);
2546 
2547 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2548 			&ut_params->auth_xform,
2549 			ts_params->session_priv_mpool);
2550 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2551 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2552 	return 0;
2553 }
2554 
2555 static int
2556 create_wireless_algo_cipher_session(uint8_t dev_id,
2557 			enum rte_crypto_cipher_operation op,
2558 			enum rte_crypto_cipher_algorithm algo,
2559 			const uint8_t *key, const uint8_t key_len,
2560 			uint8_t iv_len)
2561 {
2562 	uint8_t cipher_key[key_len];
2563 	int status;
2564 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2565 	struct crypto_unittest_params *ut_params = &unittest_params;
2566 
2567 	memcpy(cipher_key, key, key_len);
2568 
2569 	/* Setup Cipher Parameters */
2570 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2571 	ut_params->cipher_xform.next = NULL;
2572 
2573 	ut_params->cipher_xform.cipher.algo = algo;
2574 	ut_params->cipher_xform.cipher.op = op;
2575 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2576 	ut_params->cipher_xform.cipher.key.length = key_len;
2577 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2578 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2579 
2580 	debug_hexdump(stdout, "key:", key, key_len);
2581 
2582 	/* Create Crypto session */
2583 	ut_params->sess = rte_cryptodev_sym_session_create(
2584 			ts_params->session_mpool);
2585 
2586 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2587 			&ut_params->cipher_xform,
2588 			ts_params->session_priv_mpool);
2589 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2590 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2591 	return 0;
2592 }
2593 
2594 static int
2595 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2596 			unsigned int cipher_len,
2597 			unsigned int cipher_offset)
2598 {
2599 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2600 	struct crypto_unittest_params *ut_params = &unittest_params;
2601 
2602 	/* Generate Crypto op data structure */
2603 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2604 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2605 	TEST_ASSERT_NOT_NULL(ut_params->op,
2606 				"Failed to allocate pktmbuf offload");
2607 
2608 	/* Set crypto operation data parameters */
2609 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2610 
2611 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2612 
2613 	/* set crypto operation source mbuf */
2614 	sym_op->m_src = ut_params->ibuf;
2615 
2616 	/* iv */
2617 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2618 			iv, iv_len);
2619 	sym_op->cipher.data.length = cipher_len;
2620 	sym_op->cipher.data.offset = cipher_offset;
2621 	return 0;
2622 }
2623 
2624 static int
2625 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2626 			unsigned int cipher_len,
2627 			unsigned int cipher_offset)
2628 {
2629 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2630 	struct crypto_unittest_params *ut_params = &unittest_params;
2631 
2632 	/* Generate Crypto op data structure */
2633 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2634 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2635 	TEST_ASSERT_NOT_NULL(ut_params->op,
2636 				"Failed to allocate pktmbuf offload");
2637 
2638 	/* Set crypto operation data parameters */
2639 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2640 
2641 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2642 
2643 	/* set crypto operation source mbuf */
2644 	sym_op->m_src = ut_params->ibuf;
2645 	sym_op->m_dst = ut_params->obuf;
2646 
2647 	/* iv */
2648 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2649 			iv, iv_len);
2650 	sym_op->cipher.data.length = cipher_len;
2651 	sym_op->cipher.data.offset = cipher_offset;
2652 	return 0;
2653 }
2654 
2655 static int
2656 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2657 		enum rte_crypto_cipher_operation cipher_op,
2658 		enum rte_crypto_auth_operation auth_op,
2659 		enum rte_crypto_auth_algorithm auth_algo,
2660 		enum rte_crypto_cipher_algorithm cipher_algo,
2661 		const uint8_t *key, uint8_t key_len,
2662 		uint8_t auth_iv_len, uint8_t auth_len,
2663 		uint8_t cipher_iv_len)
2664 
2665 {
2666 	uint8_t cipher_auth_key[key_len];
2667 	int status;
2668 
2669 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2670 	struct crypto_unittest_params *ut_params = &unittest_params;
2671 
2672 	memcpy(cipher_auth_key, key, key_len);
2673 
2674 	/* Setup Authentication Parameters */
2675 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2676 	ut_params->auth_xform.next = NULL;
2677 
2678 	ut_params->auth_xform.auth.op = auth_op;
2679 	ut_params->auth_xform.auth.algo = auth_algo;
2680 	ut_params->auth_xform.auth.key.length = key_len;
2681 	/* Hash key = cipher key */
2682 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2683 	ut_params->auth_xform.auth.digest_length = auth_len;
2684 	/* Auth IV will be after cipher IV */
2685 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2686 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2687 
2688 	/* Setup Cipher Parameters */
2689 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2690 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2691 
2692 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2693 	ut_params->cipher_xform.cipher.op = cipher_op;
2694 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2695 	ut_params->cipher_xform.cipher.key.length = key_len;
2696 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2697 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2698 
2699 	debug_hexdump(stdout, "key:", key, key_len);
2700 
2701 	/* Create Crypto session*/
2702 	ut_params->sess = rte_cryptodev_sym_session_create(
2703 			ts_params->session_mpool);
2704 
2705 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2706 			&ut_params->cipher_xform,
2707 			ts_params->session_priv_mpool);
2708 
2709 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2710 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2711 	return 0;
2712 }
2713 
2714 static int
2715 create_wireless_cipher_auth_session(uint8_t dev_id,
2716 		enum rte_crypto_cipher_operation cipher_op,
2717 		enum rte_crypto_auth_operation auth_op,
2718 		enum rte_crypto_auth_algorithm auth_algo,
2719 		enum rte_crypto_cipher_algorithm cipher_algo,
2720 		const struct wireless_test_data *tdata)
2721 {
2722 	const uint8_t key_len = tdata->key.len;
2723 	uint8_t cipher_auth_key[key_len];
2724 	int status;
2725 
2726 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2727 	struct crypto_unittest_params *ut_params = &unittest_params;
2728 	const uint8_t *key = tdata->key.data;
2729 	const uint8_t auth_len = tdata->digest.len;
2730 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2731 	uint8_t auth_iv_len = tdata->auth_iv.len;
2732 
2733 	memcpy(cipher_auth_key, key, key_len);
2734 
2735 	/* Setup Authentication Parameters */
2736 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2737 	ut_params->auth_xform.next = NULL;
2738 
2739 	ut_params->auth_xform.auth.op = auth_op;
2740 	ut_params->auth_xform.auth.algo = auth_algo;
2741 	ut_params->auth_xform.auth.key.length = key_len;
2742 	/* Hash key = cipher key */
2743 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2744 	ut_params->auth_xform.auth.digest_length = auth_len;
2745 	/* Auth IV will be after cipher IV */
2746 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2747 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2748 
2749 	/* Setup Cipher Parameters */
2750 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2751 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2752 
2753 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2754 	ut_params->cipher_xform.cipher.op = cipher_op;
2755 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2756 	ut_params->cipher_xform.cipher.key.length = key_len;
2757 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2758 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2759 
2760 
2761 	debug_hexdump(stdout, "key:", key, key_len);
2762 
2763 	/* Create Crypto session*/
2764 	ut_params->sess = rte_cryptodev_sym_session_create(
2765 			ts_params->session_mpool);
2766 
2767 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2768 			&ut_params->cipher_xform,
2769 			ts_params->session_priv_mpool);
2770 
2771 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2772 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2773 	return 0;
2774 }
2775 
2776 static int
2777 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2778 		const struct wireless_test_data *tdata)
2779 {
2780 	return create_wireless_cipher_auth_session(dev_id,
2781 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2782 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2783 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2784 }
2785 
2786 static int
2787 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2788 		enum rte_crypto_cipher_operation cipher_op,
2789 		enum rte_crypto_auth_operation auth_op,
2790 		enum rte_crypto_auth_algorithm auth_algo,
2791 		enum rte_crypto_cipher_algorithm cipher_algo,
2792 		const uint8_t *key, const uint8_t key_len,
2793 		uint8_t auth_iv_len, uint8_t auth_len,
2794 		uint8_t cipher_iv_len)
2795 {
2796 	uint8_t auth_cipher_key[key_len];
2797 	int status;
2798 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2799 	struct crypto_unittest_params *ut_params = &unittest_params;
2800 
2801 	memcpy(auth_cipher_key, key, key_len);
2802 
2803 	/* Setup Authentication Parameters */
2804 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2805 	ut_params->auth_xform.auth.op = auth_op;
2806 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2807 	ut_params->auth_xform.auth.algo = auth_algo;
2808 	ut_params->auth_xform.auth.key.length = key_len;
2809 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
2810 	ut_params->auth_xform.auth.digest_length = auth_len;
2811 	/* Auth IV will be after cipher IV */
2812 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2813 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2814 
2815 	/* Setup Cipher Parameters */
2816 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2817 	ut_params->cipher_xform.next = NULL;
2818 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2819 	ut_params->cipher_xform.cipher.op = cipher_op;
2820 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2821 	ut_params->cipher_xform.cipher.key.length = key_len;
2822 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2823 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2824 
2825 	debug_hexdump(stdout, "key:", key, key_len);
2826 
2827 	/* Create Crypto session*/
2828 	ut_params->sess = rte_cryptodev_sym_session_create(
2829 			ts_params->session_mpool);
2830 
2831 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2832 		ut_params->auth_xform.next = NULL;
2833 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2834 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2835 				&ut_params->cipher_xform,
2836 				ts_params->session_priv_mpool);
2837 
2838 	} else
2839 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2840 				&ut_params->auth_xform,
2841 				ts_params->session_priv_mpool);
2842 
2843 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2844 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2845 
2846 	return 0;
2847 }
2848 
2849 static int
2850 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2851 		unsigned int auth_tag_len,
2852 		const uint8_t *iv, unsigned int iv_len,
2853 		unsigned int data_pad_len,
2854 		enum rte_crypto_auth_operation op,
2855 		unsigned int auth_len, unsigned int auth_offset)
2856 {
2857 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2858 
2859 	struct crypto_unittest_params *ut_params = &unittest_params;
2860 
2861 	/* Generate Crypto op data structure */
2862 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2863 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2864 	TEST_ASSERT_NOT_NULL(ut_params->op,
2865 		"Failed to allocate pktmbuf offload");
2866 
2867 	/* Set crypto operation data parameters */
2868 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2869 
2870 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2871 
2872 	/* set crypto operation source mbuf */
2873 	sym_op->m_src = ut_params->ibuf;
2874 
2875 	/* iv */
2876 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2877 			iv, iv_len);
2878 	/* digest */
2879 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2880 					ut_params->ibuf, auth_tag_len);
2881 
2882 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2883 				"no room to append auth tag");
2884 	ut_params->digest = sym_op->auth.digest.data;
2885 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2886 			ut_params->ibuf, data_pad_len);
2887 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2888 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2889 	else
2890 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2891 
2892 	debug_hexdump(stdout, "digest:",
2893 		sym_op->auth.digest.data,
2894 		auth_tag_len);
2895 
2896 	sym_op->auth.data.length = auth_len;
2897 	sym_op->auth.data.offset = auth_offset;
2898 
2899 	return 0;
2900 }
2901 
2902 static int
2903 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2904 	enum rte_crypto_auth_operation op)
2905 {
2906 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2907 	struct crypto_unittest_params *ut_params = &unittest_params;
2908 
2909 	const uint8_t *auth_tag = tdata->digest.data;
2910 	const unsigned int auth_tag_len = tdata->digest.len;
2911 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2912 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2913 
2914 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2915 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2916 	const uint8_t *auth_iv = tdata->auth_iv.data;
2917 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2918 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2919 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2920 
2921 	/* Generate Crypto op data structure */
2922 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2923 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2924 	TEST_ASSERT_NOT_NULL(ut_params->op,
2925 			"Failed to allocate pktmbuf offload");
2926 	/* Set crypto operation data parameters */
2927 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2928 
2929 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2930 
2931 	/* set crypto operation source mbuf */
2932 	sym_op->m_src = ut_params->ibuf;
2933 
2934 	/* digest */
2935 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2936 			ut_params->ibuf, auth_tag_len);
2937 
2938 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2939 			"no room to append auth tag");
2940 	ut_params->digest = sym_op->auth.digest.data;
2941 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2942 			ut_params->ibuf, data_pad_len);
2943 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2944 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2945 	else
2946 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2947 
2948 	debug_hexdump(stdout, "digest:",
2949 		sym_op->auth.digest.data,
2950 		auth_tag_len);
2951 
2952 	/* Copy cipher and auth IVs at the end of the crypto operation */
2953 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2954 						IV_OFFSET);
2955 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2956 	iv_ptr += cipher_iv_len;
2957 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2958 
2959 	sym_op->cipher.data.length = cipher_len;
2960 	sym_op->cipher.data.offset = 0;
2961 	sym_op->auth.data.length = auth_len;
2962 	sym_op->auth.data.offset = 0;
2963 
2964 	return 0;
2965 }
2966 
2967 static int
2968 create_zuc_cipher_hash_generate_operation(
2969 		const struct wireless_test_data *tdata)
2970 {
2971 	return create_wireless_cipher_hash_operation(tdata,
2972 		RTE_CRYPTO_AUTH_OP_GENERATE);
2973 }
2974 
2975 static int
2976 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2977 		const unsigned auth_tag_len,
2978 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2979 		unsigned data_pad_len,
2980 		enum rte_crypto_auth_operation op,
2981 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2982 		const unsigned cipher_len, const unsigned cipher_offset,
2983 		const unsigned auth_len, const unsigned auth_offset)
2984 {
2985 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2986 	struct crypto_unittest_params *ut_params = &unittest_params;
2987 
2988 	/* Generate Crypto op data structure */
2989 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2990 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2991 	TEST_ASSERT_NOT_NULL(ut_params->op,
2992 			"Failed to allocate pktmbuf offload");
2993 	/* Set crypto operation data parameters */
2994 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2995 
2996 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2997 
2998 	/* set crypto operation source mbuf */
2999 	sym_op->m_src = ut_params->ibuf;
3000 
3001 	/* digest */
3002 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3003 			ut_params->ibuf, auth_tag_len);
3004 
3005 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3006 			"no room to append auth tag");
3007 	ut_params->digest = sym_op->auth.digest.data;
3008 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3009 			ut_params->ibuf, data_pad_len);
3010 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3011 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3012 	else
3013 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3014 
3015 	debug_hexdump(stdout, "digest:",
3016 		sym_op->auth.digest.data,
3017 		auth_tag_len);
3018 
3019 	/* Copy cipher and auth IVs at the end of the crypto operation */
3020 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3021 						IV_OFFSET);
3022 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3023 	iv_ptr += cipher_iv_len;
3024 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3025 
3026 	sym_op->cipher.data.length = cipher_len;
3027 	sym_op->cipher.data.offset = cipher_offset;
3028 	sym_op->auth.data.length = auth_len;
3029 	sym_op->auth.data.offset = auth_offset;
3030 
3031 	return 0;
3032 }
3033 
3034 static int
3035 create_wireless_algo_auth_cipher_operation(
3036 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3037 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3038 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3039 		unsigned int data_pad_len,
3040 		unsigned int cipher_len, unsigned int cipher_offset,
3041 		unsigned int auth_len, unsigned int auth_offset,
3042 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3043 {
3044 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3045 	struct crypto_unittest_params *ut_params = &unittest_params;
3046 
3047 	enum rte_crypto_cipher_algorithm cipher_algo =
3048 			ut_params->cipher_xform.cipher.algo;
3049 	enum rte_crypto_auth_algorithm auth_algo =
3050 			ut_params->auth_xform.auth.algo;
3051 
3052 	/* Generate Crypto op data structure */
3053 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3054 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3055 	TEST_ASSERT_NOT_NULL(ut_params->op,
3056 			"Failed to allocate pktmbuf offload");
3057 
3058 	/* Set crypto operation data parameters */
3059 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3060 
3061 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3062 
3063 	/* set crypto operation mbufs */
3064 	sym_op->m_src = ut_params->ibuf;
3065 	if (op_mode == OUT_OF_PLACE)
3066 		sym_op->m_dst = ut_params->obuf;
3067 
3068 	/* digest */
3069 	if (!do_sgl) {
3070 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3071 			(op_mode == IN_PLACE ?
3072 				ut_params->ibuf : ut_params->obuf),
3073 			uint8_t *, data_pad_len);
3074 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3075 			(op_mode == IN_PLACE ?
3076 				ut_params->ibuf : ut_params->obuf),
3077 			data_pad_len);
3078 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3079 	} else {
3080 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3081 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3082 				sym_op->m_src : sym_op->m_dst);
3083 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3084 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3085 			sgl_buf = sgl_buf->next;
3086 		}
3087 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3088 				uint8_t *, remaining_off);
3089 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3090 				remaining_off);
3091 		memset(sym_op->auth.digest.data, 0, remaining_off);
3092 		while (sgl_buf->next != NULL) {
3093 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3094 				0, rte_pktmbuf_data_len(sgl_buf));
3095 			sgl_buf = sgl_buf->next;
3096 		}
3097 	}
3098 
3099 	/* Copy digest for the verification */
3100 	if (verify)
3101 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3102 
3103 	/* Copy cipher and auth IVs at the end of the crypto operation */
3104 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3105 			ut_params->op, uint8_t *, IV_OFFSET);
3106 
3107 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3108 	iv_ptr += cipher_iv_len;
3109 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3110 
3111 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3112 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3113 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3114 		sym_op->cipher.data.length = cipher_len;
3115 		sym_op->cipher.data.offset = cipher_offset;
3116 	} else {
3117 		sym_op->cipher.data.length = cipher_len >> 3;
3118 		sym_op->cipher.data.offset = cipher_offset >> 3;
3119 	}
3120 
3121 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3122 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3123 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3124 		sym_op->auth.data.length = auth_len;
3125 		sym_op->auth.data.offset = auth_offset;
3126 	} else {
3127 		sym_op->auth.data.length = auth_len >> 3;
3128 		sym_op->auth.data.offset = auth_offset >> 3;
3129 	}
3130 
3131 	return 0;
3132 }
3133 
3134 static int
3135 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3136 {
3137 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3138 	struct crypto_unittest_params *ut_params = &unittest_params;
3139 
3140 	int retval;
3141 	unsigned plaintext_pad_len;
3142 	unsigned plaintext_len;
3143 	uint8_t *plaintext;
3144 
3145 	/* Create SNOW 3G session */
3146 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3147 			tdata->key.data, tdata->key.len,
3148 			tdata->auth_iv.len, tdata->digest.len,
3149 			RTE_CRYPTO_AUTH_OP_GENERATE,
3150 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3151 	if (retval < 0)
3152 		return retval;
3153 
3154 	/* alloc mbuf and set payload */
3155 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3156 
3157 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3158 	rte_pktmbuf_tailroom(ut_params->ibuf));
3159 
3160 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3161 	/* Append data which is padded to a multiple of */
3162 	/* the algorithms block size */
3163 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3164 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3165 				plaintext_pad_len);
3166 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3167 
3168 	/* Create SNOW 3G operation */
3169 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3170 			tdata->auth_iv.data, tdata->auth_iv.len,
3171 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3172 			tdata->validAuthLenInBits.len,
3173 			0);
3174 	if (retval < 0)
3175 		return retval;
3176 
3177 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3178 				ut_params->op);
3179 	ut_params->obuf = ut_params->op->sym->m_src;
3180 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3181 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3182 			+ plaintext_pad_len;
3183 
3184 	/* Validate obuf */
3185 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3186 	ut_params->digest,
3187 	tdata->digest.data,
3188 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3189 	"SNOW 3G Generated auth tag not as expected");
3190 
3191 	return 0;
3192 }
3193 
3194 static int
3195 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3196 {
3197 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3198 	struct crypto_unittest_params *ut_params = &unittest_params;
3199 
3200 	int retval;
3201 	unsigned plaintext_pad_len;
3202 	unsigned plaintext_len;
3203 	uint8_t *plaintext;
3204 
3205 	/* Create SNOW 3G session */
3206 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3207 				tdata->key.data, tdata->key.len,
3208 				tdata->auth_iv.len, tdata->digest.len,
3209 				RTE_CRYPTO_AUTH_OP_VERIFY,
3210 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3211 	if (retval < 0)
3212 		return retval;
3213 	/* alloc mbuf and set payload */
3214 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3215 
3216 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3217 	rte_pktmbuf_tailroom(ut_params->ibuf));
3218 
3219 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3220 	/* Append data which is padded to a multiple of */
3221 	/* the algorithms block size */
3222 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3223 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3224 				plaintext_pad_len);
3225 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3226 
3227 	/* Create SNOW 3G operation */
3228 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3229 			tdata->digest.len,
3230 			tdata->auth_iv.data, tdata->auth_iv.len,
3231 			plaintext_pad_len,
3232 			RTE_CRYPTO_AUTH_OP_VERIFY,
3233 			tdata->validAuthLenInBits.len,
3234 			0);
3235 	if (retval < 0)
3236 		return retval;
3237 
3238 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3239 				ut_params->op);
3240 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3241 	ut_params->obuf = ut_params->op->sym->m_src;
3242 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3243 				+ plaintext_pad_len;
3244 
3245 	/* Validate obuf */
3246 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3247 		return 0;
3248 	else
3249 		return -1;
3250 
3251 	return 0;
3252 }
3253 
3254 static int
3255 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3256 {
3257 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3258 	struct crypto_unittest_params *ut_params = &unittest_params;
3259 
3260 	int retval;
3261 	unsigned plaintext_pad_len;
3262 	unsigned plaintext_len;
3263 	uint8_t *plaintext;
3264 
3265 	/* Create KASUMI session */
3266 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3267 			tdata->key.data, tdata->key.len,
3268 			0, tdata->digest.len,
3269 			RTE_CRYPTO_AUTH_OP_GENERATE,
3270 			RTE_CRYPTO_AUTH_KASUMI_F9);
3271 	if (retval < 0)
3272 		return retval;
3273 
3274 	/* alloc mbuf and set payload */
3275 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3276 
3277 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3278 	rte_pktmbuf_tailroom(ut_params->ibuf));
3279 
3280 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3281 	/* Append data which is padded to a multiple of */
3282 	/* the algorithms block size */
3283 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3284 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3285 				plaintext_pad_len);
3286 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3287 
3288 	/* Create KASUMI operation */
3289 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3290 			NULL, 0,
3291 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3292 			tdata->plaintext.len,
3293 			0);
3294 	if (retval < 0)
3295 		return retval;
3296 
3297 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3298 				ut_params->op);
3299 	ut_params->obuf = ut_params->op->sym->m_src;
3300 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3301 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3302 			+ plaintext_pad_len;
3303 
3304 	/* Validate obuf */
3305 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3306 	ut_params->digest,
3307 	tdata->digest.data,
3308 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3309 	"KASUMI Generated auth tag not as expected");
3310 
3311 	return 0;
3312 }
3313 
3314 static int
3315 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3316 {
3317 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3318 	struct crypto_unittest_params *ut_params = &unittest_params;
3319 
3320 	int retval;
3321 	unsigned plaintext_pad_len;
3322 	unsigned plaintext_len;
3323 	uint8_t *plaintext;
3324 
3325 	/* Create KASUMI session */
3326 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3327 				tdata->key.data, tdata->key.len,
3328 				0, tdata->digest.len,
3329 				RTE_CRYPTO_AUTH_OP_VERIFY,
3330 				RTE_CRYPTO_AUTH_KASUMI_F9);
3331 	if (retval < 0)
3332 		return retval;
3333 	/* alloc mbuf and set payload */
3334 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3335 
3336 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3337 	rte_pktmbuf_tailroom(ut_params->ibuf));
3338 
3339 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3340 	/* Append data which is padded to a multiple */
3341 	/* of the algorithms block size */
3342 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3343 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3344 				plaintext_pad_len);
3345 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3346 
3347 	/* Create KASUMI operation */
3348 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3349 			tdata->digest.len,
3350 			NULL, 0,
3351 			plaintext_pad_len,
3352 			RTE_CRYPTO_AUTH_OP_VERIFY,
3353 			tdata->plaintext.len,
3354 			0);
3355 	if (retval < 0)
3356 		return retval;
3357 
3358 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3359 				ut_params->op);
3360 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3361 	ut_params->obuf = ut_params->op->sym->m_src;
3362 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3363 				+ plaintext_pad_len;
3364 
3365 	/* Validate obuf */
3366 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3367 		return 0;
3368 	else
3369 		return -1;
3370 
3371 	return 0;
3372 }
3373 
3374 static int
3375 test_snow3g_hash_generate_test_case_1(void)
3376 {
3377 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3378 }
3379 
3380 static int
3381 test_snow3g_hash_generate_test_case_2(void)
3382 {
3383 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3384 }
3385 
3386 static int
3387 test_snow3g_hash_generate_test_case_3(void)
3388 {
3389 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3390 }
3391 
3392 static int
3393 test_snow3g_hash_generate_test_case_4(void)
3394 {
3395 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3396 }
3397 
3398 static int
3399 test_snow3g_hash_generate_test_case_5(void)
3400 {
3401 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3402 }
3403 
3404 static int
3405 test_snow3g_hash_generate_test_case_6(void)
3406 {
3407 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3408 }
3409 
3410 static int
3411 test_snow3g_hash_verify_test_case_1(void)
3412 {
3413 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3414 
3415 }
3416 
3417 static int
3418 test_snow3g_hash_verify_test_case_2(void)
3419 {
3420 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3421 }
3422 
3423 static int
3424 test_snow3g_hash_verify_test_case_3(void)
3425 {
3426 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3427 }
3428 
3429 static int
3430 test_snow3g_hash_verify_test_case_4(void)
3431 {
3432 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3433 }
3434 
3435 static int
3436 test_snow3g_hash_verify_test_case_5(void)
3437 {
3438 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3439 }
3440 
3441 static int
3442 test_snow3g_hash_verify_test_case_6(void)
3443 {
3444 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3445 }
3446 
3447 static int
3448 test_kasumi_hash_generate_test_case_1(void)
3449 {
3450 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3451 }
3452 
3453 static int
3454 test_kasumi_hash_generate_test_case_2(void)
3455 {
3456 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3457 }
3458 
3459 static int
3460 test_kasumi_hash_generate_test_case_3(void)
3461 {
3462 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3463 }
3464 
3465 static int
3466 test_kasumi_hash_generate_test_case_4(void)
3467 {
3468 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3469 }
3470 
3471 static int
3472 test_kasumi_hash_generate_test_case_5(void)
3473 {
3474 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3475 }
3476 
3477 static int
3478 test_kasumi_hash_generate_test_case_6(void)
3479 {
3480 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3481 }
3482 
3483 static int
3484 test_kasumi_hash_verify_test_case_1(void)
3485 {
3486 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3487 }
3488 
3489 static int
3490 test_kasumi_hash_verify_test_case_2(void)
3491 {
3492 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3493 }
3494 
3495 static int
3496 test_kasumi_hash_verify_test_case_3(void)
3497 {
3498 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3499 }
3500 
3501 static int
3502 test_kasumi_hash_verify_test_case_4(void)
3503 {
3504 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3505 }
3506 
3507 static int
3508 test_kasumi_hash_verify_test_case_5(void)
3509 {
3510 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3511 }
3512 
3513 static int
3514 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3515 {
3516 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3517 	struct crypto_unittest_params *ut_params = &unittest_params;
3518 
3519 	int retval;
3520 	uint8_t *plaintext, *ciphertext;
3521 	unsigned plaintext_pad_len;
3522 	unsigned plaintext_len;
3523 
3524 	/* Create KASUMI session */
3525 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3526 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3527 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3528 					tdata->key.data, tdata->key.len,
3529 					tdata->cipher_iv.len);
3530 	if (retval < 0)
3531 		return retval;
3532 
3533 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3534 
3535 	/* Clear mbuf payload */
3536 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3537 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3538 
3539 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3540 	/* Append data which is padded to a multiple */
3541 	/* of the algorithms block size */
3542 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3543 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3544 				plaintext_pad_len);
3545 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3546 
3547 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3548 
3549 	/* Create KASUMI operation */
3550 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3551 				tdata->cipher_iv.len,
3552 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3553 				tdata->validCipherOffsetInBits.len);
3554 	if (retval < 0)
3555 		return retval;
3556 
3557 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3558 						ut_params->op);
3559 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3560 
3561 	ut_params->obuf = ut_params->op->sym->m_dst;
3562 	if (ut_params->obuf)
3563 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3564 	else
3565 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3566 
3567 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3568 
3569 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3570 				(tdata->validCipherOffsetInBits.len >> 3);
3571 	/* Validate obuf */
3572 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3573 		ciphertext,
3574 		reference_ciphertext,
3575 		tdata->validCipherLenInBits.len,
3576 		"KASUMI Ciphertext data not as expected");
3577 	return 0;
3578 }
3579 
3580 static int
3581 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3582 {
3583 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3584 	struct crypto_unittest_params *ut_params = &unittest_params;
3585 
3586 	int retval;
3587 
3588 	unsigned int plaintext_pad_len;
3589 	unsigned int plaintext_len;
3590 
3591 	uint8_t buffer[10000];
3592 	const uint8_t *ciphertext;
3593 
3594 	struct rte_cryptodev_info dev_info;
3595 
3596 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3597 
3598 	uint64_t feat_flags = dev_info.feature_flags;
3599 
3600 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3601 		printf("Device doesn't support in-place scatter-gather. "
3602 				"Test Skipped.\n");
3603 		return -ENOTSUP;
3604 	}
3605 
3606 	/* Create KASUMI session */
3607 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3608 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3609 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3610 					tdata->key.data, tdata->key.len,
3611 					tdata->cipher_iv.len);
3612 	if (retval < 0)
3613 		return retval;
3614 
3615 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3616 
3617 
3618 	/* Append data which is padded to a multiple */
3619 	/* of the algorithms block size */
3620 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3621 
3622 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3623 			plaintext_pad_len, 10, 0);
3624 
3625 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3626 
3627 	/* Create KASUMI operation */
3628 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3629 				tdata->cipher_iv.len,
3630 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3631 				tdata->validCipherOffsetInBits.len);
3632 	if (retval < 0)
3633 		return retval;
3634 
3635 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3636 						ut_params->op);
3637 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3638 
3639 	ut_params->obuf = ut_params->op->sym->m_dst;
3640 
3641 	if (ut_params->obuf)
3642 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3643 				plaintext_len, buffer);
3644 	else
3645 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3646 				tdata->validCipherOffsetInBits.len >> 3,
3647 				plaintext_len, buffer);
3648 
3649 	/* Validate obuf */
3650 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3651 
3652 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3653 				(tdata->validCipherOffsetInBits.len >> 3);
3654 	/* Validate obuf */
3655 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3656 		ciphertext,
3657 		reference_ciphertext,
3658 		tdata->validCipherLenInBits.len,
3659 		"KASUMI Ciphertext data not as expected");
3660 	return 0;
3661 }
3662 
3663 static int
3664 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3665 {
3666 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3667 	struct crypto_unittest_params *ut_params = &unittest_params;
3668 
3669 	int retval;
3670 	uint8_t *plaintext, *ciphertext;
3671 	unsigned plaintext_pad_len;
3672 	unsigned plaintext_len;
3673 
3674 	/* Create KASUMI session */
3675 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3676 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3677 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3678 					tdata->key.data, tdata->key.len,
3679 					tdata->cipher_iv.len);
3680 	if (retval < 0)
3681 		return retval;
3682 
3683 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3684 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3685 
3686 	/* Clear mbuf payload */
3687 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3688 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3689 
3690 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3691 	/* Append data which is padded to a multiple */
3692 	/* of the algorithms block size */
3693 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3694 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3695 				plaintext_pad_len);
3696 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3697 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3698 
3699 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3700 
3701 	/* Create KASUMI operation */
3702 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3703 				tdata->cipher_iv.len,
3704 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3705 				tdata->validCipherOffsetInBits.len);
3706 	if (retval < 0)
3707 		return retval;
3708 
3709 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3710 						ut_params->op);
3711 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3712 
3713 	ut_params->obuf = ut_params->op->sym->m_dst;
3714 	if (ut_params->obuf)
3715 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3716 	else
3717 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3718 
3719 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3720 
3721 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3722 				(tdata->validCipherOffsetInBits.len >> 3);
3723 	/* Validate obuf */
3724 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3725 		ciphertext,
3726 		reference_ciphertext,
3727 		tdata->validCipherLenInBits.len,
3728 		"KASUMI Ciphertext data not as expected");
3729 	return 0;
3730 }
3731 
3732 static int
3733 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3734 {
3735 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3736 	struct crypto_unittest_params *ut_params = &unittest_params;
3737 
3738 	int retval;
3739 	unsigned int plaintext_pad_len;
3740 	unsigned int plaintext_len;
3741 
3742 	const uint8_t *ciphertext;
3743 	uint8_t buffer[2048];
3744 
3745 	struct rte_cryptodev_info dev_info;
3746 
3747 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3748 
3749 	uint64_t feat_flags = dev_info.feature_flags;
3750 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3751 		printf("Device doesn't support out-of-place scatter-gather "
3752 				"in both input and output mbufs. "
3753 				"Test Skipped.\n");
3754 		return -ENOTSUP;
3755 	}
3756 
3757 	/* Create KASUMI session */
3758 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3759 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3760 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3761 					tdata->key.data, tdata->key.len,
3762 					tdata->cipher_iv.len);
3763 	if (retval < 0)
3764 		return retval;
3765 
3766 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3767 	/* Append data which is padded to a multiple */
3768 	/* of the algorithms block size */
3769 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3770 
3771 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3772 			plaintext_pad_len, 10, 0);
3773 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3774 			plaintext_pad_len, 3, 0);
3775 
3776 	/* Append data which is padded to a multiple */
3777 	/* of the algorithms block size */
3778 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3779 
3780 	/* Create KASUMI operation */
3781 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3782 				tdata->cipher_iv.len,
3783 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3784 				tdata->validCipherOffsetInBits.len);
3785 	if (retval < 0)
3786 		return retval;
3787 
3788 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3789 						ut_params->op);
3790 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3791 
3792 	ut_params->obuf = ut_params->op->sym->m_dst;
3793 	if (ut_params->obuf)
3794 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3795 				plaintext_pad_len, buffer);
3796 	else
3797 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3798 				tdata->validCipherOffsetInBits.len >> 3,
3799 				plaintext_pad_len, buffer);
3800 
3801 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3802 				(tdata->validCipherOffsetInBits.len >> 3);
3803 	/* Validate obuf */
3804 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3805 		ciphertext,
3806 		reference_ciphertext,
3807 		tdata->validCipherLenInBits.len,
3808 		"KASUMI Ciphertext data not as expected");
3809 	return 0;
3810 }
3811 
3812 
3813 static int
3814 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3815 {
3816 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3817 	struct crypto_unittest_params *ut_params = &unittest_params;
3818 
3819 	int retval;
3820 	uint8_t *ciphertext, *plaintext;
3821 	unsigned ciphertext_pad_len;
3822 	unsigned ciphertext_len;
3823 
3824 	/* Create KASUMI session */
3825 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3826 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3827 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3828 					tdata->key.data, tdata->key.len,
3829 					tdata->cipher_iv.len);
3830 	if (retval < 0)
3831 		return retval;
3832 
3833 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3834 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3835 
3836 	/* Clear mbuf payload */
3837 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3838 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3839 
3840 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3841 	/* Append data which is padded to a multiple */
3842 	/* of the algorithms block size */
3843 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3844 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3845 				ciphertext_pad_len);
3846 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3847 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3848 
3849 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3850 
3851 	/* Create KASUMI operation */
3852 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3853 				tdata->cipher_iv.len,
3854 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3855 				tdata->validCipherOffsetInBits.len);
3856 	if (retval < 0)
3857 		return retval;
3858 
3859 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3860 						ut_params->op);
3861 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3862 
3863 	ut_params->obuf = ut_params->op->sym->m_dst;
3864 	if (ut_params->obuf)
3865 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3866 	else
3867 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3868 
3869 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3870 
3871 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3872 				(tdata->validCipherOffsetInBits.len >> 3);
3873 	/* Validate obuf */
3874 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3875 		plaintext,
3876 		reference_plaintext,
3877 		tdata->validCipherLenInBits.len,
3878 		"KASUMI Plaintext data not as expected");
3879 	return 0;
3880 }
3881 
3882 static int
3883 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3884 {
3885 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3886 	struct crypto_unittest_params *ut_params = &unittest_params;
3887 
3888 	int retval;
3889 	uint8_t *ciphertext, *plaintext;
3890 	unsigned ciphertext_pad_len;
3891 	unsigned ciphertext_len;
3892 
3893 	/* Create KASUMI session */
3894 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3895 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3896 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3897 					tdata->key.data, tdata->key.len,
3898 					tdata->cipher_iv.len);
3899 	if (retval < 0)
3900 		return retval;
3901 
3902 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3903 
3904 	/* Clear mbuf payload */
3905 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3906 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3907 
3908 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3909 	/* Append data which is padded to a multiple */
3910 	/* of the algorithms block size */
3911 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3912 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3913 				ciphertext_pad_len);
3914 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3915 
3916 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3917 
3918 	/* Create KASUMI operation */
3919 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3920 					tdata->cipher_iv.len,
3921 					tdata->ciphertext.len,
3922 					tdata->validCipherOffsetInBits.len);
3923 	if (retval < 0)
3924 		return retval;
3925 
3926 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3927 						ut_params->op);
3928 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3929 
3930 	ut_params->obuf = ut_params->op->sym->m_dst;
3931 	if (ut_params->obuf)
3932 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3933 	else
3934 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3935 
3936 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3937 
3938 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3939 				(tdata->validCipherOffsetInBits.len >> 3);
3940 	/* Validate obuf */
3941 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3942 		plaintext,
3943 		reference_plaintext,
3944 		tdata->validCipherLenInBits.len,
3945 		"KASUMI Plaintext data not as expected");
3946 	return 0;
3947 }
3948 
3949 static int
3950 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3951 {
3952 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3953 	struct crypto_unittest_params *ut_params = &unittest_params;
3954 
3955 	int retval;
3956 	uint8_t *plaintext, *ciphertext;
3957 	unsigned plaintext_pad_len;
3958 	unsigned plaintext_len;
3959 
3960 	/* Create SNOW 3G session */
3961 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3962 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3963 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3964 					tdata->key.data, tdata->key.len,
3965 					tdata->cipher_iv.len);
3966 	if (retval < 0)
3967 		return retval;
3968 
3969 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3970 
3971 	/* Clear mbuf payload */
3972 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3973 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3974 
3975 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3976 	/* Append data which is padded to a multiple of */
3977 	/* the algorithms block size */
3978 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3979 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3980 				plaintext_pad_len);
3981 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3982 
3983 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3984 
3985 	/* Create SNOW 3G operation */
3986 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3987 					tdata->cipher_iv.len,
3988 					tdata->validCipherLenInBits.len,
3989 					0);
3990 	if (retval < 0)
3991 		return retval;
3992 
3993 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3994 						ut_params->op);
3995 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3996 
3997 	ut_params->obuf = ut_params->op->sym->m_dst;
3998 	if (ut_params->obuf)
3999 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4000 	else
4001 		ciphertext = plaintext;
4002 
4003 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4004 
4005 	/* Validate obuf */
4006 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4007 		ciphertext,
4008 		tdata->ciphertext.data,
4009 		tdata->validDataLenInBits.len,
4010 		"SNOW 3G Ciphertext data not as expected");
4011 	return 0;
4012 }
4013 
4014 
4015 static int
4016 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4017 {
4018 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4019 	struct crypto_unittest_params *ut_params = &unittest_params;
4020 	uint8_t *plaintext, *ciphertext;
4021 
4022 	int retval;
4023 	unsigned plaintext_pad_len;
4024 	unsigned plaintext_len;
4025 
4026 	/* Create SNOW 3G session */
4027 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4028 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4029 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4030 					tdata->key.data, tdata->key.len,
4031 					tdata->cipher_iv.len);
4032 	if (retval < 0)
4033 		return retval;
4034 
4035 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4037 
4038 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4039 			"Failed to allocate input buffer in mempool");
4040 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4041 			"Failed to allocate output buffer in mempool");
4042 
4043 	/* Clear mbuf payload */
4044 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4045 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4046 
4047 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4048 	/* Append data which is padded to a multiple of */
4049 	/* the algorithms block size */
4050 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4051 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4052 				plaintext_pad_len);
4053 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4054 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4055 
4056 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4057 
4058 	/* Create SNOW 3G operation */
4059 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4060 					tdata->cipher_iv.len,
4061 					tdata->validCipherLenInBits.len,
4062 					0);
4063 	if (retval < 0)
4064 		return retval;
4065 
4066 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4067 						ut_params->op);
4068 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4069 
4070 	ut_params->obuf = ut_params->op->sym->m_dst;
4071 	if (ut_params->obuf)
4072 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4073 	else
4074 		ciphertext = plaintext;
4075 
4076 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4077 
4078 	/* Validate obuf */
4079 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4080 		ciphertext,
4081 		tdata->ciphertext.data,
4082 		tdata->validDataLenInBits.len,
4083 		"SNOW 3G Ciphertext data not as expected");
4084 	return 0;
4085 }
4086 
4087 static int
4088 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4089 {
4090 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4091 	struct crypto_unittest_params *ut_params = &unittest_params;
4092 
4093 	int retval;
4094 	unsigned int plaintext_pad_len;
4095 	unsigned int plaintext_len;
4096 	uint8_t buffer[10000];
4097 	const uint8_t *ciphertext;
4098 
4099 	struct rte_cryptodev_info dev_info;
4100 
4101 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4102 
4103 	uint64_t feat_flags = dev_info.feature_flags;
4104 
4105 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4106 		printf("Device doesn't support out-of-place scatter-gather "
4107 				"in both input and output mbufs. "
4108 				"Test Skipped.\n");
4109 		return -ENOTSUP;
4110 	}
4111 
4112 	/* Create SNOW 3G session */
4113 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4114 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4115 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4116 					tdata->key.data, tdata->key.len,
4117 					tdata->cipher_iv.len);
4118 	if (retval < 0)
4119 		return retval;
4120 
4121 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4122 	/* Append data which is padded to a multiple of */
4123 	/* the algorithms block size */
4124 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4125 
4126 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4127 			plaintext_pad_len, 10, 0);
4128 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4129 			plaintext_pad_len, 3, 0);
4130 
4131 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4132 			"Failed to allocate input buffer in mempool");
4133 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4134 			"Failed to allocate output buffer in mempool");
4135 
4136 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4137 
4138 	/* Create SNOW 3G operation */
4139 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4140 					tdata->cipher_iv.len,
4141 					tdata->validCipherLenInBits.len,
4142 					0);
4143 	if (retval < 0)
4144 		return retval;
4145 
4146 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4147 						ut_params->op);
4148 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4149 
4150 	ut_params->obuf = ut_params->op->sym->m_dst;
4151 	if (ut_params->obuf)
4152 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4153 				plaintext_len, buffer);
4154 	else
4155 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4156 				plaintext_len, buffer);
4157 
4158 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4159 
4160 	/* Validate obuf */
4161 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4162 		ciphertext,
4163 		tdata->ciphertext.data,
4164 		tdata->validDataLenInBits.len,
4165 		"SNOW 3G Ciphertext data not as expected");
4166 
4167 	return 0;
4168 }
4169 
4170 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4171 static void
4172 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4173 {
4174 	uint8_t curr_byte, prev_byte;
4175 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4176 	uint8_t lower_byte_mask = (1 << offset) - 1;
4177 	unsigned i;
4178 
4179 	prev_byte = buffer[0];
4180 	buffer[0] >>= offset;
4181 
4182 	for (i = 1; i < length_in_bytes; i++) {
4183 		curr_byte = buffer[i];
4184 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4185 				(curr_byte >> offset);
4186 		prev_byte = curr_byte;
4187 	}
4188 }
4189 
4190 static int
4191 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4192 {
4193 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4194 	struct crypto_unittest_params *ut_params = &unittest_params;
4195 	uint8_t *plaintext, *ciphertext;
4196 	int retval;
4197 	uint32_t plaintext_len;
4198 	uint32_t plaintext_pad_len;
4199 	uint8_t extra_offset = 4;
4200 	uint8_t *expected_ciphertext_shifted;
4201 
4202 	/* Create SNOW 3G session */
4203 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4204 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4205 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4206 					tdata->key.data, tdata->key.len,
4207 					tdata->cipher_iv.len);
4208 	if (retval < 0)
4209 		return retval;
4210 
4211 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4212 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4213 
4214 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4215 			"Failed to allocate input buffer in mempool");
4216 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4217 			"Failed to allocate output buffer in mempool");
4218 
4219 	/* Clear mbuf payload */
4220 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4221 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4222 
4223 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4224 	/*
4225 	 * Append data which is padded to a
4226 	 * multiple of the algorithms block size
4227 	 */
4228 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4229 
4230 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4231 						plaintext_pad_len);
4232 
4233 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4234 
4235 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4236 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4237 
4238 #ifdef RTE_APP_TEST_DEBUG
4239 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4240 #endif
4241 	/* Create SNOW 3G operation */
4242 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4243 					tdata->cipher_iv.len,
4244 					tdata->validCipherLenInBits.len,
4245 					extra_offset);
4246 	if (retval < 0)
4247 		return retval;
4248 
4249 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4250 						ut_params->op);
4251 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4252 
4253 	ut_params->obuf = ut_params->op->sym->m_dst;
4254 	if (ut_params->obuf)
4255 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4256 	else
4257 		ciphertext = plaintext;
4258 
4259 #ifdef RTE_APP_TEST_DEBUG
4260 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4261 #endif
4262 
4263 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4264 
4265 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4266 			"failed to reserve memory for ciphertext shifted\n");
4267 
4268 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4269 			ceil_byte_length(tdata->ciphertext.len));
4270 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4271 			extra_offset);
4272 	/* Validate obuf */
4273 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4274 		ciphertext,
4275 		expected_ciphertext_shifted,
4276 		tdata->validDataLenInBits.len,
4277 		extra_offset,
4278 		"SNOW 3G Ciphertext data not as expected");
4279 	return 0;
4280 }
4281 
4282 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4283 {
4284 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4285 	struct crypto_unittest_params *ut_params = &unittest_params;
4286 
4287 	int retval;
4288 
4289 	uint8_t *plaintext, *ciphertext;
4290 	unsigned ciphertext_pad_len;
4291 	unsigned ciphertext_len;
4292 
4293 	/* Create SNOW 3G session */
4294 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4295 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4296 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4297 					tdata->key.data, tdata->key.len,
4298 					tdata->cipher_iv.len);
4299 	if (retval < 0)
4300 		return retval;
4301 
4302 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4303 
4304 	/* Clear mbuf payload */
4305 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4306 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4307 
4308 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4309 	/* Append data which is padded to a multiple of */
4310 	/* the algorithms block size */
4311 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4312 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4313 				ciphertext_pad_len);
4314 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4315 
4316 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4317 
4318 	/* Create SNOW 3G operation */
4319 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4320 					tdata->cipher_iv.len,
4321 					tdata->validCipherLenInBits.len,
4322 					tdata->cipher.offset_bits);
4323 	if (retval < 0)
4324 		return retval;
4325 
4326 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4327 						ut_params->op);
4328 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4329 	ut_params->obuf = ut_params->op->sym->m_dst;
4330 	if (ut_params->obuf)
4331 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4332 	else
4333 		plaintext = ciphertext;
4334 
4335 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4336 
4337 	/* Validate obuf */
4338 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4339 				tdata->plaintext.data,
4340 				tdata->validDataLenInBits.len,
4341 				"SNOW 3G Plaintext data not as expected");
4342 	return 0;
4343 }
4344 
4345 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4346 {
4347 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4348 	struct crypto_unittest_params *ut_params = &unittest_params;
4349 
4350 	int retval;
4351 
4352 	uint8_t *plaintext, *ciphertext;
4353 	unsigned ciphertext_pad_len;
4354 	unsigned ciphertext_len;
4355 
4356 	/* Create SNOW 3G session */
4357 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4358 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4359 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4360 					tdata->key.data, tdata->key.len,
4361 					tdata->cipher_iv.len);
4362 	if (retval < 0)
4363 		return retval;
4364 
4365 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4366 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4367 
4368 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4369 			"Failed to allocate input buffer");
4370 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4371 			"Failed to allocate output buffer");
4372 
4373 	/* Clear mbuf payload */
4374 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4375 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4376 
4377 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4378 		       rte_pktmbuf_tailroom(ut_params->obuf));
4379 
4380 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4381 	/* Append data which is padded to a multiple of */
4382 	/* the algorithms block size */
4383 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4384 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4385 				ciphertext_pad_len);
4386 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4387 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4388 
4389 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4390 
4391 	/* Create SNOW 3G operation */
4392 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4393 					tdata->cipher_iv.len,
4394 					tdata->validCipherLenInBits.len,
4395 					0);
4396 	if (retval < 0)
4397 		return retval;
4398 
4399 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4400 						ut_params->op);
4401 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4402 	ut_params->obuf = ut_params->op->sym->m_dst;
4403 	if (ut_params->obuf)
4404 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4405 	else
4406 		plaintext = ciphertext;
4407 
4408 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4409 
4410 	/* Validate obuf */
4411 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4412 				tdata->plaintext.data,
4413 				tdata->validDataLenInBits.len,
4414 				"SNOW 3G Plaintext data not as expected");
4415 	return 0;
4416 }
4417 
4418 static int
4419 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4420 {
4421 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4422 	struct crypto_unittest_params *ut_params = &unittest_params;
4423 
4424 	int retval;
4425 
4426 	uint8_t *plaintext, *ciphertext;
4427 	unsigned int plaintext_pad_len;
4428 	unsigned int plaintext_len;
4429 
4430 	struct rte_cryptodev_sym_capability_idx cap_idx;
4431 
4432 	/* Check if device supports ZUC EEA3 */
4433 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4434 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4435 
4436 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4437 			&cap_idx) == NULL)
4438 		return -ENOTSUP;
4439 
4440 	/* Check if device supports ZUC EIA3 */
4441 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4442 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4443 
4444 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4445 			&cap_idx) == NULL)
4446 		return -ENOTSUP;
4447 
4448 	/* Create ZUC session */
4449 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4450 			ts_params->valid_devs[0],
4451 			tdata);
4452 	if (retval < 0)
4453 		return retval;
4454 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4455 
4456 	/* clear mbuf payload */
4457 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4458 			rte_pktmbuf_tailroom(ut_params->ibuf));
4459 
4460 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4461 	/* Append data which is padded to a multiple of */
4462 	/* the algorithms block size */
4463 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4464 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4465 				plaintext_pad_len);
4466 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4467 
4468 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4469 
4470 	/* Create ZUC operation */
4471 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4472 	if (retval < 0)
4473 		return retval;
4474 
4475 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4476 			ut_params->op);
4477 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4478 	ut_params->obuf = ut_params->op->sym->m_src;
4479 	if (ut_params->obuf)
4480 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4481 	else
4482 		ciphertext = plaintext;
4483 
4484 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4485 	/* Validate obuf */
4486 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4487 			ciphertext,
4488 			tdata->ciphertext.data,
4489 			tdata->validDataLenInBits.len,
4490 			"ZUC Ciphertext data not as expected");
4491 
4492 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4493 	    + plaintext_pad_len;
4494 
4495 	/* Validate obuf */
4496 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4497 			ut_params->digest,
4498 			tdata->digest.data,
4499 			4,
4500 			"ZUC Generated auth tag not as expected");
4501 	return 0;
4502 }
4503 
4504 static int
4505 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4506 {
4507 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4508 	struct crypto_unittest_params *ut_params = &unittest_params;
4509 
4510 	int retval;
4511 
4512 	uint8_t *plaintext, *ciphertext;
4513 	unsigned plaintext_pad_len;
4514 	unsigned plaintext_len;
4515 
4516 	/* Create SNOW 3G session */
4517 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4518 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4519 			RTE_CRYPTO_AUTH_OP_GENERATE,
4520 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4521 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4522 			tdata->key.data, tdata->key.len,
4523 			tdata->auth_iv.len, tdata->digest.len,
4524 			tdata->cipher_iv.len);
4525 	if (retval < 0)
4526 		return retval;
4527 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4528 
4529 	/* clear mbuf payload */
4530 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4531 			rte_pktmbuf_tailroom(ut_params->ibuf));
4532 
4533 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4534 	/* Append data which is padded to a multiple of */
4535 	/* the algorithms block size */
4536 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4537 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4538 				plaintext_pad_len);
4539 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4540 
4541 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4542 
4543 	/* Create SNOW 3G operation */
4544 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4545 			tdata->digest.len, tdata->auth_iv.data,
4546 			tdata->auth_iv.len,
4547 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4548 			tdata->cipher_iv.data, tdata->cipher_iv.len,
4549 			tdata->validCipherLenInBits.len,
4550 			0,
4551 			tdata->validAuthLenInBits.len,
4552 			0
4553 			);
4554 	if (retval < 0)
4555 		return retval;
4556 
4557 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4558 			ut_params->op);
4559 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4560 	ut_params->obuf = ut_params->op->sym->m_src;
4561 	if (ut_params->obuf)
4562 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4563 	else
4564 		ciphertext = plaintext;
4565 
4566 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4567 	/* Validate obuf */
4568 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4569 			ciphertext,
4570 			tdata->ciphertext.data,
4571 			tdata->validDataLenInBits.len,
4572 			"SNOW 3G Ciphertext data not as expected");
4573 
4574 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4575 	    + plaintext_pad_len;
4576 
4577 	/* Validate obuf */
4578 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4579 			ut_params->digest,
4580 			tdata->digest.data,
4581 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4582 			"SNOW 3G Generated auth tag not as expected");
4583 	return 0;
4584 }
4585 
4586 static int
4587 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4588 	uint8_t op_mode, uint8_t verify)
4589 {
4590 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4591 	struct crypto_unittest_params *ut_params = &unittest_params;
4592 
4593 	int retval;
4594 
4595 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4596 	unsigned int plaintext_pad_len;
4597 	unsigned int plaintext_len;
4598 	unsigned int ciphertext_pad_len;
4599 	unsigned int ciphertext_len;
4600 
4601 	struct rte_cryptodev_info dev_info;
4602 
4603 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4604 
4605 	uint64_t feat_flags = dev_info.feature_flags;
4606 
4607 	if (op_mode == OUT_OF_PLACE) {
4608 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4609 			printf("Device doesn't support digest encrypted.\n");
4610 			return -ENOTSUP;
4611 		}
4612 	}
4613 
4614 	/* Create SNOW 3G session */
4615 	retval = create_wireless_algo_auth_cipher_session(
4616 			ts_params->valid_devs[0],
4617 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4618 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4619 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4620 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4621 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4622 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4623 			tdata->key.data, tdata->key.len,
4624 			tdata->auth_iv.len, tdata->digest.len,
4625 			tdata->cipher_iv.len);
4626 
4627 	if (retval < 0)
4628 		return retval;
4629 
4630 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4631 	if (op_mode == OUT_OF_PLACE)
4632 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4633 
4634 	/* clear mbuf payload */
4635 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4636 		rte_pktmbuf_tailroom(ut_params->ibuf));
4637 	if (op_mode == OUT_OF_PLACE)
4638 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4639 			rte_pktmbuf_tailroom(ut_params->obuf));
4640 
4641 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4642 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4643 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4644 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4645 
4646 	if (verify) {
4647 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4648 					ciphertext_pad_len);
4649 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4650 		if (op_mode == OUT_OF_PLACE)
4651 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4652 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4653 			ciphertext_len);
4654 	} else {
4655 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4656 					plaintext_pad_len);
4657 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4658 		if (op_mode == OUT_OF_PLACE)
4659 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4660 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4661 	}
4662 
4663 	/* Create SNOW 3G operation */
4664 	retval = create_wireless_algo_auth_cipher_operation(
4665 		tdata->digest.data, tdata->digest.len,
4666 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4667 		tdata->auth_iv.data, tdata->auth_iv.len,
4668 		(tdata->digest.offset_bytes == 0 ?
4669 		(verify ? ciphertext_pad_len : plaintext_pad_len)
4670 			: tdata->digest.offset_bytes),
4671 		tdata->validCipherLenInBits.len,
4672 		tdata->cipher.offset_bits,
4673 		tdata->validAuthLenInBits.len,
4674 		tdata->auth.offset_bits,
4675 		op_mode, 0, verify);
4676 
4677 	if (retval < 0)
4678 		return retval;
4679 
4680 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4681 			ut_params->op);
4682 
4683 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4684 
4685 	ut_params->obuf = (op_mode == IN_PLACE ?
4686 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4687 
4688 	if (verify) {
4689 		if (ut_params->obuf)
4690 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4691 							uint8_t *);
4692 		else
4693 			plaintext = ciphertext +
4694 				(tdata->cipher.offset_bits >> 3);
4695 
4696 		debug_hexdump(stdout, "plaintext:", plaintext,
4697 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4698 		debug_hexdump(stdout, "plaintext expected:",
4699 			tdata->plaintext.data,
4700 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4701 	} else {
4702 		if (ut_params->obuf)
4703 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4704 							uint8_t *);
4705 		else
4706 			ciphertext = plaintext;
4707 
4708 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4709 			ciphertext_len);
4710 		debug_hexdump(stdout, "ciphertext expected:",
4711 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4712 
4713 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4714 			+ (tdata->digest.offset_bytes == 0 ?
4715 		plaintext_pad_len : tdata->digest.offset_bytes);
4716 
4717 		debug_hexdump(stdout, "digest:", ut_params->digest,
4718 			tdata->digest.len);
4719 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4720 				tdata->digest.len);
4721 	}
4722 
4723 	/* Validate obuf */
4724 	if (verify) {
4725 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4726 			plaintext,
4727 			tdata->plaintext.data,
4728 			tdata->plaintext.len >> 3,
4729 			"SNOW 3G Plaintext data not as expected");
4730 	} else {
4731 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4732 			ciphertext,
4733 			tdata->ciphertext.data,
4734 			tdata->validDataLenInBits.len,
4735 			"SNOW 3G Ciphertext data not as expected");
4736 
4737 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
4738 			ut_params->digest,
4739 			tdata->digest.data,
4740 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4741 			"SNOW 3G Generated auth tag not as expected");
4742 	}
4743 	return 0;
4744 }
4745 
4746 static int
4747 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4748 	uint8_t op_mode, uint8_t verify)
4749 {
4750 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4751 	struct crypto_unittest_params *ut_params = &unittest_params;
4752 
4753 	int retval;
4754 
4755 	const uint8_t *plaintext = NULL;
4756 	const uint8_t *ciphertext = NULL;
4757 	const uint8_t *digest = NULL;
4758 	unsigned int plaintext_pad_len;
4759 	unsigned int plaintext_len;
4760 	unsigned int ciphertext_pad_len;
4761 	unsigned int ciphertext_len;
4762 	uint8_t buffer[10000];
4763 	uint8_t digest_buffer[10000];
4764 
4765 	struct rte_cryptodev_info dev_info;
4766 
4767 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4768 
4769 	uint64_t feat_flags = dev_info.feature_flags;
4770 
4771 	if (op_mode == IN_PLACE) {
4772 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4773 			printf("Device doesn't support in-place scatter-gather "
4774 					"in both input and output mbufs.\n");
4775 			return -ENOTSUP;
4776 		}
4777 	} else {
4778 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4779 			printf("Device doesn't support out-of-place scatter-gather "
4780 					"in both input and output mbufs.\n");
4781 			return -ENOTSUP;
4782 		}
4783 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4784 			printf("Device doesn't support digest encrypted.\n");
4785 			return -ENOTSUP;
4786 		}
4787 	}
4788 
4789 	/* Create SNOW 3G session */
4790 	retval = create_wireless_algo_auth_cipher_session(
4791 			ts_params->valid_devs[0],
4792 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4793 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4794 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4795 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4796 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4797 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4798 			tdata->key.data, tdata->key.len,
4799 			tdata->auth_iv.len, tdata->digest.len,
4800 			tdata->cipher_iv.len);
4801 
4802 	if (retval < 0)
4803 		return retval;
4804 
4805 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4806 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4807 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4808 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4809 
4810 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4811 			plaintext_pad_len, 15, 0);
4812 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4813 			"Failed to allocate input buffer in mempool");
4814 
4815 	if (op_mode == OUT_OF_PLACE) {
4816 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4817 				plaintext_pad_len, 15, 0);
4818 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
4819 				"Failed to allocate output buffer in mempool");
4820 	}
4821 
4822 	if (verify) {
4823 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4824 			tdata->ciphertext.data);
4825 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4826 					ciphertext_len, buffer);
4827 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4828 			ciphertext_len);
4829 	} else {
4830 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4831 			tdata->plaintext.data);
4832 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4833 					plaintext_len, buffer);
4834 		debug_hexdump(stdout, "plaintext:", plaintext,
4835 			plaintext_len);
4836 	}
4837 	memset(buffer, 0, sizeof(buffer));
4838 
4839 	/* Create SNOW 3G operation */
4840 	retval = create_wireless_algo_auth_cipher_operation(
4841 		tdata->digest.data, tdata->digest.len,
4842 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4843 		tdata->auth_iv.data, tdata->auth_iv.len,
4844 		(tdata->digest.offset_bytes == 0 ?
4845 		(verify ? ciphertext_pad_len : plaintext_pad_len)
4846 			: tdata->digest.offset_bytes),
4847 		tdata->validCipherLenInBits.len,
4848 		tdata->cipher.offset_bits,
4849 		tdata->validAuthLenInBits.len,
4850 		tdata->auth.offset_bits,
4851 		op_mode, 1, verify);
4852 
4853 	if (retval < 0)
4854 		return retval;
4855 
4856 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4857 			ut_params->op);
4858 
4859 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4860 
4861 	ut_params->obuf = (op_mode == IN_PLACE ?
4862 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4863 
4864 	if (verify) {
4865 		if (ut_params->obuf)
4866 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4867 					plaintext_len, buffer);
4868 		else
4869 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4870 					plaintext_len, buffer);
4871 
4872 		debug_hexdump(stdout, "plaintext:", plaintext,
4873 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4874 		debug_hexdump(stdout, "plaintext expected:",
4875 			tdata->plaintext.data,
4876 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4877 	} else {
4878 		if (ut_params->obuf)
4879 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4880 					ciphertext_len, buffer);
4881 		else
4882 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4883 					ciphertext_len, buffer);
4884 
4885 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4886 			ciphertext_len);
4887 		debug_hexdump(stdout, "ciphertext expected:",
4888 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4889 
4890 		if (ut_params->obuf)
4891 			digest = rte_pktmbuf_read(ut_params->obuf,
4892 				(tdata->digest.offset_bytes == 0 ?
4893 				plaintext_pad_len : tdata->digest.offset_bytes),
4894 				tdata->digest.len, digest_buffer);
4895 		else
4896 			digest = rte_pktmbuf_read(ut_params->ibuf,
4897 				(tdata->digest.offset_bytes == 0 ?
4898 				plaintext_pad_len : tdata->digest.offset_bytes),
4899 				tdata->digest.len, digest_buffer);
4900 
4901 		debug_hexdump(stdout, "digest:", digest,
4902 			tdata->digest.len);
4903 		debug_hexdump(stdout, "digest expected:",
4904 			tdata->digest.data, tdata->digest.len);
4905 	}
4906 
4907 	/* Validate obuf */
4908 	if (verify) {
4909 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4910 			plaintext,
4911 			tdata->plaintext.data,
4912 			tdata->plaintext.len >> 3,
4913 			"SNOW 3G Plaintext data not as expected");
4914 	} else {
4915 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4916 			ciphertext,
4917 			tdata->ciphertext.data,
4918 			tdata->validDataLenInBits.len,
4919 			"SNOW 3G Ciphertext data not as expected");
4920 
4921 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
4922 			digest,
4923 			tdata->digest.data,
4924 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4925 			"SNOW 3G Generated auth tag not as expected");
4926 	}
4927 	return 0;
4928 }
4929 
4930 static int
4931 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4932 	uint8_t op_mode, uint8_t verify)
4933 {
4934 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4935 	struct crypto_unittest_params *ut_params = &unittest_params;
4936 
4937 	int retval;
4938 
4939 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4940 	unsigned int plaintext_pad_len;
4941 	unsigned int plaintext_len;
4942 	unsigned int ciphertext_pad_len;
4943 	unsigned int ciphertext_len;
4944 
4945 	struct rte_cryptodev_info dev_info;
4946 
4947 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4948 
4949 	uint64_t feat_flags = dev_info.feature_flags;
4950 
4951 	if (op_mode == OUT_OF_PLACE) {
4952 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4953 			printf("Device doesn't support digest encrypted.\n");
4954 			return -ENOTSUP;
4955 		}
4956 	}
4957 
4958 	/* Create KASUMI session */
4959 	retval = create_wireless_algo_auth_cipher_session(
4960 			ts_params->valid_devs[0],
4961 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4962 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4963 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4964 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4965 			RTE_CRYPTO_AUTH_KASUMI_F9,
4966 			RTE_CRYPTO_CIPHER_KASUMI_F8,
4967 			tdata->key.data, tdata->key.len,
4968 			0, tdata->digest.len,
4969 			tdata->cipher_iv.len);
4970 
4971 	if (retval < 0)
4972 		return retval;
4973 
4974 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4975 	if (op_mode == OUT_OF_PLACE)
4976 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4977 
4978 	/* clear mbuf payload */
4979 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4980 		rte_pktmbuf_tailroom(ut_params->ibuf));
4981 	if (op_mode == OUT_OF_PLACE)
4982 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4983 			rte_pktmbuf_tailroom(ut_params->obuf));
4984 
4985 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4986 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4987 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4988 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4989 
4990 	if (verify) {
4991 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4992 					ciphertext_pad_len);
4993 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4994 		if (op_mode == OUT_OF_PLACE)
4995 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4996 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4997 			ciphertext_len);
4998 	} else {
4999 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5000 					plaintext_pad_len);
5001 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5002 		if (op_mode == OUT_OF_PLACE)
5003 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5004 		debug_hexdump(stdout, "plaintext:", plaintext,
5005 			plaintext_len);
5006 	}
5007 
5008 	/* Create KASUMI operation */
5009 	retval = create_wireless_algo_auth_cipher_operation(
5010 		tdata->digest.data, tdata->digest.len,
5011 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5012 		NULL, 0,
5013 		(tdata->digest.offset_bytes == 0 ?
5014 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5015 			: tdata->digest.offset_bytes),
5016 		tdata->validCipherLenInBits.len,
5017 		tdata->validCipherOffsetInBits.len,
5018 		tdata->validAuthLenInBits.len,
5019 		0,
5020 		op_mode, 0, verify);
5021 
5022 	if (retval < 0)
5023 		return retval;
5024 
5025 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5026 			ut_params->op);
5027 
5028 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5029 
5030 	ut_params->obuf = (op_mode == IN_PLACE ?
5031 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5032 
5033 
5034 	if (verify) {
5035 		if (ut_params->obuf)
5036 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5037 							uint8_t *);
5038 		else
5039 			plaintext = ciphertext;
5040 
5041 		debug_hexdump(stdout, "plaintext:", plaintext,
5042 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5043 		debug_hexdump(stdout, "plaintext expected:",
5044 			tdata->plaintext.data,
5045 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5046 	} else {
5047 		if (ut_params->obuf)
5048 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5049 							uint8_t *);
5050 		else
5051 			ciphertext = plaintext;
5052 
5053 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5054 			ciphertext_len);
5055 		debug_hexdump(stdout, "ciphertext expected:",
5056 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5057 
5058 		ut_params->digest = rte_pktmbuf_mtod(
5059 			ut_params->obuf, uint8_t *) +
5060 			(tdata->digest.offset_bytes == 0 ?
5061 			plaintext_pad_len : tdata->digest.offset_bytes);
5062 
5063 		debug_hexdump(stdout, "digest:", ut_params->digest,
5064 			tdata->digest.len);
5065 		debug_hexdump(stdout, "digest expected:",
5066 			tdata->digest.data, tdata->digest.len);
5067 	}
5068 
5069 	/* Validate obuf */
5070 	if (verify) {
5071 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5072 			plaintext,
5073 			tdata->plaintext.data,
5074 			tdata->plaintext.len >> 3,
5075 			"KASUMI Plaintext data not as expected");
5076 	} else {
5077 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5078 			ciphertext,
5079 			tdata->ciphertext.data,
5080 			tdata->ciphertext.len >> 3,
5081 			"KASUMI Ciphertext data not as expected");
5082 
5083 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5084 			ut_params->digest,
5085 			tdata->digest.data,
5086 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5087 			"KASUMI Generated auth tag not as expected");
5088 	}
5089 	return 0;
5090 }
5091 
5092 static int
5093 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5094 	uint8_t op_mode, uint8_t verify)
5095 {
5096 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5097 	struct crypto_unittest_params *ut_params = &unittest_params;
5098 
5099 	int retval;
5100 
5101 	const uint8_t *plaintext = NULL;
5102 	const uint8_t *ciphertext = NULL;
5103 	const uint8_t *digest = NULL;
5104 	unsigned int plaintext_pad_len;
5105 	unsigned int plaintext_len;
5106 	unsigned int ciphertext_pad_len;
5107 	unsigned int ciphertext_len;
5108 	uint8_t buffer[10000];
5109 	uint8_t digest_buffer[10000];
5110 
5111 	struct rte_cryptodev_info dev_info;
5112 
5113 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5114 
5115 	uint64_t feat_flags = dev_info.feature_flags;
5116 
5117 	if (op_mode == IN_PLACE) {
5118 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5119 			printf("Device doesn't support in-place scatter-gather "
5120 					"in both input and output mbufs.\n");
5121 			return -ENOTSUP;
5122 		}
5123 	} else {
5124 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5125 			printf("Device doesn't support out-of-place scatter-gather "
5126 					"in both input and output mbufs.\n");
5127 			return -ENOTSUP;
5128 		}
5129 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5130 			printf("Device doesn't support digest encrypted.\n");
5131 			return -ENOTSUP;
5132 		}
5133 	}
5134 
5135 	/* Create KASUMI session */
5136 	retval = create_wireless_algo_auth_cipher_session(
5137 			ts_params->valid_devs[0],
5138 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5139 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5140 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5141 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5142 			RTE_CRYPTO_AUTH_KASUMI_F9,
5143 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5144 			tdata->key.data, tdata->key.len,
5145 			0, tdata->digest.len,
5146 			tdata->cipher_iv.len);
5147 
5148 	if (retval < 0)
5149 		return retval;
5150 
5151 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5152 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5153 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5154 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5155 
5156 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5157 			plaintext_pad_len, 15, 0);
5158 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5159 			"Failed to allocate input buffer in mempool");
5160 
5161 	if (op_mode == OUT_OF_PLACE) {
5162 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5163 				plaintext_pad_len, 15, 0);
5164 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5165 				"Failed to allocate output buffer in mempool");
5166 	}
5167 
5168 	if (verify) {
5169 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5170 			tdata->ciphertext.data);
5171 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5172 					ciphertext_len, buffer);
5173 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5174 			ciphertext_len);
5175 	} else {
5176 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5177 			tdata->plaintext.data);
5178 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5179 					plaintext_len, buffer);
5180 		debug_hexdump(stdout, "plaintext:", plaintext,
5181 			plaintext_len);
5182 	}
5183 	memset(buffer, 0, sizeof(buffer));
5184 
5185 	/* Create KASUMI operation */
5186 	retval = create_wireless_algo_auth_cipher_operation(
5187 		tdata->digest.data, tdata->digest.len,
5188 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5189 		NULL, 0,
5190 		(tdata->digest.offset_bytes == 0 ?
5191 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5192 			: tdata->digest.offset_bytes),
5193 		tdata->validCipherLenInBits.len,
5194 		tdata->validCipherOffsetInBits.len,
5195 		tdata->validAuthLenInBits.len,
5196 		0,
5197 		op_mode, 1, verify);
5198 
5199 	if (retval < 0)
5200 		return retval;
5201 
5202 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5203 			ut_params->op);
5204 
5205 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5206 
5207 	ut_params->obuf = (op_mode == IN_PLACE ?
5208 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5209 
5210 	if (verify) {
5211 		if (ut_params->obuf)
5212 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5213 					plaintext_len, buffer);
5214 		else
5215 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5216 					plaintext_len, buffer);
5217 
5218 		debug_hexdump(stdout, "plaintext:", plaintext,
5219 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5220 		debug_hexdump(stdout, "plaintext expected:",
5221 			tdata->plaintext.data,
5222 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5223 	} else {
5224 		if (ut_params->obuf)
5225 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5226 					ciphertext_len, buffer);
5227 		else
5228 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5229 					ciphertext_len, buffer);
5230 
5231 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5232 			ciphertext_len);
5233 		debug_hexdump(stdout, "ciphertext expected:",
5234 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5235 
5236 		if (ut_params->obuf)
5237 			digest = rte_pktmbuf_read(ut_params->obuf,
5238 				(tdata->digest.offset_bytes == 0 ?
5239 				plaintext_pad_len : tdata->digest.offset_bytes),
5240 				tdata->digest.len, digest_buffer);
5241 		else
5242 			digest = rte_pktmbuf_read(ut_params->ibuf,
5243 				(tdata->digest.offset_bytes == 0 ?
5244 				plaintext_pad_len : tdata->digest.offset_bytes),
5245 				tdata->digest.len, digest_buffer);
5246 
5247 		debug_hexdump(stdout, "digest:", digest,
5248 			tdata->digest.len);
5249 		debug_hexdump(stdout, "digest expected:",
5250 			tdata->digest.data, tdata->digest.len);
5251 	}
5252 
5253 	/* Validate obuf */
5254 	if (verify) {
5255 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5256 			plaintext,
5257 			tdata->plaintext.data,
5258 			tdata->plaintext.len >> 3,
5259 			"KASUMI Plaintext data not as expected");
5260 	} else {
5261 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5262 			ciphertext,
5263 			tdata->ciphertext.data,
5264 			tdata->validDataLenInBits.len,
5265 			"KASUMI Ciphertext data not as expected");
5266 
5267 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5268 			digest,
5269 			tdata->digest.data,
5270 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5271 			"KASUMI Generated auth tag not as expected");
5272 	}
5273 	return 0;
5274 }
5275 
5276 static int
5277 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5278 {
5279 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5280 	struct crypto_unittest_params *ut_params = &unittest_params;
5281 
5282 	int retval;
5283 
5284 	uint8_t *plaintext, *ciphertext;
5285 	unsigned plaintext_pad_len;
5286 	unsigned plaintext_len;
5287 
5288 	/* Create KASUMI session */
5289 	retval = create_wireless_algo_cipher_auth_session(
5290 			ts_params->valid_devs[0],
5291 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5292 			RTE_CRYPTO_AUTH_OP_GENERATE,
5293 			RTE_CRYPTO_AUTH_KASUMI_F9,
5294 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5295 			tdata->key.data, tdata->key.len,
5296 			0, tdata->digest.len,
5297 			tdata->cipher_iv.len);
5298 	if (retval < 0)
5299 		return retval;
5300 
5301 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5302 
5303 	/* clear mbuf payload */
5304 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5305 			rte_pktmbuf_tailroom(ut_params->ibuf));
5306 
5307 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5308 	/* Append data which is padded to a multiple of */
5309 	/* the algorithms block size */
5310 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5311 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5312 				plaintext_pad_len);
5313 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5314 
5315 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5316 
5317 	/* Create KASUMI operation */
5318 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5319 				tdata->digest.len, NULL, 0,
5320 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5321 				tdata->cipher_iv.data, tdata->cipher_iv.len,
5322 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5323 				tdata->validCipherOffsetInBits.len,
5324 				tdata->validAuthLenInBits.len,
5325 				0
5326 				);
5327 	if (retval < 0)
5328 		return retval;
5329 
5330 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5331 			ut_params->op);
5332 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5333 
5334 	if (ut_params->op->sym->m_dst)
5335 		ut_params->obuf = ut_params->op->sym->m_dst;
5336 	else
5337 		ut_params->obuf = ut_params->op->sym->m_src;
5338 
5339 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5340 				tdata->validCipherOffsetInBits.len >> 3);
5341 
5342 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5343 			+ plaintext_pad_len;
5344 
5345 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5346 				(tdata->validCipherOffsetInBits.len >> 3);
5347 	/* Validate obuf */
5348 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5349 		ciphertext,
5350 		reference_ciphertext,
5351 		tdata->validCipherLenInBits.len,
5352 		"KASUMI Ciphertext data not as expected");
5353 
5354 	/* Validate obuf */
5355 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5356 		ut_params->digest,
5357 		tdata->digest.data,
5358 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5359 		"KASUMI Generated auth tag not as expected");
5360 	return 0;
5361 }
5362 
5363 static int
5364 test_zuc_encryption(const struct wireless_test_data *tdata)
5365 {
5366 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5367 	struct crypto_unittest_params *ut_params = &unittest_params;
5368 
5369 	int retval;
5370 	uint8_t *plaintext, *ciphertext;
5371 	unsigned plaintext_pad_len;
5372 	unsigned plaintext_len;
5373 
5374 	struct rte_cryptodev_sym_capability_idx cap_idx;
5375 
5376 	/* Check if device supports ZUC EEA3 */
5377 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5378 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5379 
5380 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5381 			&cap_idx) == NULL)
5382 		return -ENOTSUP;
5383 
5384 	/* Create ZUC session */
5385 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5386 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5387 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
5388 					tdata->key.data, tdata->key.len,
5389 					tdata->cipher_iv.len);
5390 	if (retval < 0)
5391 		return retval;
5392 
5393 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5394 
5395 	/* Clear mbuf payload */
5396 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5397 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5398 
5399 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5400 	/* Append data which is padded to a multiple */
5401 	/* of the algorithms block size */
5402 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5403 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5404 				plaintext_pad_len);
5405 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5406 
5407 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5408 
5409 	/* Create ZUC operation */
5410 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5411 					tdata->cipher_iv.len,
5412 					tdata->plaintext.len,
5413 					0);
5414 	if (retval < 0)
5415 		return retval;
5416 
5417 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5418 						ut_params->op);
5419 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5420 
5421 	ut_params->obuf = ut_params->op->sym->m_dst;
5422 	if (ut_params->obuf)
5423 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5424 	else
5425 		ciphertext = plaintext;
5426 
5427 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5428 
5429 	/* Validate obuf */
5430 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5431 		ciphertext,
5432 		tdata->ciphertext.data,
5433 		tdata->validCipherLenInBits.len,
5434 		"ZUC Ciphertext data not as expected");
5435 	return 0;
5436 }
5437 
5438 static int
5439 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5440 {
5441 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5442 	struct crypto_unittest_params *ut_params = &unittest_params;
5443 
5444 	int retval;
5445 
5446 	unsigned int plaintext_pad_len;
5447 	unsigned int plaintext_len;
5448 	const uint8_t *ciphertext;
5449 	uint8_t ciphertext_buffer[2048];
5450 	struct rte_cryptodev_info dev_info;
5451 
5452 	struct rte_cryptodev_sym_capability_idx cap_idx;
5453 
5454 	/* Check if device supports ZUC EEA3 */
5455 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5456 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5457 
5458 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5459 			&cap_idx) == NULL)
5460 		return -ENOTSUP;
5461 
5462 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5463 
5464 	uint64_t feat_flags = dev_info.feature_flags;
5465 
5466 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5467 		printf("Device doesn't support in-place scatter-gather. "
5468 				"Test Skipped.\n");
5469 		return -ENOTSUP;
5470 	}
5471 
5472 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5473 
5474 	/* Append data which is padded to a multiple */
5475 	/* of the algorithms block size */
5476 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5477 
5478 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5479 			plaintext_pad_len, 10, 0);
5480 
5481 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5482 			tdata->plaintext.data);
5483 
5484 	/* Create ZUC session */
5485 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5486 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5487 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5488 			tdata->key.data, tdata->key.len,
5489 			tdata->cipher_iv.len);
5490 	if (retval < 0)
5491 		return retval;
5492 
5493 	/* Clear mbuf payload */
5494 
5495 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5496 
5497 	/* Create ZUC operation */
5498 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5499 			tdata->cipher_iv.len, tdata->plaintext.len,
5500 			0);
5501 	if (retval < 0)
5502 		return retval;
5503 
5504 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5505 						ut_params->op);
5506 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5507 
5508 	ut_params->obuf = ut_params->op->sym->m_dst;
5509 	if (ut_params->obuf)
5510 		ciphertext = rte_pktmbuf_read(ut_params->obuf,
5511 			0, plaintext_len, ciphertext_buffer);
5512 	else
5513 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5514 			0, plaintext_len, ciphertext_buffer);
5515 
5516 	/* Validate obuf */
5517 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5518 
5519 	/* Validate obuf */
5520 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5521 		ciphertext,
5522 		tdata->ciphertext.data,
5523 		tdata->validCipherLenInBits.len,
5524 		"ZUC Ciphertext data not as expected");
5525 
5526 	return 0;
5527 }
5528 
5529 static int
5530 test_zuc_authentication(const struct wireless_test_data *tdata)
5531 {
5532 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5533 	struct crypto_unittest_params *ut_params = &unittest_params;
5534 
5535 	int retval;
5536 	unsigned plaintext_pad_len;
5537 	unsigned plaintext_len;
5538 	uint8_t *plaintext;
5539 
5540 	struct rte_cryptodev_sym_capability_idx cap_idx;
5541 
5542 	/* Check if device supports ZUC EIA3 */
5543 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5544 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5545 
5546 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5547 			&cap_idx) == NULL)
5548 		return -ENOTSUP;
5549 
5550 	/* Create ZUC session */
5551 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5552 			tdata->key.data, tdata->key.len,
5553 			tdata->auth_iv.len, tdata->digest.len,
5554 			RTE_CRYPTO_AUTH_OP_GENERATE,
5555 			RTE_CRYPTO_AUTH_ZUC_EIA3);
5556 	if (retval < 0)
5557 		return retval;
5558 
5559 	/* alloc mbuf and set payload */
5560 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5561 
5562 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5563 	rte_pktmbuf_tailroom(ut_params->ibuf));
5564 
5565 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5566 	/* Append data which is padded to a multiple of */
5567 	/* the algorithms block size */
5568 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5569 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5570 				plaintext_pad_len);
5571 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5572 
5573 	/* Create ZUC operation */
5574 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5575 			tdata->auth_iv.data, tdata->auth_iv.len,
5576 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5577 			tdata->validAuthLenInBits.len,
5578 			0);
5579 	if (retval < 0)
5580 		return retval;
5581 
5582 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5583 				ut_params->op);
5584 	ut_params->obuf = ut_params->op->sym->m_src;
5585 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5586 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5587 			+ plaintext_pad_len;
5588 
5589 	/* Validate obuf */
5590 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5591 	ut_params->digest,
5592 	tdata->digest.data,
5593 	DIGEST_BYTE_LENGTH_KASUMI_F9,
5594 	"ZUC Generated auth tag not as expected");
5595 
5596 	return 0;
5597 }
5598 
5599 static int
5600 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5601 	uint8_t op_mode, uint8_t verify)
5602 {
5603 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5604 	struct crypto_unittest_params *ut_params = &unittest_params;
5605 
5606 	int retval;
5607 
5608 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5609 	unsigned int plaintext_pad_len;
5610 	unsigned int plaintext_len;
5611 	unsigned int ciphertext_pad_len;
5612 	unsigned int ciphertext_len;
5613 
5614 	struct rte_cryptodev_info dev_info;
5615 	struct rte_cryptodev_sym_capability_idx cap_idx;
5616 
5617 	/* Check if device supports ZUC EIA3 */
5618 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5619 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5620 
5621 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5622 			&cap_idx) == NULL)
5623 		return -ENOTSUP;
5624 
5625 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5626 
5627 	uint64_t feat_flags = dev_info.feature_flags;
5628 
5629 	if (op_mode == OUT_OF_PLACE) {
5630 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5631 			printf("Device doesn't support digest encrypted.\n");
5632 			return -ENOTSUP;
5633 		}
5634 	}
5635 
5636 	/* Create ZUC session */
5637 	retval = create_wireless_algo_auth_cipher_session(
5638 			ts_params->valid_devs[0],
5639 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5640 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5641 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5642 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5643 			RTE_CRYPTO_AUTH_ZUC_EIA3,
5644 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5645 			tdata->key.data, tdata->key.len,
5646 			tdata->auth_iv.len, tdata->digest.len,
5647 			tdata->cipher_iv.len);
5648 
5649 	if (retval < 0)
5650 		return retval;
5651 
5652 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5653 	if (op_mode == OUT_OF_PLACE)
5654 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5655 
5656 	/* clear mbuf payload */
5657 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5658 		rte_pktmbuf_tailroom(ut_params->ibuf));
5659 	if (op_mode == OUT_OF_PLACE)
5660 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5661 			rte_pktmbuf_tailroom(ut_params->obuf));
5662 
5663 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5664 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5665 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5666 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5667 
5668 	if (verify) {
5669 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5670 					ciphertext_pad_len);
5671 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5672 		if (op_mode == OUT_OF_PLACE)
5673 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5674 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5675 			ciphertext_len);
5676 	} else {
5677 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5678 					plaintext_pad_len);
5679 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5680 		if (op_mode == OUT_OF_PLACE)
5681 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5682 		debug_hexdump(stdout, "plaintext:", plaintext,
5683 			plaintext_len);
5684 	}
5685 
5686 	/* Create ZUC operation */
5687 	retval = create_wireless_algo_auth_cipher_operation(
5688 		tdata->digest.data, tdata->digest.len,
5689 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5690 		tdata->auth_iv.data, tdata->auth_iv.len,
5691 		(tdata->digest.offset_bytes == 0 ?
5692 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5693 			: tdata->digest.offset_bytes),
5694 		tdata->validCipherLenInBits.len,
5695 		tdata->validCipherOffsetInBits.len,
5696 		tdata->validAuthLenInBits.len,
5697 		0,
5698 		op_mode, 0, verify);
5699 
5700 	if (retval < 0)
5701 		return retval;
5702 
5703 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5704 			ut_params->op);
5705 
5706 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5707 
5708 	ut_params->obuf = (op_mode == IN_PLACE ?
5709 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5710 
5711 
5712 	if (verify) {
5713 		if (ut_params->obuf)
5714 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5715 							uint8_t *);
5716 		else
5717 			plaintext = ciphertext;
5718 
5719 		debug_hexdump(stdout, "plaintext:", plaintext,
5720 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5721 		debug_hexdump(stdout, "plaintext expected:",
5722 			tdata->plaintext.data,
5723 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5724 	} else {
5725 		if (ut_params->obuf)
5726 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5727 							uint8_t *);
5728 		else
5729 			ciphertext = plaintext;
5730 
5731 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5732 			ciphertext_len);
5733 		debug_hexdump(stdout, "ciphertext expected:",
5734 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5735 
5736 		ut_params->digest = rte_pktmbuf_mtod(
5737 			ut_params->obuf, uint8_t *) +
5738 			(tdata->digest.offset_bytes == 0 ?
5739 			plaintext_pad_len : tdata->digest.offset_bytes);
5740 
5741 		debug_hexdump(stdout, "digest:", ut_params->digest,
5742 			tdata->digest.len);
5743 		debug_hexdump(stdout, "digest expected:",
5744 			tdata->digest.data, tdata->digest.len);
5745 	}
5746 
5747 	/* Validate obuf */
5748 	if (verify) {
5749 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5750 			plaintext,
5751 			tdata->plaintext.data,
5752 			tdata->plaintext.len >> 3,
5753 			"ZUC Plaintext data not as expected");
5754 	} else {
5755 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5756 			ciphertext,
5757 			tdata->ciphertext.data,
5758 			tdata->ciphertext.len >> 3,
5759 			"ZUC Ciphertext data not as expected");
5760 
5761 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5762 			ut_params->digest,
5763 			tdata->digest.data,
5764 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5765 			"ZUC Generated auth tag not as expected");
5766 	}
5767 	return 0;
5768 }
5769 
5770 static int
5771 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5772 	uint8_t op_mode, uint8_t verify)
5773 {
5774 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5775 	struct crypto_unittest_params *ut_params = &unittest_params;
5776 
5777 	int retval;
5778 
5779 	const uint8_t *plaintext = NULL;
5780 	const uint8_t *ciphertext = NULL;
5781 	const uint8_t *digest = NULL;
5782 	unsigned int plaintext_pad_len;
5783 	unsigned int plaintext_len;
5784 	unsigned int ciphertext_pad_len;
5785 	unsigned int ciphertext_len;
5786 	uint8_t buffer[10000];
5787 	uint8_t digest_buffer[10000];
5788 
5789 	struct rte_cryptodev_info dev_info;
5790 	struct rte_cryptodev_sym_capability_idx cap_idx;
5791 
5792 	/* Check if device supports ZUC EIA3 */
5793 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5794 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5795 
5796 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5797 			&cap_idx) == NULL)
5798 		return -ENOTSUP;
5799 
5800 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5801 
5802 	uint64_t feat_flags = dev_info.feature_flags;
5803 
5804 	if (op_mode == IN_PLACE) {
5805 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5806 			printf("Device doesn't support in-place scatter-gather "
5807 					"in both input and output mbufs.\n");
5808 			return -ENOTSUP;
5809 		}
5810 	} else {
5811 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5812 			printf("Device doesn't support out-of-place scatter-gather "
5813 					"in both input and output mbufs.\n");
5814 			return -ENOTSUP;
5815 		}
5816 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5817 			printf("Device doesn't support digest encrypted.\n");
5818 			return -ENOTSUP;
5819 		}
5820 	}
5821 
5822 	/* Create ZUC session */
5823 	retval = create_wireless_algo_auth_cipher_session(
5824 			ts_params->valid_devs[0],
5825 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5826 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5827 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5828 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5829 			RTE_CRYPTO_AUTH_ZUC_EIA3,
5830 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5831 			tdata->key.data, tdata->key.len,
5832 			tdata->auth_iv.len, tdata->digest.len,
5833 			tdata->cipher_iv.len);
5834 
5835 	if (retval < 0)
5836 		return retval;
5837 
5838 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5839 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5840 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5841 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5842 
5843 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5844 			plaintext_pad_len, 15, 0);
5845 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5846 			"Failed to allocate input buffer in mempool");
5847 
5848 	if (op_mode == OUT_OF_PLACE) {
5849 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5850 				plaintext_pad_len, 15, 0);
5851 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5852 				"Failed to allocate output buffer in mempool");
5853 	}
5854 
5855 	if (verify) {
5856 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5857 			tdata->ciphertext.data);
5858 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5859 					ciphertext_len, buffer);
5860 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5861 			ciphertext_len);
5862 	} else {
5863 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5864 			tdata->plaintext.data);
5865 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5866 					plaintext_len, buffer);
5867 		debug_hexdump(stdout, "plaintext:", plaintext,
5868 			plaintext_len);
5869 	}
5870 	memset(buffer, 0, sizeof(buffer));
5871 
5872 	/* Create ZUC operation */
5873 	retval = create_wireless_algo_auth_cipher_operation(
5874 		tdata->digest.data, tdata->digest.len,
5875 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5876 		NULL, 0,
5877 		(tdata->digest.offset_bytes == 0 ?
5878 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5879 			: tdata->digest.offset_bytes),
5880 		tdata->validCipherLenInBits.len,
5881 		tdata->validCipherOffsetInBits.len,
5882 		tdata->validAuthLenInBits.len,
5883 		0,
5884 		op_mode, 1, verify);
5885 
5886 	if (retval < 0)
5887 		return retval;
5888 
5889 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5890 			ut_params->op);
5891 
5892 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5893 
5894 	ut_params->obuf = (op_mode == IN_PLACE ?
5895 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5896 
5897 	if (verify) {
5898 		if (ut_params->obuf)
5899 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5900 					plaintext_len, buffer);
5901 		else
5902 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5903 					plaintext_len, buffer);
5904 
5905 		debug_hexdump(stdout, "plaintext:", plaintext,
5906 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5907 		debug_hexdump(stdout, "plaintext expected:",
5908 			tdata->plaintext.data,
5909 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5910 	} else {
5911 		if (ut_params->obuf)
5912 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5913 					ciphertext_len, buffer);
5914 		else
5915 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5916 					ciphertext_len, buffer);
5917 
5918 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5919 			ciphertext_len);
5920 		debug_hexdump(stdout, "ciphertext expected:",
5921 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5922 
5923 		if (ut_params->obuf)
5924 			digest = rte_pktmbuf_read(ut_params->obuf,
5925 				(tdata->digest.offset_bytes == 0 ?
5926 				plaintext_pad_len : tdata->digest.offset_bytes),
5927 				tdata->digest.len, digest_buffer);
5928 		else
5929 			digest = rte_pktmbuf_read(ut_params->ibuf,
5930 				(tdata->digest.offset_bytes == 0 ?
5931 				plaintext_pad_len : tdata->digest.offset_bytes),
5932 				tdata->digest.len, digest_buffer);
5933 
5934 		debug_hexdump(stdout, "digest:", digest,
5935 			tdata->digest.len);
5936 		debug_hexdump(stdout, "digest expected:",
5937 			tdata->digest.data, tdata->digest.len);
5938 	}
5939 
5940 	/* Validate obuf */
5941 	if (verify) {
5942 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5943 			plaintext,
5944 			tdata->plaintext.data,
5945 			tdata->plaintext.len >> 3,
5946 			"ZUC Plaintext data not as expected");
5947 	} else {
5948 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5949 			ciphertext,
5950 			tdata->ciphertext.data,
5951 			tdata->validDataLenInBits.len,
5952 			"ZUC Ciphertext data not as expected");
5953 
5954 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5955 			digest,
5956 			tdata->digest.data,
5957 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5958 			"ZUC Generated auth tag not as expected");
5959 	}
5960 	return 0;
5961 }
5962 
5963 static int
5964 test_kasumi_encryption_test_case_1(void)
5965 {
5966 	return test_kasumi_encryption(&kasumi_test_case_1);
5967 }
5968 
5969 static int
5970 test_kasumi_encryption_test_case_1_sgl(void)
5971 {
5972 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5973 }
5974 
5975 static int
5976 test_kasumi_encryption_test_case_1_oop(void)
5977 {
5978 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
5979 }
5980 
5981 static int
5982 test_kasumi_encryption_test_case_1_oop_sgl(void)
5983 {
5984 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5985 }
5986 
5987 static int
5988 test_kasumi_encryption_test_case_2(void)
5989 {
5990 	return test_kasumi_encryption(&kasumi_test_case_2);
5991 }
5992 
5993 static int
5994 test_kasumi_encryption_test_case_3(void)
5995 {
5996 	return test_kasumi_encryption(&kasumi_test_case_3);
5997 }
5998 
5999 static int
6000 test_kasumi_encryption_test_case_4(void)
6001 {
6002 	return test_kasumi_encryption(&kasumi_test_case_4);
6003 }
6004 
6005 static int
6006 test_kasumi_encryption_test_case_5(void)
6007 {
6008 	return test_kasumi_encryption(&kasumi_test_case_5);
6009 }
6010 
6011 static int
6012 test_kasumi_decryption_test_case_1(void)
6013 {
6014 	return test_kasumi_decryption(&kasumi_test_case_1);
6015 }
6016 
6017 static int
6018 test_kasumi_decryption_test_case_1_oop(void)
6019 {
6020 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
6021 }
6022 
6023 static int
6024 test_kasumi_decryption_test_case_2(void)
6025 {
6026 	return test_kasumi_decryption(&kasumi_test_case_2);
6027 }
6028 
6029 static int
6030 test_kasumi_decryption_test_case_3(void)
6031 {
6032 	return test_kasumi_decryption(&kasumi_test_case_3);
6033 }
6034 
6035 static int
6036 test_kasumi_decryption_test_case_4(void)
6037 {
6038 	return test_kasumi_decryption(&kasumi_test_case_4);
6039 }
6040 
6041 static int
6042 test_kasumi_decryption_test_case_5(void)
6043 {
6044 	return test_kasumi_decryption(&kasumi_test_case_5);
6045 }
6046 static int
6047 test_snow3g_encryption_test_case_1(void)
6048 {
6049 	return test_snow3g_encryption(&snow3g_test_case_1);
6050 }
6051 
6052 static int
6053 test_snow3g_encryption_test_case_1_oop(void)
6054 {
6055 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
6056 }
6057 
6058 static int
6059 test_snow3g_encryption_test_case_1_oop_sgl(void)
6060 {
6061 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6062 }
6063 
6064 
6065 static int
6066 test_snow3g_encryption_test_case_1_offset_oop(void)
6067 {
6068 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6069 }
6070 
6071 static int
6072 test_snow3g_encryption_test_case_2(void)
6073 {
6074 	return test_snow3g_encryption(&snow3g_test_case_2);
6075 }
6076 
6077 static int
6078 test_snow3g_encryption_test_case_3(void)
6079 {
6080 	return test_snow3g_encryption(&snow3g_test_case_3);
6081 }
6082 
6083 static int
6084 test_snow3g_encryption_test_case_4(void)
6085 {
6086 	return test_snow3g_encryption(&snow3g_test_case_4);
6087 }
6088 
6089 static int
6090 test_snow3g_encryption_test_case_5(void)
6091 {
6092 	return test_snow3g_encryption(&snow3g_test_case_5);
6093 }
6094 
6095 static int
6096 test_snow3g_decryption_test_case_1(void)
6097 {
6098 	return test_snow3g_decryption(&snow3g_test_case_1);
6099 }
6100 
6101 static int
6102 test_snow3g_decryption_test_case_1_oop(void)
6103 {
6104 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
6105 }
6106 
6107 static int
6108 test_snow3g_decryption_test_case_2(void)
6109 {
6110 	return test_snow3g_decryption(&snow3g_test_case_2);
6111 }
6112 
6113 static int
6114 test_snow3g_decryption_test_case_3(void)
6115 {
6116 	return test_snow3g_decryption(&snow3g_test_case_3);
6117 }
6118 
6119 static int
6120 test_snow3g_decryption_test_case_4(void)
6121 {
6122 	return test_snow3g_decryption(&snow3g_test_case_4);
6123 }
6124 
6125 static int
6126 test_snow3g_decryption_test_case_5(void)
6127 {
6128 	return test_snow3g_decryption(&snow3g_test_case_5);
6129 }
6130 
6131 /*
6132  * Function prepares snow3g_hash_test_data from snow3g_test_data.
6133  * Pattern digest from snow3g_test_data must be allocated as
6134  * 4 last bytes in plaintext.
6135  */
6136 static void
6137 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6138 		struct snow3g_hash_test_data *output)
6139 {
6140 	if ((pattern != NULL) && (output != NULL)) {
6141 		output->key.len = pattern->key.len;
6142 
6143 		memcpy(output->key.data,
6144 		pattern->key.data, pattern->key.len);
6145 
6146 		output->auth_iv.len = pattern->auth_iv.len;
6147 
6148 		memcpy(output->auth_iv.data,
6149 		pattern->auth_iv.data, pattern->auth_iv.len);
6150 
6151 		output->plaintext.len = pattern->plaintext.len;
6152 
6153 		memcpy(output->plaintext.data,
6154 		pattern->plaintext.data, pattern->plaintext.len >> 3);
6155 
6156 		output->digest.len = pattern->digest.len;
6157 
6158 		memcpy(output->digest.data,
6159 		&pattern->plaintext.data[pattern->digest.offset_bytes],
6160 		pattern->digest.len);
6161 
6162 		output->validAuthLenInBits.len =
6163 		pattern->validAuthLenInBits.len;
6164 	}
6165 }
6166 
6167 /*
6168  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6169  */
6170 static int
6171 test_snow3g_decryption_with_digest_test_case_1(void)
6172 {
6173 	struct snow3g_hash_test_data snow3g_hash_data;
6174 
6175 	/*
6176 	 * Function prepare data for hash veryfication test case.
6177 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
6178 	 */
6179 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6180 
6181 	return test_snow3g_decryption(&snow3g_test_case_7) &
6182 			test_snow3g_authentication_verify(&snow3g_hash_data);
6183 }
6184 
6185 static int
6186 test_snow3g_cipher_auth_test_case_1(void)
6187 {
6188 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
6189 }
6190 
6191 static int
6192 test_snow3g_auth_cipher_test_case_1(void)
6193 {
6194 	return test_snow3g_auth_cipher(
6195 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6196 }
6197 
6198 static int
6199 test_snow3g_auth_cipher_test_case_2(void)
6200 {
6201 	return test_snow3g_auth_cipher(
6202 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6203 }
6204 
6205 static int
6206 test_snow3g_auth_cipher_test_case_2_oop(void)
6207 {
6208 	return test_snow3g_auth_cipher(
6209 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6210 }
6211 
6212 static int
6213 test_snow3g_auth_cipher_part_digest_enc(void)
6214 {
6215 	return test_snow3g_auth_cipher(
6216 		&snow3g_auth_cipher_partial_digest_encryption,
6217 			IN_PLACE, 0);
6218 }
6219 
6220 static int
6221 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6222 {
6223 	return test_snow3g_auth_cipher(
6224 		&snow3g_auth_cipher_partial_digest_encryption,
6225 			OUT_OF_PLACE, 0);
6226 }
6227 
6228 static int
6229 test_snow3g_auth_cipher_test_case_3_sgl(void)
6230 {
6231 	return test_snow3g_auth_cipher_sgl(
6232 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6233 }
6234 
6235 static int
6236 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6237 {
6238 	return test_snow3g_auth_cipher_sgl(
6239 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6240 }
6241 
6242 static int
6243 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6244 {
6245 	return test_snow3g_auth_cipher_sgl(
6246 		&snow3g_auth_cipher_partial_digest_encryption,
6247 			IN_PLACE, 0);
6248 }
6249 
6250 static int
6251 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6252 {
6253 	return test_snow3g_auth_cipher_sgl(
6254 		&snow3g_auth_cipher_partial_digest_encryption,
6255 			OUT_OF_PLACE, 0);
6256 }
6257 
6258 static int
6259 test_snow3g_auth_cipher_verify_test_case_1(void)
6260 {
6261 	return test_snow3g_auth_cipher(
6262 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6263 }
6264 
6265 static int
6266 test_snow3g_auth_cipher_verify_test_case_2(void)
6267 {
6268 	return test_snow3g_auth_cipher(
6269 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6270 }
6271 
6272 static int
6273 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6274 {
6275 	return test_snow3g_auth_cipher(
6276 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6277 }
6278 
6279 static int
6280 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6281 {
6282 	return test_snow3g_auth_cipher(
6283 		&snow3g_auth_cipher_partial_digest_encryption,
6284 			IN_PLACE, 1);
6285 }
6286 
6287 static int
6288 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6289 {
6290 	return test_snow3g_auth_cipher(
6291 		&snow3g_auth_cipher_partial_digest_encryption,
6292 			OUT_OF_PLACE, 1);
6293 }
6294 
6295 static int
6296 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6297 {
6298 	return test_snow3g_auth_cipher_sgl(
6299 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6300 }
6301 
6302 static int
6303 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6304 {
6305 	return test_snow3g_auth_cipher_sgl(
6306 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6307 }
6308 
6309 static int
6310 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6311 {
6312 	return test_snow3g_auth_cipher_sgl(
6313 		&snow3g_auth_cipher_partial_digest_encryption,
6314 			IN_PLACE, 1);
6315 }
6316 
6317 static int
6318 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6319 {
6320 	return test_snow3g_auth_cipher_sgl(
6321 		&snow3g_auth_cipher_partial_digest_encryption,
6322 			OUT_OF_PLACE, 1);
6323 }
6324 
6325 static int
6326 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6327 {
6328 	return test_snow3g_auth_cipher(
6329 		&snow3g_test_case_7, IN_PLACE, 0);
6330 }
6331 
6332 static int
6333 test_kasumi_auth_cipher_test_case_1(void)
6334 {
6335 	return test_kasumi_auth_cipher(
6336 		&kasumi_test_case_3, IN_PLACE, 0);
6337 }
6338 
6339 static int
6340 test_kasumi_auth_cipher_test_case_2(void)
6341 {
6342 	return test_kasumi_auth_cipher(
6343 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6344 }
6345 
6346 static int
6347 test_kasumi_auth_cipher_test_case_2_oop(void)
6348 {
6349 	return test_kasumi_auth_cipher(
6350 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6351 }
6352 
6353 static int
6354 test_kasumi_auth_cipher_test_case_2_sgl(void)
6355 {
6356 	return test_kasumi_auth_cipher_sgl(
6357 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6358 }
6359 
6360 static int
6361 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6362 {
6363 	return test_kasumi_auth_cipher_sgl(
6364 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6365 }
6366 
6367 static int
6368 test_kasumi_auth_cipher_verify_test_case_1(void)
6369 {
6370 	return test_kasumi_auth_cipher(
6371 		&kasumi_test_case_3, IN_PLACE, 1);
6372 }
6373 
6374 static int
6375 test_kasumi_auth_cipher_verify_test_case_2(void)
6376 {
6377 	return test_kasumi_auth_cipher(
6378 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6379 }
6380 
6381 static int
6382 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6383 {
6384 	return test_kasumi_auth_cipher(
6385 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6386 }
6387 
6388 static int
6389 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6390 {
6391 	return test_kasumi_auth_cipher_sgl(
6392 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6393 }
6394 
6395 static int
6396 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6397 {
6398 	return test_kasumi_auth_cipher_sgl(
6399 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6400 }
6401 
6402 static int
6403 test_kasumi_cipher_auth_test_case_1(void)
6404 {
6405 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
6406 }
6407 
6408 static int
6409 test_zuc_encryption_test_case_1(void)
6410 {
6411 	return test_zuc_encryption(&zuc_test_case_cipher_193b);
6412 }
6413 
6414 static int
6415 test_zuc_encryption_test_case_2(void)
6416 {
6417 	return test_zuc_encryption(&zuc_test_case_cipher_800b);
6418 }
6419 
6420 static int
6421 test_zuc_encryption_test_case_3(void)
6422 {
6423 	return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6424 }
6425 
6426 static int
6427 test_zuc_encryption_test_case_4(void)
6428 {
6429 	return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6430 }
6431 
6432 static int
6433 test_zuc_encryption_test_case_5(void)
6434 {
6435 	return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6436 }
6437 
6438 static int
6439 test_zuc_encryption_test_case_6_sgl(void)
6440 {
6441 	return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6442 }
6443 
6444 static int
6445 test_zuc_hash_generate_test_case_1(void)
6446 {
6447 	return test_zuc_authentication(&zuc_test_case_auth_1b);
6448 }
6449 
6450 static int
6451 test_zuc_hash_generate_test_case_2(void)
6452 {
6453 	return test_zuc_authentication(&zuc_test_case_auth_90b);
6454 }
6455 
6456 static int
6457 test_zuc_hash_generate_test_case_3(void)
6458 {
6459 	return test_zuc_authentication(&zuc_test_case_auth_577b);
6460 }
6461 
6462 static int
6463 test_zuc_hash_generate_test_case_4(void)
6464 {
6465 	return test_zuc_authentication(&zuc_test_case_auth_2079b);
6466 }
6467 
6468 static int
6469 test_zuc_hash_generate_test_case_5(void)
6470 {
6471 	return test_zuc_authentication(&zuc_test_auth_5670b);
6472 }
6473 
6474 static int
6475 test_zuc_hash_generate_test_case_6(void)
6476 {
6477 	return test_zuc_authentication(&zuc_test_case_auth_128b);
6478 }
6479 
6480 static int
6481 test_zuc_hash_generate_test_case_7(void)
6482 {
6483 	return test_zuc_authentication(&zuc_test_case_auth_2080b);
6484 }
6485 
6486 static int
6487 test_zuc_hash_generate_test_case_8(void)
6488 {
6489 	return test_zuc_authentication(&zuc_test_case_auth_584b);
6490 }
6491 
6492 static int
6493 test_zuc_cipher_auth_test_case_1(void)
6494 {
6495 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6496 }
6497 
6498 static int
6499 test_zuc_cipher_auth_test_case_2(void)
6500 {
6501 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6502 }
6503 
6504 static int
6505 test_zuc_auth_cipher_test_case_1(void)
6506 {
6507 	return test_zuc_auth_cipher(
6508 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6509 }
6510 
6511 static int
6512 test_zuc_auth_cipher_test_case_1_oop(void)
6513 {
6514 	return test_zuc_auth_cipher(
6515 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6516 }
6517 
6518 static int
6519 test_zuc_auth_cipher_test_case_1_sgl(void)
6520 {
6521 	return test_zuc_auth_cipher_sgl(
6522 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6523 }
6524 
6525 static int
6526 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6527 {
6528 	return test_zuc_auth_cipher_sgl(
6529 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6530 }
6531 
6532 static int
6533 test_zuc_auth_cipher_verify_test_case_1(void)
6534 {
6535 	return test_zuc_auth_cipher(
6536 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6537 }
6538 
6539 static int
6540 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6541 {
6542 	return test_zuc_auth_cipher(
6543 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6544 }
6545 
6546 static int
6547 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6548 {
6549 	return test_zuc_auth_cipher_sgl(
6550 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6551 }
6552 
6553 static int
6554 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6555 {
6556 	return test_zuc_auth_cipher_sgl(
6557 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6558 }
6559 
6560 static int
6561 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6562 {
6563 	uint8_t dev_id = testsuite_params.valid_devs[0];
6564 
6565 	struct rte_cryptodev_sym_capability_idx cap_idx;
6566 
6567 	/* Check if device supports particular cipher algorithm */
6568 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6569 	cap_idx.algo.cipher = tdata->cipher_algo;
6570 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6571 		return -ENOTSUP;
6572 
6573 	/* Check if device supports particular hash algorithm */
6574 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6575 	cap_idx.algo.auth = tdata->auth_algo;
6576 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6577 		return -ENOTSUP;
6578 
6579 	return 0;
6580 }
6581 
6582 static int
6583 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6584 	uint8_t op_mode, uint8_t verify)
6585 {
6586 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6587 	struct crypto_unittest_params *ut_params = &unittest_params;
6588 
6589 	int retval;
6590 
6591 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6592 	unsigned int plaintext_pad_len;
6593 	unsigned int plaintext_len;
6594 	unsigned int ciphertext_pad_len;
6595 	unsigned int ciphertext_len;
6596 
6597 	struct rte_cryptodev_info dev_info;
6598 
6599 	/* Check if device supports particular algorithms */
6600 	if (test_mixed_check_if_unsupported(tdata))
6601 		return -ENOTSUP;
6602 
6603 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6604 
6605 	uint64_t feat_flags = dev_info.feature_flags;
6606 
6607 	if (op_mode == OUT_OF_PLACE) {
6608 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6609 			printf("Device doesn't support digest encrypted.\n");
6610 			return -ENOTSUP;
6611 		}
6612 	}
6613 
6614 	/* Create the session */
6615 	retval = create_wireless_algo_auth_cipher_session(
6616 			ts_params->valid_devs[0],
6617 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6618 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6619 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6620 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6621 			tdata->auth_algo,
6622 			tdata->cipher_algo,
6623 			tdata->auth_key.data, tdata->auth_key.len,
6624 			tdata->auth_iv.len, tdata->digest_enc.len,
6625 			tdata->cipher_iv.len);
6626 
6627 	if (retval < 0)
6628 		return retval;
6629 
6630 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6631 	if (op_mode == OUT_OF_PLACE)
6632 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6633 
6634 	/* clear mbuf payload */
6635 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6636 		rte_pktmbuf_tailroom(ut_params->ibuf));
6637 	if (op_mode == OUT_OF_PLACE)
6638 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6639 				rte_pktmbuf_tailroom(ut_params->obuf));
6640 
6641 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6642 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6643 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6644 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6645 
6646 	if (verify) {
6647 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6648 				ciphertext_pad_len);
6649 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6650 		if (op_mode == OUT_OF_PLACE)
6651 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6652 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6653 				ciphertext_len);
6654 	} else {
6655 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6656 				plaintext_pad_len);
6657 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6658 		if (op_mode == OUT_OF_PLACE)
6659 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6660 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6661 	}
6662 
6663 	/* Create the operation */
6664 	retval = create_wireless_algo_auth_cipher_operation(
6665 			tdata->digest_enc.data, tdata->digest_enc.len,
6666 			tdata->cipher_iv.data, tdata->cipher_iv.len,
6667 			tdata->auth_iv.data, tdata->auth_iv.len,
6668 			(tdata->digest_enc.offset == 0 ?
6669 			(verify ? ciphertext_pad_len : plaintext_pad_len)
6670 				: tdata->digest_enc.offset),
6671 			tdata->validCipherLen.len_bits,
6672 			tdata->cipher.offset_bits,
6673 			tdata->validAuthLen.len_bits,
6674 			tdata->auth.offset_bits,
6675 			op_mode, 0, verify);
6676 
6677 	if (retval < 0)
6678 		return retval;
6679 
6680 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6681 			ut_params->op);
6682 
6683 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6684 
6685 	ut_params->obuf = (op_mode == IN_PLACE ?
6686 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6687 
6688 	if (verify) {
6689 		if (ut_params->obuf)
6690 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6691 							uint8_t *);
6692 		else
6693 			plaintext = ciphertext +
6694 					(tdata->cipher.offset_bits >> 3);
6695 
6696 		debug_hexdump(stdout, "plaintext:", plaintext,
6697 				(tdata->plaintext.len_bits >> 3) -
6698 				tdata->digest_enc.len);
6699 		debug_hexdump(stdout, "plaintext expected:",
6700 				tdata->plaintext.data,
6701 				(tdata->plaintext.len_bits >> 3) -
6702 				tdata->digest_enc.len);
6703 	} else {
6704 		if (ut_params->obuf)
6705 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6706 					uint8_t *);
6707 		else
6708 			ciphertext = plaintext;
6709 
6710 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6711 				ciphertext_len);
6712 		debug_hexdump(stdout, "ciphertext expected:",
6713 				tdata->ciphertext.data,
6714 				tdata->ciphertext.len_bits >> 3);
6715 
6716 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6717 				+ (tdata->digest_enc.offset == 0 ?
6718 		plaintext_pad_len : tdata->digest_enc.offset);
6719 
6720 		debug_hexdump(stdout, "digest:", ut_params->digest,
6721 				tdata->digest_enc.len);
6722 		debug_hexdump(stdout, "digest expected:",
6723 				tdata->digest_enc.data,
6724 				tdata->digest_enc.len);
6725 	}
6726 
6727 	/* Validate obuf */
6728 	if (verify) {
6729 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6730 				plaintext,
6731 				tdata->plaintext.data,
6732 				tdata->plaintext.len_bits >> 3,
6733 				"Plaintext data not as expected");
6734 	} else {
6735 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6736 				ciphertext,
6737 				tdata->ciphertext.data,
6738 				tdata->validDataLen.len_bits,
6739 				"Ciphertext data not as expected");
6740 
6741 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6742 				ut_params->digest,
6743 				tdata->digest_enc.data,
6744 				DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6745 				"Generated auth tag not as expected");
6746 	}
6747 	return 0;
6748 }
6749 
6750 static int
6751 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6752 	uint8_t op_mode, uint8_t verify)
6753 {
6754 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6755 	struct crypto_unittest_params *ut_params = &unittest_params;
6756 
6757 	int retval;
6758 
6759 	const uint8_t *plaintext = NULL;
6760 	const uint8_t *ciphertext = NULL;
6761 	const uint8_t *digest = NULL;
6762 	unsigned int plaintext_pad_len;
6763 	unsigned int plaintext_len;
6764 	unsigned int ciphertext_pad_len;
6765 	unsigned int ciphertext_len;
6766 	uint8_t buffer[10000];
6767 	uint8_t digest_buffer[10000];
6768 
6769 	struct rte_cryptodev_info dev_info;
6770 
6771 	/* Check if device supports particular algorithms */
6772 	if (test_mixed_check_if_unsupported(tdata))
6773 		return -ENOTSUP;
6774 
6775 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6776 
6777 	uint64_t feat_flags = dev_info.feature_flags;
6778 
6779 	if (op_mode == IN_PLACE) {
6780 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6781 			printf("Device doesn't support in-place scatter-gather "
6782 					"in both input and output mbufs.\n");
6783 			return -ENOTSUP;
6784 		}
6785 	} else {
6786 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6787 			printf("Device doesn't support out-of-place scatter-gather "
6788 					"in both input and output mbufs.\n");
6789 			return -ENOTSUP;
6790 		}
6791 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6792 			printf("Device doesn't support digest encrypted.\n");
6793 			return -ENOTSUP;
6794 		}
6795 	}
6796 
6797 	/* Create the session */
6798 	retval = create_wireless_algo_auth_cipher_session(
6799 			ts_params->valid_devs[0],
6800 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6801 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6802 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6803 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6804 			tdata->auth_algo,
6805 			tdata->cipher_algo,
6806 			tdata->auth_key.data, tdata->auth_key.len,
6807 			tdata->auth_iv.len, tdata->digest_enc.len,
6808 			tdata->cipher_iv.len);
6809 
6810 	if (retval < 0)
6811 		return retval;
6812 
6813 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6814 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6815 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6816 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6817 
6818 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6819 			plaintext_pad_len, 15, 0);
6820 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6821 			"Failed to allocate input buffer in mempool");
6822 
6823 	if (op_mode == OUT_OF_PLACE) {
6824 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6825 				plaintext_pad_len, 15, 0);
6826 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6827 				"Failed to allocate output buffer in mempool");
6828 	}
6829 
6830 	if (verify) {
6831 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6832 			tdata->ciphertext.data);
6833 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6834 					ciphertext_len, buffer);
6835 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6836 			ciphertext_len);
6837 	} else {
6838 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6839 			tdata->plaintext.data);
6840 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6841 					plaintext_len, buffer);
6842 		debug_hexdump(stdout, "plaintext:", plaintext,
6843 			plaintext_len);
6844 	}
6845 	memset(buffer, 0, sizeof(buffer));
6846 
6847 	/* Create the operation */
6848 	retval = create_wireless_algo_auth_cipher_operation(
6849 			tdata->digest_enc.data, tdata->digest_enc.len,
6850 			tdata->cipher_iv.data, tdata->cipher_iv.len,
6851 			tdata->auth_iv.data, tdata->auth_iv.len,
6852 			(tdata->digest_enc.offset == 0 ?
6853 			(verify ? ciphertext_pad_len : plaintext_pad_len)
6854 				: tdata->digest_enc.offset),
6855 			tdata->validCipherLen.len_bits,
6856 			tdata->cipher.offset_bits,
6857 			tdata->validAuthLen.len_bits,
6858 			tdata->auth.offset_bits,
6859 			op_mode, 1, verify);
6860 
6861 	if (retval < 0)
6862 		return retval;
6863 
6864 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6865 			ut_params->op);
6866 
6867 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6868 
6869 	ut_params->obuf = (op_mode == IN_PLACE ?
6870 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6871 
6872 	if (verify) {
6873 		if (ut_params->obuf)
6874 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6875 					plaintext_len, buffer);
6876 		else
6877 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6878 					plaintext_len, buffer);
6879 
6880 		debug_hexdump(stdout, "plaintext:", plaintext,
6881 				(tdata->plaintext.len_bits >> 3) -
6882 				tdata->digest_enc.len);
6883 		debug_hexdump(stdout, "plaintext expected:",
6884 				tdata->plaintext.data,
6885 				(tdata->plaintext.len_bits >> 3) -
6886 				tdata->digest_enc.len);
6887 	} else {
6888 		if (ut_params->obuf)
6889 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6890 					ciphertext_len, buffer);
6891 		else
6892 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6893 					ciphertext_len, buffer);
6894 
6895 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6896 			ciphertext_len);
6897 		debug_hexdump(stdout, "ciphertext expected:",
6898 			tdata->ciphertext.data,
6899 			tdata->ciphertext.len_bits >> 3);
6900 
6901 		if (ut_params->obuf)
6902 			digest = rte_pktmbuf_read(ut_params->obuf,
6903 					(tdata->digest_enc.offset == 0 ?
6904 						plaintext_pad_len :
6905 						tdata->digest_enc.offset),
6906 					tdata->digest_enc.len, digest_buffer);
6907 		else
6908 			digest = rte_pktmbuf_read(ut_params->ibuf,
6909 					(tdata->digest_enc.offset == 0 ?
6910 						plaintext_pad_len :
6911 						tdata->digest_enc.offset),
6912 					tdata->digest_enc.len, digest_buffer);
6913 
6914 		debug_hexdump(stdout, "digest:", digest,
6915 				tdata->digest_enc.len);
6916 		debug_hexdump(stdout, "digest expected:",
6917 				tdata->digest_enc.data, tdata->digest_enc.len);
6918 	}
6919 
6920 	/* Validate obuf */
6921 	if (verify) {
6922 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6923 				plaintext,
6924 				tdata->plaintext.data,
6925 				tdata->plaintext.len_bits >> 3,
6926 				"Plaintext data not as expected");
6927 	} else {
6928 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6929 				ciphertext,
6930 				tdata->ciphertext.data,
6931 				tdata->validDataLen.len_bits,
6932 				"Ciphertext data not as expected");
6933 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6934 				digest,
6935 				tdata->digest_enc.data,
6936 				tdata->digest_enc.len,
6937 				"Generated auth tag not as expected");
6938 	}
6939 	return 0;
6940 }
6941 
6942 /** AUTH AES CMAC + CIPHER AES CTR */
6943 
6944 static int
6945 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6946 {
6947 	return test_mixed_auth_cipher(
6948 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6949 }
6950 
6951 static int
6952 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6953 {
6954 	return test_mixed_auth_cipher(
6955 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6956 }
6957 
6958 static int
6959 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6960 {
6961 	return test_mixed_auth_cipher_sgl(
6962 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6963 }
6964 
6965 static int
6966 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6967 {
6968 	return test_mixed_auth_cipher_sgl(
6969 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6970 }
6971 
6972 static int
6973 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6974 {
6975 	return test_mixed_auth_cipher(
6976 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6977 }
6978 
6979 static int
6980 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6981 {
6982 	return test_mixed_auth_cipher(
6983 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6984 }
6985 
6986 static int
6987 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6988 {
6989 	return test_mixed_auth_cipher_sgl(
6990 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6991 }
6992 
6993 static int
6994 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6995 {
6996 	return test_mixed_auth_cipher_sgl(
6997 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6998 }
6999 
7000 static int
7001 test_3DES_chain_qat_all(void)
7002 {
7003 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7004 	int status;
7005 
7006 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7007 		ts_params->op_mpool,
7008 		ts_params->session_mpool, ts_params->session_priv_mpool,
7009 		ts_params->valid_devs[0],
7010 		rte_cryptodev_driver_id_get(
7011 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7012 		BLKCIPHER_3DES_CHAIN_TYPE);
7013 
7014 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7015 
7016 	return TEST_SUCCESS;
7017 }
7018 
7019 static int
7020 test_DES_cipheronly_qat_all(void)
7021 {
7022 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7023 	int status;
7024 
7025 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7026 		ts_params->op_mpool,
7027 		ts_params->session_mpool, ts_params->session_priv_mpool,
7028 		ts_params->valid_devs[0],
7029 		rte_cryptodev_driver_id_get(
7030 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7031 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7032 
7033 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7034 
7035 	return TEST_SUCCESS;
7036 }
7037 
7038 static int
7039 test_DES_cipheronly_openssl_all(void)
7040 {
7041 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7042 	int status;
7043 
7044 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7045 		ts_params->op_mpool,
7046 		ts_params->session_mpool, ts_params->session_priv_mpool,
7047 		ts_params->valid_devs[0],
7048 		rte_cryptodev_driver_id_get(
7049 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7050 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7051 
7052 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7053 
7054 	return TEST_SUCCESS;
7055 }
7056 
7057 static int
7058 test_DES_docsis_openssl_all(void)
7059 {
7060 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7061 	int status;
7062 
7063 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7064 		ts_params->op_mpool,
7065 		ts_params->session_mpool, ts_params->session_priv_mpool,
7066 		ts_params->valid_devs[0],
7067 		rte_cryptodev_driver_id_get(
7068 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7069 		BLKCIPHER_DES_DOCSIS_TYPE);
7070 
7071 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7072 
7073 	return TEST_SUCCESS;
7074 }
7075 
7076 static int
7077 test_DES_cipheronly_mb_all(void)
7078 {
7079 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7080 	int status;
7081 
7082 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7083 		ts_params->op_mpool,
7084 		ts_params->session_mpool, ts_params->session_priv_mpool,
7085 		ts_params->valid_devs[0],
7086 		rte_cryptodev_driver_id_get(
7087 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7088 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7089 
7090 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7091 
7092 	return TEST_SUCCESS;
7093 }
7094 static int
7095 test_3DES_cipheronly_mb_all(void)
7096 {
7097 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7098 	int status;
7099 
7100 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7101 		ts_params->op_mpool,
7102 		ts_params->session_mpool, ts_params->session_priv_mpool,
7103 		ts_params->valid_devs[0],
7104 		rte_cryptodev_driver_id_get(
7105 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7106 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7107 
7108 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7109 
7110 	return TEST_SUCCESS;
7111 }
7112 
7113 static int
7114 test_DES_docsis_mb_all(void)
7115 {
7116 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7117 	int status;
7118 
7119 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7120 		ts_params->op_mpool,
7121 		ts_params->session_mpool, ts_params->session_priv_mpool,
7122 		ts_params->valid_devs[0],
7123 		rte_cryptodev_driver_id_get(
7124 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7125 		BLKCIPHER_DES_DOCSIS_TYPE);
7126 
7127 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7128 
7129 	return TEST_SUCCESS;
7130 }
7131 
7132 static int
7133 test_3DES_chain_caam_jr_all(void)
7134 {
7135 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7136 	int status;
7137 
7138 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7139 		ts_params->op_mpool,
7140 		ts_params->session_mpool, ts_params->session_priv_mpool,
7141 		ts_params->valid_devs[0],
7142 		rte_cryptodev_driver_id_get(
7143 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7144 		BLKCIPHER_3DES_CHAIN_TYPE);
7145 
7146 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7147 
7148 	return TEST_SUCCESS;
7149 }
7150 
7151 static int
7152 test_3DES_cipheronly_caam_jr_all(void)
7153 {
7154 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7155 	int status;
7156 
7157 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7158 		ts_params->op_mpool,
7159 		ts_params->session_mpool, ts_params->session_priv_mpool,
7160 		ts_params->valid_devs[0],
7161 		rte_cryptodev_driver_id_get(
7162 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7163 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7164 
7165 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7166 
7167 	return TEST_SUCCESS;
7168 }
7169 
7170 static int
7171 test_3DES_chain_dpaa_sec_all(void)
7172 {
7173 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7174 	int status;
7175 
7176 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7177 		ts_params->op_mpool,
7178 		ts_params->session_mpool, ts_params->session_priv_mpool,
7179 		ts_params->valid_devs[0],
7180 		rte_cryptodev_driver_id_get(
7181 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7182 		BLKCIPHER_3DES_CHAIN_TYPE);
7183 
7184 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7185 
7186 	return TEST_SUCCESS;
7187 }
7188 
7189 static int
7190 test_3DES_cipheronly_dpaa_sec_all(void)
7191 {
7192 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7193 	int status;
7194 
7195 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7196 		ts_params->op_mpool,
7197 		ts_params->session_mpool, ts_params->session_priv_mpool,
7198 		ts_params->valid_devs[0],
7199 		rte_cryptodev_driver_id_get(
7200 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7201 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7202 
7203 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7204 
7205 	return TEST_SUCCESS;
7206 }
7207 
7208 static int
7209 test_3DES_chain_dpaa2_sec_all(void)
7210 {
7211 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7212 	int status;
7213 
7214 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7215 		ts_params->op_mpool,
7216 		ts_params->session_mpool, ts_params->session_priv_mpool,
7217 		ts_params->valid_devs[0],
7218 		rte_cryptodev_driver_id_get(
7219 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7220 		BLKCIPHER_3DES_CHAIN_TYPE);
7221 
7222 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7223 
7224 	return TEST_SUCCESS;
7225 }
7226 
7227 static int
7228 test_3DES_cipheronly_dpaa2_sec_all(void)
7229 {
7230 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7231 	int status;
7232 
7233 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7234 		ts_params->op_mpool,
7235 		ts_params->session_mpool, ts_params->session_priv_mpool,
7236 		ts_params->valid_devs[0],
7237 		rte_cryptodev_driver_id_get(
7238 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7239 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7240 
7241 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7242 
7243 	return TEST_SUCCESS;
7244 }
7245 
7246 static int
7247 test_3DES_chain_ccp_all(void)
7248 {
7249 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7250 	int status;
7251 
7252 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7253 		ts_params->op_mpool,
7254 		ts_params->session_mpool, ts_params->session_priv_mpool,
7255 		ts_params->valid_devs[0],
7256 		rte_cryptodev_driver_id_get(
7257 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7258 		BLKCIPHER_3DES_CHAIN_TYPE);
7259 
7260 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7261 
7262 	return TEST_SUCCESS;
7263 }
7264 
7265 static int
7266 test_3DES_cipheronly_ccp_all(void)
7267 {
7268 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7269 	int status;
7270 
7271 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7272 		ts_params->op_mpool,
7273 		ts_params->session_mpool, ts_params->session_priv_mpool,
7274 		ts_params->valid_devs[0],
7275 		rte_cryptodev_driver_id_get(
7276 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7277 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7278 
7279 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7280 
7281 	return TEST_SUCCESS;
7282 }
7283 
7284 static int
7285 test_3DES_cipheronly_qat_all(void)
7286 {
7287 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7288 	int status;
7289 
7290 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7291 		ts_params->op_mpool,
7292 		ts_params->session_mpool, ts_params->session_priv_mpool,
7293 		ts_params->valid_devs[0],
7294 		rte_cryptodev_driver_id_get(
7295 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7296 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7297 
7298 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7299 
7300 	return TEST_SUCCESS;
7301 }
7302 
7303 static int
7304 test_3DES_chain_openssl_all(void)
7305 {
7306 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7307 	int status;
7308 
7309 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7310 		ts_params->op_mpool,
7311 		ts_params->session_mpool, ts_params->session_priv_mpool,
7312 		ts_params->valid_devs[0],
7313 		rte_cryptodev_driver_id_get(
7314 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7315 		BLKCIPHER_3DES_CHAIN_TYPE);
7316 
7317 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7318 
7319 	return TEST_SUCCESS;
7320 }
7321 
7322 static int
7323 test_3DES_cipheronly_openssl_all(void)
7324 {
7325 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7326 	int status;
7327 
7328 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7329 		ts_params->op_mpool,
7330 		ts_params->session_mpool, ts_params->session_priv_mpool,
7331 		ts_params->valid_devs[0],
7332 		rte_cryptodev_driver_id_get(
7333 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7334 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7335 
7336 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7337 
7338 	return TEST_SUCCESS;
7339 }
7340 
7341 /* ***** AEAD algorithm Tests ***** */
7342 
7343 static int
7344 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7345 		enum rte_crypto_aead_operation op,
7346 		const uint8_t *key, const uint8_t key_len,
7347 		const uint16_t aad_len, const uint8_t auth_len,
7348 		uint8_t iv_len)
7349 {
7350 	uint8_t aead_key[key_len];
7351 
7352 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7353 	struct crypto_unittest_params *ut_params = &unittest_params;
7354 
7355 	memcpy(aead_key, key, key_len);
7356 
7357 	/* Setup AEAD Parameters */
7358 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7359 	ut_params->aead_xform.next = NULL;
7360 	ut_params->aead_xform.aead.algo = algo;
7361 	ut_params->aead_xform.aead.op = op;
7362 	ut_params->aead_xform.aead.key.data = aead_key;
7363 	ut_params->aead_xform.aead.key.length = key_len;
7364 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7365 	ut_params->aead_xform.aead.iv.length = iv_len;
7366 	ut_params->aead_xform.aead.digest_length = auth_len;
7367 	ut_params->aead_xform.aead.aad_length = aad_len;
7368 
7369 	debug_hexdump(stdout, "key:", key, key_len);
7370 
7371 	/* Create Crypto session*/
7372 	ut_params->sess = rte_cryptodev_sym_session_create(
7373 			ts_params->session_mpool);
7374 
7375 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7376 			&ut_params->aead_xform,
7377 			ts_params->session_priv_mpool);
7378 
7379 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7380 
7381 	return 0;
7382 }
7383 
7384 static int
7385 create_aead_xform(struct rte_crypto_op *op,
7386 		enum rte_crypto_aead_algorithm algo,
7387 		enum rte_crypto_aead_operation aead_op,
7388 		uint8_t *key, const uint8_t key_len,
7389 		const uint8_t aad_len, const uint8_t auth_len,
7390 		uint8_t iv_len)
7391 {
7392 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7393 			"failed to allocate space for crypto transform");
7394 
7395 	struct rte_crypto_sym_op *sym_op = op->sym;
7396 
7397 	/* Setup AEAD Parameters */
7398 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7399 	sym_op->xform->next = NULL;
7400 	sym_op->xform->aead.algo = algo;
7401 	sym_op->xform->aead.op = aead_op;
7402 	sym_op->xform->aead.key.data = key;
7403 	sym_op->xform->aead.key.length = key_len;
7404 	sym_op->xform->aead.iv.offset = IV_OFFSET;
7405 	sym_op->xform->aead.iv.length = iv_len;
7406 	sym_op->xform->aead.digest_length = auth_len;
7407 	sym_op->xform->aead.aad_length = aad_len;
7408 
7409 	debug_hexdump(stdout, "key:", key, key_len);
7410 
7411 	return 0;
7412 }
7413 
7414 static int
7415 create_aead_operation(enum rte_crypto_aead_operation op,
7416 		const struct aead_test_data *tdata)
7417 {
7418 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7419 	struct crypto_unittest_params *ut_params = &unittest_params;
7420 
7421 	uint8_t *plaintext, *ciphertext;
7422 	unsigned int aad_pad_len, plaintext_pad_len;
7423 
7424 	/* Generate Crypto op data structure */
7425 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7426 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7427 	TEST_ASSERT_NOT_NULL(ut_params->op,
7428 			"Failed to allocate symmetric crypto operation struct");
7429 
7430 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7431 
7432 	/* Append aad data */
7433 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7434 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7435 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7436 				aad_pad_len);
7437 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7438 				"no room to append aad");
7439 
7440 		sym_op->aead.aad.phys_addr =
7441 				rte_pktmbuf_iova(ut_params->ibuf);
7442 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
7443 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7444 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7445 			tdata->aad.len);
7446 
7447 		/* Append IV at the end of the crypto operation*/
7448 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7449 				uint8_t *, IV_OFFSET);
7450 
7451 		/* Copy IV 1 byte after the IV pointer, according to the API */
7452 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7453 		debug_hexdump(stdout, "iv:", iv_ptr,
7454 			tdata->iv.len);
7455 	} else {
7456 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7457 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7458 				aad_pad_len);
7459 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7460 				"no room to append aad");
7461 
7462 		sym_op->aead.aad.phys_addr =
7463 				rte_pktmbuf_iova(ut_params->ibuf);
7464 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7465 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7466 			tdata->aad.len);
7467 
7468 		/* Append IV at the end of the crypto operation*/
7469 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7470 				uint8_t *, IV_OFFSET);
7471 
7472 		rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7473 		debug_hexdump(stdout, "iv:", iv_ptr,
7474 			tdata->iv.len);
7475 	}
7476 
7477 	/* Append plaintext/ciphertext */
7478 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7479 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7480 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7481 				plaintext_pad_len);
7482 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7483 
7484 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7485 		debug_hexdump(stdout, "plaintext:", plaintext,
7486 				tdata->plaintext.len);
7487 
7488 		if (ut_params->obuf) {
7489 			ciphertext = (uint8_t *)rte_pktmbuf_append(
7490 					ut_params->obuf,
7491 					plaintext_pad_len + aad_pad_len);
7492 			TEST_ASSERT_NOT_NULL(ciphertext,
7493 					"no room to append ciphertext");
7494 
7495 			memset(ciphertext + aad_pad_len, 0,
7496 					tdata->ciphertext.len);
7497 		}
7498 	} else {
7499 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7500 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7501 				plaintext_pad_len);
7502 		TEST_ASSERT_NOT_NULL(ciphertext,
7503 				"no room to append ciphertext");
7504 
7505 		memcpy(ciphertext, tdata->ciphertext.data,
7506 				tdata->ciphertext.len);
7507 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7508 				tdata->ciphertext.len);
7509 
7510 		if (ut_params->obuf) {
7511 			plaintext = (uint8_t *)rte_pktmbuf_append(
7512 					ut_params->obuf,
7513 					plaintext_pad_len + aad_pad_len);
7514 			TEST_ASSERT_NOT_NULL(plaintext,
7515 					"no room to append plaintext");
7516 
7517 			memset(plaintext + aad_pad_len, 0,
7518 					tdata->plaintext.len);
7519 		}
7520 	}
7521 
7522 	/* Append digest data */
7523 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7524 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7525 				ut_params->obuf ? ut_params->obuf :
7526 						ut_params->ibuf,
7527 						tdata->auth_tag.len);
7528 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7529 				"no room to append digest");
7530 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7531 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7532 				ut_params->obuf ? ut_params->obuf :
7533 						ut_params->ibuf,
7534 						plaintext_pad_len +
7535 						aad_pad_len);
7536 	} else {
7537 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7538 				ut_params->ibuf, tdata->auth_tag.len);
7539 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7540 				"no room to append digest");
7541 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7542 				ut_params->ibuf,
7543 				plaintext_pad_len + aad_pad_len);
7544 
7545 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7546 			tdata->auth_tag.len);
7547 		debug_hexdump(stdout, "digest:",
7548 			sym_op->aead.digest.data,
7549 			tdata->auth_tag.len);
7550 	}
7551 
7552 	sym_op->aead.data.length = tdata->plaintext.len;
7553 	sym_op->aead.data.offset = aad_pad_len;
7554 
7555 	return 0;
7556 }
7557 
7558 static int
7559 test_authenticated_encryption(const struct aead_test_data *tdata)
7560 {
7561 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7562 	struct crypto_unittest_params *ut_params = &unittest_params;
7563 
7564 	int retval;
7565 	uint8_t *ciphertext, *auth_tag;
7566 	uint16_t plaintext_pad_len;
7567 	uint32_t i;
7568 
7569 	/* Create AEAD session */
7570 	retval = create_aead_session(ts_params->valid_devs[0],
7571 			tdata->algo,
7572 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
7573 			tdata->key.data, tdata->key.len,
7574 			tdata->aad.len, tdata->auth_tag.len,
7575 			tdata->iv.len);
7576 	if (retval < 0)
7577 		return retval;
7578 
7579 	if (tdata->aad.len > MBUF_SIZE) {
7580 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7581 		/* Populate full size of add data */
7582 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7583 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7584 	} else
7585 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7586 
7587 	/* clear mbuf payload */
7588 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7589 			rte_pktmbuf_tailroom(ut_params->ibuf));
7590 
7591 	/* Create AEAD operation */
7592 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7593 	if (retval < 0)
7594 		return retval;
7595 
7596 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7597 
7598 	ut_params->op->sym->m_src = ut_params->ibuf;
7599 
7600 	/* Process crypto operation */
7601 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7602 			ut_params->op), "failed to process sym crypto op");
7603 
7604 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7605 			"crypto op processing failed");
7606 
7607 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7608 
7609 	if (ut_params->op->sym->m_dst) {
7610 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7611 				uint8_t *);
7612 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7613 				uint8_t *, plaintext_pad_len);
7614 	} else {
7615 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7616 				uint8_t *,
7617 				ut_params->op->sym->cipher.data.offset);
7618 		auth_tag = ciphertext + plaintext_pad_len;
7619 	}
7620 
7621 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7622 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7623 
7624 	/* Validate obuf */
7625 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7626 			ciphertext,
7627 			tdata->ciphertext.data,
7628 			tdata->ciphertext.len,
7629 			"Ciphertext data not as expected");
7630 
7631 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7632 			auth_tag,
7633 			tdata->auth_tag.data,
7634 			tdata->auth_tag.len,
7635 			"Generated auth tag not as expected");
7636 
7637 	return 0;
7638 
7639 }
7640 
7641 #ifdef RTE_LIBRTE_SECURITY
7642 /* Basic algorithm run function for async inplace mode.
7643  * Creates a session from input parameters and runs one operation
7644  * on input_vec. Checks the output of the crypto operation against
7645  * output_vec.
7646  */
7647 static int
7648 test_pdcp_proto(int i, int oop,
7649 	enum rte_crypto_cipher_operation opc,
7650 	enum rte_crypto_auth_operation opa,
7651 	uint8_t *input_vec,
7652 	unsigned int input_vec_len,
7653 	uint8_t *output_vec,
7654 	unsigned int output_vec_len)
7655 {
7656 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7657 	struct crypto_unittest_params *ut_params = &unittest_params;
7658 	uint8_t *plaintext;
7659 	int ret = TEST_SUCCESS;
7660 
7661 	/* Generate test mbuf data */
7662 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7663 
7664 	/* clear mbuf payload */
7665 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7666 			rte_pktmbuf_tailroom(ut_params->ibuf));
7667 
7668 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7669 						  input_vec_len);
7670 	memcpy(plaintext, input_vec, input_vec_len);
7671 
7672 	/* Out of place support */
7673 	if (oop) {
7674 		/*
7675 		 * For out-op-place we need to alloc another mbuf
7676 		 */
7677 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7678 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7679 	}
7680 
7681 	/* Set crypto type as IPSEC */
7682 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7683 
7684 	/* Setup Cipher Parameters */
7685 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7686 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7687 	ut_params->cipher_xform.cipher.op = opc;
7688 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7689 	ut_params->cipher_xform.cipher.key.length =
7690 					pdcp_test_params[i].cipher_key_len;
7691 	ut_params->cipher_xform.cipher.iv.length = 0;
7692 
7693 	/* Setup HMAC Parameters if ICV header is required */
7694 	if (pdcp_test_params[i].auth_alg != 0) {
7695 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7696 		ut_params->auth_xform.next = NULL;
7697 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7698 		ut_params->auth_xform.auth.op = opa;
7699 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7700 		ut_params->auth_xform.auth.key.length =
7701 					pdcp_test_params[i].auth_key_len;
7702 
7703 		ut_params->cipher_xform.next = &ut_params->auth_xform;
7704 	} else {
7705 		ut_params->cipher_xform.next = NULL;
7706 	}
7707 
7708 	struct rte_security_session_conf sess_conf = {
7709 		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7710 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
7711 		{.pdcp = {
7712 			.bearer = pdcp_test_bearer[i],
7713 			.domain = pdcp_test_params[i].domain,
7714 			.pkt_dir = pdcp_test_packet_direction[i],
7715 			.sn_size = pdcp_test_data_sn_size[i],
7716 			.hfn = pdcp_test_hfn[i],
7717 			.hfn_threshold = pdcp_test_hfn_threshold[i],
7718 		} },
7719 		.crypto_xform = &ut_params->cipher_xform
7720 	};
7721 
7722 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7723 				rte_cryptodev_get_sec_ctx(
7724 				ts_params->valid_devs[0]);
7725 
7726 	/* Create security session */
7727 	ut_params->sec_session = rte_security_session_create(ctx,
7728 				&sess_conf, ts_params->session_priv_mpool);
7729 
7730 	if (!ut_params->sec_session) {
7731 		printf("TestCase %s()-%d line %d failed %s: ",
7732 			__func__, i, __LINE__, "Failed to allocate session");
7733 		ret = TEST_FAILED;
7734 		goto on_err;
7735 	}
7736 
7737 	/* Generate crypto op data structure */
7738 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7739 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7740 	if (!ut_params->op) {
7741 		printf("TestCase %s()-%d line %d failed %s: ",
7742 			__func__, i, __LINE__,
7743 			"Failed to allocate symmetric crypto operation struct");
7744 		ret = TEST_FAILED;
7745 		goto on_err;
7746 	}
7747 
7748 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
7749 
7750 	/* set crypto operation source mbuf */
7751 	ut_params->op->sym->m_src = ut_params->ibuf;
7752 	if (oop)
7753 		ut_params->op->sym->m_dst = ut_params->obuf;
7754 
7755 	/* Process crypto operation */
7756 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7757 		== NULL) {
7758 		printf("TestCase %s()-%d line %d failed %s: ",
7759 			__func__, i, __LINE__,
7760 			"failed to process sym crypto op");
7761 		ret = TEST_FAILED;
7762 		goto on_err;
7763 	}
7764 
7765 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7766 		printf("TestCase %s()-%d line %d failed %s: ",
7767 			__func__, i, __LINE__, "crypto op processing failed");
7768 		ret = TEST_FAILED;
7769 		goto on_err;
7770 	}
7771 
7772 	/* Validate obuf */
7773 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7774 			uint8_t *);
7775 	if (oop) {
7776 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7777 				uint8_t *);
7778 	}
7779 
7780 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
7781 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7782 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7783 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7784 		ret = TEST_FAILED;
7785 		goto on_err;
7786 	}
7787 
7788 on_err:
7789 	rte_crypto_op_free(ut_params->op);
7790 	ut_params->op = NULL;
7791 
7792 	if (ut_params->sec_session)
7793 		rte_security_session_destroy(ctx, ut_params->sec_session);
7794 	ut_params->sec_session = NULL;
7795 
7796 	rte_pktmbuf_free(ut_params->ibuf);
7797 	ut_params->ibuf = NULL;
7798 	if (oop) {
7799 		rte_pktmbuf_free(ut_params->obuf);
7800 		ut_params->obuf = NULL;
7801 	}
7802 
7803 	return ret;
7804 }
7805 
7806 static int
7807 test_pdcp_proto_SGL(int i, int oop,
7808 	enum rte_crypto_cipher_operation opc,
7809 	enum rte_crypto_auth_operation opa,
7810 	uint8_t *input_vec,
7811 	unsigned int input_vec_len,
7812 	uint8_t *output_vec,
7813 	unsigned int output_vec_len,
7814 	uint32_t fragsz,
7815 	uint32_t fragsz_oop)
7816 {
7817 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7818 	struct crypto_unittest_params *ut_params = &unittest_params;
7819 	uint8_t *plaintext;
7820 	struct rte_mbuf *buf, *buf_oop = NULL;
7821 	int ret = TEST_SUCCESS;
7822 	int to_trn = 0;
7823 	int to_trn_tbl[16];
7824 	int segs = 1;
7825 	unsigned int trn_data = 0;
7826 
7827 	if (fragsz > input_vec_len)
7828 		fragsz = input_vec_len;
7829 
7830 	uint16_t plaintext_len = fragsz;
7831 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7832 
7833 	if (fragsz_oop > output_vec_len)
7834 		frag_size_oop = output_vec_len;
7835 
7836 	int ecx = 0;
7837 	if (input_vec_len % fragsz != 0) {
7838 		if (input_vec_len / fragsz + 1 > 16)
7839 			return 1;
7840 	} else if (input_vec_len / fragsz > 16)
7841 		return 1;
7842 
7843 	/* Out of place support */
7844 	if (oop) {
7845 		/*
7846 		 * For out-op-place we need to alloc another mbuf
7847 		 */
7848 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7849 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7850 		buf_oop = ut_params->obuf;
7851 	}
7852 
7853 	/* Generate test mbuf data */
7854 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7855 
7856 	/* clear mbuf payload */
7857 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7858 			rte_pktmbuf_tailroom(ut_params->ibuf));
7859 
7860 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7861 						  plaintext_len);
7862 	memcpy(plaintext, input_vec, plaintext_len);
7863 	trn_data += plaintext_len;
7864 
7865 	buf = ut_params->ibuf;
7866 
7867 	/*
7868 	 * Loop until no more fragments
7869 	 */
7870 
7871 	while (trn_data < input_vec_len) {
7872 		++segs;
7873 		to_trn = (input_vec_len - trn_data < fragsz) ?
7874 				(input_vec_len - trn_data) : fragsz;
7875 
7876 		to_trn_tbl[ecx++] = to_trn;
7877 
7878 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7879 		buf = buf->next;
7880 
7881 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7882 				rte_pktmbuf_tailroom(buf));
7883 
7884 		/* OOP */
7885 		if (oop && !fragsz_oop) {
7886 			buf_oop->next =
7887 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
7888 			buf_oop = buf_oop->next;
7889 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7890 					0, rte_pktmbuf_tailroom(buf_oop));
7891 			rte_pktmbuf_append(buf_oop, to_trn);
7892 		}
7893 
7894 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7895 				to_trn);
7896 
7897 		memcpy(plaintext, input_vec + trn_data, to_trn);
7898 		trn_data += to_trn;
7899 	}
7900 
7901 	ut_params->ibuf->nb_segs = segs;
7902 
7903 	segs = 1;
7904 	if (fragsz_oop && oop) {
7905 		to_trn = 0;
7906 		ecx = 0;
7907 
7908 		trn_data = frag_size_oop;
7909 		while (trn_data < output_vec_len) {
7910 			++segs;
7911 			to_trn =
7912 				(output_vec_len - trn_data <
7913 						frag_size_oop) ?
7914 				(output_vec_len - trn_data) :
7915 						frag_size_oop;
7916 
7917 			to_trn_tbl[ecx++] = to_trn;
7918 
7919 			buf_oop->next =
7920 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
7921 			buf_oop = buf_oop->next;
7922 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7923 					0, rte_pktmbuf_tailroom(buf_oop));
7924 			rte_pktmbuf_append(buf_oop, to_trn);
7925 
7926 			trn_data += to_trn;
7927 		}
7928 		ut_params->obuf->nb_segs = segs;
7929 	}
7930 
7931 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7932 
7933 	/* Setup Cipher Parameters */
7934 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7935 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7936 	ut_params->cipher_xform.cipher.op = opc;
7937 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7938 	ut_params->cipher_xform.cipher.key.length =
7939 					pdcp_test_params[i].cipher_key_len;
7940 	ut_params->cipher_xform.cipher.iv.length = 0;
7941 
7942 	/* Setup HMAC Parameters if ICV header is required */
7943 	if (pdcp_test_params[i].auth_alg != 0) {
7944 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7945 		ut_params->auth_xform.next = NULL;
7946 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7947 		ut_params->auth_xform.auth.op = opa;
7948 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7949 		ut_params->auth_xform.auth.key.length =
7950 					pdcp_test_params[i].auth_key_len;
7951 
7952 		ut_params->cipher_xform.next = &ut_params->auth_xform;
7953 	} else {
7954 		ut_params->cipher_xform.next = NULL;
7955 	}
7956 
7957 	struct rte_security_session_conf sess_conf = {
7958 		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7959 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
7960 		{.pdcp = {
7961 			.bearer = pdcp_test_bearer[i],
7962 			.domain = pdcp_test_params[i].domain,
7963 			.pkt_dir = pdcp_test_packet_direction[i],
7964 			.sn_size = pdcp_test_data_sn_size[i],
7965 			.hfn = pdcp_test_hfn[i],
7966 			.hfn_threshold = pdcp_test_hfn_threshold[i],
7967 		} },
7968 		.crypto_xform = &ut_params->cipher_xform
7969 	};
7970 
7971 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7972 				rte_cryptodev_get_sec_ctx(
7973 				ts_params->valid_devs[0]);
7974 
7975 	/* Create security session */
7976 	ut_params->sec_session = rte_security_session_create(ctx,
7977 				&sess_conf, ts_params->session_priv_mpool);
7978 
7979 	if (!ut_params->sec_session) {
7980 		printf("TestCase %s()-%d line %d failed %s: ",
7981 			__func__, i, __LINE__, "Failed to allocate session");
7982 		ret = TEST_FAILED;
7983 		goto on_err;
7984 	}
7985 
7986 	/* Generate crypto op data structure */
7987 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7988 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7989 	if (!ut_params->op) {
7990 		printf("TestCase %s()-%d line %d failed %s: ",
7991 			__func__, i, __LINE__,
7992 			"Failed to allocate symmetric crypto operation struct");
7993 		ret = TEST_FAILED;
7994 		goto on_err;
7995 	}
7996 
7997 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
7998 
7999 	/* set crypto operation source mbuf */
8000 	ut_params->op->sym->m_src = ut_params->ibuf;
8001 	if (oop)
8002 		ut_params->op->sym->m_dst = ut_params->obuf;
8003 
8004 	/* Process crypto operation */
8005 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8006 		== NULL) {
8007 		printf("TestCase %s()-%d line %d failed %s: ",
8008 			__func__, i, __LINE__,
8009 			"failed to process sym crypto op");
8010 		ret = TEST_FAILED;
8011 		goto on_err;
8012 	}
8013 
8014 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8015 		printf("TestCase %s()-%d line %d failed %s: ",
8016 			__func__, i, __LINE__, "crypto op processing failed");
8017 		ret = TEST_FAILED;
8018 		goto on_err;
8019 	}
8020 
8021 	/* Validate obuf */
8022 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8023 			uint8_t *);
8024 	if (oop) {
8025 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8026 				uint8_t *);
8027 	}
8028 	if (fragsz_oop)
8029 		fragsz = frag_size_oop;
8030 	if (memcmp(ciphertext, output_vec, fragsz)) {
8031 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8032 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8033 		rte_hexdump(stdout, "reference", output_vec, fragsz);
8034 		ret = TEST_FAILED;
8035 		goto on_err;
8036 	}
8037 
8038 	buf = ut_params->op->sym->m_src->next;
8039 	if (oop)
8040 		buf = ut_params->op->sym->m_dst->next;
8041 
8042 	unsigned int off = fragsz;
8043 
8044 	ecx = 0;
8045 	while (buf) {
8046 		ciphertext = rte_pktmbuf_mtod(buf,
8047 				uint8_t *);
8048 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8049 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8050 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8051 			rte_hexdump(stdout, "reference", output_vec + off,
8052 					to_trn_tbl[ecx]);
8053 			ret = TEST_FAILED;
8054 			goto on_err;
8055 		}
8056 		off += to_trn_tbl[ecx++];
8057 		buf = buf->next;
8058 	}
8059 on_err:
8060 	rte_crypto_op_free(ut_params->op);
8061 	ut_params->op = NULL;
8062 
8063 	if (ut_params->sec_session)
8064 		rte_security_session_destroy(ctx, ut_params->sec_session);
8065 	ut_params->sec_session = NULL;
8066 
8067 	rte_pktmbuf_free(ut_params->ibuf);
8068 	ut_params->ibuf = NULL;
8069 	if (oop) {
8070 		rte_pktmbuf_free(ut_params->obuf);
8071 		ut_params->obuf = NULL;
8072 	}
8073 
8074 	return ret;
8075 }
8076 
8077 int
8078 test_pdcp_proto_cplane_encap(int i)
8079 {
8080 	return test_pdcp_proto(i, 0,
8081 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8082 		RTE_CRYPTO_AUTH_OP_GENERATE,
8083 		pdcp_test_data_in[i],
8084 		pdcp_test_data_in_len[i],
8085 		pdcp_test_data_out[i],
8086 		pdcp_test_data_in_len[i]+4);
8087 }
8088 
8089 int
8090 test_pdcp_proto_uplane_encap(int i)
8091 {
8092 	return test_pdcp_proto(i, 0,
8093 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8094 		RTE_CRYPTO_AUTH_OP_GENERATE,
8095 		pdcp_test_data_in[i],
8096 		pdcp_test_data_in_len[i],
8097 		pdcp_test_data_out[i],
8098 		pdcp_test_data_in_len[i]);
8099 
8100 }
8101 
8102 int
8103 test_pdcp_proto_uplane_encap_with_int(int i)
8104 {
8105 	return test_pdcp_proto(i, 0,
8106 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8107 		RTE_CRYPTO_AUTH_OP_GENERATE,
8108 		pdcp_test_data_in[i],
8109 		pdcp_test_data_in_len[i],
8110 		pdcp_test_data_out[i],
8111 		pdcp_test_data_in_len[i] + 4);
8112 }
8113 
8114 int
8115 test_pdcp_proto_cplane_decap(int i)
8116 {
8117 	return test_pdcp_proto(i, 0,
8118 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8119 		RTE_CRYPTO_AUTH_OP_VERIFY,
8120 		pdcp_test_data_out[i],
8121 		pdcp_test_data_in_len[i] + 4,
8122 		pdcp_test_data_in[i],
8123 		pdcp_test_data_in_len[i]);
8124 }
8125 
8126 int
8127 test_pdcp_proto_uplane_decap(int i)
8128 {
8129 	return test_pdcp_proto(i, 0,
8130 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8131 		RTE_CRYPTO_AUTH_OP_VERIFY,
8132 		pdcp_test_data_out[i],
8133 		pdcp_test_data_in_len[i],
8134 		pdcp_test_data_in[i],
8135 		pdcp_test_data_in_len[i]);
8136 }
8137 
8138 int
8139 test_pdcp_proto_uplane_decap_with_int(int i)
8140 {
8141 	return test_pdcp_proto(i, 0,
8142 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8143 		RTE_CRYPTO_AUTH_OP_VERIFY,
8144 		pdcp_test_data_out[i],
8145 		pdcp_test_data_in_len[i] + 4,
8146 		pdcp_test_data_in[i],
8147 		pdcp_test_data_in_len[i]);
8148 }
8149 
8150 static int
8151 test_PDCP_PROTO_SGL_in_place_32B(void)
8152 {
8153 	/* i can be used for running any PDCP case
8154 	 * In this case it is uplane 12-bit AES-SNOW DL encap
8155 	 */
8156 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8157 	return test_pdcp_proto_SGL(i, IN_PLACE,
8158 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8159 			RTE_CRYPTO_AUTH_OP_GENERATE,
8160 			pdcp_test_data_in[i],
8161 			pdcp_test_data_in_len[i],
8162 			pdcp_test_data_out[i],
8163 			pdcp_test_data_in_len[i]+4,
8164 			32, 0);
8165 }
8166 static int
8167 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8168 {
8169 	/* i can be used for running any PDCP case
8170 	 * In this case it is uplane 18-bit NULL-NULL DL encap
8171 	 */
8172 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8173 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8174 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8175 			RTE_CRYPTO_AUTH_OP_GENERATE,
8176 			pdcp_test_data_in[i],
8177 			pdcp_test_data_in_len[i],
8178 			pdcp_test_data_out[i],
8179 			pdcp_test_data_in_len[i]+4,
8180 			32, 128);
8181 }
8182 static int
8183 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8184 {
8185 	/* i can be used for running any PDCP case
8186 	 * In this case it is uplane 18-bit AES DL encap
8187 	 */
8188 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8189 			+ DOWNLINK;
8190 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8191 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8192 			RTE_CRYPTO_AUTH_OP_GENERATE,
8193 			pdcp_test_data_in[i],
8194 			pdcp_test_data_in_len[i],
8195 			pdcp_test_data_out[i],
8196 			pdcp_test_data_in_len[i],
8197 			32, 40);
8198 }
8199 static int
8200 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8201 {
8202 	/* i can be used for running any PDCP case
8203 	 * In this case it is cplane 12-bit AES-ZUC DL encap
8204 	 */
8205 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8206 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8207 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8208 			RTE_CRYPTO_AUTH_OP_GENERATE,
8209 			pdcp_test_data_in[i],
8210 			pdcp_test_data_in_len[i],
8211 			pdcp_test_data_out[i],
8212 			pdcp_test_data_in_len[i]+4,
8213 			128, 32);
8214 }
8215 #endif
8216 
8217 static int
8218 test_AES_GCM_authenticated_encryption_test_case_1(void)
8219 {
8220 	return test_authenticated_encryption(&gcm_test_case_1);
8221 }
8222 
8223 static int
8224 test_AES_GCM_authenticated_encryption_test_case_2(void)
8225 {
8226 	return test_authenticated_encryption(&gcm_test_case_2);
8227 }
8228 
8229 static int
8230 test_AES_GCM_authenticated_encryption_test_case_3(void)
8231 {
8232 	return test_authenticated_encryption(&gcm_test_case_3);
8233 }
8234 
8235 static int
8236 test_AES_GCM_authenticated_encryption_test_case_4(void)
8237 {
8238 	return test_authenticated_encryption(&gcm_test_case_4);
8239 }
8240 
8241 static int
8242 test_AES_GCM_authenticated_encryption_test_case_5(void)
8243 {
8244 	return test_authenticated_encryption(&gcm_test_case_5);
8245 }
8246 
8247 static int
8248 test_AES_GCM_authenticated_encryption_test_case_6(void)
8249 {
8250 	return test_authenticated_encryption(&gcm_test_case_6);
8251 }
8252 
8253 static int
8254 test_AES_GCM_authenticated_encryption_test_case_7(void)
8255 {
8256 	return test_authenticated_encryption(&gcm_test_case_7);
8257 }
8258 
8259 static int
8260 test_AES_GCM_authenticated_encryption_test_case_8(void)
8261 {
8262 	return test_authenticated_encryption(&gcm_test_case_8);
8263 }
8264 
8265 static int
8266 test_AES_GCM_auth_encryption_test_case_192_1(void)
8267 {
8268 	return test_authenticated_encryption(&gcm_test_case_192_1);
8269 }
8270 
8271 static int
8272 test_AES_GCM_auth_encryption_test_case_192_2(void)
8273 {
8274 	return test_authenticated_encryption(&gcm_test_case_192_2);
8275 }
8276 
8277 static int
8278 test_AES_GCM_auth_encryption_test_case_192_3(void)
8279 {
8280 	return test_authenticated_encryption(&gcm_test_case_192_3);
8281 }
8282 
8283 static int
8284 test_AES_GCM_auth_encryption_test_case_192_4(void)
8285 {
8286 	return test_authenticated_encryption(&gcm_test_case_192_4);
8287 }
8288 
8289 static int
8290 test_AES_GCM_auth_encryption_test_case_192_5(void)
8291 {
8292 	return test_authenticated_encryption(&gcm_test_case_192_5);
8293 }
8294 
8295 static int
8296 test_AES_GCM_auth_encryption_test_case_192_6(void)
8297 {
8298 	return test_authenticated_encryption(&gcm_test_case_192_6);
8299 }
8300 
8301 static int
8302 test_AES_GCM_auth_encryption_test_case_192_7(void)
8303 {
8304 	return test_authenticated_encryption(&gcm_test_case_192_7);
8305 }
8306 
8307 static int
8308 test_AES_GCM_auth_encryption_test_case_256_1(void)
8309 {
8310 	return test_authenticated_encryption(&gcm_test_case_256_1);
8311 }
8312 
8313 static int
8314 test_AES_GCM_auth_encryption_test_case_256_2(void)
8315 {
8316 	return test_authenticated_encryption(&gcm_test_case_256_2);
8317 }
8318 
8319 static int
8320 test_AES_GCM_auth_encryption_test_case_256_3(void)
8321 {
8322 	return test_authenticated_encryption(&gcm_test_case_256_3);
8323 }
8324 
8325 static int
8326 test_AES_GCM_auth_encryption_test_case_256_4(void)
8327 {
8328 	return test_authenticated_encryption(&gcm_test_case_256_4);
8329 }
8330 
8331 static int
8332 test_AES_GCM_auth_encryption_test_case_256_5(void)
8333 {
8334 	return test_authenticated_encryption(&gcm_test_case_256_5);
8335 }
8336 
8337 static int
8338 test_AES_GCM_auth_encryption_test_case_256_6(void)
8339 {
8340 	return test_authenticated_encryption(&gcm_test_case_256_6);
8341 }
8342 
8343 static int
8344 test_AES_GCM_auth_encryption_test_case_256_7(void)
8345 {
8346 	return test_authenticated_encryption(&gcm_test_case_256_7);
8347 }
8348 
8349 static int
8350 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8351 {
8352 	return test_authenticated_encryption(&gcm_test_case_aad_1);
8353 }
8354 
8355 static int
8356 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8357 {
8358 	return test_authenticated_encryption(&gcm_test_case_aad_2);
8359 }
8360 
8361 static int
8362 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8363 {
8364 	struct aead_test_data tdata;
8365 	int res;
8366 
8367 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8368 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8369 	tdata.iv.data[0] += 1;
8370 	res = test_authenticated_encryption(&tdata);
8371 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8372 	return TEST_SUCCESS;
8373 }
8374 
8375 static int
8376 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8377 {
8378 	struct aead_test_data tdata;
8379 	int res;
8380 
8381 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8382 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8383 	tdata.plaintext.data[0] += 1;
8384 	res = test_authenticated_encryption(&tdata);
8385 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8386 	return TEST_SUCCESS;
8387 }
8388 
8389 static int
8390 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8391 {
8392 	struct aead_test_data tdata;
8393 	int res;
8394 
8395 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8396 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8397 	tdata.ciphertext.data[0] += 1;
8398 	res = test_authenticated_encryption(&tdata);
8399 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8400 	return TEST_SUCCESS;
8401 }
8402 
8403 static int
8404 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8405 {
8406 	struct aead_test_data tdata;
8407 	int res;
8408 
8409 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8410 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8411 	tdata.aad.len += 1;
8412 	res = test_authenticated_encryption(&tdata);
8413 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8414 	return TEST_SUCCESS;
8415 }
8416 
8417 static int
8418 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8419 {
8420 	struct aead_test_data tdata;
8421 	uint8_t aad[gcm_test_case_7.aad.len];
8422 	int res;
8423 
8424 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8425 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8426 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8427 	aad[0] += 1;
8428 	tdata.aad.data = aad;
8429 	res = test_authenticated_encryption(&tdata);
8430 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8431 	return TEST_SUCCESS;
8432 }
8433 
8434 static int
8435 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8436 {
8437 	struct aead_test_data tdata;
8438 	int res;
8439 
8440 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8441 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8442 	tdata.auth_tag.data[0] += 1;
8443 	res = test_authenticated_encryption(&tdata);
8444 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8445 	return TEST_SUCCESS;
8446 }
8447 
8448 static int
8449 test_authenticated_decryption(const struct aead_test_data *tdata)
8450 {
8451 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8452 	struct crypto_unittest_params *ut_params = &unittest_params;
8453 
8454 	int retval;
8455 	uint8_t *plaintext;
8456 	uint32_t i;
8457 
8458 	/* Create AEAD session */
8459 	retval = create_aead_session(ts_params->valid_devs[0],
8460 			tdata->algo,
8461 			RTE_CRYPTO_AEAD_OP_DECRYPT,
8462 			tdata->key.data, tdata->key.len,
8463 			tdata->aad.len, tdata->auth_tag.len,
8464 			tdata->iv.len);
8465 	if (retval < 0)
8466 		return retval;
8467 
8468 	/* alloc mbuf and set payload */
8469 	if (tdata->aad.len > MBUF_SIZE) {
8470 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8471 		/* Populate full size of add data */
8472 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8473 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8474 	} else
8475 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8476 
8477 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8478 			rte_pktmbuf_tailroom(ut_params->ibuf));
8479 
8480 	/* Create AEAD operation */
8481 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8482 	if (retval < 0)
8483 		return retval;
8484 
8485 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8486 
8487 	ut_params->op->sym->m_src = ut_params->ibuf;
8488 
8489 	/* Process crypto operation */
8490 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8491 			ut_params->op), "failed to process sym crypto op");
8492 
8493 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8494 			"crypto op processing failed");
8495 
8496 	if (ut_params->op->sym->m_dst)
8497 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8498 				uint8_t *);
8499 	else
8500 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8501 				uint8_t *,
8502 				ut_params->op->sym->cipher.data.offset);
8503 
8504 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8505 
8506 	/* Validate obuf */
8507 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8508 			plaintext,
8509 			tdata->plaintext.data,
8510 			tdata->plaintext.len,
8511 			"Plaintext data not as expected");
8512 
8513 	TEST_ASSERT_EQUAL(ut_params->op->status,
8514 			RTE_CRYPTO_OP_STATUS_SUCCESS,
8515 			"Authentication failed");
8516 
8517 	return 0;
8518 }
8519 
8520 static int
8521 test_AES_GCM_authenticated_decryption_test_case_1(void)
8522 {
8523 	return test_authenticated_decryption(&gcm_test_case_1);
8524 }
8525 
8526 static int
8527 test_AES_GCM_authenticated_decryption_test_case_2(void)
8528 {
8529 	return test_authenticated_decryption(&gcm_test_case_2);
8530 }
8531 
8532 static int
8533 test_AES_GCM_authenticated_decryption_test_case_3(void)
8534 {
8535 	return test_authenticated_decryption(&gcm_test_case_3);
8536 }
8537 
8538 static int
8539 test_AES_GCM_authenticated_decryption_test_case_4(void)
8540 {
8541 	return test_authenticated_decryption(&gcm_test_case_4);
8542 }
8543 
8544 static int
8545 test_AES_GCM_authenticated_decryption_test_case_5(void)
8546 {
8547 	return test_authenticated_decryption(&gcm_test_case_5);
8548 }
8549 
8550 static int
8551 test_AES_GCM_authenticated_decryption_test_case_6(void)
8552 {
8553 	return test_authenticated_decryption(&gcm_test_case_6);
8554 }
8555 
8556 static int
8557 test_AES_GCM_authenticated_decryption_test_case_7(void)
8558 {
8559 	return test_authenticated_decryption(&gcm_test_case_7);
8560 }
8561 
8562 static int
8563 test_AES_GCM_authenticated_decryption_test_case_8(void)
8564 {
8565 	return test_authenticated_decryption(&gcm_test_case_8);
8566 }
8567 
8568 static int
8569 test_AES_GCM_auth_decryption_test_case_192_1(void)
8570 {
8571 	return test_authenticated_decryption(&gcm_test_case_192_1);
8572 }
8573 
8574 static int
8575 test_AES_GCM_auth_decryption_test_case_192_2(void)
8576 {
8577 	return test_authenticated_decryption(&gcm_test_case_192_2);
8578 }
8579 
8580 static int
8581 test_AES_GCM_auth_decryption_test_case_192_3(void)
8582 {
8583 	return test_authenticated_decryption(&gcm_test_case_192_3);
8584 }
8585 
8586 static int
8587 test_AES_GCM_auth_decryption_test_case_192_4(void)
8588 {
8589 	return test_authenticated_decryption(&gcm_test_case_192_4);
8590 }
8591 
8592 static int
8593 test_AES_GCM_auth_decryption_test_case_192_5(void)
8594 {
8595 	return test_authenticated_decryption(&gcm_test_case_192_5);
8596 }
8597 
8598 static int
8599 test_AES_GCM_auth_decryption_test_case_192_6(void)
8600 {
8601 	return test_authenticated_decryption(&gcm_test_case_192_6);
8602 }
8603 
8604 static int
8605 test_AES_GCM_auth_decryption_test_case_192_7(void)
8606 {
8607 	return test_authenticated_decryption(&gcm_test_case_192_7);
8608 }
8609 
8610 static int
8611 test_AES_GCM_auth_decryption_test_case_256_1(void)
8612 {
8613 	return test_authenticated_decryption(&gcm_test_case_256_1);
8614 }
8615 
8616 static int
8617 test_AES_GCM_auth_decryption_test_case_256_2(void)
8618 {
8619 	return test_authenticated_decryption(&gcm_test_case_256_2);
8620 }
8621 
8622 static int
8623 test_AES_GCM_auth_decryption_test_case_256_3(void)
8624 {
8625 	return test_authenticated_decryption(&gcm_test_case_256_3);
8626 }
8627 
8628 static int
8629 test_AES_GCM_auth_decryption_test_case_256_4(void)
8630 {
8631 	return test_authenticated_decryption(&gcm_test_case_256_4);
8632 }
8633 
8634 static int
8635 test_AES_GCM_auth_decryption_test_case_256_5(void)
8636 {
8637 	return test_authenticated_decryption(&gcm_test_case_256_5);
8638 }
8639 
8640 static int
8641 test_AES_GCM_auth_decryption_test_case_256_6(void)
8642 {
8643 	return test_authenticated_decryption(&gcm_test_case_256_6);
8644 }
8645 
8646 static int
8647 test_AES_GCM_auth_decryption_test_case_256_7(void)
8648 {
8649 	return test_authenticated_decryption(&gcm_test_case_256_7);
8650 }
8651 
8652 static int
8653 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8654 {
8655 	return test_authenticated_decryption(&gcm_test_case_aad_1);
8656 }
8657 
8658 static int
8659 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8660 {
8661 	return test_authenticated_decryption(&gcm_test_case_aad_2);
8662 }
8663 
8664 static int
8665 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8666 {
8667 	struct aead_test_data tdata;
8668 	int res;
8669 
8670 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8671 	tdata.iv.data[0] += 1;
8672 	res = test_authenticated_decryption(&tdata);
8673 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8674 	return TEST_SUCCESS;
8675 }
8676 
8677 static int
8678 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8679 {
8680 	struct aead_test_data tdata;
8681 	int res;
8682 
8683 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8684 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8685 	tdata.plaintext.data[0] += 1;
8686 	res = test_authenticated_decryption(&tdata);
8687 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8688 	return TEST_SUCCESS;
8689 }
8690 
8691 static int
8692 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8693 {
8694 	struct aead_test_data tdata;
8695 	int res;
8696 
8697 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8698 	tdata.ciphertext.data[0] += 1;
8699 	res = test_authenticated_decryption(&tdata);
8700 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8701 	return TEST_SUCCESS;
8702 }
8703 
8704 static int
8705 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8706 {
8707 	struct aead_test_data tdata;
8708 	int res;
8709 
8710 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8711 	tdata.aad.len += 1;
8712 	res = test_authenticated_decryption(&tdata);
8713 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8714 	return TEST_SUCCESS;
8715 }
8716 
8717 static int
8718 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8719 {
8720 	struct aead_test_data tdata;
8721 	uint8_t aad[gcm_test_case_7.aad.len];
8722 	int res;
8723 
8724 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8725 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8726 	aad[0] += 1;
8727 	tdata.aad.data = aad;
8728 	res = test_authenticated_decryption(&tdata);
8729 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8730 	return TEST_SUCCESS;
8731 }
8732 
8733 static int
8734 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8735 {
8736 	struct aead_test_data tdata;
8737 	int res;
8738 
8739 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8740 	tdata.auth_tag.data[0] += 1;
8741 	res = test_authenticated_decryption(&tdata);
8742 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8743 	return TEST_SUCCESS;
8744 }
8745 
8746 static int
8747 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8748 {
8749 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8750 	struct crypto_unittest_params *ut_params = &unittest_params;
8751 
8752 	int retval;
8753 	uint8_t *ciphertext, *auth_tag;
8754 	uint16_t plaintext_pad_len;
8755 
8756 	/* Create AEAD session */
8757 	retval = create_aead_session(ts_params->valid_devs[0],
8758 			tdata->algo,
8759 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
8760 			tdata->key.data, tdata->key.len,
8761 			tdata->aad.len, tdata->auth_tag.len,
8762 			tdata->iv.len);
8763 	if (retval < 0)
8764 		return retval;
8765 
8766 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8767 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8768 
8769 	/* clear mbuf payload */
8770 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8771 			rte_pktmbuf_tailroom(ut_params->ibuf));
8772 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8773 			rte_pktmbuf_tailroom(ut_params->obuf));
8774 
8775 	/* Create AEAD operation */
8776 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8777 	if (retval < 0)
8778 		return retval;
8779 
8780 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8781 
8782 	ut_params->op->sym->m_src = ut_params->ibuf;
8783 	ut_params->op->sym->m_dst = ut_params->obuf;
8784 
8785 	/* Process crypto operation */
8786 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8787 			ut_params->op), "failed to process sym crypto op");
8788 
8789 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8790 			"crypto op processing failed");
8791 
8792 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8793 
8794 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8795 			ut_params->op->sym->cipher.data.offset);
8796 	auth_tag = ciphertext + plaintext_pad_len;
8797 
8798 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8799 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8800 
8801 	/* Validate obuf */
8802 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8803 			ciphertext,
8804 			tdata->ciphertext.data,
8805 			tdata->ciphertext.len,
8806 			"Ciphertext data not as expected");
8807 
8808 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8809 			auth_tag,
8810 			tdata->auth_tag.data,
8811 			tdata->auth_tag.len,
8812 			"Generated auth tag not as expected");
8813 
8814 	return 0;
8815 
8816 }
8817 
8818 static int
8819 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8820 {
8821 	return test_authenticated_encryption_oop(&gcm_test_case_5);
8822 }
8823 
8824 static int
8825 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8826 {
8827 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8828 	struct crypto_unittest_params *ut_params = &unittest_params;
8829 
8830 	int retval;
8831 	uint8_t *plaintext;
8832 
8833 	/* Create AEAD session */
8834 	retval = create_aead_session(ts_params->valid_devs[0],
8835 			tdata->algo,
8836 			RTE_CRYPTO_AEAD_OP_DECRYPT,
8837 			tdata->key.data, tdata->key.len,
8838 			tdata->aad.len, tdata->auth_tag.len,
8839 			tdata->iv.len);
8840 	if (retval < 0)
8841 		return retval;
8842 
8843 	/* alloc mbuf and set payload */
8844 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8845 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8846 
8847 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8848 			rte_pktmbuf_tailroom(ut_params->ibuf));
8849 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8850 			rte_pktmbuf_tailroom(ut_params->obuf));
8851 
8852 	/* Create AEAD operation */
8853 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8854 	if (retval < 0)
8855 		return retval;
8856 
8857 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8858 
8859 	ut_params->op->sym->m_src = ut_params->ibuf;
8860 	ut_params->op->sym->m_dst = ut_params->obuf;
8861 
8862 	/* Process crypto operation */
8863 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8864 			ut_params->op), "failed to process sym crypto op");
8865 
8866 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8867 			"crypto op processing failed");
8868 
8869 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8870 			ut_params->op->sym->cipher.data.offset);
8871 
8872 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8873 
8874 	/* Validate obuf */
8875 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8876 			plaintext,
8877 			tdata->plaintext.data,
8878 			tdata->plaintext.len,
8879 			"Plaintext data not as expected");
8880 
8881 	TEST_ASSERT_EQUAL(ut_params->op->status,
8882 			RTE_CRYPTO_OP_STATUS_SUCCESS,
8883 			"Authentication failed");
8884 	return 0;
8885 }
8886 
8887 static int
8888 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8889 {
8890 	return test_authenticated_decryption_oop(&gcm_test_case_5);
8891 }
8892 
8893 static int
8894 test_authenticated_encryption_sessionless(
8895 		const struct aead_test_data *tdata)
8896 {
8897 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8898 	struct crypto_unittest_params *ut_params = &unittest_params;
8899 
8900 	int retval;
8901 	uint8_t *ciphertext, *auth_tag;
8902 	uint16_t plaintext_pad_len;
8903 	uint8_t key[tdata->key.len + 1];
8904 
8905 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8906 
8907 	/* clear mbuf payload */
8908 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8909 			rte_pktmbuf_tailroom(ut_params->ibuf));
8910 
8911 	/* Create AEAD operation */
8912 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8913 	if (retval < 0)
8914 		return retval;
8915 
8916 	/* Create GCM xform */
8917 	memcpy(key, tdata->key.data, tdata->key.len);
8918 	retval = create_aead_xform(ut_params->op,
8919 			tdata->algo,
8920 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
8921 			key, tdata->key.len,
8922 			tdata->aad.len, tdata->auth_tag.len,
8923 			tdata->iv.len);
8924 	if (retval < 0)
8925 		return retval;
8926 
8927 	ut_params->op->sym->m_src = ut_params->ibuf;
8928 
8929 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8930 			RTE_CRYPTO_OP_SESSIONLESS,
8931 			"crypto op session type not sessionless");
8932 
8933 	/* Process crypto operation */
8934 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8935 			ut_params->op), "failed to process sym crypto op");
8936 
8937 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8938 
8939 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8940 			"crypto op status not success");
8941 
8942 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8943 
8944 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8945 			ut_params->op->sym->cipher.data.offset);
8946 	auth_tag = ciphertext + plaintext_pad_len;
8947 
8948 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8949 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8950 
8951 	/* Validate obuf */
8952 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8953 			ciphertext,
8954 			tdata->ciphertext.data,
8955 			tdata->ciphertext.len,
8956 			"Ciphertext data not as expected");
8957 
8958 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8959 			auth_tag,
8960 			tdata->auth_tag.data,
8961 			tdata->auth_tag.len,
8962 			"Generated auth tag not as expected");
8963 
8964 	return 0;
8965 
8966 }
8967 
8968 static int
8969 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8970 {
8971 	return test_authenticated_encryption_sessionless(
8972 			&gcm_test_case_5);
8973 }
8974 
8975 static int
8976 test_authenticated_decryption_sessionless(
8977 		const struct aead_test_data *tdata)
8978 {
8979 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8980 	struct crypto_unittest_params *ut_params = &unittest_params;
8981 
8982 	int retval;
8983 	uint8_t *plaintext;
8984 	uint8_t key[tdata->key.len + 1];
8985 
8986 	/* alloc mbuf and set payload */
8987 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8988 
8989 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8990 			rte_pktmbuf_tailroom(ut_params->ibuf));
8991 
8992 	/* Create AEAD operation */
8993 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8994 	if (retval < 0)
8995 		return retval;
8996 
8997 	/* Create AEAD xform */
8998 	memcpy(key, tdata->key.data, tdata->key.len);
8999 	retval = create_aead_xform(ut_params->op,
9000 			tdata->algo,
9001 			RTE_CRYPTO_AEAD_OP_DECRYPT,
9002 			key, tdata->key.len,
9003 			tdata->aad.len, tdata->auth_tag.len,
9004 			tdata->iv.len);
9005 	if (retval < 0)
9006 		return retval;
9007 
9008 	ut_params->op->sym->m_src = ut_params->ibuf;
9009 
9010 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9011 			RTE_CRYPTO_OP_SESSIONLESS,
9012 			"crypto op session type not sessionless");
9013 
9014 	/* Process crypto operation */
9015 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9016 			ut_params->op), "failed to process sym crypto op");
9017 
9018 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9019 
9020 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9021 			"crypto op status not success");
9022 
9023 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9024 			ut_params->op->sym->cipher.data.offset);
9025 
9026 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9027 
9028 	/* Validate obuf */
9029 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9030 			plaintext,
9031 			tdata->plaintext.data,
9032 			tdata->plaintext.len,
9033 			"Plaintext data not as expected");
9034 
9035 	TEST_ASSERT_EQUAL(ut_params->op->status,
9036 			RTE_CRYPTO_OP_STATUS_SUCCESS,
9037 			"Authentication failed");
9038 	return 0;
9039 }
9040 
9041 static int
9042 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9043 {
9044 	return test_authenticated_decryption_sessionless(
9045 			&gcm_test_case_5);
9046 }
9047 
9048 static int
9049 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9050 {
9051 	return test_authenticated_encryption(&ccm_test_case_128_1);
9052 }
9053 
9054 static int
9055 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9056 {
9057 	return test_authenticated_encryption(&ccm_test_case_128_2);
9058 }
9059 
9060 static int
9061 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9062 {
9063 	return test_authenticated_encryption(&ccm_test_case_128_3);
9064 }
9065 
9066 static int
9067 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9068 {
9069 	return test_authenticated_decryption(&ccm_test_case_128_1);
9070 }
9071 
9072 static int
9073 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9074 {
9075 	return test_authenticated_decryption(&ccm_test_case_128_2);
9076 }
9077 
9078 static int
9079 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9080 {
9081 	return test_authenticated_decryption(&ccm_test_case_128_3);
9082 }
9083 
9084 static int
9085 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9086 {
9087 	return test_authenticated_encryption(&ccm_test_case_192_1);
9088 }
9089 
9090 static int
9091 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9092 {
9093 	return test_authenticated_encryption(&ccm_test_case_192_2);
9094 }
9095 
9096 static int
9097 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9098 {
9099 	return test_authenticated_encryption(&ccm_test_case_192_3);
9100 }
9101 
9102 static int
9103 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9104 {
9105 	return test_authenticated_decryption(&ccm_test_case_192_1);
9106 }
9107 
9108 static int
9109 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9110 {
9111 	return test_authenticated_decryption(&ccm_test_case_192_2);
9112 }
9113 
9114 static int
9115 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9116 {
9117 	return test_authenticated_decryption(&ccm_test_case_192_3);
9118 }
9119 
9120 static int
9121 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9122 {
9123 	return test_authenticated_encryption(&ccm_test_case_256_1);
9124 }
9125 
9126 static int
9127 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9128 {
9129 	return test_authenticated_encryption(&ccm_test_case_256_2);
9130 }
9131 
9132 static int
9133 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9134 {
9135 	return test_authenticated_encryption(&ccm_test_case_256_3);
9136 }
9137 
9138 static int
9139 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9140 {
9141 	return test_authenticated_decryption(&ccm_test_case_256_1);
9142 }
9143 
9144 static int
9145 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9146 {
9147 	return test_authenticated_decryption(&ccm_test_case_256_2);
9148 }
9149 
9150 static int
9151 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9152 {
9153 	return test_authenticated_decryption(&ccm_test_case_256_3);
9154 }
9155 
9156 static int
9157 test_stats(void)
9158 {
9159 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9160 	struct rte_cryptodev_stats stats;
9161 	struct rte_cryptodev *dev;
9162 	cryptodev_stats_get_t temp_pfn;
9163 
9164 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9165 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9166 			&stats) == -ENODEV),
9167 		"rte_cryptodev_stats_get invalid dev failed");
9168 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9169 		"rte_cryptodev_stats_get invalid Param failed");
9170 	dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9171 	temp_pfn = dev->dev_ops->stats_get;
9172 	dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9173 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9174 			== -ENOTSUP),
9175 		"rte_cryptodev_stats_get invalid Param failed");
9176 	dev->dev_ops->stats_get = temp_pfn;
9177 
9178 	/* Test expected values */
9179 	ut_setup();
9180 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
9181 	ut_teardown();
9182 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9183 			&stats),
9184 		"rte_cryptodev_stats_get failed");
9185 	TEST_ASSERT((stats.enqueued_count == 1),
9186 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9187 	TEST_ASSERT((stats.dequeued_count == 1),
9188 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9189 	TEST_ASSERT((stats.enqueue_err_count == 0),
9190 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9191 	TEST_ASSERT((stats.dequeue_err_count == 0),
9192 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9193 
9194 	/* invalid device but should ignore and not reset device stats*/
9195 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9196 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9197 			&stats),
9198 		"rte_cryptodev_stats_get failed");
9199 	TEST_ASSERT((stats.enqueued_count == 1),
9200 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9201 
9202 	/* check that a valid reset clears stats */
9203 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9204 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9205 			&stats),
9206 					  "rte_cryptodev_stats_get failed");
9207 	TEST_ASSERT((stats.enqueued_count == 0),
9208 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9209 	TEST_ASSERT((stats.dequeued_count == 0),
9210 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9211 
9212 	return TEST_SUCCESS;
9213 }
9214 
9215 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9216 				   struct crypto_unittest_params *ut_params,
9217 				   enum rte_crypto_auth_operation op,
9218 				   const struct HMAC_MD5_vector *test_case)
9219 {
9220 	uint8_t key[64];
9221 
9222 	memcpy(key, test_case->key.data, test_case->key.len);
9223 
9224 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9225 	ut_params->auth_xform.next = NULL;
9226 	ut_params->auth_xform.auth.op = op;
9227 
9228 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9229 
9230 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9231 	ut_params->auth_xform.auth.key.length = test_case->key.len;
9232 	ut_params->auth_xform.auth.key.data = key;
9233 
9234 	ut_params->sess = rte_cryptodev_sym_session_create(
9235 			ts_params->session_mpool);
9236 
9237 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9238 			ut_params->sess, &ut_params->auth_xform,
9239 			ts_params->session_priv_mpool);
9240 
9241 	if (ut_params->sess == NULL)
9242 		return TEST_FAILED;
9243 
9244 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9245 
9246 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9247 			rte_pktmbuf_tailroom(ut_params->ibuf));
9248 
9249 	return 0;
9250 }
9251 
9252 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9253 			      const struct HMAC_MD5_vector *test_case,
9254 			      uint8_t **plaintext)
9255 {
9256 	uint16_t plaintext_pad_len;
9257 
9258 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9259 
9260 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9261 				16);
9262 
9263 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9264 			plaintext_pad_len);
9265 	memcpy(*plaintext, test_case->plaintext.data,
9266 			test_case->plaintext.len);
9267 
9268 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9269 			ut_params->ibuf, MD5_DIGEST_LEN);
9270 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9271 			"no room to append digest");
9272 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9273 			ut_params->ibuf, plaintext_pad_len);
9274 
9275 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9276 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9277 			   test_case->auth_tag.len);
9278 	}
9279 
9280 	sym_op->auth.data.offset = 0;
9281 	sym_op->auth.data.length = test_case->plaintext.len;
9282 
9283 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9284 	ut_params->op->sym->m_src = ut_params->ibuf;
9285 
9286 	return 0;
9287 }
9288 
9289 static int
9290 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9291 {
9292 	uint16_t plaintext_pad_len;
9293 	uint8_t *plaintext, *auth_tag;
9294 
9295 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9296 	struct crypto_unittest_params *ut_params = &unittest_params;
9297 
9298 	if (MD5_HMAC_create_session(ts_params, ut_params,
9299 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9300 		return TEST_FAILED;
9301 
9302 	/* Generate Crypto op data structure */
9303 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9304 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9305 	TEST_ASSERT_NOT_NULL(ut_params->op,
9306 			"Failed to allocate symmetric crypto operation struct");
9307 
9308 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9309 				16);
9310 
9311 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9312 		return TEST_FAILED;
9313 
9314 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9315 			ut_params->op), "failed to process sym crypto op");
9316 
9317 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9318 			"crypto op processing failed");
9319 
9320 	if (ut_params->op->sym->m_dst) {
9321 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9322 				uint8_t *, plaintext_pad_len);
9323 	} else {
9324 		auth_tag = plaintext + plaintext_pad_len;
9325 	}
9326 
9327 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9328 			auth_tag,
9329 			test_case->auth_tag.data,
9330 			test_case->auth_tag.len,
9331 			"HMAC_MD5 generated tag not as expected");
9332 
9333 	return TEST_SUCCESS;
9334 }
9335 
9336 static int
9337 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9338 {
9339 	uint8_t *plaintext;
9340 
9341 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9342 	struct crypto_unittest_params *ut_params = &unittest_params;
9343 
9344 	if (MD5_HMAC_create_session(ts_params, ut_params,
9345 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9346 		return TEST_FAILED;
9347 	}
9348 
9349 	/* Generate Crypto op data structure */
9350 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9351 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9352 	TEST_ASSERT_NOT_NULL(ut_params->op,
9353 			"Failed to allocate symmetric crypto operation struct");
9354 
9355 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9356 		return TEST_FAILED;
9357 
9358 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9359 			ut_params->op), "failed to process sym crypto op");
9360 
9361 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9362 			"HMAC_MD5 crypto op processing failed");
9363 
9364 	return TEST_SUCCESS;
9365 }
9366 
9367 static int
9368 test_MD5_HMAC_generate_case_1(void)
9369 {
9370 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9371 }
9372 
9373 static int
9374 test_MD5_HMAC_verify_case_1(void)
9375 {
9376 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9377 }
9378 
9379 static int
9380 test_MD5_HMAC_generate_case_2(void)
9381 {
9382 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9383 }
9384 
9385 static int
9386 test_MD5_HMAC_verify_case_2(void)
9387 {
9388 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9389 }
9390 
9391 static int
9392 test_multi_session(void)
9393 {
9394 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9395 	struct crypto_unittest_params *ut_params = &unittest_params;
9396 
9397 	struct rte_cryptodev_info dev_info;
9398 	struct rte_cryptodev_sym_session **sessions;
9399 
9400 	uint16_t i;
9401 
9402 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9403 			aes_cbc_key, hmac_sha512_key);
9404 
9405 
9406 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9407 
9408 	sessions = rte_malloc(NULL,
9409 			(sizeof(struct rte_cryptodev_sym_session *) *
9410 			MAX_NB_SESSIONS) + 1, 0);
9411 
9412 	/* Create multiple crypto sessions*/
9413 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
9414 
9415 		sessions[i] = rte_cryptodev_sym_session_create(
9416 				ts_params->session_mpool);
9417 
9418 		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9419 				sessions[i], &ut_params->auth_xform,
9420 				ts_params->session_priv_mpool);
9421 		TEST_ASSERT_NOT_NULL(sessions[i],
9422 				"Session creation failed at session number %u",
9423 				i);
9424 
9425 		/* Attempt to send a request on each session */
9426 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9427 			sessions[i],
9428 			ut_params,
9429 			ts_params,
9430 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9431 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9432 			aes_cbc_iv),
9433 			"Failed to perform decrypt on request number %u.", i);
9434 		/* free crypto operation structure */
9435 		if (ut_params->op)
9436 			rte_crypto_op_free(ut_params->op);
9437 
9438 		/*
9439 		 * free mbuf - both obuf and ibuf are usually the same,
9440 		 * so check if they point at the same address is necessary,
9441 		 * to avoid freeing the mbuf twice.
9442 		 */
9443 		if (ut_params->obuf) {
9444 			rte_pktmbuf_free(ut_params->obuf);
9445 			if (ut_params->ibuf == ut_params->obuf)
9446 				ut_params->ibuf = 0;
9447 			ut_params->obuf = 0;
9448 		}
9449 		if (ut_params->ibuf) {
9450 			rte_pktmbuf_free(ut_params->ibuf);
9451 			ut_params->ibuf = 0;
9452 		}
9453 	}
9454 
9455 	/* Next session create should fail */
9456 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9457 			sessions[i], &ut_params->auth_xform,
9458 			ts_params->session_priv_mpool);
9459 	TEST_ASSERT_NULL(sessions[i],
9460 			"Session creation succeeded unexpectedly!");
9461 
9462 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
9463 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9464 				sessions[i]);
9465 		rte_cryptodev_sym_session_free(sessions[i]);
9466 	}
9467 
9468 	rte_free(sessions);
9469 
9470 	return TEST_SUCCESS;
9471 }
9472 
9473 struct multi_session_params {
9474 	struct crypto_unittest_params ut_params;
9475 	uint8_t *cipher_key;
9476 	uint8_t *hmac_key;
9477 	const uint8_t *cipher;
9478 	const uint8_t *digest;
9479 	uint8_t *iv;
9480 };
9481 
9482 #define MB_SESSION_NUMBER 3
9483 
9484 static int
9485 test_multi_session_random_usage(void)
9486 {
9487 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9488 	struct rte_cryptodev_info dev_info;
9489 	struct rte_cryptodev_sym_session **sessions;
9490 	uint32_t i, j;
9491 	struct multi_session_params ut_paramz[] = {
9492 
9493 		{
9494 			.cipher_key = ms_aes_cbc_key0,
9495 			.hmac_key = ms_hmac_key0,
9496 			.cipher = ms_aes_cbc_cipher0,
9497 			.digest = ms_hmac_digest0,
9498 			.iv = ms_aes_cbc_iv0
9499 		},
9500 		{
9501 			.cipher_key = ms_aes_cbc_key1,
9502 			.hmac_key = ms_hmac_key1,
9503 			.cipher = ms_aes_cbc_cipher1,
9504 			.digest = ms_hmac_digest1,
9505 			.iv = ms_aes_cbc_iv1
9506 		},
9507 		{
9508 			.cipher_key = ms_aes_cbc_key2,
9509 			.hmac_key = ms_hmac_key2,
9510 			.cipher = ms_aes_cbc_cipher2,
9511 			.digest = ms_hmac_digest2,
9512 			.iv = ms_aes_cbc_iv2
9513 		},
9514 
9515 	};
9516 
9517 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9518 
9519 	sessions = rte_malloc(NULL,
9520 			(sizeof(struct rte_cryptodev_sym_session *)
9521 					* MAX_NB_SESSIONS) + 1, 0);
9522 
9523 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
9524 		sessions[i] = rte_cryptodev_sym_session_create(
9525 				ts_params->session_mpool);
9526 
9527 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9528 				sizeof(struct crypto_unittest_params));
9529 
9530 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9531 				&ut_paramz[i].ut_params,
9532 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9533 
9534 		/* Create multiple crypto sessions*/
9535 		rte_cryptodev_sym_session_init(
9536 				ts_params->valid_devs[0],
9537 				sessions[i],
9538 				&ut_paramz[i].ut_params.auth_xform,
9539 				ts_params->session_priv_mpool);
9540 
9541 		TEST_ASSERT_NOT_NULL(sessions[i],
9542 				"Session creation failed at session number %u",
9543 				i);
9544 
9545 	}
9546 
9547 	srand(time(NULL));
9548 	for (i = 0; i < 40000; i++) {
9549 
9550 		j = rand() % MB_SESSION_NUMBER;
9551 
9552 		TEST_ASSERT_SUCCESS(
9553 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
9554 					sessions[j],
9555 					&ut_paramz[j].ut_params,
9556 					ts_params, ut_paramz[j].cipher,
9557 					ut_paramz[j].digest,
9558 					ut_paramz[j].iv),
9559 			"Failed to perform decrypt on request number %u.", i);
9560 
9561 		if (ut_paramz[j].ut_params.op)
9562 			rte_crypto_op_free(ut_paramz[j].ut_params.op);
9563 
9564 		/*
9565 		 * free mbuf - both obuf and ibuf are usually the same,
9566 		 * so check if they point at the same address is necessary,
9567 		 * to avoid freeing the mbuf twice.
9568 		 */
9569 		if (ut_paramz[j].ut_params.obuf) {
9570 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9571 			if (ut_paramz[j].ut_params.ibuf
9572 					== ut_paramz[j].ut_params.obuf)
9573 				ut_paramz[j].ut_params.ibuf = 0;
9574 			ut_paramz[j].ut_params.obuf = 0;
9575 		}
9576 		if (ut_paramz[j].ut_params.ibuf) {
9577 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9578 			ut_paramz[j].ut_params.ibuf = 0;
9579 		}
9580 	}
9581 
9582 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
9583 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9584 				sessions[i]);
9585 		rte_cryptodev_sym_session_free(sessions[i]);
9586 	}
9587 
9588 	rte_free(sessions);
9589 
9590 	return TEST_SUCCESS;
9591 }
9592 
9593 static int
9594 test_null_cipher_only_operation(void)
9595 {
9596 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9597 	struct crypto_unittest_params *ut_params = &unittest_params;
9598 
9599 	/* Generate test mbuf data and space for digest */
9600 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9601 			catch_22_quote, QUOTE_512_BYTES, 0);
9602 
9603 	/* Setup Cipher Parameters */
9604 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9605 	ut_params->cipher_xform.next = NULL;
9606 
9607 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9608 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9609 
9610 	ut_params->sess = rte_cryptodev_sym_session_create(
9611 			ts_params->session_mpool);
9612 
9613 	/* Create Crypto session*/
9614 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9615 				ut_params->sess,
9616 				&ut_params->cipher_xform,
9617 				ts_params->session_priv_mpool);
9618 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9619 
9620 	/* Generate Crypto op data structure */
9621 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9622 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9623 	TEST_ASSERT_NOT_NULL(ut_params->op,
9624 			"Failed to allocate symmetric crypto operation struct");
9625 
9626 	/* Set crypto operation data parameters */
9627 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9628 
9629 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9630 
9631 	/* set crypto operation source mbuf */
9632 	sym_op->m_src = ut_params->ibuf;
9633 
9634 	sym_op->cipher.data.offset = 0;
9635 	sym_op->cipher.data.length = QUOTE_512_BYTES;
9636 
9637 	/* Process crypto operation */
9638 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9639 			ut_params->op);
9640 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9641 
9642 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9643 			"crypto operation processing failed");
9644 
9645 	/* Validate obuf */
9646 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9647 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9648 			catch_22_quote,
9649 			QUOTE_512_BYTES,
9650 			"Ciphertext data not as expected");
9651 
9652 	return TEST_SUCCESS;
9653 }
9654 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9655 			0xab, 0xab, 0xab, 0xab,
9656 			0xab, 0xab, 0xab, 0xab,
9657 			0xab, 0xab, 0xab, 0xab};
9658 static int
9659 test_null_auth_only_operation(void)
9660 {
9661 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9662 	struct crypto_unittest_params *ut_params = &unittest_params;
9663 	uint8_t *digest;
9664 
9665 	/* Generate test mbuf data and space for digest */
9666 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9667 			catch_22_quote, QUOTE_512_BYTES, 0);
9668 
9669 	/* create a pointer for digest, but don't expect anything to be written
9670 	 * here in a NULL auth algo so no mbuf append done.
9671 	 */
9672 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9673 			QUOTE_512_BYTES);
9674 	/* prefill the memory pointed to by digest */
9675 	memcpy(digest, orig_data, sizeof(orig_data));
9676 
9677 	/* Setup HMAC Parameters */
9678 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9679 	ut_params->auth_xform.next = NULL;
9680 
9681 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9682 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9683 
9684 	ut_params->sess = rte_cryptodev_sym_session_create(
9685 			ts_params->session_mpool);
9686 
9687 	/* Create Crypto session*/
9688 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9689 			ut_params->sess, &ut_params->auth_xform,
9690 			ts_params->session_priv_mpool);
9691 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9692 
9693 	/* Generate Crypto op data structure */
9694 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9695 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9696 	TEST_ASSERT_NOT_NULL(ut_params->op,
9697 			"Failed to allocate symmetric crypto operation struct");
9698 
9699 	/* Set crypto operation data parameters */
9700 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9701 
9702 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9703 
9704 	sym_op->m_src = ut_params->ibuf;
9705 
9706 	sym_op->auth.data.offset = 0;
9707 	sym_op->auth.data.length = QUOTE_512_BYTES;
9708 	sym_op->auth.digest.data = digest;
9709 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9710 			QUOTE_512_BYTES);
9711 
9712 	/* Process crypto operation */
9713 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9714 			ut_params->op);
9715 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9716 
9717 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9718 			"crypto operation processing failed");
9719 	/* Make sure memory pointed to by digest hasn't been overwritten */
9720 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9721 			orig_data,
9722 			digest,
9723 			sizeof(orig_data),
9724 			"Memory at digest ptr overwritten unexpectedly");
9725 
9726 	return TEST_SUCCESS;
9727 }
9728 
9729 
9730 static int
9731 test_null_cipher_auth_operation(void)
9732 {
9733 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9734 	struct crypto_unittest_params *ut_params = &unittest_params;
9735 	uint8_t *digest;
9736 
9737 	/* Generate test mbuf data and space for digest */
9738 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9739 			catch_22_quote, QUOTE_512_BYTES, 0);
9740 
9741 	/* create a pointer for digest, but don't expect anything to be written
9742 	 * here in a NULL auth algo so no mbuf append done.
9743 	 */
9744 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9745 			QUOTE_512_BYTES);
9746 	/* prefill the memory pointed to by digest */
9747 	memcpy(digest, orig_data, sizeof(orig_data));
9748 
9749 	/* Setup Cipher Parameters */
9750 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9751 	ut_params->cipher_xform.next = &ut_params->auth_xform;
9752 
9753 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9754 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9755 
9756 	/* Setup HMAC Parameters */
9757 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9758 	ut_params->auth_xform.next = NULL;
9759 
9760 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9761 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9762 
9763 	ut_params->sess = rte_cryptodev_sym_session_create(
9764 			ts_params->session_mpool);
9765 
9766 	/* Create Crypto session*/
9767 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9768 			ut_params->sess, &ut_params->cipher_xform,
9769 			ts_params->session_priv_mpool);
9770 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9771 
9772 	/* Generate Crypto op data structure */
9773 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9774 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9775 	TEST_ASSERT_NOT_NULL(ut_params->op,
9776 			"Failed to allocate symmetric crypto operation struct");
9777 
9778 	/* Set crypto operation data parameters */
9779 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9780 
9781 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9782 
9783 	sym_op->m_src = ut_params->ibuf;
9784 
9785 	sym_op->cipher.data.offset = 0;
9786 	sym_op->cipher.data.length = QUOTE_512_BYTES;
9787 
9788 	sym_op->auth.data.offset = 0;
9789 	sym_op->auth.data.length = QUOTE_512_BYTES;
9790 	sym_op->auth.digest.data = digest;
9791 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9792 			QUOTE_512_BYTES);
9793 
9794 	/* Process crypto operation */
9795 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9796 			ut_params->op);
9797 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9798 
9799 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9800 			"crypto operation processing failed");
9801 
9802 	/* Validate obuf */
9803 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9804 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9805 			catch_22_quote,
9806 			QUOTE_512_BYTES,
9807 			"Ciphertext data not as expected");
9808 	/* Make sure memory pointed to by digest hasn't been overwritten */
9809 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9810 			orig_data,
9811 			digest,
9812 			sizeof(orig_data),
9813 			"Memory at digest ptr overwritten unexpectedly");
9814 
9815 	return TEST_SUCCESS;
9816 }
9817 
9818 static int
9819 test_null_auth_cipher_operation(void)
9820 {
9821 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9822 	struct crypto_unittest_params *ut_params = &unittest_params;
9823 	uint8_t *digest;
9824 
9825 	/* Generate test mbuf data */
9826 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9827 			catch_22_quote, QUOTE_512_BYTES, 0);
9828 
9829 	/* create a pointer for digest, but don't expect anything to be written
9830 	 * here in a NULL auth algo so no mbuf append done.
9831 	 */
9832 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9833 				QUOTE_512_BYTES);
9834 	/* prefill the memory pointed to by digest */
9835 	memcpy(digest, orig_data, sizeof(orig_data));
9836 
9837 	/* Setup Cipher Parameters */
9838 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9839 	ut_params->cipher_xform.next = NULL;
9840 
9841 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9842 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9843 
9844 	/* Setup HMAC Parameters */
9845 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9846 	ut_params->auth_xform.next = &ut_params->cipher_xform;
9847 
9848 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9849 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9850 
9851 	ut_params->sess = rte_cryptodev_sym_session_create(
9852 			ts_params->session_mpool);
9853 
9854 	/* Create Crypto session*/
9855 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9856 			ut_params->sess, &ut_params->cipher_xform,
9857 			ts_params->session_priv_mpool);
9858 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9859 
9860 	/* Generate Crypto op data structure */
9861 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9862 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9863 	TEST_ASSERT_NOT_NULL(ut_params->op,
9864 			"Failed to allocate symmetric crypto operation struct");
9865 
9866 	/* Set crypto operation data parameters */
9867 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9868 
9869 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9870 
9871 	sym_op->m_src = ut_params->ibuf;
9872 
9873 	sym_op->cipher.data.offset = 0;
9874 	sym_op->cipher.data.length = QUOTE_512_BYTES;
9875 
9876 	sym_op->auth.data.offset = 0;
9877 	sym_op->auth.data.length = QUOTE_512_BYTES;
9878 	sym_op->auth.digest.data = digest;
9879 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9880 					QUOTE_512_BYTES);
9881 
9882 	/* Process crypto operation */
9883 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9884 			ut_params->op);
9885 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9886 
9887 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9888 			"crypto operation processing failed");
9889 
9890 	/* Validate obuf */
9891 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9892 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9893 			catch_22_quote,
9894 			QUOTE_512_BYTES,
9895 			"Ciphertext data not as expected");
9896 	/* Make sure memory pointed to by digest hasn't been overwritten */
9897 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9898 			orig_data,
9899 			digest,
9900 			sizeof(orig_data),
9901 			"Memory at digest ptr overwritten unexpectedly");
9902 
9903 	return TEST_SUCCESS;
9904 }
9905 
9906 
9907 static int
9908 test_null_invalid_operation(void)
9909 {
9910 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9911 	struct crypto_unittest_params *ut_params = &unittest_params;
9912 	int ret;
9913 
9914 	/* Setup Cipher Parameters */
9915 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9916 	ut_params->cipher_xform.next = NULL;
9917 
9918 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9919 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9920 
9921 	ut_params->sess = rte_cryptodev_sym_session_create(
9922 			ts_params->session_mpool);
9923 
9924 	/* Create Crypto session*/
9925 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9926 			ut_params->sess, &ut_params->cipher_xform,
9927 			ts_params->session_priv_mpool);
9928 	TEST_ASSERT(ret < 0,
9929 			"Session creation succeeded unexpectedly");
9930 
9931 
9932 	/* Setup HMAC Parameters */
9933 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9934 	ut_params->auth_xform.next = NULL;
9935 
9936 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9937 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9938 
9939 	ut_params->sess = rte_cryptodev_sym_session_create(
9940 			ts_params->session_mpool);
9941 
9942 	/* Create Crypto session*/
9943 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9944 			ut_params->sess, &ut_params->auth_xform,
9945 			ts_params->session_priv_mpool);
9946 	TEST_ASSERT(ret < 0,
9947 			"Session creation succeeded unexpectedly");
9948 
9949 	return TEST_SUCCESS;
9950 }
9951 
9952 
9953 #define NULL_BURST_LENGTH (32)
9954 
9955 static int
9956 test_null_burst_operation(void)
9957 {
9958 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9959 	struct crypto_unittest_params *ut_params = &unittest_params;
9960 
9961 	unsigned i, burst_len = NULL_BURST_LENGTH;
9962 
9963 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9964 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9965 
9966 	/* Setup Cipher Parameters */
9967 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9968 	ut_params->cipher_xform.next = &ut_params->auth_xform;
9969 
9970 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9971 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9972 
9973 	/* Setup HMAC Parameters */
9974 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9975 	ut_params->auth_xform.next = NULL;
9976 
9977 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9978 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9979 
9980 	ut_params->sess = rte_cryptodev_sym_session_create(
9981 			ts_params->session_mpool);
9982 
9983 	/* Create Crypto session*/
9984 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9985 			ut_params->sess, &ut_params->cipher_xform,
9986 			ts_params->session_priv_mpool);
9987 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9988 
9989 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9990 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9991 			burst_len, "failed to generate burst of crypto ops");
9992 
9993 	/* Generate an operation for each mbuf in burst */
9994 	for (i = 0; i < burst_len; i++) {
9995 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9996 
9997 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9998 
9999 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10000 				sizeof(unsigned));
10001 		*data = i;
10002 
10003 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10004 
10005 		burst[i]->sym->m_src = m;
10006 	}
10007 
10008 	/* Process crypto operation */
10009 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10010 			0, burst, burst_len),
10011 			burst_len,
10012 			"Error enqueuing burst");
10013 
10014 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10015 			0, burst_dequeued, burst_len),
10016 			burst_len,
10017 			"Error dequeuing burst");
10018 
10019 
10020 	for (i = 0; i < burst_len; i++) {
10021 		TEST_ASSERT_EQUAL(
10022 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10023 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10024 					uint32_t *),
10025 			"data not as expected");
10026 
10027 		rte_pktmbuf_free(burst[i]->sym->m_src);
10028 		rte_crypto_op_free(burst[i]);
10029 	}
10030 
10031 	return TEST_SUCCESS;
10032 }
10033 
10034 static void
10035 generate_gmac_large_plaintext(uint8_t *data)
10036 {
10037 	uint16_t i;
10038 
10039 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10040 		memcpy(&data[i], &data[0], 32);
10041 }
10042 
10043 static int
10044 create_gmac_operation(enum rte_crypto_auth_operation op,
10045 		const struct gmac_test_data *tdata)
10046 {
10047 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10048 	struct crypto_unittest_params *ut_params = &unittest_params;
10049 	struct rte_crypto_sym_op *sym_op;
10050 
10051 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10052 
10053 	/* Generate Crypto op data structure */
10054 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10055 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10056 	TEST_ASSERT_NOT_NULL(ut_params->op,
10057 			"Failed to allocate symmetric crypto operation struct");
10058 
10059 	sym_op = ut_params->op->sym;
10060 
10061 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10062 			ut_params->ibuf, tdata->gmac_tag.len);
10063 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10064 			"no room to append digest");
10065 
10066 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10067 			ut_params->ibuf, plaintext_pad_len);
10068 
10069 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10070 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10071 				tdata->gmac_tag.len);
10072 		debug_hexdump(stdout, "digest:",
10073 				sym_op->auth.digest.data,
10074 				tdata->gmac_tag.len);
10075 	}
10076 
10077 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10078 			uint8_t *, IV_OFFSET);
10079 
10080 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10081 
10082 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10083 
10084 	sym_op->cipher.data.length = 0;
10085 	sym_op->cipher.data.offset = 0;
10086 
10087 	sym_op->auth.data.offset = 0;
10088 	sym_op->auth.data.length = tdata->plaintext.len;
10089 
10090 	return 0;
10091 }
10092 
10093 static int create_gmac_session(uint8_t dev_id,
10094 		const struct gmac_test_data *tdata,
10095 		enum rte_crypto_auth_operation auth_op)
10096 {
10097 	uint8_t auth_key[tdata->key.len];
10098 
10099 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10100 	struct crypto_unittest_params *ut_params = &unittest_params;
10101 
10102 	memcpy(auth_key, tdata->key.data, tdata->key.len);
10103 
10104 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10105 	ut_params->auth_xform.next = NULL;
10106 
10107 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10108 	ut_params->auth_xform.auth.op = auth_op;
10109 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10110 	ut_params->auth_xform.auth.key.length = tdata->key.len;
10111 	ut_params->auth_xform.auth.key.data = auth_key;
10112 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10113 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10114 
10115 
10116 	ut_params->sess = rte_cryptodev_sym_session_create(
10117 			ts_params->session_mpool);
10118 
10119 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10120 			&ut_params->auth_xform,
10121 			ts_params->session_priv_mpool);
10122 
10123 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10124 
10125 	return 0;
10126 }
10127 
10128 static int
10129 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10130 {
10131 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10132 	struct crypto_unittest_params *ut_params = &unittest_params;
10133 
10134 	int retval;
10135 
10136 	uint8_t *auth_tag, *plaintext;
10137 	uint16_t plaintext_pad_len;
10138 
10139 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10140 			      "No GMAC length in the source data");
10141 
10142 	retval = create_gmac_session(ts_params->valid_devs[0],
10143 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10144 
10145 	if (retval < 0)
10146 		return retval;
10147 
10148 	if (tdata->plaintext.len > MBUF_SIZE)
10149 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10150 	else
10151 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10152 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10153 			"Failed to allocate input buffer in mempool");
10154 
10155 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10156 			rte_pktmbuf_tailroom(ut_params->ibuf));
10157 
10158 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10159 	/*
10160 	 * Runtime generate the large plain text instead of use hard code
10161 	 * plain text vector. It is done to avoid create huge source file
10162 	 * with the test vector.
10163 	 */
10164 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10165 		generate_gmac_large_plaintext(tdata->plaintext.data);
10166 
10167 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10168 				plaintext_pad_len);
10169 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10170 
10171 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10172 	debug_hexdump(stdout, "plaintext:", plaintext,
10173 			tdata->plaintext.len);
10174 
10175 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10176 			tdata);
10177 
10178 	if (retval < 0)
10179 		return retval;
10180 
10181 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10182 
10183 	ut_params->op->sym->m_src = ut_params->ibuf;
10184 
10185 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10186 			ut_params->op), "failed to process sym crypto op");
10187 
10188 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10189 			"crypto op processing failed");
10190 
10191 	if (ut_params->op->sym->m_dst) {
10192 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10193 				uint8_t *, plaintext_pad_len);
10194 	} else {
10195 		auth_tag = plaintext + plaintext_pad_len;
10196 	}
10197 
10198 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10199 
10200 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10201 			auth_tag,
10202 			tdata->gmac_tag.data,
10203 			tdata->gmac_tag.len,
10204 			"GMAC Generated auth tag not as expected");
10205 
10206 	return 0;
10207 }
10208 
10209 static int
10210 test_AES_GMAC_authentication_test_case_1(void)
10211 {
10212 	return test_AES_GMAC_authentication(&gmac_test_case_1);
10213 }
10214 
10215 static int
10216 test_AES_GMAC_authentication_test_case_2(void)
10217 {
10218 	return test_AES_GMAC_authentication(&gmac_test_case_2);
10219 }
10220 
10221 static int
10222 test_AES_GMAC_authentication_test_case_3(void)
10223 {
10224 	return test_AES_GMAC_authentication(&gmac_test_case_3);
10225 }
10226 
10227 static int
10228 test_AES_GMAC_authentication_test_case_4(void)
10229 {
10230 	return test_AES_GMAC_authentication(&gmac_test_case_4);
10231 }
10232 
10233 static int
10234 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10235 {
10236 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10237 	struct crypto_unittest_params *ut_params = &unittest_params;
10238 	int retval;
10239 	uint32_t plaintext_pad_len;
10240 	uint8_t *plaintext;
10241 
10242 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10243 			      "No GMAC length in the source data");
10244 
10245 	retval = create_gmac_session(ts_params->valid_devs[0],
10246 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10247 
10248 	if (retval < 0)
10249 		return retval;
10250 
10251 	if (tdata->plaintext.len > MBUF_SIZE)
10252 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10253 	else
10254 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10255 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10256 			"Failed to allocate input buffer in mempool");
10257 
10258 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10259 			rte_pktmbuf_tailroom(ut_params->ibuf));
10260 
10261 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10262 
10263 	/*
10264 	 * Runtime generate the large plain text instead of use hard code
10265 	 * plain text vector. It is done to avoid create huge source file
10266 	 * with the test vector.
10267 	 */
10268 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10269 		generate_gmac_large_plaintext(tdata->plaintext.data);
10270 
10271 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10272 				plaintext_pad_len);
10273 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10274 
10275 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10276 	debug_hexdump(stdout, "plaintext:", plaintext,
10277 			tdata->plaintext.len);
10278 
10279 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10280 			tdata);
10281 
10282 	if (retval < 0)
10283 		return retval;
10284 
10285 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10286 
10287 	ut_params->op->sym->m_src = ut_params->ibuf;
10288 
10289 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10290 			ut_params->op), "failed to process sym crypto op");
10291 
10292 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10293 			"crypto op processing failed");
10294 
10295 	return 0;
10296 
10297 }
10298 
10299 static int
10300 test_AES_GMAC_authentication_verify_test_case_1(void)
10301 {
10302 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10303 }
10304 
10305 static int
10306 test_AES_GMAC_authentication_verify_test_case_2(void)
10307 {
10308 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10309 }
10310 
10311 static int
10312 test_AES_GMAC_authentication_verify_test_case_3(void)
10313 {
10314 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10315 }
10316 
10317 static int
10318 test_AES_GMAC_authentication_verify_test_case_4(void)
10319 {
10320 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10321 }
10322 
10323 struct test_crypto_vector {
10324 	enum rte_crypto_cipher_algorithm crypto_algo;
10325 	unsigned int cipher_offset;
10326 	unsigned int cipher_len;
10327 
10328 	struct {
10329 		uint8_t data[64];
10330 		unsigned int len;
10331 	} cipher_key;
10332 
10333 	struct {
10334 		uint8_t data[64];
10335 		unsigned int len;
10336 	} iv;
10337 
10338 	struct {
10339 		const uint8_t *data;
10340 		unsigned int len;
10341 	} plaintext;
10342 
10343 	struct {
10344 		const uint8_t *data;
10345 		unsigned int len;
10346 	} ciphertext;
10347 
10348 	enum rte_crypto_auth_algorithm auth_algo;
10349 	unsigned int auth_offset;
10350 
10351 	struct {
10352 		uint8_t data[128];
10353 		unsigned int len;
10354 	} auth_key;
10355 
10356 	struct {
10357 		const uint8_t *data;
10358 		unsigned int len;
10359 	} aad;
10360 
10361 	struct {
10362 		uint8_t data[128];
10363 		unsigned int len;
10364 	} digest;
10365 };
10366 
10367 static const struct test_crypto_vector
10368 hmac_sha1_test_crypto_vector = {
10369 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10370 	.plaintext = {
10371 		.data = plaintext_hash,
10372 		.len = 512
10373 	},
10374 	.auth_key = {
10375 		.data = {
10376 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10377 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10378 			0xDE, 0xF4, 0xDE, 0xAD
10379 		},
10380 		.len = 20
10381 	},
10382 	.digest = {
10383 		.data = {
10384 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10385 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10386 			0x3F, 0x91, 0x64, 0x59
10387 		},
10388 		.len = 20
10389 	}
10390 };
10391 
10392 static const struct test_crypto_vector
10393 aes128_gmac_test_vector = {
10394 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10395 	.plaintext = {
10396 		.data = plaintext_hash,
10397 		.len = 512
10398 	},
10399 	.iv = {
10400 		.data = {
10401 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10402 			0x08, 0x09, 0x0A, 0x0B
10403 		},
10404 		.len = 12
10405 	},
10406 	.auth_key = {
10407 		.data = {
10408 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10409 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10410 		},
10411 		.len = 16
10412 	},
10413 	.digest = {
10414 		.data = {
10415 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10416 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10417 		},
10418 		.len = 16
10419 	}
10420 };
10421 
10422 static const struct test_crypto_vector
10423 aes128cbc_hmac_sha1_test_vector = {
10424 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10425 	.cipher_offset = 0,
10426 	.cipher_len = 512,
10427 	.cipher_key = {
10428 		.data = {
10429 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10430 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10431 		},
10432 		.len = 16
10433 	},
10434 	.iv = {
10435 		.data = {
10436 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10437 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10438 		},
10439 		.len = 16
10440 	},
10441 	.plaintext = {
10442 		.data = plaintext_hash,
10443 		.len = 512
10444 	},
10445 	.ciphertext = {
10446 		.data = ciphertext512_aes128cbc,
10447 		.len = 512
10448 	},
10449 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10450 	.auth_offset = 0,
10451 	.auth_key = {
10452 		.data = {
10453 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10454 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10455 			0xDE, 0xF4, 0xDE, 0xAD
10456 		},
10457 		.len = 20
10458 	},
10459 	.digest = {
10460 		.data = {
10461 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10462 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10463 			0x18, 0x8C, 0x1D, 0x32
10464 		},
10465 		.len = 20
10466 	}
10467 };
10468 
10469 static const struct test_crypto_vector
10470 aes128cbc_hmac_sha1_aad_test_vector = {
10471 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10472 	.cipher_offset = 12,
10473 	.cipher_len = 496,
10474 	.cipher_key = {
10475 		.data = {
10476 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10477 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10478 		},
10479 		.len = 16
10480 	},
10481 	.iv = {
10482 		.data = {
10483 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10484 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10485 		},
10486 		.len = 16
10487 	},
10488 	.plaintext = {
10489 		.data = plaintext_hash,
10490 		.len = 512
10491 	},
10492 	.ciphertext = {
10493 		.data = ciphertext512_aes128cbc_aad,
10494 		.len = 512
10495 	},
10496 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10497 	.auth_offset = 0,
10498 	.auth_key = {
10499 		.data = {
10500 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10501 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10502 			0xDE, 0xF4, 0xDE, 0xAD
10503 		},
10504 		.len = 20
10505 	},
10506 	.digest = {
10507 		.data = {
10508 			0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10509 			0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10510 			0x62, 0x8D, 0x62, 0x65
10511 		},
10512 		.len = 20
10513 	}
10514 };
10515 
10516 static void
10517 data_corruption(uint8_t *data)
10518 {
10519 	data[0] += 1;
10520 }
10521 
10522 static void
10523 tag_corruption(uint8_t *data, unsigned int tag_offset)
10524 {
10525 	data[tag_offset] += 1;
10526 }
10527 
10528 static int
10529 create_auth_session(struct crypto_unittest_params *ut_params,
10530 		uint8_t dev_id,
10531 		const struct test_crypto_vector *reference,
10532 		enum rte_crypto_auth_operation auth_op)
10533 {
10534 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10535 	uint8_t auth_key[reference->auth_key.len + 1];
10536 
10537 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10538 
10539 	/* Setup Authentication Parameters */
10540 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10541 	ut_params->auth_xform.auth.op = auth_op;
10542 	ut_params->auth_xform.next = NULL;
10543 	ut_params->auth_xform.auth.algo = reference->auth_algo;
10544 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10545 	ut_params->auth_xform.auth.key.data = auth_key;
10546 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
10547 
10548 	/* Create Crypto session*/
10549 	ut_params->sess = rte_cryptodev_sym_session_create(
10550 			ts_params->session_mpool);
10551 
10552 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10553 				&ut_params->auth_xform,
10554 				ts_params->session_priv_mpool);
10555 
10556 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10557 
10558 	return 0;
10559 }
10560 
10561 static int
10562 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10563 		uint8_t dev_id,
10564 		const struct test_crypto_vector *reference,
10565 		enum rte_crypto_auth_operation auth_op,
10566 		enum rte_crypto_cipher_operation cipher_op)
10567 {
10568 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10569 	uint8_t cipher_key[reference->cipher_key.len + 1];
10570 	uint8_t auth_key[reference->auth_key.len + 1];
10571 
10572 	memcpy(cipher_key, reference->cipher_key.data,
10573 			reference->cipher_key.len);
10574 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10575 
10576 	/* Setup Authentication Parameters */
10577 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10578 	ut_params->auth_xform.auth.op = auth_op;
10579 	ut_params->auth_xform.auth.algo = reference->auth_algo;
10580 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10581 	ut_params->auth_xform.auth.key.data = auth_key;
10582 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
10583 
10584 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10585 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10586 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
10587 	} else {
10588 		ut_params->auth_xform.next = &ut_params->cipher_xform;
10589 
10590 		/* Setup Cipher Parameters */
10591 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10592 		ut_params->cipher_xform.next = NULL;
10593 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10594 		ut_params->cipher_xform.cipher.op = cipher_op;
10595 		ut_params->cipher_xform.cipher.key.data = cipher_key;
10596 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10597 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10598 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10599 	}
10600 
10601 	/* Create Crypto session*/
10602 	ut_params->sess = rte_cryptodev_sym_session_create(
10603 			ts_params->session_mpool);
10604 
10605 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10606 				&ut_params->auth_xform,
10607 				ts_params->session_priv_mpool);
10608 
10609 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10610 
10611 	return 0;
10612 }
10613 
10614 static int
10615 create_auth_operation(struct crypto_testsuite_params *ts_params,
10616 		struct crypto_unittest_params *ut_params,
10617 		const struct test_crypto_vector *reference,
10618 		unsigned int auth_generate)
10619 {
10620 	/* Generate Crypto op data structure */
10621 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10622 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10623 	TEST_ASSERT_NOT_NULL(ut_params->op,
10624 			"Failed to allocate pktmbuf offload");
10625 
10626 	/* Set crypto operation data parameters */
10627 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10628 
10629 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10630 
10631 	/* set crypto operation source mbuf */
10632 	sym_op->m_src = ut_params->ibuf;
10633 
10634 	/* digest */
10635 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10636 			ut_params->ibuf, reference->digest.len);
10637 
10638 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10639 			"no room to append auth tag");
10640 
10641 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10642 			ut_params->ibuf, reference->plaintext.len);
10643 
10644 	if (auth_generate)
10645 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10646 	else
10647 		memcpy(sym_op->auth.digest.data,
10648 				reference->digest.data,
10649 				reference->digest.len);
10650 
10651 	debug_hexdump(stdout, "digest:",
10652 			sym_op->auth.digest.data,
10653 			reference->digest.len);
10654 
10655 	sym_op->auth.data.length = reference->plaintext.len;
10656 	sym_op->auth.data.offset = 0;
10657 
10658 	return 0;
10659 }
10660 
10661 static int
10662 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10663 		struct crypto_unittest_params *ut_params,
10664 		const struct test_crypto_vector *reference,
10665 		unsigned int auth_generate)
10666 {
10667 	/* Generate Crypto op data structure */
10668 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10669 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10670 	TEST_ASSERT_NOT_NULL(ut_params->op,
10671 			"Failed to allocate pktmbuf offload");
10672 
10673 	/* Set crypto operation data parameters */
10674 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10675 
10676 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10677 
10678 	/* set crypto operation source mbuf */
10679 	sym_op->m_src = ut_params->ibuf;
10680 
10681 	/* digest */
10682 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10683 			ut_params->ibuf, reference->digest.len);
10684 
10685 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10686 			"no room to append auth tag");
10687 
10688 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10689 			ut_params->ibuf, reference->ciphertext.len);
10690 
10691 	if (auth_generate)
10692 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10693 	else
10694 		memcpy(sym_op->auth.digest.data,
10695 				reference->digest.data,
10696 				reference->digest.len);
10697 
10698 	debug_hexdump(stdout, "digest:",
10699 			sym_op->auth.digest.data,
10700 			reference->digest.len);
10701 
10702 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10703 			reference->iv.data, reference->iv.len);
10704 
10705 	sym_op->cipher.data.length = 0;
10706 	sym_op->cipher.data.offset = 0;
10707 
10708 	sym_op->auth.data.length = reference->plaintext.len;
10709 	sym_op->auth.data.offset = 0;
10710 
10711 	return 0;
10712 }
10713 
10714 static int
10715 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10716 		struct crypto_unittest_params *ut_params,
10717 		const struct test_crypto_vector *reference,
10718 		unsigned int auth_generate)
10719 {
10720 	/* Generate Crypto op data structure */
10721 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10722 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10723 	TEST_ASSERT_NOT_NULL(ut_params->op,
10724 			"Failed to allocate pktmbuf offload");
10725 
10726 	/* Set crypto operation data parameters */
10727 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10728 
10729 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10730 
10731 	/* set crypto operation source mbuf */
10732 	sym_op->m_src = ut_params->ibuf;
10733 
10734 	/* digest */
10735 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10736 			ut_params->ibuf, reference->digest.len);
10737 
10738 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10739 			"no room to append auth tag");
10740 
10741 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10742 			ut_params->ibuf, reference->ciphertext.len);
10743 
10744 	if (auth_generate)
10745 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10746 	else
10747 		memcpy(sym_op->auth.digest.data,
10748 				reference->digest.data,
10749 				reference->digest.len);
10750 
10751 	debug_hexdump(stdout, "digest:",
10752 			sym_op->auth.digest.data,
10753 			reference->digest.len);
10754 
10755 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10756 			reference->iv.data, reference->iv.len);
10757 
10758 	sym_op->cipher.data.length = reference->cipher_len;
10759 	sym_op->cipher.data.offset = reference->cipher_offset;
10760 
10761 	sym_op->auth.data.length = reference->plaintext.len;
10762 	sym_op->auth.data.offset = reference->auth_offset;
10763 
10764 	return 0;
10765 }
10766 
10767 static int
10768 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10769 		struct crypto_unittest_params *ut_params,
10770 		const struct test_crypto_vector *reference)
10771 {
10772 	return create_auth_operation(ts_params, ut_params, reference, 0);
10773 }
10774 
10775 static int
10776 create_auth_verify_GMAC_operation(
10777 		struct crypto_testsuite_params *ts_params,
10778 		struct crypto_unittest_params *ut_params,
10779 		const struct test_crypto_vector *reference)
10780 {
10781 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10782 }
10783 
10784 static int
10785 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10786 		struct crypto_unittest_params *ut_params,
10787 		const struct test_crypto_vector *reference)
10788 {
10789 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10790 }
10791 
10792 static int
10793 test_authentication_verify_fail_when_data_corruption(
10794 		struct crypto_testsuite_params *ts_params,
10795 		struct crypto_unittest_params *ut_params,
10796 		const struct test_crypto_vector *reference,
10797 		unsigned int data_corrupted)
10798 {
10799 	int retval;
10800 
10801 	uint8_t *plaintext;
10802 
10803 	/* Create session */
10804 	retval = create_auth_session(ut_params,
10805 			ts_params->valid_devs[0],
10806 			reference,
10807 			RTE_CRYPTO_AUTH_OP_VERIFY);
10808 	if (retval < 0)
10809 		return retval;
10810 
10811 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10812 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10813 			"Failed to allocate input buffer in mempool");
10814 
10815 	/* clear mbuf payload */
10816 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10817 			rte_pktmbuf_tailroom(ut_params->ibuf));
10818 
10819 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10820 			reference->plaintext.len);
10821 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10822 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10823 
10824 	debug_hexdump(stdout, "plaintext:", plaintext,
10825 		reference->plaintext.len);
10826 
10827 	/* Create operation */
10828 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
10829 
10830 	if (retval < 0)
10831 		return retval;
10832 
10833 	if (data_corrupted)
10834 		data_corruption(plaintext);
10835 	else
10836 		tag_corruption(plaintext, reference->plaintext.len);
10837 
10838 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10839 			ut_params->op);
10840 
10841 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10842 
10843 	return 0;
10844 }
10845 
10846 static int
10847 test_authentication_verify_GMAC_fail_when_corruption(
10848 		struct crypto_testsuite_params *ts_params,
10849 		struct crypto_unittest_params *ut_params,
10850 		const struct test_crypto_vector *reference,
10851 		unsigned int data_corrupted)
10852 {
10853 	int retval;
10854 	uint8_t *plaintext;
10855 
10856 	/* Create session */
10857 	retval = create_auth_cipher_session(ut_params,
10858 			ts_params->valid_devs[0],
10859 			reference,
10860 			RTE_CRYPTO_AUTH_OP_VERIFY,
10861 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
10862 	if (retval < 0)
10863 		return retval;
10864 
10865 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10866 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10867 			"Failed to allocate input buffer in mempool");
10868 
10869 	/* clear mbuf payload */
10870 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10871 			rte_pktmbuf_tailroom(ut_params->ibuf));
10872 
10873 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10874 			reference->plaintext.len);
10875 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10876 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10877 
10878 	debug_hexdump(stdout, "plaintext:", plaintext,
10879 		reference->plaintext.len);
10880 
10881 	/* Create operation */
10882 	retval = create_auth_verify_GMAC_operation(ts_params,
10883 			ut_params,
10884 			reference);
10885 
10886 	if (retval < 0)
10887 		return retval;
10888 
10889 	if (data_corrupted)
10890 		data_corruption(plaintext);
10891 	else
10892 		tag_corruption(plaintext, reference->aad.len);
10893 
10894 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10895 			ut_params->op);
10896 
10897 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10898 
10899 	return 0;
10900 }
10901 
10902 static int
10903 test_authenticated_decryption_fail_when_corruption(
10904 		struct crypto_testsuite_params *ts_params,
10905 		struct crypto_unittest_params *ut_params,
10906 		const struct test_crypto_vector *reference,
10907 		unsigned int data_corrupted)
10908 {
10909 	int retval;
10910 
10911 	uint8_t *ciphertext;
10912 
10913 	/* Create session */
10914 	retval = create_auth_cipher_session(ut_params,
10915 			ts_params->valid_devs[0],
10916 			reference,
10917 			RTE_CRYPTO_AUTH_OP_VERIFY,
10918 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
10919 	if (retval < 0)
10920 		return retval;
10921 
10922 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10923 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10924 			"Failed to allocate input buffer in mempool");
10925 
10926 	/* clear mbuf payload */
10927 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10928 			rte_pktmbuf_tailroom(ut_params->ibuf));
10929 
10930 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10931 			reference->ciphertext.len);
10932 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10933 	memcpy(ciphertext, reference->ciphertext.data,
10934 			reference->ciphertext.len);
10935 
10936 	/* Create operation */
10937 	retval = create_cipher_auth_verify_operation(ts_params,
10938 			ut_params,
10939 			reference);
10940 
10941 	if (retval < 0)
10942 		return retval;
10943 
10944 	if (data_corrupted)
10945 		data_corruption(ciphertext);
10946 	else
10947 		tag_corruption(ciphertext, reference->ciphertext.len);
10948 
10949 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10950 			ut_params->op);
10951 
10952 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10953 
10954 	return 0;
10955 }
10956 
10957 static int
10958 test_authenticated_encryt_with_esn(
10959 		struct crypto_testsuite_params *ts_params,
10960 		struct crypto_unittest_params *ut_params,
10961 		const struct test_crypto_vector *reference)
10962 {
10963 	int retval;
10964 
10965 	uint8_t *authciphertext, *plaintext, *auth_tag;
10966 	uint16_t plaintext_pad_len;
10967 	uint8_t cipher_key[reference->cipher_key.len + 1];
10968 	uint8_t auth_key[reference->auth_key.len + 1];
10969 
10970 	/* Create session */
10971 	memcpy(cipher_key, reference->cipher_key.data,
10972 			reference->cipher_key.len);
10973 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10974 
10975 	/* Setup Cipher Parameters */
10976 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10977 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10978 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10979 	ut_params->cipher_xform.cipher.key.data = cipher_key;
10980 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10981 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10982 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10983 
10984 	ut_params->cipher_xform.next = &ut_params->auth_xform;
10985 
10986 	/* Setup Authentication Parameters */
10987 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10988 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10989 	ut_params->auth_xform.auth.algo = reference->auth_algo;
10990 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10991 	ut_params->auth_xform.auth.key.data = auth_key;
10992 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
10993 	ut_params->auth_xform.next = NULL;
10994 
10995 	/* Create Crypto session*/
10996 	ut_params->sess = rte_cryptodev_sym_session_create(
10997 			ts_params->session_mpool);
10998 
10999 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11000 				ut_params->sess,
11001 				&ut_params->cipher_xform,
11002 				ts_params->session_priv_mpool);
11003 
11004 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11005 
11006 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11007 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11008 			"Failed to allocate input buffer in mempool");
11009 
11010 	/* clear mbuf payload */
11011 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11012 			rte_pktmbuf_tailroom(ut_params->ibuf));
11013 
11014 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11015 			reference->plaintext.len);
11016 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11017 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11018 
11019 	/* Create operation */
11020 	retval = create_cipher_auth_operation(ts_params,
11021 			ut_params,
11022 			reference, 0);
11023 
11024 	if (retval < 0)
11025 		return retval;
11026 
11027 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11028 			ut_params->op);
11029 
11030 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11031 
11032 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11033 			"crypto op processing failed");
11034 
11035 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11036 
11037 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11038 			ut_params->op->sym->auth.data.offset);
11039 	auth_tag = authciphertext + plaintext_pad_len;
11040 	debug_hexdump(stdout, "ciphertext:", authciphertext,
11041 			reference->ciphertext.len);
11042 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11043 
11044 	/* Validate obuf */
11045 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11046 			authciphertext,
11047 			reference->ciphertext.data,
11048 			reference->ciphertext.len,
11049 			"Ciphertext data not as expected");
11050 
11051 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11052 			auth_tag,
11053 			reference->digest.data,
11054 			reference->digest.len,
11055 			"Generated digest not as expected");
11056 
11057 	return TEST_SUCCESS;
11058 
11059 }
11060 
11061 static int
11062 test_authenticated_decrypt_with_esn(
11063 		struct crypto_testsuite_params *ts_params,
11064 		struct crypto_unittest_params *ut_params,
11065 		const struct test_crypto_vector *reference)
11066 {
11067 	int retval;
11068 
11069 	uint8_t *ciphertext;
11070 	uint8_t cipher_key[reference->cipher_key.len + 1];
11071 	uint8_t auth_key[reference->auth_key.len + 1];
11072 
11073 	/* Create session */
11074 	memcpy(cipher_key, reference->cipher_key.data,
11075 			reference->cipher_key.len);
11076 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11077 
11078 	/* Setup Authentication Parameters */
11079 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11080 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11081 	ut_params->auth_xform.auth.algo = reference->auth_algo;
11082 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11083 	ut_params->auth_xform.auth.key.data = auth_key;
11084 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
11085 	ut_params->auth_xform.next = &ut_params->cipher_xform;
11086 
11087 	/* Setup Cipher Parameters */
11088 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11089 	ut_params->cipher_xform.next = NULL;
11090 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11091 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11092 	ut_params->cipher_xform.cipher.key.data = cipher_key;
11093 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11094 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11095 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11096 
11097 	/* Create Crypto session*/
11098 	ut_params->sess = rte_cryptodev_sym_session_create(
11099 			ts_params->session_mpool);
11100 
11101 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11102 				ut_params->sess,
11103 				&ut_params->auth_xform,
11104 				ts_params->session_priv_mpool);
11105 
11106 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11107 
11108 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11109 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11110 			"Failed to allocate input buffer in mempool");
11111 
11112 	/* clear mbuf payload */
11113 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11114 			rte_pktmbuf_tailroom(ut_params->ibuf));
11115 
11116 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11117 			reference->ciphertext.len);
11118 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11119 	memcpy(ciphertext, reference->ciphertext.data,
11120 			reference->ciphertext.len);
11121 
11122 	/* Create operation */
11123 	retval = create_cipher_auth_verify_operation(ts_params,
11124 			ut_params,
11125 			reference);
11126 
11127 	if (retval < 0)
11128 		return retval;
11129 
11130 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11131 			ut_params->op);
11132 
11133 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11134 	TEST_ASSERT_EQUAL(ut_params->op->status,
11135 			RTE_CRYPTO_OP_STATUS_SUCCESS,
11136 			"crypto op processing passed");
11137 
11138 	ut_params->obuf = ut_params->op->sym->m_src;
11139 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11140 
11141 	return 0;
11142 }
11143 
11144 static int
11145 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11146 		const struct aead_test_data *tdata,
11147 		void *digest_mem, uint64_t digest_phys)
11148 {
11149 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11150 	struct crypto_unittest_params *ut_params = &unittest_params;
11151 
11152 	const unsigned int auth_tag_len = tdata->auth_tag.len;
11153 	const unsigned int iv_len = tdata->iv.len;
11154 	unsigned int aad_len = tdata->aad.len;
11155 	unsigned int aad_len_pad = 0;
11156 
11157 	/* Generate Crypto op data structure */
11158 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11159 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11160 	TEST_ASSERT_NOT_NULL(ut_params->op,
11161 		"Failed to allocate symmetric crypto operation struct");
11162 
11163 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11164 
11165 	sym_op->aead.digest.data = digest_mem;
11166 
11167 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11168 			"no room to append digest");
11169 
11170 	sym_op->aead.digest.phys_addr = digest_phys;
11171 
11172 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11173 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11174 				auth_tag_len);
11175 		debug_hexdump(stdout, "digest:",
11176 				sym_op->aead.digest.data,
11177 				auth_tag_len);
11178 	}
11179 
11180 	/* Append aad data */
11181 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11182 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11183 				uint8_t *, IV_OFFSET);
11184 
11185 		/* Copy IV 1 byte after the IV pointer, according to the API */
11186 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11187 
11188 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11189 
11190 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11191 				ut_params->ibuf, aad_len);
11192 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11193 				"no room to prepend aad");
11194 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11195 				ut_params->ibuf);
11196 
11197 		memset(sym_op->aead.aad.data, 0, aad_len);
11198 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
11199 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11200 
11201 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11202 		debug_hexdump(stdout, "aad:",
11203 				sym_op->aead.aad.data, aad_len);
11204 	} else {
11205 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11206 				uint8_t *, IV_OFFSET);
11207 
11208 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11209 
11210 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11211 
11212 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11213 				ut_params->ibuf, aad_len_pad);
11214 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11215 				"no room to prepend aad");
11216 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11217 				ut_params->ibuf);
11218 
11219 		memset(sym_op->aead.aad.data, 0, aad_len);
11220 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11221 
11222 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11223 		debug_hexdump(stdout, "aad:",
11224 				sym_op->aead.aad.data, aad_len);
11225 	}
11226 
11227 	sym_op->aead.data.length = tdata->plaintext.len;
11228 	sym_op->aead.data.offset = aad_len_pad;
11229 
11230 	return 0;
11231 }
11232 
11233 #define SGL_MAX_NO	16
11234 
11235 static int
11236 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11237 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11238 {
11239 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11240 	struct crypto_unittest_params *ut_params = &unittest_params;
11241 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11242 	int retval;
11243 	int to_trn = 0;
11244 	int to_trn_tbl[SGL_MAX_NO];
11245 	int segs = 1;
11246 	unsigned int trn_data = 0;
11247 	uint8_t *plaintext, *ciphertext, *auth_tag;
11248 
11249 	if (fragsz > tdata->plaintext.len)
11250 		fragsz = tdata->plaintext.len;
11251 
11252 	uint16_t plaintext_len = fragsz;
11253 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11254 
11255 	if (fragsz_oop > tdata->plaintext.len)
11256 		frag_size_oop = tdata->plaintext.len;
11257 
11258 	int ecx = 0;
11259 	void *digest_mem = NULL;
11260 
11261 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11262 
11263 	if (tdata->plaintext.len % fragsz != 0) {
11264 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11265 			return 1;
11266 	}	else {
11267 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11268 			return 1;
11269 	}
11270 
11271 	/*
11272 	 * For out-op-place we need to alloc another mbuf
11273 	 */
11274 	if (oop) {
11275 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11276 		rte_pktmbuf_append(ut_params->obuf,
11277 				frag_size_oop + prepend_len);
11278 		buf_oop = ut_params->obuf;
11279 	}
11280 
11281 	/* Create AEAD session */
11282 	retval = create_aead_session(ts_params->valid_devs[0],
11283 			tdata->algo,
11284 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
11285 			tdata->key.data, tdata->key.len,
11286 			tdata->aad.len, tdata->auth_tag.len,
11287 			tdata->iv.len);
11288 	if (retval < 0)
11289 		return retval;
11290 
11291 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11292 
11293 	/* clear mbuf payload */
11294 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11295 			rte_pktmbuf_tailroom(ut_params->ibuf));
11296 
11297 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11298 			plaintext_len);
11299 
11300 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11301 
11302 	trn_data += plaintext_len;
11303 
11304 	buf = ut_params->ibuf;
11305 
11306 	/*
11307 	 * Loop until no more fragments
11308 	 */
11309 
11310 	while (trn_data < tdata->plaintext.len) {
11311 		++segs;
11312 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11313 				(tdata->plaintext.len - trn_data) : fragsz;
11314 
11315 		to_trn_tbl[ecx++] = to_trn;
11316 
11317 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11318 		buf = buf->next;
11319 
11320 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11321 				rte_pktmbuf_tailroom(buf));
11322 
11323 		/* OOP */
11324 		if (oop && !fragsz_oop) {
11325 			buf_last_oop = buf_oop->next =
11326 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
11327 			buf_oop = buf_oop->next;
11328 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11329 					0, rte_pktmbuf_tailroom(buf_oop));
11330 			rte_pktmbuf_append(buf_oop, to_trn);
11331 		}
11332 
11333 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11334 				to_trn);
11335 
11336 		memcpy(plaintext, tdata->plaintext.data + trn_data,
11337 				to_trn);
11338 		trn_data += to_trn;
11339 		if (trn_data  == tdata->plaintext.len) {
11340 			if (oop) {
11341 				if (!fragsz_oop)
11342 					digest_mem = rte_pktmbuf_append(buf_oop,
11343 						tdata->auth_tag.len);
11344 			} else
11345 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11346 					tdata->auth_tag.len);
11347 		}
11348 	}
11349 
11350 	uint64_t digest_phys = 0;
11351 
11352 	ut_params->ibuf->nb_segs = segs;
11353 
11354 	segs = 1;
11355 	if (fragsz_oop && oop) {
11356 		to_trn = 0;
11357 		ecx = 0;
11358 
11359 		if (frag_size_oop == tdata->plaintext.len) {
11360 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
11361 				tdata->auth_tag.len);
11362 
11363 			digest_phys = rte_pktmbuf_iova_offset(
11364 					ut_params->obuf,
11365 					tdata->plaintext.len + prepend_len);
11366 		}
11367 
11368 		trn_data = frag_size_oop;
11369 		while (trn_data < tdata->plaintext.len) {
11370 			++segs;
11371 			to_trn =
11372 				(tdata->plaintext.len - trn_data <
11373 						frag_size_oop) ?
11374 				(tdata->plaintext.len - trn_data) :
11375 						frag_size_oop;
11376 
11377 			to_trn_tbl[ecx++] = to_trn;
11378 
11379 			buf_last_oop = buf_oop->next =
11380 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
11381 			buf_oop = buf_oop->next;
11382 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11383 					0, rte_pktmbuf_tailroom(buf_oop));
11384 			rte_pktmbuf_append(buf_oop, to_trn);
11385 
11386 			trn_data += to_trn;
11387 
11388 			if (trn_data  == tdata->plaintext.len) {
11389 				digest_mem = rte_pktmbuf_append(buf_oop,
11390 					tdata->auth_tag.len);
11391 			}
11392 		}
11393 
11394 		ut_params->obuf->nb_segs = segs;
11395 	}
11396 
11397 	/*
11398 	 * Place digest at the end of the last buffer
11399 	 */
11400 	if (!digest_phys)
11401 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11402 	if (oop && buf_last_oop)
11403 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11404 
11405 	if (!digest_mem && !oop) {
11406 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11407 				+ tdata->auth_tag.len);
11408 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11409 				tdata->plaintext.len);
11410 	}
11411 
11412 	/* Create AEAD operation */
11413 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11414 			tdata, digest_mem, digest_phys);
11415 
11416 	if (retval < 0)
11417 		return retval;
11418 
11419 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11420 
11421 	ut_params->op->sym->m_src = ut_params->ibuf;
11422 	if (oop)
11423 		ut_params->op->sym->m_dst = ut_params->obuf;
11424 
11425 	/* Process crypto operation */
11426 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11427 			ut_params->op), "failed to process sym crypto op");
11428 
11429 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11430 			"crypto op processing failed");
11431 
11432 
11433 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11434 			uint8_t *, prepend_len);
11435 	if (oop) {
11436 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11437 				uint8_t *, prepend_len);
11438 	}
11439 
11440 	if (fragsz_oop)
11441 		fragsz = fragsz_oop;
11442 
11443 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11444 			ciphertext,
11445 			tdata->ciphertext.data,
11446 			fragsz,
11447 			"Ciphertext data not as expected");
11448 
11449 	buf = ut_params->op->sym->m_src->next;
11450 	if (oop)
11451 		buf = ut_params->op->sym->m_dst->next;
11452 
11453 	unsigned int off = fragsz;
11454 
11455 	ecx = 0;
11456 	while (buf) {
11457 		ciphertext = rte_pktmbuf_mtod(buf,
11458 				uint8_t *);
11459 
11460 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
11461 				ciphertext,
11462 				tdata->ciphertext.data + off,
11463 				to_trn_tbl[ecx],
11464 				"Ciphertext data not as expected");
11465 
11466 		off += to_trn_tbl[ecx++];
11467 		buf = buf->next;
11468 	}
11469 
11470 	auth_tag = digest_mem;
11471 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11472 			auth_tag,
11473 			tdata->auth_tag.data,
11474 			tdata->auth_tag.len,
11475 			"Generated auth tag not as expected");
11476 
11477 	return 0;
11478 }
11479 
11480 static int
11481 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11482 {
11483 	return test_authenticated_encryption_SGL(
11484 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11485 }
11486 
11487 static int
11488 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11489 {
11490 	return test_authenticated_encryption_SGL(
11491 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11492 }
11493 
11494 static int
11495 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11496 {
11497 	return test_authenticated_encryption_SGL(
11498 			&gcm_test_case_8, OUT_OF_PLACE, 400,
11499 			gcm_test_case_8.plaintext.len);
11500 }
11501 
11502 static int
11503 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11504 {
11505 
11506 	return test_authenticated_encryption_SGL(
11507 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11508 }
11509 
11510 static int
11511 test_authentication_verify_fail_when_data_corrupted(
11512 		struct crypto_testsuite_params *ts_params,
11513 		struct crypto_unittest_params *ut_params,
11514 		const struct test_crypto_vector *reference)
11515 {
11516 	return test_authentication_verify_fail_when_data_corruption(
11517 			ts_params, ut_params, reference, 1);
11518 }
11519 
11520 static int
11521 test_authentication_verify_fail_when_tag_corrupted(
11522 		struct crypto_testsuite_params *ts_params,
11523 		struct crypto_unittest_params *ut_params,
11524 		const struct test_crypto_vector *reference)
11525 {
11526 	return test_authentication_verify_fail_when_data_corruption(
11527 			ts_params, ut_params, reference, 0);
11528 }
11529 
11530 static int
11531 test_authentication_verify_GMAC_fail_when_data_corrupted(
11532 		struct crypto_testsuite_params *ts_params,
11533 		struct crypto_unittest_params *ut_params,
11534 		const struct test_crypto_vector *reference)
11535 {
11536 	return test_authentication_verify_GMAC_fail_when_corruption(
11537 			ts_params, ut_params, reference, 1);
11538 }
11539 
11540 static int
11541 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11542 		struct crypto_testsuite_params *ts_params,
11543 		struct crypto_unittest_params *ut_params,
11544 		const struct test_crypto_vector *reference)
11545 {
11546 	return test_authentication_verify_GMAC_fail_when_corruption(
11547 			ts_params, ut_params, reference, 0);
11548 }
11549 
11550 static int
11551 test_authenticated_decryption_fail_when_data_corrupted(
11552 		struct crypto_testsuite_params *ts_params,
11553 		struct crypto_unittest_params *ut_params,
11554 		const struct test_crypto_vector *reference)
11555 {
11556 	return test_authenticated_decryption_fail_when_corruption(
11557 			ts_params, ut_params, reference, 1);
11558 }
11559 
11560 static int
11561 test_authenticated_decryption_fail_when_tag_corrupted(
11562 		struct crypto_testsuite_params *ts_params,
11563 		struct crypto_unittest_params *ut_params,
11564 		const struct test_crypto_vector *reference)
11565 {
11566 	return test_authenticated_decryption_fail_when_corruption(
11567 			ts_params, ut_params, reference, 0);
11568 }
11569 
11570 static int
11571 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11572 {
11573 	return test_authentication_verify_fail_when_data_corrupted(
11574 			&testsuite_params, &unittest_params,
11575 			&hmac_sha1_test_crypto_vector);
11576 }
11577 
11578 static int
11579 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11580 {
11581 	return test_authentication_verify_fail_when_tag_corrupted(
11582 			&testsuite_params, &unittest_params,
11583 			&hmac_sha1_test_crypto_vector);
11584 }
11585 
11586 static int
11587 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11588 {
11589 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
11590 			&testsuite_params, &unittest_params,
11591 			&aes128_gmac_test_vector);
11592 }
11593 
11594 static int
11595 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11596 {
11597 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11598 			&testsuite_params, &unittest_params,
11599 			&aes128_gmac_test_vector);
11600 }
11601 
11602 static int
11603 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11604 {
11605 	return test_authenticated_decryption_fail_when_data_corrupted(
11606 			&testsuite_params,
11607 			&unittest_params,
11608 			&aes128cbc_hmac_sha1_test_vector);
11609 }
11610 
11611 static int
11612 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11613 {
11614 	return test_authenticated_decryption_fail_when_tag_corrupted(
11615 			&testsuite_params,
11616 			&unittest_params,
11617 			&aes128cbc_hmac_sha1_test_vector);
11618 }
11619 
11620 static int
11621 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11622 {
11623 	return test_authenticated_encryt_with_esn(
11624 			&testsuite_params,
11625 			&unittest_params,
11626 			&aes128cbc_hmac_sha1_aad_test_vector);
11627 }
11628 
11629 static int
11630 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11631 {
11632 	return test_authenticated_decrypt_with_esn(
11633 			&testsuite_params,
11634 			&unittest_params,
11635 			&aes128cbc_hmac_sha1_aad_test_vector);
11636 }
11637 
11638 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11639 
11640 /* global AESNI slave IDs for the scheduler test */
11641 uint8_t aesni_ids[2];
11642 
11643 static int
11644 test_scheduler_attach_slave_op(void)
11645 {
11646 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11647 	uint8_t sched_id = ts_params->valid_devs[0];
11648 	uint32_t nb_devs, i, nb_devs_attached = 0;
11649 	int ret;
11650 	char vdev_name[32];
11651 
11652 	/* create 2 AESNI_MB if necessary */
11653 	nb_devs = rte_cryptodev_device_count_by_driver(
11654 			rte_cryptodev_driver_id_get(
11655 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11656 	if (nb_devs < 2) {
11657 		for (i = nb_devs; i < 2; i++) {
11658 			snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11659 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11660 					i);
11661 			ret = rte_vdev_init(vdev_name, NULL);
11662 
11663 			TEST_ASSERT(ret == 0,
11664 				"Failed to create instance %u of"
11665 				" pmd : %s",
11666 				i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11667 		}
11668 	}
11669 
11670 	/* attach 2 AESNI_MB cdevs */
11671 	for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11672 			i++) {
11673 		struct rte_cryptodev_info info;
11674 		unsigned int session_size;
11675 
11676 		rte_cryptodev_info_get(i, &info);
11677 		if (info.driver_id != rte_cryptodev_driver_id_get(
11678 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11679 			continue;
11680 
11681 		session_size = rte_cryptodev_sym_get_private_session_size(i);
11682 		/*
11683 		 * Create the session mempool again, since now there are new devices
11684 		 * to use the mempool.
11685 		 */
11686 		if (ts_params->session_mpool) {
11687 			rte_mempool_free(ts_params->session_mpool);
11688 			ts_params->session_mpool = NULL;
11689 		}
11690 		if (ts_params->session_priv_mpool) {
11691 			rte_mempool_free(ts_params->session_priv_mpool);
11692 			ts_params->session_priv_mpool = NULL;
11693 		}
11694 
11695 		if (info.sym.max_nb_sessions != 0 &&
11696 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11697 			RTE_LOG(ERR, USER1,
11698 					"Device does not support "
11699 					"at least %u sessions\n",
11700 					MAX_NB_SESSIONS);
11701 			return TEST_FAILED;
11702 		}
11703 		/*
11704 		 * Create mempool with maximum number of sessions,
11705 		 * to include the session headers
11706 		 */
11707 		if (ts_params->session_mpool == NULL) {
11708 			ts_params->session_mpool =
11709 				rte_cryptodev_sym_session_pool_create(
11710 						"test_sess_mp",
11711 						MAX_NB_SESSIONS, 0, 0, 0,
11712 						SOCKET_ID_ANY);
11713 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11714 					"session mempool allocation failed");
11715 		}
11716 
11717 		/*
11718 		 * Create mempool with maximum number of sessions,
11719 		 * to include device specific session private data
11720 		 */
11721 		if (ts_params->session_priv_mpool == NULL) {
11722 			ts_params->session_priv_mpool = rte_mempool_create(
11723 					"test_sess_mp_priv",
11724 					MAX_NB_SESSIONS,
11725 					session_size,
11726 					0, 0, NULL, NULL, NULL,
11727 					NULL, SOCKET_ID_ANY,
11728 					0);
11729 
11730 			TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11731 					"session mempool allocation failed");
11732 		}
11733 
11734 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
11735 		ts_params->qp_conf.mp_session_private =
11736 				ts_params->session_priv_mpool;
11737 
11738 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11739 				(uint8_t)i);
11740 
11741 		TEST_ASSERT(ret == 0,
11742 			"Failed to attach device %u of pmd : %s", i,
11743 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11744 
11745 		aesni_ids[nb_devs_attached] = (uint8_t)i;
11746 
11747 		nb_devs_attached++;
11748 	}
11749 
11750 	return 0;
11751 }
11752 
11753 static int
11754 test_scheduler_detach_slave_op(void)
11755 {
11756 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11757 	uint8_t sched_id = ts_params->valid_devs[0];
11758 	uint32_t i;
11759 	int ret;
11760 
11761 	for (i = 0; i < 2; i++) {
11762 		ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11763 				aesni_ids[i]);
11764 		TEST_ASSERT(ret == 0,
11765 			"Failed to detach device %u", aesni_ids[i]);
11766 	}
11767 
11768 	return 0;
11769 }
11770 
11771 static int
11772 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11773 {
11774 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11775 	uint8_t sched_id = ts_params->valid_devs[0];
11776 	/* set mode */
11777 	return rte_cryptodev_scheduler_mode_set(sched_id,
11778 		scheduler_mode);
11779 }
11780 
11781 static int
11782 test_scheduler_mode_roundrobin_op(void)
11783 {
11784 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11785 			0, "Failed to set roundrobin mode");
11786 	return 0;
11787 
11788 }
11789 
11790 static int
11791 test_scheduler_mode_multicore_op(void)
11792 {
11793 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11794 			0, "Failed to set multicore mode");
11795 
11796 	return 0;
11797 }
11798 
11799 static int
11800 test_scheduler_mode_failover_op(void)
11801 {
11802 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11803 			0, "Failed to set failover mode");
11804 
11805 	return 0;
11806 }
11807 
11808 static int
11809 test_scheduler_mode_pkt_size_distr_op(void)
11810 {
11811 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11812 			0, "Failed to set pktsize mode");
11813 
11814 	return 0;
11815 }
11816 
11817 static struct unit_test_suite cryptodev_scheduler_testsuite  = {
11818 	.suite_name = "Crypto Device Scheduler Unit Test Suite",
11819 	.setup = testsuite_setup,
11820 	.teardown = testsuite_teardown,
11821 	.unit_test_cases = {
11822 		/* Multi Core */
11823 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11824 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11825 		TEST_CASE_ST(ut_setup, ut_teardown,
11826 					test_AES_chain_scheduler_all),
11827 		TEST_CASE_ST(ut_setup, ut_teardown,
11828 					test_AES_cipheronly_scheduler_all),
11829 		TEST_CASE_ST(ut_setup, ut_teardown,
11830 					test_authonly_scheduler_all),
11831 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11832 
11833 		/* Round Robin */
11834 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11835 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11836 		TEST_CASE_ST(ut_setup, ut_teardown,
11837 				test_AES_chain_scheduler_all),
11838 		TEST_CASE_ST(ut_setup, ut_teardown,
11839 				test_AES_cipheronly_scheduler_all),
11840 		TEST_CASE_ST(ut_setup, ut_teardown,
11841 				test_authonly_scheduler_all),
11842 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11843 
11844 		/* Fail over */
11845 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11846 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11847 		TEST_CASE_ST(ut_setup, ut_teardown,
11848 					test_AES_chain_scheduler_all),
11849 		TEST_CASE_ST(ut_setup, ut_teardown,
11850 					test_AES_cipheronly_scheduler_all),
11851 		TEST_CASE_ST(ut_setup, ut_teardown,
11852 					test_authonly_scheduler_all),
11853 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11854 
11855 		/* PKT SIZE */
11856 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11857 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11858 		TEST_CASE_ST(ut_setup, ut_teardown,
11859 					test_AES_chain_scheduler_all),
11860 		TEST_CASE_ST(ut_setup, ut_teardown,
11861 					test_AES_cipheronly_scheduler_all),
11862 		TEST_CASE_ST(ut_setup, ut_teardown,
11863 					test_authonly_scheduler_all),
11864 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11865 
11866 		TEST_CASES_END() /**< NULL terminate unit test array */
11867 	}
11868 };
11869 
11870 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11871 
11872 static struct unit_test_suite cryptodev_qat_testsuite  = {
11873 	.suite_name = "Crypto QAT Unit Test Suite",
11874 	.setup = testsuite_setup,
11875 	.teardown = testsuite_teardown,
11876 	.unit_test_cases = {
11877 		TEST_CASE_ST(ut_setup, ut_teardown,
11878 				test_device_configure_invalid_dev_id),
11879 		TEST_CASE_ST(ut_setup, ut_teardown,
11880 				test_device_configure_invalid_queue_pair_ids),
11881 		TEST_CASE_ST(ut_setup, ut_teardown,
11882 				test_queue_pair_descriptor_setup),
11883 		TEST_CASE_ST(ut_setup, ut_teardown,
11884 				test_multi_session),
11885 
11886 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
11887 		TEST_CASE_ST(ut_setup, ut_teardown,
11888 						test_AES_cipheronly_qat_all),
11889 		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
11890 		TEST_CASE_ST(ut_setup, ut_teardown,
11891 						test_3DES_cipheronly_qat_all),
11892 		TEST_CASE_ST(ut_setup, ut_teardown,
11893 						test_DES_cipheronly_qat_all),
11894 		TEST_CASE_ST(ut_setup, ut_teardown,
11895 						test_AES_docsis_qat_all),
11896 		TEST_CASE_ST(ut_setup, ut_teardown,
11897 						test_DES_docsis_qat_all),
11898 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
11899 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11900 
11901 		/** AES CCM Authenticated Encryption 128 bits key */
11902 		TEST_CASE_ST(ut_setup, ut_teardown,
11903 			test_AES_CCM_authenticated_encryption_test_case_128_1),
11904 		TEST_CASE_ST(ut_setup, ut_teardown,
11905 			test_AES_CCM_authenticated_encryption_test_case_128_2),
11906 		TEST_CASE_ST(ut_setup, ut_teardown,
11907 			test_AES_CCM_authenticated_encryption_test_case_128_3),
11908 
11909 		/** AES CCM Authenticated Decryption 128 bits key*/
11910 		TEST_CASE_ST(ut_setup, ut_teardown,
11911 			test_AES_CCM_authenticated_decryption_test_case_128_1),
11912 		TEST_CASE_ST(ut_setup, ut_teardown,
11913 			test_AES_CCM_authenticated_decryption_test_case_128_2),
11914 		TEST_CASE_ST(ut_setup, ut_teardown,
11915 			test_AES_CCM_authenticated_decryption_test_case_128_3),
11916 
11917 		/** AES GCM Authenticated Encryption */
11918 		TEST_CASE_ST(ut_setup, ut_teardown,
11919 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11920 		TEST_CASE_ST(ut_setup, ut_teardown,
11921 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11922 		TEST_CASE_ST(ut_setup, ut_teardown,
11923 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11924 		TEST_CASE_ST(ut_setup, ut_teardown,
11925 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11926 		TEST_CASE_ST(ut_setup, ut_teardown,
11927 			test_AES_GCM_authenticated_encryption_test_case_1),
11928 		TEST_CASE_ST(ut_setup, ut_teardown,
11929 			test_AES_GCM_authenticated_encryption_test_case_2),
11930 		TEST_CASE_ST(ut_setup, ut_teardown,
11931 			test_AES_GCM_authenticated_encryption_test_case_3),
11932 		TEST_CASE_ST(ut_setup, ut_teardown,
11933 			test_AES_GCM_authenticated_encryption_test_case_4),
11934 		TEST_CASE_ST(ut_setup, ut_teardown,
11935 			test_AES_GCM_authenticated_encryption_test_case_5),
11936 		TEST_CASE_ST(ut_setup, ut_teardown,
11937 			test_AES_GCM_authenticated_encryption_test_case_6),
11938 		TEST_CASE_ST(ut_setup, ut_teardown,
11939 			test_AES_GCM_authenticated_encryption_test_case_7),
11940 		TEST_CASE_ST(ut_setup, ut_teardown,
11941 			test_AES_GCM_authenticated_encryption_test_case_8),
11942 
11943 		/** AES GCM Authenticated Decryption */
11944 		TEST_CASE_ST(ut_setup, ut_teardown,
11945 			test_AES_GCM_authenticated_decryption_test_case_1),
11946 		TEST_CASE_ST(ut_setup, ut_teardown,
11947 			test_AES_GCM_authenticated_decryption_test_case_2),
11948 		TEST_CASE_ST(ut_setup, ut_teardown,
11949 			test_AES_GCM_authenticated_decryption_test_case_3),
11950 		TEST_CASE_ST(ut_setup, ut_teardown,
11951 			test_AES_GCM_authenticated_decryption_test_case_4),
11952 		TEST_CASE_ST(ut_setup, ut_teardown,
11953 			test_AES_GCM_authenticated_decryption_test_case_5),
11954 		TEST_CASE_ST(ut_setup, ut_teardown,
11955 			test_AES_GCM_authenticated_decryption_test_case_6),
11956 		TEST_CASE_ST(ut_setup, ut_teardown,
11957 			test_AES_GCM_authenticated_decryption_test_case_7),
11958 		TEST_CASE_ST(ut_setup, ut_teardown,
11959 			test_AES_GCM_authenticated_decryption_test_case_8),
11960 
11961 		/** AES GCM Authenticated Encryption 192 bits key */
11962 		TEST_CASE_ST(ut_setup, ut_teardown,
11963 			test_AES_GCM_auth_encryption_test_case_192_1),
11964 		TEST_CASE_ST(ut_setup, ut_teardown,
11965 			test_AES_GCM_auth_encryption_test_case_192_2),
11966 		TEST_CASE_ST(ut_setup, ut_teardown,
11967 			test_AES_GCM_auth_encryption_test_case_192_3),
11968 		TEST_CASE_ST(ut_setup, ut_teardown,
11969 			test_AES_GCM_auth_encryption_test_case_192_4),
11970 		TEST_CASE_ST(ut_setup, ut_teardown,
11971 			test_AES_GCM_auth_encryption_test_case_192_5),
11972 		TEST_CASE_ST(ut_setup, ut_teardown,
11973 			test_AES_GCM_auth_encryption_test_case_192_6),
11974 		TEST_CASE_ST(ut_setup, ut_teardown,
11975 			test_AES_GCM_auth_encryption_test_case_192_7),
11976 
11977 		/** AES GCM Authenticated Decryption 192 bits key */
11978 		TEST_CASE_ST(ut_setup, ut_teardown,
11979 			test_AES_GCM_auth_decryption_test_case_192_1),
11980 		TEST_CASE_ST(ut_setup, ut_teardown,
11981 			test_AES_GCM_auth_decryption_test_case_192_2),
11982 		TEST_CASE_ST(ut_setup, ut_teardown,
11983 			test_AES_GCM_auth_decryption_test_case_192_3),
11984 		TEST_CASE_ST(ut_setup, ut_teardown,
11985 			test_AES_GCM_auth_decryption_test_case_192_4),
11986 		TEST_CASE_ST(ut_setup, ut_teardown,
11987 			test_AES_GCM_auth_decryption_test_case_192_5),
11988 		TEST_CASE_ST(ut_setup, ut_teardown,
11989 			test_AES_GCM_auth_decryption_test_case_192_6),
11990 		TEST_CASE_ST(ut_setup, ut_teardown,
11991 			test_AES_GCM_auth_decryption_test_case_192_7),
11992 
11993 		/** AES GCM Authenticated Encryption 256 bits key */
11994 		TEST_CASE_ST(ut_setup, ut_teardown,
11995 			test_AES_GCM_auth_encryption_test_case_256_1),
11996 		TEST_CASE_ST(ut_setup, ut_teardown,
11997 			test_AES_GCM_auth_encryption_test_case_256_2),
11998 		TEST_CASE_ST(ut_setup, ut_teardown,
11999 			test_AES_GCM_auth_encryption_test_case_256_3),
12000 		TEST_CASE_ST(ut_setup, ut_teardown,
12001 			test_AES_GCM_auth_encryption_test_case_256_4),
12002 		TEST_CASE_ST(ut_setup, ut_teardown,
12003 			test_AES_GCM_auth_encryption_test_case_256_5),
12004 		TEST_CASE_ST(ut_setup, ut_teardown,
12005 			test_AES_GCM_auth_encryption_test_case_256_6),
12006 		TEST_CASE_ST(ut_setup, ut_teardown,
12007 			test_AES_GCM_auth_encryption_test_case_256_7),
12008 
12009 		/** AES GCM Authenticated Decryption 256 bits key */
12010 		TEST_CASE_ST(ut_setup, ut_teardown,
12011 			test_AES_GCM_auth_decryption_test_case_256_1),
12012 		TEST_CASE_ST(ut_setup, ut_teardown,
12013 			test_AES_GCM_auth_decryption_test_case_256_2),
12014 		TEST_CASE_ST(ut_setup, ut_teardown,
12015 			test_AES_GCM_auth_decryption_test_case_256_3),
12016 		TEST_CASE_ST(ut_setup, ut_teardown,
12017 			test_AES_GCM_auth_decryption_test_case_256_4),
12018 		TEST_CASE_ST(ut_setup, ut_teardown,
12019 			test_AES_GCM_auth_decryption_test_case_256_5),
12020 		TEST_CASE_ST(ut_setup, ut_teardown,
12021 			test_AES_GCM_auth_decryption_test_case_256_6),
12022 		TEST_CASE_ST(ut_setup, ut_teardown,
12023 			test_AES_GCM_auth_decryption_test_case_256_7),
12024 
12025 		/** AES GMAC Authentication */
12026 		TEST_CASE_ST(ut_setup, ut_teardown,
12027 			test_AES_GMAC_authentication_test_case_1),
12028 		TEST_CASE_ST(ut_setup, ut_teardown,
12029 			test_AES_GMAC_authentication_verify_test_case_1),
12030 		TEST_CASE_ST(ut_setup, ut_teardown,
12031 			test_AES_GMAC_authentication_test_case_2),
12032 		TEST_CASE_ST(ut_setup, ut_teardown,
12033 			test_AES_GMAC_authentication_verify_test_case_2),
12034 		TEST_CASE_ST(ut_setup, ut_teardown,
12035 			test_AES_GMAC_authentication_test_case_3),
12036 		TEST_CASE_ST(ut_setup, ut_teardown,
12037 			test_AES_GMAC_authentication_verify_test_case_3),
12038 
12039 		/** SNOW 3G encrypt only (UEA2) */
12040 		TEST_CASE_ST(ut_setup, ut_teardown,
12041 			test_snow3g_encryption_test_case_1),
12042 		TEST_CASE_ST(ut_setup, ut_teardown,
12043 			test_snow3g_encryption_test_case_2),
12044 		TEST_CASE_ST(ut_setup, ut_teardown,
12045 			test_snow3g_encryption_test_case_3),
12046 		TEST_CASE_ST(ut_setup, ut_teardown,
12047 			test_snow3g_encryption_test_case_4),
12048 		TEST_CASE_ST(ut_setup, ut_teardown,
12049 			test_snow3g_encryption_test_case_5),
12050 
12051 		TEST_CASE_ST(ut_setup, ut_teardown,
12052 			test_snow3g_encryption_test_case_1_oop),
12053 		TEST_CASE_ST(ut_setup, ut_teardown,
12054 			test_snow3g_decryption_test_case_1_oop),
12055 
12056 		/** SNOW 3G generate auth, then encrypt (UEA2) */
12057 		TEST_CASE_ST(ut_setup, ut_teardown,
12058 			test_snow3g_auth_cipher_test_case_1),
12059 		TEST_CASE_ST(ut_setup, ut_teardown,
12060 			test_snow3g_auth_cipher_test_case_2),
12061 		TEST_CASE_ST(ut_setup, ut_teardown,
12062 			test_snow3g_auth_cipher_test_case_2_oop),
12063 		TEST_CASE_ST(ut_setup, ut_teardown,
12064 			test_snow3g_auth_cipher_part_digest_enc),
12065 		TEST_CASE_ST(ut_setup, ut_teardown,
12066 			test_snow3g_auth_cipher_part_digest_enc_oop),
12067 		TEST_CASE_ST(ut_setup, ut_teardown,
12068 			test_snow3g_auth_cipher_test_case_3_sgl),
12069 		TEST_CASE_ST(ut_setup, ut_teardown,
12070 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
12071 		TEST_CASE_ST(ut_setup, ut_teardown,
12072 			test_snow3g_auth_cipher_part_digest_enc_sgl),
12073 		TEST_CASE_ST(ut_setup, ut_teardown,
12074 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12075 
12076 		/** SNOW 3G decrypt (UEA2), then verify auth */
12077 		TEST_CASE_ST(ut_setup, ut_teardown,
12078 			test_snow3g_auth_cipher_verify_test_case_1),
12079 		TEST_CASE_ST(ut_setup, ut_teardown,
12080 			test_snow3g_auth_cipher_verify_test_case_2),
12081 		TEST_CASE_ST(ut_setup, ut_teardown,
12082 			test_snow3g_auth_cipher_verify_test_case_2_oop),
12083 		TEST_CASE_ST(ut_setup, ut_teardown,
12084 			test_snow3g_auth_cipher_verify_part_digest_enc),
12085 		TEST_CASE_ST(ut_setup, ut_teardown,
12086 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12087 		TEST_CASE_ST(ut_setup, ut_teardown,
12088 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
12089 		TEST_CASE_ST(ut_setup, ut_teardown,
12090 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12091 		TEST_CASE_ST(ut_setup, ut_teardown,
12092 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12093 		TEST_CASE_ST(ut_setup, ut_teardown,
12094 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12095 
12096 		/** SNOW 3G decrypt only (UEA2) */
12097 		TEST_CASE_ST(ut_setup, ut_teardown,
12098 			test_snow3g_decryption_test_case_1),
12099 		TEST_CASE_ST(ut_setup, ut_teardown,
12100 			test_snow3g_decryption_test_case_2),
12101 		TEST_CASE_ST(ut_setup, ut_teardown,
12102 			test_snow3g_decryption_test_case_3),
12103 		TEST_CASE_ST(ut_setup, ut_teardown,
12104 			test_snow3g_decryption_test_case_4),
12105 		TEST_CASE_ST(ut_setup, ut_teardown,
12106 			test_snow3g_decryption_test_case_5),
12107 		TEST_CASE_ST(ut_setup, ut_teardown,
12108 			test_snow3g_decryption_with_digest_test_case_1),
12109 		TEST_CASE_ST(ut_setup, ut_teardown,
12110 			test_snow3g_hash_generate_test_case_1),
12111 		TEST_CASE_ST(ut_setup, ut_teardown,
12112 			test_snow3g_hash_generate_test_case_2),
12113 		TEST_CASE_ST(ut_setup, ut_teardown,
12114 			test_snow3g_hash_generate_test_case_3),
12115 		TEST_CASE_ST(ut_setup, ut_teardown,
12116 			test_snow3g_hash_verify_test_case_1),
12117 		TEST_CASE_ST(ut_setup, ut_teardown,
12118 			test_snow3g_hash_verify_test_case_2),
12119 		TEST_CASE_ST(ut_setup, ut_teardown,
12120 			test_snow3g_hash_verify_test_case_3),
12121 		TEST_CASE_ST(ut_setup, ut_teardown,
12122 			test_snow3g_cipher_auth_test_case_1),
12123 		TEST_CASE_ST(ut_setup, ut_teardown,
12124 			test_snow3g_auth_cipher_with_digest_test_case_1),
12125 
12126 		/** ZUC encrypt only (EEA3) */
12127 		TEST_CASE_ST(ut_setup, ut_teardown,
12128 			test_zuc_encryption_test_case_1),
12129 		TEST_CASE_ST(ut_setup, ut_teardown,
12130 			test_zuc_encryption_test_case_2),
12131 		TEST_CASE_ST(ut_setup, ut_teardown,
12132 			test_zuc_encryption_test_case_3),
12133 		TEST_CASE_ST(ut_setup, ut_teardown,
12134 			test_zuc_encryption_test_case_4),
12135 		TEST_CASE_ST(ut_setup, ut_teardown,
12136 			test_zuc_encryption_test_case_5),
12137 
12138 		/** ZUC authenticate (EIA3) */
12139 		TEST_CASE_ST(ut_setup, ut_teardown,
12140 			test_zuc_hash_generate_test_case_6),
12141 		TEST_CASE_ST(ut_setup, ut_teardown,
12142 			test_zuc_hash_generate_test_case_7),
12143 		TEST_CASE_ST(ut_setup, ut_teardown,
12144 			test_zuc_hash_generate_test_case_8),
12145 
12146 		/** ZUC alg-chain (EEA3/EIA3) */
12147 		TEST_CASE_ST(ut_setup, ut_teardown,
12148 			test_zuc_cipher_auth_test_case_1),
12149 		TEST_CASE_ST(ut_setup, ut_teardown,
12150 			test_zuc_cipher_auth_test_case_2),
12151 
12152 		/** ZUC generate auth, then encrypt (EEA3) */
12153 		TEST_CASE_ST(ut_setup, ut_teardown,
12154 			test_zuc_auth_cipher_test_case_1),
12155 		TEST_CASE_ST(ut_setup, ut_teardown,
12156 			test_zuc_auth_cipher_test_case_1_oop),
12157 		TEST_CASE_ST(ut_setup, ut_teardown,
12158 			test_zuc_auth_cipher_test_case_1_sgl),
12159 		TEST_CASE_ST(ut_setup, ut_teardown,
12160 			test_zuc_auth_cipher_test_case_1_oop_sgl),
12161 
12162 		/** ZUC decrypt (EEA3), then verify auth */
12163 		TEST_CASE_ST(ut_setup, ut_teardown,
12164 			test_zuc_auth_cipher_verify_test_case_1),
12165 		TEST_CASE_ST(ut_setup, ut_teardown,
12166 			test_zuc_auth_cipher_verify_test_case_1_oop),
12167 		TEST_CASE_ST(ut_setup, ut_teardown,
12168 			test_zuc_auth_cipher_verify_test_case_1_sgl),
12169 		TEST_CASE_ST(ut_setup, ut_teardown,
12170 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12171 
12172 		/** HMAC_MD5 Authentication */
12173 		TEST_CASE_ST(ut_setup, ut_teardown,
12174 			test_MD5_HMAC_generate_case_1),
12175 		TEST_CASE_ST(ut_setup, ut_teardown,
12176 			test_MD5_HMAC_verify_case_1),
12177 		TEST_CASE_ST(ut_setup, ut_teardown,
12178 			test_MD5_HMAC_generate_case_2),
12179 		TEST_CASE_ST(ut_setup, ut_teardown,
12180 			test_MD5_HMAC_verify_case_2),
12181 
12182 		/** NULL algo tests done in chain_all,
12183 		 * cipheronly and authonly suites
12184 		 */
12185 
12186 		/** KASUMI tests */
12187 		TEST_CASE_ST(ut_setup, ut_teardown,
12188 			test_kasumi_hash_generate_test_case_1),
12189 		TEST_CASE_ST(ut_setup, ut_teardown,
12190 			test_kasumi_hash_generate_test_case_2),
12191 		TEST_CASE_ST(ut_setup, ut_teardown,
12192 			test_kasumi_hash_generate_test_case_3),
12193 		TEST_CASE_ST(ut_setup, ut_teardown,
12194 			test_kasumi_hash_generate_test_case_4),
12195 		TEST_CASE_ST(ut_setup, ut_teardown,
12196 			test_kasumi_hash_generate_test_case_5),
12197 		TEST_CASE_ST(ut_setup, ut_teardown,
12198 			test_kasumi_hash_generate_test_case_6),
12199 
12200 		TEST_CASE_ST(ut_setup, ut_teardown,
12201 			test_kasumi_hash_verify_test_case_1),
12202 		TEST_CASE_ST(ut_setup, ut_teardown,
12203 			test_kasumi_hash_verify_test_case_2),
12204 		TEST_CASE_ST(ut_setup, ut_teardown,
12205 			test_kasumi_hash_verify_test_case_3),
12206 		TEST_CASE_ST(ut_setup, ut_teardown,
12207 			test_kasumi_hash_verify_test_case_4),
12208 		TEST_CASE_ST(ut_setup, ut_teardown,
12209 			test_kasumi_hash_verify_test_case_5),
12210 
12211 		TEST_CASE_ST(ut_setup, ut_teardown,
12212 			test_kasumi_encryption_test_case_1),
12213 		TEST_CASE_ST(ut_setup, ut_teardown,
12214 			test_kasumi_encryption_test_case_3),
12215 		TEST_CASE_ST(ut_setup, ut_teardown,
12216 			test_kasumi_cipher_auth_test_case_1),
12217 
12218 		/** KASUMI generate auth, then encrypt (F8) */
12219 		TEST_CASE_ST(ut_setup, ut_teardown,
12220 			test_kasumi_auth_cipher_test_case_1),
12221 		TEST_CASE_ST(ut_setup, ut_teardown,
12222 			test_kasumi_auth_cipher_test_case_2),
12223 		TEST_CASE_ST(ut_setup, ut_teardown,
12224 			test_kasumi_auth_cipher_test_case_2_oop),
12225 		TEST_CASE_ST(ut_setup, ut_teardown,
12226 			test_kasumi_auth_cipher_test_case_2_sgl),
12227 		TEST_CASE_ST(ut_setup, ut_teardown,
12228 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
12229 
12230 		/** KASUMI decrypt (F8), then verify auth */
12231 		TEST_CASE_ST(ut_setup, ut_teardown,
12232 			test_kasumi_auth_cipher_verify_test_case_1),
12233 		TEST_CASE_ST(ut_setup, ut_teardown,
12234 			test_kasumi_auth_cipher_verify_test_case_2),
12235 		TEST_CASE_ST(ut_setup, ut_teardown,
12236 			test_kasumi_auth_cipher_verify_test_case_2_oop),
12237 		TEST_CASE_ST(ut_setup, ut_teardown,
12238 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
12239 		TEST_CASE_ST(ut_setup, ut_teardown,
12240 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12241 
12242 		/** Negative tests */
12243 		TEST_CASE_ST(ut_setup, ut_teardown,
12244 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
12245 		TEST_CASE_ST(ut_setup, ut_teardown,
12246 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12247 		TEST_CASE_ST(ut_setup, ut_teardown,
12248 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
12249 		TEST_CASE_ST(ut_setup, ut_teardown,
12250 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12251 		TEST_CASE_ST(ut_setup, ut_teardown,
12252 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12253 		TEST_CASE_ST(ut_setup, ut_teardown,
12254 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12255 		TEST_CASE_ST(ut_setup, ut_teardown,
12256 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
12257 		TEST_CASE_ST(ut_setup, ut_teardown,
12258 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
12259 		TEST_CASE_ST(ut_setup, ut_teardown,
12260 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
12261 		TEST_CASE_ST(ut_setup, ut_teardown,
12262 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12263 		TEST_CASE_ST(ut_setup, ut_teardown,
12264 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12265 		TEST_CASE_ST(ut_setup, ut_teardown,
12266 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12267 		TEST_CASE_ST(ut_setup, ut_teardown,
12268 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
12269 		TEST_CASE_ST(ut_setup, ut_teardown,
12270 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
12271 		TEST_CASE_ST(ut_setup, ut_teardown,
12272 			authentication_verify_AES128_GMAC_fail_data_corrupt),
12273 		TEST_CASE_ST(ut_setup, ut_teardown,
12274 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
12275 		TEST_CASE_ST(ut_setup, ut_teardown,
12276 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12277 		TEST_CASE_ST(ut_setup, ut_teardown,
12278 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12279 
12280 		/** Mixed CIPHER + HASH algorithms */
12281 		/** AUTH AES CMAC + CIPHER AES CTR */
12282 		TEST_CASE_ST(ut_setup, ut_teardown,
12283 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12284 		TEST_CASE_ST(ut_setup, ut_teardown,
12285 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12286 		TEST_CASE_ST(ut_setup, ut_teardown,
12287 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12288 		TEST_CASE_ST(ut_setup, ut_teardown,
12289 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12290 		TEST_CASE_ST(ut_setup, ut_teardown,
12291 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12292 		TEST_CASE_ST(ut_setup, ut_teardown,
12293 		       test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12294 		TEST_CASE_ST(ut_setup, ut_teardown,
12295 		       test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12296 		TEST_CASE_ST(ut_setup, ut_teardown,
12297 		   test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12298 
12299 		TEST_CASES_END() /**< NULL terminate unit test array */
12300 	}
12301 };
12302 
12303 static struct unit_test_suite cryptodev_virtio_testsuite = {
12304 	.suite_name = "Crypto VIRTIO Unit Test Suite",
12305 	.setup = testsuite_setup,
12306 	.teardown = testsuite_teardown,
12307 	.unit_test_cases = {
12308 		TEST_CASE_ST(ut_setup, ut_teardown,
12309 				test_AES_cipheronly_virtio_all),
12310 
12311 		TEST_CASES_END() /**< NULL terminate unit test array */
12312 	}
12313 };
12314 
12315 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
12316 	.suite_name = "Crypto Device AESNI MB Unit Test Suite",
12317 	.setup = testsuite_setup,
12318 	.teardown = testsuite_teardown,
12319 	.unit_test_cases = {
12320 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12321 		TEST_CASE_ST(ut_setup, ut_teardown,
12322 			test_AES_GCM_authenticated_encryption_test_case_1),
12323 		TEST_CASE_ST(ut_setup, ut_teardown,
12324 			test_AES_GCM_authenticated_encryption_test_case_2),
12325 		TEST_CASE_ST(ut_setup, ut_teardown,
12326 			test_AES_GCM_authenticated_encryption_test_case_3),
12327 		TEST_CASE_ST(ut_setup, ut_teardown,
12328 			test_AES_GCM_authenticated_encryption_test_case_4),
12329 		TEST_CASE_ST(ut_setup, ut_teardown,
12330 			test_AES_GCM_authenticated_encryption_test_case_5),
12331 		TEST_CASE_ST(ut_setup, ut_teardown,
12332 			test_AES_GCM_authenticated_encryption_test_case_6),
12333 		TEST_CASE_ST(ut_setup, ut_teardown,
12334 			test_AES_GCM_authenticated_encryption_test_case_7),
12335 
12336 		/** AES GCM Authenticated Decryption */
12337 		TEST_CASE_ST(ut_setup, ut_teardown,
12338 			test_AES_GCM_authenticated_decryption_test_case_1),
12339 		TEST_CASE_ST(ut_setup, ut_teardown,
12340 			test_AES_GCM_authenticated_decryption_test_case_2),
12341 		TEST_CASE_ST(ut_setup, ut_teardown,
12342 			test_AES_GCM_authenticated_decryption_test_case_3),
12343 		TEST_CASE_ST(ut_setup, ut_teardown,
12344 			test_AES_GCM_authenticated_decryption_test_case_4),
12345 		TEST_CASE_ST(ut_setup, ut_teardown,
12346 			test_AES_GCM_authenticated_decryption_test_case_5),
12347 		TEST_CASE_ST(ut_setup, ut_teardown,
12348 			test_AES_GCM_authenticated_decryption_test_case_6),
12349 		TEST_CASE_ST(ut_setup, ut_teardown,
12350 			test_AES_GCM_authenticated_decryption_test_case_7),
12351 
12352 		/** AES GCM Authenticated Encryption 192 bits key */
12353 		TEST_CASE_ST(ut_setup, ut_teardown,
12354 			test_AES_GCM_auth_encryption_test_case_192_1),
12355 		TEST_CASE_ST(ut_setup, ut_teardown,
12356 			test_AES_GCM_auth_encryption_test_case_192_2),
12357 		TEST_CASE_ST(ut_setup, ut_teardown,
12358 			test_AES_GCM_auth_encryption_test_case_192_3),
12359 		TEST_CASE_ST(ut_setup, ut_teardown,
12360 			test_AES_GCM_auth_encryption_test_case_192_4),
12361 		TEST_CASE_ST(ut_setup, ut_teardown,
12362 			test_AES_GCM_auth_encryption_test_case_192_5),
12363 		TEST_CASE_ST(ut_setup, ut_teardown,
12364 			test_AES_GCM_auth_encryption_test_case_192_6),
12365 		TEST_CASE_ST(ut_setup, ut_teardown,
12366 			test_AES_GCM_auth_encryption_test_case_192_7),
12367 
12368 		/** AES GCM Authenticated Decryption 192 bits key */
12369 		TEST_CASE_ST(ut_setup, ut_teardown,
12370 			test_AES_GCM_auth_decryption_test_case_192_1),
12371 		TEST_CASE_ST(ut_setup, ut_teardown,
12372 			test_AES_GCM_auth_decryption_test_case_192_2),
12373 		TEST_CASE_ST(ut_setup, ut_teardown,
12374 			test_AES_GCM_auth_decryption_test_case_192_3),
12375 		TEST_CASE_ST(ut_setup, ut_teardown,
12376 			test_AES_GCM_auth_decryption_test_case_192_4),
12377 		TEST_CASE_ST(ut_setup, ut_teardown,
12378 			test_AES_GCM_auth_decryption_test_case_192_5),
12379 		TEST_CASE_ST(ut_setup, ut_teardown,
12380 			test_AES_GCM_auth_decryption_test_case_192_6),
12381 		TEST_CASE_ST(ut_setup, ut_teardown,
12382 			test_AES_GCM_auth_decryption_test_case_192_7),
12383 
12384 		/** AES GCM Authenticated Encryption 256 bits key */
12385 		TEST_CASE_ST(ut_setup, ut_teardown,
12386 			test_AES_GCM_auth_encryption_test_case_256_1),
12387 		TEST_CASE_ST(ut_setup, ut_teardown,
12388 			test_AES_GCM_auth_encryption_test_case_256_2),
12389 		TEST_CASE_ST(ut_setup, ut_teardown,
12390 			test_AES_GCM_auth_encryption_test_case_256_3),
12391 		TEST_CASE_ST(ut_setup, ut_teardown,
12392 			test_AES_GCM_auth_encryption_test_case_256_4),
12393 		TEST_CASE_ST(ut_setup, ut_teardown,
12394 			test_AES_GCM_auth_encryption_test_case_256_5),
12395 		TEST_CASE_ST(ut_setup, ut_teardown,
12396 			test_AES_GCM_auth_encryption_test_case_256_6),
12397 		TEST_CASE_ST(ut_setup, ut_teardown,
12398 			test_AES_GCM_auth_encryption_test_case_256_7),
12399 
12400 		/** AES GCM Authenticated Decryption 256 bits key */
12401 		TEST_CASE_ST(ut_setup, ut_teardown,
12402 			test_AES_GCM_auth_decryption_test_case_256_1),
12403 		TEST_CASE_ST(ut_setup, ut_teardown,
12404 			test_AES_GCM_auth_decryption_test_case_256_2),
12405 		TEST_CASE_ST(ut_setup, ut_teardown,
12406 			test_AES_GCM_auth_decryption_test_case_256_3),
12407 		TEST_CASE_ST(ut_setup, ut_teardown,
12408 			test_AES_GCM_auth_decryption_test_case_256_4),
12409 		TEST_CASE_ST(ut_setup, ut_teardown,
12410 			test_AES_GCM_auth_decryption_test_case_256_5),
12411 		TEST_CASE_ST(ut_setup, ut_teardown,
12412 			test_AES_GCM_auth_decryption_test_case_256_6),
12413 		TEST_CASE_ST(ut_setup, ut_teardown,
12414 			test_AES_GCM_auth_decryption_test_case_256_7),
12415 
12416 		/** AES GCM Authenticated Encryption big aad size */
12417 		TEST_CASE_ST(ut_setup, ut_teardown,
12418 			test_AES_GCM_auth_encryption_test_case_aad_1),
12419 		TEST_CASE_ST(ut_setup, ut_teardown,
12420 			test_AES_GCM_auth_encryption_test_case_aad_2),
12421 
12422 		/** AES GCM Authenticated Decryption big aad size */
12423 		TEST_CASE_ST(ut_setup, ut_teardown,
12424 			test_AES_GCM_auth_decryption_test_case_aad_1),
12425 		TEST_CASE_ST(ut_setup, ut_teardown,
12426 			test_AES_GCM_auth_decryption_test_case_aad_2),
12427 
12428 		/** Session-less tests */
12429 		TEST_CASE_ST(ut_setup, ut_teardown,
12430 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12431 		TEST_CASE_ST(ut_setup, ut_teardown,
12432 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12433 
12434 		/** AES GMAC Authentication */
12435 		TEST_CASE_ST(ut_setup, ut_teardown,
12436 			test_AES_GMAC_authentication_test_case_1),
12437 		TEST_CASE_ST(ut_setup, ut_teardown,
12438 			test_AES_GMAC_authentication_verify_test_case_1),
12439 		TEST_CASE_ST(ut_setup, ut_teardown,
12440 			test_AES_GMAC_authentication_test_case_2),
12441 		TEST_CASE_ST(ut_setup, ut_teardown,
12442 			test_AES_GMAC_authentication_verify_test_case_2),
12443 		TEST_CASE_ST(ut_setup, ut_teardown,
12444 			test_AES_GMAC_authentication_test_case_3),
12445 		TEST_CASE_ST(ut_setup, ut_teardown,
12446 			test_AES_GMAC_authentication_verify_test_case_3),
12447 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12448 
12449 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12450 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12451 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12452 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12453 		TEST_CASE_ST(ut_setup, ut_teardown,
12454 						test_DES_cipheronly_mb_all),
12455 		TEST_CASE_ST(ut_setup, ut_teardown,
12456 						test_DES_docsis_mb_all),
12457 		TEST_CASE_ST(ut_setup, ut_teardown,
12458 						test_3DES_cipheronly_mb_all),
12459 		TEST_CASE_ST(ut_setup, ut_teardown,
12460 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12461 		TEST_CASE_ST(ut_setup, ut_teardown,
12462 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12463 		TEST_CASE_ST(ut_setup, ut_teardown,
12464 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12465 		TEST_CASE_ST(ut_setup, ut_teardown,
12466 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12467 		TEST_CASE_ST(ut_setup, ut_teardown,
12468 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12469 		TEST_CASE_ST(ut_setup, ut_teardown,
12470 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12471 
12472 		TEST_CASES_END() /**< NULL terminate unit test array */
12473 	}
12474 };
12475 
12476 static struct unit_test_suite cryptodev_openssl_testsuite  = {
12477 	.suite_name = "Crypto Device OPENSSL Unit Test Suite",
12478 	.setup = testsuite_setup,
12479 	.teardown = testsuite_teardown,
12480 	.unit_test_cases = {
12481 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12482 		TEST_CASE_ST(ut_setup, ut_teardown,
12483 				test_multi_session_random_usage),
12484 		TEST_CASE_ST(ut_setup, ut_teardown,
12485 				test_AES_chain_openssl_all),
12486 		TEST_CASE_ST(ut_setup, ut_teardown,
12487 				test_AES_cipheronly_openssl_all),
12488 		TEST_CASE_ST(ut_setup, ut_teardown,
12489 				test_3DES_chain_openssl_all),
12490 		TEST_CASE_ST(ut_setup, ut_teardown,
12491 				test_3DES_cipheronly_openssl_all),
12492 		TEST_CASE_ST(ut_setup, ut_teardown,
12493 				test_DES_cipheronly_openssl_all),
12494 		TEST_CASE_ST(ut_setup, ut_teardown,
12495 				test_DES_docsis_openssl_all),
12496 		TEST_CASE_ST(ut_setup, ut_teardown,
12497 				test_authonly_openssl_all),
12498 
12499 		/** AES GCM Authenticated Encryption */
12500 		TEST_CASE_ST(ut_setup, ut_teardown,
12501 			test_AES_GCM_authenticated_encryption_test_case_1),
12502 		TEST_CASE_ST(ut_setup, ut_teardown,
12503 			test_AES_GCM_authenticated_encryption_test_case_2),
12504 		TEST_CASE_ST(ut_setup, ut_teardown,
12505 			test_AES_GCM_authenticated_encryption_test_case_3),
12506 		TEST_CASE_ST(ut_setup, ut_teardown,
12507 			test_AES_GCM_authenticated_encryption_test_case_4),
12508 		TEST_CASE_ST(ut_setup, ut_teardown,
12509 			test_AES_GCM_authenticated_encryption_test_case_5),
12510 		TEST_CASE_ST(ut_setup, ut_teardown,
12511 			test_AES_GCM_authenticated_encryption_test_case_6),
12512 		TEST_CASE_ST(ut_setup, ut_teardown,
12513 			test_AES_GCM_authenticated_encryption_test_case_7),
12514 
12515 		/** AES GCM Authenticated Decryption */
12516 		TEST_CASE_ST(ut_setup, ut_teardown,
12517 			test_AES_GCM_authenticated_decryption_test_case_1),
12518 		TEST_CASE_ST(ut_setup, ut_teardown,
12519 			test_AES_GCM_authenticated_decryption_test_case_2),
12520 		TEST_CASE_ST(ut_setup, ut_teardown,
12521 			test_AES_GCM_authenticated_decryption_test_case_3),
12522 		TEST_CASE_ST(ut_setup, ut_teardown,
12523 			test_AES_GCM_authenticated_decryption_test_case_4),
12524 		TEST_CASE_ST(ut_setup, ut_teardown,
12525 			test_AES_GCM_authenticated_decryption_test_case_5),
12526 		TEST_CASE_ST(ut_setup, ut_teardown,
12527 			test_AES_GCM_authenticated_decryption_test_case_6),
12528 		TEST_CASE_ST(ut_setup, ut_teardown,
12529 			test_AES_GCM_authenticated_decryption_test_case_7),
12530 
12531 
12532 		/** AES GCM Authenticated Encryption 192 bits key */
12533 		TEST_CASE_ST(ut_setup, ut_teardown,
12534 			test_AES_GCM_auth_encryption_test_case_192_1),
12535 		TEST_CASE_ST(ut_setup, ut_teardown,
12536 			test_AES_GCM_auth_encryption_test_case_192_2),
12537 		TEST_CASE_ST(ut_setup, ut_teardown,
12538 			test_AES_GCM_auth_encryption_test_case_192_3),
12539 		TEST_CASE_ST(ut_setup, ut_teardown,
12540 			test_AES_GCM_auth_encryption_test_case_192_4),
12541 		TEST_CASE_ST(ut_setup, ut_teardown,
12542 			test_AES_GCM_auth_encryption_test_case_192_5),
12543 		TEST_CASE_ST(ut_setup, ut_teardown,
12544 			test_AES_GCM_auth_encryption_test_case_192_6),
12545 		TEST_CASE_ST(ut_setup, ut_teardown,
12546 			test_AES_GCM_auth_encryption_test_case_192_7),
12547 
12548 		/** AES GCM Authenticated Decryption 192 bits key */
12549 		TEST_CASE_ST(ut_setup, ut_teardown,
12550 			test_AES_GCM_auth_decryption_test_case_192_1),
12551 		TEST_CASE_ST(ut_setup, ut_teardown,
12552 			test_AES_GCM_auth_decryption_test_case_192_2),
12553 		TEST_CASE_ST(ut_setup, ut_teardown,
12554 			test_AES_GCM_auth_decryption_test_case_192_3),
12555 		TEST_CASE_ST(ut_setup, ut_teardown,
12556 			test_AES_GCM_auth_decryption_test_case_192_4),
12557 		TEST_CASE_ST(ut_setup, ut_teardown,
12558 			test_AES_GCM_auth_decryption_test_case_192_5),
12559 		TEST_CASE_ST(ut_setup, ut_teardown,
12560 			test_AES_GCM_auth_decryption_test_case_192_6),
12561 		TEST_CASE_ST(ut_setup, ut_teardown,
12562 			test_AES_GCM_auth_decryption_test_case_192_7),
12563 
12564 		/** AES GCM Authenticated Encryption 256 bits key */
12565 		TEST_CASE_ST(ut_setup, ut_teardown,
12566 			test_AES_GCM_auth_encryption_test_case_256_1),
12567 		TEST_CASE_ST(ut_setup, ut_teardown,
12568 			test_AES_GCM_auth_encryption_test_case_256_2),
12569 		TEST_CASE_ST(ut_setup, ut_teardown,
12570 			test_AES_GCM_auth_encryption_test_case_256_3),
12571 		TEST_CASE_ST(ut_setup, ut_teardown,
12572 			test_AES_GCM_auth_encryption_test_case_256_4),
12573 		TEST_CASE_ST(ut_setup, ut_teardown,
12574 			test_AES_GCM_auth_encryption_test_case_256_5),
12575 		TEST_CASE_ST(ut_setup, ut_teardown,
12576 			test_AES_GCM_auth_encryption_test_case_256_6),
12577 		TEST_CASE_ST(ut_setup, ut_teardown,
12578 			test_AES_GCM_auth_encryption_test_case_256_7),
12579 
12580 		/** AES GCM Authenticated Decryption 256 bits key */
12581 		TEST_CASE_ST(ut_setup, ut_teardown,
12582 			test_AES_GCM_auth_decryption_test_case_256_1),
12583 		TEST_CASE_ST(ut_setup, ut_teardown,
12584 			test_AES_GCM_auth_decryption_test_case_256_2),
12585 		TEST_CASE_ST(ut_setup, ut_teardown,
12586 			test_AES_GCM_auth_decryption_test_case_256_3),
12587 		TEST_CASE_ST(ut_setup, ut_teardown,
12588 			test_AES_GCM_auth_decryption_test_case_256_4),
12589 		TEST_CASE_ST(ut_setup, ut_teardown,
12590 			test_AES_GCM_auth_decryption_test_case_256_5),
12591 		TEST_CASE_ST(ut_setup, ut_teardown,
12592 			test_AES_GCM_auth_decryption_test_case_256_6),
12593 		TEST_CASE_ST(ut_setup, ut_teardown,
12594 			test_AES_GCM_auth_decryption_test_case_256_7),
12595 
12596 		/** AES GMAC Authentication */
12597 		TEST_CASE_ST(ut_setup, ut_teardown,
12598 			test_AES_GMAC_authentication_test_case_1),
12599 		TEST_CASE_ST(ut_setup, ut_teardown,
12600 			test_AES_GMAC_authentication_verify_test_case_1),
12601 		TEST_CASE_ST(ut_setup, ut_teardown,
12602 			test_AES_GMAC_authentication_test_case_2),
12603 		TEST_CASE_ST(ut_setup, ut_teardown,
12604 			test_AES_GMAC_authentication_verify_test_case_2),
12605 		TEST_CASE_ST(ut_setup, ut_teardown,
12606 			test_AES_GMAC_authentication_test_case_3),
12607 		TEST_CASE_ST(ut_setup, ut_teardown,
12608 			test_AES_GMAC_authentication_verify_test_case_3),
12609 		TEST_CASE_ST(ut_setup, ut_teardown,
12610 			test_AES_GMAC_authentication_test_case_4),
12611 		TEST_CASE_ST(ut_setup, ut_teardown,
12612 			test_AES_GMAC_authentication_verify_test_case_4),
12613 
12614 		/** AES CCM Authenticated Encryption 128 bits key */
12615 		TEST_CASE_ST(ut_setup, ut_teardown,
12616 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12617 		TEST_CASE_ST(ut_setup, ut_teardown,
12618 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12619 		TEST_CASE_ST(ut_setup, ut_teardown,
12620 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12621 
12622 		/** AES CCM Authenticated Decryption 128 bits key*/
12623 		TEST_CASE_ST(ut_setup, ut_teardown,
12624 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12625 		TEST_CASE_ST(ut_setup, ut_teardown,
12626 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12627 		TEST_CASE_ST(ut_setup, ut_teardown,
12628 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12629 
12630 		/** AES CCM Authenticated Encryption 192 bits key */
12631 		TEST_CASE_ST(ut_setup, ut_teardown,
12632 			test_AES_CCM_authenticated_encryption_test_case_192_1),
12633 		TEST_CASE_ST(ut_setup, ut_teardown,
12634 			test_AES_CCM_authenticated_encryption_test_case_192_2),
12635 		TEST_CASE_ST(ut_setup, ut_teardown,
12636 			test_AES_CCM_authenticated_encryption_test_case_192_3),
12637 
12638 		/** AES CCM Authenticated Decryption 192 bits key*/
12639 		TEST_CASE_ST(ut_setup, ut_teardown,
12640 			test_AES_CCM_authenticated_decryption_test_case_192_1),
12641 		TEST_CASE_ST(ut_setup, ut_teardown,
12642 			test_AES_CCM_authenticated_decryption_test_case_192_2),
12643 		TEST_CASE_ST(ut_setup, ut_teardown,
12644 			test_AES_CCM_authenticated_decryption_test_case_192_3),
12645 
12646 		/** AES CCM Authenticated Encryption 256 bits key */
12647 		TEST_CASE_ST(ut_setup, ut_teardown,
12648 			test_AES_CCM_authenticated_encryption_test_case_256_1),
12649 		TEST_CASE_ST(ut_setup, ut_teardown,
12650 			test_AES_CCM_authenticated_encryption_test_case_256_2),
12651 		TEST_CASE_ST(ut_setup, ut_teardown,
12652 			test_AES_CCM_authenticated_encryption_test_case_256_3),
12653 
12654 		/** AES CCM Authenticated Decryption 256 bits key*/
12655 		TEST_CASE_ST(ut_setup, ut_teardown,
12656 			test_AES_CCM_authenticated_decryption_test_case_256_1),
12657 		TEST_CASE_ST(ut_setup, ut_teardown,
12658 			test_AES_CCM_authenticated_decryption_test_case_256_2),
12659 		TEST_CASE_ST(ut_setup, ut_teardown,
12660 			test_AES_CCM_authenticated_decryption_test_case_256_3),
12661 
12662 		/** Scatter-Gather */
12663 		TEST_CASE_ST(ut_setup, ut_teardown,
12664 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12665 
12666 		/** Negative tests */
12667 		TEST_CASE_ST(ut_setup, ut_teardown,
12668 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
12669 		TEST_CASE_ST(ut_setup, ut_teardown,
12670 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12671 		TEST_CASE_ST(ut_setup, ut_teardown,
12672 			authentication_verify_AES128_GMAC_fail_data_corrupt),
12673 		TEST_CASE_ST(ut_setup, ut_teardown,
12674 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
12675 		TEST_CASE_ST(ut_setup, ut_teardown,
12676 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12677 		TEST_CASE_ST(ut_setup, ut_teardown,
12678 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12679 
12680 		/* ESN Testcase */
12681 		TEST_CASE_ST(ut_setup, ut_teardown,
12682 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12683 
12684 		TEST_CASE_ST(ut_setup, ut_teardown,
12685 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12686 
12687 		TEST_CASES_END() /**< NULL terminate unit test array */
12688 	}
12689 };
12690 
12691 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
12692 	.suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12693 	.setup = testsuite_setup,
12694 	.teardown = testsuite_teardown,
12695 	.unit_test_cases = {
12696 		/** AES GCM Authenticated Encryption */
12697 		TEST_CASE_ST(ut_setup, ut_teardown,
12698 			test_AES_GCM_authenticated_encryption_test_case_1),
12699 		TEST_CASE_ST(ut_setup, ut_teardown,
12700 			test_AES_GCM_authenticated_encryption_test_case_2),
12701 		TEST_CASE_ST(ut_setup, ut_teardown,
12702 			test_AES_GCM_authenticated_encryption_test_case_3),
12703 		TEST_CASE_ST(ut_setup, ut_teardown,
12704 			test_AES_GCM_authenticated_encryption_test_case_4),
12705 		TEST_CASE_ST(ut_setup, ut_teardown,
12706 			test_AES_GCM_authenticated_encryption_test_case_5),
12707 		TEST_CASE_ST(ut_setup, ut_teardown,
12708 			test_AES_GCM_authenticated_encryption_test_case_6),
12709 		TEST_CASE_ST(ut_setup, ut_teardown,
12710 			test_AES_GCM_authenticated_encryption_test_case_7),
12711 
12712 		/** AES GCM Authenticated Decryption */
12713 		TEST_CASE_ST(ut_setup, ut_teardown,
12714 			test_AES_GCM_authenticated_decryption_test_case_1),
12715 		TEST_CASE_ST(ut_setup, ut_teardown,
12716 			test_AES_GCM_authenticated_decryption_test_case_2),
12717 		TEST_CASE_ST(ut_setup, ut_teardown,
12718 			test_AES_GCM_authenticated_decryption_test_case_3),
12719 		TEST_CASE_ST(ut_setup, ut_teardown,
12720 			test_AES_GCM_authenticated_decryption_test_case_4),
12721 		TEST_CASE_ST(ut_setup, ut_teardown,
12722 			test_AES_GCM_authenticated_decryption_test_case_5),
12723 		TEST_CASE_ST(ut_setup, ut_teardown,
12724 			test_AES_GCM_authenticated_decryption_test_case_6),
12725 		TEST_CASE_ST(ut_setup, ut_teardown,
12726 			test_AES_GCM_authenticated_decryption_test_case_7),
12727 
12728 		/** AES GCM Authenticated Encryption 192 bits key */
12729 		TEST_CASE_ST(ut_setup, ut_teardown,
12730 			test_AES_GCM_auth_encryption_test_case_192_1),
12731 		TEST_CASE_ST(ut_setup, ut_teardown,
12732 			test_AES_GCM_auth_encryption_test_case_192_2),
12733 		TEST_CASE_ST(ut_setup, ut_teardown,
12734 			test_AES_GCM_auth_encryption_test_case_192_3),
12735 		TEST_CASE_ST(ut_setup, ut_teardown,
12736 			test_AES_GCM_auth_encryption_test_case_192_4),
12737 		TEST_CASE_ST(ut_setup, ut_teardown,
12738 			test_AES_GCM_auth_encryption_test_case_192_5),
12739 		TEST_CASE_ST(ut_setup, ut_teardown,
12740 			test_AES_GCM_auth_encryption_test_case_192_6),
12741 		TEST_CASE_ST(ut_setup, ut_teardown,
12742 			test_AES_GCM_auth_encryption_test_case_192_7),
12743 
12744 		/** AES GCM Authenticated Decryption 192 bits key */
12745 		TEST_CASE_ST(ut_setup, ut_teardown,
12746 			test_AES_GCM_auth_decryption_test_case_192_1),
12747 		TEST_CASE_ST(ut_setup, ut_teardown,
12748 			test_AES_GCM_auth_decryption_test_case_192_2),
12749 		TEST_CASE_ST(ut_setup, ut_teardown,
12750 			test_AES_GCM_auth_decryption_test_case_192_3),
12751 		TEST_CASE_ST(ut_setup, ut_teardown,
12752 			test_AES_GCM_auth_decryption_test_case_192_4),
12753 		TEST_CASE_ST(ut_setup, ut_teardown,
12754 			test_AES_GCM_auth_decryption_test_case_192_5),
12755 		TEST_CASE_ST(ut_setup, ut_teardown,
12756 			test_AES_GCM_auth_decryption_test_case_192_6),
12757 		TEST_CASE_ST(ut_setup, ut_teardown,
12758 			test_AES_GCM_auth_decryption_test_case_192_7),
12759 
12760 		/** AES GCM Authenticated Encryption 256 bits key */
12761 		TEST_CASE_ST(ut_setup, ut_teardown,
12762 			test_AES_GCM_auth_encryption_test_case_256_1),
12763 		TEST_CASE_ST(ut_setup, ut_teardown,
12764 			test_AES_GCM_auth_encryption_test_case_256_2),
12765 		TEST_CASE_ST(ut_setup, ut_teardown,
12766 			test_AES_GCM_auth_encryption_test_case_256_3),
12767 		TEST_CASE_ST(ut_setup, ut_teardown,
12768 			test_AES_GCM_auth_encryption_test_case_256_4),
12769 		TEST_CASE_ST(ut_setup, ut_teardown,
12770 			test_AES_GCM_auth_encryption_test_case_256_5),
12771 		TEST_CASE_ST(ut_setup, ut_teardown,
12772 			test_AES_GCM_auth_encryption_test_case_256_6),
12773 		TEST_CASE_ST(ut_setup, ut_teardown,
12774 			test_AES_GCM_auth_encryption_test_case_256_7),
12775 
12776 		/** AES GCM Authenticated Decryption 256 bits key */
12777 		TEST_CASE_ST(ut_setup, ut_teardown,
12778 			test_AES_GCM_auth_decryption_test_case_256_1),
12779 		TEST_CASE_ST(ut_setup, ut_teardown,
12780 			test_AES_GCM_auth_decryption_test_case_256_2),
12781 		TEST_CASE_ST(ut_setup, ut_teardown,
12782 			test_AES_GCM_auth_decryption_test_case_256_3),
12783 		TEST_CASE_ST(ut_setup, ut_teardown,
12784 			test_AES_GCM_auth_decryption_test_case_256_4),
12785 		TEST_CASE_ST(ut_setup, ut_teardown,
12786 			test_AES_GCM_auth_decryption_test_case_256_5),
12787 		TEST_CASE_ST(ut_setup, ut_teardown,
12788 			test_AES_GCM_auth_decryption_test_case_256_6),
12789 		TEST_CASE_ST(ut_setup, ut_teardown,
12790 			test_AES_GCM_auth_decryption_test_case_256_7),
12791 
12792 		/** AES GCM Authenticated Encryption big aad size */
12793 		TEST_CASE_ST(ut_setup, ut_teardown,
12794 			test_AES_GCM_auth_encryption_test_case_aad_1),
12795 		TEST_CASE_ST(ut_setup, ut_teardown,
12796 			test_AES_GCM_auth_encryption_test_case_aad_2),
12797 
12798 		/** AES GCM Authenticated Decryption big aad size */
12799 		TEST_CASE_ST(ut_setup, ut_teardown,
12800 			test_AES_GCM_auth_decryption_test_case_aad_1),
12801 		TEST_CASE_ST(ut_setup, ut_teardown,
12802 			test_AES_GCM_auth_decryption_test_case_aad_2),
12803 
12804 		/** AES GMAC Authentication */
12805 		TEST_CASE_ST(ut_setup, ut_teardown,
12806 			test_AES_GMAC_authentication_test_case_1),
12807 		TEST_CASE_ST(ut_setup, ut_teardown,
12808 			test_AES_GMAC_authentication_verify_test_case_1),
12809 		TEST_CASE_ST(ut_setup, ut_teardown,
12810 			test_AES_GMAC_authentication_test_case_3),
12811 		TEST_CASE_ST(ut_setup, ut_teardown,
12812 			test_AES_GMAC_authentication_verify_test_case_3),
12813 		TEST_CASE_ST(ut_setup, ut_teardown,
12814 			test_AES_GMAC_authentication_test_case_4),
12815 		TEST_CASE_ST(ut_setup, ut_teardown,
12816 			test_AES_GMAC_authentication_verify_test_case_4),
12817 
12818 		/** Negative tests */
12819 		TEST_CASE_ST(ut_setup, ut_teardown,
12820 			authentication_verify_AES128_GMAC_fail_data_corrupt),
12821 		TEST_CASE_ST(ut_setup, ut_teardown,
12822 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
12823 
12824 		/** Out of place tests */
12825 		TEST_CASE_ST(ut_setup, ut_teardown,
12826 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
12827 		TEST_CASE_ST(ut_setup, ut_teardown,
12828 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
12829 
12830 		/** Session-less tests */
12831 		TEST_CASE_ST(ut_setup, ut_teardown,
12832 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12833 		TEST_CASE_ST(ut_setup, ut_teardown,
12834 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12835 
12836 		/** Scatter-Gather */
12837 		TEST_CASE_ST(ut_setup, ut_teardown,
12838 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12839 		TEST_CASE_ST(ut_setup, ut_teardown,
12840 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12841 
12842 		TEST_CASES_END() /**< NULL terminate unit test array */
12843 	}
12844 };
12845 
12846 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
12847 	.suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12848 	.setup = testsuite_setup,
12849 	.teardown = testsuite_teardown,
12850 	.unit_test_cases = {
12851 		/** KASUMI encrypt only (UEA1) */
12852 		TEST_CASE_ST(ut_setup, ut_teardown,
12853 			test_kasumi_encryption_test_case_1),
12854 		TEST_CASE_ST(ut_setup, ut_teardown,
12855 			test_kasumi_encryption_test_case_1_sgl),
12856 		TEST_CASE_ST(ut_setup, ut_teardown,
12857 			test_kasumi_encryption_test_case_2),
12858 		TEST_CASE_ST(ut_setup, ut_teardown,
12859 			test_kasumi_encryption_test_case_3),
12860 		TEST_CASE_ST(ut_setup, ut_teardown,
12861 			test_kasumi_encryption_test_case_4),
12862 		TEST_CASE_ST(ut_setup, ut_teardown,
12863 			test_kasumi_encryption_test_case_5),
12864 		/** KASUMI decrypt only (UEA1) */
12865 		TEST_CASE_ST(ut_setup, ut_teardown,
12866 			test_kasumi_decryption_test_case_1),
12867 		TEST_CASE_ST(ut_setup, ut_teardown,
12868 			test_kasumi_decryption_test_case_2),
12869 		TEST_CASE_ST(ut_setup, ut_teardown,
12870 			test_kasumi_decryption_test_case_3),
12871 		TEST_CASE_ST(ut_setup, ut_teardown,
12872 			test_kasumi_decryption_test_case_4),
12873 		TEST_CASE_ST(ut_setup, ut_teardown,
12874 			test_kasumi_decryption_test_case_5),
12875 
12876 		TEST_CASE_ST(ut_setup, ut_teardown,
12877 			test_kasumi_encryption_test_case_1_oop),
12878 		TEST_CASE_ST(ut_setup, ut_teardown,
12879 			test_kasumi_encryption_test_case_1_oop_sgl),
12880 
12881 
12882 		TEST_CASE_ST(ut_setup, ut_teardown,
12883 			test_kasumi_decryption_test_case_1_oop),
12884 
12885 		/** KASUMI hash only (UIA1) */
12886 		TEST_CASE_ST(ut_setup, ut_teardown,
12887 			test_kasumi_hash_generate_test_case_1),
12888 		TEST_CASE_ST(ut_setup, ut_teardown,
12889 			test_kasumi_hash_generate_test_case_2),
12890 		TEST_CASE_ST(ut_setup, ut_teardown,
12891 			test_kasumi_hash_generate_test_case_3),
12892 		TEST_CASE_ST(ut_setup, ut_teardown,
12893 			test_kasumi_hash_generate_test_case_4),
12894 		TEST_CASE_ST(ut_setup, ut_teardown,
12895 			test_kasumi_hash_generate_test_case_5),
12896 		TEST_CASE_ST(ut_setup, ut_teardown,
12897 			test_kasumi_hash_generate_test_case_6),
12898 		TEST_CASE_ST(ut_setup, ut_teardown,
12899 			test_kasumi_hash_verify_test_case_1),
12900 		TEST_CASE_ST(ut_setup, ut_teardown,
12901 			test_kasumi_hash_verify_test_case_2),
12902 		TEST_CASE_ST(ut_setup, ut_teardown,
12903 			test_kasumi_hash_verify_test_case_3),
12904 		TEST_CASE_ST(ut_setup, ut_teardown,
12905 			test_kasumi_hash_verify_test_case_4),
12906 		TEST_CASE_ST(ut_setup, ut_teardown,
12907 			test_kasumi_hash_verify_test_case_5),
12908 		TEST_CASE_ST(ut_setup, ut_teardown,
12909 			test_kasumi_cipher_auth_test_case_1),
12910 
12911 		/** KASUMI generate auth, then encrypt (F8) */
12912 		TEST_CASE_ST(ut_setup, ut_teardown,
12913 			test_kasumi_auth_cipher_test_case_1),
12914 		TEST_CASE_ST(ut_setup, ut_teardown,
12915 			test_kasumi_auth_cipher_test_case_2),
12916 		TEST_CASE_ST(ut_setup, ut_teardown,
12917 			test_kasumi_auth_cipher_test_case_2_oop),
12918 		TEST_CASE_ST(ut_setup, ut_teardown,
12919 			test_kasumi_auth_cipher_test_case_2_sgl),
12920 		TEST_CASE_ST(ut_setup, ut_teardown,
12921 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
12922 
12923 		/** KASUMI decrypt (F8), then verify auth */
12924 		TEST_CASE_ST(ut_setup, ut_teardown,
12925 			test_kasumi_auth_cipher_verify_test_case_1),
12926 		TEST_CASE_ST(ut_setup, ut_teardown,
12927 			test_kasumi_auth_cipher_verify_test_case_2),
12928 		TEST_CASE_ST(ut_setup, ut_teardown,
12929 			test_kasumi_auth_cipher_verify_test_case_2_oop),
12930 		TEST_CASE_ST(ut_setup, ut_teardown,
12931 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
12932 		TEST_CASE_ST(ut_setup, ut_teardown,
12933 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12934 		TEST_CASES_END() /**< NULL terminate unit test array */
12935 	}
12936 };
12937 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
12938 	.suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12939 	.setup = testsuite_setup,
12940 	.teardown = testsuite_teardown,
12941 	.unit_test_cases = {
12942 		/** SNOW 3G encrypt only (UEA2) */
12943 		TEST_CASE_ST(ut_setup, ut_teardown,
12944 			test_snow3g_encryption_test_case_1),
12945 		TEST_CASE_ST(ut_setup, ut_teardown,
12946 			test_snow3g_encryption_test_case_2),
12947 		TEST_CASE_ST(ut_setup, ut_teardown,
12948 			test_snow3g_encryption_test_case_3),
12949 		TEST_CASE_ST(ut_setup, ut_teardown,
12950 			test_snow3g_encryption_test_case_4),
12951 		TEST_CASE_ST(ut_setup, ut_teardown,
12952 			test_snow3g_encryption_test_case_5),
12953 		TEST_CASE_ST(ut_setup, ut_teardown,
12954 			test_snow3g_auth_cipher_with_digest_test_case_1),
12955 
12956 		TEST_CASE_ST(ut_setup, ut_teardown,
12957 			test_snow3g_encryption_test_case_1_oop),
12958 		TEST_CASE_ST(ut_setup, ut_teardown,
12959 				test_snow3g_encryption_test_case_1_oop_sgl),
12960 		TEST_CASE_ST(ut_setup, ut_teardown,
12961 			test_snow3g_decryption_test_case_1_oop),
12962 
12963 		TEST_CASE_ST(ut_setup, ut_teardown,
12964 			test_snow3g_encryption_test_case_1_offset_oop),
12965 
12966 		/** SNOW 3G decrypt only (UEA2) */
12967 		TEST_CASE_ST(ut_setup, ut_teardown,
12968 			test_snow3g_decryption_test_case_1),
12969 		TEST_CASE_ST(ut_setup, ut_teardown,
12970 			test_snow3g_decryption_test_case_2),
12971 		TEST_CASE_ST(ut_setup, ut_teardown,
12972 			test_snow3g_decryption_test_case_3),
12973 		TEST_CASE_ST(ut_setup, ut_teardown,
12974 			test_snow3g_decryption_test_case_4),
12975 		TEST_CASE_ST(ut_setup, ut_teardown,
12976 			test_snow3g_decryption_test_case_5),
12977 		TEST_CASE_ST(ut_setup, ut_teardown,
12978 			test_snow3g_decryption_with_digest_test_case_1),
12979 		TEST_CASE_ST(ut_setup, ut_teardown,
12980 			test_snow3g_hash_generate_test_case_1),
12981 		TEST_CASE_ST(ut_setup, ut_teardown,
12982 			test_snow3g_hash_generate_test_case_2),
12983 		TEST_CASE_ST(ut_setup, ut_teardown,
12984 			test_snow3g_hash_generate_test_case_3),
12985 		/* Tests with buffers which length is not byte-aligned */
12986 		TEST_CASE_ST(ut_setup, ut_teardown,
12987 			test_snow3g_hash_generate_test_case_4),
12988 		TEST_CASE_ST(ut_setup, ut_teardown,
12989 			test_snow3g_hash_generate_test_case_5),
12990 		TEST_CASE_ST(ut_setup, ut_teardown,
12991 			test_snow3g_hash_generate_test_case_6),
12992 		TEST_CASE_ST(ut_setup, ut_teardown,
12993 			test_snow3g_hash_verify_test_case_1),
12994 		TEST_CASE_ST(ut_setup, ut_teardown,
12995 			test_snow3g_hash_verify_test_case_2),
12996 		TEST_CASE_ST(ut_setup, ut_teardown,
12997 			test_snow3g_hash_verify_test_case_3),
12998 		/* Tests with buffers which length is not byte-aligned */
12999 		TEST_CASE_ST(ut_setup, ut_teardown,
13000 			test_snow3g_hash_verify_test_case_4),
13001 		TEST_CASE_ST(ut_setup, ut_teardown,
13002 			test_snow3g_hash_verify_test_case_5),
13003 		TEST_CASE_ST(ut_setup, ut_teardown,
13004 			test_snow3g_hash_verify_test_case_6),
13005 		TEST_CASE_ST(ut_setup, ut_teardown,
13006 			test_snow3g_cipher_auth_test_case_1),
13007 
13008 		/** SNOW 3G generate auth, then encrypt (UEA2) */
13009 		TEST_CASE_ST(ut_setup, ut_teardown,
13010 			test_snow3g_auth_cipher_test_case_1),
13011 		TEST_CASE_ST(ut_setup, ut_teardown,
13012 			test_snow3g_auth_cipher_test_case_2),
13013 		TEST_CASE_ST(ut_setup, ut_teardown,
13014 			test_snow3g_auth_cipher_test_case_2_oop),
13015 		TEST_CASE_ST(ut_setup, ut_teardown,
13016 			test_snow3g_auth_cipher_part_digest_enc),
13017 		TEST_CASE_ST(ut_setup, ut_teardown,
13018 			test_snow3g_auth_cipher_part_digest_enc_oop),
13019 		TEST_CASE_ST(ut_setup, ut_teardown,
13020 			test_snow3g_auth_cipher_test_case_3_sgl),
13021 		TEST_CASE_ST(ut_setup, ut_teardown,
13022 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
13023 		TEST_CASE_ST(ut_setup, ut_teardown,
13024 			test_snow3g_auth_cipher_part_digest_enc_sgl),
13025 		TEST_CASE_ST(ut_setup, ut_teardown,
13026 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13027 
13028 		/** SNOW 3G decrypt (UEA2), then verify auth */
13029 		TEST_CASE_ST(ut_setup, ut_teardown,
13030 			test_snow3g_auth_cipher_verify_test_case_1),
13031 		TEST_CASE_ST(ut_setup, ut_teardown,
13032 			test_snow3g_auth_cipher_verify_test_case_2),
13033 		TEST_CASE_ST(ut_setup, ut_teardown,
13034 			test_snow3g_auth_cipher_verify_test_case_2_oop),
13035 		TEST_CASE_ST(ut_setup, ut_teardown,
13036 			test_snow3g_auth_cipher_verify_part_digest_enc),
13037 		TEST_CASE_ST(ut_setup, ut_teardown,
13038 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13039 		TEST_CASE_ST(ut_setup, ut_teardown,
13040 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
13041 		TEST_CASE_ST(ut_setup, ut_teardown,
13042 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13043 		TEST_CASE_ST(ut_setup, ut_teardown,
13044 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13045 		TEST_CASE_ST(ut_setup, ut_teardown,
13046 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13047 
13048 		TEST_CASES_END() /**< NULL terminate unit test array */
13049 	}
13050 };
13051 
13052 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
13053 	.suite_name = "Crypto Device SW ZUC Unit Test Suite",
13054 	.setup = testsuite_setup,
13055 	.teardown = testsuite_teardown,
13056 	.unit_test_cases = {
13057 		/** ZUC encrypt only (EEA3) */
13058 		TEST_CASE_ST(ut_setup, ut_teardown,
13059 			test_zuc_encryption_test_case_1),
13060 		TEST_CASE_ST(ut_setup, ut_teardown,
13061 			test_zuc_encryption_test_case_2),
13062 		TEST_CASE_ST(ut_setup, ut_teardown,
13063 			test_zuc_encryption_test_case_3),
13064 		TEST_CASE_ST(ut_setup, ut_teardown,
13065 			test_zuc_encryption_test_case_4),
13066 		TEST_CASE_ST(ut_setup, ut_teardown,
13067 			test_zuc_encryption_test_case_5),
13068 		TEST_CASE_ST(ut_setup, ut_teardown,
13069 			test_zuc_hash_generate_test_case_1),
13070 		TEST_CASE_ST(ut_setup, ut_teardown,
13071 			test_zuc_hash_generate_test_case_2),
13072 		TEST_CASE_ST(ut_setup, ut_teardown,
13073 			test_zuc_hash_generate_test_case_3),
13074 		TEST_CASE_ST(ut_setup, ut_teardown,
13075 			test_zuc_hash_generate_test_case_4),
13076 		TEST_CASE_ST(ut_setup, ut_teardown,
13077 			test_zuc_hash_generate_test_case_5),
13078 		TEST_CASE_ST(ut_setup, ut_teardown,
13079 			test_zuc_encryption_test_case_6_sgl),
13080 		TEST_CASES_END() /**< NULL terminate unit test array */
13081 	}
13082 };
13083 
13084 static struct unit_test_suite cryptodev_caam_jr_testsuite  = {
13085 	.suite_name = "Crypto CAAM JR Unit Test Suite",
13086 	.setup = testsuite_setup,
13087 	.teardown = testsuite_teardown,
13088 	.unit_test_cases = {
13089 		TEST_CASE_ST(ut_setup, ut_teardown,
13090 			     test_device_configure_invalid_dev_id),
13091 		TEST_CASE_ST(ut_setup, ut_teardown,
13092 			     test_multi_session),
13093 
13094 		TEST_CASE_ST(ut_setup, ut_teardown,
13095 			     test_AES_chain_caam_jr_all),
13096 		TEST_CASE_ST(ut_setup, ut_teardown,
13097 			     test_3DES_chain_caam_jr_all),
13098 		TEST_CASE_ST(ut_setup, ut_teardown,
13099 			     test_AES_cipheronly_caam_jr_all),
13100 		TEST_CASE_ST(ut_setup, ut_teardown,
13101 			     test_3DES_cipheronly_caam_jr_all),
13102 		TEST_CASE_ST(ut_setup, ut_teardown,
13103 			     test_authonly_caam_jr_all),
13104 
13105 		TEST_CASES_END() /**< NULL terminate unit test array */
13106 	}
13107 };
13108 
13109 static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
13110 	.suite_name = "Crypto DPAA_SEC Unit Test Suite",
13111 	.setup = testsuite_setup,
13112 	.teardown = testsuite_teardown,
13113 	.unit_test_cases = {
13114 		TEST_CASE_ST(ut_setup, ut_teardown,
13115 			     test_device_configure_invalid_dev_id),
13116 		TEST_CASE_ST(ut_setup, ut_teardown,
13117 			     test_multi_session),
13118 
13119 		TEST_CASE_ST(ut_setup, ut_teardown,
13120 			     test_AES_chain_dpaa_sec_all),
13121 		TEST_CASE_ST(ut_setup, ut_teardown,
13122 			     test_3DES_chain_dpaa_sec_all),
13123 		TEST_CASE_ST(ut_setup, ut_teardown,
13124 			     test_AES_cipheronly_dpaa_sec_all),
13125 		TEST_CASE_ST(ut_setup, ut_teardown,
13126 			     test_3DES_cipheronly_dpaa_sec_all),
13127 		TEST_CASE_ST(ut_setup, ut_teardown,
13128 			     test_authonly_dpaa_sec_all),
13129 
13130 #ifdef RTE_LIBRTE_SECURITY
13131 		TEST_CASE_ST(ut_setup, ut_teardown,
13132 			test_PDCP_PROTO_cplane_encap_all),
13133 
13134 		TEST_CASE_ST(ut_setup, ut_teardown,
13135 			test_PDCP_PROTO_cplane_decap_all),
13136 
13137 		TEST_CASE_ST(ut_setup, ut_teardown,
13138 			test_PDCP_PROTO_uplane_encap_all),
13139 
13140 		TEST_CASE_ST(ut_setup, ut_teardown,
13141 			test_PDCP_PROTO_uplane_decap_all),
13142 
13143 		TEST_CASE_ST(ut_setup, ut_teardown,
13144 			test_PDCP_PROTO_SGL_in_place_32B),
13145 		TEST_CASE_ST(ut_setup, ut_teardown,
13146 			test_PDCP_PROTO_SGL_oop_32B_128B),
13147 		TEST_CASE_ST(ut_setup, ut_teardown,
13148 			test_PDCP_PROTO_SGL_oop_32B_40B),
13149 		TEST_CASE_ST(ut_setup, ut_teardown,
13150 			test_PDCP_PROTO_SGL_oop_128B_32B),
13151 #endif
13152 		/** AES GCM Authenticated Encryption */
13153 		TEST_CASE_ST(ut_setup, ut_teardown,
13154 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13155 		TEST_CASE_ST(ut_setup, ut_teardown,
13156 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13157 		TEST_CASE_ST(ut_setup, ut_teardown,
13158 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13159 		TEST_CASE_ST(ut_setup, ut_teardown,
13160 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13161 		TEST_CASE_ST(ut_setup, ut_teardown,
13162 			test_AES_GCM_authenticated_encryption_test_case_1),
13163 		TEST_CASE_ST(ut_setup, ut_teardown,
13164 			test_AES_GCM_authenticated_encryption_test_case_2),
13165 		TEST_CASE_ST(ut_setup, ut_teardown,
13166 			test_AES_GCM_authenticated_encryption_test_case_3),
13167 		TEST_CASE_ST(ut_setup, ut_teardown,
13168 			test_AES_GCM_authenticated_encryption_test_case_4),
13169 		TEST_CASE_ST(ut_setup, ut_teardown,
13170 			test_AES_GCM_authenticated_encryption_test_case_5),
13171 		TEST_CASE_ST(ut_setup, ut_teardown,
13172 			test_AES_GCM_authenticated_encryption_test_case_6),
13173 		TEST_CASE_ST(ut_setup, ut_teardown,
13174 			test_AES_GCM_authenticated_encryption_test_case_7),
13175 		TEST_CASE_ST(ut_setup, ut_teardown,
13176 			test_AES_GCM_authenticated_encryption_test_case_8),
13177 
13178 		/** AES GCM Authenticated Decryption */
13179 		TEST_CASE_ST(ut_setup, ut_teardown,
13180 			test_AES_GCM_authenticated_decryption_test_case_1),
13181 		TEST_CASE_ST(ut_setup, ut_teardown,
13182 			test_AES_GCM_authenticated_decryption_test_case_2),
13183 		TEST_CASE_ST(ut_setup, ut_teardown,
13184 			test_AES_GCM_authenticated_decryption_test_case_3),
13185 		TEST_CASE_ST(ut_setup, ut_teardown,
13186 			test_AES_GCM_authenticated_decryption_test_case_4),
13187 		TEST_CASE_ST(ut_setup, ut_teardown,
13188 			test_AES_GCM_authenticated_decryption_test_case_5),
13189 		TEST_CASE_ST(ut_setup, ut_teardown,
13190 			test_AES_GCM_authenticated_decryption_test_case_6),
13191 		TEST_CASE_ST(ut_setup, ut_teardown,
13192 			test_AES_GCM_authenticated_decryption_test_case_7),
13193 		TEST_CASE_ST(ut_setup, ut_teardown,
13194 			test_AES_GCM_authenticated_decryption_test_case_8),
13195 
13196 		/** AES GCM Authenticated Encryption 192 bits key */
13197 		TEST_CASE_ST(ut_setup, ut_teardown,
13198 			test_AES_GCM_auth_encryption_test_case_192_1),
13199 		TEST_CASE_ST(ut_setup, ut_teardown,
13200 			test_AES_GCM_auth_encryption_test_case_192_2),
13201 		TEST_CASE_ST(ut_setup, ut_teardown,
13202 			test_AES_GCM_auth_encryption_test_case_192_3),
13203 		TEST_CASE_ST(ut_setup, ut_teardown,
13204 			test_AES_GCM_auth_encryption_test_case_192_4),
13205 		TEST_CASE_ST(ut_setup, ut_teardown,
13206 			test_AES_GCM_auth_encryption_test_case_192_5),
13207 		TEST_CASE_ST(ut_setup, ut_teardown,
13208 			test_AES_GCM_auth_encryption_test_case_192_6),
13209 		TEST_CASE_ST(ut_setup, ut_teardown,
13210 			test_AES_GCM_auth_encryption_test_case_192_7),
13211 
13212 		/** AES GCM Authenticated Decryption 192 bits key */
13213 		TEST_CASE_ST(ut_setup, ut_teardown,
13214 			test_AES_GCM_auth_decryption_test_case_192_1),
13215 		TEST_CASE_ST(ut_setup, ut_teardown,
13216 			test_AES_GCM_auth_decryption_test_case_192_2),
13217 		TEST_CASE_ST(ut_setup, ut_teardown,
13218 			test_AES_GCM_auth_decryption_test_case_192_3),
13219 		TEST_CASE_ST(ut_setup, ut_teardown,
13220 			test_AES_GCM_auth_decryption_test_case_192_4),
13221 		TEST_CASE_ST(ut_setup, ut_teardown,
13222 			test_AES_GCM_auth_decryption_test_case_192_5),
13223 		TEST_CASE_ST(ut_setup, ut_teardown,
13224 			test_AES_GCM_auth_decryption_test_case_192_6),
13225 		TEST_CASE_ST(ut_setup, ut_teardown,
13226 			test_AES_GCM_auth_decryption_test_case_192_7),
13227 
13228 		/** AES GCM Authenticated Encryption 256 bits key */
13229 		TEST_CASE_ST(ut_setup, ut_teardown,
13230 			test_AES_GCM_auth_encryption_test_case_256_1),
13231 		TEST_CASE_ST(ut_setup, ut_teardown,
13232 			test_AES_GCM_auth_encryption_test_case_256_2),
13233 		TEST_CASE_ST(ut_setup, ut_teardown,
13234 			test_AES_GCM_auth_encryption_test_case_256_3),
13235 		TEST_CASE_ST(ut_setup, ut_teardown,
13236 			test_AES_GCM_auth_encryption_test_case_256_4),
13237 		TEST_CASE_ST(ut_setup, ut_teardown,
13238 			test_AES_GCM_auth_encryption_test_case_256_5),
13239 		TEST_CASE_ST(ut_setup, ut_teardown,
13240 			test_AES_GCM_auth_encryption_test_case_256_6),
13241 		TEST_CASE_ST(ut_setup, ut_teardown,
13242 			test_AES_GCM_auth_encryption_test_case_256_7),
13243 
13244 		/** AES GCM Authenticated Decryption 256 bits key */
13245 		TEST_CASE_ST(ut_setup, ut_teardown,
13246 			test_AES_GCM_auth_decryption_test_case_256_1),
13247 		TEST_CASE_ST(ut_setup, ut_teardown,
13248 			test_AES_GCM_auth_decryption_test_case_256_2),
13249 		TEST_CASE_ST(ut_setup, ut_teardown,
13250 			test_AES_GCM_auth_decryption_test_case_256_3),
13251 		TEST_CASE_ST(ut_setup, ut_teardown,
13252 			test_AES_GCM_auth_decryption_test_case_256_4),
13253 		TEST_CASE_ST(ut_setup, ut_teardown,
13254 			test_AES_GCM_auth_decryption_test_case_256_5),
13255 		TEST_CASE_ST(ut_setup, ut_teardown,
13256 			test_AES_GCM_auth_decryption_test_case_256_6),
13257 		TEST_CASE_ST(ut_setup, ut_teardown,
13258 			test_AES_GCM_auth_decryption_test_case_256_7),
13259 
13260 		/** Out of place tests */
13261 		TEST_CASE_ST(ut_setup, ut_teardown,
13262 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13263 		TEST_CASE_ST(ut_setup, ut_teardown,
13264 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13265 
13266 		/** SNOW 3G encrypt only (UEA2) */
13267 		TEST_CASE_ST(ut_setup, ut_teardown,
13268 			test_snow3g_encryption_test_case_1),
13269 		TEST_CASE_ST(ut_setup, ut_teardown,
13270 			test_snow3g_encryption_test_case_2),
13271 		TEST_CASE_ST(ut_setup, ut_teardown,
13272 			test_snow3g_encryption_test_case_3),
13273 		TEST_CASE_ST(ut_setup, ut_teardown,
13274 			test_snow3g_encryption_test_case_4),
13275 		TEST_CASE_ST(ut_setup, ut_teardown,
13276 			test_snow3g_encryption_test_case_5),
13277 
13278 		TEST_CASE_ST(ut_setup, ut_teardown,
13279 			test_snow3g_encryption_test_case_1_oop),
13280 		TEST_CASE_ST(ut_setup, ut_teardown,
13281 				test_snow3g_encryption_test_case_1_oop_sgl),
13282 		TEST_CASE_ST(ut_setup, ut_teardown,
13283 			test_snow3g_decryption_test_case_1_oop),
13284 
13285 		/** SNOW 3G decrypt only (UEA2) */
13286 		TEST_CASE_ST(ut_setup, ut_teardown,
13287 			test_snow3g_decryption_test_case_1),
13288 		TEST_CASE_ST(ut_setup, ut_teardown,
13289 			test_snow3g_decryption_test_case_2),
13290 		TEST_CASE_ST(ut_setup, ut_teardown,
13291 			test_snow3g_decryption_test_case_3),
13292 		TEST_CASE_ST(ut_setup, ut_teardown,
13293 			test_snow3g_decryption_test_case_4),
13294 		TEST_CASE_ST(ut_setup, ut_teardown,
13295 			test_snow3g_decryption_test_case_5),
13296 
13297 		TEST_CASE_ST(ut_setup, ut_teardown,
13298 			test_snow3g_hash_generate_test_case_1),
13299 		TEST_CASE_ST(ut_setup, ut_teardown,
13300 			test_snow3g_hash_generate_test_case_2),
13301 		TEST_CASE_ST(ut_setup, ut_teardown,
13302 			test_snow3g_hash_generate_test_case_3),
13303 		TEST_CASE_ST(ut_setup, ut_teardown,
13304 			test_snow3g_hash_verify_test_case_1),
13305 		TEST_CASE_ST(ut_setup, ut_teardown,
13306 			test_snow3g_hash_verify_test_case_2),
13307 		TEST_CASE_ST(ut_setup, ut_teardown,
13308 			test_snow3g_hash_verify_test_case_3),
13309 
13310 		/** ZUC encrypt only (EEA3) */
13311 		TEST_CASE_ST(ut_setup, ut_teardown,
13312 			test_zuc_encryption_test_case_1),
13313 		TEST_CASE_ST(ut_setup, ut_teardown,
13314 			test_zuc_encryption_test_case_2),
13315 		TEST_CASE_ST(ut_setup, ut_teardown,
13316 			test_zuc_encryption_test_case_3),
13317 		TEST_CASE_ST(ut_setup, ut_teardown,
13318 			test_zuc_encryption_test_case_4),
13319 		TEST_CASE_ST(ut_setup, ut_teardown,
13320 			test_zuc_encryption_test_case_5),
13321 
13322 		/** ZUC authenticate (EIA3) */
13323 		TEST_CASE_ST(ut_setup, ut_teardown,
13324 			test_zuc_hash_generate_test_case_6),
13325 		TEST_CASE_ST(ut_setup, ut_teardown,
13326 			test_zuc_hash_generate_test_case_7),
13327 		TEST_CASE_ST(ut_setup, ut_teardown,
13328 			test_zuc_hash_generate_test_case_8),
13329 
13330 		/** Negative tests */
13331 		TEST_CASE_ST(ut_setup, ut_teardown,
13332 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
13333 		TEST_CASE_ST(ut_setup, ut_teardown,
13334 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13335 		TEST_CASE_ST(ut_setup, ut_teardown,
13336 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13337 		TEST_CASE_ST(ut_setup, ut_teardown,
13338 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13339 		TEST_CASE_ST(ut_setup, ut_teardown,
13340 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
13341 		TEST_CASE_ST(ut_setup, ut_teardown,
13342 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
13343 		TEST_CASE_ST(ut_setup, ut_teardown,
13344 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
13345 		TEST_CASE_ST(ut_setup, ut_teardown,
13346 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13347 		TEST_CASE_ST(ut_setup, ut_teardown,
13348 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13349 		TEST_CASE_ST(ut_setup, ut_teardown,
13350 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13351 		TEST_CASE_ST(ut_setup, ut_teardown,
13352 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
13353 		TEST_CASE_ST(ut_setup, ut_teardown,
13354 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
13355 		TEST_CASE_ST(ut_setup, ut_teardown,
13356 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13357 		TEST_CASE_ST(ut_setup, ut_teardown,
13358 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13359 		TEST_CASE_ST(ut_setup, ut_teardown,
13360 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13361 		TEST_CASE_ST(ut_setup, ut_teardown,
13362 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13363 
13364 		/* ESN Testcase */
13365 		TEST_CASE_ST(ut_setup, ut_teardown,
13366 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13367 		TEST_CASE_ST(ut_setup, ut_teardown,
13368 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13369 
13370 		TEST_CASES_END() /**< NULL terminate unit test array */
13371 	}
13372 };
13373 
13374 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
13375 	.suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13376 	.setup = testsuite_setup,
13377 	.teardown = testsuite_teardown,
13378 	.unit_test_cases = {
13379 		TEST_CASE_ST(ut_setup, ut_teardown,
13380 			test_device_configure_invalid_dev_id),
13381 		TEST_CASE_ST(ut_setup, ut_teardown,
13382 			test_multi_session),
13383 		TEST_CASE_ST(ut_setup, ut_teardown,
13384 			test_AES_chain_dpaa2_sec_all),
13385 		TEST_CASE_ST(ut_setup, ut_teardown,
13386 			test_3DES_chain_dpaa2_sec_all),
13387 		TEST_CASE_ST(ut_setup, ut_teardown,
13388 			test_AES_cipheronly_dpaa2_sec_all),
13389 		TEST_CASE_ST(ut_setup, ut_teardown,
13390 			test_3DES_cipheronly_dpaa2_sec_all),
13391 		TEST_CASE_ST(ut_setup, ut_teardown,
13392 			test_authonly_dpaa2_sec_all),
13393 
13394 #ifdef RTE_LIBRTE_SECURITY
13395 		TEST_CASE_ST(ut_setup, ut_teardown,
13396 			test_PDCP_PROTO_cplane_encap_all),
13397 
13398 		TEST_CASE_ST(ut_setup, ut_teardown,
13399 			test_PDCP_PROTO_cplane_decap_all),
13400 
13401 		TEST_CASE_ST(ut_setup, ut_teardown,
13402 			test_PDCP_PROTO_uplane_encap_all),
13403 
13404 		TEST_CASE_ST(ut_setup, ut_teardown,
13405 			test_PDCP_PROTO_uplane_decap_all),
13406 
13407 		TEST_CASE_ST(ut_setup, ut_teardown,
13408 			test_PDCP_PROTO_SGL_in_place_32B),
13409 		TEST_CASE_ST(ut_setup, ut_teardown,
13410 			test_PDCP_PROTO_SGL_oop_32B_128B),
13411 		TEST_CASE_ST(ut_setup, ut_teardown,
13412 			test_PDCP_PROTO_SGL_oop_32B_40B),
13413 		TEST_CASE_ST(ut_setup, ut_teardown,
13414 			test_PDCP_PROTO_SGL_oop_128B_32B),
13415 #endif
13416 		/** AES GCM Authenticated Encryption */
13417 		TEST_CASE_ST(ut_setup, ut_teardown,
13418 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13419 		TEST_CASE_ST(ut_setup, ut_teardown,
13420 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13421 		TEST_CASE_ST(ut_setup, ut_teardown,
13422 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13423 		TEST_CASE_ST(ut_setup, ut_teardown,
13424 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13425 		TEST_CASE_ST(ut_setup, ut_teardown,
13426 			test_AES_GCM_authenticated_encryption_test_case_1),
13427 		TEST_CASE_ST(ut_setup, ut_teardown,
13428 			test_AES_GCM_authenticated_encryption_test_case_2),
13429 		TEST_CASE_ST(ut_setup, ut_teardown,
13430 			test_AES_GCM_authenticated_encryption_test_case_3),
13431 		TEST_CASE_ST(ut_setup, ut_teardown,
13432 			test_AES_GCM_authenticated_encryption_test_case_4),
13433 		TEST_CASE_ST(ut_setup, ut_teardown,
13434 			test_AES_GCM_authenticated_encryption_test_case_5),
13435 		TEST_CASE_ST(ut_setup, ut_teardown,
13436 			test_AES_GCM_authenticated_encryption_test_case_6),
13437 		TEST_CASE_ST(ut_setup, ut_teardown,
13438 			test_AES_GCM_authenticated_encryption_test_case_7),
13439 		TEST_CASE_ST(ut_setup, ut_teardown,
13440 			test_AES_GCM_authenticated_encryption_test_case_8),
13441 
13442 		/** AES GCM Authenticated Decryption */
13443 		TEST_CASE_ST(ut_setup, ut_teardown,
13444 			test_AES_GCM_authenticated_decryption_test_case_1),
13445 		TEST_CASE_ST(ut_setup, ut_teardown,
13446 			test_AES_GCM_authenticated_decryption_test_case_2),
13447 		TEST_CASE_ST(ut_setup, ut_teardown,
13448 			test_AES_GCM_authenticated_decryption_test_case_3),
13449 		TEST_CASE_ST(ut_setup, ut_teardown,
13450 			test_AES_GCM_authenticated_decryption_test_case_4),
13451 		TEST_CASE_ST(ut_setup, ut_teardown,
13452 			test_AES_GCM_authenticated_decryption_test_case_5),
13453 		TEST_CASE_ST(ut_setup, ut_teardown,
13454 			test_AES_GCM_authenticated_decryption_test_case_6),
13455 		TEST_CASE_ST(ut_setup, ut_teardown,
13456 			test_AES_GCM_authenticated_decryption_test_case_7),
13457 		TEST_CASE_ST(ut_setup, ut_teardown,
13458 			test_AES_GCM_authenticated_decryption_test_case_8),
13459 
13460 		/** AES GCM Authenticated Encryption 192 bits key */
13461 		TEST_CASE_ST(ut_setup, ut_teardown,
13462 			test_AES_GCM_auth_encryption_test_case_192_1),
13463 		TEST_CASE_ST(ut_setup, ut_teardown,
13464 			test_AES_GCM_auth_encryption_test_case_192_2),
13465 		TEST_CASE_ST(ut_setup, ut_teardown,
13466 			test_AES_GCM_auth_encryption_test_case_192_3),
13467 		TEST_CASE_ST(ut_setup, ut_teardown,
13468 			test_AES_GCM_auth_encryption_test_case_192_4),
13469 		TEST_CASE_ST(ut_setup, ut_teardown,
13470 			test_AES_GCM_auth_encryption_test_case_192_5),
13471 		TEST_CASE_ST(ut_setup, ut_teardown,
13472 			test_AES_GCM_auth_encryption_test_case_192_6),
13473 		TEST_CASE_ST(ut_setup, ut_teardown,
13474 			test_AES_GCM_auth_encryption_test_case_192_7),
13475 
13476 		/** AES GCM Authenticated Decryption 192 bits key */
13477 		TEST_CASE_ST(ut_setup, ut_teardown,
13478 			test_AES_GCM_auth_decryption_test_case_192_1),
13479 		TEST_CASE_ST(ut_setup, ut_teardown,
13480 			test_AES_GCM_auth_decryption_test_case_192_2),
13481 		TEST_CASE_ST(ut_setup, ut_teardown,
13482 			test_AES_GCM_auth_decryption_test_case_192_3),
13483 		TEST_CASE_ST(ut_setup, ut_teardown,
13484 			test_AES_GCM_auth_decryption_test_case_192_4),
13485 		TEST_CASE_ST(ut_setup, ut_teardown,
13486 			test_AES_GCM_auth_decryption_test_case_192_5),
13487 		TEST_CASE_ST(ut_setup, ut_teardown,
13488 			test_AES_GCM_auth_decryption_test_case_192_6),
13489 		TEST_CASE_ST(ut_setup, ut_teardown,
13490 			test_AES_GCM_auth_decryption_test_case_192_7),
13491 
13492 		/** AES GCM Authenticated Encryption 256 bits key */
13493 		TEST_CASE_ST(ut_setup, ut_teardown,
13494 			test_AES_GCM_auth_encryption_test_case_256_1),
13495 		TEST_CASE_ST(ut_setup, ut_teardown,
13496 			test_AES_GCM_auth_encryption_test_case_256_2),
13497 		TEST_CASE_ST(ut_setup, ut_teardown,
13498 			test_AES_GCM_auth_encryption_test_case_256_3),
13499 		TEST_CASE_ST(ut_setup, ut_teardown,
13500 			test_AES_GCM_auth_encryption_test_case_256_4),
13501 		TEST_CASE_ST(ut_setup, ut_teardown,
13502 			test_AES_GCM_auth_encryption_test_case_256_5),
13503 		TEST_CASE_ST(ut_setup, ut_teardown,
13504 			test_AES_GCM_auth_encryption_test_case_256_6),
13505 		TEST_CASE_ST(ut_setup, ut_teardown,
13506 			test_AES_GCM_auth_encryption_test_case_256_7),
13507 
13508 		/** AES GCM Authenticated Decryption 256 bits key */
13509 		TEST_CASE_ST(ut_setup, ut_teardown,
13510 			test_AES_GCM_auth_decryption_test_case_256_1),
13511 		TEST_CASE_ST(ut_setup, ut_teardown,
13512 			test_AES_GCM_auth_decryption_test_case_256_2),
13513 		TEST_CASE_ST(ut_setup, ut_teardown,
13514 			test_AES_GCM_auth_decryption_test_case_256_3),
13515 		TEST_CASE_ST(ut_setup, ut_teardown,
13516 			test_AES_GCM_auth_decryption_test_case_256_4),
13517 		TEST_CASE_ST(ut_setup, ut_teardown,
13518 			test_AES_GCM_auth_decryption_test_case_256_5),
13519 		TEST_CASE_ST(ut_setup, ut_teardown,
13520 			test_AES_GCM_auth_decryption_test_case_256_6),
13521 		TEST_CASE_ST(ut_setup, ut_teardown,
13522 			test_AES_GCM_auth_decryption_test_case_256_7),
13523 
13524 		/** Out of place tests */
13525 		TEST_CASE_ST(ut_setup, ut_teardown,
13526 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13527 		TEST_CASE_ST(ut_setup, ut_teardown,
13528 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13529 
13530 		/** SNOW 3G encrypt only (UEA2) */
13531 		TEST_CASE_ST(ut_setup, ut_teardown,
13532 			test_snow3g_encryption_test_case_1),
13533 		TEST_CASE_ST(ut_setup, ut_teardown,
13534 			test_snow3g_encryption_test_case_2),
13535 		TEST_CASE_ST(ut_setup, ut_teardown,
13536 			test_snow3g_encryption_test_case_3),
13537 		TEST_CASE_ST(ut_setup, ut_teardown,
13538 			test_snow3g_encryption_test_case_4),
13539 		TEST_CASE_ST(ut_setup, ut_teardown,
13540 			test_snow3g_encryption_test_case_5),
13541 
13542 		TEST_CASE_ST(ut_setup, ut_teardown,
13543 			test_snow3g_encryption_test_case_1_oop),
13544 		TEST_CASE_ST(ut_setup, ut_teardown,
13545 				test_snow3g_encryption_test_case_1_oop_sgl),
13546 		TEST_CASE_ST(ut_setup, ut_teardown,
13547 			test_snow3g_decryption_test_case_1_oop),
13548 
13549 		/** SNOW 3G decrypt only (UEA2) */
13550 		TEST_CASE_ST(ut_setup, ut_teardown,
13551 			test_snow3g_decryption_test_case_1),
13552 		TEST_CASE_ST(ut_setup, ut_teardown,
13553 			test_snow3g_decryption_test_case_2),
13554 		TEST_CASE_ST(ut_setup, ut_teardown,
13555 			test_snow3g_decryption_test_case_3),
13556 		TEST_CASE_ST(ut_setup, ut_teardown,
13557 			test_snow3g_decryption_test_case_4),
13558 		TEST_CASE_ST(ut_setup, ut_teardown,
13559 			test_snow3g_decryption_test_case_5),
13560 
13561 		TEST_CASE_ST(ut_setup, ut_teardown,
13562 			test_snow3g_hash_generate_test_case_1),
13563 		TEST_CASE_ST(ut_setup, ut_teardown,
13564 			test_snow3g_hash_generate_test_case_2),
13565 		TEST_CASE_ST(ut_setup, ut_teardown,
13566 			test_snow3g_hash_generate_test_case_3),
13567 		TEST_CASE_ST(ut_setup, ut_teardown,
13568 			test_snow3g_hash_verify_test_case_1),
13569 		TEST_CASE_ST(ut_setup, ut_teardown,
13570 			test_snow3g_hash_verify_test_case_2),
13571 		TEST_CASE_ST(ut_setup, ut_teardown,
13572 			test_snow3g_hash_verify_test_case_3),
13573 
13574 		/** ZUC encrypt only (EEA3) */
13575 		TEST_CASE_ST(ut_setup, ut_teardown,
13576 			test_zuc_encryption_test_case_1),
13577 		TEST_CASE_ST(ut_setup, ut_teardown,
13578 			test_zuc_encryption_test_case_2),
13579 		TEST_CASE_ST(ut_setup, ut_teardown,
13580 			test_zuc_encryption_test_case_3),
13581 		TEST_CASE_ST(ut_setup, ut_teardown,
13582 			test_zuc_encryption_test_case_4),
13583 		TEST_CASE_ST(ut_setup, ut_teardown,
13584 			test_zuc_encryption_test_case_5),
13585 
13586 		/** ZUC authenticate (EIA3) */
13587 		TEST_CASE_ST(ut_setup, ut_teardown,
13588 			test_zuc_hash_generate_test_case_6),
13589 		TEST_CASE_ST(ut_setup, ut_teardown,
13590 			test_zuc_hash_generate_test_case_7),
13591 		TEST_CASE_ST(ut_setup, ut_teardown,
13592 			test_zuc_hash_generate_test_case_8),
13593 
13594 		/** HMAC_MD5 Authentication */
13595 		TEST_CASE_ST(ut_setup, ut_teardown,
13596 			test_MD5_HMAC_generate_case_1),
13597 		TEST_CASE_ST(ut_setup, ut_teardown,
13598 			test_MD5_HMAC_verify_case_1),
13599 		TEST_CASE_ST(ut_setup, ut_teardown,
13600 			test_MD5_HMAC_generate_case_2),
13601 		TEST_CASE_ST(ut_setup, ut_teardown,
13602 			test_MD5_HMAC_verify_case_2),
13603 
13604 		/** Negative tests */
13605 		TEST_CASE_ST(ut_setup, ut_teardown,
13606 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
13607 		TEST_CASE_ST(ut_setup, ut_teardown,
13608 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13609 		TEST_CASE_ST(ut_setup, ut_teardown,
13610 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13611 		TEST_CASE_ST(ut_setup, ut_teardown,
13612 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13613 		TEST_CASE_ST(ut_setup, ut_teardown,
13614 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
13615 		TEST_CASE_ST(ut_setup, ut_teardown,
13616 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
13617 		TEST_CASE_ST(ut_setup, ut_teardown,
13618 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
13619 		TEST_CASE_ST(ut_setup, ut_teardown,
13620 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13621 		TEST_CASE_ST(ut_setup, ut_teardown,
13622 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13623 		TEST_CASE_ST(ut_setup, ut_teardown,
13624 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13625 		TEST_CASE_ST(ut_setup, ut_teardown,
13626 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
13627 		TEST_CASE_ST(ut_setup, ut_teardown,
13628 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
13629 		TEST_CASE_ST(ut_setup, ut_teardown,
13630 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13631 		TEST_CASE_ST(ut_setup, ut_teardown,
13632 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13633 		TEST_CASE_ST(ut_setup, ut_teardown,
13634 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13635 		TEST_CASE_ST(ut_setup, ut_teardown,
13636 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13637 
13638 		/* ESN Testcase */
13639 		TEST_CASE_ST(ut_setup, ut_teardown,
13640 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13641 
13642 		TEST_CASE_ST(ut_setup, ut_teardown,
13643 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13644 
13645 		TEST_CASES_END() /**< NULL terminate unit test array */
13646 	}
13647 };
13648 
13649 static struct unit_test_suite cryptodev_null_testsuite  = {
13650 	.suite_name = "Crypto Device NULL Unit Test Suite",
13651 	.setup = testsuite_setup,
13652 	.teardown = testsuite_teardown,
13653 	.unit_test_cases = {
13654 		TEST_CASE_ST(ut_setup, ut_teardown,
13655 			test_null_invalid_operation),
13656 		TEST_CASE_ST(ut_setup, ut_teardown,
13657 			test_null_burst_operation),
13658 		TEST_CASE_ST(ut_setup, ut_teardown,
13659 			test_AES_chain_null_all),
13660 		TEST_CASE_ST(ut_setup, ut_teardown,
13661 			test_AES_cipheronly_null_all),
13662 		TEST_CASE_ST(ut_setup, ut_teardown,
13663 				test_authonly_null_all),
13664 
13665 		TEST_CASES_END() /**< NULL terminate unit test array */
13666 	}
13667 };
13668 
13669 static struct unit_test_suite cryptodev_armv8_testsuite  = {
13670 	.suite_name = "Crypto Device ARMv8 Unit Test Suite",
13671 	.setup = testsuite_setup,
13672 	.teardown = testsuite_teardown,
13673 	.unit_test_cases = {
13674 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13675 
13676 		/** Negative tests */
13677 		TEST_CASE_ST(ut_setup, ut_teardown,
13678 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13679 		TEST_CASE_ST(ut_setup, ut_teardown,
13680 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13681 
13682 		TEST_CASES_END() /**< NULL terminate unit test array */
13683 	}
13684 };
13685 
13686 static struct unit_test_suite cryptodev_mrvl_testsuite  = {
13687 	.suite_name = "Crypto Device Marvell Component Test Suite",
13688 	.setup = testsuite_setup,
13689 	.teardown = testsuite_teardown,
13690 	.unit_test_cases = {
13691 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13692 		TEST_CASE_ST(ut_setup, ut_teardown,
13693 				test_multi_session_random_usage),
13694 		TEST_CASE_ST(ut_setup, ut_teardown,
13695 				test_AES_chain_mrvl_all),
13696 		TEST_CASE_ST(ut_setup, ut_teardown,
13697 				test_AES_cipheronly_mrvl_all),
13698 		TEST_CASE_ST(ut_setup, ut_teardown,
13699 				test_authonly_mrvl_all),
13700 		TEST_CASE_ST(ut_setup, ut_teardown,
13701 				test_3DES_chain_mrvl_all),
13702 		TEST_CASE_ST(ut_setup, ut_teardown,
13703 				test_3DES_cipheronly_mrvl_all),
13704 
13705 		/** Negative tests */
13706 		TEST_CASE_ST(ut_setup, ut_teardown,
13707 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13708 		TEST_CASE_ST(ut_setup, ut_teardown,
13709 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13710 		TEST_CASE_ST(ut_setup, ut_teardown,
13711 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13712 		TEST_CASE_ST(ut_setup, ut_teardown,
13713 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13714 
13715 		TEST_CASES_END() /**< NULL terminate unit test array */
13716 	}
13717 };
13718 
13719 static struct unit_test_suite cryptodev_ccp_testsuite  = {
13720 	.suite_name = "Crypto Device CCP Unit Test Suite",
13721 	.setup = testsuite_setup,
13722 	.teardown = testsuite_teardown,
13723 	.unit_test_cases = {
13724 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13725 		TEST_CASE_ST(ut_setup, ut_teardown,
13726 				test_multi_session_random_usage),
13727 		TEST_CASE_ST(ut_setup, ut_teardown,
13728 				test_AES_chain_ccp_all),
13729 		TEST_CASE_ST(ut_setup, ut_teardown,
13730 				test_AES_cipheronly_ccp_all),
13731 		TEST_CASE_ST(ut_setup, ut_teardown,
13732 				test_3DES_chain_ccp_all),
13733 		TEST_CASE_ST(ut_setup, ut_teardown,
13734 				test_3DES_cipheronly_ccp_all),
13735 		TEST_CASE_ST(ut_setup, ut_teardown,
13736 				test_authonly_ccp_all),
13737 
13738 		/** Negative tests */
13739 		TEST_CASE_ST(ut_setup, ut_teardown,
13740 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13741 		TEST_CASE_ST(ut_setup, ut_teardown,
13742 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13743 		TEST_CASE_ST(ut_setup, ut_teardown,
13744 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13745 		TEST_CASE_ST(ut_setup, ut_teardown,
13746 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13747 
13748 		TEST_CASES_END() /**< NULL terminate unit test array */
13749 	}
13750 };
13751 
13752 static struct unit_test_suite cryptodev_octeontx_testsuite  = {
13753 	.suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13754 	.setup = testsuite_setup,
13755 	.teardown = testsuite_teardown,
13756 	.unit_test_cases = {
13757 		TEST_CASE_ST(ut_setup, ut_teardown,
13758 			test_AES_chain_octeontx_all),
13759 		TEST_CASE_ST(ut_setup, ut_teardown,
13760 			test_AES_cipheronly_octeontx_all),
13761 		TEST_CASE_ST(ut_setup, ut_teardown,
13762 			test_3DES_chain_octeontx_all),
13763 		TEST_CASE_ST(ut_setup, ut_teardown,
13764 			test_3DES_cipheronly_octeontx_all),
13765 		TEST_CASE_ST(ut_setup, ut_teardown,
13766 			test_authonly_octeontx_all),
13767 
13768 		/** AES GCM Authenticated Encryption */
13769 		TEST_CASE_ST(ut_setup, ut_teardown,
13770 			test_AES_GCM_authenticated_encryption_test_case_1),
13771 		TEST_CASE_ST(ut_setup, ut_teardown,
13772 			test_AES_GCM_authenticated_encryption_test_case_2),
13773 		TEST_CASE_ST(ut_setup, ut_teardown,
13774 			test_AES_GCM_authenticated_encryption_test_case_3),
13775 		TEST_CASE_ST(ut_setup, ut_teardown,
13776 			test_AES_GCM_authenticated_encryption_test_case_4),
13777 		TEST_CASE_ST(ut_setup, ut_teardown,
13778 			test_AES_GCM_authenticated_encryption_test_case_5),
13779 		TEST_CASE_ST(ut_setup, ut_teardown,
13780 			test_AES_GCM_authenticated_encryption_test_case_6),
13781 		TEST_CASE_ST(ut_setup, ut_teardown,
13782 			test_AES_GCM_authenticated_encryption_test_case_7),
13783 
13784 		/** AES GCM Authenticated Decryption */
13785 		TEST_CASE_ST(ut_setup, ut_teardown,
13786 			test_AES_GCM_authenticated_decryption_test_case_1),
13787 		TEST_CASE_ST(ut_setup, ut_teardown,
13788 			test_AES_GCM_authenticated_decryption_test_case_2),
13789 		TEST_CASE_ST(ut_setup, ut_teardown,
13790 			test_AES_GCM_authenticated_decryption_test_case_3),
13791 		TEST_CASE_ST(ut_setup, ut_teardown,
13792 			test_AES_GCM_authenticated_decryption_test_case_4),
13793 		TEST_CASE_ST(ut_setup, ut_teardown,
13794 			test_AES_GCM_authenticated_decryption_test_case_5),
13795 		TEST_CASE_ST(ut_setup, ut_teardown,
13796 			test_AES_GCM_authenticated_decryption_test_case_6),
13797 		TEST_CASE_ST(ut_setup, ut_teardown,
13798 			test_AES_GCM_authenticated_decryption_test_case_7),
13799 		/** AES GMAC Authentication */
13800 		TEST_CASE_ST(ut_setup, ut_teardown,
13801 			test_AES_GMAC_authentication_test_case_1),
13802 		TEST_CASE_ST(ut_setup, ut_teardown,
13803 			test_AES_GMAC_authentication_verify_test_case_1),
13804 		TEST_CASE_ST(ut_setup, ut_teardown,
13805 			test_AES_GMAC_authentication_test_case_2),
13806 		TEST_CASE_ST(ut_setup, ut_teardown,
13807 			test_AES_GMAC_authentication_verify_test_case_2),
13808 		TEST_CASE_ST(ut_setup, ut_teardown,
13809 			test_AES_GMAC_authentication_test_case_3),
13810 		TEST_CASE_ST(ut_setup, ut_teardown,
13811 			test_AES_GMAC_authentication_verify_test_case_3),
13812 
13813 		/** SNOW 3G encrypt only (UEA2) */
13814 		TEST_CASE_ST(ut_setup, ut_teardown,
13815 			test_snow3g_encryption_test_case_1),
13816 		TEST_CASE_ST(ut_setup, ut_teardown,
13817 			test_snow3g_encryption_test_case_2),
13818 		TEST_CASE_ST(ut_setup, ut_teardown,
13819 			test_snow3g_encryption_test_case_3),
13820 		TEST_CASE_ST(ut_setup, ut_teardown,
13821 			test_snow3g_encryption_test_case_4),
13822 		TEST_CASE_ST(ut_setup, ut_teardown,
13823 			test_snow3g_encryption_test_case_5),
13824 
13825 		TEST_CASE_ST(ut_setup, ut_teardown,
13826 			test_snow3g_encryption_test_case_1_oop),
13827 		TEST_CASE_ST(ut_setup, ut_teardown,
13828 			test_snow3g_decryption_test_case_1_oop),
13829 		TEST_CASE_ST(ut_setup, ut_teardown,
13830 			test_snow3g_encryption_test_case_1_oop_sgl),
13831 
13832 		/** SNOW 3G decrypt only (UEA2) */
13833 		TEST_CASE_ST(ut_setup, ut_teardown,
13834 			test_snow3g_decryption_test_case_1),
13835 		TEST_CASE_ST(ut_setup, ut_teardown,
13836 			test_snow3g_decryption_test_case_2),
13837 		TEST_CASE_ST(ut_setup, ut_teardown,
13838 			test_snow3g_decryption_test_case_3),
13839 		TEST_CASE_ST(ut_setup, ut_teardown,
13840 			test_snow3g_decryption_test_case_4),
13841 		TEST_CASE_ST(ut_setup, ut_teardown,
13842 			test_snow3g_decryption_test_case_5),
13843 
13844 		TEST_CASE_ST(ut_setup, ut_teardown,
13845 			test_snow3g_hash_generate_test_case_1),
13846 		TEST_CASE_ST(ut_setup, ut_teardown,
13847 			test_snow3g_hash_generate_test_case_2),
13848 		TEST_CASE_ST(ut_setup, ut_teardown,
13849 			test_snow3g_hash_generate_test_case_3),
13850 		TEST_CASE_ST(ut_setup, ut_teardown,
13851 			test_snow3g_hash_verify_test_case_1),
13852 		TEST_CASE_ST(ut_setup, ut_teardown,
13853 			test_snow3g_hash_verify_test_case_2),
13854 		TEST_CASE_ST(ut_setup, ut_teardown,
13855 			test_snow3g_hash_verify_test_case_3),
13856 
13857 		/** ZUC encrypt only (EEA3) */
13858 		TEST_CASE_ST(ut_setup, ut_teardown,
13859 			test_zuc_encryption_test_case_1),
13860 		TEST_CASE_ST(ut_setup, ut_teardown,
13861 			test_zuc_encryption_test_case_2),
13862 		TEST_CASE_ST(ut_setup, ut_teardown,
13863 			test_zuc_encryption_test_case_3),
13864 		TEST_CASE_ST(ut_setup, ut_teardown,
13865 			test_zuc_encryption_test_case_4),
13866 		TEST_CASE_ST(ut_setup, ut_teardown,
13867 			test_zuc_encryption_test_case_5),
13868 		TEST_CASE_ST(ut_setup, ut_teardown,
13869 			test_zuc_hash_generate_test_case_1),
13870 		TEST_CASE_ST(ut_setup, ut_teardown,
13871 			test_zuc_hash_generate_test_case_2),
13872 		TEST_CASE_ST(ut_setup, ut_teardown,
13873 			test_zuc_hash_generate_test_case_3),
13874 		TEST_CASE_ST(ut_setup, ut_teardown,
13875 			test_zuc_hash_generate_test_case_4),
13876 		TEST_CASE_ST(ut_setup, ut_teardown,
13877 			test_zuc_hash_generate_test_case_5),
13878 		TEST_CASE_ST(ut_setup, ut_teardown,
13879 			test_zuc_encryption_test_case_6_sgl),
13880 
13881 		/** KASUMI encrypt only (UEA1) */
13882 		TEST_CASE_ST(ut_setup, ut_teardown,
13883 			test_kasumi_encryption_test_case_1),
13884 		TEST_CASE_ST(ut_setup, ut_teardown,
13885 			test_kasumi_encryption_test_case_2),
13886 		TEST_CASE_ST(ut_setup, ut_teardown,
13887 			test_kasumi_encryption_test_case_3),
13888 		TEST_CASE_ST(ut_setup, ut_teardown,
13889 			test_kasumi_encryption_test_case_4),
13890 		TEST_CASE_ST(ut_setup, ut_teardown,
13891 			test_kasumi_encryption_test_case_5),
13892 		TEST_CASE_ST(ut_setup, ut_teardown,
13893 			test_kasumi_encryption_test_case_1_sgl),
13894 		TEST_CASE_ST(ut_setup, ut_teardown,
13895 			test_kasumi_encryption_test_case_1_oop_sgl),
13896 		/** KASUMI decrypt only (UEA1) */
13897 		TEST_CASE_ST(ut_setup, ut_teardown,
13898 			test_kasumi_decryption_test_case_1),
13899 		TEST_CASE_ST(ut_setup, ut_teardown,
13900 			test_kasumi_decryption_test_case_2),
13901 		TEST_CASE_ST(ut_setup, ut_teardown,
13902 			test_kasumi_decryption_test_case_3),
13903 		TEST_CASE_ST(ut_setup, ut_teardown,
13904 			test_kasumi_decryption_test_case_4),
13905 		TEST_CASE_ST(ut_setup, ut_teardown,
13906 			test_kasumi_decryption_test_case_5),
13907 
13908 		TEST_CASE_ST(ut_setup, ut_teardown,
13909 			test_kasumi_encryption_test_case_1_oop),
13910 		TEST_CASE_ST(ut_setup, ut_teardown,
13911 			test_kasumi_decryption_test_case_1_oop),
13912 
13913 		/** KASUMI hash only (UIA1) */
13914 		TEST_CASE_ST(ut_setup, ut_teardown,
13915 			test_kasumi_hash_generate_test_case_1),
13916 		TEST_CASE_ST(ut_setup, ut_teardown,
13917 			test_kasumi_hash_generate_test_case_2),
13918 		TEST_CASE_ST(ut_setup, ut_teardown,
13919 			test_kasumi_hash_generate_test_case_3),
13920 		TEST_CASE_ST(ut_setup, ut_teardown,
13921 			test_kasumi_hash_generate_test_case_4),
13922 		TEST_CASE_ST(ut_setup, ut_teardown,
13923 			test_kasumi_hash_generate_test_case_5),
13924 		TEST_CASE_ST(ut_setup, ut_teardown,
13925 			test_kasumi_hash_generate_test_case_6),
13926 		TEST_CASE_ST(ut_setup, ut_teardown,
13927 			test_kasumi_hash_verify_test_case_1),
13928 		TEST_CASE_ST(ut_setup, ut_teardown,
13929 			test_kasumi_hash_verify_test_case_2),
13930 		TEST_CASE_ST(ut_setup, ut_teardown,
13931 			test_kasumi_hash_verify_test_case_3),
13932 		TEST_CASE_ST(ut_setup, ut_teardown,
13933 			test_kasumi_hash_verify_test_case_4),
13934 		TEST_CASE_ST(ut_setup, ut_teardown,
13935 			test_kasumi_hash_verify_test_case_5),
13936 
13937 		/** NULL tests */
13938 		TEST_CASE_ST(ut_setup, ut_teardown,
13939 			test_null_cipher_only_operation),
13940 		TEST_CASE_ST(ut_setup, ut_teardown,
13941 			test_null_auth_only_operation),
13942 		TEST_CASE_ST(ut_setup, ut_teardown,
13943 			test_null_cipher_auth_operation),
13944 		TEST_CASE_ST(ut_setup, ut_teardown,
13945 			test_null_auth_cipher_operation),
13946 
13947 		/** Negative tests */
13948 		TEST_CASE_ST(ut_setup, ut_teardown,
13949 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13950 		TEST_CASE_ST(ut_setup, ut_teardown,
13951 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13952 		TEST_CASE_ST(ut_setup, ut_teardown,
13953 			authentication_verify_AES128_GMAC_fail_data_corrupt),
13954 		TEST_CASE_ST(ut_setup, ut_teardown,
13955 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
13956 		TEST_CASE_ST(ut_setup, ut_teardown,
13957 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13958 		TEST_CASE_ST(ut_setup, ut_teardown,
13959 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13960 		TEST_CASES_END() /**< NULL terminate unit test array */
13961 	}
13962 };
13963 
13964 static struct unit_test_suite cryptodev_nitrox_testsuite  = {
13965 	.suite_name = "Crypto NITROX Unit Test Suite",
13966 	.setup = testsuite_setup,
13967 	.teardown = testsuite_teardown,
13968 	.unit_test_cases = {
13969 		TEST_CASE_ST(ut_setup, ut_teardown,
13970 			     test_device_configure_invalid_dev_id),
13971 		TEST_CASE_ST(ut_setup, ut_teardown,
13972 				test_device_configure_invalid_queue_pair_ids),
13973 		TEST_CASE_ST(ut_setup, ut_teardown,
13974 			     test_AES_chain_nitrox_all),
13975 
13976 		TEST_CASES_END() /**< NULL terminate unit test array */
13977 	}
13978 };
13979 
13980 static struct unit_test_suite cryptodev_octeontx2_testsuite  = {
13981 	.suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13982 	.setup = testsuite_setup,
13983 	.teardown = testsuite_teardown,
13984 	.unit_test_cases = {
13985 		TEST_CASE_ST(ut_setup, ut_teardown,
13986 			test_AES_chain_octeontx2_all),
13987 		TEST_CASE_ST(ut_setup, ut_teardown,
13988 			test_AES_cipheronly_octeontx2_all),
13989 		TEST_CASE_ST(ut_setup, ut_teardown,
13990 			test_3DES_chain_octeontx2_all),
13991 		TEST_CASE_ST(ut_setup, ut_teardown,
13992 			test_3DES_cipheronly_octeontx2_all),
13993 		TEST_CASE_ST(ut_setup, ut_teardown,
13994 			test_authonly_octeontx2_all),
13995 
13996 		/** AES GCM Authenticated Encryption */
13997 		TEST_CASE_ST(ut_setup, ut_teardown,
13998 			test_AES_GCM_authenticated_encryption_test_case_1),
13999 		TEST_CASE_ST(ut_setup, ut_teardown,
14000 			test_AES_GCM_authenticated_encryption_test_case_2),
14001 		TEST_CASE_ST(ut_setup, ut_teardown,
14002 			test_AES_GCM_authenticated_encryption_test_case_3),
14003 		TEST_CASE_ST(ut_setup, ut_teardown,
14004 			test_AES_GCM_authenticated_encryption_test_case_4),
14005 		TEST_CASE_ST(ut_setup, ut_teardown,
14006 			test_AES_GCM_authenticated_encryption_test_case_5),
14007 		TEST_CASE_ST(ut_setup, ut_teardown,
14008 			test_AES_GCM_authenticated_encryption_test_case_6),
14009 		TEST_CASE_ST(ut_setup, ut_teardown,
14010 			test_AES_GCM_authenticated_encryption_test_case_7),
14011 
14012 		/** AES GCM Authenticated Decryption */
14013 		TEST_CASE_ST(ut_setup, ut_teardown,
14014 			test_AES_GCM_authenticated_decryption_test_case_1),
14015 		TEST_CASE_ST(ut_setup, ut_teardown,
14016 			test_AES_GCM_authenticated_decryption_test_case_2),
14017 		TEST_CASE_ST(ut_setup, ut_teardown,
14018 			test_AES_GCM_authenticated_decryption_test_case_3),
14019 		TEST_CASE_ST(ut_setup, ut_teardown,
14020 			test_AES_GCM_authenticated_decryption_test_case_4),
14021 		TEST_CASE_ST(ut_setup, ut_teardown,
14022 			test_AES_GCM_authenticated_decryption_test_case_5),
14023 		TEST_CASE_ST(ut_setup, ut_teardown,
14024 			test_AES_GCM_authenticated_decryption_test_case_6),
14025 		TEST_CASE_ST(ut_setup, ut_teardown,
14026 			test_AES_GCM_authenticated_decryption_test_case_7),
14027 		/** AES GMAC Authentication */
14028 		TEST_CASE_ST(ut_setup, ut_teardown,
14029 			test_AES_GMAC_authentication_test_case_1),
14030 		TEST_CASE_ST(ut_setup, ut_teardown,
14031 			test_AES_GMAC_authentication_verify_test_case_1),
14032 		TEST_CASE_ST(ut_setup, ut_teardown,
14033 			test_AES_GMAC_authentication_test_case_2),
14034 		TEST_CASE_ST(ut_setup, ut_teardown,
14035 			test_AES_GMAC_authentication_verify_test_case_2),
14036 		TEST_CASE_ST(ut_setup, ut_teardown,
14037 			test_AES_GMAC_authentication_test_case_3),
14038 		TEST_CASE_ST(ut_setup, ut_teardown,
14039 			test_AES_GMAC_authentication_verify_test_case_3),
14040 
14041 		/** SNOW 3G encrypt only (UEA2) */
14042 		TEST_CASE_ST(ut_setup, ut_teardown,
14043 			test_snow3g_encryption_test_case_1),
14044 		TEST_CASE_ST(ut_setup, ut_teardown,
14045 			test_snow3g_encryption_test_case_2),
14046 		TEST_CASE_ST(ut_setup, ut_teardown,
14047 			test_snow3g_encryption_test_case_3),
14048 		TEST_CASE_ST(ut_setup, ut_teardown,
14049 			test_snow3g_encryption_test_case_4),
14050 		TEST_CASE_ST(ut_setup, ut_teardown,
14051 			test_snow3g_encryption_test_case_5),
14052 
14053 		TEST_CASE_ST(ut_setup, ut_teardown,
14054 			test_snow3g_encryption_test_case_1_oop),
14055 		TEST_CASE_ST(ut_setup, ut_teardown,
14056 			test_snow3g_decryption_test_case_1_oop),
14057 		TEST_CASE_ST(ut_setup, ut_teardown,
14058 			test_snow3g_encryption_test_case_1_oop_sgl),
14059 
14060 		/** SNOW 3G decrypt only (UEA2) */
14061 		TEST_CASE_ST(ut_setup, ut_teardown,
14062 			test_snow3g_decryption_test_case_1),
14063 		TEST_CASE_ST(ut_setup, ut_teardown,
14064 			test_snow3g_decryption_test_case_2),
14065 		TEST_CASE_ST(ut_setup, ut_teardown,
14066 			test_snow3g_decryption_test_case_3),
14067 		TEST_CASE_ST(ut_setup, ut_teardown,
14068 			test_snow3g_decryption_test_case_4),
14069 		TEST_CASE_ST(ut_setup, ut_teardown,
14070 			test_snow3g_decryption_test_case_5),
14071 
14072 		TEST_CASE_ST(ut_setup, ut_teardown,
14073 			test_snow3g_hash_generate_test_case_1),
14074 		TEST_CASE_ST(ut_setup, ut_teardown,
14075 			test_snow3g_hash_generate_test_case_2),
14076 		TEST_CASE_ST(ut_setup, ut_teardown,
14077 			test_snow3g_hash_generate_test_case_3),
14078 		TEST_CASE_ST(ut_setup, ut_teardown,
14079 			test_snow3g_hash_verify_test_case_1),
14080 		TEST_CASE_ST(ut_setup, ut_teardown,
14081 			test_snow3g_hash_verify_test_case_2),
14082 		TEST_CASE_ST(ut_setup, ut_teardown,
14083 			test_snow3g_hash_verify_test_case_3),
14084 
14085 		/** ZUC encrypt only (EEA3) */
14086 		TEST_CASE_ST(ut_setup, ut_teardown,
14087 			test_zuc_encryption_test_case_1),
14088 		TEST_CASE_ST(ut_setup, ut_teardown,
14089 			test_zuc_encryption_test_case_2),
14090 		TEST_CASE_ST(ut_setup, ut_teardown,
14091 			test_zuc_encryption_test_case_3),
14092 		TEST_CASE_ST(ut_setup, ut_teardown,
14093 			test_zuc_encryption_test_case_4),
14094 		TEST_CASE_ST(ut_setup, ut_teardown,
14095 			test_zuc_encryption_test_case_5),
14096 		TEST_CASE_ST(ut_setup, ut_teardown,
14097 			test_zuc_hash_generate_test_case_1),
14098 		TEST_CASE_ST(ut_setup, ut_teardown,
14099 			test_zuc_hash_generate_test_case_2),
14100 		TEST_CASE_ST(ut_setup, ut_teardown,
14101 			test_zuc_hash_generate_test_case_3),
14102 		TEST_CASE_ST(ut_setup, ut_teardown,
14103 			test_zuc_hash_generate_test_case_4),
14104 		TEST_CASE_ST(ut_setup, ut_teardown,
14105 			test_zuc_hash_generate_test_case_5),
14106 		TEST_CASE_ST(ut_setup, ut_teardown,
14107 			test_zuc_encryption_test_case_6_sgl),
14108 
14109 		/** KASUMI encrypt only (UEA1) */
14110 		TEST_CASE_ST(ut_setup, ut_teardown,
14111 			test_kasumi_encryption_test_case_1),
14112 		TEST_CASE_ST(ut_setup, ut_teardown,
14113 			test_kasumi_encryption_test_case_2),
14114 		TEST_CASE_ST(ut_setup, ut_teardown,
14115 			test_kasumi_encryption_test_case_3),
14116 		TEST_CASE_ST(ut_setup, ut_teardown,
14117 			test_kasumi_encryption_test_case_4),
14118 		TEST_CASE_ST(ut_setup, ut_teardown,
14119 			test_kasumi_encryption_test_case_5),
14120 		TEST_CASE_ST(ut_setup, ut_teardown,
14121 			test_kasumi_encryption_test_case_1_sgl),
14122 		TEST_CASE_ST(ut_setup, ut_teardown,
14123 			test_kasumi_encryption_test_case_1_oop_sgl),
14124 		/** KASUMI decrypt only (UEA1) */
14125 		TEST_CASE_ST(ut_setup, ut_teardown,
14126 			test_kasumi_decryption_test_case_1),
14127 		TEST_CASE_ST(ut_setup, ut_teardown,
14128 			test_kasumi_decryption_test_case_2),
14129 		TEST_CASE_ST(ut_setup, ut_teardown,
14130 			test_kasumi_decryption_test_case_3),
14131 		TEST_CASE_ST(ut_setup, ut_teardown,
14132 			test_kasumi_decryption_test_case_4),
14133 		TEST_CASE_ST(ut_setup, ut_teardown,
14134 			test_kasumi_decryption_test_case_5),
14135 
14136 		TEST_CASE_ST(ut_setup, ut_teardown,
14137 			test_kasumi_encryption_test_case_1_oop),
14138 		TEST_CASE_ST(ut_setup, ut_teardown,
14139 			test_kasumi_decryption_test_case_1_oop),
14140 
14141 		/** KASUMI hash only (UIA1) */
14142 		TEST_CASE_ST(ut_setup, ut_teardown,
14143 			test_kasumi_hash_generate_test_case_1),
14144 		TEST_CASE_ST(ut_setup, ut_teardown,
14145 			test_kasumi_hash_generate_test_case_2),
14146 		TEST_CASE_ST(ut_setup, ut_teardown,
14147 			test_kasumi_hash_generate_test_case_3),
14148 		TEST_CASE_ST(ut_setup, ut_teardown,
14149 			test_kasumi_hash_generate_test_case_4),
14150 		TEST_CASE_ST(ut_setup, ut_teardown,
14151 			test_kasumi_hash_generate_test_case_5),
14152 		TEST_CASE_ST(ut_setup, ut_teardown,
14153 			test_kasumi_hash_generate_test_case_6),
14154 		TEST_CASE_ST(ut_setup, ut_teardown,
14155 			test_kasumi_hash_verify_test_case_1),
14156 		TEST_CASE_ST(ut_setup, ut_teardown,
14157 			test_kasumi_hash_verify_test_case_2),
14158 		TEST_CASE_ST(ut_setup, ut_teardown,
14159 			test_kasumi_hash_verify_test_case_3),
14160 		TEST_CASE_ST(ut_setup, ut_teardown,
14161 			test_kasumi_hash_verify_test_case_4),
14162 		TEST_CASE_ST(ut_setup, ut_teardown,
14163 			test_kasumi_hash_verify_test_case_5),
14164 
14165 		/** NULL tests */
14166 		TEST_CASE_ST(ut_setup, ut_teardown,
14167 			test_null_cipher_only_operation),
14168 		TEST_CASE_ST(ut_setup, ut_teardown,
14169 			test_null_auth_only_operation),
14170 		TEST_CASE_ST(ut_setup, ut_teardown,
14171 			test_null_cipher_auth_operation),
14172 		TEST_CASE_ST(ut_setup, ut_teardown,
14173 			test_null_auth_cipher_operation),
14174 
14175 		/** Negative tests */
14176 		TEST_CASE_ST(ut_setup, ut_teardown,
14177 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14178 		TEST_CASE_ST(ut_setup, ut_teardown,
14179 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14180 		TEST_CASE_ST(ut_setup, ut_teardown,
14181 			authentication_verify_AES128_GMAC_fail_data_corrupt),
14182 		TEST_CASE_ST(ut_setup, ut_teardown,
14183 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
14184 		TEST_CASE_ST(ut_setup, ut_teardown,
14185 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14186 		TEST_CASE_ST(ut_setup, ut_teardown,
14187 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14188 		TEST_CASES_END() /**< NULL terminate unit test array */
14189 	}
14190 };
14191 
14192 static int
14193 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14194 {
14195 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14196 			RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14197 
14198 	if (gbl_driver_id == -1) {
14199 		RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14200 		"CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14201 		"are enabled in config file to run this testsuite.\n");
14202 		return TEST_SKIPPED;
14203 	}
14204 
14205 	return unit_test_suite_runner(&cryptodev_qat_testsuite);
14206 }
14207 
14208 static int
14209 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14210 {
14211 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14212 			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14213 
14214 	if (gbl_driver_id == -1) {
14215 		RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14216 				"CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14217 				"in config file to run this testsuite.\n");
14218 		return TEST_FAILED;
14219 	}
14220 
14221 	return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14222 }
14223 
14224 static int
14225 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14226 {
14227 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14228 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14229 
14230 	if (gbl_driver_id == -1) {
14231 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14232 				"CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14233 				"in config file to run this testsuite.\n");
14234 		return TEST_SKIPPED;
14235 	}
14236 
14237 	return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14238 }
14239 
14240 static int
14241 test_cryptodev_openssl(void)
14242 {
14243 	gbl_driver_id = rte_cryptodev_driver_id_get(
14244 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14245 
14246 	if (gbl_driver_id == -1) {
14247 		RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14248 				"CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14249 				"in config file to run this testsuite.\n");
14250 		return TEST_SKIPPED;
14251 	}
14252 
14253 	return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14254 }
14255 
14256 static int
14257 test_cryptodev_aesni_gcm(void)
14258 {
14259 	gbl_driver_id = rte_cryptodev_driver_id_get(
14260 			RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14261 
14262 	if (gbl_driver_id == -1) {
14263 		RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14264 				"CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14265 				"in config file to run this testsuite.\n");
14266 		return TEST_SKIPPED;
14267 	}
14268 
14269 	return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14270 }
14271 
14272 static int
14273 test_cryptodev_null(void)
14274 {
14275 	gbl_driver_id = rte_cryptodev_driver_id_get(
14276 			RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14277 
14278 	if (gbl_driver_id == -1) {
14279 		RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14280 				"CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14281 				"in config file to run this testsuite.\n");
14282 		return TEST_SKIPPED;
14283 	}
14284 
14285 	return unit_test_suite_runner(&cryptodev_null_testsuite);
14286 }
14287 
14288 static int
14289 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14290 {
14291 	gbl_driver_id = rte_cryptodev_driver_id_get(
14292 			RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14293 
14294 	if (gbl_driver_id == -1) {
14295 		RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14296 				"CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14297 				"in config file to run this testsuite.\n");
14298 		return TEST_SKIPPED;
14299 	}
14300 
14301 	return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14302 }
14303 
14304 static int
14305 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14306 {
14307 	gbl_driver_id = rte_cryptodev_driver_id_get(
14308 			RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14309 
14310 	if (gbl_driver_id == -1) {
14311 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14312 				"CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14313 				"in config file to run this testsuite.\n");
14314 		return TEST_SKIPPED;
14315 	}
14316 
14317 	return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14318 }
14319 
14320 static int
14321 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14322 {
14323 	gbl_driver_id = rte_cryptodev_driver_id_get(
14324 			RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14325 
14326 	if (gbl_driver_id == -1) {
14327 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14328 				"CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14329 				"in config file to run this testsuite.\n");
14330 		return TEST_SKIPPED;
14331 	}
14332 
14333 	return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14334 }
14335 
14336 static int
14337 test_cryptodev_armv8(void)
14338 {
14339 	gbl_driver_id = rte_cryptodev_driver_id_get(
14340 			RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14341 
14342 	if (gbl_driver_id == -1) {
14343 		RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14344 				"CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14345 				"in config file to run this testsuite.\n");
14346 		return TEST_SKIPPED;
14347 	}
14348 
14349 	return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14350 }
14351 
14352 static int
14353 test_cryptodev_mrvl(void)
14354 {
14355 	gbl_driver_id = rte_cryptodev_driver_id_get(
14356 			RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14357 
14358 	if (gbl_driver_id == -1) {
14359 		RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14360 				"CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14361 				"in config file to run this testsuite.\n");
14362 		return TEST_SKIPPED;
14363 	}
14364 
14365 	return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14366 }
14367 
14368 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14369 
14370 static int
14371 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14372 {
14373 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14374 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14375 
14376 	if (gbl_driver_id == -1) {
14377 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14378 				"CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14379 				"in config file to run this testsuite.\n");
14380 		return TEST_SKIPPED;
14381 	}
14382 
14383 	if (rte_cryptodev_driver_id_get(
14384 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14385 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14386 			" enabled in config file to run this testsuite.\n");
14387 		return TEST_SKIPPED;
14388 }
14389 	return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14390 }
14391 
14392 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14393 
14394 #endif
14395 
14396 static int
14397 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14398 {
14399 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14400 			RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14401 
14402 	if (gbl_driver_id == -1) {
14403 		RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14404 				"CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14405 				"in config file to run this testsuite.\n");
14406 		return TEST_SKIPPED;
14407 	}
14408 
14409 	return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14410 }
14411 
14412 static int
14413 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14414 {
14415 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14416 			RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14417 
14418 	if (gbl_driver_id == -1) {
14419 		RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14420 				"CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14421 				"in config file to run this testsuite.\n");
14422 		return TEST_SKIPPED;
14423 	}
14424 
14425 	return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14426 }
14427 
14428 static int
14429 test_cryptodev_ccp(void)
14430 {
14431 	gbl_driver_id = rte_cryptodev_driver_id_get(
14432 			RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14433 
14434 	if (gbl_driver_id == -1) {
14435 		RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14436 				"CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14437 				"in config file to run this testsuite.\n");
14438 		return TEST_FAILED;
14439 	}
14440 
14441 	return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14442 }
14443 
14444 static int
14445 test_cryptodev_octeontx(void)
14446 {
14447 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14448 			RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14449 	if (gbl_driver_id == -1) {
14450 		RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14451 				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14452 				"enabled in config file to run this "
14453 				"testsuite.\n");
14454 		return TEST_FAILED;
14455 	}
14456 	return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14457 }
14458 
14459 static int
14460 test_cryptodev_octeontx2(void)
14461 {
14462 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14463 			RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14464 	if (gbl_driver_id == -1) {
14465 		RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14466 				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14467 				"enabled in config file to run this "
14468 				"testsuite.\n");
14469 		return TEST_FAILED;
14470 	}
14471 	return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14472 }
14473 
14474 static int
14475 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14476 {
14477 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14478 			RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14479 
14480 	if (gbl_driver_id == -1) {
14481 		RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14482 				"CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14483 				"in config file to run this testsuite.\n");
14484 		return TEST_FAILED;
14485 	}
14486 
14487 	return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14488 }
14489 
14490 static int
14491 test_cryptodev_nitrox(void)
14492 {
14493 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14494 			RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14495 
14496 	if (gbl_driver_id == -1) {
14497 		RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14498 				"CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14499 				"in config file to run this testsuite.\n");
14500 		return TEST_FAILED;
14501 	}
14502 
14503 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14504 }
14505 
14506 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14507 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14508 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14509 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14510 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14511 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14512 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14513 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14514 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14515 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14516 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14517 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14518 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14519 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14520 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14521 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14522 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14523 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14524