xref: /dpdk/app/test/test_cryptodev.c (revision e59b75ff)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2017 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 
19 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
20 #include <rte_cryptodev_scheduler.h>
21 #include <rte_cryptodev_scheduler_operations.h>
22 #endif
23 
24 #include <rte_lcore.h>
25 
26 #include "test.h"
27 #include "test_cryptodev.h"
28 
29 #include "test_cryptodev_blockcipher.h"
30 #include "test_cryptodev_aes_test_vectors.h"
31 #include "test_cryptodev_des_test_vectors.h"
32 #include "test_cryptodev_hash_test_vectors.h"
33 #include "test_cryptodev_kasumi_test_vectors.h"
34 #include "test_cryptodev_kasumi_hash_test_vectors.h"
35 #include "test_cryptodev_snow3g_test_vectors.h"
36 #include "test_cryptodev_snow3g_hash_test_vectors.h"
37 #include "test_cryptodev_zuc_test_vectors.h"
38 #include "test_cryptodev_aead_test_vectors.h"
39 #include "test_cryptodev_hmac_test_vectors.h"
40 
41 #define VDEV_ARGS_SIZE 100
42 #define MAX_NB_SESSIONS            4
43 
44 static int gbl_driver_id;
45 
46 struct crypto_testsuite_params {
47 	struct rte_mempool *mbuf_pool;
48 	struct rte_mempool *large_mbuf_pool;
49 	struct rte_mempool *op_mpool;
50 	struct rte_mempool *session_mpool;
51 	struct rte_mempool *session_priv_mpool;
52 	struct rte_cryptodev_config conf;
53 	struct rte_cryptodev_qp_conf qp_conf;
54 
55 	uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
56 	uint8_t valid_dev_count;
57 };
58 
59 struct crypto_unittest_params {
60 	struct rte_crypto_sym_xform cipher_xform;
61 	struct rte_crypto_sym_xform auth_xform;
62 	struct rte_crypto_sym_xform aead_xform;
63 
64 	struct rte_cryptodev_sym_session *sess;
65 
66 	struct rte_crypto_op *op;
67 
68 	struct rte_mbuf *obuf, *ibuf;
69 
70 	uint8_t *digest;
71 };
72 
73 #define ALIGN_POW2_ROUNDUP(num, align) \
74 	(((num) + (align) - 1) & ~((align) - 1))
75 
76 /*
77  * Forward declarations.
78  */
79 static int
80 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
81 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
82 		uint8_t *hmac_key);
83 
84 static int
85 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
86 		struct crypto_unittest_params *ut_params,
87 		struct crypto_testsuite_params *ts_param,
88 		const uint8_t *cipher,
89 		const uint8_t *digest,
90 		const uint8_t *iv);
91 
92 static struct rte_mbuf *
93 setup_test_string(struct rte_mempool *mpool,
94 		const char *string, size_t len, uint8_t blocksize)
95 {
96 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
97 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
98 
99 	memset(m->buf_addr, 0, m->buf_len);
100 	if (m) {
101 		char *dst = rte_pktmbuf_append(m, t_len);
102 
103 		if (!dst) {
104 			rte_pktmbuf_free(m);
105 			return NULL;
106 		}
107 		if (string != NULL)
108 			rte_memcpy(dst, string, t_len);
109 		else
110 			memset(dst, 0, t_len);
111 	}
112 
113 	return m;
114 }
115 
116 /* Get number of bytes in X bits (rounding up) */
117 static uint32_t
118 ceil_byte_length(uint32_t num_bits)
119 {
120 	if (num_bits % 8)
121 		return ((num_bits >> 3) + 1);
122 	else
123 		return (num_bits >> 3);
124 }
125 
126 static struct rte_crypto_op *
127 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
128 {
129 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
130 		printf("Error sending packet for encryption");
131 		return NULL;
132 	}
133 
134 	op = NULL;
135 
136 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
137 		rte_pause();
138 
139 	return op;
140 }
141 
142 static struct crypto_testsuite_params testsuite_params = { NULL };
143 static struct crypto_unittest_params unittest_params;
144 
145 static int
146 testsuite_setup(void)
147 {
148 	struct crypto_testsuite_params *ts_params = &testsuite_params;
149 	struct rte_cryptodev_info info;
150 	uint32_t i = 0, nb_devs, dev_id;
151 	int ret;
152 	uint16_t qp_id;
153 
154 	memset(ts_params, 0, sizeof(*ts_params));
155 
156 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
157 	if (ts_params->mbuf_pool == NULL) {
158 		/* Not already created so create */
159 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
160 				"CRYPTO_MBUFPOOL",
161 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
162 				rte_socket_id());
163 		if (ts_params->mbuf_pool == NULL) {
164 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
165 			return TEST_FAILED;
166 		}
167 	}
168 
169 	ts_params->large_mbuf_pool = rte_mempool_lookup(
170 			"CRYPTO_LARGE_MBUFPOOL");
171 	if (ts_params->large_mbuf_pool == NULL) {
172 		/* Not already created so create */
173 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
174 				"CRYPTO_LARGE_MBUFPOOL",
175 				1, 0, 0, UINT16_MAX,
176 				rte_socket_id());
177 		if (ts_params->large_mbuf_pool == NULL) {
178 			RTE_LOG(ERR, USER1,
179 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
180 			return TEST_FAILED;
181 		}
182 	}
183 
184 	ts_params->op_mpool = rte_crypto_op_pool_create(
185 			"MBUF_CRYPTO_SYM_OP_POOL",
186 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
187 			NUM_MBUFS, MBUF_CACHE_SIZE,
188 			DEFAULT_NUM_XFORMS *
189 			sizeof(struct rte_crypto_sym_xform) +
190 			MAXIMUM_IV_LENGTH,
191 			rte_socket_id());
192 	if (ts_params->op_mpool == NULL) {
193 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
194 		return TEST_FAILED;
195 	}
196 
197 	/* Create an AESNI MB device if required */
198 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
199 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
200 		nb_devs = rte_cryptodev_device_count_by_driver(
201 				rte_cryptodev_driver_id_get(
202 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
203 		if (nb_devs < 1) {
204 			ret = rte_vdev_init(
205 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
206 
207 			TEST_ASSERT(ret == 0,
208 				"Failed to create instance of"
209 				" pmd : %s",
210 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
211 		}
212 	}
213 
214 	/* Create an AESNI GCM device if required */
215 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
216 			RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
217 		nb_devs = rte_cryptodev_device_count_by_driver(
218 				rte_cryptodev_driver_id_get(
219 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
220 		if (nb_devs < 1) {
221 			TEST_ASSERT_SUCCESS(rte_vdev_init(
222 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
223 				"Failed to create instance of"
224 				" pmd : %s",
225 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
226 		}
227 	}
228 
229 	/* Create a SNOW 3G device if required */
230 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
231 			RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
232 		nb_devs = rte_cryptodev_device_count_by_driver(
233 				rte_cryptodev_driver_id_get(
234 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
235 		if (nb_devs < 1) {
236 			TEST_ASSERT_SUCCESS(rte_vdev_init(
237 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
238 				"Failed to create instance of"
239 				" pmd : %s",
240 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
241 		}
242 	}
243 
244 	/* Create a KASUMI device if required */
245 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
246 			RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
247 		nb_devs = rte_cryptodev_device_count_by_driver(
248 				rte_cryptodev_driver_id_get(
249 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
250 		if (nb_devs < 1) {
251 			TEST_ASSERT_SUCCESS(rte_vdev_init(
252 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
253 				"Failed to create instance of"
254 				" pmd : %s",
255 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
256 		}
257 	}
258 
259 	/* Create a ZUC device if required */
260 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
261 			RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
262 		nb_devs = rte_cryptodev_device_count_by_driver(
263 				rte_cryptodev_driver_id_get(
264 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
265 		if (nb_devs < 1) {
266 			TEST_ASSERT_SUCCESS(rte_vdev_init(
267 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
268 				"Failed to create instance of"
269 				" pmd : %s",
270 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
271 		}
272 	}
273 
274 	/* Create a NULL device if required */
275 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
276 			RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
277 		nb_devs = rte_cryptodev_device_count_by_driver(
278 				rte_cryptodev_driver_id_get(
279 				RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
280 		if (nb_devs < 1) {
281 			ret = rte_vdev_init(
282 				RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
283 
284 			TEST_ASSERT(ret == 0,
285 				"Failed to create instance of"
286 				" pmd : %s",
287 				RTE_STR(CRYPTODEV_NAME_NULL_PMD));
288 		}
289 	}
290 
291 	/* Create an OPENSSL device if required */
292 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
293 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
294 		nb_devs = rte_cryptodev_device_count_by_driver(
295 				rte_cryptodev_driver_id_get(
296 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
297 		if (nb_devs < 1) {
298 			ret = rte_vdev_init(
299 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
300 				NULL);
301 
302 			TEST_ASSERT(ret == 0, "Failed to create "
303 				"instance of pmd : %s",
304 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
305 		}
306 	}
307 
308 	/* Create a ARMv8 device if required */
309 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
310 			RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
311 		nb_devs = rte_cryptodev_device_count_by_driver(
312 				rte_cryptodev_driver_id_get(
313 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
314 		if (nb_devs < 1) {
315 			ret = rte_vdev_init(
316 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
317 				NULL);
318 
319 			TEST_ASSERT(ret == 0, "Failed to create "
320 				"instance of pmd : %s",
321 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
322 		}
323 	}
324 
325 	/* Create a MVSAM device if required */
326 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
327 			RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
328 		nb_devs = rte_cryptodev_device_count_by_driver(
329 				rte_cryptodev_driver_id_get(
330 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
331 		if (nb_devs < 1) {
332 			ret = rte_vdev_init(
333 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
334 				NULL);
335 
336 			TEST_ASSERT(ret == 0, "Failed to create "
337 				"instance of pmd : %s",
338 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
339 		}
340 	}
341 
342 	/* Create an CCP device if required */
343 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
344 			RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
345 		nb_devs = rte_cryptodev_device_count_by_driver(
346 				rte_cryptodev_driver_id_get(
347 				RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
348 		if (nb_devs < 1) {
349 			ret = rte_vdev_init(
350 				RTE_STR(CRYPTODEV_NAME_CCP_PMD),
351 				NULL);
352 
353 			TEST_ASSERT(ret == 0, "Failed to create "
354 				"instance of pmd : %s",
355 				RTE_STR(CRYPTODEV_NAME_CCP_PMD));
356 		}
357 	}
358 
359 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
360 	char vdev_args[VDEV_ARGS_SIZE] = {""};
361 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
362 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
363 	uint16_t slave_core_count = 0;
364 	uint16_t socket_id = 0;
365 
366 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
367 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
368 
369 		/* Identify the Slave Cores
370 		 * Use 2 slave cores for the device args
371 		 */
372 		RTE_LCORE_FOREACH_SLAVE(i) {
373 			if (slave_core_count > 1)
374 				break;
375 			snprintf(vdev_args, sizeof(vdev_args),
376 					"%s%d", temp_str, i);
377 			strcpy(temp_str, vdev_args);
378 			strcat(temp_str, ";");
379 			slave_core_count++;
380 			socket_id = lcore_config[i].socket_id;
381 		}
382 		if (slave_core_count != 2) {
383 			RTE_LOG(ERR, USER1,
384 				"Cryptodev scheduler test require at least "
385 				"two slave cores to run. "
386 				"Please use the correct coremask.\n");
387 			return TEST_FAILED;
388 		}
389 		strcpy(temp_str, vdev_args);
390 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
391 				temp_str, socket_id);
392 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
393 		nb_devs = rte_cryptodev_device_count_by_driver(
394 				rte_cryptodev_driver_id_get(
395 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
396 		if (nb_devs < 1) {
397 			ret = rte_vdev_init(
398 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
399 					vdev_args);
400 			TEST_ASSERT(ret == 0,
401 				"Failed to create instance %u of"
402 				" pmd : %s",
403 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
404 		}
405 	}
406 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
407 
408 	nb_devs = rte_cryptodev_count();
409 	if (nb_devs < 1) {
410 		RTE_LOG(ERR, USER1, "No crypto devices found?\n");
411 		return TEST_FAILED;
412 	}
413 
414 	/* Create list of valid crypto devs */
415 	for (i = 0; i < nb_devs; i++) {
416 		rte_cryptodev_info_get(i, &info);
417 		if (info.driver_id == gbl_driver_id)
418 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
419 	}
420 
421 	if (ts_params->valid_dev_count < 1)
422 		return TEST_FAILED;
423 
424 	/* Set up all the qps on the first of the valid devices found */
425 
426 	dev_id = ts_params->valid_devs[0];
427 
428 	rte_cryptodev_info_get(dev_id, &info);
429 
430 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
431 	ts_params->conf.socket_id = SOCKET_ID_ANY;
432 
433 	unsigned int session_size =
434 		rte_cryptodev_sym_get_private_session_size(dev_id);
435 
436 	/*
437 	 * Create mempool with maximum number of sessions * 2,
438 	 * to include the session headers
439 	 */
440 	if (info.sym.max_nb_sessions != 0 &&
441 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
442 		RTE_LOG(ERR, USER1, "Device does not support "
443 				"at least %u sessions\n",
444 				MAX_NB_SESSIONS);
445 		return TEST_FAILED;
446 	}
447 
448 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
449 			"test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
450 			SOCKET_ID_ANY);
451 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
452 			"session mempool allocation failed");
453 
454 	ts_params->session_priv_mpool = rte_mempool_create(
455 			"test_sess_mp_priv",
456 			MAX_NB_SESSIONS,
457 			session_size,
458 			0, 0, NULL, NULL, NULL,
459 			NULL, SOCKET_ID_ANY,
460 			0);
461 	TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
462 			"session mempool allocation failed");
463 
464 
465 
466 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
467 			&ts_params->conf),
468 			"Failed to configure cryptodev %u with %u qps",
469 			dev_id, ts_params->conf.nb_queue_pairs);
470 
471 	ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
472 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
473 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
474 
475 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
476 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
477 			dev_id, qp_id, &ts_params->qp_conf,
478 			rte_cryptodev_socket_id(dev_id)),
479 			"Failed to setup queue pair %u on cryptodev %u",
480 			qp_id, dev_id);
481 	}
482 
483 	return TEST_SUCCESS;
484 }
485 
486 static void
487 testsuite_teardown(void)
488 {
489 	struct crypto_testsuite_params *ts_params = &testsuite_params;
490 
491 	if (ts_params->mbuf_pool != NULL) {
492 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
493 		rte_mempool_avail_count(ts_params->mbuf_pool));
494 	}
495 
496 	if (ts_params->op_mpool != NULL) {
497 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
498 		rte_mempool_avail_count(ts_params->op_mpool));
499 	}
500 
501 	/* Free session mempools */
502 	if (ts_params->session_priv_mpool != NULL) {
503 		rte_mempool_free(ts_params->session_priv_mpool);
504 		ts_params->session_priv_mpool = NULL;
505 	}
506 
507 	if (ts_params->session_mpool != NULL) {
508 		rte_mempool_free(ts_params->session_mpool);
509 		ts_params->session_mpool = NULL;
510 	}
511 }
512 
513 static int
514 ut_setup(void)
515 {
516 	struct crypto_testsuite_params *ts_params = &testsuite_params;
517 	struct crypto_unittest_params *ut_params = &unittest_params;
518 
519 	uint16_t qp_id;
520 
521 	/* Clear unit test parameters before running test */
522 	memset(ut_params, 0, sizeof(*ut_params));
523 
524 	/* Reconfigure device to default parameters */
525 	ts_params->conf.socket_id = SOCKET_ID_ANY;
526 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
527 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
528 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
529 
530 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
531 			&ts_params->conf),
532 			"Failed to configure cryptodev %u",
533 			ts_params->valid_devs[0]);
534 
535 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
536 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
537 			ts_params->valid_devs[0], qp_id,
538 			&ts_params->qp_conf,
539 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
540 			"Failed to setup queue pair %u on cryptodev %u",
541 			qp_id, ts_params->valid_devs[0]);
542 	}
543 
544 
545 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
546 
547 	/* Start the device */
548 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
549 			"Failed to start cryptodev %u",
550 			ts_params->valid_devs[0]);
551 
552 	return TEST_SUCCESS;
553 }
554 
555 static void
556 ut_teardown(void)
557 {
558 	struct crypto_testsuite_params *ts_params = &testsuite_params;
559 	struct crypto_unittest_params *ut_params = &unittest_params;
560 	struct rte_cryptodev_stats stats;
561 
562 	/* free crypto session structure */
563 	if (ut_params->sess) {
564 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
565 				ut_params->sess);
566 		rte_cryptodev_sym_session_free(ut_params->sess);
567 		ut_params->sess = NULL;
568 	}
569 
570 	/* free crypto operation structure */
571 	if (ut_params->op)
572 		rte_crypto_op_free(ut_params->op);
573 
574 	/*
575 	 * free mbuf - both obuf and ibuf are usually the same,
576 	 * so check if they point at the same address is necessary,
577 	 * to avoid freeing the mbuf twice.
578 	 */
579 	if (ut_params->obuf) {
580 		rte_pktmbuf_free(ut_params->obuf);
581 		if (ut_params->ibuf == ut_params->obuf)
582 			ut_params->ibuf = 0;
583 		ut_params->obuf = 0;
584 	}
585 	if (ut_params->ibuf) {
586 		rte_pktmbuf_free(ut_params->ibuf);
587 		ut_params->ibuf = 0;
588 	}
589 
590 	if (ts_params->mbuf_pool != NULL)
591 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
592 			rte_mempool_avail_count(ts_params->mbuf_pool));
593 
594 	rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
595 
596 	/* Stop the device */
597 	rte_cryptodev_stop(ts_params->valid_devs[0]);
598 }
599 
600 static int
601 test_device_configure_invalid_dev_id(void)
602 {
603 	struct crypto_testsuite_params *ts_params = &testsuite_params;
604 	uint16_t dev_id, num_devs = 0;
605 
606 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
607 			"Need at least %d devices for test", 1);
608 
609 	/* valid dev_id values */
610 	dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
611 
612 	/* Stop the device in case it's started so it can be configured */
613 	rte_cryptodev_stop(dev_id);
614 
615 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
616 			"Failed test for rte_cryptodev_configure: "
617 			"invalid dev_num %u", dev_id);
618 
619 	/* invalid dev_id values */
620 	dev_id = num_devs;
621 
622 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
623 			"Failed test for rte_cryptodev_configure: "
624 			"invalid dev_num %u", dev_id);
625 
626 	dev_id = 0xff;
627 
628 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
629 			"Failed test for rte_cryptodev_configure:"
630 			"invalid dev_num %u", dev_id);
631 
632 	return TEST_SUCCESS;
633 }
634 
635 static int
636 test_device_configure_invalid_queue_pair_ids(void)
637 {
638 	struct crypto_testsuite_params *ts_params = &testsuite_params;
639 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
640 
641 	/* Stop the device in case it's started so it can be configured */
642 	rte_cryptodev_stop(ts_params->valid_devs[0]);
643 
644 	/* valid - one queue pairs */
645 	ts_params->conf.nb_queue_pairs = 1;
646 
647 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
648 			&ts_params->conf),
649 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
650 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
651 
652 
653 	/* valid - max value queue pairs */
654 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
655 
656 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
657 			&ts_params->conf),
658 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
659 			ts_params->valid_devs[0],
660 			ts_params->conf.nb_queue_pairs);
661 
662 
663 	/* invalid - zero queue pairs */
664 	ts_params->conf.nb_queue_pairs = 0;
665 
666 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
667 			&ts_params->conf),
668 			"Failed test for rte_cryptodev_configure, dev_id %u,"
669 			" invalid qps: %u",
670 			ts_params->valid_devs[0],
671 			ts_params->conf.nb_queue_pairs);
672 
673 
674 	/* invalid - max value supported by field queue pairs */
675 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
676 
677 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
678 			&ts_params->conf),
679 			"Failed test for rte_cryptodev_configure, dev_id %u,"
680 			" invalid qps: %u",
681 			ts_params->valid_devs[0],
682 			ts_params->conf.nb_queue_pairs);
683 
684 
685 	/* invalid - max value + 1 queue pairs */
686 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
687 
688 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
689 			&ts_params->conf),
690 			"Failed test for rte_cryptodev_configure, dev_id %u,"
691 			" invalid qps: %u",
692 			ts_params->valid_devs[0],
693 			ts_params->conf.nb_queue_pairs);
694 
695 	/* revert to original testsuite value */
696 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
697 
698 	return TEST_SUCCESS;
699 }
700 
701 static int
702 test_queue_pair_descriptor_setup(void)
703 {
704 	struct crypto_testsuite_params *ts_params = &testsuite_params;
705 	struct rte_cryptodev_info dev_info;
706 	struct rte_cryptodev_qp_conf qp_conf = {
707 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
708 	};
709 
710 	uint16_t qp_id;
711 
712 	/* Stop the device in case it's started so it can be configured */
713 	rte_cryptodev_stop(ts_params->valid_devs[0]);
714 
715 
716 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
717 
718 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
719 			&ts_params->conf),
720 			"Failed to configure cryptodev %u",
721 			ts_params->valid_devs[0]);
722 
723 	/*
724 	 * Test various ring sizes on this device. memzones can't be
725 	 * freed so are re-used if ring is released and re-created.
726 	 */
727 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
728 	qp_conf.mp_session = ts_params->session_mpool;
729 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
730 
731 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
732 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
733 				ts_params->valid_devs[0], qp_id, &qp_conf,
734 				rte_cryptodev_socket_id(
735 						ts_params->valid_devs[0])),
736 				"Failed test for "
737 				"rte_cryptodev_queue_pair_setup: num_inflights "
738 				"%u on qp %u on cryptodev %u",
739 				qp_conf.nb_descriptors, qp_id,
740 				ts_params->valid_devs[0]);
741 	}
742 
743 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
744 
745 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
746 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
747 				ts_params->valid_devs[0], qp_id, &qp_conf,
748 				rte_cryptodev_socket_id(
749 						ts_params->valid_devs[0])),
750 				"Failed test for"
751 				" rte_cryptodev_queue_pair_setup: num_inflights"
752 				" %u on qp %u on cryptodev %u",
753 				qp_conf.nb_descriptors, qp_id,
754 				ts_params->valid_devs[0]);
755 	}
756 
757 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
758 
759 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
760 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
761 				ts_params->valid_devs[0], qp_id, &qp_conf,
762 				rte_cryptodev_socket_id(
763 						ts_params->valid_devs[0])),
764 				"Failed test for "
765 				"rte_cryptodev_queue_pair_setup: num_inflights"
766 				" %u on qp %u on cryptodev %u",
767 				qp_conf.nb_descriptors, qp_id,
768 				ts_params->valid_devs[0]);
769 	}
770 
771 	/* invalid number of descriptors - max supported + 2 */
772 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
773 
774 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
775 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
776 				ts_params->valid_devs[0], qp_id, &qp_conf,
777 				rte_cryptodev_socket_id(
778 						ts_params->valid_devs[0])),
779 				"Unexpectedly passed test for "
780 				"rte_cryptodev_queue_pair_setup:"
781 				"num_inflights %u on qp %u on cryptodev %u",
782 				qp_conf.nb_descriptors, qp_id,
783 				ts_params->valid_devs[0]);
784 	}
785 
786 	/* invalid number of descriptors - max value of parameter */
787 	qp_conf.nb_descriptors = UINT32_MAX-1;
788 
789 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
790 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
791 				ts_params->valid_devs[0], qp_id, &qp_conf,
792 				rte_cryptodev_socket_id(
793 						ts_params->valid_devs[0])),
794 				"Unexpectedly passed test for "
795 				"rte_cryptodev_queue_pair_setup:"
796 				"num_inflights %u on qp %u on cryptodev %u",
797 				qp_conf.nb_descriptors, qp_id,
798 				ts_params->valid_devs[0]);
799 	}
800 
801 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
802 
803 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
804 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
805 				ts_params->valid_devs[0], qp_id, &qp_conf,
806 				rte_cryptodev_socket_id(
807 						ts_params->valid_devs[0])),
808 				"Failed test for"
809 				" rte_cryptodev_queue_pair_setup:"
810 				"num_inflights %u on qp %u on cryptodev %u",
811 				qp_conf.nb_descriptors, qp_id,
812 				ts_params->valid_devs[0]);
813 	}
814 
815 	/* invalid number of descriptors - max supported + 1 */
816 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
817 
818 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
819 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
820 				ts_params->valid_devs[0], qp_id, &qp_conf,
821 				rte_cryptodev_socket_id(
822 						ts_params->valid_devs[0])),
823 				"Unexpectedly passed test for "
824 				"rte_cryptodev_queue_pair_setup:"
825 				"num_inflights %u on qp %u on cryptodev %u",
826 				qp_conf.nb_descriptors, qp_id,
827 				ts_params->valid_devs[0]);
828 	}
829 
830 	/* test invalid queue pair id */
831 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
832 
833 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
834 
835 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
836 			ts_params->valid_devs[0],
837 			qp_id, &qp_conf,
838 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
839 			"Failed test for rte_cryptodev_queue_pair_setup:"
840 			"invalid qp %u on cryptodev %u",
841 			qp_id, ts_params->valid_devs[0]);
842 
843 	qp_id = 0xffff; /*invalid*/
844 
845 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
846 			ts_params->valid_devs[0],
847 			qp_id, &qp_conf,
848 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
849 			"Failed test for rte_cryptodev_queue_pair_setup:"
850 			"invalid qp %u on cryptodev %u",
851 			qp_id, ts_params->valid_devs[0]);
852 
853 	return TEST_SUCCESS;
854 }
855 
856 /* ***** Plaintext data for tests ***** */
857 
858 const char catch_22_quote_1[] =
859 		"There was only one catch and that was Catch-22, which "
860 		"specified that a concern for one's safety in the face of "
861 		"dangers that were real and immediate was the process of a "
862 		"rational mind. Orr was crazy and could be grounded. All he "
863 		"had to do was ask; and as soon as he did, he would no longer "
864 		"be crazy and would have to fly more missions. Orr would be "
865 		"crazy to fly more missions and sane if he didn't, but if he "
866 		"was sane he had to fly them. If he flew them he was crazy "
867 		"and didn't have to; but if he didn't want to he was sane and "
868 		"had to. Yossarian was moved very deeply by the absolute "
869 		"simplicity of this clause of Catch-22 and let out a "
870 		"respectful whistle. \"That's some catch, that Catch-22\", he "
871 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
872 
873 const char catch_22_quote[] =
874 		"What a lousy earth! He wondered how many people were "
875 		"destitute that same night even in his own prosperous country, "
876 		"how many homes were shanties, how many husbands were drunk "
877 		"and wives socked, and how many children were bullied, abused, "
878 		"or abandoned. How many families hungered for food they could "
879 		"not afford to buy? How many hearts were broken? How many "
880 		"suicides would take place that same night, how many people "
881 		"would go insane? How many cockroaches and landlords would "
882 		"triumph? How many winners were losers, successes failures, "
883 		"and rich men poor men? How many wise guys were stupid? How "
884 		"many happy endings were unhappy endings? How many honest men "
885 		"were liars, brave men cowards, loyal men traitors, how many "
886 		"sainted men were corrupt, how many people in positions of "
887 		"trust had sold their souls to bodyguards, how many had never "
888 		"had souls? How many straight-and-narrow paths were crooked "
889 		"paths? How many best families were worst families and how "
890 		"many good people were bad people? When you added them all up "
891 		"and then subtracted, you might be left with only the children, "
892 		"and perhaps with Albert Einstein and an old violinist or "
893 		"sculptor somewhere.";
894 
895 #define QUOTE_480_BYTES		(480)
896 #define QUOTE_512_BYTES		(512)
897 #define QUOTE_768_BYTES		(768)
898 #define QUOTE_1024_BYTES	(1024)
899 
900 
901 
902 /* ***** SHA1 Hash Tests ***** */
903 
904 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
905 
906 static uint8_t hmac_sha1_key[] = {
907 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
908 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
909 	0xDE, 0xF4, 0xDE, 0xAD };
910 
911 /* ***** SHA224 Hash Tests ***** */
912 
913 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
914 
915 
916 /* ***** AES-CBC Cipher Tests ***** */
917 
918 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
919 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
920 
921 static uint8_t aes_cbc_key[] = {
922 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
923 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
924 
925 static uint8_t aes_cbc_iv[] = {
926 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
927 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
928 
929 
930 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
931 
932 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
933 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
934 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
935 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
936 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
937 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
938 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
939 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
940 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
941 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
942 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
943 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
944 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
945 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
946 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
947 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
948 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
949 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
950 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
951 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
952 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
953 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
954 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
955 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
956 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
957 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
958 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
959 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
960 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
961 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
962 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
963 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
964 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
965 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
966 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
967 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
968 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
969 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
970 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
971 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
972 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
973 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
974 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
975 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
976 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
977 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
978 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
979 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
980 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
981 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
982 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
983 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
984 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
985 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
986 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
987 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
988 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
989 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
990 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
991 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
992 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
993 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
994 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
995 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
996 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
997 };
998 
999 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1000 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1001 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1002 	0x18, 0x8c, 0x1d, 0x32
1003 };
1004 
1005 
1006 /* Multisession Vector context Test */
1007 /*Begin Session 0 */
1008 static uint8_t ms_aes_cbc_key0[] = {
1009 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1010 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1011 };
1012 
1013 static uint8_t ms_aes_cbc_iv0[] = {
1014 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1015 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1016 };
1017 
1018 static const uint8_t ms_aes_cbc_cipher0[] = {
1019 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1020 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1021 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1022 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1023 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1024 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1025 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1026 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1027 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1028 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1029 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1030 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1031 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1032 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1033 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1034 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1035 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1036 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1037 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1038 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1039 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1040 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1041 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1042 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1043 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1044 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1045 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1046 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1047 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1048 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1049 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1050 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1051 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1052 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1053 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1054 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1055 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1056 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1057 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1058 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1059 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1060 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1061 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1062 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1063 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1064 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1065 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1066 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1067 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1068 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1069 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1070 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1071 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1072 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1073 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1074 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1075 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1076 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1077 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1078 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1079 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1080 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1081 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1082 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1083 };
1084 
1085 
1086 static  uint8_t ms_hmac_key0[] = {
1087 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1088 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1089 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1090 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1091 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1092 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1093 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1094 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1095 };
1096 
1097 static const uint8_t ms_hmac_digest0[] = {
1098 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1099 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1100 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1101 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1102 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1103 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1104 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1105 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1106 		};
1107 
1108 /* End Session 0 */
1109 /* Begin session 1 */
1110 
1111 static  uint8_t ms_aes_cbc_key1[] = {
1112 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1113 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1114 };
1115 
1116 static  uint8_t ms_aes_cbc_iv1[] = {
1117 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1118 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1119 };
1120 
1121 static const uint8_t ms_aes_cbc_cipher1[] = {
1122 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1123 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1124 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1125 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1126 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1127 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1128 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1129 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1130 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1131 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1132 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1133 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1134 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1135 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1136 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1137 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1138 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1139 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1140 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1141 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1142 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1143 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1144 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1145 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1146 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1147 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1148 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1149 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1150 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1151 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1152 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1153 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1154 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1155 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1156 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1157 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1158 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1159 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1160 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1161 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1162 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1163 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1164 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1165 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1166 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1167 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1168 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1169 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1170 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1171 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1172 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1173 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1174 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1175 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1176 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1177 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1178 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1179 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1180 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1181 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1182 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1183 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1184 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1185 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1186 
1187 };
1188 
1189 static uint8_t ms_hmac_key1[] = {
1190 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1191 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1192 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1193 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1194 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1195 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1196 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1197 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1198 };
1199 
1200 static const uint8_t ms_hmac_digest1[] = {
1201 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1202 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1203 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1204 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1205 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1206 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1207 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1208 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1209 };
1210 /* End Session 1  */
1211 /* Begin Session 2 */
1212 static  uint8_t ms_aes_cbc_key2[] = {
1213 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1214 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1215 };
1216 
1217 static  uint8_t ms_aes_cbc_iv2[] = {
1218 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1219 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1220 };
1221 
1222 static const uint8_t ms_aes_cbc_cipher2[] = {
1223 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1224 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1225 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1226 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1227 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1228 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1229 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1230 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1231 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1232 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1233 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1234 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1235 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1236 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1237 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1238 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1239 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1240 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1241 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1242 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1243 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1244 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1245 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1246 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1247 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1248 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1249 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1250 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1251 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1252 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1253 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1254 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1255 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1256 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1257 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1258 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1259 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1260 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1261 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1262 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1263 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1264 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1265 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1266 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1267 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1268 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1269 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1270 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1271 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1272 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1273 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1274 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1275 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1276 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1277 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1278 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1279 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1280 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1281 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1282 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1283 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1284 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1285 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1286 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1287 };
1288 
1289 static  uint8_t ms_hmac_key2[] = {
1290 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1291 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1292 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1293 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1294 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1295 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1296 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1297 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1298 };
1299 
1300 static const uint8_t ms_hmac_digest2[] = {
1301 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1302 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1303 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1304 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1305 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1306 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1307 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1308 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1309 };
1310 
1311 /* End Session 2 */
1312 
1313 
1314 static int
1315 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1316 {
1317 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1318 	struct crypto_unittest_params *ut_params = &unittest_params;
1319 
1320 	/* Generate test mbuf data and space for digest */
1321 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1322 			catch_22_quote,	QUOTE_512_BYTES, 0);
1323 
1324 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1325 			DIGEST_BYTE_LENGTH_SHA1);
1326 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1327 
1328 	/* Setup Cipher Parameters */
1329 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1330 	ut_params->cipher_xform.next = &ut_params->auth_xform;
1331 
1332 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1333 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1334 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1335 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1336 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1337 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1338 
1339 	/* Setup HMAC Parameters */
1340 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1341 
1342 	ut_params->auth_xform.next = NULL;
1343 
1344 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1345 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1346 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1347 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1348 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1349 
1350 	ut_params->sess = rte_cryptodev_sym_session_create(
1351 			ts_params->session_mpool);
1352 
1353 	/* Create crypto session*/
1354 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1355 			ut_params->sess, &ut_params->cipher_xform,
1356 			ts_params->session_priv_mpool);
1357 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1358 
1359 	/* Generate crypto op data structure */
1360 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1361 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1362 	TEST_ASSERT_NOT_NULL(ut_params->op,
1363 			"Failed to allocate symmetric crypto operation struct");
1364 
1365 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1366 
1367 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1368 
1369 	/* set crypto operation source mbuf */
1370 	sym_op->m_src = ut_params->ibuf;
1371 
1372 	/* Set crypto operation authentication parameters */
1373 	sym_op->auth.digest.data = ut_params->digest;
1374 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1375 			ut_params->ibuf, QUOTE_512_BYTES);
1376 
1377 	sym_op->auth.data.offset = 0;
1378 	sym_op->auth.data.length = QUOTE_512_BYTES;
1379 
1380 	/* Copy IV at the end of the crypto operation */
1381 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1382 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1383 
1384 	/* Set crypto operation cipher parameters */
1385 	sym_op->cipher.data.offset = 0;
1386 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1387 
1388 	/* Process crypto operation */
1389 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1390 			ut_params->op), "failed to process sym crypto op");
1391 
1392 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1393 			"crypto op processing failed");
1394 
1395 	/* Validate obuf */
1396 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1397 			uint8_t *);
1398 
1399 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1400 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1401 			QUOTE_512_BYTES,
1402 			"ciphertext data not as expected");
1403 
1404 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1405 
1406 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1407 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1408 			gbl_driver_id == rte_cryptodev_driver_id_get(
1409 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1410 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1411 					DIGEST_BYTE_LENGTH_SHA1,
1412 			"Generated digest data not as expected");
1413 
1414 	return TEST_SUCCESS;
1415 }
1416 
1417 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1418 
1419 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
1420 
1421 static uint8_t hmac_sha512_key[] = {
1422 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1423 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1424 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1425 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1426 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1427 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1428 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1429 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1430 
1431 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1432 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1433 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1434 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1435 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1436 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1437 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1438 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1439 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1440 
1441 
1442 
1443 static int
1444 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1445 		struct crypto_unittest_params *ut_params,
1446 		uint8_t *cipher_key,
1447 		uint8_t *hmac_key);
1448 
1449 static int
1450 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1451 		struct crypto_unittest_params *ut_params,
1452 		struct crypto_testsuite_params *ts_params,
1453 		const uint8_t *cipher,
1454 		const uint8_t *digest,
1455 		const uint8_t *iv);
1456 
1457 
1458 static int
1459 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1460 		struct crypto_unittest_params *ut_params,
1461 		uint8_t *cipher_key,
1462 		uint8_t *hmac_key)
1463 {
1464 
1465 	/* Setup Cipher Parameters */
1466 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1467 	ut_params->cipher_xform.next = NULL;
1468 
1469 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1470 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1471 	ut_params->cipher_xform.cipher.key.data = cipher_key;
1472 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1473 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1474 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1475 
1476 	/* Setup HMAC Parameters */
1477 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1478 	ut_params->auth_xform.next = &ut_params->cipher_xform;
1479 
1480 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1481 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1482 	ut_params->auth_xform.auth.key.data = hmac_key;
1483 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1484 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1485 
1486 	return TEST_SUCCESS;
1487 }
1488 
1489 
1490 static int
1491 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1492 		struct crypto_unittest_params *ut_params,
1493 		struct crypto_testsuite_params *ts_params,
1494 		const uint8_t *cipher,
1495 		const uint8_t *digest,
1496 		const uint8_t *iv)
1497 {
1498 	/* Generate test mbuf data and digest */
1499 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1500 			(const char *)
1501 			cipher,
1502 			QUOTE_512_BYTES, 0);
1503 
1504 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1505 			DIGEST_BYTE_LENGTH_SHA512);
1506 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1507 
1508 	rte_memcpy(ut_params->digest,
1509 			digest,
1510 			DIGEST_BYTE_LENGTH_SHA512);
1511 
1512 	/* Generate Crypto op data structure */
1513 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1514 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1515 	TEST_ASSERT_NOT_NULL(ut_params->op,
1516 			"Failed to allocate symmetric crypto operation struct");
1517 
1518 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
1519 
1520 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1521 
1522 	/* set crypto operation source mbuf */
1523 	sym_op->m_src = ut_params->ibuf;
1524 
1525 	sym_op->auth.digest.data = ut_params->digest;
1526 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1527 			ut_params->ibuf, QUOTE_512_BYTES);
1528 
1529 	sym_op->auth.data.offset = 0;
1530 	sym_op->auth.data.length = QUOTE_512_BYTES;
1531 
1532 	/* Copy IV at the end of the crypto operation */
1533 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1534 			iv, CIPHER_IV_LENGTH_AES_CBC);
1535 
1536 	sym_op->cipher.data.offset = 0;
1537 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1538 
1539 	/* Process crypto operation */
1540 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1541 			ut_params->op), "failed to process sym crypto op");
1542 
1543 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1544 			"crypto op processing failed");
1545 
1546 	ut_params->obuf = ut_params->op->sym->m_src;
1547 
1548 	/* Validate obuf */
1549 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
1550 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1551 			catch_22_quote,
1552 			QUOTE_512_BYTES,
1553 			"Plaintext data not as expected");
1554 
1555 	/* Validate obuf */
1556 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1557 			"Digest verification failed");
1558 
1559 	return TEST_SUCCESS;
1560 }
1561 
1562 static int
1563 test_AES_cipheronly_mb_all(void)
1564 {
1565 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1566 	int status;
1567 
1568 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1569 		ts_params->op_mpool,
1570 		ts_params->session_mpool, ts_params->session_priv_mpool,
1571 		ts_params->valid_devs[0],
1572 		rte_cryptodev_driver_id_get(
1573 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1574 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1575 
1576 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1577 
1578 	return TEST_SUCCESS;
1579 }
1580 
1581 static int
1582 test_AES_docsis_mb_all(void)
1583 {
1584 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1585 	int status;
1586 
1587 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1588 		ts_params->op_mpool,
1589 		ts_params->session_mpool, ts_params->session_priv_mpool,
1590 		ts_params->valid_devs[0],
1591 		rte_cryptodev_driver_id_get(
1592 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1593 		BLKCIPHER_AES_DOCSIS_TYPE);
1594 
1595 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1596 
1597 	return TEST_SUCCESS;
1598 }
1599 
1600 static int
1601 test_AES_docsis_qat_all(void)
1602 {
1603 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1604 	int status;
1605 
1606 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1607 		ts_params->op_mpool,
1608 		ts_params->session_mpool, ts_params->session_priv_mpool,
1609 		ts_params->valid_devs[0],
1610 		rte_cryptodev_driver_id_get(
1611 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1612 		BLKCIPHER_AES_DOCSIS_TYPE);
1613 
1614 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1615 
1616 	return TEST_SUCCESS;
1617 }
1618 
1619 static int
1620 test_DES_docsis_qat_all(void)
1621 {
1622 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1623 	int status;
1624 
1625 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1626 		ts_params->op_mpool,
1627 		ts_params->session_mpool, ts_params->session_priv_mpool,
1628 		ts_params->valid_devs[0],
1629 		rte_cryptodev_driver_id_get(
1630 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1631 		BLKCIPHER_DES_DOCSIS_TYPE);
1632 
1633 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1634 
1635 	return TEST_SUCCESS;
1636 }
1637 
1638 static int
1639 test_authonly_mb_all(void)
1640 {
1641 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1642 	int status;
1643 
1644 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1645 		ts_params->op_mpool,
1646 		ts_params->session_mpool, ts_params->session_priv_mpool,
1647 		ts_params->valid_devs[0],
1648 		rte_cryptodev_driver_id_get(
1649 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1650 		BLKCIPHER_AUTHONLY_TYPE);
1651 
1652 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1653 
1654 	return TEST_SUCCESS;
1655 }
1656 
1657 static int
1658 test_authonly_qat_all(void)
1659 {
1660 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1661 	int status;
1662 
1663 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1664 		ts_params->op_mpool,
1665 		ts_params->session_mpool, ts_params->session_priv_mpool,
1666 		ts_params->valid_devs[0],
1667 		rte_cryptodev_driver_id_get(
1668 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1669 		BLKCIPHER_AUTHONLY_TYPE);
1670 
1671 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1672 
1673 	return TEST_SUCCESS;
1674 }
1675 static int
1676 test_AES_chain_mb_all(void)
1677 {
1678 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1679 	int status;
1680 
1681 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1682 		ts_params->op_mpool,
1683 		ts_params->session_mpool, ts_params->session_priv_mpool,
1684 		ts_params->valid_devs[0],
1685 		rte_cryptodev_driver_id_get(
1686 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1687 		BLKCIPHER_AES_CHAIN_TYPE);
1688 
1689 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1690 
1691 	return TEST_SUCCESS;
1692 }
1693 
1694 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1695 
1696 static int
1697 test_AES_cipheronly_scheduler_all(void)
1698 {
1699 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1700 	int status;
1701 
1702 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1703 		ts_params->op_mpool,
1704 		ts_params->session_mpool, ts_params->session_priv_mpool,
1705 		ts_params->valid_devs[0],
1706 		rte_cryptodev_driver_id_get(
1707 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1708 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1709 
1710 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1711 
1712 	return TEST_SUCCESS;
1713 }
1714 
1715 static int
1716 test_AES_chain_scheduler_all(void)
1717 {
1718 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1719 	int status;
1720 
1721 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1722 		ts_params->op_mpool,
1723 		ts_params->session_mpool, ts_params->session_priv_mpool,
1724 		ts_params->valid_devs[0],
1725 		rte_cryptodev_driver_id_get(
1726 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1727 		BLKCIPHER_AES_CHAIN_TYPE);
1728 
1729 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1730 
1731 	return TEST_SUCCESS;
1732 }
1733 
1734 static int
1735 test_authonly_scheduler_all(void)
1736 {
1737 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1738 	int status;
1739 
1740 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1741 		ts_params->op_mpool,
1742 		ts_params->session_mpool, ts_params->session_priv_mpool,
1743 		ts_params->valid_devs[0],
1744 		rte_cryptodev_driver_id_get(
1745 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1746 		BLKCIPHER_AUTHONLY_TYPE);
1747 
1748 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1749 
1750 	return TEST_SUCCESS;
1751 }
1752 
1753 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1754 
1755 static int
1756 test_AES_chain_openssl_all(void)
1757 {
1758 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1759 	int status;
1760 
1761 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1762 		ts_params->op_mpool,
1763 		ts_params->session_mpool, ts_params->session_priv_mpool,
1764 		ts_params->valid_devs[0],
1765 		rte_cryptodev_driver_id_get(
1766 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1767 		BLKCIPHER_AES_CHAIN_TYPE);
1768 
1769 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1770 
1771 	return TEST_SUCCESS;
1772 }
1773 
1774 static int
1775 test_AES_cipheronly_openssl_all(void)
1776 {
1777 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1778 	int status;
1779 
1780 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1781 		ts_params->op_mpool,
1782 		ts_params->session_mpool, ts_params->session_priv_mpool,
1783 		ts_params->valid_devs[0],
1784 		rte_cryptodev_driver_id_get(
1785 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1786 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1787 
1788 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1789 
1790 	return TEST_SUCCESS;
1791 }
1792 
1793 static int
1794 test_AES_chain_ccp_all(void)
1795 {
1796 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1797 	int status;
1798 
1799 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1800 		ts_params->op_mpool,
1801 		ts_params->session_mpool, ts_params->session_priv_mpool,
1802 		ts_params->valid_devs[0],
1803 		rte_cryptodev_driver_id_get(
1804 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1805 		BLKCIPHER_AES_CHAIN_TYPE);
1806 
1807 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1808 
1809 	return TEST_SUCCESS;
1810 }
1811 
1812 static int
1813 test_AES_cipheronly_ccp_all(void)
1814 {
1815 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1816 	int status;
1817 
1818 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1819 		ts_params->op_mpool,
1820 		ts_params->session_mpool, ts_params->session_priv_mpool,
1821 		ts_params->valid_devs[0],
1822 		rte_cryptodev_driver_id_get(
1823 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1824 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1825 
1826 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1827 
1828 	return TEST_SUCCESS;
1829 }
1830 
1831 static int
1832 test_AES_chain_qat_all(void)
1833 {
1834 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1835 	int status;
1836 
1837 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1838 		ts_params->op_mpool,
1839 		ts_params->session_mpool, ts_params->session_priv_mpool,
1840 		ts_params->valid_devs[0],
1841 		rte_cryptodev_driver_id_get(
1842 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1843 		BLKCIPHER_AES_CHAIN_TYPE);
1844 
1845 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1846 
1847 	return TEST_SUCCESS;
1848 }
1849 
1850 static int
1851 test_AES_cipheronly_qat_all(void)
1852 {
1853 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1854 	int status;
1855 
1856 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1857 		ts_params->op_mpool,
1858 		ts_params->session_mpool, ts_params->session_priv_mpool,
1859 		ts_params->valid_devs[0],
1860 		rte_cryptodev_driver_id_get(
1861 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1862 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1863 
1864 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1865 
1866 	return TEST_SUCCESS;
1867 }
1868 
1869 static int
1870 test_AES_cipheronly_virtio_all(void)
1871 {
1872 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1873 	int status;
1874 
1875 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1876 		ts_params->op_mpool,
1877 		ts_params->session_mpool, ts_params->session_priv_mpool,
1878 		ts_params->valid_devs[0],
1879 		rte_cryptodev_driver_id_get(
1880 		RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1881 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1882 
1883 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1884 
1885 	return TEST_SUCCESS;
1886 }
1887 
1888 static int
1889 test_AES_chain_caam_jr_all(void)
1890 {
1891 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1892 	int status;
1893 
1894 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1895 		ts_params->op_mpool,
1896 		ts_params->session_mpool, ts_params->session_priv_mpool,
1897 		ts_params->valid_devs[0],
1898 		rte_cryptodev_driver_id_get(
1899 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1900 		BLKCIPHER_AES_CHAIN_TYPE);
1901 
1902 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1903 
1904 	return TEST_SUCCESS;
1905 }
1906 
1907 static int
1908 test_AES_cipheronly_caam_jr_all(void)
1909 {
1910 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1911 	int status;
1912 
1913 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1914 		ts_params->op_mpool,
1915 		ts_params->session_mpool, ts_params->session_priv_mpool,
1916 		ts_params->valid_devs[0],
1917 		rte_cryptodev_driver_id_get(
1918 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1919 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1920 
1921 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1922 
1923 	return TEST_SUCCESS;
1924 }
1925 
1926 static int
1927 test_authonly_caam_jr_all(void)
1928 {
1929 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1930 	int status;
1931 
1932 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1933 		ts_params->op_mpool,
1934 		ts_params->session_mpool, ts_params->session_priv_mpool,
1935 		ts_params->valid_devs[0],
1936 		rte_cryptodev_driver_id_get(
1937 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1938 		BLKCIPHER_AUTHONLY_TYPE);
1939 
1940 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1941 
1942 	return TEST_SUCCESS;
1943 }
1944 
1945 
1946 static int
1947 test_AES_chain_dpaa_sec_all(void)
1948 {
1949 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1950 	int status;
1951 
1952 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1953 		ts_params->op_mpool,
1954 		ts_params->session_mpool, ts_params->session_priv_mpool,
1955 		ts_params->valid_devs[0],
1956 		rte_cryptodev_driver_id_get(
1957 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1958 		BLKCIPHER_AES_CHAIN_TYPE);
1959 
1960 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1961 
1962 	return TEST_SUCCESS;
1963 }
1964 
1965 static int
1966 test_AES_cipheronly_dpaa_sec_all(void)
1967 {
1968 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1969 	int status;
1970 
1971 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1972 		ts_params->op_mpool,
1973 		ts_params->session_mpool, ts_params->session_priv_mpool,
1974 		ts_params->valid_devs[0],
1975 		rte_cryptodev_driver_id_get(
1976 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1977 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1978 
1979 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1980 
1981 	return TEST_SUCCESS;
1982 }
1983 
1984 static int
1985 test_authonly_dpaa_sec_all(void)
1986 {
1987 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1988 	int status;
1989 
1990 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1991 		ts_params->op_mpool,
1992 		ts_params->session_mpool, ts_params->session_priv_mpool,
1993 		ts_params->valid_devs[0],
1994 		rte_cryptodev_driver_id_get(
1995 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1996 		BLKCIPHER_AUTHONLY_TYPE);
1997 
1998 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1999 
2000 	return TEST_SUCCESS;
2001 }
2002 
2003 static int
2004 test_AES_chain_dpaa2_sec_all(void)
2005 {
2006 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2007 	int status;
2008 
2009 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2010 		ts_params->op_mpool,
2011 		ts_params->session_mpool, ts_params->session_priv_mpool,
2012 		ts_params->valid_devs[0],
2013 		rte_cryptodev_driver_id_get(
2014 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2015 		BLKCIPHER_AES_CHAIN_TYPE);
2016 
2017 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2018 
2019 	return TEST_SUCCESS;
2020 }
2021 
2022 static int
2023 test_AES_cipheronly_dpaa2_sec_all(void)
2024 {
2025 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2026 	int status;
2027 
2028 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2029 		ts_params->op_mpool,
2030 		ts_params->session_mpool, ts_params->session_priv_mpool,
2031 		ts_params->valid_devs[0],
2032 		rte_cryptodev_driver_id_get(
2033 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2034 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2035 
2036 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2037 
2038 	return TEST_SUCCESS;
2039 }
2040 
2041 static int
2042 test_authonly_dpaa2_sec_all(void)
2043 {
2044 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2045 	int status;
2046 
2047 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2048 		ts_params->op_mpool,
2049 		ts_params->session_mpool, ts_params->session_priv_mpool,
2050 		ts_params->valid_devs[0],
2051 		rte_cryptodev_driver_id_get(
2052 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2053 		BLKCIPHER_AUTHONLY_TYPE);
2054 
2055 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2056 
2057 	return TEST_SUCCESS;
2058 }
2059 
2060 static int
2061 test_authonly_openssl_all(void)
2062 {
2063 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2064 	int status;
2065 
2066 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2067 		ts_params->op_mpool,
2068 		ts_params->session_mpool, ts_params->session_priv_mpool,
2069 		ts_params->valid_devs[0],
2070 		rte_cryptodev_driver_id_get(
2071 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2072 		BLKCIPHER_AUTHONLY_TYPE);
2073 
2074 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2075 
2076 	return TEST_SUCCESS;
2077 }
2078 
2079 static int
2080 test_authonly_ccp_all(void)
2081 {
2082 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2083 	int status;
2084 
2085 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2086 		ts_params->op_mpool,
2087 		ts_params->session_mpool, ts_params->session_priv_mpool,
2088 		ts_params->valid_devs[0],
2089 		rte_cryptodev_driver_id_get(
2090 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2091 		BLKCIPHER_AUTHONLY_TYPE);
2092 
2093 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2094 
2095 	return TEST_SUCCESS;
2096 }
2097 
2098 static int
2099 test_AES_chain_armv8_all(void)
2100 {
2101 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2102 	int status;
2103 
2104 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2105 		ts_params->op_mpool,
2106 		ts_params->session_mpool, ts_params->session_priv_mpool,
2107 		ts_params->valid_devs[0],
2108 		rte_cryptodev_driver_id_get(
2109 		RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2110 		BLKCIPHER_AES_CHAIN_TYPE);
2111 
2112 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2113 
2114 	return TEST_SUCCESS;
2115 }
2116 
2117 static int
2118 test_AES_chain_mrvl_all(void)
2119 {
2120 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2121 	int status;
2122 
2123 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2124 		ts_params->op_mpool,
2125 		ts_params->session_mpool, ts_params->session_priv_mpool,
2126 		ts_params->valid_devs[0],
2127 		rte_cryptodev_driver_id_get(
2128 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2129 		BLKCIPHER_AES_CHAIN_TYPE);
2130 
2131 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2132 
2133 	return TEST_SUCCESS;
2134 }
2135 
2136 static int
2137 test_AES_cipheronly_mrvl_all(void)
2138 {
2139 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2140 	int status;
2141 
2142 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2143 		ts_params->op_mpool,
2144 		ts_params->session_mpool, ts_params->session_priv_mpool,
2145 		ts_params->valid_devs[0],
2146 		rte_cryptodev_driver_id_get(
2147 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2148 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2149 
2150 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2151 
2152 	return TEST_SUCCESS;
2153 }
2154 
2155 static int
2156 test_authonly_mrvl_all(void)
2157 {
2158 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2159 	int status;
2160 
2161 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2162 		ts_params->op_mpool,
2163 		ts_params->session_mpool, ts_params->session_priv_mpool,
2164 		ts_params->valid_devs[0],
2165 		rte_cryptodev_driver_id_get(
2166 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2167 		BLKCIPHER_AUTHONLY_TYPE);
2168 
2169 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2170 
2171 	return TEST_SUCCESS;
2172 }
2173 
2174 static int
2175 test_3DES_chain_mrvl_all(void)
2176 {
2177 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2178 	int status;
2179 
2180 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2181 		ts_params->op_mpool,
2182 		ts_params->session_mpool, ts_params->session_priv_mpool,
2183 		ts_params->valid_devs[0],
2184 		rte_cryptodev_driver_id_get(
2185 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2186 		BLKCIPHER_3DES_CHAIN_TYPE);
2187 
2188 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2189 
2190 	return TEST_SUCCESS;
2191 }
2192 
2193 static int
2194 test_3DES_cipheronly_mrvl_all(void)
2195 {
2196 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2197 	int status;
2198 
2199 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2200 		ts_params->op_mpool,
2201 		ts_params->session_mpool, ts_params->session_priv_mpool,
2202 		ts_params->valid_devs[0],
2203 		rte_cryptodev_driver_id_get(
2204 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2205 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2206 
2207 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2208 
2209 	return TEST_SUCCESS;
2210 }
2211 
2212 static int
2213 test_AES_chain_octeontx_all(void)
2214 {
2215 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2216 	int status;
2217 
2218 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2219 		ts_params->op_mpool, ts_params->session_mpool,
2220 		ts_params->session_priv_mpool,
2221 		ts_params->valid_devs[0],
2222 		rte_cryptodev_driver_id_get(
2223 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2224 		BLKCIPHER_AES_CHAIN_TYPE);
2225 
2226 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2227 
2228 	return TEST_SUCCESS;
2229 }
2230 
2231 static int
2232 test_AES_cipheronly_octeontx_all(void)
2233 {
2234 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2235 	int status;
2236 
2237 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2238 		ts_params->op_mpool, ts_params->session_mpool,
2239 		ts_params->session_priv_mpool,
2240 		ts_params->valid_devs[0],
2241 		rte_cryptodev_driver_id_get(
2242 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2243 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2244 
2245 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2246 
2247 	return TEST_SUCCESS;
2248 }
2249 
2250 static int
2251 test_3DES_chain_octeontx_all(void)
2252 {
2253 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2254 	int status;
2255 
2256 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2257 		ts_params->op_mpool, ts_params->session_mpool,
2258 		ts_params->session_priv_mpool,
2259 		ts_params->valid_devs[0],
2260 		rte_cryptodev_driver_id_get(
2261 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2262 		BLKCIPHER_3DES_CHAIN_TYPE);
2263 
2264 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2265 
2266 	return TEST_SUCCESS;
2267 }
2268 
2269 static int
2270 test_3DES_cipheronly_octeontx_all(void)
2271 {
2272 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2273 	int status;
2274 
2275 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2276 		ts_params->op_mpool, ts_params->session_mpool,
2277 		ts_params->session_priv_mpool,
2278 		ts_params->valid_devs[0],
2279 		rte_cryptodev_driver_id_get(
2280 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2281 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2282 
2283 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2284 
2285 	return TEST_SUCCESS;
2286 }
2287 
2288 static int
2289 test_authonly_octeontx_all(void)
2290 {
2291 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2292 	int status;
2293 
2294 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2295 		ts_params->op_mpool, ts_params->session_mpool,
2296 		ts_params->session_priv_mpool,
2297 		ts_params->valid_devs[0],
2298 		rte_cryptodev_driver_id_get(
2299 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2300 		BLKCIPHER_AUTHONLY_TYPE);
2301 
2302 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2303 
2304 	return TEST_SUCCESS;
2305 }
2306 
2307 /* ***** SNOW 3G Tests ***** */
2308 static int
2309 create_wireless_algo_hash_session(uint8_t dev_id,
2310 	const uint8_t *key, const uint8_t key_len,
2311 	const uint8_t iv_len, const uint8_t auth_len,
2312 	enum rte_crypto_auth_operation op,
2313 	enum rte_crypto_auth_algorithm algo)
2314 {
2315 	uint8_t hash_key[key_len];
2316 
2317 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2318 	struct crypto_unittest_params *ut_params = &unittest_params;
2319 
2320 	memcpy(hash_key, key, key_len);
2321 
2322 	debug_hexdump(stdout, "key:", key, key_len);
2323 
2324 	/* Setup Authentication Parameters */
2325 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2326 	ut_params->auth_xform.next = NULL;
2327 
2328 	ut_params->auth_xform.auth.op = op;
2329 	ut_params->auth_xform.auth.algo = algo;
2330 	ut_params->auth_xform.auth.key.length = key_len;
2331 	ut_params->auth_xform.auth.key.data = hash_key;
2332 	ut_params->auth_xform.auth.digest_length = auth_len;
2333 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2334 	ut_params->auth_xform.auth.iv.length = iv_len;
2335 	ut_params->sess = rte_cryptodev_sym_session_create(
2336 			ts_params->session_mpool);
2337 
2338 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2339 			&ut_params->auth_xform,
2340 			ts_params->session_priv_mpool);
2341 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2342 	return 0;
2343 }
2344 
2345 static int
2346 create_wireless_algo_cipher_session(uint8_t dev_id,
2347 			enum rte_crypto_cipher_operation op,
2348 			enum rte_crypto_cipher_algorithm algo,
2349 			const uint8_t *key, const uint8_t key_len,
2350 			uint8_t iv_len)
2351 {
2352 	uint8_t cipher_key[key_len];
2353 
2354 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2355 	struct crypto_unittest_params *ut_params = &unittest_params;
2356 
2357 	memcpy(cipher_key, key, key_len);
2358 
2359 	/* Setup Cipher Parameters */
2360 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2361 	ut_params->cipher_xform.next = NULL;
2362 
2363 	ut_params->cipher_xform.cipher.algo = algo;
2364 	ut_params->cipher_xform.cipher.op = op;
2365 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2366 	ut_params->cipher_xform.cipher.key.length = key_len;
2367 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2368 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2369 
2370 	debug_hexdump(stdout, "key:", key, key_len);
2371 
2372 	/* Create Crypto session */
2373 	ut_params->sess = rte_cryptodev_sym_session_create(
2374 			ts_params->session_mpool);
2375 
2376 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2377 			&ut_params->cipher_xform,
2378 			ts_params->session_priv_mpool);
2379 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2380 	return 0;
2381 }
2382 
2383 static int
2384 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2385 			unsigned int cipher_len,
2386 			unsigned int cipher_offset)
2387 {
2388 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2389 	struct crypto_unittest_params *ut_params = &unittest_params;
2390 
2391 	/* Generate Crypto op data structure */
2392 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2393 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2394 	TEST_ASSERT_NOT_NULL(ut_params->op,
2395 				"Failed to allocate pktmbuf offload");
2396 
2397 	/* Set crypto operation data parameters */
2398 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2399 
2400 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2401 
2402 	/* set crypto operation source mbuf */
2403 	sym_op->m_src = ut_params->ibuf;
2404 
2405 	/* iv */
2406 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2407 			iv, iv_len);
2408 	sym_op->cipher.data.length = cipher_len;
2409 	sym_op->cipher.data.offset = cipher_offset;
2410 	return 0;
2411 }
2412 
2413 static int
2414 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2415 			unsigned int cipher_len,
2416 			unsigned int cipher_offset)
2417 {
2418 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2419 	struct crypto_unittest_params *ut_params = &unittest_params;
2420 
2421 	/* Generate Crypto op data structure */
2422 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2423 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2424 	TEST_ASSERT_NOT_NULL(ut_params->op,
2425 				"Failed to allocate pktmbuf offload");
2426 
2427 	/* Set crypto operation data parameters */
2428 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2429 
2430 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2431 
2432 	/* set crypto operation source mbuf */
2433 	sym_op->m_src = ut_params->ibuf;
2434 	sym_op->m_dst = ut_params->obuf;
2435 
2436 	/* iv */
2437 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2438 			iv, iv_len);
2439 	sym_op->cipher.data.length = cipher_len;
2440 	sym_op->cipher.data.offset = cipher_offset;
2441 	return 0;
2442 }
2443 
2444 static int
2445 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2446 		enum rte_crypto_cipher_operation cipher_op,
2447 		enum rte_crypto_auth_operation auth_op,
2448 		enum rte_crypto_auth_algorithm auth_algo,
2449 		enum rte_crypto_cipher_algorithm cipher_algo,
2450 		const uint8_t *key, uint8_t key_len,
2451 		uint8_t auth_iv_len, uint8_t auth_len,
2452 		uint8_t cipher_iv_len)
2453 
2454 {
2455 	uint8_t cipher_auth_key[key_len];
2456 
2457 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2458 	struct crypto_unittest_params *ut_params = &unittest_params;
2459 
2460 	memcpy(cipher_auth_key, key, key_len);
2461 
2462 	/* Setup Authentication Parameters */
2463 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2464 	ut_params->auth_xform.next = NULL;
2465 
2466 	ut_params->auth_xform.auth.op = auth_op;
2467 	ut_params->auth_xform.auth.algo = auth_algo;
2468 	ut_params->auth_xform.auth.key.length = key_len;
2469 	/* Hash key = cipher key */
2470 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2471 	ut_params->auth_xform.auth.digest_length = auth_len;
2472 	/* Auth IV will be after cipher IV */
2473 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2474 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2475 
2476 	/* Setup Cipher Parameters */
2477 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2478 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2479 
2480 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2481 	ut_params->cipher_xform.cipher.op = cipher_op;
2482 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2483 	ut_params->cipher_xform.cipher.key.length = key_len;
2484 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2485 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2486 
2487 	debug_hexdump(stdout, "key:", key, key_len);
2488 
2489 	/* Create Crypto session*/
2490 	ut_params->sess = rte_cryptodev_sym_session_create(
2491 			ts_params->session_mpool);
2492 
2493 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2494 			&ut_params->cipher_xform,
2495 			ts_params->session_priv_mpool);
2496 
2497 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2498 	return 0;
2499 }
2500 
2501 static int
2502 create_wireless_cipher_auth_session(uint8_t dev_id,
2503 		enum rte_crypto_cipher_operation cipher_op,
2504 		enum rte_crypto_auth_operation auth_op,
2505 		enum rte_crypto_auth_algorithm auth_algo,
2506 		enum rte_crypto_cipher_algorithm cipher_algo,
2507 		const struct wireless_test_data *tdata)
2508 {
2509 	const uint8_t key_len = tdata->key.len;
2510 	uint8_t cipher_auth_key[key_len];
2511 
2512 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2513 	struct crypto_unittest_params *ut_params = &unittest_params;
2514 	const uint8_t *key = tdata->key.data;
2515 	const uint8_t auth_len = tdata->digest.len;
2516 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2517 	uint8_t auth_iv_len = tdata->auth_iv.len;
2518 
2519 	memcpy(cipher_auth_key, key, key_len);
2520 
2521 	/* Setup Authentication Parameters */
2522 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2523 	ut_params->auth_xform.next = NULL;
2524 
2525 	ut_params->auth_xform.auth.op = auth_op;
2526 	ut_params->auth_xform.auth.algo = auth_algo;
2527 	ut_params->auth_xform.auth.key.length = key_len;
2528 	/* Hash key = cipher key */
2529 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2530 	ut_params->auth_xform.auth.digest_length = auth_len;
2531 	/* Auth IV will be after cipher IV */
2532 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2533 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2534 
2535 	/* Setup Cipher Parameters */
2536 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2537 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2538 
2539 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2540 	ut_params->cipher_xform.cipher.op = cipher_op;
2541 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2542 	ut_params->cipher_xform.cipher.key.length = key_len;
2543 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2544 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2545 
2546 
2547 	debug_hexdump(stdout, "key:", key, key_len);
2548 
2549 	/* Create Crypto session*/
2550 	ut_params->sess = rte_cryptodev_sym_session_create(
2551 			ts_params->session_mpool);
2552 
2553 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2554 			&ut_params->cipher_xform,
2555 			ts_params->session_priv_mpool);
2556 
2557 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2558 	return 0;
2559 }
2560 
2561 static int
2562 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2563 		const struct wireless_test_data *tdata)
2564 {
2565 	return create_wireless_cipher_auth_session(dev_id,
2566 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2567 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2568 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2569 }
2570 
2571 static int
2572 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2573 		enum rte_crypto_cipher_operation cipher_op,
2574 		enum rte_crypto_auth_operation auth_op,
2575 		enum rte_crypto_auth_algorithm auth_algo,
2576 		enum rte_crypto_cipher_algorithm cipher_algo,
2577 		const uint8_t *key, const uint8_t key_len,
2578 		uint8_t auth_iv_len, uint8_t auth_len,
2579 		uint8_t cipher_iv_len)
2580 {
2581 	uint8_t auth_cipher_key[key_len];
2582 
2583 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2584 	struct crypto_unittest_params *ut_params = &unittest_params;
2585 
2586 	memcpy(auth_cipher_key, key, key_len);
2587 
2588 	/* Setup Authentication Parameters */
2589 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2590 	ut_params->auth_xform.auth.op = auth_op;
2591 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2592 	ut_params->auth_xform.auth.algo = auth_algo;
2593 	ut_params->auth_xform.auth.key.length = key_len;
2594 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
2595 	ut_params->auth_xform.auth.digest_length = auth_len;
2596 	/* Auth IV will be after cipher IV */
2597 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2598 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2599 
2600 	/* Setup Cipher Parameters */
2601 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2602 	ut_params->cipher_xform.next = NULL;
2603 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2604 	ut_params->cipher_xform.cipher.op = cipher_op;
2605 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2606 	ut_params->cipher_xform.cipher.key.length = key_len;
2607 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2608 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2609 
2610 	debug_hexdump(stdout, "key:", key, key_len);
2611 
2612 	/* Create Crypto session*/
2613 	ut_params->sess = rte_cryptodev_sym_session_create(
2614 			ts_params->session_mpool);
2615 
2616 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2617 			&ut_params->auth_xform,
2618 			ts_params->session_priv_mpool);
2619 
2620 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2621 
2622 	return 0;
2623 }
2624 
2625 static int
2626 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2627 		unsigned int auth_tag_len,
2628 		const uint8_t *iv, unsigned int iv_len,
2629 		unsigned int data_pad_len,
2630 		enum rte_crypto_auth_operation op,
2631 		unsigned int auth_len, unsigned int auth_offset)
2632 {
2633 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2634 
2635 	struct crypto_unittest_params *ut_params = &unittest_params;
2636 
2637 	/* Generate Crypto op data structure */
2638 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2639 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2640 	TEST_ASSERT_NOT_NULL(ut_params->op,
2641 		"Failed to allocate pktmbuf offload");
2642 
2643 	/* Set crypto operation data parameters */
2644 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2645 
2646 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2647 
2648 	/* set crypto operation source mbuf */
2649 	sym_op->m_src = ut_params->ibuf;
2650 
2651 	/* iv */
2652 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2653 			iv, iv_len);
2654 	/* digest */
2655 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2656 					ut_params->ibuf, auth_tag_len);
2657 
2658 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2659 				"no room to append auth tag");
2660 	ut_params->digest = sym_op->auth.digest.data;
2661 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2662 			ut_params->ibuf, data_pad_len);
2663 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2664 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2665 	else
2666 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2667 
2668 	debug_hexdump(stdout, "digest:",
2669 		sym_op->auth.digest.data,
2670 		auth_tag_len);
2671 
2672 	sym_op->auth.data.length = auth_len;
2673 	sym_op->auth.data.offset = auth_offset;
2674 
2675 	return 0;
2676 }
2677 
2678 static int
2679 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2680 	enum rte_crypto_auth_operation op)
2681 {
2682 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2683 	struct crypto_unittest_params *ut_params = &unittest_params;
2684 
2685 	const uint8_t *auth_tag = tdata->digest.data;
2686 	const unsigned int auth_tag_len = tdata->digest.len;
2687 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2688 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2689 
2690 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2691 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2692 	const uint8_t *auth_iv = tdata->auth_iv.data;
2693 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2694 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2695 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2696 
2697 	/* Generate Crypto op data structure */
2698 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2699 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2700 	TEST_ASSERT_NOT_NULL(ut_params->op,
2701 			"Failed to allocate pktmbuf offload");
2702 	/* Set crypto operation data parameters */
2703 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2704 
2705 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2706 
2707 	/* set crypto operation source mbuf */
2708 	sym_op->m_src = ut_params->ibuf;
2709 
2710 	/* digest */
2711 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2712 			ut_params->ibuf, auth_tag_len);
2713 
2714 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2715 			"no room to append auth tag");
2716 	ut_params->digest = sym_op->auth.digest.data;
2717 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2718 			ut_params->ibuf, data_pad_len);
2719 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2720 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2721 	else
2722 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2723 
2724 	debug_hexdump(stdout, "digest:",
2725 		sym_op->auth.digest.data,
2726 		auth_tag_len);
2727 
2728 	/* Copy cipher and auth IVs at the end of the crypto operation */
2729 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2730 						IV_OFFSET);
2731 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2732 	iv_ptr += cipher_iv_len;
2733 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2734 
2735 	sym_op->cipher.data.length = cipher_len;
2736 	sym_op->cipher.data.offset = 0;
2737 	sym_op->auth.data.length = auth_len;
2738 	sym_op->auth.data.offset = 0;
2739 
2740 	return 0;
2741 }
2742 
2743 static int
2744 create_zuc_cipher_hash_generate_operation(
2745 		const struct wireless_test_data *tdata)
2746 {
2747 	return create_wireless_cipher_hash_operation(tdata,
2748 		RTE_CRYPTO_AUTH_OP_GENERATE);
2749 }
2750 
2751 static int
2752 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2753 		const unsigned auth_tag_len,
2754 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2755 		unsigned data_pad_len,
2756 		enum rte_crypto_auth_operation op,
2757 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2758 		const unsigned cipher_len, const unsigned cipher_offset,
2759 		const unsigned auth_len, const unsigned auth_offset)
2760 {
2761 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2762 	struct crypto_unittest_params *ut_params = &unittest_params;
2763 
2764 	/* Generate Crypto op data structure */
2765 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2766 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2767 	TEST_ASSERT_NOT_NULL(ut_params->op,
2768 			"Failed to allocate pktmbuf offload");
2769 	/* Set crypto operation data parameters */
2770 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2771 
2772 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2773 
2774 	/* set crypto operation source mbuf */
2775 	sym_op->m_src = ut_params->ibuf;
2776 
2777 	/* digest */
2778 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2779 			ut_params->ibuf, auth_tag_len);
2780 
2781 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2782 			"no room to append auth tag");
2783 	ut_params->digest = sym_op->auth.digest.data;
2784 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2785 			ut_params->ibuf, data_pad_len);
2786 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2787 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2788 	else
2789 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2790 
2791 	debug_hexdump(stdout, "digest:",
2792 		sym_op->auth.digest.data,
2793 		auth_tag_len);
2794 
2795 	/* Copy cipher and auth IVs at the end of the crypto operation */
2796 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2797 						IV_OFFSET);
2798 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2799 	iv_ptr += cipher_iv_len;
2800 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2801 
2802 	sym_op->cipher.data.length = cipher_len;
2803 	sym_op->cipher.data.offset = cipher_offset;
2804 	sym_op->auth.data.length = auth_len;
2805 	sym_op->auth.data.offset = auth_offset;
2806 
2807 	return 0;
2808 }
2809 
2810 static int
2811 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2812 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2813 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2814 		unsigned int data_pad_len,
2815 		unsigned int cipher_len, unsigned int cipher_offset,
2816 		unsigned int auth_len, unsigned int auth_offset)
2817 {
2818 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2819 	struct crypto_unittest_params *ut_params = &unittest_params;
2820 
2821 	/* Generate Crypto op data structure */
2822 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2823 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2824 	TEST_ASSERT_NOT_NULL(ut_params->op,
2825 			"Failed to allocate pktmbuf offload");
2826 
2827 	/* Set crypto operation data parameters */
2828 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2829 
2830 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2831 
2832 	/* set crypto operation source mbuf */
2833 	sym_op->m_src = ut_params->ibuf;
2834 
2835 	/* digest */
2836 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2837 			ut_params->ibuf, auth_tag_len);
2838 
2839 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2840 			"no room to append auth tag");
2841 
2842 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2843 			ut_params->ibuf, data_pad_len);
2844 
2845 	memset(sym_op->auth.digest.data, 0, auth_tag_len);
2846 
2847 	debug_hexdump(stdout, "digest:",
2848 			sym_op->auth.digest.data,
2849 			auth_tag_len);
2850 
2851 	/* Copy cipher and auth IVs at the end of the crypto operation */
2852 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2853 						IV_OFFSET);
2854 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2855 	iv_ptr += cipher_iv_len;
2856 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2857 
2858 	sym_op->cipher.data.length = cipher_len;
2859 	sym_op->cipher.data.offset = cipher_offset;
2860 
2861 	sym_op->auth.data.length = auth_len;
2862 	sym_op->auth.data.offset = auth_offset;
2863 
2864 	return 0;
2865 }
2866 
2867 static int
2868 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2869 {
2870 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2871 	struct crypto_unittest_params *ut_params = &unittest_params;
2872 
2873 	int retval;
2874 	unsigned plaintext_pad_len;
2875 	unsigned plaintext_len;
2876 	uint8_t *plaintext;
2877 
2878 	/* Create SNOW 3G session */
2879 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2880 			tdata->key.data, tdata->key.len,
2881 			tdata->auth_iv.len, tdata->digest.len,
2882 			RTE_CRYPTO_AUTH_OP_GENERATE,
2883 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2884 	if (retval < 0)
2885 		return retval;
2886 
2887 	/* alloc mbuf and set payload */
2888 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2889 
2890 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2891 	rte_pktmbuf_tailroom(ut_params->ibuf));
2892 
2893 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2894 	/* Append data which is padded to a multiple of */
2895 	/* the algorithms block size */
2896 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2897 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2898 				plaintext_pad_len);
2899 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2900 
2901 	/* Create SNOW 3G operation */
2902 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2903 			tdata->auth_iv.data, tdata->auth_iv.len,
2904 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2905 			tdata->validAuthLenInBits.len,
2906 			0);
2907 	if (retval < 0)
2908 		return retval;
2909 
2910 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2911 				ut_params->op);
2912 	ut_params->obuf = ut_params->op->sym->m_src;
2913 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2914 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2915 			+ plaintext_pad_len;
2916 
2917 	/* Validate obuf */
2918 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2919 	ut_params->digest,
2920 	tdata->digest.data,
2921 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2922 	"SNOW 3G Generated auth tag not as expected");
2923 
2924 	return 0;
2925 }
2926 
2927 static int
2928 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2929 {
2930 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2931 	struct crypto_unittest_params *ut_params = &unittest_params;
2932 
2933 	int retval;
2934 	unsigned plaintext_pad_len;
2935 	unsigned plaintext_len;
2936 	uint8_t *plaintext;
2937 
2938 	/* Create SNOW 3G session */
2939 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2940 				tdata->key.data, tdata->key.len,
2941 				tdata->auth_iv.len, tdata->digest.len,
2942 				RTE_CRYPTO_AUTH_OP_VERIFY,
2943 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2944 	if (retval < 0)
2945 		return retval;
2946 	/* alloc mbuf and set payload */
2947 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2948 
2949 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2950 	rte_pktmbuf_tailroom(ut_params->ibuf));
2951 
2952 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2953 	/* Append data which is padded to a multiple of */
2954 	/* the algorithms block size */
2955 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2956 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2957 				plaintext_pad_len);
2958 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2959 
2960 	/* Create SNOW 3G operation */
2961 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
2962 			tdata->digest.len,
2963 			tdata->auth_iv.data, tdata->auth_iv.len,
2964 			plaintext_pad_len,
2965 			RTE_CRYPTO_AUTH_OP_VERIFY,
2966 			tdata->validAuthLenInBits.len,
2967 			0);
2968 	if (retval < 0)
2969 		return retval;
2970 
2971 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2972 				ut_params->op);
2973 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2974 	ut_params->obuf = ut_params->op->sym->m_src;
2975 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2976 				+ plaintext_pad_len;
2977 
2978 	/* Validate obuf */
2979 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2980 		return 0;
2981 	else
2982 		return -1;
2983 
2984 	return 0;
2985 }
2986 
2987 static int
2988 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2989 {
2990 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 	struct crypto_unittest_params *ut_params = &unittest_params;
2992 
2993 	int retval;
2994 	unsigned plaintext_pad_len;
2995 	unsigned plaintext_len;
2996 	uint8_t *plaintext;
2997 
2998 	/* Create KASUMI session */
2999 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3000 			tdata->key.data, tdata->key.len,
3001 			0, tdata->digest.len,
3002 			RTE_CRYPTO_AUTH_OP_GENERATE,
3003 			RTE_CRYPTO_AUTH_KASUMI_F9);
3004 	if (retval < 0)
3005 		return retval;
3006 
3007 	/* alloc mbuf and set payload */
3008 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3009 
3010 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3011 	rte_pktmbuf_tailroom(ut_params->ibuf));
3012 
3013 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3014 	/* Append data which is padded to a multiple of */
3015 	/* the algorithms block size */
3016 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3017 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3018 				plaintext_pad_len);
3019 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3020 
3021 	/* Create KASUMI operation */
3022 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3023 			NULL, 0,
3024 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3025 			tdata->plaintext.len,
3026 			0);
3027 	if (retval < 0)
3028 		return retval;
3029 
3030 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3031 				ut_params->op);
3032 	ut_params->obuf = ut_params->op->sym->m_src;
3033 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3034 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3035 			+ plaintext_pad_len;
3036 
3037 	/* Validate obuf */
3038 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3039 	ut_params->digest,
3040 	tdata->digest.data,
3041 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3042 	"KASUMI Generated auth tag not as expected");
3043 
3044 	return 0;
3045 }
3046 
3047 static int
3048 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3049 {
3050 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3051 	struct crypto_unittest_params *ut_params = &unittest_params;
3052 
3053 	int retval;
3054 	unsigned plaintext_pad_len;
3055 	unsigned plaintext_len;
3056 	uint8_t *plaintext;
3057 
3058 	/* Create KASUMI session */
3059 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3060 				tdata->key.data, tdata->key.len,
3061 				0, tdata->digest.len,
3062 				RTE_CRYPTO_AUTH_OP_VERIFY,
3063 				RTE_CRYPTO_AUTH_KASUMI_F9);
3064 	if (retval < 0)
3065 		return retval;
3066 	/* alloc mbuf and set payload */
3067 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3068 
3069 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3070 	rte_pktmbuf_tailroom(ut_params->ibuf));
3071 
3072 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3073 	/* Append data which is padded to a multiple */
3074 	/* of the algorithms block size */
3075 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3076 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3077 				plaintext_pad_len);
3078 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3079 
3080 	/* Create KASUMI operation */
3081 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3082 			tdata->digest.len,
3083 			NULL, 0,
3084 			plaintext_pad_len,
3085 			RTE_CRYPTO_AUTH_OP_VERIFY,
3086 			tdata->plaintext.len,
3087 			0);
3088 	if (retval < 0)
3089 		return retval;
3090 
3091 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3092 				ut_params->op);
3093 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3094 	ut_params->obuf = ut_params->op->sym->m_src;
3095 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3096 				+ plaintext_pad_len;
3097 
3098 	/* Validate obuf */
3099 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3100 		return 0;
3101 	else
3102 		return -1;
3103 
3104 	return 0;
3105 }
3106 
3107 static int
3108 test_snow3g_hash_generate_test_case_1(void)
3109 {
3110 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3111 }
3112 
3113 static int
3114 test_snow3g_hash_generate_test_case_2(void)
3115 {
3116 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3117 }
3118 
3119 static int
3120 test_snow3g_hash_generate_test_case_3(void)
3121 {
3122 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3123 }
3124 
3125 static int
3126 test_snow3g_hash_generate_test_case_4(void)
3127 {
3128 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3129 }
3130 
3131 static int
3132 test_snow3g_hash_generate_test_case_5(void)
3133 {
3134 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3135 }
3136 
3137 static int
3138 test_snow3g_hash_generate_test_case_6(void)
3139 {
3140 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3141 }
3142 
3143 static int
3144 test_snow3g_hash_verify_test_case_1(void)
3145 {
3146 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3147 
3148 }
3149 
3150 static int
3151 test_snow3g_hash_verify_test_case_2(void)
3152 {
3153 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3154 }
3155 
3156 static int
3157 test_snow3g_hash_verify_test_case_3(void)
3158 {
3159 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3160 }
3161 
3162 static int
3163 test_snow3g_hash_verify_test_case_4(void)
3164 {
3165 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3166 }
3167 
3168 static int
3169 test_snow3g_hash_verify_test_case_5(void)
3170 {
3171 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3172 }
3173 
3174 static int
3175 test_snow3g_hash_verify_test_case_6(void)
3176 {
3177 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3178 }
3179 
3180 static int
3181 test_kasumi_hash_generate_test_case_1(void)
3182 {
3183 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3184 }
3185 
3186 static int
3187 test_kasumi_hash_generate_test_case_2(void)
3188 {
3189 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3190 }
3191 
3192 static int
3193 test_kasumi_hash_generate_test_case_3(void)
3194 {
3195 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3196 }
3197 
3198 static int
3199 test_kasumi_hash_generate_test_case_4(void)
3200 {
3201 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3202 }
3203 
3204 static int
3205 test_kasumi_hash_generate_test_case_5(void)
3206 {
3207 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3208 }
3209 
3210 static int
3211 test_kasumi_hash_generate_test_case_6(void)
3212 {
3213 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3214 }
3215 
3216 static int
3217 test_kasumi_hash_verify_test_case_1(void)
3218 {
3219 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3220 }
3221 
3222 static int
3223 test_kasumi_hash_verify_test_case_2(void)
3224 {
3225 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3226 }
3227 
3228 static int
3229 test_kasumi_hash_verify_test_case_3(void)
3230 {
3231 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3232 }
3233 
3234 static int
3235 test_kasumi_hash_verify_test_case_4(void)
3236 {
3237 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3238 }
3239 
3240 static int
3241 test_kasumi_hash_verify_test_case_5(void)
3242 {
3243 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3244 }
3245 
3246 static int
3247 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3248 {
3249 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3250 	struct crypto_unittest_params *ut_params = &unittest_params;
3251 
3252 	int retval;
3253 	uint8_t *plaintext, *ciphertext;
3254 	unsigned plaintext_pad_len;
3255 	unsigned plaintext_len;
3256 
3257 	/* Create KASUMI session */
3258 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3259 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3260 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3261 					tdata->key.data, tdata->key.len,
3262 					tdata->cipher_iv.len);
3263 	if (retval < 0)
3264 		return retval;
3265 
3266 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3267 
3268 	/* Clear mbuf payload */
3269 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3270 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3271 
3272 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3273 	/* Append data which is padded to a multiple */
3274 	/* of the algorithms block size */
3275 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3276 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3277 				plaintext_pad_len);
3278 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3279 
3280 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3281 
3282 	/* Create KASUMI operation */
3283 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3284 				tdata->cipher_iv.len,
3285 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3286 				tdata->validCipherOffsetInBits.len);
3287 	if (retval < 0)
3288 		return retval;
3289 
3290 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3291 						ut_params->op);
3292 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3293 
3294 	ut_params->obuf = ut_params->op->sym->m_dst;
3295 	if (ut_params->obuf)
3296 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3297 	else
3298 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3299 
3300 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3301 
3302 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3303 				(tdata->validCipherOffsetInBits.len >> 3);
3304 	/* Validate obuf */
3305 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3306 		ciphertext,
3307 		reference_ciphertext,
3308 		tdata->validCipherLenInBits.len,
3309 		"KASUMI Ciphertext data not as expected");
3310 	return 0;
3311 }
3312 
3313 static int
3314 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3315 {
3316 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3317 	struct crypto_unittest_params *ut_params = &unittest_params;
3318 
3319 	int retval;
3320 
3321 	unsigned int plaintext_pad_len;
3322 	unsigned int plaintext_len;
3323 
3324 	uint8_t buffer[10000];
3325 	const uint8_t *ciphertext;
3326 
3327 	struct rte_cryptodev_info dev_info;
3328 
3329 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3330 
3331 	uint64_t feat_flags = dev_info.feature_flags;
3332 
3333 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3334 		printf("Device doesn't support in-place scatter-gather. "
3335 				"Test Skipped.\n");
3336 		return 0;
3337 	}
3338 
3339 	/* Create KASUMI session */
3340 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3341 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3342 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3343 					tdata->key.data, tdata->key.len,
3344 					tdata->cipher_iv.len);
3345 	if (retval < 0)
3346 		return retval;
3347 
3348 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3349 
3350 
3351 	/* Append data which is padded to a multiple */
3352 	/* of the algorithms block size */
3353 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3354 
3355 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3356 			plaintext_pad_len, 10, 0);
3357 
3358 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3359 
3360 	/* Create KASUMI operation */
3361 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3362 				tdata->cipher_iv.len,
3363 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3364 				tdata->validCipherOffsetInBits.len);
3365 	if (retval < 0)
3366 		return retval;
3367 
3368 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3369 						ut_params->op);
3370 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3371 
3372 	ut_params->obuf = ut_params->op->sym->m_dst;
3373 
3374 	if (ut_params->obuf)
3375 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3376 				plaintext_len, buffer);
3377 	else
3378 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3379 				tdata->validCipherOffsetInBits.len >> 3,
3380 				plaintext_len, buffer);
3381 
3382 	/* Validate obuf */
3383 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3384 
3385 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3386 				(tdata->validCipherOffsetInBits.len >> 3);
3387 	/* Validate obuf */
3388 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3389 		ciphertext,
3390 		reference_ciphertext,
3391 		tdata->validCipherLenInBits.len,
3392 		"KASUMI Ciphertext data not as expected");
3393 	return 0;
3394 }
3395 
3396 static int
3397 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3398 {
3399 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3400 	struct crypto_unittest_params *ut_params = &unittest_params;
3401 
3402 	int retval;
3403 	uint8_t *plaintext, *ciphertext;
3404 	unsigned plaintext_pad_len;
3405 	unsigned plaintext_len;
3406 
3407 	/* Create KASUMI session */
3408 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3409 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3410 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3411 					tdata->key.data, tdata->key.len,
3412 					tdata->cipher_iv.len);
3413 	if (retval < 0)
3414 		return retval;
3415 
3416 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3417 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3418 
3419 	/* Clear mbuf payload */
3420 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3421 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3422 
3423 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3424 	/* Append data which is padded to a multiple */
3425 	/* of the algorithms block size */
3426 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3427 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3428 				plaintext_pad_len);
3429 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3430 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3431 
3432 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3433 
3434 	/* Create KASUMI operation */
3435 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3436 				tdata->cipher_iv.len,
3437 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3438 				tdata->validCipherOffsetInBits.len);
3439 	if (retval < 0)
3440 		return retval;
3441 
3442 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3443 						ut_params->op);
3444 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3445 
3446 	ut_params->obuf = ut_params->op->sym->m_dst;
3447 	if (ut_params->obuf)
3448 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3449 	else
3450 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3451 
3452 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3453 
3454 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3455 				(tdata->validCipherOffsetInBits.len >> 3);
3456 	/* Validate obuf */
3457 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3458 		ciphertext,
3459 		reference_ciphertext,
3460 		tdata->validCipherLenInBits.len,
3461 		"KASUMI Ciphertext data not as expected");
3462 	return 0;
3463 }
3464 
3465 static int
3466 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3467 {
3468 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3469 	struct crypto_unittest_params *ut_params = &unittest_params;
3470 
3471 	int retval;
3472 	unsigned int plaintext_pad_len;
3473 	unsigned int plaintext_len;
3474 
3475 	const uint8_t *ciphertext;
3476 	uint8_t buffer[2048];
3477 
3478 	struct rte_cryptodev_info dev_info;
3479 
3480 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3481 
3482 	uint64_t feat_flags = dev_info.feature_flags;
3483 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3484 		printf("Device doesn't support out-of-place scatter-gather "
3485 				"in both input and output mbufs. "
3486 				"Test Skipped.\n");
3487 		return 0;
3488 	}
3489 
3490 	/* Create KASUMI session */
3491 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3492 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3493 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3494 					tdata->key.data, tdata->key.len,
3495 					tdata->cipher_iv.len);
3496 	if (retval < 0)
3497 		return retval;
3498 
3499 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3500 	/* Append data which is padded to a multiple */
3501 	/* of the algorithms block size */
3502 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3503 
3504 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3505 			plaintext_pad_len, 10, 0);
3506 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3507 			plaintext_pad_len, 3, 0);
3508 
3509 	/* Append data which is padded to a multiple */
3510 	/* of the algorithms block size */
3511 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3512 
3513 	/* Create KASUMI operation */
3514 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3515 				tdata->cipher_iv.len,
3516 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3517 				tdata->validCipherOffsetInBits.len);
3518 	if (retval < 0)
3519 		return retval;
3520 
3521 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3522 						ut_params->op);
3523 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3524 
3525 	ut_params->obuf = ut_params->op->sym->m_dst;
3526 	if (ut_params->obuf)
3527 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3528 				plaintext_pad_len, buffer);
3529 	else
3530 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3531 				tdata->validCipherOffsetInBits.len >> 3,
3532 				plaintext_pad_len, buffer);
3533 
3534 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3535 				(tdata->validCipherOffsetInBits.len >> 3);
3536 	/* Validate obuf */
3537 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3538 		ciphertext,
3539 		reference_ciphertext,
3540 		tdata->validCipherLenInBits.len,
3541 		"KASUMI Ciphertext data not as expected");
3542 	return 0;
3543 }
3544 
3545 
3546 static int
3547 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3548 {
3549 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3550 	struct crypto_unittest_params *ut_params = &unittest_params;
3551 
3552 	int retval;
3553 	uint8_t *ciphertext, *plaintext;
3554 	unsigned ciphertext_pad_len;
3555 	unsigned ciphertext_len;
3556 
3557 	/* Create KASUMI session */
3558 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3559 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3560 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3561 					tdata->key.data, tdata->key.len,
3562 					tdata->cipher_iv.len);
3563 	if (retval < 0)
3564 		return retval;
3565 
3566 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3567 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3568 
3569 	/* Clear mbuf payload */
3570 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3571 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3572 
3573 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3574 	/* Append data which is padded to a multiple */
3575 	/* of the algorithms block size */
3576 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3577 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3578 				ciphertext_pad_len);
3579 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3580 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3581 
3582 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3583 
3584 	/* Create KASUMI operation */
3585 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3586 				tdata->cipher_iv.len,
3587 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3588 				tdata->validCipherOffsetInBits.len);
3589 	if (retval < 0)
3590 		return retval;
3591 
3592 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3593 						ut_params->op);
3594 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3595 
3596 	ut_params->obuf = ut_params->op->sym->m_dst;
3597 	if (ut_params->obuf)
3598 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3599 	else
3600 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3601 
3602 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3603 
3604 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3605 				(tdata->validCipherOffsetInBits.len >> 3);
3606 	/* Validate obuf */
3607 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3608 		plaintext,
3609 		reference_plaintext,
3610 		tdata->validCipherLenInBits.len,
3611 		"KASUMI Plaintext data not as expected");
3612 	return 0;
3613 }
3614 
3615 static int
3616 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3617 {
3618 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3619 	struct crypto_unittest_params *ut_params = &unittest_params;
3620 
3621 	int retval;
3622 	uint8_t *ciphertext, *plaintext;
3623 	unsigned ciphertext_pad_len;
3624 	unsigned ciphertext_len;
3625 
3626 	/* Create KASUMI session */
3627 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3628 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3629 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3630 					tdata->key.data, tdata->key.len,
3631 					tdata->cipher_iv.len);
3632 	if (retval < 0)
3633 		return retval;
3634 
3635 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3636 
3637 	/* Clear mbuf payload */
3638 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3639 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3640 
3641 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3642 	/* Append data which is padded to a multiple */
3643 	/* of the algorithms block size */
3644 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3645 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646 				ciphertext_pad_len);
3647 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3648 
3649 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3650 
3651 	/* Create KASUMI operation */
3652 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3653 					tdata->cipher_iv.len,
3654 					tdata->ciphertext.len,
3655 					tdata->validCipherOffsetInBits.len);
3656 	if (retval < 0)
3657 		return retval;
3658 
3659 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3660 						ut_params->op);
3661 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3662 
3663 	ut_params->obuf = ut_params->op->sym->m_dst;
3664 	if (ut_params->obuf)
3665 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3666 	else
3667 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3668 
3669 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3670 
3671 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3672 				(tdata->validCipherOffsetInBits.len >> 3);
3673 	/* Validate obuf */
3674 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3675 		plaintext,
3676 		reference_plaintext,
3677 		tdata->validCipherLenInBits.len,
3678 		"KASUMI Plaintext data not as expected");
3679 	return 0;
3680 }
3681 
3682 static int
3683 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3684 {
3685 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3686 	struct crypto_unittest_params *ut_params = &unittest_params;
3687 
3688 	int retval;
3689 	uint8_t *plaintext, *ciphertext;
3690 	unsigned plaintext_pad_len;
3691 	unsigned plaintext_len;
3692 
3693 	/* Create SNOW 3G session */
3694 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3695 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3696 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3697 					tdata->key.data, tdata->key.len,
3698 					tdata->cipher_iv.len);
3699 	if (retval < 0)
3700 		return retval;
3701 
3702 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3703 
3704 	/* Clear mbuf payload */
3705 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3706 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3707 
3708 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3709 	/* Append data which is padded to a multiple of */
3710 	/* the algorithms block size */
3711 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3712 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3713 				plaintext_pad_len);
3714 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3715 
3716 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3717 
3718 	/* Create SNOW 3G operation */
3719 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3720 					tdata->cipher_iv.len,
3721 					tdata->validCipherLenInBits.len,
3722 					0);
3723 	if (retval < 0)
3724 		return retval;
3725 
3726 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3727 						ut_params->op);
3728 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3729 
3730 	ut_params->obuf = ut_params->op->sym->m_dst;
3731 	if (ut_params->obuf)
3732 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3733 	else
3734 		ciphertext = plaintext;
3735 
3736 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3737 
3738 	/* Validate obuf */
3739 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3740 		ciphertext,
3741 		tdata->ciphertext.data,
3742 		tdata->validDataLenInBits.len,
3743 		"SNOW 3G Ciphertext data not as expected");
3744 	return 0;
3745 }
3746 
3747 
3748 static int
3749 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3750 {
3751 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3752 	struct crypto_unittest_params *ut_params = &unittest_params;
3753 	uint8_t *plaintext, *ciphertext;
3754 
3755 	int retval;
3756 	unsigned plaintext_pad_len;
3757 	unsigned plaintext_len;
3758 
3759 	/* Create SNOW 3G session */
3760 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3761 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3762 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3763 					tdata->key.data, tdata->key.len,
3764 					tdata->cipher_iv.len);
3765 	if (retval < 0)
3766 		return retval;
3767 
3768 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3769 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3770 
3771 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3772 			"Failed to allocate input buffer in mempool");
3773 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
3774 			"Failed to allocate output buffer in mempool");
3775 
3776 	/* Clear mbuf payload */
3777 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3778 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3779 
3780 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3781 	/* Append data which is padded to a multiple of */
3782 	/* the algorithms block size */
3783 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3784 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3785 				plaintext_pad_len);
3786 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3787 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3788 
3789 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3790 
3791 	/* Create SNOW 3G operation */
3792 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3793 					tdata->cipher_iv.len,
3794 					tdata->validCipherLenInBits.len,
3795 					0);
3796 	if (retval < 0)
3797 		return retval;
3798 
3799 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3800 						ut_params->op);
3801 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3802 
3803 	ut_params->obuf = ut_params->op->sym->m_dst;
3804 	if (ut_params->obuf)
3805 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3806 	else
3807 		ciphertext = plaintext;
3808 
3809 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3810 
3811 	/* Validate obuf */
3812 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3813 		ciphertext,
3814 		tdata->ciphertext.data,
3815 		tdata->validDataLenInBits.len,
3816 		"SNOW 3G Ciphertext data not as expected");
3817 	return 0;
3818 }
3819 
3820 static int
3821 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3822 {
3823 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3824 	struct crypto_unittest_params *ut_params = &unittest_params;
3825 
3826 	int retval;
3827 	unsigned int plaintext_pad_len;
3828 	unsigned int plaintext_len;
3829 	uint8_t buffer[10000];
3830 	const uint8_t *ciphertext;
3831 
3832 	struct rte_cryptodev_info dev_info;
3833 
3834 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3835 
3836 	uint64_t feat_flags = dev_info.feature_flags;
3837 
3838 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3839 		printf("Device doesn't support out-of-place scatter-gather "
3840 				"in both input and output mbufs. "
3841 				"Test Skipped.\n");
3842 		return 0;
3843 	}
3844 
3845 	/* Create SNOW 3G session */
3846 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3847 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3848 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3849 					tdata->key.data, tdata->key.len,
3850 					tdata->cipher_iv.len);
3851 	if (retval < 0)
3852 		return retval;
3853 
3854 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3855 	/* Append data which is padded to a multiple of */
3856 	/* the algorithms block size */
3857 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3858 
3859 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3860 			plaintext_pad_len, 10, 0);
3861 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3862 			plaintext_pad_len, 3, 0);
3863 
3864 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3865 			"Failed to allocate input buffer in mempool");
3866 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
3867 			"Failed to allocate output buffer in mempool");
3868 
3869 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3870 
3871 	/* Create SNOW 3G operation */
3872 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3873 					tdata->cipher_iv.len,
3874 					tdata->validCipherLenInBits.len,
3875 					0);
3876 	if (retval < 0)
3877 		return retval;
3878 
3879 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3880 						ut_params->op);
3881 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3882 
3883 	ut_params->obuf = ut_params->op->sym->m_dst;
3884 	if (ut_params->obuf)
3885 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3886 				plaintext_len, buffer);
3887 	else
3888 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3889 				plaintext_len, buffer);
3890 
3891 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3892 
3893 	/* Validate obuf */
3894 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3895 		ciphertext,
3896 		tdata->ciphertext.data,
3897 		tdata->validDataLenInBits.len,
3898 		"SNOW 3G Ciphertext data not as expected");
3899 
3900 	return 0;
3901 }
3902 
3903 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3904 static void
3905 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3906 {
3907 	uint8_t curr_byte, prev_byte;
3908 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
3909 	uint8_t lower_byte_mask = (1 << offset) - 1;
3910 	unsigned i;
3911 
3912 	prev_byte = buffer[0];
3913 	buffer[0] >>= offset;
3914 
3915 	for (i = 1; i < length_in_bytes; i++) {
3916 		curr_byte = buffer[i];
3917 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3918 				(curr_byte >> offset);
3919 		prev_byte = curr_byte;
3920 	}
3921 }
3922 
3923 static int
3924 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3925 {
3926 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3927 	struct crypto_unittest_params *ut_params = &unittest_params;
3928 	uint8_t *plaintext, *ciphertext;
3929 	int retval;
3930 	uint32_t plaintext_len;
3931 	uint32_t plaintext_pad_len;
3932 	uint8_t extra_offset = 4;
3933 	uint8_t *expected_ciphertext_shifted;
3934 
3935 	/* Create SNOW 3G session */
3936 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3937 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3938 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3939 					tdata->key.data, tdata->key.len,
3940 					tdata->cipher_iv.len);
3941 	if (retval < 0)
3942 		return retval;
3943 
3944 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3945 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3946 
3947 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3948 			"Failed to allocate input buffer in mempool");
3949 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
3950 			"Failed to allocate output buffer in mempool");
3951 
3952 	/* Clear mbuf payload */
3953 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3954 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3955 
3956 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3957 	/*
3958 	 * Append data which is padded to a
3959 	 * multiple of the algorithms block size
3960 	 */
3961 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3962 
3963 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3964 						plaintext_pad_len);
3965 
3966 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3967 
3968 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3969 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3970 
3971 #ifdef RTE_APP_TEST_DEBUG
3972 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3973 #endif
3974 	/* Create SNOW 3G operation */
3975 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3976 					tdata->cipher_iv.len,
3977 					tdata->validCipherLenInBits.len,
3978 					extra_offset);
3979 	if (retval < 0)
3980 		return retval;
3981 
3982 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3983 						ut_params->op);
3984 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3985 
3986 	ut_params->obuf = ut_params->op->sym->m_dst;
3987 	if (ut_params->obuf)
3988 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3989 	else
3990 		ciphertext = plaintext;
3991 
3992 #ifdef RTE_APP_TEST_DEBUG
3993 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3994 #endif
3995 
3996 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3997 
3998 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3999 			"failed to reserve memory for ciphertext shifted\n");
4000 
4001 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4002 			ceil_byte_length(tdata->ciphertext.len));
4003 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4004 			extra_offset);
4005 	/* Validate obuf */
4006 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4007 		ciphertext,
4008 		expected_ciphertext_shifted,
4009 		tdata->validDataLenInBits.len,
4010 		extra_offset,
4011 		"SNOW 3G Ciphertext data not as expected");
4012 	return 0;
4013 }
4014 
4015 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4016 {
4017 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4018 	struct crypto_unittest_params *ut_params = &unittest_params;
4019 
4020 	int retval;
4021 
4022 	uint8_t *plaintext, *ciphertext;
4023 	unsigned ciphertext_pad_len;
4024 	unsigned ciphertext_len;
4025 
4026 	/* Create SNOW 3G session */
4027 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4028 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4029 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4030 					tdata->key.data, tdata->key.len,
4031 					tdata->cipher_iv.len);
4032 	if (retval < 0)
4033 		return retval;
4034 
4035 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 
4037 	/* Clear mbuf payload */
4038 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4039 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4040 
4041 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4042 	/* Append data which is padded to a multiple of */
4043 	/* the algorithms block size */
4044 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4045 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4046 				ciphertext_pad_len);
4047 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4048 
4049 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4050 
4051 	/* Create SNOW 3G operation */
4052 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4053 					tdata->cipher_iv.len,
4054 					tdata->validCipherLenInBits.len,
4055 					0);
4056 	if (retval < 0)
4057 		return retval;
4058 
4059 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4060 						ut_params->op);
4061 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4062 	ut_params->obuf = ut_params->op->sym->m_dst;
4063 	if (ut_params->obuf)
4064 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4065 	else
4066 		plaintext = ciphertext;
4067 
4068 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4069 
4070 	/* Validate obuf */
4071 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4072 				tdata->plaintext.data,
4073 				tdata->validDataLenInBits.len,
4074 				"SNOW 3G Plaintext data not as expected");
4075 	return 0;
4076 }
4077 
4078 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4079 {
4080 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4081 	struct crypto_unittest_params *ut_params = &unittest_params;
4082 
4083 	int retval;
4084 
4085 	uint8_t *plaintext, *ciphertext;
4086 	unsigned ciphertext_pad_len;
4087 	unsigned ciphertext_len;
4088 
4089 	/* Create SNOW 3G session */
4090 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4091 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4092 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4093 					tdata->key.data, tdata->key.len,
4094 					tdata->cipher_iv.len);
4095 	if (retval < 0)
4096 		return retval;
4097 
4098 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4099 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4100 
4101 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4102 			"Failed to allocate input buffer");
4103 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4104 			"Failed to allocate output buffer");
4105 
4106 	/* Clear mbuf payload */
4107 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4108 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4109 
4110 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4111 		       rte_pktmbuf_tailroom(ut_params->obuf));
4112 
4113 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4114 	/* Append data which is padded to a multiple of */
4115 	/* the algorithms block size */
4116 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4117 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4118 				ciphertext_pad_len);
4119 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4120 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4121 
4122 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4123 
4124 	/* Create SNOW 3G operation */
4125 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4126 					tdata->cipher_iv.len,
4127 					tdata->validCipherLenInBits.len,
4128 					0);
4129 	if (retval < 0)
4130 		return retval;
4131 
4132 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4133 						ut_params->op);
4134 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4135 	ut_params->obuf = ut_params->op->sym->m_dst;
4136 	if (ut_params->obuf)
4137 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4138 	else
4139 		plaintext = ciphertext;
4140 
4141 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4142 
4143 	/* Validate obuf */
4144 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4145 				tdata->plaintext.data,
4146 				tdata->validDataLenInBits.len,
4147 				"SNOW 3G Plaintext data not as expected");
4148 	return 0;
4149 }
4150 
4151 static int
4152 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4153 {
4154 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4155 	struct crypto_unittest_params *ut_params = &unittest_params;
4156 
4157 	int retval;
4158 
4159 	uint8_t *plaintext, *ciphertext;
4160 	unsigned int plaintext_pad_len;
4161 	unsigned int plaintext_len;
4162 
4163 	struct rte_cryptodev_sym_capability_idx cap_idx;
4164 
4165 	/* Check if device supports ZUC EEA3 */
4166 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4167 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4168 
4169 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4170 			&cap_idx) == NULL)
4171 		return -ENOTSUP;
4172 
4173 	/* Check if device supports ZUC EIA3 */
4174 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4175 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4176 
4177 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4178 			&cap_idx) == NULL)
4179 		return -ENOTSUP;
4180 
4181 	/* Create ZUC session */
4182 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4183 			ts_params->valid_devs[0],
4184 			tdata);
4185 	if (retval < 0)
4186 		return retval;
4187 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4188 
4189 	/* clear mbuf payload */
4190 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4191 			rte_pktmbuf_tailroom(ut_params->ibuf));
4192 
4193 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4194 	/* Append data which is padded to a multiple of */
4195 	/* the algorithms block size */
4196 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4197 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4198 				plaintext_pad_len);
4199 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4200 
4201 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4202 
4203 	/* Create ZUC operation */
4204 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4205 	if (retval < 0)
4206 		return retval;
4207 
4208 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4209 			ut_params->op);
4210 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4211 	ut_params->obuf = ut_params->op->sym->m_src;
4212 	if (ut_params->obuf)
4213 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4214 	else
4215 		ciphertext = plaintext;
4216 
4217 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4218 	/* Validate obuf */
4219 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4220 			ciphertext,
4221 			tdata->ciphertext.data,
4222 			tdata->validDataLenInBits.len,
4223 			"ZUC Ciphertext data not as expected");
4224 
4225 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4226 	    + plaintext_pad_len;
4227 
4228 	/* Validate obuf */
4229 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4230 			ut_params->digest,
4231 			tdata->digest.data,
4232 			4,
4233 			"ZUC Generated auth tag not as expected");
4234 	return 0;
4235 }
4236 
4237 static int
4238 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4239 {
4240 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4241 	struct crypto_unittest_params *ut_params = &unittest_params;
4242 
4243 	int retval;
4244 
4245 	uint8_t *plaintext, *ciphertext;
4246 	unsigned plaintext_pad_len;
4247 	unsigned plaintext_len;
4248 
4249 	/* Create SNOW 3G session */
4250 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4251 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4252 			RTE_CRYPTO_AUTH_OP_GENERATE,
4253 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4254 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4255 			tdata->key.data, tdata->key.len,
4256 			tdata->auth_iv.len, tdata->digest.len,
4257 			tdata->cipher_iv.len);
4258 	if (retval < 0)
4259 		return retval;
4260 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4261 
4262 	/* clear mbuf payload */
4263 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4264 			rte_pktmbuf_tailroom(ut_params->ibuf));
4265 
4266 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4267 	/* Append data which is padded to a multiple of */
4268 	/* the algorithms block size */
4269 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4270 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4271 				plaintext_pad_len);
4272 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4273 
4274 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4275 
4276 	/* Create SNOW 3G operation */
4277 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4278 			tdata->digest.len, tdata->auth_iv.data,
4279 			tdata->auth_iv.len,
4280 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4281 			tdata->cipher_iv.data, tdata->cipher_iv.len,
4282 			tdata->validCipherLenInBits.len,
4283 			0,
4284 			tdata->validAuthLenInBits.len,
4285 			0
4286 			);
4287 	if (retval < 0)
4288 		return retval;
4289 
4290 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4291 			ut_params->op);
4292 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4293 	ut_params->obuf = ut_params->op->sym->m_src;
4294 	if (ut_params->obuf)
4295 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4296 	else
4297 		ciphertext = plaintext;
4298 
4299 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4300 	/* Validate obuf */
4301 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4302 			ciphertext,
4303 			tdata->ciphertext.data,
4304 			tdata->validDataLenInBits.len,
4305 			"SNOW 3G Ciphertext data not as expected");
4306 
4307 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4308 	    + plaintext_pad_len;
4309 
4310 	/* Validate obuf */
4311 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4312 			ut_params->digest,
4313 			tdata->digest.data,
4314 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4315 			"SNOW 3G Generated auth tag not as expected");
4316 	return 0;
4317 }
4318 static int
4319 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4320 {
4321 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4322 	struct crypto_unittest_params *ut_params = &unittest_params;
4323 
4324 	int retval;
4325 
4326 	uint8_t *plaintext, *ciphertext;
4327 	unsigned plaintext_pad_len;
4328 	unsigned plaintext_len;
4329 
4330 	/* Create SNOW 3G session */
4331 	retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4332 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4333 			RTE_CRYPTO_AUTH_OP_GENERATE,
4334 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4335 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4336 			tdata->key.data, tdata->key.len,
4337 			tdata->auth_iv.len, tdata->digest.len,
4338 			tdata->cipher_iv.len);
4339 	if (retval < 0)
4340 		return retval;
4341 
4342 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4343 
4344 	/* clear mbuf payload */
4345 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4346 			rte_pktmbuf_tailroom(ut_params->ibuf));
4347 
4348 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4349 	/* Append data which is padded to a multiple of */
4350 	/* the algorithms block size */
4351 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4352 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4353 				plaintext_pad_len);
4354 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4355 
4356 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4357 
4358 	/* Create SNOW 3G operation */
4359 	retval = create_wireless_algo_auth_cipher_operation(
4360 		tdata->digest.len,
4361 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4362 		tdata->auth_iv.data, tdata->auth_iv.len,
4363 		plaintext_pad_len,
4364 		tdata->validCipherLenInBits.len,
4365 		0,
4366 		tdata->validAuthLenInBits.len,
4367 		0);
4368 
4369 	if (retval < 0)
4370 		return retval;
4371 
4372 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4373 			ut_params->op);
4374 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4375 	ut_params->obuf = ut_params->op->sym->m_src;
4376 	if (ut_params->obuf)
4377 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4378 	else
4379 		ciphertext = plaintext;
4380 
4381 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4382 			+ plaintext_pad_len;
4383 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4384 
4385 	/* Validate obuf */
4386 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4387 		ciphertext,
4388 		tdata->ciphertext.data,
4389 		tdata->validDataLenInBits.len,
4390 		"SNOW 3G Ciphertext data not as expected");
4391 
4392 	/* Validate obuf */
4393 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4394 		ut_params->digest,
4395 		tdata->digest.data,
4396 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4397 		"SNOW 3G Generated auth tag not as expected");
4398 	return 0;
4399 }
4400 
4401 static int
4402 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4403 {
4404 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4405 	struct crypto_unittest_params *ut_params = &unittest_params;
4406 
4407 	int retval;
4408 
4409 	uint8_t *plaintext, *ciphertext;
4410 	unsigned plaintext_pad_len;
4411 	unsigned plaintext_len;
4412 
4413 	/* Create KASUMI session */
4414 	retval = create_wireless_algo_auth_cipher_session(
4415 			ts_params->valid_devs[0],
4416 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4417 			RTE_CRYPTO_AUTH_OP_GENERATE,
4418 			RTE_CRYPTO_AUTH_KASUMI_F9,
4419 			RTE_CRYPTO_CIPHER_KASUMI_F8,
4420 			tdata->key.data, tdata->key.len,
4421 			0, tdata->digest.len,
4422 			tdata->cipher_iv.len);
4423 	if (retval < 0)
4424 		return retval;
4425 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4426 
4427 	/* clear mbuf payload */
4428 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4429 			rte_pktmbuf_tailroom(ut_params->ibuf));
4430 
4431 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4432 	/* Append data which is padded to a multiple of */
4433 	/* the algorithms block size */
4434 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4435 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4436 				plaintext_pad_len);
4437 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4438 
4439 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4440 
4441 	/* Create KASUMI operation */
4442 	retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4443 				tdata->cipher_iv.data, tdata->cipher_iv.len,
4444 				NULL, 0,
4445 				plaintext_pad_len,
4446 				tdata->validCipherLenInBits.len,
4447 				tdata->validCipherOffsetInBits.len,
4448 				tdata->validAuthLenInBits.len,
4449 				0
4450 				);
4451 
4452 	if (retval < 0)
4453 		return retval;
4454 
4455 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4456 			ut_params->op);
4457 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4458 	if (ut_params->op->sym->m_dst)
4459 		ut_params->obuf = ut_params->op->sym->m_dst;
4460 	else
4461 		ut_params->obuf = ut_params->op->sym->m_src;
4462 
4463 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4464 				tdata->validCipherOffsetInBits.len >> 3);
4465 
4466 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4467 				(tdata->validCipherOffsetInBits.len >> 3);
4468 	/* Validate obuf */
4469 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4470 			ciphertext,
4471 			reference_ciphertext,
4472 			tdata->validCipherLenInBits.len,
4473 			"KASUMI Ciphertext data not as expected");
4474 	ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4475 	    + plaintext_pad_len;
4476 
4477 	/* Validate obuf */
4478 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4479 			ut_params->digest,
4480 			tdata->digest.data,
4481 			DIGEST_BYTE_LENGTH_KASUMI_F9,
4482 			"KASUMI Generated auth tag not as expected");
4483 	return 0;
4484 }
4485 
4486 static int
4487 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4488 {
4489 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4490 	struct crypto_unittest_params *ut_params = &unittest_params;
4491 
4492 	int retval;
4493 
4494 	uint8_t *plaintext, *ciphertext;
4495 	unsigned plaintext_pad_len;
4496 	unsigned plaintext_len;
4497 
4498 	/* Create KASUMI session */
4499 	retval = create_wireless_algo_cipher_auth_session(
4500 			ts_params->valid_devs[0],
4501 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4502 			RTE_CRYPTO_AUTH_OP_GENERATE,
4503 			RTE_CRYPTO_AUTH_KASUMI_F9,
4504 			RTE_CRYPTO_CIPHER_KASUMI_F8,
4505 			tdata->key.data, tdata->key.len,
4506 			0, tdata->digest.len,
4507 			tdata->cipher_iv.len);
4508 	if (retval < 0)
4509 		return retval;
4510 
4511 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4512 
4513 	/* clear mbuf payload */
4514 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4515 			rte_pktmbuf_tailroom(ut_params->ibuf));
4516 
4517 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4518 	/* Append data which is padded to a multiple of */
4519 	/* the algorithms block size */
4520 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4521 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4522 				plaintext_pad_len);
4523 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4524 
4525 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4526 
4527 	/* Create KASUMI operation */
4528 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4529 				tdata->digest.len, NULL, 0,
4530 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4531 				tdata->cipher_iv.data, tdata->cipher_iv.len,
4532 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4533 				tdata->validCipherOffsetInBits.len,
4534 				tdata->validAuthLenInBits.len,
4535 				0
4536 				);
4537 	if (retval < 0)
4538 		return retval;
4539 
4540 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4541 			ut_params->op);
4542 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4543 
4544 	if (ut_params->op->sym->m_dst)
4545 		ut_params->obuf = ut_params->op->sym->m_dst;
4546 	else
4547 		ut_params->obuf = ut_params->op->sym->m_src;
4548 
4549 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4550 				tdata->validCipherOffsetInBits.len >> 3);
4551 
4552 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4553 			+ plaintext_pad_len;
4554 
4555 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4556 				(tdata->validCipherOffsetInBits.len >> 3);
4557 	/* Validate obuf */
4558 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4559 		ciphertext,
4560 		reference_ciphertext,
4561 		tdata->validCipherLenInBits.len,
4562 		"KASUMI Ciphertext data not as expected");
4563 
4564 	/* Validate obuf */
4565 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4566 		ut_params->digest,
4567 		tdata->digest.data,
4568 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4569 		"KASUMI Generated auth tag not as expected");
4570 	return 0;
4571 }
4572 
4573 static int
4574 test_zuc_encryption(const struct wireless_test_data *tdata)
4575 {
4576 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4577 	struct crypto_unittest_params *ut_params = &unittest_params;
4578 
4579 	int retval;
4580 	uint8_t *plaintext, *ciphertext;
4581 	unsigned plaintext_pad_len;
4582 	unsigned plaintext_len;
4583 
4584 	struct rte_cryptodev_sym_capability_idx cap_idx;
4585 
4586 	/* Check if device supports ZUC EEA3 */
4587 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4588 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4589 
4590 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4591 			&cap_idx) == NULL)
4592 		return -ENOTSUP;
4593 
4594 	/* Create ZUC session */
4595 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4596 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4597 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
4598 					tdata->key.data, tdata->key.len,
4599 					tdata->cipher_iv.len);
4600 	if (retval < 0)
4601 		return retval;
4602 
4603 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4604 
4605 	/* Clear mbuf payload */
4606 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4607 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4608 
4609 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4610 	/* Append data which is padded to a multiple */
4611 	/* of the algorithms block size */
4612 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4613 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4614 				plaintext_pad_len);
4615 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4616 
4617 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4618 
4619 	/* Create ZUC operation */
4620 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4621 					tdata->cipher_iv.len,
4622 					tdata->plaintext.len,
4623 					0);
4624 	if (retval < 0)
4625 		return retval;
4626 
4627 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4628 						ut_params->op);
4629 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4630 
4631 	ut_params->obuf = ut_params->op->sym->m_dst;
4632 	if (ut_params->obuf)
4633 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4634 	else
4635 		ciphertext = plaintext;
4636 
4637 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4638 
4639 	/* Validate obuf */
4640 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4641 		ciphertext,
4642 		tdata->ciphertext.data,
4643 		tdata->validCipherLenInBits.len,
4644 		"ZUC Ciphertext data not as expected");
4645 	return 0;
4646 }
4647 
4648 static int
4649 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4650 {
4651 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4652 	struct crypto_unittest_params *ut_params = &unittest_params;
4653 
4654 	int retval;
4655 
4656 	unsigned int plaintext_pad_len;
4657 	unsigned int plaintext_len;
4658 	const uint8_t *ciphertext;
4659 	uint8_t ciphertext_buffer[2048];
4660 	struct rte_cryptodev_info dev_info;
4661 
4662 	struct rte_cryptodev_sym_capability_idx cap_idx;
4663 
4664 	/* Check if device supports ZUC EEA3 */
4665 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4666 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4667 
4668 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4669 			&cap_idx) == NULL)
4670 		return -ENOTSUP;
4671 
4672 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4673 
4674 	uint64_t feat_flags = dev_info.feature_flags;
4675 
4676 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4677 		printf("Device doesn't support in-place scatter-gather. "
4678 				"Test Skipped.\n");
4679 		return 0;
4680 	}
4681 
4682 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4683 
4684 	/* Append data which is padded to a multiple */
4685 	/* of the algorithms block size */
4686 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4687 
4688 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4689 			plaintext_pad_len, 10, 0);
4690 
4691 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4692 			tdata->plaintext.data);
4693 
4694 	/* Create ZUC session */
4695 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4696 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4697 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
4698 			tdata->key.data, tdata->key.len,
4699 			tdata->cipher_iv.len);
4700 	if (retval < 0)
4701 		return retval;
4702 
4703 	/* Clear mbuf payload */
4704 
4705 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4706 
4707 	/* Create ZUC operation */
4708 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4709 			tdata->cipher_iv.len, tdata->plaintext.len,
4710 			0);
4711 	if (retval < 0)
4712 		return retval;
4713 
4714 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4715 						ut_params->op);
4716 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4717 
4718 	ut_params->obuf = ut_params->op->sym->m_dst;
4719 	if (ut_params->obuf)
4720 		ciphertext = rte_pktmbuf_read(ut_params->obuf,
4721 			0, plaintext_len, ciphertext_buffer);
4722 	else
4723 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4724 			0, plaintext_len, ciphertext_buffer);
4725 
4726 	/* Validate obuf */
4727 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4728 
4729 	/* Validate obuf */
4730 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4731 		ciphertext,
4732 		tdata->ciphertext.data,
4733 		tdata->validCipherLenInBits.len,
4734 		"ZUC Ciphertext data not as expected");
4735 
4736 	return 0;
4737 }
4738 
4739 static int
4740 test_zuc_authentication(const struct wireless_test_data *tdata)
4741 {
4742 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 	struct crypto_unittest_params *ut_params = &unittest_params;
4744 
4745 	int retval;
4746 	unsigned plaintext_pad_len;
4747 	unsigned plaintext_len;
4748 	uint8_t *plaintext;
4749 
4750 	struct rte_cryptodev_sym_capability_idx cap_idx;
4751 
4752 	/* Check if device supports ZUC EIA3 */
4753 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4754 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4755 
4756 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4757 			&cap_idx) == NULL)
4758 		return -ENOTSUP;
4759 
4760 	/* Create ZUC session */
4761 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4762 			tdata->key.data, tdata->key.len,
4763 			tdata->auth_iv.len, tdata->digest.len,
4764 			RTE_CRYPTO_AUTH_OP_GENERATE,
4765 			RTE_CRYPTO_AUTH_ZUC_EIA3);
4766 	if (retval < 0)
4767 		return retval;
4768 
4769 	/* alloc mbuf and set payload */
4770 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4771 
4772 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4773 	rte_pktmbuf_tailroom(ut_params->ibuf));
4774 
4775 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4776 	/* Append data which is padded to a multiple of */
4777 	/* the algorithms block size */
4778 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4779 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4780 				plaintext_pad_len);
4781 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4782 
4783 	/* Create ZUC operation */
4784 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4785 			tdata->auth_iv.data, tdata->auth_iv.len,
4786 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4787 			tdata->validAuthLenInBits.len,
4788 			0);
4789 	if (retval < 0)
4790 		return retval;
4791 
4792 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4793 				ut_params->op);
4794 	ut_params->obuf = ut_params->op->sym->m_src;
4795 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4796 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4797 			+ plaintext_pad_len;
4798 
4799 	/* Validate obuf */
4800 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4801 	ut_params->digest,
4802 	tdata->digest.data,
4803 	DIGEST_BYTE_LENGTH_KASUMI_F9,
4804 	"ZUC Generated auth tag not as expected");
4805 
4806 	return 0;
4807 }
4808 
4809 static int
4810 test_kasumi_encryption_test_case_1(void)
4811 {
4812 	return test_kasumi_encryption(&kasumi_test_case_1);
4813 }
4814 
4815 static int
4816 test_kasumi_encryption_test_case_1_sgl(void)
4817 {
4818 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4819 }
4820 
4821 static int
4822 test_kasumi_encryption_test_case_1_oop(void)
4823 {
4824 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
4825 }
4826 
4827 static int
4828 test_kasumi_encryption_test_case_1_oop_sgl(void)
4829 {
4830 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4831 }
4832 
4833 static int
4834 test_kasumi_encryption_test_case_2(void)
4835 {
4836 	return test_kasumi_encryption(&kasumi_test_case_2);
4837 }
4838 
4839 static int
4840 test_kasumi_encryption_test_case_3(void)
4841 {
4842 	return test_kasumi_encryption(&kasumi_test_case_3);
4843 }
4844 
4845 static int
4846 test_kasumi_encryption_test_case_4(void)
4847 {
4848 	return test_kasumi_encryption(&kasumi_test_case_4);
4849 }
4850 
4851 static int
4852 test_kasumi_encryption_test_case_5(void)
4853 {
4854 	return test_kasumi_encryption(&kasumi_test_case_5);
4855 }
4856 
4857 static int
4858 test_kasumi_decryption_test_case_1(void)
4859 {
4860 	return test_kasumi_decryption(&kasumi_test_case_1);
4861 }
4862 
4863 static int
4864 test_kasumi_decryption_test_case_1_oop(void)
4865 {
4866 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
4867 }
4868 
4869 static int
4870 test_kasumi_decryption_test_case_2(void)
4871 {
4872 	return test_kasumi_decryption(&kasumi_test_case_2);
4873 }
4874 
4875 static int
4876 test_kasumi_decryption_test_case_3(void)
4877 {
4878 	return test_kasumi_decryption(&kasumi_test_case_3);
4879 }
4880 
4881 static int
4882 test_kasumi_decryption_test_case_4(void)
4883 {
4884 	return test_kasumi_decryption(&kasumi_test_case_4);
4885 }
4886 
4887 static int
4888 test_kasumi_decryption_test_case_5(void)
4889 {
4890 	return test_kasumi_decryption(&kasumi_test_case_5);
4891 }
4892 static int
4893 test_snow3g_encryption_test_case_1(void)
4894 {
4895 	return test_snow3g_encryption(&snow3g_test_case_1);
4896 }
4897 
4898 static int
4899 test_snow3g_encryption_test_case_1_oop(void)
4900 {
4901 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
4902 }
4903 
4904 static int
4905 test_snow3g_encryption_test_case_1_oop_sgl(void)
4906 {
4907 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4908 }
4909 
4910 
4911 static int
4912 test_snow3g_encryption_test_case_1_offset_oop(void)
4913 {
4914 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4915 }
4916 
4917 static int
4918 test_snow3g_encryption_test_case_2(void)
4919 {
4920 	return test_snow3g_encryption(&snow3g_test_case_2);
4921 }
4922 
4923 static int
4924 test_snow3g_encryption_test_case_3(void)
4925 {
4926 	return test_snow3g_encryption(&snow3g_test_case_3);
4927 }
4928 
4929 static int
4930 test_snow3g_encryption_test_case_4(void)
4931 {
4932 	return test_snow3g_encryption(&snow3g_test_case_4);
4933 }
4934 
4935 static int
4936 test_snow3g_encryption_test_case_5(void)
4937 {
4938 	return test_snow3g_encryption(&snow3g_test_case_5);
4939 }
4940 
4941 static int
4942 test_snow3g_decryption_test_case_1(void)
4943 {
4944 	return test_snow3g_decryption(&snow3g_test_case_1);
4945 }
4946 
4947 static int
4948 test_snow3g_decryption_test_case_1_oop(void)
4949 {
4950 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
4951 }
4952 
4953 static int
4954 test_snow3g_decryption_test_case_2(void)
4955 {
4956 	return test_snow3g_decryption(&snow3g_test_case_2);
4957 }
4958 
4959 static int
4960 test_snow3g_decryption_test_case_3(void)
4961 {
4962 	return test_snow3g_decryption(&snow3g_test_case_3);
4963 }
4964 
4965 static int
4966 test_snow3g_decryption_test_case_4(void)
4967 {
4968 	return test_snow3g_decryption(&snow3g_test_case_4);
4969 }
4970 
4971 static int
4972 test_snow3g_decryption_test_case_5(void)
4973 {
4974 	return test_snow3g_decryption(&snow3g_test_case_5);
4975 }
4976 static int
4977 test_snow3g_cipher_auth_test_case_1(void)
4978 {
4979 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
4980 }
4981 
4982 static int
4983 test_snow3g_auth_cipher_test_case_1(void)
4984 {
4985 	return test_snow3g_auth_cipher(&snow3g_test_case_6);
4986 }
4987 
4988 static int
4989 test_kasumi_auth_cipher_test_case_1(void)
4990 {
4991 	return test_kasumi_auth_cipher(&kasumi_test_case_3);
4992 }
4993 
4994 static int
4995 test_kasumi_cipher_auth_test_case_1(void)
4996 {
4997 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
4998 }
4999 
5000 static int
5001 test_zuc_encryption_test_case_1(void)
5002 {
5003 	return test_zuc_encryption(&zuc_test_case_cipher_193b);
5004 }
5005 
5006 static int
5007 test_zuc_encryption_test_case_2(void)
5008 {
5009 	return test_zuc_encryption(&zuc_test_case_cipher_800b);
5010 }
5011 
5012 static int
5013 test_zuc_encryption_test_case_3(void)
5014 {
5015 	return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5016 }
5017 
5018 static int
5019 test_zuc_encryption_test_case_4(void)
5020 {
5021 	return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5022 }
5023 
5024 static int
5025 test_zuc_encryption_test_case_5(void)
5026 {
5027 	return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5028 }
5029 
5030 static int
5031 test_zuc_encryption_test_case_6_sgl(void)
5032 {
5033 	return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5034 }
5035 
5036 static int
5037 test_zuc_hash_generate_test_case_1(void)
5038 {
5039 	return test_zuc_authentication(&zuc_test_case_auth_1b);
5040 }
5041 
5042 static int
5043 test_zuc_hash_generate_test_case_2(void)
5044 {
5045 	return test_zuc_authentication(&zuc_test_case_auth_90b);
5046 }
5047 
5048 static int
5049 test_zuc_hash_generate_test_case_3(void)
5050 {
5051 	return test_zuc_authentication(&zuc_test_case_auth_577b);
5052 }
5053 
5054 static int
5055 test_zuc_hash_generate_test_case_4(void)
5056 {
5057 	return test_zuc_authentication(&zuc_test_case_auth_2079b);
5058 }
5059 
5060 static int
5061 test_zuc_hash_generate_test_case_5(void)
5062 {
5063 	return test_zuc_authentication(&zuc_test_auth_5670b);
5064 }
5065 
5066 static int
5067 test_zuc_hash_generate_test_case_6(void)
5068 {
5069 	return test_zuc_authentication(&zuc_test_case_auth_128b);
5070 }
5071 
5072 static int
5073 test_zuc_hash_generate_test_case_7(void)
5074 {
5075 	return test_zuc_authentication(&zuc_test_case_auth_2080b);
5076 }
5077 
5078 static int
5079 test_zuc_hash_generate_test_case_8(void)
5080 {
5081 	return test_zuc_authentication(&zuc_test_case_auth_584b);
5082 }
5083 
5084 static int
5085 test_zuc_cipher_auth_test_case_1(void)
5086 {
5087 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5088 }
5089 
5090 static int
5091 test_zuc_cipher_auth_test_case_2(void)
5092 {
5093 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5094 }
5095 
5096 static int
5097 test_3DES_chain_qat_all(void)
5098 {
5099 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5100 	int status;
5101 
5102 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5103 		ts_params->op_mpool,
5104 		ts_params->session_mpool, ts_params->session_priv_mpool,
5105 		ts_params->valid_devs[0],
5106 		rte_cryptodev_driver_id_get(
5107 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5108 		BLKCIPHER_3DES_CHAIN_TYPE);
5109 
5110 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5111 
5112 	return TEST_SUCCESS;
5113 }
5114 
5115 static int
5116 test_DES_cipheronly_qat_all(void)
5117 {
5118 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5119 	int status;
5120 
5121 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5122 		ts_params->op_mpool,
5123 		ts_params->session_mpool, ts_params->session_priv_mpool,
5124 		ts_params->valid_devs[0],
5125 		rte_cryptodev_driver_id_get(
5126 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5127 		BLKCIPHER_DES_CIPHERONLY_TYPE);
5128 
5129 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5130 
5131 	return TEST_SUCCESS;
5132 }
5133 
5134 static int
5135 test_DES_cipheronly_openssl_all(void)
5136 {
5137 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5138 	int status;
5139 
5140 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5141 		ts_params->op_mpool,
5142 		ts_params->session_mpool, ts_params->session_priv_mpool,
5143 		ts_params->valid_devs[0],
5144 		rte_cryptodev_driver_id_get(
5145 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5146 		BLKCIPHER_DES_CIPHERONLY_TYPE);
5147 
5148 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5149 
5150 	return TEST_SUCCESS;
5151 }
5152 
5153 static int
5154 test_DES_docsis_openssl_all(void)
5155 {
5156 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5157 	int status;
5158 
5159 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5160 		ts_params->op_mpool,
5161 		ts_params->session_mpool, ts_params->session_priv_mpool,
5162 		ts_params->valid_devs[0],
5163 		rte_cryptodev_driver_id_get(
5164 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5165 		BLKCIPHER_DES_DOCSIS_TYPE);
5166 
5167 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5168 
5169 	return TEST_SUCCESS;
5170 }
5171 
5172 static int
5173 test_DES_cipheronly_mb_all(void)
5174 {
5175 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5176 	int status;
5177 
5178 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5179 		ts_params->op_mpool,
5180 		ts_params->session_mpool, ts_params->session_priv_mpool,
5181 		ts_params->valid_devs[0],
5182 		rte_cryptodev_driver_id_get(
5183 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5184 		BLKCIPHER_DES_CIPHERONLY_TYPE);
5185 
5186 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5187 
5188 	return TEST_SUCCESS;
5189 }
5190 static int
5191 test_3DES_cipheronly_mb_all(void)
5192 {
5193 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5194 	int status;
5195 
5196 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5197 		ts_params->op_mpool,
5198 		ts_params->session_mpool, ts_params->session_priv_mpool,
5199 		ts_params->valid_devs[0],
5200 		rte_cryptodev_driver_id_get(
5201 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5202 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
5203 
5204 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5205 
5206 	return TEST_SUCCESS;
5207 }
5208 
5209 static int
5210 test_DES_docsis_mb_all(void)
5211 {
5212 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5213 	int status;
5214 
5215 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5216 		ts_params->op_mpool,
5217 		ts_params->session_mpool, ts_params->session_priv_mpool,
5218 		ts_params->valid_devs[0],
5219 		rte_cryptodev_driver_id_get(
5220 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5221 		BLKCIPHER_DES_DOCSIS_TYPE);
5222 
5223 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5224 
5225 	return TEST_SUCCESS;
5226 }
5227 
5228 static int
5229 test_3DES_chain_caam_jr_all(void)
5230 {
5231 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5232 	int status;
5233 
5234 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5235 		ts_params->op_mpool,
5236 		ts_params->session_mpool, ts_params->session_priv_mpool,
5237 		ts_params->valid_devs[0],
5238 		rte_cryptodev_driver_id_get(
5239 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5240 		BLKCIPHER_3DES_CHAIN_TYPE);
5241 
5242 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5243 
5244 	return TEST_SUCCESS;
5245 }
5246 
5247 static int
5248 test_3DES_cipheronly_caam_jr_all(void)
5249 {
5250 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5251 	int status;
5252 
5253 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5254 		ts_params->op_mpool,
5255 		ts_params->session_mpool, ts_params->session_priv_mpool,
5256 		ts_params->valid_devs[0],
5257 		rte_cryptodev_driver_id_get(
5258 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5259 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
5260 
5261 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5262 
5263 	return TEST_SUCCESS;
5264 }
5265 
5266 static int
5267 test_3DES_chain_dpaa_sec_all(void)
5268 {
5269 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5270 	int status;
5271 
5272 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5273 		ts_params->op_mpool,
5274 		ts_params->session_mpool, ts_params->session_priv_mpool,
5275 		ts_params->valid_devs[0],
5276 		rte_cryptodev_driver_id_get(
5277 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5278 		BLKCIPHER_3DES_CHAIN_TYPE);
5279 
5280 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5281 
5282 	return TEST_SUCCESS;
5283 }
5284 
5285 static int
5286 test_3DES_cipheronly_dpaa_sec_all(void)
5287 {
5288 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5289 	int status;
5290 
5291 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5292 		ts_params->op_mpool,
5293 		ts_params->session_mpool, ts_params->session_priv_mpool,
5294 		ts_params->valid_devs[0],
5295 		rte_cryptodev_driver_id_get(
5296 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5297 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
5298 
5299 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5300 
5301 	return TEST_SUCCESS;
5302 }
5303 
5304 static int
5305 test_3DES_chain_dpaa2_sec_all(void)
5306 {
5307 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5308 	int status;
5309 
5310 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5311 		ts_params->op_mpool,
5312 		ts_params->session_mpool, ts_params->session_priv_mpool,
5313 		ts_params->valid_devs[0],
5314 		rte_cryptodev_driver_id_get(
5315 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5316 		BLKCIPHER_3DES_CHAIN_TYPE);
5317 
5318 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5319 
5320 	return TEST_SUCCESS;
5321 }
5322 
5323 static int
5324 test_3DES_cipheronly_dpaa2_sec_all(void)
5325 {
5326 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5327 	int status;
5328 
5329 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5330 		ts_params->op_mpool,
5331 		ts_params->session_mpool, ts_params->session_priv_mpool,
5332 		ts_params->valid_devs[0],
5333 		rte_cryptodev_driver_id_get(
5334 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5335 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
5336 
5337 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5338 
5339 	return TEST_SUCCESS;
5340 }
5341 
5342 static int
5343 test_3DES_chain_ccp_all(void)
5344 {
5345 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5346 	int status;
5347 
5348 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5349 		ts_params->op_mpool,
5350 		ts_params->session_mpool, ts_params->session_priv_mpool,
5351 		ts_params->valid_devs[0],
5352 		rte_cryptodev_driver_id_get(
5353 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5354 		BLKCIPHER_3DES_CHAIN_TYPE);
5355 
5356 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5357 
5358 	return TEST_SUCCESS;
5359 }
5360 
5361 static int
5362 test_3DES_cipheronly_ccp_all(void)
5363 {
5364 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5365 	int status;
5366 
5367 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5368 		ts_params->op_mpool,
5369 		ts_params->session_mpool, ts_params->session_priv_mpool,
5370 		ts_params->valid_devs[0],
5371 		rte_cryptodev_driver_id_get(
5372 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5373 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
5374 
5375 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5376 
5377 	return TEST_SUCCESS;
5378 }
5379 
5380 static int
5381 test_3DES_cipheronly_qat_all(void)
5382 {
5383 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5384 	int status;
5385 
5386 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5387 		ts_params->op_mpool,
5388 		ts_params->session_mpool, ts_params->session_priv_mpool,
5389 		ts_params->valid_devs[0],
5390 		rte_cryptodev_driver_id_get(
5391 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5392 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
5393 
5394 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5395 
5396 	return TEST_SUCCESS;
5397 }
5398 
5399 static int
5400 test_3DES_chain_openssl_all(void)
5401 {
5402 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5403 	int status;
5404 
5405 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5406 		ts_params->op_mpool,
5407 		ts_params->session_mpool, ts_params->session_priv_mpool,
5408 		ts_params->valid_devs[0],
5409 		rte_cryptodev_driver_id_get(
5410 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5411 		BLKCIPHER_3DES_CHAIN_TYPE);
5412 
5413 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5414 
5415 	return TEST_SUCCESS;
5416 }
5417 
5418 static int
5419 test_3DES_cipheronly_openssl_all(void)
5420 {
5421 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5422 	int status;
5423 
5424 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5425 		ts_params->op_mpool,
5426 		ts_params->session_mpool, ts_params->session_priv_mpool,
5427 		ts_params->valid_devs[0],
5428 		rte_cryptodev_driver_id_get(
5429 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5430 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
5431 
5432 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
5433 
5434 	return TEST_SUCCESS;
5435 }
5436 
5437 /* ***** AEAD algorithm Tests ***** */
5438 
5439 static int
5440 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5441 		enum rte_crypto_aead_operation op,
5442 		const uint8_t *key, const uint8_t key_len,
5443 		const uint16_t aad_len, const uint8_t auth_len,
5444 		uint8_t iv_len)
5445 {
5446 	uint8_t aead_key[key_len];
5447 
5448 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5449 	struct crypto_unittest_params *ut_params = &unittest_params;
5450 
5451 	memcpy(aead_key, key, key_len);
5452 
5453 	/* Setup AEAD Parameters */
5454 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5455 	ut_params->aead_xform.next = NULL;
5456 	ut_params->aead_xform.aead.algo = algo;
5457 	ut_params->aead_xform.aead.op = op;
5458 	ut_params->aead_xform.aead.key.data = aead_key;
5459 	ut_params->aead_xform.aead.key.length = key_len;
5460 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5461 	ut_params->aead_xform.aead.iv.length = iv_len;
5462 	ut_params->aead_xform.aead.digest_length = auth_len;
5463 	ut_params->aead_xform.aead.aad_length = aad_len;
5464 
5465 	debug_hexdump(stdout, "key:", key, key_len);
5466 
5467 	/* Create Crypto session*/
5468 	ut_params->sess = rte_cryptodev_sym_session_create(
5469 			ts_params->session_mpool);
5470 
5471 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5472 			&ut_params->aead_xform,
5473 			ts_params->session_priv_mpool);
5474 
5475 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5476 
5477 	return 0;
5478 }
5479 
5480 static int
5481 create_aead_xform(struct rte_crypto_op *op,
5482 		enum rte_crypto_aead_algorithm algo,
5483 		enum rte_crypto_aead_operation aead_op,
5484 		uint8_t *key, const uint8_t key_len,
5485 		const uint8_t aad_len, const uint8_t auth_len,
5486 		uint8_t iv_len)
5487 {
5488 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5489 			"failed to allocate space for crypto transform");
5490 
5491 	struct rte_crypto_sym_op *sym_op = op->sym;
5492 
5493 	/* Setup AEAD Parameters */
5494 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5495 	sym_op->xform->next = NULL;
5496 	sym_op->xform->aead.algo = algo;
5497 	sym_op->xform->aead.op = aead_op;
5498 	sym_op->xform->aead.key.data = key;
5499 	sym_op->xform->aead.key.length = key_len;
5500 	sym_op->xform->aead.iv.offset = IV_OFFSET;
5501 	sym_op->xform->aead.iv.length = iv_len;
5502 	sym_op->xform->aead.digest_length = auth_len;
5503 	sym_op->xform->aead.aad_length = aad_len;
5504 
5505 	debug_hexdump(stdout, "key:", key, key_len);
5506 
5507 	return 0;
5508 }
5509 
5510 static int
5511 create_aead_operation(enum rte_crypto_aead_operation op,
5512 		const struct aead_test_data *tdata)
5513 {
5514 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5515 	struct crypto_unittest_params *ut_params = &unittest_params;
5516 
5517 	uint8_t *plaintext, *ciphertext;
5518 	unsigned int aad_pad_len, plaintext_pad_len;
5519 
5520 	/* Generate Crypto op data structure */
5521 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5522 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5523 	TEST_ASSERT_NOT_NULL(ut_params->op,
5524 			"Failed to allocate symmetric crypto operation struct");
5525 
5526 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5527 
5528 	/* Append aad data */
5529 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5530 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5531 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5532 				aad_pad_len);
5533 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5534 				"no room to append aad");
5535 
5536 		sym_op->aead.aad.phys_addr =
5537 				rte_pktmbuf_iova(ut_params->ibuf);
5538 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
5539 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5540 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5541 			tdata->aad.len);
5542 
5543 		/* Append IV at the end of the crypto operation*/
5544 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5545 				uint8_t *, IV_OFFSET);
5546 
5547 		/* Copy IV 1 byte after the IV pointer, according to the API */
5548 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5549 		debug_hexdump(stdout, "iv:", iv_ptr,
5550 			tdata->iv.len);
5551 	} else {
5552 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5553 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5554 				aad_pad_len);
5555 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5556 				"no room to append aad");
5557 
5558 		sym_op->aead.aad.phys_addr =
5559 				rte_pktmbuf_iova(ut_params->ibuf);
5560 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5561 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5562 			tdata->aad.len);
5563 
5564 		/* Append IV at the end of the crypto operation*/
5565 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5566 				uint8_t *, IV_OFFSET);
5567 
5568 		rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5569 		debug_hexdump(stdout, "iv:", iv_ptr,
5570 			tdata->iv.len);
5571 	}
5572 
5573 	/* Append plaintext/ciphertext */
5574 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5575 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5576 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5577 				plaintext_pad_len);
5578 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5579 
5580 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5581 		debug_hexdump(stdout, "plaintext:", plaintext,
5582 				tdata->plaintext.len);
5583 
5584 		if (ut_params->obuf) {
5585 			ciphertext = (uint8_t *)rte_pktmbuf_append(
5586 					ut_params->obuf,
5587 					plaintext_pad_len + aad_pad_len);
5588 			TEST_ASSERT_NOT_NULL(ciphertext,
5589 					"no room to append ciphertext");
5590 
5591 			memset(ciphertext + aad_pad_len, 0,
5592 					tdata->ciphertext.len);
5593 		}
5594 	} else {
5595 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5596 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5597 				plaintext_pad_len);
5598 		TEST_ASSERT_NOT_NULL(ciphertext,
5599 				"no room to append ciphertext");
5600 
5601 		memcpy(ciphertext, tdata->ciphertext.data,
5602 				tdata->ciphertext.len);
5603 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5604 				tdata->ciphertext.len);
5605 
5606 		if (ut_params->obuf) {
5607 			plaintext = (uint8_t *)rte_pktmbuf_append(
5608 					ut_params->obuf,
5609 					plaintext_pad_len + aad_pad_len);
5610 			TEST_ASSERT_NOT_NULL(plaintext,
5611 					"no room to append plaintext");
5612 
5613 			memset(plaintext + aad_pad_len, 0,
5614 					tdata->plaintext.len);
5615 		}
5616 	}
5617 
5618 	/* Append digest data */
5619 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5620 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5621 				ut_params->obuf ? ut_params->obuf :
5622 						ut_params->ibuf,
5623 						tdata->auth_tag.len);
5624 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5625 				"no room to append digest");
5626 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5627 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5628 				ut_params->obuf ? ut_params->obuf :
5629 						ut_params->ibuf,
5630 						plaintext_pad_len +
5631 						aad_pad_len);
5632 	} else {
5633 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5634 				ut_params->ibuf, tdata->auth_tag.len);
5635 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5636 				"no room to append digest");
5637 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5638 				ut_params->ibuf,
5639 				plaintext_pad_len + aad_pad_len);
5640 
5641 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5642 			tdata->auth_tag.len);
5643 		debug_hexdump(stdout, "digest:",
5644 			sym_op->aead.digest.data,
5645 			tdata->auth_tag.len);
5646 	}
5647 
5648 	sym_op->aead.data.length = tdata->plaintext.len;
5649 	sym_op->aead.data.offset = aad_pad_len;
5650 
5651 	return 0;
5652 }
5653 
5654 static int
5655 test_authenticated_encryption(const struct aead_test_data *tdata)
5656 {
5657 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5658 	struct crypto_unittest_params *ut_params = &unittest_params;
5659 
5660 	int retval;
5661 	uint8_t *ciphertext, *auth_tag;
5662 	uint16_t plaintext_pad_len;
5663 	uint32_t i;
5664 
5665 	/* Create AEAD session */
5666 	retval = create_aead_session(ts_params->valid_devs[0],
5667 			tdata->algo,
5668 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
5669 			tdata->key.data, tdata->key.len,
5670 			tdata->aad.len, tdata->auth_tag.len,
5671 			tdata->iv.len);
5672 	if (retval < 0)
5673 		return retval;
5674 
5675 	if (tdata->aad.len > MBUF_SIZE) {
5676 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5677 		/* Populate full size of add data */
5678 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5679 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5680 	} else
5681 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5682 
5683 	/* clear mbuf payload */
5684 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5685 			rte_pktmbuf_tailroom(ut_params->ibuf));
5686 
5687 	/* Create AEAD operation */
5688 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5689 	if (retval < 0)
5690 		return retval;
5691 
5692 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5693 
5694 	ut_params->op->sym->m_src = ut_params->ibuf;
5695 
5696 	/* Process crypto operation */
5697 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5698 			ut_params->op), "failed to process sym crypto op");
5699 
5700 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5701 			"crypto op processing failed");
5702 
5703 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5704 
5705 	if (ut_params->op->sym->m_dst) {
5706 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5707 				uint8_t *);
5708 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5709 				uint8_t *, plaintext_pad_len);
5710 	} else {
5711 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5712 				uint8_t *,
5713 				ut_params->op->sym->cipher.data.offset);
5714 		auth_tag = ciphertext + plaintext_pad_len;
5715 	}
5716 
5717 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5718 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5719 
5720 	/* Validate obuf */
5721 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5722 			ciphertext,
5723 			tdata->ciphertext.data,
5724 			tdata->ciphertext.len,
5725 			"Ciphertext data not as expected");
5726 
5727 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5728 			auth_tag,
5729 			tdata->auth_tag.data,
5730 			tdata->auth_tag.len,
5731 			"Generated auth tag not as expected");
5732 
5733 	return 0;
5734 
5735 }
5736 
5737 static int
5738 test_AES_GCM_authenticated_encryption_test_case_1(void)
5739 {
5740 	return test_authenticated_encryption(&gcm_test_case_1);
5741 }
5742 
5743 static int
5744 test_AES_GCM_authenticated_encryption_test_case_2(void)
5745 {
5746 	return test_authenticated_encryption(&gcm_test_case_2);
5747 }
5748 
5749 static int
5750 test_AES_GCM_authenticated_encryption_test_case_3(void)
5751 {
5752 	return test_authenticated_encryption(&gcm_test_case_3);
5753 }
5754 
5755 static int
5756 test_AES_GCM_authenticated_encryption_test_case_4(void)
5757 {
5758 	return test_authenticated_encryption(&gcm_test_case_4);
5759 }
5760 
5761 static int
5762 test_AES_GCM_authenticated_encryption_test_case_5(void)
5763 {
5764 	return test_authenticated_encryption(&gcm_test_case_5);
5765 }
5766 
5767 static int
5768 test_AES_GCM_authenticated_encryption_test_case_6(void)
5769 {
5770 	return test_authenticated_encryption(&gcm_test_case_6);
5771 }
5772 
5773 static int
5774 test_AES_GCM_authenticated_encryption_test_case_7(void)
5775 {
5776 	return test_authenticated_encryption(&gcm_test_case_7);
5777 }
5778 
5779 static int
5780 test_AES_GCM_auth_encryption_test_case_192_1(void)
5781 {
5782 	return test_authenticated_encryption(&gcm_test_case_192_1);
5783 }
5784 
5785 static int
5786 test_AES_GCM_auth_encryption_test_case_192_2(void)
5787 {
5788 	return test_authenticated_encryption(&gcm_test_case_192_2);
5789 }
5790 
5791 static int
5792 test_AES_GCM_auth_encryption_test_case_192_3(void)
5793 {
5794 	return test_authenticated_encryption(&gcm_test_case_192_3);
5795 }
5796 
5797 static int
5798 test_AES_GCM_auth_encryption_test_case_192_4(void)
5799 {
5800 	return test_authenticated_encryption(&gcm_test_case_192_4);
5801 }
5802 
5803 static int
5804 test_AES_GCM_auth_encryption_test_case_192_5(void)
5805 {
5806 	return test_authenticated_encryption(&gcm_test_case_192_5);
5807 }
5808 
5809 static int
5810 test_AES_GCM_auth_encryption_test_case_192_6(void)
5811 {
5812 	return test_authenticated_encryption(&gcm_test_case_192_6);
5813 }
5814 
5815 static int
5816 test_AES_GCM_auth_encryption_test_case_192_7(void)
5817 {
5818 	return test_authenticated_encryption(&gcm_test_case_192_7);
5819 }
5820 
5821 static int
5822 test_AES_GCM_auth_encryption_test_case_256_1(void)
5823 {
5824 	return test_authenticated_encryption(&gcm_test_case_256_1);
5825 }
5826 
5827 static int
5828 test_AES_GCM_auth_encryption_test_case_256_2(void)
5829 {
5830 	return test_authenticated_encryption(&gcm_test_case_256_2);
5831 }
5832 
5833 static int
5834 test_AES_GCM_auth_encryption_test_case_256_3(void)
5835 {
5836 	return test_authenticated_encryption(&gcm_test_case_256_3);
5837 }
5838 
5839 static int
5840 test_AES_GCM_auth_encryption_test_case_256_4(void)
5841 {
5842 	return test_authenticated_encryption(&gcm_test_case_256_4);
5843 }
5844 
5845 static int
5846 test_AES_GCM_auth_encryption_test_case_256_5(void)
5847 {
5848 	return test_authenticated_encryption(&gcm_test_case_256_5);
5849 }
5850 
5851 static int
5852 test_AES_GCM_auth_encryption_test_case_256_6(void)
5853 {
5854 	return test_authenticated_encryption(&gcm_test_case_256_6);
5855 }
5856 
5857 static int
5858 test_AES_GCM_auth_encryption_test_case_256_7(void)
5859 {
5860 	return test_authenticated_encryption(&gcm_test_case_256_7);
5861 }
5862 
5863 static int
5864 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5865 {
5866 	return test_authenticated_encryption(&gcm_test_case_aad_1);
5867 }
5868 
5869 static int
5870 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5871 {
5872 	return test_authenticated_encryption(&gcm_test_case_aad_2);
5873 }
5874 
5875 static int
5876 test_authenticated_decryption(const struct aead_test_data *tdata)
5877 {
5878 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5879 	struct crypto_unittest_params *ut_params = &unittest_params;
5880 
5881 	int retval;
5882 	uint8_t *plaintext;
5883 	uint32_t i;
5884 
5885 	/* Create AEAD session */
5886 	retval = create_aead_session(ts_params->valid_devs[0],
5887 			tdata->algo,
5888 			RTE_CRYPTO_AEAD_OP_DECRYPT,
5889 			tdata->key.data, tdata->key.len,
5890 			tdata->aad.len, tdata->auth_tag.len,
5891 			tdata->iv.len);
5892 	if (retval < 0)
5893 		return retval;
5894 
5895 	/* alloc mbuf and set payload */
5896 	if (tdata->aad.len > MBUF_SIZE) {
5897 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5898 		/* Populate full size of add data */
5899 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5900 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5901 	} else
5902 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5903 
5904 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5905 			rte_pktmbuf_tailroom(ut_params->ibuf));
5906 
5907 	/* Create AEAD operation */
5908 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5909 	if (retval < 0)
5910 		return retval;
5911 
5912 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5913 
5914 	ut_params->op->sym->m_src = ut_params->ibuf;
5915 
5916 	/* Process crypto operation */
5917 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5918 			ut_params->op), "failed to process sym crypto op");
5919 
5920 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5921 			"crypto op processing failed");
5922 
5923 	if (ut_params->op->sym->m_dst)
5924 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5925 				uint8_t *);
5926 	else
5927 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5928 				uint8_t *,
5929 				ut_params->op->sym->cipher.data.offset);
5930 
5931 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5932 
5933 	/* Validate obuf */
5934 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5935 			plaintext,
5936 			tdata->plaintext.data,
5937 			tdata->plaintext.len,
5938 			"Plaintext data not as expected");
5939 
5940 	TEST_ASSERT_EQUAL(ut_params->op->status,
5941 			RTE_CRYPTO_OP_STATUS_SUCCESS,
5942 			"Authentication failed");
5943 	return 0;
5944 }
5945 
5946 static int
5947 test_AES_GCM_authenticated_decryption_test_case_1(void)
5948 {
5949 	return test_authenticated_decryption(&gcm_test_case_1);
5950 }
5951 
5952 static int
5953 test_AES_GCM_authenticated_decryption_test_case_2(void)
5954 {
5955 	return test_authenticated_decryption(&gcm_test_case_2);
5956 }
5957 
5958 static int
5959 test_AES_GCM_authenticated_decryption_test_case_3(void)
5960 {
5961 	return test_authenticated_decryption(&gcm_test_case_3);
5962 }
5963 
5964 static int
5965 test_AES_GCM_authenticated_decryption_test_case_4(void)
5966 {
5967 	return test_authenticated_decryption(&gcm_test_case_4);
5968 }
5969 
5970 static int
5971 test_AES_GCM_authenticated_decryption_test_case_5(void)
5972 {
5973 	return test_authenticated_decryption(&gcm_test_case_5);
5974 }
5975 
5976 static int
5977 test_AES_GCM_authenticated_decryption_test_case_6(void)
5978 {
5979 	return test_authenticated_decryption(&gcm_test_case_6);
5980 }
5981 
5982 static int
5983 test_AES_GCM_authenticated_decryption_test_case_7(void)
5984 {
5985 	return test_authenticated_decryption(&gcm_test_case_7);
5986 }
5987 
5988 static int
5989 test_AES_GCM_auth_decryption_test_case_192_1(void)
5990 {
5991 	return test_authenticated_decryption(&gcm_test_case_192_1);
5992 }
5993 
5994 static int
5995 test_AES_GCM_auth_decryption_test_case_192_2(void)
5996 {
5997 	return test_authenticated_decryption(&gcm_test_case_192_2);
5998 }
5999 
6000 static int
6001 test_AES_GCM_auth_decryption_test_case_192_3(void)
6002 {
6003 	return test_authenticated_decryption(&gcm_test_case_192_3);
6004 }
6005 
6006 static int
6007 test_AES_GCM_auth_decryption_test_case_192_4(void)
6008 {
6009 	return test_authenticated_decryption(&gcm_test_case_192_4);
6010 }
6011 
6012 static int
6013 test_AES_GCM_auth_decryption_test_case_192_5(void)
6014 {
6015 	return test_authenticated_decryption(&gcm_test_case_192_5);
6016 }
6017 
6018 static int
6019 test_AES_GCM_auth_decryption_test_case_192_6(void)
6020 {
6021 	return test_authenticated_decryption(&gcm_test_case_192_6);
6022 }
6023 
6024 static int
6025 test_AES_GCM_auth_decryption_test_case_192_7(void)
6026 {
6027 	return test_authenticated_decryption(&gcm_test_case_192_7);
6028 }
6029 
6030 static int
6031 test_AES_GCM_auth_decryption_test_case_256_1(void)
6032 {
6033 	return test_authenticated_decryption(&gcm_test_case_256_1);
6034 }
6035 
6036 static int
6037 test_AES_GCM_auth_decryption_test_case_256_2(void)
6038 {
6039 	return test_authenticated_decryption(&gcm_test_case_256_2);
6040 }
6041 
6042 static int
6043 test_AES_GCM_auth_decryption_test_case_256_3(void)
6044 {
6045 	return test_authenticated_decryption(&gcm_test_case_256_3);
6046 }
6047 
6048 static int
6049 test_AES_GCM_auth_decryption_test_case_256_4(void)
6050 {
6051 	return test_authenticated_decryption(&gcm_test_case_256_4);
6052 }
6053 
6054 static int
6055 test_AES_GCM_auth_decryption_test_case_256_5(void)
6056 {
6057 	return test_authenticated_decryption(&gcm_test_case_256_5);
6058 }
6059 
6060 static int
6061 test_AES_GCM_auth_decryption_test_case_256_6(void)
6062 {
6063 	return test_authenticated_decryption(&gcm_test_case_256_6);
6064 }
6065 
6066 static int
6067 test_AES_GCM_auth_decryption_test_case_256_7(void)
6068 {
6069 	return test_authenticated_decryption(&gcm_test_case_256_7);
6070 }
6071 
6072 static int
6073 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6074 {
6075 	return test_authenticated_decryption(&gcm_test_case_aad_1);
6076 }
6077 
6078 static int
6079 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6080 {
6081 	return test_authenticated_decryption(&gcm_test_case_aad_2);
6082 }
6083 
6084 static int
6085 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6086 {
6087 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6088 	struct crypto_unittest_params *ut_params = &unittest_params;
6089 
6090 	int retval;
6091 	uint8_t *ciphertext, *auth_tag;
6092 	uint16_t plaintext_pad_len;
6093 
6094 	/* Create AEAD session */
6095 	retval = create_aead_session(ts_params->valid_devs[0],
6096 			tdata->algo,
6097 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
6098 			tdata->key.data, tdata->key.len,
6099 			tdata->aad.len, tdata->auth_tag.len,
6100 			tdata->iv.len);
6101 	if (retval < 0)
6102 		return retval;
6103 
6104 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6105 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6106 
6107 	/* clear mbuf payload */
6108 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6109 			rte_pktmbuf_tailroom(ut_params->ibuf));
6110 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6111 			rte_pktmbuf_tailroom(ut_params->obuf));
6112 
6113 	/* Create AEAD operation */
6114 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6115 	if (retval < 0)
6116 		return retval;
6117 
6118 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6119 
6120 	ut_params->op->sym->m_src = ut_params->ibuf;
6121 	ut_params->op->sym->m_dst = ut_params->obuf;
6122 
6123 	/* Process crypto operation */
6124 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6125 			ut_params->op), "failed to process sym crypto op");
6126 
6127 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6128 			"crypto op processing failed");
6129 
6130 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6131 
6132 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6133 			ut_params->op->sym->cipher.data.offset);
6134 	auth_tag = ciphertext + plaintext_pad_len;
6135 
6136 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6137 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6138 
6139 	/* Validate obuf */
6140 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6141 			ciphertext,
6142 			tdata->ciphertext.data,
6143 			tdata->ciphertext.len,
6144 			"Ciphertext data not as expected");
6145 
6146 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6147 			auth_tag,
6148 			tdata->auth_tag.data,
6149 			tdata->auth_tag.len,
6150 			"Generated auth tag not as expected");
6151 
6152 	return 0;
6153 
6154 }
6155 
6156 static int
6157 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6158 {
6159 	return test_authenticated_encryption_oop(&gcm_test_case_5);
6160 }
6161 
6162 static int
6163 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6164 {
6165 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6166 	struct crypto_unittest_params *ut_params = &unittest_params;
6167 
6168 	int retval;
6169 	uint8_t *plaintext;
6170 
6171 	/* Create AEAD session */
6172 	retval = create_aead_session(ts_params->valid_devs[0],
6173 			tdata->algo,
6174 			RTE_CRYPTO_AEAD_OP_DECRYPT,
6175 			tdata->key.data, tdata->key.len,
6176 			tdata->aad.len, tdata->auth_tag.len,
6177 			tdata->iv.len);
6178 	if (retval < 0)
6179 		return retval;
6180 
6181 	/* alloc mbuf and set payload */
6182 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6183 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6184 
6185 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6186 			rte_pktmbuf_tailroom(ut_params->ibuf));
6187 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6188 			rte_pktmbuf_tailroom(ut_params->obuf));
6189 
6190 	/* Create AEAD operation */
6191 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6192 	if (retval < 0)
6193 		return retval;
6194 
6195 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6196 
6197 	ut_params->op->sym->m_src = ut_params->ibuf;
6198 	ut_params->op->sym->m_dst = ut_params->obuf;
6199 
6200 	/* Process crypto operation */
6201 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6202 			ut_params->op), "failed to process sym crypto op");
6203 
6204 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6205 			"crypto op processing failed");
6206 
6207 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6208 			ut_params->op->sym->cipher.data.offset);
6209 
6210 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6211 
6212 	/* Validate obuf */
6213 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6214 			plaintext,
6215 			tdata->plaintext.data,
6216 			tdata->plaintext.len,
6217 			"Plaintext data not as expected");
6218 
6219 	TEST_ASSERT_EQUAL(ut_params->op->status,
6220 			RTE_CRYPTO_OP_STATUS_SUCCESS,
6221 			"Authentication failed");
6222 	return 0;
6223 }
6224 
6225 static int
6226 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6227 {
6228 	return test_authenticated_decryption_oop(&gcm_test_case_5);
6229 }
6230 
6231 static int
6232 test_authenticated_encryption_sessionless(
6233 		const struct aead_test_data *tdata)
6234 {
6235 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6236 	struct crypto_unittest_params *ut_params = &unittest_params;
6237 
6238 	int retval;
6239 	uint8_t *ciphertext, *auth_tag;
6240 	uint16_t plaintext_pad_len;
6241 	uint8_t key[tdata->key.len + 1];
6242 
6243 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6244 
6245 	/* clear mbuf payload */
6246 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6247 			rte_pktmbuf_tailroom(ut_params->ibuf));
6248 
6249 	/* Create AEAD operation */
6250 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6251 	if (retval < 0)
6252 		return retval;
6253 
6254 	/* Create GCM xform */
6255 	memcpy(key, tdata->key.data, tdata->key.len);
6256 	retval = create_aead_xform(ut_params->op,
6257 			tdata->algo,
6258 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
6259 			key, tdata->key.len,
6260 			tdata->aad.len, tdata->auth_tag.len,
6261 			tdata->iv.len);
6262 	if (retval < 0)
6263 		return retval;
6264 
6265 	ut_params->op->sym->m_src = ut_params->ibuf;
6266 
6267 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6268 			RTE_CRYPTO_OP_SESSIONLESS,
6269 			"crypto op session type not sessionless");
6270 
6271 	/* Process crypto operation */
6272 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6273 			ut_params->op), "failed to process sym crypto op");
6274 
6275 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6276 
6277 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6278 			"crypto op status not success");
6279 
6280 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6281 
6282 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6283 			ut_params->op->sym->cipher.data.offset);
6284 	auth_tag = ciphertext + plaintext_pad_len;
6285 
6286 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6287 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6288 
6289 	/* Validate obuf */
6290 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6291 			ciphertext,
6292 			tdata->ciphertext.data,
6293 			tdata->ciphertext.len,
6294 			"Ciphertext data not as expected");
6295 
6296 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6297 			auth_tag,
6298 			tdata->auth_tag.data,
6299 			tdata->auth_tag.len,
6300 			"Generated auth tag not as expected");
6301 
6302 	return 0;
6303 
6304 }
6305 
6306 static int
6307 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6308 {
6309 	return test_authenticated_encryption_sessionless(
6310 			&gcm_test_case_5);
6311 }
6312 
6313 static int
6314 test_authenticated_decryption_sessionless(
6315 		const struct aead_test_data *tdata)
6316 {
6317 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6318 	struct crypto_unittest_params *ut_params = &unittest_params;
6319 
6320 	int retval;
6321 	uint8_t *plaintext;
6322 	uint8_t key[tdata->key.len + 1];
6323 
6324 	/* alloc mbuf and set payload */
6325 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6326 
6327 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6328 			rte_pktmbuf_tailroom(ut_params->ibuf));
6329 
6330 	/* Create AEAD operation */
6331 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6332 	if (retval < 0)
6333 		return retval;
6334 
6335 	/* Create AEAD xform */
6336 	memcpy(key, tdata->key.data, tdata->key.len);
6337 	retval = create_aead_xform(ut_params->op,
6338 			tdata->algo,
6339 			RTE_CRYPTO_AEAD_OP_DECRYPT,
6340 			key, tdata->key.len,
6341 			tdata->aad.len, tdata->auth_tag.len,
6342 			tdata->iv.len);
6343 	if (retval < 0)
6344 		return retval;
6345 
6346 	ut_params->op->sym->m_src = ut_params->ibuf;
6347 
6348 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6349 			RTE_CRYPTO_OP_SESSIONLESS,
6350 			"crypto op session type not sessionless");
6351 
6352 	/* Process crypto operation */
6353 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6354 			ut_params->op), "failed to process sym crypto op");
6355 
6356 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6357 
6358 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6359 			"crypto op status not success");
6360 
6361 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6362 			ut_params->op->sym->cipher.data.offset);
6363 
6364 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6365 
6366 	/* Validate obuf */
6367 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6368 			plaintext,
6369 			tdata->plaintext.data,
6370 			tdata->plaintext.len,
6371 			"Plaintext data not as expected");
6372 
6373 	TEST_ASSERT_EQUAL(ut_params->op->status,
6374 			RTE_CRYPTO_OP_STATUS_SUCCESS,
6375 			"Authentication failed");
6376 	return 0;
6377 }
6378 
6379 static int
6380 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6381 {
6382 	return test_authenticated_decryption_sessionless(
6383 			&gcm_test_case_5);
6384 }
6385 
6386 static int
6387 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6388 {
6389 	return test_authenticated_encryption(&ccm_test_case_128_1);
6390 }
6391 
6392 static int
6393 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6394 {
6395 	return test_authenticated_encryption(&ccm_test_case_128_2);
6396 }
6397 
6398 static int
6399 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6400 {
6401 	return test_authenticated_encryption(&ccm_test_case_128_3);
6402 }
6403 
6404 static int
6405 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6406 {
6407 	return test_authenticated_decryption(&ccm_test_case_128_1);
6408 }
6409 
6410 static int
6411 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6412 {
6413 	return test_authenticated_decryption(&ccm_test_case_128_2);
6414 }
6415 
6416 static int
6417 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6418 {
6419 	return test_authenticated_decryption(&ccm_test_case_128_3);
6420 }
6421 
6422 static int
6423 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6424 {
6425 	return test_authenticated_encryption(&ccm_test_case_192_1);
6426 }
6427 
6428 static int
6429 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6430 {
6431 	return test_authenticated_encryption(&ccm_test_case_192_2);
6432 }
6433 
6434 static int
6435 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6436 {
6437 	return test_authenticated_encryption(&ccm_test_case_192_3);
6438 }
6439 
6440 static int
6441 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6442 {
6443 	return test_authenticated_decryption(&ccm_test_case_192_1);
6444 }
6445 
6446 static int
6447 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6448 {
6449 	return test_authenticated_decryption(&ccm_test_case_192_2);
6450 }
6451 
6452 static int
6453 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6454 {
6455 	return test_authenticated_decryption(&ccm_test_case_192_3);
6456 }
6457 
6458 static int
6459 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6460 {
6461 	return test_authenticated_encryption(&ccm_test_case_256_1);
6462 }
6463 
6464 static int
6465 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6466 {
6467 	return test_authenticated_encryption(&ccm_test_case_256_2);
6468 }
6469 
6470 static int
6471 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6472 {
6473 	return test_authenticated_encryption(&ccm_test_case_256_3);
6474 }
6475 
6476 static int
6477 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6478 {
6479 	return test_authenticated_decryption(&ccm_test_case_256_1);
6480 }
6481 
6482 static int
6483 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6484 {
6485 	return test_authenticated_decryption(&ccm_test_case_256_2);
6486 }
6487 
6488 static int
6489 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6490 {
6491 	return test_authenticated_decryption(&ccm_test_case_256_3);
6492 }
6493 
6494 static int
6495 test_stats(void)
6496 {
6497 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6498 	struct rte_cryptodev_stats stats;
6499 	struct rte_cryptodev *dev;
6500 	cryptodev_stats_get_t temp_pfn;
6501 
6502 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6503 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6504 			&stats) == -ENODEV),
6505 		"rte_cryptodev_stats_get invalid dev failed");
6506 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6507 		"rte_cryptodev_stats_get invalid Param failed");
6508 	dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6509 	temp_pfn = dev->dev_ops->stats_get;
6510 	dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6511 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6512 			== -ENOTSUP),
6513 		"rte_cryptodev_stats_get invalid Param failed");
6514 	dev->dev_ops->stats_get = temp_pfn;
6515 
6516 	/* Test expected values */
6517 	ut_setup();
6518 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
6519 	ut_teardown();
6520 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6521 			&stats),
6522 		"rte_cryptodev_stats_get failed");
6523 	TEST_ASSERT((stats.enqueued_count == 1),
6524 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
6525 	TEST_ASSERT((stats.dequeued_count == 1),
6526 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
6527 	TEST_ASSERT((stats.enqueue_err_count == 0),
6528 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
6529 	TEST_ASSERT((stats.dequeue_err_count == 0),
6530 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
6531 
6532 	/* invalid device but should ignore and not reset device stats*/
6533 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6534 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6535 			&stats),
6536 		"rte_cryptodev_stats_get failed");
6537 	TEST_ASSERT((stats.enqueued_count == 1),
6538 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
6539 
6540 	/* check that a valid reset clears stats */
6541 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6542 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6543 			&stats),
6544 					  "rte_cryptodev_stats_get failed");
6545 	TEST_ASSERT((stats.enqueued_count == 0),
6546 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
6547 	TEST_ASSERT((stats.dequeued_count == 0),
6548 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
6549 
6550 	return TEST_SUCCESS;
6551 }
6552 
6553 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6554 				   struct crypto_unittest_params *ut_params,
6555 				   enum rte_crypto_auth_operation op,
6556 				   const struct HMAC_MD5_vector *test_case)
6557 {
6558 	uint8_t key[64];
6559 
6560 	memcpy(key, test_case->key.data, test_case->key.len);
6561 
6562 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6563 	ut_params->auth_xform.next = NULL;
6564 	ut_params->auth_xform.auth.op = op;
6565 
6566 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6567 
6568 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6569 	ut_params->auth_xform.auth.key.length = test_case->key.len;
6570 	ut_params->auth_xform.auth.key.data = key;
6571 
6572 	ut_params->sess = rte_cryptodev_sym_session_create(
6573 			ts_params->session_mpool);
6574 
6575 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6576 			ut_params->sess, &ut_params->auth_xform,
6577 			ts_params->session_priv_mpool);
6578 
6579 	if (ut_params->sess == NULL)
6580 		return TEST_FAILED;
6581 
6582 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6583 
6584 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6585 			rte_pktmbuf_tailroom(ut_params->ibuf));
6586 
6587 	return 0;
6588 }
6589 
6590 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6591 			      const struct HMAC_MD5_vector *test_case,
6592 			      uint8_t **plaintext)
6593 {
6594 	uint16_t plaintext_pad_len;
6595 
6596 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6597 
6598 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6599 				16);
6600 
6601 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6602 			plaintext_pad_len);
6603 	memcpy(*plaintext, test_case->plaintext.data,
6604 			test_case->plaintext.len);
6605 
6606 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6607 			ut_params->ibuf, MD5_DIGEST_LEN);
6608 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6609 			"no room to append digest");
6610 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6611 			ut_params->ibuf, plaintext_pad_len);
6612 
6613 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6614 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6615 			   test_case->auth_tag.len);
6616 	}
6617 
6618 	sym_op->auth.data.offset = 0;
6619 	sym_op->auth.data.length = test_case->plaintext.len;
6620 
6621 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6622 	ut_params->op->sym->m_src = ut_params->ibuf;
6623 
6624 	return 0;
6625 }
6626 
6627 static int
6628 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6629 {
6630 	uint16_t plaintext_pad_len;
6631 	uint8_t *plaintext, *auth_tag;
6632 
6633 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6634 	struct crypto_unittest_params *ut_params = &unittest_params;
6635 
6636 	if (MD5_HMAC_create_session(ts_params, ut_params,
6637 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6638 		return TEST_FAILED;
6639 
6640 	/* Generate Crypto op data structure */
6641 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6642 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6643 	TEST_ASSERT_NOT_NULL(ut_params->op,
6644 			"Failed to allocate symmetric crypto operation struct");
6645 
6646 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6647 				16);
6648 
6649 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6650 		return TEST_FAILED;
6651 
6652 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6653 			ut_params->op), "failed to process sym crypto op");
6654 
6655 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6656 			"crypto op processing failed");
6657 
6658 	if (ut_params->op->sym->m_dst) {
6659 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6660 				uint8_t *, plaintext_pad_len);
6661 	} else {
6662 		auth_tag = plaintext + plaintext_pad_len;
6663 	}
6664 
6665 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6666 			auth_tag,
6667 			test_case->auth_tag.data,
6668 			test_case->auth_tag.len,
6669 			"HMAC_MD5 generated tag not as expected");
6670 
6671 	return TEST_SUCCESS;
6672 }
6673 
6674 static int
6675 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6676 {
6677 	uint8_t *plaintext;
6678 
6679 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6680 	struct crypto_unittest_params *ut_params = &unittest_params;
6681 
6682 	if (MD5_HMAC_create_session(ts_params, ut_params,
6683 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6684 		return TEST_FAILED;
6685 	}
6686 
6687 	/* Generate Crypto op data structure */
6688 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6689 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6690 	TEST_ASSERT_NOT_NULL(ut_params->op,
6691 			"Failed to allocate symmetric crypto operation struct");
6692 
6693 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6694 		return TEST_FAILED;
6695 
6696 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6697 			ut_params->op), "failed to process sym crypto op");
6698 
6699 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6700 			"HMAC_MD5 crypto op processing failed");
6701 
6702 	return TEST_SUCCESS;
6703 }
6704 
6705 static int
6706 test_MD5_HMAC_generate_case_1(void)
6707 {
6708 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6709 }
6710 
6711 static int
6712 test_MD5_HMAC_verify_case_1(void)
6713 {
6714 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6715 }
6716 
6717 static int
6718 test_MD5_HMAC_generate_case_2(void)
6719 {
6720 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6721 }
6722 
6723 static int
6724 test_MD5_HMAC_verify_case_2(void)
6725 {
6726 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6727 }
6728 
6729 static int
6730 test_multi_session(void)
6731 {
6732 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6733 	struct crypto_unittest_params *ut_params = &unittest_params;
6734 
6735 	struct rte_cryptodev_info dev_info;
6736 	struct rte_cryptodev_sym_session **sessions;
6737 
6738 	uint16_t i;
6739 
6740 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6741 			aes_cbc_key, hmac_sha512_key);
6742 
6743 
6744 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6745 
6746 	sessions = rte_malloc(NULL,
6747 			(sizeof(struct rte_cryptodev_sym_session *) *
6748 			MAX_NB_SESSIONS) + 1, 0);
6749 
6750 	/* Create multiple crypto sessions*/
6751 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
6752 
6753 		sessions[i] = rte_cryptodev_sym_session_create(
6754 				ts_params->session_mpool);
6755 
6756 		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6757 				sessions[i], &ut_params->auth_xform,
6758 				ts_params->session_priv_mpool);
6759 		TEST_ASSERT_NOT_NULL(sessions[i],
6760 				"Session creation failed at session number %u",
6761 				i);
6762 
6763 		/* Attempt to send a request on each session */
6764 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6765 			sessions[i],
6766 			ut_params,
6767 			ts_params,
6768 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6769 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6770 			aes_cbc_iv),
6771 			"Failed to perform decrypt on request number %u.", i);
6772 		/* free crypto operation structure */
6773 		if (ut_params->op)
6774 			rte_crypto_op_free(ut_params->op);
6775 
6776 		/*
6777 		 * free mbuf - both obuf and ibuf are usually the same,
6778 		 * so check if they point at the same address is necessary,
6779 		 * to avoid freeing the mbuf twice.
6780 		 */
6781 		if (ut_params->obuf) {
6782 			rte_pktmbuf_free(ut_params->obuf);
6783 			if (ut_params->ibuf == ut_params->obuf)
6784 				ut_params->ibuf = 0;
6785 			ut_params->obuf = 0;
6786 		}
6787 		if (ut_params->ibuf) {
6788 			rte_pktmbuf_free(ut_params->ibuf);
6789 			ut_params->ibuf = 0;
6790 		}
6791 	}
6792 
6793 	/* Next session create should fail */
6794 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6795 			sessions[i], &ut_params->auth_xform,
6796 			ts_params->session_priv_mpool);
6797 	TEST_ASSERT_NULL(sessions[i],
6798 			"Session creation succeeded unexpectedly!");
6799 
6800 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
6801 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6802 				sessions[i]);
6803 		rte_cryptodev_sym_session_free(sessions[i]);
6804 	}
6805 
6806 	rte_free(sessions);
6807 
6808 	return TEST_SUCCESS;
6809 }
6810 
6811 struct multi_session_params {
6812 	struct crypto_unittest_params ut_params;
6813 	uint8_t *cipher_key;
6814 	uint8_t *hmac_key;
6815 	const uint8_t *cipher;
6816 	const uint8_t *digest;
6817 	uint8_t *iv;
6818 };
6819 
6820 #define MB_SESSION_NUMBER 3
6821 
6822 static int
6823 test_multi_session_random_usage(void)
6824 {
6825 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6826 	struct rte_cryptodev_info dev_info;
6827 	struct rte_cryptodev_sym_session **sessions;
6828 	uint32_t i, j;
6829 	struct multi_session_params ut_paramz[] = {
6830 
6831 		{
6832 			.cipher_key = ms_aes_cbc_key0,
6833 			.hmac_key = ms_hmac_key0,
6834 			.cipher = ms_aes_cbc_cipher0,
6835 			.digest = ms_hmac_digest0,
6836 			.iv = ms_aes_cbc_iv0
6837 		},
6838 		{
6839 			.cipher_key = ms_aes_cbc_key1,
6840 			.hmac_key = ms_hmac_key1,
6841 			.cipher = ms_aes_cbc_cipher1,
6842 			.digest = ms_hmac_digest1,
6843 			.iv = ms_aes_cbc_iv1
6844 		},
6845 		{
6846 			.cipher_key = ms_aes_cbc_key2,
6847 			.hmac_key = ms_hmac_key2,
6848 			.cipher = ms_aes_cbc_cipher2,
6849 			.digest = ms_hmac_digest2,
6850 			.iv = ms_aes_cbc_iv2
6851 		},
6852 
6853 	};
6854 
6855 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6856 
6857 	sessions = rte_malloc(NULL,
6858 			(sizeof(struct rte_cryptodev_sym_session *)
6859 					* MAX_NB_SESSIONS) + 1, 0);
6860 
6861 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
6862 		sessions[i] = rte_cryptodev_sym_session_create(
6863 				ts_params->session_mpool);
6864 
6865 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6866 				sizeof(struct crypto_unittest_params));
6867 
6868 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6869 				&ut_paramz[i].ut_params,
6870 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6871 
6872 		/* Create multiple crypto sessions*/
6873 		rte_cryptodev_sym_session_init(
6874 				ts_params->valid_devs[0],
6875 				sessions[i],
6876 				&ut_paramz[i].ut_params.auth_xform,
6877 				ts_params->session_priv_mpool);
6878 
6879 		TEST_ASSERT_NOT_NULL(sessions[i],
6880 				"Session creation failed at session number %u",
6881 				i);
6882 
6883 	}
6884 
6885 	srand(time(NULL));
6886 	for (i = 0; i < 40000; i++) {
6887 
6888 		j = rand() % MB_SESSION_NUMBER;
6889 
6890 		TEST_ASSERT_SUCCESS(
6891 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
6892 					sessions[j],
6893 					&ut_paramz[j].ut_params,
6894 					ts_params, ut_paramz[j].cipher,
6895 					ut_paramz[j].digest,
6896 					ut_paramz[j].iv),
6897 			"Failed to perform decrypt on request number %u.", i);
6898 
6899 		if (ut_paramz[j].ut_params.op)
6900 			rte_crypto_op_free(ut_paramz[j].ut_params.op);
6901 
6902 		/*
6903 		 * free mbuf - both obuf and ibuf are usually the same,
6904 		 * so check if they point at the same address is necessary,
6905 		 * to avoid freeing the mbuf twice.
6906 		 */
6907 		if (ut_paramz[j].ut_params.obuf) {
6908 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6909 			if (ut_paramz[j].ut_params.ibuf
6910 					== ut_paramz[j].ut_params.obuf)
6911 				ut_paramz[j].ut_params.ibuf = 0;
6912 			ut_paramz[j].ut_params.obuf = 0;
6913 		}
6914 		if (ut_paramz[j].ut_params.ibuf) {
6915 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6916 			ut_paramz[j].ut_params.ibuf = 0;
6917 		}
6918 	}
6919 
6920 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
6921 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6922 				sessions[i]);
6923 		rte_cryptodev_sym_session_free(sessions[i]);
6924 	}
6925 
6926 	rte_free(sessions);
6927 
6928 	return TEST_SUCCESS;
6929 }
6930 
6931 static int
6932 test_null_cipher_only_operation(void)
6933 {
6934 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6935 	struct crypto_unittest_params *ut_params = &unittest_params;
6936 
6937 	/* Generate test mbuf data and space for digest */
6938 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6939 			catch_22_quote, QUOTE_512_BYTES, 0);
6940 
6941 	/* Setup Cipher Parameters */
6942 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6943 	ut_params->cipher_xform.next = NULL;
6944 
6945 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6946 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6947 
6948 	ut_params->sess = rte_cryptodev_sym_session_create(
6949 			ts_params->session_mpool);
6950 
6951 	/* Create Crypto session*/
6952 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6953 				ut_params->sess,
6954 				&ut_params->cipher_xform,
6955 				ts_params->session_priv_mpool);
6956 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6957 
6958 	/* Generate Crypto op data structure */
6959 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6960 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6961 	TEST_ASSERT_NOT_NULL(ut_params->op,
6962 			"Failed to allocate symmetric crypto operation struct");
6963 
6964 	/* Set crypto operation data parameters */
6965 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6966 
6967 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6968 
6969 	/* set crypto operation source mbuf */
6970 	sym_op->m_src = ut_params->ibuf;
6971 
6972 	sym_op->cipher.data.offset = 0;
6973 	sym_op->cipher.data.length = QUOTE_512_BYTES;
6974 
6975 	/* Process crypto operation */
6976 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6977 			ut_params->op);
6978 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6979 
6980 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6981 			"crypto operation processing failed");
6982 
6983 	/* Validate obuf */
6984 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6985 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6986 			catch_22_quote,
6987 			QUOTE_512_BYTES,
6988 			"Ciphertext data not as expected");
6989 
6990 	return TEST_SUCCESS;
6991 }
6992 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6993 			0xab, 0xab, 0xab, 0xab,
6994 			0xab, 0xab, 0xab, 0xab,
6995 			0xab, 0xab, 0xab, 0xab};
6996 static int
6997 test_null_auth_only_operation(void)
6998 {
6999 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7000 	struct crypto_unittest_params *ut_params = &unittest_params;
7001 	uint8_t *digest;
7002 
7003 	/* Generate test mbuf data and space for digest */
7004 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7005 			catch_22_quote, QUOTE_512_BYTES, 0);
7006 
7007 	/* create a pointer for digest, but don't expect anything to be written
7008 	 * here in a NULL auth algo so no mbuf append done.
7009 	 */
7010 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7011 			QUOTE_512_BYTES);
7012 	/* prefill the memory pointed to by digest */
7013 	memcpy(digest, orig_data, sizeof(orig_data));
7014 
7015 	/* Setup HMAC Parameters */
7016 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7017 	ut_params->auth_xform.next = NULL;
7018 
7019 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7020 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7021 
7022 	ut_params->sess = rte_cryptodev_sym_session_create(
7023 			ts_params->session_mpool);
7024 
7025 	/* Create Crypto session*/
7026 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7027 			ut_params->sess, &ut_params->auth_xform,
7028 			ts_params->session_priv_mpool);
7029 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7030 
7031 	/* Generate Crypto op data structure */
7032 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7033 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7034 	TEST_ASSERT_NOT_NULL(ut_params->op,
7035 			"Failed to allocate symmetric crypto operation struct");
7036 
7037 	/* Set crypto operation data parameters */
7038 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7039 
7040 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7041 
7042 	sym_op->m_src = ut_params->ibuf;
7043 
7044 	sym_op->auth.data.offset = 0;
7045 	sym_op->auth.data.length = QUOTE_512_BYTES;
7046 	sym_op->auth.digest.data = digest;
7047 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7048 			QUOTE_512_BYTES);
7049 
7050 	/* Process crypto operation */
7051 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7052 			ut_params->op);
7053 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7054 
7055 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7056 			"crypto operation processing failed");
7057 	/* Make sure memory pointed to by digest hasn't been overwritten */
7058 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7059 			orig_data,
7060 			digest,
7061 			sizeof(orig_data),
7062 			"Memory at digest ptr overwritten unexpectedly");
7063 
7064 	return TEST_SUCCESS;
7065 }
7066 
7067 
7068 static int
7069 test_null_cipher_auth_operation(void)
7070 {
7071 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7072 	struct crypto_unittest_params *ut_params = &unittest_params;
7073 	uint8_t *digest;
7074 
7075 	/* Generate test mbuf data and space for digest */
7076 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7077 			catch_22_quote, QUOTE_512_BYTES, 0);
7078 
7079 	/* create a pointer for digest, but don't expect anything to be written
7080 	 * here in a NULL auth algo so no mbuf append done.
7081 	 */
7082 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7083 			QUOTE_512_BYTES);
7084 	/* prefill the memory pointed to by digest */
7085 	memcpy(digest, orig_data, sizeof(orig_data));
7086 
7087 	/* Setup Cipher Parameters */
7088 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7089 	ut_params->cipher_xform.next = &ut_params->auth_xform;
7090 
7091 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7092 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7093 
7094 	/* Setup HMAC Parameters */
7095 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7096 	ut_params->auth_xform.next = NULL;
7097 
7098 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7099 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7100 
7101 	ut_params->sess = rte_cryptodev_sym_session_create(
7102 			ts_params->session_mpool);
7103 
7104 	/* Create Crypto session*/
7105 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7106 			ut_params->sess, &ut_params->cipher_xform,
7107 			ts_params->session_priv_mpool);
7108 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7109 
7110 	/* Generate Crypto op data structure */
7111 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7112 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7113 	TEST_ASSERT_NOT_NULL(ut_params->op,
7114 			"Failed to allocate symmetric crypto operation struct");
7115 
7116 	/* Set crypto operation data parameters */
7117 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7118 
7119 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7120 
7121 	sym_op->m_src = ut_params->ibuf;
7122 
7123 	sym_op->cipher.data.offset = 0;
7124 	sym_op->cipher.data.length = QUOTE_512_BYTES;
7125 
7126 	sym_op->auth.data.offset = 0;
7127 	sym_op->auth.data.length = QUOTE_512_BYTES;
7128 	sym_op->auth.digest.data = digest;
7129 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7130 			QUOTE_512_BYTES);
7131 
7132 	/* Process crypto operation */
7133 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7134 			ut_params->op);
7135 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7136 
7137 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7138 			"crypto operation processing failed");
7139 
7140 	/* Validate obuf */
7141 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7142 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7143 			catch_22_quote,
7144 			QUOTE_512_BYTES,
7145 			"Ciphertext data not as expected");
7146 	/* Make sure memory pointed to by digest hasn't been overwritten */
7147 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7148 			orig_data,
7149 			digest,
7150 			sizeof(orig_data),
7151 			"Memory at digest ptr overwritten unexpectedly");
7152 
7153 	return TEST_SUCCESS;
7154 }
7155 
7156 static int
7157 test_null_auth_cipher_operation(void)
7158 {
7159 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7160 	struct crypto_unittest_params *ut_params = &unittest_params;
7161 	uint8_t *digest;
7162 
7163 	/* Generate test mbuf data */
7164 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7165 			catch_22_quote, QUOTE_512_BYTES, 0);
7166 
7167 	/* create a pointer for digest, but don't expect anything to be written
7168 	 * here in a NULL auth algo so no mbuf append done.
7169 	 */
7170 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7171 				QUOTE_512_BYTES);
7172 	/* prefill the memory pointed to by digest */
7173 	memcpy(digest, orig_data, sizeof(orig_data));
7174 
7175 	/* Setup Cipher Parameters */
7176 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7177 	ut_params->cipher_xform.next = NULL;
7178 
7179 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7180 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7181 
7182 	/* Setup HMAC Parameters */
7183 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7184 	ut_params->auth_xform.next = &ut_params->cipher_xform;
7185 
7186 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7187 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7188 
7189 	ut_params->sess = rte_cryptodev_sym_session_create(
7190 			ts_params->session_mpool);
7191 
7192 	/* Create Crypto session*/
7193 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7194 			ut_params->sess, &ut_params->cipher_xform,
7195 			ts_params->session_priv_mpool);
7196 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7197 
7198 	/* Generate Crypto op data structure */
7199 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7200 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7201 	TEST_ASSERT_NOT_NULL(ut_params->op,
7202 			"Failed to allocate symmetric crypto operation struct");
7203 
7204 	/* Set crypto operation data parameters */
7205 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7206 
7207 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7208 
7209 	sym_op->m_src = ut_params->ibuf;
7210 
7211 	sym_op->cipher.data.offset = 0;
7212 	sym_op->cipher.data.length = QUOTE_512_BYTES;
7213 
7214 	sym_op->auth.data.offset = 0;
7215 	sym_op->auth.data.length = QUOTE_512_BYTES;
7216 	sym_op->auth.digest.data = digest;
7217 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7218 					QUOTE_512_BYTES);
7219 
7220 	/* Process crypto operation */
7221 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7222 			ut_params->op);
7223 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7224 
7225 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7226 			"crypto operation processing failed");
7227 
7228 	/* Validate obuf */
7229 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7230 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7231 			catch_22_quote,
7232 			QUOTE_512_BYTES,
7233 			"Ciphertext data not as expected");
7234 	/* Make sure memory pointed to by digest hasn't been overwritten */
7235 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7236 			orig_data,
7237 			digest,
7238 			sizeof(orig_data),
7239 			"Memory at digest ptr overwritten unexpectedly");
7240 
7241 	return TEST_SUCCESS;
7242 }
7243 
7244 
7245 static int
7246 test_null_invalid_operation(void)
7247 {
7248 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7249 	struct crypto_unittest_params *ut_params = &unittest_params;
7250 	int ret;
7251 
7252 	/* Setup Cipher Parameters */
7253 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7254 	ut_params->cipher_xform.next = NULL;
7255 
7256 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7257 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7258 
7259 	ut_params->sess = rte_cryptodev_sym_session_create(
7260 			ts_params->session_mpool);
7261 
7262 	/* Create Crypto session*/
7263 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7264 			ut_params->sess, &ut_params->cipher_xform,
7265 			ts_params->session_priv_mpool);
7266 	TEST_ASSERT(ret < 0,
7267 			"Session creation succeeded unexpectedly");
7268 
7269 
7270 	/* Setup HMAC Parameters */
7271 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7272 	ut_params->auth_xform.next = NULL;
7273 
7274 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7275 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7276 
7277 	ut_params->sess = rte_cryptodev_sym_session_create(
7278 			ts_params->session_mpool);
7279 
7280 	/* Create Crypto session*/
7281 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7282 			ut_params->sess, &ut_params->auth_xform,
7283 			ts_params->session_priv_mpool);
7284 	TEST_ASSERT(ret < 0,
7285 			"Session creation succeeded unexpectedly");
7286 
7287 	return TEST_SUCCESS;
7288 }
7289 
7290 
7291 #define NULL_BURST_LENGTH (32)
7292 
7293 static int
7294 test_null_burst_operation(void)
7295 {
7296 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7297 	struct crypto_unittest_params *ut_params = &unittest_params;
7298 
7299 	unsigned i, burst_len = NULL_BURST_LENGTH;
7300 
7301 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7302 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7303 
7304 	/* Setup Cipher Parameters */
7305 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7306 	ut_params->cipher_xform.next = &ut_params->auth_xform;
7307 
7308 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7309 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7310 
7311 	/* Setup HMAC Parameters */
7312 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7313 	ut_params->auth_xform.next = NULL;
7314 
7315 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7316 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7317 
7318 	ut_params->sess = rte_cryptodev_sym_session_create(
7319 			ts_params->session_mpool);
7320 
7321 	/* Create Crypto session*/
7322 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7323 			ut_params->sess, &ut_params->cipher_xform,
7324 			ts_params->session_priv_mpool);
7325 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7326 
7327 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7328 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7329 			burst_len, "failed to generate burst of crypto ops");
7330 
7331 	/* Generate an operation for each mbuf in burst */
7332 	for (i = 0; i < burst_len; i++) {
7333 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7334 
7335 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7336 
7337 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7338 				sizeof(unsigned));
7339 		*data = i;
7340 
7341 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7342 
7343 		burst[i]->sym->m_src = m;
7344 	}
7345 
7346 	/* Process crypto operation */
7347 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7348 			0, burst, burst_len),
7349 			burst_len,
7350 			"Error enqueuing burst");
7351 
7352 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7353 			0, burst_dequeued, burst_len),
7354 			burst_len,
7355 			"Error dequeuing burst");
7356 
7357 
7358 	for (i = 0; i < burst_len; i++) {
7359 		TEST_ASSERT_EQUAL(
7360 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7361 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7362 					uint32_t *),
7363 			"data not as expected");
7364 
7365 		rte_pktmbuf_free(burst[i]->sym->m_src);
7366 		rte_crypto_op_free(burst[i]);
7367 	}
7368 
7369 	return TEST_SUCCESS;
7370 }
7371 
7372 static void
7373 generate_gmac_large_plaintext(uint8_t *data)
7374 {
7375 	uint16_t i;
7376 
7377 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7378 		memcpy(&data[i], &data[0], 32);
7379 }
7380 
7381 static int
7382 create_gmac_operation(enum rte_crypto_auth_operation op,
7383 		const struct gmac_test_data *tdata)
7384 {
7385 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7386 	struct crypto_unittest_params *ut_params = &unittest_params;
7387 	struct rte_crypto_sym_op *sym_op;
7388 
7389 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7390 
7391 	/* Generate Crypto op data structure */
7392 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7393 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7394 	TEST_ASSERT_NOT_NULL(ut_params->op,
7395 			"Failed to allocate symmetric crypto operation struct");
7396 
7397 	sym_op = ut_params->op->sym;
7398 
7399 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7400 			ut_params->ibuf, tdata->gmac_tag.len);
7401 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7402 			"no room to append digest");
7403 
7404 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7405 			ut_params->ibuf, plaintext_pad_len);
7406 
7407 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7408 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7409 				tdata->gmac_tag.len);
7410 		debug_hexdump(stdout, "digest:",
7411 				sym_op->auth.digest.data,
7412 				tdata->gmac_tag.len);
7413 	}
7414 
7415 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7416 			uint8_t *, IV_OFFSET);
7417 
7418 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7419 
7420 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7421 
7422 	sym_op->cipher.data.length = 0;
7423 	sym_op->cipher.data.offset = 0;
7424 
7425 	sym_op->auth.data.offset = 0;
7426 	sym_op->auth.data.length = tdata->plaintext.len;
7427 
7428 	return 0;
7429 }
7430 
7431 static int create_gmac_session(uint8_t dev_id,
7432 		const struct gmac_test_data *tdata,
7433 		enum rte_crypto_auth_operation auth_op)
7434 {
7435 	uint8_t auth_key[tdata->key.len];
7436 
7437 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7438 	struct crypto_unittest_params *ut_params = &unittest_params;
7439 
7440 	memcpy(auth_key, tdata->key.data, tdata->key.len);
7441 
7442 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7443 	ut_params->auth_xform.next = NULL;
7444 
7445 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7446 	ut_params->auth_xform.auth.op = auth_op;
7447 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7448 	ut_params->auth_xform.auth.key.length = tdata->key.len;
7449 	ut_params->auth_xform.auth.key.data = auth_key;
7450 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7451 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7452 
7453 
7454 	ut_params->sess = rte_cryptodev_sym_session_create(
7455 			ts_params->session_mpool);
7456 
7457 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7458 			&ut_params->auth_xform,
7459 			ts_params->session_priv_mpool);
7460 
7461 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7462 
7463 	return 0;
7464 }
7465 
7466 static int
7467 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7468 {
7469 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7470 	struct crypto_unittest_params *ut_params = &unittest_params;
7471 
7472 	int retval;
7473 
7474 	uint8_t *auth_tag, *plaintext;
7475 	uint16_t plaintext_pad_len;
7476 
7477 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7478 			      "No GMAC length in the source data");
7479 
7480 	retval = create_gmac_session(ts_params->valid_devs[0],
7481 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7482 
7483 	if (retval < 0)
7484 		return retval;
7485 
7486 	if (tdata->plaintext.len > MBUF_SIZE)
7487 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7488 	else
7489 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7490 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7491 			"Failed to allocate input buffer in mempool");
7492 
7493 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7494 			rte_pktmbuf_tailroom(ut_params->ibuf));
7495 
7496 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7497 	/*
7498 	 * Runtime generate the large plain text instead of use hard code
7499 	 * plain text vector. It is done to avoid create huge source file
7500 	 * with the test vector.
7501 	 */
7502 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7503 		generate_gmac_large_plaintext(tdata->plaintext.data);
7504 
7505 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7506 				plaintext_pad_len);
7507 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7508 
7509 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7510 	debug_hexdump(stdout, "plaintext:", plaintext,
7511 			tdata->plaintext.len);
7512 
7513 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7514 			tdata);
7515 
7516 	if (retval < 0)
7517 		return retval;
7518 
7519 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7520 
7521 	ut_params->op->sym->m_src = ut_params->ibuf;
7522 
7523 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7524 			ut_params->op), "failed to process sym crypto op");
7525 
7526 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7527 			"crypto op processing failed");
7528 
7529 	if (ut_params->op->sym->m_dst) {
7530 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7531 				uint8_t *, plaintext_pad_len);
7532 	} else {
7533 		auth_tag = plaintext + plaintext_pad_len;
7534 	}
7535 
7536 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7537 
7538 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7539 			auth_tag,
7540 			tdata->gmac_tag.data,
7541 			tdata->gmac_tag.len,
7542 			"GMAC Generated auth tag not as expected");
7543 
7544 	return 0;
7545 }
7546 
7547 static int
7548 test_AES_GMAC_authentication_test_case_1(void)
7549 {
7550 	return test_AES_GMAC_authentication(&gmac_test_case_1);
7551 }
7552 
7553 static int
7554 test_AES_GMAC_authentication_test_case_2(void)
7555 {
7556 	return test_AES_GMAC_authentication(&gmac_test_case_2);
7557 }
7558 
7559 static int
7560 test_AES_GMAC_authentication_test_case_3(void)
7561 {
7562 	return test_AES_GMAC_authentication(&gmac_test_case_3);
7563 }
7564 
7565 static int
7566 test_AES_GMAC_authentication_test_case_4(void)
7567 {
7568 	return test_AES_GMAC_authentication(&gmac_test_case_4);
7569 }
7570 
7571 static int
7572 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7573 {
7574 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7575 	struct crypto_unittest_params *ut_params = &unittest_params;
7576 	int retval;
7577 	uint32_t plaintext_pad_len;
7578 	uint8_t *plaintext;
7579 
7580 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7581 			      "No GMAC length in the source data");
7582 
7583 	retval = create_gmac_session(ts_params->valid_devs[0],
7584 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7585 
7586 	if (retval < 0)
7587 		return retval;
7588 
7589 	if (tdata->plaintext.len > MBUF_SIZE)
7590 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7591 	else
7592 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7593 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7594 			"Failed to allocate input buffer in mempool");
7595 
7596 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7597 			rte_pktmbuf_tailroom(ut_params->ibuf));
7598 
7599 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7600 
7601 	/*
7602 	 * Runtime generate the large plain text instead of use hard code
7603 	 * plain text vector. It is done to avoid create huge source file
7604 	 * with the test vector.
7605 	 */
7606 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7607 		generate_gmac_large_plaintext(tdata->plaintext.data);
7608 
7609 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7610 				plaintext_pad_len);
7611 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7612 
7613 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7614 	debug_hexdump(stdout, "plaintext:", plaintext,
7615 			tdata->plaintext.len);
7616 
7617 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7618 			tdata);
7619 
7620 	if (retval < 0)
7621 		return retval;
7622 
7623 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7624 
7625 	ut_params->op->sym->m_src = ut_params->ibuf;
7626 
7627 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7628 			ut_params->op), "failed to process sym crypto op");
7629 
7630 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7631 			"crypto op processing failed");
7632 
7633 	return 0;
7634 
7635 }
7636 
7637 static int
7638 test_AES_GMAC_authentication_verify_test_case_1(void)
7639 {
7640 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7641 }
7642 
7643 static int
7644 test_AES_GMAC_authentication_verify_test_case_2(void)
7645 {
7646 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7647 }
7648 
7649 static int
7650 test_AES_GMAC_authentication_verify_test_case_3(void)
7651 {
7652 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7653 }
7654 
7655 static int
7656 test_AES_GMAC_authentication_verify_test_case_4(void)
7657 {
7658 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7659 }
7660 
7661 struct test_crypto_vector {
7662 	enum rte_crypto_cipher_algorithm crypto_algo;
7663 
7664 	struct {
7665 		uint8_t data[64];
7666 		unsigned int len;
7667 	} cipher_key;
7668 
7669 	struct {
7670 		uint8_t data[64];
7671 		unsigned int len;
7672 	} iv;
7673 
7674 	struct {
7675 		const uint8_t *data;
7676 		unsigned int len;
7677 	} plaintext;
7678 
7679 	struct {
7680 		const uint8_t *data;
7681 		unsigned int len;
7682 	} ciphertext;
7683 
7684 	enum rte_crypto_auth_algorithm auth_algo;
7685 
7686 	struct {
7687 		uint8_t data[128];
7688 		unsigned int len;
7689 	} auth_key;
7690 
7691 	struct {
7692 		const uint8_t *data;
7693 		unsigned int len;
7694 	} aad;
7695 
7696 	struct {
7697 		uint8_t data[128];
7698 		unsigned int len;
7699 	} digest;
7700 };
7701 
7702 static const struct test_crypto_vector
7703 hmac_sha1_test_crypto_vector = {
7704 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7705 	.plaintext = {
7706 		.data = plaintext_hash,
7707 		.len = 512
7708 	},
7709 	.auth_key = {
7710 		.data = {
7711 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7712 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7713 			0xDE, 0xF4, 0xDE, 0xAD
7714 		},
7715 		.len = 20
7716 	},
7717 	.digest = {
7718 		.data = {
7719 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7720 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7721 			0x3F, 0x91, 0x64, 0x59
7722 		},
7723 		.len = 20
7724 	}
7725 };
7726 
7727 static const struct test_crypto_vector
7728 aes128_gmac_test_vector = {
7729 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7730 	.plaintext = {
7731 		.data = plaintext_hash,
7732 		.len = 512
7733 	},
7734 	.iv = {
7735 		.data = {
7736 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7737 			0x08, 0x09, 0x0A, 0x0B
7738 		},
7739 		.len = 12
7740 	},
7741 	.auth_key = {
7742 		.data = {
7743 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7744 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7745 		},
7746 		.len = 16
7747 	},
7748 	.digest = {
7749 		.data = {
7750 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7751 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7752 		},
7753 		.len = 16
7754 	}
7755 };
7756 
7757 static const struct test_crypto_vector
7758 aes128cbc_hmac_sha1_test_vector = {
7759 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7760 	.cipher_key = {
7761 		.data = {
7762 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7763 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7764 		},
7765 		.len = 16
7766 	},
7767 	.iv = {
7768 		.data = {
7769 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7770 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7771 		},
7772 		.len = 16
7773 	},
7774 	.plaintext = {
7775 		.data = plaintext_hash,
7776 		.len = 512
7777 	},
7778 	.ciphertext = {
7779 		.data = ciphertext512_aes128cbc,
7780 		.len = 512
7781 	},
7782 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7783 	.auth_key = {
7784 		.data = {
7785 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7786 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7787 			0xDE, 0xF4, 0xDE, 0xAD
7788 		},
7789 		.len = 20
7790 	},
7791 	.digest = {
7792 		.data = {
7793 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7794 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7795 			0x18, 0x8C, 0x1D, 0x32
7796 		},
7797 		.len = 20
7798 	}
7799 };
7800 
7801 static void
7802 data_corruption(uint8_t *data)
7803 {
7804 	data[0] += 1;
7805 }
7806 
7807 static void
7808 tag_corruption(uint8_t *data, unsigned int tag_offset)
7809 {
7810 	data[tag_offset] += 1;
7811 }
7812 
7813 static int
7814 create_auth_session(struct crypto_unittest_params *ut_params,
7815 		uint8_t dev_id,
7816 		const struct test_crypto_vector *reference,
7817 		enum rte_crypto_auth_operation auth_op)
7818 {
7819 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7820 	uint8_t auth_key[reference->auth_key.len + 1];
7821 
7822 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7823 
7824 	/* Setup Authentication Parameters */
7825 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7826 	ut_params->auth_xform.auth.op = auth_op;
7827 	ut_params->auth_xform.next = NULL;
7828 	ut_params->auth_xform.auth.algo = reference->auth_algo;
7829 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7830 	ut_params->auth_xform.auth.key.data = auth_key;
7831 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
7832 
7833 	/* Create Crypto session*/
7834 	ut_params->sess = rte_cryptodev_sym_session_create(
7835 			ts_params->session_mpool);
7836 
7837 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7838 				&ut_params->auth_xform,
7839 				ts_params->session_priv_mpool);
7840 
7841 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7842 
7843 	return 0;
7844 }
7845 
7846 static int
7847 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7848 		uint8_t dev_id,
7849 		const struct test_crypto_vector *reference,
7850 		enum rte_crypto_auth_operation auth_op,
7851 		enum rte_crypto_cipher_operation cipher_op)
7852 {
7853 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7854 	uint8_t cipher_key[reference->cipher_key.len + 1];
7855 	uint8_t auth_key[reference->auth_key.len + 1];
7856 
7857 	memcpy(cipher_key, reference->cipher_key.data,
7858 			reference->cipher_key.len);
7859 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7860 
7861 	/* Setup Authentication Parameters */
7862 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7863 	ut_params->auth_xform.auth.op = auth_op;
7864 	ut_params->auth_xform.auth.algo = reference->auth_algo;
7865 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7866 	ut_params->auth_xform.auth.key.data = auth_key;
7867 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
7868 
7869 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7870 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7871 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
7872 	} else {
7873 		ut_params->auth_xform.next = &ut_params->cipher_xform;
7874 
7875 		/* Setup Cipher Parameters */
7876 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7877 		ut_params->cipher_xform.next = NULL;
7878 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7879 		ut_params->cipher_xform.cipher.op = cipher_op;
7880 		ut_params->cipher_xform.cipher.key.data = cipher_key;
7881 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7882 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7883 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7884 	}
7885 
7886 	/* Create Crypto session*/
7887 	ut_params->sess = rte_cryptodev_sym_session_create(
7888 			ts_params->session_mpool);
7889 
7890 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7891 				&ut_params->auth_xform,
7892 				ts_params->session_priv_mpool);
7893 
7894 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7895 
7896 	return 0;
7897 }
7898 
7899 static int
7900 create_auth_operation(struct crypto_testsuite_params *ts_params,
7901 		struct crypto_unittest_params *ut_params,
7902 		const struct test_crypto_vector *reference,
7903 		unsigned int auth_generate)
7904 {
7905 	/* Generate Crypto op data structure */
7906 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7907 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7908 	TEST_ASSERT_NOT_NULL(ut_params->op,
7909 			"Failed to allocate pktmbuf offload");
7910 
7911 	/* Set crypto operation data parameters */
7912 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7913 
7914 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7915 
7916 	/* set crypto operation source mbuf */
7917 	sym_op->m_src = ut_params->ibuf;
7918 
7919 	/* digest */
7920 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7921 			ut_params->ibuf, reference->digest.len);
7922 
7923 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7924 			"no room to append auth tag");
7925 
7926 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7927 			ut_params->ibuf, reference->plaintext.len);
7928 
7929 	if (auth_generate)
7930 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
7931 	else
7932 		memcpy(sym_op->auth.digest.data,
7933 				reference->digest.data,
7934 				reference->digest.len);
7935 
7936 	debug_hexdump(stdout, "digest:",
7937 			sym_op->auth.digest.data,
7938 			reference->digest.len);
7939 
7940 	sym_op->auth.data.length = reference->plaintext.len;
7941 	sym_op->auth.data.offset = 0;
7942 
7943 	return 0;
7944 }
7945 
7946 static int
7947 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7948 		struct crypto_unittest_params *ut_params,
7949 		const struct test_crypto_vector *reference,
7950 		unsigned int auth_generate)
7951 {
7952 	/* Generate Crypto op data structure */
7953 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7954 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7955 	TEST_ASSERT_NOT_NULL(ut_params->op,
7956 			"Failed to allocate pktmbuf offload");
7957 
7958 	/* Set crypto operation data parameters */
7959 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7960 
7961 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7962 
7963 	/* set crypto operation source mbuf */
7964 	sym_op->m_src = ut_params->ibuf;
7965 
7966 	/* digest */
7967 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7968 			ut_params->ibuf, reference->digest.len);
7969 
7970 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7971 			"no room to append auth tag");
7972 
7973 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7974 			ut_params->ibuf, reference->ciphertext.len);
7975 
7976 	if (auth_generate)
7977 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
7978 	else
7979 		memcpy(sym_op->auth.digest.data,
7980 				reference->digest.data,
7981 				reference->digest.len);
7982 
7983 	debug_hexdump(stdout, "digest:",
7984 			sym_op->auth.digest.data,
7985 			reference->digest.len);
7986 
7987 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7988 			reference->iv.data, reference->iv.len);
7989 
7990 	sym_op->cipher.data.length = 0;
7991 	sym_op->cipher.data.offset = 0;
7992 
7993 	sym_op->auth.data.length = reference->plaintext.len;
7994 	sym_op->auth.data.offset = 0;
7995 
7996 	return 0;
7997 }
7998 
7999 static int
8000 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8001 		struct crypto_unittest_params *ut_params,
8002 		const struct test_crypto_vector *reference,
8003 		unsigned int auth_generate)
8004 {
8005 	/* Generate Crypto op data structure */
8006 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8007 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8008 	TEST_ASSERT_NOT_NULL(ut_params->op,
8009 			"Failed to allocate pktmbuf offload");
8010 
8011 	/* Set crypto operation data parameters */
8012 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8013 
8014 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8015 
8016 	/* set crypto operation source mbuf */
8017 	sym_op->m_src = ut_params->ibuf;
8018 
8019 	/* digest */
8020 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8021 			ut_params->ibuf, reference->digest.len);
8022 
8023 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8024 			"no room to append auth tag");
8025 
8026 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8027 			ut_params->ibuf, reference->ciphertext.len);
8028 
8029 	if (auth_generate)
8030 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
8031 	else
8032 		memcpy(sym_op->auth.digest.data,
8033 				reference->digest.data,
8034 				reference->digest.len);
8035 
8036 	debug_hexdump(stdout, "digest:",
8037 			sym_op->auth.digest.data,
8038 			reference->digest.len);
8039 
8040 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8041 			reference->iv.data, reference->iv.len);
8042 
8043 	sym_op->cipher.data.length = reference->ciphertext.len;
8044 	sym_op->cipher.data.offset = 0;
8045 
8046 	sym_op->auth.data.length = reference->ciphertext.len;
8047 	sym_op->auth.data.offset = 0;
8048 
8049 	return 0;
8050 }
8051 
8052 static int
8053 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8054 		struct crypto_unittest_params *ut_params,
8055 		const struct test_crypto_vector *reference)
8056 {
8057 	return create_auth_operation(ts_params, ut_params, reference, 0);
8058 }
8059 
8060 static int
8061 create_auth_verify_GMAC_operation(
8062 		struct crypto_testsuite_params *ts_params,
8063 		struct crypto_unittest_params *ut_params,
8064 		const struct test_crypto_vector *reference)
8065 {
8066 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8067 }
8068 
8069 static int
8070 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8071 		struct crypto_unittest_params *ut_params,
8072 		const struct test_crypto_vector *reference)
8073 {
8074 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8075 }
8076 
8077 static int
8078 test_authentication_verify_fail_when_data_corruption(
8079 		struct crypto_testsuite_params *ts_params,
8080 		struct crypto_unittest_params *ut_params,
8081 		const struct test_crypto_vector *reference,
8082 		unsigned int data_corrupted)
8083 {
8084 	int retval;
8085 
8086 	uint8_t *plaintext;
8087 
8088 	/* Create session */
8089 	retval = create_auth_session(ut_params,
8090 			ts_params->valid_devs[0],
8091 			reference,
8092 			RTE_CRYPTO_AUTH_OP_VERIFY);
8093 	if (retval < 0)
8094 		return retval;
8095 
8096 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8097 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8098 			"Failed to allocate input buffer in mempool");
8099 
8100 	/* clear mbuf payload */
8101 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8102 			rte_pktmbuf_tailroom(ut_params->ibuf));
8103 
8104 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8105 			reference->plaintext.len);
8106 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8107 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8108 
8109 	debug_hexdump(stdout, "plaintext:", plaintext,
8110 		reference->plaintext.len);
8111 
8112 	/* Create operation */
8113 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
8114 
8115 	if (retval < 0)
8116 		return retval;
8117 
8118 	if (data_corrupted)
8119 		data_corruption(plaintext);
8120 	else
8121 		tag_corruption(plaintext, reference->plaintext.len);
8122 
8123 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8124 			ut_params->op);
8125 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8126 	TEST_ASSERT_EQUAL(ut_params->op->status,
8127 			RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8128 			"authentication not failed");
8129 
8130 	ut_params->obuf = ut_params->op->sym->m_src;
8131 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8132 
8133 	return 0;
8134 }
8135 
8136 static int
8137 test_authentication_verify_GMAC_fail_when_corruption(
8138 		struct crypto_testsuite_params *ts_params,
8139 		struct crypto_unittest_params *ut_params,
8140 		const struct test_crypto_vector *reference,
8141 		unsigned int data_corrupted)
8142 {
8143 	int retval;
8144 	uint8_t *plaintext;
8145 
8146 	/* Create session */
8147 	retval = create_auth_cipher_session(ut_params,
8148 			ts_params->valid_devs[0],
8149 			reference,
8150 			RTE_CRYPTO_AUTH_OP_VERIFY,
8151 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
8152 	if (retval < 0)
8153 		return retval;
8154 
8155 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8156 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8157 			"Failed to allocate input buffer in mempool");
8158 
8159 	/* clear mbuf payload */
8160 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8161 			rte_pktmbuf_tailroom(ut_params->ibuf));
8162 
8163 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8164 			reference->plaintext.len);
8165 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8166 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8167 
8168 	debug_hexdump(stdout, "plaintext:", plaintext,
8169 		reference->plaintext.len);
8170 
8171 	/* Create operation */
8172 	retval = create_auth_verify_GMAC_operation(ts_params,
8173 			ut_params,
8174 			reference);
8175 
8176 	if (retval < 0)
8177 		return retval;
8178 
8179 	if (data_corrupted)
8180 		data_corruption(plaintext);
8181 	else
8182 		tag_corruption(plaintext, reference->aad.len);
8183 
8184 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8185 			ut_params->op);
8186 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8187 	TEST_ASSERT_EQUAL(ut_params->op->status,
8188 			RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8189 			"authentication not failed");
8190 
8191 	ut_params->obuf = ut_params->op->sym->m_src;
8192 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8193 
8194 	return 0;
8195 }
8196 
8197 static int
8198 test_authenticated_decryption_fail_when_corruption(
8199 		struct crypto_testsuite_params *ts_params,
8200 		struct crypto_unittest_params *ut_params,
8201 		const struct test_crypto_vector *reference,
8202 		unsigned int data_corrupted)
8203 {
8204 	int retval;
8205 
8206 	uint8_t *ciphertext;
8207 
8208 	/* Create session */
8209 	retval = create_auth_cipher_session(ut_params,
8210 			ts_params->valid_devs[0],
8211 			reference,
8212 			RTE_CRYPTO_AUTH_OP_VERIFY,
8213 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
8214 	if (retval < 0)
8215 		return retval;
8216 
8217 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8218 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8219 			"Failed to allocate input buffer in mempool");
8220 
8221 	/* clear mbuf payload */
8222 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8223 			rte_pktmbuf_tailroom(ut_params->ibuf));
8224 
8225 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8226 			reference->ciphertext.len);
8227 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8228 	memcpy(ciphertext, reference->ciphertext.data,
8229 			reference->ciphertext.len);
8230 
8231 	/* Create operation */
8232 	retval = create_cipher_auth_verify_operation(ts_params,
8233 			ut_params,
8234 			reference);
8235 
8236 	if (retval < 0)
8237 		return retval;
8238 
8239 	if (data_corrupted)
8240 		data_corruption(ciphertext);
8241 	else
8242 		tag_corruption(ciphertext, reference->ciphertext.len);
8243 
8244 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8245 			ut_params->op);
8246 
8247 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8248 	TEST_ASSERT_EQUAL(ut_params->op->status,
8249 			RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8250 			"authentication not failed");
8251 
8252 	ut_params->obuf = ut_params->op->sym->m_src;
8253 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8254 
8255 	return 0;
8256 }
8257 
8258 static int
8259 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8260 		const struct aead_test_data *tdata,
8261 		void *digest_mem, uint64_t digest_phys)
8262 {
8263 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8264 	struct crypto_unittest_params *ut_params = &unittest_params;
8265 
8266 	const unsigned int auth_tag_len = tdata->auth_tag.len;
8267 	const unsigned int iv_len = tdata->iv.len;
8268 	unsigned int aad_len = tdata->aad.len;
8269 
8270 	/* Generate Crypto op data structure */
8271 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8272 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8273 	TEST_ASSERT_NOT_NULL(ut_params->op,
8274 		"Failed to allocate symmetric crypto operation struct");
8275 
8276 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8277 
8278 	sym_op->aead.digest.data = digest_mem;
8279 
8280 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8281 			"no room to append digest");
8282 
8283 	sym_op->aead.digest.phys_addr = digest_phys;
8284 
8285 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8286 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8287 				auth_tag_len);
8288 		debug_hexdump(stdout, "digest:",
8289 				sym_op->aead.digest.data,
8290 				auth_tag_len);
8291 	}
8292 
8293 	/* Append aad data */
8294 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8295 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8296 				uint8_t *, IV_OFFSET);
8297 
8298 		/* Copy IV 1 byte after the IV pointer, according to the API */
8299 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8300 
8301 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8302 
8303 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8304 				ut_params->ibuf, aad_len);
8305 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8306 				"no room to prepend aad");
8307 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8308 				ut_params->ibuf);
8309 
8310 		memset(sym_op->aead.aad.data, 0, aad_len);
8311 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
8312 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8313 
8314 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8315 		debug_hexdump(stdout, "aad:",
8316 				sym_op->aead.aad.data, aad_len);
8317 	} else {
8318 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8319 				uint8_t *, IV_OFFSET);
8320 
8321 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8322 
8323 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8324 				ut_params->ibuf, aad_len);
8325 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8326 				"no room to prepend aad");
8327 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8328 				ut_params->ibuf);
8329 
8330 		memset(sym_op->aead.aad.data, 0, aad_len);
8331 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8332 
8333 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8334 		debug_hexdump(stdout, "aad:",
8335 				sym_op->aead.aad.data, aad_len);
8336 	}
8337 
8338 	sym_op->aead.data.length = tdata->plaintext.len;
8339 	sym_op->aead.data.offset = aad_len;
8340 
8341 	return 0;
8342 }
8343 
8344 #define SGL_MAX_NO	16
8345 
8346 static int
8347 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8348 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8349 {
8350 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8351 	struct crypto_unittest_params *ut_params = &unittest_params;
8352 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8353 	int retval;
8354 	int to_trn = 0;
8355 	int to_trn_tbl[SGL_MAX_NO];
8356 	int segs = 1;
8357 	unsigned int trn_data = 0;
8358 	uint8_t *plaintext, *ciphertext, *auth_tag;
8359 
8360 	if (fragsz > tdata->plaintext.len)
8361 		fragsz = tdata->plaintext.len;
8362 
8363 	uint16_t plaintext_len = fragsz;
8364 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8365 
8366 	if (fragsz_oop > tdata->plaintext.len)
8367 		frag_size_oop = tdata->plaintext.len;
8368 
8369 	int ecx = 0;
8370 	void *digest_mem = NULL;
8371 
8372 	uint32_t prepend_len = tdata->aad.len;
8373 
8374 	if (tdata->plaintext.len % fragsz != 0) {
8375 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8376 			return 1;
8377 	}	else {
8378 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8379 			return 1;
8380 	}
8381 
8382 	/*
8383 	 * For out-op-place we need to alloc another mbuf
8384 	 */
8385 	if (oop) {
8386 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8387 		rte_pktmbuf_append(ut_params->obuf,
8388 				frag_size_oop + prepend_len);
8389 		buf_oop = ut_params->obuf;
8390 	}
8391 
8392 	/* Create AEAD session */
8393 	retval = create_aead_session(ts_params->valid_devs[0],
8394 			tdata->algo,
8395 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
8396 			tdata->key.data, tdata->key.len,
8397 			tdata->aad.len, tdata->auth_tag.len,
8398 			tdata->iv.len);
8399 	if (retval < 0)
8400 		return retval;
8401 
8402 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8403 
8404 	/* clear mbuf payload */
8405 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8406 			rte_pktmbuf_tailroom(ut_params->ibuf));
8407 
8408 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8409 			plaintext_len);
8410 
8411 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8412 
8413 	trn_data += plaintext_len;
8414 
8415 	buf = ut_params->ibuf;
8416 
8417 	/*
8418 	 * Loop until no more fragments
8419 	 */
8420 
8421 	while (trn_data < tdata->plaintext.len) {
8422 		++segs;
8423 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8424 				(tdata->plaintext.len - trn_data) : fragsz;
8425 
8426 		to_trn_tbl[ecx++] = to_trn;
8427 
8428 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8429 		buf = buf->next;
8430 
8431 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8432 				rte_pktmbuf_tailroom(buf));
8433 
8434 		/* OOP */
8435 		if (oop && !fragsz_oop) {
8436 			buf_last_oop = buf_oop->next =
8437 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
8438 			buf_oop = buf_oop->next;
8439 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8440 					0, rte_pktmbuf_tailroom(buf_oop));
8441 			rte_pktmbuf_append(buf_oop, to_trn);
8442 		}
8443 
8444 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8445 				to_trn);
8446 
8447 		memcpy(plaintext, tdata->plaintext.data + trn_data,
8448 				to_trn);
8449 		trn_data += to_trn;
8450 		if (trn_data  == tdata->plaintext.len) {
8451 			if (oop) {
8452 				if (!fragsz_oop)
8453 					digest_mem = rte_pktmbuf_append(buf_oop,
8454 						tdata->auth_tag.len);
8455 			} else
8456 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8457 					tdata->auth_tag.len);
8458 		}
8459 	}
8460 
8461 	uint64_t digest_phys = 0;
8462 
8463 	ut_params->ibuf->nb_segs = segs;
8464 
8465 	segs = 1;
8466 	if (fragsz_oop && oop) {
8467 		to_trn = 0;
8468 		ecx = 0;
8469 
8470 		if (frag_size_oop == tdata->plaintext.len) {
8471 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
8472 				tdata->auth_tag.len);
8473 
8474 			digest_phys = rte_pktmbuf_iova_offset(
8475 					ut_params->obuf,
8476 					tdata->plaintext.len + prepend_len);
8477 		}
8478 
8479 		trn_data = frag_size_oop;
8480 		while (trn_data < tdata->plaintext.len) {
8481 			++segs;
8482 			to_trn =
8483 				(tdata->plaintext.len - trn_data <
8484 						frag_size_oop) ?
8485 				(tdata->plaintext.len - trn_data) :
8486 						frag_size_oop;
8487 
8488 			to_trn_tbl[ecx++] = to_trn;
8489 
8490 			buf_last_oop = buf_oop->next =
8491 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
8492 			buf_oop = buf_oop->next;
8493 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8494 					0, rte_pktmbuf_tailroom(buf_oop));
8495 			rte_pktmbuf_append(buf_oop, to_trn);
8496 
8497 			trn_data += to_trn;
8498 
8499 			if (trn_data  == tdata->plaintext.len) {
8500 				digest_mem = rte_pktmbuf_append(buf_oop,
8501 					tdata->auth_tag.len);
8502 			}
8503 		}
8504 
8505 		ut_params->obuf->nb_segs = segs;
8506 	}
8507 
8508 	/*
8509 	 * Place digest at the end of the last buffer
8510 	 */
8511 	if (!digest_phys)
8512 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8513 	if (oop && buf_last_oop)
8514 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8515 
8516 	if (!digest_mem && !oop) {
8517 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8518 				+ tdata->auth_tag.len);
8519 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8520 				tdata->plaintext.len);
8521 	}
8522 
8523 	/* Create AEAD operation */
8524 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8525 			tdata, digest_mem, digest_phys);
8526 
8527 	if (retval < 0)
8528 		return retval;
8529 
8530 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8531 
8532 	ut_params->op->sym->m_src = ut_params->ibuf;
8533 	if (oop)
8534 		ut_params->op->sym->m_dst = ut_params->obuf;
8535 
8536 	/* Process crypto operation */
8537 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8538 			ut_params->op), "failed to process sym crypto op");
8539 
8540 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8541 			"crypto op processing failed");
8542 
8543 
8544 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8545 			uint8_t *, prepend_len);
8546 	if (oop) {
8547 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8548 				uint8_t *, prepend_len);
8549 	}
8550 
8551 	if (fragsz_oop)
8552 		fragsz = fragsz_oop;
8553 
8554 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8555 			ciphertext,
8556 			tdata->ciphertext.data,
8557 			fragsz,
8558 			"Ciphertext data not as expected");
8559 
8560 	buf = ut_params->op->sym->m_src->next;
8561 	if (oop)
8562 		buf = ut_params->op->sym->m_dst->next;
8563 
8564 	unsigned int off = fragsz;
8565 
8566 	ecx = 0;
8567 	while (buf) {
8568 		ciphertext = rte_pktmbuf_mtod(buf,
8569 				uint8_t *);
8570 
8571 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
8572 				ciphertext,
8573 				tdata->ciphertext.data + off,
8574 				to_trn_tbl[ecx],
8575 				"Ciphertext data not as expected");
8576 
8577 		off += to_trn_tbl[ecx++];
8578 		buf = buf->next;
8579 	}
8580 
8581 	auth_tag = digest_mem;
8582 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8583 			auth_tag,
8584 			tdata->auth_tag.data,
8585 			tdata->auth_tag.len,
8586 			"Generated auth tag not as expected");
8587 
8588 	return 0;
8589 }
8590 
8591 #define IN_PLACE	0
8592 #define OUT_OF_PLACE	1
8593 
8594 static int
8595 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8596 {
8597 	return test_authenticated_encryption_SGL(
8598 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8599 }
8600 
8601 static int
8602 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8603 {
8604 	return test_authenticated_encryption_SGL(
8605 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8606 }
8607 
8608 static int
8609 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8610 {
8611 	return test_authenticated_encryption_SGL(
8612 			&gcm_test_case_8, OUT_OF_PLACE, 400,
8613 			gcm_test_case_8.plaintext.len);
8614 }
8615 
8616 static int
8617 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8618 {
8619 
8620 	return test_authenticated_encryption_SGL(
8621 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8622 }
8623 
8624 static int
8625 test_authentication_verify_fail_when_data_corrupted(
8626 		struct crypto_testsuite_params *ts_params,
8627 		struct crypto_unittest_params *ut_params,
8628 		const struct test_crypto_vector *reference)
8629 {
8630 	return test_authentication_verify_fail_when_data_corruption(
8631 			ts_params, ut_params, reference, 1);
8632 }
8633 
8634 static int
8635 test_authentication_verify_fail_when_tag_corrupted(
8636 		struct crypto_testsuite_params *ts_params,
8637 		struct crypto_unittest_params *ut_params,
8638 		const struct test_crypto_vector *reference)
8639 {
8640 	return test_authentication_verify_fail_when_data_corruption(
8641 			ts_params, ut_params, reference, 0);
8642 }
8643 
8644 static int
8645 test_authentication_verify_GMAC_fail_when_data_corrupted(
8646 		struct crypto_testsuite_params *ts_params,
8647 		struct crypto_unittest_params *ut_params,
8648 		const struct test_crypto_vector *reference)
8649 {
8650 	return test_authentication_verify_GMAC_fail_when_corruption(
8651 			ts_params, ut_params, reference, 1);
8652 }
8653 
8654 static int
8655 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8656 		struct crypto_testsuite_params *ts_params,
8657 		struct crypto_unittest_params *ut_params,
8658 		const struct test_crypto_vector *reference)
8659 {
8660 	return test_authentication_verify_GMAC_fail_when_corruption(
8661 			ts_params, ut_params, reference, 0);
8662 }
8663 
8664 static int
8665 test_authenticated_decryption_fail_when_data_corrupted(
8666 		struct crypto_testsuite_params *ts_params,
8667 		struct crypto_unittest_params *ut_params,
8668 		const struct test_crypto_vector *reference)
8669 {
8670 	return test_authenticated_decryption_fail_when_corruption(
8671 			ts_params, ut_params, reference, 1);
8672 }
8673 
8674 static int
8675 test_authenticated_decryption_fail_when_tag_corrupted(
8676 		struct crypto_testsuite_params *ts_params,
8677 		struct crypto_unittest_params *ut_params,
8678 		const struct test_crypto_vector *reference)
8679 {
8680 	return test_authenticated_decryption_fail_when_corruption(
8681 			ts_params, ut_params, reference, 0);
8682 }
8683 
8684 static int
8685 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8686 {
8687 	return test_authentication_verify_fail_when_data_corrupted(
8688 			&testsuite_params, &unittest_params,
8689 			&hmac_sha1_test_crypto_vector);
8690 }
8691 
8692 static int
8693 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8694 {
8695 	return test_authentication_verify_fail_when_tag_corrupted(
8696 			&testsuite_params, &unittest_params,
8697 			&hmac_sha1_test_crypto_vector);
8698 }
8699 
8700 static int
8701 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8702 {
8703 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
8704 			&testsuite_params, &unittest_params,
8705 			&aes128_gmac_test_vector);
8706 }
8707 
8708 static int
8709 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8710 {
8711 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8712 			&testsuite_params, &unittest_params,
8713 			&aes128_gmac_test_vector);
8714 }
8715 
8716 static int
8717 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8718 {
8719 	return test_authenticated_decryption_fail_when_data_corrupted(
8720 			&testsuite_params,
8721 			&unittest_params,
8722 			&aes128cbc_hmac_sha1_test_vector);
8723 }
8724 
8725 static int
8726 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8727 {
8728 	return test_authenticated_decryption_fail_when_tag_corrupted(
8729 			&testsuite_params,
8730 			&unittest_params,
8731 			&aes128cbc_hmac_sha1_test_vector);
8732 }
8733 
8734 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8735 
8736 /* global AESNI slave IDs for the scheduler test */
8737 uint8_t aesni_ids[2];
8738 
8739 static int
8740 test_scheduler_attach_slave_op(void)
8741 {
8742 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8743 	uint8_t sched_id = ts_params->valid_devs[0];
8744 	uint32_t nb_devs, i, nb_devs_attached = 0;
8745 	int ret;
8746 	char vdev_name[32];
8747 
8748 	/* create 2 AESNI_MB if necessary */
8749 	nb_devs = rte_cryptodev_device_count_by_driver(
8750 			rte_cryptodev_driver_id_get(
8751 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8752 	if (nb_devs < 2) {
8753 		for (i = nb_devs; i < 2; i++) {
8754 			snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8755 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8756 					i);
8757 			ret = rte_vdev_init(vdev_name, NULL);
8758 
8759 			TEST_ASSERT(ret == 0,
8760 				"Failed to create instance %u of"
8761 				" pmd : %s",
8762 				i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8763 		}
8764 	}
8765 
8766 	/* attach 2 AESNI_MB cdevs */
8767 	for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8768 			i++) {
8769 		struct rte_cryptodev_info info;
8770 		unsigned int session_size;
8771 
8772 		rte_cryptodev_info_get(i, &info);
8773 		if (info.driver_id != rte_cryptodev_driver_id_get(
8774 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8775 			continue;
8776 
8777 		session_size = rte_cryptodev_sym_get_private_session_size(i);
8778 		/*
8779 		 * Create the session mempool again, since now there are new devices
8780 		 * to use the mempool.
8781 		 */
8782 		if (ts_params->session_mpool) {
8783 			rte_mempool_free(ts_params->session_mpool);
8784 			ts_params->session_mpool = NULL;
8785 		}
8786 		if (ts_params->session_priv_mpool) {
8787 			rte_mempool_free(ts_params->session_priv_mpool);
8788 			ts_params->session_priv_mpool = NULL;
8789 		}
8790 
8791 		if (info.sym.max_nb_sessions != 0 &&
8792 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8793 			RTE_LOG(ERR, USER1,
8794 					"Device does not support "
8795 					"at least %u sessions\n",
8796 					MAX_NB_SESSIONS);
8797 			return TEST_FAILED;
8798 		}
8799 		/*
8800 		 * Create mempool with maximum number of sessions,
8801 		 * to include the session headers
8802 		 */
8803 		if (ts_params->session_mpool == NULL) {
8804 			ts_params->session_mpool =
8805 				rte_cryptodev_sym_session_pool_create(
8806 						"test_sess_mp",
8807 						MAX_NB_SESSIONS, 0, 0, 0,
8808 						SOCKET_ID_ANY);
8809 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8810 					"session mempool allocation failed");
8811 		}
8812 
8813 		/*
8814 		 * Create mempool with maximum number of sessions,
8815 		 * to include device specific session private data
8816 		 */
8817 		if (ts_params->session_priv_mpool == NULL) {
8818 			ts_params->session_priv_mpool = rte_mempool_create(
8819 					"test_sess_mp_priv",
8820 					MAX_NB_SESSIONS,
8821 					session_size,
8822 					0, 0, NULL, NULL, NULL,
8823 					NULL, SOCKET_ID_ANY,
8824 					0);
8825 
8826 			TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
8827 					"session mempool allocation failed");
8828 		}
8829 
8830 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
8831 		ts_params->qp_conf.mp_session_private =
8832 				ts_params->session_priv_mpool;
8833 
8834 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8835 				(uint8_t)i);
8836 
8837 		TEST_ASSERT(ret == 0,
8838 			"Failed to attach device %u of pmd : %s", i,
8839 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8840 
8841 		aesni_ids[nb_devs_attached] = (uint8_t)i;
8842 
8843 		nb_devs_attached++;
8844 	}
8845 
8846 	return 0;
8847 }
8848 
8849 static int
8850 test_scheduler_detach_slave_op(void)
8851 {
8852 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8853 	uint8_t sched_id = ts_params->valid_devs[0];
8854 	uint32_t i;
8855 	int ret;
8856 
8857 	for (i = 0; i < 2; i++) {
8858 		ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8859 				aesni_ids[i]);
8860 		TEST_ASSERT(ret == 0,
8861 			"Failed to detach device %u", aesni_ids[i]);
8862 	}
8863 
8864 	return 0;
8865 }
8866 
8867 static int
8868 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8869 {
8870 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8871 	uint8_t sched_id = ts_params->valid_devs[0];
8872 	/* set mode */
8873 	return rte_cryptodev_scheduler_mode_set(sched_id,
8874 		scheduler_mode);
8875 }
8876 
8877 static int
8878 test_scheduler_mode_roundrobin_op(void)
8879 {
8880 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8881 			0, "Failed to set roundrobin mode");
8882 	return 0;
8883 
8884 }
8885 
8886 static int
8887 test_scheduler_mode_multicore_op(void)
8888 {
8889 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8890 			0, "Failed to set multicore mode");
8891 
8892 	return 0;
8893 }
8894 
8895 static int
8896 test_scheduler_mode_failover_op(void)
8897 {
8898 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8899 			0, "Failed to set failover mode");
8900 
8901 	return 0;
8902 }
8903 
8904 static int
8905 test_scheduler_mode_pkt_size_distr_op(void)
8906 {
8907 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8908 			0, "Failed to set pktsize mode");
8909 
8910 	return 0;
8911 }
8912 
8913 static struct unit_test_suite cryptodev_scheduler_testsuite  = {
8914 	.suite_name = "Crypto Device Scheduler Unit Test Suite",
8915 	.setup = testsuite_setup,
8916 	.teardown = testsuite_teardown,
8917 	.unit_test_cases = {
8918 		/* Multi Core */
8919 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8920 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8921 		TEST_CASE_ST(ut_setup, ut_teardown,
8922 					test_AES_chain_scheduler_all),
8923 		TEST_CASE_ST(ut_setup, ut_teardown,
8924 					test_AES_cipheronly_scheduler_all),
8925 		TEST_CASE_ST(ut_setup, ut_teardown,
8926 					test_authonly_scheduler_all),
8927 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8928 
8929 		/* Round Robin */
8930 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8931 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8932 		TEST_CASE_ST(ut_setup, ut_teardown,
8933 				test_AES_chain_scheduler_all),
8934 		TEST_CASE_ST(ut_setup, ut_teardown,
8935 				test_AES_cipheronly_scheduler_all),
8936 		TEST_CASE_ST(ut_setup, ut_teardown,
8937 				test_authonly_scheduler_all),
8938 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8939 
8940 		/* Fail over */
8941 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8942 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8943 		TEST_CASE_ST(ut_setup, ut_teardown,
8944 					test_AES_chain_scheduler_all),
8945 		TEST_CASE_ST(ut_setup, ut_teardown,
8946 					test_AES_cipheronly_scheduler_all),
8947 		TEST_CASE_ST(ut_setup, ut_teardown,
8948 					test_authonly_scheduler_all),
8949 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8950 
8951 		/* PKT SIZE */
8952 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8953 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8954 		TEST_CASE_ST(ut_setup, ut_teardown,
8955 					test_AES_chain_scheduler_all),
8956 		TEST_CASE_ST(ut_setup, ut_teardown,
8957 					test_AES_cipheronly_scheduler_all),
8958 		TEST_CASE_ST(ut_setup, ut_teardown,
8959 					test_authonly_scheduler_all),
8960 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8961 
8962 		TEST_CASES_END() /**< NULL terminate unit test array */
8963 	}
8964 };
8965 
8966 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8967 
8968 static struct unit_test_suite cryptodev_qat_testsuite  = {
8969 	.suite_name = "Crypto QAT Unit Test Suite",
8970 	.setup = testsuite_setup,
8971 	.teardown = testsuite_teardown,
8972 	.unit_test_cases = {
8973 		TEST_CASE_ST(ut_setup, ut_teardown,
8974 				test_device_configure_invalid_dev_id),
8975 		TEST_CASE_ST(ut_setup, ut_teardown,
8976 				test_device_configure_invalid_queue_pair_ids),
8977 		TEST_CASE_ST(ut_setup, ut_teardown,
8978 				test_queue_pair_descriptor_setup),
8979 		TEST_CASE_ST(ut_setup, ut_teardown,
8980 				test_multi_session),
8981 
8982 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8983 		TEST_CASE_ST(ut_setup, ut_teardown,
8984 						test_AES_cipheronly_qat_all),
8985 		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8986 		TEST_CASE_ST(ut_setup, ut_teardown,
8987 						test_3DES_cipheronly_qat_all),
8988 		TEST_CASE_ST(ut_setup, ut_teardown,
8989 						test_DES_cipheronly_qat_all),
8990 		TEST_CASE_ST(ut_setup, ut_teardown,
8991 						test_AES_docsis_qat_all),
8992 		TEST_CASE_ST(ut_setup, ut_teardown,
8993 						test_DES_docsis_qat_all),
8994 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8995 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8996 
8997 		/** AES CCM Authenticated Encryption 128 bits key */
8998 		TEST_CASE_ST(ut_setup, ut_teardown,
8999 			test_AES_CCM_authenticated_encryption_test_case_128_1),
9000 		TEST_CASE_ST(ut_setup, ut_teardown,
9001 			test_AES_CCM_authenticated_encryption_test_case_128_2),
9002 		TEST_CASE_ST(ut_setup, ut_teardown,
9003 			test_AES_CCM_authenticated_encryption_test_case_128_3),
9004 
9005 		/** AES CCM Authenticated Decryption 128 bits key*/
9006 		TEST_CASE_ST(ut_setup, ut_teardown,
9007 			test_AES_CCM_authenticated_decryption_test_case_128_1),
9008 		TEST_CASE_ST(ut_setup, ut_teardown,
9009 			test_AES_CCM_authenticated_decryption_test_case_128_2),
9010 		TEST_CASE_ST(ut_setup, ut_teardown,
9011 			test_AES_CCM_authenticated_decryption_test_case_128_3),
9012 
9013 		/** AES GCM Authenticated Encryption */
9014 		TEST_CASE_ST(ut_setup, ut_teardown,
9015 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9016 		TEST_CASE_ST(ut_setup, ut_teardown,
9017 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9018 		TEST_CASE_ST(ut_setup, ut_teardown,
9019 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9020 		TEST_CASE_ST(ut_setup, ut_teardown,
9021 			test_AES_GCM_authenticated_encryption_test_case_1),
9022 		TEST_CASE_ST(ut_setup, ut_teardown,
9023 			test_AES_GCM_authenticated_encryption_test_case_2),
9024 		TEST_CASE_ST(ut_setup, ut_teardown,
9025 			test_AES_GCM_authenticated_encryption_test_case_3),
9026 		TEST_CASE_ST(ut_setup, ut_teardown,
9027 			test_AES_GCM_authenticated_encryption_test_case_4),
9028 		TEST_CASE_ST(ut_setup, ut_teardown,
9029 			test_AES_GCM_authenticated_encryption_test_case_5),
9030 		TEST_CASE_ST(ut_setup, ut_teardown,
9031 			test_AES_GCM_authenticated_encryption_test_case_6),
9032 		TEST_CASE_ST(ut_setup, ut_teardown,
9033 			test_AES_GCM_authenticated_encryption_test_case_7),
9034 
9035 		/** AES GCM Authenticated Decryption */
9036 		TEST_CASE_ST(ut_setup, ut_teardown,
9037 			test_AES_GCM_authenticated_decryption_test_case_1),
9038 		TEST_CASE_ST(ut_setup, ut_teardown,
9039 			test_AES_GCM_authenticated_decryption_test_case_2),
9040 		TEST_CASE_ST(ut_setup, ut_teardown,
9041 			test_AES_GCM_authenticated_decryption_test_case_3),
9042 		TEST_CASE_ST(ut_setup, ut_teardown,
9043 			test_AES_GCM_authenticated_decryption_test_case_4),
9044 		TEST_CASE_ST(ut_setup, ut_teardown,
9045 			test_AES_GCM_authenticated_decryption_test_case_5),
9046 		TEST_CASE_ST(ut_setup, ut_teardown,
9047 			test_AES_GCM_authenticated_decryption_test_case_6),
9048 		TEST_CASE_ST(ut_setup, ut_teardown,
9049 			test_AES_GCM_authenticated_decryption_test_case_7),
9050 
9051 		/** AES GCM Authenticated Encryption 192 bits key */
9052 		TEST_CASE_ST(ut_setup, ut_teardown,
9053 			test_AES_GCM_auth_encryption_test_case_192_1),
9054 		TEST_CASE_ST(ut_setup, ut_teardown,
9055 			test_AES_GCM_auth_encryption_test_case_192_2),
9056 		TEST_CASE_ST(ut_setup, ut_teardown,
9057 			test_AES_GCM_auth_encryption_test_case_192_3),
9058 		TEST_CASE_ST(ut_setup, ut_teardown,
9059 			test_AES_GCM_auth_encryption_test_case_192_4),
9060 		TEST_CASE_ST(ut_setup, ut_teardown,
9061 			test_AES_GCM_auth_encryption_test_case_192_5),
9062 		TEST_CASE_ST(ut_setup, ut_teardown,
9063 			test_AES_GCM_auth_encryption_test_case_192_6),
9064 		TEST_CASE_ST(ut_setup, ut_teardown,
9065 			test_AES_GCM_auth_encryption_test_case_192_7),
9066 
9067 		/** AES GCM Authenticated Decryption 192 bits key */
9068 		TEST_CASE_ST(ut_setup, ut_teardown,
9069 			test_AES_GCM_auth_decryption_test_case_192_1),
9070 		TEST_CASE_ST(ut_setup, ut_teardown,
9071 			test_AES_GCM_auth_decryption_test_case_192_2),
9072 		TEST_CASE_ST(ut_setup, ut_teardown,
9073 			test_AES_GCM_auth_decryption_test_case_192_3),
9074 		TEST_CASE_ST(ut_setup, ut_teardown,
9075 			test_AES_GCM_auth_decryption_test_case_192_4),
9076 		TEST_CASE_ST(ut_setup, ut_teardown,
9077 			test_AES_GCM_auth_decryption_test_case_192_5),
9078 		TEST_CASE_ST(ut_setup, ut_teardown,
9079 			test_AES_GCM_auth_decryption_test_case_192_6),
9080 		TEST_CASE_ST(ut_setup, ut_teardown,
9081 			test_AES_GCM_auth_decryption_test_case_192_7),
9082 
9083 		/** AES GCM Authenticated Encryption 256 bits key */
9084 		TEST_CASE_ST(ut_setup, ut_teardown,
9085 			test_AES_GCM_auth_encryption_test_case_256_1),
9086 		TEST_CASE_ST(ut_setup, ut_teardown,
9087 			test_AES_GCM_auth_encryption_test_case_256_2),
9088 		TEST_CASE_ST(ut_setup, ut_teardown,
9089 			test_AES_GCM_auth_encryption_test_case_256_3),
9090 		TEST_CASE_ST(ut_setup, ut_teardown,
9091 			test_AES_GCM_auth_encryption_test_case_256_4),
9092 		TEST_CASE_ST(ut_setup, ut_teardown,
9093 			test_AES_GCM_auth_encryption_test_case_256_5),
9094 		TEST_CASE_ST(ut_setup, ut_teardown,
9095 			test_AES_GCM_auth_encryption_test_case_256_6),
9096 		TEST_CASE_ST(ut_setup, ut_teardown,
9097 			test_AES_GCM_auth_encryption_test_case_256_7),
9098 
9099 		/** AES GMAC Authentication */
9100 		TEST_CASE_ST(ut_setup, ut_teardown,
9101 			test_AES_GMAC_authentication_test_case_1),
9102 		TEST_CASE_ST(ut_setup, ut_teardown,
9103 			test_AES_GMAC_authentication_verify_test_case_1),
9104 		TEST_CASE_ST(ut_setup, ut_teardown,
9105 			test_AES_GMAC_authentication_test_case_2),
9106 		TEST_CASE_ST(ut_setup, ut_teardown,
9107 			test_AES_GMAC_authentication_verify_test_case_2),
9108 		TEST_CASE_ST(ut_setup, ut_teardown,
9109 			test_AES_GMAC_authentication_test_case_3),
9110 		TEST_CASE_ST(ut_setup, ut_teardown,
9111 			test_AES_GMAC_authentication_verify_test_case_3),
9112 
9113 		/** SNOW 3G encrypt only (UEA2) */
9114 		TEST_CASE_ST(ut_setup, ut_teardown,
9115 			test_snow3g_encryption_test_case_1),
9116 		TEST_CASE_ST(ut_setup, ut_teardown,
9117 			test_snow3g_encryption_test_case_2),
9118 		TEST_CASE_ST(ut_setup, ut_teardown,
9119 			test_snow3g_encryption_test_case_3),
9120 		TEST_CASE_ST(ut_setup, ut_teardown,
9121 			test_snow3g_encryption_test_case_4),
9122 		TEST_CASE_ST(ut_setup, ut_teardown,
9123 			test_snow3g_encryption_test_case_5),
9124 
9125 		TEST_CASE_ST(ut_setup, ut_teardown,
9126 			test_snow3g_encryption_test_case_1_oop),
9127 		TEST_CASE_ST(ut_setup, ut_teardown,
9128 			test_snow3g_decryption_test_case_1_oop),
9129 
9130 		/** SNOW 3G decrypt only (UEA2) */
9131 		TEST_CASE_ST(ut_setup, ut_teardown,
9132 			test_snow3g_decryption_test_case_1),
9133 		TEST_CASE_ST(ut_setup, ut_teardown,
9134 			test_snow3g_decryption_test_case_2),
9135 		TEST_CASE_ST(ut_setup, ut_teardown,
9136 			test_snow3g_decryption_test_case_3),
9137 		TEST_CASE_ST(ut_setup, ut_teardown,
9138 			test_snow3g_decryption_test_case_4),
9139 		TEST_CASE_ST(ut_setup, ut_teardown,
9140 			test_snow3g_decryption_test_case_5),
9141 		TEST_CASE_ST(ut_setup, ut_teardown,
9142 			test_snow3g_hash_generate_test_case_1),
9143 		TEST_CASE_ST(ut_setup, ut_teardown,
9144 			test_snow3g_hash_generate_test_case_2),
9145 		TEST_CASE_ST(ut_setup, ut_teardown,
9146 			test_snow3g_hash_generate_test_case_3),
9147 		TEST_CASE_ST(ut_setup, ut_teardown,
9148 			test_snow3g_hash_verify_test_case_1),
9149 		TEST_CASE_ST(ut_setup, ut_teardown,
9150 			test_snow3g_hash_verify_test_case_2),
9151 		TEST_CASE_ST(ut_setup, ut_teardown,
9152 			test_snow3g_hash_verify_test_case_3),
9153 		TEST_CASE_ST(ut_setup, ut_teardown,
9154 			test_snow3g_cipher_auth_test_case_1),
9155 		TEST_CASE_ST(ut_setup, ut_teardown,
9156 			test_snow3g_auth_cipher_test_case_1),
9157 
9158 		/** ZUC encrypt only (EEA3) */
9159 		TEST_CASE_ST(ut_setup, ut_teardown,
9160 			test_zuc_encryption_test_case_1),
9161 		TEST_CASE_ST(ut_setup, ut_teardown,
9162 			test_zuc_encryption_test_case_2),
9163 		TEST_CASE_ST(ut_setup, ut_teardown,
9164 			test_zuc_encryption_test_case_3),
9165 		TEST_CASE_ST(ut_setup, ut_teardown,
9166 			test_zuc_encryption_test_case_4),
9167 		TEST_CASE_ST(ut_setup, ut_teardown,
9168 			test_zuc_encryption_test_case_5),
9169 
9170 		/** ZUC authenticate (EIA3) */
9171 		TEST_CASE_ST(ut_setup, ut_teardown,
9172 			test_zuc_hash_generate_test_case_6),
9173 		TEST_CASE_ST(ut_setup, ut_teardown,
9174 			test_zuc_hash_generate_test_case_7),
9175 		TEST_CASE_ST(ut_setup, ut_teardown,
9176 			test_zuc_hash_generate_test_case_8),
9177 
9178 		/** ZUC alg-chain (EEA3/EIA3) */
9179 		TEST_CASE_ST(ut_setup, ut_teardown,
9180 			test_zuc_cipher_auth_test_case_1),
9181 		TEST_CASE_ST(ut_setup, ut_teardown,
9182 			test_zuc_cipher_auth_test_case_2),
9183 
9184 		/** HMAC_MD5 Authentication */
9185 		TEST_CASE_ST(ut_setup, ut_teardown,
9186 			test_MD5_HMAC_generate_case_1),
9187 		TEST_CASE_ST(ut_setup, ut_teardown,
9188 			test_MD5_HMAC_verify_case_1),
9189 		TEST_CASE_ST(ut_setup, ut_teardown,
9190 			test_MD5_HMAC_generate_case_2),
9191 		TEST_CASE_ST(ut_setup, ut_teardown,
9192 			test_MD5_HMAC_verify_case_2),
9193 
9194 		/** NULL tests */
9195 		TEST_CASE_ST(ut_setup, ut_teardown,
9196 			test_null_auth_only_operation),
9197 		TEST_CASE_ST(ut_setup, ut_teardown,
9198 			test_null_cipher_only_operation),
9199 		TEST_CASE_ST(ut_setup, ut_teardown,
9200 			test_null_cipher_auth_operation),
9201 		TEST_CASE_ST(ut_setup, ut_teardown,
9202 			test_null_auth_cipher_operation),
9203 
9204 		/** KASUMI tests */
9205 		TEST_CASE_ST(ut_setup, ut_teardown,
9206 			test_kasumi_hash_generate_test_case_1),
9207 		TEST_CASE_ST(ut_setup, ut_teardown,
9208 			test_kasumi_hash_generate_test_case_2),
9209 		TEST_CASE_ST(ut_setup, ut_teardown,
9210 			test_kasumi_hash_generate_test_case_3),
9211 		TEST_CASE_ST(ut_setup, ut_teardown,
9212 			test_kasumi_hash_generate_test_case_4),
9213 		TEST_CASE_ST(ut_setup, ut_teardown,
9214 			test_kasumi_hash_generate_test_case_5),
9215 		TEST_CASE_ST(ut_setup, ut_teardown,
9216 			test_kasumi_hash_generate_test_case_6),
9217 
9218 		TEST_CASE_ST(ut_setup, ut_teardown,
9219 			test_kasumi_hash_verify_test_case_1),
9220 		TEST_CASE_ST(ut_setup, ut_teardown,
9221 			test_kasumi_hash_verify_test_case_2),
9222 		TEST_CASE_ST(ut_setup, ut_teardown,
9223 			test_kasumi_hash_verify_test_case_3),
9224 		TEST_CASE_ST(ut_setup, ut_teardown,
9225 			test_kasumi_hash_verify_test_case_4),
9226 		TEST_CASE_ST(ut_setup, ut_teardown,
9227 			test_kasumi_hash_verify_test_case_5),
9228 
9229 		TEST_CASE_ST(ut_setup, ut_teardown,
9230 			test_kasumi_encryption_test_case_1),
9231 		TEST_CASE_ST(ut_setup, ut_teardown,
9232 			test_kasumi_encryption_test_case_3),
9233 		TEST_CASE_ST(ut_setup, ut_teardown,
9234 			test_kasumi_auth_cipher_test_case_1),
9235 		TEST_CASE_ST(ut_setup, ut_teardown,
9236 			test_kasumi_cipher_auth_test_case_1),
9237 
9238 		/** Negative tests */
9239 		TEST_CASE_ST(ut_setup, ut_teardown,
9240 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
9241 		TEST_CASE_ST(ut_setup, ut_teardown,
9242 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9243 		TEST_CASE_ST(ut_setup, ut_teardown,
9244 			authentication_verify_AES128_GMAC_fail_data_corrupt),
9245 		TEST_CASE_ST(ut_setup, ut_teardown,
9246 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
9247 		TEST_CASE_ST(ut_setup, ut_teardown,
9248 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9249 		TEST_CASE_ST(ut_setup, ut_teardown,
9250 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9251 
9252 		TEST_CASES_END() /**< NULL terminate unit test array */
9253 	}
9254 };
9255 
9256 static struct unit_test_suite cryptodev_virtio_testsuite = {
9257 	.suite_name = "Crypto VIRTIO Unit Test Suite",
9258 	.setup = testsuite_setup,
9259 	.teardown = testsuite_teardown,
9260 	.unit_test_cases = {
9261 		TEST_CASE_ST(ut_setup, ut_teardown,
9262 				test_AES_cipheronly_virtio_all),
9263 
9264 		TEST_CASES_END() /**< NULL terminate unit test array */
9265 	}
9266 };
9267 
9268 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
9269 	.suite_name = "Crypto Device AESNI MB Unit Test Suite",
9270 	.setup = testsuite_setup,
9271 	.teardown = testsuite_teardown,
9272 	.unit_test_cases = {
9273 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9274 		TEST_CASE_ST(ut_setup, ut_teardown,
9275 			test_AES_GCM_authenticated_encryption_test_case_1),
9276 		TEST_CASE_ST(ut_setup, ut_teardown,
9277 			test_AES_GCM_authenticated_encryption_test_case_2),
9278 		TEST_CASE_ST(ut_setup, ut_teardown,
9279 			test_AES_GCM_authenticated_encryption_test_case_3),
9280 		TEST_CASE_ST(ut_setup, ut_teardown,
9281 			test_AES_GCM_authenticated_encryption_test_case_4),
9282 		TEST_CASE_ST(ut_setup, ut_teardown,
9283 			test_AES_GCM_authenticated_encryption_test_case_5),
9284 		TEST_CASE_ST(ut_setup, ut_teardown,
9285 			test_AES_GCM_authenticated_encryption_test_case_6),
9286 		TEST_CASE_ST(ut_setup, ut_teardown,
9287 			test_AES_GCM_authenticated_encryption_test_case_7),
9288 
9289 		/** AES GCM Authenticated Decryption */
9290 		TEST_CASE_ST(ut_setup, ut_teardown,
9291 			test_AES_GCM_authenticated_decryption_test_case_1),
9292 		TEST_CASE_ST(ut_setup, ut_teardown,
9293 			test_AES_GCM_authenticated_decryption_test_case_2),
9294 		TEST_CASE_ST(ut_setup, ut_teardown,
9295 			test_AES_GCM_authenticated_decryption_test_case_3),
9296 		TEST_CASE_ST(ut_setup, ut_teardown,
9297 			test_AES_GCM_authenticated_decryption_test_case_4),
9298 		TEST_CASE_ST(ut_setup, ut_teardown,
9299 			test_AES_GCM_authenticated_decryption_test_case_5),
9300 		TEST_CASE_ST(ut_setup, ut_teardown,
9301 			test_AES_GCM_authenticated_decryption_test_case_6),
9302 		TEST_CASE_ST(ut_setup, ut_teardown,
9303 			test_AES_GCM_authenticated_decryption_test_case_7),
9304 
9305 		/** AES GCM Authenticated Encryption 192 bits key */
9306 		TEST_CASE_ST(ut_setup, ut_teardown,
9307 			test_AES_GCM_auth_encryption_test_case_192_1),
9308 		TEST_CASE_ST(ut_setup, ut_teardown,
9309 			test_AES_GCM_auth_encryption_test_case_192_2),
9310 		TEST_CASE_ST(ut_setup, ut_teardown,
9311 			test_AES_GCM_auth_encryption_test_case_192_3),
9312 		TEST_CASE_ST(ut_setup, ut_teardown,
9313 			test_AES_GCM_auth_encryption_test_case_192_4),
9314 		TEST_CASE_ST(ut_setup, ut_teardown,
9315 			test_AES_GCM_auth_encryption_test_case_192_5),
9316 		TEST_CASE_ST(ut_setup, ut_teardown,
9317 			test_AES_GCM_auth_encryption_test_case_192_6),
9318 		TEST_CASE_ST(ut_setup, ut_teardown,
9319 			test_AES_GCM_auth_encryption_test_case_192_7),
9320 
9321 		/** AES GCM Authenticated Decryption 192 bits key */
9322 		TEST_CASE_ST(ut_setup, ut_teardown,
9323 			test_AES_GCM_auth_decryption_test_case_192_1),
9324 		TEST_CASE_ST(ut_setup, ut_teardown,
9325 			test_AES_GCM_auth_decryption_test_case_192_2),
9326 		TEST_CASE_ST(ut_setup, ut_teardown,
9327 			test_AES_GCM_auth_decryption_test_case_192_3),
9328 		TEST_CASE_ST(ut_setup, ut_teardown,
9329 			test_AES_GCM_auth_decryption_test_case_192_4),
9330 		TEST_CASE_ST(ut_setup, ut_teardown,
9331 			test_AES_GCM_auth_decryption_test_case_192_5),
9332 		TEST_CASE_ST(ut_setup, ut_teardown,
9333 			test_AES_GCM_auth_decryption_test_case_192_6),
9334 		TEST_CASE_ST(ut_setup, ut_teardown,
9335 			test_AES_GCM_auth_decryption_test_case_192_7),
9336 
9337 		/** AES GCM Authenticated Encryption 256 bits key */
9338 		TEST_CASE_ST(ut_setup, ut_teardown,
9339 			test_AES_GCM_auth_encryption_test_case_256_1),
9340 		TEST_CASE_ST(ut_setup, ut_teardown,
9341 			test_AES_GCM_auth_encryption_test_case_256_2),
9342 		TEST_CASE_ST(ut_setup, ut_teardown,
9343 			test_AES_GCM_auth_encryption_test_case_256_3),
9344 		TEST_CASE_ST(ut_setup, ut_teardown,
9345 			test_AES_GCM_auth_encryption_test_case_256_4),
9346 		TEST_CASE_ST(ut_setup, ut_teardown,
9347 			test_AES_GCM_auth_encryption_test_case_256_5),
9348 		TEST_CASE_ST(ut_setup, ut_teardown,
9349 			test_AES_GCM_auth_encryption_test_case_256_6),
9350 		TEST_CASE_ST(ut_setup, ut_teardown,
9351 			test_AES_GCM_auth_encryption_test_case_256_7),
9352 
9353 		/** AES GCM Authenticated Decryption 256 bits key */
9354 		TEST_CASE_ST(ut_setup, ut_teardown,
9355 			test_AES_GCM_auth_decryption_test_case_256_1),
9356 		TEST_CASE_ST(ut_setup, ut_teardown,
9357 			test_AES_GCM_auth_decryption_test_case_256_2),
9358 		TEST_CASE_ST(ut_setup, ut_teardown,
9359 			test_AES_GCM_auth_decryption_test_case_256_3),
9360 		TEST_CASE_ST(ut_setup, ut_teardown,
9361 			test_AES_GCM_auth_decryption_test_case_256_4),
9362 		TEST_CASE_ST(ut_setup, ut_teardown,
9363 			test_AES_GCM_auth_decryption_test_case_256_5),
9364 		TEST_CASE_ST(ut_setup, ut_teardown,
9365 			test_AES_GCM_auth_decryption_test_case_256_6),
9366 		TEST_CASE_ST(ut_setup, ut_teardown,
9367 			test_AES_GCM_auth_decryption_test_case_256_7),
9368 
9369 		/** AES GCM Authenticated Encryption big aad size */
9370 		TEST_CASE_ST(ut_setup, ut_teardown,
9371 			test_AES_GCM_auth_encryption_test_case_aad_1),
9372 		TEST_CASE_ST(ut_setup, ut_teardown,
9373 			test_AES_GCM_auth_encryption_test_case_aad_2),
9374 
9375 		/** AES GCM Authenticated Decryption big aad size */
9376 		TEST_CASE_ST(ut_setup, ut_teardown,
9377 			test_AES_GCM_auth_decryption_test_case_aad_1),
9378 		TEST_CASE_ST(ut_setup, ut_teardown,
9379 			test_AES_GCM_auth_decryption_test_case_aad_2),
9380 
9381 		/** Session-less tests */
9382 		TEST_CASE_ST(ut_setup, ut_teardown,
9383 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9384 		TEST_CASE_ST(ut_setup, ut_teardown,
9385 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9386 
9387 		/** AES GMAC Authentication */
9388 		TEST_CASE_ST(ut_setup, ut_teardown,
9389 			test_AES_GMAC_authentication_test_case_1),
9390 		TEST_CASE_ST(ut_setup, ut_teardown,
9391 			test_AES_GMAC_authentication_verify_test_case_1),
9392 		TEST_CASE_ST(ut_setup, ut_teardown,
9393 			test_AES_GMAC_authentication_test_case_2),
9394 		TEST_CASE_ST(ut_setup, ut_teardown,
9395 			test_AES_GMAC_authentication_verify_test_case_2),
9396 		TEST_CASE_ST(ut_setup, ut_teardown,
9397 			test_AES_GMAC_authentication_test_case_3),
9398 		TEST_CASE_ST(ut_setup, ut_teardown,
9399 			test_AES_GMAC_authentication_verify_test_case_3),
9400 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
9401 
9402 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9403 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9404 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9405 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9406 		TEST_CASE_ST(ut_setup, ut_teardown,
9407 						test_DES_cipheronly_mb_all),
9408 		TEST_CASE_ST(ut_setup, ut_teardown,
9409 						test_DES_docsis_mb_all),
9410 		TEST_CASE_ST(ut_setup, ut_teardown,
9411 						test_3DES_cipheronly_mb_all),
9412 		TEST_CASE_ST(ut_setup, ut_teardown,
9413 			test_AES_CCM_authenticated_encryption_test_case_128_1),
9414 		TEST_CASE_ST(ut_setup, ut_teardown,
9415 			test_AES_CCM_authenticated_decryption_test_case_128_1),
9416 		TEST_CASE_ST(ut_setup, ut_teardown,
9417 			test_AES_CCM_authenticated_encryption_test_case_128_2),
9418 		TEST_CASE_ST(ut_setup, ut_teardown,
9419 			test_AES_CCM_authenticated_decryption_test_case_128_2),
9420 		TEST_CASE_ST(ut_setup, ut_teardown,
9421 			test_AES_CCM_authenticated_encryption_test_case_128_3),
9422 		TEST_CASE_ST(ut_setup, ut_teardown,
9423 			test_AES_CCM_authenticated_decryption_test_case_128_3),
9424 
9425 		TEST_CASES_END() /**< NULL terminate unit test array */
9426 	}
9427 };
9428 
9429 static struct unit_test_suite cryptodev_openssl_testsuite  = {
9430 	.suite_name = "Crypto Device OPENSSL Unit Test Suite",
9431 	.setup = testsuite_setup,
9432 	.teardown = testsuite_teardown,
9433 	.unit_test_cases = {
9434 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9435 		TEST_CASE_ST(ut_setup, ut_teardown,
9436 				test_multi_session_random_usage),
9437 		TEST_CASE_ST(ut_setup, ut_teardown,
9438 				test_AES_chain_openssl_all),
9439 		TEST_CASE_ST(ut_setup, ut_teardown,
9440 				test_AES_cipheronly_openssl_all),
9441 		TEST_CASE_ST(ut_setup, ut_teardown,
9442 				test_3DES_chain_openssl_all),
9443 		TEST_CASE_ST(ut_setup, ut_teardown,
9444 				test_3DES_cipheronly_openssl_all),
9445 		TEST_CASE_ST(ut_setup, ut_teardown,
9446 				test_DES_cipheronly_openssl_all),
9447 		TEST_CASE_ST(ut_setup, ut_teardown,
9448 				test_DES_docsis_openssl_all),
9449 		TEST_CASE_ST(ut_setup, ut_teardown,
9450 				test_authonly_openssl_all),
9451 
9452 		/** AES GCM Authenticated Encryption */
9453 		TEST_CASE_ST(ut_setup, ut_teardown,
9454 			test_AES_GCM_authenticated_encryption_test_case_1),
9455 		TEST_CASE_ST(ut_setup, ut_teardown,
9456 			test_AES_GCM_authenticated_encryption_test_case_2),
9457 		TEST_CASE_ST(ut_setup, ut_teardown,
9458 			test_AES_GCM_authenticated_encryption_test_case_3),
9459 		TEST_CASE_ST(ut_setup, ut_teardown,
9460 			test_AES_GCM_authenticated_encryption_test_case_4),
9461 		TEST_CASE_ST(ut_setup, ut_teardown,
9462 			test_AES_GCM_authenticated_encryption_test_case_5),
9463 		TEST_CASE_ST(ut_setup, ut_teardown,
9464 			test_AES_GCM_authenticated_encryption_test_case_6),
9465 		TEST_CASE_ST(ut_setup, ut_teardown,
9466 			test_AES_GCM_authenticated_encryption_test_case_7),
9467 
9468 		/** AES GCM Authenticated Decryption */
9469 		TEST_CASE_ST(ut_setup, ut_teardown,
9470 			test_AES_GCM_authenticated_decryption_test_case_1),
9471 		TEST_CASE_ST(ut_setup, ut_teardown,
9472 			test_AES_GCM_authenticated_decryption_test_case_2),
9473 		TEST_CASE_ST(ut_setup, ut_teardown,
9474 			test_AES_GCM_authenticated_decryption_test_case_3),
9475 		TEST_CASE_ST(ut_setup, ut_teardown,
9476 			test_AES_GCM_authenticated_decryption_test_case_4),
9477 		TEST_CASE_ST(ut_setup, ut_teardown,
9478 			test_AES_GCM_authenticated_decryption_test_case_5),
9479 		TEST_CASE_ST(ut_setup, ut_teardown,
9480 			test_AES_GCM_authenticated_decryption_test_case_6),
9481 		TEST_CASE_ST(ut_setup, ut_teardown,
9482 			test_AES_GCM_authenticated_decryption_test_case_7),
9483 
9484 
9485 		/** AES GCM Authenticated Encryption 192 bits key */
9486 		TEST_CASE_ST(ut_setup, ut_teardown,
9487 			test_AES_GCM_auth_encryption_test_case_192_1),
9488 		TEST_CASE_ST(ut_setup, ut_teardown,
9489 			test_AES_GCM_auth_encryption_test_case_192_2),
9490 		TEST_CASE_ST(ut_setup, ut_teardown,
9491 			test_AES_GCM_auth_encryption_test_case_192_3),
9492 		TEST_CASE_ST(ut_setup, ut_teardown,
9493 			test_AES_GCM_auth_encryption_test_case_192_4),
9494 		TEST_CASE_ST(ut_setup, ut_teardown,
9495 			test_AES_GCM_auth_encryption_test_case_192_5),
9496 		TEST_CASE_ST(ut_setup, ut_teardown,
9497 			test_AES_GCM_auth_encryption_test_case_192_6),
9498 		TEST_CASE_ST(ut_setup, ut_teardown,
9499 			test_AES_GCM_auth_encryption_test_case_192_7),
9500 
9501 		/** AES GCM Authenticated Decryption 192 bits key */
9502 		TEST_CASE_ST(ut_setup, ut_teardown,
9503 			test_AES_GCM_auth_decryption_test_case_192_1),
9504 		TEST_CASE_ST(ut_setup, ut_teardown,
9505 			test_AES_GCM_auth_decryption_test_case_192_2),
9506 		TEST_CASE_ST(ut_setup, ut_teardown,
9507 			test_AES_GCM_auth_decryption_test_case_192_3),
9508 		TEST_CASE_ST(ut_setup, ut_teardown,
9509 			test_AES_GCM_auth_decryption_test_case_192_4),
9510 		TEST_CASE_ST(ut_setup, ut_teardown,
9511 			test_AES_GCM_auth_decryption_test_case_192_5),
9512 		TEST_CASE_ST(ut_setup, ut_teardown,
9513 			test_AES_GCM_auth_decryption_test_case_192_6),
9514 		TEST_CASE_ST(ut_setup, ut_teardown,
9515 			test_AES_GCM_auth_decryption_test_case_192_7),
9516 
9517 		/** AES GCM Authenticated Encryption 256 bits key */
9518 		TEST_CASE_ST(ut_setup, ut_teardown,
9519 			test_AES_GCM_auth_encryption_test_case_256_1),
9520 		TEST_CASE_ST(ut_setup, ut_teardown,
9521 			test_AES_GCM_auth_encryption_test_case_256_2),
9522 		TEST_CASE_ST(ut_setup, ut_teardown,
9523 			test_AES_GCM_auth_encryption_test_case_256_3),
9524 		TEST_CASE_ST(ut_setup, ut_teardown,
9525 			test_AES_GCM_auth_encryption_test_case_256_4),
9526 		TEST_CASE_ST(ut_setup, ut_teardown,
9527 			test_AES_GCM_auth_encryption_test_case_256_5),
9528 		TEST_CASE_ST(ut_setup, ut_teardown,
9529 			test_AES_GCM_auth_encryption_test_case_256_6),
9530 		TEST_CASE_ST(ut_setup, ut_teardown,
9531 			test_AES_GCM_auth_encryption_test_case_256_7),
9532 
9533 		/** AES GCM Authenticated Decryption 256 bits key */
9534 		TEST_CASE_ST(ut_setup, ut_teardown,
9535 			test_AES_GCM_auth_decryption_test_case_256_1),
9536 		TEST_CASE_ST(ut_setup, ut_teardown,
9537 			test_AES_GCM_auth_decryption_test_case_256_2),
9538 		TEST_CASE_ST(ut_setup, ut_teardown,
9539 			test_AES_GCM_auth_decryption_test_case_256_3),
9540 		TEST_CASE_ST(ut_setup, ut_teardown,
9541 			test_AES_GCM_auth_decryption_test_case_256_4),
9542 		TEST_CASE_ST(ut_setup, ut_teardown,
9543 			test_AES_GCM_auth_decryption_test_case_256_5),
9544 		TEST_CASE_ST(ut_setup, ut_teardown,
9545 			test_AES_GCM_auth_decryption_test_case_256_6),
9546 		TEST_CASE_ST(ut_setup, ut_teardown,
9547 			test_AES_GCM_auth_decryption_test_case_256_7),
9548 
9549 		/** AES GMAC Authentication */
9550 		TEST_CASE_ST(ut_setup, ut_teardown,
9551 			test_AES_GMAC_authentication_test_case_1),
9552 		TEST_CASE_ST(ut_setup, ut_teardown,
9553 			test_AES_GMAC_authentication_verify_test_case_1),
9554 		TEST_CASE_ST(ut_setup, ut_teardown,
9555 			test_AES_GMAC_authentication_test_case_2),
9556 		TEST_CASE_ST(ut_setup, ut_teardown,
9557 			test_AES_GMAC_authentication_verify_test_case_2),
9558 		TEST_CASE_ST(ut_setup, ut_teardown,
9559 			test_AES_GMAC_authentication_test_case_3),
9560 		TEST_CASE_ST(ut_setup, ut_teardown,
9561 			test_AES_GMAC_authentication_verify_test_case_3),
9562 		TEST_CASE_ST(ut_setup, ut_teardown,
9563 			test_AES_GMAC_authentication_test_case_4),
9564 		TEST_CASE_ST(ut_setup, ut_teardown,
9565 			test_AES_GMAC_authentication_verify_test_case_4),
9566 
9567 		/** AES CCM Authenticated Encryption 128 bits key */
9568 		TEST_CASE_ST(ut_setup, ut_teardown,
9569 			test_AES_CCM_authenticated_encryption_test_case_128_1),
9570 		TEST_CASE_ST(ut_setup, ut_teardown,
9571 			test_AES_CCM_authenticated_encryption_test_case_128_2),
9572 		TEST_CASE_ST(ut_setup, ut_teardown,
9573 			test_AES_CCM_authenticated_encryption_test_case_128_3),
9574 
9575 		/** AES CCM Authenticated Decryption 128 bits key*/
9576 		TEST_CASE_ST(ut_setup, ut_teardown,
9577 			test_AES_CCM_authenticated_decryption_test_case_128_1),
9578 		TEST_CASE_ST(ut_setup, ut_teardown,
9579 			test_AES_CCM_authenticated_decryption_test_case_128_2),
9580 		TEST_CASE_ST(ut_setup, ut_teardown,
9581 			test_AES_CCM_authenticated_decryption_test_case_128_3),
9582 
9583 		/** AES CCM Authenticated Encryption 192 bits key */
9584 		TEST_CASE_ST(ut_setup, ut_teardown,
9585 			test_AES_CCM_authenticated_encryption_test_case_192_1),
9586 		TEST_CASE_ST(ut_setup, ut_teardown,
9587 			test_AES_CCM_authenticated_encryption_test_case_192_2),
9588 		TEST_CASE_ST(ut_setup, ut_teardown,
9589 			test_AES_CCM_authenticated_encryption_test_case_192_3),
9590 
9591 		/** AES CCM Authenticated Decryption 192 bits key*/
9592 		TEST_CASE_ST(ut_setup, ut_teardown,
9593 			test_AES_CCM_authenticated_decryption_test_case_192_1),
9594 		TEST_CASE_ST(ut_setup, ut_teardown,
9595 			test_AES_CCM_authenticated_decryption_test_case_192_2),
9596 		TEST_CASE_ST(ut_setup, ut_teardown,
9597 			test_AES_CCM_authenticated_decryption_test_case_192_3),
9598 
9599 		/** AES CCM Authenticated Encryption 256 bits key */
9600 		TEST_CASE_ST(ut_setup, ut_teardown,
9601 			test_AES_CCM_authenticated_encryption_test_case_256_1),
9602 		TEST_CASE_ST(ut_setup, ut_teardown,
9603 			test_AES_CCM_authenticated_encryption_test_case_256_2),
9604 		TEST_CASE_ST(ut_setup, ut_teardown,
9605 			test_AES_CCM_authenticated_encryption_test_case_256_3),
9606 
9607 		/** AES CCM Authenticated Decryption 256 bits key*/
9608 		TEST_CASE_ST(ut_setup, ut_teardown,
9609 			test_AES_CCM_authenticated_decryption_test_case_256_1),
9610 		TEST_CASE_ST(ut_setup, ut_teardown,
9611 			test_AES_CCM_authenticated_decryption_test_case_256_2),
9612 		TEST_CASE_ST(ut_setup, ut_teardown,
9613 			test_AES_CCM_authenticated_decryption_test_case_256_3),
9614 
9615 		/** Scatter-Gather */
9616 		TEST_CASE_ST(ut_setup, ut_teardown,
9617 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9618 
9619 		/** Negative tests */
9620 		TEST_CASE_ST(ut_setup, ut_teardown,
9621 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
9622 		TEST_CASE_ST(ut_setup, ut_teardown,
9623 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9624 		TEST_CASE_ST(ut_setup, ut_teardown,
9625 			authentication_verify_AES128_GMAC_fail_data_corrupt),
9626 		TEST_CASE_ST(ut_setup, ut_teardown,
9627 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
9628 		TEST_CASE_ST(ut_setup, ut_teardown,
9629 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9630 		TEST_CASE_ST(ut_setup, ut_teardown,
9631 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9632 
9633 		TEST_CASES_END() /**< NULL terminate unit test array */
9634 	}
9635 };
9636 
9637 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
9638 	.suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9639 	.setup = testsuite_setup,
9640 	.teardown = testsuite_teardown,
9641 	.unit_test_cases = {
9642 		/** AES GCM Authenticated Encryption */
9643 		TEST_CASE_ST(ut_setup, ut_teardown,
9644 			test_AES_GCM_authenticated_encryption_test_case_1),
9645 		TEST_CASE_ST(ut_setup, ut_teardown,
9646 			test_AES_GCM_authenticated_encryption_test_case_2),
9647 		TEST_CASE_ST(ut_setup, ut_teardown,
9648 			test_AES_GCM_authenticated_encryption_test_case_3),
9649 		TEST_CASE_ST(ut_setup, ut_teardown,
9650 			test_AES_GCM_authenticated_encryption_test_case_4),
9651 		TEST_CASE_ST(ut_setup, ut_teardown,
9652 			test_AES_GCM_authenticated_encryption_test_case_5),
9653 		TEST_CASE_ST(ut_setup, ut_teardown,
9654 			test_AES_GCM_authenticated_encryption_test_case_6),
9655 		TEST_CASE_ST(ut_setup, ut_teardown,
9656 			test_AES_GCM_authenticated_encryption_test_case_7),
9657 
9658 		/** AES GCM Authenticated Decryption */
9659 		TEST_CASE_ST(ut_setup, ut_teardown,
9660 			test_AES_GCM_authenticated_decryption_test_case_1),
9661 		TEST_CASE_ST(ut_setup, ut_teardown,
9662 			test_AES_GCM_authenticated_decryption_test_case_2),
9663 		TEST_CASE_ST(ut_setup, ut_teardown,
9664 			test_AES_GCM_authenticated_decryption_test_case_3),
9665 		TEST_CASE_ST(ut_setup, ut_teardown,
9666 			test_AES_GCM_authenticated_decryption_test_case_4),
9667 		TEST_CASE_ST(ut_setup, ut_teardown,
9668 			test_AES_GCM_authenticated_decryption_test_case_5),
9669 		TEST_CASE_ST(ut_setup, ut_teardown,
9670 			test_AES_GCM_authenticated_decryption_test_case_6),
9671 		TEST_CASE_ST(ut_setup, ut_teardown,
9672 			test_AES_GCM_authenticated_decryption_test_case_7),
9673 
9674 		/** AES GCM Authenticated Encryption 192 bits key */
9675 		TEST_CASE_ST(ut_setup, ut_teardown,
9676 			test_AES_GCM_auth_encryption_test_case_192_1),
9677 		TEST_CASE_ST(ut_setup, ut_teardown,
9678 			test_AES_GCM_auth_encryption_test_case_192_2),
9679 		TEST_CASE_ST(ut_setup, ut_teardown,
9680 			test_AES_GCM_auth_encryption_test_case_192_3),
9681 		TEST_CASE_ST(ut_setup, ut_teardown,
9682 			test_AES_GCM_auth_encryption_test_case_192_4),
9683 		TEST_CASE_ST(ut_setup, ut_teardown,
9684 			test_AES_GCM_auth_encryption_test_case_192_5),
9685 		TEST_CASE_ST(ut_setup, ut_teardown,
9686 			test_AES_GCM_auth_encryption_test_case_192_6),
9687 		TEST_CASE_ST(ut_setup, ut_teardown,
9688 			test_AES_GCM_auth_encryption_test_case_192_7),
9689 
9690 		/** AES GCM Authenticated Decryption 192 bits key */
9691 		TEST_CASE_ST(ut_setup, ut_teardown,
9692 			test_AES_GCM_auth_decryption_test_case_192_1),
9693 		TEST_CASE_ST(ut_setup, ut_teardown,
9694 			test_AES_GCM_auth_decryption_test_case_192_2),
9695 		TEST_CASE_ST(ut_setup, ut_teardown,
9696 			test_AES_GCM_auth_decryption_test_case_192_3),
9697 		TEST_CASE_ST(ut_setup, ut_teardown,
9698 			test_AES_GCM_auth_decryption_test_case_192_4),
9699 		TEST_CASE_ST(ut_setup, ut_teardown,
9700 			test_AES_GCM_auth_decryption_test_case_192_5),
9701 		TEST_CASE_ST(ut_setup, ut_teardown,
9702 			test_AES_GCM_auth_decryption_test_case_192_6),
9703 		TEST_CASE_ST(ut_setup, ut_teardown,
9704 			test_AES_GCM_auth_decryption_test_case_192_7),
9705 
9706 		/** AES GCM Authenticated Encryption 256 bits key */
9707 		TEST_CASE_ST(ut_setup, ut_teardown,
9708 			test_AES_GCM_auth_encryption_test_case_256_1),
9709 		TEST_CASE_ST(ut_setup, ut_teardown,
9710 			test_AES_GCM_auth_encryption_test_case_256_2),
9711 		TEST_CASE_ST(ut_setup, ut_teardown,
9712 			test_AES_GCM_auth_encryption_test_case_256_3),
9713 		TEST_CASE_ST(ut_setup, ut_teardown,
9714 			test_AES_GCM_auth_encryption_test_case_256_4),
9715 		TEST_CASE_ST(ut_setup, ut_teardown,
9716 			test_AES_GCM_auth_encryption_test_case_256_5),
9717 		TEST_CASE_ST(ut_setup, ut_teardown,
9718 			test_AES_GCM_auth_encryption_test_case_256_6),
9719 		TEST_CASE_ST(ut_setup, ut_teardown,
9720 			test_AES_GCM_auth_encryption_test_case_256_7),
9721 
9722 		/** AES GCM Authenticated Decryption 256 bits key */
9723 		TEST_CASE_ST(ut_setup, ut_teardown,
9724 			test_AES_GCM_auth_decryption_test_case_256_1),
9725 		TEST_CASE_ST(ut_setup, ut_teardown,
9726 			test_AES_GCM_auth_decryption_test_case_256_2),
9727 		TEST_CASE_ST(ut_setup, ut_teardown,
9728 			test_AES_GCM_auth_decryption_test_case_256_3),
9729 		TEST_CASE_ST(ut_setup, ut_teardown,
9730 			test_AES_GCM_auth_decryption_test_case_256_4),
9731 		TEST_CASE_ST(ut_setup, ut_teardown,
9732 			test_AES_GCM_auth_decryption_test_case_256_5),
9733 		TEST_CASE_ST(ut_setup, ut_teardown,
9734 			test_AES_GCM_auth_decryption_test_case_256_6),
9735 		TEST_CASE_ST(ut_setup, ut_teardown,
9736 			test_AES_GCM_auth_decryption_test_case_256_7),
9737 
9738 		/** AES GCM Authenticated Encryption big aad size */
9739 		TEST_CASE_ST(ut_setup, ut_teardown,
9740 			test_AES_GCM_auth_encryption_test_case_aad_1),
9741 		TEST_CASE_ST(ut_setup, ut_teardown,
9742 			test_AES_GCM_auth_encryption_test_case_aad_2),
9743 
9744 		/** AES GCM Authenticated Decryption big aad size */
9745 		TEST_CASE_ST(ut_setup, ut_teardown,
9746 			test_AES_GCM_auth_decryption_test_case_aad_1),
9747 		TEST_CASE_ST(ut_setup, ut_teardown,
9748 			test_AES_GCM_auth_decryption_test_case_aad_2),
9749 
9750 		/** AES GMAC Authentication */
9751 		TEST_CASE_ST(ut_setup, ut_teardown,
9752 			test_AES_GMAC_authentication_test_case_1),
9753 		TEST_CASE_ST(ut_setup, ut_teardown,
9754 			test_AES_GMAC_authentication_verify_test_case_1),
9755 		TEST_CASE_ST(ut_setup, ut_teardown,
9756 			test_AES_GMAC_authentication_test_case_3),
9757 		TEST_CASE_ST(ut_setup, ut_teardown,
9758 			test_AES_GMAC_authentication_verify_test_case_3),
9759 		TEST_CASE_ST(ut_setup, ut_teardown,
9760 			test_AES_GMAC_authentication_test_case_4),
9761 		TEST_CASE_ST(ut_setup, ut_teardown,
9762 			test_AES_GMAC_authentication_verify_test_case_4),
9763 
9764 		/** Negative tests */
9765 		TEST_CASE_ST(ut_setup, ut_teardown,
9766 			authentication_verify_AES128_GMAC_fail_data_corrupt),
9767 		TEST_CASE_ST(ut_setup, ut_teardown,
9768 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
9769 
9770 		/** Out of place tests */
9771 		TEST_CASE_ST(ut_setup, ut_teardown,
9772 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
9773 		TEST_CASE_ST(ut_setup, ut_teardown,
9774 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
9775 
9776 		/** Session-less tests */
9777 		TEST_CASE_ST(ut_setup, ut_teardown,
9778 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9779 		TEST_CASE_ST(ut_setup, ut_teardown,
9780 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9781 
9782 		/** Scatter-Gather */
9783 		TEST_CASE_ST(ut_setup, ut_teardown,
9784 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9785 
9786 		TEST_CASES_END() /**< NULL terminate unit test array */
9787 	}
9788 };
9789 
9790 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
9791 	.suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9792 	.setup = testsuite_setup,
9793 	.teardown = testsuite_teardown,
9794 	.unit_test_cases = {
9795 		/** KASUMI encrypt only (UEA1) */
9796 		TEST_CASE_ST(ut_setup, ut_teardown,
9797 			test_kasumi_encryption_test_case_1),
9798 		TEST_CASE_ST(ut_setup, ut_teardown,
9799 			test_kasumi_encryption_test_case_1_sgl),
9800 		TEST_CASE_ST(ut_setup, ut_teardown,
9801 			test_kasumi_encryption_test_case_2),
9802 		TEST_CASE_ST(ut_setup, ut_teardown,
9803 			test_kasumi_encryption_test_case_3),
9804 		TEST_CASE_ST(ut_setup, ut_teardown,
9805 			test_kasumi_encryption_test_case_4),
9806 		TEST_CASE_ST(ut_setup, ut_teardown,
9807 			test_kasumi_encryption_test_case_5),
9808 		/** KASUMI decrypt only (UEA1) */
9809 		TEST_CASE_ST(ut_setup, ut_teardown,
9810 			test_kasumi_decryption_test_case_1),
9811 		TEST_CASE_ST(ut_setup, ut_teardown,
9812 			test_kasumi_decryption_test_case_2),
9813 		TEST_CASE_ST(ut_setup, ut_teardown,
9814 			test_kasumi_decryption_test_case_3),
9815 		TEST_CASE_ST(ut_setup, ut_teardown,
9816 			test_kasumi_decryption_test_case_4),
9817 		TEST_CASE_ST(ut_setup, ut_teardown,
9818 			test_kasumi_decryption_test_case_5),
9819 
9820 		TEST_CASE_ST(ut_setup, ut_teardown,
9821 			test_kasumi_encryption_test_case_1_oop),
9822 		TEST_CASE_ST(ut_setup, ut_teardown,
9823 			test_kasumi_encryption_test_case_1_oop_sgl),
9824 
9825 
9826 		TEST_CASE_ST(ut_setup, ut_teardown,
9827 			test_kasumi_decryption_test_case_1_oop),
9828 
9829 		/** KASUMI hash only (UIA1) */
9830 		TEST_CASE_ST(ut_setup, ut_teardown,
9831 			test_kasumi_hash_generate_test_case_1),
9832 		TEST_CASE_ST(ut_setup, ut_teardown,
9833 			test_kasumi_hash_generate_test_case_2),
9834 		TEST_CASE_ST(ut_setup, ut_teardown,
9835 			test_kasumi_hash_generate_test_case_3),
9836 		TEST_CASE_ST(ut_setup, ut_teardown,
9837 			test_kasumi_hash_generate_test_case_4),
9838 		TEST_CASE_ST(ut_setup, ut_teardown,
9839 			test_kasumi_hash_generate_test_case_5),
9840 		TEST_CASE_ST(ut_setup, ut_teardown,
9841 			test_kasumi_hash_generate_test_case_6),
9842 		TEST_CASE_ST(ut_setup, ut_teardown,
9843 			test_kasumi_hash_verify_test_case_1),
9844 		TEST_CASE_ST(ut_setup, ut_teardown,
9845 			test_kasumi_hash_verify_test_case_2),
9846 		TEST_CASE_ST(ut_setup, ut_teardown,
9847 			test_kasumi_hash_verify_test_case_3),
9848 		TEST_CASE_ST(ut_setup, ut_teardown,
9849 			test_kasumi_hash_verify_test_case_4),
9850 		TEST_CASE_ST(ut_setup, ut_teardown,
9851 			test_kasumi_hash_verify_test_case_5),
9852 		TEST_CASE_ST(ut_setup, ut_teardown,
9853 			test_kasumi_auth_cipher_test_case_1),
9854 		TEST_CASE_ST(ut_setup, ut_teardown,
9855 			test_kasumi_cipher_auth_test_case_1),
9856 		TEST_CASES_END() /**< NULL terminate unit test array */
9857 	}
9858 };
9859 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
9860 	.suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9861 	.setup = testsuite_setup,
9862 	.teardown = testsuite_teardown,
9863 	.unit_test_cases = {
9864 		/** SNOW 3G encrypt only (UEA2) */
9865 		TEST_CASE_ST(ut_setup, ut_teardown,
9866 			test_snow3g_encryption_test_case_1),
9867 		TEST_CASE_ST(ut_setup, ut_teardown,
9868 			test_snow3g_encryption_test_case_2),
9869 		TEST_CASE_ST(ut_setup, ut_teardown,
9870 			test_snow3g_encryption_test_case_3),
9871 		TEST_CASE_ST(ut_setup, ut_teardown,
9872 			test_snow3g_encryption_test_case_4),
9873 		TEST_CASE_ST(ut_setup, ut_teardown,
9874 			test_snow3g_encryption_test_case_5),
9875 
9876 		TEST_CASE_ST(ut_setup, ut_teardown,
9877 			test_snow3g_encryption_test_case_1_oop),
9878 		TEST_CASE_ST(ut_setup, ut_teardown,
9879 				test_snow3g_encryption_test_case_1_oop_sgl),
9880 		TEST_CASE_ST(ut_setup, ut_teardown,
9881 			test_snow3g_decryption_test_case_1_oop),
9882 
9883 		TEST_CASE_ST(ut_setup, ut_teardown,
9884 			test_snow3g_encryption_test_case_1_offset_oop),
9885 
9886 		/** SNOW 3G decrypt only (UEA2) */
9887 		TEST_CASE_ST(ut_setup, ut_teardown,
9888 			test_snow3g_decryption_test_case_1),
9889 		TEST_CASE_ST(ut_setup, ut_teardown,
9890 			test_snow3g_decryption_test_case_2),
9891 		TEST_CASE_ST(ut_setup, ut_teardown,
9892 			test_snow3g_decryption_test_case_3),
9893 		TEST_CASE_ST(ut_setup, ut_teardown,
9894 			test_snow3g_decryption_test_case_4),
9895 		TEST_CASE_ST(ut_setup, ut_teardown,
9896 			test_snow3g_decryption_test_case_5),
9897 		TEST_CASE_ST(ut_setup, ut_teardown,
9898 			test_snow3g_hash_generate_test_case_1),
9899 		TEST_CASE_ST(ut_setup, ut_teardown,
9900 			test_snow3g_hash_generate_test_case_2),
9901 		TEST_CASE_ST(ut_setup, ut_teardown,
9902 			test_snow3g_hash_generate_test_case_3),
9903 		/* Tests with buffers which length is not byte-aligned */
9904 		TEST_CASE_ST(ut_setup, ut_teardown,
9905 			test_snow3g_hash_generate_test_case_4),
9906 		TEST_CASE_ST(ut_setup, ut_teardown,
9907 			test_snow3g_hash_generate_test_case_5),
9908 		TEST_CASE_ST(ut_setup, ut_teardown,
9909 			test_snow3g_hash_generate_test_case_6),
9910 		TEST_CASE_ST(ut_setup, ut_teardown,
9911 			test_snow3g_hash_verify_test_case_1),
9912 		TEST_CASE_ST(ut_setup, ut_teardown,
9913 			test_snow3g_hash_verify_test_case_2),
9914 		TEST_CASE_ST(ut_setup, ut_teardown,
9915 			test_snow3g_hash_verify_test_case_3),
9916 		/* Tests with buffers which length is not byte-aligned */
9917 		TEST_CASE_ST(ut_setup, ut_teardown,
9918 			test_snow3g_hash_verify_test_case_4),
9919 		TEST_CASE_ST(ut_setup, ut_teardown,
9920 			test_snow3g_hash_verify_test_case_5),
9921 		TEST_CASE_ST(ut_setup, ut_teardown,
9922 			test_snow3g_hash_verify_test_case_6),
9923 		TEST_CASE_ST(ut_setup, ut_teardown,
9924 			test_snow3g_cipher_auth_test_case_1),
9925 		TEST_CASE_ST(ut_setup, ut_teardown,
9926 			test_snow3g_auth_cipher_test_case_1),
9927 
9928 		TEST_CASES_END() /**< NULL terminate unit test array */
9929 	}
9930 };
9931 
9932 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
9933 	.suite_name = "Crypto Device SW ZUC Unit Test Suite",
9934 	.setup = testsuite_setup,
9935 	.teardown = testsuite_teardown,
9936 	.unit_test_cases = {
9937 		/** ZUC encrypt only (EEA3) */
9938 		TEST_CASE_ST(ut_setup, ut_teardown,
9939 			test_zuc_encryption_test_case_1),
9940 		TEST_CASE_ST(ut_setup, ut_teardown,
9941 			test_zuc_encryption_test_case_2),
9942 		TEST_CASE_ST(ut_setup, ut_teardown,
9943 			test_zuc_encryption_test_case_3),
9944 		TEST_CASE_ST(ut_setup, ut_teardown,
9945 			test_zuc_encryption_test_case_4),
9946 		TEST_CASE_ST(ut_setup, ut_teardown,
9947 			test_zuc_encryption_test_case_5),
9948 		TEST_CASE_ST(ut_setup, ut_teardown,
9949 			test_zuc_hash_generate_test_case_1),
9950 		TEST_CASE_ST(ut_setup, ut_teardown,
9951 			test_zuc_hash_generate_test_case_2),
9952 		TEST_CASE_ST(ut_setup, ut_teardown,
9953 			test_zuc_hash_generate_test_case_3),
9954 		TEST_CASE_ST(ut_setup, ut_teardown,
9955 			test_zuc_hash_generate_test_case_4),
9956 		TEST_CASE_ST(ut_setup, ut_teardown,
9957 			test_zuc_hash_generate_test_case_5),
9958 		TEST_CASE_ST(ut_setup, ut_teardown,
9959 			test_zuc_encryption_test_case_6_sgl),
9960 		TEST_CASES_END() /**< NULL terminate unit test array */
9961 	}
9962 };
9963 
9964 static struct unit_test_suite cryptodev_caam_jr_testsuite  = {
9965 	.suite_name = "Crypto CAAM JR Unit Test Suite",
9966 	.setup = testsuite_setup,
9967 	.teardown = testsuite_teardown,
9968 	.unit_test_cases = {
9969 		TEST_CASE_ST(ut_setup, ut_teardown,
9970 			     test_device_configure_invalid_dev_id),
9971 		TEST_CASE_ST(ut_setup, ut_teardown,
9972 			     test_multi_session),
9973 
9974 		TEST_CASE_ST(ut_setup, ut_teardown,
9975 			     test_AES_chain_caam_jr_all),
9976 		TEST_CASE_ST(ut_setup, ut_teardown,
9977 			     test_3DES_chain_caam_jr_all),
9978 		TEST_CASE_ST(ut_setup, ut_teardown,
9979 			     test_AES_cipheronly_caam_jr_all),
9980 		TEST_CASE_ST(ut_setup, ut_teardown,
9981 			     test_3DES_cipheronly_caam_jr_all),
9982 		TEST_CASE_ST(ut_setup, ut_teardown,
9983 			     test_authonly_caam_jr_all),
9984 
9985 		TEST_CASES_END() /**< NULL terminate unit test array */
9986 	}
9987 };
9988 
9989 static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
9990 	.suite_name = "Crypto DPAA_SEC Unit Test Suite",
9991 	.setup = testsuite_setup,
9992 	.teardown = testsuite_teardown,
9993 	.unit_test_cases = {
9994 		TEST_CASE_ST(ut_setup, ut_teardown,
9995 			     test_device_configure_invalid_dev_id),
9996 		TEST_CASE_ST(ut_setup, ut_teardown,
9997 			     test_multi_session),
9998 
9999 		TEST_CASE_ST(ut_setup, ut_teardown,
10000 			     test_AES_chain_dpaa_sec_all),
10001 		TEST_CASE_ST(ut_setup, ut_teardown,
10002 			     test_3DES_chain_dpaa_sec_all),
10003 		TEST_CASE_ST(ut_setup, ut_teardown,
10004 			     test_AES_cipheronly_dpaa_sec_all),
10005 		TEST_CASE_ST(ut_setup, ut_teardown,
10006 			     test_3DES_cipheronly_dpaa_sec_all),
10007 		TEST_CASE_ST(ut_setup, ut_teardown,
10008 			     test_authonly_dpaa_sec_all),
10009 
10010 		/** AES GCM Authenticated Encryption */
10011 		TEST_CASE_ST(ut_setup, ut_teardown,
10012 			test_AES_GCM_authenticated_encryption_test_case_1),
10013 		TEST_CASE_ST(ut_setup, ut_teardown,
10014 			test_AES_GCM_authenticated_encryption_test_case_2),
10015 		TEST_CASE_ST(ut_setup, ut_teardown,
10016 			test_AES_GCM_authenticated_encryption_test_case_3),
10017 		TEST_CASE_ST(ut_setup, ut_teardown,
10018 			test_AES_GCM_authenticated_encryption_test_case_4),
10019 		TEST_CASE_ST(ut_setup, ut_teardown,
10020 			test_AES_GCM_authenticated_encryption_test_case_5),
10021 		TEST_CASE_ST(ut_setup, ut_teardown,
10022 			test_AES_GCM_authenticated_encryption_test_case_6),
10023 		TEST_CASE_ST(ut_setup, ut_teardown,
10024 			test_AES_GCM_authenticated_encryption_test_case_7),
10025 
10026 		/** AES GCM Authenticated Decryption */
10027 		TEST_CASE_ST(ut_setup, ut_teardown,
10028 			test_AES_GCM_authenticated_decryption_test_case_1),
10029 		TEST_CASE_ST(ut_setup, ut_teardown,
10030 			test_AES_GCM_authenticated_decryption_test_case_2),
10031 		TEST_CASE_ST(ut_setup, ut_teardown,
10032 			test_AES_GCM_authenticated_decryption_test_case_3),
10033 		TEST_CASE_ST(ut_setup, ut_teardown,
10034 			test_AES_GCM_authenticated_decryption_test_case_4),
10035 		TEST_CASE_ST(ut_setup, ut_teardown,
10036 			test_AES_GCM_authenticated_decryption_test_case_5),
10037 		TEST_CASE_ST(ut_setup, ut_teardown,
10038 			test_AES_GCM_authenticated_decryption_test_case_6),
10039 		TEST_CASE_ST(ut_setup, ut_teardown,
10040 			test_AES_GCM_authenticated_decryption_test_case_7),
10041 
10042 		/** AES GCM Authenticated Encryption 256 bits key */
10043 		TEST_CASE_ST(ut_setup, ut_teardown,
10044 			test_AES_GCM_auth_encryption_test_case_256_1),
10045 		TEST_CASE_ST(ut_setup, ut_teardown,
10046 			test_AES_GCM_auth_encryption_test_case_256_2),
10047 		TEST_CASE_ST(ut_setup, ut_teardown,
10048 			test_AES_GCM_auth_encryption_test_case_256_3),
10049 		TEST_CASE_ST(ut_setup, ut_teardown,
10050 			test_AES_GCM_auth_encryption_test_case_256_4),
10051 		TEST_CASE_ST(ut_setup, ut_teardown,
10052 			test_AES_GCM_auth_encryption_test_case_256_5),
10053 		TEST_CASE_ST(ut_setup, ut_teardown,
10054 			test_AES_GCM_auth_encryption_test_case_256_6),
10055 		TEST_CASE_ST(ut_setup, ut_teardown,
10056 			test_AES_GCM_auth_encryption_test_case_256_7),
10057 
10058 		/** AES GCM Authenticated Decryption 256 bits key */
10059 		TEST_CASE_ST(ut_setup, ut_teardown,
10060 			test_AES_GCM_auth_decryption_test_case_256_1),
10061 		TEST_CASE_ST(ut_setup, ut_teardown,
10062 			test_AES_GCM_auth_decryption_test_case_256_2),
10063 		TEST_CASE_ST(ut_setup, ut_teardown,
10064 			test_AES_GCM_auth_decryption_test_case_256_3),
10065 		TEST_CASE_ST(ut_setup, ut_teardown,
10066 			test_AES_GCM_auth_decryption_test_case_256_4),
10067 		TEST_CASE_ST(ut_setup, ut_teardown,
10068 			test_AES_GCM_auth_decryption_test_case_256_5),
10069 		TEST_CASE_ST(ut_setup, ut_teardown,
10070 			test_AES_GCM_auth_decryption_test_case_256_6),
10071 		TEST_CASE_ST(ut_setup, ut_teardown,
10072 			test_AES_GCM_auth_decryption_test_case_256_7),
10073 
10074 		/** Out of place tests */
10075 		TEST_CASE_ST(ut_setup, ut_teardown,
10076 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
10077 		TEST_CASE_ST(ut_setup, ut_teardown,
10078 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
10079 
10080 		/** Scatter-Gather */
10081 		TEST_CASE_ST(ut_setup, ut_teardown,
10082 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10083 		TEST_CASE_ST(ut_setup, ut_teardown,
10084 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10085 		TEST_CASE_ST(ut_setup, ut_teardown,
10086 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10087 		TEST_CASE_ST(ut_setup, ut_teardown,
10088 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10089 
10090 		TEST_CASES_END() /**< NULL terminate unit test array */
10091 	}
10092 };
10093 
10094 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
10095 	.suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10096 	.setup = testsuite_setup,
10097 	.teardown = testsuite_teardown,
10098 	.unit_test_cases = {
10099 		TEST_CASE_ST(ut_setup, ut_teardown,
10100 			test_device_configure_invalid_dev_id),
10101 		TEST_CASE_ST(ut_setup, ut_teardown,
10102 			test_multi_session),
10103 
10104 		TEST_CASE_ST(ut_setup, ut_teardown,
10105 			test_AES_chain_dpaa2_sec_all),
10106 		TEST_CASE_ST(ut_setup, ut_teardown,
10107 			test_3DES_chain_dpaa2_sec_all),
10108 		TEST_CASE_ST(ut_setup, ut_teardown,
10109 			test_AES_cipheronly_dpaa2_sec_all),
10110 		TEST_CASE_ST(ut_setup, ut_teardown,
10111 			test_3DES_cipheronly_dpaa2_sec_all),
10112 		TEST_CASE_ST(ut_setup, ut_teardown,
10113 			test_authonly_dpaa2_sec_all),
10114 
10115 		/** AES GCM Authenticated Encryption */
10116 		TEST_CASE_ST(ut_setup, ut_teardown,
10117 			test_AES_GCM_authenticated_encryption_test_case_1),
10118 		TEST_CASE_ST(ut_setup, ut_teardown,
10119 			test_AES_GCM_authenticated_encryption_test_case_2),
10120 		TEST_CASE_ST(ut_setup, ut_teardown,
10121 			test_AES_GCM_authenticated_encryption_test_case_3),
10122 		TEST_CASE_ST(ut_setup, ut_teardown,
10123 			test_AES_GCM_authenticated_encryption_test_case_4),
10124 		TEST_CASE_ST(ut_setup, ut_teardown,
10125 			test_AES_GCM_authenticated_encryption_test_case_5),
10126 		TEST_CASE_ST(ut_setup, ut_teardown,
10127 			test_AES_GCM_authenticated_encryption_test_case_6),
10128 		TEST_CASE_ST(ut_setup, ut_teardown,
10129 			test_AES_GCM_authenticated_encryption_test_case_7),
10130 
10131 		/** AES GCM Authenticated Decryption */
10132 		TEST_CASE_ST(ut_setup, ut_teardown,
10133 			test_AES_GCM_authenticated_decryption_test_case_1),
10134 		TEST_CASE_ST(ut_setup, ut_teardown,
10135 			test_AES_GCM_authenticated_decryption_test_case_2),
10136 		TEST_CASE_ST(ut_setup, ut_teardown,
10137 			test_AES_GCM_authenticated_decryption_test_case_3),
10138 		TEST_CASE_ST(ut_setup, ut_teardown,
10139 			test_AES_GCM_authenticated_decryption_test_case_4),
10140 		TEST_CASE_ST(ut_setup, ut_teardown,
10141 			test_AES_GCM_authenticated_decryption_test_case_5),
10142 		TEST_CASE_ST(ut_setup, ut_teardown,
10143 			test_AES_GCM_authenticated_decryption_test_case_6),
10144 		TEST_CASE_ST(ut_setup, ut_teardown,
10145 			test_AES_GCM_authenticated_decryption_test_case_7),
10146 
10147 		/** AES GCM Authenticated Encryption 192 bits key */
10148 		TEST_CASE_ST(ut_setup, ut_teardown,
10149 			test_AES_GCM_auth_encryption_test_case_192_1),
10150 		TEST_CASE_ST(ut_setup, ut_teardown,
10151 			test_AES_GCM_auth_encryption_test_case_192_2),
10152 		TEST_CASE_ST(ut_setup, ut_teardown,
10153 			test_AES_GCM_auth_encryption_test_case_192_3),
10154 		TEST_CASE_ST(ut_setup, ut_teardown,
10155 			test_AES_GCM_auth_encryption_test_case_192_4),
10156 		TEST_CASE_ST(ut_setup, ut_teardown,
10157 			test_AES_GCM_auth_encryption_test_case_192_5),
10158 		TEST_CASE_ST(ut_setup, ut_teardown,
10159 			test_AES_GCM_auth_encryption_test_case_192_6),
10160 		TEST_CASE_ST(ut_setup, ut_teardown,
10161 			test_AES_GCM_auth_encryption_test_case_192_7),
10162 
10163 		/** AES GCM Authenticated Decryption 192 bits key */
10164 		TEST_CASE_ST(ut_setup, ut_teardown,
10165 			test_AES_GCM_auth_decryption_test_case_192_1),
10166 		TEST_CASE_ST(ut_setup, ut_teardown,
10167 			test_AES_GCM_auth_decryption_test_case_192_2),
10168 		TEST_CASE_ST(ut_setup, ut_teardown,
10169 			test_AES_GCM_auth_decryption_test_case_192_3),
10170 		TEST_CASE_ST(ut_setup, ut_teardown,
10171 			test_AES_GCM_auth_decryption_test_case_192_4),
10172 		TEST_CASE_ST(ut_setup, ut_teardown,
10173 			test_AES_GCM_auth_decryption_test_case_192_5),
10174 		TEST_CASE_ST(ut_setup, ut_teardown,
10175 			test_AES_GCM_auth_decryption_test_case_192_6),
10176 		TEST_CASE_ST(ut_setup, ut_teardown,
10177 			test_AES_GCM_auth_decryption_test_case_192_7),
10178 
10179 		/** AES GCM Authenticated Encryption 256 bits key */
10180 		TEST_CASE_ST(ut_setup, ut_teardown,
10181 			test_AES_GCM_auth_encryption_test_case_256_1),
10182 		TEST_CASE_ST(ut_setup, ut_teardown,
10183 			test_AES_GCM_auth_encryption_test_case_256_2),
10184 		TEST_CASE_ST(ut_setup, ut_teardown,
10185 			test_AES_GCM_auth_encryption_test_case_256_3),
10186 		TEST_CASE_ST(ut_setup, ut_teardown,
10187 			test_AES_GCM_auth_encryption_test_case_256_4),
10188 		TEST_CASE_ST(ut_setup, ut_teardown,
10189 			test_AES_GCM_auth_encryption_test_case_256_5),
10190 		TEST_CASE_ST(ut_setup, ut_teardown,
10191 			test_AES_GCM_auth_encryption_test_case_256_6),
10192 		TEST_CASE_ST(ut_setup, ut_teardown,
10193 			test_AES_GCM_auth_encryption_test_case_256_7),
10194 
10195 		/** AES GCM Authenticated Decryption 256 bits key */
10196 		TEST_CASE_ST(ut_setup, ut_teardown,
10197 			test_AES_GCM_auth_decryption_test_case_256_1),
10198 		TEST_CASE_ST(ut_setup, ut_teardown,
10199 			test_AES_GCM_auth_decryption_test_case_256_2),
10200 		TEST_CASE_ST(ut_setup, ut_teardown,
10201 			test_AES_GCM_auth_decryption_test_case_256_3),
10202 		TEST_CASE_ST(ut_setup, ut_teardown,
10203 			test_AES_GCM_auth_decryption_test_case_256_4),
10204 		TEST_CASE_ST(ut_setup, ut_teardown,
10205 			test_AES_GCM_auth_decryption_test_case_256_5),
10206 		TEST_CASE_ST(ut_setup, ut_teardown,
10207 			test_AES_GCM_auth_decryption_test_case_256_6),
10208 		TEST_CASE_ST(ut_setup, ut_teardown,
10209 			test_AES_GCM_auth_decryption_test_case_256_7),
10210 
10211 		/** Out of place tests */
10212 		TEST_CASE_ST(ut_setup, ut_teardown,
10213 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
10214 		TEST_CASE_ST(ut_setup, ut_teardown,
10215 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
10216 
10217 		/** Scatter-Gather */
10218 		TEST_CASE_ST(ut_setup, ut_teardown,
10219 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10220 		TEST_CASE_ST(ut_setup, ut_teardown,
10221 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10222 		TEST_CASE_ST(ut_setup, ut_teardown,
10223 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10224 		TEST_CASE_ST(ut_setup, ut_teardown,
10225 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10226 
10227 		TEST_CASES_END() /**< NULL terminate unit test array */
10228 	}
10229 };
10230 
10231 static struct unit_test_suite cryptodev_null_testsuite  = {
10232 	.suite_name = "Crypto Device NULL Unit Test Suite",
10233 	.setup = testsuite_setup,
10234 	.teardown = testsuite_teardown,
10235 	.unit_test_cases = {
10236 		TEST_CASE_ST(ut_setup, ut_teardown,
10237 			test_null_auth_only_operation),
10238 		TEST_CASE_ST(ut_setup, ut_teardown,
10239 			test_null_cipher_only_operation),
10240 		TEST_CASE_ST(ut_setup, ut_teardown,
10241 			test_null_cipher_auth_operation),
10242 		TEST_CASE_ST(ut_setup, ut_teardown,
10243 			test_null_auth_cipher_operation),
10244 		TEST_CASE_ST(ut_setup, ut_teardown,
10245 			test_null_invalid_operation),
10246 		TEST_CASE_ST(ut_setup, ut_teardown,
10247 			test_null_burst_operation),
10248 
10249 		TEST_CASES_END() /**< NULL terminate unit test array */
10250 	}
10251 };
10252 
10253 static struct unit_test_suite cryptodev_armv8_testsuite  = {
10254 	.suite_name = "Crypto Device ARMv8 Unit Test Suite",
10255 	.setup = testsuite_setup,
10256 	.teardown = testsuite_teardown,
10257 	.unit_test_cases = {
10258 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10259 
10260 		/** Negative tests */
10261 		TEST_CASE_ST(ut_setup, ut_teardown,
10262 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10263 		TEST_CASE_ST(ut_setup, ut_teardown,
10264 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10265 
10266 		TEST_CASES_END() /**< NULL terminate unit test array */
10267 	}
10268 };
10269 
10270 static struct unit_test_suite cryptodev_mrvl_testsuite  = {
10271 	.suite_name = "Crypto Device Marvell Component Test Suite",
10272 	.setup = testsuite_setup,
10273 	.teardown = testsuite_teardown,
10274 	.unit_test_cases = {
10275 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10276 		TEST_CASE_ST(ut_setup, ut_teardown,
10277 				test_multi_session_random_usage),
10278 		TEST_CASE_ST(ut_setup, ut_teardown,
10279 				test_AES_chain_mrvl_all),
10280 		TEST_CASE_ST(ut_setup, ut_teardown,
10281 				test_AES_cipheronly_mrvl_all),
10282 		TEST_CASE_ST(ut_setup, ut_teardown,
10283 				test_authonly_mrvl_all),
10284 		TEST_CASE_ST(ut_setup, ut_teardown,
10285 				test_3DES_chain_mrvl_all),
10286 		TEST_CASE_ST(ut_setup, ut_teardown,
10287 				test_3DES_cipheronly_mrvl_all),
10288 
10289 		/** Negative tests */
10290 		TEST_CASE_ST(ut_setup, ut_teardown,
10291 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
10292 		TEST_CASE_ST(ut_setup, ut_teardown,
10293 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10294 		TEST_CASE_ST(ut_setup, ut_teardown,
10295 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10296 		TEST_CASE_ST(ut_setup, ut_teardown,
10297 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10298 
10299 		TEST_CASES_END() /**< NULL terminate unit test array */
10300 	}
10301 };
10302 
10303 static struct unit_test_suite cryptodev_ccp_testsuite  = {
10304 	.suite_name = "Crypto Device CCP Unit Test Suite",
10305 	.setup = testsuite_setup,
10306 	.teardown = testsuite_teardown,
10307 	.unit_test_cases = {
10308 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10309 		TEST_CASE_ST(ut_setup, ut_teardown,
10310 				test_multi_session_random_usage),
10311 		TEST_CASE_ST(ut_setup, ut_teardown,
10312 				test_AES_chain_ccp_all),
10313 		TEST_CASE_ST(ut_setup, ut_teardown,
10314 				test_AES_cipheronly_ccp_all),
10315 		TEST_CASE_ST(ut_setup, ut_teardown,
10316 				test_3DES_chain_ccp_all),
10317 		TEST_CASE_ST(ut_setup, ut_teardown,
10318 				test_3DES_cipheronly_ccp_all),
10319 		TEST_CASE_ST(ut_setup, ut_teardown,
10320 				test_authonly_ccp_all),
10321 
10322 		/** Negative tests */
10323 		TEST_CASE_ST(ut_setup, ut_teardown,
10324 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
10325 		TEST_CASE_ST(ut_setup, ut_teardown,
10326 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10327 		TEST_CASE_ST(ut_setup, ut_teardown,
10328 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10329 		TEST_CASE_ST(ut_setup, ut_teardown,
10330 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10331 
10332 		TEST_CASES_END() /**< NULL terminate unit test array */
10333 	}
10334 };
10335 
10336 static struct unit_test_suite cryptodev_octeontx_testsuite  = {
10337 	.suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10338 	.setup = testsuite_setup,
10339 	.teardown = testsuite_teardown,
10340 	.unit_test_cases = {
10341 		TEST_CASE_ST(ut_setup, ut_teardown,
10342 			test_AES_chain_octeontx_all),
10343 		TEST_CASE_ST(ut_setup, ut_teardown,
10344 			test_AES_cipheronly_octeontx_all),
10345 		TEST_CASE_ST(ut_setup, ut_teardown,
10346 			test_3DES_chain_octeontx_all),
10347 		TEST_CASE_ST(ut_setup, ut_teardown,
10348 			test_3DES_cipheronly_octeontx_all),
10349 		TEST_CASE_ST(ut_setup, ut_teardown,
10350 			test_authonly_octeontx_all),
10351 
10352 		/** AES GCM Authenticated Encryption */
10353 		TEST_CASE_ST(ut_setup, ut_teardown,
10354 			test_AES_GCM_authenticated_encryption_test_case_1),
10355 		TEST_CASE_ST(ut_setup, ut_teardown,
10356 			test_AES_GCM_authenticated_encryption_test_case_2),
10357 		TEST_CASE_ST(ut_setup, ut_teardown,
10358 			test_AES_GCM_authenticated_encryption_test_case_3),
10359 		TEST_CASE_ST(ut_setup, ut_teardown,
10360 			test_AES_GCM_authenticated_encryption_test_case_4),
10361 		TEST_CASE_ST(ut_setup, ut_teardown,
10362 			test_AES_GCM_authenticated_encryption_test_case_5),
10363 		TEST_CASE_ST(ut_setup, ut_teardown,
10364 			test_AES_GCM_authenticated_encryption_test_case_6),
10365 		TEST_CASE_ST(ut_setup, ut_teardown,
10366 			test_AES_GCM_authenticated_encryption_test_case_7),
10367 
10368 		/** AES GCM Authenticated Decryption */
10369 		TEST_CASE_ST(ut_setup, ut_teardown,
10370 			test_AES_GCM_authenticated_decryption_test_case_1),
10371 		TEST_CASE_ST(ut_setup, ut_teardown,
10372 			test_AES_GCM_authenticated_decryption_test_case_2),
10373 		TEST_CASE_ST(ut_setup, ut_teardown,
10374 			test_AES_GCM_authenticated_decryption_test_case_3),
10375 		TEST_CASE_ST(ut_setup, ut_teardown,
10376 			test_AES_GCM_authenticated_decryption_test_case_4),
10377 		TEST_CASE_ST(ut_setup, ut_teardown,
10378 			test_AES_GCM_authenticated_decryption_test_case_5),
10379 		TEST_CASE_ST(ut_setup, ut_teardown,
10380 			test_AES_GCM_authenticated_decryption_test_case_6),
10381 		TEST_CASE_ST(ut_setup, ut_teardown,
10382 			test_AES_GCM_authenticated_decryption_test_case_7),
10383 		/** AES GMAC Authentication */
10384 		TEST_CASE_ST(ut_setup, ut_teardown,
10385 			test_AES_GMAC_authentication_test_case_1),
10386 		TEST_CASE_ST(ut_setup, ut_teardown,
10387 			test_AES_GMAC_authentication_verify_test_case_1),
10388 		TEST_CASE_ST(ut_setup, ut_teardown,
10389 			test_AES_GMAC_authentication_test_case_2),
10390 		TEST_CASE_ST(ut_setup, ut_teardown,
10391 			test_AES_GMAC_authentication_verify_test_case_2),
10392 		TEST_CASE_ST(ut_setup, ut_teardown,
10393 			test_AES_GMAC_authentication_test_case_3),
10394 		TEST_CASE_ST(ut_setup, ut_teardown,
10395 			test_AES_GMAC_authentication_verify_test_case_3),
10396 
10397 		/** SNOW 3G encrypt only (UEA2) */
10398 		TEST_CASE_ST(ut_setup, ut_teardown,
10399 			test_snow3g_encryption_test_case_1),
10400 		TEST_CASE_ST(ut_setup, ut_teardown,
10401 			test_snow3g_encryption_test_case_2),
10402 		TEST_CASE_ST(ut_setup, ut_teardown,
10403 			test_snow3g_encryption_test_case_3),
10404 		TEST_CASE_ST(ut_setup, ut_teardown,
10405 			test_snow3g_encryption_test_case_4),
10406 		TEST_CASE_ST(ut_setup, ut_teardown,
10407 			test_snow3g_encryption_test_case_5),
10408 
10409 		TEST_CASE_ST(ut_setup, ut_teardown,
10410 			test_snow3g_encryption_test_case_1_oop),
10411 		TEST_CASE_ST(ut_setup, ut_teardown,
10412 			test_snow3g_decryption_test_case_1_oop),
10413 		TEST_CASE_ST(ut_setup, ut_teardown,
10414 			test_snow3g_encryption_test_case_1_oop_sgl),
10415 
10416 		/** SNOW 3G decrypt only (UEA2) */
10417 		TEST_CASE_ST(ut_setup, ut_teardown,
10418 			test_snow3g_decryption_test_case_1),
10419 		TEST_CASE_ST(ut_setup, ut_teardown,
10420 			test_snow3g_decryption_test_case_2),
10421 		TEST_CASE_ST(ut_setup, ut_teardown,
10422 			test_snow3g_decryption_test_case_3),
10423 		TEST_CASE_ST(ut_setup, ut_teardown,
10424 			test_snow3g_decryption_test_case_4),
10425 		TEST_CASE_ST(ut_setup, ut_teardown,
10426 			test_snow3g_decryption_test_case_5),
10427 
10428 		TEST_CASE_ST(ut_setup, ut_teardown,
10429 			test_snow3g_hash_generate_test_case_1),
10430 		TEST_CASE_ST(ut_setup, ut_teardown,
10431 			test_snow3g_hash_generate_test_case_2),
10432 		TEST_CASE_ST(ut_setup, ut_teardown,
10433 			test_snow3g_hash_generate_test_case_3),
10434 		TEST_CASE_ST(ut_setup, ut_teardown,
10435 			test_snow3g_hash_verify_test_case_1),
10436 		TEST_CASE_ST(ut_setup, ut_teardown,
10437 			test_snow3g_hash_verify_test_case_2),
10438 		TEST_CASE_ST(ut_setup, ut_teardown,
10439 			test_snow3g_hash_verify_test_case_3),
10440 
10441 		/** ZUC encrypt only (EEA3) */
10442 		TEST_CASE_ST(ut_setup, ut_teardown,
10443 			test_zuc_encryption_test_case_1),
10444 		TEST_CASE_ST(ut_setup, ut_teardown,
10445 			test_zuc_encryption_test_case_2),
10446 		TEST_CASE_ST(ut_setup, ut_teardown,
10447 			test_zuc_encryption_test_case_3),
10448 		TEST_CASE_ST(ut_setup, ut_teardown,
10449 			test_zuc_encryption_test_case_4),
10450 		TEST_CASE_ST(ut_setup, ut_teardown,
10451 			test_zuc_encryption_test_case_5),
10452 		TEST_CASE_ST(ut_setup, ut_teardown,
10453 			test_zuc_hash_generate_test_case_1),
10454 		TEST_CASE_ST(ut_setup, ut_teardown,
10455 			test_zuc_hash_generate_test_case_2),
10456 		TEST_CASE_ST(ut_setup, ut_teardown,
10457 			test_zuc_hash_generate_test_case_3),
10458 		TEST_CASE_ST(ut_setup, ut_teardown,
10459 			test_zuc_hash_generate_test_case_4),
10460 		TEST_CASE_ST(ut_setup, ut_teardown,
10461 			test_zuc_hash_generate_test_case_5),
10462 		TEST_CASE_ST(ut_setup, ut_teardown,
10463 			test_zuc_encryption_test_case_6_sgl),
10464 
10465 		/** KASUMI encrypt only (UEA1) */
10466 		TEST_CASE_ST(ut_setup, ut_teardown,
10467 			test_kasumi_encryption_test_case_1),
10468 		TEST_CASE_ST(ut_setup, ut_teardown,
10469 			test_kasumi_encryption_test_case_2),
10470 		TEST_CASE_ST(ut_setup, ut_teardown,
10471 			test_kasumi_encryption_test_case_3),
10472 		TEST_CASE_ST(ut_setup, ut_teardown,
10473 			test_kasumi_encryption_test_case_4),
10474 		TEST_CASE_ST(ut_setup, ut_teardown,
10475 			test_kasumi_encryption_test_case_5),
10476 		TEST_CASE_ST(ut_setup, ut_teardown,
10477 			test_kasumi_encryption_test_case_1_sgl),
10478 		TEST_CASE_ST(ut_setup, ut_teardown,
10479 			test_kasumi_encryption_test_case_1_oop_sgl),
10480 		/** KASUMI decrypt only (UEA1) */
10481 		TEST_CASE_ST(ut_setup, ut_teardown,
10482 			test_kasumi_decryption_test_case_1),
10483 		TEST_CASE_ST(ut_setup, ut_teardown,
10484 			test_kasumi_decryption_test_case_2),
10485 		TEST_CASE_ST(ut_setup, ut_teardown,
10486 			test_kasumi_decryption_test_case_3),
10487 		TEST_CASE_ST(ut_setup, ut_teardown,
10488 			test_kasumi_decryption_test_case_4),
10489 		TEST_CASE_ST(ut_setup, ut_teardown,
10490 			test_kasumi_decryption_test_case_5),
10491 
10492 		TEST_CASE_ST(ut_setup, ut_teardown,
10493 			test_kasumi_encryption_test_case_1_oop),
10494 		TEST_CASE_ST(ut_setup, ut_teardown,
10495 			test_kasumi_decryption_test_case_1_oop),
10496 
10497 		/** KASUMI hash only (UIA1) */
10498 		TEST_CASE_ST(ut_setup, ut_teardown,
10499 			test_kasumi_hash_generate_test_case_1),
10500 		TEST_CASE_ST(ut_setup, ut_teardown,
10501 			test_kasumi_hash_generate_test_case_2),
10502 		TEST_CASE_ST(ut_setup, ut_teardown,
10503 			test_kasumi_hash_generate_test_case_3),
10504 		TEST_CASE_ST(ut_setup, ut_teardown,
10505 			test_kasumi_hash_generate_test_case_4),
10506 		TEST_CASE_ST(ut_setup, ut_teardown,
10507 			test_kasumi_hash_generate_test_case_5),
10508 		TEST_CASE_ST(ut_setup, ut_teardown,
10509 			test_kasumi_hash_generate_test_case_6),
10510 		TEST_CASE_ST(ut_setup, ut_teardown,
10511 			test_kasumi_hash_verify_test_case_1),
10512 		TEST_CASE_ST(ut_setup, ut_teardown,
10513 			test_kasumi_hash_verify_test_case_2),
10514 		TEST_CASE_ST(ut_setup, ut_teardown,
10515 			test_kasumi_hash_verify_test_case_3),
10516 		TEST_CASE_ST(ut_setup, ut_teardown,
10517 			test_kasumi_hash_verify_test_case_4),
10518 		TEST_CASE_ST(ut_setup, ut_teardown,
10519 			test_kasumi_hash_verify_test_case_5),
10520 
10521 		/** NULL tests */
10522 		TEST_CASE_ST(ut_setup, ut_teardown,
10523 			test_null_cipher_only_operation),
10524 		TEST_CASE_ST(ut_setup, ut_teardown,
10525 			test_null_auth_only_operation),
10526 		TEST_CASE_ST(ut_setup, ut_teardown,
10527 			test_null_cipher_auth_operation),
10528 		TEST_CASE_ST(ut_setup, ut_teardown,
10529 			test_null_auth_cipher_operation),
10530 
10531 		/** Negative tests */
10532 		TEST_CASE_ST(ut_setup, ut_teardown,
10533 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
10534 		TEST_CASE_ST(ut_setup, ut_teardown,
10535 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10536 		TEST_CASE_ST(ut_setup, ut_teardown,
10537 			authentication_verify_AES128_GMAC_fail_data_corrupt),
10538 		TEST_CASE_ST(ut_setup, ut_teardown,
10539 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
10540 		TEST_CASE_ST(ut_setup, ut_teardown,
10541 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10542 		TEST_CASE_ST(ut_setup, ut_teardown,
10543 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10544 		TEST_CASES_END() /**< NULL terminate unit test array */
10545 	}
10546 };
10547 
10548 static int
10549 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10550 {
10551 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10552 			RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10553 
10554 	if (gbl_driver_id == -1) {
10555 		RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10556 		"CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10557 		"are enabled in config file to run this testsuite.\n");
10558 		return TEST_SKIPPED;
10559 	}
10560 
10561 	return unit_test_suite_runner(&cryptodev_qat_testsuite);
10562 }
10563 
10564 static int
10565 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10566 {
10567 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10568 			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10569 
10570 	if (gbl_driver_id == -1) {
10571 		RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10572 				"CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10573 				"in config file to run this testsuite.\n");
10574 		return TEST_FAILED;
10575 	}
10576 
10577 	return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10578 }
10579 
10580 static int
10581 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10582 {
10583 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10584 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10585 
10586 	if (gbl_driver_id == -1) {
10587 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10588 				"CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10589 				"in config file to run this testsuite.\n");
10590 		return TEST_SKIPPED;
10591 	}
10592 
10593 	return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10594 }
10595 
10596 static int
10597 test_cryptodev_openssl(void)
10598 {
10599 	gbl_driver_id = rte_cryptodev_driver_id_get(
10600 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10601 
10602 	if (gbl_driver_id == -1) {
10603 		RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10604 				"CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10605 				"in config file to run this testsuite.\n");
10606 		return TEST_SKIPPED;
10607 	}
10608 
10609 	return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10610 }
10611 
10612 static int
10613 test_cryptodev_aesni_gcm(void)
10614 {
10615 	gbl_driver_id = rte_cryptodev_driver_id_get(
10616 			RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10617 
10618 	if (gbl_driver_id == -1) {
10619 		RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10620 				"CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10621 				"in config file to run this testsuite.\n");
10622 		return TEST_SKIPPED;
10623 	}
10624 
10625 	return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10626 }
10627 
10628 static int
10629 test_cryptodev_null(void)
10630 {
10631 	gbl_driver_id = rte_cryptodev_driver_id_get(
10632 			RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10633 
10634 	if (gbl_driver_id == -1) {
10635 		RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10636 				"CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10637 				"in config file to run this testsuite.\n");
10638 		return TEST_SKIPPED;
10639 	}
10640 
10641 	return unit_test_suite_runner(&cryptodev_null_testsuite);
10642 }
10643 
10644 static int
10645 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10646 {
10647 	gbl_driver_id = rte_cryptodev_driver_id_get(
10648 			RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10649 
10650 	if (gbl_driver_id == -1) {
10651 		RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10652 				"CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10653 				"in config file to run this testsuite.\n");
10654 		return TEST_SKIPPED;
10655 	}
10656 
10657 	return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10658 }
10659 
10660 static int
10661 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10662 {
10663 	gbl_driver_id = rte_cryptodev_driver_id_get(
10664 			RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10665 
10666 	if (gbl_driver_id == -1) {
10667 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10668 				"CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10669 				"in config file to run this testsuite.\n");
10670 		return TEST_SKIPPED;
10671 	}
10672 
10673 	return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10674 }
10675 
10676 static int
10677 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10678 {
10679 	gbl_driver_id = rte_cryptodev_driver_id_get(
10680 			RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10681 
10682 	if (gbl_driver_id == -1) {
10683 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10684 				"CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10685 				"in config file to run this testsuite.\n");
10686 		return TEST_SKIPPED;
10687 	}
10688 
10689 	return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10690 }
10691 
10692 static int
10693 test_cryptodev_armv8(void)
10694 {
10695 	gbl_driver_id = rte_cryptodev_driver_id_get(
10696 			RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10697 
10698 	if (gbl_driver_id == -1) {
10699 		RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10700 				"CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10701 				"in config file to run this testsuite.\n");
10702 		return TEST_SKIPPED;
10703 	}
10704 
10705 	return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10706 }
10707 
10708 static int
10709 test_cryptodev_mrvl(void)
10710 {
10711 	gbl_driver_id = rte_cryptodev_driver_id_get(
10712 			RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10713 
10714 	if (gbl_driver_id == -1) {
10715 		RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10716 				"CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10717 				"in config file to run this testsuite.\n");
10718 		return TEST_SKIPPED;
10719 	}
10720 
10721 	return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10722 }
10723 
10724 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10725 
10726 static int
10727 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10728 {
10729 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10730 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10731 
10732 	if (gbl_driver_id == -1) {
10733 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10734 				"CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10735 				"in config file to run this testsuite.\n");
10736 		return TEST_SKIPPED;
10737 	}
10738 
10739 	if (rte_cryptodev_driver_id_get(
10740 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10741 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10742 			" enabled in config file to run this testsuite.\n");
10743 		return TEST_SKIPPED;
10744 }
10745 	return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10746 }
10747 
10748 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10749 
10750 #endif
10751 
10752 static int
10753 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10754 {
10755 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10756 			RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10757 
10758 	if (gbl_driver_id == -1) {
10759 		RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10760 				"CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10761 				"in config file to run this testsuite.\n");
10762 		return TEST_SKIPPED;
10763 	}
10764 
10765 	return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10766 }
10767 
10768 static int
10769 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10770 {
10771 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10772 			RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10773 
10774 	if (gbl_driver_id == -1) {
10775 		RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10776 				"CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10777 				"in config file to run this testsuite.\n");
10778 		return TEST_SKIPPED;
10779 	}
10780 
10781 	return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10782 }
10783 
10784 static int
10785 test_cryptodev_ccp(void)
10786 {
10787 	gbl_driver_id = rte_cryptodev_driver_id_get(
10788 			RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10789 
10790 	if (gbl_driver_id == -1) {
10791 		RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10792 				"CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10793 				"in config file to run this testsuite.\n");
10794 		return TEST_FAILED;
10795 	}
10796 
10797 	return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10798 }
10799 
10800 static int
10801 test_cryptodev_octeontx(void)
10802 {
10803 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10804 			RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10805 	if (gbl_driver_id == -1) {
10806 		RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10807 				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10808 				"enabled in config file to run this "
10809 				"testsuite.\n");
10810 		return TEST_FAILED;
10811 	}
10812 	return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10813 }
10814 
10815 static int
10816 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10817 {
10818 	gbl_driver_id =	rte_cryptodev_driver_id_get(
10819 			RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10820 
10821 	if (gbl_driver_id == -1) {
10822 		RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10823 				"CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10824 				"in config file to run this testsuite.\n");
10825 		return TEST_FAILED;
10826 	}
10827 
10828 	return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10829 }
10830 
10831 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10832 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10833 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10834 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10835 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10836 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10837 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10838 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10839 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10840 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10841 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10842 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10843 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10844 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10845 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10846 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
10847