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