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