xref: /dpdk/app/test/test_cryptodev.c (revision e4373bf1b3f51715bf66e87c0134e2c217e4612c)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2019 Intel Corporation
3  */
4 
5 #include <time.h>
6 
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
9 #include <rte_mbuf.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
14 
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
19 
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
23 #endif
24 
25 #include <rte_lcore.h>
26 
27 #include "test.h"
28 #include "test_cryptodev.h"
29 
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
45 #endif
46 
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
49 
50 #define IN_PLACE 0
51 #define OUT_OF_PLACE 1
52 
53 static int gbl_driver_id;
54 
55 struct crypto_testsuite_params {
56 	struct rte_mempool *mbuf_pool;
57 	struct rte_mempool *large_mbuf_pool;
58 	struct rte_mempool *op_mpool;
59 	struct rte_mempool *session_mpool;
60 	struct rte_mempool *session_priv_mpool;
61 	struct rte_cryptodev_config conf;
62 	struct rte_cryptodev_qp_conf qp_conf;
63 
64 	uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
65 	uint8_t valid_dev_count;
66 };
67 
68 struct crypto_unittest_params {
69 	struct rte_crypto_sym_xform cipher_xform;
70 	struct rte_crypto_sym_xform auth_xform;
71 	struct rte_crypto_sym_xform aead_xform;
72 
73 	union {
74 		struct rte_cryptodev_sym_session *sess;
75 #ifdef RTE_LIBRTE_SECURITY
76 		struct rte_security_session *sec_session;
77 #endif
78 	};
79 #ifdef RTE_LIBRTE_SECURITY
80 	enum rte_security_session_action_type type;
81 #endif
82 	struct rte_crypto_op *op;
83 
84 	struct rte_mbuf *obuf, *ibuf;
85 
86 	uint8_t *digest;
87 };
88 
89 #define ALIGN_POW2_ROUNDUP(num, align) \
90 	(((num) + (align) - 1) & ~((align) - 1))
91 
92 /*
93  * Forward declarations.
94  */
95 static int
96 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
97 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
98 		uint8_t *hmac_key);
99 
100 static int
101 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
102 		struct crypto_unittest_params *ut_params,
103 		struct crypto_testsuite_params *ts_param,
104 		const uint8_t *cipher,
105 		const uint8_t *digest,
106 		const uint8_t *iv);
107 
108 static struct rte_mbuf *
109 setup_test_string(struct rte_mempool *mpool,
110 		const char *string, size_t len, uint8_t blocksize)
111 {
112 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
113 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
114 
115 	memset(m->buf_addr, 0, m->buf_len);
116 	if (m) {
117 		char *dst = rte_pktmbuf_append(m, t_len);
118 
119 		if (!dst) {
120 			rte_pktmbuf_free(m);
121 			return NULL;
122 		}
123 		if (string != NULL)
124 			rte_memcpy(dst, string, t_len);
125 		else
126 			memset(dst, 0, t_len);
127 	}
128 
129 	return m;
130 }
131 
132 /* Get number of bytes in X bits (rounding up) */
133 static uint32_t
134 ceil_byte_length(uint32_t num_bits)
135 {
136 	if (num_bits % 8)
137 		return ((num_bits >> 3) + 1);
138 	else
139 		return (num_bits >> 3);
140 }
141 
142 static struct rte_crypto_op *
143 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
144 {
145 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
146 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
147 		return NULL;
148 	}
149 
150 	op = NULL;
151 
152 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
153 		rte_pause();
154 
155 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
156 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
157 		return NULL;
158 	}
159 
160 	return op;
161 }
162 
163 static struct crypto_testsuite_params testsuite_params = { NULL };
164 static struct crypto_unittest_params unittest_params;
165 
166 static int
167 testsuite_setup(void)
168 {
169 	struct crypto_testsuite_params *ts_params = &testsuite_params;
170 	struct rte_cryptodev_info info;
171 	uint32_t i = 0, nb_devs, dev_id;
172 	int ret;
173 	uint16_t qp_id;
174 
175 	memset(ts_params, 0, sizeof(*ts_params));
176 
177 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
178 	if (ts_params->mbuf_pool == NULL) {
179 		/* Not already created so create */
180 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
181 				"CRYPTO_MBUFPOOL",
182 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
183 				rte_socket_id());
184 		if (ts_params->mbuf_pool == NULL) {
185 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
186 			return TEST_FAILED;
187 		}
188 	}
189 
190 	ts_params->large_mbuf_pool = rte_mempool_lookup(
191 			"CRYPTO_LARGE_MBUFPOOL");
192 	if (ts_params->large_mbuf_pool == NULL) {
193 		/* Not already created so create */
194 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
195 				"CRYPTO_LARGE_MBUFPOOL",
196 				1, 0, 0, UINT16_MAX,
197 				rte_socket_id());
198 		if (ts_params->large_mbuf_pool == NULL) {
199 			RTE_LOG(ERR, USER1,
200 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
201 			return TEST_FAILED;
202 		}
203 	}
204 
205 	ts_params->op_mpool = rte_crypto_op_pool_create(
206 			"MBUF_CRYPTO_SYM_OP_POOL",
207 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
208 			NUM_MBUFS, MBUF_CACHE_SIZE,
209 			DEFAULT_NUM_XFORMS *
210 			sizeof(struct rte_crypto_sym_xform) +
211 			MAXIMUM_IV_LENGTH,
212 			rte_socket_id());
213 	if (ts_params->op_mpool == NULL) {
214 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
215 		return TEST_FAILED;
216 	}
217 
218 	/* Create an AESNI MB device if required */
219 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
220 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
221 		nb_devs = rte_cryptodev_device_count_by_driver(
222 				rte_cryptodev_driver_id_get(
223 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
224 		if (nb_devs < 1) {
225 			ret = rte_vdev_init(
226 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
227 
228 			TEST_ASSERT(ret == 0,
229 				"Failed to create instance of"
230 				" pmd : %s",
231 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
232 		}
233 	}
234 
235 	/* Create an AESNI GCM device if required */
236 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
237 			RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
238 		nb_devs = rte_cryptodev_device_count_by_driver(
239 				rte_cryptodev_driver_id_get(
240 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
241 		if (nb_devs < 1) {
242 			TEST_ASSERT_SUCCESS(rte_vdev_init(
243 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
244 				"Failed to create instance of"
245 				" pmd : %s",
246 				RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
247 		}
248 	}
249 
250 	/* Create a SNOW 3G device if required */
251 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
252 			RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
253 		nb_devs = rte_cryptodev_device_count_by_driver(
254 				rte_cryptodev_driver_id_get(
255 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
256 		if (nb_devs < 1) {
257 			TEST_ASSERT_SUCCESS(rte_vdev_init(
258 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
259 				"Failed to create instance of"
260 				" pmd : %s",
261 				RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
262 		}
263 	}
264 
265 	/* Create a KASUMI device if required */
266 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
267 			RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
268 		nb_devs = rte_cryptodev_device_count_by_driver(
269 				rte_cryptodev_driver_id_get(
270 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
271 		if (nb_devs < 1) {
272 			TEST_ASSERT_SUCCESS(rte_vdev_init(
273 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
274 				"Failed to create instance of"
275 				" pmd : %s",
276 				RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
277 		}
278 	}
279 
280 	/* Create a ZUC device if required */
281 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
282 			RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
283 		nb_devs = rte_cryptodev_device_count_by_driver(
284 				rte_cryptodev_driver_id_get(
285 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
286 		if (nb_devs < 1) {
287 			TEST_ASSERT_SUCCESS(rte_vdev_init(
288 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
289 				"Failed to create instance of"
290 				" pmd : %s",
291 				RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
292 		}
293 	}
294 
295 	/* Create a NULL device if required */
296 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
297 			RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
298 		nb_devs = rte_cryptodev_device_count_by_driver(
299 				rte_cryptodev_driver_id_get(
300 				RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
301 		if (nb_devs < 1) {
302 			ret = rte_vdev_init(
303 				RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
304 
305 			TEST_ASSERT(ret == 0,
306 				"Failed to create instance of"
307 				" pmd : %s",
308 				RTE_STR(CRYPTODEV_NAME_NULL_PMD));
309 		}
310 	}
311 
312 	/* Create an OPENSSL device if required */
313 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
314 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
315 		nb_devs = rte_cryptodev_device_count_by_driver(
316 				rte_cryptodev_driver_id_get(
317 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
318 		if (nb_devs < 1) {
319 			ret = rte_vdev_init(
320 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
321 				NULL);
322 
323 			TEST_ASSERT(ret == 0, "Failed to create "
324 				"instance of pmd : %s",
325 				RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
326 		}
327 	}
328 
329 	/* Create a ARMv8 device if required */
330 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
331 			RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
332 		nb_devs = rte_cryptodev_device_count_by_driver(
333 				rte_cryptodev_driver_id_get(
334 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
335 		if (nb_devs < 1) {
336 			ret = rte_vdev_init(
337 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
338 				NULL);
339 
340 			TEST_ASSERT(ret == 0, "Failed to create "
341 				"instance of pmd : %s",
342 				RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
343 		}
344 	}
345 
346 	/* Create a MVSAM device if required */
347 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
348 			RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
349 		nb_devs = rte_cryptodev_device_count_by_driver(
350 				rte_cryptodev_driver_id_get(
351 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
352 		if (nb_devs < 1) {
353 			ret = rte_vdev_init(
354 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
355 				NULL);
356 
357 			TEST_ASSERT(ret == 0, "Failed to create "
358 				"instance of pmd : %s",
359 				RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
360 		}
361 	}
362 
363 	/* Create an CCP device if required */
364 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 			RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
366 		nb_devs = rte_cryptodev_device_count_by_driver(
367 				rte_cryptodev_driver_id_get(
368 				RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
369 		if (nb_devs < 1) {
370 			ret = rte_vdev_init(
371 				RTE_STR(CRYPTODEV_NAME_CCP_PMD),
372 				NULL);
373 
374 			TEST_ASSERT(ret == 0, "Failed to create "
375 				"instance of pmd : %s",
376 				RTE_STR(CRYPTODEV_NAME_CCP_PMD));
377 		}
378 	}
379 
380 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
381 	char vdev_args[VDEV_ARGS_SIZE] = {""};
382 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
383 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
384 	uint16_t slave_core_count = 0;
385 	uint16_t socket_id = 0;
386 
387 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
388 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
389 
390 		/* Identify the Slave Cores
391 		 * Use 2 slave cores for the device args
392 		 */
393 		RTE_LCORE_FOREACH_SLAVE(i) {
394 			if (slave_core_count > 1)
395 				break;
396 			snprintf(vdev_args, sizeof(vdev_args),
397 					"%s%d", temp_str, i);
398 			strcpy(temp_str, vdev_args);
399 			strlcat(temp_str, ";", sizeof(temp_str));
400 			slave_core_count++;
401 			socket_id = rte_lcore_to_socket_id(i);
402 		}
403 		if (slave_core_count != 2) {
404 			RTE_LOG(ERR, USER1,
405 				"Cryptodev scheduler test require at least "
406 				"two slave cores to run. "
407 				"Please use the correct coremask.\n");
408 			return TEST_FAILED;
409 		}
410 		strcpy(temp_str, vdev_args);
411 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
412 				temp_str, socket_id);
413 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
414 		nb_devs = rte_cryptodev_device_count_by_driver(
415 				rte_cryptodev_driver_id_get(
416 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
417 		if (nb_devs < 1) {
418 			ret = rte_vdev_init(
419 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
420 					vdev_args);
421 			TEST_ASSERT(ret == 0,
422 				"Failed to create instance %u of"
423 				" pmd : %s",
424 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
425 		}
426 	}
427 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
428 
429 	nb_devs = rte_cryptodev_count();
430 	if (nb_devs < 1) {
431 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
432 		return TEST_SKIPPED;
433 	}
434 
435 	/* Create list of valid crypto devs */
436 	for (i = 0; i < nb_devs; i++) {
437 		rte_cryptodev_info_get(i, &info);
438 		if (info.driver_id == gbl_driver_id)
439 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
440 	}
441 
442 	if (ts_params->valid_dev_count < 1)
443 		return TEST_FAILED;
444 
445 	/* Set up all the qps on the first of the valid devices found */
446 
447 	dev_id = ts_params->valid_devs[0];
448 
449 	rte_cryptodev_info_get(dev_id, &info);
450 
451 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
452 	ts_params->conf.socket_id = SOCKET_ID_ANY;
453 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
454 
455 	unsigned int session_size =
456 		rte_cryptodev_sym_get_private_session_size(dev_id);
457 
458 	/*
459 	 * Create mempool with maximum number of sessions * 2,
460 	 * to include the session headers
461 	 */
462 	if (info.sym.max_nb_sessions != 0 &&
463 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
464 		RTE_LOG(ERR, USER1, "Device does not support "
465 				"at least %u sessions\n",
466 				MAX_NB_SESSIONS);
467 		return TEST_FAILED;
468 	}
469 
470 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
471 			"test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
472 			SOCKET_ID_ANY);
473 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
474 			"session mempool allocation failed");
475 
476 	ts_params->session_priv_mpool = rte_mempool_create(
477 			"test_sess_mp_priv",
478 			MAX_NB_SESSIONS,
479 			session_size,
480 			0, 0, NULL, NULL, NULL,
481 			NULL, SOCKET_ID_ANY,
482 			0);
483 	TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
484 			"session mempool allocation failed");
485 
486 
487 
488 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
489 			&ts_params->conf),
490 			"Failed to configure cryptodev %u with %u qps",
491 			dev_id, ts_params->conf.nb_queue_pairs);
492 
493 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
494 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
495 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
496 
497 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
498 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
499 			dev_id, qp_id, &ts_params->qp_conf,
500 			rte_cryptodev_socket_id(dev_id)),
501 			"Failed to setup queue pair %u on cryptodev %u",
502 			qp_id, dev_id);
503 	}
504 
505 	return TEST_SUCCESS;
506 }
507 
508 static void
509 testsuite_teardown(void)
510 {
511 	struct crypto_testsuite_params *ts_params = &testsuite_params;
512 
513 	if (ts_params->mbuf_pool != NULL) {
514 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
515 		rte_mempool_avail_count(ts_params->mbuf_pool));
516 	}
517 
518 	if (ts_params->op_mpool != NULL) {
519 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
520 		rte_mempool_avail_count(ts_params->op_mpool));
521 	}
522 
523 	/* Free session mempools */
524 	if (ts_params->session_priv_mpool != NULL) {
525 		rte_mempool_free(ts_params->session_priv_mpool);
526 		ts_params->session_priv_mpool = NULL;
527 	}
528 
529 	if (ts_params->session_mpool != NULL) {
530 		rte_mempool_free(ts_params->session_mpool);
531 		ts_params->session_mpool = NULL;
532 	}
533 }
534 
535 static int
536 ut_setup(void)
537 {
538 	struct crypto_testsuite_params *ts_params = &testsuite_params;
539 	struct crypto_unittest_params *ut_params = &unittest_params;
540 
541 	uint16_t qp_id;
542 
543 	/* Clear unit test parameters before running test */
544 	memset(ut_params, 0, sizeof(*ut_params));
545 
546 	/* Reconfigure device to default parameters */
547 	ts_params->conf.socket_id = SOCKET_ID_ANY;
548 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
549 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
550 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
551 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
552 
553 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
554 			&ts_params->conf),
555 			"Failed to configure cryptodev %u",
556 			ts_params->valid_devs[0]);
557 
558 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
559 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
560 			ts_params->valid_devs[0], qp_id,
561 			&ts_params->qp_conf,
562 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
563 			"Failed to setup queue pair %u on cryptodev %u",
564 			qp_id, ts_params->valid_devs[0]);
565 	}
566 
567 
568 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
569 
570 	/* Start the device */
571 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
572 			"Failed to start cryptodev %u",
573 			ts_params->valid_devs[0]);
574 
575 	return TEST_SUCCESS;
576 }
577 
578 static void
579 ut_teardown(void)
580 {
581 	struct crypto_testsuite_params *ts_params = &testsuite_params;
582 	struct crypto_unittest_params *ut_params = &unittest_params;
583 	struct rte_cryptodev_stats stats;
584 
585 	/* free crypto session structure */
586 #ifdef RTE_LIBRTE_SECURITY
587 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
588 		if (ut_params->sec_session) {
589 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
590 						(ts_params->valid_devs[0]),
591 						ut_params->sec_session);
592 			ut_params->sec_session = NULL;
593 		}
594 	} else
595 #endif
596 	{
597 		if (ut_params->sess) {
598 			rte_cryptodev_sym_session_clear(
599 					ts_params->valid_devs[0],
600 					ut_params->sess);
601 			rte_cryptodev_sym_session_free(ut_params->sess);
602 			ut_params->sess = NULL;
603 		}
604 	}
605 
606 	/* free crypto operation structure */
607 	if (ut_params->op)
608 		rte_crypto_op_free(ut_params->op);
609 
610 	/*
611 	 * free mbuf - both obuf and ibuf are usually the same,
612 	 * so check if they point at the same address is necessary,
613 	 * to avoid freeing the mbuf twice.
614 	 */
615 	if (ut_params->obuf) {
616 		rte_pktmbuf_free(ut_params->obuf);
617 		if (ut_params->ibuf == ut_params->obuf)
618 			ut_params->ibuf = 0;
619 		ut_params->obuf = 0;
620 	}
621 	if (ut_params->ibuf) {
622 		rte_pktmbuf_free(ut_params->ibuf);
623 		ut_params->ibuf = 0;
624 	}
625 
626 	if (ts_params->mbuf_pool != NULL)
627 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
628 			rte_mempool_avail_count(ts_params->mbuf_pool));
629 
630 	rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
631 
632 	/* Stop the device */
633 	rte_cryptodev_stop(ts_params->valid_devs[0]);
634 }
635 
636 static int
637 test_device_configure_invalid_dev_id(void)
638 {
639 	struct crypto_testsuite_params *ts_params = &testsuite_params;
640 	uint16_t dev_id, num_devs = 0;
641 
642 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
643 			"Need at least %d devices for test", 1);
644 
645 	/* valid dev_id values */
646 	dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
647 
648 	/* Stop the device in case it's started so it can be configured */
649 	rte_cryptodev_stop(dev_id);
650 
651 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
652 			"Failed test for rte_cryptodev_configure: "
653 			"invalid dev_num %u", dev_id);
654 
655 	/* invalid dev_id values */
656 	dev_id = num_devs;
657 
658 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
659 			"Failed test for rte_cryptodev_configure: "
660 			"invalid dev_num %u", dev_id);
661 
662 	dev_id = 0xff;
663 
664 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
665 			"Failed test for rte_cryptodev_configure:"
666 			"invalid dev_num %u", dev_id);
667 
668 	return TEST_SUCCESS;
669 }
670 
671 static int
672 test_device_configure_invalid_queue_pair_ids(void)
673 {
674 	struct crypto_testsuite_params *ts_params = &testsuite_params;
675 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
676 
677 	/* Stop the device in case it's started so it can be configured */
678 	rte_cryptodev_stop(ts_params->valid_devs[0]);
679 
680 	/* valid - one queue pairs */
681 	ts_params->conf.nb_queue_pairs = 1;
682 
683 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
684 			&ts_params->conf),
685 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
686 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
687 
688 
689 	/* valid - max value queue pairs */
690 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
691 
692 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
693 			&ts_params->conf),
694 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
695 			ts_params->valid_devs[0],
696 			ts_params->conf.nb_queue_pairs);
697 
698 
699 	/* invalid - zero queue pairs */
700 	ts_params->conf.nb_queue_pairs = 0;
701 
702 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
703 			&ts_params->conf),
704 			"Failed test for rte_cryptodev_configure, dev_id %u,"
705 			" invalid qps: %u",
706 			ts_params->valid_devs[0],
707 			ts_params->conf.nb_queue_pairs);
708 
709 
710 	/* invalid - max value supported by field queue pairs */
711 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
712 
713 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
714 			&ts_params->conf),
715 			"Failed test for rte_cryptodev_configure, dev_id %u,"
716 			" invalid qps: %u",
717 			ts_params->valid_devs[0],
718 			ts_params->conf.nb_queue_pairs);
719 
720 
721 	/* invalid - max value + 1 queue pairs */
722 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
723 
724 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
725 			&ts_params->conf),
726 			"Failed test for rte_cryptodev_configure, dev_id %u,"
727 			" invalid qps: %u",
728 			ts_params->valid_devs[0],
729 			ts_params->conf.nb_queue_pairs);
730 
731 	/* revert to original testsuite value */
732 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
733 
734 	return TEST_SUCCESS;
735 }
736 
737 static int
738 test_queue_pair_descriptor_setup(void)
739 {
740 	struct crypto_testsuite_params *ts_params = &testsuite_params;
741 	struct rte_cryptodev_info dev_info;
742 	struct rte_cryptodev_qp_conf qp_conf = {
743 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
744 	};
745 
746 	uint16_t qp_id;
747 
748 	/* Stop the device in case it's started so it can be configured */
749 	rte_cryptodev_stop(ts_params->valid_devs[0]);
750 
751 
752 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
753 
754 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
755 			&ts_params->conf),
756 			"Failed to configure cryptodev %u",
757 			ts_params->valid_devs[0]);
758 
759 	/*
760 	 * Test various ring sizes on this device. memzones can't be
761 	 * freed so are re-used if ring is released and re-created.
762 	 */
763 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
764 	qp_conf.mp_session = ts_params->session_mpool;
765 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
766 
767 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
768 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
769 				ts_params->valid_devs[0], qp_id, &qp_conf,
770 				rte_cryptodev_socket_id(
771 						ts_params->valid_devs[0])),
772 				"Failed test for "
773 				"rte_cryptodev_queue_pair_setup: num_inflights "
774 				"%u on qp %u on cryptodev %u",
775 				qp_conf.nb_descriptors, qp_id,
776 				ts_params->valid_devs[0]);
777 	}
778 
779 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
780 
781 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
782 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
783 				ts_params->valid_devs[0], qp_id, &qp_conf,
784 				rte_cryptodev_socket_id(
785 						ts_params->valid_devs[0])),
786 				"Failed test for"
787 				" rte_cryptodev_queue_pair_setup: num_inflights"
788 				" %u on qp %u on cryptodev %u",
789 				qp_conf.nb_descriptors, qp_id,
790 				ts_params->valid_devs[0]);
791 	}
792 
793 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
794 
795 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
796 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
797 				ts_params->valid_devs[0], qp_id, &qp_conf,
798 				rte_cryptodev_socket_id(
799 						ts_params->valid_devs[0])),
800 				"Failed test for "
801 				"rte_cryptodev_queue_pair_setup: num_inflights"
802 				" %u on qp %u on cryptodev %u",
803 				qp_conf.nb_descriptors, qp_id,
804 				ts_params->valid_devs[0]);
805 	}
806 
807 	/* invalid number of descriptors - max supported + 2 */
808 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
809 
810 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
811 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
812 				ts_params->valid_devs[0], qp_id, &qp_conf,
813 				rte_cryptodev_socket_id(
814 						ts_params->valid_devs[0])),
815 				"Unexpectedly passed test for "
816 				"rte_cryptodev_queue_pair_setup:"
817 				"num_inflights %u on qp %u on cryptodev %u",
818 				qp_conf.nb_descriptors, qp_id,
819 				ts_params->valid_devs[0]);
820 	}
821 
822 	/* invalid number of descriptors - max value of parameter */
823 	qp_conf.nb_descriptors = UINT32_MAX-1;
824 
825 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
826 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
827 				ts_params->valid_devs[0], qp_id, &qp_conf,
828 				rte_cryptodev_socket_id(
829 						ts_params->valid_devs[0])),
830 				"Unexpectedly passed test for "
831 				"rte_cryptodev_queue_pair_setup:"
832 				"num_inflights %u on qp %u on cryptodev %u",
833 				qp_conf.nb_descriptors, qp_id,
834 				ts_params->valid_devs[0]);
835 	}
836 
837 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
838 
839 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
840 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
841 				ts_params->valid_devs[0], qp_id, &qp_conf,
842 				rte_cryptodev_socket_id(
843 						ts_params->valid_devs[0])),
844 				"Failed test for"
845 				" rte_cryptodev_queue_pair_setup:"
846 				"num_inflights %u on qp %u on cryptodev %u",
847 				qp_conf.nb_descriptors, qp_id,
848 				ts_params->valid_devs[0]);
849 	}
850 
851 	/* invalid number of descriptors - max supported + 1 */
852 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
853 
854 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
855 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
856 				ts_params->valid_devs[0], qp_id, &qp_conf,
857 				rte_cryptodev_socket_id(
858 						ts_params->valid_devs[0])),
859 				"Unexpectedly passed test for "
860 				"rte_cryptodev_queue_pair_setup:"
861 				"num_inflights %u on qp %u on cryptodev %u",
862 				qp_conf.nb_descriptors, qp_id,
863 				ts_params->valid_devs[0]);
864 	}
865 
866 	/* test invalid queue pair id */
867 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
868 
869 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
870 
871 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
872 			ts_params->valid_devs[0],
873 			qp_id, &qp_conf,
874 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
875 			"Failed test for rte_cryptodev_queue_pair_setup:"
876 			"invalid qp %u on cryptodev %u",
877 			qp_id, ts_params->valid_devs[0]);
878 
879 	qp_id = 0xffff; /*invalid*/
880 
881 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
882 			ts_params->valid_devs[0],
883 			qp_id, &qp_conf,
884 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
885 			"Failed test for rte_cryptodev_queue_pair_setup:"
886 			"invalid qp %u on cryptodev %u",
887 			qp_id, ts_params->valid_devs[0]);
888 
889 	return TEST_SUCCESS;
890 }
891 
892 /* ***** Plaintext data for tests ***** */
893 
894 const char catch_22_quote_1[] =
895 		"There was only one catch and that was Catch-22, which "
896 		"specified that a concern for one's safety in the face of "
897 		"dangers that were real and immediate was the process of a "
898 		"rational mind. Orr was crazy and could be grounded. All he "
899 		"had to do was ask; and as soon as he did, he would no longer "
900 		"be crazy and would have to fly more missions. Orr would be "
901 		"crazy to fly more missions and sane if he didn't, but if he "
902 		"was sane he had to fly them. If he flew them he was crazy "
903 		"and didn't have to; but if he didn't want to he was sane and "
904 		"had to. Yossarian was moved very deeply by the absolute "
905 		"simplicity of this clause of Catch-22 and let out a "
906 		"respectful whistle. \"That's some catch, that Catch-22\", he "
907 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
908 
909 const char catch_22_quote[] =
910 		"What a lousy earth! He wondered how many people were "
911 		"destitute that same night even in his own prosperous country, "
912 		"how many homes were shanties, how many husbands were drunk "
913 		"and wives socked, and how many children were bullied, abused, "
914 		"or abandoned. How many families hungered for food they could "
915 		"not afford to buy? How many hearts were broken? How many "
916 		"suicides would take place that same night, how many people "
917 		"would go insane? How many cockroaches and landlords would "
918 		"triumph? How many winners were losers, successes failures, "
919 		"and rich men poor men? How many wise guys were stupid? How "
920 		"many happy endings were unhappy endings? How many honest men "
921 		"were liars, brave men cowards, loyal men traitors, how many "
922 		"sainted men were corrupt, how many people in positions of "
923 		"trust had sold their souls to bodyguards, how many had never "
924 		"had souls? How many straight-and-narrow paths were crooked "
925 		"paths? How many best families were worst families and how "
926 		"many good people were bad people? When you added them all up "
927 		"and then subtracted, you might be left with only the children, "
928 		"and perhaps with Albert Einstein and an old violinist or "
929 		"sculptor somewhere.";
930 
931 #define QUOTE_480_BYTES		(480)
932 #define QUOTE_512_BYTES		(512)
933 #define QUOTE_768_BYTES		(768)
934 #define QUOTE_1024_BYTES	(1024)
935 
936 
937 
938 /* ***** SHA1 Hash Tests ***** */
939 
940 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
941 
942 static uint8_t hmac_sha1_key[] = {
943 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
944 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
945 	0xDE, 0xF4, 0xDE, 0xAD };
946 
947 /* ***** SHA224 Hash Tests ***** */
948 
949 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
950 
951 
952 /* ***** AES-CBC Cipher Tests ***** */
953 
954 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
955 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
956 
957 static uint8_t aes_cbc_key[] = {
958 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
959 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
960 
961 static uint8_t aes_cbc_iv[] = {
962 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
963 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
964 
965 
966 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
967 
968 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
969 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
970 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
971 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
972 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
973 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
974 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
975 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
976 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
977 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
978 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
979 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
980 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
981 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
982 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
983 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
984 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
985 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
986 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
987 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
988 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
989 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
990 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
991 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
992 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
993 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
994 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
995 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
996 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
997 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
998 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
999 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1000 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1001 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1002 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1003 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1004 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1005 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1006 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1007 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1008 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1009 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1010 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1011 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1012 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1013 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1014 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1015 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1016 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1017 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1018 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1019 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1020 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1021 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1022 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1023 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1024 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1025 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1026 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1027 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1028 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1029 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1030 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1031 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1032 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1033 };
1034 
1035 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1036 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1037 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1038 	0x18, 0x8c, 0x1d, 0x32
1039 };
1040 
1041 
1042 /* Multisession Vector context Test */
1043 /*Begin Session 0 */
1044 static uint8_t ms_aes_cbc_key0[] = {
1045 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1046 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1047 };
1048 
1049 static uint8_t ms_aes_cbc_iv0[] = {
1050 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1052 };
1053 
1054 static const uint8_t ms_aes_cbc_cipher0[] = {
1055 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1056 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1057 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1058 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1059 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1060 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1061 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1062 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1063 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1064 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1065 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1066 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1067 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1068 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1069 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1070 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1071 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1072 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1073 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1074 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1075 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1076 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1077 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1078 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1079 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1080 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1081 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1082 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1083 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1084 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1085 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1086 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1087 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1088 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1089 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1090 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1091 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1092 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1093 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1094 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1095 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1096 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1097 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1098 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1099 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1100 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1101 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1102 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1103 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1104 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1105 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1106 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1107 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1108 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1109 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1110 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1111 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1112 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1113 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1114 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1115 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1116 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1117 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1118 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1119 };
1120 
1121 
1122 static  uint8_t ms_hmac_key0[] = {
1123 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1124 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1125 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1126 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1127 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1128 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1129 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1130 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1131 };
1132 
1133 static const uint8_t ms_hmac_digest0[] = {
1134 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1135 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1136 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1137 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1138 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1139 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1140 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1141 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1142 		};
1143 
1144 /* End Session 0 */
1145 /* Begin session 1 */
1146 
1147 static  uint8_t ms_aes_cbc_key1[] = {
1148 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1149 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1150 };
1151 
1152 static  uint8_t ms_aes_cbc_iv1[] = {
1153 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1154 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1155 };
1156 
1157 static const uint8_t ms_aes_cbc_cipher1[] = {
1158 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1159 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1160 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1161 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1162 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1163 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1164 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1165 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1166 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1167 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1168 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1169 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1170 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1171 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1172 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1173 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1174 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1175 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1176 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1177 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1178 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1179 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1180 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1181 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1182 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1183 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1184 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1185 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1186 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1187 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1188 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1189 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1190 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1191 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1192 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1193 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1194 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1195 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1196 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1197 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1198 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1199 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1200 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1201 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1202 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1203 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1204 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1205 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1206 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1207 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1208 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1209 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1210 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1211 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1212 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1213 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1214 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1215 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1216 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1217 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1218 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1219 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1220 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1221 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1222 
1223 };
1224 
1225 static uint8_t ms_hmac_key1[] = {
1226 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1234 };
1235 
1236 static const uint8_t ms_hmac_digest1[] = {
1237 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1238 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1239 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1240 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1241 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1242 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1243 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1244 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1245 };
1246 /* End Session 1  */
1247 /* Begin Session 2 */
1248 static  uint8_t ms_aes_cbc_key2[] = {
1249 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1250 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1251 };
1252 
1253 static  uint8_t ms_aes_cbc_iv2[] = {
1254 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1255 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1256 };
1257 
1258 static const uint8_t ms_aes_cbc_cipher2[] = {
1259 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1260 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1261 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1262 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1263 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1264 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1265 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1266 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1267 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1268 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1269 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1270 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1271 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1272 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1273 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1274 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1275 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1276 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1277 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1278 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1279 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1280 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1281 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1282 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1283 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1284 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1285 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1286 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1287 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1288 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1289 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1290 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1291 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1292 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1293 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1294 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1295 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1296 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1297 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1298 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1299 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1300 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1301 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1302 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1303 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1304 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1305 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1306 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1307 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1308 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1309 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1310 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1311 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1312 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1313 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1314 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1315 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1316 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1317 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1318 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1319 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1320 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1321 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1322 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1323 };
1324 
1325 static  uint8_t ms_hmac_key2[] = {
1326 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1327 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1328 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1329 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1330 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1331 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1332 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1333 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1334 };
1335 
1336 static const uint8_t ms_hmac_digest2[] = {
1337 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1338 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1339 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1340 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1341 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1342 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1343 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1344 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1345 };
1346 
1347 /* End Session 2 */
1348 
1349 
1350 static int
1351 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1352 {
1353 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1354 	struct crypto_unittest_params *ut_params = &unittest_params;
1355 
1356 	/* Generate test mbuf data and space for digest */
1357 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1358 			catch_22_quote,	QUOTE_512_BYTES, 0);
1359 
1360 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1361 			DIGEST_BYTE_LENGTH_SHA1);
1362 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1363 
1364 	/* Setup Cipher Parameters */
1365 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1366 	ut_params->cipher_xform.next = &ut_params->auth_xform;
1367 
1368 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1369 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1370 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1371 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1372 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1373 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1374 
1375 	/* Setup HMAC Parameters */
1376 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1377 
1378 	ut_params->auth_xform.next = NULL;
1379 
1380 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1381 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1382 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1383 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1384 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1385 
1386 	ut_params->sess = rte_cryptodev_sym_session_create(
1387 			ts_params->session_mpool);
1388 
1389 	/* Create crypto session*/
1390 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1391 			ut_params->sess, &ut_params->cipher_xform,
1392 			ts_params->session_priv_mpool);
1393 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1394 
1395 	/* Generate crypto op data structure */
1396 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1397 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1398 	TEST_ASSERT_NOT_NULL(ut_params->op,
1399 			"Failed to allocate symmetric crypto operation struct");
1400 
1401 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1402 
1403 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1404 
1405 	/* set crypto operation source mbuf */
1406 	sym_op->m_src = ut_params->ibuf;
1407 
1408 	/* Set crypto operation authentication parameters */
1409 	sym_op->auth.digest.data = ut_params->digest;
1410 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1411 			ut_params->ibuf, QUOTE_512_BYTES);
1412 
1413 	sym_op->auth.data.offset = 0;
1414 	sym_op->auth.data.length = QUOTE_512_BYTES;
1415 
1416 	/* Copy IV at the end of the crypto operation */
1417 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1418 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1419 
1420 	/* Set crypto operation cipher parameters */
1421 	sym_op->cipher.data.offset = 0;
1422 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1423 
1424 	/* Process crypto operation */
1425 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1426 			ut_params->op), "failed to process sym crypto op");
1427 
1428 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1429 			"crypto op processing failed");
1430 
1431 	/* Validate obuf */
1432 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1433 			uint8_t *);
1434 
1435 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1436 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1437 			QUOTE_512_BYTES,
1438 			"ciphertext data not as expected");
1439 
1440 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1441 
1442 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1443 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1444 			gbl_driver_id == rte_cryptodev_driver_id_get(
1445 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1446 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1447 					DIGEST_BYTE_LENGTH_SHA1,
1448 			"Generated digest data not as expected");
1449 
1450 	return TEST_SUCCESS;
1451 }
1452 
1453 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1454 
1455 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
1456 
1457 static uint8_t hmac_sha512_key[] = {
1458 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1459 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1460 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1461 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1462 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1463 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1464 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1465 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1466 
1467 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1468 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1469 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1470 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1471 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1472 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1473 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1474 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1475 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1476 
1477 
1478 
1479 static int
1480 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1481 		struct crypto_unittest_params *ut_params,
1482 		uint8_t *cipher_key,
1483 		uint8_t *hmac_key);
1484 
1485 static int
1486 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1487 		struct crypto_unittest_params *ut_params,
1488 		struct crypto_testsuite_params *ts_params,
1489 		const uint8_t *cipher,
1490 		const uint8_t *digest,
1491 		const uint8_t *iv);
1492 
1493 
1494 static int
1495 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1496 		struct crypto_unittest_params *ut_params,
1497 		uint8_t *cipher_key,
1498 		uint8_t *hmac_key)
1499 {
1500 
1501 	/* Setup Cipher Parameters */
1502 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1503 	ut_params->cipher_xform.next = NULL;
1504 
1505 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1506 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1507 	ut_params->cipher_xform.cipher.key.data = cipher_key;
1508 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1509 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1510 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1511 
1512 	/* Setup HMAC Parameters */
1513 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1514 	ut_params->auth_xform.next = &ut_params->cipher_xform;
1515 
1516 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1517 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1518 	ut_params->auth_xform.auth.key.data = hmac_key;
1519 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1520 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1521 
1522 	return TEST_SUCCESS;
1523 }
1524 
1525 
1526 static int
1527 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1528 		struct crypto_unittest_params *ut_params,
1529 		struct crypto_testsuite_params *ts_params,
1530 		const uint8_t *cipher,
1531 		const uint8_t *digest,
1532 		const uint8_t *iv)
1533 {
1534 	/* Generate test mbuf data and digest */
1535 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1536 			(const char *)
1537 			cipher,
1538 			QUOTE_512_BYTES, 0);
1539 
1540 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1541 			DIGEST_BYTE_LENGTH_SHA512);
1542 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1543 
1544 	rte_memcpy(ut_params->digest,
1545 			digest,
1546 			DIGEST_BYTE_LENGTH_SHA512);
1547 
1548 	/* Generate Crypto op data structure */
1549 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1550 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1551 	TEST_ASSERT_NOT_NULL(ut_params->op,
1552 			"Failed to allocate symmetric crypto operation struct");
1553 
1554 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
1555 
1556 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1557 
1558 	/* set crypto operation source mbuf */
1559 	sym_op->m_src = ut_params->ibuf;
1560 
1561 	sym_op->auth.digest.data = ut_params->digest;
1562 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1563 			ut_params->ibuf, QUOTE_512_BYTES);
1564 
1565 	sym_op->auth.data.offset = 0;
1566 	sym_op->auth.data.length = QUOTE_512_BYTES;
1567 
1568 	/* Copy IV at the end of the crypto operation */
1569 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1570 			iv, CIPHER_IV_LENGTH_AES_CBC);
1571 
1572 	sym_op->cipher.data.offset = 0;
1573 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1574 
1575 	/* Process crypto operation */
1576 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1577 			ut_params->op), "failed to process sym crypto op");
1578 
1579 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1580 			"crypto op processing failed");
1581 
1582 	ut_params->obuf = ut_params->op->sym->m_src;
1583 
1584 	/* Validate obuf */
1585 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
1586 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1587 			catch_22_quote,
1588 			QUOTE_512_BYTES,
1589 			"Plaintext data not as expected");
1590 
1591 	/* Validate obuf */
1592 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1593 			"Digest verification failed");
1594 
1595 	return TEST_SUCCESS;
1596 }
1597 
1598 static int
1599 test_AES_cipheronly_mb_all(void)
1600 {
1601 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1602 	int status;
1603 
1604 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1605 		ts_params->op_mpool,
1606 		ts_params->session_mpool, ts_params->session_priv_mpool,
1607 		ts_params->valid_devs[0],
1608 		rte_cryptodev_driver_id_get(
1609 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1610 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1611 
1612 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1613 
1614 	return TEST_SUCCESS;
1615 }
1616 
1617 static int
1618 test_AES_docsis_mb_all(void)
1619 {
1620 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1621 	int status;
1622 
1623 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1624 		ts_params->op_mpool,
1625 		ts_params->session_mpool, ts_params->session_priv_mpool,
1626 		ts_params->valid_devs[0],
1627 		rte_cryptodev_driver_id_get(
1628 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1629 		BLKCIPHER_AES_DOCSIS_TYPE);
1630 
1631 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1632 
1633 	return TEST_SUCCESS;
1634 }
1635 
1636 static int
1637 test_AES_docsis_qat_all(void)
1638 {
1639 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1640 	int status;
1641 
1642 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1643 		ts_params->op_mpool,
1644 		ts_params->session_mpool, ts_params->session_priv_mpool,
1645 		ts_params->valid_devs[0],
1646 		rte_cryptodev_driver_id_get(
1647 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1648 		BLKCIPHER_AES_DOCSIS_TYPE);
1649 
1650 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1651 
1652 	return TEST_SUCCESS;
1653 }
1654 
1655 static int
1656 test_DES_docsis_qat_all(void)
1657 {
1658 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1659 	int status;
1660 
1661 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1662 		ts_params->op_mpool,
1663 		ts_params->session_mpool, ts_params->session_priv_mpool,
1664 		ts_params->valid_devs[0],
1665 		rte_cryptodev_driver_id_get(
1666 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1667 		BLKCIPHER_DES_DOCSIS_TYPE);
1668 
1669 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1670 
1671 	return TEST_SUCCESS;
1672 }
1673 
1674 static int
1675 test_authonly_mb_all(void)
1676 {
1677 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1678 	int status;
1679 
1680 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1681 		ts_params->op_mpool,
1682 		ts_params->session_mpool, ts_params->session_priv_mpool,
1683 		ts_params->valid_devs[0],
1684 		rte_cryptodev_driver_id_get(
1685 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1686 		BLKCIPHER_AUTHONLY_TYPE);
1687 
1688 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1689 
1690 	return TEST_SUCCESS;
1691 }
1692 
1693 static int
1694 test_authonly_qat_all(void)
1695 {
1696 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1697 	int status;
1698 
1699 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1700 		ts_params->op_mpool,
1701 		ts_params->session_mpool, ts_params->session_priv_mpool,
1702 		ts_params->valid_devs[0],
1703 		rte_cryptodev_driver_id_get(
1704 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1705 		BLKCIPHER_AUTHONLY_TYPE);
1706 
1707 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1708 
1709 	return TEST_SUCCESS;
1710 }
1711 
1712 static int
1713 test_AES_chain_null_all(void)
1714 {
1715 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 	int status;
1717 
1718 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1719 		ts_params->op_mpool,
1720 		ts_params->session_mpool, ts_params->session_priv_mpool,
1721 		ts_params->valid_devs[0],
1722 		rte_cryptodev_driver_id_get(
1723 		RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1724 		BLKCIPHER_AES_CHAIN_TYPE);
1725 
1726 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1727 
1728 	return TEST_SUCCESS;
1729 }
1730 
1731 static int
1732 test_AES_cipheronly_null_all(void)
1733 {
1734 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1735 	int status;
1736 
1737 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1738 		ts_params->op_mpool,
1739 		ts_params->session_mpool, ts_params->session_priv_mpool,
1740 		ts_params->valid_devs[0],
1741 		rte_cryptodev_driver_id_get(
1742 		RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1743 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1744 
1745 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1746 
1747 	return TEST_SUCCESS;
1748 }
1749 
1750 static int
1751 test_authonly_null_all(void)
1752 {
1753 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1754 	int status;
1755 
1756 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1757 		ts_params->op_mpool,
1758 		ts_params->session_mpool, ts_params->session_priv_mpool,
1759 		ts_params->valid_devs[0],
1760 		rte_cryptodev_driver_id_get(
1761 		RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1762 		BLKCIPHER_AUTHONLY_TYPE);
1763 
1764 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1765 
1766 	return TEST_SUCCESS;
1767 }
1768 
1769 static int
1770 test_AES_chain_mb_all(void)
1771 {
1772 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1773 	int status;
1774 
1775 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1776 		ts_params->op_mpool,
1777 		ts_params->session_mpool, ts_params->session_priv_mpool,
1778 		ts_params->valid_devs[0],
1779 		rte_cryptodev_driver_id_get(
1780 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1781 		BLKCIPHER_AES_CHAIN_TYPE);
1782 
1783 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1784 
1785 	return TEST_SUCCESS;
1786 }
1787 
1788 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1789 
1790 static int
1791 test_AES_cipheronly_scheduler_all(void)
1792 {
1793 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1794 	int status;
1795 
1796 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1797 		ts_params->op_mpool,
1798 		ts_params->session_mpool, ts_params->session_priv_mpool,
1799 		ts_params->valid_devs[0],
1800 		rte_cryptodev_driver_id_get(
1801 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1802 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1803 
1804 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1805 
1806 	return TEST_SUCCESS;
1807 }
1808 
1809 static int
1810 test_AES_chain_scheduler_all(void)
1811 {
1812 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1813 	int status;
1814 
1815 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1816 		ts_params->op_mpool,
1817 		ts_params->session_mpool, ts_params->session_priv_mpool,
1818 		ts_params->valid_devs[0],
1819 		rte_cryptodev_driver_id_get(
1820 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1821 		BLKCIPHER_AES_CHAIN_TYPE);
1822 
1823 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1824 
1825 	return TEST_SUCCESS;
1826 }
1827 
1828 static int
1829 test_authonly_scheduler_all(void)
1830 {
1831 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1832 	int status;
1833 
1834 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1835 		ts_params->op_mpool,
1836 		ts_params->session_mpool, ts_params->session_priv_mpool,
1837 		ts_params->valid_devs[0],
1838 		rte_cryptodev_driver_id_get(
1839 		RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1840 		BLKCIPHER_AUTHONLY_TYPE);
1841 
1842 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1843 
1844 	return TEST_SUCCESS;
1845 }
1846 
1847 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1848 
1849 static int
1850 test_AES_chain_openssl_all(void)
1851 {
1852 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1853 	int status;
1854 
1855 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1856 		ts_params->op_mpool,
1857 		ts_params->session_mpool, ts_params->session_priv_mpool,
1858 		ts_params->valid_devs[0],
1859 		rte_cryptodev_driver_id_get(
1860 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1861 		BLKCIPHER_AES_CHAIN_TYPE);
1862 
1863 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1864 
1865 	return TEST_SUCCESS;
1866 }
1867 
1868 static int
1869 test_AES_cipheronly_openssl_all(void)
1870 {
1871 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1872 	int status;
1873 
1874 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1875 		ts_params->op_mpool,
1876 		ts_params->session_mpool, ts_params->session_priv_mpool,
1877 		ts_params->valid_devs[0],
1878 		rte_cryptodev_driver_id_get(
1879 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1880 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1881 
1882 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1883 
1884 	return TEST_SUCCESS;
1885 }
1886 
1887 static int
1888 test_AES_chain_ccp_all(void)
1889 {
1890 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1891 	int status;
1892 
1893 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1894 		ts_params->op_mpool,
1895 		ts_params->session_mpool, ts_params->session_priv_mpool,
1896 		ts_params->valid_devs[0],
1897 		rte_cryptodev_driver_id_get(
1898 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1899 		BLKCIPHER_AES_CHAIN_TYPE);
1900 
1901 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1902 
1903 	return TEST_SUCCESS;
1904 }
1905 
1906 static int
1907 test_AES_cipheronly_ccp_all(void)
1908 {
1909 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1910 	int status;
1911 
1912 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1913 		ts_params->op_mpool,
1914 		ts_params->session_mpool, ts_params->session_priv_mpool,
1915 		ts_params->valid_devs[0],
1916 		rte_cryptodev_driver_id_get(
1917 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1918 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1919 
1920 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1921 
1922 	return TEST_SUCCESS;
1923 }
1924 
1925 static int
1926 test_AES_chain_qat_all(void)
1927 {
1928 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1929 	int status;
1930 
1931 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1932 		ts_params->op_mpool,
1933 		ts_params->session_mpool, ts_params->session_priv_mpool,
1934 		ts_params->valid_devs[0],
1935 		rte_cryptodev_driver_id_get(
1936 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1937 		BLKCIPHER_AES_CHAIN_TYPE);
1938 
1939 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1940 
1941 	return TEST_SUCCESS;
1942 }
1943 
1944 static int
1945 test_AES_cipheronly_qat_all(void)
1946 {
1947 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1948 	int status;
1949 
1950 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1951 		ts_params->op_mpool,
1952 		ts_params->session_mpool, ts_params->session_priv_mpool,
1953 		ts_params->valid_devs[0],
1954 		rte_cryptodev_driver_id_get(
1955 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1956 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1957 
1958 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1959 
1960 	return TEST_SUCCESS;
1961 }
1962 
1963 static int
1964 test_AES_cipheronly_virtio_all(void)
1965 {
1966 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1967 	int status;
1968 
1969 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1970 		ts_params->op_mpool,
1971 		ts_params->session_mpool, ts_params->session_priv_mpool,
1972 		ts_params->valid_devs[0],
1973 		rte_cryptodev_driver_id_get(
1974 		RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1975 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1976 
1977 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1978 
1979 	return TEST_SUCCESS;
1980 }
1981 
1982 static int
1983 test_AES_chain_caam_jr_all(void)
1984 {
1985 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1986 	int status;
1987 
1988 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1989 		ts_params->op_mpool,
1990 		ts_params->session_mpool, ts_params->session_priv_mpool,
1991 		ts_params->valid_devs[0],
1992 		rte_cryptodev_driver_id_get(
1993 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1994 		BLKCIPHER_AES_CHAIN_TYPE);
1995 
1996 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1997 
1998 	return TEST_SUCCESS;
1999 }
2000 
2001 static int
2002 test_AES_cipheronly_caam_jr_all(void)
2003 {
2004 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2005 	int status;
2006 
2007 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2008 		ts_params->op_mpool,
2009 		ts_params->session_mpool, ts_params->session_priv_mpool,
2010 		ts_params->valid_devs[0],
2011 		rte_cryptodev_driver_id_get(
2012 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2013 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2014 
2015 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2016 
2017 	return TEST_SUCCESS;
2018 }
2019 
2020 static int
2021 test_authonly_caam_jr_all(void)
2022 {
2023 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2024 	int status;
2025 
2026 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2027 		ts_params->op_mpool,
2028 		ts_params->session_mpool, ts_params->session_priv_mpool,
2029 		ts_params->valid_devs[0],
2030 		rte_cryptodev_driver_id_get(
2031 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2032 		BLKCIPHER_AUTHONLY_TYPE);
2033 
2034 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2035 
2036 	return TEST_SUCCESS;
2037 }
2038 
2039 
2040 static int
2041 test_AES_chain_dpaa_sec_all(void)
2042 {
2043 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2044 	int status;
2045 
2046 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2047 		ts_params->op_mpool,
2048 		ts_params->session_mpool, ts_params->session_priv_mpool,
2049 		ts_params->valid_devs[0],
2050 		rte_cryptodev_driver_id_get(
2051 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2052 		BLKCIPHER_AES_CHAIN_TYPE);
2053 
2054 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2055 
2056 	return TEST_SUCCESS;
2057 }
2058 
2059 static int
2060 test_AES_cipheronly_dpaa_sec_all(void)
2061 {
2062 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2063 	int status;
2064 
2065 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2066 		ts_params->op_mpool,
2067 		ts_params->session_mpool, ts_params->session_priv_mpool,
2068 		ts_params->valid_devs[0],
2069 		rte_cryptodev_driver_id_get(
2070 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2071 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2072 
2073 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2074 
2075 	return TEST_SUCCESS;
2076 }
2077 
2078 static int
2079 test_authonly_dpaa_sec_all(void)
2080 {
2081 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2082 	int status;
2083 
2084 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2085 		ts_params->op_mpool,
2086 		ts_params->session_mpool, ts_params->session_priv_mpool,
2087 		ts_params->valid_devs[0],
2088 		rte_cryptodev_driver_id_get(
2089 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2090 		BLKCIPHER_AUTHONLY_TYPE);
2091 
2092 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2093 
2094 	return TEST_SUCCESS;
2095 }
2096 
2097 static int
2098 test_AES_chain_dpaa2_sec_all(void)
2099 {
2100 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2101 	int status;
2102 
2103 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2104 		ts_params->op_mpool,
2105 		ts_params->session_mpool, ts_params->session_priv_mpool,
2106 		ts_params->valid_devs[0],
2107 		rte_cryptodev_driver_id_get(
2108 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2109 		BLKCIPHER_AES_CHAIN_TYPE);
2110 
2111 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2112 
2113 	return TEST_SUCCESS;
2114 }
2115 
2116 static int
2117 test_AES_cipheronly_dpaa2_sec_all(void)
2118 {
2119 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2120 	int status;
2121 
2122 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2123 		ts_params->op_mpool,
2124 		ts_params->session_mpool, ts_params->session_priv_mpool,
2125 		ts_params->valid_devs[0],
2126 		rte_cryptodev_driver_id_get(
2127 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2128 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2129 
2130 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2131 
2132 	return TEST_SUCCESS;
2133 }
2134 
2135 static int
2136 test_authonly_dpaa2_sec_all(void)
2137 {
2138 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2139 	int status;
2140 
2141 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2142 		ts_params->op_mpool,
2143 		ts_params->session_mpool, ts_params->session_priv_mpool,
2144 		ts_params->valid_devs[0],
2145 		rte_cryptodev_driver_id_get(
2146 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2147 		BLKCIPHER_AUTHONLY_TYPE);
2148 
2149 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2150 
2151 	return TEST_SUCCESS;
2152 }
2153 
2154 static int
2155 test_authonly_openssl_all(void)
2156 {
2157 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2158 	int status;
2159 
2160 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2161 		ts_params->op_mpool,
2162 		ts_params->session_mpool, ts_params->session_priv_mpool,
2163 		ts_params->valid_devs[0],
2164 		rte_cryptodev_driver_id_get(
2165 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2166 		BLKCIPHER_AUTHONLY_TYPE);
2167 
2168 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2169 
2170 	return TEST_SUCCESS;
2171 }
2172 
2173 static int
2174 test_authonly_ccp_all(void)
2175 {
2176 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2177 	int status;
2178 
2179 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2180 		ts_params->op_mpool,
2181 		ts_params->session_mpool, ts_params->session_priv_mpool,
2182 		ts_params->valid_devs[0],
2183 		rte_cryptodev_driver_id_get(
2184 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2185 		BLKCIPHER_AUTHONLY_TYPE);
2186 
2187 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2188 
2189 	return TEST_SUCCESS;
2190 }
2191 
2192 static int
2193 test_AES_chain_armv8_all(void)
2194 {
2195 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2196 	int status;
2197 
2198 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2199 		ts_params->op_mpool,
2200 		ts_params->session_mpool, ts_params->session_priv_mpool,
2201 		ts_params->valid_devs[0],
2202 		rte_cryptodev_driver_id_get(
2203 		RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2204 		BLKCIPHER_AES_CHAIN_TYPE);
2205 
2206 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2207 
2208 	return TEST_SUCCESS;
2209 }
2210 
2211 static int
2212 test_AES_chain_mrvl_all(void)
2213 {
2214 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2215 	int status;
2216 
2217 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2218 		ts_params->op_mpool,
2219 		ts_params->session_mpool, ts_params->session_priv_mpool,
2220 		ts_params->valid_devs[0],
2221 		rte_cryptodev_driver_id_get(
2222 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2223 		BLKCIPHER_AES_CHAIN_TYPE);
2224 
2225 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2226 
2227 	return TEST_SUCCESS;
2228 }
2229 
2230 static int
2231 test_AES_cipheronly_mrvl_all(void)
2232 {
2233 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2234 	int status;
2235 
2236 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2237 		ts_params->op_mpool,
2238 		ts_params->session_mpool, ts_params->session_priv_mpool,
2239 		ts_params->valid_devs[0],
2240 		rte_cryptodev_driver_id_get(
2241 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2242 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2243 
2244 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2245 
2246 	return TEST_SUCCESS;
2247 }
2248 
2249 static int
2250 test_authonly_mrvl_all(void)
2251 {
2252 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2253 	int status;
2254 
2255 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2256 		ts_params->op_mpool,
2257 		ts_params->session_mpool, ts_params->session_priv_mpool,
2258 		ts_params->valid_devs[0],
2259 		rte_cryptodev_driver_id_get(
2260 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2261 		BLKCIPHER_AUTHONLY_TYPE);
2262 
2263 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2264 
2265 	return TEST_SUCCESS;
2266 }
2267 
2268 static int
2269 test_3DES_chain_mrvl_all(void)
2270 {
2271 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2272 	int status;
2273 
2274 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2275 		ts_params->op_mpool,
2276 		ts_params->session_mpool, ts_params->session_priv_mpool,
2277 		ts_params->valid_devs[0],
2278 		rte_cryptodev_driver_id_get(
2279 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2280 		BLKCIPHER_3DES_CHAIN_TYPE);
2281 
2282 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2283 
2284 	return TEST_SUCCESS;
2285 }
2286 
2287 static int
2288 test_3DES_cipheronly_mrvl_all(void)
2289 {
2290 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2291 	int status;
2292 
2293 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2294 		ts_params->op_mpool,
2295 		ts_params->session_mpool, ts_params->session_priv_mpool,
2296 		ts_params->valid_devs[0],
2297 		rte_cryptodev_driver_id_get(
2298 		RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2299 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2300 
2301 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2302 
2303 	return TEST_SUCCESS;
2304 }
2305 
2306 static int
2307 test_AES_chain_octeontx_all(void)
2308 {
2309 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2310 	int status;
2311 
2312 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2313 		ts_params->op_mpool, ts_params->session_mpool,
2314 		ts_params->session_priv_mpool,
2315 		ts_params->valid_devs[0],
2316 		rte_cryptodev_driver_id_get(
2317 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2318 		BLKCIPHER_AES_CHAIN_TYPE);
2319 
2320 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2321 
2322 	return TEST_SUCCESS;
2323 }
2324 
2325 static int
2326 test_AES_cipheronly_octeontx_all(void)
2327 {
2328 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2329 	int status;
2330 
2331 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2332 		ts_params->op_mpool, ts_params->session_mpool,
2333 		ts_params->session_priv_mpool,
2334 		ts_params->valid_devs[0],
2335 		rte_cryptodev_driver_id_get(
2336 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2337 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2338 
2339 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2340 
2341 	return TEST_SUCCESS;
2342 }
2343 
2344 static int
2345 test_3DES_chain_octeontx_all(void)
2346 {
2347 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2348 	int status;
2349 
2350 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2351 		ts_params->op_mpool, ts_params->session_mpool,
2352 		ts_params->session_priv_mpool,
2353 		ts_params->valid_devs[0],
2354 		rte_cryptodev_driver_id_get(
2355 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2356 		BLKCIPHER_3DES_CHAIN_TYPE);
2357 
2358 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2359 
2360 	return TEST_SUCCESS;
2361 }
2362 
2363 static int
2364 test_AES_chain_nitrox_all(void)
2365 {
2366 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2367 	int status;
2368 
2369 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2370 		ts_params->op_mpool,
2371 		ts_params->session_mpool, ts_params->session_priv_mpool,
2372 		ts_params->valid_devs[0],
2373 		rte_cryptodev_driver_id_get(
2374 		RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2375 		BLKCIPHER_AES_CHAIN_TYPE);
2376 
2377 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2378 
2379 	return TEST_SUCCESS;
2380 }
2381 
2382 static int
2383 test_3DES_cipheronly_octeontx_all(void)
2384 {
2385 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2386 	int status;
2387 
2388 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2389 		ts_params->op_mpool, ts_params->session_mpool,
2390 		ts_params->session_priv_mpool,
2391 		ts_params->valid_devs[0],
2392 		rte_cryptodev_driver_id_get(
2393 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2394 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2395 
2396 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2397 
2398 	return TEST_SUCCESS;
2399 }
2400 
2401 static int
2402 test_authonly_octeontx_all(void)
2403 {
2404 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2405 	int status;
2406 
2407 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2408 		ts_params->op_mpool, ts_params->session_mpool,
2409 		ts_params->session_priv_mpool,
2410 		ts_params->valid_devs[0],
2411 		rte_cryptodev_driver_id_get(
2412 		RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2413 		BLKCIPHER_AUTHONLY_TYPE);
2414 
2415 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2416 
2417 	return TEST_SUCCESS;
2418 }
2419 
2420 static int
2421 test_AES_chain_octeontx2_all(void)
2422 {
2423 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2424 	int status;
2425 
2426 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2427 		ts_params->op_mpool, ts_params->session_mpool,
2428 		ts_params->session_priv_mpool,
2429 		ts_params->valid_devs[0],
2430 		rte_cryptodev_driver_id_get(
2431 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2432 		BLKCIPHER_AES_CHAIN_TYPE);
2433 
2434 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2435 
2436 	return TEST_SUCCESS;
2437 }
2438 
2439 static int
2440 test_AES_cipheronly_octeontx2_all(void)
2441 {
2442 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2443 	int status;
2444 
2445 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2446 		ts_params->op_mpool, ts_params->session_mpool,
2447 		ts_params->session_priv_mpool,
2448 		ts_params->valid_devs[0],
2449 		rte_cryptodev_driver_id_get(
2450 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2451 		BLKCIPHER_AES_CIPHERONLY_TYPE);
2452 
2453 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2454 
2455 	return TEST_SUCCESS;
2456 }
2457 
2458 static int
2459 test_3DES_chain_octeontx2_all(void)
2460 {
2461 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2462 	int status;
2463 
2464 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2465 		ts_params->op_mpool, ts_params->session_mpool,
2466 		ts_params->session_priv_mpool,
2467 		ts_params->valid_devs[0],
2468 		rte_cryptodev_driver_id_get(
2469 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2470 		BLKCIPHER_3DES_CHAIN_TYPE);
2471 
2472 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2473 
2474 	return TEST_SUCCESS;
2475 }
2476 
2477 static int
2478 test_3DES_cipheronly_octeontx2_all(void)
2479 {
2480 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2481 	int status;
2482 
2483 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2484 		ts_params->op_mpool, ts_params->session_mpool,
2485 		ts_params->session_priv_mpool,
2486 		ts_params->valid_devs[0],
2487 		rte_cryptodev_driver_id_get(
2488 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2489 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
2490 
2491 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2492 
2493 	return TEST_SUCCESS;
2494 }
2495 
2496 static int
2497 test_authonly_octeontx2_all(void)
2498 {
2499 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2500 	int status;
2501 
2502 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2503 		ts_params->op_mpool, ts_params->session_mpool,
2504 		ts_params->session_priv_mpool,
2505 		ts_params->valid_devs[0],
2506 		rte_cryptodev_driver_id_get(
2507 		RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2508 		BLKCIPHER_AUTHONLY_TYPE);
2509 
2510 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
2511 
2512 	return TEST_SUCCESS;
2513 }
2514 
2515 /* ***** SNOW 3G Tests ***** */
2516 static int
2517 create_wireless_algo_hash_session(uint8_t dev_id,
2518 	const uint8_t *key, const uint8_t key_len,
2519 	const uint8_t iv_len, const uint8_t auth_len,
2520 	enum rte_crypto_auth_operation op,
2521 	enum rte_crypto_auth_algorithm algo)
2522 {
2523 	uint8_t hash_key[key_len];
2524 	int status;
2525 
2526 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2527 	struct crypto_unittest_params *ut_params = &unittest_params;
2528 
2529 	memcpy(hash_key, key, key_len);
2530 
2531 	debug_hexdump(stdout, "key:", key, key_len);
2532 
2533 	/* Setup Authentication Parameters */
2534 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2535 	ut_params->auth_xform.next = NULL;
2536 
2537 	ut_params->auth_xform.auth.op = op;
2538 	ut_params->auth_xform.auth.algo = algo;
2539 	ut_params->auth_xform.auth.key.length = key_len;
2540 	ut_params->auth_xform.auth.key.data = hash_key;
2541 	ut_params->auth_xform.auth.digest_length = auth_len;
2542 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2543 	ut_params->auth_xform.auth.iv.length = iv_len;
2544 	ut_params->sess = rte_cryptodev_sym_session_create(
2545 			ts_params->session_mpool);
2546 
2547 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2548 			&ut_params->auth_xform,
2549 			ts_params->session_priv_mpool);
2550 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2551 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2552 	return 0;
2553 }
2554 
2555 static int
2556 create_wireless_algo_cipher_session(uint8_t dev_id,
2557 			enum rte_crypto_cipher_operation op,
2558 			enum rte_crypto_cipher_algorithm algo,
2559 			const uint8_t *key, const uint8_t key_len,
2560 			uint8_t iv_len)
2561 {
2562 	uint8_t cipher_key[key_len];
2563 	int status;
2564 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2565 	struct crypto_unittest_params *ut_params = &unittest_params;
2566 
2567 	memcpy(cipher_key, key, key_len);
2568 
2569 	/* Setup Cipher Parameters */
2570 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2571 	ut_params->cipher_xform.next = NULL;
2572 
2573 	ut_params->cipher_xform.cipher.algo = algo;
2574 	ut_params->cipher_xform.cipher.op = op;
2575 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2576 	ut_params->cipher_xform.cipher.key.length = key_len;
2577 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2578 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2579 
2580 	debug_hexdump(stdout, "key:", key, key_len);
2581 
2582 	/* Create Crypto session */
2583 	ut_params->sess = rte_cryptodev_sym_session_create(
2584 			ts_params->session_mpool);
2585 
2586 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2587 			&ut_params->cipher_xform,
2588 			ts_params->session_priv_mpool);
2589 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2590 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2591 	return 0;
2592 }
2593 
2594 static int
2595 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2596 			unsigned int cipher_len,
2597 			unsigned int cipher_offset)
2598 {
2599 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2600 	struct crypto_unittest_params *ut_params = &unittest_params;
2601 
2602 	/* Generate Crypto op data structure */
2603 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2604 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2605 	TEST_ASSERT_NOT_NULL(ut_params->op,
2606 				"Failed to allocate pktmbuf offload");
2607 
2608 	/* Set crypto operation data parameters */
2609 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2610 
2611 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2612 
2613 	/* set crypto operation source mbuf */
2614 	sym_op->m_src = ut_params->ibuf;
2615 
2616 	/* iv */
2617 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2618 			iv, iv_len);
2619 	sym_op->cipher.data.length = cipher_len;
2620 	sym_op->cipher.data.offset = cipher_offset;
2621 	return 0;
2622 }
2623 
2624 static int
2625 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2626 			unsigned int cipher_len,
2627 			unsigned int cipher_offset)
2628 {
2629 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2630 	struct crypto_unittest_params *ut_params = &unittest_params;
2631 
2632 	/* Generate Crypto op data structure */
2633 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2634 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2635 	TEST_ASSERT_NOT_NULL(ut_params->op,
2636 				"Failed to allocate pktmbuf offload");
2637 
2638 	/* Set crypto operation data parameters */
2639 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2640 
2641 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2642 
2643 	/* set crypto operation source mbuf */
2644 	sym_op->m_src = ut_params->ibuf;
2645 	sym_op->m_dst = ut_params->obuf;
2646 
2647 	/* iv */
2648 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2649 			iv, iv_len);
2650 	sym_op->cipher.data.length = cipher_len;
2651 	sym_op->cipher.data.offset = cipher_offset;
2652 	return 0;
2653 }
2654 
2655 static int
2656 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2657 		enum rte_crypto_cipher_operation cipher_op,
2658 		enum rte_crypto_auth_operation auth_op,
2659 		enum rte_crypto_auth_algorithm auth_algo,
2660 		enum rte_crypto_cipher_algorithm cipher_algo,
2661 		const uint8_t *key, uint8_t key_len,
2662 		uint8_t auth_iv_len, uint8_t auth_len,
2663 		uint8_t cipher_iv_len)
2664 
2665 {
2666 	uint8_t cipher_auth_key[key_len];
2667 	int status;
2668 
2669 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2670 	struct crypto_unittest_params *ut_params = &unittest_params;
2671 
2672 	memcpy(cipher_auth_key, key, key_len);
2673 
2674 	/* Setup Authentication Parameters */
2675 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2676 	ut_params->auth_xform.next = NULL;
2677 
2678 	ut_params->auth_xform.auth.op = auth_op;
2679 	ut_params->auth_xform.auth.algo = auth_algo;
2680 	ut_params->auth_xform.auth.key.length = key_len;
2681 	/* Hash key = cipher key */
2682 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2683 	ut_params->auth_xform.auth.digest_length = auth_len;
2684 	/* Auth IV will be after cipher IV */
2685 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2686 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2687 
2688 	/* Setup Cipher Parameters */
2689 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2690 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2691 
2692 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2693 	ut_params->cipher_xform.cipher.op = cipher_op;
2694 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2695 	ut_params->cipher_xform.cipher.key.length = key_len;
2696 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2697 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2698 
2699 	debug_hexdump(stdout, "key:", key, key_len);
2700 
2701 	/* Create Crypto session*/
2702 	ut_params->sess = rte_cryptodev_sym_session_create(
2703 			ts_params->session_mpool);
2704 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2705 
2706 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2707 			&ut_params->cipher_xform,
2708 			ts_params->session_priv_mpool);
2709 	if (status == -ENOTSUP)
2710 		return status;
2711 
2712 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2713 	return 0;
2714 }
2715 
2716 static int
2717 create_wireless_cipher_auth_session(uint8_t dev_id,
2718 		enum rte_crypto_cipher_operation cipher_op,
2719 		enum rte_crypto_auth_operation auth_op,
2720 		enum rte_crypto_auth_algorithm auth_algo,
2721 		enum rte_crypto_cipher_algorithm cipher_algo,
2722 		const struct wireless_test_data *tdata)
2723 {
2724 	const uint8_t key_len = tdata->key.len;
2725 	uint8_t cipher_auth_key[key_len];
2726 	int status;
2727 
2728 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2729 	struct crypto_unittest_params *ut_params = &unittest_params;
2730 	const uint8_t *key = tdata->key.data;
2731 	const uint8_t auth_len = tdata->digest.len;
2732 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2733 	uint8_t auth_iv_len = tdata->auth_iv.len;
2734 
2735 	memcpy(cipher_auth_key, key, key_len);
2736 
2737 	/* Setup Authentication Parameters */
2738 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2739 	ut_params->auth_xform.next = NULL;
2740 
2741 	ut_params->auth_xform.auth.op = auth_op;
2742 	ut_params->auth_xform.auth.algo = auth_algo;
2743 	ut_params->auth_xform.auth.key.length = key_len;
2744 	/* Hash key = cipher key */
2745 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2746 	ut_params->auth_xform.auth.digest_length = auth_len;
2747 	/* Auth IV will be after cipher IV */
2748 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2749 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2750 
2751 	/* Setup Cipher Parameters */
2752 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2753 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2754 
2755 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2756 	ut_params->cipher_xform.cipher.op = cipher_op;
2757 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2758 	ut_params->cipher_xform.cipher.key.length = key_len;
2759 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2760 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2761 
2762 
2763 	debug_hexdump(stdout, "key:", key, key_len);
2764 
2765 	/* Create Crypto session*/
2766 	ut_params->sess = rte_cryptodev_sym_session_create(
2767 			ts_params->session_mpool);
2768 
2769 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2770 			&ut_params->cipher_xform,
2771 			ts_params->session_priv_mpool);
2772 
2773 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2774 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2775 	return 0;
2776 }
2777 
2778 static int
2779 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2780 		const struct wireless_test_data *tdata)
2781 {
2782 	return create_wireless_cipher_auth_session(dev_id,
2783 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2784 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2785 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2786 }
2787 
2788 static int
2789 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2790 		enum rte_crypto_cipher_operation cipher_op,
2791 		enum rte_crypto_auth_operation auth_op,
2792 		enum rte_crypto_auth_algorithm auth_algo,
2793 		enum rte_crypto_cipher_algorithm cipher_algo,
2794 		const uint8_t *key, const uint8_t key_len,
2795 		uint8_t auth_iv_len, uint8_t auth_len,
2796 		uint8_t cipher_iv_len)
2797 {
2798 	uint8_t auth_cipher_key[key_len];
2799 	int status;
2800 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2801 	struct crypto_unittest_params *ut_params = &unittest_params;
2802 
2803 	memcpy(auth_cipher_key, key, key_len);
2804 
2805 	/* Setup Authentication Parameters */
2806 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2807 	ut_params->auth_xform.auth.op = auth_op;
2808 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2809 	ut_params->auth_xform.auth.algo = auth_algo;
2810 	ut_params->auth_xform.auth.key.length = key_len;
2811 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
2812 	ut_params->auth_xform.auth.digest_length = auth_len;
2813 	/* Auth IV will be after cipher IV */
2814 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2815 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2816 
2817 	/* Setup Cipher Parameters */
2818 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2819 	ut_params->cipher_xform.next = NULL;
2820 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2821 	ut_params->cipher_xform.cipher.op = cipher_op;
2822 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2823 	ut_params->cipher_xform.cipher.key.length = key_len;
2824 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2825 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2826 
2827 	debug_hexdump(stdout, "key:", key, key_len);
2828 
2829 	/* Create Crypto session*/
2830 	ut_params->sess = rte_cryptodev_sym_session_create(
2831 			ts_params->session_mpool);
2832 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2833 
2834 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2835 		ut_params->auth_xform.next = NULL;
2836 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2837 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2838 				&ut_params->cipher_xform,
2839 				ts_params->session_priv_mpool);
2840 
2841 	} else
2842 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2843 				&ut_params->auth_xform,
2844 				ts_params->session_priv_mpool);
2845 
2846 	if (status == -ENOTSUP)
2847 		return status;
2848 
2849 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2850 
2851 	return 0;
2852 }
2853 
2854 static int
2855 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2856 		unsigned int auth_tag_len,
2857 		const uint8_t *iv, unsigned int iv_len,
2858 		unsigned int data_pad_len,
2859 		enum rte_crypto_auth_operation op,
2860 		unsigned int auth_len, unsigned int auth_offset)
2861 {
2862 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2863 
2864 	struct crypto_unittest_params *ut_params = &unittest_params;
2865 
2866 	/* Generate Crypto op data structure */
2867 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2868 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2869 	TEST_ASSERT_NOT_NULL(ut_params->op,
2870 		"Failed to allocate pktmbuf offload");
2871 
2872 	/* Set crypto operation data parameters */
2873 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2874 
2875 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2876 
2877 	/* set crypto operation source mbuf */
2878 	sym_op->m_src = ut_params->ibuf;
2879 
2880 	/* iv */
2881 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2882 			iv, iv_len);
2883 	/* digest */
2884 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2885 					ut_params->ibuf, auth_tag_len);
2886 
2887 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2888 				"no room to append auth tag");
2889 	ut_params->digest = sym_op->auth.digest.data;
2890 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2891 			ut_params->ibuf, data_pad_len);
2892 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2893 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2894 	else
2895 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2896 
2897 	debug_hexdump(stdout, "digest:",
2898 		sym_op->auth.digest.data,
2899 		auth_tag_len);
2900 
2901 	sym_op->auth.data.length = auth_len;
2902 	sym_op->auth.data.offset = auth_offset;
2903 
2904 	return 0;
2905 }
2906 
2907 static int
2908 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2909 	enum rte_crypto_auth_operation op)
2910 {
2911 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2912 	struct crypto_unittest_params *ut_params = &unittest_params;
2913 
2914 	const uint8_t *auth_tag = tdata->digest.data;
2915 	const unsigned int auth_tag_len = tdata->digest.len;
2916 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2917 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2918 
2919 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2920 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2921 	const uint8_t *auth_iv = tdata->auth_iv.data;
2922 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2923 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2924 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2925 
2926 	/* Generate Crypto op data structure */
2927 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2928 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2929 	TEST_ASSERT_NOT_NULL(ut_params->op,
2930 			"Failed to allocate pktmbuf offload");
2931 	/* Set crypto operation data parameters */
2932 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2933 
2934 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2935 
2936 	/* set crypto operation source mbuf */
2937 	sym_op->m_src = ut_params->ibuf;
2938 
2939 	/* digest */
2940 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2941 			ut_params->ibuf, auth_tag_len);
2942 
2943 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2944 			"no room to append auth tag");
2945 	ut_params->digest = sym_op->auth.digest.data;
2946 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2947 			ut_params->ibuf, data_pad_len);
2948 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2949 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2950 	else
2951 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2952 
2953 	debug_hexdump(stdout, "digest:",
2954 		sym_op->auth.digest.data,
2955 		auth_tag_len);
2956 
2957 	/* Copy cipher and auth IVs at the end of the crypto operation */
2958 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2959 						IV_OFFSET);
2960 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2961 	iv_ptr += cipher_iv_len;
2962 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2963 
2964 	sym_op->cipher.data.length = cipher_len;
2965 	sym_op->cipher.data.offset = 0;
2966 	sym_op->auth.data.length = auth_len;
2967 	sym_op->auth.data.offset = 0;
2968 
2969 	return 0;
2970 }
2971 
2972 static int
2973 create_zuc_cipher_hash_generate_operation(
2974 		const struct wireless_test_data *tdata)
2975 {
2976 	return create_wireless_cipher_hash_operation(tdata,
2977 		RTE_CRYPTO_AUTH_OP_GENERATE);
2978 }
2979 
2980 static int
2981 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2982 		const unsigned auth_tag_len,
2983 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2984 		unsigned data_pad_len,
2985 		enum rte_crypto_auth_operation op,
2986 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2987 		const unsigned cipher_len, const unsigned cipher_offset,
2988 		const unsigned auth_len, const unsigned auth_offset)
2989 {
2990 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 	struct crypto_unittest_params *ut_params = &unittest_params;
2992 
2993 	enum rte_crypto_cipher_algorithm cipher_algo =
2994 			ut_params->cipher_xform.cipher.algo;
2995 	enum rte_crypto_auth_algorithm auth_algo =
2996 			ut_params->auth_xform.auth.algo;
2997 
2998 	/* Generate Crypto op data structure */
2999 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3000 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3001 	TEST_ASSERT_NOT_NULL(ut_params->op,
3002 			"Failed to allocate pktmbuf offload");
3003 	/* Set crypto operation data parameters */
3004 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3005 
3006 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3007 
3008 	/* set crypto operation source mbuf */
3009 	sym_op->m_src = ut_params->ibuf;
3010 
3011 	/* digest */
3012 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3013 			ut_params->ibuf, auth_tag_len);
3014 
3015 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3016 			"no room to append auth tag");
3017 	ut_params->digest = sym_op->auth.digest.data;
3018 
3019 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3020 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3021 				ut_params->ibuf, data_pad_len);
3022 	} else {
3023 		struct rte_mbuf *m = ut_params->ibuf;
3024 		unsigned int offset = data_pad_len;
3025 
3026 		while (offset > m->data_len && m->next != NULL) {
3027 			offset -= m->data_len;
3028 			m = m->next;
3029 		}
3030 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3031 			m, offset);
3032 	}
3033 
3034 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3035 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3036 	else
3037 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3038 
3039 	debug_hexdump(stdout, "digest:",
3040 		sym_op->auth.digest.data,
3041 		auth_tag_len);
3042 
3043 	/* Copy cipher and auth IVs at the end of the crypto operation */
3044 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3045 						IV_OFFSET);
3046 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3047 	iv_ptr += cipher_iv_len;
3048 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3049 
3050 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3051 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3052 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3053 		sym_op->cipher.data.length = cipher_len;
3054 		sym_op->cipher.data.offset = cipher_offset;
3055 	} else {
3056 		sym_op->cipher.data.length = cipher_len >> 3;
3057 		sym_op->cipher.data.offset = cipher_offset >> 3;
3058 	}
3059 
3060 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3061 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3062 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3063 		sym_op->auth.data.length = auth_len;
3064 		sym_op->auth.data.offset = auth_offset;
3065 	} else {
3066 		sym_op->auth.data.length = auth_len >> 3;
3067 		sym_op->auth.data.offset = auth_offset >> 3;
3068 	}
3069 
3070 	return 0;
3071 }
3072 
3073 static int
3074 create_wireless_algo_auth_cipher_operation(
3075 		const uint8_t *auth_tag, unsigned int auth_tag_len,
3076 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3077 		const uint8_t *auth_iv, uint8_t auth_iv_len,
3078 		unsigned int data_pad_len,
3079 		unsigned int cipher_len, unsigned int cipher_offset,
3080 		unsigned int auth_len, unsigned int auth_offset,
3081 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3082 {
3083 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3084 	struct crypto_unittest_params *ut_params = &unittest_params;
3085 
3086 	enum rte_crypto_cipher_algorithm cipher_algo =
3087 			ut_params->cipher_xform.cipher.algo;
3088 	enum rte_crypto_auth_algorithm auth_algo =
3089 			ut_params->auth_xform.auth.algo;
3090 
3091 	/* Generate Crypto op data structure */
3092 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3093 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3094 	TEST_ASSERT_NOT_NULL(ut_params->op,
3095 			"Failed to allocate pktmbuf offload");
3096 
3097 	/* Set crypto operation data parameters */
3098 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3099 
3100 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3101 
3102 	/* set crypto operation mbufs */
3103 	sym_op->m_src = ut_params->ibuf;
3104 	if (op_mode == OUT_OF_PLACE)
3105 		sym_op->m_dst = ut_params->obuf;
3106 
3107 	/* digest */
3108 	if (!do_sgl) {
3109 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3110 			(op_mode == IN_PLACE ?
3111 				ut_params->ibuf : ut_params->obuf),
3112 			uint8_t *, data_pad_len);
3113 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3114 			(op_mode == IN_PLACE ?
3115 				ut_params->ibuf : ut_params->obuf),
3116 			data_pad_len);
3117 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
3118 	} else {
3119 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3120 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3121 				sym_op->m_src : sym_op->m_dst);
3122 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3123 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3124 			sgl_buf = sgl_buf->next;
3125 		}
3126 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3127 				uint8_t *, remaining_off);
3128 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3129 				remaining_off);
3130 		memset(sym_op->auth.digest.data, 0, remaining_off);
3131 		while (sgl_buf->next != NULL) {
3132 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3133 				0, rte_pktmbuf_data_len(sgl_buf));
3134 			sgl_buf = sgl_buf->next;
3135 		}
3136 	}
3137 
3138 	/* Copy digest for the verification */
3139 	if (verify)
3140 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3141 
3142 	/* Copy cipher and auth IVs at the end of the crypto operation */
3143 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3144 			ut_params->op, uint8_t *, IV_OFFSET);
3145 
3146 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3147 	iv_ptr += cipher_iv_len;
3148 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3149 
3150 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3151 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3152 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3153 		sym_op->cipher.data.length = cipher_len;
3154 		sym_op->cipher.data.offset = cipher_offset;
3155 	} else {
3156 		sym_op->cipher.data.length = cipher_len >> 3;
3157 		sym_op->cipher.data.offset = cipher_offset >> 3;
3158 	}
3159 
3160 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3161 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3162 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3163 		sym_op->auth.data.length = auth_len;
3164 		sym_op->auth.data.offset = auth_offset;
3165 	} else {
3166 		sym_op->auth.data.length = auth_len >> 3;
3167 		sym_op->auth.data.offset = auth_offset >> 3;
3168 	}
3169 
3170 	return 0;
3171 }
3172 
3173 static int
3174 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3175 {
3176 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 	struct crypto_unittest_params *ut_params = &unittest_params;
3178 
3179 	int retval;
3180 	unsigned plaintext_pad_len;
3181 	unsigned plaintext_len;
3182 	uint8_t *plaintext;
3183 
3184 	/* Create SNOW 3G session */
3185 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3186 			tdata->key.data, tdata->key.len,
3187 			tdata->auth_iv.len, tdata->digest.len,
3188 			RTE_CRYPTO_AUTH_OP_GENERATE,
3189 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3190 	if (retval < 0)
3191 		return retval;
3192 
3193 	/* alloc mbuf and set payload */
3194 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3195 
3196 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3197 	rte_pktmbuf_tailroom(ut_params->ibuf));
3198 
3199 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3200 	/* Append data which is padded to a multiple of */
3201 	/* the algorithms block size */
3202 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3203 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3204 				plaintext_pad_len);
3205 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3206 
3207 	/* Create SNOW 3G operation */
3208 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3209 			tdata->auth_iv.data, tdata->auth_iv.len,
3210 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3211 			tdata->validAuthLenInBits.len,
3212 			0);
3213 	if (retval < 0)
3214 		return retval;
3215 
3216 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3217 				ut_params->op);
3218 	ut_params->obuf = ut_params->op->sym->m_src;
3219 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3220 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3221 			+ plaintext_pad_len;
3222 
3223 	/* Validate obuf */
3224 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3225 	ut_params->digest,
3226 	tdata->digest.data,
3227 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3228 	"SNOW 3G Generated auth tag not as expected");
3229 
3230 	return 0;
3231 }
3232 
3233 static int
3234 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3235 {
3236 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3237 	struct crypto_unittest_params *ut_params = &unittest_params;
3238 
3239 	int retval;
3240 	unsigned plaintext_pad_len;
3241 	unsigned plaintext_len;
3242 	uint8_t *plaintext;
3243 
3244 	/* Create SNOW 3G session */
3245 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3246 				tdata->key.data, tdata->key.len,
3247 				tdata->auth_iv.len, tdata->digest.len,
3248 				RTE_CRYPTO_AUTH_OP_VERIFY,
3249 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3250 	if (retval < 0)
3251 		return retval;
3252 	/* alloc mbuf and set payload */
3253 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3254 
3255 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3256 	rte_pktmbuf_tailroom(ut_params->ibuf));
3257 
3258 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3259 	/* Append data which is padded to a multiple of */
3260 	/* the algorithms block size */
3261 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3262 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3263 				plaintext_pad_len);
3264 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3265 
3266 	/* Create SNOW 3G operation */
3267 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3268 			tdata->digest.len,
3269 			tdata->auth_iv.data, tdata->auth_iv.len,
3270 			plaintext_pad_len,
3271 			RTE_CRYPTO_AUTH_OP_VERIFY,
3272 			tdata->validAuthLenInBits.len,
3273 			0);
3274 	if (retval < 0)
3275 		return retval;
3276 
3277 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3278 				ut_params->op);
3279 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 	ut_params->obuf = ut_params->op->sym->m_src;
3281 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3282 				+ plaintext_pad_len;
3283 
3284 	/* Validate obuf */
3285 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3286 		return 0;
3287 	else
3288 		return -1;
3289 
3290 	return 0;
3291 }
3292 
3293 static int
3294 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3295 {
3296 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3297 	struct crypto_unittest_params *ut_params = &unittest_params;
3298 
3299 	int retval;
3300 	unsigned plaintext_pad_len;
3301 	unsigned plaintext_len;
3302 	uint8_t *plaintext;
3303 
3304 	/* Create KASUMI session */
3305 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3306 			tdata->key.data, tdata->key.len,
3307 			0, tdata->digest.len,
3308 			RTE_CRYPTO_AUTH_OP_GENERATE,
3309 			RTE_CRYPTO_AUTH_KASUMI_F9);
3310 	if (retval < 0)
3311 		return retval;
3312 
3313 	/* alloc mbuf and set payload */
3314 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3315 
3316 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3317 	rte_pktmbuf_tailroom(ut_params->ibuf));
3318 
3319 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3320 	/* Append data which is padded to a multiple of */
3321 	/* the algorithms block size */
3322 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3323 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3324 				plaintext_pad_len);
3325 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3326 
3327 	/* Create KASUMI operation */
3328 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3329 			NULL, 0,
3330 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3331 			tdata->plaintext.len,
3332 			0);
3333 	if (retval < 0)
3334 		return retval;
3335 
3336 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3337 				ut_params->op);
3338 	ut_params->obuf = ut_params->op->sym->m_src;
3339 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3340 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3341 			+ plaintext_pad_len;
3342 
3343 	/* Validate obuf */
3344 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3345 	ut_params->digest,
3346 	tdata->digest.data,
3347 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3348 	"KASUMI Generated auth tag not as expected");
3349 
3350 	return 0;
3351 }
3352 
3353 static int
3354 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3355 {
3356 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3357 	struct crypto_unittest_params *ut_params = &unittest_params;
3358 
3359 	int retval;
3360 	unsigned plaintext_pad_len;
3361 	unsigned plaintext_len;
3362 	uint8_t *plaintext;
3363 
3364 	/* Create KASUMI session */
3365 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3366 				tdata->key.data, tdata->key.len,
3367 				0, tdata->digest.len,
3368 				RTE_CRYPTO_AUTH_OP_VERIFY,
3369 				RTE_CRYPTO_AUTH_KASUMI_F9);
3370 	if (retval < 0)
3371 		return retval;
3372 	/* alloc mbuf and set payload */
3373 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3374 
3375 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3376 	rte_pktmbuf_tailroom(ut_params->ibuf));
3377 
3378 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3379 	/* Append data which is padded to a multiple */
3380 	/* of the algorithms block size */
3381 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3382 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3383 				plaintext_pad_len);
3384 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3385 
3386 	/* Create KASUMI operation */
3387 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3388 			tdata->digest.len,
3389 			NULL, 0,
3390 			plaintext_pad_len,
3391 			RTE_CRYPTO_AUTH_OP_VERIFY,
3392 			tdata->plaintext.len,
3393 			0);
3394 	if (retval < 0)
3395 		return retval;
3396 
3397 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3398 				ut_params->op);
3399 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3400 	ut_params->obuf = ut_params->op->sym->m_src;
3401 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3402 				+ plaintext_pad_len;
3403 
3404 	/* Validate obuf */
3405 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3406 		return 0;
3407 	else
3408 		return -1;
3409 
3410 	return 0;
3411 }
3412 
3413 static int
3414 test_snow3g_hash_generate_test_case_1(void)
3415 {
3416 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3417 }
3418 
3419 static int
3420 test_snow3g_hash_generate_test_case_2(void)
3421 {
3422 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3423 }
3424 
3425 static int
3426 test_snow3g_hash_generate_test_case_3(void)
3427 {
3428 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3429 }
3430 
3431 static int
3432 test_snow3g_hash_generate_test_case_4(void)
3433 {
3434 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3435 }
3436 
3437 static int
3438 test_snow3g_hash_generate_test_case_5(void)
3439 {
3440 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3441 }
3442 
3443 static int
3444 test_snow3g_hash_generate_test_case_6(void)
3445 {
3446 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3447 }
3448 
3449 static int
3450 test_snow3g_hash_verify_test_case_1(void)
3451 {
3452 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3453 
3454 }
3455 
3456 static int
3457 test_snow3g_hash_verify_test_case_2(void)
3458 {
3459 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3460 }
3461 
3462 static int
3463 test_snow3g_hash_verify_test_case_3(void)
3464 {
3465 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3466 }
3467 
3468 static int
3469 test_snow3g_hash_verify_test_case_4(void)
3470 {
3471 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3472 }
3473 
3474 static int
3475 test_snow3g_hash_verify_test_case_5(void)
3476 {
3477 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3478 }
3479 
3480 static int
3481 test_snow3g_hash_verify_test_case_6(void)
3482 {
3483 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3484 }
3485 
3486 static int
3487 test_kasumi_hash_generate_test_case_1(void)
3488 {
3489 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3490 }
3491 
3492 static int
3493 test_kasumi_hash_generate_test_case_2(void)
3494 {
3495 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3496 }
3497 
3498 static int
3499 test_kasumi_hash_generate_test_case_3(void)
3500 {
3501 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3502 }
3503 
3504 static int
3505 test_kasumi_hash_generate_test_case_4(void)
3506 {
3507 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3508 }
3509 
3510 static int
3511 test_kasumi_hash_generate_test_case_5(void)
3512 {
3513 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3514 }
3515 
3516 static int
3517 test_kasumi_hash_generate_test_case_6(void)
3518 {
3519 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3520 }
3521 
3522 static int
3523 test_kasumi_hash_verify_test_case_1(void)
3524 {
3525 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3526 }
3527 
3528 static int
3529 test_kasumi_hash_verify_test_case_2(void)
3530 {
3531 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3532 }
3533 
3534 static int
3535 test_kasumi_hash_verify_test_case_3(void)
3536 {
3537 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3538 }
3539 
3540 static int
3541 test_kasumi_hash_verify_test_case_4(void)
3542 {
3543 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3544 }
3545 
3546 static int
3547 test_kasumi_hash_verify_test_case_5(void)
3548 {
3549 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3550 }
3551 
3552 static int
3553 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3554 {
3555 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3556 	struct crypto_unittest_params *ut_params = &unittest_params;
3557 
3558 	int retval;
3559 	uint8_t *plaintext, *ciphertext;
3560 	unsigned plaintext_pad_len;
3561 	unsigned plaintext_len;
3562 
3563 	/* Create KASUMI session */
3564 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3565 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3566 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3567 					tdata->key.data, tdata->key.len,
3568 					tdata->cipher_iv.len);
3569 	if (retval < 0)
3570 		return retval;
3571 
3572 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3573 
3574 	/* Clear mbuf payload */
3575 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3576 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3577 
3578 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3579 	/* Append data which is padded to a multiple */
3580 	/* of the algorithms block size */
3581 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3582 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3583 				plaintext_pad_len);
3584 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3585 
3586 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3587 
3588 	/* Create KASUMI operation */
3589 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3590 				tdata->cipher_iv.len,
3591 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3592 				tdata->validCipherOffsetInBits.len);
3593 	if (retval < 0)
3594 		return retval;
3595 
3596 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3597 						ut_params->op);
3598 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3599 
3600 	ut_params->obuf = ut_params->op->sym->m_dst;
3601 	if (ut_params->obuf)
3602 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3603 	else
3604 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3605 
3606 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3607 
3608 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3609 				(tdata->validCipherOffsetInBits.len >> 3);
3610 	/* Validate obuf */
3611 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3612 		ciphertext,
3613 		reference_ciphertext,
3614 		tdata->validCipherLenInBits.len,
3615 		"KASUMI Ciphertext data not as expected");
3616 	return 0;
3617 }
3618 
3619 static int
3620 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3621 {
3622 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3623 	struct crypto_unittest_params *ut_params = &unittest_params;
3624 
3625 	int retval;
3626 
3627 	unsigned int plaintext_pad_len;
3628 	unsigned int plaintext_len;
3629 
3630 	uint8_t buffer[10000];
3631 	const uint8_t *ciphertext;
3632 
3633 	struct rte_cryptodev_info dev_info;
3634 
3635 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3636 
3637 	uint64_t feat_flags = dev_info.feature_flags;
3638 
3639 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3640 		printf("Device doesn't support in-place scatter-gather. "
3641 				"Test Skipped.\n");
3642 		return -ENOTSUP;
3643 	}
3644 
3645 	/* Create KASUMI session */
3646 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3647 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3648 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3649 					tdata->key.data, tdata->key.len,
3650 					tdata->cipher_iv.len);
3651 	if (retval < 0)
3652 		return retval;
3653 
3654 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3655 
3656 
3657 	/* Append data which is padded to a multiple */
3658 	/* of the algorithms block size */
3659 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3660 
3661 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3662 			plaintext_pad_len, 10, 0);
3663 
3664 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3665 
3666 	/* Create KASUMI operation */
3667 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3668 				tdata->cipher_iv.len,
3669 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3670 				tdata->validCipherOffsetInBits.len);
3671 	if (retval < 0)
3672 		return retval;
3673 
3674 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3675 						ut_params->op);
3676 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3677 
3678 	ut_params->obuf = ut_params->op->sym->m_dst;
3679 
3680 	if (ut_params->obuf)
3681 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3682 				plaintext_len, buffer);
3683 	else
3684 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3685 				tdata->validCipherOffsetInBits.len >> 3,
3686 				plaintext_len, buffer);
3687 
3688 	/* Validate obuf */
3689 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3690 
3691 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3692 				(tdata->validCipherOffsetInBits.len >> 3);
3693 	/* Validate obuf */
3694 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3695 		ciphertext,
3696 		reference_ciphertext,
3697 		tdata->validCipherLenInBits.len,
3698 		"KASUMI Ciphertext data not as expected");
3699 	return 0;
3700 }
3701 
3702 static int
3703 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3704 {
3705 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3706 	struct crypto_unittest_params *ut_params = &unittest_params;
3707 
3708 	int retval;
3709 	uint8_t *plaintext, *ciphertext;
3710 	unsigned plaintext_pad_len;
3711 	unsigned plaintext_len;
3712 
3713 	/* Create KASUMI session */
3714 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3715 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3716 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3717 					tdata->key.data, tdata->key.len,
3718 					tdata->cipher_iv.len);
3719 	if (retval < 0)
3720 		return retval;
3721 
3722 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3723 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3724 
3725 	/* Clear mbuf payload */
3726 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3727 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3728 
3729 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3730 	/* Append data which is padded to a multiple */
3731 	/* of the algorithms block size */
3732 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3733 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3734 				plaintext_pad_len);
3735 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3736 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3737 
3738 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3739 
3740 	/* Create KASUMI operation */
3741 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3742 				tdata->cipher_iv.len,
3743 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3744 				tdata->validCipherOffsetInBits.len);
3745 	if (retval < 0)
3746 		return retval;
3747 
3748 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3749 						ut_params->op);
3750 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3751 
3752 	ut_params->obuf = ut_params->op->sym->m_dst;
3753 	if (ut_params->obuf)
3754 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3755 	else
3756 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3757 
3758 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3759 
3760 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3761 				(tdata->validCipherOffsetInBits.len >> 3);
3762 	/* Validate obuf */
3763 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3764 		ciphertext,
3765 		reference_ciphertext,
3766 		tdata->validCipherLenInBits.len,
3767 		"KASUMI Ciphertext data not as expected");
3768 	return 0;
3769 }
3770 
3771 static int
3772 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3773 {
3774 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3775 	struct crypto_unittest_params *ut_params = &unittest_params;
3776 
3777 	int retval;
3778 	unsigned int plaintext_pad_len;
3779 	unsigned int plaintext_len;
3780 
3781 	const uint8_t *ciphertext;
3782 	uint8_t buffer[2048];
3783 
3784 	struct rte_cryptodev_info dev_info;
3785 
3786 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3787 
3788 	uint64_t feat_flags = dev_info.feature_flags;
3789 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3790 		printf("Device doesn't support out-of-place scatter-gather "
3791 				"in both input and output mbufs. "
3792 				"Test Skipped.\n");
3793 		return -ENOTSUP;
3794 	}
3795 
3796 	/* Create KASUMI session */
3797 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3798 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3799 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3800 					tdata->key.data, tdata->key.len,
3801 					tdata->cipher_iv.len);
3802 	if (retval < 0)
3803 		return retval;
3804 
3805 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3806 	/* Append data which is padded to a multiple */
3807 	/* of the algorithms block size */
3808 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3809 
3810 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3811 			plaintext_pad_len, 10, 0);
3812 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3813 			plaintext_pad_len, 3, 0);
3814 
3815 	/* Append data which is padded to a multiple */
3816 	/* of the algorithms block size */
3817 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3818 
3819 	/* Create KASUMI operation */
3820 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3821 				tdata->cipher_iv.len,
3822 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3823 				tdata->validCipherOffsetInBits.len);
3824 	if (retval < 0)
3825 		return retval;
3826 
3827 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3828 						ut_params->op);
3829 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3830 
3831 	ut_params->obuf = ut_params->op->sym->m_dst;
3832 	if (ut_params->obuf)
3833 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3834 				plaintext_pad_len, buffer);
3835 	else
3836 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3837 				tdata->validCipherOffsetInBits.len >> 3,
3838 				plaintext_pad_len, buffer);
3839 
3840 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3841 				(tdata->validCipherOffsetInBits.len >> 3);
3842 	/* Validate obuf */
3843 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3844 		ciphertext,
3845 		reference_ciphertext,
3846 		tdata->validCipherLenInBits.len,
3847 		"KASUMI Ciphertext data not as expected");
3848 	return 0;
3849 }
3850 
3851 
3852 static int
3853 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3854 {
3855 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3856 	struct crypto_unittest_params *ut_params = &unittest_params;
3857 
3858 	int retval;
3859 	uint8_t *ciphertext, *plaintext;
3860 	unsigned ciphertext_pad_len;
3861 	unsigned ciphertext_len;
3862 
3863 	/* Create KASUMI session */
3864 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3865 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3866 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3867 					tdata->key.data, tdata->key.len,
3868 					tdata->cipher_iv.len);
3869 	if (retval < 0)
3870 		return retval;
3871 
3872 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3873 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3874 
3875 	/* Clear mbuf payload */
3876 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3877 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3878 
3879 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3880 	/* Append data which is padded to a multiple */
3881 	/* of the algorithms block size */
3882 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3883 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3884 				ciphertext_pad_len);
3885 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3886 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3887 
3888 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3889 
3890 	/* Create KASUMI operation */
3891 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3892 				tdata->cipher_iv.len,
3893 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3894 				tdata->validCipherOffsetInBits.len);
3895 	if (retval < 0)
3896 		return retval;
3897 
3898 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3899 						ut_params->op);
3900 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3901 
3902 	ut_params->obuf = ut_params->op->sym->m_dst;
3903 	if (ut_params->obuf)
3904 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3905 	else
3906 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3907 
3908 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3909 
3910 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3911 				(tdata->validCipherOffsetInBits.len >> 3);
3912 	/* Validate obuf */
3913 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3914 		plaintext,
3915 		reference_plaintext,
3916 		tdata->validCipherLenInBits.len,
3917 		"KASUMI Plaintext data not as expected");
3918 	return 0;
3919 }
3920 
3921 static int
3922 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3923 {
3924 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3925 	struct crypto_unittest_params *ut_params = &unittest_params;
3926 
3927 	int retval;
3928 	uint8_t *ciphertext, *plaintext;
3929 	unsigned ciphertext_pad_len;
3930 	unsigned ciphertext_len;
3931 
3932 	/* Create KASUMI session */
3933 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3934 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3935 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3936 					tdata->key.data, tdata->key.len,
3937 					tdata->cipher_iv.len);
3938 	if (retval < 0)
3939 		return retval;
3940 
3941 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3942 
3943 	/* Clear mbuf payload */
3944 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3945 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3946 
3947 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3948 	/* Append data which is padded to a multiple */
3949 	/* of the algorithms block size */
3950 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3951 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3952 				ciphertext_pad_len);
3953 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3954 
3955 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3956 
3957 	/* Create KASUMI operation */
3958 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3959 					tdata->cipher_iv.len,
3960 					tdata->ciphertext.len,
3961 					tdata->validCipherOffsetInBits.len);
3962 	if (retval < 0)
3963 		return retval;
3964 
3965 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3966 						ut_params->op);
3967 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3968 
3969 	ut_params->obuf = ut_params->op->sym->m_dst;
3970 	if (ut_params->obuf)
3971 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3972 	else
3973 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3974 
3975 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3976 
3977 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3978 				(tdata->validCipherOffsetInBits.len >> 3);
3979 	/* Validate obuf */
3980 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3981 		plaintext,
3982 		reference_plaintext,
3983 		tdata->validCipherLenInBits.len,
3984 		"KASUMI Plaintext data not as expected");
3985 	return 0;
3986 }
3987 
3988 static int
3989 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3990 {
3991 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3992 	struct crypto_unittest_params *ut_params = &unittest_params;
3993 
3994 	int retval;
3995 	uint8_t *plaintext, *ciphertext;
3996 	unsigned plaintext_pad_len;
3997 	unsigned plaintext_len;
3998 
3999 	/* Create SNOW 3G session */
4000 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4001 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4002 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4003 					tdata->key.data, tdata->key.len,
4004 					tdata->cipher_iv.len);
4005 	if (retval < 0)
4006 		return retval;
4007 
4008 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4009 
4010 	/* Clear mbuf payload */
4011 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4012 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4013 
4014 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4015 	/* Append data which is padded to a multiple of */
4016 	/* the algorithms block size */
4017 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4018 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4019 				plaintext_pad_len);
4020 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4021 
4022 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4023 
4024 	/* Create SNOW 3G operation */
4025 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4026 					tdata->cipher_iv.len,
4027 					tdata->validCipherLenInBits.len,
4028 					0);
4029 	if (retval < 0)
4030 		return retval;
4031 
4032 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4033 						ut_params->op);
4034 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4035 
4036 	ut_params->obuf = ut_params->op->sym->m_dst;
4037 	if (ut_params->obuf)
4038 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4039 	else
4040 		ciphertext = plaintext;
4041 
4042 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4043 
4044 	/* Validate obuf */
4045 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4046 		ciphertext,
4047 		tdata->ciphertext.data,
4048 		tdata->validDataLenInBits.len,
4049 		"SNOW 3G Ciphertext data not as expected");
4050 	return 0;
4051 }
4052 
4053 
4054 static int
4055 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4056 {
4057 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4058 	struct crypto_unittest_params *ut_params = &unittest_params;
4059 	uint8_t *plaintext, *ciphertext;
4060 
4061 	int retval;
4062 	unsigned plaintext_pad_len;
4063 	unsigned plaintext_len;
4064 
4065 	/* Create SNOW 3G session */
4066 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4067 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4068 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4069 					tdata->key.data, tdata->key.len,
4070 					tdata->cipher_iv.len);
4071 	if (retval < 0)
4072 		return retval;
4073 
4074 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4075 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4076 
4077 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4078 			"Failed to allocate input buffer in mempool");
4079 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4080 			"Failed to allocate output buffer in mempool");
4081 
4082 	/* Clear mbuf payload */
4083 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4084 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4085 
4086 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4087 	/* Append data which is padded to a multiple of */
4088 	/* the algorithms block size */
4089 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4090 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4091 				plaintext_pad_len);
4092 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4094 
4095 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4096 
4097 	/* Create SNOW 3G operation */
4098 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4099 					tdata->cipher_iv.len,
4100 					tdata->validCipherLenInBits.len,
4101 					0);
4102 	if (retval < 0)
4103 		return retval;
4104 
4105 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4106 						ut_params->op);
4107 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4108 
4109 	ut_params->obuf = ut_params->op->sym->m_dst;
4110 	if (ut_params->obuf)
4111 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4112 	else
4113 		ciphertext = plaintext;
4114 
4115 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4116 
4117 	/* Validate obuf */
4118 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4119 		ciphertext,
4120 		tdata->ciphertext.data,
4121 		tdata->validDataLenInBits.len,
4122 		"SNOW 3G Ciphertext data not as expected");
4123 	return 0;
4124 }
4125 
4126 static int
4127 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4128 {
4129 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4130 	struct crypto_unittest_params *ut_params = &unittest_params;
4131 
4132 	int retval;
4133 	unsigned int plaintext_pad_len;
4134 	unsigned int plaintext_len;
4135 	uint8_t buffer[10000];
4136 	const uint8_t *ciphertext;
4137 
4138 	struct rte_cryptodev_info dev_info;
4139 
4140 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4141 
4142 	uint64_t feat_flags = dev_info.feature_flags;
4143 
4144 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4145 		printf("Device doesn't support out-of-place scatter-gather "
4146 				"in both input and output mbufs. "
4147 				"Test Skipped.\n");
4148 		return -ENOTSUP;
4149 	}
4150 
4151 	/* Create SNOW 3G session */
4152 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4153 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4154 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4155 					tdata->key.data, tdata->key.len,
4156 					tdata->cipher_iv.len);
4157 	if (retval < 0)
4158 		return retval;
4159 
4160 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4161 	/* Append data which is padded to a multiple of */
4162 	/* the algorithms block size */
4163 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4164 
4165 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4166 			plaintext_pad_len, 10, 0);
4167 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4168 			plaintext_pad_len, 3, 0);
4169 
4170 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4171 			"Failed to allocate input buffer in mempool");
4172 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4173 			"Failed to allocate output buffer in mempool");
4174 
4175 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4176 
4177 	/* Create SNOW 3G operation */
4178 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4179 					tdata->cipher_iv.len,
4180 					tdata->validCipherLenInBits.len,
4181 					0);
4182 	if (retval < 0)
4183 		return retval;
4184 
4185 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4186 						ut_params->op);
4187 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4188 
4189 	ut_params->obuf = ut_params->op->sym->m_dst;
4190 	if (ut_params->obuf)
4191 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4192 				plaintext_len, buffer);
4193 	else
4194 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4195 				plaintext_len, buffer);
4196 
4197 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4198 
4199 	/* Validate obuf */
4200 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4201 		ciphertext,
4202 		tdata->ciphertext.data,
4203 		tdata->validDataLenInBits.len,
4204 		"SNOW 3G Ciphertext data not as expected");
4205 
4206 	return 0;
4207 }
4208 
4209 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4210 static void
4211 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4212 {
4213 	uint8_t curr_byte, prev_byte;
4214 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4215 	uint8_t lower_byte_mask = (1 << offset) - 1;
4216 	unsigned i;
4217 
4218 	prev_byte = buffer[0];
4219 	buffer[0] >>= offset;
4220 
4221 	for (i = 1; i < length_in_bytes; i++) {
4222 		curr_byte = buffer[i];
4223 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4224 				(curr_byte >> offset);
4225 		prev_byte = curr_byte;
4226 	}
4227 }
4228 
4229 static int
4230 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4231 {
4232 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4233 	struct crypto_unittest_params *ut_params = &unittest_params;
4234 	uint8_t *plaintext, *ciphertext;
4235 	int retval;
4236 	uint32_t plaintext_len;
4237 	uint32_t plaintext_pad_len;
4238 	uint8_t extra_offset = 4;
4239 	uint8_t *expected_ciphertext_shifted;
4240 
4241 	/* Create SNOW 3G session */
4242 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4243 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4244 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4245 					tdata->key.data, tdata->key.len,
4246 					tdata->cipher_iv.len);
4247 	if (retval < 0)
4248 		return retval;
4249 
4250 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4251 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4252 
4253 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4254 			"Failed to allocate input buffer in mempool");
4255 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4256 			"Failed to allocate output buffer in mempool");
4257 
4258 	/* Clear mbuf payload */
4259 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4260 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4261 
4262 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4263 	/*
4264 	 * Append data which is padded to a
4265 	 * multiple of the algorithms block size
4266 	 */
4267 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4268 
4269 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4270 						plaintext_pad_len);
4271 
4272 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4273 
4274 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4275 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4276 
4277 #ifdef RTE_APP_TEST_DEBUG
4278 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4279 #endif
4280 	/* Create SNOW 3G operation */
4281 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4282 					tdata->cipher_iv.len,
4283 					tdata->validCipherLenInBits.len,
4284 					extra_offset);
4285 	if (retval < 0)
4286 		return retval;
4287 
4288 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4289 						ut_params->op);
4290 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4291 
4292 	ut_params->obuf = ut_params->op->sym->m_dst;
4293 	if (ut_params->obuf)
4294 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4295 	else
4296 		ciphertext = plaintext;
4297 
4298 #ifdef RTE_APP_TEST_DEBUG
4299 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4300 #endif
4301 
4302 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4303 
4304 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4305 			"failed to reserve memory for ciphertext shifted\n");
4306 
4307 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4308 			ceil_byte_length(tdata->ciphertext.len));
4309 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4310 			extra_offset);
4311 	/* Validate obuf */
4312 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4313 		ciphertext,
4314 		expected_ciphertext_shifted,
4315 		tdata->validDataLenInBits.len,
4316 		extra_offset,
4317 		"SNOW 3G Ciphertext data not as expected");
4318 	return 0;
4319 }
4320 
4321 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4322 {
4323 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4324 	struct crypto_unittest_params *ut_params = &unittest_params;
4325 
4326 	int retval;
4327 
4328 	uint8_t *plaintext, *ciphertext;
4329 	unsigned ciphertext_pad_len;
4330 	unsigned ciphertext_len;
4331 
4332 	/* Create SNOW 3G session */
4333 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4334 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4335 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4336 					tdata->key.data, tdata->key.len,
4337 					tdata->cipher_iv.len);
4338 	if (retval < 0)
4339 		return retval;
4340 
4341 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4342 
4343 	/* Clear mbuf payload */
4344 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4345 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4346 
4347 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4348 	/* Append data which is padded to a multiple of */
4349 	/* the algorithms block size */
4350 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4351 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4352 				ciphertext_pad_len);
4353 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4354 
4355 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4356 
4357 	/* Create SNOW 3G operation */
4358 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4359 					tdata->cipher_iv.len,
4360 					tdata->validCipherLenInBits.len,
4361 					tdata->cipher.offset_bits);
4362 	if (retval < 0)
4363 		return retval;
4364 
4365 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4366 						ut_params->op);
4367 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4368 	ut_params->obuf = ut_params->op->sym->m_dst;
4369 	if (ut_params->obuf)
4370 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4371 	else
4372 		plaintext = ciphertext;
4373 
4374 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4375 
4376 	/* Validate obuf */
4377 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4378 				tdata->plaintext.data,
4379 				tdata->validDataLenInBits.len,
4380 				"SNOW 3G Plaintext data not as expected");
4381 	return 0;
4382 }
4383 
4384 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4385 {
4386 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4387 	struct crypto_unittest_params *ut_params = &unittest_params;
4388 
4389 	int retval;
4390 
4391 	uint8_t *plaintext, *ciphertext;
4392 	unsigned ciphertext_pad_len;
4393 	unsigned ciphertext_len;
4394 
4395 	/* Create SNOW 3G session */
4396 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4397 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4398 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4399 					tdata->key.data, tdata->key.len,
4400 					tdata->cipher_iv.len);
4401 	if (retval < 0)
4402 		return retval;
4403 
4404 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4405 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4406 
4407 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4408 			"Failed to allocate input buffer");
4409 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4410 			"Failed to allocate output buffer");
4411 
4412 	/* Clear mbuf payload */
4413 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4414 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4415 
4416 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4417 		       rte_pktmbuf_tailroom(ut_params->obuf));
4418 
4419 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4420 	/* Append data which is padded to a multiple of */
4421 	/* the algorithms block size */
4422 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4423 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4424 				ciphertext_pad_len);
4425 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4426 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4427 
4428 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4429 
4430 	/* Create SNOW 3G operation */
4431 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4432 					tdata->cipher_iv.len,
4433 					tdata->validCipherLenInBits.len,
4434 					0);
4435 	if (retval < 0)
4436 		return retval;
4437 
4438 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4439 						ut_params->op);
4440 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4441 	ut_params->obuf = ut_params->op->sym->m_dst;
4442 	if (ut_params->obuf)
4443 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4444 	else
4445 		plaintext = ciphertext;
4446 
4447 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4448 
4449 	/* Validate obuf */
4450 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4451 				tdata->plaintext.data,
4452 				tdata->validDataLenInBits.len,
4453 				"SNOW 3G Plaintext data not as expected");
4454 	return 0;
4455 }
4456 
4457 static int
4458 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4459 {
4460 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4461 	struct crypto_unittest_params *ut_params = &unittest_params;
4462 
4463 	int retval;
4464 
4465 	uint8_t *plaintext, *ciphertext;
4466 	unsigned int plaintext_pad_len;
4467 	unsigned int plaintext_len;
4468 
4469 	struct rte_cryptodev_sym_capability_idx cap_idx;
4470 
4471 	/* Check if device supports ZUC EEA3 */
4472 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4473 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4474 
4475 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4476 			&cap_idx) == NULL)
4477 		return -ENOTSUP;
4478 
4479 	/* Check if device supports ZUC EIA3 */
4480 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4481 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4482 
4483 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4484 			&cap_idx) == NULL)
4485 		return -ENOTSUP;
4486 
4487 	/* Create ZUC session */
4488 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4489 			ts_params->valid_devs[0],
4490 			tdata);
4491 	if (retval < 0)
4492 		return retval;
4493 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4494 
4495 	/* clear mbuf payload */
4496 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4497 			rte_pktmbuf_tailroom(ut_params->ibuf));
4498 
4499 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4500 	/* Append data which is padded to a multiple of */
4501 	/* the algorithms block size */
4502 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4503 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4504 				plaintext_pad_len);
4505 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4506 
4507 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4508 
4509 	/* Create ZUC operation */
4510 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4511 	if (retval < 0)
4512 		return retval;
4513 
4514 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4515 			ut_params->op);
4516 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4517 	ut_params->obuf = ut_params->op->sym->m_src;
4518 	if (ut_params->obuf)
4519 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4520 	else
4521 		ciphertext = plaintext;
4522 
4523 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4524 	/* Validate obuf */
4525 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4526 			ciphertext,
4527 			tdata->ciphertext.data,
4528 			tdata->validDataLenInBits.len,
4529 			"ZUC Ciphertext data not as expected");
4530 
4531 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4532 	    + plaintext_pad_len;
4533 
4534 	/* Validate obuf */
4535 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4536 			ut_params->digest,
4537 			tdata->digest.data,
4538 			4,
4539 			"ZUC Generated auth tag not as expected");
4540 	return 0;
4541 }
4542 
4543 static int
4544 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4545 {
4546 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4547 	struct crypto_unittest_params *ut_params = &unittest_params;
4548 
4549 	int retval;
4550 
4551 	uint8_t *plaintext, *ciphertext;
4552 	unsigned plaintext_pad_len;
4553 	unsigned plaintext_len;
4554 
4555 	/* Create SNOW 3G session */
4556 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4557 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4558 			RTE_CRYPTO_AUTH_OP_GENERATE,
4559 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4560 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4561 			tdata->key.data, tdata->key.len,
4562 			tdata->auth_iv.len, tdata->digest.len,
4563 			tdata->cipher_iv.len);
4564 	if (retval < 0)
4565 		return retval;
4566 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4567 
4568 	/* clear mbuf payload */
4569 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4570 			rte_pktmbuf_tailroom(ut_params->ibuf));
4571 
4572 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4573 	/* Append data which is padded to a multiple of */
4574 	/* the algorithms block size */
4575 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4576 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4577 				plaintext_pad_len);
4578 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4579 
4580 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4581 
4582 	/* Create SNOW 3G operation */
4583 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4584 			tdata->digest.len, tdata->auth_iv.data,
4585 			tdata->auth_iv.len,
4586 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4587 			tdata->cipher_iv.data, tdata->cipher_iv.len,
4588 			tdata->validCipherLenInBits.len,
4589 			0,
4590 			tdata->validAuthLenInBits.len,
4591 			0
4592 			);
4593 	if (retval < 0)
4594 		return retval;
4595 
4596 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4597 			ut_params->op);
4598 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4599 	ut_params->obuf = ut_params->op->sym->m_src;
4600 	if (ut_params->obuf)
4601 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4602 	else
4603 		ciphertext = plaintext;
4604 
4605 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4606 	/* Validate obuf */
4607 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4608 			ciphertext,
4609 			tdata->ciphertext.data,
4610 			tdata->validDataLenInBits.len,
4611 			"SNOW 3G Ciphertext data not as expected");
4612 
4613 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4614 	    + plaintext_pad_len;
4615 
4616 	/* Validate obuf */
4617 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4618 			ut_params->digest,
4619 			tdata->digest.data,
4620 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4621 			"SNOW 3G Generated auth tag not as expected");
4622 	return 0;
4623 }
4624 
4625 static int
4626 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4627 	uint8_t op_mode, uint8_t verify)
4628 {
4629 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4630 	struct crypto_unittest_params *ut_params = &unittest_params;
4631 
4632 	int retval;
4633 
4634 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4635 	unsigned int plaintext_pad_len;
4636 	unsigned int plaintext_len;
4637 	unsigned int ciphertext_pad_len;
4638 	unsigned int ciphertext_len;
4639 
4640 	struct rte_cryptodev_info dev_info;
4641 
4642 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4643 
4644 	uint64_t feat_flags = dev_info.feature_flags;
4645 
4646 	if (op_mode == OUT_OF_PLACE) {
4647 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4648 			printf("Device doesn't support digest encrypted.\n");
4649 			return -ENOTSUP;
4650 		}
4651 	}
4652 
4653 	/* Create SNOW 3G session */
4654 	retval = create_wireless_algo_auth_cipher_session(
4655 			ts_params->valid_devs[0],
4656 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4657 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4658 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4659 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4660 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4661 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4662 			tdata->key.data, tdata->key.len,
4663 			tdata->auth_iv.len, tdata->digest.len,
4664 			tdata->cipher_iv.len);
4665 
4666 	if (retval < 0)
4667 		return retval;
4668 
4669 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4670 	if (op_mode == OUT_OF_PLACE)
4671 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4672 
4673 	/* clear mbuf payload */
4674 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4675 		rte_pktmbuf_tailroom(ut_params->ibuf));
4676 	if (op_mode == OUT_OF_PLACE)
4677 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4678 			rte_pktmbuf_tailroom(ut_params->obuf));
4679 
4680 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4681 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4682 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4683 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4684 
4685 	if (verify) {
4686 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4687 					ciphertext_pad_len);
4688 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4689 		if (op_mode == OUT_OF_PLACE)
4690 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4691 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4692 			ciphertext_len);
4693 	} else {
4694 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4695 					plaintext_pad_len);
4696 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4697 		if (op_mode == OUT_OF_PLACE)
4698 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4699 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4700 	}
4701 
4702 	/* Create SNOW 3G operation */
4703 	retval = create_wireless_algo_auth_cipher_operation(
4704 		tdata->digest.data, tdata->digest.len,
4705 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4706 		tdata->auth_iv.data, tdata->auth_iv.len,
4707 		(tdata->digest.offset_bytes == 0 ?
4708 		(verify ? ciphertext_pad_len : plaintext_pad_len)
4709 			: tdata->digest.offset_bytes),
4710 		tdata->validCipherLenInBits.len,
4711 		tdata->cipher.offset_bits,
4712 		tdata->validAuthLenInBits.len,
4713 		tdata->auth.offset_bits,
4714 		op_mode, 0, verify);
4715 
4716 	if (retval < 0)
4717 		return retval;
4718 
4719 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4720 			ut_params->op);
4721 
4722 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4723 
4724 	ut_params->obuf = (op_mode == IN_PLACE ?
4725 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4726 
4727 	if (verify) {
4728 		if (ut_params->obuf)
4729 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4730 							uint8_t *);
4731 		else
4732 			plaintext = ciphertext +
4733 				(tdata->cipher.offset_bits >> 3);
4734 
4735 		debug_hexdump(stdout, "plaintext:", plaintext,
4736 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4737 		debug_hexdump(stdout, "plaintext expected:",
4738 			tdata->plaintext.data,
4739 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4740 	} else {
4741 		if (ut_params->obuf)
4742 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4743 							uint8_t *);
4744 		else
4745 			ciphertext = plaintext;
4746 
4747 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4748 			ciphertext_len);
4749 		debug_hexdump(stdout, "ciphertext expected:",
4750 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4751 
4752 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4753 			+ (tdata->digest.offset_bytes == 0 ?
4754 		plaintext_pad_len : tdata->digest.offset_bytes);
4755 
4756 		debug_hexdump(stdout, "digest:", ut_params->digest,
4757 			tdata->digest.len);
4758 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4759 				tdata->digest.len);
4760 	}
4761 
4762 	/* Validate obuf */
4763 	if (verify) {
4764 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4765 			plaintext,
4766 			tdata->plaintext.data,
4767 			tdata->plaintext.len >> 3,
4768 			"SNOW 3G Plaintext data not as expected");
4769 	} else {
4770 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4771 			ciphertext,
4772 			tdata->ciphertext.data,
4773 			tdata->validDataLenInBits.len,
4774 			"SNOW 3G Ciphertext data not as expected");
4775 
4776 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
4777 			ut_params->digest,
4778 			tdata->digest.data,
4779 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4780 			"SNOW 3G Generated auth tag not as expected");
4781 	}
4782 	return 0;
4783 }
4784 
4785 static int
4786 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4787 	uint8_t op_mode, uint8_t verify)
4788 {
4789 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4790 	struct crypto_unittest_params *ut_params = &unittest_params;
4791 
4792 	int retval;
4793 
4794 	const uint8_t *plaintext = NULL;
4795 	const uint8_t *ciphertext = NULL;
4796 	const uint8_t *digest = NULL;
4797 	unsigned int plaintext_pad_len;
4798 	unsigned int plaintext_len;
4799 	unsigned int ciphertext_pad_len;
4800 	unsigned int ciphertext_len;
4801 	uint8_t buffer[10000];
4802 	uint8_t digest_buffer[10000];
4803 
4804 	struct rte_cryptodev_info dev_info;
4805 
4806 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4807 
4808 	uint64_t feat_flags = dev_info.feature_flags;
4809 
4810 	if (op_mode == IN_PLACE) {
4811 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4812 			printf("Device doesn't support in-place scatter-gather "
4813 					"in both input and output mbufs.\n");
4814 			return -ENOTSUP;
4815 		}
4816 	} else {
4817 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4818 			printf("Device doesn't support out-of-place scatter-gather "
4819 					"in both input and output mbufs.\n");
4820 			return -ENOTSUP;
4821 		}
4822 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4823 			printf("Device doesn't support digest encrypted.\n");
4824 			return -ENOTSUP;
4825 		}
4826 	}
4827 
4828 	/* Create SNOW 3G session */
4829 	retval = create_wireless_algo_auth_cipher_session(
4830 			ts_params->valid_devs[0],
4831 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4832 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4833 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4834 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4835 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4836 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4837 			tdata->key.data, tdata->key.len,
4838 			tdata->auth_iv.len, tdata->digest.len,
4839 			tdata->cipher_iv.len);
4840 
4841 	if (retval < 0)
4842 		return retval;
4843 
4844 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4845 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4846 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4847 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4848 
4849 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4850 			plaintext_pad_len, 15, 0);
4851 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4852 			"Failed to allocate input buffer in mempool");
4853 
4854 	if (op_mode == OUT_OF_PLACE) {
4855 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4856 				plaintext_pad_len, 15, 0);
4857 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
4858 				"Failed to allocate output buffer in mempool");
4859 	}
4860 
4861 	if (verify) {
4862 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4863 			tdata->ciphertext.data);
4864 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4865 					ciphertext_len, buffer);
4866 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4867 			ciphertext_len);
4868 	} else {
4869 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4870 			tdata->plaintext.data);
4871 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4872 					plaintext_len, buffer);
4873 		debug_hexdump(stdout, "plaintext:", plaintext,
4874 			plaintext_len);
4875 	}
4876 	memset(buffer, 0, sizeof(buffer));
4877 
4878 	/* Create SNOW 3G operation */
4879 	retval = create_wireless_algo_auth_cipher_operation(
4880 		tdata->digest.data, tdata->digest.len,
4881 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4882 		tdata->auth_iv.data, tdata->auth_iv.len,
4883 		(tdata->digest.offset_bytes == 0 ?
4884 		(verify ? ciphertext_pad_len : plaintext_pad_len)
4885 			: tdata->digest.offset_bytes),
4886 		tdata->validCipherLenInBits.len,
4887 		tdata->cipher.offset_bits,
4888 		tdata->validAuthLenInBits.len,
4889 		tdata->auth.offset_bits,
4890 		op_mode, 1, verify);
4891 
4892 	if (retval < 0)
4893 		return retval;
4894 
4895 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4896 			ut_params->op);
4897 
4898 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4899 
4900 	ut_params->obuf = (op_mode == IN_PLACE ?
4901 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4902 
4903 	if (verify) {
4904 		if (ut_params->obuf)
4905 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4906 					plaintext_len, buffer);
4907 		else
4908 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4909 					plaintext_len, buffer);
4910 
4911 		debug_hexdump(stdout, "plaintext:", plaintext,
4912 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4913 		debug_hexdump(stdout, "plaintext expected:",
4914 			tdata->plaintext.data,
4915 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4916 	} else {
4917 		if (ut_params->obuf)
4918 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4919 					ciphertext_len, buffer);
4920 		else
4921 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4922 					ciphertext_len, buffer);
4923 
4924 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4925 			ciphertext_len);
4926 		debug_hexdump(stdout, "ciphertext expected:",
4927 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4928 
4929 		if (ut_params->obuf)
4930 			digest = rte_pktmbuf_read(ut_params->obuf,
4931 				(tdata->digest.offset_bytes == 0 ?
4932 				plaintext_pad_len : tdata->digest.offset_bytes),
4933 				tdata->digest.len, digest_buffer);
4934 		else
4935 			digest = rte_pktmbuf_read(ut_params->ibuf,
4936 				(tdata->digest.offset_bytes == 0 ?
4937 				plaintext_pad_len : tdata->digest.offset_bytes),
4938 				tdata->digest.len, digest_buffer);
4939 
4940 		debug_hexdump(stdout, "digest:", digest,
4941 			tdata->digest.len);
4942 		debug_hexdump(stdout, "digest expected:",
4943 			tdata->digest.data, tdata->digest.len);
4944 	}
4945 
4946 	/* Validate obuf */
4947 	if (verify) {
4948 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4949 			plaintext,
4950 			tdata->plaintext.data,
4951 			tdata->plaintext.len >> 3,
4952 			"SNOW 3G Plaintext data not as expected");
4953 	} else {
4954 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4955 			ciphertext,
4956 			tdata->ciphertext.data,
4957 			tdata->validDataLenInBits.len,
4958 			"SNOW 3G Ciphertext data not as expected");
4959 
4960 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
4961 			digest,
4962 			tdata->digest.data,
4963 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4964 			"SNOW 3G Generated auth tag not as expected");
4965 	}
4966 	return 0;
4967 }
4968 
4969 static int
4970 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4971 	uint8_t op_mode, uint8_t verify)
4972 {
4973 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4974 	struct crypto_unittest_params *ut_params = &unittest_params;
4975 
4976 	int retval;
4977 
4978 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4979 	unsigned int plaintext_pad_len;
4980 	unsigned int plaintext_len;
4981 	unsigned int ciphertext_pad_len;
4982 	unsigned int ciphertext_len;
4983 
4984 	struct rte_cryptodev_info dev_info;
4985 
4986 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4987 
4988 	uint64_t feat_flags = dev_info.feature_flags;
4989 
4990 	if (op_mode == OUT_OF_PLACE) {
4991 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4992 			printf("Device doesn't support digest encrypted.\n");
4993 			return -ENOTSUP;
4994 		}
4995 	}
4996 
4997 	/* Create KASUMI session */
4998 	retval = create_wireless_algo_auth_cipher_session(
4999 			ts_params->valid_devs[0],
5000 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5001 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5002 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5003 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5004 			RTE_CRYPTO_AUTH_KASUMI_F9,
5005 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5006 			tdata->key.data, tdata->key.len,
5007 			0, tdata->digest.len,
5008 			tdata->cipher_iv.len);
5009 
5010 	if (retval < 0)
5011 		return retval;
5012 
5013 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5014 	if (op_mode == OUT_OF_PLACE)
5015 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5016 
5017 	/* clear mbuf payload */
5018 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5019 		rte_pktmbuf_tailroom(ut_params->ibuf));
5020 	if (op_mode == OUT_OF_PLACE)
5021 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5022 			rte_pktmbuf_tailroom(ut_params->obuf));
5023 
5024 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5025 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5026 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5027 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5028 
5029 	if (verify) {
5030 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5031 					ciphertext_pad_len);
5032 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5033 		if (op_mode == OUT_OF_PLACE)
5034 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5035 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5036 			ciphertext_len);
5037 	} else {
5038 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5039 					plaintext_pad_len);
5040 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5041 		if (op_mode == OUT_OF_PLACE)
5042 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5043 		debug_hexdump(stdout, "plaintext:", plaintext,
5044 			plaintext_len);
5045 	}
5046 
5047 	/* Create KASUMI operation */
5048 	retval = create_wireless_algo_auth_cipher_operation(
5049 		tdata->digest.data, tdata->digest.len,
5050 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5051 		NULL, 0,
5052 		(tdata->digest.offset_bytes == 0 ?
5053 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5054 			: tdata->digest.offset_bytes),
5055 		tdata->validCipherLenInBits.len,
5056 		tdata->validCipherOffsetInBits.len,
5057 		tdata->validAuthLenInBits.len,
5058 		0,
5059 		op_mode, 0, verify);
5060 
5061 	if (retval < 0)
5062 		return retval;
5063 
5064 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5065 			ut_params->op);
5066 
5067 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5068 
5069 	ut_params->obuf = (op_mode == IN_PLACE ?
5070 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5071 
5072 
5073 	if (verify) {
5074 		if (ut_params->obuf)
5075 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5076 							uint8_t *);
5077 		else
5078 			plaintext = ciphertext;
5079 
5080 		debug_hexdump(stdout, "plaintext:", plaintext,
5081 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5082 		debug_hexdump(stdout, "plaintext expected:",
5083 			tdata->plaintext.data,
5084 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5085 	} else {
5086 		if (ut_params->obuf)
5087 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5088 							uint8_t *);
5089 		else
5090 			ciphertext = plaintext;
5091 
5092 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5093 			ciphertext_len);
5094 		debug_hexdump(stdout, "ciphertext expected:",
5095 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5096 
5097 		ut_params->digest = rte_pktmbuf_mtod(
5098 			ut_params->obuf, uint8_t *) +
5099 			(tdata->digest.offset_bytes == 0 ?
5100 			plaintext_pad_len : tdata->digest.offset_bytes);
5101 
5102 		debug_hexdump(stdout, "digest:", ut_params->digest,
5103 			tdata->digest.len);
5104 		debug_hexdump(stdout, "digest expected:",
5105 			tdata->digest.data, tdata->digest.len);
5106 	}
5107 
5108 	/* Validate obuf */
5109 	if (verify) {
5110 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5111 			plaintext,
5112 			tdata->plaintext.data,
5113 			tdata->plaintext.len >> 3,
5114 			"KASUMI Plaintext data not as expected");
5115 	} else {
5116 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5117 			ciphertext,
5118 			tdata->ciphertext.data,
5119 			tdata->ciphertext.len >> 3,
5120 			"KASUMI Ciphertext data not as expected");
5121 
5122 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5123 			ut_params->digest,
5124 			tdata->digest.data,
5125 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5126 			"KASUMI Generated auth tag not as expected");
5127 	}
5128 	return 0;
5129 }
5130 
5131 static int
5132 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5133 	uint8_t op_mode, uint8_t verify)
5134 {
5135 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5136 	struct crypto_unittest_params *ut_params = &unittest_params;
5137 
5138 	int retval;
5139 
5140 	const uint8_t *plaintext = NULL;
5141 	const uint8_t *ciphertext = NULL;
5142 	const uint8_t *digest = NULL;
5143 	unsigned int plaintext_pad_len;
5144 	unsigned int plaintext_len;
5145 	unsigned int ciphertext_pad_len;
5146 	unsigned int ciphertext_len;
5147 	uint8_t buffer[10000];
5148 	uint8_t digest_buffer[10000];
5149 
5150 	struct rte_cryptodev_info dev_info;
5151 
5152 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5153 
5154 	uint64_t feat_flags = dev_info.feature_flags;
5155 
5156 	if (op_mode == IN_PLACE) {
5157 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5158 			printf("Device doesn't support in-place scatter-gather "
5159 					"in both input and output mbufs.\n");
5160 			return -ENOTSUP;
5161 		}
5162 	} else {
5163 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5164 			printf("Device doesn't support out-of-place scatter-gather "
5165 					"in both input and output mbufs.\n");
5166 			return -ENOTSUP;
5167 		}
5168 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5169 			printf("Device doesn't support digest encrypted.\n");
5170 			return -ENOTSUP;
5171 		}
5172 	}
5173 
5174 	/* Create KASUMI session */
5175 	retval = create_wireless_algo_auth_cipher_session(
5176 			ts_params->valid_devs[0],
5177 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5178 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5179 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5180 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5181 			RTE_CRYPTO_AUTH_KASUMI_F9,
5182 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5183 			tdata->key.data, tdata->key.len,
5184 			0, tdata->digest.len,
5185 			tdata->cipher_iv.len);
5186 
5187 	if (retval < 0)
5188 		return retval;
5189 
5190 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5191 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5192 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5193 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5194 
5195 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5196 			plaintext_pad_len, 15, 0);
5197 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5198 			"Failed to allocate input buffer in mempool");
5199 
5200 	if (op_mode == OUT_OF_PLACE) {
5201 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5202 				plaintext_pad_len, 15, 0);
5203 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5204 				"Failed to allocate output buffer in mempool");
5205 	}
5206 
5207 	if (verify) {
5208 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5209 			tdata->ciphertext.data);
5210 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5211 					ciphertext_len, buffer);
5212 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5213 			ciphertext_len);
5214 	} else {
5215 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5216 			tdata->plaintext.data);
5217 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5218 					plaintext_len, buffer);
5219 		debug_hexdump(stdout, "plaintext:", plaintext,
5220 			plaintext_len);
5221 	}
5222 	memset(buffer, 0, sizeof(buffer));
5223 
5224 	/* Create KASUMI operation */
5225 	retval = create_wireless_algo_auth_cipher_operation(
5226 		tdata->digest.data, tdata->digest.len,
5227 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5228 		NULL, 0,
5229 		(tdata->digest.offset_bytes == 0 ?
5230 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5231 			: tdata->digest.offset_bytes),
5232 		tdata->validCipherLenInBits.len,
5233 		tdata->validCipherOffsetInBits.len,
5234 		tdata->validAuthLenInBits.len,
5235 		0,
5236 		op_mode, 1, verify);
5237 
5238 	if (retval < 0)
5239 		return retval;
5240 
5241 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5242 			ut_params->op);
5243 
5244 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5245 
5246 	ut_params->obuf = (op_mode == IN_PLACE ?
5247 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5248 
5249 	if (verify) {
5250 		if (ut_params->obuf)
5251 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5252 					plaintext_len, buffer);
5253 		else
5254 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5255 					plaintext_len, buffer);
5256 
5257 		debug_hexdump(stdout, "plaintext:", plaintext,
5258 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5259 		debug_hexdump(stdout, "plaintext expected:",
5260 			tdata->plaintext.data,
5261 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5262 	} else {
5263 		if (ut_params->obuf)
5264 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5265 					ciphertext_len, buffer);
5266 		else
5267 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5268 					ciphertext_len, buffer);
5269 
5270 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5271 			ciphertext_len);
5272 		debug_hexdump(stdout, "ciphertext expected:",
5273 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5274 
5275 		if (ut_params->obuf)
5276 			digest = rte_pktmbuf_read(ut_params->obuf,
5277 				(tdata->digest.offset_bytes == 0 ?
5278 				plaintext_pad_len : tdata->digest.offset_bytes),
5279 				tdata->digest.len, digest_buffer);
5280 		else
5281 			digest = rte_pktmbuf_read(ut_params->ibuf,
5282 				(tdata->digest.offset_bytes == 0 ?
5283 				plaintext_pad_len : tdata->digest.offset_bytes),
5284 				tdata->digest.len, digest_buffer);
5285 
5286 		debug_hexdump(stdout, "digest:", digest,
5287 			tdata->digest.len);
5288 		debug_hexdump(stdout, "digest expected:",
5289 			tdata->digest.data, tdata->digest.len);
5290 	}
5291 
5292 	/* Validate obuf */
5293 	if (verify) {
5294 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5295 			plaintext,
5296 			tdata->plaintext.data,
5297 			tdata->plaintext.len >> 3,
5298 			"KASUMI Plaintext data not as expected");
5299 	} else {
5300 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5301 			ciphertext,
5302 			tdata->ciphertext.data,
5303 			tdata->validDataLenInBits.len,
5304 			"KASUMI Ciphertext data not as expected");
5305 
5306 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5307 			digest,
5308 			tdata->digest.data,
5309 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5310 			"KASUMI Generated auth tag not as expected");
5311 	}
5312 	return 0;
5313 }
5314 
5315 static int
5316 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5317 {
5318 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5319 	struct crypto_unittest_params *ut_params = &unittest_params;
5320 
5321 	int retval;
5322 
5323 	uint8_t *plaintext, *ciphertext;
5324 	unsigned plaintext_pad_len;
5325 	unsigned plaintext_len;
5326 
5327 	/* Create KASUMI session */
5328 	retval = create_wireless_algo_cipher_auth_session(
5329 			ts_params->valid_devs[0],
5330 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5331 			RTE_CRYPTO_AUTH_OP_GENERATE,
5332 			RTE_CRYPTO_AUTH_KASUMI_F9,
5333 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5334 			tdata->key.data, tdata->key.len,
5335 			0, tdata->digest.len,
5336 			tdata->cipher_iv.len);
5337 	if (retval < 0)
5338 		return retval;
5339 
5340 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5341 
5342 	/* clear mbuf payload */
5343 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5344 			rte_pktmbuf_tailroom(ut_params->ibuf));
5345 
5346 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5347 	/* Append data which is padded to a multiple of */
5348 	/* the algorithms block size */
5349 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5350 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5351 				plaintext_pad_len);
5352 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5353 
5354 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5355 
5356 	/* Create KASUMI operation */
5357 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5358 				tdata->digest.len, NULL, 0,
5359 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5360 				tdata->cipher_iv.data, tdata->cipher_iv.len,
5361 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5362 				tdata->validCipherOffsetInBits.len,
5363 				tdata->validAuthLenInBits.len,
5364 				0
5365 				);
5366 	if (retval < 0)
5367 		return retval;
5368 
5369 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5370 			ut_params->op);
5371 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5372 
5373 	if (ut_params->op->sym->m_dst)
5374 		ut_params->obuf = ut_params->op->sym->m_dst;
5375 	else
5376 		ut_params->obuf = ut_params->op->sym->m_src;
5377 
5378 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5379 				tdata->validCipherOffsetInBits.len >> 3);
5380 
5381 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5382 			+ plaintext_pad_len;
5383 
5384 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5385 				(tdata->validCipherOffsetInBits.len >> 3);
5386 	/* Validate obuf */
5387 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5388 		ciphertext,
5389 		reference_ciphertext,
5390 		tdata->validCipherLenInBits.len,
5391 		"KASUMI Ciphertext data not as expected");
5392 
5393 	/* Validate obuf */
5394 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5395 		ut_params->digest,
5396 		tdata->digest.data,
5397 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5398 		"KASUMI Generated auth tag not as expected");
5399 	return 0;
5400 }
5401 
5402 static int
5403 test_zuc_encryption(const struct wireless_test_data *tdata)
5404 {
5405 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5406 	struct crypto_unittest_params *ut_params = &unittest_params;
5407 
5408 	int retval;
5409 	uint8_t *plaintext, *ciphertext;
5410 	unsigned plaintext_pad_len;
5411 	unsigned plaintext_len;
5412 
5413 	struct rte_cryptodev_sym_capability_idx cap_idx;
5414 
5415 	/* Check if device supports ZUC EEA3 */
5416 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5417 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5418 
5419 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5420 			&cap_idx) == NULL)
5421 		return -ENOTSUP;
5422 
5423 	/* Create ZUC session */
5424 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5425 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5426 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
5427 					tdata->key.data, tdata->key.len,
5428 					tdata->cipher_iv.len);
5429 	if (retval < 0)
5430 		return retval;
5431 
5432 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5433 
5434 	/* Clear mbuf payload */
5435 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5436 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5437 
5438 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5439 	/* Append data which is padded to a multiple */
5440 	/* of the algorithms block size */
5441 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5442 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5443 				plaintext_pad_len);
5444 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5445 
5446 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5447 
5448 	/* Create ZUC operation */
5449 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5450 					tdata->cipher_iv.len,
5451 					tdata->plaintext.len,
5452 					0);
5453 	if (retval < 0)
5454 		return retval;
5455 
5456 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5457 						ut_params->op);
5458 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5459 
5460 	ut_params->obuf = ut_params->op->sym->m_dst;
5461 	if (ut_params->obuf)
5462 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5463 	else
5464 		ciphertext = plaintext;
5465 
5466 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5467 
5468 	/* Validate obuf */
5469 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5470 		ciphertext,
5471 		tdata->ciphertext.data,
5472 		tdata->validCipherLenInBits.len,
5473 		"ZUC Ciphertext data not as expected");
5474 	return 0;
5475 }
5476 
5477 static int
5478 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5479 {
5480 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5481 	struct crypto_unittest_params *ut_params = &unittest_params;
5482 
5483 	int retval;
5484 
5485 	unsigned int plaintext_pad_len;
5486 	unsigned int plaintext_len;
5487 	const uint8_t *ciphertext;
5488 	uint8_t ciphertext_buffer[2048];
5489 	struct rte_cryptodev_info dev_info;
5490 
5491 	struct rte_cryptodev_sym_capability_idx cap_idx;
5492 
5493 	/* Check if device supports ZUC EEA3 */
5494 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5495 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5496 
5497 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5498 			&cap_idx) == NULL)
5499 		return -ENOTSUP;
5500 
5501 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5502 
5503 	uint64_t feat_flags = dev_info.feature_flags;
5504 
5505 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5506 		printf("Device doesn't support in-place scatter-gather. "
5507 				"Test Skipped.\n");
5508 		return -ENOTSUP;
5509 	}
5510 
5511 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5512 
5513 	/* Append data which is padded to a multiple */
5514 	/* of the algorithms block size */
5515 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5516 
5517 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5518 			plaintext_pad_len, 10, 0);
5519 
5520 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5521 			tdata->plaintext.data);
5522 
5523 	/* Create ZUC session */
5524 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5525 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5526 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5527 			tdata->key.data, tdata->key.len,
5528 			tdata->cipher_iv.len);
5529 	if (retval < 0)
5530 		return retval;
5531 
5532 	/* Clear mbuf payload */
5533 
5534 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5535 
5536 	/* Create ZUC operation */
5537 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5538 			tdata->cipher_iv.len, tdata->plaintext.len,
5539 			0);
5540 	if (retval < 0)
5541 		return retval;
5542 
5543 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5544 						ut_params->op);
5545 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5546 
5547 	ut_params->obuf = ut_params->op->sym->m_dst;
5548 	if (ut_params->obuf)
5549 		ciphertext = rte_pktmbuf_read(ut_params->obuf,
5550 			0, plaintext_len, ciphertext_buffer);
5551 	else
5552 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5553 			0, plaintext_len, ciphertext_buffer);
5554 
5555 	/* Validate obuf */
5556 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5557 
5558 	/* Validate obuf */
5559 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5560 		ciphertext,
5561 		tdata->ciphertext.data,
5562 		tdata->validCipherLenInBits.len,
5563 		"ZUC Ciphertext data not as expected");
5564 
5565 	return 0;
5566 }
5567 
5568 static int
5569 test_zuc_authentication(const struct wireless_test_data *tdata)
5570 {
5571 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5572 	struct crypto_unittest_params *ut_params = &unittest_params;
5573 
5574 	int retval;
5575 	unsigned plaintext_pad_len;
5576 	unsigned plaintext_len;
5577 	uint8_t *plaintext;
5578 
5579 	struct rte_cryptodev_sym_capability_idx cap_idx;
5580 
5581 	/* Check if device supports ZUC EIA3 */
5582 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5583 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5584 
5585 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5586 			&cap_idx) == NULL)
5587 		return -ENOTSUP;
5588 
5589 	/* Create ZUC session */
5590 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5591 			tdata->key.data, tdata->key.len,
5592 			tdata->auth_iv.len, tdata->digest.len,
5593 			RTE_CRYPTO_AUTH_OP_GENERATE,
5594 			RTE_CRYPTO_AUTH_ZUC_EIA3);
5595 	if (retval < 0)
5596 		return retval;
5597 
5598 	/* alloc mbuf and set payload */
5599 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5600 
5601 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5602 	rte_pktmbuf_tailroom(ut_params->ibuf));
5603 
5604 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5605 	/* Append data which is padded to a multiple of */
5606 	/* the algorithms block size */
5607 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5608 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5609 				plaintext_pad_len);
5610 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5611 
5612 	/* Create ZUC operation */
5613 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5614 			tdata->auth_iv.data, tdata->auth_iv.len,
5615 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5616 			tdata->validAuthLenInBits.len,
5617 			0);
5618 	if (retval < 0)
5619 		return retval;
5620 
5621 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5622 				ut_params->op);
5623 	ut_params->obuf = ut_params->op->sym->m_src;
5624 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5625 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5626 			+ plaintext_pad_len;
5627 
5628 	/* Validate obuf */
5629 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5630 	ut_params->digest,
5631 	tdata->digest.data,
5632 	DIGEST_BYTE_LENGTH_KASUMI_F9,
5633 	"ZUC Generated auth tag not as expected");
5634 
5635 	return 0;
5636 }
5637 
5638 static int
5639 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5640 	uint8_t op_mode, uint8_t verify)
5641 {
5642 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5643 	struct crypto_unittest_params *ut_params = &unittest_params;
5644 
5645 	int retval;
5646 
5647 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5648 	unsigned int plaintext_pad_len;
5649 	unsigned int plaintext_len;
5650 	unsigned int ciphertext_pad_len;
5651 	unsigned int ciphertext_len;
5652 
5653 	struct rte_cryptodev_info dev_info;
5654 	struct rte_cryptodev_sym_capability_idx cap_idx;
5655 
5656 	/* Check if device supports ZUC EIA3 */
5657 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5658 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5659 
5660 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5661 			&cap_idx) == NULL)
5662 		return -ENOTSUP;
5663 
5664 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5665 
5666 	uint64_t feat_flags = dev_info.feature_flags;
5667 
5668 	if (op_mode == OUT_OF_PLACE) {
5669 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5670 			printf("Device doesn't support digest encrypted.\n");
5671 			return -ENOTSUP;
5672 		}
5673 	}
5674 
5675 	/* Create ZUC session */
5676 	retval = create_wireless_algo_auth_cipher_session(
5677 			ts_params->valid_devs[0],
5678 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5679 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5680 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5681 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5682 			RTE_CRYPTO_AUTH_ZUC_EIA3,
5683 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5684 			tdata->key.data, tdata->key.len,
5685 			tdata->auth_iv.len, tdata->digest.len,
5686 			tdata->cipher_iv.len);
5687 
5688 	if (retval < 0)
5689 		return retval;
5690 
5691 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5692 	if (op_mode == OUT_OF_PLACE)
5693 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5694 
5695 	/* clear mbuf payload */
5696 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5697 		rte_pktmbuf_tailroom(ut_params->ibuf));
5698 	if (op_mode == OUT_OF_PLACE)
5699 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5700 			rte_pktmbuf_tailroom(ut_params->obuf));
5701 
5702 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5703 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5704 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5705 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5706 
5707 	if (verify) {
5708 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5709 					ciphertext_pad_len);
5710 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5711 		if (op_mode == OUT_OF_PLACE)
5712 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5713 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5714 			ciphertext_len);
5715 	} else {
5716 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5717 					plaintext_pad_len);
5718 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5719 		if (op_mode == OUT_OF_PLACE)
5720 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5721 		debug_hexdump(stdout, "plaintext:", plaintext,
5722 			plaintext_len);
5723 	}
5724 
5725 	/* Create ZUC operation */
5726 	retval = create_wireless_algo_auth_cipher_operation(
5727 		tdata->digest.data, tdata->digest.len,
5728 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5729 		tdata->auth_iv.data, tdata->auth_iv.len,
5730 		(tdata->digest.offset_bytes == 0 ?
5731 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5732 			: tdata->digest.offset_bytes),
5733 		tdata->validCipherLenInBits.len,
5734 		tdata->validCipherOffsetInBits.len,
5735 		tdata->validAuthLenInBits.len,
5736 		0,
5737 		op_mode, 0, verify);
5738 
5739 	if (retval < 0)
5740 		return retval;
5741 
5742 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5743 			ut_params->op);
5744 
5745 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5746 
5747 	ut_params->obuf = (op_mode == IN_PLACE ?
5748 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5749 
5750 
5751 	if (verify) {
5752 		if (ut_params->obuf)
5753 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5754 							uint8_t *);
5755 		else
5756 			plaintext = ciphertext;
5757 
5758 		debug_hexdump(stdout, "plaintext:", plaintext,
5759 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5760 		debug_hexdump(stdout, "plaintext expected:",
5761 			tdata->plaintext.data,
5762 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5763 	} else {
5764 		if (ut_params->obuf)
5765 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5766 							uint8_t *);
5767 		else
5768 			ciphertext = plaintext;
5769 
5770 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5771 			ciphertext_len);
5772 		debug_hexdump(stdout, "ciphertext expected:",
5773 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5774 
5775 		ut_params->digest = rte_pktmbuf_mtod(
5776 			ut_params->obuf, uint8_t *) +
5777 			(tdata->digest.offset_bytes == 0 ?
5778 			plaintext_pad_len : tdata->digest.offset_bytes);
5779 
5780 		debug_hexdump(stdout, "digest:", ut_params->digest,
5781 			tdata->digest.len);
5782 		debug_hexdump(stdout, "digest expected:",
5783 			tdata->digest.data, tdata->digest.len);
5784 	}
5785 
5786 	/* Validate obuf */
5787 	if (verify) {
5788 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5789 			plaintext,
5790 			tdata->plaintext.data,
5791 			tdata->plaintext.len >> 3,
5792 			"ZUC Plaintext data not as expected");
5793 	} else {
5794 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5795 			ciphertext,
5796 			tdata->ciphertext.data,
5797 			tdata->ciphertext.len >> 3,
5798 			"ZUC Ciphertext data not as expected");
5799 
5800 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5801 			ut_params->digest,
5802 			tdata->digest.data,
5803 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5804 			"ZUC Generated auth tag not as expected");
5805 	}
5806 	return 0;
5807 }
5808 
5809 static int
5810 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5811 	uint8_t op_mode, uint8_t verify)
5812 {
5813 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5814 	struct crypto_unittest_params *ut_params = &unittest_params;
5815 
5816 	int retval;
5817 
5818 	const uint8_t *plaintext = NULL;
5819 	const uint8_t *ciphertext = NULL;
5820 	const uint8_t *digest = NULL;
5821 	unsigned int plaintext_pad_len;
5822 	unsigned int plaintext_len;
5823 	unsigned int ciphertext_pad_len;
5824 	unsigned int ciphertext_len;
5825 	uint8_t buffer[10000];
5826 	uint8_t digest_buffer[10000];
5827 
5828 	struct rte_cryptodev_info dev_info;
5829 	struct rte_cryptodev_sym_capability_idx cap_idx;
5830 
5831 	/* Check if device supports ZUC EIA3 */
5832 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5833 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5834 
5835 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5836 			&cap_idx) == NULL)
5837 		return -ENOTSUP;
5838 
5839 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5840 
5841 	uint64_t feat_flags = dev_info.feature_flags;
5842 
5843 	if (op_mode == IN_PLACE) {
5844 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5845 			printf("Device doesn't support in-place scatter-gather "
5846 					"in both input and output mbufs.\n");
5847 			return -ENOTSUP;
5848 		}
5849 	} else {
5850 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5851 			printf("Device doesn't support out-of-place scatter-gather "
5852 					"in both input and output mbufs.\n");
5853 			return -ENOTSUP;
5854 		}
5855 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5856 			printf("Device doesn't support digest encrypted.\n");
5857 			return -ENOTSUP;
5858 		}
5859 	}
5860 
5861 	/* Create ZUC session */
5862 	retval = create_wireless_algo_auth_cipher_session(
5863 			ts_params->valid_devs[0],
5864 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5865 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5866 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5867 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5868 			RTE_CRYPTO_AUTH_ZUC_EIA3,
5869 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5870 			tdata->key.data, tdata->key.len,
5871 			tdata->auth_iv.len, tdata->digest.len,
5872 			tdata->cipher_iv.len);
5873 
5874 	if (retval < 0)
5875 		return retval;
5876 
5877 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5878 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5879 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5880 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5881 
5882 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5883 			plaintext_pad_len, 15, 0);
5884 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5885 			"Failed to allocate input buffer in mempool");
5886 
5887 	if (op_mode == OUT_OF_PLACE) {
5888 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5889 				plaintext_pad_len, 15, 0);
5890 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5891 				"Failed to allocate output buffer in mempool");
5892 	}
5893 
5894 	if (verify) {
5895 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5896 			tdata->ciphertext.data);
5897 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5898 					ciphertext_len, buffer);
5899 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5900 			ciphertext_len);
5901 	} else {
5902 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5903 			tdata->plaintext.data);
5904 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5905 					plaintext_len, buffer);
5906 		debug_hexdump(stdout, "plaintext:", plaintext,
5907 			plaintext_len);
5908 	}
5909 	memset(buffer, 0, sizeof(buffer));
5910 
5911 	/* Create ZUC operation */
5912 	retval = create_wireless_algo_auth_cipher_operation(
5913 		tdata->digest.data, tdata->digest.len,
5914 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5915 		NULL, 0,
5916 		(tdata->digest.offset_bytes == 0 ?
5917 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5918 			: tdata->digest.offset_bytes),
5919 		tdata->validCipherLenInBits.len,
5920 		tdata->validCipherOffsetInBits.len,
5921 		tdata->validAuthLenInBits.len,
5922 		0,
5923 		op_mode, 1, verify);
5924 
5925 	if (retval < 0)
5926 		return retval;
5927 
5928 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5929 			ut_params->op);
5930 
5931 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5932 
5933 	ut_params->obuf = (op_mode == IN_PLACE ?
5934 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5935 
5936 	if (verify) {
5937 		if (ut_params->obuf)
5938 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5939 					plaintext_len, buffer);
5940 		else
5941 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5942 					plaintext_len, buffer);
5943 
5944 		debug_hexdump(stdout, "plaintext:", plaintext,
5945 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5946 		debug_hexdump(stdout, "plaintext expected:",
5947 			tdata->plaintext.data,
5948 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5949 	} else {
5950 		if (ut_params->obuf)
5951 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5952 					ciphertext_len, buffer);
5953 		else
5954 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5955 					ciphertext_len, buffer);
5956 
5957 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5958 			ciphertext_len);
5959 		debug_hexdump(stdout, "ciphertext expected:",
5960 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5961 
5962 		if (ut_params->obuf)
5963 			digest = rte_pktmbuf_read(ut_params->obuf,
5964 				(tdata->digest.offset_bytes == 0 ?
5965 				plaintext_pad_len : tdata->digest.offset_bytes),
5966 				tdata->digest.len, digest_buffer);
5967 		else
5968 			digest = rte_pktmbuf_read(ut_params->ibuf,
5969 				(tdata->digest.offset_bytes == 0 ?
5970 				plaintext_pad_len : tdata->digest.offset_bytes),
5971 				tdata->digest.len, digest_buffer);
5972 
5973 		debug_hexdump(stdout, "digest:", digest,
5974 			tdata->digest.len);
5975 		debug_hexdump(stdout, "digest expected:",
5976 			tdata->digest.data, tdata->digest.len);
5977 	}
5978 
5979 	/* Validate obuf */
5980 	if (verify) {
5981 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5982 			plaintext,
5983 			tdata->plaintext.data,
5984 			tdata->plaintext.len >> 3,
5985 			"ZUC Plaintext data not as expected");
5986 	} else {
5987 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5988 			ciphertext,
5989 			tdata->ciphertext.data,
5990 			tdata->validDataLenInBits.len,
5991 			"ZUC Ciphertext data not as expected");
5992 
5993 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5994 			digest,
5995 			tdata->digest.data,
5996 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5997 			"ZUC Generated auth tag not as expected");
5998 	}
5999 	return 0;
6000 }
6001 
6002 static int
6003 test_kasumi_encryption_test_case_1(void)
6004 {
6005 	return test_kasumi_encryption(&kasumi_test_case_1);
6006 }
6007 
6008 static int
6009 test_kasumi_encryption_test_case_1_sgl(void)
6010 {
6011 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6012 }
6013 
6014 static int
6015 test_kasumi_encryption_test_case_1_oop(void)
6016 {
6017 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
6018 }
6019 
6020 static int
6021 test_kasumi_encryption_test_case_1_oop_sgl(void)
6022 {
6023 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6024 }
6025 
6026 static int
6027 test_kasumi_encryption_test_case_2(void)
6028 {
6029 	return test_kasumi_encryption(&kasumi_test_case_2);
6030 }
6031 
6032 static int
6033 test_kasumi_encryption_test_case_3(void)
6034 {
6035 	return test_kasumi_encryption(&kasumi_test_case_3);
6036 }
6037 
6038 static int
6039 test_kasumi_encryption_test_case_4(void)
6040 {
6041 	return test_kasumi_encryption(&kasumi_test_case_4);
6042 }
6043 
6044 static int
6045 test_kasumi_encryption_test_case_5(void)
6046 {
6047 	return test_kasumi_encryption(&kasumi_test_case_5);
6048 }
6049 
6050 static int
6051 test_kasumi_decryption_test_case_1(void)
6052 {
6053 	return test_kasumi_decryption(&kasumi_test_case_1);
6054 }
6055 
6056 static int
6057 test_kasumi_decryption_test_case_1_oop(void)
6058 {
6059 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
6060 }
6061 
6062 static int
6063 test_kasumi_decryption_test_case_2(void)
6064 {
6065 	return test_kasumi_decryption(&kasumi_test_case_2);
6066 }
6067 
6068 static int
6069 test_kasumi_decryption_test_case_3(void)
6070 {
6071 	return test_kasumi_decryption(&kasumi_test_case_3);
6072 }
6073 
6074 static int
6075 test_kasumi_decryption_test_case_4(void)
6076 {
6077 	return test_kasumi_decryption(&kasumi_test_case_4);
6078 }
6079 
6080 static int
6081 test_kasumi_decryption_test_case_5(void)
6082 {
6083 	return test_kasumi_decryption(&kasumi_test_case_5);
6084 }
6085 static int
6086 test_snow3g_encryption_test_case_1(void)
6087 {
6088 	return test_snow3g_encryption(&snow3g_test_case_1);
6089 }
6090 
6091 static int
6092 test_snow3g_encryption_test_case_1_oop(void)
6093 {
6094 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
6095 }
6096 
6097 static int
6098 test_snow3g_encryption_test_case_1_oop_sgl(void)
6099 {
6100 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6101 }
6102 
6103 
6104 static int
6105 test_snow3g_encryption_test_case_1_offset_oop(void)
6106 {
6107 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6108 }
6109 
6110 static int
6111 test_snow3g_encryption_test_case_2(void)
6112 {
6113 	return test_snow3g_encryption(&snow3g_test_case_2);
6114 }
6115 
6116 static int
6117 test_snow3g_encryption_test_case_3(void)
6118 {
6119 	return test_snow3g_encryption(&snow3g_test_case_3);
6120 }
6121 
6122 static int
6123 test_snow3g_encryption_test_case_4(void)
6124 {
6125 	return test_snow3g_encryption(&snow3g_test_case_4);
6126 }
6127 
6128 static int
6129 test_snow3g_encryption_test_case_5(void)
6130 {
6131 	return test_snow3g_encryption(&snow3g_test_case_5);
6132 }
6133 
6134 static int
6135 test_snow3g_decryption_test_case_1(void)
6136 {
6137 	return test_snow3g_decryption(&snow3g_test_case_1);
6138 }
6139 
6140 static int
6141 test_snow3g_decryption_test_case_1_oop(void)
6142 {
6143 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
6144 }
6145 
6146 static int
6147 test_snow3g_decryption_test_case_2(void)
6148 {
6149 	return test_snow3g_decryption(&snow3g_test_case_2);
6150 }
6151 
6152 static int
6153 test_snow3g_decryption_test_case_3(void)
6154 {
6155 	return test_snow3g_decryption(&snow3g_test_case_3);
6156 }
6157 
6158 static int
6159 test_snow3g_decryption_test_case_4(void)
6160 {
6161 	return test_snow3g_decryption(&snow3g_test_case_4);
6162 }
6163 
6164 static int
6165 test_snow3g_decryption_test_case_5(void)
6166 {
6167 	return test_snow3g_decryption(&snow3g_test_case_5);
6168 }
6169 
6170 /*
6171  * Function prepares snow3g_hash_test_data from snow3g_test_data.
6172  * Pattern digest from snow3g_test_data must be allocated as
6173  * 4 last bytes in plaintext.
6174  */
6175 static void
6176 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6177 		struct snow3g_hash_test_data *output)
6178 {
6179 	if ((pattern != NULL) && (output != NULL)) {
6180 		output->key.len = pattern->key.len;
6181 
6182 		memcpy(output->key.data,
6183 		pattern->key.data, pattern->key.len);
6184 
6185 		output->auth_iv.len = pattern->auth_iv.len;
6186 
6187 		memcpy(output->auth_iv.data,
6188 		pattern->auth_iv.data, pattern->auth_iv.len);
6189 
6190 		output->plaintext.len = pattern->plaintext.len;
6191 
6192 		memcpy(output->plaintext.data,
6193 		pattern->plaintext.data, pattern->plaintext.len >> 3);
6194 
6195 		output->digest.len = pattern->digest.len;
6196 
6197 		memcpy(output->digest.data,
6198 		&pattern->plaintext.data[pattern->digest.offset_bytes],
6199 		pattern->digest.len);
6200 
6201 		output->validAuthLenInBits.len =
6202 		pattern->validAuthLenInBits.len;
6203 	}
6204 }
6205 
6206 /*
6207  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6208  */
6209 static int
6210 test_snow3g_decryption_with_digest_test_case_1(void)
6211 {
6212 	struct snow3g_hash_test_data snow3g_hash_data;
6213 
6214 	/*
6215 	 * Function prepare data for hash veryfication test case.
6216 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
6217 	 */
6218 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6219 
6220 	return test_snow3g_decryption(&snow3g_test_case_7) &
6221 			test_snow3g_authentication_verify(&snow3g_hash_data);
6222 }
6223 
6224 static int
6225 test_snow3g_cipher_auth_test_case_1(void)
6226 {
6227 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
6228 }
6229 
6230 static int
6231 test_snow3g_auth_cipher_test_case_1(void)
6232 {
6233 	return test_snow3g_auth_cipher(
6234 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6235 }
6236 
6237 static int
6238 test_snow3g_auth_cipher_test_case_2(void)
6239 {
6240 	return test_snow3g_auth_cipher(
6241 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6242 }
6243 
6244 static int
6245 test_snow3g_auth_cipher_test_case_2_oop(void)
6246 {
6247 	return test_snow3g_auth_cipher(
6248 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6249 }
6250 
6251 static int
6252 test_snow3g_auth_cipher_part_digest_enc(void)
6253 {
6254 	return test_snow3g_auth_cipher(
6255 		&snow3g_auth_cipher_partial_digest_encryption,
6256 			IN_PLACE, 0);
6257 }
6258 
6259 static int
6260 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6261 {
6262 	return test_snow3g_auth_cipher(
6263 		&snow3g_auth_cipher_partial_digest_encryption,
6264 			OUT_OF_PLACE, 0);
6265 }
6266 
6267 static int
6268 test_snow3g_auth_cipher_test_case_3_sgl(void)
6269 {
6270 	return test_snow3g_auth_cipher_sgl(
6271 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6272 }
6273 
6274 static int
6275 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6276 {
6277 	return test_snow3g_auth_cipher_sgl(
6278 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6279 }
6280 
6281 static int
6282 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6283 {
6284 	return test_snow3g_auth_cipher_sgl(
6285 		&snow3g_auth_cipher_partial_digest_encryption,
6286 			IN_PLACE, 0);
6287 }
6288 
6289 static int
6290 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6291 {
6292 	return test_snow3g_auth_cipher_sgl(
6293 		&snow3g_auth_cipher_partial_digest_encryption,
6294 			OUT_OF_PLACE, 0);
6295 }
6296 
6297 static int
6298 test_snow3g_auth_cipher_verify_test_case_1(void)
6299 {
6300 	return test_snow3g_auth_cipher(
6301 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6302 }
6303 
6304 static int
6305 test_snow3g_auth_cipher_verify_test_case_2(void)
6306 {
6307 	return test_snow3g_auth_cipher(
6308 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6309 }
6310 
6311 static int
6312 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6313 {
6314 	return test_snow3g_auth_cipher(
6315 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6316 }
6317 
6318 static int
6319 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6320 {
6321 	return test_snow3g_auth_cipher(
6322 		&snow3g_auth_cipher_partial_digest_encryption,
6323 			IN_PLACE, 1);
6324 }
6325 
6326 static int
6327 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6328 {
6329 	return test_snow3g_auth_cipher(
6330 		&snow3g_auth_cipher_partial_digest_encryption,
6331 			OUT_OF_PLACE, 1);
6332 }
6333 
6334 static int
6335 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6336 {
6337 	return test_snow3g_auth_cipher_sgl(
6338 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6339 }
6340 
6341 static int
6342 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6343 {
6344 	return test_snow3g_auth_cipher_sgl(
6345 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6346 }
6347 
6348 static int
6349 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6350 {
6351 	return test_snow3g_auth_cipher_sgl(
6352 		&snow3g_auth_cipher_partial_digest_encryption,
6353 			IN_PLACE, 1);
6354 }
6355 
6356 static int
6357 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6358 {
6359 	return test_snow3g_auth_cipher_sgl(
6360 		&snow3g_auth_cipher_partial_digest_encryption,
6361 			OUT_OF_PLACE, 1);
6362 }
6363 
6364 static int
6365 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6366 {
6367 	return test_snow3g_auth_cipher(
6368 		&snow3g_test_case_7, IN_PLACE, 0);
6369 }
6370 
6371 static int
6372 test_kasumi_auth_cipher_test_case_1(void)
6373 {
6374 	return test_kasumi_auth_cipher(
6375 		&kasumi_test_case_3, IN_PLACE, 0);
6376 }
6377 
6378 static int
6379 test_kasumi_auth_cipher_test_case_2(void)
6380 {
6381 	return test_kasumi_auth_cipher(
6382 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6383 }
6384 
6385 static int
6386 test_kasumi_auth_cipher_test_case_2_oop(void)
6387 {
6388 	return test_kasumi_auth_cipher(
6389 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6390 }
6391 
6392 static int
6393 test_kasumi_auth_cipher_test_case_2_sgl(void)
6394 {
6395 	return test_kasumi_auth_cipher_sgl(
6396 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6397 }
6398 
6399 static int
6400 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6401 {
6402 	return test_kasumi_auth_cipher_sgl(
6403 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6404 }
6405 
6406 static int
6407 test_kasumi_auth_cipher_verify_test_case_1(void)
6408 {
6409 	return test_kasumi_auth_cipher(
6410 		&kasumi_test_case_3, IN_PLACE, 1);
6411 }
6412 
6413 static int
6414 test_kasumi_auth_cipher_verify_test_case_2(void)
6415 {
6416 	return test_kasumi_auth_cipher(
6417 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6418 }
6419 
6420 static int
6421 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6422 {
6423 	return test_kasumi_auth_cipher(
6424 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6425 }
6426 
6427 static int
6428 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6429 {
6430 	return test_kasumi_auth_cipher_sgl(
6431 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6432 }
6433 
6434 static int
6435 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6436 {
6437 	return test_kasumi_auth_cipher_sgl(
6438 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6439 }
6440 
6441 static int
6442 test_kasumi_cipher_auth_test_case_1(void)
6443 {
6444 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
6445 }
6446 
6447 static int
6448 test_zuc_encryption_test_case_1(void)
6449 {
6450 	return test_zuc_encryption(&zuc_test_case_cipher_193b);
6451 }
6452 
6453 static int
6454 test_zuc_encryption_test_case_2(void)
6455 {
6456 	return test_zuc_encryption(&zuc_test_case_cipher_800b);
6457 }
6458 
6459 static int
6460 test_zuc_encryption_test_case_3(void)
6461 {
6462 	return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6463 }
6464 
6465 static int
6466 test_zuc_encryption_test_case_4(void)
6467 {
6468 	return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6469 }
6470 
6471 static int
6472 test_zuc_encryption_test_case_5(void)
6473 {
6474 	return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6475 }
6476 
6477 static int
6478 test_zuc_encryption_test_case_6_sgl(void)
6479 {
6480 	return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6481 }
6482 
6483 static int
6484 test_zuc_hash_generate_test_case_1(void)
6485 {
6486 	return test_zuc_authentication(&zuc_test_case_auth_1b);
6487 }
6488 
6489 static int
6490 test_zuc_hash_generate_test_case_2(void)
6491 {
6492 	return test_zuc_authentication(&zuc_test_case_auth_90b);
6493 }
6494 
6495 static int
6496 test_zuc_hash_generate_test_case_3(void)
6497 {
6498 	return test_zuc_authentication(&zuc_test_case_auth_577b);
6499 }
6500 
6501 static int
6502 test_zuc_hash_generate_test_case_4(void)
6503 {
6504 	return test_zuc_authentication(&zuc_test_case_auth_2079b);
6505 }
6506 
6507 static int
6508 test_zuc_hash_generate_test_case_5(void)
6509 {
6510 	return test_zuc_authentication(&zuc_test_auth_5670b);
6511 }
6512 
6513 static int
6514 test_zuc_hash_generate_test_case_6(void)
6515 {
6516 	return test_zuc_authentication(&zuc_test_case_auth_128b);
6517 }
6518 
6519 static int
6520 test_zuc_hash_generate_test_case_7(void)
6521 {
6522 	return test_zuc_authentication(&zuc_test_case_auth_2080b);
6523 }
6524 
6525 static int
6526 test_zuc_hash_generate_test_case_8(void)
6527 {
6528 	return test_zuc_authentication(&zuc_test_case_auth_584b);
6529 }
6530 
6531 static int
6532 test_zuc_cipher_auth_test_case_1(void)
6533 {
6534 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6535 }
6536 
6537 static int
6538 test_zuc_cipher_auth_test_case_2(void)
6539 {
6540 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6541 }
6542 
6543 static int
6544 test_zuc_auth_cipher_test_case_1(void)
6545 {
6546 	return test_zuc_auth_cipher(
6547 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6548 }
6549 
6550 static int
6551 test_zuc_auth_cipher_test_case_1_oop(void)
6552 {
6553 	return test_zuc_auth_cipher(
6554 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6555 }
6556 
6557 static int
6558 test_zuc_auth_cipher_test_case_1_sgl(void)
6559 {
6560 	return test_zuc_auth_cipher_sgl(
6561 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6562 }
6563 
6564 static int
6565 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6566 {
6567 	return test_zuc_auth_cipher_sgl(
6568 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6569 }
6570 
6571 static int
6572 test_zuc_auth_cipher_verify_test_case_1(void)
6573 {
6574 	return test_zuc_auth_cipher(
6575 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6576 }
6577 
6578 static int
6579 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6580 {
6581 	return test_zuc_auth_cipher(
6582 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6583 }
6584 
6585 static int
6586 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6587 {
6588 	return test_zuc_auth_cipher_sgl(
6589 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6590 }
6591 
6592 static int
6593 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6594 {
6595 	return test_zuc_auth_cipher_sgl(
6596 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6597 }
6598 
6599 static int
6600 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6601 {
6602 	uint8_t dev_id = testsuite_params.valid_devs[0];
6603 
6604 	struct rte_cryptodev_sym_capability_idx cap_idx;
6605 
6606 	/* Check if device supports particular cipher algorithm */
6607 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6608 	cap_idx.algo.cipher = tdata->cipher_algo;
6609 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6610 		return -ENOTSUP;
6611 
6612 	/* Check if device supports particular hash algorithm */
6613 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6614 	cap_idx.algo.auth = tdata->auth_algo;
6615 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6616 		return -ENOTSUP;
6617 
6618 	return 0;
6619 }
6620 
6621 static int
6622 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6623 	uint8_t op_mode, uint8_t verify)
6624 {
6625 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6626 	struct crypto_unittest_params *ut_params = &unittest_params;
6627 
6628 	int retval;
6629 
6630 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6631 	unsigned int plaintext_pad_len;
6632 	unsigned int plaintext_len;
6633 	unsigned int ciphertext_pad_len;
6634 	unsigned int ciphertext_len;
6635 
6636 	struct rte_cryptodev_info dev_info;
6637 	struct rte_crypto_op *op;
6638 
6639 	/* Check if device supports particular algorithms separately */
6640 	if (test_mixed_check_if_unsupported(tdata))
6641 		return -ENOTSUP;
6642 
6643 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6644 
6645 	uint64_t feat_flags = dev_info.feature_flags;
6646 
6647 	if (op_mode == OUT_OF_PLACE) {
6648 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6649 			printf("Device doesn't support digest encrypted.\n");
6650 			return -ENOTSUP;
6651 		}
6652 	}
6653 
6654 	/* Create the session */
6655 	if (verify)
6656 		retval = create_wireless_algo_cipher_auth_session(
6657 				ts_params->valid_devs[0],
6658 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
6659 				RTE_CRYPTO_AUTH_OP_VERIFY,
6660 				tdata->auth_algo,
6661 				tdata->cipher_algo,
6662 				tdata->auth_key.data, tdata->auth_key.len,
6663 				tdata->auth_iv.len, tdata->digest_enc.len,
6664 				tdata->cipher_iv.len);
6665 	else
6666 		retval = create_wireless_algo_auth_cipher_session(
6667 				ts_params->valid_devs[0],
6668 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6669 				RTE_CRYPTO_AUTH_OP_GENERATE,
6670 				tdata->auth_algo,
6671 				tdata->cipher_algo,
6672 				tdata->auth_key.data, tdata->auth_key.len,
6673 				tdata->auth_iv.len, tdata->digest_enc.len,
6674 				tdata->cipher_iv.len);
6675 	if (retval < 0)
6676 		return retval;
6677 
6678 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6679 	if (op_mode == OUT_OF_PLACE)
6680 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6681 
6682 	/* clear mbuf payload */
6683 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6684 		rte_pktmbuf_tailroom(ut_params->ibuf));
6685 	if (op_mode == OUT_OF_PLACE)
6686 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6687 				rte_pktmbuf_tailroom(ut_params->obuf));
6688 
6689 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6690 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6691 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6692 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6693 
6694 	if (verify) {
6695 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6696 				ciphertext_pad_len);
6697 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6698 		if (op_mode == OUT_OF_PLACE)
6699 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6700 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6701 				ciphertext_len);
6702 	} else {
6703 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6704 				plaintext_pad_len);
6705 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6706 		if (op_mode == OUT_OF_PLACE)
6707 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6708 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6709 	}
6710 
6711 	/* Create the operation */
6712 	retval = create_wireless_algo_auth_cipher_operation(
6713 			tdata->digest_enc.data, tdata->digest_enc.len,
6714 			tdata->cipher_iv.data, tdata->cipher_iv.len,
6715 			tdata->auth_iv.data, tdata->auth_iv.len,
6716 			(tdata->digest_enc.offset == 0 ?
6717 				plaintext_pad_len
6718 				: tdata->digest_enc.offset),
6719 			tdata->validCipherLen.len_bits,
6720 			tdata->cipher.offset_bits,
6721 			tdata->validAuthLen.len_bits,
6722 			tdata->auth.offset_bits,
6723 			op_mode, 0, verify);
6724 
6725 	if (retval < 0)
6726 		return retval;
6727 
6728 	op = process_crypto_request(ts_params->valid_devs[0],
6729 			ut_params->op);
6730 
6731 	/* Check if the op failed because the device doesn't */
6732 	/* support this particular combination of algorithms */
6733 	if (op == NULL && ut_params->op->status ==
6734 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6735 		printf("Device doesn't support this mixed combination. "
6736 				"Test Skipped.\n");
6737 		return -ENOTSUP;
6738 	}
6739 	ut_params->op = op;
6740 
6741 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6742 
6743 	ut_params->obuf = (op_mode == IN_PLACE ?
6744 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6745 
6746 	if (verify) {
6747 		if (ut_params->obuf)
6748 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6749 							uint8_t *);
6750 		else
6751 			plaintext = ciphertext +
6752 					(tdata->cipher.offset_bits >> 3);
6753 
6754 		debug_hexdump(stdout, "plaintext:", plaintext,
6755 				tdata->plaintext.len_bits >> 3);
6756 		debug_hexdump(stdout, "plaintext expected:",
6757 				tdata->plaintext.data,
6758 				tdata->plaintext.len_bits >> 3);
6759 	} else {
6760 		if (ut_params->obuf)
6761 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6762 					uint8_t *);
6763 		else
6764 			ciphertext = plaintext;
6765 
6766 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6767 				ciphertext_len);
6768 		debug_hexdump(stdout, "ciphertext expected:",
6769 				tdata->ciphertext.data,
6770 				tdata->ciphertext.len_bits >> 3);
6771 
6772 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6773 				+ (tdata->digest_enc.offset == 0 ?
6774 		plaintext_pad_len : tdata->digest_enc.offset);
6775 
6776 		debug_hexdump(stdout, "digest:", ut_params->digest,
6777 				tdata->digest_enc.len);
6778 		debug_hexdump(stdout, "digest expected:",
6779 				tdata->digest_enc.data,
6780 				tdata->digest_enc.len);
6781 	}
6782 
6783 	/* Validate obuf */
6784 	if (verify) {
6785 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6786 				plaintext,
6787 				tdata->plaintext.data,
6788 				tdata->plaintext.len_bits >> 3,
6789 				"Plaintext data not as expected");
6790 	} else {
6791 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6792 				ciphertext,
6793 				tdata->ciphertext.data,
6794 				tdata->validDataLen.len_bits,
6795 				"Ciphertext data not as expected");
6796 
6797 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6798 				ut_params->digest,
6799 				tdata->digest_enc.data,
6800 				DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6801 				"Generated auth tag not as expected");
6802 	}
6803 
6804 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6805 			"crypto op processing failed");
6806 
6807 	return 0;
6808 }
6809 
6810 static int
6811 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6812 	uint8_t op_mode, uint8_t verify)
6813 {
6814 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6815 	struct crypto_unittest_params *ut_params = &unittest_params;
6816 
6817 	int retval;
6818 
6819 	const uint8_t *plaintext = NULL;
6820 	const uint8_t *ciphertext = NULL;
6821 	const uint8_t *digest = NULL;
6822 	unsigned int plaintext_pad_len;
6823 	unsigned int plaintext_len;
6824 	unsigned int ciphertext_pad_len;
6825 	unsigned int ciphertext_len;
6826 	uint8_t buffer[10000];
6827 	uint8_t digest_buffer[10000];
6828 
6829 	struct rte_cryptodev_info dev_info;
6830 	struct rte_crypto_op *op;
6831 
6832 	/* Check if device supports particular algorithms */
6833 	if (test_mixed_check_if_unsupported(tdata))
6834 		return -ENOTSUP;
6835 
6836 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6837 
6838 	uint64_t feat_flags = dev_info.feature_flags;
6839 
6840 	if (op_mode == IN_PLACE) {
6841 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6842 			printf("Device doesn't support in-place scatter-gather "
6843 					"in both input and output mbufs.\n");
6844 			return -ENOTSUP;
6845 		}
6846 	} else {
6847 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6848 			printf("Device doesn't support out-of-place scatter-gather "
6849 					"in both input and output mbufs.\n");
6850 			return -ENOTSUP;
6851 		}
6852 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6853 			printf("Device doesn't support digest encrypted.\n");
6854 			return -ENOTSUP;
6855 		}
6856 	}
6857 
6858 	/* Create the session */
6859 	if (verify)
6860 		retval = create_wireless_algo_cipher_auth_session(
6861 				ts_params->valid_devs[0],
6862 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
6863 				RTE_CRYPTO_AUTH_OP_VERIFY,
6864 				tdata->auth_algo,
6865 				tdata->cipher_algo,
6866 				tdata->auth_key.data, tdata->auth_key.len,
6867 				tdata->auth_iv.len, tdata->digest_enc.len,
6868 				tdata->cipher_iv.len);
6869 	else
6870 		retval = create_wireless_algo_auth_cipher_session(
6871 				ts_params->valid_devs[0],
6872 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6873 				RTE_CRYPTO_AUTH_OP_GENERATE,
6874 				tdata->auth_algo,
6875 				tdata->cipher_algo,
6876 				tdata->auth_key.data, tdata->auth_key.len,
6877 				tdata->auth_iv.len, tdata->digest_enc.len,
6878 				tdata->cipher_iv.len);
6879 	if (retval < 0)
6880 		return retval;
6881 
6882 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6883 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6884 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6885 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6886 
6887 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6888 			ciphertext_pad_len, 15, 0);
6889 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6890 			"Failed to allocate input buffer in mempool");
6891 
6892 	if (op_mode == OUT_OF_PLACE) {
6893 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6894 				plaintext_pad_len, 15, 0);
6895 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6896 				"Failed to allocate output buffer in mempool");
6897 	}
6898 
6899 	if (verify) {
6900 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6901 			tdata->ciphertext.data);
6902 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6903 					ciphertext_len, buffer);
6904 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6905 			ciphertext_len);
6906 	} else {
6907 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6908 			tdata->plaintext.data);
6909 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6910 					plaintext_len, buffer);
6911 		debug_hexdump(stdout, "plaintext:", plaintext,
6912 			plaintext_len);
6913 	}
6914 	memset(buffer, 0, sizeof(buffer));
6915 
6916 	/* Create the operation */
6917 	retval = create_wireless_algo_auth_cipher_operation(
6918 			tdata->digest_enc.data, tdata->digest_enc.len,
6919 			tdata->cipher_iv.data, tdata->cipher_iv.len,
6920 			tdata->auth_iv.data, tdata->auth_iv.len,
6921 			(tdata->digest_enc.offset == 0 ?
6922 				plaintext_pad_len
6923 				: tdata->digest_enc.offset),
6924 			tdata->validCipherLen.len_bits,
6925 			tdata->cipher.offset_bits,
6926 			tdata->validAuthLen.len_bits,
6927 			tdata->auth.offset_bits,
6928 			op_mode, 1, verify);
6929 
6930 	if (retval < 0)
6931 		return retval;
6932 
6933 	op = process_crypto_request(ts_params->valid_devs[0],
6934 			ut_params->op);
6935 
6936 	/* Check if the op failed because the device doesn't */
6937 	/* support this particular combination of algorithms */
6938 	if (op == NULL && ut_params->op->status ==
6939 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6940 		printf("Device doesn't support this mixed combination. "
6941 				"Test Skipped.\n");
6942 		return -ENOTSUP;
6943 	}
6944 
6945 	ut_params->op = op;
6946 
6947 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6948 
6949 	ut_params->obuf = (op_mode == IN_PLACE ?
6950 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6951 
6952 	if (verify) {
6953 		if (ut_params->obuf)
6954 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6955 					plaintext_len, buffer);
6956 		else
6957 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6958 					plaintext_len, buffer);
6959 
6960 		debug_hexdump(stdout, "plaintext:", plaintext,
6961 				(tdata->plaintext.len_bits >> 3) -
6962 				tdata->digest_enc.len);
6963 		debug_hexdump(stdout, "plaintext expected:",
6964 				tdata->plaintext.data,
6965 				(tdata->plaintext.len_bits >> 3) -
6966 				tdata->digest_enc.len);
6967 	} else {
6968 		if (ut_params->obuf)
6969 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6970 					ciphertext_len, buffer);
6971 		else
6972 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6973 					ciphertext_len, buffer);
6974 
6975 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6976 			ciphertext_len);
6977 		debug_hexdump(stdout, "ciphertext expected:",
6978 			tdata->ciphertext.data,
6979 			tdata->ciphertext.len_bits >> 3);
6980 
6981 		if (ut_params->obuf)
6982 			digest = rte_pktmbuf_read(ut_params->obuf,
6983 					(tdata->digest_enc.offset == 0 ?
6984 						plaintext_pad_len :
6985 						tdata->digest_enc.offset),
6986 					tdata->digest_enc.len, digest_buffer);
6987 		else
6988 			digest = rte_pktmbuf_read(ut_params->ibuf,
6989 					(tdata->digest_enc.offset == 0 ?
6990 						plaintext_pad_len :
6991 						tdata->digest_enc.offset),
6992 					tdata->digest_enc.len, digest_buffer);
6993 
6994 		debug_hexdump(stdout, "digest:", digest,
6995 				tdata->digest_enc.len);
6996 		debug_hexdump(stdout, "digest expected:",
6997 				tdata->digest_enc.data, tdata->digest_enc.len);
6998 	}
6999 
7000 	/* Validate obuf */
7001 	if (verify) {
7002 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7003 				plaintext,
7004 				tdata->plaintext.data,
7005 				tdata->plaintext.len_bits >> 3,
7006 				"Plaintext data not as expected");
7007 	} else {
7008 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7009 				ciphertext,
7010 				tdata->ciphertext.data,
7011 				tdata->validDataLen.len_bits,
7012 				"Ciphertext data not as expected");
7013 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7014 				digest,
7015 				tdata->digest_enc.data,
7016 				tdata->digest_enc.len,
7017 				"Generated auth tag not as expected");
7018 	}
7019 
7020 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7021 			"crypto op processing failed");
7022 
7023 	return 0;
7024 }
7025 
7026 /** AUTH AES CMAC + CIPHER AES CTR */
7027 
7028 static int
7029 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7030 {
7031 	return test_mixed_auth_cipher(
7032 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7033 }
7034 
7035 static int
7036 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7037 {
7038 	return test_mixed_auth_cipher(
7039 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7040 }
7041 
7042 static int
7043 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7044 {
7045 	return test_mixed_auth_cipher_sgl(
7046 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7047 }
7048 
7049 static int
7050 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7051 {
7052 	return test_mixed_auth_cipher_sgl(
7053 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7054 }
7055 
7056 static int
7057 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7058 {
7059 	return test_mixed_auth_cipher(
7060 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7061 }
7062 
7063 static int
7064 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7065 {
7066 	return test_mixed_auth_cipher(
7067 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7068 }
7069 
7070 static int
7071 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7072 {
7073 	return test_mixed_auth_cipher_sgl(
7074 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7075 }
7076 
7077 static int
7078 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7079 {
7080 	return test_mixed_auth_cipher_sgl(
7081 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7082 }
7083 
7084 /** MIXED AUTH + CIPHER */
7085 
7086 static int
7087 test_auth_zuc_cipher_snow_test_case_1(void)
7088 {
7089 	return test_mixed_auth_cipher(
7090 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7091 }
7092 
7093 static int
7094 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7095 {
7096 	return test_mixed_auth_cipher(
7097 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7098 }
7099 
7100 static int
7101 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7102 {
7103 	return test_mixed_auth_cipher(
7104 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7105 }
7106 
7107 static int
7108 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7109 {
7110 	return test_mixed_auth_cipher(
7111 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7112 }
7113 
7114 static int
7115 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7116 {
7117 	return test_mixed_auth_cipher(
7118 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7119 }
7120 
7121 static int
7122 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7123 {
7124 	return test_mixed_auth_cipher(
7125 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7126 }
7127 
7128 static int
7129 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7130 {
7131 	return test_mixed_auth_cipher(
7132 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7133 }
7134 
7135 static int
7136 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7137 {
7138 	return test_mixed_auth_cipher(
7139 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7140 }
7141 
7142 static int
7143 test_auth_snow_cipher_zuc_test_case_1(void)
7144 {
7145 	return test_mixed_auth_cipher(
7146 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7147 }
7148 
7149 static int
7150 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7151 {
7152 	return test_mixed_auth_cipher(
7153 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7154 }
7155 
7156 static int
7157 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7158 {
7159 	return test_mixed_auth_cipher(
7160 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7161 }
7162 
7163 static int
7164 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7165 {
7166 	return test_mixed_auth_cipher(
7167 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7168 }
7169 
7170 static int
7171 test_auth_null_cipher_snow_test_case_1(void)
7172 {
7173 	return test_mixed_auth_cipher(
7174 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7175 }
7176 
7177 static int
7178 test_verify_auth_null_cipher_snow_test_case_1(void)
7179 {
7180 	return test_mixed_auth_cipher(
7181 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7182 }
7183 
7184 static int
7185 test_auth_null_cipher_zuc_test_case_1(void)
7186 {
7187 	return test_mixed_auth_cipher(
7188 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7189 }
7190 
7191 static int
7192 test_verify_auth_null_cipher_zuc_test_case_1(void)
7193 {
7194 	return test_mixed_auth_cipher(
7195 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7196 }
7197 
7198 static int
7199 test_auth_snow_cipher_null_test_case_1(void)
7200 {
7201 	return test_mixed_auth_cipher(
7202 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7203 }
7204 
7205 static int
7206 test_verify_auth_snow_cipher_null_test_case_1(void)
7207 {
7208 	return test_mixed_auth_cipher(
7209 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7210 }
7211 
7212 static int
7213 test_auth_zuc_cipher_null_test_case_1(void)
7214 {
7215 	return test_mixed_auth_cipher(
7216 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7217 }
7218 
7219 static int
7220 test_verify_auth_zuc_cipher_null_test_case_1(void)
7221 {
7222 	return test_mixed_auth_cipher(
7223 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7224 }
7225 
7226 static int
7227 test_auth_null_cipher_aes_ctr_test_case_1(void)
7228 {
7229 	return test_mixed_auth_cipher(
7230 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7231 }
7232 
7233 static int
7234 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7235 {
7236 	return test_mixed_auth_cipher(
7237 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7238 }
7239 
7240 static int
7241 test_auth_aes_cmac_cipher_null_test_case_1(void)
7242 {
7243 	return test_mixed_auth_cipher(
7244 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7245 }
7246 
7247 static int
7248 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7249 {
7250 	return test_mixed_auth_cipher(
7251 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7252 }
7253 
7254 static int
7255 test_3DES_chain_qat_all(void)
7256 {
7257 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7258 	int status;
7259 
7260 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7261 		ts_params->op_mpool,
7262 		ts_params->session_mpool, ts_params->session_priv_mpool,
7263 		ts_params->valid_devs[0],
7264 		rte_cryptodev_driver_id_get(
7265 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7266 		BLKCIPHER_3DES_CHAIN_TYPE);
7267 
7268 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7269 
7270 	return TEST_SUCCESS;
7271 }
7272 
7273 static int
7274 test_DES_cipheronly_qat_all(void)
7275 {
7276 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7277 	int status;
7278 
7279 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7280 		ts_params->op_mpool,
7281 		ts_params->session_mpool, ts_params->session_priv_mpool,
7282 		ts_params->valid_devs[0],
7283 		rte_cryptodev_driver_id_get(
7284 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7285 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7286 
7287 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7288 
7289 	return TEST_SUCCESS;
7290 }
7291 
7292 static int
7293 test_DES_cipheronly_openssl_all(void)
7294 {
7295 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7296 	int status;
7297 
7298 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7299 		ts_params->op_mpool,
7300 		ts_params->session_mpool, ts_params->session_priv_mpool,
7301 		ts_params->valid_devs[0],
7302 		rte_cryptodev_driver_id_get(
7303 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7304 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7305 
7306 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7307 
7308 	return TEST_SUCCESS;
7309 }
7310 
7311 static int
7312 test_DES_docsis_openssl_all(void)
7313 {
7314 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7315 	int status;
7316 
7317 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7318 		ts_params->op_mpool,
7319 		ts_params->session_mpool, ts_params->session_priv_mpool,
7320 		ts_params->valid_devs[0],
7321 		rte_cryptodev_driver_id_get(
7322 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7323 		BLKCIPHER_DES_DOCSIS_TYPE);
7324 
7325 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7326 
7327 	return TEST_SUCCESS;
7328 }
7329 
7330 static int
7331 test_DES_cipheronly_mb_all(void)
7332 {
7333 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7334 	int status;
7335 
7336 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7337 		ts_params->op_mpool,
7338 		ts_params->session_mpool, ts_params->session_priv_mpool,
7339 		ts_params->valid_devs[0],
7340 		rte_cryptodev_driver_id_get(
7341 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7342 		BLKCIPHER_DES_CIPHERONLY_TYPE);
7343 
7344 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7345 
7346 	return TEST_SUCCESS;
7347 }
7348 static int
7349 test_3DES_cipheronly_mb_all(void)
7350 {
7351 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7352 	int status;
7353 
7354 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7355 		ts_params->op_mpool,
7356 		ts_params->session_mpool, ts_params->session_priv_mpool,
7357 		ts_params->valid_devs[0],
7358 		rte_cryptodev_driver_id_get(
7359 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7360 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7361 
7362 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7363 
7364 	return TEST_SUCCESS;
7365 }
7366 
7367 static int
7368 test_DES_docsis_mb_all(void)
7369 {
7370 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7371 	int status;
7372 
7373 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7374 		ts_params->op_mpool,
7375 		ts_params->session_mpool, ts_params->session_priv_mpool,
7376 		ts_params->valid_devs[0],
7377 		rte_cryptodev_driver_id_get(
7378 		RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7379 		BLKCIPHER_DES_DOCSIS_TYPE);
7380 
7381 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7382 
7383 	return TEST_SUCCESS;
7384 }
7385 
7386 static int
7387 test_3DES_chain_caam_jr_all(void)
7388 {
7389 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7390 	int status;
7391 
7392 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7393 		ts_params->op_mpool,
7394 		ts_params->session_mpool, ts_params->session_priv_mpool,
7395 		ts_params->valid_devs[0],
7396 		rte_cryptodev_driver_id_get(
7397 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7398 		BLKCIPHER_3DES_CHAIN_TYPE);
7399 
7400 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7401 
7402 	return TEST_SUCCESS;
7403 }
7404 
7405 static int
7406 test_3DES_cipheronly_caam_jr_all(void)
7407 {
7408 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7409 	int status;
7410 
7411 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7412 		ts_params->op_mpool,
7413 		ts_params->session_mpool, ts_params->session_priv_mpool,
7414 		ts_params->valid_devs[0],
7415 		rte_cryptodev_driver_id_get(
7416 		RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7417 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7418 
7419 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7420 
7421 	return TEST_SUCCESS;
7422 }
7423 
7424 static int
7425 test_3DES_chain_dpaa_sec_all(void)
7426 {
7427 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7428 	int status;
7429 
7430 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7431 		ts_params->op_mpool,
7432 		ts_params->session_mpool, ts_params->session_priv_mpool,
7433 		ts_params->valid_devs[0],
7434 		rte_cryptodev_driver_id_get(
7435 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7436 		BLKCIPHER_3DES_CHAIN_TYPE);
7437 
7438 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7439 
7440 	return TEST_SUCCESS;
7441 }
7442 
7443 static int
7444 test_3DES_cipheronly_dpaa_sec_all(void)
7445 {
7446 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7447 	int status;
7448 
7449 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7450 		ts_params->op_mpool,
7451 		ts_params->session_mpool, ts_params->session_priv_mpool,
7452 		ts_params->valid_devs[0],
7453 		rte_cryptodev_driver_id_get(
7454 		RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7455 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7456 
7457 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7458 
7459 	return TEST_SUCCESS;
7460 }
7461 
7462 static int
7463 test_3DES_chain_dpaa2_sec_all(void)
7464 {
7465 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7466 	int status;
7467 
7468 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7469 		ts_params->op_mpool,
7470 		ts_params->session_mpool, ts_params->session_priv_mpool,
7471 		ts_params->valid_devs[0],
7472 		rte_cryptodev_driver_id_get(
7473 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7474 		BLKCIPHER_3DES_CHAIN_TYPE);
7475 
7476 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7477 
7478 	return TEST_SUCCESS;
7479 }
7480 
7481 static int
7482 test_3DES_cipheronly_dpaa2_sec_all(void)
7483 {
7484 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7485 	int status;
7486 
7487 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7488 		ts_params->op_mpool,
7489 		ts_params->session_mpool, ts_params->session_priv_mpool,
7490 		ts_params->valid_devs[0],
7491 		rte_cryptodev_driver_id_get(
7492 		RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7493 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7494 
7495 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7496 
7497 	return TEST_SUCCESS;
7498 }
7499 
7500 static int
7501 test_3DES_chain_ccp_all(void)
7502 {
7503 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7504 	int status;
7505 
7506 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7507 		ts_params->op_mpool,
7508 		ts_params->session_mpool, ts_params->session_priv_mpool,
7509 		ts_params->valid_devs[0],
7510 		rte_cryptodev_driver_id_get(
7511 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7512 		BLKCIPHER_3DES_CHAIN_TYPE);
7513 
7514 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7515 
7516 	return TEST_SUCCESS;
7517 }
7518 
7519 static int
7520 test_3DES_cipheronly_ccp_all(void)
7521 {
7522 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7523 	int status;
7524 
7525 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7526 		ts_params->op_mpool,
7527 		ts_params->session_mpool, ts_params->session_priv_mpool,
7528 		ts_params->valid_devs[0],
7529 		rte_cryptodev_driver_id_get(
7530 		RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7531 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7532 
7533 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7534 
7535 	return TEST_SUCCESS;
7536 }
7537 
7538 static int
7539 test_3DES_cipheronly_qat_all(void)
7540 {
7541 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7542 	int status;
7543 
7544 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7545 		ts_params->op_mpool,
7546 		ts_params->session_mpool, ts_params->session_priv_mpool,
7547 		ts_params->valid_devs[0],
7548 		rte_cryptodev_driver_id_get(
7549 		RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7550 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7551 
7552 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7553 
7554 	return TEST_SUCCESS;
7555 }
7556 
7557 static int
7558 test_3DES_chain_openssl_all(void)
7559 {
7560 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7561 	int status;
7562 
7563 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7564 		ts_params->op_mpool,
7565 		ts_params->session_mpool, ts_params->session_priv_mpool,
7566 		ts_params->valid_devs[0],
7567 		rte_cryptodev_driver_id_get(
7568 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7569 		BLKCIPHER_3DES_CHAIN_TYPE);
7570 
7571 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7572 
7573 	return TEST_SUCCESS;
7574 }
7575 
7576 static int
7577 test_3DES_cipheronly_openssl_all(void)
7578 {
7579 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7580 	int status;
7581 
7582 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7583 		ts_params->op_mpool,
7584 		ts_params->session_mpool, ts_params->session_priv_mpool,
7585 		ts_params->valid_devs[0],
7586 		rte_cryptodev_driver_id_get(
7587 		RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7588 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
7589 
7590 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
7591 
7592 	return TEST_SUCCESS;
7593 }
7594 
7595 /* ***** AEAD algorithm Tests ***** */
7596 
7597 static int
7598 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7599 		enum rte_crypto_aead_operation op,
7600 		const uint8_t *key, const uint8_t key_len,
7601 		const uint16_t aad_len, const uint8_t auth_len,
7602 		uint8_t iv_len)
7603 {
7604 	uint8_t aead_key[key_len];
7605 
7606 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7607 	struct crypto_unittest_params *ut_params = &unittest_params;
7608 
7609 	memcpy(aead_key, key, key_len);
7610 
7611 	/* Setup AEAD Parameters */
7612 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7613 	ut_params->aead_xform.next = NULL;
7614 	ut_params->aead_xform.aead.algo = algo;
7615 	ut_params->aead_xform.aead.op = op;
7616 	ut_params->aead_xform.aead.key.data = aead_key;
7617 	ut_params->aead_xform.aead.key.length = key_len;
7618 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7619 	ut_params->aead_xform.aead.iv.length = iv_len;
7620 	ut_params->aead_xform.aead.digest_length = auth_len;
7621 	ut_params->aead_xform.aead.aad_length = aad_len;
7622 
7623 	debug_hexdump(stdout, "key:", key, key_len);
7624 
7625 	/* Create Crypto session*/
7626 	ut_params->sess = rte_cryptodev_sym_session_create(
7627 			ts_params->session_mpool);
7628 
7629 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7630 			&ut_params->aead_xform,
7631 			ts_params->session_priv_mpool);
7632 
7633 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7634 
7635 	return 0;
7636 }
7637 
7638 static int
7639 create_aead_xform(struct rte_crypto_op *op,
7640 		enum rte_crypto_aead_algorithm algo,
7641 		enum rte_crypto_aead_operation aead_op,
7642 		uint8_t *key, const uint8_t key_len,
7643 		const uint8_t aad_len, const uint8_t auth_len,
7644 		uint8_t iv_len)
7645 {
7646 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7647 			"failed to allocate space for crypto transform");
7648 
7649 	struct rte_crypto_sym_op *sym_op = op->sym;
7650 
7651 	/* Setup AEAD Parameters */
7652 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7653 	sym_op->xform->next = NULL;
7654 	sym_op->xform->aead.algo = algo;
7655 	sym_op->xform->aead.op = aead_op;
7656 	sym_op->xform->aead.key.data = key;
7657 	sym_op->xform->aead.key.length = key_len;
7658 	sym_op->xform->aead.iv.offset = IV_OFFSET;
7659 	sym_op->xform->aead.iv.length = iv_len;
7660 	sym_op->xform->aead.digest_length = auth_len;
7661 	sym_op->xform->aead.aad_length = aad_len;
7662 
7663 	debug_hexdump(stdout, "key:", key, key_len);
7664 
7665 	return 0;
7666 }
7667 
7668 static int
7669 create_aead_operation(enum rte_crypto_aead_operation op,
7670 		const struct aead_test_data *tdata)
7671 {
7672 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7673 	struct crypto_unittest_params *ut_params = &unittest_params;
7674 
7675 	uint8_t *plaintext, *ciphertext;
7676 	unsigned int aad_pad_len, plaintext_pad_len;
7677 
7678 	/* Generate Crypto op data structure */
7679 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7680 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7681 	TEST_ASSERT_NOT_NULL(ut_params->op,
7682 			"Failed to allocate symmetric crypto operation struct");
7683 
7684 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7685 
7686 	/* Append aad data */
7687 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7688 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7689 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7690 				aad_pad_len);
7691 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7692 				"no room to append aad");
7693 
7694 		sym_op->aead.aad.phys_addr =
7695 				rte_pktmbuf_iova(ut_params->ibuf);
7696 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
7697 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7698 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7699 			tdata->aad.len);
7700 
7701 		/* Append IV at the end of the crypto operation*/
7702 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7703 				uint8_t *, IV_OFFSET);
7704 
7705 		/* Copy IV 1 byte after the IV pointer, according to the API */
7706 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7707 		debug_hexdump(stdout, "iv:", iv_ptr,
7708 			tdata->iv.len);
7709 	} else {
7710 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7711 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7712 				aad_pad_len);
7713 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7714 				"no room to append aad");
7715 
7716 		sym_op->aead.aad.phys_addr =
7717 				rte_pktmbuf_iova(ut_params->ibuf);
7718 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7719 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7720 			tdata->aad.len);
7721 
7722 		/* Append IV at the end of the crypto operation*/
7723 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7724 				uint8_t *, IV_OFFSET);
7725 
7726 		rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7727 		debug_hexdump(stdout, "iv:", iv_ptr,
7728 			tdata->iv.len);
7729 	}
7730 
7731 	/* Append plaintext/ciphertext */
7732 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7733 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7734 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7735 				plaintext_pad_len);
7736 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7737 
7738 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7739 		debug_hexdump(stdout, "plaintext:", plaintext,
7740 				tdata->plaintext.len);
7741 
7742 		if (ut_params->obuf) {
7743 			ciphertext = (uint8_t *)rte_pktmbuf_append(
7744 					ut_params->obuf,
7745 					plaintext_pad_len + aad_pad_len);
7746 			TEST_ASSERT_NOT_NULL(ciphertext,
7747 					"no room to append ciphertext");
7748 
7749 			memset(ciphertext + aad_pad_len, 0,
7750 					tdata->ciphertext.len);
7751 		}
7752 	} else {
7753 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7754 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7755 				plaintext_pad_len);
7756 		TEST_ASSERT_NOT_NULL(ciphertext,
7757 				"no room to append ciphertext");
7758 
7759 		memcpy(ciphertext, tdata->ciphertext.data,
7760 				tdata->ciphertext.len);
7761 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7762 				tdata->ciphertext.len);
7763 
7764 		if (ut_params->obuf) {
7765 			plaintext = (uint8_t *)rte_pktmbuf_append(
7766 					ut_params->obuf,
7767 					plaintext_pad_len + aad_pad_len);
7768 			TEST_ASSERT_NOT_NULL(plaintext,
7769 					"no room to append plaintext");
7770 
7771 			memset(plaintext + aad_pad_len, 0,
7772 					tdata->plaintext.len);
7773 		}
7774 	}
7775 
7776 	/* Append digest data */
7777 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7778 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7779 				ut_params->obuf ? ut_params->obuf :
7780 						ut_params->ibuf,
7781 						tdata->auth_tag.len);
7782 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7783 				"no room to append digest");
7784 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7785 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7786 				ut_params->obuf ? ut_params->obuf :
7787 						ut_params->ibuf,
7788 						plaintext_pad_len +
7789 						aad_pad_len);
7790 	} else {
7791 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7792 				ut_params->ibuf, tdata->auth_tag.len);
7793 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7794 				"no room to append digest");
7795 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7796 				ut_params->ibuf,
7797 				plaintext_pad_len + aad_pad_len);
7798 
7799 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7800 			tdata->auth_tag.len);
7801 		debug_hexdump(stdout, "digest:",
7802 			sym_op->aead.digest.data,
7803 			tdata->auth_tag.len);
7804 	}
7805 
7806 	sym_op->aead.data.length = tdata->plaintext.len;
7807 	sym_op->aead.data.offset = aad_pad_len;
7808 
7809 	return 0;
7810 }
7811 
7812 static int
7813 test_authenticated_encryption(const struct aead_test_data *tdata)
7814 {
7815 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7816 	struct crypto_unittest_params *ut_params = &unittest_params;
7817 	struct rte_cryptodev_sym_capability_idx cap_idx;
7818 
7819 	int retval;
7820 	uint8_t *ciphertext, *auth_tag;
7821 	uint16_t plaintext_pad_len;
7822 	uint32_t i;
7823 
7824 	/* Create AEAD session */
7825 	retval = create_aead_session(ts_params->valid_devs[0],
7826 			tdata->algo,
7827 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
7828 			tdata->key.data, tdata->key.len,
7829 			tdata->aad.len, tdata->auth_tag.len,
7830 			tdata->iv.len);
7831 
7832 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7833 	cap_idx.algo.aead = tdata->algo;
7834 
7835 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
7836 			&cap_idx) == NULL) {
7837 		return -ENOTSUP;
7838 	}
7839 
7840 	if (retval < 0)
7841 		return retval;
7842 
7843 	if (tdata->aad.len > MBUF_SIZE) {
7844 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7845 		/* Populate full size of add data */
7846 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7847 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7848 	} else
7849 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7850 
7851 	/* clear mbuf payload */
7852 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7853 			rte_pktmbuf_tailroom(ut_params->ibuf));
7854 
7855 	/* Create AEAD operation */
7856 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7857 	if (retval < 0)
7858 		return retval;
7859 
7860 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7861 
7862 	ut_params->op->sym->m_src = ut_params->ibuf;
7863 
7864 	/* Process crypto operation */
7865 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7866 			ut_params->op), "failed to process sym crypto op");
7867 
7868 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7869 			"crypto op processing failed");
7870 
7871 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7872 
7873 	if (ut_params->op->sym->m_dst) {
7874 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7875 				uint8_t *);
7876 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7877 				uint8_t *, plaintext_pad_len);
7878 	} else {
7879 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7880 				uint8_t *,
7881 				ut_params->op->sym->cipher.data.offset);
7882 		auth_tag = ciphertext + plaintext_pad_len;
7883 	}
7884 
7885 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7886 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7887 
7888 	/* Validate obuf */
7889 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7890 			ciphertext,
7891 			tdata->ciphertext.data,
7892 			tdata->ciphertext.len,
7893 			"Ciphertext data not as expected");
7894 
7895 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
7896 			auth_tag,
7897 			tdata->auth_tag.data,
7898 			tdata->auth_tag.len,
7899 			"Generated auth tag not as expected");
7900 
7901 	return 0;
7902 
7903 }
7904 
7905 #ifdef RTE_LIBRTE_SECURITY
7906 /* Basic algorithm run function for async inplace mode.
7907  * Creates a session from input parameters and runs one operation
7908  * on input_vec. Checks the output of the crypto operation against
7909  * output_vec.
7910  */
7911 static int
7912 test_pdcp_proto(int i, int oop,
7913 	enum rte_crypto_cipher_operation opc,
7914 	enum rte_crypto_auth_operation opa,
7915 	uint8_t *input_vec,
7916 	unsigned int input_vec_len,
7917 	uint8_t *output_vec,
7918 	unsigned int output_vec_len)
7919 {
7920 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7921 	struct crypto_unittest_params *ut_params = &unittest_params;
7922 	uint8_t *plaintext;
7923 	int ret = TEST_SUCCESS;
7924 
7925 	/* Generate test mbuf data */
7926 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7927 
7928 	/* clear mbuf payload */
7929 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7930 			rte_pktmbuf_tailroom(ut_params->ibuf));
7931 
7932 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7933 						  input_vec_len);
7934 	memcpy(plaintext, input_vec, input_vec_len);
7935 
7936 	/* Out of place support */
7937 	if (oop) {
7938 		/*
7939 		 * For out-op-place we need to alloc another mbuf
7940 		 */
7941 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7942 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7943 	}
7944 
7945 	/* Set crypto type as IPSEC */
7946 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7947 
7948 	/* Setup Cipher Parameters */
7949 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7950 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7951 	ut_params->cipher_xform.cipher.op = opc;
7952 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7953 	ut_params->cipher_xform.cipher.key.length =
7954 					pdcp_test_params[i].cipher_key_len;
7955 	ut_params->cipher_xform.cipher.iv.length = 0;
7956 
7957 	/* Setup HMAC Parameters if ICV header is required */
7958 	if (pdcp_test_params[i].auth_alg != 0) {
7959 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7960 		ut_params->auth_xform.next = NULL;
7961 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7962 		ut_params->auth_xform.auth.op = opa;
7963 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7964 		ut_params->auth_xform.auth.key.length =
7965 					pdcp_test_params[i].auth_key_len;
7966 
7967 		ut_params->cipher_xform.next = &ut_params->auth_xform;
7968 	} else {
7969 		ut_params->cipher_xform.next = NULL;
7970 	}
7971 
7972 	struct rte_security_session_conf sess_conf = {
7973 		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7974 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
7975 		{.pdcp = {
7976 			.bearer = pdcp_test_bearer[i],
7977 			.domain = pdcp_test_params[i].domain,
7978 			.pkt_dir = pdcp_test_packet_direction[i],
7979 			.sn_size = pdcp_test_data_sn_size[i],
7980 			.hfn = pdcp_test_hfn[i],
7981 			.hfn_threshold = pdcp_test_hfn_threshold[i],
7982 		} },
7983 		.crypto_xform = &ut_params->cipher_xform
7984 	};
7985 
7986 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7987 				rte_cryptodev_get_sec_ctx(
7988 				ts_params->valid_devs[0]);
7989 
7990 	/* Create security session */
7991 	ut_params->sec_session = rte_security_session_create(ctx,
7992 				&sess_conf, ts_params->session_priv_mpool);
7993 
7994 	if (!ut_params->sec_session) {
7995 		printf("TestCase %s()-%d line %d failed %s: ",
7996 			__func__, i, __LINE__, "Failed to allocate session");
7997 		ret = TEST_FAILED;
7998 		goto on_err;
7999 	}
8000 
8001 	/* Generate crypto op data structure */
8002 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8003 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8004 	if (!ut_params->op) {
8005 		printf("TestCase %s()-%d line %d failed %s: ",
8006 			__func__, i, __LINE__,
8007 			"Failed to allocate symmetric crypto operation struct");
8008 		ret = TEST_FAILED;
8009 		goto on_err;
8010 	}
8011 
8012 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8013 
8014 	/* set crypto operation source mbuf */
8015 	ut_params->op->sym->m_src = ut_params->ibuf;
8016 	if (oop)
8017 		ut_params->op->sym->m_dst = ut_params->obuf;
8018 
8019 	/* Process crypto operation */
8020 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8021 		== NULL) {
8022 		printf("TestCase %s()-%d line %d failed %s: ",
8023 			__func__, i, __LINE__,
8024 			"failed to process sym crypto op");
8025 		ret = TEST_FAILED;
8026 		goto on_err;
8027 	}
8028 
8029 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8030 		printf("TestCase %s()-%d line %d failed %s: ",
8031 			__func__, i, __LINE__, "crypto op processing failed");
8032 		ret = TEST_FAILED;
8033 		goto on_err;
8034 	}
8035 
8036 	/* Validate obuf */
8037 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8038 			uint8_t *);
8039 	if (oop) {
8040 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8041 				uint8_t *);
8042 	}
8043 
8044 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
8045 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8046 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8047 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8048 		ret = TEST_FAILED;
8049 		goto on_err;
8050 	}
8051 
8052 on_err:
8053 	rte_crypto_op_free(ut_params->op);
8054 	ut_params->op = NULL;
8055 
8056 	if (ut_params->sec_session)
8057 		rte_security_session_destroy(ctx, ut_params->sec_session);
8058 	ut_params->sec_session = NULL;
8059 
8060 	rte_pktmbuf_free(ut_params->ibuf);
8061 	ut_params->ibuf = NULL;
8062 	if (oop) {
8063 		rte_pktmbuf_free(ut_params->obuf);
8064 		ut_params->obuf = NULL;
8065 	}
8066 
8067 	return ret;
8068 }
8069 
8070 static int
8071 test_pdcp_proto_SGL(int i, int oop,
8072 	enum rte_crypto_cipher_operation opc,
8073 	enum rte_crypto_auth_operation opa,
8074 	uint8_t *input_vec,
8075 	unsigned int input_vec_len,
8076 	uint8_t *output_vec,
8077 	unsigned int output_vec_len,
8078 	uint32_t fragsz,
8079 	uint32_t fragsz_oop)
8080 {
8081 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8082 	struct crypto_unittest_params *ut_params = &unittest_params;
8083 	uint8_t *plaintext;
8084 	struct rte_mbuf *buf, *buf_oop = NULL;
8085 	int ret = TEST_SUCCESS;
8086 	int to_trn = 0;
8087 	int to_trn_tbl[16];
8088 	int segs = 1;
8089 	unsigned int trn_data = 0;
8090 
8091 	if (fragsz > input_vec_len)
8092 		fragsz = input_vec_len;
8093 
8094 	uint16_t plaintext_len = fragsz;
8095 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8096 
8097 	if (fragsz_oop > output_vec_len)
8098 		frag_size_oop = output_vec_len;
8099 
8100 	int ecx = 0;
8101 	if (input_vec_len % fragsz != 0) {
8102 		if (input_vec_len / fragsz + 1 > 16)
8103 			return 1;
8104 	} else if (input_vec_len / fragsz > 16)
8105 		return 1;
8106 
8107 	/* Out of place support */
8108 	if (oop) {
8109 		/*
8110 		 * For out-op-place we need to alloc another mbuf
8111 		 */
8112 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8113 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8114 		buf_oop = ut_params->obuf;
8115 	}
8116 
8117 	/* Generate test mbuf data */
8118 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8119 
8120 	/* clear mbuf payload */
8121 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8122 			rte_pktmbuf_tailroom(ut_params->ibuf));
8123 
8124 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8125 						  plaintext_len);
8126 	memcpy(plaintext, input_vec, plaintext_len);
8127 	trn_data += plaintext_len;
8128 
8129 	buf = ut_params->ibuf;
8130 
8131 	/*
8132 	 * Loop until no more fragments
8133 	 */
8134 
8135 	while (trn_data < input_vec_len) {
8136 		++segs;
8137 		to_trn = (input_vec_len - trn_data < fragsz) ?
8138 				(input_vec_len - trn_data) : fragsz;
8139 
8140 		to_trn_tbl[ecx++] = to_trn;
8141 
8142 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8143 		buf = buf->next;
8144 
8145 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8146 				rte_pktmbuf_tailroom(buf));
8147 
8148 		/* OOP */
8149 		if (oop && !fragsz_oop) {
8150 			buf_oop->next =
8151 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
8152 			buf_oop = buf_oop->next;
8153 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8154 					0, rte_pktmbuf_tailroom(buf_oop));
8155 			rte_pktmbuf_append(buf_oop, to_trn);
8156 		}
8157 
8158 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8159 				to_trn);
8160 
8161 		memcpy(plaintext, input_vec + trn_data, to_trn);
8162 		trn_data += to_trn;
8163 	}
8164 
8165 	ut_params->ibuf->nb_segs = segs;
8166 
8167 	segs = 1;
8168 	if (fragsz_oop && oop) {
8169 		to_trn = 0;
8170 		ecx = 0;
8171 
8172 		trn_data = frag_size_oop;
8173 		while (trn_data < output_vec_len) {
8174 			++segs;
8175 			to_trn =
8176 				(output_vec_len - trn_data <
8177 						frag_size_oop) ?
8178 				(output_vec_len - trn_data) :
8179 						frag_size_oop;
8180 
8181 			to_trn_tbl[ecx++] = to_trn;
8182 
8183 			buf_oop->next =
8184 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
8185 			buf_oop = buf_oop->next;
8186 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8187 					0, rte_pktmbuf_tailroom(buf_oop));
8188 			rte_pktmbuf_append(buf_oop, to_trn);
8189 
8190 			trn_data += to_trn;
8191 		}
8192 		ut_params->obuf->nb_segs = segs;
8193 	}
8194 
8195 	ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8196 
8197 	/* Setup Cipher Parameters */
8198 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8199 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8200 	ut_params->cipher_xform.cipher.op = opc;
8201 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8202 	ut_params->cipher_xform.cipher.key.length =
8203 					pdcp_test_params[i].cipher_key_len;
8204 	ut_params->cipher_xform.cipher.iv.length = 0;
8205 
8206 	/* Setup HMAC Parameters if ICV header is required */
8207 	if (pdcp_test_params[i].auth_alg != 0) {
8208 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8209 		ut_params->auth_xform.next = NULL;
8210 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8211 		ut_params->auth_xform.auth.op = opa;
8212 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8213 		ut_params->auth_xform.auth.key.length =
8214 					pdcp_test_params[i].auth_key_len;
8215 
8216 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8217 	} else {
8218 		ut_params->cipher_xform.next = NULL;
8219 	}
8220 
8221 	struct rte_security_session_conf sess_conf = {
8222 		.action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
8223 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8224 		{.pdcp = {
8225 			.bearer = pdcp_test_bearer[i],
8226 			.domain = pdcp_test_params[i].domain,
8227 			.pkt_dir = pdcp_test_packet_direction[i],
8228 			.sn_size = pdcp_test_data_sn_size[i],
8229 			.hfn = pdcp_test_hfn[i],
8230 			.hfn_threshold = pdcp_test_hfn_threshold[i],
8231 		} },
8232 		.crypto_xform = &ut_params->cipher_xform
8233 	};
8234 
8235 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8236 				rte_cryptodev_get_sec_ctx(
8237 				ts_params->valid_devs[0]);
8238 
8239 	/* Create security session */
8240 	ut_params->sec_session = rte_security_session_create(ctx,
8241 				&sess_conf, ts_params->session_priv_mpool);
8242 
8243 	if (!ut_params->sec_session) {
8244 		printf("TestCase %s()-%d line %d failed %s: ",
8245 			__func__, i, __LINE__, "Failed to allocate session");
8246 		ret = TEST_FAILED;
8247 		goto on_err;
8248 	}
8249 
8250 	/* Generate crypto op data structure */
8251 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8252 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8253 	if (!ut_params->op) {
8254 		printf("TestCase %s()-%d line %d failed %s: ",
8255 			__func__, i, __LINE__,
8256 			"Failed to allocate symmetric crypto operation struct");
8257 		ret = TEST_FAILED;
8258 		goto on_err;
8259 	}
8260 
8261 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8262 
8263 	/* set crypto operation source mbuf */
8264 	ut_params->op->sym->m_src = ut_params->ibuf;
8265 	if (oop)
8266 		ut_params->op->sym->m_dst = ut_params->obuf;
8267 
8268 	/* Process crypto operation */
8269 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8270 		== NULL) {
8271 		printf("TestCase %s()-%d line %d failed %s: ",
8272 			__func__, i, __LINE__,
8273 			"failed to process sym crypto op");
8274 		ret = TEST_FAILED;
8275 		goto on_err;
8276 	}
8277 
8278 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8279 		printf("TestCase %s()-%d line %d failed %s: ",
8280 			__func__, i, __LINE__, "crypto op processing failed");
8281 		ret = TEST_FAILED;
8282 		goto on_err;
8283 	}
8284 
8285 	/* Validate obuf */
8286 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8287 			uint8_t *);
8288 	if (oop) {
8289 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8290 				uint8_t *);
8291 	}
8292 	if (fragsz_oop)
8293 		fragsz = frag_size_oop;
8294 	if (memcmp(ciphertext, output_vec, fragsz)) {
8295 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8296 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8297 		rte_hexdump(stdout, "reference", output_vec, fragsz);
8298 		ret = TEST_FAILED;
8299 		goto on_err;
8300 	}
8301 
8302 	buf = ut_params->op->sym->m_src->next;
8303 	if (oop)
8304 		buf = ut_params->op->sym->m_dst->next;
8305 
8306 	unsigned int off = fragsz;
8307 
8308 	ecx = 0;
8309 	while (buf) {
8310 		ciphertext = rte_pktmbuf_mtod(buf,
8311 				uint8_t *);
8312 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8313 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8314 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8315 			rte_hexdump(stdout, "reference", output_vec + off,
8316 					to_trn_tbl[ecx]);
8317 			ret = TEST_FAILED;
8318 			goto on_err;
8319 		}
8320 		off += to_trn_tbl[ecx++];
8321 		buf = buf->next;
8322 	}
8323 on_err:
8324 	rte_crypto_op_free(ut_params->op);
8325 	ut_params->op = NULL;
8326 
8327 	if (ut_params->sec_session)
8328 		rte_security_session_destroy(ctx, ut_params->sec_session);
8329 	ut_params->sec_session = NULL;
8330 
8331 	rte_pktmbuf_free(ut_params->ibuf);
8332 	ut_params->ibuf = NULL;
8333 	if (oop) {
8334 		rte_pktmbuf_free(ut_params->obuf);
8335 		ut_params->obuf = NULL;
8336 	}
8337 
8338 	return ret;
8339 }
8340 
8341 int
8342 test_pdcp_proto_cplane_encap(int i)
8343 {
8344 	return test_pdcp_proto(i, 0,
8345 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8346 		RTE_CRYPTO_AUTH_OP_GENERATE,
8347 		pdcp_test_data_in[i],
8348 		pdcp_test_data_in_len[i],
8349 		pdcp_test_data_out[i],
8350 		pdcp_test_data_in_len[i]+4);
8351 }
8352 
8353 int
8354 test_pdcp_proto_uplane_encap(int i)
8355 {
8356 	return test_pdcp_proto(i, 0,
8357 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8358 		RTE_CRYPTO_AUTH_OP_GENERATE,
8359 		pdcp_test_data_in[i],
8360 		pdcp_test_data_in_len[i],
8361 		pdcp_test_data_out[i],
8362 		pdcp_test_data_in_len[i]);
8363 
8364 }
8365 
8366 int
8367 test_pdcp_proto_uplane_encap_with_int(int i)
8368 {
8369 	return test_pdcp_proto(i, 0,
8370 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8371 		RTE_CRYPTO_AUTH_OP_GENERATE,
8372 		pdcp_test_data_in[i],
8373 		pdcp_test_data_in_len[i],
8374 		pdcp_test_data_out[i],
8375 		pdcp_test_data_in_len[i] + 4);
8376 }
8377 
8378 int
8379 test_pdcp_proto_cplane_decap(int i)
8380 {
8381 	return test_pdcp_proto(i, 0,
8382 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8383 		RTE_CRYPTO_AUTH_OP_VERIFY,
8384 		pdcp_test_data_out[i],
8385 		pdcp_test_data_in_len[i] + 4,
8386 		pdcp_test_data_in[i],
8387 		pdcp_test_data_in_len[i]);
8388 }
8389 
8390 int
8391 test_pdcp_proto_uplane_decap(int i)
8392 {
8393 	return test_pdcp_proto(i, 0,
8394 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8395 		RTE_CRYPTO_AUTH_OP_VERIFY,
8396 		pdcp_test_data_out[i],
8397 		pdcp_test_data_in_len[i],
8398 		pdcp_test_data_in[i],
8399 		pdcp_test_data_in_len[i]);
8400 }
8401 
8402 int
8403 test_pdcp_proto_uplane_decap_with_int(int i)
8404 {
8405 	return test_pdcp_proto(i, 0,
8406 		RTE_CRYPTO_CIPHER_OP_DECRYPT,
8407 		RTE_CRYPTO_AUTH_OP_VERIFY,
8408 		pdcp_test_data_out[i],
8409 		pdcp_test_data_in_len[i] + 4,
8410 		pdcp_test_data_in[i],
8411 		pdcp_test_data_in_len[i]);
8412 }
8413 
8414 static int
8415 test_PDCP_PROTO_SGL_in_place_32B(void)
8416 {
8417 	/* i can be used for running any PDCP case
8418 	 * In this case it is uplane 12-bit AES-SNOW DL encap
8419 	 */
8420 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8421 	return test_pdcp_proto_SGL(i, IN_PLACE,
8422 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8423 			RTE_CRYPTO_AUTH_OP_GENERATE,
8424 			pdcp_test_data_in[i],
8425 			pdcp_test_data_in_len[i],
8426 			pdcp_test_data_out[i],
8427 			pdcp_test_data_in_len[i]+4,
8428 			32, 0);
8429 }
8430 static int
8431 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8432 {
8433 	/* i can be used for running any PDCP case
8434 	 * In this case it is uplane 18-bit NULL-NULL DL encap
8435 	 */
8436 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8437 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8438 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8439 			RTE_CRYPTO_AUTH_OP_GENERATE,
8440 			pdcp_test_data_in[i],
8441 			pdcp_test_data_in_len[i],
8442 			pdcp_test_data_out[i],
8443 			pdcp_test_data_in_len[i]+4,
8444 			32, 128);
8445 }
8446 static int
8447 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8448 {
8449 	/* i can be used for running any PDCP case
8450 	 * In this case it is uplane 18-bit AES DL encap
8451 	 */
8452 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8453 			+ DOWNLINK;
8454 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8455 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8456 			RTE_CRYPTO_AUTH_OP_GENERATE,
8457 			pdcp_test_data_in[i],
8458 			pdcp_test_data_in_len[i],
8459 			pdcp_test_data_out[i],
8460 			pdcp_test_data_in_len[i],
8461 			32, 40);
8462 }
8463 static int
8464 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8465 {
8466 	/* i can be used for running any PDCP case
8467 	 * In this case it is cplane 12-bit AES-ZUC DL encap
8468 	 */
8469 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8470 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8471 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8472 			RTE_CRYPTO_AUTH_OP_GENERATE,
8473 			pdcp_test_data_in[i],
8474 			pdcp_test_data_in_len[i],
8475 			pdcp_test_data_out[i],
8476 			pdcp_test_data_in_len[i]+4,
8477 			128, 32);
8478 }
8479 #endif
8480 
8481 static int
8482 test_AES_GCM_authenticated_encryption_test_case_1(void)
8483 {
8484 	return test_authenticated_encryption(&gcm_test_case_1);
8485 }
8486 
8487 static int
8488 test_AES_GCM_authenticated_encryption_test_case_2(void)
8489 {
8490 	return test_authenticated_encryption(&gcm_test_case_2);
8491 }
8492 
8493 static int
8494 test_AES_GCM_authenticated_encryption_test_case_3(void)
8495 {
8496 	return test_authenticated_encryption(&gcm_test_case_3);
8497 }
8498 
8499 static int
8500 test_AES_GCM_authenticated_encryption_test_case_4(void)
8501 {
8502 	return test_authenticated_encryption(&gcm_test_case_4);
8503 }
8504 
8505 static int
8506 test_AES_GCM_authenticated_encryption_test_case_5(void)
8507 {
8508 	return test_authenticated_encryption(&gcm_test_case_5);
8509 }
8510 
8511 static int
8512 test_AES_GCM_authenticated_encryption_test_case_6(void)
8513 {
8514 	return test_authenticated_encryption(&gcm_test_case_6);
8515 }
8516 
8517 static int
8518 test_AES_GCM_authenticated_encryption_test_case_7(void)
8519 {
8520 	return test_authenticated_encryption(&gcm_test_case_7);
8521 }
8522 
8523 static int
8524 test_AES_GCM_authenticated_encryption_test_case_8(void)
8525 {
8526 	return test_authenticated_encryption(&gcm_test_case_8);
8527 }
8528 
8529 static int
8530 test_AES_GCM_auth_encryption_test_case_192_1(void)
8531 {
8532 	return test_authenticated_encryption(&gcm_test_case_192_1);
8533 }
8534 
8535 static int
8536 test_AES_GCM_auth_encryption_test_case_192_2(void)
8537 {
8538 	return test_authenticated_encryption(&gcm_test_case_192_2);
8539 }
8540 
8541 static int
8542 test_AES_GCM_auth_encryption_test_case_192_3(void)
8543 {
8544 	return test_authenticated_encryption(&gcm_test_case_192_3);
8545 }
8546 
8547 static int
8548 test_AES_GCM_auth_encryption_test_case_192_4(void)
8549 {
8550 	return test_authenticated_encryption(&gcm_test_case_192_4);
8551 }
8552 
8553 static int
8554 test_AES_GCM_auth_encryption_test_case_192_5(void)
8555 {
8556 	return test_authenticated_encryption(&gcm_test_case_192_5);
8557 }
8558 
8559 static int
8560 test_AES_GCM_auth_encryption_test_case_192_6(void)
8561 {
8562 	return test_authenticated_encryption(&gcm_test_case_192_6);
8563 }
8564 
8565 static int
8566 test_AES_GCM_auth_encryption_test_case_192_7(void)
8567 {
8568 	return test_authenticated_encryption(&gcm_test_case_192_7);
8569 }
8570 
8571 static int
8572 test_AES_GCM_auth_encryption_test_case_256_1(void)
8573 {
8574 	return test_authenticated_encryption(&gcm_test_case_256_1);
8575 }
8576 
8577 static int
8578 test_AES_GCM_auth_encryption_test_case_256_2(void)
8579 {
8580 	return test_authenticated_encryption(&gcm_test_case_256_2);
8581 }
8582 
8583 static int
8584 test_AES_GCM_auth_encryption_test_case_256_3(void)
8585 {
8586 	return test_authenticated_encryption(&gcm_test_case_256_3);
8587 }
8588 
8589 static int
8590 test_AES_GCM_auth_encryption_test_case_256_4(void)
8591 {
8592 	return test_authenticated_encryption(&gcm_test_case_256_4);
8593 }
8594 
8595 static int
8596 test_AES_GCM_auth_encryption_test_case_256_5(void)
8597 {
8598 	return test_authenticated_encryption(&gcm_test_case_256_5);
8599 }
8600 
8601 static int
8602 test_AES_GCM_auth_encryption_test_case_256_6(void)
8603 {
8604 	return test_authenticated_encryption(&gcm_test_case_256_6);
8605 }
8606 
8607 static int
8608 test_AES_GCM_auth_encryption_test_case_256_7(void)
8609 {
8610 	return test_authenticated_encryption(&gcm_test_case_256_7);
8611 }
8612 
8613 static int
8614 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8615 {
8616 	return test_authenticated_encryption(&gcm_test_case_aad_1);
8617 }
8618 
8619 static int
8620 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8621 {
8622 	return test_authenticated_encryption(&gcm_test_case_aad_2);
8623 }
8624 
8625 static int
8626 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8627 {
8628 	struct aead_test_data tdata;
8629 	int res;
8630 
8631 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8632 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8633 	tdata.iv.data[0] += 1;
8634 	res = test_authenticated_encryption(&tdata);
8635 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8636 	return TEST_SUCCESS;
8637 }
8638 
8639 static int
8640 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8641 {
8642 	struct aead_test_data tdata;
8643 	int res;
8644 
8645 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8646 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8647 	tdata.plaintext.data[0] += 1;
8648 	res = test_authenticated_encryption(&tdata);
8649 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8650 	return TEST_SUCCESS;
8651 }
8652 
8653 static int
8654 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8655 {
8656 	struct aead_test_data tdata;
8657 	int res;
8658 
8659 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8660 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8661 	tdata.ciphertext.data[0] += 1;
8662 	res = test_authenticated_encryption(&tdata);
8663 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8664 	return TEST_SUCCESS;
8665 }
8666 
8667 static int
8668 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8669 {
8670 	struct aead_test_data tdata;
8671 	int res;
8672 
8673 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8674 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8675 	tdata.aad.len += 1;
8676 	res = test_authenticated_encryption(&tdata);
8677 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8678 	return TEST_SUCCESS;
8679 }
8680 
8681 static int
8682 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8683 {
8684 	struct aead_test_data tdata;
8685 	uint8_t aad[gcm_test_case_7.aad.len];
8686 	int res;
8687 
8688 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8689 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8690 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8691 	aad[0] += 1;
8692 	tdata.aad.data = aad;
8693 	res = test_authenticated_encryption(&tdata);
8694 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8695 	return TEST_SUCCESS;
8696 }
8697 
8698 static int
8699 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8700 {
8701 	struct aead_test_data tdata;
8702 	int res;
8703 
8704 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8705 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8706 	tdata.auth_tag.data[0] += 1;
8707 	res = test_authenticated_encryption(&tdata);
8708 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8709 	return TEST_SUCCESS;
8710 }
8711 
8712 static int
8713 test_authenticated_decryption(const struct aead_test_data *tdata)
8714 {
8715 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8716 	struct crypto_unittest_params *ut_params = &unittest_params;
8717 	struct rte_cryptodev_sym_capability_idx cap_idx;
8718 
8719 	int retval;
8720 	uint8_t *plaintext;
8721 	uint32_t i;
8722 
8723 	/* Create AEAD session */
8724 	retval = create_aead_session(ts_params->valid_devs[0],
8725 			tdata->algo,
8726 			RTE_CRYPTO_AEAD_OP_DECRYPT,
8727 			tdata->key.data, tdata->key.len,
8728 			tdata->aad.len, tdata->auth_tag.len,
8729 			tdata->iv.len);
8730 	if (retval < 0)
8731 		return retval;
8732 
8733 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8734 	cap_idx.algo.aead = tdata->algo;
8735 
8736 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8737 			&cap_idx) == NULL) {
8738 		return -ENOTSUP;
8739 	}
8740 
8741 	/* alloc mbuf and set payload */
8742 	if (tdata->aad.len > MBUF_SIZE) {
8743 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8744 		/* Populate full size of add data */
8745 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8746 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8747 	} else
8748 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8749 
8750 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8751 			rte_pktmbuf_tailroom(ut_params->ibuf));
8752 
8753 	/* Create AEAD operation */
8754 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8755 	if (retval < 0)
8756 		return retval;
8757 
8758 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8759 
8760 	ut_params->op->sym->m_src = ut_params->ibuf;
8761 
8762 	/* Process crypto operation */
8763 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8764 			ut_params->op), "failed to process sym crypto op");
8765 
8766 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8767 			"crypto op processing failed");
8768 
8769 	if (ut_params->op->sym->m_dst)
8770 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8771 				uint8_t *);
8772 	else
8773 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8774 				uint8_t *,
8775 				ut_params->op->sym->cipher.data.offset);
8776 
8777 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8778 
8779 	/* Validate obuf */
8780 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8781 			plaintext,
8782 			tdata->plaintext.data,
8783 			tdata->plaintext.len,
8784 			"Plaintext data not as expected");
8785 
8786 	TEST_ASSERT_EQUAL(ut_params->op->status,
8787 			RTE_CRYPTO_OP_STATUS_SUCCESS,
8788 			"Authentication failed");
8789 
8790 	return 0;
8791 }
8792 
8793 static int
8794 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
8795 {
8796 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
8797 }
8798 
8799 static int
8800 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
8801 {
8802 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
8803 }
8804 
8805 static int
8806 test_AES_GCM_authenticated_decryption_test_case_1(void)
8807 {
8808 	return test_authenticated_decryption(&gcm_test_case_1);
8809 }
8810 
8811 static int
8812 test_AES_GCM_authenticated_decryption_test_case_2(void)
8813 {
8814 	return test_authenticated_decryption(&gcm_test_case_2);
8815 }
8816 
8817 static int
8818 test_AES_GCM_authenticated_decryption_test_case_3(void)
8819 {
8820 	return test_authenticated_decryption(&gcm_test_case_3);
8821 }
8822 
8823 static int
8824 test_AES_GCM_authenticated_decryption_test_case_4(void)
8825 {
8826 	return test_authenticated_decryption(&gcm_test_case_4);
8827 }
8828 
8829 static int
8830 test_AES_GCM_authenticated_decryption_test_case_5(void)
8831 {
8832 	return test_authenticated_decryption(&gcm_test_case_5);
8833 }
8834 
8835 static int
8836 test_AES_GCM_authenticated_decryption_test_case_6(void)
8837 {
8838 	return test_authenticated_decryption(&gcm_test_case_6);
8839 }
8840 
8841 static int
8842 test_AES_GCM_authenticated_decryption_test_case_7(void)
8843 {
8844 	return test_authenticated_decryption(&gcm_test_case_7);
8845 }
8846 
8847 static int
8848 test_AES_GCM_authenticated_decryption_test_case_8(void)
8849 {
8850 	return test_authenticated_decryption(&gcm_test_case_8);
8851 }
8852 
8853 static int
8854 test_AES_GCM_auth_decryption_test_case_192_1(void)
8855 {
8856 	return test_authenticated_decryption(&gcm_test_case_192_1);
8857 }
8858 
8859 static int
8860 test_AES_GCM_auth_decryption_test_case_192_2(void)
8861 {
8862 	return test_authenticated_decryption(&gcm_test_case_192_2);
8863 }
8864 
8865 static int
8866 test_AES_GCM_auth_decryption_test_case_192_3(void)
8867 {
8868 	return test_authenticated_decryption(&gcm_test_case_192_3);
8869 }
8870 
8871 static int
8872 test_AES_GCM_auth_decryption_test_case_192_4(void)
8873 {
8874 	return test_authenticated_decryption(&gcm_test_case_192_4);
8875 }
8876 
8877 static int
8878 test_AES_GCM_auth_decryption_test_case_192_5(void)
8879 {
8880 	return test_authenticated_decryption(&gcm_test_case_192_5);
8881 }
8882 
8883 static int
8884 test_AES_GCM_auth_decryption_test_case_192_6(void)
8885 {
8886 	return test_authenticated_decryption(&gcm_test_case_192_6);
8887 }
8888 
8889 static int
8890 test_AES_GCM_auth_decryption_test_case_192_7(void)
8891 {
8892 	return test_authenticated_decryption(&gcm_test_case_192_7);
8893 }
8894 
8895 static int
8896 test_AES_GCM_auth_decryption_test_case_256_1(void)
8897 {
8898 	return test_authenticated_decryption(&gcm_test_case_256_1);
8899 }
8900 
8901 static int
8902 test_AES_GCM_auth_decryption_test_case_256_2(void)
8903 {
8904 	return test_authenticated_decryption(&gcm_test_case_256_2);
8905 }
8906 
8907 static int
8908 test_AES_GCM_auth_decryption_test_case_256_3(void)
8909 {
8910 	return test_authenticated_decryption(&gcm_test_case_256_3);
8911 }
8912 
8913 static int
8914 test_AES_GCM_auth_decryption_test_case_256_4(void)
8915 {
8916 	return test_authenticated_decryption(&gcm_test_case_256_4);
8917 }
8918 
8919 static int
8920 test_AES_GCM_auth_decryption_test_case_256_5(void)
8921 {
8922 	return test_authenticated_decryption(&gcm_test_case_256_5);
8923 }
8924 
8925 static int
8926 test_AES_GCM_auth_decryption_test_case_256_6(void)
8927 {
8928 	return test_authenticated_decryption(&gcm_test_case_256_6);
8929 }
8930 
8931 static int
8932 test_AES_GCM_auth_decryption_test_case_256_7(void)
8933 {
8934 	return test_authenticated_decryption(&gcm_test_case_256_7);
8935 }
8936 
8937 static int
8938 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8939 {
8940 	return test_authenticated_decryption(&gcm_test_case_aad_1);
8941 }
8942 
8943 static int
8944 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8945 {
8946 	return test_authenticated_decryption(&gcm_test_case_aad_2);
8947 }
8948 
8949 static int
8950 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8951 {
8952 	struct aead_test_data tdata;
8953 	int res;
8954 
8955 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8956 	tdata.iv.data[0] += 1;
8957 	res = test_authenticated_decryption(&tdata);
8958 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8959 	return TEST_SUCCESS;
8960 }
8961 
8962 static int
8963 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8964 {
8965 	struct aead_test_data tdata;
8966 	int res;
8967 
8968 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8969 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8970 	tdata.plaintext.data[0] += 1;
8971 	res = test_authenticated_decryption(&tdata);
8972 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8973 	return TEST_SUCCESS;
8974 }
8975 
8976 static int
8977 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8978 {
8979 	struct aead_test_data tdata;
8980 	int res;
8981 
8982 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8983 	tdata.ciphertext.data[0] += 1;
8984 	res = test_authenticated_decryption(&tdata);
8985 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8986 	return TEST_SUCCESS;
8987 }
8988 
8989 static int
8990 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8991 {
8992 	struct aead_test_data tdata;
8993 	int res;
8994 
8995 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8996 	tdata.aad.len += 1;
8997 	res = test_authenticated_decryption(&tdata);
8998 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8999 	return TEST_SUCCESS;
9000 }
9001 
9002 static int
9003 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9004 {
9005 	struct aead_test_data tdata;
9006 	uint8_t aad[gcm_test_case_7.aad.len];
9007 	int res;
9008 
9009 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9010 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9011 	aad[0] += 1;
9012 	tdata.aad.data = aad;
9013 	res = test_authenticated_decryption(&tdata);
9014 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9015 	return TEST_SUCCESS;
9016 }
9017 
9018 static int
9019 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9020 {
9021 	struct aead_test_data tdata;
9022 	int res;
9023 
9024 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9025 	tdata.auth_tag.data[0] += 1;
9026 	res = test_authenticated_decryption(&tdata);
9027 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9028 	return TEST_SUCCESS;
9029 }
9030 
9031 static int
9032 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9033 {
9034 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9035 	struct crypto_unittest_params *ut_params = &unittest_params;
9036 
9037 	int retval;
9038 	uint8_t *ciphertext, *auth_tag;
9039 	uint16_t plaintext_pad_len;
9040 
9041 	/* Create AEAD session */
9042 	retval = create_aead_session(ts_params->valid_devs[0],
9043 			tdata->algo,
9044 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9045 			tdata->key.data, tdata->key.len,
9046 			tdata->aad.len, tdata->auth_tag.len,
9047 			tdata->iv.len);
9048 	if (retval < 0)
9049 		return retval;
9050 
9051 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9052 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9053 
9054 	/* clear mbuf payload */
9055 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9056 			rte_pktmbuf_tailroom(ut_params->ibuf));
9057 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9058 			rte_pktmbuf_tailroom(ut_params->obuf));
9059 
9060 	/* Create AEAD operation */
9061 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9062 	if (retval < 0)
9063 		return retval;
9064 
9065 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9066 
9067 	ut_params->op->sym->m_src = ut_params->ibuf;
9068 	ut_params->op->sym->m_dst = ut_params->obuf;
9069 
9070 	/* Process crypto operation */
9071 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9072 			ut_params->op), "failed to process sym crypto op");
9073 
9074 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9075 			"crypto op processing failed");
9076 
9077 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9078 
9079 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9080 			ut_params->op->sym->cipher.data.offset);
9081 	auth_tag = ciphertext + plaintext_pad_len;
9082 
9083 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9084 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9085 
9086 	/* Validate obuf */
9087 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9088 			ciphertext,
9089 			tdata->ciphertext.data,
9090 			tdata->ciphertext.len,
9091 			"Ciphertext data not as expected");
9092 
9093 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9094 			auth_tag,
9095 			tdata->auth_tag.data,
9096 			tdata->auth_tag.len,
9097 			"Generated auth tag not as expected");
9098 
9099 	return 0;
9100 
9101 }
9102 
9103 static int
9104 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9105 {
9106 	return test_authenticated_encryption_oop(&gcm_test_case_5);
9107 }
9108 
9109 static int
9110 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9111 {
9112 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9113 	struct crypto_unittest_params *ut_params = &unittest_params;
9114 
9115 	int retval;
9116 	uint8_t *plaintext;
9117 
9118 	/* Create AEAD session */
9119 	retval = create_aead_session(ts_params->valid_devs[0],
9120 			tdata->algo,
9121 			RTE_CRYPTO_AEAD_OP_DECRYPT,
9122 			tdata->key.data, tdata->key.len,
9123 			tdata->aad.len, tdata->auth_tag.len,
9124 			tdata->iv.len);
9125 	if (retval < 0)
9126 		return retval;
9127 
9128 	/* alloc mbuf and set payload */
9129 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9130 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9131 
9132 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9133 			rte_pktmbuf_tailroom(ut_params->ibuf));
9134 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9135 			rte_pktmbuf_tailroom(ut_params->obuf));
9136 
9137 	/* Create AEAD operation */
9138 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9139 	if (retval < 0)
9140 		return retval;
9141 
9142 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9143 
9144 	ut_params->op->sym->m_src = ut_params->ibuf;
9145 	ut_params->op->sym->m_dst = ut_params->obuf;
9146 
9147 	/* Process crypto operation */
9148 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9149 			ut_params->op), "failed to process sym crypto op");
9150 
9151 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9152 			"crypto op processing failed");
9153 
9154 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9155 			ut_params->op->sym->cipher.data.offset);
9156 
9157 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9158 
9159 	/* Validate obuf */
9160 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9161 			plaintext,
9162 			tdata->plaintext.data,
9163 			tdata->plaintext.len,
9164 			"Plaintext data not as expected");
9165 
9166 	TEST_ASSERT_EQUAL(ut_params->op->status,
9167 			RTE_CRYPTO_OP_STATUS_SUCCESS,
9168 			"Authentication failed");
9169 	return 0;
9170 }
9171 
9172 static int
9173 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9174 {
9175 	return test_authenticated_decryption_oop(&gcm_test_case_5);
9176 }
9177 
9178 static int
9179 test_authenticated_encryption_sessionless(
9180 		const struct aead_test_data *tdata)
9181 {
9182 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9183 	struct crypto_unittest_params *ut_params = &unittest_params;
9184 
9185 	int retval;
9186 	uint8_t *ciphertext, *auth_tag;
9187 	uint16_t plaintext_pad_len;
9188 	uint8_t key[tdata->key.len + 1];
9189 
9190 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9191 
9192 	/* clear mbuf payload */
9193 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9194 			rte_pktmbuf_tailroom(ut_params->ibuf));
9195 
9196 	/* Create AEAD operation */
9197 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9198 	if (retval < 0)
9199 		return retval;
9200 
9201 	/* Create GCM xform */
9202 	memcpy(key, tdata->key.data, tdata->key.len);
9203 	retval = create_aead_xform(ut_params->op,
9204 			tdata->algo,
9205 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9206 			key, tdata->key.len,
9207 			tdata->aad.len, tdata->auth_tag.len,
9208 			tdata->iv.len);
9209 	if (retval < 0)
9210 		return retval;
9211 
9212 	ut_params->op->sym->m_src = ut_params->ibuf;
9213 
9214 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9215 			RTE_CRYPTO_OP_SESSIONLESS,
9216 			"crypto op session type not sessionless");
9217 
9218 	/* Process crypto operation */
9219 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9220 			ut_params->op), "failed to process sym crypto op");
9221 
9222 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9223 
9224 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9225 			"crypto op status not success");
9226 
9227 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9228 
9229 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9230 			ut_params->op->sym->cipher.data.offset);
9231 	auth_tag = ciphertext + plaintext_pad_len;
9232 
9233 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9234 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9235 
9236 	/* Validate obuf */
9237 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9238 			ciphertext,
9239 			tdata->ciphertext.data,
9240 			tdata->ciphertext.len,
9241 			"Ciphertext data not as expected");
9242 
9243 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9244 			auth_tag,
9245 			tdata->auth_tag.data,
9246 			tdata->auth_tag.len,
9247 			"Generated auth tag not as expected");
9248 
9249 	return 0;
9250 
9251 }
9252 
9253 static int
9254 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9255 {
9256 	return test_authenticated_encryption_sessionless(
9257 			&gcm_test_case_5);
9258 }
9259 
9260 static int
9261 test_authenticated_decryption_sessionless(
9262 		const struct aead_test_data *tdata)
9263 {
9264 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9265 	struct crypto_unittest_params *ut_params = &unittest_params;
9266 
9267 	int retval;
9268 	uint8_t *plaintext;
9269 	uint8_t key[tdata->key.len + 1];
9270 
9271 	/* alloc mbuf and set payload */
9272 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9273 
9274 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9275 			rte_pktmbuf_tailroom(ut_params->ibuf));
9276 
9277 	/* Create AEAD operation */
9278 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9279 	if (retval < 0)
9280 		return retval;
9281 
9282 	/* Create AEAD xform */
9283 	memcpy(key, tdata->key.data, tdata->key.len);
9284 	retval = create_aead_xform(ut_params->op,
9285 			tdata->algo,
9286 			RTE_CRYPTO_AEAD_OP_DECRYPT,
9287 			key, tdata->key.len,
9288 			tdata->aad.len, tdata->auth_tag.len,
9289 			tdata->iv.len);
9290 	if (retval < 0)
9291 		return retval;
9292 
9293 	ut_params->op->sym->m_src = ut_params->ibuf;
9294 
9295 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9296 			RTE_CRYPTO_OP_SESSIONLESS,
9297 			"crypto op session type not sessionless");
9298 
9299 	/* Process crypto operation */
9300 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9301 			ut_params->op), "failed to process sym crypto op");
9302 
9303 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9304 
9305 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9306 			"crypto op status not success");
9307 
9308 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9309 			ut_params->op->sym->cipher.data.offset);
9310 
9311 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9312 
9313 	/* Validate obuf */
9314 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9315 			plaintext,
9316 			tdata->plaintext.data,
9317 			tdata->plaintext.len,
9318 			"Plaintext data not as expected");
9319 
9320 	TEST_ASSERT_EQUAL(ut_params->op->status,
9321 			RTE_CRYPTO_OP_STATUS_SUCCESS,
9322 			"Authentication failed");
9323 	return 0;
9324 }
9325 
9326 static int
9327 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9328 {
9329 	return test_authenticated_decryption_sessionless(
9330 			&gcm_test_case_5);
9331 }
9332 
9333 static int
9334 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9335 {
9336 	return test_authenticated_encryption(&ccm_test_case_128_1);
9337 }
9338 
9339 static int
9340 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9341 {
9342 	return test_authenticated_encryption(&ccm_test_case_128_2);
9343 }
9344 
9345 static int
9346 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9347 {
9348 	return test_authenticated_encryption(&ccm_test_case_128_3);
9349 }
9350 
9351 static int
9352 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9353 {
9354 	return test_authenticated_decryption(&ccm_test_case_128_1);
9355 }
9356 
9357 static int
9358 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9359 {
9360 	return test_authenticated_decryption(&ccm_test_case_128_2);
9361 }
9362 
9363 static int
9364 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9365 {
9366 	return test_authenticated_decryption(&ccm_test_case_128_3);
9367 }
9368 
9369 static int
9370 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9371 {
9372 	return test_authenticated_encryption(&ccm_test_case_192_1);
9373 }
9374 
9375 static int
9376 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9377 {
9378 	return test_authenticated_encryption(&ccm_test_case_192_2);
9379 }
9380 
9381 static int
9382 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9383 {
9384 	return test_authenticated_encryption(&ccm_test_case_192_3);
9385 }
9386 
9387 static int
9388 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9389 {
9390 	return test_authenticated_decryption(&ccm_test_case_192_1);
9391 }
9392 
9393 static int
9394 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9395 {
9396 	return test_authenticated_decryption(&ccm_test_case_192_2);
9397 }
9398 
9399 static int
9400 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9401 {
9402 	return test_authenticated_decryption(&ccm_test_case_192_3);
9403 }
9404 
9405 static int
9406 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9407 {
9408 	return test_authenticated_encryption(&ccm_test_case_256_1);
9409 }
9410 
9411 static int
9412 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9413 {
9414 	return test_authenticated_encryption(&ccm_test_case_256_2);
9415 }
9416 
9417 static int
9418 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9419 {
9420 	return test_authenticated_encryption(&ccm_test_case_256_3);
9421 }
9422 
9423 static int
9424 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9425 {
9426 	return test_authenticated_decryption(&ccm_test_case_256_1);
9427 }
9428 
9429 static int
9430 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9431 {
9432 	return test_authenticated_decryption(&ccm_test_case_256_2);
9433 }
9434 
9435 static int
9436 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9437 {
9438 	return test_authenticated_decryption(&ccm_test_case_256_3);
9439 }
9440 
9441 static int
9442 test_stats(void)
9443 {
9444 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9445 	struct rte_cryptodev_stats stats;
9446 	struct rte_cryptodev *dev;
9447 	cryptodev_stats_get_t temp_pfn;
9448 
9449 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9450 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9451 			&stats) == -ENODEV),
9452 		"rte_cryptodev_stats_get invalid dev failed");
9453 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9454 		"rte_cryptodev_stats_get invalid Param failed");
9455 	dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9456 	temp_pfn = dev->dev_ops->stats_get;
9457 	dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9458 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9459 			== -ENOTSUP),
9460 		"rte_cryptodev_stats_get invalid Param failed");
9461 	dev->dev_ops->stats_get = temp_pfn;
9462 
9463 	/* Test expected values */
9464 	ut_setup();
9465 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
9466 	ut_teardown();
9467 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9468 			&stats),
9469 		"rte_cryptodev_stats_get failed");
9470 	TEST_ASSERT((stats.enqueued_count == 1),
9471 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9472 	TEST_ASSERT((stats.dequeued_count == 1),
9473 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9474 	TEST_ASSERT((stats.enqueue_err_count == 0),
9475 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9476 	TEST_ASSERT((stats.dequeue_err_count == 0),
9477 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9478 
9479 	/* invalid device but should ignore and not reset device stats*/
9480 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9481 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9482 			&stats),
9483 		"rte_cryptodev_stats_get failed");
9484 	TEST_ASSERT((stats.enqueued_count == 1),
9485 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9486 
9487 	/* check that a valid reset clears stats */
9488 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9489 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9490 			&stats),
9491 					  "rte_cryptodev_stats_get failed");
9492 	TEST_ASSERT((stats.enqueued_count == 0),
9493 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9494 	TEST_ASSERT((stats.dequeued_count == 0),
9495 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
9496 
9497 	return TEST_SUCCESS;
9498 }
9499 
9500 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9501 				   struct crypto_unittest_params *ut_params,
9502 				   enum rte_crypto_auth_operation op,
9503 				   const struct HMAC_MD5_vector *test_case)
9504 {
9505 	uint8_t key[64];
9506 
9507 	memcpy(key, test_case->key.data, test_case->key.len);
9508 
9509 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9510 	ut_params->auth_xform.next = NULL;
9511 	ut_params->auth_xform.auth.op = op;
9512 
9513 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9514 
9515 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9516 	ut_params->auth_xform.auth.key.length = test_case->key.len;
9517 	ut_params->auth_xform.auth.key.data = key;
9518 
9519 	ut_params->sess = rte_cryptodev_sym_session_create(
9520 			ts_params->session_mpool);
9521 
9522 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9523 			ut_params->sess, &ut_params->auth_xform,
9524 			ts_params->session_priv_mpool);
9525 
9526 	if (ut_params->sess == NULL)
9527 		return TEST_FAILED;
9528 
9529 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9530 
9531 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9532 			rte_pktmbuf_tailroom(ut_params->ibuf));
9533 
9534 	return 0;
9535 }
9536 
9537 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9538 			      const struct HMAC_MD5_vector *test_case,
9539 			      uint8_t **plaintext)
9540 {
9541 	uint16_t plaintext_pad_len;
9542 
9543 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9544 
9545 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9546 				16);
9547 
9548 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9549 			plaintext_pad_len);
9550 	memcpy(*plaintext, test_case->plaintext.data,
9551 			test_case->plaintext.len);
9552 
9553 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9554 			ut_params->ibuf, MD5_DIGEST_LEN);
9555 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9556 			"no room to append digest");
9557 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9558 			ut_params->ibuf, plaintext_pad_len);
9559 
9560 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9561 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9562 			   test_case->auth_tag.len);
9563 	}
9564 
9565 	sym_op->auth.data.offset = 0;
9566 	sym_op->auth.data.length = test_case->plaintext.len;
9567 
9568 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9569 	ut_params->op->sym->m_src = ut_params->ibuf;
9570 
9571 	return 0;
9572 }
9573 
9574 static int
9575 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9576 {
9577 	uint16_t plaintext_pad_len;
9578 	uint8_t *plaintext, *auth_tag;
9579 
9580 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9581 	struct crypto_unittest_params *ut_params = &unittest_params;
9582 
9583 	if (MD5_HMAC_create_session(ts_params, ut_params,
9584 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9585 		return TEST_FAILED;
9586 
9587 	/* Generate Crypto op data structure */
9588 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9589 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9590 	TEST_ASSERT_NOT_NULL(ut_params->op,
9591 			"Failed to allocate symmetric crypto operation struct");
9592 
9593 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9594 				16);
9595 
9596 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9597 		return TEST_FAILED;
9598 
9599 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9600 			ut_params->op), "failed to process sym crypto op");
9601 
9602 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9603 			"crypto op processing failed");
9604 
9605 	if (ut_params->op->sym->m_dst) {
9606 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9607 				uint8_t *, plaintext_pad_len);
9608 	} else {
9609 		auth_tag = plaintext + plaintext_pad_len;
9610 	}
9611 
9612 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9613 			auth_tag,
9614 			test_case->auth_tag.data,
9615 			test_case->auth_tag.len,
9616 			"HMAC_MD5 generated tag not as expected");
9617 
9618 	return TEST_SUCCESS;
9619 }
9620 
9621 static int
9622 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9623 {
9624 	uint8_t *plaintext;
9625 
9626 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9627 	struct crypto_unittest_params *ut_params = &unittest_params;
9628 
9629 	if (MD5_HMAC_create_session(ts_params, ut_params,
9630 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9631 		return TEST_FAILED;
9632 	}
9633 
9634 	/* Generate Crypto op data structure */
9635 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9636 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9637 	TEST_ASSERT_NOT_NULL(ut_params->op,
9638 			"Failed to allocate symmetric crypto operation struct");
9639 
9640 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9641 		return TEST_FAILED;
9642 
9643 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9644 			ut_params->op), "failed to process sym crypto op");
9645 
9646 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9647 			"HMAC_MD5 crypto op processing failed");
9648 
9649 	return TEST_SUCCESS;
9650 }
9651 
9652 static int
9653 test_MD5_HMAC_generate_case_1(void)
9654 {
9655 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9656 }
9657 
9658 static int
9659 test_MD5_HMAC_verify_case_1(void)
9660 {
9661 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9662 }
9663 
9664 static int
9665 test_MD5_HMAC_generate_case_2(void)
9666 {
9667 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9668 }
9669 
9670 static int
9671 test_MD5_HMAC_verify_case_2(void)
9672 {
9673 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9674 }
9675 
9676 static int
9677 test_multi_session(void)
9678 {
9679 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9680 	struct crypto_unittest_params *ut_params = &unittest_params;
9681 
9682 	struct rte_cryptodev_info dev_info;
9683 	struct rte_cryptodev_sym_session **sessions;
9684 
9685 	uint16_t i;
9686 
9687 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9688 			aes_cbc_key, hmac_sha512_key);
9689 
9690 
9691 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9692 
9693 	sessions = rte_malloc(NULL,
9694 			(sizeof(struct rte_cryptodev_sym_session *) *
9695 			MAX_NB_SESSIONS) + 1, 0);
9696 
9697 	/* Create multiple crypto sessions*/
9698 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
9699 
9700 		sessions[i] = rte_cryptodev_sym_session_create(
9701 				ts_params->session_mpool);
9702 
9703 		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9704 				sessions[i], &ut_params->auth_xform,
9705 				ts_params->session_priv_mpool);
9706 		TEST_ASSERT_NOT_NULL(sessions[i],
9707 				"Session creation failed at session number %u",
9708 				i);
9709 
9710 		/* Attempt to send a request on each session */
9711 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9712 			sessions[i],
9713 			ut_params,
9714 			ts_params,
9715 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9716 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9717 			aes_cbc_iv),
9718 			"Failed to perform decrypt on request number %u.", i);
9719 		/* free crypto operation structure */
9720 		if (ut_params->op)
9721 			rte_crypto_op_free(ut_params->op);
9722 
9723 		/*
9724 		 * free mbuf - both obuf and ibuf are usually the same,
9725 		 * so check if they point at the same address is necessary,
9726 		 * to avoid freeing the mbuf twice.
9727 		 */
9728 		if (ut_params->obuf) {
9729 			rte_pktmbuf_free(ut_params->obuf);
9730 			if (ut_params->ibuf == ut_params->obuf)
9731 				ut_params->ibuf = 0;
9732 			ut_params->obuf = 0;
9733 		}
9734 		if (ut_params->ibuf) {
9735 			rte_pktmbuf_free(ut_params->ibuf);
9736 			ut_params->ibuf = 0;
9737 		}
9738 	}
9739 
9740 	/* Next session create should fail */
9741 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9742 			sessions[i], &ut_params->auth_xform,
9743 			ts_params->session_priv_mpool);
9744 	TEST_ASSERT_NULL(sessions[i],
9745 			"Session creation succeeded unexpectedly!");
9746 
9747 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
9748 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9749 				sessions[i]);
9750 		rte_cryptodev_sym_session_free(sessions[i]);
9751 	}
9752 
9753 	rte_free(sessions);
9754 
9755 	return TEST_SUCCESS;
9756 }
9757 
9758 struct multi_session_params {
9759 	struct crypto_unittest_params ut_params;
9760 	uint8_t *cipher_key;
9761 	uint8_t *hmac_key;
9762 	const uint8_t *cipher;
9763 	const uint8_t *digest;
9764 	uint8_t *iv;
9765 };
9766 
9767 #define MB_SESSION_NUMBER 3
9768 
9769 static int
9770 test_multi_session_random_usage(void)
9771 {
9772 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9773 	struct rte_cryptodev_info dev_info;
9774 	struct rte_cryptodev_sym_session **sessions;
9775 	uint32_t i, j;
9776 	struct multi_session_params ut_paramz[] = {
9777 
9778 		{
9779 			.cipher_key = ms_aes_cbc_key0,
9780 			.hmac_key = ms_hmac_key0,
9781 			.cipher = ms_aes_cbc_cipher0,
9782 			.digest = ms_hmac_digest0,
9783 			.iv = ms_aes_cbc_iv0
9784 		},
9785 		{
9786 			.cipher_key = ms_aes_cbc_key1,
9787 			.hmac_key = ms_hmac_key1,
9788 			.cipher = ms_aes_cbc_cipher1,
9789 			.digest = ms_hmac_digest1,
9790 			.iv = ms_aes_cbc_iv1
9791 		},
9792 		{
9793 			.cipher_key = ms_aes_cbc_key2,
9794 			.hmac_key = ms_hmac_key2,
9795 			.cipher = ms_aes_cbc_cipher2,
9796 			.digest = ms_hmac_digest2,
9797 			.iv = ms_aes_cbc_iv2
9798 		},
9799 
9800 	};
9801 
9802 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9803 
9804 	sessions = rte_malloc(NULL,
9805 			(sizeof(struct rte_cryptodev_sym_session *)
9806 					* MAX_NB_SESSIONS) + 1, 0);
9807 
9808 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
9809 		sessions[i] = rte_cryptodev_sym_session_create(
9810 				ts_params->session_mpool);
9811 
9812 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9813 				sizeof(struct crypto_unittest_params));
9814 
9815 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9816 				&ut_paramz[i].ut_params,
9817 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9818 
9819 		/* Create multiple crypto sessions*/
9820 		rte_cryptodev_sym_session_init(
9821 				ts_params->valid_devs[0],
9822 				sessions[i],
9823 				&ut_paramz[i].ut_params.auth_xform,
9824 				ts_params->session_priv_mpool);
9825 
9826 		TEST_ASSERT_NOT_NULL(sessions[i],
9827 				"Session creation failed at session number %u",
9828 				i);
9829 
9830 	}
9831 
9832 	srand(time(NULL));
9833 	for (i = 0; i < 40000; i++) {
9834 
9835 		j = rand() % MB_SESSION_NUMBER;
9836 
9837 		TEST_ASSERT_SUCCESS(
9838 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
9839 					sessions[j],
9840 					&ut_paramz[j].ut_params,
9841 					ts_params, ut_paramz[j].cipher,
9842 					ut_paramz[j].digest,
9843 					ut_paramz[j].iv),
9844 			"Failed to perform decrypt on request number %u.", i);
9845 
9846 		if (ut_paramz[j].ut_params.op)
9847 			rte_crypto_op_free(ut_paramz[j].ut_params.op);
9848 
9849 		/*
9850 		 * free mbuf - both obuf and ibuf are usually the same,
9851 		 * so check if they point at the same address is necessary,
9852 		 * to avoid freeing the mbuf twice.
9853 		 */
9854 		if (ut_paramz[j].ut_params.obuf) {
9855 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9856 			if (ut_paramz[j].ut_params.ibuf
9857 					== ut_paramz[j].ut_params.obuf)
9858 				ut_paramz[j].ut_params.ibuf = 0;
9859 			ut_paramz[j].ut_params.obuf = 0;
9860 		}
9861 		if (ut_paramz[j].ut_params.ibuf) {
9862 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9863 			ut_paramz[j].ut_params.ibuf = 0;
9864 		}
9865 	}
9866 
9867 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
9868 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9869 				sessions[i]);
9870 		rte_cryptodev_sym_session_free(sessions[i]);
9871 	}
9872 
9873 	rte_free(sessions);
9874 
9875 	return TEST_SUCCESS;
9876 }
9877 
9878 static int
9879 test_null_cipher_only_operation(void)
9880 {
9881 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9882 	struct crypto_unittest_params *ut_params = &unittest_params;
9883 
9884 	/* Generate test mbuf data and space for digest */
9885 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9886 			catch_22_quote, QUOTE_512_BYTES, 0);
9887 
9888 	/* Setup Cipher Parameters */
9889 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9890 	ut_params->cipher_xform.next = NULL;
9891 
9892 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9893 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9894 
9895 	ut_params->sess = rte_cryptodev_sym_session_create(
9896 			ts_params->session_mpool);
9897 
9898 	/* Create Crypto session*/
9899 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9900 				ut_params->sess,
9901 				&ut_params->cipher_xform,
9902 				ts_params->session_priv_mpool);
9903 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9904 
9905 	/* Generate Crypto op data structure */
9906 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9907 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9908 	TEST_ASSERT_NOT_NULL(ut_params->op,
9909 			"Failed to allocate symmetric crypto operation struct");
9910 
9911 	/* Set crypto operation data parameters */
9912 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9913 
9914 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9915 
9916 	/* set crypto operation source mbuf */
9917 	sym_op->m_src = ut_params->ibuf;
9918 
9919 	sym_op->cipher.data.offset = 0;
9920 	sym_op->cipher.data.length = QUOTE_512_BYTES;
9921 
9922 	/* Process crypto operation */
9923 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9924 			ut_params->op);
9925 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9926 
9927 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9928 			"crypto operation processing failed");
9929 
9930 	/* Validate obuf */
9931 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9932 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9933 			catch_22_quote,
9934 			QUOTE_512_BYTES,
9935 			"Ciphertext data not as expected");
9936 
9937 	return TEST_SUCCESS;
9938 }
9939 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9940 			0xab, 0xab, 0xab, 0xab,
9941 			0xab, 0xab, 0xab, 0xab,
9942 			0xab, 0xab, 0xab, 0xab};
9943 static int
9944 test_null_auth_only_operation(void)
9945 {
9946 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9947 	struct crypto_unittest_params *ut_params = &unittest_params;
9948 	uint8_t *digest;
9949 
9950 	/* Generate test mbuf data and space for digest */
9951 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9952 			catch_22_quote, QUOTE_512_BYTES, 0);
9953 
9954 	/* create a pointer for digest, but don't expect anything to be written
9955 	 * here in a NULL auth algo so no mbuf append done.
9956 	 */
9957 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9958 			QUOTE_512_BYTES);
9959 	/* prefill the memory pointed to by digest */
9960 	memcpy(digest, orig_data, sizeof(orig_data));
9961 
9962 	/* Setup HMAC Parameters */
9963 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9964 	ut_params->auth_xform.next = NULL;
9965 
9966 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9967 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9968 
9969 	ut_params->sess = rte_cryptodev_sym_session_create(
9970 			ts_params->session_mpool);
9971 
9972 	/* Create Crypto session*/
9973 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9974 			ut_params->sess, &ut_params->auth_xform,
9975 			ts_params->session_priv_mpool);
9976 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9977 
9978 	/* Generate Crypto op data structure */
9979 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9980 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9981 	TEST_ASSERT_NOT_NULL(ut_params->op,
9982 			"Failed to allocate symmetric crypto operation struct");
9983 
9984 	/* Set crypto operation data parameters */
9985 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9986 
9987 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9988 
9989 	sym_op->m_src = ut_params->ibuf;
9990 
9991 	sym_op->auth.data.offset = 0;
9992 	sym_op->auth.data.length = QUOTE_512_BYTES;
9993 	sym_op->auth.digest.data = digest;
9994 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9995 			QUOTE_512_BYTES);
9996 
9997 	/* Process crypto operation */
9998 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9999 			ut_params->op);
10000 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10001 
10002 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10003 			"crypto operation processing failed");
10004 	/* Make sure memory pointed to by digest hasn't been overwritten */
10005 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10006 			orig_data,
10007 			digest,
10008 			sizeof(orig_data),
10009 			"Memory at digest ptr overwritten unexpectedly");
10010 
10011 	return TEST_SUCCESS;
10012 }
10013 
10014 
10015 static int
10016 test_null_cipher_auth_operation(void)
10017 {
10018 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10019 	struct crypto_unittest_params *ut_params = &unittest_params;
10020 	uint8_t *digest;
10021 
10022 	/* Generate test mbuf data and space for digest */
10023 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
10024 			catch_22_quote, QUOTE_512_BYTES, 0);
10025 
10026 	/* create a pointer for digest, but don't expect anything to be written
10027 	 * here in a NULL auth algo so no mbuf append done.
10028 	 */
10029 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10030 			QUOTE_512_BYTES);
10031 	/* prefill the memory pointed to by digest */
10032 	memcpy(digest, orig_data, sizeof(orig_data));
10033 
10034 	/* Setup Cipher Parameters */
10035 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10036 	ut_params->cipher_xform.next = &ut_params->auth_xform;
10037 
10038 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10039 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10040 
10041 	/* Setup HMAC Parameters */
10042 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10043 	ut_params->auth_xform.next = NULL;
10044 
10045 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10046 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10047 
10048 	ut_params->sess = rte_cryptodev_sym_session_create(
10049 			ts_params->session_mpool);
10050 
10051 	/* Create Crypto session*/
10052 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10053 			ut_params->sess, &ut_params->cipher_xform,
10054 			ts_params->session_priv_mpool);
10055 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10056 
10057 	/* Generate Crypto op data structure */
10058 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10059 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10060 	TEST_ASSERT_NOT_NULL(ut_params->op,
10061 			"Failed to allocate symmetric crypto operation struct");
10062 
10063 	/* Set crypto operation data parameters */
10064 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10065 
10066 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10067 
10068 	sym_op->m_src = ut_params->ibuf;
10069 
10070 	sym_op->cipher.data.offset = 0;
10071 	sym_op->cipher.data.length = QUOTE_512_BYTES;
10072 
10073 	sym_op->auth.data.offset = 0;
10074 	sym_op->auth.data.length = QUOTE_512_BYTES;
10075 	sym_op->auth.digest.data = digest;
10076 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10077 			QUOTE_512_BYTES);
10078 
10079 	/* Process crypto operation */
10080 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10081 			ut_params->op);
10082 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10083 
10084 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10085 			"crypto operation processing failed");
10086 
10087 	/* Validate obuf */
10088 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10089 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10090 			catch_22_quote,
10091 			QUOTE_512_BYTES,
10092 			"Ciphertext data not as expected");
10093 	/* Make sure memory pointed to by digest hasn't been overwritten */
10094 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10095 			orig_data,
10096 			digest,
10097 			sizeof(orig_data),
10098 			"Memory at digest ptr overwritten unexpectedly");
10099 
10100 	return TEST_SUCCESS;
10101 }
10102 
10103 static int
10104 test_null_auth_cipher_operation(void)
10105 {
10106 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10107 	struct crypto_unittest_params *ut_params = &unittest_params;
10108 	uint8_t *digest;
10109 
10110 	/* Generate test mbuf data */
10111 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
10112 			catch_22_quote, QUOTE_512_BYTES, 0);
10113 
10114 	/* create a pointer for digest, but don't expect anything to be written
10115 	 * here in a NULL auth algo so no mbuf append done.
10116 	 */
10117 	digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10118 				QUOTE_512_BYTES);
10119 	/* prefill the memory pointed to by digest */
10120 	memcpy(digest, orig_data, sizeof(orig_data));
10121 
10122 	/* Setup Cipher Parameters */
10123 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10124 	ut_params->cipher_xform.next = NULL;
10125 
10126 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10127 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10128 
10129 	/* Setup HMAC Parameters */
10130 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10131 	ut_params->auth_xform.next = &ut_params->cipher_xform;
10132 
10133 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10134 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10135 
10136 	ut_params->sess = rte_cryptodev_sym_session_create(
10137 			ts_params->session_mpool);
10138 
10139 	/* Create Crypto session*/
10140 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10141 			ut_params->sess, &ut_params->cipher_xform,
10142 			ts_params->session_priv_mpool);
10143 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10144 
10145 	/* Generate Crypto op data structure */
10146 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10147 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10148 	TEST_ASSERT_NOT_NULL(ut_params->op,
10149 			"Failed to allocate symmetric crypto operation struct");
10150 
10151 	/* Set crypto operation data parameters */
10152 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10153 
10154 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10155 
10156 	sym_op->m_src = ut_params->ibuf;
10157 
10158 	sym_op->cipher.data.offset = 0;
10159 	sym_op->cipher.data.length = QUOTE_512_BYTES;
10160 
10161 	sym_op->auth.data.offset = 0;
10162 	sym_op->auth.data.length = QUOTE_512_BYTES;
10163 	sym_op->auth.digest.data = digest;
10164 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10165 					QUOTE_512_BYTES);
10166 
10167 	/* Process crypto operation */
10168 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10169 			ut_params->op);
10170 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10171 
10172 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10173 			"crypto operation processing failed");
10174 
10175 	/* Validate obuf */
10176 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10177 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10178 			catch_22_quote,
10179 			QUOTE_512_BYTES,
10180 			"Ciphertext data not as expected");
10181 	/* Make sure memory pointed to by digest hasn't been overwritten */
10182 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10183 			orig_data,
10184 			digest,
10185 			sizeof(orig_data),
10186 			"Memory at digest ptr overwritten unexpectedly");
10187 
10188 	return TEST_SUCCESS;
10189 }
10190 
10191 
10192 static int
10193 test_null_invalid_operation(void)
10194 {
10195 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10196 	struct crypto_unittest_params *ut_params = &unittest_params;
10197 	int ret;
10198 
10199 	/* Setup Cipher Parameters */
10200 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10201 	ut_params->cipher_xform.next = NULL;
10202 
10203 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10204 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10205 
10206 	ut_params->sess = rte_cryptodev_sym_session_create(
10207 			ts_params->session_mpool);
10208 
10209 	/* Create Crypto session*/
10210 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10211 			ut_params->sess, &ut_params->cipher_xform,
10212 			ts_params->session_priv_mpool);
10213 	TEST_ASSERT(ret < 0,
10214 			"Session creation succeeded unexpectedly");
10215 
10216 
10217 	/* Setup HMAC Parameters */
10218 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10219 	ut_params->auth_xform.next = NULL;
10220 
10221 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10222 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10223 
10224 	ut_params->sess = rte_cryptodev_sym_session_create(
10225 			ts_params->session_mpool);
10226 
10227 	/* Create Crypto session*/
10228 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10229 			ut_params->sess, &ut_params->auth_xform,
10230 			ts_params->session_priv_mpool);
10231 	TEST_ASSERT(ret < 0,
10232 			"Session creation succeeded unexpectedly");
10233 
10234 	return TEST_SUCCESS;
10235 }
10236 
10237 
10238 #define NULL_BURST_LENGTH (32)
10239 
10240 static int
10241 test_null_burst_operation(void)
10242 {
10243 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10244 	struct crypto_unittest_params *ut_params = &unittest_params;
10245 
10246 	unsigned i, burst_len = NULL_BURST_LENGTH;
10247 
10248 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10249 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10250 
10251 	/* Setup Cipher Parameters */
10252 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10253 	ut_params->cipher_xform.next = &ut_params->auth_xform;
10254 
10255 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10256 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10257 
10258 	/* Setup HMAC Parameters */
10259 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10260 	ut_params->auth_xform.next = NULL;
10261 
10262 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10263 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10264 
10265 	ut_params->sess = rte_cryptodev_sym_session_create(
10266 			ts_params->session_mpool);
10267 
10268 	/* Create Crypto session*/
10269 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10270 			ut_params->sess, &ut_params->cipher_xform,
10271 			ts_params->session_priv_mpool);
10272 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10273 
10274 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10275 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10276 			burst_len, "failed to generate burst of crypto ops");
10277 
10278 	/* Generate an operation for each mbuf in burst */
10279 	for (i = 0; i < burst_len; i++) {
10280 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10281 
10282 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10283 
10284 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10285 				sizeof(unsigned));
10286 		*data = i;
10287 
10288 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10289 
10290 		burst[i]->sym->m_src = m;
10291 	}
10292 
10293 	/* Process crypto operation */
10294 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10295 			0, burst, burst_len),
10296 			burst_len,
10297 			"Error enqueuing burst");
10298 
10299 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10300 			0, burst_dequeued, burst_len),
10301 			burst_len,
10302 			"Error dequeuing burst");
10303 
10304 
10305 	for (i = 0; i < burst_len; i++) {
10306 		TEST_ASSERT_EQUAL(
10307 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10308 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10309 					uint32_t *),
10310 			"data not as expected");
10311 
10312 		rte_pktmbuf_free(burst[i]->sym->m_src);
10313 		rte_crypto_op_free(burst[i]);
10314 	}
10315 
10316 	return TEST_SUCCESS;
10317 }
10318 
10319 static void
10320 generate_gmac_large_plaintext(uint8_t *data)
10321 {
10322 	uint16_t i;
10323 
10324 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10325 		memcpy(&data[i], &data[0], 32);
10326 }
10327 
10328 static int
10329 create_gmac_operation(enum rte_crypto_auth_operation op,
10330 		const struct gmac_test_data *tdata)
10331 {
10332 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10333 	struct crypto_unittest_params *ut_params = &unittest_params;
10334 	struct rte_crypto_sym_op *sym_op;
10335 
10336 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10337 
10338 	/* Generate Crypto op data structure */
10339 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10340 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10341 	TEST_ASSERT_NOT_NULL(ut_params->op,
10342 			"Failed to allocate symmetric crypto operation struct");
10343 
10344 	sym_op = ut_params->op->sym;
10345 
10346 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10347 			ut_params->ibuf, tdata->gmac_tag.len);
10348 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10349 			"no room to append digest");
10350 
10351 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10352 			ut_params->ibuf, plaintext_pad_len);
10353 
10354 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10355 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10356 				tdata->gmac_tag.len);
10357 		debug_hexdump(stdout, "digest:",
10358 				sym_op->auth.digest.data,
10359 				tdata->gmac_tag.len);
10360 	}
10361 
10362 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10363 			uint8_t *, IV_OFFSET);
10364 
10365 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10366 
10367 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10368 
10369 	sym_op->cipher.data.length = 0;
10370 	sym_op->cipher.data.offset = 0;
10371 
10372 	sym_op->auth.data.offset = 0;
10373 	sym_op->auth.data.length = tdata->plaintext.len;
10374 
10375 	return 0;
10376 }
10377 
10378 static int create_gmac_session(uint8_t dev_id,
10379 		const struct gmac_test_data *tdata,
10380 		enum rte_crypto_auth_operation auth_op)
10381 {
10382 	uint8_t auth_key[tdata->key.len];
10383 
10384 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10385 	struct crypto_unittest_params *ut_params = &unittest_params;
10386 
10387 	memcpy(auth_key, tdata->key.data, tdata->key.len);
10388 
10389 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10390 	ut_params->auth_xform.next = NULL;
10391 
10392 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10393 	ut_params->auth_xform.auth.op = auth_op;
10394 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10395 	ut_params->auth_xform.auth.key.length = tdata->key.len;
10396 	ut_params->auth_xform.auth.key.data = auth_key;
10397 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10398 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10399 
10400 
10401 	ut_params->sess = rte_cryptodev_sym_session_create(
10402 			ts_params->session_mpool);
10403 
10404 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10405 			&ut_params->auth_xform,
10406 			ts_params->session_priv_mpool);
10407 
10408 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10409 
10410 	return 0;
10411 }
10412 
10413 static int
10414 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10415 {
10416 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10417 	struct crypto_unittest_params *ut_params = &unittest_params;
10418 
10419 	int retval;
10420 
10421 	uint8_t *auth_tag, *plaintext;
10422 	uint16_t plaintext_pad_len;
10423 
10424 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10425 			      "No GMAC length in the source data");
10426 
10427 	retval = create_gmac_session(ts_params->valid_devs[0],
10428 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10429 
10430 	if (retval < 0)
10431 		return retval;
10432 
10433 	if (tdata->plaintext.len > MBUF_SIZE)
10434 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10435 	else
10436 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10437 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10438 			"Failed to allocate input buffer in mempool");
10439 
10440 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10441 			rte_pktmbuf_tailroom(ut_params->ibuf));
10442 
10443 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10444 	/*
10445 	 * Runtime generate the large plain text instead of use hard code
10446 	 * plain text vector. It is done to avoid create huge source file
10447 	 * with the test vector.
10448 	 */
10449 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10450 		generate_gmac_large_plaintext(tdata->plaintext.data);
10451 
10452 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10453 				plaintext_pad_len);
10454 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10455 
10456 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10457 	debug_hexdump(stdout, "plaintext:", plaintext,
10458 			tdata->plaintext.len);
10459 
10460 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10461 			tdata);
10462 
10463 	if (retval < 0)
10464 		return retval;
10465 
10466 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10467 
10468 	ut_params->op->sym->m_src = ut_params->ibuf;
10469 
10470 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10471 			ut_params->op), "failed to process sym crypto op");
10472 
10473 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10474 			"crypto op processing failed");
10475 
10476 	if (ut_params->op->sym->m_dst) {
10477 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10478 				uint8_t *, plaintext_pad_len);
10479 	} else {
10480 		auth_tag = plaintext + plaintext_pad_len;
10481 	}
10482 
10483 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10484 
10485 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10486 			auth_tag,
10487 			tdata->gmac_tag.data,
10488 			tdata->gmac_tag.len,
10489 			"GMAC Generated auth tag not as expected");
10490 
10491 	return 0;
10492 }
10493 
10494 static int
10495 test_AES_GMAC_authentication_test_case_1(void)
10496 {
10497 	return test_AES_GMAC_authentication(&gmac_test_case_1);
10498 }
10499 
10500 static int
10501 test_AES_GMAC_authentication_test_case_2(void)
10502 {
10503 	return test_AES_GMAC_authentication(&gmac_test_case_2);
10504 }
10505 
10506 static int
10507 test_AES_GMAC_authentication_test_case_3(void)
10508 {
10509 	return test_AES_GMAC_authentication(&gmac_test_case_3);
10510 }
10511 
10512 static int
10513 test_AES_GMAC_authentication_test_case_4(void)
10514 {
10515 	return test_AES_GMAC_authentication(&gmac_test_case_4);
10516 }
10517 
10518 static int
10519 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10520 {
10521 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10522 	struct crypto_unittest_params *ut_params = &unittest_params;
10523 	int retval;
10524 	uint32_t plaintext_pad_len;
10525 	uint8_t *plaintext;
10526 
10527 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10528 			      "No GMAC length in the source data");
10529 
10530 	retval = create_gmac_session(ts_params->valid_devs[0],
10531 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10532 
10533 	if (retval < 0)
10534 		return retval;
10535 
10536 	if (tdata->plaintext.len > MBUF_SIZE)
10537 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10538 	else
10539 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10540 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10541 			"Failed to allocate input buffer in mempool");
10542 
10543 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10544 			rte_pktmbuf_tailroom(ut_params->ibuf));
10545 
10546 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10547 
10548 	/*
10549 	 * Runtime generate the large plain text instead of use hard code
10550 	 * plain text vector. It is done to avoid create huge source file
10551 	 * with the test vector.
10552 	 */
10553 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10554 		generate_gmac_large_plaintext(tdata->plaintext.data);
10555 
10556 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10557 				plaintext_pad_len);
10558 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10559 
10560 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10561 	debug_hexdump(stdout, "plaintext:", plaintext,
10562 			tdata->plaintext.len);
10563 
10564 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10565 			tdata);
10566 
10567 	if (retval < 0)
10568 		return retval;
10569 
10570 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10571 
10572 	ut_params->op->sym->m_src = ut_params->ibuf;
10573 
10574 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10575 			ut_params->op), "failed to process sym crypto op");
10576 
10577 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10578 			"crypto op processing failed");
10579 
10580 	return 0;
10581 
10582 }
10583 
10584 static int
10585 test_AES_GMAC_authentication_verify_test_case_1(void)
10586 {
10587 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10588 }
10589 
10590 static int
10591 test_AES_GMAC_authentication_verify_test_case_2(void)
10592 {
10593 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10594 }
10595 
10596 static int
10597 test_AES_GMAC_authentication_verify_test_case_3(void)
10598 {
10599 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10600 }
10601 
10602 static int
10603 test_AES_GMAC_authentication_verify_test_case_4(void)
10604 {
10605 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10606 }
10607 
10608 struct test_crypto_vector {
10609 	enum rte_crypto_cipher_algorithm crypto_algo;
10610 	unsigned int cipher_offset;
10611 	unsigned int cipher_len;
10612 
10613 	struct {
10614 		uint8_t data[64];
10615 		unsigned int len;
10616 	} cipher_key;
10617 
10618 	struct {
10619 		uint8_t data[64];
10620 		unsigned int len;
10621 	} iv;
10622 
10623 	struct {
10624 		const uint8_t *data;
10625 		unsigned int len;
10626 	} plaintext;
10627 
10628 	struct {
10629 		const uint8_t *data;
10630 		unsigned int len;
10631 	} ciphertext;
10632 
10633 	enum rte_crypto_auth_algorithm auth_algo;
10634 	unsigned int auth_offset;
10635 
10636 	struct {
10637 		uint8_t data[128];
10638 		unsigned int len;
10639 	} auth_key;
10640 
10641 	struct {
10642 		const uint8_t *data;
10643 		unsigned int len;
10644 	} aad;
10645 
10646 	struct {
10647 		uint8_t data[128];
10648 		unsigned int len;
10649 	} digest;
10650 };
10651 
10652 static const struct test_crypto_vector
10653 hmac_sha1_test_crypto_vector = {
10654 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10655 	.plaintext = {
10656 		.data = plaintext_hash,
10657 		.len = 512
10658 	},
10659 	.auth_key = {
10660 		.data = {
10661 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10662 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10663 			0xDE, 0xF4, 0xDE, 0xAD
10664 		},
10665 		.len = 20
10666 	},
10667 	.digest = {
10668 		.data = {
10669 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10670 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10671 			0x3F, 0x91, 0x64, 0x59
10672 		},
10673 		.len = 20
10674 	}
10675 };
10676 
10677 static const struct test_crypto_vector
10678 aes128_gmac_test_vector = {
10679 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10680 	.plaintext = {
10681 		.data = plaintext_hash,
10682 		.len = 512
10683 	},
10684 	.iv = {
10685 		.data = {
10686 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10687 			0x08, 0x09, 0x0A, 0x0B
10688 		},
10689 		.len = 12
10690 	},
10691 	.auth_key = {
10692 		.data = {
10693 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10694 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10695 		},
10696 		.len = 16
10697 	},
10698 	.digest = {
10699 		.data = {
10700 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10701 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10702 		},
10703 		.len = 16
10704 	}
10705 };
10706 
10707 static const struct test_crypto_vector
10708 aes128cbc_hmac_sha1_test_vector = {
10709 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10710 	.cipher_offset = 0,
10711 	.cipher_len = 512,
10712 	.cipher_key = {
10713 		.data = {
10714 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10715 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10716 		},
10717 		.len = 16
10718 	},
10719 	.iv = {
10720 		.data = {
10721 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10722 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10723 		},
10724 		.len = 16
10725 	},
10726 	.plaintext = {
10727 		.data = plaintext_hash,
10728 		.len = 512
10729 	},
10730 	.ciphertext = {
10731 		.data = ciphertext512_aes128cbc,
10732 		.len = 512
10733 	},
10734 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10735 	.auth_offset = 0,
10736 	.auth_key = {
10737 		.data = {
10738 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10739 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10740 			0xDE, 0xF4, 0xDE, 0xAD
10741 		},
10742 		.len = 20
10743 	},
10744 	.digest = {
10745 		.data = {
10746 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10747 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10748 			0x18, 0x8C, 0x1D, 0x32
10749 		},
10750 		.len = 20
10751 	}
10752 };
10753 
10754 static const struct test_crypto_vector
10755 aes128cbc_hmac_sha1_aad_test_vector = {
10756 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10757 	.cipher_offset = 12,
10758 	.cipher_len = 496,
10759 	.cipher_key = {
10760 		.data = {
10761 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10762 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10763 		},
10764 		.len = 16
10765 	},
10766 	.iv = {
10767 		.data = {
10768 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10769 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10770 		},
10771 		.len = 16
10772 	},
10773 	.plaintext = {
10774 		.data = plaintext_hash,
10775 		.len = 512
10776 	},
10777 	.ciphertext = {
10778 		.data = ciphertext512_aes128cbc_aad,
10779 		.len = 512
10780 	},
10781 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10782 	.auth_offset = 0,
10783 	.auth_key = {
10784 		.data = {
10785 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10786 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10787 			0xDE, 0xF4, 0xDE, 0xAD
10788 		},
10789 		.len = 20
10790 	},
10791 	.digest = {
10792 		.data = {
10793 			0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10794 			0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10795 			0x62, 0x8D, 0x62, 0x65
10796 		},
10797 		.len = 20
10798 	}
10799 };
10800 
10801 static void
10802 data_corruption(uint8_t *data)
10803 {
10804 	data[0] += 1;
10805 }
10806 
10807 static void
10808 tag_corruption(uint8_t *data, unsigned int tag_offset)
10809 {
10810 	data[tag_offset] += 1;
10811 }
10812 
10813 static int
10814 create_auth_session(struct crypto_unittest_params *ut_params,
10815 		uint8_t dev_id,
10816 		const struct test_crypto_vector *reference,
10817 		enum rte_crypto_auth_operation auth_op)
10818 {
10819 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10820 	uint8_t auth_key[reference->auth_key.len + 1];
10821 
10822 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10823 
10824 	/* Setup Authentication Parameters */
10825 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10826 	ut_params->auth_xform.auth.op = auth_op;
10827 	ut_params->auth_xform.next = NULL;
10828 	ut_params->auth_xform.auth.algo = reference->auth_algo;
10829 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10830 	ut_params->auth_xform.auth.key.data = auth_key;
10831 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
10832 
10833 	/* Create Crypto session*/
10834 	ut_params->sess = rte_cryptodev_sym_session_create(
10835 			ts_params->session_mpool);
10836 
10837 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10838 				&ut_params->auth_xform,
10839 				ts_params->session_priv_mpool);
10840 
10841 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10842 
10843 	return 0;
10844 }
10845 
10846 static int
10847 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10848 		uint8_t dev_id,
10849 		const struct test_crypto_vector *reference,
10850 		enum rte_crypto_auth_operation auth_op,
10851 		enum rte_crypto_cipher_operation cipher_op)
10852 {
10853 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10854 	uint8_t cipher_key[reference->cipher_key.len + 1];
10855 	uint8_t auth_key[reference->auth_key.len + 1];
10856 
10857 	memcpy(cipher_key, reference->cipher_key.data,
10858 			reference->cipher_key.len);
10859 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10860 
10861 	/* Setup Authentication Parameters */
10862 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10863 	ut_params->auth_xform.auth.op = auth_op;
10864 	ut_params->auth_xform.auth.algo = reference->auth_algo;
10865 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10866 	ut_params->auth_xform.auth.key.data = auth_key;
10867 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
10868 
10869 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10870 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10871 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
10872 	} else {
10873 		ut_params->auth_xform.next = &ut_params->cipher_xform;
10874 
10875 		/* Setup Cipher Parameters */
10876 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10877 		ut_params->cipher_xform.next = NULL;
10878 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10879 		ut_params->cipher_xform.cipher.op = cipher_op;
10880 		ut_params->cipher_xform.cipher.key.data = cipher_key;
10881 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10882 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10883 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10884 	}
10885 
10886 	/* Create Crypto session*/
10887 	ut_params->sess = rte_cryptodev_sym_session_create(
10888 			ts_params->session_mpool);
10889 
10890 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10891 				&ut_params->auth_xform,
10892 				ts_params->session_priv_mpool);
10893 
10894 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10895 
10896 	return 0;
10897 }
10898 
10899 static int
10900 create_auth_operation(struct crypto_testsuite_params *ts_params,
10901 		struct crypto_unittest_params *ut_params,
10902 		const struct test_crypto_vector *reference,
10903 		unsigned int auth_generate)
10904 {
10905 	/* Generate Crypto op data structure */
10906 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10907 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10908 	TEST_ASSERT_NOT_NULL(ut_params->op,
10909 			"Failed to allocate pktmbuf offload");
10910 
10911 	/* Set crypto operation data parameters */
10912 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10913 
10914 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10915 
10916 	/* set crypto operation source mbuf */
10917 	sym_op->m_src = ut_params->ibuf;
10918 
10919 	/* digest */
10920 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10921 			ut_params->ibuf, reference->digest.len);
10922 
10923 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10924 			"no room to append auth tag");
10925 
10926 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10927 			ut_params->ibuf, reference->plaintext.len);
10928 
10929 	if (auth_generate)
10930 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10931 	else
10932 		memcpy(sym_op->auth.digest.data,
10933 				reference->digest.data,
10934 				reference->digest.len);
10935 
10936 	debug_hexdump(stdout, "digest:",
10937 			sym_op->auth.digest.data,
10938 			reference->digest.len);
10939 
10940 	sym_op->auth.data.length = reference->plaintext.len;
10941 	sym_op->auth.data.offset = 0;
10942 
10943 	return 0;
10944 }
10945 
10946 static int
10947 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10948 		struct crypto_unittest_params *ut_params,
10949 		const struct test_crypto_vector *reference,
10950 		unsigned int auth_generate)
10951 {
10952 	/* Generate Crypto op data structure */
10953 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10954 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10955 	TEST_ASSERT_NOT_NULL(ut_params->op,
10956 			"Failed to allocate pktmbuf offload");
10957 
10958 	/* Set crypto operation data parameters */
10959 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10960 
10961 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10962 
10963 	/* set crypto operation source mbuf */
10964 	sym_op->m_src = ut_params->ibuf;
10965 
10966 	/* digest */
10967 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10968 			ut_params->ibuf, reference->digest.len);
10969 
10970 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10971 			"no room to append auth tag");
10972 
10973 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10974 			ut_params->ibuf, reference->ciphertext.len);
10975 
10976 	if (auth_generate)
10977 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
10978 	else
10979 		memcpy(sym_op->auth.digest.data,
10980 				reference->digest.data,
10981 				reference->digest.len);
10982 
10983 	debug_hexdump(stdout, "digest:",
10984 			sym_op->auth.digest.data,
10985 			reference->digest.len);
10986 
10987 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10988 			reference->iv.data, reference->iv.len);
10989 
10990 	sym_op->cipher.data.length = 0;
10991 	sym_op->cipher.data.offset = 0;
10992 
10993 	sym_op->auth.data.length = reference->plaintext.len;
10994 	sym_op->auth.data.offset = 0;
10995 
10996 	return 0;
10997 }
10998 
10999 static int
11000 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11001 		struct crypto_unittest_params *ut_params,
11002 		const struct test_crypto_vector *reference,
11003 		unsigned int auth_generate)
11004 {
11005 	/* Generate Crypto op data structure */
11006 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11007 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11008 	TEST_ASSERT_NOT_NULL(ut_params->op,
11009 			"Failed to allocate pktmbuf offload");
11010 
11011 	/* Set crypto operation data parameters */
11012 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11013 
11014 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11015 
11016 	/* set crypto operation source mbuf */
11017 	sym_op->m_src = ut_params->ibuf;
11018 
11019 	/* digest */
11020 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11021 			ut_params->ibuf, reference->digest.len);
11022 
11023 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11024 			"no room to append auth tag");
11025 
11026 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11027 			ut_params->ibuf, reference->ciphertext.len);
11028 
11029 	if (auth_generate)
11030 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
11031 	else
11032 		memcpy(sym_op->auth.digest.data,
11033 				reference->digest.data,
11034 				reference->digest.len);
11035 
11036 	debug_hexdump(stdout, "digest:",
11037 			sym_op->auth.digest.data,
11038 			reference->digest.len);
11039 
11040 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11041 			reference->iv.data, reference->iv.len);
11042 
11043 	sym_op->cipher.data.length = reference->cipher_len;
11044 	sym_op->cipher.data.offset = reference->cipher_offset;
11045 
11046 	sym_op->auth.data.length = reference->plaintext.len;
11047 	sym_op->auth.data.offset = reference->auth_offset;
11048 
11049 	return 0;
11050 }
11051 
11052 static int
11053 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11054 		struct crypto_unittest_params *ut_params,
11055 		const struct test_crypto_vector *reference)
11056 {
11057 	return create_auth_operation(ts_params, ut_params, reference, 0);
11058 }
11059 
11060 static int
11061 create_auth_verify_GMAC_operation(
11062 		struct crypto_testsuite_params *ts_params,
11063 		struct crypto_unittest_params *ut_params,
11064 		const struct test_crypto_vector *reference)
11065 {
11066 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11067 }
11068 
11069 static int
11070 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11071 		struct crypto_unittest_params *ut_params,
11072 		const struct test_crypto_vector *reference)
11073 {
11074 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11075 }
11076 
11077 static int
11078 test_authentication_verify_fail_when_data_corruption(
11079 		struct crypto_testsuite_params *ts_params,
11080 		struct crypto_unittest_params *ut_params,
11081 		const struct test_crypto_vector *reference,
11082 		unsigned int data_corrupted)
11083 {
11084 	int retval;
11085 
11086 	uint8_t *plaintext;
11087 
11088 	/* Create session */
11089 	retval = create_auth_session(ut_params,
11090 			ts_params->valid_devs[0],
11091 			reference,
11092 			RTE_CRYPTO_AUTH_OP_VERIFY);
11093 	if (retval < 0)
11094 		return retval;
11095 
11096 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11097 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11098 			"Failed to allocate input buffer in mempool");
11099 
11100 	/* clear mbuf payload */
11101 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11102 			rte_pktmbuf_tailroom(ut_params->ibuf));
11103 
11104 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11105 			reference->plaintext.len);
11106 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11107 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11108 
11109 	debug_hexdump(stdout, "plaintext:", plaintext,
11110 		reference->plaintext.len);
11111 
11112 	/* Create operation */
11113 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
11114 
11115 	if (retval < 0)
11116 		return retval;
11117 
11118 	if (data_corrupted)
11119 		data_corruption(plaintext);
11120 	else
11121 		tag_corruption(plaintext, reference->plaintext.len);
11122 
11123 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11124 			ut_params->op);
11125 
11126 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11127 
11128 	return 0;
11129 }
11130 
11131 static int
11132 test_authentication_verify_GMAC_fail_when_corruption(
11133 		struct crypto_testsuite_params *ts_params,
11134 		struct crypto_unittest_params *ut_params,
11135 		const struct test_crypto_vector *reference,
11136 		unsigned int data_corrupted)
11137 {
11138 	int retval;
11139 	uint8_t *plaintext;
11140 
11141 	/* Create session */
11142 	retval = create_auth_cipher_session(ut_params,
11143 			ts_params->valid_devs[0],
11144 			reference,
11145 			RTE_CRYPTO_AUTH_OP_VERIFY,
11146 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
11147 	if (retval < 0)
11148 		return retval;
11149 
11150 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11151 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11152 			"Failed to allocate input buffer in mempool");
11153 
11154 	/* clear mbuf payload */
11155 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11156 			rte_pktmbuf_tailroom(ut_params->ibuf));
11157 
11158 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11159 			reference->plaintext.len);
11160 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11161 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11162 
11163 	debug_hexdump(stdout, "plaintext:", plaintext,
11164 		reference->plaintext.len);
11165 
11166 	/* Create operation */
11167 	retval = create_auth_verify_GMAC_operation(ts_params,
11168 			ut_params,
11169 			reference);
11170 
11171 	if (retval < 0)
11172 		return retval;
11173 
11174 	if (data_corrupted)
11175 		data_corruption(plaintext);
11176 	else
11177 		tag_corruption(plaintext, reference->aad.len);
11178 
11179 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11180 			ut_params->op);
11181 
11182 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11183 
11184 	return 0;
11185 }
11186 
11187 static int
11188 test_authenticated_decryption_fail_when_corruption(
11189 		struct crypto_testsuite_params *ts_params,
11190 		struct crypto_unittest_params *ut_params,
11191 		const struct test_crypto_vector *reference,
11192 		unsigned int data_corrupted)
11193 {
11194 	int retval;
11195 
11196 	uint8_t *ciphertext;
11197 
11198 	/* Create session */
11199 	retval = create_auth_cipher_session(ut_params,
11200 			ts_params->valid_devs[0],
11201 			reference,
11202 			RTE_CRYPTO_AUTH_OP_VERIFY,
11203 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
11204 	if (retval < 0)
11205 		return retval;
11206 
11207 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11208 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11209 			"Failed to allocate input buffer in mempool");
11210 
11211 	/* clear mbuf payload */
11212 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11213 			rte_pktmbuf_tailroom(ut_params->ibuf));
11214 
11215 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11216 			reference->ciphertext.len);
11217 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11218 	memcpy(ciphertext, reference->ciphertext.data,
11219 			reference->ciphertext.len);
11220 
11221 	/* Create operation */
11222 	retval = create_cipher_auth_verify_operation(ts_params,
11223 			ut_params,
11224 			reference);
11225 
11226 	if (retval < 0)
11227 		return retval;
11228 
11229 	if (data_corrupted)
11230 		data_corruption(ciphertext);
11231 	else
11232 		tag_corruption(ciphertext, reference->ciphertext.len);
11233 
11234 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11235 			ut_params->op);
11236 
11237 	TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11238 
11239 	return 0;
11240 }
11241 
11242 static int
11243 test_authenticated_encryt_with_esn(
11244 		struct crypto_testsuite_params *ts_params,
11245 		struct crypto_unittest_params *ut_params,
11246 		const struct test_crypto_vector *reference)
11247 {
11248 	int retval;
11249 
11250 	uint8_t *authciphertext, *plaintext, *auth_tag;
11251 	uint16_t plaintext_pad_len;
11252 	uint8_t cipher_key[reference->cipher_key.len + 1];
11253 	uint8_t auth_key[reference->auth_key.len + 1];
11254 
11255 	/* Create session */
11256 	memcpy(cipher_key, reference->cipher_key.data,
11257 			reference->cipher_key.len);
11258 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11259 
11260 	/* Setup Cipher Parameters */
11261 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11262 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11263 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11264 	ut_params->cipher_xform.cipher.key.data = cipher_key;
11265 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11266 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11267 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11268 
11269 	ut_params->cipher_xform.next = &ut_params->auth_xform;
11270 
11271 	/* Setup Authentication Parameters */
11272 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11273 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11274 	ut_params->auth_xform.auth.algo = reference->auth_algo;
11275 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11276 	ut_params->auth_xform.auth.key.data = auth_key;
11277 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
11278 	ut_params->auth_xform.next = NULL;
11279 
11280 	/* Create Crypto session*/
11281 	ut_params->sess = rte_cryptodev_sym_session_create(
11282 			ts_params->session_mpool);
11283 
11284 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11285 				ut_params->sess,
11286 				&ut_params->cipher_xform,
11287 				ts_params->session_priv_mpool);
11288 
11289 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11290 
11291 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11292 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11293 			"Failed to allocate input buffer in mempool");
11294 
11295 	/* clear mbuf payload */
11296 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11297 			rte_pktmbuf_tailroom(ut_params->ibuf));
11298 
11299 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11300 			reference->plaintext.len);
11301 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11302 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11303 
11304 	/* Create operation */
11305 	retval = create_cipher_auth_operation(ts_params,
11306 			ut_params,
11307 			reference, 0);
11308 
11309 	if (retval < 0)
11310 		return retval;
11311 
11312 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11313 			ut_params->op);
11314 
11315 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11316 
11317 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11318 			"crypto op processing failed");
11319 
11320 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11321 
11322 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11323 			ut_params->op->sym->auth.data.offset);
11324 	auth_tag = authciphertext + plaintext_pad_len;
11325 	debug_hexdump(stdout, "ciphertext:", authciphertext,
11326 			reference->ciphertext.len);
11327 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11328 
11329 	/* Validate obuf */
11330 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11331 			authciphertext,
11332 			reference->ciphertext.data,
11333 			reference->ciphertext.len,
11334 			"Ciphertext data not as expected");
11335 
11336 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11337 			auth_tag,
11338 			reference->digest.data,
11339 			reference->digest.len,
11340 			"Generated digest not as expected");
11341 
11342 	return TEST_SUCCESS;
11343 
11344 }
11345 
11346 static int
11347 test_authenticated_decrypt_with_esn(
11348 		struct crypto_testsuite_params *ts_params,
11349 		struct crypto_unittest_params *ut_params,
11350 		const struct test_crypto_vector *reference)
11351 {
11352 	int retval;
11353 
11354 	uint8_t *ciphertext;
11355 	uint8_t cipher_key[reference->cipher_key.len + 1];
11356 	uint8_t auth_key[reference->auth_key.len + 1];
11357 
11358 	/* Create session */
11359 	memcpy(cipher_key, reference->cipher_key.data,
11360 			reference->cipher_key.len);
11361 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11362 
11363 	/* Setup Authentication Parameters */
11364 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11365 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11366 	ut_params->auth_xform.auth.algo = reference->auth_algo;
11367 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11368 	ut_params->auth_xform.auth.key.data = auth_key;
11369 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
11370 	ut_params->auth_xform.next = &ut_params->cipher_xform;
11371 
11372 	/* Setup Cipher Parameters */
11373 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11374 	ut_params->cipher_xform.next = NULL;
11375 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11376 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11377 	ut_params->cipher_xform.cipher.key.data = cipher_key;
11378 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11379 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11380 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11381 
11382 	/* Create Crypto session*/
11383 	ut_params->sess = rte_cryptodev_sym_session_create(
11384 			ts_params->session_mpool);
11385 
11386 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11387 				ut_params->sess,
11388 				&ut_params->auth_xform,
11389 				ts_params->session_priv_mpool);
11390 
11391 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11392 
11393 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11394 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11395 			"Failed to allocate input buffer in mempool");
11396 
11397 	/* clear mbuf payload */
11398 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11399 			rte_pktmbuf_tailroom(ut_params->ibuf));
11400 
11401 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11402 			reference->ciphertext.len);
11403 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11404 	memcpy(ciphertext, reference->ciphertext.data,
11405 			reference->ciphertext.len);
11406 
11407 	/* Create operation */
11408 	retval = create_cipher_auth_verify_operation(ts_params,
11409 			ut_params,
11410 			reference);
11411 
11412 	if (retval < 0)
11413 		return retval;
11414 
11415 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11416 			ut_params->op);
11417 
11418 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11419 	TEST_ASSERT_EQUAL(ut_params->op->status,
11420 			RTE_CRYPTO_OP_STATUS_SUCCESS,
11421 			"crypto op processing passed");
11422 
11423 	ut_params->obuf = ut_params->op->sym->m_src;
11424 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11425 
11426 	return 0;
11427 }
11428 
11429 static int
11430 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11431 		const struct aead_test_data *tdata,
11432 		void *digest_mem, uint64_t digest_phys)
11433 {
11434 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11435 	struct crypto_unittest_params *ut_params = &unittest_params;
11436 
11437 	const unsigned int auth_tag_len = tdata->auth_tag.len;
11438 	const unsigned int iv_len = tdata->iv.len;
11439 	unsigned int aad_len = tdata->aad.len;
11440 	unsigned int aad_len_pad = 0;
11441 
11442 	/* Generate Crypto op data structure */
11443 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11444 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11445 	TEST_ASSERT_NOT_NULL(ut_params->op,
11446 		"Failed to allocate symmetric crypto operation struct");
11447 
11448 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11449 
11450 	sym_op->aead.digest.data = digest_mem;
11451 
11452 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11453 			"no room to append digest");
11454 
11455 	sym_op->aead.digest.phys_addr = digest_phys;
11456 
11457 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11458 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11459 				auth_tag_len);
11460 		debug_hexdump(stdout, "digest:",
11461 				sym_op->aead.digest.data,
11462 				auth_tag_len);
11463 	}
11464 
11465 	/* Append aad data */
11466 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11467 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11468 				uint8_t *, IV_OFFSET);
11469 
11470 		/* Copy IV 1 byte after the IV pointer, according to the API */
11471 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11472 
11473 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11474 
11475 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11476 				ut_params->ibuf, aad_len);
11477 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11478 				"no room to prepend aad");
11479 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11480 				ut_params->ibuf);
11481 
11482 		memset(sym_op->aead.aad.data, 0, aad_len);
11483 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
11484 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11485 
11486 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11487 		debug_hexdump(stdout, "aad:",
11488 				sym_op->aead.aad.data, aad_len);
11489 	} else {
11490 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11491 				uint8_t *, IV_OFFSET);
11492 
11493 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11494 
11495 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11496 
11497 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11498 				ut_params->ibuf, aad_len_pad);
11499 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11500 				"no room to prepend aad");
11501 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11502 				ut_params->ibuf);
11503 
11504 		memset(sym_op->aead.aad.data, 0, aad_len);
11505 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11506 
11507 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11508 		debug_hexdump(stdout, "aad:",
11509 				sym_op->aead.aad.data, aad_len);
11510 	}
11511 
11512 	sym_op->aead.data.length = tdata->plaintext.len;
11513 	sym_op->aead.data.offset = aad_len_pad;
11514 
11515 	return 0;
11516 }
11517 
11518 #define SGL_MAX_NO	16
11519 
11520 static int
11521 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11522 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11523 {
11524 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11525 	struct crypto_unittest_params *ut_params = &unittest_params;
11526 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11527 	int retval;
11528 	int to_trn = 0;
11529 	int to_trn_tbl[SGL_MAX_NO];
11530 	int segs = 1;
11531 	unsigned int trn_data = 0;
11532 	uint8_t *plaintext, *ciphertext, *auth_tag;
11533 
11534 	if (fragsz > tdata->plaintext.len)
11535 		fragsz = tdata->plaintext.len;
11536 
11537 	uint16_t plaintext_len = fragsz;
11538 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11539 
11540 	if (fragsz_oop > tdata->plaintext.len)
11541 		frag_size_oop = tdata->plaintext.len;
11542 
11543 	int ecx = 0;
11544 	void *digest_mem = NULL;
11545 
11546 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11547 
11548 	if (tdata->plaintext.len % fragsz != 0) {
11549 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11550 			return 1;
11551 	}	else {
11552 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11553 			return 1;
11554 	}
11555 
11556 	/*
11557 	 * For out-op-place we need to alloc another mbuf
11558 	 */
11559 	if (oop) {
11560 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11561 		rte_pktmbuf_append(ut_params->obuf,
11562 				frag_size_oop + prepend_len);
11563 		buf_oop = ut_params->obuf;
11564 	}
11565 
11566 	/* Create AEAD session */
11567 	retval = create_aead_session(ts_params->valid_devs[0],
11568 			tdata->algo,
11569 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
11570 			tdata->key.data, tdata->key.len,
11571 			tdata->aad.len, tdata->auth_tag.len,
11572 			tdata->iv.len);
11573 	if (retval < 0)
11574 		return retval;
11575 
11576 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11577 
11578 	/* clear mbuf payload */
11579 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11580 			rte_pktmbuf_tailroom(ut_params->ibuf));
11581 
11582 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11583 			plaintext_len);
11584 
11585 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11586 
11587 	trn_data += plaintext_len;
11588 
11589 	buf = ut_params->ibuf;
11590 
11591 	/*
11592 	 * Loop until no more fragments
11593 	 */
11594 
11595 	while (trn_data < tdata->plaintext.len) {
11596 		++segs;
11597 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11598 				(tdata->plaintext.len - trn_data) : fragsz;
11599 
11600 		to_trn_tbl[ecx++] = to_trn;
11601 
11602 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11603 		buf = buf->next;
11604 
11605 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11606 				rte_pktmbuf_tailroom(buf));
11607 
11608 		/* OOP */
11609 		if (oop && !fragsz_oop) {
11610 			buf_last_oop = buf_oop->next =
11611 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
11612 			buf_oop = buf_oop->next;
11613 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11614 					0, rte_pktmbuf_tailroom(buf_oop));
11615 			rte_pktmbuf_append(buf_oop, to_trn);
11616 		}
11617 
11618 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11619 				to_trn);
11620 
11621 		memcpy(plaintext, tdata->plaintext.data + trn_data,
11622 				to_trn);
11623 		trn_data += to_trn;
11624 		if (trn_data  == tdata->plaintext.len) {
11625 			if (oop) {
11626 				if (!fragsz_oop)
11627 					digest_mem = rte_pktmbuf_append(buf_oop,
11628 						tdata->auth_tag.len);
11629 			} else
11630 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11631 					tdata->auth_tag.len);
11632 		}
11633 	}
11634 
11635 	uint64_t digest_phys = 0;
11636 
11637 	ut_params->ibuf->nb_segs = segs;
11638 
11639 	segs = 1;
11640 	if (fragsz_oop && oop) {
11641 		to_trn = 0;
11642 		ecx = 0;
11643 
11644 		if (frag_size_oop == tdata->plaintext.len) {
11645 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
11646 				tdata->auth_tag.len);
11647 
11648 			digest_phys = rte_pktmbuf_iova_offset(
11649 					ut_params->obuf,
11650 					tdata->plaintext.len + prepend_len);
11651 		}
11652 
11653 		trn_data = frag_size_oop;
11654 		while (trn_data < tdata->plaintext.len) {
11655 			++segs;
11656 			to_trn =
11657 				(tdata->plaintext.len - trn_data <
11658 						frag_size_oop) ?
11659 				(tdata->plaintext.len - trn_data) :
11660 						frag_size_oop;
11661 
11662 			to_trn_tbl[ecx++] = to_trn;
11663 
11664 			buf_last_oop = buf_oop->next =
11665 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
11666 			buf_oop = buf_oop->next;
11667 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11668 					0, rte_pktmbuf_tailroom(buf_oop));
11669 			rte_pktmbuf_append(buf_oop, to_trn);
11670 
11671 			trn_data += to_trn;
11672 
11673 			if (trn_data  == tdata->plaintext.len) {
11674 				digest_mem = rte_pktmbuf_append(buf_oop,
11675 					tdata->auth_tag.len);
11676 			}
11677 		}
11678 
11679 		ut_params->obuf->nb_segs = segs;
11680 	}
11681 
11682 	/*
11683 	 * Place digest at the end of the last buffer
11684 	 */
11685 	if (!digest_phys)
11686 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11687 	if (oop && buf_last_oop)
11688 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11689 
11690 	if (!digest_mem && !oop) {
11691 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11692 				+ tdata->auth_tag.len);
11693 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11694 				tdata->plaintext.len);
11695 	}
11696 
11697 	/* Create AEAD operation */
11698 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11699 			tdata, digest_mem, digest_phys);
11700 
11701 	if (retval < 0)
11702 		return retval;
11703 
11704 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11705 
11706 	ut_params->op->sym->m_src = ut_params->ibuf;
11707 	if (oop)
11708 		ut_params->op->sym->m_dst = ut_params->obuf;
11709 
11710 	/* Process crypto operation */
11711 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11712 			ut_params->op), "failed to process sym crypto op");
11713 
11714 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11715 			"crypto op processing failed");
11716 
11717 
11718 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11719 			uint8_t *, prepend_len);
11720 	if (oop) {
11721 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11722 				uint8_t *, prepend_len);
11723 	}
11724 
11725 	if (fragsz_oop)
11726 		fragsz = fragsz_oop;
11727 
11728 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11729 			ciphertext,
11730 			tdata->ciphertext.data,
11731 			fragsz,
11732 			"Ciphertext data not as expected");
11733 
11734 	buf = ut_params->op->sym->m_src->next;
11735 	if (oop)
11736 		buf = ut_params->op->sym->m_dst->next;
11737 
11738 	unsigned int off = fragsz;
11739 
11740 	ecx = 0;
11741 	while (buf) {
11742 		ciphertext = rte_pktmbuf_mtod(buf,
11743 				uint8_t *);
11744 
11745 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
11746 				ciphertext,
11747 				tdata->ciphertext.data + off,
11748 				to_trn_tbl[ecx],
11749 				"Ciphertext data not as expected");
11750 
11751 		off += to_trn_tbl[ecx++];
11752 		buf = buf->next;
11753 	}
11754 
11755 	auth_tag = digest_mem;
11756 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11757 			auth_tag,
11758 			tdata->auth_tag.data,
11759 			tdata->auth_tag.len,
11760 			"Generated auth tag not as expected");
11761 
11762 	return 0;
11763 }
11764 
11765 static int
11766 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11767 {
11768 	return test_authenticated_encryption_SGL(
11769 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11770 }
11771 
11772 static int
11773 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11774 {
11775 	return test_authenticated_encryption_SGL(
11776 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11777 }
11778 
11779 static int
11780 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11781 {
11782 	return test_authenticated_encryption_SGL(
11783 			&gcm_test_case_8, OUT_OF_PLACE, 400,
11784 			gcm_test_case_8.plaintext.len);
11785 }
11786 
11787 static int
11788 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11789 {
11790 
11791 	return test_authenticated_encryption_SGL(
11792 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11793 }
11794 
11795 static int
11796 test_authentication_verify_fail_when_data_corrupted(
11797 		struct crypto_testsuite_params *ts_params,
11798 		struct crypto_unittest_params *ut_params,
11799 		const struct test_crypto_vector *reference)
11800 {
11801 	return test_authentication_verify_fail_when_data_corruption(
11802 			ts_params, ut_params, reference, 1);
11803 }
11804 
11805 static int
11806 test_authentication_verify_fail_when_tag_corrupted(
11807 		struct crypto_testsuite_params *ts_params,
11808 		struct crypto_unittest_params *ut_params,
11809 		const struct test_crypto_vector *reference)
11810 {
11811 	return test_authentication_verify_fail_when_data_corruption(
11812 			ts_params, ut_params, reference, 0);
11813 }
11814 
11815 static int
11816 test_authentication_verify_GMAC_fail_when_data_corrupted(
11817 		struct crypto_testsuite_params *ts_params,
11818 		struct crypto_unittest_params *ut_params,
11819 		const struct test_crypto_vector *reference)
11820 {
11821 	return test_authentication_verify_GMAC_fail_when_corruption(
11822 			ts_params, ut_params, reference, 1);
11823 }
11824 
11825 static int
11826 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11827 		struct crypto_testsuite_params *ts_params,
11828 		struct crypto_unittest_params *ut_params,
11829 		const struct test_crypto_vector *reference)
11830 {
11831 	return test_authentication_verify_GMAC_fail_when_corruption(
11832 			ts_params, ut_params, reference, 0);
11833 }
11834 
11835 static int
11836 test_authenticated_decryption_fail_when_data_corrupted(
11837 		struct crypto_testsuite_params *ts_params,
11838 		struct crypto_unittest_params *ut_params,
11839 		const struct test_crypto_vector *reference)
11840 {
11841 	return test_authenticated_decryption_fail_when_corruption(
11842 			ts_params, ut_params, reference, 1);
11843 }
11844 
11845 static int
11846 test_authenticated_decryption_fail_when_tag_corrupted(
11847 		struct crypto_testsuite_params *ts_params,
11848 		struct crypto_unittest_params *ut_params,
11849 		const struct test_crypto_vector *reference)
11850 {
11851 	return test_authenticated_decryption_fail_when_corruption(
11852 			ts_params, ut_params, reference, 0);
11853 }
11854 
11855 static int
11856 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11857 {
11858 	return test_authentication_verify_fail_when_data_corrupted(
11859 			&testsuite_params, &unittest_params,
11860 			&hmac_sha1_test_crypto_vector);
11861 }
11862 
11863 static int
11864 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11865 {
11866 	return test_authentication_verify_fail_when_tag_corrupted(
11867 			&testsuite_params, &unittest_params,
11868 			&hmac_sha1_test_crypto_vector);
11869 }
11870 
11871 static int
11872 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11873 {
11874 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
11875 			&testsuite_params, &unittest_params,
11876 			&aes128_gmac_test_vector);
11877 }
11878 
11879 static int
11880 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11881 {
11882 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11883 			&testsuite_params, &unittest_params,
11884 			&aes128_gmac_test_vector);
11885 }
11886 
11887 static int
11888 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11889 {
11890 	return test_authenticated_decryption_fail_when_data_corrupted(
11891 			&testsuite_params,
11892 			&unittest_params,
11893 			&aes128cbc_hmac_sha1_test_vector);
11894 }
11895 
11896 static int
11897 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11898 {
11899 	return test_authenticated_decryption_fail_when_tag_corrupted(
11900 			&testsuite_params,
11901 			&unittest_params,
11902 			&aes128cbc_hmac_sha1_test_vector);
11903 }
11904 
11905 static int
11906 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11907 {
11908 	return test_authenticated_encryt_with_esn(
11909 			&testsuite_params,
11910 			&unittest_params,
11911 			&aes128cbc_hmac_sha1_aad_test_vector);
11912 }
11913 
11914 static int
11915 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11916 {
11917 	return test_authenticated_decrypt_with_esn(
11918 			&testsuite_params,
11919 			&unittest_params,
11920 			&aes128cbc_hmac_sha1_aad_test_vector);
11921 }
11922 
11923 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11924 
11925 /* global AESNI slave IDs for the scheduler test */
11926 uint8_t aesni_ids[2];
11927 
11928 static int
11929 test_scheduler_attach_slave_op(void)
11930 {
11931 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11932 	uint8_t sched_id = ts_params->valid_devs[0];
11933 	uint32_t nb_devs, i, nb_devs_attached = 0;
11934 	int ret;
11935 	char vdev_name[32];
11936 
11937 	/* create 2 AESNI_MB if necessary */
11938 	nb_devs = rte_cryptodev_device_count_by_driver(
11939 			rte_cryptodev_driver_id_get(
11940 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11941 	if (nb_devs < 2) {
11942 		for (i = nb_devs; i < 2; i++) {
11943 			snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11944 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11945 					i);
11946 			ret = rte_vdev_init(vdev_name, NULL);
11947 
11948 			TEST_ASSERT(ret == 0,
11949 				"Failed to create instance %u of"
11950 				" pmd : %s",
11951 				i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11952 		}
11953 	}
11954 
11955 	/* attach 2 AESNI_MB cdevs */
11956 	for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11957 			i++) {
11958 		struct rte_cryptodev_info info;
11959 		unsigned int session_size;
11960 
11961 		rte_cryptodev_info_get(i, &info);
11962 		if (info.driver_id != rte_cryptodev_driver_id_get(
11963 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11964 			continue;
11965 
11966 		session_size = rte_cryptodev_sym_get_private_session_size(i);
11967 		/*
11968 		 * Create the session mempool again, since now there are new devices
11969 		 * to use the mempool.
11970 		 */
11971 		if (ts_params->session_mpool) {
11972 			rte_mempool_free(ts_params->session_mpool);
11973 			ts_params->session_mpool = NULL;
11974 		}
11975 		if (ts_params->session_priv_mpool) {
11976 			rte_mempool_free(ts_params->session_priv_mpool);
11977 			ts_params->session_priv_mpool = NULL;
11978 		}
11979 
11980 		if (info.sym.max_nb_sessions != 0 &&
11981 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11982 			RTE_LOG(ERR, USER1,
11983 					"Device does not support "
11984 					"at least %u sessions\n",
11985 					MAX_NB_SESSIONS);
11986 			return TEST_FAILED;
11987 		}
11988 		/*
11989 		 * Create mempool with maximum number of sessions,
11990 		 * to include the session headers
11991 		 */
11992 		if (ts_params->session_mpool == NULL) {
11993 			ts_params->session_mpool =
11994 				rte_cryptodev_sym_session_pool_create(
11995 						"test_sess_mp",
11996 						MAX_NB_SESSIONS, 0, 0, 0,
11997 						SOCKET_ID_ANY);
11998 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11999 					"session mempool allocation failed");
12000 		}
12001 
12002 		/*
12003 		 * Create mempool with maximum number of sessions,
12004 		 * to include device specific session private data
12005 		 */
12006 		if (ts_params->session_priv_mpool == NULL) {
12007 			ts_params->session_priv_mpool = rte_mempool_create(
12008 					"test_sess_mp_priv",
12009 					MAX_NB_SESSIONS,
12010 					session_size,
12011 					0, 0, NULL, NULL, NULL,
12012 					NULL, SOCKET_ID_ANY,
12013 					0);
12014 
12015 			TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
12016 					"session mempool allocation failed");
12017 		}
12018 
12019 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
12020 		ts_params->qp_conf.mp_session_private =
12021 				ts_params->session_priv_mpool;
12022 
12023 		ret = rte_cryptodev_scheduler_slave_attach(sched_id,
12024 				(uint8_t)i);
12025 
12026 		TEST_ASSERT(ret == 0,
12027 			"Failed to attach device %u of pmd : %s", i,
12028 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12029 
12030 		aesni_ids[nb_devs_attached] = (uint8_t)i;
12031 
12032 		nb_devs_attached++;
12033 	}
12034 
12035 	return 0;
12036 }
12037 
12038 static int
12039 test_scheduler_detach_slave_op(void)
12040 {
12041 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12042 	uint8_t sched_id = ts_params->valid_devs[0];
12043 	uint32_t i;
12044 	int ret;
12045 
12046 	for (i = 0; i < 2; i++) {
12047 		ret = rte_cryptodev_scheduler_slave_detach(sched_id,
12048 				aesni_ids[i]);
12049 		TEST_ASSERT(ret == 0,
12050 			"Failed to detach device %u", aesni_ids[i]);
12051 	}
12052 
12053 	return 0;
12054 }
12055 
12056 static int
12057 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12058 {
12059 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12060 	uint8_t sched_id = ts_params->valid_devs[0];
12061 	/* set mode */
12062 	return rte_cryptodev_scheduler_mode_set(sched_id,
12063 		scheduler_mode);
12064 }
12065 
12066 static int
12067 test_scheduler_mode_roundrobin_op(void)
12068 {
12069 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12070 			0, "Failed to set roundrobin mode");
12071 	return 0;
12072 
12073 }
12074 
12075 static int
12076 test_scheduler_mode_multicore_op(void)
12077 {
12078 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12079 			0, "Failed to set multicore mode");
12080 
12081 	return 0;
12082 }
12083 
12084 static int
12085 test_scheduler_mode_failover_op(void)
12086 {
12087 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12088 			0, "Failed to set failover mode");
12089 
12090 	return 0;
12091 }
12092 
12093 static int
12094 test_scheduler_mode_pkt_size_distr_op(void)
12095 {
12096 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12097 			0, "Failed to set pktsize mode");
12098 
12099 	return 0;
12100 }
12101 
12102 static struct unit_test_suite cryptodev_scheduler_testsuite  = {
12103 	.suite_name = "Crypto Device Scheduler Unit Test Suite",
12104 	.setup = testsuite_setup,
12105 	.teardown = testsuite_teardown,
12106 	.unit_test_cases = {
12107 		/* Multi Core */
12108 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12109 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12110 		TEST_CASE_ST(ut_setup, ut_teardown,
12111 					test_AES_chain_scheduler_all),
12112 		TEST_CASE_ST(ut_setup, ut_teardown,
12113 					test_AES_cipheronly_scheduler_all),
12114 		TEST_CASE_ST(ut_setup, ut_teardown,
12115 					test_authonly_scheduler_all),
12116 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12117 
12118 		/* Round Robin */
12119 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12120 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12121 		TEST_CASE_ST(ut_setup, ut_teardown,
12122 				test_AES_chain_scheduler_all),
12123 		TEST_CASE_ST(ut_setup, ut_teardown,
12124 				test_AES_cipheronly_scheduler_all),
12125 		TEST_CASE_ST(ut_setup, ut_teardown,
12126 				test_authonly_scheduler_all),
12127 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12128 
12129 		/* Fail over */
12130 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12131 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12132 		TEST_CASE_ST(ut_setup, ut_teardown,
12133 					test_AES_chain_scheduler_all),
12134 		TEST_CASE_ST(ut_setup, ut_teardown,
12135 					test_AES_cipheronly_scheduler_all),
12136 		TEST_CASE_ST(ut_setup, ut_teardown,
12137 					test_authonly_scheduler_all),
12138 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12139 
12140 		/* PKT SIZE */
12141 		TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12142 		TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12143 		TEST_CASE_ST(ut_setup, ut_teardown,
12144 					test_AES_chain_scheduler_all),
12145 		TEST_CASE_ST(ut_setup, ut_teardown,
12146 					test_AES_cipheronly_scheduler_all),
12147 		TEST_CASE_ST(ut_setup, ut_teardown,
12148 					test_authonly_scheduler_all),
12149 		TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12150 
12151 		TEST_CASES_END() /**< NULL terminate unit test array */
12152 	}
12153 };
12154 
12155 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12156 
12157 static struct unit_test_suite cryptodev_qat_testsuite  = {
12158 	.suite_name = "Crypto QAT Unit Test Suite",
12159 	.setup = testsuite_setup,
12160 	.teardown = testsuite_teardown,
12161 	.unit_test_cases = {
12162 		TEST_CASE_ST(ut_setup, ut_teardown,
12163 				test_device_configure_invalid_dev_id),
12164 		TEST_CASE_ST(ut_setup, ut_teardown,
12165 				test_device_configure_invalid_queue_pair_ids),
12166 		TEST_CASE_ST(ut_setup, ut_teardown,
12167 				test_queue_pair_descriptor_setup),
12168 		TEST_CASE_ST(ut_setup, ut_teardown,
12169 				test_multi_session),
12170 
12171 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
12172 		TEST_CASE_ST(ut_setup, ut_teardown,
12173 						test_AES_cipheronly_qat_all),
12174 		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
12175 		TEST_CASE_ST(ut_setup, ut_teardown,
12176 						test_3DES_cipheronly_qat_all),
12177 		TEST_CASE_ST(ut_setup, ut_teardown,
12178 						test_DES_cipheronly_qat_all),
12179 		TEST_CASE_ST(ut_setup, ut_teardown,
12180 						test_AES_docsis_qat_all),
12181 		TEST_CASE_ST(ut_setup, ut_teardown,
12182 						test_DES_docsis_qat_all),
12183 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
12184 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12185 
12186 		/** AES CCM Authenticated Encryption 128 bits key */
12187 		TEST_CASE_ST(ut_setup, ut_teardown,
12188 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12189 		TEST_CASE_ST(ut_setup, ut_teardown,
12190 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12191 		TEST_CASE_ST(ut_setup, ut_teardown,
12192 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12193 
12194 		/** AES CCM Authenticated Decryption 128 bits key*/
12195 		TEST_CASE_ST(ut_setup, ut_teardown,
12196 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12197 		TEST_CASE_ST(ut_setup, ut_teardown,
12198 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12199 		TEST_CASE_ST(ut_setup, ut_teardown,
12200 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12201 
12202 		TEST_CASE_ST(ut_setup, ut_teardown,
12203 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
12204 		TEST_CASE_ST(ut_setup, ut_teardown,
12205 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
12206 		/** AES GCM Authenticated Encryption */
12207 		TEST_CASE_ST(ut_setup, ut_teardown,
12208 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12209 		TEST_CASE_ST(ut_setup, ut_teardown,
12210 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12211 		TEST_CASE_ST(ut_setup, ut_teardown,
12212 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12213 		TEST_CASE_ST(ut_setup, ut_teardown,
12214 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12215 		TEST_CASE_ST(ut_setup, ut_teardown,
12216 			test_AES_GCM_authenticated_encryption_test_case_1),
12217 		TEST_CASE_ST(ut_setup, ut_teardown,
12218 			test_AES_GCM_authenticated_encryption_test_case_2),
12219 		TEST_CASE_ST(ut_setup, ut_teardown,
12220 			test_AES_GCM_authenticated_encryption_test_case_3),
12221 		TEST_CASE_ST(ut_setup, ut_teardown,
12222 			test_AES_GCM_authenticated_encryption_test_case_4),
12223 		TEST_CASE_ST(ut_setup, ut_teardown,
12224 			test_AES_GCM_authenticated_encryption_test_case_5),
12225 		TEST_CASE_ST(ut_setup, ut_teardown,
12226 			test_AES_GCM_authenticated_encryption_test_case_6),
12227 		TEST_CASE_ST(ut_setup, ut_teardown,
12228 			test_AES_GCM_authenticated_encryption_test_case_7),
12229 		TEST_CASE_ST(ut_setup, ut_teardown,
12230 			test_AES_GCM_authenticated_encryption_test_case_8),
12231 
12232 		/** AES GCM Authenticated Decryption */
12233 		TEST_CASE_ST(ut_setup, ut_teardown,
12234 			test_AES_GCM_authenticated_decryption_test_case_1),
12235 		TEST_CASE_ST(ut_setup, ut_teardown,
12236 			test_AES_GCM_authenticated_decryption_test_case_2),
12237 		TEST_CASE_ST(ut_setup, ut_teardown,
12238 			test_AES_GCM_authenticated_decryption_test_case_3),
12239 		TEST_CASE_ST(ut_setup, ut_teardown,
12240 			test_AES_GCM_authenticated_decryption_test_case_4),
12241 		TEST_CASE_ST(ut_setup, ut_teardown,
12242 			test_AES_GCM_authenticated_decryption_test_case_5),
12243 		TEST_CASE_ST(ut_setup, ut_teardown,
12244 			test_AES_GCM_authenticated_decryption_test_case_6),
12245 		TEST_CASE_ST(ut_setup, ut_teardown,
12246 			test_AES_GCM_authenticated_decryption_test_case_7),
12247 		TEST_CASE_ST(ut_setup, ut_teardown,
12248 			test_AES_GCM_authenticated_decryption_test_case_8),
12249 
12250 		/** AES GCM Authenticated Encryption 192 bits key */
12251 		TEST_CASE_ST(ut_setup, ut_teardown,
12252 			test_AES_GCM_auth_encryption_test_case_192_1),
12253 		TEST_CASE_ST(ut_setup, ut_teardown,
12254 			test_AES_GCM_auth_encryption_test_case_192_2),
12255 		TEST_CASE_ST(ut_setup, ut_teardown,
12256 			test_AES_GCM_auth_encryption_test_case_192_3),
12257 		TEST_CASE_ST(ut_setup, ut_teardown,
12258 			test_AES_GCM_auth_encryption_test_case_192_4),
12259 		TEST_CASE_ST(ut_setup, ut_teardown,
12260 			test_AES_GCM_auth_encryption_test_case_192_5),
12261 		TEST_CASE_ST(ut_setup, ut_teardown,
12262 			test_AES_GCM_auth_encryption_test_case_192_6),
12263 		TEST_CASE_ST(ut_setup, ut_teardown,
12264 			test_AES_GCM_auth_encryption_test_case_192_7),
12265 
12266 		/** AES GCM Authenticated Decryption 192 bits key */
12267 		TEST_CASE_ST(ut_setup, ut_teardown,
12268 			test_AES_GCM_auth_decryption_test_case_192_1),
12269 		TEST_CASE_ST(ut_setup, ut_teardown,
12270 			test_AES_GCM_auth_decryption_test_case_192_2),
12271 		TEST_CASE_ST(ut_setup, ut_teardown,
12272 			test_AES_GCM_auth_decryption_test_case_192_3),
12273 		TEST_CASE_ST(ut_setup, ut_teardown,
12274 			test_AES_GCM_auth_decryption_test_case_192_4),
12275 		TEST_CASE_ST(ut_setup, ut_teardown,
12276 			test_AES_GCM_auth_decryption_test_case_192_5),
12277 		TEST_CASE_ST(ut_setup, ut_teardown,
12278 			test_AES_GCM_auth_decryption_test_case_192_6),
12279 		TEST_CASE_ST(ut_setup, ut_teardown,
12280 			test_AES_GCM_auth_decryption_test_case_192_7),
12281 
12282 		/** AES GCM Authenticated Encryption 256 bits key */
12283 		TEST_CASE_ST(ut_setup, ut_teardown,
12284 			test_AES_GCM_auth_encryption_test_case_256_1),
12285 		TEST_CASE_ST(ut_setup, ut_teardown,
12286 			test_AES_GCM_auth_encryption_test_case_256_2),
12287 		TEST_CASE_ST(ut_setup, ut_teardown,
12288 			test_AES_GCM_auth_encryption_test_case_256_3),
12289 		TEST_CASE_ST(ut_setup, ut_teardown,
12290 			test_AES_GCM_auth_encryption_test_case_256_4),
12291 		TEST_CASE_ST(ut_setup, ut_teardown,
12292 			test_AES_GCM_auth_encryption_test_case_256_5),
12293 		TEST_CASE_ST(ut_setup, ut_teardown,
12294 			test_AES_GCM_auth_encryption_test_case_256_6),
12295 		TEST_CASE_ST(ut_setup, ut_teardown,
12296 			test_AES_GCM_auth_encryption_test_case_256_7),
12297 
12298 		/** AES GCM Authenticated Decryption 256 bits key */
12299 		TEST_CASE_ST(ut_setup, ut_teardown,
12300 			test_AES_GCM_auth_decryption_test_case_256_1),
12301 		TEST_CASE_ST(ut_setup, ut_teardown,
12302 			test_AES_GCM_auth_decryption_test_case_256_2),
12303 		TEST_CASE_ST(ut_setup, ut_teardown,
12304 			test_AES_GCM_auth_decryption_test_case_256_3),
12305 		TEST_CASE_ST(ut_setup, ut_teardown,
12306 			test_AES_GCM_auth_decryption_test_case_256_4),
12307 		TEST_CASE_ST(ut_setup, ut_teardown,
12308 			test_AES_GCM_auth_decryption_test_case_256_5),
12309 		TEST_CASE_ST(ut_setup, ut_teardown,
12310 			test_AES_GCM_auth_decryption_test_case_256_6),
12311 		TEST_CASE_ST(ut_setup, ut_teardown,
12312 			test_AES_GCM_auth_decryption_test_case_256_7),
12313 
12314 		/** AES GMAC Authentication */
12315 		TEST_CASE_ST(ut_setup, ut_teardown,
12316 			test_AES_GMAC_authentication_test_case_1),
12317 		TEST_CASE_ST(ut_setup, ut_teardown,
12318 			test_AES_GMAC_authentication_verify_test_case_1),
12319 		TEST_CASE_ST(ut_setup, ut_teardown,
12320 			test_AES_GMAC_authentication_test_case_2),
12321 		TEST_CASE_ST(ut_setup, ut_teardown,
12322 			test_AES_GMAC_authentication_verify_test_case_2),
12323 		TEST_CASE_ST(ut_setup, ut_teardown,
12324 			test_AES_GMAC_authentication_test_case_3),
12325 		TEST_CASE_ST(ut_setup, ut_teardown,
12326 			test_AES_GMAC_authentication_verify_test_case_3),
12327 
12328 		/** SNOW 3G encrypt only (UEA2) */
12329 		TEST_CASE_ST(ut_setup, ut_teardown,
12330 			test_snow3g_encryption_test_case_1),
12331 		TEST_CASE_ST(ut_setup, ut_teardown,
12332 			test_snow3g_encryption_test_case_2),
12333 		TEST_CASE_ST(ut_setup, ut_teardown,
12334 			test_snow3g_encryption_test_case_3),
12335 		TEST_CASE_ST(ut_setup, ut_teardown,
12336 			test_snow3g_encryption_test_case_4),
12337 		TEST_CASE_ST(ut_setup, ut_teardown,
12338 			test_snow3g_encryption_test_case_5),
12339 
12340 		TEST_CASE_ST(ut_setup, ut_teardown,
12341 			test_snow3g_encryption_test_case_1_oop),
12342 		TEST_CASE_ST(ut_setup, ut_teardown,
12343 			test_snow3g_decryption_test_case_1_oop),
12344 
12345 		/** SNOW 3G generate auth, then encrypt (UEA2) */
12346 		TEST_CASE_ST(ut_setup, ut_teardown,
12347 			test_snow3g_auth_cipher_test_case_1),
12348 		TEST_CASE_ST(ut_setup, ut_teardown,
12349 			test_snow3g_auth_cipher_test_case_2),
12350 		TEST_CASE_ST(ut_setup, ut_teardown,
12351 			test_snow3g_auth_cipher_test_case_2_oop),
12352 		TEST_CASE_ST(ut_setup, ut_teardown,
12353 			test_snow3g_auth_cipher_part_digest_enc),
12354 		TEST_CASE_ST(ut_setup, ut_teardown,
12355 			test_snow3g_auth_cipher_part_digest_enc_oop),
12356 		TEST_CASE_ST(ut_setup, ut_teardown,
12357 			test_snow3g_auth_cipher_test_case_3_sgl),
12358 		TEST_CASE_ST(ut_setup, ut_teardown,
12359 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
12360 		TEST_CASE_ST(ut_setup, ut_teardown,
12361 			test_snow3g_auth_cipher_part_digest_enc_sgl),
12362 		TEST_CASE_ST(ut_setup, ut_teardown,
12363 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12364 
12365 		/** SNOW 3G decrypt (UEA2), then verify auth */
12366 		TEST_CASE_ST(ut_setup, ut_teardown,
12367 			test_snow3g_auth_cipher_verify_test_case_1),
12368 		TEST_CASE_ST(ut_setup, ut_teardown,
12369 			test_snow3g_auth_cipher_verify_test_case_2),
12370 		TEST_CASE_ST(ut_setup, ut_teardown,
12371 			test_snow3g_auth_cipher_verify_test_case_2_oop),
12372 		TEST_CASE_ST(ut_setup, ut_teardown,
12373 			test_snow3g_auth_cipher_verify_part_digest_enc),
12374 		TEST_CASE_ST(ut_setup, ut_teardown,
12375 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12376 		TEST_CASE_ST(ut_setup, ut_teardown,
12377 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
12378 		TEST_CASE_ST(ut_setup, ut_teardown,
12379 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12380 		TEST_CASE_ST(ut_setup, ut_teardown,
12381 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12382 		TEST_CASE_ST(ut_setup, ut_teardown,
12383 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12384 
12385 		/** SNOW 3G decrypt only (UEA2) */
12386 		TEST_CASE_ST(ut_setup, ut_teardown,
12387 			test_snow3g_decryption_test_case_1),
12388 		TEST_CASE_ST(ut_setup, ut_teardown,
12389 			test_snow3g_decryption_test_case_2),
12390 		TEST_CASE_ST(ut_setup, ut_teardown,
12391 			test_snow3g_decryption_test_case_3),
12392 		TEST_CASE_ST(ut_setup, ut_teardown,
12393 			test_snow3g_decryption_test_case_4),
12394 		TEST_CASE_ST(ut_setup, ut_teardown,
12395 			test_snow3g_decryption_test_case_5),
12396 		TEST_CASE_ST(ut_setup, ut_teardown,
12397 			test_snow3g_decryption_with_digest_test_case_1),
12398 		TEST_CASE_ST(ut_setup, ut_teardown,
12399 			test_snow3g_hash_generate_test_case_1),
12400 		TEST_CASE_ST(ut_setup, ut_teardown,
12401 			test_snow3g_hash_generate_test_case_2),
12402 		TEST_CASE_ST(ut_setup, ut_teardown,
12403 			test_snow3g_hash_generate_test_case_3),
12404 		TEST_CASE_ST(ut_setup, ut_teardown,
12405 			test_snow3g_hash_verify_test_case_1),
12406 		TEST_CASE_ST(ut_setup, ut_teardown,
12407 			test_snow3g_hash_verify_test_case_2),
12408 		TEST_CASE_ST(ut_setup, ut_teardown,
12409 			test_snow3g_hash_verify_test_case_3),
12410 		TEST_CASE_ST(ut_setup, ut_teardown,
12411 			test_snow3g_cipher_auth_test_case_1),
12412 		TEST_CASE_ST(ut_setup, ut_teardown,
12413 			test_snow3g_auth_cipher_with_digest_test_case_1),
12414 
12415 		/** ZUC encrypt only (EEA3) */
12416 		TEST_CASE_ST(ut_setup, ut_teardown,
12417 			test_zuc_encryption_test_case_1),
12418 		TEST_CASE_ST(ut_setup, ut_teardown,
12419 			test_zuc_encryption_test_case_2),
12420 		TEST_CASE_ST(ut_setup, ut_teardown,
12421 			test_zuc_encryption_test_case_3),
12422 		TEST_CASE_ST(ut_setup, ut_teardown,
12423 			test_zuc_encryption_test_case_4),
12424 		TEST_CASE_ST(ut_setup, ut_teardown,
12425 			test_zuc_encryption_test_case_5),
12426 
12427 		/** ZUC authenticate (EIA3) */
12428 		TEST_CASE_ST(ut_setup, ut_teardown,
12429 			test_zuc_hash_generate_test_case_6),
12430 		TEST_CASE_ST(ut_setup, ut_teardown,
12431 			test_zuc_hash_generate_test_case_7),
12432 		TEST_CASE_ST(ut_setup, ut_teardown,
12433 			test_zuc_hash_generate_test_case_8),
12434 
12435 		/** ZUC alg-chain (EEA3/EIA3) */
12436 		TEST_CASE_ST(ut_setup, ut_teardown,
12437 			test_zuc_cipher_auth_test_case_1),
12438 		TEST_CASE_ST(ut_setup, ut_teardown,
12439 			test_zuc_cipher_auth_test_case_2),
12440 
12441 		/** ZUC generate auth, then encrypt (EEA3) */
12442 		TEST_CASE_ST(ut_setup, ut_teardown,
12443 			test_zuc_auth_cipher_test_case_1),
12444 		TEST_CASE_ST(ut_setup, ut_teardown,
12445 			test_zuc_auth_cipher_test_case_1_oop),
12446 		TEST_CASE_ST(ut_setup, ut_teardown,
12447 			test_zuc_auth_cipher_test_case_1_sgl),
12448 		TEST_CASE_ST(ut_setup, ut_teardown,
12449 			test_zuc_auth_cipher_test_case_1_oop_sgl),
12450 
12451 		/** ZUC decrypt (EEA3), then verify auth */
12452 		TEST_CASE_ST(ut_setup, ut_teardown,
12453 			test_zuc_auth_cipher_verify_test_case_1),
12454 		TEST_CASE_ST(ut_setup, ut_teardown,
12455 			test_zuc_auth_cipher_verify_test_case_1_oop),
12456 		TEST_CASE_ST(ut_setup, ut_teardown,
12457 			test_zuc_auth_cipher_verify_test_case_1_sgl),
12458 		TEST_CASE_ST(ut_setup, ut_teardown,
12459 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12460 
12461 		/** HMAC_MD5 Authentication */
12462 		TEST_CASE_ST(ut_setup, ut_teardown,
12463 			test_MD5_HMAC_generate_case_1),
12464 		TEST_CASE_ST(ut_setup, ut_teardown,
12465 			test_MD5_HMAC_verify_case_1),
12466 		TEST_CASE_ST(ut_setup, ut_teardown,
12467 			test_MD5_HMAC_generate_case_2),
12468 		TEST_CASE_ST(ut_setup, ut_teardown,
12469 			test_MD5_HMAC_verify_case_2),
12470 
12471 		/** NULL algo tests done in chain_all,
12472 		 * cipheronly and authonly suites
12473 		 */
12474 
12475 		/** KASUMI tests */
12476 		TEST_CASE_ST(ut_setup, ut_teardown,
12477 			test_kasumi_hash_generate_test_case_1),
12478 		TEST_CASE_ST(ut_setup, ut_teardown,
12479 			test_kasumi_hash_generate_test_case_2),
12480 		TEST_CASE_ST(ut_setup, ut_teardown,
12481 			test_kasumi_hash_generate_test_case_3),
12482 		TEST_CASE_ST(ut_setup, ut_teardown,
12483 			test_kasumi_hash_generate_test_case_4),
12484 		TEST_CASE_ST(ut_setup, ut_teardown,
12485 			test_kasumi_hash_generate_test_case_5),
12486 		TEST_CASE_ST(ut_setup, ut_teardown,
12487 			test_kasumi_hash_generate_test_case_6),
12488 
12489 		TEST_CASE_ST(ut_setup, ut_teardown,
12490 			test_kasumi_hash_verify_test_case_1),
12491 		TEST_CASE_ST(ut_setup, ut_teardown,
12492 			test_kasumi_hash_verify_test_case_2),
12493 		TEST_CASE_ST(ut_setup, ut_teardown,
12494 			test_kasumi_hash_verify_test_case_3),
12495 		TEST_CASE_ST(ut_setup, ut_teardown,
12496 			test_kasumi_hash_verify_test_case_4),
12497 		TEST_CASE_ST(ut_setup, ut_teardown,
12498 			test_kasumi_hash_verify_test_case_5),
12499 
12500 		TEST_CASE_ST(ut_setup, ut_teardown,
12501 			test_kasumi_encryption_test_case_1),
12502 		TEST_CASE_ST(ut_setup, ut_teardown,
12503 			test_kasumi_encryption_test_case_3),
12504 		TEST_CASE_ST(ut_setup, ut_teardown,
12505 			test_kasumi_cipher_auth_test_case_1),
12506 
12507 		/** KASUMI generate auth, then encrypt (F8) */
12508 		TEST_CASE_ST(ut_setup, ut_teardown,
12509 			test_kasumi_auth_cipher_test_case_1),
12510 		TEST_CASE_ST(ut_setup, ut_teardown,
12511 			test_kasumi_auth_cipher_test_case_2),
12512 		TEST_CASE_ST(ut_setup, ut_teardown,
12513 			test_kasumi_auth_cipher_test_case_2_oop),
12514 		TEST_CASE_ST(ut_setup, ut_teardown,
12515 			test_kasumi_auth_cipher_test_case_2_sgl),
12516 		TEST_CASE_ST(ut_setup, ut_teardown,
12517 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
12518 
12519 		/** KASUMI decrypt (F8), then verify auth */
12520 		TEST_CASE_ST(ut_setup, ut_teardown,
12521 			test_kasumi_auth_cipher_verify_test_case_1),
12522 		TEST_CASE_ST(ut_setup, ut_teardown,
12523 			test_kasumi_auth_cipher_verify_test_case_2),
12524 		TEST_CASE_ST(ut_setup, ut_teardown,
12525 			test_kasumi_auth_cipher_verify_test_case_2_oop),
12526 		TEST_CASE_ST(ut_setup, ut_teardown,
12527 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
12528 		TEST_CASE_ST(ut_setup, ut_teardown,
12529 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12530 
12531 		/** Negative tests */
12532 		TEST_CASE_ST(ut_setup, ut_teardown,
12533 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
12534 		TEST_CASE_ST(ut_setup, ut_teardown,
12535 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12536 		TEST_CASE_ST(ut_setup, ut_teardown,
12537 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
12538 		TEST_CASE_ST(ut_setup, ut_teardown,
12539 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12540 		TEST_CASE_ST(ut_setup, ut_teardown,
12541 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12542 		TEST_CASE_ST(ut_setup, ut_teardown,
12543 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12544 		TEST_CASE_ST(ut_setup, ut_teardown,
12545 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
12546 		TEST_CASE_ST(ut_setup, ut_teardown,
12547 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
12548 		TEST_CASE_ST(ut_setup, ut_teardown,
12549 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
12550 		TEST_CASE_ST(ut_setup, ut_teardown,
12551 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12552 		TEST_CASE_ST(ut_setup, ut_teardown,
12553 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12554 		TEST_CASE_ST(ut_setup, ut_teardown,
12555 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12556 		TEST_CASE_ST(ut_setup, ut_teardown,
12557 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
12558 		TEST_CASE_ST(ut_setup, ut_teardown,
12559 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
12560 		TEST_CASE_ST(ut_setup, ut_teardown,
12561 			authentication_verify_AES128_GMAC_fail_data_corrupt),
12562 		TEST_CASE_ST(ut_setup, ut_teardown,
12563 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
12564 		TEST_CASE_ST(ut_setup, ut_teardown,
12565 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12566 		TEST_CASE_ST(ut_setup, ut_teardown,
12567 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12568 
12569 		/** Mixed CIPHER + HASH algorithms */
12570 		/** AUTH AES CMAC + CIPHER AES CTR */
12571 		TEST_CASE_ST(ut_setup, ut_teardown,
12572 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12573 		TEST_CASE_ST(ut_setup, ut_teardown,
12574 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12575 		TEST_CASE_ST(ut_setup, ut_teardown,
12576 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12577 		TEST_CASE_ST(ut_setup, ut_teardown,
12578 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12579 		TEST_CASE_ST(ut_setup, ut_teardown,
12580 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12581 		TEST_CASE_ST(ut_setup, ut_teardown,
12582 		       test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12583 		TEST_CASE_ST(ut_setup, ut_teardown,
12584 		       test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12585 		TEST_CASE_ST(ut_setup, ut_teardown,
12586 		   test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12587 
12588 		/** AUTH ZUC + CIPHER SNOW3G */
12589 		TEST_CASE_ST(ut_setup, ut_teardown,
12590 			test_auth_zuc_cipher_snow_test_case_1),
12591 		TEST_CASE_ST(ut_setup, ut_teardown,
12592 			test_verify_auth_zuc_cipher_snow_test_case_1),
12593 		/** AUTH AES CMAC + CIPHER SNOW3G */
12594 		TEST_CASE_ST(ut_setup, ut_teardown,
12595 			test_auth_aes_cmac_cipher_snow_test_case_1),
12596 		TEST_CASE_ST(ut_setup, ut_teardown,
12597 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12598 		/** AUTH ZUC + CIPHER AES CTR */
12599 		TEST_CASE_ST(ut_setup, ut_teardown,
12600 			test_auth_zuc_cipher_aes_ctr_test_case_1),
12601 		TEST_CASE_ST(ut_setup, ut_teardown,
12602 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12603 		/** AUTH SNOW3G + CIPHER AES CTR */
12604 		TEST_CASE_ST(ut_setup, ut_teardown,
12605 			test_auth_snow_cipher_aes_ctr_test_case_1),
12606 		TEST_CASE_ST(ut_setup, ut_teardown,
12607 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12608 		/** AUTH SNOW3G + CIPHER ZUC */
12609 		TEST_CASE_ST(ut_setup, ut_teardown,
12610 			test_auth_snow_cipher_zuc_test_case_1),
12611 		TEST_CASE_ST(ut_setup, ut_teardown,
12612 			test_verify_auth_snow_cipher_zuc_test_case_1),
12613 		/** AUTH AES CMAC + CIPHER ZUC */
12614 		TEST_CASE_ST(ut_setup, ut_teardown,
12615 			test_auth_aes_cmac_cipher_zuc_test_case_1),
12616 		TEST_CASE_ST(ut_setup, ut_teardown,
12617 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12618 
12619 		/** AUTH NULL + CIPHER SNOW3G */
12620 		TEST_CASE_ST(ut_setup, ut_teardown,
12621 			test_auth_null_cipher_snow_test_case_1),
12622 		TEST_CASE_ST(ut_setup, ut_teardown,
12623 			test_verify_auth_null_cipher_snow_test_case_1),
12624 		/** AUTH NULL + CIPHER ZUC */
12625 		TEST_CASE_ST(ut_setup, ut_teardown,
12626 			test_auth_null_cipher_zuc_test_case_1),
12627 		TEST_CASE_ST(ut_setup, ut_teardown,
12628 			test_verify_auth_null_cipher_zuc_test_case_1),
12629 		/** AUTH SNOW3G + CIPHER NULL */
12630 		TEST_CASE_ST(ut_setup, ut_teardown,
12631 			test_auth_snow_cipher_null_test_case_1),
12632 		TEST_CASE_ST(ut_setup, ut_teardown,
12633 			test_verify_auth_snow_cipher_null_test_case_1),
12634 		/** AUTH ZUC + CIPHER NULL */
12635 		TEST_CASE_ST(ut_setup, ut_teardown,
12636 			test_auth_zuc_cipher_null_test_case_1),
12637 		TEST_CASE_ST(ut_setup, ut_teardown,
12638 			test_verify_auth_zuc_cipher_null_test_case_1),
12639 		/** AUTH NULL + CIPHER AES CTR */
12640 		TEST_CASE_ST(ut_setup, ut_teardown,
12641 			test_auth_null_cipher_aes_ctr_test_case_1),
12642 		TEST_CASE_ST(ut_setup, ut_teardown,
12643 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
12644 		/** AUTH AES CMAC + CIPHER NULL */
12645 		TEST_CASE_ST(ut_setup, ut_teardown,
12646 			test_auth_aes_cmac_cipher_null_test_case_1),
12647 		TEST_CASE_ST(ut_setup, ut_teardown,
12648 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
12649 
12650 		TEST_CASES_END() /**< NULL terminate unit test array */
12651 	}
12652 };
12653 
12654 static struct unit_test_suite cryptodev_virtio_testsuite = {
12655 	.suite_name = "Crypto VIRTIO Unit Test Suite",
12656 	.setup = testsuite_setup,
12657 	.teardown = testsuite_teardown,
12658 	.unit_test_cases = {
12659 		TEST_CASE_ST(ut_setup, ut_teardown,
12660 				test_AES_cipheronly_virtio_all),
12661 
12662 		TEST_CASES_END() /**< NULL terminate unit test array */
12663 	}
12664 };
12665 
12666 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
12667 	.suite_name = "Crypto Device AESNI MB Unit Test Suite",
12668 	.setup = testsuite_setup,
12669 	.teardown = testsuite_teardown,
12670 	.unit_test_cases = {
12671 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12672 		TEST_CASE_ST(ut_setup, ut_teardown,
12673 			test_AES_GCM_authenticated_encryption_test_case_1),
12674 		TEST_CASE_ST(ut_setup, ut_teardown,
12675 			test_AES_GCM_authenticated_encryption_test_case_2),
12676 		TEST_CASE_ST(ut_setup, ut_teardown,
12677 			test_AES_GCM_authenticated_encryption_test_case_3),
12678 		TEST_CASE_ST(ut_setup, ut_teardown,
12679 			test_AES_GCM_authenticated_encryption_test_case_4),
12680 		TEST_CASE_ST(ut_setup, ut_teardown,
12681 			test_AES_GCM_authenticated_encryption_test_case_5),
12682 		TEST_CASE_ST(ut_setup, ut_teardown,
12683 			test_AES_GCM_authenticated_encryption_test_case_6),
12684 		TEST_CASE_ST(ut_setup, ut_teardown,
12685 			test_AES_GCM_authenticated_encryption_test_case_7),
12686 
12687 		/** AES GCM Authenticated Decryption */
12688 		TEST_CASE_ST(ut_setup, ut_teardown,
12689 			test_AES_GCM_authenticated_decryption_test_case_1),
12690 		TEST_CASE_ST(ut_setup, ut_teardown,
12691 			test_AES_GCM_authenticated_decryption_test_case_2),
12692 		TEST_CASE_ST(ut_setup, ut_teardown,
12693 			test_AES_GCM_authenticated_decryption_test_case_3),
12694 		TEST_CASE_ST(ut_setup, ut_teardown,
12695 			test_AES_GCM_authenticated_decryption_test_case_4),
12696 		TEST_CASE_ST(ut_setup, ut_teardown,
12697 			test_AES_GCM_authenticated_decryption_test_case_5),
12698 		TEST_CASE_ST(ut_setup, ut_teardown,
12699 			test_AES_GCM_authenticated_decryption_test_case_6),
12700 		TEST_CASE_ST(ut_setup, ut_teardown,
12701 			test_AES_GCM_authenticated_decryption_test_case_7),
12702 
12703 		/** AES GCM Authenticated Encryption 192 bits key */
12704 		TEST_CASE_ST(ut_setup, ut_teardown,
12705 			test_AES_GCM_auth_encryption_test_case_192_1),
12706 		TEST_CASE_ST(ut_setup, ut_teardown,
12707 			test_AES_GCM_auth_encryption_test_case_192_2),
12708 		TEST_CASE_ST(ut_setup, ut_teardown,
12709 			test_AES_GCM_auth_encryption_test_case_192_3),
12710 		TEST_CASE_ST(ut_setup, ut_teardown,
12711 			test_AES_GCM_auth_encryption_test_case_192_4),
12712 		TEST_CASE_ST(ut_setup, ut_teardown,
12713 			test_AES_GCM_auth_encryption_test_case_192_5),
12714 		TEST_CASE_ST(ut_setup, ut_teardown,
12715 			test_AES_GCM_auth_encryption_test_case_192_6),
12716 		TEST_CASE_ST(ut_setup, ut_teardown,
12717 			test_AES_GCM_auth_encryption_test_case_192_7),
12718 
12719 		/** AES GCM Authenticated Decryption 192 bits key */
12720 		TEST_CASE_ST(ut_setup, ut_teardown,
12721 			test_AES_GCM_auth_decryption_test_case_192_1),
12722 		TEST_CASE_ST(ut_setup, ut_teardown,
12723 			test_AES_GCM_auth_decryption_test_case_192_2),
12724 		TEST_CASE_ST(ut_setup, ut_teardown,
12725 			test_AES_GCM_auth_decryption_test_case_192_3),
12726 		TEST_CASE_ST(ut_setup, ut_teardown,
12727 			test_AES_GCM_auth_decryption_test_case_192_4),
12728 		TEST_CASE_ST(ut_setup, ut_teardown,
12729 			test_AES_GCM_auth_decryption_test_case_192_5),
12730 		TEST_CASE_ST(ut_setup, ut_teardown,
12731 			test_AES_GCM_auth_decryption_test_case_192_6),
12732 		TEST_CASE_ST(ut_setup, ut_teardown,
12733 			test_AES_GCM_auth_decryption_test_case_192_7),
12734 
12735 		/** AES GCM Authenticated Encryption 256 bits key */
12736 		TEST_CASE_ST(ut_setup, ut_teardown,
12737 			test_AES_GCM_auth_encryption_test_case_256_1),
12738 		TEST_CASE_ST(ut_setup, ut_teardown,
12739 			test_AES_GCM_auth_encryption_test_case_256_2),
12740 		TEST_CASE_ST(ut_setup, ut_teardown,
12741 			test_AES_GCM_auth_encryption_test_case_256_3),
12742 		TEST_CASE_ST(ut_setup, ut_teardown,
12743 			test_AES_GCM_auth_encryption_test_case_256_4),
12744 		TEST_CASE_ST(ut_setup, ut_teardown,
12745 			test_AES_GCM_auth_encryption_test_case_256_5),
12746 		TEST_CASE_ST(ut_setup, ut_teardown,
12747 			test_AES_GCM_auth_encryption_test_case_256_6),
12748 		TEST_CASE_ST(ut_setup, ut_teardown,
12749 			test_AES_GCM_auth_encryption_test_case_256_7),
12750 
12751 		/** AES GCM Authenticated Decryption 256 bits key */
12752 		TEST_CASE_ST(ut_setup, ut_teardown,
12753 			test_AES_GCM_auth_decryption_test_case_256_1),
12754 		TEST_CASE_ST(ut_setup, ut_teardown,
12755 			test_AES_GCM_auth_decryption_test_case_256_2),
12756 		TEST_CASE_ST(ut_setup, ut_teardown,
12757 			test_AES_GCM_auth_decryption_test_case_256_3),
12758 		TEST_CASE_ST(ut_setup, ut_teardown,
12759 			test_AES_GCM_auth_decryption_test_case_256_4),
12760 		TEST_CASE_ST(ut_setup, ut_teardown,
12761 			test_AES_GCM_auth_decryption_test_case_256_5),
12762 		TEST_CASE_ST(ut_setup, ut_teardown,
12763 			test_AES_GCM_auth_decryption_test_case_256_6),
12764 		TEST_CASE_ST(ut_setup, ut_teardown,
12765 			test_AES_GCM_auth_decryption_test_case_256_7),
12766 
12767 		/** AES GCM Authenticated Encryption big aad size */
12768 		TEST_CASE_ST(ut_setup, ut_teardown,
12769 			test_AES_GCM_auth_encryption_test_case_aad_1),
12770 		TEST_CASE_ST(ut_setup, ut_teardown,
12771 			test_AES_GCM_auth_encryption_test_case_aad_2),
12772 
12773 		/** AES GCM Authenticated Decryption big aad size */
12774 		TEST_CASE_ST(ut_setup, ut_teardown,
12775 			test_AES_GCM_auth_decryption_test_case_aad_1),
12776 		TEST_CASE_ST(ut_setup, ut_teardown,
12777 			test_AES_GCM_auth_decryption_test_case_aad_2),
12778 
12779 		/** Session-less tests */
12780 		TEST_CASE_ST(ut_setup, ut_teardown,
12781 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12782 		TEST_CASE_ST(ut_setup, ut_teardown,
12783 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12784 
12785 		/** AES GMAC Authentication */
12786 		TEST_CASE_ST(ut_setup, ut_teardown,
12787 			test_AES_GMAC_authentication_test_case_1),
12788 		TEST_CASE_ST(ut_setup, ut_teardown,
12789 			test_AES_GMAC_authentication_verify_test_case_1),
12790 		TEST_CASE_ST(ut_setup, ut_teardown,
12791 			test_AES_GMAC_authentication_test_case_2),
12792 		TEST_CASE_ST(ut_setup, ut_teardown,
12793 			test_AES_GMAC_authentication_verify_test_case_2),
12794 		TEST_CASE_ST(ut_setup, ut_teardown,
12795 			test_AES_GMAC_authentication_test_case_3),
12796 		TEST_CASE_ST(ut_setup, ut_teardown,
12797 			test_AES_GMAC_authentication_verify_test_case_3),
12798 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12799 
12800 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12801 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12802 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12803 		TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12804 		TEST_CASE_ST(ut_setup, ut_teardown,
12805 						test_DES_cipheronly_mb_all),
12806 		TEST_CASE_ST(ut_setup, ut_teardown,
12807 						test_DES_docsis_mb_all),
12808 		TEST_CASE_ST(ut_setup, ut_teardown,
12809 						test_3DES_cipheronly_mb_all),
12810 		TEST_CASE_ST(ut_setup, ut_teardown,
12811 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12812 		TEST_CASE_ST(ut_setup, ut_teardown,
12813 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12814 		TEST_CASE_ST(ut_setup, ut_teardown,
12815 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12816 		TEST_CASE_ST(ut_setup, ut_teardown,
12817 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12818 		TEST_CASE_ST(ut_setup, ut_teardown,
12819 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12820 		TEST_CASE_ST(ut_setup, ut_teardown,
12821 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12822 
12823 		TEST_CASES_END() /**< NULL terminate unit test array */
12824 	}
12825 };
12826 
12827 static struct unit_test_suite cryptodev_openssl_testsuite  = {
12828 	.suite_name = "Crypto Device OPENSSL Unit Test Suite",
12829 	.setup = testsuite_setup,
12830 	.teardown = testsuite_teardown,
12831 	.unit_test_cases = {
12832 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12833 		TEST_CASE_ST(ut_setup, ut_teardown,
12834 				test_multi_session_random_usage),
12835 		TEST_CASE_ST(ut_setup, ut_teardown,
12836 				test_AES_chain_openssl_all),
12837 		TEST_CASE_ST(ut_setup, ut_teardown,
12838 				test_AES_cipheronly_openssl_all),
12839 		TEST_CASE_ST(ut_setup, ut_teardown,
12840 				test_3DES_chain_openssl_all),
12841 		TEST_CASE_ST(ut_setup, ut_teardown,
12842 				test_3DES_cipheronly_openssl_all),
12843 		TEST_CASE_ST(ut_setup, ut_teardown,
12844 				test_DES_cipheronly_openssl_all),
12845 		TEST_CASE_ST(ut_setup, ut_teardown,
12846 				test_DES_docsis_openssl_all),
12847 		TEST_CASE_ST(ut_setup, ut_teardown,
12848 				test_authonly_openssl_all),
12849 
12850 		/** AES GCM Authenticated Encryption */
12851 		TEST_CASE_ST(ut_setup, ut_teardown,
12852 			test_AES_GCM_authenticated_encryption_test_case_1),
12853 		TEST_CASE_ST(ut_setup, ut_teardown,
12854 			test_AES_GCM_authenticated_encryption_test_case_2),
12855 		TEST_CASE_ST(ut_setup, ut_teardown,
12856 			test_AES_GCM_authenticated_encryption_test_case_3),
12857 		TEST_CASE_ST(ut_setup, ut_teardown,
12858 			test_AES_GCM_authenticated_encryption_test_case_4),
12859 		TEST_CASE_ST(ut_setup, ut_teardown,
12860 			test_AES_GCM_authenticated_encryption_test_case_5),
12861 		TEST_CASE_ST(ut_setup, ut_teardown,
12862 			test_AES_GCM_authenticated_encryption_test_case_6),
12863 		TEST_CASE_ST(ut_setup, ut_teardown,
12864 			test_AES_GCM_authenticated_encryption_test_case_7),
12865 
12866 		/** AES GCM Authenticated Decryption */
12867 		TEST_CASE_ST(ut_setup, ut_teardown,
12868 			test_AES_GCM_authenticated_decryption_test_case_1),
12869 		TEST_CASE_ST(ut_setup, ut_teardown,
12870 			test_AES_GCM_authenticated_decryption_test_case_2),
12871 		TEST_CASE_ST(ut_setup, ut_teardown,
12872 			test_AES_GCM_authenticated_decryption_test_case_3),
12873 		TEST_CASE_ST(ut_setup, ut_teardown,
12874 			test_AES_GCM_authenticated_decryption_test_case_4),
12875 		TEST_CASE_ST(ut_setup, ut_teardown,
12876 			test_AES_GCM_authenticated_decryption_test_case_5),
12877 		TEST_CASE_ST(ut_setup, ut_teardown,
12878 			test_AES_GCM_authenticated_decryption_test_case_6),
12879 		TEST_CASE_ST(ut_setup, ut_teardown,
12880 			test_AES_GCM_authenticated_decryption_test_case_7),
12881 
12882 
12883 		/** AES GCM Authenticated Encryption 192 bits key */
12884 		TEST_CASE_ST(ut_setup, ut_teardown,
12885 			test_AES_GCM_auth_encryption_test_case_192_1),
12886 		TEST_CASE_ST(ut_setup, ut_teardown,
12887 			test_AES_GCM_auth_encryption_test_case_192_2),
12888 		TEST_CASE_ST(ut_setup, ut_teardown,
12889 			test_AES_GCM_auth_encryption_test_case_192_3),
12890 		TEST_CASE_ST(ut_setup, ut_teardown,
12891 			test_AES_GCM_auth_encryption_test_case_192_4),
12892 		TEST_CASE_ST(ut_setup, ut_teardown,
12893 			test_AES_GCM_auth_encryption_test_case_192_5),
12894 		TEST_CASE_ST(ut_setup, ut_teardown,
12895 			test_AES_GCM_auth_encryption_test_case_192_6),
12896 		TEST_CASE_ST(ut_setup, ut_teardown,
12897 			test_AES_GCM_auth_encryption_test_case_192_7),
12898 
12899 		/** AES GCM Authenticated Decryption 192 bits key */
12900 		TEST_CASE_ST(ut_setup, ut_teardown,
12901 			test_AES_GCM_auth_decryption_test_case_192_1),
12902 		TEST_CASE_ST(ut_setup, ut_teardown,
12903 			test_AES_GCM_auth_decryption_test_case_192_2),
12904 		TEST_CASE_ST(ut_setup, ut_teardown,
12905 			test_AES_GCM_auth_decryption_test_case_192_3),
12906 		TEST_CASE_ST(ut_setup, ut_teardown,
12907 			test_AES_GCM_auth_decryption_test_case_192_4),
12908 		TEST_CASE_ST(ut_setup, ut_teardown,
12909 			test_AES_GCM_auth_decryption_test_case_192_5),
12910 		TEST_CASE_ST(ut_setup, ut_teardown,
12911 			test_AES_GCM_auth_decryption_test_case_192_6),
12912 		TEST_CASE_ST(ut_setup, ut_teardown,
12913 			test_AES_GCM_auth_decryption_test_case_192_7),
12914 
12915 		/** AES GCM Authenticated Encryption 256 bits key */
12916 		TEST_CASE_ST(ut_setup, ut_teardown,
12917 			test_AES_GCM_auth_encryption_test_case_256_1),
12918 		TEST_CASE_ST(ut_setup, ut_teardown,
12919 			test_AES_GCM_auth_encryption_test_case_256_2),
12920 		TEST_CASE_ST(ut_setup, ut_teardown,
12921 			test_AES_GCM_auth_encryption_test_case_256_3),
12922 		TEST_CASE_ST(ut_setup, ut_teardown,
12923 			test_AES_GCM_auth_encryption_test_case_256_4),
12924 		TEST_CASE_ST(ut_setup, ut_teardown,
12925 			test_AES_GCM_auth_encryption_test_case_256_5),
12926 		TEST_CASE_ST(ut_setup, ut_teardown,
12927 			test_AES_GCM_auth_encryption_test_case_256_6),
12928 		TEST_CASE_ST(ut_setup, ut_teardown,
12929 			test_AES_GCM_auth_encryption_test_case_256_7),
12930 
12931 		/** AES GCM Authenticated Decryption 256 bits key */
12932 		TEST_CASE_ST(ut_setup, ut_teardown,
12933 			test_AES_GCM_auth_decryption_test_case_256_1),
12934 		TEST_CASE_ST(ut_setup, ut_teardown,
12935 			test_AES_GCM_auth_decryption_test_case_256_2),
12936 		TEST_CASE_ST(ut_setup, ut_teardown,
12937 			test_AES_GCM_auth_decryption_test_case_256_3),
12938 		TEST_CASE_ST(ut_setup, ut_teardown,
12939 			test_AES_GCM_auth_decryption_test_case_256_4),
12940 		TEST_CASE_ST(ut_setup, ut_teardown,
12941 			test_AES_GCM_auth_decryption_test_case_256_5),
12942 		TEST_CASE_ST(ut_setup, ut_teardown,
12943 			test_AES_GCM_auth_decryption_test_case_256_6),
12944 		TEST_CASE_ST(ut_setup, ut_teardown,
12945 			test_AES_GCM_auth_decryption_test_case_256_7),
12946 
12947 		/** AES GMAC Authentication */
12948 		TEST_CASE_ST(ut_setup, ut_teardown,
12949 			test_AES_GMAC_authentication_test_case_1),
12950 		TEST_CASE_ST(ut_setup, ut_teardown,
12951 			test_AES_GMAC_authentication_verify_test_case_1),
12952 		TEST_CASE_ST(ut_setup, ut_teardown,
12953 			test_AES_GMAC_authentication_test_case_2),
12954 		TEST_CASE_ST(ut_setup, ut_teardown,
12955 			test_AES_GMAC_authentication_verify_test_case_2),
12956 		TEST_CASE_ST(ut_setup, ut_teardown,
12957 			test_AES_GMAC_authentication_test_case_3),
12958 		TEST_CASE_ST(ut_setup, ut_teardown,
12959 			test_AES_GMAC_authentication_verify_test_case_3),
12960 		TEST_CASE_ST(ut_setup, ut_teardown,
12961 			test_AES_GMAC_authentication_test_case_4),
12962 		TEST_CASE_ST(ut_setup, ut_teardown,
12963 			test_AES_GMAC_authentication_verify_test_case_4),
12964 
12965 		/** AES CCM Authenticated Encryption 128 bits key */
12966 		TEST_CASE_ST(ut_setup, ut_teardown,
12967 			test_AES_CCM_authenticated_encryption_test_case_128_1),
12968 		TEST_CASE_ST(ut_setup, ut_teardown,
12969 			test_AES_CCM_authenticated_encryption_test_case_128_2),
12970 		TEST_CASE_ST(ut_setup, ut_teardown,
12971 			test_AES_CCM_authenticated_encryption_test_case_128_3),
12972 
12973 		/** AES CCM Authenticated Decryption 128 bits key*/
12974 		TEST_CASE_ST(ut_setup, ut_teardown,
12975 			test_AES_CCM_authenticated_decryption_test_case_128_1),
12976 		TEST_CASE_ST(ut_setup, ut_teardown,
12977 			test_AES_CCM_authenticated_decryption_test_case_128_2),
12978 		TEST_CASE_ST(ut_setup, ut_teardown,
12979 			test_AES_CCM_authenticated_decryption_test_case_128_3),
12980 
12981 		/** AES CCM Authenticated Encryption 192 bits key */
12982 		TEST_CASE_ST(ut_setup, ut_teardown,
12983 			test_AES_CCM_authenticated_encryption_test_case_192_1),
12984 		TEST_CASE_ST(ut_setup, ut_teardown,
12985 			test_AES_CCM_authenticated_encryption_test_case_192_2),
12986 		TEST_CASE_ST(ut_setup, ut_teardown,
12987 			test_AES_CCM_authenticated_encryption_test_case_192_3),
12988 
12989 		/** AES CCM Authenticated Decryption 192 bits key*/
12990 		TEST_CASE_ST(ut_setup, ut_teardown,
12991 			test_AES_CCM_authenticated_decryption_test_case_192_1),
12992 		TEST_CASE_ST(ut_setup, ut_teardown,
12993 			test_AES_CCM_authenticated_decryption_test_case_192_2),
12994 		TEST_CASE_ST(ut_setup, ut_teardown,
12995 			test_AES_CCM_authenticated_decryption_test_case_192_3),
12996 
12997 		/** AES CCM Authenticated Encryption 256 bits key */
12998 		TEST_CASE_ST(ut_setup, ut_teardown,
12999 			test_AES_CCM_authenticated_encryption_test_case_256_1),
13000 		TEST_CASE_ST(ut_setup, ut_teardown,
13001 			test_AES_CCM_authenticated_encryption_test_case_256_2),
13002 		TEST_CASE_ST(ut_setup, ut_teardown,
13003 			test_AES_CCM_authenticated_encryption_test_case_256_3),
13004 
13005 		/** AES CCM Authenticated Decryption 256 bits key*/
13006 		TEST_CASE_ST(ut_setup, ut_teardown,
13007 			test_AES_CCM_authenticated_decryption_test_case_256_1),
13008 		TEST_CASE_ST(ut_setup, ut_teardown,
13009 			test_AES_CCM_authenticated_decryption_test_case_256_2),
13010 		TEST_CASE_ST(ut_setup, ut_teardown,
13011 			test_AES_CCM_authenticated_decryption_test_case_256_3),
13012 
13013 		/** Scatter-Gather */
13014 		TEST_CASE_ST(ut_setup, ut_teardown,
13015 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13016 
13017 		/** Negative tests */
13018 		TEST_CASE_ST(ut_setup, ut_teardown,
13019 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13020 		TEST_CASE_ST(ut_setup, ut_teardown,
13021 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13022 		TEST_CASE_ST(ut_setup, ut_teardown,
13023 			authentication_verify_AES128_GMAC_fail_data_corrupt),
13024 		TEST_CASE_ST(ut_setup, ut_teardown,
13025 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
13026 		TEST_CASE_ST(ut_setup, ut_teardown,
13027 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13028 		TEST_CASE_ST(ut_setup, ut_teardown,
13029 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13030 
13031 		/* ESN Testcase */
13032 		TEST_CASE_ST(ut_setup, ut_teardown,
13033 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13034 
13035 		TEST_CASE_ST(ut_setup, ut_teardown,
13036 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13037 
13038 		TEST_CASES_END() /**< NULL terminate unit test array */
13039 	}
13040 };
13041 
13042 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
13043 	.suite_name = "Crypto Device AESNI GCM Unit Test Suite",
13044 	.setup = testsuite_setup,
13045 	.teardown = testsuite_teardown,
13046 	.unit_test_cases = {
13047 		/** AES GCM Authenticated Encryption */
13048 		TEST_CASE_ST(ut_setup, ut_teardown,
13049 			test_AES_GCM_authenticated_encryption_test_case_1),
13050 		TEST_CASE_ST(ut_setup, ut_teardown,
13051 			test_AES_GCM_authenticated_encryption_test_case_2),
13052 		TEST_CASE_ST(ut_setup, ut_teardown,
13053 			test_AES_GCM_authenticated_encryption_test_case_3),
13054 		TEST_CASE_ST(ut_setup, ut_teardown,
13055 			test_AES_GCM_authenticated_encryption_test_case_4),
13056 		TEST_CASE_ST(ut_setup, ut_teardown,
13057 			test_AES_GCM_authenticated_encryption_test_case_5),
13058 		TEST_CASE_ST(ut_setup, ut_teardown,
13059 			test_AES_GCM_authenticated_encryption_test_case_6),
13060 		TEST_CASE_ST(ut_setup, ut_teardown,
13061 			test_AES_GCM_authenticated_encryption_test_case_7),
13062 
13063 		/** AES GCM Authenticated Decryption */
13064 		TEST_CASE_ST(ut_setup, ut_teardown,
13065 			test_AES_GCM_authenticated_decryption_test_case_1),
13066 		TEST_CASE_ST(ut_setup, ut_teardown,
13067 			test_AES_GCM_authenticated_decryption_test_case_2),
13068 		TEST_CASE_ST(ut_setup, ut_teardown,
13069 			test_AES_GCM_authenticated_decryption_test_case_3),
13070 		TEST_CASE_ST(ut_setup, ut_teardown,
13071 			test_AES_GCM_authenticated_decryption_test_case_4),
13072 		TEST_CASE_ST(ut_setup, ut_teardown,
13073 			test_AES_GCM_authenticated_decryption_test_case_5),
13074 		TEST_CASE_ST(ut_setup, ut_teardown,
13075 			test_AES_GCM_authenticated_decryption_test_case_6),
13076 		TEST_CASE_ST(ut_setup, ut_teardown,
13077 			test_AES_GCM_authenticated_decryption_test_case_7),
13078 
13079 		/** AES GCM Authenticated Encryption 192 bits key */
13080 		TEST_CASE_ST(ut_setup, ut_teardown,
13081 			test_AES_GCM_auth_encryption_test_case_192_1),
13082 		TEST_CASE_ST(ut_setup, ut_teardown,
13083 			test_AES_GCM_auth_encryption_test_case_192_2),
13084 		TEST_CASE_ST(ut_setup, ut_teardown,
13085 			test_AES_GCM_auth_encryption_test_case_192_3),
13086 		TEST_CASE_ST(ut_setup, ut_teardown,
13087 			test_AES_GCM_auth_encryption_test_case_192_4),
13088 		TEST_CASE_ST(ut_setup, ut_teardown,
13089 			test_AES_GCM_auth_encryption_test_case_192_5),
13090 		TEST_CASE_ST(ut_setup, ut_teardown,
13091 			test_AES_GCM_auth_encryption_test_case_192_6),
13092 		TEST_CASE_ST(ut_setup, ut_teardown,
13093 			test_AES_GCM_auth_encryption_test_case_192_7),
13094 
13095 		/** AES GCM Authenticated Decryption 192 bits key */
13096 		TEST_CASE_ST(ut_setup, ut_teardown,
13097 			test_AES_GCM_auth_decryption_test_case_192_1),
13098 		TEST_CASE_ST(ut_setup, ut_teardown,
13099 			test_AES_GCM_auth_decryption_test_case_192_2),
13100 		TEST_CASE_ST(ut_setup, ut_teardown,
13101 			test_AES_GCM_auth_decryption_test_case_192_3),
13102 		TEST_CASE_ST(ut_setup, ut_teardown,
13103 			test_AES_GCM_auth_decryption_test_case_192_4),
13104 		TEST_CASE_ST(ut_setup, ut_teardown,
13105 			test_AES_GCM_auth_decryption_test_case_192_5),
13106 		TEST_CASE_ST(ut_setup, ut_teardown,
13107 			test_AES_GCM_auth_decryption_test_case_192_6),
13108 		TEST_CASE_ST(ut_setup, ut_teardown,
13109 			test_AES_GCM_auth_decryption_test_case_192_7),
13110 
13111 		/** AES GCM Authenticated Encryption 256 bits key */
13112 		TEST_CASE_ST(ut_setup, ut_teardown,
13113 			test_AES_GCM_auth_encryption_test_case_256_1),
13114 		TEST_CASE_ST(ut_setup, ut_teardown,
13115 			test_AES_GCM_auth_encryption_test_case_256_2),
13116 		TEST_CASE_ST(ut_setup, ut_teardown,
13117 			test_AES_GCM_auth_encryption_test_case_256_3),
13118 		TEST_CASE_ST(ut_setup, ut_teardown,
13119 			test_AES_GCM_auth_encryption_test_case_256_4),
13120 		TEST_CASE_ST(ut_setup, ut_teardown,
13121 			test_AES_GCM_auth_encryption_test_case_256_5),
13122 		TEST_CASE_ST(ut_setup, ut_teardown,
13123 			test_AES_GCM_auth_encryption_test_case_256_6),
13124 		TEST_CASE_ST(ut_setup, ut_teardown,
13125 			test_AES_GCM_auth_encryption_test_case_256_7),
13126 
13127 		/** AES GCM Authenticated Decryption 256 bits key */
13128 		TEST_CASE_ST(ut_setup, ut_teardown,
13129 			test_AES_GCM_auth_decryption_test_case_256_1),
13130 		TEST_CASE_ST(ut_setup, ut_teardown,
13131 			test_AES_GCM_auth_decryption_test_case_256_2),
13132 		TEST_CASE_ST(ut_setup, ut_teardown,
13133 			test_AES_GCM_auth_decryption_test_case_256_3),
13134 		TEST_CASE_ST(ut_setup, ut_teardown,
13135 			test_AES_GCM_auth_decryption_test_case_256_4),
13136 		TEST_CASE_ST(ut_setup, ut_teardown,
13137 			test_AES_GCM_auth_decryption_test_case_256_5),
13138 		TEST_CASE_ST(ut_setup, ut_teardown,
13139 			test_AES_GCM_auth_decryption_test_case_256_6),
13140 		TEST_CASE_ST(ut_setup, ut_teardown,
13141 			test_AES_GCM_auth_decryption_test_case_256_7),
13142 
13143 		/** AES GCM Authenticated Encryption big aad size */
13144 		TEST_CASE_ST(ut_setup, ut_teardown,
13145 			test_AES_GCM_auth_encryption_test_case_aad_1),
13146 		TEST_CASE_ST(ut_setup, ut_teardown,
13147 			test_AES_GCM_auth_encryption_test_case_aad_2),
13148 
13149 		/** AES GCM Authenticated Decryption big aad size */
13150 		TEST_CASE_ST(ut_setup, ut_teardown,
13151 			test_AES_GCM_auth_decryption_test_case_aad_1),
13152 		TEST_CASE_ST(ut_setup, ut_teardown,
13153 			test_AES_GCM_auth_decryption_test_case_aad_2),
13154 
13155 		/** AES GMAC Authentication */
13156 		TEST_CASE_ST(ut_setup, ut_teardown,
13157 			test_AES_GMAC_authentication_test_case_1),
13158 		TEST_CASE_ST(ut_setup, ut_teardown,
13159 			test_AES_GMAC_authentication_verify_test_case_1),
13160 		TEST_CASE_ST(ut_setup, ut_teardown,
13161 			test_AES_GMAC_authentication_test_case_3),
13162 		TEST_CASE_ST(ut_setup, ut_teardown,
13163 			test_AES_GMAC_authentication_verify_test_case_3),
13164 		TEST_CASE_ST(ut_setup, ut_teardown,
13165 			test_AES_GMAC_authentication_test_case_4),
13166 		TEST_CASE_ST(ut_setup, ut_teardown,
13167 			test_AES_GMAC_authentication_verify_test_case_4),
13168 
13169 		/** Negative tests */
13170 		TEST_CASE_ST(ut_setup, ut_teardown,
13171 			authentication_verify_AES128_GMAC_fail_data_corrupt),
13172 		TEST_CASE_ST(ut_setup, ut_teardown,
13173 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
13174 
13175 		/** Out of place tests */
13176 		TEST_CASE_ST(ut_setup, ut_teardown,
13177 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13178 		TEST_CASE_ST(ut_setup, ut_teardown,
13179 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13180 
13181 		/** Session-less tests */
13182 		TEST_CASE_ST(ut_setup, ut_teardown,
13183 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13184 		TEST_CASE_ST(ut_setup, ut_teardown,
13185 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13186 
13187 		/** Scatter-Gather */
13188 		TEST_CASE_ST(ut_setup, ut_teardown,
13189 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13190 		TEST_CASE_ST(ut_setup, ut_teardown,
13191 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13192 
13193 		TEST_CASES_END() /**< NULL terminate unit test array */
13194 	}
13195 };
13196 
13197 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
13198 	.suite_name = "Crypto Device SW KASUMI Unit Test Suite",
13199 	.setup = testsuite_setup,
13200 	.teardown = testsuite_teardown,
13201 	.unit_test_cases = {
13202 		/** KASUMI encrypt only (UEA1) */
13203 		TEST_CASE_ST(ut_setup, ut_teardown,
13204 			test_kasumi_encryption_test_case_1),
13205 		TEST_CASE_ST(ut_setup, ut_teardown,
13206 			test_kasumi_encryption_test_case_1_sgl),
13207 		TEST_CASE_ST(ut_setup, ut_teardown,
13208 			test_kasumi_encryption_test_case_2),
13209 		TEST_CASE_ST(ut_setup, ut_teardown,
13210 			test_kasumi_encryption_test_case_3),
13211 		TEST_CASE_ST(ut_setup, ut_teardown,
13212 			test_kasumi_encryption_test_case_4),
13213 		TEST_CASE_ST(ut_setup, ut_teardown,
13214 			test_kasumi_encryption_test_case_5),
13215 		/** KASUMI decrypt only (UEA1) */
13216 		TEST_CASE_ST(ut_setup, ut_teardown,
13217 			test_kasumi_decryption_test_case_1),
13218 		TEST_CASE_ST(ut_setup, ut_teardown,
13219 			test_kasumi_decryption_test_case_2),
13220 		TEST_CASE_ST(ut_setup, ut_teardown,
13221 			test_kasumi_decryption_test_case_3),
13222 		TEST_CASE_ST(ut_setup, ut_teardown,
13223 			test_kasumi_decryption_test_case_4),
13224 		TEST_CASE_ST(ut_setup, ut_teardown,
13225 			test_kasumi_decryption_test_case_5),
13226 
13227 		TEST_CASE_ST(ut_setup, ut_teardown,
13228 			test_kasumi_encryption_test_case_1_oop),
13229 		TEST_CASE_ST(ut_setup, ut_teardown,
13230 			test_kasumi_encryption_test_case_1_oop_sgl),
13231 
13232 
13233 		TEST_CASE_ST(ut_setup, ut_teardown,
13234 			test_kasumi_decryption_test_case_1_oop),
13235 
13236 		/** KASUMI hash only (UIA1) */
13237 		TEST_CASE_ST(ut_setup, ut_teardown,
13238 			test_kasumi_hash_generate_test_case_1),
13239 		TEST_CASE_ST(ut_setup, ut_teardown,
13240 			test_kasumi_hash_generate_test_case_2),
13241 		TEST_CASE_ST(ut_setup, ut_teardown,
13242 			test_kasumi_hash_generate_test_case_3),
13243 		TEST_CASE_ST(ut_setup, ut_teardown,
13244 			test_kasumi_hash_generate_test_case_4),
13245 		TEST_CASE_ST(ut_setup, ut_teardown,
13246 			test_kasumi_hash_generate_test_case_5),
13247 		TEST_CASE_ST(ut_setup, ut_teardown,
13248 			test_kasumi_hash_generate_test_case_6),
13249 		TEST_CASE_ST(ut_setup, ut_teardown,
13250 			test_kasumi_hash_verify_test_case_1),
13251 		TEST_CASE_ST(ut_setup, ut_teardown,
13252 			test_kasumi_hash_verify_test_case_2),
13253 		TEST_CASE_ST(ut_setup, ut_teardown,
13254 			test_kasumi_hash_verify_test_case_3),
13255 		TEST_CASE_ST(ut_setup, ut_teardown,
13256 			test_kasumi_hash_verify_test_case_4),
13257 		TEST_CASE_ST(ut_setup, ut_teardown,
13258 			test_kasumi_hash_verify_test_case_5),
13259 		TEST_CASE_ST(ut_setup, ut_teardown,
13260 			test_kasumi_cipher_auth_test_case_1),
13261 
13262 		/** KASUMI generate auth, then encrypt (F8) */
13263 		TEST_CASE_ST(ut_setup, ut_teardown,
13264 			test_kasumi_auth_cipher_test_case_1),
13265 		TEST_CASE_ST(ut_setup, ut_teardown,
13266 			test_kasumi_auth_cipher_test_case_2),
13267 		TEST_CASE_ST(ut_setup, ut_teardown,
13268 			test_kasumi_auth_cipher_test_case_2_oop),
13269 		TEST_CASE_ST(ut_setup, ut_teardown,
13270 			test_kasumi_auth_cipher_test_case_2_sgl),
13271 		TEST_CASE_ST(ut_setup, ut_teardown,
13272 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
13273 
13274 		/** KASUMI decrypt (F8), then verify auth */
13275 		TEST_CASE_ST(ut_setup, ut_teardown,
13276 			test_kasumi_auth_cipher_verify_test_case_1),
13277 		TEST_CASE_ST(ut_setup, ut_teardown,
13278 			test_kasumi_auth_cipher_verify_test_case_2),
13279 		TEST_CASE_ST(ut_setup, ut_teardown,
13280 			test_kasumi_auth_cipher_verify_test_case_2_oop),
13281 		TEST_CASE_ST(ut_setup, ut_teardown,
13282 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
13283 		TEST_CASE_ST(ut_setup, ut_teardown,
13284 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13285 		TEST_CASES_END() /**< NULL terminate unit test array */
13286 	}
13287 };
13288 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
13289 	.suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
13290 	.setup = testsuite_setup,
13291 	.teardown = testsuite_teardown,
13292 	.unit_test_cases = {
13293 		/** SNOW 3G encrypt only (UEA2) */
13294 		TEST_CASE_ST(ut_setup, ut_teardown,
13295 			test_snow3g_encryption_test_case_1),
13296 		TEST_CASE_ST(ut_setup, ut_teardown,
13297 			test_snow3g_encryption_test_case_2),
13298 		TEST_CASE_ST(ut_setup, ut_teardown,
13299 			test_snow3g_encryption_test_case_3),
13300 		TEST_CASE_ST(ut_setup, ut_teardown,
13301 			test_snow3g_encryption_test_case_4),
13302 		TEST_CASE_ST(ut_setup, ut_teardown,
13303 			test_snow3g_encryption_test_case_5),
13304 		TEST_CASE_ST(ut_setup, ut_teardown,
13305 			test_snow3g_auth_cipher_with_digest_test_case_1),
13306 
13307 		TEST_CASE_ST(ut_setup, ut_teardown,
13308 			test_snow3g_encryption_test_case_1_oop),
13309 		TEST_CASE_ST(ut_setup, ut_teardown,
13310 				test_snow3g_encryption_test_case_1_oop_sgl),
13311 		TEST_CASE_ST(ut_setup, ut_teardown,
13312 			test_snow3g_decryption_test_case_1_oop),
13313 
13314 		TEST_CASE_ST(ut_setup, ut_teardown,
13315 			test_snow3g_encryption_test_case_1_offset_oop),
13316 
13317 		/** SNOW 3G decrypt only (UEA2) */
13318 		TEST_CASE_ST(ut_setup, ut_teardown,
13319 			test_snow3g_decryption_test_case_1),
13320 		TEST_CASE_ST(ut_setup, ut_teardown,
13321 			test_snow3g_decryption_test_case_2),
13322 		TEST_CASE_ST(ut_setup, ut_teardown,
13323 			test_snow3g_decryption_test_case_3),
13324 		TEST_CASE_ST(ut_setup, ut_teardown,
13325 			test_snow3g_decryption_test_case_4),
13326 		TEST_CASE_ST(ut_setup, ut_teardown,
13327 			test_snow3g_decryption_test_case_5),
13328 		TEST_CASE_ST(ut_setup, ut_teardown,
13329 			test_snow3g_decryption_with_digest_test_case_1),
13330 		TEST_CASE_ST(ut_setup, ut_teardown,
13331 			test_snow3g_hash_generate_test_case_1),
13332 		TEST_CASE_ST(ut_setup, ut_teardown,
13333 			test_snow3g_hash_generate_test_case_2),
13334 		TEST_CASE_ST(ut_setup, ut_teardown,
13335 			test_snow3g_hash_generate_test_case_3),
13336 		/* Tests with buffers which length is not byte-aligned */
13337 		TEST_CASE_ST(ut_setup, ut_teardown,
13338 			test_snow3g_hash_generate_test_case_4),
13339 		TEST_CASE_ST(ut_setup, ut_teardown,
13340 			test_snow3g_hash_generate_test_case_5),
13341 		TEST_CASE_ST(ut_setup, ut_teardown,
13342 			test_snow3g_hash_generate_test_case_6),
13343 		TEST_CASE_ST(ut_setup, ut_teardown,
13344 			test_snow3g_hash_verify_test_case_1),
13345 		TEST_CASE_ST(ut_setup, ut_teardown,
13346 			test_snow3g_hash_verify_test_case_2),
13347 		TEST_CASE_ST(ut_setup, ut_teardown,
13348 			test_snow3g_hash_verify_test_case_3),
13349 		/* Tests with buffers which length is not byte-aligned */
13350 		TEST_CASE_ST(ut_setup, ut_teardown,
13351 			test_snow3g_hash_verify_test_case_4),
13352 		TEST_CASE_ST(ut_setup, ut_teardown,
13353 			test_snow3g_hash_verify_test_case_5),
13354 		TEST_CASE_ST(ut_setup, ut_teardown,
13355 			test_snow3g_hash_verify_test_case_6),
13356 		TEST_CASE_ST(ut_setup, ut_teardown,
13357 			test_snow3g_cipher_auth_test_case_1),
13358 
13359 		/** SNOW 3G generate auth, then encrypt (UEA2) */
13360 		TEST_CASE_ST(ut_setup, ut_teardown,
13361 			test_snow3g_auth_cipher_test_case_1),
13362 		TEST_CASE_ST(ut_setup, ut_teardown,
13363 			test_snow3g_auth_cipher_test_case_2),
13364 		TEST_CASE_ST(ut_setup, ut_teardown,
13365 			test_snow3g_auth_cipher_test_case_2_oop),
13366 		TEST_CASE_ST(ut_setup, ut_teardown,
13367 			test_snow3g_auth_cipher_part_digest_enc),
13368 		TEST_CASE_ST(ut_setup, ut_teardown,
13369 			test_snow3g_auth_cipher_part_digest_enc_oop),
13370 		TEST_CASE_ST(ut_setup, ut_teardown,
13371 			test_snow3g_auth_cipher_test_case_3_sgl),
13372 		TEST_CASE_ST(ut_setup, ut_teardown,
13373 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
13374 		TEST_CASE_ST(ut_setup, ut_teardown,
13375 			test_snow3g_auth_cipher_part_digest_enc_sgl),
13376 		TEST_CASE_ST(ut_setup, ut_teardown,
13377 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13378 
13379 		/** SNOW 3G decrypt (UEA2), then verify auth */
13380 		TEST_CASE_ST(ut_setup, ut_teardown,
13381 			test_snow3g_auth_cipher_verify_test_case_1),
13382 		TEST_CASE_ST(ut_setup, ut_teardown,
13383 			test_snow3g_auth_cipher_verify_test_case_2),
13384 		TEST_CASE_ST(ut_setup, ut_teardown,
13385 			test_snow3g_auth_cipher_verify_test_case_2_oop),
13386 		TEST_CASE_ST(ut_setup, ut_teardown,
13387 			test_snow3g_auth_cipher_verify_part_digest_enc),
13388 		TEST_CASE_ST(ut_setup, ut_teardown,
13389 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13390 		TEST_CASE_ST(ut_setup, ut_teardown,
13391 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
13392 		TEST_CASE_ST(ut_setup, ut_teardown,
13393 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13394 		TEST_CASE_ST(ut_setup, ut_teardown,
13395 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13396 		TEST_CASE_ST(ut_setup, ut_teardown,
13397 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13398 
13399 		TEST_CASES_END() /**< NULL terminate unit test array */
13400 	}
13401 };
13402 
13403 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
13404 	.suite_name = "Crypto Device SW ZUC Unit Test Suite",
13405 	.setup = testsuite_setup,
13406 	.teardown = testsuite_teardown,
13407 	.unit_test_cases = {
13408 		/** ZUC encrypt only (EEA3) */
13409 		TEST_CASE_ST(ut_setup, ut_teardown,
13410 			test_zuc_encryption_test_case_1),
13411 		TEST_CASE_ST(ut_setup, ut_teardown,
13412 			test_zuc_encryption_test_case_2),
13413 		TEST_CASE_ST(ut_setup, ut_teardown,
13414 			test_zuc_encryption_test_case_3),
13415 		TEST_CASE_ST(ut_setup, ut_teardown,
13416 			test_zuc_encryption_test_case_4),
13417 		TEST_CASE_ST(ut_setup, ut_teardown,
13418 			test_zuc_encryption_test_case_5),
13419 		TEST_CASE_ST(ut_setup, ut_teardown,
13420 			test_zuc_hash_generate_test_case_1),
13421 		TEST_CASE_ST(ut_setup, ut_teardown,
13422 			test_zuc_hash_generate_test_case_2),
13423 		TEST_CASE_ST(ut_setup, ut_teardown,
13424 			test_zuc_hash_generate_test_case_3),
13425 		TEST_CASE_ST(ut_setup, ut_teardown,
13426 			test_zuc_hash_generate_test_case_4),
13427 		TEST_CASE_ST(ut_setup, ut_teardown,
13428 			test_zuc_hash_generate_test_case_5),
13429 		TEST_CASE_ST(ut_setup, ut_teardown,
13430 			test_zuc_encryption_test_case_6_sgl),
13431 		TEST_CASES_END() /**< NULL terminate unit test array */
13432 	}
13433 };
13434 
13435 static struct unit_test_suite cryptodev_caam_jr_testsuite  = {
13436 	.suite_name = "Crypto CAAM JR Unit Test Suite",
13437 	.setup = testsuite_setup,
13438 	.teardown = testsuite_teardown,
13439 	.unit_test_cases = {
13440 		TEST_CASE_ST(ut_setup, ut_teardown,
13441 			     test_device_configure_invalid_dev_id),
13442 		TEST_CASE_ST(ut_setup, ut_teardown,
13443 			     test_multi_session),
13444 
13445 		TEST_CASE_ST(ut_setup, ut_teardown,
13446 			     test_AES_chain_caam_jr_all),
13447 		TEST_CASE_ST(ut_setup, ut_teardown,
13448 			     test_3DES_chain_caam_jr_all),
13449 		TEST_CASE_ST(ut_setup, ut_teardown,
13450 			     test_AES_cipheronly_caam_jr_all),
13451 		TEST_CASE_ST(ut_setup, ut_teardown,
13452 			     test_3DES_cipheronly_caam_jr_all),
13453 		TEST_CASE_ST(ut_setup, ut_teardown,
13454 			     test_authonly_caam_jr_all),
13455 
13456 		TEST_CASES_END() /**< NULL terminate unit test array */
13457 	}
13458 };
13459 
13460 static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
13461 	.suite_name = "Crypto DPAA_SEC Unit Test Suite",
13462 	.setup = testsuite_setup,
13463 	.teardown = testsuite_teardown,
13464 	.unit_test_cases = {
13465 		TEST_CASE_ST(ut_setup, ut_teardown,
13466 			     test_device_configure_invalid_dev_id),
13467 		TEST_CASE_ST(ut_setup, ut_teardown,
13468 			     test_multi_session),
13469 
13470 		TEST_CASE_ST(ut_setup, ut_teardown,
13471 			     test_AES_chain_dpaa_sec_all),
13472 		TEST_CASE_ST(ut_setup, ut_teardown,
13473 			     test_3DES_chain_dpaa_sec_all),
13474 		TEST_CASE_ST(ut_setup, ut_teardown,
13475 			     test_AES_cipheronly_dpaa_sec_all),
13476 		TEST_CASE_ST(ut_setup, ut_teardown,
13477 			     test_3DES_cipheronly_dpaa_sec_all),
13478 		TEST_CASE_ST(ut_setup, ut_teardown,
13479 			     test_authonly_dpaa_sec_all),
13480 
13481 #ifdef RTE_LIBRTE_SECURITY
13482 		TEST_CASE_ST(ut_setup, ut_teardown,
13483 			test_PDCP_PROTO_cplane_encap_all),
13484 
13485 		TEST_CASE_ST(ut_setup, ut_teardown,
13486 			test_PDCP_PROTO_cplane_decap_all),
13487 
13488 		TEST_CASE_ST(ut_setup, ut_teardown,
13489 			test_PDCP_PROTO_uplane_encap_all),
13490 
13491 		TEST_CASE_ST(ut_setup, ut_teardown,
13492 			test_PDCP_PROTO_uplane_decap_all),
13493 
13494 		TEST_CASE_ST(ut_setup, ut_teardown,
13495 			test_PDCP_PROTO_SGL_in_place_32B),
13496 		TEST_CASE_ST(ut_setup, ut_teardown,
13497 			test_PDCP_PROTO_SGL_oop_32B_128B),
13498 		TEST_CASE_ST(ut_setup, ut_teardown,
13499 			test_PDCP_PROTO_SGL_oop_32B_40B),
13500 		TEST_CASE_ST(ut_setup, ut_teardown,
13501 			test_PDCP_PROTO_SGL_oop_128B_32B),
13502 #endif
13503 		/** AES GCM Authenticated Encryption */
13504 		TEST_CASE_ST(ut_setup, ut_teardown,
13505 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13506 		TEST_CASE_ST(ut_setup, ut_teardown,
13507 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13508 		TEST_CASE_ST(ut_setup, ut_teardown,
13509 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13510 		TEST_CASE_ST(ut_setup, ut_teardown,
13511 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13512 		TEST_CASE_ST(ut_setup, ut_teardown,
13513 			test_AES_GCM_authenticated_encryption_test_case_1),
13514 		TEST_CASE_ST(ut_setup, ut_teardown,
13515 			test_AES_GCM_authenticated_encryption_test_case_2),
13516 		TEST_CASE_ST(ut_setup, ut_teardown,
13517 			test_AES_GCM_authenticated_encryption_test_case_3),
13518 		TEST_CASE_ST(ut_setup, ut_teardown,
13519 			test_AES_GCM_authenticated_encryption_test_case_4),
13520 		TEST_CASE_ST(ut_setup, ut_teardown,
13521 			test_AES_GCM_authenticated_encryption_test_case_5),
13522 		TEST_CASE_ST(ut_setup, ut_teardown,
13523 			test_AES_GCM_authenticated_encryption_test_case_6),
13524 		TEST_CASE_ST(ut_setup, ut_teardown,
13525 			test_AES_GCM_authenticated_encryption_test_case_7),
13526 		TEST_CASE_ST(ut_setup, ut_teardown,
13527 			test_AES_GCM_authenticated_encryption_test_case_8),
13528 
13529 		/** AES GCM Authenticated Decryption */
13530 		TEST_CASE_ST(ut_setup, ut_teardown,
13531 			test_AES_GCM_authenticated_decryption_test_case_1),
13532 		TEST_CASE_ST(ut_setup, ut_teardown,
13533 			test_AES_GCM_authenticated_decryption_test_case_2),
13534 		TEST_CASE_ST(ut_setup, ut_teardown,
13535 			test_AES_GCM_authenticated_decryption_test_case_3),
13536 		TEST_CASE_ST(ut_setup, ut_teardown,
13537 			test_AES_GCM_authenticated_decryption_test_case_4),
13538 		TEST_CASE_ST(ut_setup, ut_teardown,
13539 			test_AES_GCM_authenticated_decryption_test_case_5),
13540 		TEST_CASE_ST(ut_setup, ut_teardown,
13541 			test_AES_GCM_authenticated_decryption_test_case_6),
13542 		TEST_CASE_ST(ut_setup, ut_teardown,
13543 			test_AES_GCM_authenticated_decryption_test_case_7),
13544 		TEST_CASE_ST(ut_setup, ut_teardown,
13545 			test_AES_GCM_authenticated_decryption_test_case_8),
13546 
13547 		/** AES GCM Authenticated Encryption 192 bits key */
13548 		TEST_CASE_ST(ut_setup, ut_teardown,
13549 			test_AES_GCM_auth_encryption_test_case_192_1),
13550 		TEST_CASE_ST(ut_setup, ut_teardown,
13551 			test_AES_GCM_auth_encryption_test_case_192_2),
13552 		TEST_CASE_ST(ut_setup, ut_teardown,
13553 			test_AES_GCM_auth_encryption_test_case_192_3),
13554 		TEST_CASE_ST(ut_setup, ut_teardown,
13555 			test_AES_GCM_auth_encryption_test_case_192_4),
13556 		TEST_CASE_ST(ut_setup, ut_teardown,
13557 			test_AES_GCM_auth_encryption_test_case_192_5),
13558 		TEST_CASE_ST(ut_setup, ut_teardown,
13559 			test_AES_GCM_auth_encryption_test_case_192_6),
13560 		TEST_CASE_ST(ut_setup, ut_teardown,
13561 			test_AES_GCM_auth_encryption_test_case_192_7),
13562 
13563 		/** AES GCM Authenticated Decryption 192 bits key */
13564 		TEST_CASE_ST(ut_setup, ut_teardown,
13565 			test_AES_GCM_auth_decryption_test_case_192_1),
13566 		TEST_CASE_ST(ut_setup, ut_teardown,
13567 			test_AES_GCM_auth_decryption_test_case_192_2),
13568 		TEST_CASE_ST(ut_setup, ut_teardown,
13569 			test_AES_GCM_auth_decryption_test_case_192_3),
13570 		TEST_CASE_ST(ut_setup, ut_teardown,
13571 			test_AES_GCM_auth_decryption_test_case_192_4),
13572 		TEST_CASE_ST(ut_setup, ut_teardown,
13573 			test_AES_GCM_auth_decryption_test_case_192_5),
13574 		TEST_CASE_ST(ut_setup, ut_teardown,
13575 			test_AES_GCM_auth_decryption_test_case_192_6),
13576 		TEST_CASE_ST(ut_setup, ut_teardown,
13577 			test_AES_GCM_auth_decryption_test_case_192_7),
13578 
13579 		/** AES GCM Authenticated Encryption 256 bits key */
13580 		TEST_CASE_ST(ut_setup, ut_teardown,
13581 			test_AES_GCM_auth_encryption_test_case_256_1),
13582 		TEST_CASE_ST(ut_setup, ut_teardown,
13583 			test_AES_GCM_auth_encryption_test_case_256_2),
13584 		TEST_CASE_ST(ut_setup, ut_teardown,
13585 			test_AES_GCM_auth_encryption_test_case_256_3),
13586 		TEST_CASE_ST(ut_setup, ut_teardown,
13587 			test_AES_GCM_auth_encryption_test_case_256_4),
13588 		TEST_CASE_ST(ut_setup, ut_teardown,
13589 			test_AES_GCM_auth_encryption_test_case_256_5),
13590 		TEST_CASE_ST(ut_setup, ut_teardown,
13591 			test_AES_GCM_auth_encryption_test_case_256_6),
13592 		TEST_CASE_ST(ut_setup, ut_teardown,
13593 			test_AES_GCM_auth_encryption_test_case_256_7),
13594 
13595 		/** AES GCM Authenticated Decryption 256 bits key */
13596 		TEST_CASE_ST(ut_setup, ut_teardown,
13597 			test_AES_GCM_auth_decryption_test_case_256_1),
13598 		TEST_CASE_ST(ut_setup, ut_teardown,
13599 			test_AES_GCM_auth_decryption_test_case_256_2),
13600 		TEST_CASE_ST(ut_setup, ut_teardown,
13601 			test_AES_GCM_auth_decryption_test_case_256_3),
13602 		TEST_CASE_ST(ut_setup, ut_teardown,
13603 			test_AES_GCM_auth_decryption_test_case_256_4),
13604 		TEST_CASE_ST(ut_setup, ut_teardown,
13605 			test_AES_GCM_auth_decryption_test_case_256_5),
13606 		TEST_CASE_ST(ut_setup, ut_teardown,
13607 			test_AES_GCM_auth_decryption_test_case_256_6),
13608 		TEST_CASE_ST(ut_setup, ut_teardown,
13609 			test_AES_GCM_auth_decryption_test_case_256_7),
13610 
13611 		/** Out of place tests */
13612 		TEST_CASE_ST(ut_setup, ut_teardown,
13613 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13614 		TEST_CASE_ST(ut_setup, ut_teardown,
13615 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13616 
13617 		/** SNOW 3G encrypt only (UEA2) */
13618 		TEST_CASE_ST(ut_setup, ut_teardown,
13619 			test_snow3g_encryption_test_case_1),
13620 		TEST_CASE_ST(ut_setup, ut_teardown,
13621 			test_snow3g_encryption_test_case_2),
13622 		TEST_CASE_ST(ut_setup, ut_teardown,
13623 			test_snow3g_encryption_test_case_3),
13624 		TEST_CASE_ST(ut_setup, ut_teardown,
13625 			test_snow3g_encryption_test_case_4),
13626 		TEST_CASE_ST(ut_setup, ut_teardown,
13627 			test_snow3g_encryption_test_case_5),
13628 
13629 		TEST_CASE_ST(ut_setup, ut_teardown,
13630 			test_snow3g_encryption_test_case_1_oop),
13631 		TEST_CASE_ST(ut_setup, ut_teardown,
13632 				test_snow3g_encryption_test_case_1_oop_sgl),
13633 		TEST_CASE_ST(ut_setup, ut_teardown,
13634 			test_snow3g_decryption_test_case_1_oop),
13635 
13636 		/** SNOW 3G decrypt only (UEA2) */
13637 		TEST_CASE_ST(ut_setup, ut_teardown,
13638 			test_snow3g_decryption_test_case_1),
13639 		TEST_CASE_ST(ut_setup, ut_teardown,
13640 			test_snow3g_decryption_test_case_2),
13641 		TEST_CASE_ST(ut_setup, ut_teardown,
13642 			test_snow3g_decryption_test_case_3),
13643 		TEST_CASE_ST(ut_setup, ut_teardown,
13644 			test_snow3g_decryption_test_case_4),
13645 		TEST_CASE_ST(ut_setup, ut_teardown,
13646 			test_snow3g_decryption_test_case_5),
13647 
13648 		TEST_CASE_ST(ut_setup, ut_teardown,
13649 			test_snow3g_hash_generate_test_case_1),
13650 		TEST_CASE_ST(ut_setup, ut_teardown,
13651 			test_snow3g_hash_generate_test_case_2),
13652 		TEST_CASE_ST(ut_setup, ut_teardown,
13653 			test_snow3g_hash_generate_test_case_3),
13654 		TEST_CASE_ST(ut_setup, ut_teardown,
13655 			test_snow3g_hash_verify_test_case_1),
13656 		TEST_CASE_ST(ut_setup, ut_teardown,
13657 			test_snow3g_hash_verify_test_case_2),
13658 		TEST_CASE_ST(ut_setup, ut_teardown,
13659 			test_snow3g_hash_verify_test_case_3),
13660 
13661 		/** ZUC encrypt only (EEA3) */
13662 		TEST_CASE_ST(ut_setup, ut_teardown,
13663 			test_zuc_encryption_test_case_1),
13664 		TEST_CASE_ST(ut_setup, ut_teardown,
13665 			test_zuc_encryption_test_case_2),
13666 		TEST_CASE_ST(ut_setup, ut_teardown,
13667 			test_zuc_encryption_test_case_3),
13668 		TEST_CASE_ST(ut_setup, ut_teardown,
13669 			test_zuc_encryption_test_case_4),
13670 		TEST_CASE_ST(ut_setup, ut_teardown,
13671 			test_zuc_encryption_test_case_5),
13672 
13673 		/** ZUC authenticate (EIA3) */
13674 		TEST_CASE_ST(ut_setup, ut_teardown,
13675 			test_zuc_hash_generate_test_case_6),
13676 		TEST_CASE_ST(ut_setup, ut_teardown,
13677 			test_zuc_hash_generate_test_case_7),
13678 		TEST_CASE_ST(ut_setup, ut_teardown,
13679 			test_zuc_hash_generate_test_case_8),
13680 
13681 		/** Negative tests */
13682 		TEST_CASE_ST(ut_setup, ut_teardown,
13683 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
13684 		TEST_CASE_ST(ut_setup, ut_teardown,
13685 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13686 		TEST_CASE_ST(ut_setup, ut_teardown,
13687 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13688 		TEST_CASE_ST(ut_setup, ut_teardown,
13689 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13690 		TEST_CASE_ST(ut_setup, ut_teardown,
13691 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
13692 		TEST_CASE_ST(ut_setup, ut_teardown,
13693 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
13694 		TEST_CASE_ST(ut_setup, ut_teardown,
13695 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
13696 		TEST_CASE_ST(ut_setup, ut_teardown,
13697 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13698 		TEST_CASE_ST(ut_setup, ut_teardown,
13699 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13700 		TEST_CASE_ST(ut_setup, ut_teardown,
13701 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13702 		TEST_CASE_ST(ut_setup, ut_teardown,
13703 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
13704 		TEST_CASE_ST(ut_setup, ut_teardown,
13705 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
13706 		TEST_CASE_ST(ut_setup, ut_teardown,
13707 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13708 		TEST_CASE_ST(ut_setup, ut_teardown,
13709 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13710 		TEST_CASE_ST(ut_setup, ut_teardown,
13711 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13712 		TEST_CASE_ST(ut_setup, ut_teardown,
13713 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13714 
13715 		/* ESN Testcase */
13716 		TEST_CASE_ST(ut_setup, ut_teardown,
13717 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13718 		TEST_CASE_ST(ut_setup, ut_teardown,
13719 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13720 
13721 		TEST_CASES_END() /**< NULL terminate unit test array */
13722 	}
13723 };
13724 
13725 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
13726 	.suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13727 	.setup = testsuite_setup,
13728 	.teardown = testsuite_teardown,
13729 	.unit_test_cases = {
13730 		TEST_CASE_ST(ut_setup, ut_teardown,
13731 			test_device_configure_invalid_dev_id),
13732 		TEST_CASE_ST(ut_setup, ut_teardown,
13733 			test_multi_session),
13734 		TEST_CASE_ST(ut_setup, ut_teardown,
13735 			test_AES_chain_dpaa2_sec_all),
13736 		TEST_CASE_ST(ut_setup, ut_teardown,
13737 			test_3DES_chain_dpaa2_sec_all),
13738 		TEST_CASE_ST(ut_setup, ut_teardown,
13739 			test_AES_cipheronly_dpaa2_sec_all),
13740 		TEST_CASE_ST(ut_setup, ut_teardown,
13741 			test_3DES_cipheronly_dpaa2_sec_all),
13742 		TEST_CASE_ST(ut_setup, ut_teardown,
13743 			test_authonly_dpaa2_sec_all),
13744 
13745 #ifdef RTE_LIBRTE_SECURITY
13746 		TEST_CASE_ST(ut_setup, ut_teardown,
13747 			test_PDCP_PROTO_cplane_encap_all),
13748 
13749 		TEST_CASE_ST(ut_setup, ut_teardown,
13750 			test_PDCP_PROTO_cplane_decap_all),
13751 
13752 		TEST_CASE_ST(ut_setup, ut_teardown,
13753 			test_PDCP_PROTO_uplane_encap_all),
13754 
13755 		TEST_CASE_ST(ut_setup, ut_teardown,
13756 			test_PDCP_PROTO_uplane_decap_all),
13757 
13758 		TEST_CASE_ST(ut_setup, ut_teardown,
13759 			test_PDCP_PROTO_SGL_in_place_32B),
13760 		TEST_CASE_ST(ut_setup, ut_teardown,
13761 			test_PDCP_PROTO_SGL_oop_32B_128B),
13762 		TEST_CASE_ST(ut_setup, ut_teardown,
13763 			test_PDCP_PROTO_SGL_oop_32B_40B),
13764 		TEST_CASE_ST(ut_setup, ut_teardown,
13765 			test_PDCP_PROTO_SGL_oop_128B_32B),
13766 #endif
13767 		/** AES GCM Authenticated Encryption */
13768 		TEST_CASE_ST(ut_setup, ut_teardown,
13769 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13770 		TEST_CASE_ST(ut_setup, ut_teardown,
13771 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13772 		TEST_CASE_ST(ut_setup, ut_teardown,
13773 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13774 		TEST_CASE_ST(ut_setup, ut_teardown,
13775 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13776 		TEST_CASE_ST(ut_setup, ut_teardown,
13777 			test_AES_GCM_authenticated_encryption_test_case_1),
13778 		TEST_CASE_ST(ut_setup, ut_teardown,
13779 			test_AES_GCM_authenticated_encryption_test_case_2),
13780 		TEST_CASE_ST(ut_setup, ut_teardown,
13781 			test_AES_GCM_authenticated_encryption_test_case_3),
13782 		TEST_CASE_ST(ut_setup, ut_teardown,
13783 			test_AES_GCM_authenticated_encryption_test_case_4),
13784 		TEST_CASE_ST(ut_setup, ut_teardown,
13785 			test_AES_GCM_authenticated_encryption_test_case_5),
13786 		TEST_CASE_ST(ut_setup, ut_teardown,
13787 			test_AES_GCM_authenticated_encryption_test_case_6),
13788 		TEST_CASE_ST(ut_setup, ut_teardown,
13789 			test_AES_GCM_authenticated_encryption_test_case_7),
13790 		TEST_CASE_ST(ut_setup, ut_teardown,
13791 			test_AES_GCM_authenticated_encryption_test_case_8),
13792 
13793 		/** AES GCM Authenticated Decryption */
13794 		TEST_CASE_ST(ut_setup, ut_teardown,
13795 			test_AES_GCM_authenticated_decryption_test_case_1),
13796 		TEST_CASE_ST(ut_setup, ut_teardown,
13797 			test_AES_GCM_authenticated_decryption_test_case_2),
13798 		TEST_CASE_ST(ut_setup, ut_teardown,
13799 			test_AES_GCM_authenticated_decryption_test_case_3),
13800 		TEST_CASE_ST(ut_setup, ut_teardown,
13801 			test_AES_GCM_authenticated_decryption_test_case_4),
13802 		TEST_CASE_ST(ut_setup, ut_teardown,
13803 			test_AES_GCM_authenticated_decryption_test_case_5),
13804 		TEST_CASE_ST(ut_setup, ut_teardown,
13805 			test_AES_GCM_authenticated_decryption_test_case_6),
13806 		TEST_CASE_ST(ut_setup, ut_teardown,
13807 			test_AES_GCM_authenticated_decryption_test_case_7),
13808 		TEST_CASE_ST(ut_setup, ut_teardown,
13809 			test_AES_GCM_authenticated_decryption_test_case_8),
13810 
13811 		/** AES GCM Authenticated Encryption 192 bits key */
13812 		TEST_CASE_ST(ut_setup, ut_teardown,
13813 			test_AES_GCM_auth_encryption_test_case_192_1),
13814 		TEST_CASE_ST(ut_setup, ut_teardown,
13815 			test_AES_GCM_auth_encryption_test_case_192_2),
13816 		TEST_CASE_ST(ut_setup, ut_teardown,
13817 			test_AES_GCM_auth_encryption_test_case_192_3),
13818 		TEST_CASE_ST(ut_setup, ut_teardown,
13819 			test_AES_GCM_auth_encryption_test_case_192_4),
13820 		TEST_CASE_ST(ut_setup, ut_teardown,
13821 			test_AES_GCM_auth_encryption_test_case_192_5),
13822 		TEST_CASE_ST(ut_setup, ut_teardown,
13823 			test_AES_GCM_auth_encryption_test_case_192_6),
13824 		TEST_CASE_ST(ut_setup, ut_teardown,
13825 			test_AES_GCM_auth_encryption_test_case_192_7),
13826 
13827 		/** AES GCM Authenticated Decryption 192 bits key */
13828 		TEST_CASE_ST(ut_setup, ut_teardown,
13829 			test_AES_GCM_auth_decryption_test_case_192_1),
13830 		TEST_CASE_ST(ut_setup, ut_teardown,
13831 			test_AES_GCM_auth_decryption_test_case_192_2),
13832 		TEST_CASE_ST(ut_setup, ut_teardown,
13833 			test_AES_GCM_auth_decryption_test_case_192_3),
13834 		TEST_CASE_ST(ut_setup, ut_teardown,
13835 			test_AES_GCM_auth_decryption_test_case_192_4),
13836 		TEST_CASE_ST(ut_setup, ut_teardown,
13837 			test_AES_GCM_auth_decryption_test_case_192_5),
13838 		TEST_CASE_ST(ut_setup, ut_teardown,
13839 			test_AES_GCM_auth_decryption_test_case_192_6),
13840 		TEST_CASE_ST(ut_setup, ut_teardown,
13841 			test_AES_GCM_auth_decryption_test_case_192_7),
13842 
13843 		/** AES GCM Authenticated Encryption 256 bits key */
13844 		TEST_CASE_ST(ut_setup, ut_teardown,
13845 			test_AES_GCM_auth_encryption_test_case_256_1),
13846 		TEST_CASE_ST(ut_setup, ut_teardown,
13847 			test_AES_GCM_auth_encryption_test_case_256_2),
13848 		TEST_CASE_ST(ut_setup, ut_teardown,
13849 			test_AES_GCM_auth_encryption_test_case_256_3),
13850 		TEST_CASE_ST(ut_setup, ut_teardown,
13851 			test_AES_GCM_auth_encryption_test_case_256_4),
13852 		TEST_CASE_ST(ut_setup, ut_teardown,
13853 			test_AES_GCM_auth_encryption_test_case_256_5),
13854 		TEST_CASE_ST(ut_setup, ut_teardown,
13855 			test_AES_GCM_auth_encryption_test_case_256_6),
13856 		TEST_CASE_ST(ut_setup, ut_teardown,
13857 			test_AES_GCM_auth_encryption_test_case_256_7),
13858 
13859 		/** AES GCM Authenticated Decryption 256 bits key */
13860 		TEST_CASE_ST(ut_setup, ut_teardown,
13861 			test_AES_GCM_auth_decryption_test_case_256_1),
13862 		TEST_CASE_ST(ut_setup, ut_teardown,
13863 			test_AES_GCM_auth_decryption_test_case_256_2),
13864 		TEST_CASE_ST(ut_setup, ut_teardown,
13865 			test_AES_GCM_auth_decryption_test_case_256_3),
13866 		TEST_CASE_ST(ut_setup, ut_teardown,
13867 			test_AES_GCM_auth_decryption_test_case_256_4),
13868 		TEST_CASE_ST(ut_setup, ut_teardown,
13869 			test_AES_GCM_auth_decryption_test_case_256_5),
13870 		TEST_CASE_ST(ut_setup, ut_teardown,
13871 			test_AES_GCM_auth_decryption_test_case_256_6),
13872 		TEST_CASE_ST(ut_setup, ut_teardown,
13873 			test_AES_GCM_auth_decryption_test_case_256_7),
13874 
13875 		/** Out of place tests */
13876 		TEST_CASE_ST(ut_setup, ut_teardown,
13877 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13878 		TEST_CASE_ST(ut_setup, ut_teardown,
13879 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13880 
13881 		/** SNOW 3G encrypt only (UEA2) */
13882 		TEST_CASE_ST(ut_setup, ut_teardown,
13883 			test_snow3g_encryption_test_case_1),
13884 		TEST_CASE_ST(ut_setup, ut_teardown,
13885 			test_snow3g_encryption_test_case_2),
13886 		TEST_CASE_ST(ut_setup, ut_teardown,
13887 			test_snow3g_encryption_test_case_3),
13888 		TEST_CASE_ST(ut_setup, ut_teardown,
13889 			test_snow3g_encryption_test_case_4),
13890 		TEST_CASE_ST(ut_setup, ut_teardown,
13891 			test_snow3g_encryption_test_case_5),
13892 
13893 		TEST_CASE_ST(ut_setup, ut_teardown,
13894 			test_snow3g_encryption_test_case_1_oop),
13895 		TEST_CASE_ST(ut_setup, ut_teardown,
13896 				test_snow3g_encryption_test_case_1_oop_sgl),
13897 		TEST_CASE_ST(ut_setup, ut_teardown,
13898 			test_snow3g_decryption_test_case_1_oop),
13899 
13900 		/** SNOW 3G decrypt only (UEA2) */
13901 		TEST_CASE_ST(ut_setup, ut_teardown,
13902 			test_snow3g_decryption_test_case_1),
13903 		TEST_CASE_ST(ut_setup, ut_teardown,
13904 			test_snow3g_decryption_test_case_2),
13905 		TEST_CASE_ST(ut_setup, ut_teardown,
13906 			test_snow3g_decryption_test_case_3),
13907 		TEST_CASE_ST(ut_setup, ut_teardown,
13908 			test_snow3g_decryption_test_case_4),
13909 		TEST_CASE_ST(ut_setup, ut_teardown,
13910 			test_snow3g_decryption_test_case_5),
13911 
13912 		TEST_CASE_ST(ut_setup, ut_teardown,
13913 			test_snow3g_hash_generate_test_case_1),
13914 		TEST_CASE_ST(ut_setup, ut_teardown,
13915 			test_snow3g_hash_generate_test_case_2),
13916 		TEST_CASE_ST(ut_setup, ut_teardown,
13917 			test_snow3g_hash_generate_test_case_3),
13918 		TEST_CASE_ST(ut_setup, ut_teardown,
13919 			test_snow3g_hash_verify_test_case_1),
13920 		TEST_CASE_ST(ut_setup, ut_teardown,
13921 			test_snow3g_hash_verify_test_case_2),
13922 		TEST_CASE_ST(ut_setup, ut_teardown,
13923 			test_snow3g_hash_verify_test_case_3),
13924 
13925 		/** ZUC encrypt only (EEA3) */
13926 		TEST_CASE_ST(ut_setup, ut_teardown,
13927 			test_zuc_encryption_test_case_1),
13928 		TEST_CASE_ST(ut_setup, ut_teardown,
13929 			test_zuc_encryption_test_case_2),
13930 		TEST_CASE_ST(ut_setup, ut_teardown,
13931 			test_zuc_encryption_test_case_3),
13932 		TEST_CASE_ST(ut_setup, ut_teardown,
13933 			test_zuc_encryption_test_case_4),
13934 		TEST_CASE_ST(ut_setup, ut_teardown,
13935 			test_zuc_encryption_test_case_5),
13936 
13937 		/** ZUC authenticate (EIA3) */
13938 		TEST_CASE_ST(ut_setup, ut_teardown,
13939 			test_zuc_hash_generate_test_case_6),
13940 		TEST_CASE_ST(ut_setup, ut_teardown,
13941 			test_zuc_hash_generate_test_case_7),
13942 		TEST_CASE_ST(ut_setup, ut_teardown,
13943 			test_zuc_hash_generate_test_case_8),
13944 
13945 		/** HMAC_MD5 Authentication */
13946 		TEST_CASE_ST(ut_setup, ut_teardown,
13947 			test_MD5_HMAC_generate_case_1),
13948 		TEST_CASE_ST(ut_setup, ut_teardown,
13949 			test_MD5_HMAC_verify_case_1),
13950 		TEST_CASE_ST(ut_setup, ut_teardown,
13951 			test_MD5_HMAC_generate_case_2),
13952 		TEST_CASE_ST(ut_setup, ut_teardown,
13953 			test_MD5_HMAC_verify_case_2),
13954 
13955 		/** Negative tests */
13956 		TEST_CASE_ST(ut_setup, ut_teardown,
13957 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
13958 		TEST_CASE_ST(ut_setup, ut_teardown,
13959 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13960 		TEST_CASE_ST(ut_setup, ut_teardown,
13961 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13962 		TEST_CASE_ST(ut_setup, ut_teardown,
13963 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13964 		TEST_CASE_ST(ut_setup, ut_teardown,
13965 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
13966 		TEST_CASE_ST(ut_setup, ut_teardown,
13967 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
13968 		TEST_CASE_ST(ut_setup, ut_teardown,
13969 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
13970 		TEST_CASE_ST(ut_setup, ut_teardown,
13971 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13972 		TEST_CASE_ST(ut_setup, ut_teardown,
13973 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13974 		TEST_CASE_ST(ut_setup, ut_teardown,
13975 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13976 		TEST_CASE_ST(ut_setup, ut_teardown,
13977 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
13978 		TEST_CASE_ST(ut_setup, ut_teardown,
13979 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
13980 		TEST_CASE_ST(ut_setup, ut_teardown,
13981 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13982 		TEST_CASE_ST(ut_setup, ut_teardown,
13983 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13984 		TEST_CASE_ST(ut_setup, ut_teardown,
13985 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13986 		TEST_CASE_ST(ut_setup, ut_teardown,
13987 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13988 
13989 		/* ESN Testcase */
13990 		TEST_CASE_ST(ut_setup, ut_teardown,
13991 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13992 
13993 		TEST_CASE_ST(ut_setup, ut_teardown,
13994 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13995 
13996 		TEST_CASES_END() /**< NULL terminate unit test array */
13997 	}
13998 };
13999 
14000 static struct unit_test_suite cryptodev_null_testsuite  = {
14001 	.suite_name = "Crypto Device NULL Unit Test Suite",
14002 	.setup = testsuite_setup,
14003 	.teardown = testsuite_teardown,
14004 	.unit_test_cases = {
14005 		TEST_CASE_ST(ut_setup, ut_teardown,
14006 			test_null_invalid_operation),
14007 		TEST_CASE_ST(ut_setup, ut_teardown,
14008 			test_null_burst_operation),
14009 		TEST_CASE_ST(ut_setup, ut_teardown,
14010 			test_AES_chain_null_all),
14011 		TEST_CASE_ST(ut_setup, ut_teardown,
14012 			test_AES_cipheronly_null_all),
14013 		TEST_CASE_ST(ut_setup, ut_teardown,
14014 				test_authonly_null_all),
14015 
14016 		TEST_CASES_END() /**< NULL terminate unit test array */
14017 	}
14018 };
14019 
14020 static struct unit_test_suite cryptodev_armv8_testsuite  = {
14021 	.suite_name = "Crypto Device ARMv8 Unit Test Suite",
14022 	.setup = testsuite_setup,
14023 	.teardown = testsuite_teardown,
14024 	.unit_test_cases = {
14025 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
14026 
14027 		/** Negative tests */
14028 		TEST_CASE_ST(ut_setup, ut_teardown,
14029 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14030 		TEST_CASE_ST(ut_setup, ut_teardown,
14031 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14032 
14033 		TEST_CASES_END() /**< NULL terminate unit test array */
14034 	}
14035 };
14036 
14037 static struct unit_test_suite cryptodev_mrvl_testsuite  = {
14038 	.suite_name = "Crypto Device Marvell Component Test Suite",
14039 	.setup = testsuite_setup,
14040 	.teardown = testsuite_teardown,
14041 	.unit_test_cases = {
14042 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14043 		TEST_CASE_ST(ut_setup, ut_teardown,
14044 				test_multi_session_random_usage),
14045 		TEST_CASE_ST(ut_setup, ut_teardown,
14046 				test_AES_chain_mrvl_all),
14047 		TEST_CASE_ST(ut_setup, ut_teardown,
14048 				test_AES_cipheronly_mrvl_all),
14049 		TEST_CASE_ST(ut_setup, ut_teardown,
14050 				test_authonly_mrvl_all),
14051 		TEST_CASE_ST(ut_setup, ut_teardown,
14052 				test_3DES_chain_mrvl_all),
14053 		TEST_CASE_ST(ut_setup, ut_teardown,
14054 				test_3DES_cipheronly_mrvl_all),
14055 
14056 		/** Negative tests */
14057 		TEST_CASE_ST(ut_setup, ut_teardown,
14058 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14059 		TEST_CASE_ST(ut_setup, ut_teardown,
14060 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14061 		TEST_CASE_ST(ut_setup, ut_teardown,
14062 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14063 		TEST_CASE_ST(ut_setup, ut_teardown,
14064 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14065 
14066 		TEST_CASES_END() /**< NULL terminate unit test array */
14067 	}
14068 };
14069 
14070 static struct unit_test_suite cryptodev_ccp_testsuite  = {
14071 	.suite_name = "Crypto Device CCP Unit Test Suite",
14072 	.setup = testsuite_setup,
14073 	.teardown = testsuite_teardown,
14074 	.unit_test_cases = {
14075 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14076 		TEST_CASE_ST(ut_setup, ut_teardown,
14077 				test_multi_session_random_usage),
14078 		TEST_CASE_ST(ut_setup, ut_teardown,
14079 				test_AES_chain_ccp_all),
14080 		TEST_CASE_ST(ut_setup, ut_teardown,
14081 				test_AES_cipheronly_ccp_all),
14082 		TEST_CASE_ST(ut_setup, ut_teardown,
14083 				test_3DES_chain_ccp_all),
14084 		TEST_CASE_ST(ut_setup, ut_teardown,
14085 				test_3DES_cipheronly_ccp_all),
14086 		TEST_CASE_ST(ut_setup, ut_teardown,
14087 				test_authonly_ccp_all),
14088 
14089 		/** Negative tests */
14090 		TEST_CASE_ST(ut_setup, ut_teardown,
14091 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14092 		TEST_CASE_ST(ut_setup, ut_teardown,
14093 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14094 		TEST_CASE_ST(ut_setup, ut_teardown,
14095 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14096 		TEST_CASE_ST(ut_setup, ut_teardown,
14097 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14098 
14099 		TEST_CASES_END() /**< NULL terminate unit test array */
14100 	}
14101 };
14102 
14103 static struct unit_test_suite cryptodev_octeontx_testsuite  = {
14104 	.suite_name = "Crypto Device OCTEONTX Unit Test Suite",
14105 	.setup = testsuite_setup,
14106 	.teardown = testsuite_teardown,
14107 	.unit_test_cases = {
14108 		TEST_CASE_ST(ut_setup, ut_teardown,
14109 			test_AES_chain_octeontx_all),
14110 		TEST_CASE_ST(ut_setup, ut_teardown,
14111 			test_AES_cipheronly_octeontx_all),
14112 		TEST_CASE_ST(ut_setup, ut_teardown,
14113 			test_3DES_chain_octeontx_all),
14114 		TEST_CASE_ST(ut_setup, ut_teardown,
14115 			test_3DES_cipheronly_octeontx_all),
14116 		TEST_CASE_ST(ut_setup, ut_teardown,
14117 			test_authonly_octeontx_all),
14118 
14119 		/** AES GCM Authenticated Encryption */
14120 		TEST_CASE_ST(ut_setup, ut_teardown,
14121 			test_AES_GCM_authenticated_encryption_test_case_1),
14122 		TEST_CASE_ST(ut_setup, ut_teardown,
14123 			test_AES_GCM_authenticated_encryption_test_case_2),
14124 		TEST_CASE_ST(ut_setup, ut_teardown,
14125 			test_AES_GCM_authenticated_encryption_test_case_3),
14126 		TEST_CASE_ST(ut_setup, ut_teardown,
14127 			test_AES_GCM_authenticated_encryption_test_case_4),
14128 		TEST_CASE_ST(ut_setup, ut_teardown,
14129 			test_AES_GCM_authenticated_encryption_test_case_5),
14130 		TEST_CASE_ST(ut_setup, ut_teardown,
14131 			test_AES_GCM_authenticated_encryption_test_case_6),
14132 		TEST_CASE_ST(ut_setup, ut_teardown,
14133 			test_AES_GCM_authenticated_encryption_test_case_7),
14134 
14135 		/** AES GCM Authenticated Decryption */
14136 		TEST_CASE_ST(ut_setup, ut_teardown,
14137 			test_AES_GCM_authenticated_decryption_test_case_1),
14138 		TEST_CASE_ST(ut_setup, ut_teardown,
14139 			test_AES_GCM_authenticated_decryption_test_case_2),
14140 		TEST_CASE_ST(ut_setup, ut_teardown,
14141 			test_AES_GCM_authenticated_decryption_test_case_3),
14142 		TEST_CASE_ST(ut_setup, ut_teardown,
14143 			test_AES_GCM_authenticated_decryption_test_case_4),
14144 		TEST_CASE_ST(ut_setup, ut_teardown,
14145 			test_AES_GCM_authenticated_decryption_test_case_5),
14146 		TEST_CASE_ST(ut_setup, ut_teardown,
14147 			test_AES_GCM_authenticated_decryption_test_case_6),
14148 		TEST_CASE_ST(ut_setup, ut_teardown,
14149 			test_AES_GCM_authenticated_decryption_test_case_7),
14150 		/** AES GMAC Authentication */
14151 		TEST_CASE_ST(ut_setup, ut_teardown,
14152 			test_AES_GMAC_authentication_test_case_1),
14153 		TEST_CASE_ST(ut_setup, ut_teardown,
14154 			test_AES_GMAC_authentication_verify_test_case_1),
14155 		TEST_CASE_ST(ut_setup, ut_teardown,
14156 			test_AES_GMAC_authentication_test_case_2),
14157 		TEST_CASE_ST(ut_setup, ut_teardown,
14158 			test_AES_GMAC_authentication_verify_test_case_2),
14159 		TEST_CASE_ST(ut_setup, ut_teardown,
14160 			test_AES_GMAC_authentication_test_case_3),
14161 		TEST_CASE_ST(ut_setup, ut_teardown,
14162 			test_AES_GMAC_authentication_verify_test_case_3),
14163 
14164 		/** SNOW 3G encrypt only (UEA2) */
14165 		TEST_CASE_ST(ut_setup, ut_teardown,
14166 			test_snow3g_encryption_test_case_1),
14167 		TEST_CASE_ST(ut_setup, ut_teardown,
14168 			test_snow3g_encryption_test_case_2),
14169 		TEST_CASE_ST(ut_setup, ut_teardown,
14170 			test_snow3g_encryption_test_case_3),
14171 		TEST_CASE_ST(ut_setup, ut_teardown,
14172 			test_snow3g_encryption_test_case_4),
14173 		TEST_CASE_ST(ut_setup, ut_teardown,
14174 			test_snow3g_encryption_test_case_5),
14175 
14176 		TEST_CASE_ST(ut_setup, ut_teardown,
14177 			test_snow3g_encryption_test_case_1_oop),
14178 		TEST_CASE_ST(ut_setup, ut_teardown,
14179 			test_snow3g_decryption_test_case_1_oop),
14180 		TEST_CASE_ST(ut_setup, ut_teardown,
14181 			test_snow3g_encryption_test_case_1_oop_sgl),
14182 
14183 		/** SNOW 3G decrypt only (UEA2) */
14184 		TEST_CASE_ST(ut_setup, ut_teardown,
14185 			test_snow3g_decryption_test_case_1),
14186 		TEST_CASE_ST(ut_setup, ut_teardown,
14187 			test_snow3g_decryption_test_case_2),
14188 		TEST_CASE_ST(ut_setup, ut_teardown,
14189 			test_snow3g_decryption_test_case_3),
14190 		TEST_CASE_ST(ut_setup, ut_teardown,
14191 			test_snow3g_decryption_test_case_4),
14192 		TEST_CASE_ST(ut_setup, ut_teardown,
14193 			test_snow3g_decryption_test_case_5),
14194 
14195 		TEST_CASE_ST(ut_setup, ut_teardown,
14196 			test_snow3g_hash_generate_test_case_1),
14197 		TEST_CASE_ST(ut_setup, ut_teardown,
14198 			test_snow3g_hash_generate_test_case_2),
14199 		TEST_CASE_ST(ut_setup, ut_teardown,
14200 			test_snow3g_hash_generate_test_case_3),
14201 		TEST_CASE_ST(ut_setup, ut_teardown,
14202 			test_snow3g_hash_verify_test_case_1),
14203 		TEST_CASE_ST(ut_setup, ut_teardown,
14204 			test_snow3g_hash_verify_test_case_2),
14205 		TEST_CASE_ST(ut_setup, ut_teardown,
14206 			test_snow3g_hash_verify_test_case_3),
14207 
14208 		/** ZUC encrypt only (EEA3) */
14209 		TEST_CASE_ST(ut_setup, ut_teardown,
14210 			test_zuc_encryption_test_case_1),
14211 		TEST_CASE_ST(ut_setup, ut_teardown,
14212 			test_zuc_encryption_test_case_2),
14213 		TEST_CASE_ST(ut_setup, ut_teardown,
14214 			test_zuc_encryption_test_case_3),
14215 		TEST_CASE_ST(ut_setup, ut_teardown,
14216 			test_zuc_encryption_test_case_4),
14217 		TEST_CASE_ST(ut_setup, ut_teardown,
14218 			test_zuc_encryption_test_case_5),
14219 		TEST_CASE_ST(ut_setup, ut_teardown,
14220 			test_zuc_hash_generate_test_case_1),
14221 		TEST_CASE_ST(ut_setup, ut_teardown,
14222 			test_zuc_hash_generate_test_case_2),
14223 		TEST_CASE_ST(ut_setup, ut_teardown,
14224 			test_zuc_hash_generate_test_case_3),
14225 		TEST_CASE_ST(ut_setup, ut_teardown,
14226 			test_zuc_hash_generate_test_case_4),
14227 		TEST_CASE_ST(ut_setup, ut_teardown,
14228 			test_zuc_hash_generate_test_case_5),
14229 		TEST_CASE_ST(ut_setup, ut_teardown,
14230 			test_zuc_encryption_test_case_6_sgl),
14231 
14232 		/** KASUMI encrypt only (UEA1) */
14233 		TEST_CASE_ST(ut_setup, ut_teardown,
14234 			test_kasumi_encryption_test_case_1),
14235 		TEST_CASE_ST(ut_setup, ut_teardown,
14236 			test_kasumi_encryption_test_case_2),
14237 		TEST_CASE_ST(ut_setup, ut_teardown,
14238 			test_kasumi_encryption_test_case_3),
14239 		TEST_CASE_ST(ut_setup, ut_teardown,
14240 			test_kasumi_encryption_test_case_4),
14241 		TEST_CASE_ST(ut_setup, ut_teardown,
14242 			test_kasumi_encryption_test_case_5),
14243 		TEST_CASE_ST(ut_setup, ut_teardown,
14244 			test_kasumi_encryption_test_case_1_sgl),
14245 		TEST_CASE_ST(ut_setup, ut_teardown,
14246 			test_kasumi_encryption_test_case_1_oop_sgl),
14247 		/** KASUMI decrypt only (UEA1) */
14248 		TEST_CASE_ST(ut_setup, ut_teardown,
14249 			test_kasumi_decryption_test_case_1),
14250 		TEST_CASE_ST(ut_setup, ut_teardown,
14251 			test_kasumi_decryption_test_case_2),
14252 		TEST_CASE_ST(ut_setup, ut_teardown,
14253 			test_kasumi_decryption_test_case_3),
14254 		TEST_CASE_ST(ut_setup, ut_teardown,
14255 			test_kasumi_decryption_test_case_4),
14256 		TEST_CASE_ST(ut_setup, ut_teardown,
14257 			test_kasumi_decryption_test_case_5),
14258 
14259 		TEST_CASE_ST(ut_setup, ut_teardown,
14260 			test_kasumi_encryption_test_case_1_oop),
14261 		TEST_CASE_ST(ut_setup, ut_teardown,
14262 			test_kasumi_decryption_test_case_1_oop),
14263 
14264 		/** KASUMI hash only (UIA1) */
14265 		TEST_CASE_ST(ut_setup, ut_teardown,
14266 			test_kasumi_hash_generate_test_case_1),
14267 		TEST_CASE_ST(ut_setup, ut_teardown,
14268 			test_kasumi_hash_generate_test_case_2),
14269 		TEST_CASE_ST(ut_setup, ut_teardown,
14270 			test_kasumi_hash_generate_test_case_3),
14271 		TEST_CASE_ST(ut_setup, ut_teardown,
14272 			test_kasumi_hash_generate_test_case_4),
14273 		TEST_CASE_ST(ut_setup, ut_teardown,
14274 			test_kasumi_hash_generate_test_case_5),
14275 		TEST_CASE_ST(ut_setup, ut_teardown,
14276 			test_kasumi_hash_generate_test_case_6),
14277 		TEST_CASE_ST(ut_setup, ut_teardown,
14278 			test_kasumi_hash_verify_test_case_1),
14279 		TEST_CASE_ST(ut_setup, ut_teardown,
14280 			test_kasumi_hash_verify_test_case_2),
14281 		TEST_CASE_ST(ut_setup, ut_teardown,
14282 			test_kasumi_hash_verify_test_case_3),
14283 		TEST_CASE_ST(ut_setup, ut_teardown,
14284 			test_kasumi_hash_verify_test_case_4),
14285 		TEST_CASE_ST(ut_setup, ut_teardown,
14286 			test_kasumi_hash_verify_test_case_5),
14287 
14288 		/** NULL tests */
14289 		TEST_CASE_ST(ut_setup, ut_teardown,
14290 			test_null_cipher_only_operation),
14291 		TEST_CASE_ST(ut_setup, ut_teardown,
14292 			test_null_auth_only_operation),
14293 		TEST_CASE_ST(ut_setup, ut_teardown,
14294 			test_null_cipher_auth_operation),
14295 		TEST_CASE_ST(ut_setup, ut_teardown,
14296 			test_null_auth_cipher_operation),
14297 
14298 		/** Negative tests */
14299 		TEST_CASE_ST(ut_setup, ut_teardown,
14300 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14301 		TEST_CASE_ST(ut_setup, ut_teardown,
14302 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14303 		TEST_CASE_ST(ut_setup, ut_teardown,
14304 			authentication_verify_AES128_GMAC_fail_data_corrupt),
14305 		TEST_CASE_ST(ut_setup, ut_teardown,
14306 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
14307 		TEST_CASE_ST(ut_setup, ut_teardown,
14308 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14309 		TEST_CASE_ST(ut_setup, ut_teardown,
14310 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14311 		TEST_CASES_END() /**< NULL terminate unit test array */
14312 	}
14313 };
14314 
14315 static struct unit_test_suite cryptodev_nitrox_testsuite  = {
14316 	.suite_name = "Crypto NITROX Unit Test Suite",
14317 	.setup = testsuite_setup,
14318 	.teardown = testsuite_teardown,
14319 	.unit_test_cases = {
14320 		TEST_CASE_ST(ut_setup, ut_teardown,
14321 			     test_device_configure_invalid_dev_id),
14322 		TEST_CASE_ST(ut_setup, ut_teardown,
14323 				test_device_configure_invalid_queue_pair_ids),
14324 		TEST_CASE_ST(ut_setup, ut_teardown,
14325 			     test_AES_chain_nitrox_all),
14326 
14327 		TEST_CASES_END() /**< NULL terminate unit test array */
14328 	}
14329 };
14330 
14331 static struct unit_test_suite cryptodev_octeontx2_testsuite  = {
14332 	.suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
14333 	.setup = testsuite_setup,
14334 	.teardown = testsuite_teardown,
14335 	.unit_test_cases = {
14336 		TEST_CASE_ST(ut_setup, ut_teardown,
14337 			test_AES_chain_octeontx2_all),
14338 		TEST_CASE_ST(ut_setup, ut_teardown,
14339 			test_AES_cipheronly_octeontx2_all),
14340 		TEST_CASE_ST(ut_setup, ut_teardown,
14341 			test_3DES_chain_octeontx2_all),
14342 		TEST_CASE_ST(ut_setup, ut_teardown,
14343 			test_3DES_cipheronly_octeontx2_all),
14344 		TEST_CASE_ST(ut_setup, ut_teardown,
14345 			test_authonly_octeontx2_all),
14346 
14347 		/** AES GCM Authenticated Encryption */
14348 		TEST_CASE_ST(ut_setup, ut_teardown,
14349 			test_AES_GCM_authenticated_encryption_test_case_1),
14350 		TEST_CASE_ST(ut_setup, ut_teardown,
14351 			test_AES_GCM_authenticated_encryption_test_case_2),
14352 		TEST_CASE_ST(ut_setup, ut_teardown,
14353 			test_AES_GCM_authenticated_encryption_test_case_3),
14354 		TEST_CASE_ST(ut_setup, ut_teardown,
14355 			test_AES_GCM_authenticated_encryption_test_case_4),
14356 		TEST_CASE_ST(ut_setup, ut_teardown,
14357 			test_AES_GCM_authenticated_encryption_test_case_5),
14358 		TEST_CASE_ST(ut_setup, ut_teardown,
14359 			test_AES_GCM_authenticated_encryption_test_case_6),
14360 		TEST_CASE_ST(ut_setup, ut_teardown,
14361 			test_AES_GCM_authenticated_encryption_test_case_7),
14362 
14363 		/** AES GCM Authenticated Decryption */
14364 		TEST_CASE_ST(ut_setup, ut_teardown,
14365 			test_AES_GCM_authenticated_decryption_test_case_1),
14366 		TEST_CASE_ST(ut_setup, ut_teardown,
14367 			test_AES_GCM_authenticated_decryption_test_case_2),
14368 		TEST_CASE_ST(ut_setup, ut_teardown,
14369 			test_AES_GCM_authenticated_decryption_test_case_3),
14370 		TEST_CASE_ST(ut_setup, ut_teardown,
14371 			test_AES_GCM_authenticated_decryption_test_case_4),
14372 		TEST_CASE_ST(ut_setup, ut_teardown,
14373 			test_AES_GCM_authenticated_decryption_test_case_5),
14374 		TEST_CASE_ST(ut_setup, ut_teardown,
14375 			test_AES_GCM_authenticated_decryption_test_case_6),
14376 		TEST_CASE_ST(ut_setup, ut_teardown,
14377 			test_AES_GCM_authenticated_decryption_test_case_7),
14378 		/** AES GMAC Authentication */
14379 		TEST_CASE_ST(ut_setup, ut_teardown,
14380 			test_AES_GMAC_authentication_test_case_1),
14381 		TEST_CASE_ST(ut_setup, ut_teardown,
14382 			test_AES_GMAC_authentication_verify_test_case_1),
14383 		TEST_CASE_ST(ut_setup, ut_teardown,
14384 			test_AES_GMAC_authentication_test_case_2),
14385 		TEST_CASE_ST(ut_setup, ut_teardown,
14386 			test_AES_GMAC_authentication_verify_test_case_2),
14387 		TEST_CASE_ST(ut_setup, ut_teardown,
14388 			test_AES_GMAC_authentication_test_case_3),
14389 		TEST_CASE_ST(ut_setup, ut_teardown,
14390 			test_AES_GMAC_authentication_verify_test_case_3),
14391 
14392 		/** SNOW 3G encrypt only (UEA2) */
14393 		TEST_CASE_ST(ut_setup, ut_teardown,
14394 			test_snow3g_encryption_test_case_1),
14395 		TEST_CASE_ST(ut_setup, ut_teardown,
14396 			test_snow3g_encryption_test_case_2),
14397 		TEST_CASE_ST(ut_setup, ut_teardown,
14398 			test_snow3g_encryption_test_case_3),
14399 		TEST_CASE_ST(ut_setup, ut_teardown,
14400 			test_snow3g_encryption_test_case_4),
14401 		TEST_CASE_ST(ut_setup, ut_teardown,
14402 			test_snow3g_encryption_test_case_5),
14403 
14404 		TEST_CASE_ST(ut_setup, ut_teardown,
14405 			test_snow3g_encryption_test_case_1_oop),
14406 		TEST_CASE_ST(ut_setup, ut_teardown,
14407 			test_snow3g_decryption_test_case_1_oop),
14408 		TEST_CASE_ST(ut_setup, ut_teardown,
14409 			test_snow3g_encryption_test_case_1_oop_sgl),
14410 
14411 		/** SNOW 3G decrypt only (UEA2) */
14412 		TEST_CASE_ST(ut_setup, ut_teardown,
14413 			test_snow3g_decryption_test_case_1),
14414 		TEST_CASE_ST(ut_setup, ut_teardown,
14415 			test_snow3g_decryption_test_case_2),
14416 		TEST_CASE_ST(ut_setup, ut_teardown,
14417 			test_snow3g_decryption_test_case_3),
14418 		TEST_CASE_ST(ut_setup, ut_teardown,
14419 			test_snow3g_decryption_test_case_4),
14420 		TEST_CASE_ST(ut_setup, ut_teardown,
14421 			test_snow3g_decryption_test_case_5),
14422 
14423 		TEST_CASE_ST(ut_setup, ut_teardown,
14424 			test_snow3g_hash_generate_test_case_1),
14425 		TEST_CASE_ST(ut_setup, ut_teardown,
14426 			test_snow3g_hash_generate_test_case_2),
14427 		TEST_CASE_ST(ut_setup, ut_teardown,
14428 			test_snow3g_hash_generate_test_case_3),
14429 		TEST_CASE_ST(ut_setup, ut_teardown,
14430 			test_snow3g_hash_verify_test_case_1),
14431 		TEST_CASE_ST(ut_setup, ut_teardown,
14432 			test_snow3g_hash_verify_test_case_2),
14433 		TEST_CASE_ST(ut_setup, ut_teardown,
14434 			test_snow3g_hash_verify_test_case_3),
14435 
14436 		/** ZUC encrypt only (EEA3) */
14437 		TEST_CASE_ST(ut_setup, ut_teardown,
14438 			test_zuc_encryption_test_case_1),
14439 		TEST_CASE_ST(ut_setup, ut_teardown,
14440 			test_zuc_encryption_test_case_2),
14441 		TEST_CASE_ST(ut_setup, ut_teardown,
14442 			test_zuc_encryption_test_case_3),
14443 		TEST_CASE_ST(ut_setup, ut_teardown,
14444 			test_zuc_encryption_test_case_4),
14445 		TEST_CASE_ST(ut_setup, ut_teardown,
14446 			test_zuc_encryption_test_case_5),
14447 		TEST_CASE_ST(ut_setup, ut_teardown,
14448 			test_zuc_hash_generate_test_case_1),
14449 		TEST_CASE_ST(ut_setup, ut_teardown,
14450 			test_zuc_hash_generate_test_case_2),
14451 		TEST_CASE_ST(ut_setup, ut_teardown,
14452 			test_zuc_hash_generate_test_case_3),
14453 		TEST_CASE_ST(ut_setup, ut_teardown,
14454 			test_zuc_hash_generate_test_case_4),
14455 		TEST_CASE_ST(ut_setup, ut_teardown,
14456 			test_zuc_hash_generate_test_case_5),
14457 		TEST_CASE_ST(ut_setup, ut_teardown,
14458 			test_zuc_encryption_test_case_6_sgl),
14459 
14460 		/** KASUMI encrypt only (UEA1) */
14461 		TEST_CASE_ST(ut_setup, ut_teardown,
14462 			test_kasumi_encryption_test_case_1),
14463 		TEST_CASE_ST(ut_setup, ut_teardown,
14464 			test_kasumi_encryption_test_case_2),
14465 		TEST_CASE_ST(ut_setup, ut_teardown,
14466 			test_kasumi_encryption_test_case_3),
14467 		TEST_CASE_ST(ut_setup, ut_teardown,
14468 			test_kasumi_encryption_test_case_4),
14469 		TEST_CASE_ST(ut_setup, ut_teardown,
14470 			test_kasumi_encryption_test_case_5),
14471 		TEST_CASE_ST(ut_setup, ut_teardown,
14472 			test_kasumi_encryption_test_case_1_sgl),
14473 		TEST_CASE_ST(ut_setup, ut_teardown,
14474 			test_kasumi_encryption_test_case_1_oop_sgl),
14475 		/** KASUMI decrypt only (UEA1) */
14476 		TEST_CASE_ST(ut_setup, ut_teardown,
14477 			test_kasumi_decryption_test_case_1),
14478 		TEST_CASE_ST(ut_setup, ut_teardown,
14479 			test_kasumi_decryption_test_case_2),
14480 		TEST_CASE_ST(ut_setup, ut_teardown,
14481 			test_kasumi_decryption_test_case_3),
14482 		TEST_CASE_ST(ut_setup, ut_teardown,
14483 			test_kasumi_decryption_test_case_4),
14484 		TEST_CASE_ST(ut_setup, ut_teardown,
14485 			test_kasumi_decryption_test_case_5),
14486 
14487 		TEST_CASE_ST(ut_setup, ut_teardown,
14488 			test_kasumi_encryption_test_case_1_oop),
14489 		TEST_CASE_ST(ut_setup, ut_teardown,
14490 			test_kasumi_decryption_test_case_1_oop),
14491 
14492 		/** KASUMI hash only (UIA1) */
14493 		TEST_CASE_ST(ut_setup, ut_teardown,
14494 			test_kasumi_hash_generate_test_case_1),
14495 		TEST_CASE_ST(ut_setup, ut_teardown,
14496 			test_kasumi_hash_generate_test_case_2),
14497 		TEST_CASE_ST(ut_setup, ut_teardown,
14498 			test_kasumi_hash_generate_test_case_3),
14499 		TEST_CASE_ST(ut_setup, ut_teardown,
14500 			test_kasumi_hash_generate_test_case_4),
14501 		TEST_CASE_ST(ut_setup, ut_teardown,
14502 			test_kasumi_hash_generate_test_case_5),
14503 		TEST_CASE_ST(ut_setup, ut_teardown,
14504 			test_kasumi_hash_generate_test_case_6),
14505 		TEST_CASE_ST(ut_setup, ut_teardown,
14506 			test_kasumi_hash_verify_test_case_1),
14507 		TEST_CASE_ST(ut_setup, ut_teardown,
14508 			test_kasumi_hash_verify_test_case_2),
14509 		TEST_CASE_ST(ut_setup, ut_teardown,
14510 			test_kasumi_hash_verify_test_case_3),
14511 		TEST_CASE_ST(ut_setup, ut_teardown,
14512 			test_kasumi_hash_verify_test_case_4),
14513 		TEST_CASE_ST(ut_setup, ut_teardown,
14514 			test_kasumi_hash_verify_test_case_5),
14515 
14516 		/** NULL tests */
14517 		TEST_CASE_ST(ut_setup, ut_teardown,
14518 			test_null_cipher_only_operation),
14519 		TEST_CASE_ST(ut_setup, ut_teardown,
14520 			test_null_auth_only_operation),
14521 		TEST_CASE_ST(ut_setup, ut_teardown,
14522 			test_null_cipher_auth_operation),
14523 		TEST_CASE_ST(ut_setup, ut_teardown,
14524 			test_null_auth_cipher_operation),
14525 
14526 		/** Negative tests */
14527 		TEST_CASE_ST(ut_setup, ut_teardown,
14528 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
14529 		TEST_CASE_ST(ut_setup, ut_teardown,
14530 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14531 		TEST_CASE_ST(ut_setup, ut_teardown,
14532 			authentication_verify_AES128_GMAC_fail_data_corrupt),
14533 		TEST_CASE_ST(ut_setup, ut_teardown,
14534 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
14535 		TEST_CASE_ST(ut_setup, ut_teardown,
14536 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14537 		TEST_CASE_ST(ut_setup, ut_teardown,
14538 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14539 		TEST_CASES_END() /**< NULL terminate unit test array */
14540 	}
14541 };
14542 
14543 static int
14544 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14545 {
14546 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14547 			RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14548 
14549 	if (gbl_driver_id == -1) {
14550 		RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14551 		"CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14552 		"are enabled in config file to run this testsuite.\n");
14553 		return TEST_SKIPPED;
14554 	}
14555 
14556 	return unit_test_suite_runner(&cryptodev_qat_testsuite);
14557 }
14558 
14559 static int
14560 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14561 {
14562 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14563 			RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14564 
14565 	if (gbl_driver_id == -1) {
14566 		RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14567 				"CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14568 				"in config file to run this testsuite.\n");
14569 		return TEST_FAILED;
14570 	}
14571 
14572 	return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14573 }
14574 
14575 static int
14576 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14577 {
14578 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14579 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14580 
14581 	if (gbl_driver_id == -1) {
14582 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14583 				"CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14584 				"in config file to run this testsuite.\n");
14585 		return TEST_SKIPPED;
14586 	}
14587 
14588 	return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14589 }
14590 
14591 static int
14592 test_cryptodev_openssl(void)
14593 {
14594 	gbl_driver_id = rte_cryptodev_driver_id_get(
14595 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14596 
14597 	if (gbl_driver_id == -1) {
14598 		RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14599 				"CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14600 				"in config file to run this testsuite.\n");
14601 		return TEST_SKIPPED;
14602 	}
14603 
14604 	return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14605 }
14606 
14607 static int
14608 test_cryptodev_aesni_gcm(void)
14609 {
14610 	gbl_driver_id = rte_cryptodev_driver_id_get(
14611 			RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14612 
14613 	if (gbl_driver_id == -1) {
14614 		RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14615 				"CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14616 				"in config file to run this testsuite.\n");
14617 		return TEST_SKIPPED;
14618 	}
14619 
14620 	return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14621 }
14622 
14623 static int
14624 test_cryptodev_null(void)
14625 {
14626 	gbl_driver_id = rte_cryptodev_driver_id_get(
14627 			RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14628 
14629 	if (gbl_driver_id == -1) {
14630 		RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14631 				"CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14632 				"in config file to run this testsuite.\n");
14633 		return TEST_SKIPPED;
14634 	}
14635 
14636 	return unit_test_suite_runner(&cryptodev_null_testsuite);
14637 }
14638 
14639 static int
14640 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14641 {
14642 	gbl_driver_id = rte_cryptodev_driver_id_get(
14643 			RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14644 
14645 	if (gbl_driver_id == -1) {
14646 		RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14647 				"CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14648 				"in config file to run this testsuite.\n");
14649 		return TEST_SKIPPED;
14650 	}
14651 
14652 	return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14653 }
14654 
14655 static int
14656 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14657 {
14658 	gbl_driver_id = rte_cryptodev_driver_id_get(
14659 			RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14660 
14661 	if (gbl_driver_id == -1) {
14662 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14663 				"CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14664 				"in config file to run this testsuite.\n");
14665 		return TEST_SKIPPED;
14666 	}
14667 
14668 	return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14669 }
14670 
14671 static int
14672 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14673 {
14674 	gbl_driver_id = rte_cryptodev_driver_id_get(
14675 			RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14676 
14677 	if (gbl_driver_id == -1) {
14678 		RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14679 				"CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14680 				"in config file to run this testsuite.\n");
14681 		return TEST_SKIPPED;
14682 	}
14683 
14684 	return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14685 }
14686 
14687 static int
14688 test_cryptodev_armv8(void)
14689 {
14690 	gbl_driver_id = rte_cryptodev_driver_id_get(
14691 			RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14692 
14693 	if (gbl_driver_id == -1) {
14694 		RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14695 				"CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14696 				"in config file to run this testsuite.\n");
14697 		return TEST_SKIPPED;
14698 	}
14699 
14700 	return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14701 }
14702 
14703 static int
14704 test_cryptodev_mrvl(void)
14705 {
14706 	gbl_driver_id = rte_cryptodev_driver_id_get(
14707 			RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14708 
14709 	if (gbl_driver_id == -1) {
14710 		RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14711 				"CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14712 				"in config file to run this testsuite.\n");
14713 		return TEST_SKIPPED;
14714 	}
14715 
14716 	return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14717 }
14718 
14719 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14720 
14721 static int
14722 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14723 {
14724 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14725 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14726 
14727 	if (gbl_driver_id == -1) {
14728 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14729 				"CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14730 				"in config file to run this testsuite.\n");
14731 		return TEST_SKIPPED;
14732 	}
14733 
14734 	if (rte_cryptodev_driver_id_get(
14735 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14736 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14737 			" enabled in config file to run this testsuite.\n");
14738 		return TEST_SKIPPED;
14739 }
14740 	return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14741 }
14742 
14743 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14744 
14745 #endif
14746 
14747 static int
14748 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14749 {
14750 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14751 			RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14752 
14753 	if (gbl_driver_id == -1) {
14754 		RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14755 				"CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14756 				"in config file to run this testsuite.\n");
14757 		return TEST_SKIPPED;
14758 	}
14759 
14760 	return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14761 }
14762 
14763 static int
14764 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14765 {
14766 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14767 			RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14768 
14769 	if (gbl_driver_id == -1) {
14770 		RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14771 				"CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14772 				"in config file to run this testsuite.\n");
14773 		return TEST_SKIPPED;
14774 	}
14775 
14776 	return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14777 }
14778 
14779 static int
14780 test_cryptodev_ccp(void)
14781 {
14782 	gbl_driver_id = rte_cryptodev_driver_id_get(
14783 			RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14784 
14785 	if (gbl_driver_id == -1) {
14786 		RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14787 				"CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14788 				"in config file to run this testsuite.\n");
14789 		return TEST_FAILED;
14790 	}
14791 
14792 	return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14793 }
14794 
14795 static int
14796 test_cryptodev_octeontx(void)
14797 {
14798 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14799 			RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14800 	if (gbl_driver_id == -1) {
14801 		RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14802 				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14803 				"enabled in config file to run this "
14804 				"testsuite.\n");
14805 		return TEST_FAILED;
14806 	}
14807 	return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14808 }
14809 
14810 static int
14811 test_cryptodev_octeontx2(void)
14812 {
14813 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14814 			RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14815 	if (gbl_driver_id == -1) {
14816 		RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14817 				"CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14818 				"enabled in config file to run this "
14819 				"testsuite.\n");
14820 		return TEST_FAILED;
14821 	}
14822 	return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14823 }
14824 
14825 static int
14826 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14827 {
14828 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14829 			RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14830 
14831 	if (gbl_driver_id == -1) {
14832 		RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14833 				"CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14834 				"in config file to run this testsuite.\n");
14835 		return TEST_FAILED;
14836 	}
14837 
14838 	return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14839 }
14840 
14841 static int
14842 test_cryptodev_nitrox(void)
14843 {
14844 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14845 			RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14846 
14847 	if (gbl_driver_id == -1) {
14848 		RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14849 				"CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14850 				"in config file to run this testsuite.\n");
14851 		return TEST_FAILED;
14852 	}
14853 
14854 	return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14855 }
14856 
14857 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14858 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14859 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14860 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14861 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14862 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14863 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14864 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14865 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14866 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14867 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14868 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14869 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14870 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14871 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14872 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14873 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14874 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14875