xref: /f-stack/dpdk/app/test/test_cryptodev.c (revision 0c6bd470)
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[0];
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 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2705 
2706 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2707 			&ut_params->cipher_xform,
2708 			ts_params->session_priv_mpool);
2709 	if (status == -ENOTSUP)
2710 		return status;
2711 
2712 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2713 	return 0;
2714 }
2715 
2716 static int
2717 create_wireless_cipher_auth_session(uint8_t dev_id,
2718 		enum rte_crypto_cipher_operation cipher_op,
2719 		enum rte_crypto_auth_operation auth_op,
2720 		enum rte_crypto_auth_algorithm auth_algo,
2721 		enum rte_crypto_cipher_algorithm cipher_algo,
2722 		const struct wireless_test_data *tdata)
2723 {
2724 	const uint8_t key_len = tdata->key.len;
2725 	uint8_t cipher_auth_key[key_len];
2726 	int status;
2727 
2728 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2729 	struct crypto_unittest_params *ut_params = &unittest_params;
2730 	const uint8_t *key = tdata->key.data;
2731 	const uint8_t auth_len = tdata->digest.len;
2732 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2733 	uint8_t auth_iv_len = tdata->auth_iv.len;
2734 
2735 	memcpy(cipher_auth_key, key, key_len);
2736 
2737 	/* Setup Authentication Parameters */
2738 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2739 	ut_params->auth_xform.next = NULL;
2740 
2741 	ut_params->auth_xform.auth.op = auth_op;
2742 	ut_params->auth_xform.auth.algo = auth_algo;
2743 	ut_params->auth_xform.auth.key.length = key_len;
2744 	/* Hash key = cipher key */
2745 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2746 	ut_params->auth_xform.auth.digest_length = auth_len;
2747 	/* Auth IV will be after cipher IV */
2748 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2749 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2750 
2751 	/* Setup Cipher Parameters */
2752 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2753 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2754 
2755 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2756 	ut_params->cipher_xform.cipher.op = cipher_op;
2757 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2758 	ut_params->cipher_xform.cipher.key.length = key_len;
2759 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2760 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2761 
2762 
2763 	debug_hexdump(stdout, "key:", key, key_len);
2764 
2765 	/* Create Crypto session*/
2766 	ut_params->sess = rte_cryptodev_sym_session_create(
2767 			ts_params->session_mpool);
2768 
2769 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2770 			&ut_params->cipher_xform,
2771 			ts_params->session_priv_mpool);
2772 
2773 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2774 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2775 	return 0;
2776 }
2777 
2778 static int
2779 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2780 		const struct wireless_test_data *tdata)
2781 {
2782 	return create_wireless_cipher_auth_session(dev_id,
2783 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2784 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2785 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2786 }
2787 
2788 static int
2789 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2790 		enum rte_crypto_cipher_operation cipher_op,
2791 		enum rte_crypto_auth_operation auth_op,
2792 		enum rte_crypto_auth_algorithm auth_algo,
2793 		enum rte_crypto_cipher_algorithm cipher_algo,
2794 		const uint8_t *key, const uint8_t key_len,
2795 		uint8_t auth_iv_len, uint8_t auth_len,
2796 		uint8_t cipher_iv_len)
2797 {
2798 	uint8_t auth_cipher_key[key_len];
2799 	int status;
2800 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2801 	struct crypto_unittest_params *ut_params = &unittest_params;
2802 
2803 	memcpy(auth_cipher_key, key, key_len);
2804 
2805 	/* Setup Authentication Parameters */
2806 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2807 	ut_params->auth_xform.auth.op = auth_op;
2808 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2809 	ut_params->auth_xform.auth.algo = auth_algo;
2810 	ut_params->auth_xform.auth.key.length = key_len;
2811 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
2812 	ut_params->auth_xform.auth.digest_length = auth_len;
2813 	/* Auth IV will be after cipher IV */
2814 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2815 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2816 
2817 	/* Setup Cipher Parameters */
2818 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2819 	ut_params->cipher_xform.next = NULL;
2820 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2821 	ut_params->cipher_xform.cipher.op = cipher_op;
2822 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2823 	ut_params->cipher_xform.cipher.key.length = key_len;
2824 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2825 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2826 
2827 	debug_hexdump(stdout, "key:", key, key_len);
2828 
2829 	/* Create Crypto session*/
2830 	ut_params->sess = rte_cryptodev_sym_session_create(
2831 			ts_params->session_mpool);
2832 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2833 
2834 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2835 		ut_params->auth_xform.next = NULL;
2836 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2837 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2838 				&ut_params->cipher_xform,
2839 				ts_params->session_priv_mpool);
2840 
2841 	} else
2842 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2843 				&ut_params->auth_xform,
2844 				ts_params->session_priv_mpool);
2845 
2846 	if (status == -ENOTSUP)
2847 		return status;
2848 
2849 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2850 
2851 	return 0;
2852 }
2853 
2854 static int
2855 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2856 		unsigned int auth_tag_len,
2857 		const uint8_t *iv, unsigned int iv_len,
2858 		unsigned int data_pad_len,
2859 		enum rte_crypto_auth_operation op,
2860 		unsigned int auth_len, unsigned int auth_offset)
2861 {
2862 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2863 
2864 	struct crypto_unittest_params *ut_params = &unittest_params;
2865 
2866 	/* Generate Crypto op data structure */
2867 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2868 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2869 	TEST_ASSERT_NOT_NULL(ut_params->op,
2870 		"Failed to allocate pktmbuf offload");
2871 
2872 	/* Set crypto operation data parameters */
2873 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2874 
2875 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2876 
2877 	/* set crypto operation source mbuf */
2878 	sym_op->m_src = ut_params->ibuf;
2879 
2880 	/* iv */
2881 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2882 			iv, iv_len);
2883 	/* digest */
2884 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2885 					ut_params->ibuf, auth_tag_len);
2886 
2887 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2888 				"no room to append auth tag");
2889 	ut_params->digest = sym_op->auth.digest.data;
2890 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2891 			ut_params->ibuf, data_pad_len);
2892 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2893 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2894 	else
2895 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2896 
2897 	debug_hexdump(stdout, "digest:",
2898 		sym_op->auth.digest.data,
2899 		auth_tag_len);
2900 
2901 	sym_op->auth.data.length = auth_len;
2902 	sym_op->auth.data.offset = auth_offset;
2903 
2904 	return 0;
2905 }
2906 
2907 static int
2908 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2909 	enum rte_crypto_auth_operation op)
2910 {
2911 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2912 	struct crypto_unittest_params *ut_params = &unittest_params;
2913 
2914 	const uint8_t *auth_tag = tdata->digest.data;
2915 	const unsigned int auth_tag_len = tdata->digest.len;
2916 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2917 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2918 
2919 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2920 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2921 	const uint8_t *auth_iv = tdata->auth_iv.data;
2922 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2923 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2924 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2925 
2926 	/* Generate Crypto op data structure */
2927 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2928 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2929 	TEST_ASSERT_NOT_NULL(ut_params->op,
2930 			"Failed to allocate pktmbuf offload");
2931 	/* Set crypto operation data parameters */
2932 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2933 
2934 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2935 
2936 	/* set crypto operation source mbuf */
2937 	sym_op->m_src = ut_params->ibuf;
2938 
2939 	/* digest */
2940 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2941 			ut_params->ibuf, auth_tag_len);
2942 
2943 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2944 			"no room to append auth tag");
2945 	ut_params->digest = sym_op->auth.digest.data;
2946 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2947 			ut_params->ibuf, data_pad_len);
2948 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2949 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2950 	else
2951 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2952 
2953 	debug_hexdump(stdout, "digest:",
2954 		sym_op->auth.digest.data,
2955 		auth_tag_len);
2956 
2957 	/* Copy cipher and auth IVs at the end of the crypto operation */
2958 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2959 						IV_OFFSET);
2960 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2961 	iv_ptr += cipher_iv_len;
2962 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2963 
2964 	sym_op->cipher.data.length = cipher_len;
2965 	sym_op->cipher.data.offset = 0;
2966 	sym_op->auth.data.length = auth_len;
2967 	sym_op->auth.data.offset = 0;
2968 
2969 	return 0;
2970 }
2971 
2972 static int
2973 create_zuc_cipher_hash_generate_operation(
2974 		const struct wireless_test_data *tdata)
2975 {
2976 	return create_wireless_cipher_hash_operation(tdata,
2977 		RTE_CRYPTO_AUTH_OP_GENERATE);
2978 }
2979 
2980 static int
2981 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2982 		const unsigned auth_tag_len,
2983 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2984 		unsigned data_pad_len,
2985 		enum rte_crypto_auth_operation op,
2986 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2987 		const unsigned cipher_len, const unsigned cipher_offset,
2988 		const unsigned auth_len, const unsigned auth_offset)
2989 {
2990 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 	struct crypto_unittest_params *ut_params = &unittest_params;
2992 
2993 	enum rte_crypto_cipher_algorithm cipher_algo =
2994 			ut_params->cipher_xform.cipher.algo;
2995 	enum rte_crypto_auth_algorithm auth_algo =
2996 			ut_params->auth_xform.auth.algo;
2997 
2998 	/* Generate Crypto op data structure */
2999 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3000 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3001 	TEST_ASSERT_NOT_NULL(ut_params->op,
3002 			"Failed to allocate pktmbuf offload");
3003 	/* Set crypto operation data parameters */
3004 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3005 
3006 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3007 
3008 	/* set crypto operation source mbuf */
3009 	sym_op->m_src = ut_params->ibuf;
3010 
3011 	/* digest */
3012 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3013 			ut_params->ibuf, auth_tag_len);
3014 
3015 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3016 			"no room to append auth tag");
3017 	ut_params->digest = sym_op->auth.digest.data;
3018 
3019 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3020 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3021 				ut_params->ibuf, data_pad_len);
3022 	} else {
3023 		struct rte_mbuf *m = ut_params->ibuf;
3024 		unsigned int offset = data_pad_len;
3025 
3026 		while (offset > m->data_len && m->next != NULL) {
3027 			offset -= m->data_len;
3028 			m = m->next;
3029 		}
3030 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3031 			m, offset);
3032 	}
3033 
3034 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3035 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3036 	else
3037 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3038 
3039 	debug_hexdump(stdout, "digest:",
3040 		sym_op->auth.digest.data,
3041 		auth_tag_len);
3042 
3043 	/* Copy cipher and auth IVs at the end of the crypto operation */
3044 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3045 						IV_OFFSET);
3046 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3047 	iv_ptr += cipher_iv_len;
3048 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3049 
3050 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3051 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3052 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3053 		sym_op->cipher.data.length = cipher_len;
3054 		sym_op->cipher.data.offset = cipher_offset;
3055 	} else {
3056 		sym_op->cipher.data.length = cipher_len >> 3;
3057 		sym_op->cipher.data.offset = cipher_offset >> 3;
3058 	}
3059 
3060 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3061 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3062 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3063 		sym_op->auth.data.length = auth_len;
3064 		sym_op->auth.data.offset = auth_offset;
3065 	} else {
3066 		sym_op->auth.data.length = auth_len >> 3;
3067 		sym_op->auth.data.offset = auth_offset >> 3;
3068 	}
3069 
3070 	return 0;
3071 }
3072 
3073 static int
3074 create_wireless_algo_auth_cipher_operation(
3075 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3076 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3077 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3078 		unsigned int data_pad_len,
3079 		unsigned int cipher_len, unsigned int cipher_offset,
3080 		unsigned int auth_len, unsigned int auth_offset,
3081 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3082 {
3083 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3084 	struct crypto_unittest_params *ut_params = &unittest_params;
3085 
3086 	enum rte_crypto_cipher_algorithm cipher_algo =
3087 			ut_params->cipher_xform.cipher.algo;
3088 	enum rte_crypto_auth_algorithm auth_algo =
3089 			ut_params->auth_xform.auth.algo;
3090 
3091 	/* Generate Crypto op data structure */
3092 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3093 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3094 	TEST_ASSERT_NOT_NULL(ut_params->op,
3095 			"Failed to allocate pktmbuf offload");
3096 
3097 	/* Set crypto operation data parameters */
3098 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3099 
3100 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3101 
3102 	/* set crypto operation mbufs */
3103 	sym_op->m_src = ut_params->ibuf;
3104 	if (op_mode == OUT_OF_PLACE)
3105 		sym_op->m_dst = ut_params->obuf;
3106 
3107 	/* digest */
3108 	if (!do_sgl) {
3109 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3110 			(op_mode == IN_PLACE ?
3111 				ut_params->ibuf : ut_params->obuf),
3112 			uint8_t *, data_pad_len);
3113 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3114 			(op_mode == IN_PLACE ?
3115 				ut_params->ibuf : ut_params->obuf),
3116 			data_pad_len);
3117 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3118 	} else {
3119 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3120 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3121 				sym_op->m_src : sym_op->m_dst);
3122 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3123 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3124 			sgl_buf = sgl_buf->next;
3125 		}
3126 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3127 				uint8_t *, remaining_off);
3128 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3129 				remaining_off);
3130 		memset(sym_op->auth.digest.data, 0, remaining_off);
3131 		while (sgl_buf->next != NULL) {
3132 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3133 				0, rte_pktmbuf_data_len(sgl_buf));
3134 			sgl_buf = sgl_buf->next;
3135 		}
3136 	}
3137 
3138 	/* Copy digest for the verification */
3139 	if (verify)
3140 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3141 
3142 	/* Copy cipher and auth IVs at the end of the crypto operation */
3143 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3144 			ut_params->op, uint8_t *, IV_OFFSET);
3145 
3146 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3147 	iv_ptr += cipher_iv_len;
3148 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3149 
3150 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3151 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3152 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3153 		sym_op->cipher.data.length = cipher_len;
3154 		sym_op->cipher.data.offset = cipher_offset;
3155 	} else {
3156 		sym_op->cipher.data.length = cipher_len >> 3;
3157 		sym_op->cipher.data.offset = cipher_offset >> 3;
3158 	}
3159 
3160 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3161 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3162 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3163 		sym_op->auth.data.length = auth_len;
3164 		sym_op->auth.data.offset = auth_offset;
3165 	} else {
3166 		sym_op->auth.data.length = auth_len >> 3;
3167 		sym_op->auth.data.offset = auth_offset >> 3;
3168 	}
3169 
3170 	return 0;
3171 }
3172 
3173 static int
3174 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3175 {
3176 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 	struct crypto_unittest_params *ut_params = &unittest_params;
3178 
3179 	int retval;
3180 	unsigned plaintext_pad_len;
3181 	unsigned plaintext_len;
3182 	uint8_t *plaintext;
3183 
3184 	/* Create SNOW 3G session */
3185 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3186 			tdata->key.data, tdata->key.len,
3187 			tdata->auth_iv.len, tdata->digest.len,
3188 			RTE_CRYPTO_AUTH_OP_GENERATE,
3189 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3190 	if (retval < 0)
3191 		return retval;
3192 
3193 	/* alloc mbuf and set payload */
3194 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3195 
3196 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3197 	rte_pktmbuf_tailroom(ut_params->ibuf));
3198 
3199 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3200 	/* Append data which is padded to a multiple of */
3201 	/* the algorithms block size */
3202 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3203 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3204 				plaintext_pad_len);
3205 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3206 
3207 	/* Create SNOW 3G operation */
3208 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3209 			tdata->auth_iv.data, tdata->auth_iv.len,
3210 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3211 			tdata->validAuthLenInBits.len,
3212 			0);
3213 	if (retval < 0)
3214 		return retval;
3215 
3216 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3217 				ut_params->op);
3218 	ut_params->obuf = ut_params->op->sym->m_src;
3219 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3220 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3221 			+ plaintext_pad_len;
3222 
3223 	/* Validate obuf */
3224 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3225 	ut_params->digest,
3226 	tdata->digest.data,
3227 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3228 	"SNOW 3G Generated auth tag not as expected");
3229 
3230 	return 0;
3231 }
3232 
3233 static int
3234 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3235 {
3236 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3237 	struct crypto_unittest_params *ut_params = &unittest_params;
3238 
3239 	int retval;
3240 	unsigned plaintext_pad_len;
3241 	unsigned plaintext_len;
3242 	uint8_t *plaintext;
3243 
3244 	/* Create SNOW 3G session */
3245 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3246 				tdata->key.data, tdata->key.len,
3247 				tdata->auth_iv.len, tdata->digest.len,
3248 				RTE_CRYPTO_AUTH_OP_VERIFY,
3249 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3250 	if (retval < 0)
3251 		return retval;
3252 	/* alloc mbuf and set payload */
3253 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3254 
3255 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3256 	rte_pktmbuf_tailroom(ut_params->ibuf));
3257 
3258 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3259 	/* Append data which is padded to a multiple of */
3260 	/* the algorithms block size */
3261 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3262 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3263 				plaintext_pad_len);
3264 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3265 
3266 	/* Create SNOW 3G operation */
3267 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3268 			tdata->digest.len,
3269 			tdata->auth_iv.data, tdata->auth_iv.len,
3270 			plaintext_pad_len,
3271 			RTE_CRYPTO_AUTH_OP_VERIFY,
3272 			tdata->validAuthLenInBits.len,
3273 			0);
3274 	if (retval < 0)
3275 		return retval;
3276 
3277 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3278 				ut_params->op);
3279 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 	ut_params->obuf = ut_params->op->sym->m_src;
3281 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3282 				+ plaintext_pad_len;
3283 
3284 	/* Validate obuf */
3285 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3286 		return 0;
3287 	else
3288 		return -1;
3289 
3290 	return 0;
3291 }
3292 
3293 static int
3294 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3295 {
3296 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3297 	struct crypto_unittest_params *ut_params = &unittest_params;
3298 
3299 	int retval;
3300 	unsigned plaintext_pad_len;
3301 	unsigned plaintext_len;
3302 	uint8_t *plaintext;
3303 
3304 	/* Create KASUMI session */
3305 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3306 			tdata->key.data, tdata->key.len,
3307 			0, tdata->digest.len,
3308 			RTE_CRYPTO_AUTH_OP_GENERATE,
3309 			RTE_CRYPTO_AUTH_KASUMI_F9);
3310 	if (retval < 0)
3311 		return retval;
3312 
3313 	/* alloc mbuf and set payload */
3314 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3315 
3316 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3317 	rte_pktmbuf_tailroom(ut_params->ibuf));
3318 
3319 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3320 	/* Append data which is padded to a multiple of */
3321 	/* the algorithms block size */
3322 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3323 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3324 				plaintext_pad_len);
3325 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3326 
3327 	/* Create KASUMI operation */
3328 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3329 			NULL, 0,
3330 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3331 			tdata->plaintext.len,
3332 			0);
3333 	if (retval < 0)
3334 		return retval;
3335 
3336 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3337 				ut_params->op);
3338 	ut_params->obuf = ut_params->op->sym->m_src;
3339 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3340 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3341 			+ plaintext_pad_len;
3342 
3343 	/* Validate obuf */
3344 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3345 	ut_params->digest,
3346 	tdata->digest.data,
3347 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3348 	"KASUMI Generated auth tag not as expected");
3349 
3350 	return 0;
3351 }
3352 
3353 static int
3354 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3355 {
3356 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3357 	struct crypto_unittest_params *ut_params = &unittest_params;
3358 
3359 	int retval;
3360 	unsigned plaintext_pad_len;
3361 	unsigned plaintext_len;
3362 	uint8_t *plaintext;
3363 
3364 	/* Create KASUMI session */
3365 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3366 				tdata->key.data, tdata->key.len,
3367 				0, tdata->digest.len,
3368 				RTE_CRYPTO_AUTH_OP_VERIFY,
3369 				RTE_CRYPTO_AUTH_KASUMI_F9);
3370 	if (retval < 0)
3371 		return retval;
3372 	/* alloc mbuf and set payload */
3373 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3374 
3375 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3376 	rte_pktmbuf_tailroom(ut_params->ibuf));
3377 
3378 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3379 	/* Append data which is padded to a multiple */
3380 	/* of the algorithms block size */
3381 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3382 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3383 				plaintext_pad_len);
3384 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3385 
3386 	/* Create KASUMI operation */
3387 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3388 			tdata->digest.len,
3389 			NULL, 0,
3390 			plaintext_pad_len,
3391 			RTE_CRYPTO_AUTH_OP_VERIFY,
3392 			tdata->plaintext.len,
3393 			0);
3394 	if (retval < 0)
3395 		return retval;
3396 
3397 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3398 				ut_params->op);
3399 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3400 	ut_params->obuf = ut_params->op->sym->m_src;
3401 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3402 				+ plaintext_pad_len;
3403 
3404 	/* Validate obuf */
3405 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3406 		return 0;
3407 	else
3408 		return -1;
3409 
3410 	return 0;
3411 }
3412 
3413 static int
3414 test_snow3g_hash_generate_test_case_1(void)
3415 {
3416 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3417 }
3418 
3419 static int
3420 test_snow3g_hash_generate_test_case_2(void)
3421 {
3422 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3423 }
3424 
3425 static int
3426 test_snow3g_hash_generate_test_case_3(void)
3427 {
3428 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3429 }
3430 
3431 static int
3432 test_snow3g_hash_generate_test_case_4(void)
3433 {
3434 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3435 }
3436 
3437 static int
3438 test_snow3g_hash_generate_test_case_5(void)
3439 {
3440 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3441 }
3442 
3443 static int
3444 test_snow3g_hash_generate_test_case_6(void)
3445 {
3446 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3447 }
3448 
3449 static int
3450 test_snow3g_hash_verify_test_case_1(void)
3451 {
3452 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3453 
3454 }
3455 
3456 static int
3457 test_snow3g_hash_verify_test_case_2(void)
3458 {
3459 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3460 }
3461 
3462 static int
3463 test_snow3g_hash_verify_test_case_3(void)
3464 {
3465 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3466 }
3467 
3468 static int
3469 test_snow3g_hash_verify_test_case_4(void)
3470 {
3471 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3472 }
3473 
3474 static int
3475 test_snow3g_hash_verify_test_case_5(void)
3476 {
3477 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3478 }
3479 
3480 static int
3481 test_snow3g_hash_verify_test_case_6(void)
3482 {
3483 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3484 }
3485 
3486 static int
3487 test_kasumi_hash_generate_test_case_1(void)
3488 {
3489 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3490 }
3491 
3492 static int
3493 test_kasumi_hash_generate_test_case_2(void)
3494 {
3495 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3496 }
3497 
3498 static int
3499 test_kasumi_hash_generate_test_case_3(void)
3500 {
3501 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3502 }
3503 
3504 static int
3505 test_kasumi_hash_generate_test_case_4(void)
3506 {
3507 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3508 }
3509 
3510 static int
3511 test_kasumi_hash_generate_test_case_5(void)
3512 {
3513 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3514 }
3515 
3516 static int
3517 test_kasumi_hash_generate_test_case_6(void)
3518 {
3519 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3520 }
3521 
3522 static int
3523 test_kasumi_hash_verify_test_case_1(void)
3524 {
3525 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3526 }
3527 
3528 static int
3529 test_kasumi_hash_verify_test_case_2(void)
3530 {
3531 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3532 }
3533 
3534 static int
3535 test_kasumi_hash_verify_test_case_3(void)
3536 {
3537 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3538 }
3539 
3540 static int
3541 test_kasumi_hash_verify_test_case_4(void)
3542 {
3543 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3544 }
3545 
3546 static int
3547 test_kasumi_hash_verify_test_case_5(void)
3548 {
3549 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3550 }
3551 
3552 static int
3553 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3554 {
3555 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3556 	struct crypto_unittest_params *ut_params = &unittest_params;
3557 
3558 	int retval;
3559 	uint8_t *plaintext, *ciphertext;
3560 	unsigned plaintext_pad_len;
3561 	unsigned plaintext_len;
3562 
3563 	/* Create KASUMI session */
3564 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3565 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3566 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3567 					tdata->key.data, tdata->key.len,
3568 					tdata->cipher_iv.len);
3569 	if (retval < 0)
3570 		return retval;
3571 
3572 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3573 
3574 	/* Clear mbuf payload */
3575 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3576 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3577 
3578 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3579 	/* Append data which is padded to a multiple */
3580 	/* of the algorithms block size */
3581 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3582 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3583 				plaintext_pad_len);
3584 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3585 
3586 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3587 
3588 	/* Create KASUMI operation */
3589 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3590 				tdata->cipher_iv.len,
3591 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3592 				tdata->validCipherOffsetInBits.len);
3593 	if (retval < 0)
3594 		return retval;
3595 
3596 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3597 						ut_params->op);
3598 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3599 
3600 	ut_params->obuf = ut_params->op->sym->m_dst;
3601 	if (ut_params->obuf)
3602 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3603 	else
3604 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3605 
3606 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3607 
3608 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3609 				(tdata->validCipherOffsetInBits.len >> 3);
3610 	/* Validate obuf */
3611 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3612 		ciphertext,
3613 		reference_ciphertext,
3614 		tdata->validCipherLenInBits.len,
3615 		"KASUMI Ciphertext data not as expected");
3616 	return 0;
3617 }
3618 
3619 static int
3620 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3621 {
3622 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3623 	struct crypto_unittest_params *ut_params = &unittest_params;
3624 
3625 	int retval;
3626 
3627 	unsigned int plaintext_pad_len;
3628 	unsigned int plaintext_len;
3629 
3630 	uint8_t buffer[10000];
3631 	const uint8_t *ciphertext;
3632 
3633 	struct rte_cryptodev_info dev_info;
3634 
3635 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3636 
3637 	uint64_t feat_flags = dev_info.feature_flags;
3638 
3639 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3640 		printf("Device doesn't support in-place scatter-gather. "
3641 				"Test Skipped.\n");
3642 		return -ENOTSUP;
3643 	}
3644 
3645 	/* Create KASUMI session */
3646 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3647 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3648 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3649 					tdata->key.data, tdata->key.len,
3650 					tdata->cipher_iv.len);
3651 	if (retval < 0)
3652 		return retval;
3653 
3654 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3655 
3656 
3657 	/* Append data which is padded to a multiple */
3658 	/* of the algorithms block size */
3659 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3660 
3661 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3662 			plaintext_pad_len, 10, 0);
3663 
3664 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3665 
3666 	/* Create KASUMI operation */
3667 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3668 				tdata->cipher_iv.len,
3669 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3670 				tdata->validCipherOffsetInBits.len);
3671 	if (retval < 0)
3672 		return retval;
3673 
3674 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3675 						ut_params->op);
3676 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3677 
3678 	ut_params->obuf = ut_params->op->sym->m_dst;
3679 
3680 	if (ut_params->obuf)
3681 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3682 				plaintext_len, buffer);
3683 	else
3684 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3685 				tdata->validCipherOffsetInBits.len >> 3,
3686 				plaintext_len, buffer);
3687 
3688 	/* Validate obuf */
3689 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3690 
3691 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3692 				(tdata->validCipherOffsetInBits.len >> 3);
3693 	/* Validate obuf */
3694 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3695 		ciphertext,
3696 		reference_ciphertext,
3697 		tdata->validCipherLenInBits.len,
3698 		"KASUMI Ciphertext data not as expected");
3699 	return 0;
3700 }
3701 
3702 static int
3703 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3704 {
3705 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3706 	struct crypto_unittest_params *ut_params = &unittest_params;
3707 
3708 	int retval;
3709 	uint8_t *plaintext, *ciphertext;
3710 	unsigned plaintext_pad_len;
3711 	unsigned plaintext_len;
3712 
3713 	/* Create KASUMI session */
3714 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3715 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3716 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3717 					tdata->key.data, tdata->key.len,
3718 					tdata->cipher_iv.len);
3719 	if (retval < 0)
3720 		return retval;
3721 
3722 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3723 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3724 
3725 	/* Clear mbuf payload */
3726 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3727 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3728 
3729 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3730 	/* Append data which is padded to a multiple */
3731 	/* of the algorithms block size */
3732 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3733 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3734 				plaintext_pad_len);
3735 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3736 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3737 
3738 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3739 
3740 	/* Create KASUMI operation */
3741 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3742 				tdata->cipher_iv.len,
3743 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3744 				tdata->validCipherOffsetInBits.len);
3745 	if (retval < 0)
3746 		return retval;
3747 
3748 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3749 						ut_params->op);
3750 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3751 
3752 	ut_params->obuf = ut_params->op->sym->m_dst;
3753 	if (ut_params->obuf)
3754 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3755 	else
3756 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3757 
3758 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3759 
3760 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3761 				(tdata->validCipherOffsetInBits.len >> 3);
3762 	/* Validate obuf */
3763 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3764 		ciphertext,
3765 		reference_ciphertext,
3766 		tdata->validCipherLenInBits.len,
3767 		"KASUMI Ciphertext data not as expected");
3768 	return 0;
3769 }
3770 
3771 static int
3772 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3773 {
3774 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3775 	struct crypto_unittest_params *ut_params = &unittest_params;
3776 
3777 	int retval;
3778 	unsigned int plaintext_pad_len;
3779 	unsigned int plaintext_len;
3780 
3781 	const uint8_t *ciphertext;
3782 	uint8_t buffer[2048];
3783 
3784 	struct rte_cryptodev_info dev_info;
3785 
3786 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3787 
3788 	uint64_t feat_flags = dev_info.feature_flags;
3789 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3790 		printf("Device doesn't support out-of-place scatter-gather "
3791 				"in both input and output mbufs. "
3792 				"Test Skipped.\n");
3793 		return -ENOTSUP;
3794 	}
3795 
3796 	/* Create KASUMI session */
3797 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3798 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3799 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3800 					tdata->key.data, tdata->key.len,
3801 					tdata->cipher_iv.len);
3802 	if (retval < 0)
3803 		return retval;
3804 
3805 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3806 	/* Append data which is padded to a multiple */
3807 	/* of the algorithms block size */
3808 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3809 
3810 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3811 			plaintext_pad_len, 10, 0);
3812 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3813 			plaintext_pad_len, 3, 0);
3814 
3815 	/* Append data which is padded to a multiple */
3816 	/* of the algorithms block size */
3817 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3818 
3819 	/* Create KASUMI operation */
3820 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3821 				tdata->cipher_iv.len,
3822 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3823 				tdata->validCipherOffsetInBits.len);
3824 	if (retval < 0)
3825 		return retval;
3826 
3827 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3828 						ut_params->op);
3829 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3830 
3831 	ut_params->obuf = ut_params->op->sym->m_dst;
3832 	if (ut_params->obuf)
3833 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3834 				plaintext_pad_len, buffer);
3835 	else
3836 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3837 				tdata->validCipherOffsetInBits.len >> 3,
3838 				plaintext_pad_len, buffer);
3839 
3840 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3841 				(tdata->validCipherOffsetInBits.len >> 3);
3842 	/* Validate obuf */
3843 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3844 		ciphertext,
3845 		reference_ciphertext,
3846 		tdata->validCipherLenInBits.len,
3847 		"KASUMI Ciphertext data not as expected");
3848 	return 0;
3849 }
3850 
3851 
3852 static int
3853 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3854 {
3855 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3856 	struct crypto_unittest_params *ut_params = &unittest_params;
3857 
3858 	int retval;
3859 	uint8_t *ciphertext, *plaintext;
3860 	unsigned ciphertext_pad_len;
3861 	unsigned ciphertext_len;
3862 
3863 	/* Create KASUMI session */
3864 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3865 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3866 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3867 					tdata->key.data, tdata->key.len,
3868 					tdata->cipher_iv.len);
3869 	if (retval < 0)
3870 		return retval;
3871 
3872 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3873 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3874 
3875 	/* Clear mbuf payload */
3876 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3877 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3878 
3879 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3880 	/* Append data which is padded to a multiple */
3881 	/* of the algorithms block size */
3882 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3883 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3884 				ciphertext_pad_len);
3885 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3886 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3887 
3888 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3889 
3890 	/* Create KASUMI operation */
3891 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3892 				tdata->cipher_iv.len,
3893 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3894 				tdata->validCipherOffsetInBits.len);
3895 	if (retval < 0)
3896 		return retval;
3897 
3898 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3899 						ut_params->op);
3900 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3901 
3902 	ut_params->obuf = ut_params->op->sym->m_dst;
3903 	if (ut_params->obuf)
3904 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3905 	else
3906 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3907 
3908 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3909 
3910 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3911 				(tdata->validCipherOffsetInBits.len >> 3);
3912 	/* Validate obuf */
3913 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3914 		plaintext,
3915 		reference_plaintext,
3916 		tdata->validCipherLenInBits.len,
3917 		"KASUMI Plaintext data not as expected");
3918 	return 0;
3919 }
3920 
3921 static int
3922 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3923 {
3924 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3925 	struct crypto_unittest_params *ut_params = &unittest_params;
3926 
3927 	int retval;
3928 	uint8_t *ciphertext, *plaintext;
3929 	unsigned ciphertext_pad_len;
3930 	unsigned ciphertext_len;
3931 
3932 	/* Create KASUMI session */
3933 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3934 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3935 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3936 					tdata->key.data, tdata->key.len,
3937 					tdata->cipher_iv.len);
3938 	if (retval < 0)
3939 		return retval;
3940 
3941 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3942 
3943 	/* Clear mbuf payload */
3944 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3945 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3946 
3947 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3948 	/* Append data which is padded to a multiple */
3949 	/* of the algorithms block size */
3950 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3951 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3952 				ciphertext_pad_len);
3953 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3954 
3955 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3956 
3957 	/* Create KASUMI operation */
3958 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3959 					tdata->cipher_iv.len,
3960 					tdata->ciphertext.len,
3961 					tdata->validCipherOffsetInBits.len);
3962 	if (retval < 0)
3963 		return retval;
3964 
3965 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3966 						ut_params->op);
3967 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3968 
3969 	ut_params->obuf = ut_params->op->sym->m_dst;
3970 	if (ut_params->obuf)
3971 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3972 	else
3973 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3974 
3975 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3976 
3977 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3978 				(tdata->validCipherOffsetInBits.len >> 3);
3979 	/* Validate obuf */
3980 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3981 		plaintext,
3982 		reference_plaintext,
3983 		tdata->validCipherLenInBits.len,
3984 		"KASUMI Plaintext data not as expected");
3985 	return 0;
3986 }
3987 
3988 static int
3989 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3990 {
3991 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3992 	struct crypto_unittest_params *ut_params = &unittest_params;
3993 
3994 	int retval;
3995 	uint8_t *plaintext, *ciphertext;
3996 	unsigned plaintext_pad_len;
3997 	unsigned plaintext_len;
3998 
3999 	/* Create SNOW 3G session */
4000 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4001 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4002 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4003 					tdata->key.data, tdata->key.len,
4004 					tdata->cipher_iv.len);
4005 	if (retval < 0)
4006 		return retval;
4007 
4008 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4009 
4010 	/* Clear mbuf payload */
4011 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4012 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4013 
4014 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4015 	/* Append data which is padded to a multiple of */
4016 	/* the algorithms block size */
4017 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4018 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4019 				plaintext_pad_len);
4020 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4021 
4022 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4023 
4024 	/* Create SNOW 3G operation */
4025 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4026 					tdata->cipher_iv.len,
4027 					tdata->validCipherLenInBits.len,
4028 					0);
4029 	if (retval < 0)
4030 		return retval;
4031 
4032 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4033 						ut_params->op);
4034 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4035 
4036 	ut_params->obuf = ut_params->op->sym->m_dst;
4037 	if (ut_params->obuf)
4038 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4039 	else
4040 		ciphertext = plaintext;
4041 
4042 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4043 
4044 	/* Validate obuf */
4045 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4046 		ciphertext,
4047 		tdata->ciphertext.data,
4048 		tdata->validDataLenInBits.len,
4049 		"SNOW 3G Ciphertext data not as expected");
4050 	return 0;
4051 }
4052 
4053 
4054 static int
4055 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4056 {
4057 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4058 	struct crypto_unittest_params *ut_params = &unittest_params;
4059 	uint8_t *plaintext, *ciphertext;
4060 
4061 	int retval;
4062 	unsigned plaintext_pad_len;
4063 	unsigned plaintext_len;
4064 
4065 	/* Create SNOW 3G session */
4066 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4067 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4068 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4069 					tdata->key.data, tdata->key.len,
4070 					tdata->cipher_iv.len);
4071 	if (retval < 0)
4072 		return retval;
4073 
4074 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4075 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4076 
4077 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4078 			"Failed to allocate input buffer in mempool");
4079 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4080 			"Failed to allocate output buffer in mempool");
4081 
4082 	/* Clear mbuf payload */
4083 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4084 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4085 
4086 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4087 	/* Append data which is padded to a multiple of */
4088 	/* the algorithms block size */
4089 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4090 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4091 				plaintext_pad_len);
4092 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4094 
4095 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4096 
4097 	/* Create SNOW 3G operation */
4098 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4099 					tdata->cipher_iv.len,
4100 					tdata->validCipherLenInBits.len,
4101 					0);
4102 	if (retval < 0)
4103 		return retval;
4104 
4105 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4106 						ut_params->op);
4107 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4108 
4109 	ut_params->obuf = ut_params->op->sym->m_dst;
4110 	if (ut_params->obuf)
4111 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4112 	else
4113 		ciphertext = plaintext;
4114 
4115 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4116 
4117 	/* Validate obuf */
4118 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4119 		ciphertext,
4120 		tdata->ciphertext.data,
4121 		tdata->validDataLenInBits.len,
4122 		"SNOW 3G Ciphertext data not as expected");
4123 	return 0;
4124 }
4125 
4126 static int
4127 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4128 {
4129 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4130 	struct crypto_unittest_params *ut_params = &unittest_params;
4131 
4132 	int retval;
4133 	unsigned int plaintext_pad_len;
4134 	unsigned int plaintext_len;
4135 	uint8_t buffer[10000];
4136 	const uint8_t *ciphertext;
4137 
4138 	struct rte_cryptodev_info dev_info;
4139 
4140 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4141 
4142 	uint64_t feat_flags = dev_info.feature_flags;
4143 
4144 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4145 		printf("Device doesn't support out-of-place scatter-gather "
4146 				"in both input and output mbufs. "
4147 				"Test Skipped.\n");
4148 		return -ENOTSUP;
4149 	}
4150 
4151 	/* Create SNOW 3G session */
4152 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4153 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4154 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4155 					tdata->key.data, tdata->key.len,
4156 					tdata->cipher_iv.len);
4157 	if (retval < 0)
4158 		return retval;
4159 
4160 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4161 	/* Append data which is padded to a multiple of */
4162 	/* the algorithms block size */
4163 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4164 
4165 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4166 			plaintext_pad_len, 10, 0);
4167 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4168 			plaintext_pad_len, 3, 0);
4169 
4170 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4171 			"Failed to allocate input buffer in mempool");
4172 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4173 			"Failed to allocate output buffer in mempool");
4174 
4175 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4176 
4177 	/* Create SNOW 3G operation */
4178 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4179 					tdata->cipher_iv.len,
4180 					tdata->validCipherLenInBits.len,
4181 					0);
4182 	if (retval < 0)
4183 		return retval;
4184 
4185 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4186 						ut_params->op);
4187 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4188 
4189 	ut_params->obuf = ut_params->op->sym->m_dst;
4190 	if (ut_params->obuf)
4191 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4192 				plaintext_len, buffer);
4193 	else
4194 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4195 				plaintext_len, buffer);
4196 
4197 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4198 
4199 	/* Validate obuf */
4200 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4201 		ciphertext,
4202 		tdata->ciphertext.data,
4203 		tdata->validDataLenInBits.len,
4204 		"SNOW 3G Ciphertext data not as expected");
4205 
4206 	return 0;
4207 }
4208 
4209 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4210 static void
4211 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4212 {
4213 	uint8_t curr_byte, prev_byte;
4214 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4215 	uint8_t lower_byte_mask = (1 << offset) - 1;
4216 	unsigned i;
4217 
4218 	prev_byte = buffer[0];
4219 	buffer[0] >>= offset;
4220 
4221 	for (i = 1; i < length_in_bytes; i++) {
4222 		curr_byte = buffer[i];
4223 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4224 				(curr_byte >> offset);
4225 		prev_byte = curr_byte;
4226 	}
4227 }
4228 
4229 static int
4230 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4231 {
4232 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4233 	struct crypto_unittest_params *ut_params = &unittest_params;
4234 	uint8_t *plaintext, *ciphertext;
4235 	int retval;
4236 	uint32_t plaintext_len;
4237 	uint32_t plaintext_pad_len;
4238 	uint8_t extra_offset = 4;
4239 	uint8_t *expected_ciphertext_shifted;
4240 
4241 	/* Create SNOW 3G session */
4242 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4243 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4244 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4245 					tdata->key.data, tdata->key.len,
4246 					tdata->cipher_iv.len);
4247 	if (retval < 0)
4248 		return retval;
4249 
4250 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4251 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4252 
4253 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4254 			"Failed to allocate input buffer in mempool");
4255 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4256 			"Failed to allocate output buffer in mempool");
4257 
4258 	/* Clear mbuf payload */
4259 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4260 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4261 
4262 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4263 	/*
4264 	 * Append data which is padded to a
4265 	 * multiple of the algorithms block size
4266 	 */
4267 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4268 
4269 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4270 						plaintext_pad_len);
4271 
4272 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4273 
4274 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4275 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4276 
4277 #ifdef RTE_APP_TEST_DEBUG
4278 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4279 #endif
4280 	/* Create SNOW 3G operation */
4281 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4282 					tdata->cipher_iv.len,
4283 					tdata->validCipherLenInBits.len,
4284 					extra_offset);
4285 	if (retval < 0)
4286 		return retval;
4287 
4288 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4289 						ut_params->op);
4290 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4291 
4292 	ut_params->obuf = ut_params->op->sym->m_dst;
4293 	if (ut_params->obuf)
4294 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4295 	else
4296 		ciphertext = plaintext;
4297 
4298 #ifdef RTE_APP_TEST_DEBUG
4299 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4300 #endif
4301 
4302 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4303 
4304 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4305 			"failed to reserve memory for ciphertext shifted\n");
4306 
4307 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4308 			ceil_byte_length(tdata->ciphertext.len));
4309 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4310 			extra_offset);
4311 	/* Validate obuf */
4312 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4313 		ciphertext,
4314 		expected_ciphertext_shifted,
4315 		tdata->validDataLenInBits.len,
4316 		extra_offset,
4317 		"SNOW 3G Ciphertext data not as expected");
4318 	return 0;
4319 }
4320 
4321 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4322 {
4323 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4324 	struct crypto_unittest_params *ut_params = &unittest_params;
4325 
4326 	int retval;
4327 
4328 	uint8_t *plaintext, *ciphertext;
4329 	unsigned ciphertext_pad_len;
4330 	unsigned ciphertext_len;
4331 
4332 	/* Create SNOW 3G session */
4333 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4334 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4335 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4336 					tdata->key.data, tdata->key.len,
4337 					tdata->cipher_iv.len);
4338 	if (retval < 0)
4339 		return retval;
4340 
4341 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4342 
4343 	/* Clear mbuf payload */
4344 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4345 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4346 
4347 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4348 	/* Append data which is padded to a multiple of */
4349 	/* the algorithms block size */
4350 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4351 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4352 				ciphertext_pad_len);
4353 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4354 
4355 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4356 
4357 	/* Create SNOW 3G operation */
4358 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4359 					tdata->cipher_iv.len,
4360 					tdata->validCipherLenInBits.len,
4361 					tdata->cipher.offset_bits);
4362 	if (retval < 0)
4363 		return retval;
4364 
4365 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4366 						ut_params->op);
4367 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4368 	ut_params->obuf = ut_params->op->sym->m_dst;
4369 	if (ut_params->obuf)
4370 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4371 	else
4372 		plaintext = ciphertext;
4373 
4374 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4375 
4376 	/* Validate obuf */
4377 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4378 				tdata->plaintext.data,
4379 				tdata->validDataLenInBits.len,
4380 				"SNOW 3G Plaintext data not as expected");
4381 	return 0;
4382 }
4383 
4384 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4385 {
4386 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4387 	struct crypto_unittest_params *ut_params = &unittest_params;
4388 
4389 	int retval;
4390 
4391 	uint8_t *plaintext, *ciphertext;
4392 	unsigned ciphertext_pad_len;
4393 	unsigned ciphertext_len;
4394 
4395 	/* Create SNOW 3G session */
4396 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4397 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4398 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4399 					tdata->key.data, tdata->key.len,
4400 					tdata->cipher_iv.len);
4401 	if (retval < 0)
4402 		return retval;
4403 
4404 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4405 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4406 
4407 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4408 			"Failed to allocate input buffer");
4409 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4410 			"Failed to allocate output buffer");
4411 
4412 	/* Clear mbuf payload */
4413 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4414 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4415 
4416 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4417 		       rte_pktmbuf_tailroom(ut_params->obuf));
4418 
4419 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4420 	/* Append data which is padded to a multiple of */
4421 	/* the algorithms block size */
4422 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4423 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4424 				ciphertext_pad_len);
4425 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4426 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4427 
4428 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4429 
4430 	/* Create SNOW 3G operation */
4431 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4432 					tdata->cipher_iv.len,
4433 					tdata->validCipherLenInBits.len,
4434 					0);
4435 	if (retval < 0)
4436 		return retval;
4437 
4438 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4439 						ut_params->op);
4440 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4441 	ut_params->obuf = ut_params->op->sym->m_dst;
4442 	if (ut_params->obuf)
4443 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4444 	else
4445 		plaintext = ciphertext;
4446 
4447 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4448 
4449 	/* Validate obuf */
4450 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4451 				tdata->plaintext.data,
4452 				tdata->validDataLenInBits.len,
4453 				"SNOW 3G Plaintext data not as expected");
4454 	return 0;
4455 }
4456 
4457 static int
4458 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4459 {
4460 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4461 	struct crypto_unittest_params *ut_params = &unittest_params;
4462 
4463 	int retval;
4464 
4465 	uint8_t *plaintext, *ciphertext;
4466 	unsigned int plaintext_pad_len;
4467 	unsigned int plaintext_len;
4468 
4469 	struct rte_cryptodev_sym_capability_idx cap_idx;
4470 
4471 	/* Check if device supports ZUC EEA3 */
4472 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4473 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4474 
4475 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4476 			&cap_idx) == NULL)
4477 		return -ENOTSUP;
4478 
4479 	/* Check if device supports ZUC EIA3 */
4480 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4481 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4482 
4483 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4484 			&cap_idx) == NULL)
4485 		return -ENOTSUP;
4486 
4487 	/* Create ZUC session */
4488 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4489 			ts_params->valid_devs[0],
4490 			tdata);
4491 	if (retval < 0)
4492 		return retval;
4493 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4494 
4495 	/* clear mbuf payload */
4496 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4497 			rte_pktmbuf_tailroom(ut_params->ibuf));
4498 
4499 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4500 	/* Append data which is padded to a multiple of */
4501 	/* the algorithms block size */
4502 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4503 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4504 				plaintext_pad_len);
4505 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4506 
4507 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4508 
4509 	/* Create ZUC operation */
4510 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4511 	if (retval < 0)
4512 		return retval;
4513 
4514 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4515 			ut_params->op);
4516 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4517 	ut_params->obuf = ut_params->op->sym->m_src;
4518 	if (ut_params->obuf)
4519 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4520 	else
4521 		ciphertext = plaintext;
4522 
4523 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4524 	/* Validate obuf */
4525 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4526 			ciphertext,
4527 			tdata->ciphertext.data,
4528 			tdata->validDataLenInBits.len,
4529 			"ZUC Ciphertext data not as expected");
4530 
4531 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4532 	    + plaintext_pad_len;
4533 
4534 	/* Validate obuf */
4535 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4536 			ut_params->digest,
4537 			tdata->digest.data,
4538 			4,
4539 			"ZUC Generated auth tag not as expected");
4540 	return 0;
4541 }
4542 
4543 static int
4544 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4545 {
4546 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4547 	struct crypto_unittest_params *ut_params = &unittest_params;
4548 
4549 	int retval;
4550 
4551 	uint8_t *plaintext, *ciphertext;
4552 	unsigned plaintext_pad_len;
4553 	unsigned plaintext_len;
4554 
4555 	/* Create SNOW 3G session */
4556 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4557 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4558 			RTE_CRYPTO_AUTH_OP_GENERATE,
4559 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4560 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4561 			tdata->key.data, tdata->key.len,
4562 			tdata->auth_iv.len, tdata->digest.len,
4563 			tdata->cipher_iv.len);
4564 	if (retval < 0)
4565 		return retval;
4566 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4567 
4568 	/* clear mbuf payload */
4569 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4570 			rte_pktmbuf_tailroom(ut_params->ibuf));
4571 
4572 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4573 	/* Append data which is padded to a multiple of */
4574 	/* the algorithms block size */
4575 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4576 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4577 				plaintext_pad_len);
4578 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4579 
4580 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4581 
4582 	/* Create SNOW 3G operation */
4583 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4584 			tdata->digest.len, tdata->auth_iv.data,
4585 			tdata->auth_iv.len,
4586 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4587 			tdata->cipher_iv.data, tdata->cipher_iv.len,
4588 			tdata->validCipherLenInBits.len,
4589 			0,
4590 			tdata->validAuthLenInBits.len,
4591 			0
4592 			);
4593 	if (retval < 0)
4594 		return retval;
4595 
4596 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4597 			ut_params->op);
4598 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4599 	ut_params->obuf = ut_params->op->sym->m_src;
4600 	if (ut_params->obuf)
4601 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4602 	else
4603 		ciphertext = plaintext;
4604 
4605 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4606 	/* Validate obuf */
4607 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4608 			ciphertext,
4609 			tdata->ciphertext.data,
4610 			tdata->validDataLenInBits.len,
4611 			"SNOW 3G Ciphertext data not as expected");
4612 
4613 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4614 	    + plaintext_pad_len;
4615 
4616 	/* Validate obuf */
4617 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4618 			ut_params->digest,
4619 			tdata->digest.data,
4620 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4621 			"SNOW 3G Generated auth tag not as expected");
4622 	return 0;
4623 }
4624 
4625 static int
4626 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4627 	uint8_t op_mode, uint8_t verify)
4628 {
4629 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4630 	struct crypto_unittest_params *ut_params = &unittest_params;
4631 
4632 	int retval;
4633 
4634 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4635 	unsigned int plaintext_pad_len;
4636 	unsigned int plaintext_len;
4637 	unsigned int ciphertext_pad_len;
4638 	unsigned int ciphertext_len;
4639 
4640 	struct rte_cryptodev_info dev_info;
4641 
4642 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4643 
4644 	uint64_t feat_flags = dev_info.feature_flags;
4645 
4646 	if (op_mode == OUT_OF_PLACE) {
4647 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4648 			printf("Device doesn't support digest encrypted.\n");
4649 			return -ENOTSUP;
4650 		}
4651 	}
4652 
4653 	/* Create SNOW 3G session */
4654 	retval = create_wireless_algo_auth_cipher_session(
4655 			ts_params->valid_devs[0],
4656 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4657 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4658 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4659 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4660 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4661 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4662 			tdata->key.data, tdata->key.len,
4663 			tdata->auth_iv.len, tdata->digest.len,
4664 			tdata->cipher_iv.len);
4665 
4666 	if (retval < 0)
4667 		return retval;
4668 
4669 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4670 	if (op_mode == OUT_OF_PLACE)
4671 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4672 
4673 	/* clear mbuf payload */
4674 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4675 		rte_pktmbuf_tailroom(ut_params->ibuf));
4676 	if (op_mode == OUT_OF_PLACE)
4677 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4678 			rte_pktmbuf_tailroom(ut_params->obuf));
4679 
4680 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4681 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4682 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4683 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4684 
4685 	if (verify) {
4686 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4687 					ciphertext_pad_len);
4688 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4689 		if (op_mode == OUT_OF_PLACE)
4690 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4691 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4692 			ciphertext_len);
4693 	} else {
4694 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4695 					plaintext_pad_len);
4696 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4697 		if (op_mode == OUT_OF_PLACE)
4698 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4699 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4700 	}
4701 
4702 	/* Create SNOW 3G operation */
4703 	retval = create_wireless_algo_auth_cipher_operation(
4704 		tdata->digest.data, tdata->digest.len,
4705 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4706 		tdata->auth_iv.data, tdata->auth_iv.len,
4707 		(tdata->digest.offset_bytes == 0 ?
4708 		(verify ? ciphertext_pad_len : plaintext_pad_len)
4709 			: tdata->digest.offset_bytes),
4710 		tdata->validCipherLenInBits.len,
4711 		tdata->cipher.offset_bits,
4712 		tdata->validAuthLenInBits.len,
4713 		tdata->auth.offset_bits,
4714 		op_mode, 0, verify);
4715 
4716 	if (retval < 0)
4717 		return retval;
4718 
4719 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4720 			ut_params->op);
4721 
4722 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4723 
4724 	ut_params->obuf = (op_mode == IN_PLACE ?
4725 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4726 
4727 	if (verify) {
4728 		if (ut_params->obuf)
4729 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4730 							uint8_t *);
4731 		else
4732 			plaintext = ciphertext +
4733 				(tdata->cipher.offset_bits >> 3);
4734 
4735 		debug_hexdump(stdout, "plaintext:", plaintext,
4736 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4737 		debug_hexdump(stdout, "plaintext expected:",
4738 			tdata->plaintext.data,
4739 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4740 	} else {
4741 		if (ut_params->obuf)
4742 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4743 							uint8_t *);
4744 		else
4745 			ciphertext = plaintext;
4746 
4747 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4748 			ciphertext_len);
4749 		debug_hexdump(stdout, "ciphertext expected:",
4750 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4751 
4752 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4753 			+ (tdata->digest.offset_bytes == 0 ?
4754 		plaintext_pad_len : tdata->digest.offset_bytes);
4755 
4756 		debug_hexdump(stdout, "digest:", ut_params->digest,
4757 			tdata->digest.len);
4758 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4759 				tdata->digest.len);
4760 	}
4761 
4762 	/* Validate obuf */
4763 	if (verify) {
4764 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4765 			plaintext,
4766 			tdata->plaintext.data,
4767 			tdata->plaintext.len >> 3,
4768 			"SNOW 3G Plaintext data not as expected");
4769 	} else {
4770 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4771 			ciphertext,
4772 			tdata->ciphertext.data,
4773 			tdata->validDataLenInBits.len,
4774 			"SNOW 3G Ciphertext data not as expected");
4775 
4776 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
4777 			ut_params->digest,
4778 			tdata->digest.data,
4779 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4780 			"SNOW 3G Generated auth tag not as expected");
4781 	}
4782 	return 0;
4783 }
4784 
4785 static int
4786 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4787 	uint8_t op_mode, uint8_t verify)
4788 {
4789 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4790 	struct crypto_unittest_params *ut_params = &unittest_params;
4791 
4792 	int retval;
4793 
4794 	const uint8_t *plaintext = NULL;
4795 	const uint8_t *ciphertext = NULL;
4796 	const uint8_t *digest = NULL;
4797 	unsigned int plaintext_pad_len;
4798 	unsigned int plaintext_len;
4799 	unsigned int ciphertext_pad_len;
4800 	unsigned int ciphertext_len;
4801 	uint8_t buffer[10000];
4802 	uint8_t digest_buffer[10000];
4803 
4804 	struct rte_cryptodev_info dev_info;
4805 
4806 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4807 
4808 	uint64_t feat_flags = dev_info.feature_flags;
4809 
4810 	if (op_mode == IN_PLACE) {
4811 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4812 			printf("Device doesn't support in-place scatter-gather "
4813 					"in both input and output mbufs.\n");
4814 			return -ENOTSUP;
4815 		}
4816 	} else {
4817 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4818 			printf("Device doesn't support out-of-place scatter-gather "
4819 					"in both input and output mbufs.\n");
4820 			return -ENOTSUP;
4821 		}
4822 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4823 			printf("Device doesn't support digest encrypted.\n");
4824 			return -ENOTSUP;
4825 		}
4826 	}
4827 
4828 	/* Create SNOW 3G session */
4829 	retval = create_wireless_algo_auth_cipher_session(
4830 			ts_params->valid_devs[0],
4831 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4832 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4833 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4834 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4835 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4836 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4837 			tdata->key.data, tdata->key.len,
4838 			tdata->auth_iv.len, tdata->digest.len,
4839 			tdata->cipher_iv.len);
4840 
4841 	if (retval < 0)
4842 		return retval;
4843 
4844 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4845 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4846 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4847 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4848 
4849 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4850 			plaintext_pad_len, 15, 0);
4851 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4852 			"Failed to allocate input buffer in mempool");
4853 
4854 	if (op_mode == OUT_OF_PLACE) {
4855 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4856 				plaintext_pad_len, 15, 0);
4857 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
4858 				"Failed to allocate output buffer in mempool");
4859 	}
4860 
4861 	if (verify) {
4862 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4863 			tdata->ciphertext.data);
4864 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4865 					ciphertext_len, buffer);
4866 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4867 			ciphertext_len);
4868 	} else {
4869 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4870 			tdata->plaintext.data);
4871 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4872 					plaintext_len, buffer);
4873 		debug_hexdump(stdout, "plaintext:", plaintext,
4874 			plaintext_len);
4875 	}
4876 	memset(buffer, 0, sizeof(buffer));
4877 
4878 	/* Create SNOW 3G operation */
4879 	retval = create_wireless_algo_auth_cipher_operation(
4880 		tdata->digest.data, tdata->digest.len,
4881 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4882 		tdata->auth_iv.data, tdata->auth_iv.len,
4883 		(tdata->digest.offset_bytes == 0 ?
4884 		(verify ? ciphertext_pad_len : plaintext_pad_len)
4885 			: tdata->digest.offset_bytes),
4886 		tdata->validCipherLenInBits.len,
4887 		tdata->cipher.offset_bits,
4888 		tdata->validAuthLenInBits.len,
4889 		tdata->auth.offset_bits,
4890 		op_mode, 1, verify);
4891 
4892 	if (retval < 0)
4893 		return retval;
4894 
4895 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4896 			ut_params->op);
4897 
4898 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4899 
4900 	ut_params->obuf = (op_mode == IN_PLACE ?
4901 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4902 
4903 	if (verify) {
4904 		if (ut_params->obuf)
4905 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4906 					plaintext_len, buffer);
4907 		else
4908 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4909 					plaintext_len, buffer);
4910 
4911 		debug_hexdump(stdout, "plaintext:", plaintext,
4912 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4913 		debug_hexdump(stdout, "plaintext expected:",
4914 			tdata->plaintext.data,
4915 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4916 	} else {
4917 		if (ut_params->obuf)
4918 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4919 					ciphertext_len, buffer);
4920 		else
4921 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4922 					ciphertext_len, buffer);
4923 
4924 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4925 			ciphertext_len);
4926 		debug_hexdump(stdout, "ciphertext expected:",
4927 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4928 
4929 		if (ut_params->obuf)
4930 			digest = rte_pktmbuf_read(ut_params->obuf,
4931 				(tdata->digest.offset_bytes == 0 ?
4932 				plaintext_pad_len : tdata->digest.offset_bytes),
4933 				tdata->digest.len, digest_buffer);
4934 		else
4935 			digest = rte_pktmbuf_read(ut_params->ibuf,
4936 				(tdata->digest.offset_bytes == 0 ?
4937 				plaintext_pad_len : tdata->digest.offset_bytes),
4938 				tdata->digest.len, digest_buffer);
4939 
4940 		debug_hexdump(stdout, "digest:", digest,
4941 			tdata->digest.len);
4942 		debug_hexdump(stdout, "digest expected:",
4943 			tdata->digest.data, tdata->digest.len);
4944 	}
4945 
4946 	/* Validate obuf */
4947 	if (verify) {
4948 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4949 			plaintext,
4950 			tdata->plaintext.data,
4951 			tdata->plaintext.len >> 3,
4952 			"SNOW 3G Plaintext data not as expected");
4953 	} else {
4954 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4955 			ciphertext,
4956 			tdata->ciphertext.data,
4957 			tdata->validDataLenInBits.len,
4958 			"SNOW 3G Ciphertext data not as expected");
4959 
4960 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
4961 			digest,
4962 			tdata->digest.data,
4963 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4964 			"SNOW 3G Generated auth tag not as expected");
4965 	}
4966 	return 0;
4967 }
4968 
4969 static int
4970 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4971 	uint8_t op_mode, uint8_t verify)
4972 {
4973 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4974 	struct crypto_unittest_params *ut_params = &unittest_params;
4975 
4976 	int retval;
4977 
4978 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4979 	unsigned int plaintext_pad_len;
4980 	unsigned int plaintext_len;
4981 	unsigned int ciphertext_pad_len;
4982 	unsigned int ciphertext_len;
4983 
4984 	struct rte_cryptodev_info dev_info;
4985 
4986 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4987 
4988 	uint64_t feat_flags = dev_info.feature_flags;
4989 
4990 	if (op_mode == OUT_OF_PLACE) {
4991 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4992 			printf("Device doesn't support digest encrypted.\n");
4993 			return -ENOTSUP;
4994 		}
4995 	}
4996 
4997 	/* Create KASUMI session */
4998 	retval = create_wireless_algo_auth_cipher_session(
4999 			ts_params->valid_devs[0],
5000 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5001 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5002 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5003 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5004 			RTE_CRYPTO_AUTH_KASUMI_F9,
5005 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5006 			tdata->key.data, tdata->key.len,
5007 			0, tdata->digest.len,
5008 			tdata->cipher_iv.len);
5009 
5010 	if (retval < 0)
5011 		return retval;
5012 
5013 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5014 	if (op_mode == OUT_OF_PLACE)
5015 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5016 
5017 	/* clear mbuf payload */
5018 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5019 		rte_pktmbuf_tailroom(ut_params->ibuf));
5020 	if (op_mode == OUT_OF_PLACE)
5021 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5022 			rte_pktmbuf_tailroom(ut_params->obuf));
5023 
5024 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5025 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5026 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5027 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5028 
5029 	if (verify) {
5030 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5031 					ciphertext_pad_len);
5032 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5033 		if (op_mode == OUT_OF_PLACE)
5034 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5035 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5036 			ciphertext_len);
5037 	} else {
5038 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5039 					plaintext_pad_len);
5040 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5041 		if (op_mode == OUT_OF_PLACE)
5042 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5043 		debug_hexdump(stdout, "plaintext:", plaintext,
5044 			plaintext_len);
5045 	}
5046 
5047 	/* Create KASUMI operation */
5048 	retval = create_wireless_algo_auth_cipher_operation(
5049 		tdata->digest.data, tdata->digest.len,
5050 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5051 		NULL, 0,
5052 		(tdata->digest.offset_bytes == 0 ?
5053 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5054 			: tdata->digest.offset_bytes),
5055 		tdata->validCipherLenInBits.len,
5056 		tdata->validCipherOffsetInBits.len,
5057 		tdata->validAuthLenInBits.len,
5058 		0,
5059 		op_mode, 0, verify);
5060 
5061 	if (retval < 0)
5062 		return retval;
5063 
5064 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5065 			ut_params->op);
5066 
5067 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5068 
5069 	ut_params->obuf = (op_mode == IN_PLACE ?
5070 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5071 
5072 
5073 	if (verify) {
5074 		if (ut_params->obuf)
5075 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5076 							uint8_t *);
5077 		else
5078 			plaintext = ciphertext;
5079 
5080 		debug_hexdump(stdout, "plaintext:", plaintext,
5081 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5082 		debug_hexdump(stdout, "plaintext expected:",
5083 			tdata->plaintext.data,
5084 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5085 	} else {
5086 		if (ut_params->obuf)
5087 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5088 							uint8_t *);
5089 		else
5090 			ciphertext = plaintext;
5091 
5092 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5093 			ciphertext_len);
5094 		debug_hexdump(stdout, "ciphertext expected:",
5095 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5096 
5097 		ut_params->digest = rte_pktmbuf_mtod(
5098 			ut_params->obuf, uint8_t *) +
5099 			(tdata->digest.offset_bytes == 0 ?
5100 			plaintext_pad_len : tdata->digest.offset_bytes);
5101 
5102 		debug_hexdump(stdout, "digest:", ut_params->digest,
5103 			tdata->digest.len);
5104 		debug_hexdump(stdout, "digest expected:",
5105 			tdata->digest.data, tdata->digest.len);
5106 	}
5107 
5108 	/* Validate obuf */
5109 	if (verify) {
5110 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5111 			plaintext,
5112 			tdata->plaintext.data,
5113 			tdata->plaintext.len >> 3,
5114 			"KASUMI Plaintext data not as expected");
5115 	} else {
5116 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5117 			ciphertext,
5118 			tdata->ciphertext.data,
5119 			tdata->ciphertext.len >> 3,
5120 			"KASUMI Ciphertext data not as expected");
5121 
5122 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5123 			ut_params->digest,
5124 			tdata->digest.data,
5125 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5126 			"KASUMI Generated auth tag not as expected");
5127 	}
5128 	return 0;
5129 }
5130 
5131 static int
5132 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5133 	uint8_t op_mode, uint8_t verify)
5134 {
5135 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5136 	struct crypto_unittest_params *ut_params = &unittest_params;
5137 
5138 	int retval;
5139 
5140 	const uint8_t *plaintext = NULL;
5141 	const uint8_t *ciphertext = NULL;
5142 	const uint8_t *digest = NULL;
5143 	unsigned int plaintext_pad_len;
5144 	unsigned int plaintext_len;
5145 	unsigned int ciphertext_pad_len;
5146 	unsigned int ciphertext_len;
5147 	uint8_t buffer[10000];
5148 	uint8_t digest_buffer[10000];
5149 
5150 	struct rte_cryptodev_info dev_info;
5151 
5152 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5153 
5154 	uint64_t feat_flags = dev_info.feature_flags;
5155 
5156 	if (op_mode == IN_PLACE) {
5157 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5158 			printf("Device doesn't support in-place scatter-gather "
5159 					"in both input and output mbufs.\n");
5160 			return -ENOTSUP;
5161 		}
5162 	} else {
5163 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5164 			printf("Device doesn't support out-of-place scatter-gather "
5165 					"in both input and output mbufs.\n");
5166 			return -ENOTSUP;
5167 		}
5168 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5169 			printf("Device doesn't support digest encrypted.\n");
5170 			return -ENOTSUP;
5171 		}
5172 	}
5173 
5174 	/* Create KASUMI session */
5175 	retval = create_wireless_algo_auth_cipher_session(
5176 			ts_params->valid_devs[0],
5177 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5178 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5179 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5180 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5181 			RTE_CRYPTO_AUTH_KASUMI_F9,
5182 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5183 			tdata->key.data, tdata->key.len,
5184 			0, tdata->digest.len,
5185 			tdata->cipher_iv.len);
5186 
5187 	if (retval < 0)
5188 		return retval;
5189 
5190 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5191 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5192 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5193 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5194 
5195 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5196 			plaintext_pad_len, 15, 0);
5197 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5198 			"Failed to allocate input buffer in mempool");
5199 
5200 	if (op_mode == OUT_OF_PLACE) {
5201 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5202 				plaintext_pad_len, 15, 0);
5203 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5204 				"Failed to allocate output buffer in mempool");
5205 	}
5206 
5207 	if (verify) {
5208 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5209 			tdata->ciphertext.data);
5210 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5211 					ciphertext_len, buffer);
5212 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5213 			ciphertext_len);
5214 	} else {
5215 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5216 			tdata->plaintext.data);
5217 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5218 					plaintext_len, buffer);
5219 		debug_hexdump(stdout, "plaintext:", plaintext,
5220 			plaintext_len);
5221 	}
5222 	memset(buffer, 0, sizeof(buffer));
5223 
5224 	/* Create KASUMI operation */
5225 	retval = create_wireless_algo_auth_cipher_operation(
5226 		tdata->digest.data, tdata->digest.len,
5227 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5228 		NULL, 0,
5229 		(tdata->digest.offset_bytes == 0 ?
5230 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5231 			: tdata->digest.offset_bytes),
5232 		tdata->validCipherLenInBits.len,
5233 		tdata->validCipherOffsetInBits.len,
5234 		tdata->validAuthLenInBits.len,
5235 		0,
5236 		op_mode, 1, verify);
5237 
5238 	if (retval < 0)
5239 		return retval;
5240 
5241 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5242 			ut_params->op);
5243 
5244 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5245 
5246 	ut_params->obuf = (op_mode == IN_PLACE ?
5247 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5248 
5249 	if (verify) {
5250 		if (ut_params->obuf)
5251 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5252 					plaintext_len, buffer);
5253 		else
5254 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5255 					plaintext_len, buffer);
5256 
5257 		debug_hexdump(stdout, "plaintext:", plaintext,
5258 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5259 		debug_hexdump(stdout, "plaintext expected:",
5260 			tdata->plaintext.data,
5261 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5262 	} else {
5263 		if (ut_params->obuf)
5264 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5265 					ciphertext_len, buffer);
5266 		else
5267 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5268 					ciphertext_len, buffer);
5269 
5270 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5271 			ciphertext_len);
5272 		debug_hexdump(stdout, "ciphertext expected:",
5273 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5274 
5275 		if (ut_params->obuf)
5276 			digest = rte_pktmbuf_read(ut_params->obuf,
5277 				(tdata->digest.offset_bytes == 0 ?
5278 				plaintext_pad_len : tdata->digest.offset_bytes),
5279 				tdata->digest.len, digest_buffer);
5280 		else
5281 			digest = rte_pktmbuf_read(ut_params->ibuf,
5282 				(tdata->digest.offset_bytes == 0 ?
5283 				plaintext_pad_len : tdata->digest.offset_bytes),
5284 				tdata->digest.len, digest_buffer);
5285 
5286 		debug_hexdump(stdout, "digest:", digest,
5287 			tdata->digest.len);
5288 		debug_hexdump(stdout, "digest expected:",
5289 			tdata->digest.data, tdata->digest.len);
5290 	}
5291 
5292 	/* Validate obuf */
5293 	if (verify) {
5294 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5295 			plaintext,
5296 			tdata->plaintext.data,
5297 			tdata->plaintext.len >> 3,
5298 			"KASUMI Plaintext data not as expected");
5299 	} else {
5300 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5301 			ciphertext,
5302 			tdata->ciphertext.data,
5303 			tdata->validDataLenInBits.len,
5304 			"KASUMI Ciphertext data not as expected");
5305 
5306 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5307 			digest,
5308 			tdata->digest.data,
5309 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5310 			"KASUMI Generated auth tag not as expected");
5311 	}
5312 	return 0;
5313 }
5314 
5315 static int
5316 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5317 {
5318 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5319 	struct crypto_unittest_params *ut_params = &unittest_params;
5320 
5321 	int retval;
5322 
5323 	uint8_t *plaintext, *ciphertext;
5324 	unsigned plaintext_pad_len;
5325 	unsigned plaintext_len;
5326 
5327 	/* Create KASUMI session */
5328 	retval = create_wireless_algo_cipher_auth_session(
5329 			ts_params->valid_devs[0],
5330 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5331 			RTE_CRYPTO_AUTH_OP_GENERATE,
5332 			RTE_CRYPTO_AUTH_KASUMI_F9,
5333 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5334 			tdata->key.data, tdata->key.len,
5335 			0, tdata->digest.len,
5336 			tdata->cipher_iv.len);
5337 	if (retval < 0)
5338 		return retval;
5339 
5340 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5341 
5342 	/* clear mbuf payload */
5343 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5344 			rte_pktmbuf_tailroom(ut_params->ibuf));
5345 
5346 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5347 	/* Append data which is padded to a multiple of */
5348 	/* the algorithms block size */
5349 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5350 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5351 				plaintext_pad_len);
5352 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5353 
5354 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5355 
5356 	/* Create KASUMI operation */
5357 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5358 				tdata->digest.len, NULL, 0,
5359 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5360 				tdata->cipher_iv.data, tdata->cipher_iv.len,
5361 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5362 				tdata->validCipherOffsetInBits.len,
5363 				tdata->validAuthLenInBits.len,
5364 				0
5365 				);
5366 	if (retval < 0)
5367 		return retval;
5368 
5369 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5370 			ut_params->op);
5371 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5372 
5373 	if (ut_params->op->sym->m_dst)
5374 		ut_params->obuf = ut_params->op->sym->m_dst;
5375 	else
5376 		ut_params->obuf = ut_params->op->sym->m_src;
5377 
5378 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5379 				tdata->validCipherOffsetInBits.len >> 3);
5380 
5381 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5382 			+ plaintext_pad_len;
5383 
5384 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5385 				(tdata->validCipherOffsetInBits.len >> 3);
5386 	/* Validate obuf */
5387 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5388 		ciphertext,
5389 		reference_ciphertext,
5390 		tdata->validCipherLenInBits.len,
5391 		"KASUMI Ciphertext data not as expected");
5392 
5393 	/* Validate obuf */
5394 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5395 		ut_params->digest,
5396 		tdata->digest.data,
5397 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5398 		"KASUMI Generated auth tag not as expected");
5399 	return 0;
5400 }
5401 
5402 static int
5403 test_zuc_encryption(const struct wireless_test_data *tdata)
5404 {
5405 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5406 	struct crypto_unittest_params *ut_params = &unittest_params;
5407 
5408 	int retval;
5409 	uint8_t *plaintext, *ciphertext;
5410 	unsigned plaintext_pad_len;
5411 	unsigned plaintext_len;
5412 
5413 	struct rte_cryptodev_sym_capability_idx cap_idx;
5414 
5415 	/* Check if device supports ZUC EEA3 */
5416 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5417 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5418 
5419 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5420 			&cap_idx) == NULL)
5421 		return -ENOTSUP;
5422 
5423 	/* Create ZUC session */
5424 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5425 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5426 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
5427 					tdata->key.data, tdata->key.len,
5428 					tdata->cipher_iv.len);
5429 	if (retval < 0)
5430 		return retval;
5431 
5432 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5433 
5434 	/* Clear mbuf payload */
5435 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5436 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5437 
5438 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5439 	/* Append data which is padded to a multiple */
5440 	/* of the algorithms block size */
5441 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5442 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5443 				plaintext_pad_len);
5444 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5445 
5446 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5447 
5448 	/* Create ZUC operation */
5449 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5450 					tdata->cipher_iv.len,
5451 					tdata->plaintext.len,
5452 					0);
5453 	if (retval < 0)
5454 		return retval;
5455 
5456 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5457 						ut_params->op);
5458 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5459 
5460 	ut_params->obuf = ut_params->op->sym->m_dst;
5461 	if (ut_params->obuf)
5462 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5463 	else
5464 		ciphertext = plaintext;
5465 
5466 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5467 
5468 	/* Validate obuf */
5469 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5470 		ciphertext,
5471 		tdata->ciphertext.data,
5472 		tdata->validCipherLenInBits.len,
5473 		"ZUC Ciphertext data not as expected");
5474 	return 0;
5475 }
5476 
5477 static int
5478 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5479 {
5480 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5481 	struct crypto_unittest_params *ut_params = &unittest_params;
5482 
5483 	int retval;
5484 
5485 	unsigned int plaintext_pad_len;
5486 	unsigned int plaintext_len;
5487 	const uint8_t *ciphertext;
5488 	uint8_t ciphertext_buffer[2048];
5489 	struct rte_cryptodev_info dev_info;
5490 
5491 	struct rte_cryptodev_sym_capability_idx cap_idx;
5492 
5493 	/* Check if device supports ZUC EEA3 */
5494 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5495 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5496 
5497 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5498 			&cap_idx) == NULL)
5499 		return -ENOTSUP;
5500 
5501 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5502 
5503 	uint64_t feat_flags = dev_info.feature_flags;
5504 
5505 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5506 		printf("Device doesn't support in-place scatter-gather. "
5507 				"Test Skipped.\n");
5508 		return -ENOTSUP;
5509 	}
5510 
5511 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5512 
5513 	/* Append data which is padded to a multiple */
5514 	/* of the algorithms block size */
5515 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5516 
5517 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5518 			plaintext_pad_len, 10, 0);
5519 
5520 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5521 			tdata->plaintext.data);
5522 
5523 	/* Create ZUC session */
5524 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5525 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5526 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5527 			tdata->key.data, tdata->key.len,
5528 			tdata->cipher_iv.len);
5529 	if (retval < 0)
5530 		return retval;
5531 
5532 	/* Clear mbuf payload */
5533 
5534 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5535 
5536 	/* Create ZUC operation */
5537 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5538 			tdata->cipher_iv.len, tdata->plaintext.len,
5539 			0);
5540 	if (retval < 0)
5541 		return retval;
5542 
5543 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5544 						ut_params->op);
5545 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5546 
5547 	ut_params->obuf = ut_params->op->sym->m_dst;
5548 	if (ut_params->obuf)
5549 		ciphertext = rte_pktmbuf_read(ut_params->obuf,
5550 			0, plaintext_len, ciphertext_buffer);
5551 	else
5552 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5553 			0, plaintext_len, ciphertext_buffer);
5554 
5555 	/* Validate obuf */
5556 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5557 
5558 	/* Validate obuf */
5559 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5560 		ciphertext,
5561 		tdata->ciphertext.data,
5562 		tdata->validCipherLenInBits.len,
5563 		"ZUC Ciphertext data not as expected");
5564 
5565 	return 0;
5566 }
5567 
5568 static int
5569 test_zuc_authentication(const struct wireless_test_data *tdata)
5570 {
5571 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5572 	struct crypto_unittest_params *ut_params = &unittest_params;
5573 
5574 	int retval;
5575 	unsigned plaintext_pad_len;
5576 	unsigned plaintext_len;
5577 	uint8_t *plaintext;
5578 
5579 	struct rte_cryptodev_sym_capability_idx cap_idx;
5580 
5581 	/* Check if device supports ZUC EIA3 */
5582 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5583 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5584 
5585 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5586 			&cap_idx) == NULL)
5587 		return -ENOTSUP;
5588 
5589 	/* Create ZUC session */
5590 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5591 			tdata->key.data, tdata->key.len,
5592 			tdata->auth_iv.len, tdata->digest.len,
5593 			RTE_CRYPTO_AUTH_OP_GENERATE,
5594 			RTE_CRYPTO_AUTH_ZUC_EIA3);
5595 	if (retval < 0)
5596 		return retval;
5597 
5598 	/* alloc mbuf and set payload */
5599 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5600 
5601 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5602 	rte_pktmbuf_tailroom(ut_params->ibuf));
5603 
5604 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5605 	/* Append data which is padded to a multiple of */
5606 	/* the algorithms block size */
5607 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5608 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5609 				plaintext_pad_len);
5610 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5611 
5612 	/* Create ZUC operation */
5613 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5614 			tdata->auth_iv.data, tdata->auth_iv.len,
5615 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5616 			tdata->validAuthLenInBits.len,
5617 			0);
5618 	if (retval < 0)
5619 		return retval;
5620 
5621 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5622 				ut_params->op);
5623 	ut_params->obuf = ut_params->op->sym->m_src;
5624 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5625 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5626 			+ plaintext_pad_len;
5627 
5628 	/* Validate obuf */
5629 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5630 	ut_params->digest,
5631 	tdata->digest.data,
5632 	DIGEST_BYTE_LENGTH_KASUMI_F9,
5633 	"ZUC Generated auth tag not as expected");
5634 
5635 	return 0;
5636 }
5637 
5638 static int
5639 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5640 	uint8_t op_mode, uint8_t verify)
5641 {
5642 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5643 	struct crypto_unittest_params *ut_params = &unittest_params;
5644 
5645 	int retval;
5646 
5647 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5648 	unsigned int plaintext_pad_len;
5649 	unsigned int plaintext_len;
5650 	unsigned int ciphertext_pad_len;
5651 	unsigned int ciphertext_len;
5652 
5653 	struct rte_cryptodev_info dev_info;
5654 	struct rte_cryptodev_sym_capability_idx cap_idx;
5655 
5656 	/* Check if device supports ZUC EIA3 */
5657 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5658 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5659 
5660 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5661 			&cap_idx) == NULL)
5662 		return -ENOTSUP;
5663 
5664 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5665 
5666 	uint64_t feat_flags = dev_info.feature_flags;
5667 
5668 	if (op_mode == OUT_OF_PLACE) {
5669 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5670 			printf("Device doesn't support digest encrypted.\n");
5671 			return -ENOTSUP;
5672 		}
5673 	}
5674 
5675 	/* Create ZUC session */
5676 	retval = create_wireless_algo_auth_cipher_session(
5677 			ts_params->valid_devs[0],
5678 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5679 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5680 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5681 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5682 			RTE_CRYPTO_AUTH_ZUC_EIA3,
5683 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5684 			tdata->key.data, tdata->key.len,
5685 			tdata->auth_iv.len, tdata->digest.len,
5686 			tdata->cipher_iv.len);
5687 
5688 	if (retval < 0)
5689 		return retval;
5690 
5691 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5692 	if (op_mode == OUT_OF_PLACE)
5693 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5694 
5695 	/* clear mbuf payload */
5696 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5697 		rte_pktmbuf_tailroom(ut_params->ibuf));
5698 	if (op_mode == OUT_OF_PLACE)
5699 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5700 			rte_pktmbuf_tailroom(ut_params->obuf));
5701 
5702 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5703 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5704 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5705 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5706 
5707 	if (verify) {
5708 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5709 					ciphertext_pad_len);
5710 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5711 		if (op_mode == OUT_OF_PLACE)
5712 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5713 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5714 			ciphertext_len);
5715 	} else {
5716 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5717 					plaintext_pad_len);
5718 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5719 		if (op_mode == OUT_OF_PLACE)
5720 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5721 		debug_hexdump(stdout, "plaintext:", plaintext,
5722 			plaintext_len);
5723 	}
5724 
5725 	/* Create ZUC operation */
5726 	retval = create_wireless_algo_auth_cipher_operation(
5727 		tdata->digest.data, tdata->digest.len,
5728 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5729 		tdata->auth_iv.data, tdata->auth_iv.len,
5730 		(tdata->digest.offset_bytes == 0 ?
5731 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5732 			: tdata->digest.offset_bytes),
5733 		tdata->validCipherLenInBits.len,
5734 		tdata->validCipherOffsetInBits.len,
5735 		tdata->validAuthLenInBits.len,
5736 		0,
5737 		op_mode, 0, verify);
5738 
5739 	if (retval < 0)
5740 		return retval;
5741 
5742 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5743 			ut_params->op);
5744 
5745 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5746 
5747 	ut_params->obuf = (op_mode == IN_PLACE ?
5748 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5749 
5750 
5751 	if (verify) {
5752 		if (ut_params->obuf)
5753 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5754 							uint8_t *);
5755 		else
5756 			plaintext = ciphertext;
5757 
5758 		debug_hexdump(stdout, "plaintext:", plaintext,
5759 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5760 		debug_hexdump(stdout, "plaintext expected:",
5761 			tdata->plaintext.data,
5762 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5763 	} else {
5764 		if (ut_params->obuf)
5765 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5766 							uint8_t *);
5767 		else
5768 			ciphertext = plaintext;
5769 
5770 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5771 			ciphertext_len);
5772 		debug_hexdump(stdout, "ciphertext expected:",
5773 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5774 
5775 		ut_params->digest = rte_pktmbuf_mtod(
5776 			ut_params->obuf, uint8_t *) +
5777 			(tdata->digest.offset_bytes == 0 ?
5778 			plaintext_pad_len : tdata->digest.offset_bytes);
5779 
5780 		debug_hexdump(stdout, "digest:", ut_params->digest,
5781 			tdata->digest.len);
5782 		debug_hexdump(stdout, "digest expected:",
5783 			tdata->digest.data, tdata->digest.len);
5784 	}
5785 
5786 	/* Validate obuf */
5787 	if (verify) {
5788 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5789 			plaintext,
5790 			tdata->plaintext.data,
5791 			tdata->plaintext.len >> 3,
5792 			"ZUC Plaintext data not as expected");
5793 	} else {
5794 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5795 			ciphertext,
5796 			tdata->ciphertext.data,
5797 			tdata->ciphertext.len >> 3,
5798 			"ZUC Ciphertext data not as expected");
5799 
5800 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5801 			ut_params->digest,
5802 			tdata->digest.data,
5803 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5804 			"ZUC Generated auth tag not as expected");
5805 	}
5806 	return 0;
5807 }
5808 
5809 static int
5810 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5811 	uint8_t op_mode, uint8_t verify)
5812 {
5813 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5814 	struct crypto_unittest_params *ut_params = &unittest_params;
5815 
5816 	int retval;
5817 
5818 	const uint8_t *plaintext = NULL;
5819 	const uint8_t *ciphertext = NULL;
5820 	const uint8_t *digest = NULL;
5821 	unsigned int plaintext_pad_len;
5822 	unsigned int plaintext_len;
5823 	unsigned int ciphertext_pad_len;
5824 	unsigned int ciphertext_len;
5825 	uint8_t buffer[10000];
5826 	uint8_t digest_buffer[10000];
5827 
5828 	struct rte_cryptodev_info dev_info;
5829 	struct rte_cryptodev_sym_capability_idx cap_idx;
5830 
5831 	/* Check if device supports ZUC EIA3 */
5832 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5833 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5834 
5835 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5836 			&cap_idx) == NULL)
5837 		return -ENOTSUP;
5838 
5839 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5840 
5841 	uint64_t feat_flags = dev_info.feature_flags;
5842 
5843 	if (op_mode == IN_PLACE) {
5844 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5845 			printf("Device doesn't support in-place scatter-gather "
5846 					"in both input and output mbufs.\n");
5847 			return -ENOTSUP;
5848 		}
5849 	} else {
5850 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5851 			printf("Device doesn't support out-of-place scatter-gather "
5852 					"in both input and output mbufs.\n");
5853 			return -ENOTSUP;
5854 		}
5855 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5856 			printf("Device doesn't support digest encrypted.\n");
5857 			return -ENOTSUP;
5858 		}
5859 	}
5860 
5861 	/* Create ZUC session */
5862 	retval = create_wireless_algo_auth_cipher_session(
5863 			ts_params->valid_devs[0],
5864 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5865 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5866 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5867 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5868 			RTE_CRYPTO_AUTH_ZUC_EIA3,
5869 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5870 			tdata->key.data, tdata->key.len,
5871 			tdata->auth_iv.len, tdata->digest.len,
5872 			tdata->cipher_iv.len);
5873 
5874 	if (retval < 0)
5875 		return retval;
5876 
5877 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5878 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5879 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5880 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5881 
5882 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5883 			plaintext_pad_len, 15, 0);
5884 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5885 			"Failed to allocate input buffer in mempool");
5886 
5887 	if (op_mode == OUT_OF_PLACE) {
5888 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5889 				plaintext_pad_len, 15, 0);
5890 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5891 				"Failed to allocate output buffer in mempool");
5892 	}
5893 
5894 	if (verify) {
5895 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5896 			tdata->ciphertext.data);
5897 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5898 					ciphertext_len, buffer);
5899 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5900 			ciphertext_len);
5901 	} else {
5902 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5903 			tdata->plaintext.data);
5904 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5905 					plaintext_len, buffer);
5906 		debug_hexdump(stdout, "plaintext:", plaintext,
5907 			plaintext_len);
5908 	}
5909 	memset(buffer, 0, sizeof(buffer));
5910 
5911 	/* Create ZUC operation */
5912 	retval = create_wireless_algo_auth_cipher_operation(
5913 		tdata->digest.data, tdata->digest.len,
5914 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5915 		NULL, 0,
5916 		(tdata->digest.offset_bytes == 0 ?
5917 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5918 			: tdata->digest.offset_bytes),
5919 		tdata->validCipherLenInBits.len,
5920 		tdata->validCipherOffsetInBits.len,
5921 		tdata->validAuthLenInBits.len,
5922 		0,
5923 		op_mode, 1, verify);
5924 
5925 	if (retval < 0)
5926 		return retval;
5927 
5928 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5929 			ut_params->op);
5930 
5931 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5932 
5933 	ut_params->obuf = (op_mode == IN_PLACE ?
5934 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5935 
5936 	if (verify) {
5937 		if (ut_params->obuf)
5938 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5939 					plaintext_len, buffer);
5940 		else
5941 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5942 					plaintext_len, buffer);
5943 
5944 		debug_hexdump(stdout, "plaintext:", plaintext,
5945 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5946 		debug_hexdump(stdout, "plaintext expected:",
5947 			tdata->plaintext.data,
5948 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5949 	} else {
5950 		if (ut_params->obuf)
5951 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5952 					ciphertext_len, buffer);
5953 		else
5954 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5955 					ciphertext_len, buffer);
5956 
5957 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5958 			ciphertext_len);
5959 		debug_hexdump(stdout, "ciphertext expected:",
5960 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5961 
5962 		if (ut_params->obuf)
5963 			digest = rte_pktmbuf_read(ut_params->obuf,
5964 				(tdata->digest.offset_bytes == 0 ?
5965 				plaintext_pad_len : tdata->digest.offset_bytes),
5966 				tdata->digest.len, digest_buffer);
5967 		else
5968 			digest = rte_pktmbuf_read(ut_params->ibuf,
5969 				(tdata->digest.offset_bytes == 0 ?
5970 				plaintext_pad_len : tdata->digest.offset_bytes),
5971 				tdata->digest.len, digest_buffer);
5972 
5973 		debug_hexdump(stdout, "digest:", digest,
5974 			tdata->digest.len);
5975 		debug_hexdump(stdout, "digest expected:",
5976 			tdata->digest.data, tdata->digest.len);
5977 	}
5978 
5979 	/* Validate obuf */
5980 	if (verify) {
5981 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5982 			plaintext,
5983 			tdata->plaintext.data,
5984 			tdata->plaintext.len >> 3,
5985 			"ZUC Plaintext data not as expected");
5986 	} else {
5987 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5988 			ciphertext,
5989 			tdata->ciphertext.data,
5990 			tdata->validDataLenInBits.len,
5991 			"ZUC Ciphertext data not as expected");
5992 
5993 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5994 			digest,
5995 			tdata->digest.data,
5996 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5997 			"ZUC Generated auth tag not as expected");
5998 	}
5999 	return 0;
6000 }
6001 
6002 static int
6003 test_kasumi_encryption_test_case_1(void)
6004 {
6005 	return test_kasumi_encryption(&kasumi_test_case_1);
6006 }
6007 
6008 static int
6009 test_kasumi_encryption_test_case_1_sgl(void)
6010 {
6011 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6012 }
6013 
6014 static int
6015 test_kasumi_encryption_test_case_1_oop(void)
6016 {
6017 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
6018 }
6019 
6020 static int
6021 test_kasumi_encryption_test_case_1_oop_sgl(void)
6022 {
6023 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6024 }
6025 
6026 static int
6027 test_kasumi_encryption_test_case_2(void)
6028 {
6029 	return test_kasumi_encryption(&kasumi_test_case_2);
6030 }
6031 
6032 static int
6033 test_kasumi_encryption_test_case_3(void)
6034 {
6035 	return test_kasumi_encryption(&kasumi_test_case_3);
6036 }
6037 
6038 static int
6039 test_kasumi_encryption_test_case_4(void)
6040 {
6041 	return test_kasumi_encryption(&kasumi_test_case_4);
6042 }
6043 
6044 static int
6045 test_kasumi_encryption_test_case_5(void)
6046 {
6047 	return test_kasumi_encryption(&kasumi_test_case_5);
6048 }
6049 
6050 static int
6051 test_kasumi_decryption_test_case_1(void)
6052 {
6053 	return test_kasumi_decryption(&kasumi_test_case_1);
6054 }
6055 
6056 static int
6057 test_kasumi_decryption_test_case_1_oop(void)
6058 {
6059 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
6060 }
6061 
6062 static int
6063 test_kasumi_decryption_test_case_2(void)
6064 {
6065 	return test_kasumi_decryption(&kasumi_test_case_2);
6066 }
6067 
6068 static int
6069 test_kasumi_decryption_test_case_3(void)
6070 {
6071 	return test_kasumi_decryption(&kasumi_test_case_3);
6072 }
6073 
6074 static int
6075 test_kasumi_decryption_test_case_4(void)
6076 {
6077 	return test_kasumi_decryption(&kasumi_test_case_4);
6078 }
6079 
6080 static int
6081 test_kasumi_decryption_test_case_5(void)
6082 {
6083 	return test_kasumi_decryption(&kasumi_test_case_5);
6084 }
6085 static int
6086 test_snow3g_encryption_test_case_1(void)
6087 {
6088 	return test_snow3g_encryption(&snow3g_test_case_1);
6089 }
6090 
6091 static int
6092 test_snow3g_encryption_test_case_1_oop(void)
6093 {
6094 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
6095 }
6096 
6097 static int
6098 test_snow3g_encryption_test_case_1_oop_sgl(void)
6099 {
6100 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6101 }
6102 
6103 
6104 static int
6105 test_snow3g_encryption_test_case_1_offset_oop(void)
6106 {
6107 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6108 }
6109 
6110 static int
6111 test_snow3g_encryption_test_case_2(void)
6112 {
6113 	return test_snow3g_encryption(&snow3g_test_case_2);
6114 }
6115 
6116 static int
6117 test_snow3g_encryption_test_case_3(void)
6118 {
6119 	return test_snow3g_encryption(&snow3g_test_case_3);
6120 }
6121 
6122 static int
6123 test_snow3g_encryption_test_case_4(void)
6124 {
6125 	return test_snow3g_encryption(&snow3g_test_case_4);
6126 }
6127 
6128 static int
6129 test_snow3g_encryption_test_case_5(void)
6130 {
6131 	return test_snow3g_encryption(&snow3g_test_case_5);
6132 }
6133 
6134 static int
6135 test_snow3g_decryption_test_case_1(void)
6136 {
6137 	return test_snow3g_decryption(&snow3g_test_case_1);
6138 }
6139 
6140 static int
6141 test_snow3g_decryption_test_case_1_oop(void)
6142 {
6143 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
6144 }
6145 
6146 static int
6147 test_snow3g_decryption_test_case_2(void)
6148 {
6149 	return test_snow3g_decryption(&snow3g_test_case_2);
6150 }
6151 
6152 static int
6153 test_snow3g_decryption_test_case_3(void)
6154 {
6155 	return test_snow3g_decryption(&snow3g_test_case_3);
6156 }
6157 
6158 static int
6159 test_snow3g_decryption_test_case_4(void)
6160 {
6161 	return test_snow3g_decryption(&snow3g_test_case_4);
6162 }
6163 
6164 static int
6165 test_snow3g_decryption_test_case_5(void)
6166 {
6167 	return test_snow3g_decryption(&snow3g_test_case_5);
6168 }
6169 
6170 /*
6171  * Function prepares snow3g_hash_test_data from snow3g_test_data.
6172  * Pattern digest from snow3g_test_data must be allocated as
6173  * 4 last bytes in plaintext.
6174  */
6175 static void
6176 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6177 		struct snow3g_hash_test_data *output)
6178 {
6179 	if ((pattern != NULL) && (output != NULL)) {
6180 		output->key.len = pattern->key.len;
6181 
6182 		memcpy(output->key.data,
6183 		pattern->key.data, pattern->key.len);
6184 
6185 		output->auth_iv.len = pattern->auth_iv.len;
6186 
6187 		memcpy(output->auth_iv.data,
6188 		pattern->auth_iv.data, pattern->auth_iv.len);
6189 
6190 		output->plaintext.len = pattern->plaintext.len;
6191 
6192 		memcpy(output->plaintext.data,
6193 		pattern->plaintext.data, pattern->plaintext.len >> 3);
6194 
6195 		output->digest.len = pattern->digest.len;
6196 
6197 		memcpy(output->digest.data,
6198 		&pattern->plaintext.data[pattern->digest.offset_bytes],
6199 		pattern->digest.len);
6200 
6201 		output->validAuthLenInBits.len =
6202 		pattern->validAuthLenInBits.len;
6203 	}
6204 }
6205 
6206 /*
6207  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6208  */
6209 static int
6210 test_snow3g_decryption_with_digest_test_case_1(void)
6211 {
6212 	struct snow3g_hash_test_data snow3g_hash_data;
6213 
6214 	/*
6215 	 * Function prepare data for hash veryfication test case.
6216 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
6217 	 */
6218 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6219 
6220 	return test_snow3g_decryption(&snow3g_test_case_7) &
6221 			test_snow3g_authentication_verify(&snow3g_hash_data);
6222 }
6223 
6224 static int
6225 test_snow3g_cipher_auth_test_case_1(void)
6226 {
6227 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
6228 }
6229 
6230 static int
6231 test_snow3g_auth_cipher_test_case_1(void)
6232 {
6233 	return test_snow3g_auth_cipher(
6234 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6235 }
6236 
6237 static int
6238 test_snow3g_auth_cipher_test_case_2(void)
6239 {
6240 	return test_snow3g_auth_cipher(
6241 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6242 }
6243 
6244 static int
6245 test_snow3g_auth_cipher_test_case_2_oop(void)
6246 {
6247 	return test_snow3g_auth_cipher(
6248 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6249 }
6250 
6251 static int
6252 test_snow3g_auth_cipher_part_digest_enc(void)
6253 {
6254 	return test_snow3g_auth_cipher(
6255 		&snow3g_auth_cipher_partial_digest_encryption,
6256 			IN_PLACE, 0);
6257 }
6258 
6259 static int
6260 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6261 {
6262 	return test_snow3g_auth_cipher(
6263 		&snow3g_auth_cipher_partial_digest_encryption,
6264 			OUT_OF_PLACE, 0);
6265 }
6266 
6267 static int
6268 test_snow3g_auth_cipher_test_case_3_sgl(void)
6269 {
6270 	return test_snow3g_auth_cipher_sgl(
6271 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6272 }
6273 
6274 static int
6275 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6276 {
6277 	return test_snow3g_auth_cipher_sgl(
6278 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6279 }
6280 
6281 static int
6282 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6283 {
6284 	return test_snow3g_auth_cipher_sgl(
6285 		&snow3g_auth_cipher_partial_digest_encryption,
6286 			IN_PLACE, 0);
6287 }
6288 
6289 static int
6290 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6291 {
6292 	return test_snow3g_auth_cipher_sgl(
6293 		&snow3g_auth_cipher_partial_digest_encryption,
6294 			OUT_OF_PLACE, 0);
6295 }
6296 
6297 static int
6298 test_snow3g_auth_cipher_verify_test_case_1(void)
6299 {
6300 	return test_snow3g_auth_cipher(
6301 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6302 }
6303 
6304 static int
6305 test_snow3g_auth_cipher_verify_test_case_2(void)
6306 {
6307 	return test_snow3g_auth_cipher(
6308 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6309 }
6310 
6311 static int
6312 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6313 {
6314 	return test_snow3g_auth_cipher(
6315 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6316 }
6317 
6318 static int
6319 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6320 {
6321 	return test_snow3g_auth_cipher(
6322 		&snow3g_auth_cipher_partial_digest_encryption,
6323 			IN_PLACE, 1);
6324 }
6325 
6326 static int
6327 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6328 {
6329 	return test_snow3g_auth_cipher(
6330 		&snow3g_auth_cipher_partial_digest_encryption,
6331 			OUT_OF_PLACE, 1);
6332 }
6333 
6334 static int
6335 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6336 {
6337 	return test_snow3g_auth_cipher_sgl(
6338 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6339 }
6340 
6341 static int
6342 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6343 {
6344 	return test_snow3g_auth_cipher_sgl(
6345 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6346 }
6347 
6348 static int
6349 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6350 {
6351 	return test_snow3g_auth_cipher_sgl(
6352 		&snow3g_auth_cipher_partial_digest_encryption,
6353 			IN_PLACE, 1);
6354 }
6355 
6356 static int
6357 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6358 {
6359 	return test_snow3g_auth_cipher_sgl(
6360 		&snow3g_auth_cipher_partial_digest_encryption,
6361 			OUT_OF_PLACE, 1);
6362 }
6363 
6364 static int
6365 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6366 {
6367 	return test_snow3g_auth_cipher(
6368 		&snow3g_test_case_7, IN_PLACE, 0);
6369 }
6370 
6371 static int
6372 test_kasumi_auth_cipher_test_case_1(void)
6373 {
6374 	return test_kasumi_auth_cipher(
6375 		&kasumi_test_case_3, IN_PLACE, 0);
6376 }
6377 
6378 static int
6379 test_kasumi_auth_cipher_test_case_2(void)
6380 {
6381 	return test_kasumi_auth_cipher(
6382 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6383 }
6384 
6385 static int
6386 test_kasumi_auth_cipher_test_case_2_oop(void)
6387 {
6388 	return test_kasumi_auth_cipher(
6389 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6390 }
6391 
6392 static int
6393 test_kasumi_auth_cipher_test_case_2_sgl(void)
6394 {
6395 	return test_kasumi_auth_cipher_sgl(
6396 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6397 }
6398 
6399 static int
6400 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6401 {
6402 	return test_kasumi_auth_cipher_sgl(
6403 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6404 }
6405 
6406 static int
6407 test_kasumi_auth_cipher_verify_test_case_1(void)
6408 {
6409 	return test_kasumi_auth_cipher(
6410 		&kasumi_test_case_3, IN_PLACE, 1);
6411 }
6412 
6413 static int
6414 test_kasumi_auth_cipher_verify_test_case_2(void)
6415 {
6416 	return test_kasumi_auth_cipher(
6417 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6418 }
6419 
6420 static int
6421 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6422 {
6423 	return test_kasumi_auth_cipher(
6424 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6425 }
6426 
6427 static int
6428 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6429 {
6430 	return test_kasumi_auth_cipher_sgl(
6431 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6432 }
6433 
6434 static int
6435 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6436 {
6437 	return test_kasumi_auth_cipher_sgl(
6438 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6439 }
6440 
6441 static int
6442 test_kasumi_cipher_auth_test_case_1(void)
6443 {
6444 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
6445 }
6446 
6447 static int
6448 test_zuc_encryption_test_case_1(void)
6449 {
6450 	return test_zuc_encryption(&zuc_test_case_cipher_193b);
6451 }
6452 
6453 static int
6454 test_zuc_encryption_test_case_2(void)
6455 {
6456 	return test_zuc_encryption(&zuc_test_case_cipher_800b);
6457 }
6458 
6459 static int
6460 test_zuc_encryption_test_case_3(void)
6461 {
6462 	return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6463 }
6464 
6465 static int
6466 test_zuc_encryption_test_case_4(void)
6467 {
6468 	return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6469 }
6470 
6471 static int
6472 test_zuc_encryption_test_case_5(void)
6473 {
6474 	return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6475 }
6476 
6477 static int
6478 test_zuc_encryption_test_case_6_sgl(void)
6479 {
6480 	return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6481 }
6482 
6483 static int
6484 test_zuc_hash_generate_test_case_1(void)
6485 {
6486 	return test_zuc_authentication(&zuc_test_case_auth_1b);
6487 }
6488 
6489 static int
6490 test_zuc_hash_generate_test_case_2(void)
6491 {
6492 	return test_zuc_authentication(&zuc_test_case_auth_90b);
6493 }
6494 
6495 static int
6496 test_zuc_hash_generate_test_case_3(void)
6497 {
6498 	return test_zuc_authentication(&zuc_test_case_auth_577b);
6499 }
6500 
6501 static int
6502 test_zuc_hash_generate_test_case_4(void)
6503 {
6504 	return test_zuc_authentication(&zuc_test_case_auth_2079b);
6505 }
6506 
6507 static int
6508 test_zuc_hash_generate_test_case_5(void)
6509 {
6510 	return test_zuc_authentication(&zuc_test_auth_5670b);
6511 }
6512 
6513 static int
6514 test_zuc_hash_generate_test_case_6(void)
6515 {
6516 	return test_zuc_authentication(&zuc_test_case_auth_128b);
6517 }
6518 
6519 static int
6520 test_zuc_hash_generate_test_case_7(void)
6521 {
6522 	return test_zuc_authentication(&zuc_test_case_auth_2080b);
6523 }
6524 
6525 static int
6526 test_zuc_hash_generate_test_case_8(void)
6527 {
6528 	return test_zuc_authentication(&zuc_test_case_auth_584b);
6529 }
6530 
6531 static int
6532 test_zuc_cipher_auth_test_case_1(void)
6533 {
6534 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6535 }
6536 
6537 static int
6538 test_zuc_cipher_auth_test_case_2(void)
6539 {
6540 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6541 }
6542 
6543 static int
6544 test_zuc_auth_cipher_test_case_1(void)
6545 {
6546 	return test_zuc_auth_cipher(
6547 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6548 }
6549 
6550 static int
6551 test_zuc_auth_cipher_test_case_1_oop(void)
6552 {
6553 	return test_zuc_auth_cipher(
6554 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6555 }
6556 
6557 static int
6558 test_zuc_auth_cipher_test_case_1_sgl(void)
6559 {
6560 	return test_zuc_auth_cipher_sgl(
6561 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6562 }
6563 
6564 static int
6565 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6566 {
6567 	return test_zuc_auth_cipher_sgl(
6568 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6569 }
6570 
6571 static int
6572 test_zuc_auth_cipher_verify_test_case_1(void)
6573 {
6574 	return test_zuc_auth_cipher(
6575 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6576 }
6577 
6578 static int
6579 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6580 {
6581 	return test_zuc_auth_cipher(
6582 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6583 }
6584 
6585 static int
6586 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6587 {
6588 	return test_zuc_auth_cipher_sgl(
6589 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6590 }
6591 
6592 static int
6593 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6594 {
6595 	return test_zuc_auth_cipher_sgl(
6596 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6597 }
6598 
6599 static int
6600 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6601 {
6602 	uint8_t dev_id = testsuite_params.valid_devs[0];
6603 
6604 	struct rte_cryptodev_sym_capability_idx cap_idx;
6605 
6606 	/* Check if device supports particular cipher algorithm */
6607 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6608 	cap_idx.algo.cipher = tdata->cipher_algo;
6609 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6610 		return -ENOTSUP;
6611 
6612 	/* Check if device supports particular hash algorithm */
6613 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6614 	cap_idx.algo.auth = tdata->auth_algo;
6615 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6616 		return -ENOTSUP;
6617 
6618 	return 0;
6619 }
6620 
6621 static int
6622 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6623 	uint8_t op_mode, uint8_t verify)
6624 {
6625 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6626 	struct crypto_unittest_params *ut_params = &unittest_params;
6627 
6628 	int retval;
6629 
6630 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6631 	unsigned int plaintext_pad_len;
6632 	unsigned int plaintext_len;
6633 	unsigned int ciphertext_pad_len;
6634 	unsigned int ciphertext_len;
6635 
6636 	struct rte_cryptodev_info dev_info;
6637 	struct rte_crypto_op *op;
6638 
6639 	/* Check if device supports particular algorithms separately */
6640 	if (test_mixed_check_if_unsupported(tdata))
6641 		return -ENOTSUP;
6642 
6643 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6644 
6645 	uint64_t feat_flags = dev_info.feature_flags;
6646 
6647 	if (op_mode == OUT_OF_PLACE) {
6648 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6649 			printf("Device doesn't support digest encrypted.\n");
6650 			return -ENOTSUP;
6651 		}
6652 	}
6653 
6654 	/* Create the session */
6655 	if (verify)
6656 		retval = create_wireless_algo_cipher_auth_session(
6657 				ts_params->valid_devs[0],
6658 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
6659 				RTE_CRYPTO_AUTH_OP_VERIFY,
6660 				tdata->auth_algo,
6661 				tdata->cipher_algo,
6662 				tdata->auth_key.data, tdata->auth_key.len,
6663 				tdata->auth_iv.len, tdata->digest_enc.len,
6664 				tdata->cipher_iv.len);
6665 	else
6666 		retval = create_wireless_algo_auth_cipher_session(
6667 				ts_params->valid_devs[0],
6668 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6669 				RTE_CRYPTO_AUTH_OP_GENERATE,
6670 				tdata->auth_algo,
6671 				tdata->cipher_algo,
6672 				tdata->auth_key.data, tdata->auth_key.len,
6673 				tdata->auth_iv.len, tdata->digest_enc.len,
6674 				tdata->cipher_iv.len);
6675 	if (retval < 0)
6676 		return retval;
6677 
6678 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6679 	if (op_mode == OUT_OF_PLACE)
6680 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6681 
6682 	/* clear mbuf payload */
6683 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6684 		rte_pktmbuf_tailroom(ut_params->ibuf));
6685 	if (op_mode == OUT_OF_PLACE)
6686 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6687 				rte_pktmbuf_tailroom(ut_params->obuf));
6688 
6689 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6690 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6691 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6692 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6693 
6694 	if (verify) {
6695 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6696 				ciphertext_pad_len);
6697 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6698 		if (op_mode == OUT_OF_PLACE)
6699 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6700 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6701 				ciphertext_len);
6702 	} else {
6703 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6704 				plaintext_pad_len);
6705 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6706 		if (op_mode == OUT_OF_PLACE)
6707 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6708 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6709 	}
6710 
6711 	/* Create the operation */
6712 	retval = create_wireless_algo_auth_cipher_operation(
6713 			tdata->digest_enc.data, tdata->digest_enc.len,
6714 			tdata->cipher_iv.data, tdata->cipher_iv.len,
6715 			tdata->auth_iv.data, tdata->auth_iv.len,
6716 			(tdata->digest_enc.offset == 0 ?
6717 				plaintext_pad_len
6718 				: tdata->digest_enc.offset),
6719 			tdata->validCipherLen.len_bits,
6720 			tdata->cipher.offset_bits,
6721 			tdata->validAuthLen.len_bits,
6722 			tdata->auth.offset_bits,
6723 			op_mode, 0, verify);
6724 
6725 	if (retval < 0)
6726 		return retval;
6727 
6728 	op = process_crypto_request(ts_params->valid_devs[0],
6729 			ut_params->op);
6730 
6731 	/* Check if the op failed because the device doesn't */
6732 	/* support this particular combination of algorithms */
6733 	if (op == NULL && ut_params->op->status ==
6734 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6735 		printf("Device doesn't support this mixed combination. "
6736 				"Test Skipped.\n");
6737 		return -ENOTSUP;
6738 	}
6739 	ut_params->op = op;
6740 
6741 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6742 
6743 	ut_params->obuf = (op_mode == IN_PLACE ?
6744 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6745 
6746 	if (verify) {
6747 		if (ut_params->obuf)
6748 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6749 							uint8_t *);
6750 		else
6751 			plaintext = ciphertext +
6752 					(tdata->cipher.offset_bits >> 3);
6753 
6754 		debug_hexdump(stdout, "plaintext:", plaintext,
6755 				tdata->plaintext.len_bits >> 3);
6756 		debug_hexdump(stdout, "plaintext expected:",
6757 				tdata->plaintext.data,
6758 				tdata->plaintext.len_bits >> 3);
6759 	} else {
6760 		if (ut_params->obuf)
6761 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6762 					uint8_t *);
6763 		else
6764 			ciphertext = plaintext;
6765 
6766 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6767 				ciphertext_len);
6768 		debug_hexdump(stdout, "ciphertext expected:",
6769 				tdata->ciphertext.data,
6770 				tdata->ciphertext.len_bits >> 3);
6771 
6772 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6773 				+ (tdata->digest_enc.offset == 0 ?
6774 		plaintext_pad_len : tdata->digest_enc.offset);
6775 
6776 		debug_hexdump(stdout, "digest:", ut_params->digest,
6777 				tdata->digest_enc.len);
6778 		debug_hexdump(stdout, "digest expected:",
6779 				tdata->digest_enc.data,
6780 				tdata->digest_enc.len);
6781 	}
6782 
6783 	/* Validate obuf */
6784 	if (verify) {
6785 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6786 				plaintext,
6787 				tdata->plaintext.data,
6788 				tdata->plaintext.len_bits >> 3,
6789 				"Plaintext data not as expected");
6790 	} else {
6791 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6792 				ciphertext,
6793 				tdata->ciphertext.data,
6794 				tdata->validDataLen.len_bits,
6795 				"Ciphertext data not as expected");
6796 
6797 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6798 				ut_params->digest,
6799 				tdata->digest_enc.data,
6800 				DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6801 				"Generated auth tag not as expected");
6802 	}
6803 
6804 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6805 			"crypto op processing failed");
6806 
6807 	return 0;
6808 }
6809 
6810 static int
6811 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6812 	uint8_t op_mode, uint8_t verify)
6813 {
6814 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6815 	struct crypto_unittest_params *ut_params = &unittest_params;
6816 
6817 	int retval;
6818 
6819 	const uint8_t *plaintext = NULL;
6820 	const uint8_t *ciphertext = NULL;
6821 	const uint8_t *digest = NULL;
6822 	unsigned int plaintext_pad_len;
6823 	unsigned int plaintext_len;
6824 	unsigned int ciphertext_pad_len;
6825 	unsigned int ciphertext_len;
6826 	uint8_t buffer[10000];
6827 	uint8_t digest_buffer[10000];
6828 
6829 	struct rte_cryptodev_info dev_info;
6830 	struct rte_crypto_op *op;
6831 
6832 	/* Check if device supports particular algorithms */
6833 	if (test_mixed_check_if_unsupported(tdata))
6834 		return -ENOTSUP;
6835 
6836 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6837 
6838 	uint64_t feat_flags = dev_info.feature_flags;
6839 
6840 	if (op_mode == IN_PLACE) {
6841 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6842 			printf("Device doesn't support in-place scatter-gather "
6843 					"in both input and output mbufs.\n");
6844 			return -ENOTSUP;
6845 		}
6846 	} else {
6847 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6848 			printf("Device doesn't support out-of-place scatter-gather "
6849 					"in both input and output mbufs.\n");
6850 			return -ENOTSUP;
6851 		}
6852 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6853 			printf("Device doesn't support digest encrypted.\n");
6854 			return -ENOTSUP;
6855 		}
6856 	}
6857 
6858 	/* Create the session */
6859 	if (verify)
6860 		retval = create_wireless_algo_cipher_auth_session(
6861 				ts_params->valid_devs[0],
6862 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
6863 				RTE_CRYPTO_AUTH_OP_VERIFY,
6864 				tdata->auth_algo,
6865 				tdata->cipher_algo,
6866 				tdata->auth_key.data, tdata->auth_key.len,
6867 				tdata->auth_iv.len, tdata->digest_enc.len,
6868 				tdata->cipher_iv.len);
6869 	else
6870 		retval = create_wireless_algo_auth_cipher_session(
6871 				ts_params->valid_devs[0],
6872 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6873 				RTE_CRYPTO_AUTH_OP_GENERATE,
6874 				tdata->auth_algo,
6875 				tdata->cipher_algo,
6876 				tdata->auth_key.data, tdata->auth_key.len,
6877 				tdata->auth_iv.len, tdata->digest_enc.len,
6878 				tdata->cipher_iv.len);
6879 	if (retval < 0)
6880 		return retval;
6881 
6882 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6883 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6884 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6885 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6886 
6887 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6888 			ciphertext_pad_len, 15, 0);
6889 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6890 			"Failed to allocate input buffer in mempool");
6891 
6892 	if (op_mode == OUT_OF_PLACE) {
6893 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6894 				plaintext_pad_len, 15, 0);
6895 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6896 				"Failed to allocate output buffer in mempool");
6897 	}
6898 
6899 	if (verify) {
6900 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6901 			tdata->ciphertext.data);
6902 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6903 					ciphertext_len, buffer);
6904 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6905 			ciphertext_len);
6906 	} else {
6907 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6908 			tdata->plaintext.data);
6909 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6910 					plaintext_len, buffer);
6911 		debug_hexdump(stdout, "plaintext:", plaintext,
6912 			plaintext_len);
6913 	}
6914 	memset(buffer, 0, sizeof(buffer));
6915 
6916 	/* Create the operation */
6917 	retval = create_wireless_algo_auth_cipher_operation(
6918 			tdata->digest_enc.data, tdata->digest_enc.len,
6919 			tdata->cipher_iv.data, tdata->cipher_iv.len,
6920 			tdata->auth_iv.data, tdata->auth_iv.len,
6921 			(tdata->digest_enc.offset == 0 ?
6922 				plaintext_pad_len
6923 				: tdata->digest_enc.offset),
6924 			tdata->validCipherLen.len_bits,
6925 			tdata->cipher.offset_bits,
6926 			tdata->validAuthLen.len_bits,
6927 			tdata->auth.offset_bits,
6928 			op_mode, 1, verify);
6929 
6930 	if (retval < 0)
6931 		return retval;
6932 
6933 	op = process_crypto_request(ts_params->valid_devs[0],
6934 			ut_params->op);
6935 
6936 	/* Check if the op failed because the device doesn't */
6937 	/* support this particular combination of algorithms */
6938 	if (op == NULL && ut_params->op->status ==
6939 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6940 		printf("Device doesn't support this mixed combination. "
6941 				"Test Skipped.\n");
6942 		return -ENOTSUP;
6943 	}
6944 
6945 	ut_params->op = op;
6946 
6947 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6948 
6949 	ut_params->obuf = (op_mode == IN_PLACE ?
6950 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6951 
6952 	if (verify) {
6953 		if (ut_params->obuf)
6954 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6955 					plaintext_len, buffer);
6956 		else
6957 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6958 					plaintext_len, buffer);
6959 
6960 		debug_hexdump(stdout, "plaintext:", plaintext,
6961 				(tdata->plaintext.len_bits >> 3) -
6962 				tdata->digest_enc.len);
6963 		debug_hexdump(stdout, "plaintext expected:",
6964 				tdata->plaintext.data,
6965 				(tdata->plaintext.len_bits >> 3) -
6966 				tdata->digest_enc.len);
6967 	} else {
6968 		if (ut_params->obuf)
6969 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6970 					ciphertext_len, buffer);
6971 		else
6972 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6973 					ciphertext_len, buffer);
6974 
6975 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6976 			ciphertext_len);
6977 		debug_hexdump(stdout, "ciphertext expected:",
6978 			tdata->ciphertext.data,
6979 			tdata->ciphertext.len_bits >> 3);
6980 
6981 		if (ut_params->obuf)
6982 			digest = rte_pktmbuf_read(ut_params->obuf,
6983 					(tdata->digest_enc.offset == 0 ?
6984 						plaintext_pad_len :
6985 						tdata->digest_enc.offset),
6986 					tdata->digest_enc.len, digest_buffer);
6987 		else
6988 			digest = rte_pktmbuf_read(ut_params->ibuf,
6989 					(tdata->digest_enc.offset == 0 ?
6990 						plaintext_pad_len :
6991 						tdata->digest_enc.offset),
6992 					tdata->digest_enc.len, digest_buffer);
6993 
6994 		debug_hexdump(stdout, "digest:", digest,
6995 				tdata->digest_enc.len);
6996 		debug_hexdump(stdout, "digest expected:",
6997 				tdata->digest_enc.data, tdata->digest_enc.len);
6998 	}
6999 
7000 	/* Validate obuf */
7001 	if (verify) {
7002 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7003 				plaintext,
7004 				tdata->plaintext.data,
7005 				tdata->plaintext.len_bits >> 3,
7006 				"Plaintext data not as expected");
7007 	} else {
7008 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7009 				ciphertext,
7010 				tdata->ciphertext.data,
7011 				tdata->validDataLen.len_bits,
7012 				"Ciphertext data not as expected");
7013 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7014 				digest,
7015 				tdata->digest_enc.data,
7016 				tdata->digest_enc.len,
7017 				"Generated auth tag not as expected");
7018 	}
7019 
7020 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7021 			"crypto op processing failed");
7022 
7023 	return 0;
7024 }
7025 
7026 /** AUTH AES CMAC + CIPHER AES CTR */
7027 
7028 static int
7029 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7030 {
7031 	return test_mixed_auth_cipher(
7032 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7033 }
7034 
7035 static int
7036 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7037 {
7038 	return test_mixed_auth_cipher(
7039 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7040 }
7041 
7042 static int
7043 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7044 {
7045 	return test_mixed_auth_cipher_sgl(
7046 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7047 }
7048 
7049 static int
7050 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7051 {
7052 	return test_mixed_auth_cipher_sgl(
7053 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7054 }
7055 
7056 static int
7057 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7058 {
7059 	return test_mixed_auth_cipher(
7060 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7061 }
7062 
7063 static int
7064 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7065 {
7066 	return test_mixed_auth_cipher(
7067 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7068 }
7069 
7070 static int
7071 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7072 {
7073 	return test_mixed_auth_cipher_sgl(
7074 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7075 }
7076 
7077 static int
7078 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7079 {
7080 	return test_mixed_auth_cipher_sgl(
7081 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7082 }
7083 
7084 /** MIXED AUTH + CIPHER */
7085 
7086 static int
7087 test_auth_zuc_cipher_snow_test_case_1(void)
7088 {
7089 	return test_mixed_auth_cipher(
7090 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7091 }
7092 
7093 static int
7094 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7095 {
7096 	return test_mixed_auth_cipher(
7097 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7098 }
7099 
7100 static int
7101 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7102 {
7103 	return test_mixed_auth_cipher(
7104 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7105 }
7106 
7107 static int
7108 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7109 {
7110 	return test_mixed_auth_cipher(
7111 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7112 }
7113 
7114 static int
7115 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7116 {
7117 	return test_mixed_auth_cipher(
7118 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7119 }
7120 
7121 static int
7122 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7123 {
7124 	return test_mixed_auth_cipher(
7125 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7126 }
7127 
7128 static int
7129 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7130 {
7131 	return test_mixed_auth_cipher(
7132 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7133 }
7134 
7135 static int
7136 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7137 {
7138 	return test_mixed_auth_cipher(
7139 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7140 }
7141 
7142 static int
7143 test_auth_snow_cipher_zuc_test_case_1(void)
7144 {
7145 	return test_mixed_auth_cipher(
7146 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7147 }
7148 
7149 static int
7150 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7151 {
7152 	return test_mixed_auth_cipher(
7153 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7154 }
7155 
7156 static int
7157 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7158 {
7159 	return test_mixed_auth_cipher(
7160 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7161 }
7162 
7163 static int
7164 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7165 {
7166 	return test_mixed_auth_cipher(
7167 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7168 }
7169 
7170 static int
7171 test_auth_null_cipher_snow_test_case_1(void)
7172 {
7173 	return test_mixed_auth_cipher(
7174 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7175 }
7176 
7177 static int
7178 test_verify_auth_null_cipher_snow_test_case_1(void)
7179 {
7180 	return test_mixed_auth_cipher(
7181 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7182 }
7183 
7184 static int
7185 test_auth_null_cipher_zuc_test_case_1(void)
7186 {
7187 	return test_mixed_auth_cipher(
7188 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7189 }
7190 
7191 static int
7192 test_verify_auth_null_cipher_zuc_test_case_1(void)
7193 {
7194 	return test_mixed_auth_cipher(
7195 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7196 }
7197 
7198 static int
7199 test_auth_snow_cipher_null_test_case_1(void)
7200 {
7201 	return test_mixed_auth_cipher(
7202 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7203 }
7204 
7205 static int
7206 test_verify_auth_snow_cipher_null_test_case_1(void)
7207 {
7208 	return test_mixed_auth_cipher(
7209 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7210 }
7211 
7212 static int
7213 test_auth_zuc_cipher_null_test_case_1(void)
7214 {
7215 	return test_mixed_auth_cipher(
7216 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7217 }
7218 
7219 static int
7220 test_verify_auth_zuc_cipher_null_test_case_1(void)
7221 {
7222 	return test_mixed_auth_cipher(
7223 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7224 }
7225 
7226 static int
7227 test_auth_null_cipher_aes_ctr_test_case_1(void)
7228 {
7229 	return test_mixed_auth_cipher(
7230 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7231 }
7232 
7233 static int
7234 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7235 {
7236 	return test_mixed_auth_cipher(
7237 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7238 }
7239 
7240 static int
7241 test_auth_aes_cmac_cipher_null_test_case_1(void)
7242 {
7243 	return test_mixed_auth_cipher(
7244 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7245 }
7246 
7247 static int
7248 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7249 {
7250 	return test_mixed_auth_cipher(
7251 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7252 }
7253 
7254 static int
7255 test_3DES_chain_qat_all(void)
7256 {
7257 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7258 	int status;
7259 
7260 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7261 		ts_params->op_mpool,
7262 		ts_params->session_mpool, ts_params->session_priv_mpool,
7263 		ts_params->valid_devs[0],
7264 		rte_cryptodev_driver_id_get(
7265 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7266 		BLKCIPHER_3DES_CHAIN_TYPE);
7267 
7268 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7269 
7270 	return TEST_SUCCESS;
7271 }
7272 
7273 static int
7274 test_DES_cipheronly_qat_all(void)
7275 {
7276 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7277 	int status;
7278 
7279 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7280 		ts_params->op_mpool,
7281 		ts_params->session_mpool, ts_params->session_priv_mpool,
7282 		ts_params->valid_devs[0],
7283 		rte_cryptodev_driver_id_get(
7284 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7285 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7286 
7287 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7288 
7289 	return TEST_SUCCESS;
7290 }
7291 
7292 static int
7293 test_DES_cipheronly_openssl_all(void)
7294 {
7295 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7296 	int status;
7297 
7298 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7299 		ts_params->op_mpool,
7300 		ts_params->session_mpool, ts_params->session_priv_mpool,
7301 		ts_params->valid_devs[0],
7302 		rte_cryptodev_driver_id_get(
7303 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7304 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7305 
7306 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7307 
7308 	return TEST_SUCCESS;
7309 }
7310 
7311 static int
7312 test_DES_docsis_openssl_all(void)
7313 {
7314 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7315 	int status;
7316 
7317 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7318 		ts_params->op_mpool,
7319 		ts_params->session_mpool, ts_params->session_priv_mpool,
7320 		ts_params->valid_devs[0],
7321 		rte_cryptodev_driver_id_get(
7322 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7323 		BLKCIPHER_DES_DOCSIS_TYPE);
7324 
7325 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7326 
7327 	return TEST_SUCCESS;
7328 }
7329 
7330 static int
7331 test_DES_cipheronly_mb_all(void)
7332 {
7333 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7334 	int status;
7335 
7336 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7337 		ts_params->op_mpool,
7338 		ts_params->session_mpool, ts_params->session_priv_mpool,
7339 		ts_params->valid_devs[0],
7340 		rte_cryptodev_driver_id_get(
7341 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7342 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7343 
7344 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7345 
7346 	return TEST_SUCCESS;
7347 }
7348 static int
7349 test_3DES_cipheronly_mb_all(void)
7350 {
7351 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7352 	int status;
7353 
7354 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7355 		ts_params->op_mpool,
7356 		ts_params->session_mpool, ts_params->session_priv_mpool,
7357 		ts_params->valid_devs[0],
7358 		rte_cryptodev_driver_id_get(
7359 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7360 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7361 
7362 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7363 
7364 	return TEST_SUCCESS;
7365 }
7366 
7367 static int
7368 test_DES_docsis_mb_all(void)
7369 {
7370 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7371 	int status;
7372 
7373 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7374 		ts_params->op_mpool,
7375 		ts_params->session_mpool, ts_params->session_priv_mpool,
7376 		ts_params->valid_devs[0],
7377 		rte_cryptodev_driver_id_get(
7378 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7379 		BLKCIPHER_DES_DOCSIS_TYPE);
7380 
7381 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7382 
7383 	return TEST_SUCCESS;
7384 }
7385 
7386 static int
7387 test_3DES_chain_caam_jr_all(void)
7388 {
7389 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7390 	int status;
7391 
7392 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7393 		ts_params->op_mpool,
7394 		ts_params->session_mpool, ts_params->session_priv_mpool,
7395 		ts_params->valid_devs[0],
7396 		rte_cryptodev_driver_id_get(
7397 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7398 		BLKCIPHER_3DES_CHAIN_TYPE);
7399 
7400 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7401 
7402 	return TEST_SUCCESS;
7403 }
7404 
7405 static int
7406 test_3DES_cipheronly_caam_jr_all(void)
7407 {
7408 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7409 	int status;
7410 
7411 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7412 		ts_params->op_mpool,
7413 		ts_params->session_mpool, ts_params->session_priv_mpool,
7414 		ts_params->valid_devs[0],
7415 		rte_cryptodev_driver_id_get(
7416 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7417 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7418 
7419 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7420 
7421 	return TEST_SUCCESS;
7422 }
7423 
7424 static int
7425 test_3DES_chain_dpaa_sec_all(void)
7426 {
7427 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7428 	int status;
7429 
7430 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7431 		ts_params->op_mpool,
7432 		ts_params->session_mpool, ts_params->session_priv_mpool,
7433 		ts_params->valid_devs[0],
7434 		rte_cryptodev_driver_id_get(
7435 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7436 		BLKCIPHER_3DES_CHAIN_TYPE);
7437 
7438 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7439 
7440 	return TEST_SUCCESS;
7441 }
7442 
7443 static int
7444 test_3DES_cipheronly_dpaa_sec_all(void)
7445 {
7446 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7447 	int status;
7448 
7449 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7450 		ts_params->op_mpool,
7451 		ts_params->session_mpool, ts_params->session_priv_mpool,
7452 		ts_params->valid_devs[0],
7453 		rte_cryptodev_driver_id_get(
7454 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7455 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7456 
7457 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7458 
7459 	return TEST_SUCCESS;
7460 }
7461 
7462 static int
7463 test_3DES_chain_dpaa2_sec_all(void)
7464 {
7465 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7466 	int status;
7467 
7468 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7469 		ts_params->op_mpool,
7470 		ts_params->session_mpool, ts_params->session_priv_mpool,
7471 		ts_params->valid_devs[0],
7472 		rte_cryptodev_driver_id_get(
7473 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7474 		BLKCIPHER_3DES_CHAIN_TYPE);
7475 
7476 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7477 
7478 	return TEST_SUCCESS;
7479 }
7480 
7481 static int
7482 test_3DES_cipheronly_dpaa2_sec_all(void)
7483 {
7484 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7485 	int status;
7486 
7487 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7488 		ts_params->op_mpool,
7489 		ts_params->session_mpool, ts_params->session_priv_mpool,
7490 		ts_params->valid_devs[0],
7491 		rte_cryptodev_driver_id_get(
7492 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7493 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7494 
7495 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7496 
7497 	return TEST_SUCCESS;
7498 }
7499 
7500 static int
7501 test_3DES_chain_ccp_all(void)
7502 {
7503 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7504 	int status;
7505 
7506 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7507 		ts_params->op_mpool,
7508 		ts_params->session_mpool, ts_params->session_priv_mpool,
7509 		ts_params->valid_devs[0],
7510 		rte_cryptodev_driver_id_get(
7511 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7512 		BLKCIPHER_3DES_CHAIN_TYPE);
7513 
7514 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7515 
7516 	return TEST_SUCCESS;
7517 }
7518 
7519 static int
7520 test_3DES_cipheronly_ccp_all(void)
7521 {
7522 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7523 	int status;
7524 
7525 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7526 		ts_params->op_mpool,
7527 		ts_params->session_mpool, ts_params->session_priv_mpool,
7528 		ts_params->valid_devs[0],
7529 		rte_cryptodev_driver_id_get(
7530 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7531 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7532 
7533 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7534 
7535 	return TEST_SUCCESS;
7536 }
7537 
7538 static int
7539 test_3DES_cipheronly_qat_all(void)
7540 {
7541 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7542 	int status;
7543 
7544 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7545 		ts_params->op_mpool,
7546 		ts_params->session_mpool, ts_params->session_priv_mpool,
7547 		ts_params->valid_devs[0],
7548 		rte_cryptodev_driver_id_get(
7549 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7550 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7551 
7552 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7553 
7554 	return TEST_SUCCESS;
7555 }
7556 
7557 static int
7558 test_3DES_chain_openssl_all(void)
7559 {
7560 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7561 	int status;
7562 
7563 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7564 		ts_params->op_mpool,
7565 		ts_params->session_mpool, ts_params->session_priv_mpool,
7566 		ts_params->valid_devs[0],
7567 		rte_cryptodev_driver_id_get(
7568 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7569 		BLKCIPHER_3DES_CHAIN_TYPE);
7570 
7571 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7572 
7573 	return TEST_SUCCESS;
7574 }
7575 
7576 static int
7577 test_3DES_cipheronly_openssl_all(void)
7578 {
7579 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7580 	int status;
7581 
7582 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7583 		ts_params->op_mpool,
7584 		ts_params->session_mpool, ts_params->session_priv_mpool,
7585 		ts_params->valid_devs[0],
7586 		rte_cryptodev_driver_id_get(
7587 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7588 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7589 
7590 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7591 
7592 	return TEST_SUCCESS;
7593 }
7594 
7595 /* ***** AEAD algorithm Tests ***** */
7596 
7597 static int
7598 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7599 		enum rte_crypto_aead_operation op,
7600 		const uint8_t *key, const uint8_t key_len,
7601 		const uint16_t aad_len, const uint8_t auth_len,
7602 		uint8_t iv_len)
7603 {
7604 	uint8_t aead_key[key_len];
7605 
7606 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7607 	struct crypto_unittest_params *ut_params = &unittest_params;
7608 
7609 	memcpy(aead_key, key, key_len);
7610 
7611 	/* Setup AEAD Parameters */
7612 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7613 	ut_params->aead_xform.next = NULL;
7614 	ut_params->aead_xform.aead.algo = algo;
7615 	ut_params->aead_xform.aead.op = op;
7616 	ut_params->aead_xform.aead.key.data = aead_key;
7617 	ut_params->aead_xform.aead.key.length = key_len;
7618 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7619 	ut_params->aead_xform.aead.iv.length = iv_len;
7620 	ut_params->aead_xform.aead.digest_length = auth_len;
7621 	ut_params->aead_xform.aead.aad_length = aad_len;
7622 
7623 	debug_hexdump(stdout, "key:", key, key_len);
7624 
7625 	/* Create Crypto session*/
7626 	ut_params->sess = rte_cryptodev_sym_session_create(
7627 			ts_params->session_mpool);
7628 
7629 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7630 			&ut_params->aead_xform,
7631 			ts_params->session_priv_mpool);
7632 
7633 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7634 
7635 	return 0;
7636 }
7637 
7638 static int
7639 create_aead_xform(struct rte_crypto_op *op,
7640 		enum rte_crypto_aead_algorithm algo,
7641 		enum rte_crypto_aead_operation aead_op,
7642 		uint8_t *key, const uint8_t key_len,
7643 		const uint8_t aad_len, const uint8_t auth_len,
7644 		uint8_t iv_len)
7645 {
7646 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7647 			"failed to allocate space for crypto transform");
7648 
7649 	struct rte_crypto_sym_op *sym_op = op->sym;
7650 
7651 	/* Setup AEAD Parameters */
7652 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7653 	sym_op->xform->next = NULL;
7654 	sym_op->xform->aead.algo = algo;
7655 	sym_op->xform->aead.op = aead_op;
7656 	sym_op->xform->aead.key.data = key;
7657 	sym_op->xform->aead.key.length = key_len;
7658 	sym_op->xform->aead.iv.offset = IV_OFFSET;
7659 	sym_op->xform->aead.iv.length = iv_len;
7660 	sym_op->xform->aead.digest_length = auth_len;
7661 	sym_op->xform->aead.aad_length = aad_len;
7662 
7663 	debug_hexdump(stdout, "key:", key, key_len);
7664 
7665 	return 0;
7666 }
7667 
7668 static int
7669 create_aead_operation(enum rte_crypto_aead_operation op,
7670 		const struct aead_test_data *tdata)
7671 {
7672 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7673 	struct crypto_unittest_params *ut_params = &unittest_params;
7674 
7675 	uint8_t *plaintext, *ciphertext;
7676 	unsigned int aad_pad_len, plaintext_pad_len;
7677 
7678 	/* Generate Crypto op data structure */
7679 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7680 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7681 	TEST_ASSERT_NOT_NULL(ut_params->op,
7682 			"Failed to allocate symmetric crypto operation struct");
7683 
7684 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7685 
7686 	/* Append aad data */
7687 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7688 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7689 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7690 				aad_pad_len);
7691 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7692 				"no room to append aad");
7693 
7694 		sym_op->aead.aad.phys_addr =
7695 				rte_pktmbuf_iova(ut_params->ibuf);
7696 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
7697 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7698 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7699 			tdata->aad.len);
7700 
7701 		/* Append IV at the end of the crypto operation*/
7702 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7703 				uint8_t *, IV_OFFSET);
7704 
7705 		/* Copy IV 1 byte after the IV pointer, according to the API */
7706 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7707 		debug_hexdump(stdout, "iv:", iv_ptr,
7708 			tdata->iv.len);
7709 	} else {
7710 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7711 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7712 				aad_pad_len);
7713 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7714 				"no room to append aad");
7715 
7716 		sym_op->aead.aad.phys_addr =
7717 				rte_pktmbuf_iova(ut_params->ibuf);
7718 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7719 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7720 			tdata->aad.len);
7721 
7722 		/* Append IV at the end of the crypto operation*/
7723 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7724 				uint8_t *, IV_OFFSET);
7725 
7726 		rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7727 		debug_hexdump(stdout, "iv:", iv_ptr,
7728 			tdata->iv.len);
7729 	}
7730 
7731 	/* Append plaintext/ciphertext */
7732 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7733 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7734 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7735 				plaintext_pad_len);
7736 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7737 
7738 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7739 		debug_hexdump(stdout, "plaintext:", plaintext,
7740 				tdata->plaintext.len);
7741 
7742 		if (ut_params->obuf) {
7743 			ciphertext = (uint8_t *)rte_pktmbuf_append(
7744 					ut_params->obuf,
7745 					plaintext_pad_len + aad_pad_len);
7746 			TEST_ASSERT_NOT_NULL(ciphertext,
7747 					"no room to append ciphertext");
7748 
7749 			memset(ciphertext + aad_pad_len, 0,
7750 					tdata->ciphertext.len);
7751 		}
7752 	} else {
7753 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7754 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7755 				plaintext_pad_len);
7756 		TEST_ASSERT_NOT_NULL(ciphertext,
7757 				"no room to append ciphertext");
7758 
7759 		memcpy(ciphertext, tdata->ciphertext.data,
7760 				tdata->ciphertext.len);
7761 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7762 				tdata->ciphertext.len);
7763 
7764 		if (ut_params->obuf) {
7765 			plaintext = (uint8_t *)rte_pktmbuf_append(
7766 					ut_params->obuf,
7767 					plaintext_pad_len + aad_pad_len);
7768 			TEST_ASSERT_NOT_NULL(plaintext,
7769 					"no room to append plaintext");
7770 
7771 			memset(plaintext + aad_pad_len, 0,
7772 					tdata->plaintext.len);
7773 		}
7774 	}
7775 
7776 	/* Append digest data */
7777 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7778 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7779 				ut_params->obuf ? ut_params->obuf :
7780 						ut_params->ibuf,
7781 						tdata->auth_tag.len);
7782 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7783 				"no room to append digest");
7784 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7785 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7786 				ut_params->obuf ? ut_params->obuf :
7787 						ut_params->ibuf,
7788 						plaintext_pad_len +
7789 						aad_pad_len);
7790 	} else {
7791 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7792 				ut_params->ibuf, tdata->auth_tag.len);
7793 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7794 				"no room to append digest");
7795 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7796 				ut_params->ibuf,
7797 				plaintext_pad_len + aad_pad_len);
7798 
7799 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7800 			tdata->auth_tag.len);
7801 		debug_hexdump(stdout, "digest:",
7802 			sym_op->aead.digest.data,
7803 			tdata->auth_tag.len);
7804 	}
7805 
7806 	sym_op->aead.data.length = tdata->plaintext.len;
7807 	sym_op->aead.data.offset = aad_pad_len;
7808 
7809 	return 0;
7810 }
7811 
7812 static int
7813 test_authenticated_encryption(const struct aead_test_data *tdata)
7814 {
7815 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7816 	struct crypto_unittest_params *ut_params = &unittest_params;
7817 
7818 	int retval;
7819 	uint8_t *ciphertext, *auth_tag;
7820 	uint16_t plaintext_pad_len;
7821 	uint32_t i;
7822 
7823 	/* Create AEAD session */
7824 	retval = create_aead_session(ts_params->valid_devs[0],
7825 			tdata->algo,
7826 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
7827 			tdata->key.data, tdata->key.len,
7828 			tdata->aad.len, tdata->auth_tag.len,
7829 			tdata->iv.len);
7830 	if (retval < 0)
7831 		return retval;
7832 
7833 	if (tdata->aad.len > MBUF_SIZE) {
7834 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7835 		/* Populate full size of add data */
7836 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7837 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7838 	} else
7839 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7840 
7841 	/* clear mbuf payload */
7842 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7843 			rte_pktmbuf_tailroom(ut_params->ibuf));
7844 
7845 	/* Create AEAD operation */
7846 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7847 	if (retval < 0)
7848 		return retval;
7849 
7850 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7851 
7852 	ut_params->op->sym->m_src = ut_params->ibuf;
7853 
7854 	/* Process crypto operation */
7855 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7856 			ut_params->op), "failed to process sym crypto op");
7857 
7858 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7859 			"crypto op processing failed");
7860 
7861 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7862 
7863 	if (ut_params->op->sym->m_dst) {
7864 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7865 				uint8_t *);
7866 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7867 				uint8_t *, plaintext_pad_len);
7868 	} else {
7869 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7870 				uint8_t *,
7871 				ut_params->op->sym->cipher.data.offset);
7872 		auth_tag = ciphertext + plaintext_pad_len;
7873 	}
7874 
7875 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7876 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7877 
7878 	/* Validate obuf */
7879 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7880 			ciphertext,
7881 			tdata->ciphertext.data,
7882 			tdata->ciphertext.len,
7883 			"Ciphertext data not as expected");
7884 
7885 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7886 			auth_tag,
7887 			tdata->auth_tag.data,
7888 			tdata->auth_tag.len,
7889 			"Generated auth tag not as expected");
7890 
7891 	return 0;
7892 
7893 }
7894 
7895 #ifdef RTE_LIBRTE_SECURITY
7896 /* Basic algorithm run function for async inplace mode.
7897  * Creates a session from input parameters and runs one operation
7898  * on input_vec. Checks the output of the crypto operation against
7899  * output_vec.
7900  */
7901 static int
7902 test_pdcp_proto(int i, int oop,
7903 	enum rte_crypto_cipher_operation opc,
7904 	enum rte_crypto_auth_operation opa,
7905 	uint8_t *input_vec,
7906 	unsigned int input_vec_len,
7907 	uint8_t *output_vec,
7908 	unsigned int output_vec_len)
7909 {
7910 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7911 	struct crypto_unittest_params *ut_params = &unittest_params;
7912 	uint8_t *plaintext;
7913 	int ret = TEST_SUCCESS;
7914 
7915 	/* Generate test mbuf data */
7916 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7917 
7918 	/* clear mbuf payload */
7919 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7920 			rte_pktmbuf_tailroom(ut_params->ibuf));
7921 
7922 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7923 						  input_vec_len);
7924 	memcpy(plaintext, input_vec, input_vec_len);
7925 
7926 	/* Out of place support */
7927 	if (oop) {
7928 		/*
7929 		 * For out-op-place we need to alloc another mbuf
7930 		 */
7931 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7932 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7933 	}
7934 
7935 	/* Set crypto type as IPSEC */
7936 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7937 
7938 	/* Setup Cipher Parameters */
7939 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7940 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7941 	ut_params->cipher_xform.cipher.op = opc;
7942 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7943 	ut_params->cipher_xform.cipher.key.length =
7944 					pdcp_test_params[i].cipher_key_len;
7945 	ut_params->cipher_xform.cipher.iv.length = 0;
7946 
7947 	/* Setup HMAC Parameters if ICV header is required */
7948 	if (pdcp_test_params[i].auth_alg != 0) {
7949 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7950 		ut_params->auth_xform.next = NULL;
7951 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7952 		ut_params->auth_xform.auth.op = opa;
7953 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7954 		ut_params->auth_xform.auth.key.length =
7955 					pdcp_test_params[i].auth_key_len;
7956 
7957 		ut_params->cipher_xform.next = &ut_params->auth_xform;
7958 	} else {
7959 		ut_params->cipher_xform.next = NULL;
7960 	}
7961 
7962 	struct rte_security_session_conf sess_conf = {
7963 		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7964 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
7965 		{.pdcp = {
7966 			.bearer = pdcp_test_bearer[i],
7967 			.domain = pdcp_test_params[i].domain,
7968 			.pkt_dir = pdcp_test_packet_direction[i],
7969 			.sn_size = pdcp_test_data_sn_size[i],
7970 			.hfn = pdcp_test_hfn[i],
7971 			.hfn_threshold = pdcp_test_hfn_threshold[i],
7972 		} },
7973 		.crypto_xform = &ut_params->cipher_xform
7974 	};
7975 
7976 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7977 				rte_cryptodev_get_sec_ctx(
7978 				ts_params->valid_devs[0]);
7979 
7980 	/* Create security session */
7981 	ut_params->sec_session = rte_security_session_create(ctx,
7982 				&sess_conf, ts_params->session_priv_mpool);
7983 
7984 	if (!ut_params->sec_session) {
7985 		printf("TestCase %s()-%d line %d failed %s: ",
7986 			__func__, i, __LINE__, "Failed to allocate session");
7987 		ret = TEST_FAILED;
7988 		goto on_err;
7989 	}
7990 
7991 	/* Generate crypto op data structure */
7992 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7993 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7994 	if (!ut_params->op) {
7995 		printf("TestCase %s()-%d line %d failed %s: ",
7996 			__func__, i, __LINE__,
7997 			"Failed to allocate symmetric crypto operation struct");
7998 		ret = TEST_FAILED;
7999 		goto on_err;
8000 	}
8001 
8002 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8003 
8004 	/* set crypto operation source mbuf */
8005 	ut_params->op->sym->m_src = ut_params->ibuf;
8006 	if (oop)
8007 		ut_params->op->sym->m_dst = ut_params->obuf;
8008 
8009 	/* Process crypto operation */
8010 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8011 		== NULL) {
8012 		printf("TestCase %s()-%d line %d failed %s: ",
8013 			__func__, i, __LINE__,
8014 			"failed to process sym crypto op");
8015 		ret = TEST_FAILED;
8016 		goto on_err;
8017 	}
8018 
8019 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8020 		printf("TestCase %s()-%d line %d failed %s: ",
8021 			__func__, i, __LINE__, "crypto op processing failed");
8022 		ret = TEST_FAILED;
8023 		goto on_err;
8024 	}
8025 
8026 	/* Validate obuf */
8027 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8028 			uint8_t *);
8029 	if (oop) {
8030 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8031 				uint8_t *);
8032 	}
8033 
8034 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
8035 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8036 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8037 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8038 		ret = TEST_FAILED;
8039 		goto on_err;
8040 	}
8041 
8042 on_err:
8043 	rte_crypto_op_free(ut_params->op);
8044 	ut_params->op = NULL;
8045 
8046 	if (ut_params->sec_session)
8047 		rte_security_session_destroy(ctx, ut_params->sec_session);
8048 	ut_params->sec_session = NULL;
8049 
8050 	rte_pktmbuf_free(ut_params->ibuf);
8051 	ut_params->ibuf = NULL;
8052 	if (oop) {
8053 		rte_pktmbuf_free(ut_params->obuf);
8054 		ut_params->obuf = NULL;
8055 	}
8056 
8057 	return ret;
8058 }
8059 
8060 static int
8061 test_pdcp_proto_SGL(int i, int oop,
8062 	enum rte_crypto_cipher_operation opc,
8063 	enum rte_crypto_auth_operation opa,
8064 	uint8_t *input_vec,
8065 	unsigned int input_vec_len,
8066 	uint8_t *output_vec,
8067 	unsigned int output_vec_len,
8068 	uint32_t fragsz,
8069 	uint32_t fragsz_oop)
8070 {
8071 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8072 	struct crypto_unittest_params *ut_params = &unittest_params;
8073 	uint8_t *plaintext;
8074 	struct rte_mbuf *buf, *buf_oop = NULL;
8075 	int ret = TEST_SUCCESS;
8076 	int to_trn = 0;
8077 	int to_trn_tbl[16];
8078 	int segs = 1;
8079 	unsigned int trn_data = 0;
8080 
8081 	if (fragsz > input_vec_len)
8082 		fragsz = input_vec_len;
8083 
8084 	uint16_t plaintext_len = fragsz;
8085 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8086 
8087 	if (fragsz_oop > output_vec_len)
8088 		frag_size_oop = output_vec_len;
8089 
8090 	int ecx = 0;
8091 	if (input_vec_len % fragsz != 0) {
8092 		if (input_vec_len / fragsz + 1 > 16)
8093 			return 1;
8094 	} else if (input_vec_len / fragsz > 16)
8095 		return 1;
8096 
8097 	/* Out of place support */
8098 	if (oop) {
8099 		/*
8100 		 * For out-op-place we need to alloc another mbuf
8101 		 */
8102 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8103 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8104 		buf_oop = ut_params->obuf;
8105 	}
8106 
8107 	/* Generate test mbuf data */
8108 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8109 
8110 	/* clear mbuf payload */
8111 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8112 			rte_pktmbuf_tailroom(ut_params->ibuf));
8113 
8114 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8115 						  plaintext_len);
8116 	memcpy(plaintext, input_vec, plaintext_len);
8117 	trn_data += plaintext_len;
8118 
8119 	buf = ut_params->ibuf;
8120 
8121 	/*
8122 	 * Loop until no more fragments
8123 	 */
8124 
8125 	while (trn_data < input_vec_len) {
8126 		++segs;
8127 		to_trn = (input_vec_len - trn_data < fragsz) ?
8128 				(input_vec_len - trn_data) : fragsz;
8129 
8130 		to_trn_tbl[ecx++] = to_trn;
8131 
8132 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8133 		buf = buf->next;
8134 
8135 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8136 				rte_pktmbuf_tailroom(buf));
8137 
8138 		/* OOP */
8139 		if (oop && !fragsz_oop) {
8140 			buf_oop->next =
8141 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
8142 			buf_oop = buf_oop->next;
8143 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8144 					0, rte_pktmbuf_tailroom(buf_oop));
8145 			rte_pktmbuf_append(buf_oop, to_trn);
8146 		}
8147 
8148 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8149 				to_trn);
8150 
8151 		memcpy(plaintext, input_vec + trn_data, to_trn);
8152 		trn_data += to_trn;
8153 	}
8154 
8155 	ut_params->ibuf->nb_segs = segs;
8156 
8157 	segs = 1;
8158 	if (fragsz_oop && oop) {
8159 		to_trn = 0;
8160 		ecx = 0;
8161 
8162 		trn_data = frag_size_oop;
8163 		while (trn_data < output_vec_len) {
8164 			++segs;
8165 			to_trn =
8166 				(output_vec_len - trn_data <
8167 						frag_size_oop) ?
8168 				(output_vec_len - trn_data) :
8169 						frag_size_oop;
8170 
8171 			to_trn_tbl[ecx++] = to_trn;
8172 
8173 			buf_oop->next =
8174 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
8175 			buf_oop = buf_oop->next;
8176 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8177 					0, rte_pktmbuf_tailroom(buf_oop));
8178 			rte_pktmbuf_append(buf_oop, to_trn);
8179 
8180 			trn_data += to_trn;
8181 		}
8182 		ut_params->obuf->nb_segs = segs;
8183 	}
8184 
8185 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8186 
8187 	/* Setup Cipher Parameters */
8188 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8189 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8190 	ut_params->cipher_xform.cipher.op = opc;
8191 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8192 	ut_params->cipher_xform.cipher.key.length =
8193 					pdcp_test_params[i].cipher_key_len;
8194 	ut_params->cipher_xform.cipher.iv.length = 0;
8195 
8196 	/* Setup HMAC Parameters if ICV header is required */
8197 	if (pdcp_test_params[i].auth_alg != 0) {
8198 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8199 		ut_params->auth_xform.next = NULL;
8200 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8201 		ut_params->auth_xform.auth.op = opa;
8202 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8203 		ut_params->auth_xform.auth.key.length =
8204 					pdcp_test_params[i].auth_key_len;
8205 
8206 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8207 	} else {
8208 		ut_params->cipher_xform.next = NULL;
8209 	}
8210 
8211 	struct rte_security_session_conf sess_conf = {
8212 		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
8213 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8214 		{.pdcp = {
8215 			.bearer = pdcp_test_bearer[i],
8216 			.domain = pdcp_test_params[i].domain,
8217 			.pkt_dir = pdcp_test_packet_direction[i],
8218 			.sn_size = pdcp_test_data_sn_size[i],
8219 			.hfn = pdcp_test_hfn[i],
8220 			.hfn_threshold = pdcp_test_hfn_threshold[i],
8221 		} },
8222 		.crypto_xform = &ut_params->cipher_xform
8223 	};
8224 
8225 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8226 				rte_cryptodev_get_sec_ctx(
8227 				ts_params->valid_devs[0]);
8228 
8229 	/* Create security session */
8230 	ut_params->sec_session = rte_security_session_create(ctx,
8231 				&sess_conf, ts_params->session_priv_mpool);
8232 
8233 	if (!ut_params->sec_session) {
8234 		printf("TestCase %s()-%d line %d failed %s: ",
8235 			__func__, i, __LINE__, "Failed to allocate session");
8236 		ret = TEST_FAILED;
8237 		goto on_err;
8238 	}
8239 
8240 	/* Generate crypto op data structure */
8241 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8242 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8243 	if (!ut_params->op) {
8244 		printf("TestCase %s()-%d line %d failed %s: ",
8245 			__func__, i, __LINE__,
8246 			"Failed to allocate symmetric crypto operation struct");
8247 		ret = TEST_FAILED;
8248 		goto on_err;
8249 	}
8250 
8251 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8252 
8253 	/* set crypto operation source mbuf */
8254 	ut_params->op->sym->m_src = ut_params->ibuf;
8255 	if (oop)
8256 		ut_params->op->sym->m_dst = ut_params->obuf;
8257 
8258 	/* Process crypto operation */
8259 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8260 		== NULL) {
8261 		printf("TestCase %s()-%d line %d failed %s: ",
8262 			__func__, i, __LINE__,
8263 			"failed to process sym crypto op");
8264 		ret = TEST_FAILED;
8265 		goto on_err;
8266 	}
8267 
8268 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8269 		printf("TestCase %s()-%d line %d failed %s: ",
8270 			__func__, i, __LINE__, "crypto op processing failed");
8271 		ret = TEST_FAILED;
8272 		goto on_err;
8273 	}
8274 
8275 	/* Validate obuf */
8276 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8277 			uint8_t *);
8278 	if (oop) {
8279 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8280 				uint8_t *);
8281 	}
8282 	if (fragsz_oop)
8283 		fragsz = frag_size_oop;
8284 	if (memcmp(ciphertext, output_vec, fragsz)) {
8285 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8286 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8287 		rte_hexdump(stdout, "reference", output_vec, fragsz);
8288 		ret = TEST_FAILED;
8289 		goto on_err;
8290 	}
8291 
8292 	buf = ut_params->op->sym->m_src->next;
8293 	if (oop)
8294 		buf = ut_params->op->sym->m_dst->next;
8295 
8296 	unsigned int off = fragsz;
8297 
8298 	ecx = 0;
8299 	while (buf) {
8300 		ciphertext = rte_pktmbuf_mtod(buf,
8301 				uint8_t *);
8302 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8303 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8304 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8305 			rte_hexdump(stdout, "reference", output_vec + off,
8306 					to_trn_tbl[ecx]);
8307 			ret = TEST_FAILED;
8308 			goto on_err;
8309 		}
8310 		off += to_trn_tbl[ecx++];
8311 		buf = buf->next;
8312 	}
8313 on_err:
8314 	rte_crypto_op_free(ut_params->op);
8315 	ut_params->op = NULL;
8316 
8317 	if (ut_params->sec_session)
8318 		rte_security_session_destroy(ctx, ut_params->sec_session);
8319 	ut_params->sec_session = NULL;
8320 
8321 	rte_pktmbuf_free(ut_params->ibuf);
8322 	ut_params->ibuf = NULL;
8323 	if (oop) {
8324 		rte_pktmbuf_free(ut_params->obuf);
8325 		ut_params->obuf = NULL;
8326 	}
8327 
8328 	return ret;
8329 }
8330 
8331 int
8332 test_pdcp_proto_cplane_encap(int i)
8333 {
8334 	return test_pdcp_proto(i, 0,
8335 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8336 		RTE_CRYPTO_AUTH_OP_GENERATE,
8337 		pdcp_test_data_in[i],
8338 		pdcp_test_data_in_len[i],
8339 		pdcp_test_data_out[i],
8340 		pdcp_test_data_in_len[i]+4);
8341 }
8342 
8343 int
8344 test_pdcp_proto_uplane_encap(int i)
8345 {
8346 	return test_pdcp_proto(i, 0,
8347 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8348 		RTE_CRYPTO_AUTH_OP_GENERATE,
8349 		pdcp_test_data_in[i],
8350 		pdcp_test_data_in_len[i],
8351 		pdcp_test_data_out[i],
8352 		pdcp_test_data_in_len[i]);
8353 
8354 }
8355 
8356 int
8357 test_pdcp_proto_uplane_encap_with_int(int i)
8358 {
8359 	return test_pdcp_proto(i, 0,
8360 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8361 		RTE_CRYPTO_AUTH_OP_GENERATE,
8362 		pdcp_test_data_in[i],
8363 		pdcp_test_data_in_len[i],
8364 		pdcp_test_data_out[i],
8365 		pdcp_test_data_in_len[i] + 4);
8366 }
8367 
8368 int
8369 test_pdcp_proto_cplane_decap(int i)
8370 {
8371 	return test_pdcp_proto(i, 0,
8372 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8373 		RTE_CRYPTO_AUTH_OP_VERIFY,
8374 		pdcp_test_data_out[i],
8375 		pdcp_test_data_in_len[i] + 4,
8376 		pdcp_test_data_in[i],
8377 		pdcp_test_data_in_len[i]);
8378 }
8379 
8380 int
8381 test_pdcp_proto_uplane_decap(int i)
8382 {
8383 	return test_pdcp_proto(i, 0,
8384 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8385 		RTE_CRYPTO_AUTH_OP_VERIFY,
8386 		pdcp_test_data_out[i],
8387 		pdcp_test_data_in_len[i],
8388 		pdcp_test_data_in[i],
8389 		pdcp_test_data_in_len[i]);
8390 }
8391 
8392 int
8393 test_pdcp_proto_uplane_decap_with_int(int i)
8394 {
8395 	return test_pdcp_proto(i, 0,
8396 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8397 		RTE_CRYPTO_AUTH_OP_VERIFY,
8398 		pdcp_test_data_out[i],
8399 		pdcp_test_data_in_len[i] + 4,
8400 		pdcp_test_data_in[i],
8401 		pdcp_test_data_in_len[i]);
8402 }
8403 
8404 static int
8405 test_PDCP_PROTO_SGL_in_place_32B(void)
8406 {
8407 	/* i can be used for running any PDCP case
8408 	 * In this case it is uplane 12-bit AES-SNOW DL encap
8409 	 */
8410 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8411 	return test_pdcp_proto_SGL(i, IN_PLACE,
8412 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8413 			RTE_CRYPTO_AUTH_OP_GENERATE,
8414 			pdcp_test_data_in[i],
8415 			pdcp_test_data_in_len[i],
8416 			pdcp_test_data_out[i],
8417 			pdcp_test_data_in_len[i]+4,
8418 			32, 0);
8419 }
8420 static int
8421 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8422 {
8423 	/* i can be used for running any PDCP case
8424 	 * In this case it is uplane 18-bit NULL-NULL DL encap
8425 	 */
8426 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8427 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8428 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8429 			RTE_CRYPTO_AUTH_OP_GENERATE,
8430 			pdcp_test_data_in[i],
8431 			pdcp_test_data_in_len[i],
8432 			pdcp_test_data_out[i],
8433 			pdcp_test_data_in_len[i]+4,
8434 			32, 128);
8435 }
8436 static int
8437 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8438 {
8439 	/* i can be used for running any PDCP case
8440 	 * In this case it is uplane 18-bit AES DL encap
8441 	 */
8442 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8443 			+ DOWNLINK;
8444 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8445 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8446 			RTE_CRYPTO_AUTH_OP_GENERATE,
8447 			pdcp_test_data_in[i],
8448 			pdcp_test_data_in_len[i],
8449 			pdcp_test_data_out[i],
8450 			pdcp_test_data_in_len[i],
8451 			32, 40);
8452 }
8453 static int
8454 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8455 {
8456 	/* i can be used for running any PDCP case
8457 	 * In this case it is cplane 12-bit AES-ZUC DL encap
8458 	 */
8459 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8460 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8461 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8462 			RTE_CRYPTO_AUTH_OP_GENERATE,
8463 			pdcp_test_data_in[i],
8464 			pdcp_test_data_in_len[i],
8465 			pdcp_test_data_out[i],
8466 			pdcp_test_data_in_len[i]+4,
8467 			128, 32);
8468 }
8469 #endif
8470 
8471 static int
8472 test_AES_GCM_authenticated_encryption_test_case_1(void)
8473 {
8474 	return test_authenticated_encryption(&gcm_test_case_1);
8475 }
8476 
8477 static int
8478 test_AES_GCM_authenticated_encryption_test_case_2(void)
8479 {
8480 	return test_authenticated_encryption(&gcm_test_case_2);
8481 }
8482 
8483 static int
8484 test_AES_GCM_authenticated_encryption_test_case_3(void)
8485 {
8486 	return test_authenticated_encryption(&gcm_test_case_3);
8487 }
8488 
8489 static int
8490 test_AES_GCM_authenticated_encryption_test_case_4(void)
8491 {
8492 	return test_authenticated_encryption(&gcm_test_case_4);
8493 }
8494 
8495 static int
8496 test_AES_GCM_authenticated_encryption_test_case_5(void)
8497 {
8498 	return test_authenticated_encryption(&gcm_test_case_5);
8499 }
8500 
8501 static int
8502 test_AES_GCM_authenticated_encryption_test_case_6(void)
8503 {
8504 	return test_authenticated_encryption(&gcm_test_case_6);
8505 }
8506 
8507 static int
8508 test_AES_GCM_authenticated_encryption_test_case_7(void)
8509 {
8510 	return test_authenticated_encryption(&gcm_test_case_7);
8511 }
8512 
8513 static int
8514 test_AES_GCM_authenticated_encryption_test_case_8(void)
8515 {
8516 	return test_authenticated_encryption(&gcm_test_case_8);
8517 }
8518 
8519 static int
8520 test_AES_GCM_auth_encryption_test_case_192_1(void)
8521 {
8522 	return test_authenticated_encryption(&gcm_test_case_192_1);
8523 }
8524 
8525 static int
8526 test_AES_GCM_auth_encryption_test_case_192_2(void)
8527 {
8528 	return test_authenticated_encryption(&gcm_test_case_192_2);
8529 }
8530 
8531 static int
8532 test_AES_GCM_auth_encryption_test_case_192_3(void)
8533 {
8534 	return test_authenticated_encryption(&gcm_test_case_192_3);
8535 }
8536 
8537 static int
8538 test_AES_GCM_auth_encryption_test_case_192_4(void)
8539 {
8540 	return test_authenticated_encryption(&gcm_test_case_192_4);
8541 }
8542 
8543 static int
8544 test_AES_GCM_auth_encryption_test_case_192_5(void)
8545 {
8546 	return test_authenticated_encryption(&gcm_test_case_192_5);
8547 }
8548 
8549 static int
8550 test_AES_GCM_auth_encryption_test_case_192_6(void)
8551 {
8552 	return test_authenticated_encryption(&gcm_test_case_192_6);
8553 }
8554 
8555 static int
8556 test_AES_GCM_auth_encryption_test_case_192_7(void)
8557 {
8558 	return test_authenticated_encryption(&gcm_test_case_192_7);
8559 }
8560 
8561 static int
8562 test_AES_GCM_auth_encryption_test_case_256_1(void)
8563 {
8564 	return test_authenticated_encryption(&gcm_test_case_256_1);
8565 }
8566 
8567 static int
8568 test_AES_GCM_auth_encryption_test_case_256_2(void)
8569 {
8570 	return test_authenticated_encryption(&gcm_test_case_256_2);
8571 }
8572 
8573 static int
8574 test_AES_GCM_auth_encryption_test_case_256_3(void)
8575 {
8576 	return test_authenticated_encryption(&gcm_test_case_256_3);
8577 }
8578 
8579 static int
8580 test_AES_GCM_auth_encryption_test_case_256_4(void)
8581 {
8582 	return test_authenticated_encryption(&gcm_test_case_256_4);
8583 }
8584 
8585 static int
8586 test_AES_GCM_auth_encryption_test_case_256_5(void)
8587 {
8588 	return test_authenticated_encryption(&gcm_test_case_256_5);
8589 }
8590 
8591 static int
8592 test_AES_GCM_auth_encryption_test_case_256_6(void)
8593 {
8594 	return test_authenticated_encryption(&gcm_test_case_256_6);
8595 }
8596 
8597 static int
8598 test_AES_GCM_auth_encryption_test_case_256_7(void)
8599 {
8600 	return test_authenticated_encryption(&gcm_test_case_256_7);
8601 }
8602 
8603 static int
8604 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8605 {
8606 	return test_authenticated_encryption(&gcm_test_case_aad_1);
8607 }
8608 
8609 static int
8610 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8611 {
8612 	return test_authenticated_encryption(&gcm_test_case_aad_2);
8613 }
8614 
8615 static int
8616 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8617 {
8618 	struct aead_test_data tdata;
8619 	int res;
8620 
8621 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8622 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8623 	tdata.iv.data[0] += 1;
8624 	res = test_authenticated_encryption(&tdata);
8625 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8626 	return TEST_SUCCESS;
8627 }
8628 
8629 static int
8630 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8631 {
8632 	struct aead_test_data tdata;
8633 	int res;
8634 
8635 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8636 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8637 	tdata.plaintext.data[0] += 1;
8638 	res = test_authenticated_encryption(&tdata);
8639 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8640 	return TEST_SUCCESS;
8641 }
8642 
8643 static int
8644 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8645 {
8646 	struct aead_test_data tdata;
8647 	int res;
8648 
8649 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8650 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8651 	tdata.ciphertext.data[0] += 1;
8652 	res = test_authenticated_encryption(&tdata);
8653 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8654 	return TEST_SUCCESS;
8655 }
8656 
8657 static int
8658 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8659 {
8660 	struct aead_test_data tdata;
8661 	int res;
8662 
8663 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8664 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8665 	tdata.aad.len += 1;
8666 	res = test_authenticated_encryption(&tdata);
8667 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8668 	return TEST_SUCCESS;
8669 }
8670 
8671 static int
8672 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8673 {
8674 	struct aead_test_data tdata;
8675 	uint8_t aad[gcm_test_case_7.aad.len];
8676 	int res;
8677 
8678 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8679 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8680 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8681 	aad[0] += 1;
8682 	tdata.aad.data = aad;
8683 	res = test_authenticated_encryption(&tdata);
8684 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8685 	return TEST_SUCCESS;
8686 }
8687 
8688 static int
8689 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8690 {
8691 	struct aead_test_data tdata;
8692 	int res;
8693 
8694 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8695 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8696 	tdata.auth_tag.data[0] += 1;
8697 	res = test_authenticated_encryption(&tdata);
8698 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8699 	return TEST_SUCCESS;
8700 }
8701 
8702 static int
8703 test_authenticated_decryption(const struct aead_test_data *tdata)
8704 {
8705 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8706 	struct crypto_unittest_params *ut_params = &unittest_params;
8707 
8708 	int retval;
8709 	uint8_t *plaintext;
8710 	uint32_t i;
8711 
8712 	/* Create AEAD session */
8713 	retval = create_aead_session(ts_params->valid_devs[0],
8714 			tdata->algo,
8715 			RTE_CRYPTO_AEAD_OP_DECRYPT,
8716 			tdata->key.data, tdata->key.len,
8717 			tdata->aad.len, tdata->auth_tag.len,
8718 			tdata->iv.len);
8719 	if (retval < 0)
8720 		return retval;
8721 
8722 	/* alloc mbuf and set payload */
8723 	if (tdata->aad.len > MBUF_SIZE) {
8724 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8725 		/* Populate full size of add data */
8726 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8727 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8728 	} else
8729 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8730 
8731 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8732 			rte_pktmbuf_tailroom(ut_params->ibuf));
8733 
8734 	/* Create AEAD operation */
8735 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8736 	if (retval < 0)
8737 		return retval;
8738 
8739 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8740 
8741 	ut_params->op->sym->m_src = ut_params->ibuf;
8742 
8743 	/* Process crypto operation */
8744 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8745 			ut_params->op), "failed to process sym crypto op");
8746 
8747 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8748 			"crypto op processing failed");
8749 
8750 	if (ut_params->op->sym->m_dst)
8751 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8752 				uint8_t *);
8753 	else
8754 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8755 				uint8_t *,
8756 				ut_params->op->sym->cipher.data.offset);
8757 
8758 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8759 
8760 	/* Validate obuf */
8761 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8762 			plaintext,
8763 			tdata->plaintext.data,
8764 			tdata->plaintext.len,
8765 			"Plaintext data not as expected");
8766 
8767 	TEST_ASSERT_EQUAL(ut_params->op->status,
8768 			RTE_CRYPTO_OP_STATUS_SUCCESS,
8769 			"Authentication failed");
8770 
8771 	return 0;
8772 }
8773 
8774 static int
8775 test_AES_GCM_authenticated_decryption_test_case_1(void)
8776 {
8777 	return test_authenticated_decryption(&gcm_test_case_1);
8778 }
8779 
8780 static int
8781 test_AES_GCM_authenticated_decryption_test_case_2(void)
8782 {
8783 	return test_authenticated_decryption(&gcm_test_case_2);
8784 }
8785 
8786 static int
8787 test_AES_GCM_authenticated_decryption_test_case_3(void)
8788 {
8789 	return test_authenticated_decryption(&gcm_test_case_3);
8790 }
8791 
8792 static int
8793 test_AES_GCM_authenticated_decryption_test_case_4(void)
8794 {
8795 	return test_authenticated_decryption(&gcm_test_case_4);
8796 }
8797 
8798 static int
8799 test_AES_GCM_authenticated_decryption_test_case_5(void)
8800 {
8801 	return test_authenticated_decryption(&gcm_test_case_5);
8802 }
8803 
8804 static int
8805 test_AES_GCM_authenticated_decryption_test_case_6(void)
8806 {
8807 	return test_authenticated_decryption(&gcm_test_case_6);
8808 }
8809 
8810 static int
8811 test_AES_GCM_authenticated_decryption_test_case_7(void)
8812 {
8813 	return test_authenticated_decryption(&gcm_test_case_7);
8814 }
8815 
8816 static int
8817 test_AES_GCM_authenticated_decryption_test_case_8(void)
8818 {
8819 	return test_authenticated_decryption(&gcm_test_case_8);
8820 }
8821 
8822 static int
8823 test_AES_GCM_auth_decryption_test_case_192_1(void)
8824 {
8825 	return test_authenticated_decryption(&gcm_test_case_192_1);
8826 }
8827 
8828 static int
8829 test_AES_GCM_auth_decryption_test_case_192_2(void)
8830 {
8831 	return test_authenticated_decryption(&gcm_test_case_192_2);
8832 }
8833 
8834 static int
8835 test_AES_GCM_auth_decryption_test_case_192_3(void)
8836 {
8837 	return test_authenticated_decryption(&gcm_test_case_192_3);
8838 }
8839 
8840 static int
8841 test_AES_GCM_auth_decryption_test_case_192_4(void)
8842 {
8843 	return test_authenticated_decryption(&gcm_test_case_192_4);
8844 }
8845 
8846 static int
8847 test_AES_GCM_auth_decryption_test_case_192_5(void)
8848 {
8849 	return test_authenticated_decryption(&gcm_test_case_192_5);
8850 }
8851 
8852 static int
8853 test_AES_GCM_auth_decryption_test_case_192_6(void)
8854 {
8855 	return test_authenticated_decryption(&gcm_test_case_192_6);
8856 }
8857 
8858 static int
8859 test_AES_GCM_auth_decryption_test_case_192_7(void)
8860 {
8861 	return test_authenticated_decryption(&gcm_test_case_192_7);
8862 }
8863 
8864 static int
8865 test_AES_GCM_auth_decryption_test_case_256_1(void)
8866 {
8867 	return test_authenticated_decryption(&gcm_test_case_256_1);
8868 }
8869 
8870 static int
8871 test_AES_GCM_auth_decryption_test_case_256_2(void)
8872 {
8873 	return test_authenticated_decryption(&gcm_test_case_256_2);
8874 }
8875 
8876 static int
8877 test_AES_GCM_auth_decryption_test_case_256_3(void)
8878 {
8879 	return test_authenticated_decryption(&gcm_test_case_256_3);
8880 }
8881 
8882 static int
8883 test_AES_GCM_auth_decryption_test_case_256_4(void)
8884 {
8885 	return test_authenticated_decryption(&gcm_test_case_256_4);
8886 }
8887 
8888 static int
8889 test_AES_GCM_auth_decryption_test_case_256_5(void)
8890 {
8891 	return test_authenticated_decryption(&gcm_test_case_256_5);
8892 }
8893 
8894 static int
8895 test_AES_GCM_auth_decryption_test_case_256_6(void)
8896 {
8897 	return test_authenticated_decryption(&gcm_test_case_256_6);
8898 }
8899 
8900 static int
8901 test_AES_GCM_auth_decryption_test_case_256_7(void)
8902 {
8903 	return test_authenticated_decryption(&gcm_test_case_256_7);
8904 }
8905 
8906 static int
8907 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8908 {
8909 	return test_authenticated_decryption(&gcm_test_case_aad_1);
8910 }
8911 
8912 static int
8913 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8914 {
8915 	return test_authenticated_decryption(&gcm_test_case_aad_2);
8916 }
8917 
8918 static int
8919 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8920 {
8921 	struct aead_test_data tdata;
8922 	int res;
8923 
8924 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8925 	tdata.iv.data[0] += 1;
8926 	res = test_authenticated_decryption(&tdata);
8927 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8928 	return TEST_SUCCESS;
8929 }
8930 
8931 static int
8932 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8933 {
8934 	struct aead_test_data tdata;
8935 	int res;
8936 
8937 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8938 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8939 	tdata.plaintext.data[0] += 1;
8940 	res = test_authenticated_decryption(&tdata);
8941 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8942 	return TEST_SUCCESS;
8943 }
8944 
8945 static int
8946 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8947 {
8948 	struct aead_test_data tdata;
8949 	int res;
8950 
8951 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8952 	tdata.ciphertext.data[0] += 1;
8953 	res = test_authenticated_decryption(&tdata);
8954 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8955 	return TEST_SUCCESS;
8956 }
8957 
8958 static int
8959 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8960 {
8961 	struct aead_test_data tdata;
8962 	int res;
8963 
8964 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8965 	tdata.aad.len += 1;
8966 	res = test_authenticated_decryption(&tdata);
8967 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8968 	return TEST_SUCCESS;
8969 }
8970 
8971 static int
8972 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8973 {
8974 	struct aead_test_data tdata;
8975 	uint8_t aad[gcm_test_case_7.aad.len];
8976 	int res;
8977 
8978 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8979 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8980 	aad[0] += 1;
8981 	tdata.aad.data = aad;
8982 	res = test_authenticated_decryption(&tdata);
8983 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8984 	return TEST_SUCCESS;
8985 }
8986 
8987 static int
8988 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8989 {
8990 	struct aead_test_data tdata;
8991 	int res;
8992 
8993 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8994 	tdata.auth_tag.data[0] += 1;
8995 	res = test_authenticated_decryption(&tdata);
8996 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8997 	return TEST_SUCCESS;
8998 }
8999 
9000 static int
9001 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9002 {
9003 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9004 	struct crypto_unittest_params *ut_params = &unittest_params;
9005 
9006 	int retval;
9007 	uint8_t *ciphertext, *auth_tag;
9008 	uint16_t plaintext_pad_len;
9009 
9010 	/* Create AEAD session */
9011 	retval = create_aead_session(ts_params->valid_devs[0],
9012 			tdata->algo,
9013 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9014 			tdata->key.data, tdata->key.len,
9015 			tdata->aad.len, tdata->auth_tag.len,
9016 			tdata->iv.len);
9017 	if (retval < 0)
9018 		return retval;
9019 
9020 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9021 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9022 
9023 	/* clear mbuf payload */
9024 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9025 			rte_pktmbuf_tailroom(ut_params->ibuf));
9026 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9027 			rte_pktmbuf_tailroom(ut_params->obuf));
9028 
9029 	/* Create AEAD operation */
9030 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9031 	if (retval < 0)
9032 		return retval;
9033 
9034 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9035 
9036 	ut_params->op->sym->m_src = ut_params->ibuf;
9037 	ut_params->op->sym->m_dst = ut_params->obuf;
9038 
9039 	/* Process crypto operation */
9040 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9041 			ut_params->op), "failed to process sym crypto op");
9042 
9043 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9044 			"crypto op processing failed");
9045 
9046 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9047 
9048 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9049 			ut_params->op->sym->cipher.data.offset);
9050 	auth_tag = ciphertext + plaintext_pad_len;
9051 
9052 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9053 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9054 
9055 	/* Validate obuf */
9056 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9057 			ciphertext,
9058 			tdata->ciphertext.data,
9059 			tdata->ciphertext.len,
9060 			"Ciphertext data not as expected");
9061 
9062 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9063 			auth_tag,
9064 			tdata->auth_tag.data,
9065 			tdata->auth_tag.len,
9066 			"Generated auth tag not as expected");
9067 
9068 	return 0;
9069 
9070 }
9071 
9072 static int
9073 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9074 {
9075 	return test_authenticated_encryption_oop(&gcm_test_case_5);
9076 }
9077 
9078 static int
9079 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9080 {
9081 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9082 	struct crypto_unittest_params *ut_params = &unittest_params;
9083 
9084 	int retval;
9085 	uint8_t *plaintext;
9086 
9087 	/* Create AEAD session */
9088 	retval = create_aead_session(ts_params->valid_devs[0],
9089 			tdata->algo,
9090 			RTE_CRYPTO_AEAD_OP_DECRYPT,
9091 			tdata->key.data, tdata->key.len,
9092 			tdata->aad.len, tdata->auth_tag.len,
9093 			tdata->iv.len);
9094 	if (retval < 0)
9095 		return retval;
9096 
9097 	/* alloc mbuf and set payload */
9098 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9099 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9100 
9101 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9102 			rte_pktmbuf_tailroom(ut_params->ibuf));
9103 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9104 			rte_pktmbuf_tailroom(ut_params->obuf));
9105 
9106 	/* Create AEAD operation */
9107 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9108 	if (retval < 0)
9109 		return retval;
9110 
9111 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9112 
9113 	ut_params->op->sym->m_src = ut_params->ibuf;
9114 	ut_params->op->sym->m_dst = ut_params->obuf;
9115 
9116 	/* Process crypto operation */
9117 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9118 			ut_params->op), "failed to process sym crypto op");
9119 
9120 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9121 			"crypto op processing failed");
9122 
9123 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9124 			ut_params->op->sym->cipher.data.offset);
9125 
9126 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9127 
9128 	/* Validate obuf */
9129 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9130 			plaintext,
9131 			tdata->plaintext.data,
9132 			tdata->plaintext.len,
9133 			"Plaintext data not as expected");
9134 
9135 	TEST_ASSERT_EQUAL(ut_params->op->status,
9136 			RTE_CRYPTO_OP_STATUS_SUCCESS,
9137 			"Authentication failed");
9138 	return 0;
9139 }
9140 
9141 static int
9142 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9143 {
9144 	return test_authenticated_decryption_oop(&gcm_test_case_5);
9145 }
9146 
9147 static int
9148 test_authenticated_encryption_sessionless(
9149 		const struct aead_test_data *tdata)
9150 {
9151 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9152 	struct crypto_unittest_params *ut_params = &unittest_params;
9153 
9154 	int retval;
9155 	uint8_t *ciphertext, *auth_tag;
9156 	uint16_t plaintext_pad_len;
9157 	uint8_t key[tdata->key.len + 1];
9158 
9159 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9160 
9161 	/* clear mbuf payload */
9162 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9163 			rte_pktmbuf_tailroom(ut_params->ibuf));
9164 
9165 	/* Create AEAD operation */
9166 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9167 	if (retval < 0)
9168 		return retval;
9169 
9170 	/* Create GCM xform */
9171 	memcpy(key, tdata->key.data, tdata->key.len);
9172 	retval = create_aead_xform(ut_params->op,
9173 			tdata->algo,
9174 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9175 			key, tdata->key.len,
9176 			tdata->aad.len, tdata->auth_tag.len,
9177 			tdata->iv.len);
9178 	if (retval < 0)
9179 		return retval;
9180 
9181 	ut_params->op->sym->m_src = ut_params->ibuf;
9182 
9183 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9184 			RTE_CRYPTO_OP_SESSIONLESS,
9185 			"crypto op session type not sessionless");
9186 
9187 	/* Process crypto operation */
9188 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9189 			ut_params->op), "failed to process sym crypto op");
9190 
9191 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9192 
9193 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9194 			"crypto op status not success");
9195 
9196 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9197 
9198 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9199 			ut_params->op->sym->cipher.data.offset);
9200 	auth_tag = ciphertext + plaintext_pad_len;
9201 
9202 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9203 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9204 
9205 	/* Validate obuf */
9206 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9207 			ciphertext,
9208 			tdata->ciphertext.data,
9209 			tdata->ciphertext.len,
9210 			"Ciphertext data not as expected");
9211 
9212 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9213 			auth_tag,
9214 			tdata->auth_tag.data,
9215 			tdata->auth_tag.len,
9216 			"Generated auth tag not as expected");
9217 
9218 	return 0;
9219 
9220 }
9221 
9222 static int
9223 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9224 {
9225 	return test_authenticated_encryption_sessionless(
9226 			&gcm_test_case_5);
9227 }
9228 
9229 static int
9230 test_authenticated_decryption_sessionless(
9231 		const struct aead_test_data *tdata)
9232 {
9233 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9234 	struct crypto_unittest_params *ut_params = &unittest_params;
9235 
9236 	int retval;
9237 	uint8_t *plaintext;
9238 	uint8_t key[tdata->key.len + 1];
9239 
9240 	/* alloc mbuf and set payload */
9241 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9242 
9243 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9244 			rte_pktmbuf_tailroom(ut_params->ibuf));
9245 
9246 	/* Create AEAD operation */
9247 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9248 	if (retval < 0)
9249 		return retval;
9250 
9251 	/* Create AEAD xform */
9252 	memcpy(key, tdata->key.data, tdata->key.len);
9253 	retval = create_aead_xform(ut_params->op,
9254 			tdata->algo,
9255 			RTE_CRYPTO_AEAD_OP_DECRYPT,
9256 			key, tdata->key.len,
9257 			tdata->aad.len, tdata->auth_tag.len,
9258 			tdata->iv.len);
9259 	if (retval < 0)
9260 		return retval;
9261 
9262 	ut_params->op->sym->m_src = ut_params->ibuf;
9263 
9264 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9265 			RTE_CRYPTO_OP_SESSIONLESS,
9266 			"crypto op session type not sessionless");
9267 
9268 	/* Process crypto operation */
9269 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9270 			ut_params->op), "failed to process sym crypto op");
9271 
9272 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9273 
9274 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9275 			"crypto op status not success");
9276 
9277 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9278 			ut_params->op->sym->cipher.data.offset);
9279 
9280 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9281 
9282 	/* Validate obuf */
9283 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9284 			plaintext,
9285 			tdata->plaintext.data,
9286 			tdata->plaintext.len,
9287 			"Plaintext data not as expected");
9288 
9289 	TEST_ASSERT_EQUAL(ut_params->op->status,
9290 			RTE_CRYPTO_OP_STATUS_SUCCESS,
9291 			"Authentication failed");
9292 	return 0;
9293 }
9294 
9295 static int
9296 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9297 {
9298 	return test_authenticated_decryption_sessionless(
9299 			&gcm_test_case_5);
9300 }
9301 
9302 static int
9303 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9304 {
9305 	return test_authenticated_encryption(&ccm_test_case_128_1);
9306 }
9307 
9308 static int
9309 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9310 {
9311 	return test_authenticated_encryption(&ccm_test_case_128_2);
9312 }
9313 
9314 static int
9315 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9316 {
9317 	return test_authenticated_encryption(&ccm_test_case_128_3);
9318 }
9319 
9320 static int
9321 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9322 {
9323 	return test_authenticated_decryption(&ccm_test_case_128_1);
9324 }
9325 
9326 static int
9327 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9328 {
9329 	return test_authenticated_decryption(&ccm_test_case_128_2);
9330 }
9331 
9332 static int
9333 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9334 {
9335 	return test_authenticated_decryption(&ccm_test_case_128_3);
9336 }
9337 
9338 static int
9339 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9340 {
9341 	return test_authenticated_encryption(&ccm_test_case_192_1);
9342 }
9343 
9344 static int
9345 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9346 {
9347 	return test_authenticated_encryption(&ccm_test_case_192_2);
9348 }
9349 
9350 static int
9351 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9352 {
9353 	return test_authenticated_encryption(&ccm_test_case_192_3);
9354 }
9355 
9356 static int
9357 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9358 {
9359 	return test_authenticated_decryption(&ccm_test_case_192_1);
9360 }
9361 
9362 static int
9363 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9364 {
9365 	return test_authenticated_decryption(&ccm_test_case_192_2);
9366 }
9367 
9368 static int
9369 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9370 {
9371 	return test_authenticated_decryption(&ccm_test_case_192_3);
9372 }
9373 
9374 static int
9375 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9376 {
9377 	return test_authenticated_encryption(&ccm_test_case_256_1);
9378 }
9379 
9380 static int
9381 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9382 {
9383 	return test_authenticated_encryption(&ccm_test_case_256_2);
9384 }
9385 
9386 static int
9387 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9388 {
9389 	return test_authenticated_encryption(&ccm_test_case_256_3);
9390 }
9391 
9392 static int
9393 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9394 {
9395 	return test_authenticated_decryption(&ccm_test_case_256_1);
9396 }
9397 
9398 static int
9399 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9400 {
9401 	return test_authenticated_decryption(&ccm_test_case_256_2);
9402 }
9403 
9404 static int
9405 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9406 {
9407 	return test_authenticated_decryption(&ccm_test_case_256_3);
9408 }
9409 
9410 static int
9411 test_stats(void)
9412 {
9413 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9414 	struct rte_cryptodev_stats stats;
9415 
9416 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9417 			== -ENOTSUP)
9418 		return -ENOTSUP;
9419 
9420 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9421 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9422 			&stats) == -ENODEV),
9423 		"rte_cryptodev_stats_get invalid dev failed");
9424 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9425 		"rte_cryptodev_stats_get invalid Param failed");
9426 
9427 	/* Test expected values */
9428 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
9429 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9430 			&stats),
9431 		"rte_cryptodev_stats_get failed");
9432 	TEST_ASSERT((stats.enqueued_count == 1),
9433 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9434 	TEST_ASSERT((stats.dequeued_count == 1),
9435 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9436 	TEST_ASSERT((stats.enqueue_err_count == 0),
9437 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9438 	TEST_ASSERT((stats.dequeue_err_count == 0),
9439 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9440 
9441 	/* invalid device but should ignore and not reset device stats*/
9442 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9443 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9444 			&stats),
9445 		"rte_cryptodev_stats_get failed");
9446 	TEST_ASSERT((stats.enqueued_count == 1),
9447 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9448 
9449 	/* check that a valid reset clears stats */
9450 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9451 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9452 			&stats),
9453 					  "rte_cryptodev_stats_get failed");
9454 	TEST_ASSERT((stats.enqueued_count == 0),
9455 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9456 	TEST_ASSERT((stats.dequeued_count == 0),
9457 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9458 
9459 	return TEST_SUCCESS;
9460 }
9461 
9462 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9463 				   struct crypto_unittest_params *ut_params,
9464 				   enum rte_crypto_auth_operation op,
9465 				   const struct HMAC_MD5_vector *test_case)
9466 {
9467 	uint8_t key[64];
9468 
9469 	memcpy(key, test_case->key.data, test_case->key.len);
9470 
9471 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9472 	ut_params->auth_xform.next = NULL;
9473 	ut_params->auth_xform.auth.op = op;
9474 
9475 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9476 
9477 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9478 	ut_params->auth_xform.auth.key.length = test_case->key.len;
9479 	ut_params->auth_xform.auth.key.data = key;
9480 
9481 	ut_params->sess = rte_cryptodev_sym_session_create(
9482 			ts_params->session_mpool);
9483 
9484 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9485 			ut_params->sess, &ut_params->auth_xform,
9486 			ts_params->session_priv_mpool);
9487 
9488 	if (ut_params->sess == NULL)
9489 		return TEST_FAILED;
9490 
9491 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9492 
9493 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9494 			rte_pktmbuf_tailroom(ut_params->ibuf));
9495 
9496 	return 0;
9497 }
9498 
9499 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9500 			      const struct HMAC_MD5_vector *test_case,
9501 			      uint8_t **plaintext)
9502 {
9503 	uint16_t plaintext_pad_len;
9504 
9505 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9506 
9507 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9508 				16);
9509 
9510 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9511 			plaintext_pad_len);
9512 	memcpy(*plaintext, test_case->plaintext.data,
9513 			test_case->plaintext.len);
9514 
9515 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9516 			ut_params->ibuf, MD5_DIGEST_LEN);
9517 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9518 			"no room to append digest");
9519 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9520 			ut_params->ibuf, plaintext_pad_len);
9521 
9522 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9523 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9524 			   test_case->auth_tag.len);
9525 	}
9526 
9527 	sym_op->auth.data.offset = 0;
9528 	sym_op->auth.data.length = test_case->plaintext.len;
9529 
9530 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9531 	ut_params->op->sym->m_src = ut_params->ibuf;
9532 
9533 	return 0;
9534 }
9535 
9536 static int
9537 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9538 {
9539 	uint16_t plaintext_pad_len;
9540 	uint8_t *plaintext, *auth_tag;
9541 
9542 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9543 	struct crypto_unittest_params *ut_params = &unittest_params;
9544 
9545 	if (MD5_HMAC_create_session(ts_params, ut_params,
9546 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9547 		return TEST_FAILED;
9548 
9549 	/* Generate Crypto op data structure */
9550 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9551 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9552 	TEST_ASSERT_NOT_NULL(ut_params->op,
9553 			"Failed to allocate symmetric crypto operation struct");
9554 
9555 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9556 				16);
9557 
9558 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9559 		return TEST_FAILED;
9560 
9561 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9562 			ut_params->op), "failed to process sym crypto op");
9563 
9564 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9565 			"crypto op processing failed");
9566 
9567 	if (ut_params->op->sym->m_dst) {
9568 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9569 				uint8_t *, plaintext_pad_len);
9570 	} else {
9571 		auth_tag = plaintext + plaintext_pad_len;
9572 	}
9573 
9574 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9575 			auth_tag,
9576 			test_case->auth_tag.data,
9577 			test_case->auth_tag.len,
9578 			"HMAC_MD5 generated tag not as expected");
9579 
9580 	return TEST_SUCCESS;
9581 }
9582 
9583 static int
9584 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9585 {
9586 	uint8_t *plaintext;
9587 
9588 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9589 	struct crypto_unittest_params *ut_params = &unittest_params;
9590 
9591 	if (MD5_HMAC_create_session(ts_params, ut_params,
9592 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9593 		return TEST_FAILED;
9594 	}
9595 
9596 	/* Generate Crypto op data structure */
9597 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9598 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9599 	TEST_ASSERT_NOT_NULL(ut_params->op,
9600 			"Failed to allocate symmetric crypto operation struct");
9601 
9602 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9603 		return TEST_FAILED;
9604 
9605 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9606 			ut_params->op), "failed to process sym crypto op");
9607 
9608 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9609 			"HMAC_MD5 crypto op processing failed");
9610 
9611 	return TEST_SUCCESS;
9612 }
9613 
9614 static int
9615 test_MD5_HMAC_generate_case_1(void)
9616 {
9617 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9618 }
9619 
9620 static int
9621 test_MD5_HMAC_verify_case_1(void)
9622 {
9623 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9624 }
9625 
9626 static int
9627 test_MD5_HMAC_generate_case_2(void)
9628 {
9629 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9630 }
9631 
9632 static int
9633 test_MD5_HMAC_verify_case_2(void)
9634 {
9635 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9636 }
9637 
9638 static int
9639 test_multi_session(void)
9640 {
9641 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9642 	struct crypto_unittest_params *ut_params = &unittest_params;
9643 
9644 	struct rte_cryptodev_info dev_info;
9645 	struct rte_cryptodev_sym_session **sessions;
9646 
9647 	uint16_t i;
9648 
9649 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9650 			aes_cbc_key, hmac_sha512_key);
9651 
9652 
9653 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9654 
9655 	sessions = rte_malloc(NULL,
9656 			(sizeof(struct rte_cryptodev_sym_session *) *
9657 			MAX_NB_SESSIONS) + 1, 0);
9658 
9659 	/* Create multiple crypto sessions*/
9660 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
9661 
9662 		sessions[i] = rte_cryptodev_sym_session_create(
9663 				ts_params->session_mpool);
9664 
9665 		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9666 				sessions[i], &ut_params->auth_xform,
9667 				ts_params->session_priv_mpool);
9668 		TEST_ASSERT_NOT_NULL(sessions[i],
9669 				"Session creation failed at session number %u",
9670 				i);
9671 
9672 		/* Attempt to send a request on each session */
9673 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9674 			sessions[i],
9675 			ut_params,
9676 			ts_params,
9677 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9678 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9679 			aes_cbc_iv),
9680 			"Failed to perform decrypt on request number %u.", i);
9681 		/* free crypto operation structure */
9682 		if (ut_params->op)
9683 			rte_crypto_op_free(ut_params->op);
9684 
9685 		/*
9686 		 * free mbuf - both obuf and ibuf are usually the same,
9687 		 * so check if they point at the same address is necessary,
9688 		 * to avoid freeing the mbuf twice.
9689 		 */
9690 		if (ut_params->obuf) {
9691 			rte_pktmbuf_free(ut_params->obuf);
9692 			if (ut_params->ibuf == ut_params->obuf)
9693 				ut_params->ibuf = 0;
9694 			ut_params->obuf = 0;
9695 		}
9696 		if (ut_params->ibuf) {
9697 			rte_pktmbuf_free(ut_params->ibuf);
9698 			ut_params->ibuf = 0;
9699 		}
9700 	}
9701 
9702 	/* Next session create should fail */
9703 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9704 			sessions[i], &ut_params->auth_xform,
9705 			ts_params->session_priv_mpool);
9706 	TEST_ASSERT_NULL(sessions[i],
9707 			"Session creation succeeded unexpectedly!");
9708 
9709 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
9710 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9711 				sessions[i]);
9712 		rte_cryptodev_sym_session_free(sessions[i]);
9713 	}
9714 
9715 	rte_free(sessions);
9716 
9717 	return TEST_SUCCESS;
9718 }
9719 
9720 struct multi_session_params {
9721 	struct crypto_unittest_params ut_params;
9722 	uint8_t *cipher_key;
9723 	uint8_t *hmac_key;
9724 	const uint8_t *cipher;
9725 	const uint8_t *digest;
9726 	uint8_t *iv;
9727 };
9728 
9729 #define MB_SESSION_NUMBER 3
9730 
9731 static int
9732 test_multi_session_random_usage(void)
9733 {
9734 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9735 	struct rte_cryptodev_info dev_info;
9736 	struct rte_cryptodev_sym_session **sessions;
9737 	uint32_t i, j;
9738 	struct multi_session_params ut_paramz[] = {
9739 
9740 		{
9741 			.cipher_key = ms_aes_cbc_key0,
9742 			.hmac_key = ms_hmac_key0,
9743 			.cipher = ms_aes_cbc_cipher0,
9744 			.digest = ms_hmac_digest0,
9745 			.iv = ms_aes_cbc_iv0
9746 		},
9747 		{
9748 			.cipher_key = ms_aes_cbc_key1,
9749 			.hmac_key = ms_hmac_key1,
9750 			.cipher = ms_aes_cbc_cipher1,
9751 			.digest = ms_hmac_digest1,
9752 			.iv = ms_aes_cbc_iv1
9753 		},
9754 		{
9755 			.cipher_key = ms_aes_cbc_key2,
9756 			.hmac_key = ms_hmac_key2,
9757 			.cipher = ms_aes_cbc_cipher2,
9758 			.digest = ms_hmac_digest2,
9759 			.iv = ms_aes_cbc_iv2
9760 		},
9761 
9762 	};
9763 
9764 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9765 
9766 	sessions = rte_malloc(NULL,
9767 			(sizeof(struct rte_cryptodev_sym_session *)
9768 					* MAX_NB_SESSIONS) + 1, 0);
9769 
9770 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
9771 		sessions[i] = rte_cryptodev_sym_session_create(
9772 				ts_params->session_mpool);
9773 
9774 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9775 				sizeof(struct crypto_unittest_params));
9776 
9777 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9778 				&ut_paramz[i].ut_params,
9779 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9780 
9781 		/* Create multiple crypto sessions*/
9782 		rte_cryptodev_sym_session_init(
9783 				ts_params->valid_devs[0],
9784 				sessions[i],
9785 				&ut_paramz[i].ut_params.auth_xform,
9786 				ts_params->session_priv_mpool);
9787 
9788 		TEST_ASSERT_NOT_NULL(sessions[i],
9789 				"Session creation failed at session number %u",
9790 				i);
9791 
9792 	}
9793 
9794 	srand(time(NULL));
9795 	for (i = 0; i < 40000; i++) {
9796 
9797 		j = rand() % MB_SESSION_NUMBER;
9798 
9799 		TEST_ASSERT_SUCCESS(
9800 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
9801 					sessions[j],
9802 					&ut_paramz[j].ut_params,
9803 					ts_params, ut_paramz[j].cipher,
9804 					ut_paramz[j].digest,
9805 					ut_paramz[j].iv),
9806 			"Failed to perform decrypt on request number %u.", i);
9807 
9808 		if (ut_paramz[j].ut_params.op)
9809 			rte_crypto_op_free(ut_paramz[j].ut_params.op);
9810 
9811 		/*
9812 		 * free mbuf - both obuf and ibuf are usually the same,
9813 		 * so check if they point at the same address is necessary,
9814 		 * to avoid freeing the mbuf twice.
9815 		 */
9816 		if (ut_paramz[j].ut_params.obuf) {
9817 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9818 			if (ut_paramz[j].ut_params.ibuf
9819 					== ut_paramz[j].ut_params.obuf)
9820 				ut_paramz[j].ut_params.ibuf = 0;
9821 			ut_paramz[j].ut_params.obuf = 0;
9822 		}
9823 		if (ut_paramz[j].ut_params.ibuf) {
9824 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9825 			ut_paramz[j].ut_params.ibuf = 0;
9826 		}
9827 	}
9828 
9829 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
9830 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9831 				sessions[i]);
9832 		rte_cryptodev_sym_session_free(sessions[i]);
9833 	}
9834 
9835 	rte_free(sessions);
9836 
9837 	return TEST_SUCCESS;
9838 }
9839 
9840 static int
9841 test_null_cipher_only_operation(void)
9842 {
9843 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9844 	struct crypto_unittest_params *ut_params = &unittest_params;
9845 
9846 	/* Generate test mbuf data and space for digest */
9847 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9848 			catch_22_quote, QUOTE_512_BYTES, 0);
9849 
9850 	/* Setup Cipher Parameters */
9851 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9852 	ut_params->cipher_xform.next = NULL;
9853 
9854 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9855 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9856 
9857 	ut_params->sess = rte_cryptodev_sym_session_create(
9858 			ts_params->session_mpool);
9859 
9860 	/* Create Crypto session*/
9861 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9862 				ut_params->sess,
9863 				&ut_params->cipher_xform,
9864 				ts_params->session_priv_mpool);
9865 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9866 
9867 	/* Generate Crypto op data structure */
9868 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9869 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9870 	TEST_ASSERT_NOT_NULL(ut_params->op,
9871 			"Failed to allocate symmetric crypto operation struct");
9872 
9873 	/* Set crypto operation data parameters */
9874 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9875 
9876 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9877 
9878 	/* set crypto operation source mbuf */
9879 	sym_op->m_src = ut_params->ibuf;
9880 
9881 	sym_op->cipher.data.offset = 0;
9882 	sym_op->cipher.data.length = QUOTE_512_BYTES;
9883 
9884 	/* Process crypto operation */
9885 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9886 			ut_params->op);
9887 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9888 
9889 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9890 			"crypto operation processing failed");
9891 
9892 	/* Validate obuf */
9893 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9894 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9895 			catch_22_quote,
9896 			QUOTE_512_BYTES,
9897 			"Ciphertext data not as expected");
9898 
9899 	return TEST_SUCCESS;
9900 }
9901 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9902 			0xab, 0xab, 0xab, 0xab,
9903 			0xab, 0xab, 0xab, 0xab,
9904 			0xab, 0xab, 0xab, 0xab};
9905 static int
9906 test_null_auth_only_operation(void)
9907 {
9908 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9909 	struct crypto_unittest_params *ut_params = &unittest_params;
9910 	uint8_t *digest;
9911 
9912 	/* Generate test mbuf data and space for digest */
9913 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9914 			catch_22_quote, QUOTE_512_BYTES, 0);
9915 
9916 	/* create a pointer for digest, but don't expect anything to be written
9917 	 * here in a NULL auth algo so no mbuf append done.
9918 	 */
9919 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9920 			QUOTE_512_BYTES);
9921 	/* prefill the memory pointed to by digest */
9922 	memcpy(digest, orig_data, sizeof(orig_data));
9923 
9924 	/* Setup HMAC Parameters */
9925 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9926 	ut_params->auth_xform.next = NULL;
9927 
9928 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9929 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9930 
9931 	ut_params->sess = rte_cryptodev_sym_session_create(
9932 			ts_params->session_mpool);
9933 
9934 	/* Create Crypto session*/
9935 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9936 			ut_params->sess, &ut_params->auth_xform,
9937 			ts_params->session_priv_mpool);
9938 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9939 
9940 	/* Generate Crypto op data structure */
9941 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9942 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9943 	TEST_ASSERT_NOT_NULL(ut_params->op,
9944 			"Failed to allocate symmetric crypto operation struct");
9945 
9946 	/* Set crypto operation data parameters */
9947 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9948 
9949 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9950 
9951 	sym_op->m_src = ut_params->ibuf;
9952 
9953 	sym_op->auth.data.offset = 0;
9954 	sym_op->auth.data.length = QUOTE_512_BYTES;
9955 	sym_op->auth.digest.data = digest;
9956 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9957 			QUOTE_512_BYTES);
9958 
9959 	/* Process crypto operation */
9960 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9961 			ut_params->op);
9962 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9963 
9964 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9965 			"crypto operation processing failed");
9966 	/* Make sure memory pointed to by digest hasn't been overwritten */
9967 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9968 			orig_data,
9969 			digest,
9970 			sizeof(orig_data),
9971 			"Memory at digest ptr overwritten unexpectedly");
9972 
9973 	return TEST_SUCCESS;
9974 }
9975 
9976 
9977 static int
9978 test_null_cipher_auth_operation(void)
9979 {
9980 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9981 	struct crypto_unittest_params *ut_params = &unittest_params;
9982 	uint8_t *digest;
9983 
9984 	/* Generate test mbuf data and space for digest */
9985 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9986 			catch_22_quote, QUOTE_512_BYTES, 0);
9987 
9988 	/* create a pointer for digest, but don't expect anything to be written
9989 	 * here in a NULL auth algo so no mbuf append done.
9990 	 */
9991 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9992 			QUOTE_512_BYTES);
9993 	/* prefill the memory pointed to by digest */
9994 	memcpy(digest, orig_data, sizeof(orig_data));
9995 
9996 	/* Setup Cipher Parameters */
9997 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9998 	ut_params->cipher_xform.next = &ut_params->auth_xform;
9999 
10000 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10001 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10002 
10003 	/* Setup HMAC Parameters */
10004 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10005 	ut_params->auth_xform.next = NULL;
10006 
10007 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10008 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10009 
10010 	ut_params->sess = rte_cryptodev_sym_session_create(
10011 			ts_params->session_mpool);
10012 
10013 	/* Create Crypto session*/
10014 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10015 			ut_params->sess, &ut_params->cipher_xform,
10016 			ts_params->session_priv_mpool);
10017 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10018 
10019 	/* Generate Crypto op data structure */
10020 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10021 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10022 	TEST_ASSERT_NOT_NULL(ut_params->op,
10023 			"Failed to allocate symmetric crypto operation struct");
10024 
10025 	/* Set crypto operation data parameters */
10026 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10027 
10028 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10029 
10030 	sym_op->m_src = ut_params->ibuf;
10031 
10032 	sym_op->cipher.data.offset = 0;
10033 	sym_op->cipher.data.length = QUOTE_512_BYTES;
10034 
10035 	sym_op->auth.data.offset = 0;
10036 	sym_op->auth.data.length = QUOTE_512_BYTES;
10037 	sym_op->auth.digest.data = digest;
10038 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10039 			QUOTE_512_BYTES);
10040 
10041 	/* Process crypto operation */
10042 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10043 			ut_params->op);
10044 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10045 
10046 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10047 			"crypto operation processing failed");
10048 
10049 	/* Validate obuf */
10050 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10051 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10052 			catch_22_quote,
10053 			QUOTE_512_BYTES,
10054 			"Ciphertext data not as expected");
10055 	/* Make sure memory pointed to by digest hasn't been overwritten */
10056 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10057 			orig_data,
10058 			digest,
10059 			sizeof(orig_data),
10060 			"Memory at digest ptr overwritten unexpectedly");
10061 
10062 	return TEST_SUCCESS;
10063 }
10064 
10065 static int
10066 test_null_auth_cipher_operation(void)
10067 {
10068 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10069 	struct crypto_unittest_params *ut_params = &unittest_params;
10070 	uint8_t *digest;
10071 
10072 	/* Generate test mbuf data */
10073 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
10074 			catch_22_quote, QUOTE_512_BYTES, 0);
10075 
10076 	/* create a pointer for digest, but don't expect anything to be written
10077 	 * here in a NULL auth algo so no mbuf append done.
10078 	 */
10079 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10080 				QUOTE_512_BYTES);
10081 	/* prefill the memory pointed to by digest */
10082 	memcpy(digest, orig_data, sizeof(orig_data));
10083 
10084 	/* Setup Cipher Parameters */
10085 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10086 	ut_params->cipher_xform.next = NULL;
10087 
10088 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10089 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10090 
10091 	/* Setup HMAC Parameters */
10092 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10093 	ut_params->auth_xform.next = &ut_params->cipher_xform;
10094 
10095 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10096 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10097 
10098 	ut_params->sess = rte_cryptodev_sym_session_create(
10099 			ts_params->session_mpool);
10100 
10101 	/* Create Crypto session*/
10102 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10103 			ut_params->sess, &ut_params->cipher_xform,
10104 			ts_params->session_priv_mpool);
10105 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10106 
10107 	/* Generate Crypto op data structure */
10108 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10109 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10110 	TEST_ASSERT_NOT_NULL(ut_params->op,
10111 			"Failed to allocate symmetric crypto operation struct");
10112 
10113 	/* Set crypto operation data parameters */
10114 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10115 
10116 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10117 
10118 	sym_op->m_src = ut_params->ibuf;
10119 
10120 	sym_op->cipher.data.offset = 0;
10121 	sym_op->cipher.data.length = QUOTE_512_BYTES;
10122 
10123 	sym_op->auth.data.offset = 0;
10124 	sym_op->auth.data.length = QUOTE_512_BYTES;
10125 	sym_op->auth.digest.data = digest;
10126 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10127 					QUOTE_512_BYTES);
10128 
10129 	/* Process crypto operation */
10130 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10131 			ut_params->op);
10132 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10133 
10134 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10135 			"crypto operation processing failed");
10136 
10137 	/* Validate obuf */
10138 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10139 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10140 			catch_22_quote,
10141 			QUOTE_512_BYTES,
10142 			"Ciphertext data not as expected");
10143 	/* Make sure memory pointed to by digest hasn't been overwritten */
10144 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10145 			orig_data,
10146 			digest,
10147 			sizeof(orig_data),
10148 			"Memory at digest ptr overwritten unexpectedly");
10149 
10150 	return TEST_SUCCESS;
10151 }
10152 
10153 
10154 static int
10155 test_null_invalid_operation(void)
10156 {
10157 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10158 	struct crypto_unittest_params *ut_params = &unittest_params;
10159 	int ret;
10160 
10161 	/* Setup Cipher Parameters */
10162 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10163 	ut_params->cipher_xform.next = NULL;
10164 
10165 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10166 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10167 
10168 	ut_params->sess = rte_cryptodev_sym_session_create(
10169 			ts_params->session_mpool);
10170 
10171 	/* Create Crypto session*/
10172 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10173 			ut_params->sess, &ut_params->cipher_xform,
10174 			ts_params->session_priv_mpool);
10175 	TEST_ASSERT(ret < 0,
10176 			"Session creation succeeded unexpectedly");
10177 
10178 
10179 	/* Setup HMAC Parameters */
10180 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10181 	ut_params->auth_xform.next = NULL;
10182 
10183 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10184 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10185 
10186 	ut_params->sess = rte_cryptodev_sym_session_create(
10187 			ts_params->session_mpool);
10188 
10189 	/* Create Crypto session*/
10190 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10191 			ut_params->sess, &ut_params->auth_xform,
10192 			ts_params->session_priv_mpool);
10193 	TEST_ASSERT(ret < 0,
10194 			"Session creation succeeded unexpectedly");
10195 
10196 	return TEST_SUCCESS;
10197 }
10198 
10199 
10200 #define NULL_BURST_LENGTH (32)
10201 
10202 static int
10203 test_null_burst_operation(void)
10204 {
10205 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10206 	struct crypto_unittest_params *ut_params = &unittest_params;
10207 
10208 	unsigned i, burst_len = NULL_BURST_LENGTH;
10209 
10210 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10211 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10212 
10213 	/* Setup Cipher Parameters */
10214 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10215 	ut_params->cipher_xform.next = &ut_params->auth_xform;
10216 
10217 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10218 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10219 
10220 	/* Setup HMAC Parameters */
10221 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10222 	ut_params->auth_xform.next = NULL;
10223 
10224 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10225 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10226 
10227 	ut_params->sess = rte_cryptodev_sym_session_create(
10228 			ts_params->session_mpool);
10229 
10230 	/* Create Crypto session*/
10231 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10232 			ut_params->sess, &ut_params->cipher_xform,
10233 			ts_params->session_priv_mpool);
10234 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10235 
10236 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10237 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10238 			burst_len, "failed to generate burst of crypto ops");
10239 
10240 	/* Generate an operation for each mbuf in burst */
10241 	for (i = 0; i < burst_len; i++) {
10242 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10243 
10244 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10245 
10246 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10247 				sizeof(unsigned));
10248 		*data = i;
10249 
10250 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10251 
10252 		burst[i]->sym->m_src = m;
10253 	}
10254 
10255 	/* Process crypto operation */
10256 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10257 			0, burst, burst_len),
10258 			burst_len,
10259 			"Error enqueuing burst");
10260 
10261 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10262 			0, burst_dequeued, burst_len),
10263 			burst_len,
10264 			"Error dequeuing burst");
10265 
10266 
10267 	for (i = 0; i < burst_len; i++) {
10268 		TEST_ASSERT_EQUAL(
10269 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10270 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10271 					uint32_t *),
10272 			"data not as expected");
10273 
10274 		rte_pktmbuf_free(burst[i]->sym->m_src);
10275 		rte_crypto_op_free(burst[i]);
10276 	}
10277 
10278 	return TEST_SUCCESS;
10279 }
10280 
10281 static void
10282 generate_gmac_large_plaintext(uint8_t *data)
10283 {
10284 	uint16_t i;
10285 
10286 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10287 		memcpy(&data[i], &data[0], 32);
10288 }
10289 
10290 static int
10291 create_gmac_operation(enum rte_crypto_auth_operation op,
10292 		const struct gmac_test_data *tdata)
10293 {
10294 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10295 	struct crypto_unittest_params *ut_params = &unittest_params;
10296 	struct rte_crypto_sym_op *sym_op;
10297 
10298 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10299 
10300 	/* Generate Crypto op data structure */
10301 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10302 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10303 	TEST_ASSERT_NOT_NULL(ut_params->op,
10304 			"Failed to allocate symmetric crypto operation struct");
10305 
10306 	sym_op = ut_params->op->sym;
10307 
10308 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10309 			ut_params->ibuf, tdata->gmac_tag.len);
10310 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10311 			"no room to append digest");
10312 
10313 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10314 			ut_params->ibuf, plaintext_pad_len);
10315 
10316 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10317 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10318 				tdata->gmac_tag.len);
10319 		debug_hexdump(stdout, "digest:",
10320 				sym_op->auth.digest.data,
10321 				tdata->gmac_tag.len);
10322 	}
10323 
10324 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10325 			uint8_t *, IV_OFFSET);
10326 
10327 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10328 
10329 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10330 
10331 	sym_op->cipher.data.length = 0;
10332 	sym_op->cipher.data.offset = 0;
10333 
10334 	sym_op->auth.data.offset = 0;
10335 	sym_op->auth.data.length = tdata->plaintext.len;
10336 
10337 	return 0;
10338 }
10339 
10340 static int create_gmac_session(uint8_t dev_id,
10341 		const struct gmac_test_data *tdata,
10342 		enum rte_crypto_auth_operation auth_op)
10343 {
10344 	uint8_t auth_key[tdata->key.len];
10345 
10346 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10347 	struct crypto_unittest_params *ut_params = &unittest_params;
10348 
10349 	memcpy(auth_key, tdata->key.data, tdata->key.len);
10350 
10351 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10352 	ut_params->auth_xform.next = NULL;
10353 
10354 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10355 	ut_params->auth_xform.auth.op = auth_op;
10356 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10357 	ut_params->auth_xform.auth.key.length = tdata->key.len;
10358 	ut_params->auth_xform.auth.key.data = auth_key;
10359 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10360 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10361 
10362 
10363 	ut_params->sess = rte_cryptodev_sym_session_create(
10364 			ts_params->session_mpool);
10365 
10366 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10367 			&ut_params->auth_xform,
10368 			ts_params->session_priv_mpool);
10369 
10370 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10371 
10372 	return 0;
10373 }
10374 
10375 static int
10376 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10377 {
10378 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10379 	struct crypto_unittest_params *ut_params = &unittest_params;
10380 
10381 	int retval;
10382 
10383 	uint8_t *auth_tag, *plaintext;
10384 	uint16_t plaintext_pad_len;
10385 
10386 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10387 			      "No GMAC length in the source data");
10388 
10389 	retval = create_gmac_session(ts_params->valid_devs[0],
10390 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10391 
10392 	if (retval < 0)
10393 		return retval;
10394 
10395 	if (tdata->plaintext.len > MBUF_SIZE)
10396 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10397 	else
10398 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10399 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10400 			"Failed to allocate input buffer in mempool");
10401 
10402 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10403 			rte_pktmbuf_tailroom(ut_params->ibuf));
10404 
10405 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10406 	/*
10407 	 * Runtime generate the large plain text instead of use hard code
10408 	 * plain text vector. It is done to avoid create huge source file
10409 	 * with the test vector.
10410 	 */
10411 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10412 		generate_gmac_large_plaintext(tdata->plaintext.data);
10413 
10414 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10415 				plaintext_pad_len);
10416 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10417 
10418 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10419 	debug_hexdump(stdout, "plaintext:", plaintext,
10420 			tdata->plaintext.len);
10421 
10422 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10423 			tdata);
10424 
10425 	if (retval < 0)
10426 		return retval;
10427 
10428 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10429 
10430 	ut_params->op->sym->m_src = ut_params->ibuf;
10431 
10432 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10433 			ut_params->op), "failed to process sym crypto op");
10434 
10435 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10436 			"crypto op processing failed");
10437 
10438 	if (ut_params->op->sym->m_dst) {
10439 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10440 				uint8_t *, plaintext_pad_len);
10441 	} else {
10442 		auth_tag = plaintext + plaintext_pad_len;
10443 	}
10444 
10445 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10446 
10447 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10448 			auth_tag,
10449 			tdata->gmac_tag.data,
10450 			tdata->gmac_tag.len,
10451 			"GMAC Generated auth tag not as expected");
10452 
10453 	return 0;
10454 }
10455 
10456 static int
10457 test_AES_GMAC_authentication_test_case_1(void)
10458 {
10459 	return test_AES_GMAC_authentication(&gmac_test_case_1);
10460 }
10461 
10462 static int
10463 test_AES_GMAC_authentication_test_case_2(void)
10464 {
10465 	return test_AES_GMAC_authentication(&gmac_test_case_2);
10466 }
10467 
10468 static int
10469 test_AES_GMAC_authentication_test_case_3(void)
10470 {
10471 	return test_AES_GMAC_authentication(&gmac_test_case_3);
10472 }
10473 
10474 static int
10475 test_AES_GMAC_authentication_test_case_4(void)
10476 {
10477 	return test_AES_GMAC_authentication(&gmac_test_case_4);
10478 }
10479 
10480 static int
10481 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10482 {
10483 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10484 	struct crypto_unittest_params *ut_params = &unittest_params;
10485 	int retval;
10486 	uint32_t plaintext_pad_len;
10487 	uint8_t *plaintext;
10488 
10489 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10490 			      "No GMAC length in the source data");
10491 
10492 	retval = create_gmac_session(ts_params->valid_devs[0],
10493 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10494 
10495 	if (retval < 0)
10496 		return retval;
10497 
10498 	if (tdata->plaintext.len > MBUF_SIZE)
10499 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10500 	else
10501 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10502 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10503 			"Failed to allocate input buffer in mempool");
10504 
10505 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10506 			rte_pktmbuf_tailroom(ut_params->ibuf));
10507 
10508 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10509 
10510 	/*
10511 	 * Runtime generate the large plain text instead of use hard code
10512 	 * plain text vector. It is done to avoid create huge source file
10513 	 * with the test vector.
10514 	 */
10515 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10516 		generate_gmac_large_plaintext(tdata->plaintext.data);
10517 
10518 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10519 				plaintext_pad_len);
10520 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10521 
10522 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10523 	debug_hexdump(stdout, "plaintext:", plaintext,
10524 			tdata->plaintext.len);
10525 
10526 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10527 			tdata);
10528 
10529 	if (retval < 0)
10530 		return retval;
10531 
10532 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10533 
10534 	ut_params->op->sym->m_src = ut_params->ibuf;
10535 
10536 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10537 			ut_params->op), "failed to process sym crypto op");
10538 
10539 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10540 			"crypto op processing failed");
10541 
10542 	return 0;
10543 
10544 }
10545 
10546 static int
10547 test_AES_GMAC_authentication_verify_test_case_1(void)
10548 {
10549 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10550 }
10551 
10552 static int
10553 test_AES_GMAC_authentication_verify_test_case_2(void)
10554 {
10555 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10556 }
10557 
10558 static int
10559 test_AES_GMAC_authentication_verify_test_case_3(void)
10560 {
10561 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10562 }
10563 
10564 static int
10565 test_AES_GMAC_authentication_verify_test_case_4(void)
10566 {
10567 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10568 }
10569 
10570 struct test_crypto_vector {
10571 	enum rte_crypto_cipher_algorithm crypto_algo;
10572 	unsigned int cipher_offset;
10573 	unsigned int cipher_len;
10574 
10575 	struct {
10576 		uint8_t data[64];
10577 		unsigned int len;
10578 	} cipher_key;
10579 
10580 	struct {
10581 		uint8_t data[64];
10582 		unsigned int len;
10583 	} iv;
10584 
10585 	struct {
10586 		const uint8_t *data;
10587 		unsigned int len;
10588 	} plaintext;
10589 
10590 	struct {
10591 		const uint8_t *data;
10592 		unsigned int len;
10593 	} ciphertext;
10594 
10595 	enum rte_crypto_auth_algorithm auth_algo;
10596 	unsigned int auth_offset;
10597 
10598 	struct {
10599 		uint8_t data[128];
10600 		unsigned int len;
10601 	} auth_key;
10602 
10603 	struct {
10604 		const uint8_t *data;
10605 		unsigned int len;
10606 	} aad;
10607 
10608 	struct {
10609 		uint8_t data[128];
10610 		unsigned int len;
10611 	} digest;
10612 };
10613 
10614 static const struct test_crypto_vector
10615 hmac_sha1_test_crypto_vector = {
10616 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10617 	.plaintext = {
10618 		.data = plaintext_hash,
10619 		.len = 512
10620 	},
10621 	.auth_key = {
10622 		.data = {
10623 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10624 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10625 			0xDE, 0xF4, 0xDE, 0xAD
10626 		},
10627 		.len = 20
10628 	},
10629 	.digest = {
10630 		.data = {
10631 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10632 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10633 			0x3F, 0x91, 0x64, 0x59
10634 		},
10635 		.len = 20
10636 	}
10637 };
10638 
10639 static const struct test_crypto_vector
10640 aes128_gmac_test_vector = {
10641 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10642 	.plaintext = {
10643 		.data = plaintext_hash,
10644 		.len = 512
10645 	},
10646 	.iv = {
10647 		.data = {
10648 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10649 			0x08, 0x09, 0x0A, 0x0B
10650 		},
10651 		.len = 12
10652 	},
10653 	.auth_key = {
10654 		.data = {
10655 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10656 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10657 		},
10658 		.len = 16
10659 	},
10660 	.digest = {
10661 		.data = {
10662 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10663 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10664 		},
10665 		.len = 16
10666 	}
10667 };
10668 
10669 static const struct test_crypto_vector
10670 aes128cbc_hmac_sha1_test_vector = {
10671 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10672 	.cipher_offset = 0,
10673 	.cipher_len = 512,
10674 	.cipher_key = {
10675 		.data = {
10676 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10677 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10678 		},
10679 		.len = 16
10680 	},
10681 	.iv = {
10682 		.data = {
10683 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10684 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10685 		},
10686 		.len = 16
10687 	},
10688 	.plaintext = {
10689 		.data = plaintext_hash,
10690 		.len = 512
10691 	},
10692 	.ciphertext = {
10693 		.data = ciphertext512_aes128cbc,
10694 		.len = 512
10695 	},
10696 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10697 	.auth_offset = 0,
10698 	.auth_key = {
10699 		.data = {
10700 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10701 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10702 			0xDE, 0xF4, 0xDE, 0xAD
10703 		},
10704 		.len = 20
10705 	},
10706 	.digest = {
10707 		.data = {
10708 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10709 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10710 			0x18, 0x8C, 0x1D, 0x32
10711 		},
10712 		.len = 20
10713 	}
10714 };
10715 
10716 static const struct test_crypto_vector
10717 aes128cbc_hmac_sha1_aad_test_vector = {
10718 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10719 	.cipher_offset = 8,
10720 	.cipher_len = 496,
10721 	.cipher_key = {
10722 		.data = {
10723 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10724 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10725 		},
10726 		.len = 16
10727 	},
10728 	.iv = {
10729 		.data = {
10730 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10731 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10732 		},
10733 		.len = 16
10734 	},
10735 	.plaintext = {
10736 		.data = plaintext_hash,
10737 		.len = 512
10738 	},
10739 	.ciphertext = {
10740 		.data = ciphertext512_aes128cbc_aad,
10741 		.len = 512
10742 	},
10743 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10744 	.auth_offset = 0,
10745 	.auth_key = {
10746 		.data = {
10747 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10748 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10749 			0xDE, 0xF4, 0xDE, 0xAD
10750 		},
10751 		.len = 20
10752 	},
10753 	.digest = {
10754 		.data = {
10755 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
10756 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
10757 			0x62, 0x0F, 0xFB, 0x10
10758 		},
10759 		.len = 20
10760 	}
10761 };
10762 
10763 static void
10764 data_corruption(uint8_t *data)
10765 {
10766 	data[0] += 1;
10767 }
10768 
10769 static void
10770 tag_corruption(uint8_t *data, unsigned int tag_offset)
10771 {
10772 	data[tag_offset] += 1;
10773 }
10774 
10775 static int
10776 create_auth_session(struct crypto_unittest_params *ut_params,
10777 		uint8_t dev_id,
10778 		const struct test_crypto_vector *reference,
10779 		enum rte_crypto_auth_operation auth_op)
10780 {
10781 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10782 	uint8_t auth_key[reference->auth_key.len + 1];
10783 
10784 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10785 
10786 	/* Setup Authentication Parameters */
10787 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10788 	ut_params->auth_xform.auth.op = auth_op;
10789 	ut_params->auth_xform.next = NULL;
10790 	ut_params->auth_xform.auth.algo = reference->auth_algo;
10791 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10792 	ut_params->auth_xform.auth.key.data = auth_key;
10793 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
10794 
10795 	/* Create Crypto session*/
10796 	ut_params->sess = rte_cryptodev_sym_session_create(
10797 			ts_params->session_mpool);
10798 
10799 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10800 				&ut_params->auth_xform,
10801 				ts_params->session_priv_mpool);
10802 
10803 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10804 
10805 	return 0;
10806 }
10807 
10808 static int
10809 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10810 		uint8_t dev_id,
10811 		const struct test_crypto_vector *reference,
10812 		enum rte_crypto_auth_operation auth_op,
10813 		enum rte_crypto_cipher_operation cipher_op)
10814 {
10815 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10816 	uint8_t cipher_key[reference->cipher_key.len + 1];
10817 	uint8_t auth_key[reference->auth_key.len + 1];
10818 
10819 	memcpy(cipher_key, reference->cipher_key.data,
10820 			reference->cipher_key.len);
10821 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10822 
10823 	/* Setup Authentication Parameters */
10824 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10825 	ut_params->auth_xform.auth.op = auth_op;
10826 	ut_params->auth_xform.auth.algo = reference->auth_algo;
10827 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10828 	ut_params->auth_xform.auth.key.data = auth_key;
10829 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
10830 
10831 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10832 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10833 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
10834 	} else {
10835 		ut_params->auth_xform.next = &ut_params->cipher_xform;
10836 
10837 		/* Setup Cipher Parameters */
10838 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10839 		ut_params->cipher_xform.next = NULL;
10840 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10841 		ut_params->cipher_xform.cipher.op = cipher_op;
10842 		ut_params->cipher_xform.cipher.key.data = cipher_key;
10843 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10844 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10845 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10846 	}
10847 
10848 	/* Create Crypto session*/
10849 	ut_params->sess = rte_cryptodev_sym_session_create(
10850 			ts_params->session_mpool);
10851 
10852 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10853 				&ut_params->auth_xform,
10854 				ts_params->session_priv_mpool);
10855 
10856 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10857 
10858 	return 0;
10859 }
10860 
10861 static int
10862 create_auth_operation(struct crypto_testsuite_params *ts_params,
10863 		struct crypto_unittest_params *ut_params,
10864 		const struct test_crypto_vector *reference,
10865 		unsigned int auth_generate)
10866 {
10867 	/* Generate Crypto op data structure */
10868 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10869 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10870 	TEST_ASSERT_NOT_NULL(ut_params->op,
10871 			"Failed to allocate pktmbuf offload");
10872 
10873 	/* Set crypto operation data parameters */
10874 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10875 
10876 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10877 
10878 	/* set crypto operation source mbuf */
10879 	sym_op->m_src = ut_params->ibuf;
10880 
10881 	/* digest */
10882 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10883 			ut_params->ibuf, reference->digest.len);
10884 
10885 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10886 			"no room to append auth tag");
10887 
10888 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10889 			ut_params->ibuf, reference->plaintext.len);
10890 
10891 	if (auth_generate)
10892 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10893 	else
10894 		memcpy(sym_op->auth.digest.data,
10895 				reference->digest.data,
10896 				reference->digest.len);
10897 
10898 	debug_hexdump(stdout, "digest:",
10899 			sym_op->auth.digest.data,
10900 			reference->digest.len);
10901 
10902 	sym_op->auth.data.length = reference->plaintext.len;
10903 	sym_op->auth.data.offset = 0;
10904 
10905 	return 0;
10906 }
10907 
10908 static int
10909 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10910 		struct crypto_unittest_params *ut_params,
10911 		const struct test_crypto_vector *reference,
10912 		unsigned int auth_generate)
10913 {
10914 	/* Generate Crypto op data structure */
10915 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10916 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10917 	TEST_ASSERT_NOT_NULL(ut_params->op,
10918 			"Failed to allocate pktmbuf offload");
10919 
10920 	/* Set crypto operation data parameters */
10921 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10922 
10923 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10924 
10925 	/* set crypto operation source mbuf */
10926 	sym_op->m_src = ut_params->ibuf;
10927 
10928 	/* digest */
10929 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10930 			ut_params->ibuf, reference->digest.len);
10931 
10932 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10933 			"no room to append auth tag");
10934 
10935 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10936 			ut_params->ibuf, reference->ciphertext.len);
10937 
10938 	if (auth_generate)
10939 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10940 	else
10941 		memcpy(sym_op->auth.digest.data,
10942 				reference->digest.data,
10943 				reference->digest.len);
10944 
10945 	debug_hexdump(stdout, "digest:",
10946 			sym_op->auth.digest.data,
10947 			reference->digest.len);
10948 
10949 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10950 			reference->iv.data, reference->iv.len);
10951 
10952 	sym_op->cipher.data.length = 0;
10953 	sym_op->cipher.data.offset = 0;
10954 
10955 	sym_op->auth.data.length = reference->plaintext.len;
10956 	sym_op->auth.data.offset = 0;
10957 
10958 	return 0;
10959 }
10960 
10961 static int
10962 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10963 		struct crypto_unittest_params *ut_params,
10964 		const struct test_crypto_vector *reference,
10965 		unsigned int auth_generate)
10966 {
10967 	/* Generate Crypto op data structure */
10968 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10969 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10970 	TEST_ASSERT_NOT_NULL(ut_params->op,
10971 			"Failed to allocate pktmbuf offload");
10972 
10973 	/* Set crypto operation data parameters */
10974 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10975 
10976 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10977 
10978 	/* set crypto operation source mbuf */
10979 	sym_op->m_src = ut_params->ibuf;
10980 
10981 	/* digest */
10982 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10983 			ut_params->ibuf, reference->digest.len);
10984 
10985 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10986 			"no room to append auth tag");
10987 
10988 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10989 			ut_params->ibuf, reference->ciphertext.len);
10990 
10991 	if (auth_generate)
10992 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10993 	else
10994 		memcpy(sym_op->auth.digest.data,
10995 				reference->digest.data,
10996 				reference->digest.len);
10997 
10998 	debug_hexdump(stdout, "digest:",
10999 			sym_op->auth.digest.data,
11000 			reference->digest.len);
11001 
11002 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11003 			reference->iv.data, reference->iv.len);
11004 
11005 	sym_op->cipher.data.length = reference->cipher_len;
11006 	sym_op->cipher.data.offset = reference->cipher_offset;
11007 
11008 	sym_op->auth.data.length = reference->plaintext.len;
11009 	sym_op->auth.data.offset = reference->auth_offset;
11010 
11011 	return 0;
11012 }
11013 
11014 static int
11015 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11016 		struct crypto_unittest_params *ut_params,
11017 		const struct test_crypto_vector *reference)
11018 {
11019 	return create_auth_operation(ts_params, ut_params, reference, 0);
11020 }
11021 
11022 static int
11023 create_auth_verify_GMAC_operation(
11024 		struct crypto_testsuite_params *ts_params,
11025 		struct crypto_unittest_params *ut_params,
11026 		const struct test_crypto_vector *reference)
11027 {
11028 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11029 }
11030 
11031 static int
11032 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11033 		struct crypto_unittest_params *ut_params,
11034 		const struct test_crypto_vector *reference)
11035 {
11036 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11037 }
11038 
11039 static int
11040 test_authentication_verify_fail_when_data_corruption(
11041 		struct crypto_testsuite_params *ts_params,
11042 		struct crypto_unittest_params *ut_params,
11043 		const struct test_crypto_vector *reference,
11044 		unsigned int data_corrupted)
11045 {
11046 	int retval;
11047 
11048 	uint8_t *plaintext;
11049 
11050 	/* Create session */
11051 	retval = create_auth_session(ut_params,
11052 			ts_params->valid_devs[0],
11053 			reference,
11054 			RTE_CRYPTO_AUTH_OP_VERIFY);
11055 	if (retval < 0)
11056 		return retval;
11057 
11058 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11059 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11060 			"Failed to allocate input buffer in mempool");
11061 
11062 	/* clear mbuf payload */
11063 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11064 			rte_pktmbuf_tailroom(ut_params->ibuf));
11065 
11066 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11067 			reference->plaintext.len);
11068 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11069 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11070 
11071 	debug_hexdump(stdout, "plaintext:", plaintext,
11072 		reference->plaintext.len);
11073 
11074 	/* Create operation */
11075 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
11076 
11077 	if (retval < 0)
11078 		return retval;
11079 
11080 	if (data_corrupted)
11081 		data_corruption(plaintext);
11082 	else
11083 		tag_corruption(plaintext, reference->plaintext.len);
11084 
11085 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11086 			ut_params->op);
11087 
11088 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11089 
11090 	return 0;
11091 }
11092 
11093 static int
11094 test_authentication_verify_GMAC_fail_when_corruption(
11095 		struct crypto_testsuite_params *ts_params,
11096 		struct crypto_unittest_params *ut_params,
11097 		const struct test_crypto_vector *reference,
11098 		unsigned int data_corrupted)
11099 {
11100 	int retval;
11101 	uint8_t *plaintext;
11102 
11103 	/* Create session */
11104 	retval = create_auth_cipher_session(ut_params,
11105 			ts_params->valid_devs[0],
11106 			reference,
11107 			RTE_CRYPTO_AUTH_OP_VERIFY,
11108 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
11109 	if (retval < 0)
11110 		return retval;
11111 
11112 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11113 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11114 			"Failed to allocate input buffer in mempool");
11115 
11116 	/* clear mbuf payload */
11117 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11118 			rte_pktmbuf_tailroom(ut_params->ibuf));
11119 
11120 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11121 			reference->plaintext.len);
11122 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11123 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11124 
11125 	debug_hexdump(stdout, "plaintext:", plaintext,
11126 		reference->plaintext.len);
11127 
11128 	/* Create operation */
11129 	retval = create_auth_verify_GMAC_operation(ts_params,
11130 			ut_params,
11131 			reference);
11132 
11133 	if (retval < 0)
11134 		return retval;
11135 
11136 	if (data_corrupted)
11137 		data_corruption(plaintext);
11138 	else
11139 		tag_corruption(plaintext, reference->aad.len);
11140 
11141 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11142 			ut_params->op);
11143 
11144 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11145 
11146 	return 0;
11147 }
11148 
11149 static int
11150 test_authenticated_decryption_fail_when_corruption(
11151 		struct crypto_testsuite_params *ts_params,
11152 		struct crypto_unittest_params *ut_params,
11153 		const struct test_crypto_vector *reference,
11154 		unsigned int data_corrupted)
11155 {
11156 	int retval;
11157 
11158 	uint8_t *ciphertext;
11159 
11160 	/* Create session */
11161 	retval = create_auth_cipher_session(ut_params,
11162 			ts_params->valid_devs[0],
11163 			reference,
11164 			RTE_CRYPTO_AUTH_OP_VERIFY,
11165 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
11166 	if (retval < 0)
11167 		return retval;
11168 
11169 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11170 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11171 			"Failed to allocate input buffer in mempool");
11172 
11173 	/* clear mbuf payload */
11174 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11175 			rte_pktmbuf_tailroom(ut_params->ibuf));
11176 
11177 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11178 			reference->ciphertext.len);
11179 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11180 	memcpy(ciphertext, reference->ciphertext.data,
11181 			reference->ciphertext.len);
11182 
11183 	/* Create operation */
11184 	retval = create_cipher_auth_verify_operation(ts_params,
11185 			ut_params,
11186 			reference);
11187 
11188 	if (retval < 0)
11189 		return retval;
11190 
11191 	if (data_corrupted)
11192 		data_corruption(ciphertext);
11193 	else
11194 		tag_corruption(ciphertext, reference->ciphertext.len);
11195 
11196 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11197 			ut_params->op);
11198 
11199 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11200 
11201 	return 0;
11202 }
11203 
11204 static int
11205 test_authenticated_encryt_with_esn(
11206 		struct crypto_testsuite_params *ts_params,
11207 		struct crypto_unittest_params *ut_params,
11208 		const struct test_crypto_vector *reference)
11209 {
11210 	int retval;
11211 
11212 	uint8_t *authciphertext, *plaintext, *auth_tag;
11213 	uint16_t plaintext_pad_len;
11214 	uint8_t cipher_key[reference->cipher_key.len + 1];
11215 	uint8_t auth_key[reference->auth_key.len + 1];
11216 
11217 	/* Create session */
11218 	memcpy(cipher_key, reference->cipher_key.data,
11219 			reference->cipher_key.len);
11220 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11221 
11222 	/* Setup Cipher Parameters */
11223 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11224 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11225 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11226 	ut_params->cipher_xform.cipher.key.data = cipher_key;
11227 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11228 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11229 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11230 
11231 	ut_params->cipher_xform.next = &ut_params->auth_xform;
11232 
11233 	/* Setup Authentication Parameters */
11234 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11235 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11236 	ut_params->auth_xform.auth.algo = reference->auth_algo;
11237 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11238 	ut_params->auth_xform.auth.key.data = auth_key;
11239 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
11240 	ut_params->auth_xform.next = NULL;
11241 
11242 	/* Create Crypto session*/
11243 	ut_params->sess = rte_cryptodev_sym_session_create(
11244 			ts_params->session_mpool);
11245 
11246 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11247 				ut_params->sess,
11248 				&ut_params->cipher_xform,
11249 				ts_params->session_priv_mpool);
11250 
11251 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11252 
11253 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11254 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11255 			"Failed to allocate input buffer in mempool");
11256 
11257 	/* clear mbuf payload */
11258 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11259 			rte_pktmbuf_tailroom(ut_params->ibuf));
11260 
11261 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11262 			reference->plaintext.len);
11263 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11264 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11265 
11266 	/* Create operation */
11267 	retval = create_cipher_auth_operation(ts_params,
11268 			ut_params,
11269 			reference, 0);
11270 
11271 	if (retval < 0)
11272 		return retval;
11273 
11274 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11275 			ut_params->op);
11276 
11277 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11278 
11279 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11280 			"crypto op processing failed");
11281 
11282 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11283 
11284 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11285 			ut_params->op->sym->auth.data.offset);
11286 	auth_tag = authciphertext + plaintext_pad_len;
11287 	debug_hexdump(stdout, "ciphertext:", authciphertext,
11288 			reference->ciphertext.len);
11289 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11290 
11291 	/* Validate obuf */
11292 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11293 			authciphertext,
11294 			reference->ciphertext.data,
11295 			reference->ciphertext.len,
11296 			"Ciphertext data not as expected");
11297 
11298 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11299 			auth_tag,
11300 			reference->digest.data,
11301 			reference->digest.len,
11302 			"Generated digest not as expected");
11303 
11304 	return TEST_SUCCESS;
11305 
11306 }
11307 
11308 static int
11309 test_authenticated_decrypt_with_esn(
11310 		struct crypto_testsuite_params *ts_params,
11311 		struct crypto_unittest_params *ut_params,
11312 		const struct test_crypto_vector *reference)
11313 {
11314 	int retval;
11315 
11316 	uint8_t *ciphertext;
11317 	uint8_t cipher_key[reference->cipher_key.len + 1];
11318 	uint8_t auth_key[reference->auth_key.len + 1];
11319 
11320 	/* Create session */
11321 	memcpy(cipher_key, reference->cipher_key.data,
11322 			reference->cipher_key.len);
11323 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11324 
11325 	/* Setup Authentication Parameters */
11326 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11327 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11328 	ut_params->auth_xform.auth.algo = reference->auth_algo;
11329 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11330 	ut_params->auth_xform.auth.key.data = auth_key;
11331 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
11332 	ut_params->auth_xform.next = &ut_params->cipher_xform;
11333 
11334 	/* Setup Cipher Parameters */
11335 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11336 	ut_params->cipher_xform.next = NULL;
11337 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11338 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11339 	ut_params->cipher_xform.cipher.key.data = cipher_key;
11340 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11341 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11342 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11343 
11344 	/* Create Crypto session*/
11345 	ut_params->sess = rte_cryptodev_sym_session_create(
11346 			ts_params->session_mpool);
11347 
11348 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11349 				ut_params->sess,
11350 				&ut_params->auth_xform,
11351 				ts_params->session_priv_mpool);
11352 
11353 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11354 
11355 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11356 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11357 			"Failed to allocate input buffer in mempool");
11358 
11359 	/* clear mbuf payload */
11360 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11361 			rte_pktmbuf_tailroom(ut_params->ibuf));
11362 
11363 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11364 			reference->ciphertext.len);
11365 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11366 	memcpy(ciphertext, reference->ciphertext.data,
11367 			reference->ciphertext.len);
11368 
11369 	/* Create operation */
11370 	retval = create_cipher_auth_verify_operation(ts_params,
11371 			ut_params,
11372 			reference);
11373 
11374 	if (retval < 0)
11375 		return retval;
11376 
11377 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11378 			ut_params->op);
11379 
11380 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11381 	TEST_ASSERT_EQUAL(ut_params->op->status,
11382 			RTE_CRYPTO_OP_STATUS_SUCCESS,
11383 			"crypto op processing passed");
11384 
11385 	ut_params->obuf = ut_params->op->sym->m_src;
11386 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11387 
11388 	return 0;
11389 }
11390 
11391 static int
11392 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11393 		const struct aead_test_data *tdata,
11394 		void *digest_mem, uint64_t digest_phys)
11395 {
11396 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11397 	struct crypto_unittest_params *ut_params = &unittest_params;
11398 
11399 	const unsigned int auth_tag_len = tdata->auth_tag.len;
11400 	const unsigned int iv_len = tdata->iv.len;
11401 	unsigned int aad_len = tdata->aad.len;
11402 	unsigned int aad_len_pad = 0;
11403 
11404 	/* Generate Crypto op data structure */
11405 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11406 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11407 	TEST_ASSERT_NOT_NULL(ut_params->op,
11408 		"Failed to allocate symmetric crypto operation struct");
11409 
11410 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11411 
11412 	sym_op->aead.digest.data = digest_mem;
11413 
11414 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11415 			"no room to append digest");
11416 
11417 	sym_op->aead.digest.phys_addr = digest_phys;
11418 
11419 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11420 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11421 				auth_tag_len);
11422 		debug_hexdump(stdout, "digest:",
11423 				sym_op->aead.digest.data,
11424 				auth_tag_len);
11425 	}
11426 
11427 	/* Append aad data */
11428 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11429 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11430 				uint8_t *, IV_OFFSET);
11431 
11432 		/* Copy IV 1 byte after the IV pointer, according to the API */
11433 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11434 
11435 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11436 
11437 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11438 				ut_params->ibuf, aad_len);
11439 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11440 				"no room to prepend aad");
11441 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11442 				ut_params->ibuf);
11443 
11444 		memset(sym_op->aead.aad.data, 0, aad_len);
11445 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
11446 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11447 
11448 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11449 		debug_hexdump(stdout, "aad:",
11450 				sym_op->aead.aad.data, aad_len);
11451 	} else {
11452 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11453 				uint8_t *, IV_OFFSET);
11454 
11455 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11456 
11457 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11458 
11459 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11460 				ut_params->ibuf, aad_len_pad);
11461 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11462 				"no room to prepend aad");
11463 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11464 				ut_params->ibuf);
11465 
11466 		memset(sym_op->aead.aad.data, 0, aad_len);
11467 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11468 
11469 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11470 		debug_hexdump(stdout, "aad:",
11471 				sym_op->aead.aad.data, aad_len);
11472 	}
11473 
11474 	sym_op->aead.data.length = tdata->plaintext.len;
11475 	sym_op->aead.data.offset = aad_len_pad;
11476 
11477 	return 0;
11478 }
11479 
11480 #define SGL_MAX_NO	16
11481 
11482 static int
11483 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11484 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11485 {
11486 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11487 	struct crypto_unittest_params *ut_params = &unittest_params;
11488 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11489 	int retval;
11490 	int to_trn = 0;
11491 	int to_trn_tbl[SGL_MAX_NO];
11492 	int segs = 1;
11493 	unsigned int trn_data = 0;
11494 	uint8_t *plaintext, *ciphertext, *auth_tag;
11495 
11496 	if (fragsz > tdata->plaintext.len)
11497 		fragsz = tdata->plaintext.len;
11498 
11499 	uint16_t plaintext_len = fragsz;
11500 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11501 
11502 	if (fragsz_oop > tdata->plaintext.len)
11503 		frag_size_oop = tdata->plaintext.len;
11504 
11505 	int ecx = 0;
11506 	void *digest_mem = NULL;
11507 
11508 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11509 
11510 	if (tdata->plaintext.len % fragsz != 0) {
11511 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11512 			return 1;
11513 	}	else {
11514 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11515 			return 1;
11516 	}
11517 
11518 	/*
11519 	 * For out-op-place we need to alloc another mbuf
11520 	 */
11521 	if (oop) {
11522 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11523 		rte_pktmbuf_append(ut_params->obuf,
11524 				frag_size_oop + prepend_len);
11525 		buf_oop = ut_params->obuf;
11526 	}
11527 
11528 	/* Create AEAD session */
11529 	retval = create_aead_session(ts_params->valid_devs[0],
11530 			tdata->algo,
11531 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
11532 			tdata->key.data, tdata->key.len,
11533 			tdata->aad.len, tdata->auth_tag.len,
11534 			tdata->iv.len);
11535 	if (retval < 0)
11536 		return retval;
11537 
11538 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11539 
11540 	/* clear mbuf payload */
11541 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11542 			rte_pktmbuf_tailroom(ut_params->ibuf));
11543 
11544 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11545 			plaintext_len);
11546 
11547 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11548 
11549 	trn_data += plaintext_len;
11550 
11551 	buf = ut_params->ibuf;
11552 
11553 	/*
11554 	 * Loop until no more fragments
11555 	 */
11556 
11557 	while (trn_data < tdata->plaintext.len) {
11558 		++segs;
11559 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11560 				(tdata->plaintext.len - trn_data) : fragsz;
11561 
11562 		to_trn_tbl[ecx++] = to_trn;
11563 
11564 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11565 		buf = buf->next;
11566 
11567 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11568 				rte_pktmbuf_tailroom(buf));
11569 
11570 		/* OOP */
11571 		if (oop && !fragsz_oop) {
11572 			buf_last_oop = buf_oop->next =
11573 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
11574 			buf_oop = buf_oop->next;
11575 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11576 					0, rte_pktmbuf_tailroom(buf_oop));
11577 			rte_pktmbuf_append(buf_oop, to_trn);
11578 		}
11579 
11580 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11581 				to_trn);
11582 
11583 		memcpy(plaintext, tdata->plaintext.data + trn_data,
11584 				to_trn);
11585 		trn_data += to_trn;
11586 		if (trn_data  == tdata->plaintext.len) {
11587 			if (oop) {
11588 				if (!fragsz_oop)
11589 					digest_mem = rte_pktmbuf_append(buf_oop,
11590 						tdata->auth_tag.len);
11591 			} else
11592 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11593 					tdata->auth_tag.len);
11594 		}
11595 	}
11596 
11597 	uint64_t digest_phys = 0;
11598 
11599 	ut_params->ibuf->nb_segs = segs;
11600 
11601 	segs = 1;
11602 	if (fragsz_oop && oop) {
11603 		to_trn = 0;
11604 		ecx = 0;
11605 
11606 		if (frag_size_oop == tdata->plaintext.len) {
11607 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
11608 				tdata->auth_tag.len);
11609 
11610 			digest_phys = rte_pktmbuf_iova_offset(
11611 					ut_params->obuf,
11612 					tdata->plaintext.len + prepend_len);
11613 		}
11614 
11615 		trn_data = frag_size_oop;
11616 		while (trn_data < tdata->plaintext.len) {
11617 			++segs;
11618 			to_trn =
11619 				(tdata->plaintext.len - trn_data <
11620 						frag_size_oop) ?
11621 				(tdata->plaintext.len - trn_data) :
11622 						frag_size_oop;
11623 
11624 			to_trn_tbl[ecx++] = to_trn;
11625 
11626 			buf_last_oop = buf_oop->next =
11627 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
11628 			buf_oop = buf_oop->next;
11629 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11630 					0, rte_pktmbuf_tailroom(buf_oop));
11631 			rte_pktmbuf_append(buf_oop, to_trn);
11632 
11633 			trn_data += to_trn;
11634 
11635 			if (trn_data  == tdata->plaintext.len) {
11636 				digest_mem = rte_pktmbuf_append(buf_oop,
11637 					tdata->auth_tag.len);
11638 			}
11639 		}
11640 
11641 		ut_params->obuf->nb_segs = segs;
11642 	}
11643 
11644 	/*
11645 	 * Place digest at the end of the last buffer
11646 	 */
11647 	if (!digest_phys)
11648 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11649 	if (oop && buf_last_oop)
11650 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11651 
11652 	if (!digest_mem && !oop) {
11653 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11654 				+ tdata->auth_tag.len);
11655 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11656 				tdata->plaintext.len);
11657 	}
11658 
11659 	/* Create AEAD operation */
11660 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11661 			tdata, digest_mem, digest_phys);
11662 
11663 	if (retval < 0)
11664 		return retval;
11665 
11666 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11667 
11668 	ut_params->op->sym->m_src = ut_params->ibuf;
11669 	if (oop)
11670 		ut_params->op->sym->m_dst = ut_params->obuf;
11671 
11672 	/* Process crypto operation */
11673 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11674 			ut_params->op), "failed to process sym crypto op");
11675 
11676 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11677 			"crypto op processing failed");
11678 
11679 
11680 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11681 			uint8_t *, prepend_len);
11682 	if (oop) {
11683 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11684 				uint8_t *, prepend_len);
11685 	}
11686 
11687 	if (fragsz_oop)
11688 		fragsz = fragsz_oop;
11689 
11690 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11691 			ciphertext,
11692 			tdata->ciphertext.data,
11693 			fragsz,
11694 			"Ciphertext data not as expected");
11695 
11696 	buf = ut_params->op->sym->m_src->next;
11697 	if (oop)
11698 		buf = ut_params->op->sym->m_dst->next;
11699 
11700 	unsigned int off = fragsz;
11701 
11702 	ecx = 0;
11703 	while (buf) {
11704 		ciphertext = rte_pktmbuf_mtod(buf,
11705 				uint8_t *);
11706 
11707 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
11708 				ciphertext,
11709 				tdata->ciphertext.data + off,
11710 				to_trn_tbl[ecx],
11711 				"Ciphertext data not as expected");
11712 
11713 		off += to_trn_tbl[ecx++];
11714 		buf = buf->next;
11715 	}
11716 
11717 	auth_tag = digest_mem;
11718 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11719 			auth_tag,
11720 			tdata->auth_tag.data,
11721 			tdata->auth_tag.len,
11722 			"Generated auth tag not as expected");
11723 
11724 	return 0;
11725 }
11726 
11727 static int
11728 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11729 {
11730 	return test_authenticated_encryption_SGL(
11731 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11732 }
11733 
11734 static int
11735 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11736 {
11737 	return test_authenticated_encryption_SGL(
11738 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11739 }
11740 
11741 static int
11742 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11743 {
11744 	return test_authenticated_encryption_SGL(
11745 			&gcm_test_case_8, OUT_OF_PLACE, 400,
11746 			gcm_test_case_8.plaintext.len);
11747 }
11748 
11749 static int
11750 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11751 {
11752 
11753 	return test_authenticated_encryption_SGL(
11754 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11755 }
11756 
11757 static int
11758 test_authentication_verify_fail_when_data_corrupted(
11759 		struct crypto_testsuite_params *ts_params,
11760 		struct crypto_unittest_params *ut_params,
11761 		const struct test_crypto_vector *reference)
11762 {
11763 	return test_authentication_verify_fail_when_data_corruption(
11764 			ts_params, ut_params, reference, 1);
11765 }
11766 
11767 static int
11768 test_authentication_verify_fail_when_tag_corrupted(
11769 		struct crypto_testsuite_params *ts_params,
11770 		struct crypto_unittest_params *ut_params,
11771 		const struct test_crypto_vector *reference)
11772 {
11773 	return test_authentication_verify_fail_when_data_corruption(
11774 			ts_params, ut_params, reference, 0);
11775 }
11776 
11777 static int
11778 test_authentication_verify_GMAC_fail_when_data_corrupted(
11779 		struct crypto_testsuite_params *ts_params,
11780 		struct crypto_unittest_params *ut_params,
11781 		const struct test_crypto_vector *reference)
11782 {
11783 	return test_authentication_verify_GMAC_fail_when_corruption(
11784 			ts_params, ut_params, reference, 1);
11785 }
11786 
11787 static int
11788 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11789 		struct crypto_testsuite_params *ts_params,
11790 		struct crypto_unittest_params *ut_params,
11791 		const struct test_crypto_vector *reference)
11792 {
11793 	return test_authentication_verify_GMAC_fail_when_corruption(
11794 			ts_params, ut_params, reference, 0);
11795 }
11796 
11797 static int
11798 test_authenticated_decryption_fail_when_data_corrupted(
11799 		struct crypto_testsuite_params *ts_params,
11800 		struct crypto_unittest_params *ut_params,
11801 		const struct test_crypto_vector *reference)
11802 {
11803 	return test_authenticated_decryption_fail_when_corruption(
11804 			ts_params, ut_params, reference, 1);
11805 }
11806 
11807 static int
11808 test_authenticated_decryption_fail_when_tag_corrupted(
11809 		struct crypto_testsuite_params *ts_params,
11810 		struct crypto_unittest_params *ut_params,
11811 		const struct test_crypto_vector *reference)
11812 {
11813 	return test_authenticated_decryption_fail_when_corruption(
11814 			ts_params, ut_params, reference, 0);
11815 }
11816 
11817 static int
11818 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11819 {
11820 	return test_authentication_verify_fail_when_data_corrupted(
11821 			&testsuite_params, &unittest_params,
11822 			&hmac_sha1_test_crypto_vector);
11823 }
11824 
11825 static int
11826 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11827 {
11828 	return test_authentication_verify_fail_when_tag_corrupted(
11829 			&testsuite_params, &unittest_params,
11830 			&hmac_sha1_test_crypto_vector);
11831 }
11832 
11833 static int
11834 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11835 {
11836 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
11837 			&testsuite_params, &unittest_params,
11838 			&aes128_gmac_test_vector);
11839 }
11840 
11841 static int
11842 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11843 {
11844 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11845 			&testsuite_params, &unittest_params,
11846 			&aes128_gmac_test_vector);
11847 }
11848 
11849 static int
11850 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11851 {
11852 	return test_authenticated_decryption_fail_when_data_corrupted(
11853 			&testsuite_params,
11854 			&unittest_params,
11855 			&aes128cbc_hmac_sha1_test_vector);
11856 }
11857 
11858 static int
11859 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11860 {
11861 	return test_authenticated_decryption_fail_when_tag_corrupted(
11862 			&testsuite_params,
11863 			&unittest_params,
11864 			&aes128cbc_hmac_sha1_test_vector);
11865 }
11866 
11867 static int
11868 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11869 {
11870 	return test_authenticated_encryt_with_esn(
11871 			&testsuite_params,
11872 			&unittest_params,
11873 			&aes128cbc_hmac_sha1_aad_test_vector);
11874 }
11875 
11876 static int
11877 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11878 {
11879 	return test_authenticated_decrypt_with_esn(
11880 			&testsuite_params,
11881 			&unittest_params,
11882 			&aes128cbc_hmac_sha1_aad_test_vector);
11883 }
11884 
11885 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11886 
11887 /* global AESNI slave IDs for the scheduler test */
11888 uint8_t aesni_ids[2];
11889 
11890 static int
11891 test_scheduler_attach_slave_op(void)
11892 {
11893 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11894 	uint8_t sched_id = ts_params->valid_devs[0];
11895 	uint32_t nb_devs, i, nb_devs_attached = 0;
11896 	int ret;
11897 	char vdev_name[32];
11898 
11899 	/* create 2 AESNI_MB if necessary */
11900 	nb_devs = rte_cryptodev_device_count_by_driver(
11901 			rte_cryptodev_driver_id_get(
11902 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11903 	if (nb_devs < 2) {
11904 		for (i = nb_devs; i < 2; i++) {
11905 			snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11906 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11907 					i);
11908 			ret = rte_vdev_init(vdev_name, NULL);
11909 
11910 			TEST_ASSERT(ret == 0,
11911 				"Failed to create instance %u of"
11912 				" pmd : %s",
11913 				i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11914 		}
11915 	}
11916 
11917 	/* attach 2 AESNI_MB cdevs */
11918 	for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11919 			i++) {
11920 		struct rte_cryptodev_info info;
11921 		unsigned int session_size;
11922 
11923 		rte_cryptodev_info_get(i, &info);
11924 		if (info.driver_id != rte_cryptodev_driver_id_get(
11925 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11926 			continue;
11927 
11928 		session_size = rte_cryptodev_sym_get_private_session_size(i);
11929 		/*
11930 		 * Create the session mempool again, since now there are new devices
11931 		 * to use the mempool.
11932 		 */
11933 		if (ts_params->session_mpool) {
11934 			rte_mempool_free(ts_params->session_mpool);
11935 			ts_params->session_mpool = NULL;
11936 		}
11937 		if (ts_params->session_priv_mpool) {
11938 			rte_mempool_free(ts_params->session_priv_mpool);
11939 			ts_params->session_priv_mpool = NULL;
11940 		}
11941 
11942 		if (info.sym.max_nb_sessions != 0 &&
11943 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11944 			RTE_LOG(ERR, USER1,
11945 					"Device does not support "
11946 					"at least %u sessions\n",
11947 					MAX_NB_SESSIONS);
11948 			return TEST_FAILED;
11949 		}
11950 		/*
11951 		 * Create mempool with maximum number of sessions,
11952 		 * to include the session headers
11953 		 */
11954 		if (ts_params->session_mpool == NULL) {
11955 			ts_params->session_mpool =
11956 				rte_cryptodev_sym_session_pool_create(
11957 						"test_sess_mp",
11958 						MAX_NB_SESSIONS, 0, 0, 0,
11959 						SOCKET_ID_ANY);
11960 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11961 					"session mempool allocation failed");
11962 		}
11963 
11964 		/*
11965 		 * Create mempool with maximum number of sessions,
11966 		 * to include device specific session private data
11967 		 */
11968 		if (ts_params->session_priv_mpool == NULL) {
11969 			ts_params->session_priv_mpool = rte_mempool_create(
11970 					"test_sess_mp_priv",
11971 					MAX_NB_SESSIONS,
11972 					session_size,
11973 					0, 0, NULL, NULL, NULL,
11974 					NULL, SOCKET_ID_ANY,
11975 					0);
11976 
11977 			TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11978 					"session mempool allocation failed");
11979 		}
11980 
11981 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
11982 		ts_params->qp_conf.mp_session_private =
11983 				ts_params->session_priv_mpool;
11984 
11985 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11986 				(uint8_t)i);
11987 
11988 		TEST_ASSERT(ret == 0,
11989 			"Failed to attach device %u of pmd : %s", i,
11990 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11991 
11992 		aesni_ids[nb_devs_attached] = (uint8_t)i;
11993 
11994 		nb_devs_attached++;
11995 	}
11996 
11997 	return 0;
11998 }
11999 
12000 static int
12001 test_scheduler_detach_slave_op(void)
12002 {
12003 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12004 	uint8_t sched_id = ts_params->valid_devs[0];
12005 	uint32_t i;
12006 	int ret;
12007 
12008 	for (i = 0; i < 2; i++) {
12009 		ret = rte_cryptodev_scheduler_slave_detach(sched_id,
12010 				aesni_ids[i]);
12011 		TEST_ASSERT(ret == 0,
12012 			"Failed to detach device %u", aesni_ids[i]);
12013 	}
12014 
12015 	return 0;
12016 }
12017 
12018 static int
12019 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12020 {
12021 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12022 	uint8_t sched_id = ts_params->valid_devs[0];
12023 	/* set mode */
12024 	return rte_cryptodev_scheduler_mode_set(sched_id,
12025 		scheduler_mode);
12026 }
12027 
12028 static int
12029 test_scheduler_mode_roundrobin_op(void)
12030 {
12031 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12032 			0, "Failed to set roundrobin mode");
12033 	return 0;
12034 
12035 }
12036 
12037 static int
12038 test_scheduler_mode_multicore_op(void)
12039 {
12040 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12041 			0, "Failed to set multicore mode");
12042 
12043 	return 0;
12044 }
12045 
12046 static int
12047 test_scheduler_mode_failover_op(void)
12048 {
12049 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12050 			0, "Failed to set failover mode");
12051 
12052 	return 0;
12053 }
12054 
12055 static int
12056 test_scheduler_mode_pkt_size_distr_op(void)
12057 {
12058 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12059 			0, "Failed to set pktsize mode");
12060 
12061 	return 0;
12062 }
12063 
12064 static struct unit_test_suite cryptodev_scheduler_testsuite  = {
12065 	.suite_name = "Crypto Device Scheduler Unit Test Suite",
12066 	.setup = testsuite_setup,
12067 	.teardown = testsuite_teardown,
12068 	.unit_test_cases = {
12069 		/* Multi Core */
12070 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12071 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12072 		TEST_CASE_ST(ut_setup, ut_teardown,
12073 					test_AES_chain_scheduler_all),
12074 		TEST_CASE_ST(ut_setup, ut_teardown,
12075 					test_AES_cipheronly_scheduler_all),
12076 		TEST_CASE_ST(ut_setup, ut_teardown,
12077 					test_authonly_scheduler_all),
12078 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12079 
12080 		/* Round Robin */
12081 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12082 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12083 		TEST_CASE_ST(ut_setup, ut_teardown,
12084 				test_AES_chain_scheduler_all),
12085 		TEST_CASE_ST(ut_setup, ut_teardown,
12086 				test_AES_cipheronly_scheduler_all),
12087 		TEST_CASE_ST(ut_setup, ut_teardown,
12088 				test_authonly_scheduler_all),
12089 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12090 
12091 		/* Fail over */
12092 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12093 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12094 		TEST_CASE_ST(ut_setup, ut_teardown,
12095 					test_AES_chain_scheduler_all),
12096 		TEST_CASE_ST(ut_setup, ut_teardown,
12097 					test_AES_cipheronly_scheduler_all),
12098 		TEST_CASE_ST(ut_setup, ut_teardown,
12099 					test_authonly_scheduler_all),
12100 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12101 
12102 		/* PKT SIZE */
12103 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12104 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12105 		TEST_CASE_ST(ut_setup, ut_teardown,
12106 					test_AES_chain_scheduler_all),
12107 		TEST_CASE_ST(ut_setup, ut_teardown,
12108 					test_AES_cipheronly_scheduler_all),
12109 		TEST_CASE_ST(ut_setup, ut_teardown,
12110 					test_authonly_scheduler_all),
12111 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12112 
12113 		TEST_CASES_END() /**< NULL terminate unit test array */
12114 	}
12115 };
12116 
12117 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12118 
12119 static struct unit_test_suite cryptodev_qat_testsuite  = {
12120 	.suite_name = "Crypto QAT Unit Test Suite",
12121 	.setup = testsuite_setup,
12122 	.teardown = testsuite_teardown,
12123 	.unit_test_cases = {
12124 		TEST_CASE_ST(ut_setup, ut_teardown,
12125 				test_device_configure_invalid_dev_id),
12126 		TEST_CASE_ST(ut_setup, ut_teardown,
12127 				test_device_configure_invalid_queue_pair_ids),
12128 		TEST_CASE_ST(ut_setup, ut_teardown,
12129 				test_queue_pair_descriptor_setup),
12130 		TEST_CASE_ST(ut_setup, ut_teardown,
12131 				test_multi_session),
12132 
12133 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
12134 		TEST_CASE_ST(ut_setup, ut_teardown,
12135 						test_AES_cipheronly_qat_all),
12136 		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
12137 		TEST_CASE_ST(ut_setup, ut_teardown,
12138 						test_3DES_cipheronly_qat_all),
12139 		TEST_CASE_ST(ut_setup, ut_teardown,
12140 						test_DES_cipheronly_qat_all),
12141 		TEST_CASE_ST(ut_setup, ut_teardown,
12142 						test_AES_docsis_qat_all),
12143 		TEST_CASE_ST(ut_setup, ut_teardown,
12144 						test_DES_docsis_qat_all),
12145 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
12146 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12147 
12148 		/** AES CCM Authenticated Encryption 128 bits key */
12149 		TEST_CASE_ST(ut_setup, ut_teardown,
12150 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12151 		TEST_CASE_ST(ut_setup, ut_teardown,
12152 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12153 		TEST_CASE_ST(ut_setup, ut_teardown,
12154 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12155 
12156 		/** AES CCM Authenticated Decryption 128 bits key*/
12157 		TEST_CASE_ST(ut_setup, ut_teardown,
12158 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12159 		TEST_CASE_ST(ut_setup, ut_teardown,
12160 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12161 		TEST_CASE_ST(ut_setup, ut_teardown,
12162 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12163 
12164 		/** AES GCM Authenticated Encryption */
12165 		TEST_CASE_ST(ut_setup, ut_teardown,
12166 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12167 		TEST_CASE_ST(ut_setup, ut_teardown,
12168 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12169 		TEST_CASE_ST(ut_setup, ut_teardown,
12170 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12171 		TEST_CASE_ST(ut_setup, ut_teardown,
12172 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12173 		TEST_CASE_ST(ut_setup, ut_teardown,
12174 			test_AES_GCM_authenticated_encryption_test_case_1),
12175 		TEST_CASE_ST(ut_setup, ut_teardown,
12176 			test_AES_GCM_authenticated_encryption_test_case_2),
12177 		TEST_CASE_ST(ut_setup, ut_teardown,
12178 			test_AES_GCM_authenticated_encryption_test_case_3),
12179 		TEST_CASE_ST(ut_setup, ut_teardown,
12180 			test_AES_GCM_authenticated_encryption_test_case_4),
12181 		TEST_CASE_ST(ut_setup, ut_teardown,
12182 			test_AES_GCM_authenticated_encryption_test_case_5),
12183 		TEST_CASE_ST(ut_setup, ut_teardown,
12184 			test_AES_GCM_authenticated_encryption_test_case_6),
12185 		TEST_CASE_ST(ut_setup, ut_teardown,
12186 			test_AES_GCM_authenticated_encryption_test_case_7),
12187 		TEST_CASE_ST(ut_setup, ut_teardown,
12188 			test_AES_GCM_authenticated_encryption_test_case_8),
12189 
12190 		/** AES GCM Authenticated Decryption */
12191 		TEST_CASE_ST(ut_setup, ut_teardown,
12192 			test_AES_GCM_authenticated_decryption_test_case_1),
12193 		TEST_CASE_ST(ut_setup, ut_teardown,
12194 			test_AES_GCM_authenticated_decryption_test_case_2),
12195 		TEST_CASE_ST(ut_setup, ut_teardown,
12196 			test_AES_GCM_authenticated_decryption_test_case_3),
12197 		TEST_CASE_ST(ut_setup, ut_teardown,
12198 			test_AES_GCM_authenticated_decryption_test_case_4),
12199 		TEST_CASE_ST(ut_setup, ut_teardown,
12200 			test_AES_GCM_authenticated_decryption_test_case_5),
12201 		TEST_CASE_ST(ut_setup, ut_teardown,
12202 			test_AES_GCM_authenticated_decryption_test_case_6),
12203 		TEST_CASE_ST(ut_setup, ut_teardown,
12204 			test_AES_GCM_authenticated_decryption_test_case_7),
12205 		TEST_CASE_ST(ut_setup, ut_teardown,
12206 			test_AES_GCM_authenticated_decryption_test_case_8),
12207 
12208 		/** AES GCM Authenticated Encryption 192 bits key */
12209 		TEST_CASE_ST(ut_setup, ut_teardown,
12210 			test_AES_GCM_auth_encryption_test_case_192_1),
12211 		TEST_CASE_ST(ut_setup, ut_teardown,
12212 			test_AES_GCM_auth_encryption_test_case_192_2),
12213 		TEST_CASE_ST(ut_setup, ut_teardown,
12214 			test_AES_GCM_auth_encryption_test_case_192_3),
12215 		TEST_CASE_ST(ut_setup, ut_teardown,
12216 			test_AES_GCM_auth_encryption_test_case_192_4),
12217 		TEST_CASE_ST(ut_setup, ut_teardown,
12218 			test_AES_GCM_auth_encryption_test_case_192_5),
12219 		TEST_CASE_ST(ut_setup, ut_teardown,
12220 			test_AES_GCM_auth_encryption_test_case_192_6),
12221 		TEST_CASE_ST(ut_setup, ut_teardown,
12222 			test_AES_GCM_auth_encryption_test_case_192_7),
12223 
12224 		/** AES GCM Authenticated Decryption 192 bits key */
12225 		TEST_CASE_ST(ut_setup, ut_teardown,
12226 			test_AES_GCM_auth_decryption_test_case_192_1),
12227 		TEST_CASE_ST(ut_setup, ut_teardown,
12228 			test_AES_GCM_auth_decryption_test_case_192_2),
12229 		TEST_CASE_ST(ut_setup, ut_teardown,
12230 			test_AES_GCM_auth_decryption_test_case_192_3),
12231 		TEST_CASE_ST(ut_setup, ut_teardown,
12232 			test_AES_GCM_auth_decryption_test_case_192_4),
12233 		TEST_CASE_ST(ut_setup, ut_teardown,
12234 			test_AES_GCM_auth_decryption_test_case_192_5),
12235 		TEST_CASE_ST(ut_setup, ut_teardown,
12236 			test_AES_GCM_auth_decryption_test_case_192_6),
12237 		TEST_CASE_ST(ut_setup, ut_teardown,
12238 			test_AES_GCM_auth_decryption_test_case_192_7),
12239 
12240 		/** AES GCM Authenticated Encryption 256 bits key */
12241 		TEST_CASE_ST(ut_setup, ut_teardown,
12242 			test_AES_GCM_auth_encryption_test_case_256_1),
12243 		TEST_CASE_ST(ut_setup, ut_teardown,
12244 			test_AES_GCM_auth_encryption_test_case_256_2),
12245 		TEST_CASE_ST(ut_setup, ut_teardown,
12246 			test_AES_GCM_auth_encryption_test_case_256_3),
12247 		TEST_CASE_ST(ut_setup, ut_teardown,
12248 			test_AES_GCM_auth_encryption_test_case_256_4),
12249 		TEST_CASE_ST(ut_setup, ut_teardown,
12250 			test_AES_GCM_auth_encryption_test_case_256_5),
12251 		TEST_CASE_ST(ut_setup, ut_teardown,
12252 			test_AES_GCM_auth_encryption_test_case_256_6),
12253 		TEST_CASE_ST(ut_setup, ut_teardown,
12254 			test_AES_GCM_auth_encryption_test_case_256_7),
12255 
12256 		/** AES GCM Authenticated Decryption 256 bits key */
12257 		TEST_CASE_ST(ut_setup, ut_teardown,
12258 			test_AES_GCM_auth_decryption_test_case_256_1),
12259 		TEST_CASE_ST(ut_setup, ut_teardown,
12260 			test_AES_GCM_auth_decryption_test_case_256_2),
12261 		TEST_CASE_ST(ut_setup, ut_teardown,
12262 			test_AES_GCM_auth_decryption_test_case_256_3),
12263 		TEST_CASE_ST(ut_setup, ut_teardown,
12264 			test_AES_GCM_auth_decryption_test_case_256_4),
12265 		TEST_CASE_ST(ut_setup, ut_teardown,
12266 			test_AES_GCM_auth_decryption_test_case_256_5),
12267 		TEST_CASE_ST(ut_setup, ut_teardown,
12268 			test_AES_GCM_auth_decryption_test_case_256_6),
12269 		TEST_CASE_ST(ut_setup, ut_teardown,
12270 			test_AES_GCM_auth_decryption_test_case_256_7),
12271 
12272 		/** AES GMAC Authentication */
12273 		TEST_CASE_ST(ut_setup, ut_teardown,
12274 			test_AES_GMAC_authentication_test_case_1),
12275 		TEST_CASE_ST(ut_setup, ut_teardown,
12276 			test_AES_GMAC_authentication_verify_test_case_1),
12277 		TEST_CASE_ST(ut_setup, ut_teardown,
12278 			test_AES_GMAC_authentication_test_case_2),
12279 		TEST_CASE_ST(ut_setup, ut_teardown,
12280 			test_AES_GMAC_authentication_verify_test_case_2),
12281 		TEST_CASE_ST(ut_setup, ut_teardown,
12282 			test_AES_GMAC_authentication_test_case_3),
12283 		TEST_CASE_ST(ut_setup, ut_teardown,
12284 			test_AES_GMAC_authentication_verify_test_case_3),
12285 
12286 		/** SNOW 3G encrypt only (UEA2) */
12287 		TEST_CASE_ST(ut_setup, ut_teardown,
12288 			test_snow3g_encryption_test_case_1),
12289 		TEST_CASE_ST(ut_setup, ut_teardown,
12290 			test_snow3g_encryption_test_case_2),
12291 		TEST_CASE_ST(ut_setup, ut_teardown,
12292 			test_snow3g_encryption_test_case_3),
12293 		TEST_CASE_ST(ut_setup, ut_teardown,
12294 			test_snow3g_encryption_test_case_4),
12295 		TEST_CASE_ST(ut_setup, ut_teardown,
12296 			test_snow3g_encryption_test_case_5),
12297 
12298 		TEST_CASE_ST(ut_setup, ut_teardown,
12299 			test_snow3g_encryption_test_case_1_oop),
12300 		TEST_CASE_ST(ut_setup, ut_teardown,
12301 			test_snow3g_decryption_test_case_1_oop),
12302 
12303 		/** SNOW 3G generate auth, then encrypt (UEA2) */
12304 		TEST_CASE_ST(ut_setup, ut_teardown,
12305 			test_snow3g_auth_cipher_test_case_1),
12306 		TEST_CASE_ST(ut_setup, ut_teardown,
12307 			test_snow3g_auth_cipher_test_case_2),
12308 		TEST_CASE_ST(ut_setup, ut_teardown,
12309 			test_snow3g_auth_cipher_test_case_2_oop),
12310 		TEST_CASE_ST(ut_setup, ut_teardown,
12311 			test_snow3g_auth_cipher_part_digest_enc),
12312 		TEST_CASE_ST(ut_setup, ut_teardown,
12313 			test_snow3g_auth_cipher_part_digest_enc_oop),
12314 		TEST_CASE_ST(ut_setup, ut_teardown,
12315 			test_snow3g_auth_cipher_test_case_3_sgl),
12316 		TEST_CASE_ST(ut_setup, ut_teardown,
12317 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
12318 		TEST_CASE_ST(ut_setup, ut_teardown,
12319 			test_snow3g_auth_cipher_part_digest_enc_sgl),
12320 		TEST_CASE_ST(ut_setup, ut_teardown,
12321 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12322 
12323 		/** SNOW 3G decrypt (UEA2), then verify auth */
12324 		TEST_CASE_ST(ut_setup, ut_teardown,
12325 			test_snow3g_auth_cipher_verify_test_case_1),
12326 		TEST_CASE_ST(ut_setup, ut_teardown,
12327 			test_snow3g_auth_cipher_verify_test_case_2),
12328 		TEST_CASE_ST(ut_setup, ut_teardown,
12329 			test_snow3g_auth_cipher_verify_test_case_2_oop),
12330 		TEST_CASE_ST(ut_setup, ut_teardown,
12331 			test_snow3g_auth_cipher_verify_part_digest_enc),
12332 		TEST_CASE_ST(ut_setup, ut_teardown,
12333 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12334 		TEST_CASE_ST(ut_setup, ut_teardown,
12335 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
12336 		TEST_CASE_ST(ut_setup, ut_teardown,
12337 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12338 		TEST_CASE_ST(ut_setup, ut_teardown,
12339 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12340 		TEST_CASE_ST(ut_setup, ut_teardown,
12341 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12342 
12343 		/** SNOW 3G decrypt only (UEA2) */
12344 		TEST_CASE_ST(ut_setup, ut_teardown,
12345 			test_snow3g_decryption_test_case_1),
12346 		TEST_CASE_ST(ut_setup, ut_teardown,
12347 			test_snow3g_decryption_test_case_2),
12348 		TEST_CASE_ST(ut_setup, ut_teardown,
12349 			test_snow3g_decryption_test_case_3),
12350 		TEST_CASE_ST(ut_setup, ut_teardown,
12351 			test_snow3g_decryption_test_case_4),
12352 		TEST_CASE_ST(ut_setup, ut_teardown,
12353 			test_snow3g_decryption_test_case_5),
12354 		TEST_CASE_ST(ut_setup, ut_teardown,
12355 			test_snow3g_decryption_with_digest_test_case_1),
12356 		TEST_CASE_ST(ut_setup, ut_teardown,
12357 			test_snow3g_hash_generate_test_case_1),
12358 		TEST_CASE_ST(ut_setup, ut_teardown,
12359 			test_snow3g_hash_generate_test_case_2),
12360 		TEST_CASE_ST(ut_setup, ut_teardown,
12361 			test_snow3g_hash_generate_test_case_3),
12362 		TEST_CASE_ST(ut_setup, ut_teardown,
12363 			test_snow3g_hash_verify_test_case_1),
12364 		TEST_CASE_ST(ut_setup, ut_teardown,
12365 			test_snow3g_hash_verify_test_case_2),
12366 		TEST_CASE_ST(ut_setup, ut_teardown,
12367 			test_snow3g_hash_verify_test_case_3),
12368 		TEST_CASE_ST(ut_setup, ut_teardown,
12369 			test_snow3g_cipher_auth_test_case_1),
12370 		TEST_CASE_ST(ut_setup, ut_teardown,
12371 			test_snow3g_auth_cipher_with_digest_test_case_1),
12372 
12373 		/** ZUC encrypt only (EEA3) */
12374 		TEST_CASE_ST(ut_setup, ut_teardown,
12375 			test_zuc_encryption_test_case_1),
12376 		TEST_CASE_ST(ut_setup, ut_teardown,
12377 			test_zuc_encryption_test_case_2),
12378 		TEST_CASE_ST(ut_setup, ut_teardown,
12379 			test_zuc_encryption_test_case_3),
12380 		TEST_CASE_ST(ut_setup, ut_teardown,
12381 			test_zuc_encryption_test_case_4),
12382 		TEST_CASE_ST(ut_setup, ut_teardown,
12383 			test_zuc_encryption_test_case_5),
12384 
12385 		/** ZUC authenticate (EIA3) */
12386 		TEST_CASE_ST(ut_setup, ut_teardown,
12387 			test_zuc_hash_generate_test_case_6),
12388 		TEST_CASE_ST(ut_setup, ut_teardown,
12389 			test_zuc_hash_generate_test_case_7),
12390 		TEST_CASE_ST(ut_setup, ut_teardown,
12391 			test_zuc_hash_generate_test_case_8),
12392 
12393 		/** ZUC alg-chain (EEA3/EIA3) */
12394 		TEST_CASE_ST(ut_setup, ut_teardown,
12395 			test_zuc_cipher_auth_test_case_1),
12396 		TEST_CASE_ST(ut_setup, ut_teardown,
12397 			test_zuc_cipher_auth_test_case_2),
12398 
12399 		/** ZUC generate auth, then encrypt (EEA3) */
12400 		TEST_CASE_ST(ut_setup, ut_teardown,
12401 			test_zuc_auth_cipher_test_case_1),
12402 		TEST_CASE_ST(ut_setup, ut_teardown,
12403 			test_zuc_auth_cipher_test_case_1_oop),
12404 		TEST_CASE_ST(ut_setup, ut_teardown,
12405 			test_zuc_auth_cipher_test_case_1_sgl),
12406 		TEST_CASE_ST(ut_setup, ut_teardown,
12407 			test_zuc_auth_cipher_test_case_1_oop_sgl),
12408 
12409 		/** ZUC decrypt (EEA3), then verify auth */
12410 		TEST_CASE_ST(ut_setup, ut_teardown,
12411 			test_zuc_auth_cipher_verify_test_case_1),
12412 		TEST_CASE_ST(ut_setup, ut_teardown,
12413 			test_zuc_auth_cipher_verify_test_case_1_oop),
12414 		TEST_CASE_ST(ut_setup, ut_teardown,
12415 			test_zuc_auth_cipher_verify_test_case_1_sgl),
12416 		TEST_CASE_ST(ut_setup, ut_teardown,
12417 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12418 
12419 		/** HMAC_MD5 Authentication */
12420 		TEST_CASE_ST(ut_setup, ut_teardown,
12421 			test_MD5_HMAC_generate_case_1),
12422 		TEST_CASE_ST(ut_setup, ut_teardown,
12423 			test_MD5_HMAC_verify_case_1),
12424 		TEST_CASE_ST(ut_setup, ut_teardown,
12425 			test_MD5_HMAC_generate_case_2),
12426 		TEST_CASE_ST(ut_setup, ut_teardown,
12427 			test_MD5_HMAC_verify_case_2),
12428 
12429 		/** NULL algo tests done in chain_all,
12430 		 * cipheronly and authonly suites
12431 		 */
12432 
12433 		/** KASUMI tests */
12434 		TEST_CASE_ST(ut_setup, ut_teardown,
12435 			test_kasumi_hash_generate_test_case_1),
12436 		TEST_CASE_ST(ut_setup, ut_teardown,
12437 			test_kasumi_hash_generate_test_case_2),
12438 		TEST_CASE_ST(ut_setup, ut_teardown,
12439 			test_kasumi_hash_generate_test_case_3),
12440 		TEST_CASE_ST(ut_setup, ut_teardown,
12441 			test_kasumi_hash_generate_test_case_4),
12442 		TEST_CASE_ST(ut_setup, ut_teardown,
12443 			test_kasumi_hash_generate_test_case_5),
12444 		TEST_CASE_ST(ut_setup, ut_teardown,
12445 			test_kasumi_hash_generate_test_case_6),
12446 
12447 		TEST_CASE_ST(ut_setup, ut_teardown,
12448 			test_kasumi_hash_verify_test_case_1),
12449 		TEST_CASE_ST(ut_setup, ut_teardown,
12450 			test_kasumi_hash_verify_test_case_2),
12451 		TEST_CASE_ST(ut_setup, ut_teardown,
12452 			test_kasumi_hash_verify_test_case_3),
12453 		TEST_CASE_ST(ut_setup, ut_teardown,
12454 			test_kasumi_hash_verify_test_case_4),
12455 		TEST_CASE_ST(ut_setup, ut_teardown,
12456 			test_kasumi_hash_verify_test_case_5),
12457 
12458 		TEST_CASE_ST(ut_setup, ut_teardown,
12459 			test_kasumi_encryption_test_case_1),
12460 		TEST_CASE_ST(ut_setup, ut_teardown,
12461 			test_kasumi_encryption_test_case_3),
12462 		TEST_CASE_ST(ut_setup, ut_teardown,
12463 			test_kasumi_cipher_auth_test_case_1),
12464 
12465 		/** KASUMI generate auth, then encrypt (F8) */
12466 		TEST_CASE_ST(ut_setup, ut_teardown,
12467 			test_kasumi_auth_cipher_test_case_1),
12468 		TEST_CASE_ST(ut_setup, ut_teardown,
12469 			test_kasumi_auth_cipher_test_case_2),
12470 		TEST_CASE_ST(ut_setup, ut_teardown,
12471 			test_kasumi_auth_cipher_test_case_2_oop),
12472 		TEST_CASE_ST(ut_setup, ut_teardown,
12473 			test_kasumi_auth_cipher_test_case_2_sgl),
12474 		TEST_CASE_ST(ut_setup, ut_teardown,
12475 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
12476 
12477 		/** KASUMI decrypt (F8), then verify auth */
12478 		TEST_CASE_ST(ut_setup, ut_teardown,
12479 			test_kasumi_auth_cipher_verify_test_case_1),
12480 		TEST_CASE_ST(ut_setup, ut_teardown,
12481 			test_kasumi_auth_cipher_verify_test_case_2),
12482 		TEST_CASE_ST(ut_setup, ut_teardown,
12483 			test_kasumi_auth_cipher_verify_test_case_2_oop),
12484 		TEST_CASE_ST(ut_setup, ut_teardown,
12485 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
12486 		TEST_CASE_ST(ut_setup, ut_teardown,
12487 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12488 
12489 		/** Negative tests */
12490 		TEST_CASE_ST(ut_setup, ut_teardown,
12491 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
12492 		TEST_CASE_ST(ut_setup, ut_teardown,
12493 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12494 		TEST_CASE_ST(ut_setup, ut_teardown,
12495 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
12496 		TEST_CASE_ST(ut_setup, ut_teardown,
12497 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12498 		TEST_CASE_ST(ut_setup, ut_teardown,
12499 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12500 		TEST_CASE_ST(ut_setup, ut_teardown,
12501 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12502 		TEST_CASE_ST(ut_setup, ut_teardown,
12503 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
12504 		TEST_CASE_ST(ut_setup, ut_teardown,
12505 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
12506 		TEST_CASE_ST(ut_setup, ut_teardown,
12507 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
12508 		TEST_CASE_ST(ut_setup, ut_teardown,
12509 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12510 		TEST_CASE_ST(ut_setup, ut_teardown,
12511 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12512 		TEST_CASE_ST(ut_setup, ut_teardown,
12513 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12514 		TEST_CASE_ST(ut_setup, ut_teardown,
12515 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
12516 		TEST_CASE_ST(ut_setup, ut_teardown,
12517 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
12518 		TEST_CASE_ST(ut_setup, ut_teardown,
12519 			authentication_verify_AES128_GMAC_fail_data_corrupt),
12520 		TEST_CASE_ST(ut_setup, ut_teardown,
12521 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
12522 		TEST_CASE_ST(ut_setup, ut_teardown,
12523 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12524 		TEST_CASE_ST(ut_setup, ut_teardown,
12525 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12526 
12527 		/** Mixed CIPHER + HASH algorithms */
12528 		/** AUTH AES CMAC + CIPHER AES CTR */
12529 		TEST_CASE_ST(ut_setup, ut_teardown,
12530 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12531 		TEST_CASE_ST(ut_setup, ut_teardown,
12532 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12533 		TEST_CASE_ST(ut_setup, ut_teardown,
12534 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12535 		TEST_CASE_ST(ut_setup, ut_teardown,
12536 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12537 		TEST_CASE_ST(ut_setup, ut_teardown,
12538 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12539 		TEST_CASE_ST(ut_setup, ut_teardown,
12540 		       test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12541 		TEST_CASE_ST(ut_setup, ut_teardown,
12542 		       test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12543 		TEST_CASE_ST(ut_setup, ut_teardown,
12544 		   test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12545 
12546 		/** AUTH ZUC + CIPHER SNOW3G */
12547 		TEST_CASE_ST(ut_setup, ut_teardown,
12548 			test_auth_zuc_cipher_snow_test_case_1),
12549 		TEST_CASE_ST(ut_setup, ut_teardown,
12550 			test_verify_auth_zuc_cipher_snow_test_case_1),
12551 		/** AUTH AES CMAC + CIPHER SNOW3G */
12552 		TEST_CASE_ST(ut_setup, ut_teardown,
12553 			test_auth_aes_cmac_cipher_snow_test_case_1),
12554 		TEST_CASE_ST(ut_setup, ut_teardown,
12555 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12556 		/** AUTH ZUC + CIPHER AES CTR */
12557 		TEST_CASE_ST(ut_setup, ut_teardown,
12558 			test_auth_zuc_cipher_aes_ctr_test_case_1),
12559 		TEST_CASE_ST(ut_setup, ut_teardown,
12560 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12561 		/** AUTH SNOW3G + CIPHER AES CTR */
12562 		TEST_CASE_ST(ut_setup, ut_teardown,
12563 			test_auth_snow_cipher_aes_ctr_test_case_1),
12564 		TEST_CASE_ST(ut_setup, ut_teardown,
12565 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12566 		/** AUTH SNOW3G + CIPHER ZUC */
12567 		TEST_CASE_ST(ut_setup, ut_teardown,
12568 			test_auth_snow_cipher_zuc_test_case_1),
12569 		TEST_CASE_ST(ut_setup, ut_teardown,
12570 			test_verify_auth_snow_cipher_zuc_test_case_1),
12571 		/** AUTH AES CMAC + CIPHER ZUC */
12572 		TEST_CASE_ST(ut_setup, ut_teardown,
12573 			test_auth_aes_cmac_cipher_zuc_test_case_1),
12574 		TEST_CASE_ST(ut_setup, ut_teardown,
12575 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12576 
12577 		/** AUTH NULL + CIPHER SNOW3G */
12578 		TEST_CASE_ST(ut_setup, ut_teardown,
12579 			test_auth_null_cipher_snow_test_case_1),
12580 		TEST_CASE_ST(ut_setup, ut_teardown,
12581 			test_verify_auth_null_cipher_snow_test_case_1),
12582 		/** AUTH NULL + CIPHER ZUC */
12583 		TEST_CASE_ST(ut_setup, ut_teardown,
12584 			test_auth_null_cipher_zuc_test_case_1),
12585 		TEST_CASE_ST(ut_setup, ut_teardown,
12586 			test_verify_auth_null_cipher_zuc_test_case_1),
12587 		/** AUTH SNOW3G + CIPHER NULL */
12588 		TEST_CASE_ST(ut_setup, ut_teardown,
12589 			test_auth_snow_cipher_null_test_case_1),
12590 		TEST_CASE_ST(ut_setup, ut_teardown,
12591 			test_verify_auth_snow_cipher_null_test_case_1),
12592 		/** AUTH ZUC + CIPHER NULL */
12593 		TEST_CASE_ST(ut_setup, ut_teardown,
12594 			test_auth_zuc_cipher_null_test_case_1),
12595 		TEST_CASE_ST(ut_setup, ut_teardown,
12596 			test_verify_auth_zuc_cipher_null_test_case_1),
12597 		/** AUTH NULL + CIPHER AES CTR */
12598 		TEST_CASE_ST(ut_setup, ut_teardown,
12599 			test_auth_null_cipher_aes_ctr_test_case_1),
12600 		TEST_CASE_ST(ut_setup, ut_teardown,
12601 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
12602 		/** AUTH AES CMAC + CIPHER NULL */
12603 		TEST_CASE_ST(ut_setup, ut_teardown,
12604 			test_auth_aes_cmac_cipher_null_test_case_1),
12605 		TEST_CASE_ST(ut_setup, ut_teardown,
12606 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
12607 
12608 		TEST_CASES_END() /**< NULL terminate unit test array */
12609 	}
12610 };
12611 
12612 static struct unit_test_suite cryptodev_virtio_testsuite = {
12613 	.suite_name = "Crypto VIRTIO Unit Test Suite",
12614 	.setup = testsuite_setup,
12615 	.teardown = testsuite_teardown,
12616 	.unit_test_cases = {
12617 		TEST_CASE_ST(ut_setup, ut_teardown,
12618 				test_AES_cipheronly_virtio_all),
12619 
12620 		TEST_CASES_END() /**< NULL terminate unit test array */
12621 	}
12622 };
12623 
12624 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
12625 	.suite_name = "Crypto Device AESNI MB Unit Test Suite",
12626 	.setup = testsuite_setup,
12627 	.teardown = testsuite_teardown,
12628 	.unit_test_cases = {
12629 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12630 		TEST_CASE_ST(ut_setup, ut_teardown,
12631 			test_AES_GCM_authenticated_encryption_test_case_1),
12632 		TEST_CASE_ST(ut_setup, ut_teardown,
12633 			test_AES_GCM_authenticated_encryption_test_case_2),
12634 		TEST_CASE_ST(ut_setup, ut_teardown,
12635 			test_AES_GCM_authenticated_encryption_test_case_3),
12636 		TEST_CASE_ST(ut_setup, ut_teardown,
12637 			test_AES_GCM_authenticated_encryption_test_case_4),
12638 		TEST_CASE_ST(ut_setup, ut_teardown,
12639 			test_AES_GCM_authenticated_encryption_test_case_5),
12640 		TEST_CASE_ST(ut_setup, ut_teardown,
12641 			test_AES_GCM_authenticated_encryption_test_case_6),
12642 		TEST_CASE_ST(ut_setup, ut_teardown,
12643 			test_AES_GCM_authenticated_encryption_test_case_7),
12644 
12645 		/** AES GCM Authenticated Decryption */
12646 		TEST_CASE_ST(ut_setup, ut_teardown,
12647 			test_AES_GCM_authenticated_decryption_test_case_1),
12648 		TEST_CASE_ST(ut_setup, ut_teardown,
12649 			test_AES_GCM_authenticated_decryption_test_case_2),
12650 		TEST_CASE_ST(ut_setup, ut_teardown,
12651 			test_AES_GCM_authenticated_decryption_test_case_3),
12652 		TEST_CASE_ST(ut_setup, ut_teardown,
12653 			test_AES_GCM_authenticated_decryption_test_case_4),
12654 		TEST_CASE_ST(ut_setup, ut_teardown,
12655 			test_AES_GCM_authenticated_decryption_test_case_5),
12656 		TEST_CASE_ST(ut_setup, ut_teardown,
12657 			test_AES_GCM_authenticated_decryption_test_case_6),
12658 		TEST_CASE_ST(ut_setup, ut_teardown,
12659 			test_AES_GCM_authenticated_decryption_test_case_7),
12660 
12661 		/** AES GCM Authenticated Encryption 192 bits key */
12662 		TEST_CASE_ST(ut_setup, ut_teardown,
12663 			test_AES_GCM_auth_encryption_test_case_192_1),
12664 		TEST_CASE_ST(ut_setup, ut_teardown,
12665 			test_AES_GCM_auth_encryption_test_case_192_2),
12666 		TEST_CASE_ST(ut_setup, ut_teardown,
12667 			test_AES_GCM_auth_encryption_test_case_192_3),
12668 		TEST_CASE_ST(ut_setup, ut_teardown,
12669 			test_AES_GCM_auth_encryption_test_case_192_4),
12670 		TEST_CASE_ST(ut_setup, ut_teardown,
12671 			test_AES_GCM_auth_encryption_test_case_192_5),
12672 		TEST_CASE_ST(ut_setup, ut_teardown,
12673 			test_AES_GCM_auth_encryption_test_case_192_6),
12674 		TEST_CASE_ST(ut_setup, ut_teardown,
12675 			test_AES_GCM_auth_encryption_test_case_192_7),
12676 
12677 		/** AES GCM Authenticated Decryption 192 bits key */
12678 		TEST_CASE_ST(ut_setup, ut_teardown,
12679 			test_AES_GCM_auth_decryption_test_case_192_1),
12680 		TEST_CASE_ST(ut_setup, ut_teardown,
12681 			test_AES_GCM_auth_decryption_test_case_192_2),
12682 		TEST_CASE_ST(ut_setup, ut_teardown,
12683 			test_AES_GCM_auth_decryption_test_case_192_3),
12684 		TEST_CASE_ST(ut_setup, ut_teardown,
12685 			test_AES_GCM_auth_decryption_test_case_192_4),
12686 		TEST_CASE_ST(ut_setup, ut_teardown,
12687 			test_AES_GCM_auth_decryption_test_case_192_5),
12688 		TEST_CASE_ST(ut_setup, ut_teardown,
12689 			test_AES_GCM_auth_decryption_test_case_192_6),
12690 		TEST_CASE_ST(ut_setup, ut_teardown,
12691 			test_AES_GCM_auth_decryption_test_case_192_7),
12692 
12693 		/** AES GCM Authenticated Encryption 256 bits key */
12694 		TEST_CASE_ST(ut_setup, ut_teardown,
12695 			test_AES_GCM_auth_encryption_test_case_256_1),
12696 		TEST_CASE_ST(ut_setup, ut_teardown,
12697 			test_AES_GCM_auth_encryption_test_case_256_2),
12698 		TEST_CASE_ST(ut_setup, ut_teardown,
12699 			test_AES_GCM_auth_encryption_test_case_256_3),
12700 		TEST_CASE_ST(ut_setup, ut_teardown,
12701 			test_AES_GCM_auth_encryption_test_case_256_4),
12702 		TEST_CASE_ST(ut_setup, ut_teardown,
12703 			test_AES_GCM_auth_encryption_test_case_256_5),
12704 		TEST_CASE_ST(ut_setup, ut_teardown,
12705 			test_AES_GCM_auth_encryption_test_case_256_6),
12706 		TEST_CASE_ST(ut_setup, ut_teardown,
12707 			test_AES_GCM_auth_encryption_test_case_256_7),
12708 
12709 		/** AES GCM Authenticated Decryption 256 bits key */
12710 		TEST_CASE_ST(ut_setup, ut_teardown,
12711 			test_AES_GCM_auth_decryption_test_case_256_1),
12712 		TEST_CASE_ST(ut_setup, ut_teardown,
12713 			test_AES_GCM_auth_decryption_test_case_256_2),
12714 		TEST_CASE_ST(ut_setup, ut_teardown,
12715 			test_AES_GCM_auth_decryption_test_case_256_3),
12716 		TEST_CASE_ST(ut_setup, ut_teardown,
12717 			test_AES_GCM_auth_decryption_test_case_256_4),
12718 		TEST_CASE_ST(ut_setup, ut_teardown,
12719 			test_AES_GCM_auth_decryption_test_case_256_5),
12720 		TEST_CASE_ST(ut_setup, ut_teardown,
12721 			test_AES_GCM_auth_decryption_test_case_256_6),
12722 		TEST_CASE_ST(ut_setup, ut_teardown,
12723 			test_AES_GCM_auth_decryption_test_case_256_7),
12724 
12725 		/** AES GCM Authenticated Encryption big aad size */
12726 		TEST_CASE_ST(ut_setup, ut_teardown,
12727 			test_AES_GCM_auth_encryption_test_case_aad_1),
12728 		TEST_CASE_ST(ut_setup, ut_teardown,
12729 			test_AES_GCM_auth_encryption_test_case_aad_2),
12730 
12731 		/** AES GCM Authenticated Decryption big aad size */
12732 		TEST_CASE_ST(ut_setup, ut_teardown,
12733 			test_AES_GCM_auth_decryption_test_case_aad_1),
12734 		TEST_CASE_ST(ut_setup, ut_teardown,
12735 			test_AES_GCM_auth_decryption_test_case_aad_2),
12736 
12737 		/** Session-less tests */
12738 		TEST_CASE_ST(ut_setup, ut_teardown,
12739 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12740 		TEST_CASE_ST(ut_setup, ut_teardown,
12741 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12742 
12743 		/** AES GMAC Authentication */
12744 		TEST_CASE_ST(ut_setup, ut_teardown,
12745 			test_AES_GMAC_authentication_test_case_1),
12746 		TEST_CASE_ST(ut_setup, ut_teardown,
12747 			test_AES_GMAC_authentication_verify_test_case_1),
12748 		TEST_CASE_ST(ut_setup, ut_teardown,
12749 			test_AES_GMAC_authentication_test_case_2),
12750 		TEST_CASE_ST(ut_setup, ut_teardown,
12751 			test_AES_GMAC_authentication_verify_test_case_2),
12752 		TEST_CASE_ST(ut_setup, ut_teardown,
12753 			test_AES_GMAC_authentication_test_case_3),
12754 		TEST_CASE_ST(ut_setup, ut_teardown,
12755 			test_AES_GMAC_authentication_verify_test_case_3),
12756 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12757 
12758 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12759 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12760 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12761 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12762 		TEST_CASE_ST(ut_setup, ut_teardown,
12763 						test_DES_cipheronly_mb_all),
12764 		TEST_CASE_ST(ut_setup, ut_teardown,
12765 						test_DES_docsis_mb_all),
12766 		TEST_CASE_ST(ut_setup, ut_teardown,
12767 						test_3DES_cipheronly_mb_all),
12768 		TEST_CASE_ST(ut_setup, ut_teardown,
12769 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12770 		TEST_CASE_ST(ut_setup, ut_teardown,
12771 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12772 		TEST_CASE_ST(ut_setup, ut_teardown,
12773 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12774 		TEST_CASE_ST(ut_setup, ut_teardown,
12775 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12776 		TEST_CASE_ST(ut_setup, ut_teardown,
12777 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12778 		TEST_CASE_ST(ut_setup, ut_teardown,
12779 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12780 
12781 		TEST_CASES_END() /**< NULL terminate unit test array */
12782 	}
12783 };
12784 
12785 static struct unit_test_suite cryptodev_openssl_testsuite  = {
12786 	.suite_name = "Crypto Device OPENSSL Unit Test Suite",
12787 	.setup = testsuite_setup,
12788 	.teardown = testsuite_teardown,
12789 	.unit_test_cases = {
12790 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12791 		TEST_CASE_ST(ut_setup, ut_teardown,
12792 				test_multi_session_random_usage),
12793 		TEST_CASE_ST(ut_setup, ut_teardown,
12794 				test_AES_chain_openssl_all),
12795 		TEST_CASE_ST(ut_setup, ut_teardown,
12796 				test_AES_cipheronly_openssl_all),
12797 		TEST_CASE_ST(ut_setup, ut_teardown,
12798 				test_3DES_chain_openssl_all),
12799 		TEST_CASE_ST(ut_setup, ut_teardown,
12800 				test_3DES_cipheronly_openssl_all),
12801 		TEST_CASE_ST(ut_setup, ut_teardown,
12802 				test_DES_cipheronly_openssl_all),
12803 		TEST_CASE_ST(ut_setup, ut_teardown,
12804 				test_DES_docsis_openssl_all),
12805 		TEST_CASE_ST(ut_setup, ut_teardown,
12806 				test_authonly_openssl_all),
12807 
12808 		/** AES GCM Authenticated Encryption */
12809 		TEST_CASE_ST(ut_setup, ut_teardown,
12810 			test_AES_GCM_authenticated_encryption_test_case_1),
12811 		TEST_CASE_ST(ut_setup, ut_teardown,
12812 			test_AES_GCM_authenticated_encryption_test_case_2),
12813 		TEST_CASE_ST(ut_setup, ut_teardown,
12814 			test_AES_GCM_authenticated_encryption_test_case_3),
12815 		TEST_CASE_ST(ut_setup, ut_teardown,
12816 			test_AES_GCM_authenticated_encryption_test_case_4),
12817 		TEST_CASE_ST(ut_setup, ut_teardown,
12818 			test_AES_GCM_authenticated_encryption_test_case_5),
12819 		TEST_CASE_ST(ut_setup, ut_teardown,
12820 			test_AES_GCM_authenticated_encryption_test_case_6),
12821 		TEST_CASE_ST(ut_setup, ut_teardown,
12822 			test_AES_GCM_authenticated_encryption_test_case_7),
12823 
12824 		/** AES GCM Authenticated Decryption */
12825 		TEST_CASE_ST(ut_setup, ut_teardown,
12826 			test_AES_GCM_authenticated_decryption_test_case_1),
12827 		TEST_CASE_ST(ut_setup, ut_teardown,
12828 			test_AES_GCM_authenticated_decryption_test_case_2),
12829 		TEST_CASE_ST(ut_setup, ut_teardown,
12830 			test_AES_GCM_authenticated_decryption_test_case_3),
12831 		TEST_CASE_ST(ut_setup, ut_teardown,
12832 			test_AES_GCM_authenticated_decryption_test_case_4),
12833 		TEST_CASE_ST(ut_setup, ut_teardown,
12834 			test_AES_GCM_authenticated_decryption_test_case_5),
12835 		TEST_CASE_ST(ut_setup, ut_teardown,
12836 			test_AES_GCM_authenticated_decryption_test_case_6),
12837 		TEST_CASE_ST(ut_setup, ut_teardown,
12838 			test_AES_GCM_authenticated_decryption_test_case_7),
12839 
12840 
12841 		/** AES GCM Authenticated Encryption 192 bits key */
12842 		TEST_CASE_ST(ut_setup, ut_teardown,
12843 			test_AES_GCM_auth_encryption_test_case_192_1),
12844 		TEST_CASE_ST(ut_setup, ut_teardown,
12845 			test_AES_GCM_auth_encryption_test_case_192_2),
12846 		TEST_CASE_ST(ut_setup, ut_teardown,
12847 			test_AES_GCM_auth_encryption_test_case_192_3),
12848 		TEST_CASE_ST(ut_setup, ut_teardown,
12849 			test_AES_GCM_auth_encryption_test_case_192_4),
12850 		TEST_CASE_ST(ut_setup, ut_teardown,
12851 			test_AES_GCM_auth_encryption_test_case_192_5),
12852 		TEST_CASE_ST(ut_setup, ut_teardown,
12853 			test_AES_GCM_auth_encryption_test_case_192_6),
12854 		TEST_CASE_ST(ut_setup, ut_teardown,
12855 			test_AES_GCM_auth_encryption_test_case_192_7),
12856 
12857 		/** AES GCM Authenticated Decryption 192 bits key */
12858 		TEST_CASE_ST(ut_setup, ut_teardown,
12859 			test_AES_GCM_auth_decryption_test_case_192_1),
12860 		TEST_CASE_ST(ut_setup, ut_teardown,
12861 			test_AES_GCM_auth_decryption_test_case_192_2),
12862 		TEST_CASE_ST(ut_setup, ut_teardown,
12863 			test_AES_GCM_auth_decryption_test_case_192_3),
12864 		TEST_CASE_ST(ut_setup, ut_teardown,
12865 			test_AES_GCM_auth_decryption_test_case_192_4),
12866 		TEST_CASE_ST(ut_setup, ut_teardown,
12867 			test_AES_GCM_auth_decryption_test_case_192_5),
12868 		TEST_CASE_ST(ut_setup, ut_teardown,
12869 			test_AES_GCM_auth_decryption_test_case_192_6),
12870 		TEST_CASE_ST(ut_setup, ut_teardown,
12871 			test_AES_GCM_auth_decryption_test_case_192_7),
12872 
12873 		/** AES GCM Authenticated Encryption 256 bits key */
12874 		TEST_CASE_ST(ut_setup, ut_teardown,
12875 			test_AES_GCM_auth_encryption_test_case_256_1),
12876 		TEST_CASE_ST(ut_setup, ut_teardown,
12877 			test_AES_GCM_auth_encryption_test_case_256_2),
12878 		TEST_CASE_ST(ut_setup, ut_teardown,
12879 			test_AES_GCM_auth_encryption_test_case_256_3),
12880 		TEST_CASE_ST(ut_setup, ut_teardown,
12881 			test_AES_GCM_auth_encryption_test_case_256_4),
12882 		TEST_CASE_ST(ut_setup, ut_teardown,
12883 			test_AES_GCM_auth_encryption_test_case_256_5),
12884 		TEST_CASE_ST(ut_setup, ut_teardown,
12885 			test_AES_GCM_auth_encryption_test_case_256_6),
12886 		TEST_CASE_ST(ut_setup, ut_teardown,
12887 			test_AES_GCM_auth_encryption_test_case_256_7),
12888 
12889 		/** AES GCM Authenticated Decryption 256 bits key */
12890 		TEST_CASE_ST(ut_setup, ut_teardown,
12891 			test_AES_GCM_auth_decryption_test_case_256_1),
12892 		TEST_CASE_ST(ut_setup, ut_teardown,
12893 			test_AES_GCM_auth_decryption_test_case_256_2),
12894 		TEST_CASE_ST(ut_setup, ut_teardown,
12895 			test_AES_GCM_auth_decryption_test_case_256_3),
12896 		TEST_CASE_ST(ut_setup, ut_teardown,
12897 			test_AES_GCM_auth_decryption_test_case_256_4),
12898 		TEST_CASE_ST(ut_setup, ut_teardown,
12899 			test_AES_GCM_auth_decryption_test_case_256_5),
12900 		TEST_CASE_ST(ut_setup, ut_teardown,
12901 			test_AES_GCM_auth_decryption_test_case_256_6),
12902 		TEST_CASE_ST(ut_setup, ut_teardown,
12903 			test_AES_GCM_auth_decryption_test_case_256_7),
12904 
12905 		/** AES GMAC Authentication */
12906 		TEST_CASE_ST(ut_setup, ut_teardown,
12907 			test_AES_GMAC_authentication_test_case_1),
12908 		TEST_CASE_ST(ut_setup, ut_teardown,
12909 			test_AES_GMAC_authentication_verify_test_case_1),
12910 		TEST_CASE_ST(ut_setup, ut_teardown,
12911 			test_AES_GMAC_authentication_test_case_2),
12912 		TEST_CASE_ST(ut_setup, ut_teardown,
12913 			test_AES_GMAC_authentication_verify_test_case_2),
12914 		TEST_CASE_ST(ut_setup, ut_teardown,
12915 			test_AES_GMAC_authentication_test_case_3),
12916 		TEST_CASE_ST(ut_setup, ut_teardown,
12917 			test_AES_GMAC_authentication_verify_test_case_3),
12918 		TEST_CASE_ST(ut_setup, ut_teardown,
12919 			test_AES_GMAC_authentication_test_case_4),
12920 		TEST_CASE_ST(ut_setup, ut_teardown,
12921 			test_AES_GMAC_authentication_verify_test_case_4),
12922 
12923 		/** AES CCM Authenticated Encryption 128 bits key */
12924 		TEST_CASE_ST(ut_setup, ut_teardown,
12925 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12926 		TEST_CASE_ST(ut_setup, ut_teardown,
12927 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12928 		TEST_CASE_ST(ut_setup, ut_teardown,
12929 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12930 
12931 		/** AES CCM Authenticated Decryption 128 bits key*/
12932 		TEST_CASE_ST(ut_setup, ut_teardown,
12933 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12934 		TEST_CASE_ST(ut_setup, ut_teardown,
12935 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12936 		TEST_CASE_ST(ut_setup, ut_teardown,
12937 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12938 
12939 		/** AES CCM Authenticated Encryption 192 bits key */
12940 		TEST_CASE_ST(ut_setup, ut_teardown,
12941 			test_AES_CCM_authenticated_encryption_test_case_192_1),
12942 		TEST_CASE_ST(ut_setup, ut_teardown,
12943 			test_AES_CCM_authenticated_encryption_test_case_192_2),
12944 		TEST_CASE_ST(ut_setup, ut_teardown,
12945 			test_AES_CCM_authenticated_encryption_test_case_192_3),
12946 
12947 		/** AES CCM Authenticated Decryption 192 bits key*/
12948 		TEST_CASE_ST(ut_setup, ut_teardown,
12949 			test_AES_CCM_authenticated_decryption_test_case_192_1),
12950 		TEST_CASE_ST(ut_setup, ut_teardown,
12951 			test_AES_CCM_authenticated_decryption_test_case_192_2),
12952 		TEST_CASE_ST(ut_setup, ut_teardown,
12953 			test_AES_CCM_authenticated_decryption_test_case_192_3),
12954 
12955 		/** AES CCM Authenticated Encryption 256 bits key */
12956 		TEST_CASE_ST(ut_setup, ut_teardown,
12957 			test_AES_CCM_authenticated_encryption_test_case_256_1),
12958 		TEST_CASE_ST(ut_setup, ut_teardown,
12959 			test_AES_CCM_authenticated_encryption_test_case_256_2),
12960 		TEST_CASE_ST(ut_setup, ut_teardown,
12961 			test_AES_CCM_authenticated_encryption_test_case_256_3),
12962 
12963 		/** AES CCM Authenticated Decryption 256 bits key*/
12964 		TEST_CASE_ST(ut_setup, ut_teardown,
12965 			test_AES_CCM_authenticated_decryption_test_case_256_1),
12966 		TEST_CASE_ST(ut_setup, ut_teardown,
12967 			test_AES_CCM_authenticated_decryption_test_case_256_2),
12968 		TEST_CASE_ST(ut_setup, ut_teardown,
12969 			test_AES_CCM_authenticated_decryption_test_case_256_3),
12970 
12971 		/** Scatter-Gather */
12972 		TEST_CASE_ST(ut_setup, ut_teardown,
12973 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12974 
12975 		/** Negative tests */
12976 		TEST_CASE_ST(ut_setup, ut_teardown,
12977 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
12978 		TEST_CASE_ST(ut_setup, ut_teardown,
12979 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12980 		TEST_CASE_ST(ut_setup, ut_teardown,
12981 			authentication_verify_AES128_GMAC_fail_data_corrupt),
12982 		TEST_CASE_ST(ut_setup, ut_teardown,
12983 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
12984 		TEST_CASE_ST(ut_setup, ut_teardown,
12985 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12986 		TEST_CASE_ST(ut_setup, ut_teardown,
12987 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12988 
12989 		/* ESN Testcase */
12990 		TEST_CASE_ST(ut_setup, ut_teardown,
12991 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12992 
12993 		TEST_CASE_ST(ut_setup, ut_teardown,
12994 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12995 
12996 		TEST_CASES_END() /**< NULL terminate unit test array */
12997 	}
12998 };
12999 
13000 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
13001 	.suite_name = "Crypto Device AESNI GCM Unit Test Suite",
13002 	.setup = testsuite_setup,
13003 	.teardown = testsuite_teardown,
13004 	.unit_test_cases = {
13005 		/** AES GCM Authenticated Encryption */
13006 		TEST_CASE_ST(ut_setup, ut_teardown,
13007 			test_AES_GCM_authenticated_encryption_test_case_1),
13008 		TEST_CASE_ST(ut_setup, ut_teardown,
13009 			test_AES_GCM_authenticated_encryption_test_case_2),
13010 		TEST_CASE_ST(ut_setup, ut_teardown,
13011 			test_AES_GCM_authenticated_encryption_test_case_3),
13012 		TEST_CASE_ST(ut_setup, ut_teardown,
13013 			test_AES_GCM_authenticated_encryption_test_case_4),
13014 		TEST_CASE_ST(ut_setup, ut_teardown,
13015 			test_AES_GCM_authenticated_encryption_test_case_5),
13016 		TEST_CASE_ST(ut_setup, ut_teardown,
13017 			test_AES_GCM_authenticated_encryption_test_case_6),
13018 		TEST_CASE_ST(ut_setup, ut_teardown,
13019 			test_AES_GCM_authenticated_encryption_test_case_7),
13020 
13021 		/** AES GCM Authenticated Decryption */
13022 		TEST_CASE_ST(ut_setup, ut_teardown,
13023 			test_AES_GCM_authenticated_decryption_test_case_1),
13024 		TEST_CASE_ST(ut_setup, ut_teardown,
13025 			test_AES_GCM_authenticated_decryption_test_case_2),
13026 		TEST_CASE_ST(ut_setup, ut_teardown,
13027 			test_AES_GCM_authenticated_decryption_test_case_3),
13028 		TEST_CASE_ST(ut_setup, ut_teardown,
13029 			test_AES_GCM_authenticated_decryption_test_case_4),
13030 		TEST_CASE_ST(ut_setup, ut_teardown,
13031 			test_AES_GCM_authenticated_decryption_test_case_5),
13032 		TEST_CASE_ST(ut_setup, ut_teardown,
13033 			test_AES_GCM_authenticated_decryption_test_case_6),
13034 		TEST_CASE_ST(ut_setup, ut_teardown,
13035 			test_AES_GCM_authenticated_decryption_test_case_7),
13036 
13037 		/** AES GCM Authenticated Encryption 192 bits key */
13038 		TEST_CASE_ST(ut_setup, ut_teardown,
13039 			test_AES_GCM_auth_encryption_test_case_192_1),
13040 		TEST_CASE_ST(ut_setup, ut_teardown,
13041 			test_AES_GCM_auth_encryption_test_case_192_2),
13042 		TEST_CASE_ST(ut_setup, ut_teardown,
13043 			test_AES_GCM_auth_encryption_test_case_192_3),
13044 		TEST_CASE_ST(ut_setup, ut_teardown,
13045 			test_AES_GCM_auth_encryption_test_case_192_4),
13046 		TEST_CASE_ST(ut_setup, ut_teardown,
13047 			test_AES_GCM_auth_encryption_test_case_192_5),
13048 		TEST_CASE_ST(ut_setup, ut_teardown,
13049 			test_AES_GCM_auth_encryption_test_case_192_6),
13050 		TEST_CASE_ST(ut_setup, ut_teardown,
13051 			test_AES_GCM_auth_encryption_test_case_192_7),
13052 
13053 		/** AES GCM Authenticated Decryption 192 bits key */
13054 		TEST_CASE_ST(ut_setup, ut_teardown,
13055 			test_AES_GCM_auth_decryption_test_case_192_1),
13056 		TEST_CASE_ST(ut_setup, ut_teardown,
13057 			test_AES_GCM_auth_decryption_test_case_192_2),
13058 		TEST_CASE_ST(ut_setup, ut_teardown,
13059 			test_AES_GCM_auth_decryption_test_case_192_3),
13060 		TEST_CASE_ST(ut_setup, ut_teardown,
13061 			test_AES_GCM_auth_decryption_test_case_192_4),
13062 		TEST_CASE_ST(ut_setup, ut_teardown,
13063 			test_AES_GCM_auth_decryption_test_case_192_5),
13064 		TEST_CASE_ST(ut_setup, ut_teardown,
13065 			test_AES_GCM_auth_decryption_test_case_192_6),
13066 		TEST_CASE_ST(ut_setup, ut_teardown,
13067 			test_AES_GCM_auth_decryption_test_case_192_7),
13068 
13069 		/** AES GCM Authenticated Encryption 256 bits key */
13070 		TEST_CASE_ST(ut_setup, ut_teardown,
13071 			test_AES_GCM_auth_encryption_test_case_256_1),
13072 		TEST_CASE_ST(ut_setup, ut_teardown,
13073 			test_AES_GCM_auth_encryption_test_case_256_2),
13074 		TEST_CASE_ST(ut_setup, ut_teardown,
13075 			test_AES_GCM_auth_encryption_test_case_256_3),
13076 		TEST_CASE_ST(ut_setup, ut_teardown,
13077 			test_AES_GCM_auth_encryption_test_case_256_4),
13078 		TEST_CASE_ST(ut_setup, ut_teardown,
13079 			test_AES_GCM_auth_encryption_test_case_256_5),
13080 		TEST_CASE_ST(ut_setup, ut_teardown,
13081 			test_AES_GCM_auth_encryption_test_case_256_6),
13082 		TEST_CASE_ST(ut_setup, ut_teardown,
13083 			test_AES_GCM_auth_encryption_test_case_256_7),
13084 
13085 		/** AES GCM Authenticated Decryption 256 bits key */
13086 		TEST_CASE_ST(ut_setup, ut_teardown,
13087 			test_AES_GCM_auth_decryption_test_case_256_1),
13088 		TEST_CASE_ST(ut_setup, ut_teardown,
13089 			test_AES_GCM_auth_decryption_test_case_256_2),
13090 		TEST_CASE_ST(ut_setup, ut_teardown,
13091 			test_AES_GCM_auth_decryption_test_case_256_3),
13092 		TEST_CASE_ST(ut_setup, ut_teardown,
13093 			test_AES_GCM_auth_decryption_test_case_256_4),
13094 		TEST_CASE_ST(ut_setup, ut_teardown,
13095 			test_AES_GCM_auth_decryption_test_case_256_5),
13096 		TEST_CASE_ST(ut_setup, ut_teardown,
13097 			test_AES_GCM_auth_decryption_test_case_256_6),
13098 		TEST_CASE_ST(ut_setup, ut_teardown,
13099 			test_AES_GCM_auth_decryption_test_case_256_7),
13100 
13101 		/** AES GCM Authenticated Encryption big aad size */
13102 		TEST_CASE_ST(ut_setup, ut_teardown,
13103 			test_AES_GCM_auth_encryption_test_case_aad_1),
13104 		TEST_CASE_ST(ut_setup, ut_teardown,
13105 			test_AES_GCM_auth_encryption_test_case_aad_2),
13106 
13107 		/** AES GCM Authenticated Decryption big aad size */
13108 		TEST_CASE_ST(ut_setup, ut_teardown,
13109 			test_AES_GCM_auth_decryption_test_case_aad_1),
13110 		TEST_CASE_ST(ut_setup, ut_teardown,
13111 			test_AES_GCM_auth_decryption_test_case_aad_2),
13112 
13113 		/** AES GMAC Authentication */
13114 		TEST_CASE_ST(ut_setup, ut_teardown,
13115 			test_AES_GMAC_authentication_test_case_1),
13116 		TEST_CASE_ST(ut_setup, ut_teardown,
13117 			test_AES_GMAC_authentication_verify_test_case_1),
13118 		TEST_CASE_ST(ut_setup, ut_teardown,
13119 			test_AES_GMAC_authentication_test_case_3),
13120 		TEST_CASE_ST(ut_setup, ut_teardown,
13121 			test_AES_GMAC_authentication_verify_test_case_3),
13122 		TEST_CASE_ST(ut_setup, ut_teardown,
13123 			test_AES_GMAC_authentication_test_case_4),
13124 		TEST_CASE_ST(ut_setup, ut_teardown,
13125 			test_AES_GMAC_authentication_verify_test_case_4),
13126 
13127 		/** Negative tests */
13128 		TEST_CASE_ST(ut_setup, ut_teardown,
13129 			authentication_verify_AES128_GMAC_fail_data_corrupt),
13130 		TEST_CASE_ST(ut_setup, ut_teardown,
13131 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
13132 
13133 		/** Out of place tests */
13134 		TEST_CASE_ST(ut_setup, ut_teardown,
13135 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13136 		TEST_CASE_ST(ut_setup, ut_teardown,
13137 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13138 
13139 		/** Session-less tests */
13140 		TEST_CASE_ST(ut_setup, ut_teardown,
13141 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13142 		TEST_CASE_ST(ut_setup, ut_teardown,
13143 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13144 
13145 		/** Scatter-Gather */
13146 		TEST_CASE_ST(ut_setup, ut_teardown,
13147 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13148 		TEST_CASE_ST(ut_setup, ut_teardown,
13149 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13150 
13151 		TEST_CASES_END() /**< NULL terminate unit test array */
13152 	}
13153 };
13154 
13155 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
13156 	.suite_name = "Crypto Device SW KASUMI Unit Test Suite",
13157 	.setup = testsuite_setup,
13158 	.teardown = testsuite_teardown,
13159 	.unit_test_cases = {
13160 		/** KASUMI encrypt only (UEA1) */
13161 		TEST_CASE_ST(ut_setup, ut_teardown,
13162 			test_kasumi_encryption_test_case_1),
13163 		TEST_CASE_ST(ut_setup, ut_teardown,
13164 			test_kasumi_encryption_test_case_1_sgl),
13165 		TEST_CASE_ST(ut_setup, ut_teardown,
13166 			test_kasumi_encryption_test_case_2),
13167 		TEST_CASE_ST(ut_setup, ut_teardown,
13168 			test_kasumi_encryption_test_case_3),
13169 		TEST_CASE_ST(ut_setup, ut_teardown,
13170 			test_kasumi_encryption_test_case_4),
13171 		TEST_CASE_ST(ut_setup, ut_teardown,
13172 			test_kasumi_encryption_test_case_5),
13173 		/** KASUMI decrypt only (UEA1) */
13174 		TEST_CASE_ST(ut_setup, ut_teardown,
13175 			test_kasumi_decryption_test_case_1),
13176 		TEST_CASE_ST(ut_setup, ut_teardown,
13177 			test_kasumi_decryption_test_case_2),
13178 		TEST_CASE_ST(ut_setup, ut_teardown,
13179 			test_kasumi_decryption_test_case_3),
13180 		TEST_CASE_ST(ut_setup, ut_teardown,
13181 			test_kasumi_decryption_test_case_4),
13182 		TEST_CASE_ST(ut_setup, ut_teardown,
13183 			test_kasumi_decryption_test_case_5),
13184 
13185 		TEST_CASE_ST(ut_setup, ut_teardown,
13186 			test_kasumi_encryption_test_case_1_oop),
13187 		TEST_CASE_ST(ut_setup, ut_teardown,
13188 			test_kasumi_encryption_test_case_1_oop_sgl),
13189 
13190 
13191 		TEST_CASE_ST(ut_setup, ut_teardown,
13192 			test_kasumi_decryption_test_case_1_oop),
13193 
13194 		/** KASUMI hash only (UIA1) */
13195 		TEST_CASE_ST(ut_setup, ut_teardown,
13196 			test_kasumi_hash_generate_test_case_1),
13197 		TEST_CASE_ST(ut_setup, ut_teardown,
13198 			test_kasumi_hash_generate_test_case_2),
13199 		TEST_CASE_ST(ut_setup, ut_teardown,
13200 			test_kasumi_hash_generate_test_case_3),
13201 		TEST_CASE_ST(ut_setup, ut_teardown,
13202 			test_kasumi_hash_generate_test_case_4),
13203 		TEST_CASE_ST(ut_setup, ut_teardown,
13204 			test_kasumi_hash_generate_test_case_5),
13205 		TEST_CASE_ST(ut_setup, ut_teardown,
13206 			test_kasumi_hash_generate_test_case_6),
13207 		TEST_CASE_ST(ut_setup, ut_teardown,
13208 			test_kasumi_hash_verify_test_case_1),
13209 		TEST_CASE_ST(ut_setup, ut_teardown,
13210 			test_kasumi_hash_verify_test_case_2),
13211 		TEST_CASE_ST(ut_setup, ut_teardown,
13212 			test_kasumi_hash_verify_test_case_3),
13213 		TEST_CASE_ST(ut_setup, ut_teardown,
13214 			test_kasumi_hash_verify_test_case_4),
13215 		TEST_CASE_ST(ut_setup, ut_teardown,
13216 			test_kasumi_hash_verify_test_case_5),
13217 		TEST_CASE_ST(ut_setup, ut_teardown,
13218 			test_kasumi_cipher_auth_test_case_1),
13219 
13220 		/** KASUMI generate auth, then encrypt (F8) */
13221 		TEST_CASE_ST(ut_setup, ut_teardown,
13222 			test_kasumi_auth_cipher_test_case_1),
13223 		TEST_CASE_ST(ut_setup, ut_teardown,
13224 			test_kasumi_auth_cipher_test_case_2),
13225 		TEST_CASE_ST(ut_setup, ut_teardown,
13226 			test_kasumi_auth_cipher_test_case_2_oop),
13227 		TEST_CASE_ST(ut_setup, ut_teardown,
13228 			test_kasumi_auth_cipher_test_case_2_sgl),
13229 		TEST_CASE_ST(ut_setup, ut_teardown,
13230 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
13231 
13232 		/** KASUMI decrypt (F8), then verify auth */
13233 		TEST_CASE_ST(ut_setup, ut_teardown,
13234 			test_kasumi_auth_cipher_verify_test_case_1),
13235 		TEST_CASE_ST(ut_setup, ut_teardown,
13236 			test_kasumi_auth_cipher_verify_test_case_2),
13237 		TEST_CASE_ST(ut_setup, ut_teardown,
13238 			test_kasumi_auth_cipher_verify_test_case_2_oop),
13239 		TEST_CASE_ST(ut_setup, ut_teardown,
13240 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
13241 		TEST_CASE_ST(ut_setup, ut_teardown,
13242 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13243 		TEST_CASES_END() /**< NULL terminate unit test array */
13244 	}
13245 };
13246 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
13247 	.suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
13248 	.setup = testsuite_setup,
13249 	.teardown = testsuite_teardown,
13250 	.unit_test_cases = {
13251 		/** SNOW 3G encrypt only (UEA2) */
13252 		TEST_CASE_ST(ut_setup, ut_teardown,
13253 			test_snow3g_encryption_test_case_1),
13254 		TEST_CASE_ST(ut_setup, ut_teardown,
13255 			test_snow3g_encryption_test_case_2),
13256 		TEST_CASE_ST(ut_setup, ut_teardown,
13257 			test_snow3g_encryption_test_case_3),
13258 		TEST_CASE_ST(ut_setup, ut_teardown,
13259 			test_snow3g_encryption_test_case_4),
13260 		TEST_CASE_ST(ut_setup, ut_teardown,
13261 			test_snow3g_encryption_test_case_5),
13262 		TEST_CASE_ST(ut_setup, ut_teardown,
13263 			test_snow3g_auth_cipher_with_digest_test_case_1),
13264 
13265 		TEST_CASE_ST(ut_setup, ut_teardown,
13266 			test_snow3g_encryption_test_case_1_oop),
13267 		TEST_CASE_ST(ut_setup, ut_teardown,
13268 				test_snow3g_encryption_test_case_1_oop_sgl),
13269 		TEST_CASE_ST(ut_setup, ut_teardown,
13270 			test_snow3g_decryption_test_case_1_oop),
13271 
13272 		TEST_CASE_ST(ut_setup, ut_teardown,
13273 			test_snow3g_encryption_test_case_1_offset_oop),
13274 
13275 		/** SNOW 3G decrypt only (UEA2) */
13276 		TEST_CASE_ST(ut_setup, ut_teardown,
13277 			test_snow3g_decryption_test_case_1),
13278 		TEST_CASE_ST(ut_setup, ut_teardown,
13279 			test_snow3g_decryption_test_case_2),
13280 		TEST_CASE_ST(ut_setup, ut_teardown,
13281 			test_snow3g_decryption_test_case_3),
13282 		TEST_CASE_ST(ut_setup, ut_teardown,
13283 			test_snow3g_decryption_test_case_4),
13284 		TEST_CASE_ST(ut_setup, ut_teardown,
13285 			test_snow3g_decryption_test_case_5),
13286 		TEST_CASE_ST(ut_setup, ut_teardown,
13287 			test_snow3g_decryption_with_digest_test_case_1),
13288 		TEST_CASE_ST(ut_setup, ut_teardown,
13289 			test_snow3g_hash_generate_test_case_1),
13290 		TEST_CASE_ST(ut_setup, ut_teardown,
13291 			test_snow3g_hash_generate_test_case_2),
13292 		TEST_CASE_ST(ut_setup, ut_teardown,
13293 			test_snow3g_hash_generate_test_case_3),
13294 		/* Tests with buffers which length is not byte-aligned */
13295 		TEST_CASE_ST(ut_setup, ut_teardown,
13296 			test_snow3g_hash_generate_test_case_4),
13297 		TEST_CASE_ST(ut_setup, ut_teardown,
13298 			test_snow3g_hash_generate_test_case_5),
13299 		TEST_CASE_ST(ut_setup, ut_teardown,
13300 			test_snow3g_hash_generate_test_case_6),
13301 		TEST_CASE_ST(ut_setup, ut_teardown,
13302 			test_snow3g_hash_verify_test_case_1),
13303 		TEST_CASE_ST(ut_setup, ut_teardown,
13304 			test_snow3g_hash_verify_test_case_2),
13305 		TEST_CASE_ST(ut_setup, ut_teardown,
13306 			test_snow3g_hash_verify_test_case_3),
13307 		/* Tests with buffers which length is not byte-aligned */
13308 		TEST_CASE_ST(ut_setup, ut_teardown,
13309 			test_snow3g_hash_verify_test_case_4),
13310 		TEST_CASE_ST(ut_setup, ut_teardown,
13311 			test_snow3g_hash_verify_test_case_5),
13312 		TEST_CASE_ST(ut_setup, ut_teardown,
13313 			test_snow3g_hash_verify_test_case_6),
13314 		TEST_CASE_ST(ut_setup, ut_teardown,
13315 			test_snow3g_cipher_auth_test_case_1),
13316 
13317 		/** SNOW 3G generate auth, then encrypt (UEA2) */
13318 		TEST_CASE_ST(ut_setup, ut_teardown,
13319 			test_snow3g_auth_cipher_test_case_1),
13320 		TEST_CASE_ST(ut_setup, ut_teardown,
13321 			test_snow3g_auth_cipher_test_case_2),
13322 		TEST_CASE_ST(ut_setup, ut_teardown,
13323 			test_snow3g_auth_cipher_test_case_2_oop),
13324 		TEST_CASE_ST(ut_setup, ut_teardown,
13325 			test_snow3g_auth_cipher_part_digest_enc),
13326 		TEST_CASE_ST(ut_setup, ut_teardown,
13327 			test_snow3g_auth_cipher_part_digest_enc_oop),
13328 		TEST_CASE_ST(ut_setup, ut_teardown,
13329 			test_snow3g_auth_cipher_test_case_3_sgl),
13330 		TEST_CASE_ST(ut_setup, ut_teardown,
13331 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
13332 		TEST_CASE_ST(ut_setup, ut_teardown,
13333 			test_snow3g_auth_cipher_part_digest_enc_sgl),
13334 		TEST_CASE_ST(ut_setup, ut_teardown,
13335 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13336 
13337 		/** SNOW 3G decrypt (UEA2), then verify auth */
13338 		TEST_CASE_ST(ut_setup, ut_teardown,
13339 			test_snow3g_auth_cipher_verify_test_case_1),
13340 		TEST_CASE_ST(ut_setup, ut_teardown,
13341 			test_snow3g_auth_cipher_verify_test_case_2),
13342 		TEST_CASE_ST(ut_setup, ut_teardown,
13343 			test_snow3g_auth_cipher_verify_test_case_2_oop),
13344 		TEST_CASE_ST(ut_setup, ut_teardown,
13345 			test_snow3g_auth_cipher_verify_part_digest_enc),
13346 		TEST_CASE_ST(ut_setup, ut_teardown,
13347 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13348 		TEST_CASE_ST(ut_setup, ut_teardown,
13349 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
13350 		TEST_CASE_ST(ut_setup, ut_teardown,
13351 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13352 		TEST_CASE_ST(ut_setup, ut_teardown,
13353 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13354 		TEST_CASE_ST(ut_setup, ut_teardown,
13355 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13356 
13357 		TEST_CASES_END() /**< NULL terminate unit test array */
13358 	}
13359 };
13360 
13361 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
13362 	.suite_name = "Crypto Device SW ZUC Unit Test Suite",
13363 	.setup = testsuite_setup,
13364 	.teardown = testsuite_teardown,
13365 	.unit_test_cases = {
13366 		/** ZUC encrypt only (EEA3) */
13367 		TEST_CASE_ST(ut_setup, ut_teardown,
13368 			test_zuc_encryption_test_case_1),
13369 		TEST_CASE_ST(ut_setup, ut_teardown,
13370 			test_zuc_encryption_test_case_2),
13371 		TEST_CASE_ST(ut_setup, ut_teardown,
13372 			test_zuc_encryption_test_case_3),
13373 		TEST_CASE_ST(ut_setup, ut_teardown,
13374 			test_zuc_encryption_test_case_4),
13375 		TEST_CASE_ST(ut_setup, ut_teardown,
13376 			test_zuc_encryption_test_case_5),
13377 		TEST_CASE_ST(ut_setup, ut_teardown,
13378 			test_zuc_hash_generate_test_case_1),
13379 		TEST_CASE_ST(ut_setup, ut_teardown,
13380 			test_zuc_hash_generate_test_case_2),
13381 		TEST_CASE_ST(ut_setup, ut_teardown,
13382 			test_zuc_hash_generate_test_case_3),
13383 		TEST_CASE_ST(ut_setup, ut_teardown,
13384 			test_zuc_hash_generate_test_case_4),
13385 		TEST_CASE_ST(ut_setup, ut_teardown,
13386 			test_zuc_hash_generate_test_case_5),
13387 		TEST_CASE_ST(ut_setup, ut_teardown,
13388 			test_zuc_encryption_test_case_6_sgl),
13389 		TEST_CASES_END() /**< NULL terminate unit test array */
13390 	}
13391 };
13392 
13393 static struct unit_test_suite cryptodev_caam_jr_testsuite  = {
13394 	.suite_name = "Crypto CAAM JR Unit Test Suite",
13395 	.setup = testsuite_setup,
13396 	.teardown = testsuite_teardown,
13397 	.unit_test_cases = {
13398 		TEST_CASE_ST(ut_setup, ut_teardown,
13399 			     test_device_configure_invalid_dev_id),
13400 		TEST_CASE_ST(ut_setup, ut_teardown,
13401 			     test_multi_session),
13402 
13403 		TEST_CASE_ST(ut_setup, ut_teardown,
13404 			     test_AES_chain_caam_jr_all),
13405 		TEST_CASE_ST(ut_setup, ut_teardown,
13406 			     test_3DES_chain_caam_jr_all),
13407 		TEST_CASE_ST(ut_setup, ut_teardown,
13408 			     test_AES_cipheronly_caam_jr_all),
13409 		TEST_CASE_ST(ut_setup, ut_teardown,
13410 			     test_3DES_cipheronly_caam_jr_all),
13411 		TEST_CASE_ST(ut_setup, ut_teardown,
13412 			     test_authonly_caam_jr_all),
13413 
13414 		TEST_CASES_END() /**< NULL terminate unit test array */
13415 	}
13416 };
13417 
13418 static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
13419 	.suite_name = "Crypto DPAA_SEC Unit Test Suite",
13420 	.setup = testsuite_setup,
13421 	.teardown = testsuite_teardown,
13422 	.unit_test_cases = {
13423 		TEST_CASE_ST(ut_setup, ut_teardown,
13424 			     test_device_configure_invalid_dev_id),
13425 		TEST_CASE_ST(ut_setup, ut_teardown,
13426 			     test_multi_session),
13427 
13428 		TEST_CASE_ST(ut_setup, ut_teardown,
13429 			     test_AES_chain_dpaa_sec_all),
13430 		TEST_CASE_ST(ut_setup, ut_teardown,
13431 			     test_3DES_chain_dpaa_sec_all),
13432 		TEST_CASE_ST(ut_setup, ut_teardown,
13433 			     test_AES_cipheronly_dpaa_sec_all),
13434 		TEST_CASE_ST(ut_setup, ut_teardown,
13435 			     test_3DES_cipheronly_dpaa_sec_all),
13436 		TEST_CASE_ST(ut_setup, ut_teardown,
13437 			     test_authonly_dpaa_sec_all),
13438 
13439 #ifdef RTE_LIBRTE_SECURITY
13440 		TEST_CASE_ST(ut_setup, ut_teardown,
13441 			test_PDCP_PROTO_cplane_encap_all),
13442 
13443 		TEST_CASE_ST(ut_setup, ut_teardown,
13444 			test_PDCP_PROTO_cplane_decap_all),
13445 
13446 		TEST_CASE_ST(ut_setup, ut_teardown,
13447 			test_PDCP_PROTO_uplane_encap_all),
13448 
13449 		TEST_CASE_ST(ut_setup, ut_teardown,
13450 			test_PDCP_PROTO_uplane_decap_all),
13451 
13452 		TEST_CASE_ST(ut_setup, ut_teardown,
13453 			test_PDCP_PROTO_SGL_in_place_32B),
13454 		TEST_CASE_ST(ut_setup, ut_teardown,
13455 			test_PDCP_PROTO_SGL_oop_32B_128B),
13456 		TEST_CASE_ST(ut_setup, ut_teardown,
13457 			test_PDCP_PROTO_SGL_oop_32B_40B),
13458 		TEST_CASE_ST(ut_setup, ut_teardown,
13459 			test_PDCP_PROTO_SGL_oop_128B_32B),
13460 #endif
13461 		/** AES GCM Authenticated Encryption */
13462 		TEST_CASE_ST(ut_setup, ut_teardown,
13463 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13464 		TEST_CASE_ST(ut_setup, ut_teardown,
13465 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13466 		TEST_CASE_ST(ut_setup, ut_teardown,
13467 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13468 		TEST_CASE_ST(ut_setup, ut_teardown,
13469 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13470 		TEST_CASE_ST(ut_setup, ut_teardown,
13471 			test_AES_GCM_authenticated_encryption_test_case_1),
13472 		TEST_CASE_ST(ut_setup, ut_teardown,
13473 			test_AES_GCM_authenticated_encryption_test_case_2),
13474 		TEST_CASE_ST(ut_setup, ut_teardown,
13475 			test_AES_GCM_authenticated_encryption_test_case_3),
13476 		TEST_CASE_ST(ut_setup, ut_teardown,
13477 			test_AES_GCM_authenticated_encryption_test_case_4),
13478 		TEST_CASE_ST(ut_setup, ut_teardown,
13479 			test_AES_GCM_authenticated_encryption_test_case_5),
13480 		TEST_CASE_ST(ut_setup, ut_teardown,
13481 			test_AES_GCM_authenticated_encryption_test_case_6),
13482 		TEST_CASE_ST(ut_setup, ut_teardown,
13483 			test_AES_GCM_authenticated_encryption_test_case_7),
13484 		TEST_CASE_ST(ut_setup, ut_teardown,
13485 			test_AES_GCM_authenticated_encryption_test_case_8),
13486 
13487 		/** AES GCM Authenticated Decryption */
13488 		TEST_CASE_ST(ut_setup, ut_teardown,
13489 			test_AES_GCM_authenticated_decryption_test_case_1),
13490 		TEST_CASE_ST(ut_setup, ut_teardown,
13491 			test_AES_GCM_authenticated_decryption_test_case_2),
13492 		TEST_CASE_ST(ut_setup, ut_teardown,
13493 			test_AES_GCM_authenticated_decryption_test_case_3),
13494 		TEST_CASE_ST(ut_setup, ut_teardown,
13495 			test_AES_GCM_authenticated_decryption_test_case_4),
13496 		TEST_CASE_ST(ut_setup, ut_teardown,
13497 			test_AES_GCM_authenticated_decryption_test_case_5),
13498 		TEST_CASE_ST(ut_setup, ut_teardown,
13499 			test_AES_GCM_authenticated_decryption_test_case_6),
13500 		TEST_CASE_ST(ut_setup, ut_teardown,
13501 			test_AES_GCM_authenticated_decryption_test_case_7),
13502 		TEST_CASE_ST(ut_setup, ut_teardown,
13503 			test_AES_GCM_authenticated_decryption_test_case_8),
13504 
13505 		/** AES GCM Authenticated Encryption 192 bits key */
13506 		TEST_CASE_ST(ut_setup, ut_teardown,
13507 			test_AES_GCM_auth_encryption_test_case_192_1),
13508 		TEST_CASE_ST(ut_setup, ut_teardown,
13509 			test_AES_GCM_auth_encryption_test_case_192_2),
13510 		TEST_CASE_ST(ut_setup, ut_teardown,
13511 			test_AES_GCM_auth_encryption_test_case_192_3),
13512 		TEST_CASE_ST(ut_setup, ut_teardown,
13513 			test_AES_GCM_auth_encryption_test_case_192_4),
13514 		TEST_CASE_ST(ut_setup, ut_teardown,
13515 			test_AES_GCM_auth_encryption_test_case_192_5),
13516 		TEST_CASE_ST(ut_setup, ut_teardown,
13517 			test_AES_GCM_auth_encryption_test_case_192_6),
13518 		TEST_CASE_ST(ut_setup, ut_teardown,
13519 			test_AES_GCM_auth_encryption_test_case_192_7),
13520 
13521 		/** AES GCM Authenticated Decryption 192 bits key */
13522 		TEST_CASE_ST(ut_setup, ut_teardown,
13523 			test_AES_GCM_auth_decryption_test_case_192_1),
13524 		TEST_CASE_ST(ut_setup, ut_teardown,
13525 			test_AES_GCM_auth_decryption_test_case_192_2),
13526 		TEST_CASE_ST(ut_setup, ut_teardown,
13527 			test_AES_GCM_auth_decryption_test_case_192_3),
13528 		TEST_CASE_ST(ut_setup, ut_teardown,
13529 			test_AES_GCM_auth_decryption_test_case_192_4),
13530 		TEST_CASE_ST(ut_setup, ut_teardown,
13531 			test_AES_GCM_auth_decryption_test_case_192_5),
13532 		TEST_CASE_ST(ut_setup, ut_teardown,
13533 			test_AES_GCM_auth_decryption_test_case_192_6),
13534 		TEST_CASE_ST(ut_setup, ut_teardown,
13535 			test_AES_GCM_auth_decryption_test_case_192_7),
13536 
13537 		/** AES GCM Authenticated Encryption 256 bits key */
13538 		TEST_CASE_ST(ut_setup, ut_teardown,
13539 			test_AES_GCM_auth_encryption_test_case_256_1),
13540 		TEST_CASE_ST(ut_setup, ut_teardown,
13541 			test_AES_GCM_auth_encryption_test_case_256_2),
13542 		TEST_CASE_ST(ut_setup, ut_teardown,
13543 			test_AES_GCM_auth_encryption_test_case_256_3),
13544 		TEST_CASE_ST(ut_setup, ut_teardown,
13545 			test_AES_GCM_auth_encryption_test_case_256_4),
13546 		TEST_CASE_ST(ut_setup, ut_teardown,
13547 			test_AES_GCM_auth_encryption_test_case_256_5),
13548 		TEST_CASE_ST(ut_setup, ut_teardown,
13549 			test_AES_GCM_auth_encryption_test_case_256_6),
13550 		TEST_CASE_ST(ut_setup, ut_teardown,
13551 			test_AES_GCM_auth_encryption_test_case_256_7),
13552 
13553 		/** AES GCM Authenticated Decryption 256 bits key */
13554 		TEST_CASE_ST(ut_setup, ut_teardown,
13555 			test_AES_GCM_auth_decryption_test_case_256_1),
13556 		TEST_CASE_ST(ut_setup, ut_teardown,
13557 			test_AES_GCM_auth_decryption_test_case_256_2),
13558 		TEST_CASE_ST(ut_setup, ut_teardown,
13559 			test_AES_GCM_auth_decryption_test_case_256_3),
13560 		TEST_CASE_ST(ut_setup, ut_teardown,
13561 			test_AES_GCM_auth_decryption_test_case_256_4),
13562 		TEST_CASE_ST(ut_setup, ut_teardown,
13563 			test_AES_GCM_auth_decryption_test_case_256_5),
13564 		TEST_CASE_ST(ut_setup, ut_teardown,
13565 			test_AES_GCM_auth_decryption_test_case_256_6),
13566 		TEST_CASE_ST(ut_setup, ut_teardown,
13567 			test_AES_GCM_auth_decryption_test_case_256_7),
13568 
13569 		/** Out of place tests */
13570 		TEST_CASE_ST(ut_setup, ut_teardown,
13571 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13572 		TEST_CASE_ST(ut_setup, ut_teardown,
13573 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13574 
13575 		/** SNOW 3G encrypt only (UEA2) */
13576 		TEST_CASE_ST(ut_setup, ut_teardown,
13577 			test_snow3g_encryption_test_case_1),
13578 		TEST_CASE_ST(ut_setup, ut_teardown,
13579 			test_snow3g_encryption_test_case_2),
13580 		TEST_CASE_ST(ut_setup, ut_teardown,
13581 			test_snow3g_encryption_test_case_3),
13582 		TEST_CASE_ST(ut_setup, ut_teardown,
13583 			test_snow3g_encryption_test_case_4),
13584 		TEST_CASE_ST(ut_setup, ut_teardown,
13585 			test_snow3g_encryption_test_case_5),
13586 
13587 		TEST_CASE_ST(ut_setup, ut_teardown,
13588 			test_snow3g_encryption_test_case_1_oop),
13589 		TEST_CASE_ST(ut_setup, ut_teardown,
13590 				test_snow3g_encryption_test_case_1_oop_sgl),
13591 		TEST_CASE_ST(ut_setup, ut_teardown,
13592 			test_snow3g_decryption_test_case_1_oop),
13593 
13594 		/** SNOW 3G decrypt only (UEA2) */
13595 		TEST_CASE_ST(ut_setup, ut_teardown,
13596 			test_snow3g_decryption_test_case_1),
13597 		TEST_CASE_ST(ut_setup, ut_teardown,
13598 			test_snow3g_decryption_test_case_2),
13599 		TEST_CASE_ST(ut_setup, ut_teardown,
13600 			test_snow3g_decryption_test_case_3),
13601 		TEST_CASE_ST(ut_setup, ut_teardown,
13602 			test_snow3g_decryption_test_case_4),
13603 		TEST_CASE_ST(ut_setup, ut_teardown,
13604 			test_snow3g_decryption_test_case_5),
13605 
13606 		TEST_CASE_ST(ut_setup, ut_teardown,
13607 			test_snow3g_hash_generate_test_case_1),
13608 		TEST_CASE_ST(ut_setup, ut_teardown,
13609 			test_snow3g_hash_generate_test_case_2),
13610 		TEST_CASE_ST(ut_setup, ut_teardown,
13611 			test_snow3g_hash_generate_test_case_3),
13612 		TEST_CASE_ST(ut_setup, ut_teardown,
13613 			test_snow3g_hash_verify_test_case_1),
13614 		TEST_CASE_ST(ut_setup, ut_teardown,
13615 			test_snow3g_hash_verify_test_case_2),
13616 		TEST_CASE_ST(ut_setup, ut_teardown,
13617 			test_snow3g_hash_verify_test_case_3),
13618 
13619 		/** ZUC encrypt only (EEA3) */
13620 		TEST_CASE_ST(ut_setup, ut_teardown,
13621 			test_zuc_encryption_test_case_1),
13622 		TEST_CASE_ST(ut_setup, ut_teardown,
13623 			test_zuc_encryption_test_case_2),
13624 		TEST_CASE_ST(ut_setup, ut_teardown,
13625 			test_zuc_encryption_test_case_3),
13626 		TEST_CASE_ST(ut_setup, ut_teardown,
13627 			test_zuc_encryption_test_case_4),
13628 		TEST_CASE_ST(ut_setup, ut_teardown,
13629 			test_zuc_encryption_test_case_5),
13630 
13631 		/** ZUC authenticate (EIA3) */
13632 		TEST_CASE_ST(ut_setup, ut_teardown,
13633 			test_zuc_hash_generate_test_case_6),
13634 		TEST_CASE_ST(ut_setup, ut_teardown,
13635 			test_zuc_hash_generate_test_case_7),
13636 		TEST_CASE_ST(ut_setup, ut_teardown,
13637 			test_zuc_hash_generate_test_case_8),
13638 
13639 		/** Negative tests */
13640 		TEST_CASE_ST(ut_setup, ut_teardown,
13641 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
13642 		TEST_CASE_ST(ut_setup, ut_teardown,
13643 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13644 		TEST_CASE_ST(ut_setup, ut_teardown,
13645 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13646 		TEST_CASE_ST(ut_setup, ut_teardown,
13647 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13648 		TEST_CASE_ST(ut_setup, ut_teardown,
13649 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
13650 		TEST_CASE_ST(ut_setup, ut_teardown,
13651 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
13652 		TEST_CASE_ST(ut_setup, ut_teardown,
13653 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
13654 		TEST_CASE_ST(ut_setup, ut_teardown,
13655 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13656 		TEST_CASE_ST(ut_setup, ut_teardown,
13657 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13658 		TEST_CASE_ST(ut_setup, ut_teardown,
13659 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13660 		TEST_CASE_ST(ut_setup, ut_teardown,
13661 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
13662 		TEST_CASE_ST(ut_setup, ut_teardown,
13663 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
13664 		TEST_CASE_ST(ut_setup, ut_teardown,
13665 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13666 		TEST_CASE_ST(ut_setup, ut_teardown,
13667 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13668 		TEST_CASE_ST(ut_setup, ut_teardown,
13669 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13670 		TEST_CASE_ST(ut_setup, ut_teardown,
13671 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13672 
13673 		/* ESN Testcase */
13674 		TEST_CASE_ST(ut_setup, ut_teardown,
13675 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13676 		TEST_CASE_ST(ut_setup, ut_teardown,
13677 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13678 
13679 		TEST_CASES_END() /**< NULL terminate unit test array */
13680 	}
13681 };
13682 
13683 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
13684 	.suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13685 	.setup = testsuite_setup,
13686 	.teardown = testsuite_teardown,
13687 	.unit_test_cases = {
13688 		TEST_CASE_ST(ut_setup, ut_teardown,
13689 			test_device_configure_invalid_dev_id),
13690 		TEST_CASE_ST(ut_setup, ut_teardown,
13691 			test_multi_session),
13692 		TEST_CASE_ST(ut_setup, ut_teardown,
13693 			test_AES_chain_dpaa2_sec_all),
13694 		TEST_CASE_ST(ut_setup, ut_teardown,
13695 			test_3DES_chain_dpaa2_sec_all),
13696 		TEST_CASE_ST(ut_setup, ut_teardown,
13697 			test_AES_cipheronly_dpaa2_sec_all),
13698 		TEST_CASE_ST(ut_setup, ut_teardown,
13699 			test_3DES_cipheronly_dpaa2_sec_all),
13700 		TEST_CASE_ST(ut_setup, ut_teardown,
13701 			test_authonly_dpaa2_sec_all),
13702 
13703 #ifdef RTE_LIBRTE_SECURITY
13704 		TEST_CASE_ST(ut_setup, ut_teardown,
13705 			test_PDCP_PROTO_cplane_encap_all),
13706 
13707 		TEST_CASE_ST(ut_setup, ut_teardown,
13708 			test_PDCP_PROTO_cplane_decap_all),
13709 
13710 		TEST_CASE_ST(ut_setup, ut_teardown,
13711 			test_PDCP_PROTO_uplane_encap_all),
13712 
13713 		TEST_CASE_ST(ut_setup, ut_teardown,
13714 			test_PDCP_PROTO_uplane_decap_all),
13715 
13716 		TEST_CASE_ST(ut_setup, ut_teardown,
13717 			test_PDCP_PROTO_SGL_in_place_32B),
13718 		TEST_CASE_ST(ut_setup, ut_teardown,
13719 			test_PDCP_PROTO_SGL_oop_32B_128B),
13720 		TEST_CASE_ST(ut_setup, ut_teardown,
13721 			test_PDCP_PROTO_SGL_oop_32B_40B),
13722 		TEST_CASE_ST(ut_setup, ut_teardown,
13723 			test_PDCP_PROTO_SGL_oop_128B_32B),
13724 #endif
13725 		/** AES GCM Authenticated Encryption */
13726 		TEST_CASE_ST(ut_setup, ut_teardown,
13727 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13728 		TEST_CASE_ST(ut_setup, ut_teardown,
13729 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13730 		TEST_CASE_ST(ut_setup, ut_teardown,
13731 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13732 		TEST_CASE_ST(ut_setup, ut_teardown,
13733 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13734 		TEST_CASE_ST(ut_setup, ut_teardown,
13735 			test_AES_GCM_authenticated_encryption_test_case_1),
13736 		TEST_CASE_ST(ut_setup, ut_teardown,
13737 			test_AES_GCM_authenticated_encryption_test_case_2),
13738 		TEST_CASE_ST(ut_setup, ut_teardown,
13739 			test_AES_GCM_authenticated_encryption_test_case_3),
13740 		TEST_CASE_ST(ut_setup, ut_teardown,
13741 			test_AES_GCM_authenticated_encryption_test_case_4),
13742 		TEST_CASE_ST(ut_setup, ut_teardown,
13743 			test_AES_GCM_authenticated_encryption_test_case_5),
13744 		TEST_CASE_ST(ut_setup, ut_teardown,
13745 			test_AES_GCM_authenticated_encryption_test_case_6),
13746 		TEST_CASE_ST(ut_setup, ut_teardown,
13747 			test_AES_GCM_authenticated_encryption_test_case_7),
13748 		TEST_CASE_ST(ut_setup, ut_teardown,
13749 			test_AES_GCM_authenticated_encryption_test_case_8),
13750 
13751 		/** AES GCM Authenticated Decryption */
13752 		TEST_CASE_ST(ut_setup, ut_teardown,
13753 			test_AES_GCM_authenticated_decryption_test_case_1),
13754 		TEST_CASE_ST(ut_setup, ut_teardown,
13755 			test_AES_GCM_authenticated_decryption_test_case_2),
13756 		TEST_CASE_ST(ut_setup, ut_teardown,
13757 			test_AES_GCM_authenticated_decryption_test_case_3),
13758 		TEST_CASE_ST(ut_setup, ut_teardown,
13759 			test_AES_GCM_authenticated_decryption_test_case_4),
13760 		TEST_CASE_ST(ut_setup, ut_teardown,
13761 			test_AES_GCM_authenticated_decryption_test_case_5),
13762 		TEST_CASE_ST(ut_setup, ut_teardown,
13763 			test_AES_GCM_authenticated_decryption_test_case_6),
13764 		TEST_CASE_ST(ut_setup, ut_teardown,
13765 			test_AES_GCM_authenticated_decryption_test_case_7),
13766 		TEST_CASE_ST(ut_setup, ut_teardown,
13767 			test_AES_GCM_authenticated_decryption_test_case_8),
13768 
13769 		/** AES GCM Authenticated Encryption 192 bits key */
13770 		TEST_CASE_ST(ut_setup, ut_teardown,
13771 			test_AES_GCM_auth_encryption_test_case_192_1),
13772 		TEST_CASE_ST(ut_setup, ut_teardown,
13773 			test_AES_GCM_auth_encryption_test_case_192_2),
13774 		TEST_CASE_ST(ut_setup, ut_teardown,
13775 			test_AES_GCM_auth_encryption_test_case_192_3),
13776 		TEST_CASE_ST(ut_setup, ut_teardown,
13777 			test_AES_GCM_auth_encryption_test_case_192_4),
13778 		TEST_CASE_ST(ut_setup, ut_teardown,
13779 			test_AES_GCM_auth_encryption_test_case_192_5),
13780 		TEST_CASE_ST(ut_setup, ut_teardown,
13781 			test_AES_GCM_auth_encryption_test_case_192_6),
13782 		TEST_CASE_ST(ut_setup, ut_teardown,
13783 			test_AES_GCM_auth_encryption_test_case_192_7),
13784 
13785 		/** AES GCM Authenticated Decryption 192 bits key */
13786 		TEST_CASE_ST(ut_setup, ut_teardown,
13787 			test_AES_GCM_auth_decryption_test_case_192_1),
13788 		TEST_CASE_ST(ut_setup, ut_teardown,
13789 			test_AES_GCM_auth_decryption_test_case_192_2),
13790 		TEST_CASE_ST(ut_setup, ut_teardown,
13791 			test_AES_GCM_auth_decryption_test_case_192_3),
13792 		TEST_CASE_ST(ut_setup, ut_teardown,
13793 			test_AES_GCM_auth_decryption_test_case_192_4),
13794 		TEST_CASE_ST(ut_setup, ut_teardown,
13795 			test_AES_GCM_auth_decryption_test_case_192_5),
13796 		TEST_CASE_ST(ut_setup, ut_teardown,
13797 			test_AES_GCM_auth_decryption_test_case_192_6),
13798 		TEST_CASE_ST(ut_setup, ut_teardown,
13799 			test_AES_GCM_auth_decryption_test_case_192_7),
13800 
13801 		/** AES GCM Authenticated Encryption 256 bits key */
13802 		TEST_CASE_ST(ut_setup, ut_teardown,
13803 			test_AES_GCM_auth_encryption_test_case_256_1),
13804 		TEST_CASE_ST(ut_setup, ut_teardown,
13805 			test_AES_GCM_auth_encryption_test_case_256_2),
13806 		TEST_CASE_ST(ut_setup, ut_teardown,
13807 			test_AES_GCM_auth_encryption_test_case_256_3),
13808 		TEST_CASE_ST(ut_setup, ut_teardown,
13809 			test_AES_GCM_auth_encryption_test_case_256_4),
13810 		TEST_CASE_ST(ut_setup, ut_teardown,
13811 			test_AES_GCM_auth_encryption_test_case_256_5),
13812 		TEST_CASE_ST(ut_setup, ut_teardown,
13813 			test_AES_GCM_auth_encryption_test_case_256_6),
13814 		TEST_CASE_ST(ut_setup, ut_teardown,
13815 			test_AES_GCM_auth_encryption_test_case_256_7),
13816 
13817 		/** AES GCM Authenticated Decryption 256 bits key */
13818 		TEST_CASE_ST(ut_setup, ut_teardown,
13819 			test_AES_GCM_auth_decryption_test_case_256_1),
13820 		TEST_CASE_ST(ut_setup, ut_teardown,
13821 			test_AES_GCM_auth_decryption_test_case_256_2),
13822 		TEST_CASE_ST(ut_setup, ut_teardown,
13823 			test_AES_GCM_auth_decryption_test_case_256_3),
13824 		TEST_CASE_ST(ut_setup, ut_teardown,
13825 			test_AES_GCM_auth_decryption_test_case_256_4),
13826 		TEST_CASE_ST(ut_setup, ut_teardown,
13827 			test_AES_GCM_auth_decryption_test_case_256_5),
13828 		TEST_CASE_ST(ut_setup, ut_teardown,
13829 			test_AES_GCM_auth_decryption_test_case_256_6),
13830 		TEST_CASE_ST(ut_setup, ut_teardown,
13831 			test_AES_GCM_auth_decryption_test_case_256_7),
13832 
13833 		/** Out of place tests */
13834 		TEST_CASE_ST(ut_setup, ut_teardown,
13835 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13836 		TEST_CASE_ST(ut_setup, ut_teardown,
13837 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13838 
13839 		/** SNOW 3G encrypt only (UEA2) */
13840 		TEST_CASE_ST(ut_setup, ut_teardown,
13841 			test_snow3g_encryption_test_case_1),
13842 		TEST_CASE_ST(ut_setup, ut_teardown,
13843 			test_snow3g_encryption_test_case_2),
13844 		TEST_CASE_ST(ut_setup, ut_teardown,
13845 			test_snow3g_encryption_test_case_3),
13846 		TEST_CASE_ST(ut_setup, ut_teardown,
13847 			test_snow3g_encryption_test_case_4),
13848 		TEST_CASE_ST(ut_setup, ut_teardown,
13849 			test_snow3g_encryption_test_case_5),
13850 
13851 		TEST_CASE_ST(ut_setup, ut_teardown,
13852 			test_snow3g_encryption_test_case_1_oop),
13853 		TEST_CASE_ST(ut_setup, ut_teardown,
13854 				test_snow3g_encryption_test_case_1_oop_sgl),
13855 		TEST_CASE_ST(ut_setup, ut_teardown,
13856 			test_snow3g_decryption_test_case_1_oop),
13857 
13858 		/** SNOW 3G decrypt only (UEA2) */
13859 		TEST_CASE_ST(ut_setup, ut_teardown,
13860 			test_snow3g_decryption_test_case_1),
13861 		TEST_CASE_ST(ut_setup, ut_teardown,
13862 			test_snow3g_decryption_test_case_2),
13863 		TEST_CASE_ST(ut_setup, ut_teardown,
13864 			test_snow3g_decryption_test_case_3),
13865 		TEST_CASE_ST(ut_setup, ut_teardown,
13866 			test_snow3g_decryption_test_case_4),
13867 		TEST_CASE_ST(ut_setup, ut_teardown,
13868 			test_snow3g_decryption_test_case_5),
13869 
13870 		TEST_CASE_ST(ut_setup, ut_teardown,
13871 			test_snow3g_hash_generate_test_case_1),
13872 		TEST_CASE_ST(ut_setup, ut_teardown,
13873 			test_snow3g_hash_generate_test_case_2),
13874 		TEST_CASE_ST(ut_setup, ut_teardown,
13875 			test_snow3g_hash_generate_test_case_3),
13876 		TEST_CASE_ST(ut_setup, ut_teardown,
13877 			test_snow3g_hash_verify_test_case_1),
13878 		TEST_CASE_ST(ut_setup, ut_teardown,
13879 			test_snow3g_hash_verify_test_case_2),
13880 		TEST_CASE_ST(ut_setup, ut_teardown,
13881 			test_snow3g_hash_verify_test_case_3),
13882 
13883 		/** ZUC encrypt only (EEA3) */
13884 		TEST_CASE_ST(ut_setup, ut_teardown,
13885 			test_zuc_encryption_test_case_1),
13886 		TEST_CASE_ST(ut_setup, ut_teardown,
13887 			test_zuc_encryption_test_case_2),
13888 		TEST_CASE_ST(ut_setup, ut_teardown,
13889 			test_zuc_encryption_test_case_3),
13890 		TEST_CASE_ST(ut_setup, ut_teardown,
13891 			test_zuc_encryption_test_case_4),
13892 		TEST_CASE_ST(ut_setup, ut_teardown,
13893 			test_zuc_encryption_test_case_5),
13894 
13895 		/** ZUC authenticate (EIA3) */
13896 		TEST_CASE_ST(ut_setup, ut_teardown,
13897 			test_zuc_hash_generate_test_case_6),
13898 		TEST_CASE_ST(ut_setup, ut_teardown,
13899 			test_zuc_hash_generate_test_case_7),
13900 		TEST_CASE_ST(ut_setup, ut_teardown,
13901 			test_zuc_hash_generate_test_case_8),
13902 
13903 		/** HMAC_MD5 Authentication */
13904 		TEST_CASE_ST(ut_setup, ut_teardown,
13905 			test_MD5_HMAC_generate_case_1),
13906 		TEST_CASE_ST(ut_setup, ut_teardown,
13907 			test_MD5_HMAC_verify_case_1),
13908 		TEST_CASE_ST(ut_setup, ut_teardown,
13909 			test_MD5_HMAC_generate_case_2),
13910 		TEST_CASE_ST(ut_setup, ut_teardown,
13911 			test_MD5_HMAC_verify_case_2),
13912 
13913 		/** Negative tests */
13914 		TEST_CASE_ST(ut_setup, ut_teardown,
13915 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
13916 		TEST_CASE_ST(ut_setup, ut_teardown,
13917 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13918 		TEST_CASE_ST(ut_setup, ut_teardown,
13919 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13920 		TEST_CASE_ST(ut_setup, ut_teardown,
13921 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13922 		TEST_CASE_ST(ut_setup, ut_teardown,
13923 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
13924 		TEST_CASE_ST(ut_setup, ut_teardown,
13925 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
13926 		TEST_CASE_ST(ut_setup, ut_teardown,
13927 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
13928 		TEST_CASE_ST(ut_setup, ut_teardown,
13929 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13930 		TEST_CASE_ST(ut_setup, ut_teardown,
13931 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13932 		TEST_CASE_ST(ut_setup, ut_teardown,
13933 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13934 		TEST_CASE_ST(ut_setup, ut_teardown,
13935 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
13936 		TEST_CASE_ST(ut_setup, ut_teardown,
13937 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
13938 		TEST_CASE_ST(ut_setup, ut_teardown,
13939 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13940 		TEST_CASE_ST(ut_setup, ut_teardown,
13941 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13942 		TEST_CASE_ST(ut_setup, ut_teardown,
13943 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13944 		TEST_CASE_ST(ut_setup, ut_teardown,
13945 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13946 
13947 		/* ESN Testcase */
13948 		TEST_CASE_ST(ut_setup, ut_teardown,
13949 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13950 
13951 		TEST_CASE_ST(ut_setup, ut_teardown,
13952 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13953 
13954 		TEST_CASES_END() /**< NULL terminate unit test array */
13955 	}
13956 };
13957 
13958 static struct unit_test_suite cryptodev_null_testsuite  = {
13959 	.suite_name = "Crypto Device NULL Unit Test Suite",
13960 	.setup = testsuite_setup,
13961 	.teardown = testsuite_teardown,
13962 	.unit_test_cases = {
13963 		TEST_CASE_ST(ut_setup, ut_teardown,
13964 			test_null_invalid_operation),
13965 		TEST_CASE_ST(ut_setup, ut_teardown,
13966 			test_null_burst_operation),
13967 		TEST_CASE_ST(ut_setup, ut_teardown,
13968 			test_AES_chain_null_all),
13969 		TEST_CASE_ST(ut_setup, ut_teardown,
13970 			test_AES_cipheronly_null_all),
13971 		TEST_CASE_ST(ut_setup, ut_teardown,
13972 				test_authonly_null_all),
13973 
13974 		TEST_CASES_END() /**< NULL terminate unit test array */
13975 	}
13976 };
13977 
13978 static struct unit_test_suite cryptodev_armv8_testsuite  = {
13979 	.suite_name = "Crypto Device ARMv8 Unit Test Suite",
13980 	.setup = testsuite_setup,
13981 	.teardown = testsuite_teardown,
13982 	.unit_test_cases = {
13983 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13984 
13985 		/** Negative tests */
13986 		TEST_CASE_ST(ut_setup, ut_teardown,
13987 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13988 		TEST_CASE_ST(ut_setup, ut_teardown,
13989 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13990 
13991 		TEST_CASES_END() /**< NULL terminate unit test array */
13992 	}
13993 };
13994 
13995 static struct unit_test_suite cryptodev_mrvl_testsuite  = {
13996 	.suite_name = "Crypto Device Marvell Component Test Suite",
13997 	.setup = testsuite_setup,
13998 	.teardown = testsuite_teardown,
13999 	.unit_test_cases = {
14000 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14001 		TEST_CASE_ST(ut_setup, ut_teardown,
14002 				test_multi_session_random_usage),
14003 		TEST_CASE_ST(ut_setup, ut_teardown,
14004 				test_AES_chain_mrvl_all),
14005 		TEST_CASE_ST(ut_setup, ut_teardown,
14006 				test_AES_cipheronly_mrvl_all),
14007 		TEST_CASE_ST(ut_setup, ut_teardown,
14008 				test_authonly_mrvl_all),
14009 		TEST_CASE_ST(ut_setup, ut_teardown,
14010 				test_3DES_chain_mrvl_all),
14011 		TEST_CASE_ST(ut_setup, ut_teardown,
14012 				test_3DES_cipheronly_mrvl_all),
14013 
14014 		/** Negative tests */
14015 		TEST_CASE_ST(ut_setup, ut_teardown,
14016 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14017 		TEST_CASE_ST(ut_setup, ut_teardown,
14018 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14019 		TEST_CASE_ST(ut_setup, ut_teardown,
14020 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14021 		TEST_CASE_ST(ut_setup, ut_teardown,
14022 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14023 
14024 		TEST_CASES_END() /**< NULL terminate unit test array */
14025 	}
14026 };
14027 
14028 static struct unit_test_suite cryptodev_ccp_testsuite  = {
14029 	.suite_name = "Crypto Device CCP Unit Test Suite",
14030 	.setup = testsuite_setup,
14031 	.teardown = testsuite_teardown,
14032 	.unit_test_cases = {
14033 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14034 		TEST_CASE_ST(ut_setup, ut_teardown,
14035 				test_multi_session_random_usage),
14036 		TEST_CASE_ST(ut_setup, ut_teardown,
14037 				test_AES_chain_ccp_all),
14038 		TEST_CASE_ST(ut_setup, ut_teardown,
14039 				test_AES_cipheronly_ccp_all),
14040 		TEST_CASE_ST(ut_setup, ut_teardown,
14041 				test_3DES_chain_ccp_all),
14042 		TEST_CASE_ST(ut_setup, ut_teardown,
14043 				test_3DES_cipheronly_ccp_all),
14044 		TEST_CASE_ST(ut_setup, ut_teardown,
14045 				test_authonly_ccp_all),
14046 
14047 		/** Negative tests */
14048 		TEST_CASE_ST(ut_setup, ut_teardown,
14049 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14050 		TEST_CASE_ST(ut_setup, ut_teardown,
14051 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14052 		TEST_CASE_ST(ut_setup, ut_teardown,
14053 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14054 		TEST_CASE_ST(ut_setup, ut_teardown,
14055 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14056 
14057 		TEST_CASES_END() /**< NULL terminate unit test array */
14058 	}
14059 };
14060 
14061 static struct unit_test_suite cryptodev_octeontx_testsuite  = {
14062 	.suite_name = "Crypto Device OCTEONTX Unit Test Suite",
14063 	.setup = testsuite_setup,
14064 	.teardown = testsuite_teardown,
14065 	.unit_test_cases = {
14066 		TEST_CASE_ST(ut_setup, ut_teardown,
14067 			test_AES_chain_octeontx_all),
14068 		TEST_CASE_ST(ut_setup, ut_teardown,
14069 			test_AES_cipheronly_octeontx_all),
14070 		TEST_CASE_ST(ut_setup, ut_teardown,
14071 			test_3DES_chain_octeontx_all),
14072 		TEST_CASE_ST(ut_setup, ut_teardown,
14073 			test_3DES_cipheronly_octeontx_all),
14074 		TEST_CASE_ST(ut_setup, ut_teardown,
14075 			test_authonly_octeontx_all),
14076 
14077 		/** AES GCM Authenticated Encryption */
14078 		TEST_CASE_ST(ut_setup, ut_teardown,
14079 			test_AES_GCM_authenticated_encryption_test_case_1),
14080 		TEST_CASE_ST(ut_setup, ut_teardown,
14081 			test_AES_GCM_authenticated_encryption_test_case_2),
14082 		TEST_CASE_ST(ut_setup, ut_teardown,
14083 			test_AES_GCM_authenticated_encryption_test_case_3),
14084 		TEST_CASE_ST(ut_setup, ut_teardown,
14085 			test_AES_GCM_authenticated_encryption_test_case_4),
14086 		TEST_CASE_ST(ut_setup, ut_teardown,
14087 			test_AES_GCM_authenticated_encryption_test_case_5),
14088 		TEST_CASE_ST(ut_setup, ut_teardown,
14089 			test_AES_GCM_authenticated_encryption_test_case_6),
14090 		TEST_CASE_ST(ut_setup, ut_teardown,
14091 			test_AES_GCM_authenticated_encryption_test_case_7),
14092 
14093 		/** AES GCM Authenticated Decryption */
14094 		TEST_CASE_ST(ut_setup, ut_teardown,
14095 			test_AES_GCM_authenticated_decryption_test_case_1),
14096 		TEST_CASE_ST(ut_setup, ut_teardown,
14097 			test_AES_GCM_authenticated_decryption_test_case_2),
14098 		TEST_CASE_ST(ut_setup, ut_teardown,
14099 			test_AES_GCM_authenticated_decryption_test_case_3),
14100 		TEST_CASE_ST(ut_setup, ut_teardown,
14101 			test_AES_GCM_authenticated_decryption_test_case_4),
14102 		TEST_CASE_ST(ut_setup, ut_teardown,
14103 			test_AES_GCM_authenticated_decryption_test_case_5),
14104 		TEST_CASE_ST(ut_setup, ut_teardown,
14105 			test_AES_GCM_authenticated_decryption_test_case_6),
14106 		TEST_CASE_ST(ut_setup, ut_teardown,
14107 			test_AES_GCM_authenticated_decryption_test_case_7),
14108 		/** AES GMAC Authentication */
14109 		TEST_CASE_ST(ut_setup, ut_teardown,
14110 			test_AES_GMAC_authentication_test_case_1),
14111 		TEST_CASE_ST(ut_setup, ut_teardown,
14112 			test_AES_GMAC_authentication_verify_test_case_1),
14113 		TEST_CASE_ST(ut_setup, ut_teardown,
14114 			test_AES_GMAC_authentication_test_case_2),
14115 		TEST_CASE_ST(ut_setup, ut_teardown,
14116 			test_AES_GMAC_authentication_verify_test_case_2),
14117 		TEST_CASE_ST(ut_setup, ut_teardown,
14118 			test_AES_GMAC_authentication_test_case_3),
14119 		TEST_CASE_ST(ut_setup, ut_teardown,
14120 			test_AES_GMAC_authentication_verify_test_case_3),
14121 
14122 		/** SNOW 3G encrypt only (UEA2) */
14123 		TEST_CASE_ST(ut_setup, ut_teardown,
14124 			test_snow3g_encryption_test_case_1),
14125 		TEST_CASE_ST(ut_setup, ut_teardown,
14126 			test_snow3g_encryption_test_case_2),
14127 		TEST_CASE_ST(ut_setup, ut_teardown,
14128 			test_snow3g_encryption_test_case_3),
14129 		TEST_CASE_ST(ut_setup, ut_teardown,
14130 			test_snow3g_encryption_test_case_4),
14131 		TEST_CASE_ST(ut_setup, ut_teardown,
14132 			test_snow3g_encryption_test_case_5),
14133 
14134 		TEST_CASE_ST(ut_setup, ut_teardown,
14135 			test_snow3g_encryption_test_case_1_oop),
14136 		TEST_CASE_ST(ut_setup, ut_teardown,
14137 			test_snow3g_decryption_test_case_1_oop),
14138 		TEST_CASE_ST(ut_setup, ut_teardown,
14139 			test_snow3g_encryption_test_case_1_oop_sgl),
14140 
14141 		/** SNOW 3G decrypt only (UEA2) */
14142 		TEST_CASE_ST(ut_setup, ut_teardown,
14143 			test_snow3g_decryption_test_case_1),
14144 		TEST_CASE_ST(ut_setup, ut_teardown,
14145 			test_snow3g_decryption_test_case_2),
14146 		TEST_CASE_ST(ut_setup, ut_teardown,
14147 			test_snow3g_decryption_test_case_3),
14148 		TEST_CASE_ST(ut_setup, ut_teardown,
14149 			test_snow3g_decryption_test_case_4),
14150 		TEST_CASE_ST(ut_setup, ut_teardown,
14151 			test_snow3g_decryption_test_case_5),
14152 
14153 		TEST_CASE_ST(ut_setup, ut_teardown,
14154 			test_snow3g_hash_generate_test_case_1),
14155 		TEST_CASE_ST(ut_setup, ut_teardown,
14156 			test_snow3g_hash_generate_test_case_2),
14157 		TEST_CASE_ST(ut_setup, ut_teardown,
14158 			test_snow3g_hash_generate_test_case_3),
14159 		TEST_CASE_ST(ut_setup, ut_teardown,
14160 			test_snow3g_hash_verify_test_case_1),
14161 		TEST_CASE_ST(ut_setup, ut_teardown,
14162 			test_snow3g_hash_verify_test_case_2),
14163 		TEST_CASE_ST(ut_setup, ut_teardown,
14164 			test_snow3g_hash_verify_test_case_3),
14165 
14166 		/** ZUC encrypt only (EEA3) */
14167 		TEST_CASE_ST(ut_setup, ut_teardown,
14168 			test_zuc_encryption_test_case_1),
14169 		TEST_CASE_ST(ut_setup, ut_teardown,
14170 			test_zuc_encryption_test_case_2),
14171 		TEST_CASE_ST(ut_setup, ut_teardown,
14172 			test_zuc_encryption_test_case_3),
14173 		TEST_CASE_ST(ut_setup, ut_teardown,
14174 			test_zuc_encryption_test_case_4),
14175 		TEST_CASE_ST(ut_setup, ut_teardown,
14176 			test_zuc_encryption_test_case_5),
14177 		TEST_CASE_ST(ut_setup, ut_teardown,
14178 			test_zuc_hash_generate_test_case_1),
14179 		TEST_CASE_ST(ut_setup, ut_teardown,
14180 			test_zuc_hash_generate_test_case_2),
14181 		TEST_CASE_ST(ut_setup, ut_teardown,
14182 			test_zuc_hash_generate_test_case_3),
14183 		TEST_CASE_ST(ut_setup, ut_teardown,
14184 			test_zuc_hash_generate_test_case_4),
14185 		TEST_CASE_ST(ut_setup, ut_teardown,
14186 			test_zuc_hash_generate_test_case_5),
14187 		TEST_CASE_ST(ut_setup, ut_teardown,
14188 			test_zuc_encryption_test_case_6_sgl),
14189 
14190 		/** KASUMI encrypt only (UEA1) */
14191 		TEST_CASE_ST(ut_setup, ut_teardown,
14192 			test_kasumi_encryption_test_case_1),
14193 		TEST_CASE_ST(ut_setup, ut_teardown,
14194 			test_kasumi_encryption_test_case_2),
14195 		TEST_CASE_ST(ut_setup, ut_teardown,
14196 			test_kasumi_encryption_test_case_3),
14197 		TEST_CASE_ST(ut_setup, ut_teardown,
14198 			test_kasumi_encryption_test_case_4),
14199 		TEST_CASE_ST(ut_setup, ut_teardown,
14200 			test_kasumi_encryption_test_case_5),
14201 		TEST_CASE_ST(ut_setup, ut_teardown,
14202 			test_kasumi_encryption_test_case_1_sgl),
14203 		TEST_CASE_ST(ut_setup, ut_teardown,
14204 			test_kasumi_encryption_test_case_1_oop_sgl),
14205 		/** KASUMI decrypt only (UEA1) */
14206 		TEST_CASE_ST(ut_setup, ut_teardown,
14207 			test_kasumi_decryption_test_case_1),
14208 		TEST_CASE_ST(ut_setup, ut_teardown,
14209 			test_kasumi_decryption_test_case_2),
14210 		TEST_CASE_ST(ut_setup, ut_teardown,
14211 			test_kasumi_decryption_test_case_3),
14212 		TEST_CASE_ST(ut_setup, ut_teardown,
14213 			test_kasumi_decryption_test_case_4),
14214 		TEST_CASE_ST(ut_setup, ut_teardown,
14215 			test_kasumi_decryption_test_case_5),
14216 
14217 		TEST_CASE_ST(ut_setup, ut_teardown,
14218 			test_kasumi_encryption_test_case_1_oop),
14219 		TEST_CASE_ST(ut_setup, ut_teardown,
14220 			test_kasumi_decryption_test_case_1_oop),
14221 
14222 		/** KASUMI hash only (UIA1) */
14223 		TEST_CASE_ST(ut_setup, ut_teardown,
14224 			test_kasumi_hash_generate_test_case_1),
14225 		TEST_CASE_ST(ut_setup, ut_teardown,
14226 			test_kasumi_hash_generate_test_case_2),
14227 		TEST_CASE_ST(ut_setup, ut_teardown,
14228 			test_kasumi_hash_generate_test_case_3),
14229 		TEST_CASE_ST(ut_setup, ut_teardown,
14230 			test_kasumi_hash_generate_test_case_4),
14231 		TEST_CASE_ST(ut_setup, ut_teardown,
14232 			test_kasumi_hash_generate_test_case_5),
14233 		TEST_CASE_ST(ut_setup, ut_teardown,
14234 			test_kasumi_hash_generate_test_case_6),
14235 		TEST_CASE_ST(ut_setup, ut_teardown,
14236 			test_kasumi_hash_verify_test_case_1),
14237 		TEST_CASE_ST(ut_setup, ut_teardown,
14238 			test_kasumi_hash_verify_test_case_2),
14239 		TEST_CASE_ST(ut_setup, ut_teardown,
14240 			test_kasumi_hash_verify_test_case_3),
14241 		TEST_CASE_ST(ut_setup, ut_teardown,
14242 			test_kasumi_hash_verify_test_case_4),
14243 		TEST_CASE_ST(ut_setup, ut_teardown,
14244 			test_kasumi_hash_verify_test_case_5),
14245 
14246 		/** NULL tests */
14247 		TEST_CASE_ST(ut_setup, ut_teardown,
14248 			test_null_cipher_only_operation),
14249 		TEST_CASE_ST(ut_setup, ut_teardown,
14250 			test_null_auth_only_operation),
14251 		TEST_CASE_ST(ut_setup, ut_teardown,
14252 			test_null_cipher_auth_operation),
14253 		TEST_CASE_ST(ut_setup, ut_teardown,
14254 			test_null_auth_cipher_operation),
14255 
14256 		/** Negative tests */
14257 		TEST_CASE_ST(ut_setup, ut_teardown,
14258 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14259 		TEST_CASE_ST(ut_setup, ut_teardown,
14260 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14261 		TEST_CASE_ST(ut_setup, ut_teardown,
14262 			authentication_verify_AES128_GMAC_fail_data_corrupt),
14263 		TEST_CASE_ST(ut_setup, ut_teardown,
14264 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
14265 		TEST_CASE_ST(ut_setup, ut_teardown,
14266 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14267 		TEST_CASE_ST(ut_setup, ut_teardown,
14268 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14269 		TEST_CASES_END() /**< NULL terminate unit test array */
14270 	}
14271 };
14272 
14273 static struct unit_test_suite cryptodev_nitrox_testsuite  = {
14274 	.suite_name = "Crypto NITROX Unit Test Suite",
14275 	.setup = testsuite_setup,
14276 	.teardown = testsuite_teardown,
14277 	.unit_test_cases = {
14278 		TEST_CASE_ST(ut_setup, ut_teardown,
14279 			     test_device_configure_invalid_dev_id),
14280 		TEST_CASE_ST(ut_setup, ut_teardown,
14281 				test_device_configure_invalid_queue_pair_ids),
14282 		TEST_CASE_ST(ut_setup, ut_teardown,
14283 			     test_AES_chain_nitrox_all),
14284 
14285 		TEST_CASES_END() /**< NULL terminate unit test array */
14286 	}
14287 };
14288 
14289 static struct unit_test_suite cryptodev_octeontx2_testsuite  = {
14290 	.suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
14291 	.setup = testsuite_setup,
14292 	.teardown = testsuite_teardown,
14293 	.unit_test_cases = {
14294 		TEST_CASE_ST(ut_setup, ut_teardown,
14295 			test_AES_chain_octeontx2_all),
14296 		TEST_CASE_ST(ut_setup, ut_teardown,
14297 			test_AES_cipheronly_octeontx2_all),
14298 		TEST_CASE_ST(ut_setup, ut_teardown,
14299 			test_3DES_chain_octeontx2_all),
14300 		TEST_CASE_ST(ut_setup, ut_teardown,
14301 			test_3DES_cipheronly_octeontx2_all),
14302 		TEST_CASE_ST(ut_setup, ut_teardown,
14303 			test_authonly_octeontx2_all),
14304 
14305 		/** AES GCM Authenticated Encryption */
14306 		TEST_CASE_ST(ut_setup, ut_teardown,
14307 			test_AES_GCM_authenticated_encryption_test_case_1),
14308 		TEST_CASE_ST(ut_setup, ut_teardown,
14309 			test_AES_GCM_authenticated_encryption_test_case_2),
14310 		TEST_CASE_ST(ut_setup, ut_teardown,
14311 			test_AES_GCM_authenticated_encryption_test_case_3),
14312 		TEST_CASE_ST(ut_setup, ut_teardown,
14313 			test_AES_GCM_authenticated_encryption_test_case_4),
14314 		TEST_CASE_ST(ut_setup, ut_teardown,
14315 			test_AES_GCM_authenticated_encryption_test_case_5),
14316 		TEST_CASE_ST(ut_setup, ut_teardown,
14317 			test_AES_GCM_authenticated_encryption_test_case_6),
14318 		TEST_CASE_ST(ut_setup, ut_teardown,
14319 			test_AES_GCM_authenticated_encryption_test_case_7),
14320 
14321 		/** AES GCM Authenticated Decryption */
14322 		TEST_CASE_ST(ut_setup, ut_teardown,
14323 			test_AES_GCM_authenticated_decryption_test_case_1),
14324 		TEST_CASE_ST(ut_setup, ut_teardown,
14325 			test_AES_GCM_authenticated_decryption_test_case_2),
14326 		TEST_CASE_ST(ut_setup, ut_teardown,
14327 			test_AES_GCM_authenticated_decryption_test_case_3),
14328 		TEST_CASE_ST(ut_setup, ut_teardown,
14329 			test_AES_GCM_authenticated_decryption_test_case_4),
14330 		TEST_CASE_ST(ut_setup, ut_teardown,
14331 			test_AES_GCM_authenticated_decryption_test_case_5),
14332 		TEST_CASE_ST(ut_setup, ut_teardown,
14333 			test_AES_GCM_authenticated_decryption_test_case_6),
14334 		TEST_CASE_ST(ut_setup, ut_teardown,
14335 			test_AES_GCM_authenticated_decryption_test_case_7),
14336 		/** AES GMAC Authentication */
14337 		TEST_CASE_ST(ut_setup, ut_teardown,
14338 			test_AES_GMAC_authentication_test_case_1),
14339 		TEST_CASE_ST(ut_setup, ut_teardown,
14340 			test_AES_GMAC_authentication_verify_test_case_1),
14341 		TEST_CASE_ST(ut_setup, ut_teardown,
14342 			test_AES_GMAC_authentication_test_case_2),
14343 		TEST_CASE_ST(ut_setup, ut_teardown,
14344 			test_AES_GMAC_authentication_verify_test_case_2),
14345 		TEST_CASE_ST(ut_setup, ut_teardown,
14346 			test_AES_GMAC_authentication_test_case_3),
14347 		TEST_CASE_ST(ut_setup, ut_teardown,
14348 			test_AES_GMAC_authentication_verify_test_case_3),
14349 
14350 		/** SNOW 3G encrypt only (UEA2) */
14351 		TEST_CASE_ST(ut_setup, ut_teardown,
14352 			test_snow3g_encryption_test_case_1),
14353 		TEST_CASE_ST(ut_setup, ut_teardown,
14354 			test_snow3g_encryption_test_case_2),
14355 		TEST_CASE_ST(ut_setup, ut_teardown,
14356 			test_snow3g_encryption_test_case_3),
14357 		TEST_CASE_ST(ut_setup, ut_teardown,
14358 			test_snow3g_encryption_test_case_4),
14359 		TEST_CASE_ST(ut_setup, ut_teardown,
14360 			test_snow3g_encryption_test_case_5),
14361 
14362 		TEST_CASE_ST(ut_setup, ut_teardown,
14363 			test_snow3g_encryption_test_case_1_oop),
14364 		TEST_CASE_ST(ut_setup, ut_teardown,
14365 			test_snow3g_decryption_test_case_1_oop),
14366 		TEST_CASE_ST(ut_setup, ut_teardown,
14367 			test_snow3g_encryption_test_case_1_oop_sgl),
14368 
14369 		/** SNOW 3G decrypt only (UEA2) */
14370 		TEST_CASE_ST(ut_setup, ut_teardown,
14371 			test_snow3g_decryption_test_case_1),
14372 		TEST_CASE_ST(ut_setup, ut_teardown,
14373 			test_snow3g_decryption_test_case_2),
14374 		TEST_CASE_ST(ut_setup, ut_teardown,
14375 			test_snow3g_decryption_test_case_3),
14376 		TEST_CASE_ST(ut_setup, ut_teardown,
14377 			test_snow3g_decryption_test_case_4),
14378 		TEST_CASE_ST(ut_setup, ut_teardown,
14379 			test_snow3g_decryption_test_case_5),
14380 
14381 		TEST_CASE_ST(ut_setup, ut_teardown,
14382 			test_snow3g_hash_generate_test_case_1),
14383 		TEST_CASE_ST(ut_setup, ut_teardown,
14384 			test_snow3g_hash_generate_test_case_2),
14385 		TEST_CASE_ST(ut_setup, ut_teardown,
14386 			test_snow3g_hash_generate_test_case_3),
14387 		TEST_CASE_ST(ut_setup, ut_teardown,
14388 			test_snow3g_hash_verify_test_case_1),
14389 		TEST_CASE_ST(ut_setup, ut_teardown,
14390 			test_snow3g_hash_verify_test_case_2),
14391 		TEST_CASE_ST(ut_setup, ut_teardown,
14392 			test_snow3g_hash_verify_test_case_3),
14393 
14394 		/** ZUC encrypt only (EEA3) */
14395 		TEST_CASE_ST(ut_setup, ut_teardown,
14396 			test_zuc_encryption_test_case_1),
14397 		TEST_CASE_ST(ut_setup, ut_teardown,
14398 			test_zuc_encryption_test_case_2),
14399 		TEST_CASE_ST(ut_setup, ut_teardown,
14400 			test_zuc_encryption_test_case_3),
14401 		TEST_CASE_ST(ut_setup, ut_teardown,
14402 			test_zuc_encryption_test_case_4),
14403 		TEST_CASE_ST(ut_setup, ut_teardown,
14404 			test_zuc_encryption_test_case_5),
14405 		TEST_CASE_ST(ut_setup, ut_teardown,
14406 			test_zuc_hash_generate_test_case_1),
14407 		TEST_CASE_ST(ut_setup, ut_teardown,
14408 			test_zuc_hash_generate_test_case_2),
14409 		TEST_CASE_ST(ut_setup, ut_teardown,
14410 			test_zuc_hash_generate_test_case_3),
14411 		TEST_CASE_ST(ut_setup, ut_teardown,
14412 			test_zuc_hash_generate_test_case_4),
14413 		TEST_CASE_ST(ut_setup, ut_teardown,
14414 			test_zuc_hash_generate_test_case_5),
14415 		TEST_CASE_ST(ut_setup, ut_teardown,
14416 			test_zuc_encryption_test_case_6_sgl),
14417 
14418 		/** KASUMI encrypt only (UEA1) */
14419 		TEST_CASE_ST(ut_setup, ut_teardown,
14420 			test_kasumi_encryption_test_case_1),
14421 		TEST_CASE_ST(ut_setup, ut_teardown,
14422 			test_kasumi_encryption_test_case_2),
14423 		TEST_CASE_ST(ut_setup, ut_teardown,
14424 			test_kasumi_encryption_test_case_3),
14425 		TEST_CASE_ST(ut_setup, ut_teardown,
14426 			test_kasumi_encryption_test_case_4),
14427 		TEST_CASE_ST(ut_setup, ut_teardown,
14428 			test_kasumi_encryption_test_case_5),
14429 		TEST_CASE_ST(ut_setup, ut_teardown,
14430 			test_kasumi_encryption_test_case_1_sgl),
14431 		TEST_CASE_ST(ut_setup, ut_teardown,
14432 			test_kasumi_encryption_test_case_1_oop_sgl),
14433 		/** KASUMI decrypt only (UEA1) */
14434 		TEST_CASE_ST(ut_setup, ut_teardown,
14435 			test_kasumi_decryption_test_case_1),
14436 		TEST_CASE_ST(ut_setup, ut_teardown,
14437 			test_kasumi_decryption_test_case_2),
14438 		TEST_CASE_ST(ut_setup, ut_teardown,
14439 			test_kasumi_decryption_test_case_3),
14440 		TEST_CASE_ST(ut_setup, ut_teardown,
14441 			test_kasumi_decryption_test_case_4),
14442 		TEST_CASE_ST(ut_setup, ut_teardown,
14443 			test_kasumi_decryption_test_case_5),
14444 
14445 		TEST_CASE_ST(ut_setup, ut_teardown,
14446 			test_kasumi_encryption_test_case_1_oop),
14447 		TEST_CASE_ST(ut_setup, ut_teardown,
14448 			test_kasumi_decryption_test_case_1_oop),
14449 
14450 		/** KASUMI hash only (UIA1) */
14451 		TEST_CASE_ST(ut_setup, ut_teardown,
14452 			test_kasumi_hash_generate_test_case_1),
14453 		TEST_CASE_ST(ut_setup, ut_teardown,
14454 			test_kasumi_hash_generate_test_case_2),
14455 		TEST_CASE_ST(ut_setup, ut_teardown,
14456 			test_kasumi_hash_generate_test_case_3),
14457 		TEST_CASE_ST(ut_setup, ut_teardown,
14458 			test_kasumi_hash_generate_test_case_4),
14459 		TEST_CASE_ST(ut_setup, ut_teardown,
14460 			test_kasumi_hash_generate_test_case_5),
14461 		TEST_CASE_ST(ut_setup, ut_teardown,
14462 			test_kasumi_hash_generate_test_case_6),
14463 		TEST_CASE_ST(ut_setup, ut_teardown,
14464 			test_kasumi_hash_verify_test_case_1),
14465 		TEST_CASE_ST(ut_setup, ut_teardown,
14466 			test_kasumi_hash_verify_test_case_2),
14467 		TEST_CASE_ST(ut_setup, ut_teardown,
14468 			test_kasumi_hash_verify_test_case_3),
14469 		TEST_CASE_ST(ut_setup, ut_teardown,
14470 			test_kasumi_hash_verify_test_case_4),
14471 		TEST_CASE_ST(ut_setup, ut_teardown,
14472 			test_kasumi_hash_verify_test_case_5),
14473 
14474 		/** NULL tests */
14475 		TEST_CASE_ST(ut_setup, ut_teardown,
14476 			test_null_cipher_only_operation),
14477 		TEST_CASE_ST(ut_setup, ut_teardown,
14478 			test_null_auth_only_operation),
14479 		TEST_CASE_ST(ut_setup, ut_teardown,
14480 			test_null_cipher_auth_operation),
14481 		TEST_CASE_ST(ut_setup, ut_teardown,
14482 			test_null_auth_cipher_operation),
14483 
14484 		/** Negative tests */
14485 		TEST_CASE_ST(ut_setup, ut_teardown,
14486 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14487 		TEST_CASE_ST(ut_setup, ut_teardown,
14488 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14489 		TEST_CASE_ST(ut_setup, ut_teardown,
14490 			authentication_verify_AES128_GMAC_fail_data_corrupt),
14491 		TEST_CASE_ST(ut_setup, ut_teardown,
14492 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
14493 		TEST_CASE_ST(ut_setup, ut_teardown,
14494 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14495 		TEST_CASE_ST(ut_setup, ut_teardown,
14496 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14497 		TEST_CASES_END() /**< NULL terminate unit test array */
14498 	}
14499 };
14500 
14501 static int
14502 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14503 {
14504 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14505 			RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14506 
14507 	if (gbl_driver_id == -1) {
14508 		RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14509 		"CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14510 		"are enabled in config file to run this testsuite.\n");
14511 		return TEST_SKIPPED;
14512 	}
14513 
14514 	return unit_test_suite_runner(&cryptodev_qat_testsuite);
14515 }
14516 
14517 static int
14518 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14519 {
14520 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14521 			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14522 
14523 	if (gbl_driver_id == -1) {
14524 		RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14525 				"CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14526 				"in config file to run this testsuite.\n");
14527 		return TEST_FAILED;
14528 	}
14529 
14530 	return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14531 }
14532 
14533 static int
14534 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14535 {
14536 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14537 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14538 
14539 	if (gbl_driver_id == -1) {
14540 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14541 				"CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14542 				"in config file to run this testsuite.\n");
14543 		return TEST_SKIPPED;
14544 	}
14545 
14546 	return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14547 }
14548 
14549 static int
14550 test_cryptodev_openssl(void)
14551 {
14552 	gbl_driver_id = rte_cryptodev_driver_id_get(
14553 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14554 
14555 	if (gbl_driver_id == -1) {
14556 		RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14557 				"CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14558 				"in config file to run this testsuite.\n");
14559 		return TEST_SKIPPED;
14560 	}
14561 
14562 	return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14563 }
14564 
14565 static int
14566 test_cryptodev_aesni_gcm(void)
14567 {
14568 	gbl_driver_id = rte_cryptodev_driver_id_get(
14569 			RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14570 
14571 	if (gbl_driver_id == -1) {
14572 		RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14573 				"CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14574 				"in config file to run this testsuite.\n");
14575 		return TEST_SKIPPED;
14576 	}
14577 
14578 	return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14579 }
14580 
14581 static int
14582 test_cryptodev_null(void)
14583 {
14584 	gbl_driver_id = rte_cryptodev_driver_id_get(
14585 			RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14586 
14587 	if (gbl_driver_id == -1) {
14588 		RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14589 				"CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14590 				"in config file to run this testsuite.\n");
14591 		return TEST_SKIPPED;
14592 	}
14593 
14594 	return unit_test_suite_runner(&cryptodev_null_testsuite);
14595 }
14596 
14597 static int
14598 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14599 {
14600 	gbl_driver_id = rte_cryptodev_driver_id_get(
14601 			RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14602 
14603 	if (gbl_driver_id == -1) {
14604 		RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14605 				"CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14606 				"in config file to run this testsuite.\n");
14607 		return TEST_SKIPPED;
14608 	}
14609 
14610 	return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14611 }
14612 
14613 static int
14614 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14615 {
14616 	gbl_driver_id = rte_cryptodev_driver_id_get(
14617 			RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14618 
14619 	if (gbl_driver_id == -1) {
14620 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14621 				"CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14622 				"in config file to run this testsuite.\n");
14623 		return TEST_SKIPPED;
14624 	}
14625 
14626 	return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14627 }
14628 
14629 static int
14630 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14631 {
14632 	gbl_driver_id = rte_cryptodev_driver_id_get(
14633 			RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14634 
14635 	if (gbl_driver_id == -1) {
14636 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14637 				"CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14638 				"in config file to run this testsuite.\n");
14639 		return TEST_SKIPPED;
14640 	}
14641 
14642 	return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14643 }
14644 
14645 static int
14646 test_cryptodev_armv8(void)
14647 {
14648 	gbl_driver_id = rte_cryptodev_driver_id_get(
14649 			RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14650 
14651 	if (gbl_driver_id == -1) {
14652 		RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14653 				"CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14654 				"in config file to run this testsuite.\n");
14655 		return TEST_SKIPPED;
14656 	}
14657 
14658 	return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14659 }
14660 
14661 static int
14662 test_cryptodev_mrvl(void)
14663 {
14664 	gbl_driver_id = rte_cryptodev_driver_id_get(
14665 			RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14666 
14667 	if (gbl_driver_id == -1) {
14668 		RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14669 				"CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14670 				"in config file to run this testsuite.\n");
14671 		return TEST_SKIPPED;
14672 	}
14673 
14674 	return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14675 }
14676 
14677 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14678 
14679 static int
14680 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14681 {
14682 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14683 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14684 
14685 	if (gbl_driver_id == -1) {
14686 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14687 				"CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14688 				"in config file to run this testsuite.\n");
14689 		return TEST_SKIPPED;
14690 	}
14691 
14692 	if (rte_cryptodev_driver_id_get(
14693 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14694 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14695 			" enabled in config file to run this testsuite.\n");
14696 		return TEST_SKIPPED;
14697 }
14698 	return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14699 }
14700 
14701 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14702 
14703 #endif
14704 
14705 static int
14706 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14707 {
14708 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14709 			RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14710 
14711 	if (gbl_driver_id == -1) {
14712 		RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14713 				"CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14714 				"in config file to run this testsuite.\n");
14715 		return TEST_SKIPPED;
14716 	}
14717 
14718 	return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14719 }
14720 
14721 static int
14722 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14723 {
14724 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14725 			RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14726 
14727 	if (gbl_driver_id == -1) {
14728 		RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14729 				"CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14730 				"in config file to run this testsuite.\n");
14731 		return TEST_SKIPPED;
14732 	}
14733 
14734 	return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14735 }
14736 
14737 static int
14738 test_cryptodev_ccp(void)
14739 {
14740 	gbl_driver_id = rte_cryptodev_driver_id_get(
14741 			RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14742 
14743 	if (gbl_driver_id == -1) {
14744 		RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14745 				"CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14746 				"in config file to run this testsuite.\n");
14747 		return TEST_FAILED;
14748 	}
14749 
14750 	return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14751 }
14752 
14753 static int
14754 test_cryptodev_octeontx(void)
14755 {
14756 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14757 			RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14758 	if (gbl_driver_id == -1) {
14759 		RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14760 				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14761 				"enabled in config file to run this "
14762 				"testsuite.\n");
14763 		return TEST_FAILED;
14764 	}
14765 	return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14766 }
14767 
14768 static int
14769 test_cryptodev_octeontx2(void)
14770 {
14771 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14772 			RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14773 	if (gbl_driver_id == -1) {
14774 		RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14775 				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14776 				"enabled in config file to run this "
14777 				"testsuite.\n");
14778 		return TEST_FAILED;
14779 	}
14780 	return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14781 }
14782 
14783 static int
14784 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14785 {
14786 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14787 			RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14788 
14789 	if (gbl_driver_id == -1) {
14790 		RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14791 				"CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14792 				"in config file to run this testsuite.\n");
14793 		return TEST_FAILED;
14794 	}
14795 
14796 	return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14797 }
14798 
14799 static int
14800 test_cryptodev_nitrox(void)
14801 {
14802 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14803 			RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14804 
14805 	if (gbl_driver_id == -1) {
14806 		RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14807 				"CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14808 				"in config file to run this testsuite.\n");
14809 		return TEST_FAILED;
14810 	}
14811 
14812 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14813 }
14814 
14815 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14816 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14817 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14818 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14819 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14820 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14821 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14822 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14823 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14824 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14825 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14826 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14827 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14828 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14829 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14830 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14831 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14832 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14833