xref: /dpdk/app/test/test_cryptodev.c (revision 21c0a80e11bbf3405c849fc68a794a08ce1a732c)
1 /*-
2  *   BSD LICENSE
3  *
4  *   Copyright(c) 2015-2016 Intel Corporation. All rights reserved.
5  *
6  *   Redistribution and use in source and binary forms, with or without
7  *   modification, are permitted provided that the following conditions
8  *   are met:
9  *
10  *	 * Redistributions of source code must retain the above copyright
11  *	   notice, this list of conditions and the following disclaimer.
12  *	 * Redistributions in binary form must reproduce the above copyright
13  *	   notice, this list of conditions and the following disclaimer in
14  *	   the documentation and/or other materials provided with the
15  *	   distribution.
16  *	 * Neither the name of Intel Corporation nor the names of its
17  *	   contributors may be used to endorse or promote products derived
18  *	   from this software without specific prior written permission.
19  *
20  *   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  *   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22  *   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
23  *   A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
24  *   OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
25  *   SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
26  *   LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27  *   DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28  *   THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29  *   (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30  *   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 #include <rte_common.h>
34 #include <rte_hexdump.h>
35 #include <rte_mbuf.h>
36 #include <rte_malloc.h>
37 #include <rte_memcpy.h>
38 
39 #include <rte_crypto.h>
40 #include <rte_cryptodev.h>
41 #include <rte_cryptodev_pmd.h>
42 
43 #include "test.h"
44 #include "test_cryptodev.h"
45 
46 #include "test_cryptodev_blockcipher.h"
47 #include "test_cryptodev_aes_test_vectors.h"
48 #include "test_cryptodev_des_test_vectors.h"
49 #include "test_cryptodev_hash_test_vectors.h"
50 #include "test_cryptodev_kasumi_test_vectors.h"
51 #include "test_cryptodev_kasumi_hash_test_vectors.h"
52 #include "test_cryptodev_snow3g_test_vectors.h"
53 #include "test_cryptodev_snow3g_hash_test_vectors.h"
54 #include "test_cryptodev_zuc_test_vectors.h"
55 #include "test_cryptodev_zuc_hash_test_vectors.h"
56 #include "test_cryptodev_gcm_test_vectors.h"
57 #include "test_cryptodev_hmac_test_vectors.h"
58 
59 static enum rte_cryptodev_type gbl_cryptodev_type;
60 
61 struct crypto_testsuite_params {
62 	struct rte_mempool *mbuf_pool;
63 	struct rte_mempool *large_mbuf_pool;
64 	struct rte_mempool *op_mpool;
65 	struct rte_cryptodev_config conf;
66 	struct rte_cryptodev_qp_conf qp_conf;
67 
68 	uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
69 	uint8_t valid_dev_count;
70 };
71 
72 struct crypto_unittest_params {
73 	struct rte_crypto_sym_xform cipher_xform;
74 	struct rte_crypto_sym_xform auth_xform;
75 
76 	struct rte_cryptodev_sym_session *sess;
77 
78 	struct rte_crypto_op *op;
79 
80 	struct rte_mbuf *obuf, *ibuf;
81 
82 	uint8_t *digest;
83 };
84 
85 #define ALIGN_POW2_ROUNDUP(num, align) \
86 	(((num) + (align) - 1) & ~((align) - 1))
87 
88 /*
89  * Forward declarations.
90  */
91 static int
92 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
93 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
94 		uint8_t *hmac_key);
95 
96 static int
97 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
98 		struct crypto_unittest_params *ut_params,
99 		struct crypto_testsuite_params *ts_param,
100 		const uint8_t *cipher,
101 		const uint8_t *digest,
102 		const uint8_t *iv);
103 
104 static struct rte_mbuf *
105 setup_test_string(struct rte_mempool *mpool,
106 		const char *string, size_t len, uint8_t blocksize)
107 {
108 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
109 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
110 
111 	memset(m->buf_addr, 0, m->buf_len);
112 	if (m) {
113 		char *dst = rte_pktmbuf_append(m, t_len);
114 
115 		if (!dst) {
116 			rte_pktmbuf_free(m);
117 			return NULL;
118 		}
119 		if (string != NULL)
120 			rte_memcpy(dst, string, t_len);
121 		else
122 			memset(dst, 0, t_len);
123 	}
124 
125 	return m;
126 }
127 
128 /* Get number of bytes in X bits (rounding up) */
129 static uint32_t
130 ceil_byte_length(uint32_t num_bits)
131 {
132 	if (num_bits % 8)
133 		return ((num_bits >> 3) + 1);
134 	else
135 		return (num_bits >> 3);
136 }
137 
138 static struct rte_crypto_op *
139 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
140 {
141 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
142 		printf("Error sending packet for encryption");
143 		return NULL;
144 	}
145 
146 	op = NULL;
147 
148 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
149 		rte_pause();
150 
151 	return op;
152 }
153 
154 static struct crypto_testsuite_params testsuite_params = { NULL };
155 static struct crypto_unittest_params unittest_params;
156 
157 static int
158 testsuite_setup(void)
159 {
160 	struct crypto_testsuite_params *ts_params = &testsuite_params;
161 	struct rte_cryptodev_info info;
162 	unsigned i, nb_devs, dev_id;
163 	int ret;
164 	uint16_t qp_id;
165 
166 	memset(ts_params, 0, sizeof(*ts_params));
167 
168 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
169 	if (ts_params->mbuf_pool == NULL) {
170 		/* Not already created so create */
171 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
172 				"CRYPTO_MBUFPOOL",
173 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
174 				rte_socket_id());
175 		if (ts_params->mbuf_pool == NULL) {
176 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
177 			return TEST_FAILED;
178 		}
179 	}
180 
181 	ts_params->large_mbuf_pool = rte_mempool_lookup(
182 			"CRYPTO_LARGE_MBUFPOOL");
183 	if (ts_params->large_mbuf_pool == NULL) {
184 		/* Not already created so create */
185 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
186 				"CRYPTO_LARGE_MBUFPOOL",
187 				1, 0, 0, UINT16_MAX,
188 				rte_socket_id());
189 		if (ts_params->large_mbuf_pool == NULL) {
190 			RTE_LOG(ERR, USER1,
191 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
192 			return TEST_FAILED;
193 		}
194 	}
195 
196 	ts_params->op_mpool = rte_crypto_op_pool_create(
197 			"MBUF_CRYPTO_SYM_OP_POOL",
198 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
199 			NUM_MBUFS, MBUF_CACHE_SIZE,
200 			DEFAULT_NUM_XFORMS *
201 			sizeof(struct rte_crypto_sym_xform),
202 			rte_socket_id());
203 	if (ts_params->op_mpool == NULL) {
204 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
205 		return TEST_FAILED;
206 	}
207 
208 	/* Create 2 AESNI MB devices if required */
209 	if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD) {
210 #ifndef RTE_LIBRTE_PMD_AESNI_MB
211 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
212 			" enabled in config file to run this testsuite.\n");
213 		return TEST_FAILED;
214 #endif
215 		nb_devs = rte_cryptodev_count_devtype(
216 				RTE_CRYPTODEV_AESNI_MB_PMD);
217 		if (nb_devs < 2) {
218 			for (i = nb_devs; i < 2; i++) {
219 				ret = rte_eal_vdev_init(
220 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
221 
222 				TEST_ASSERT(ret == 0,
223 					"Failed to create instance %u of"
224 					" pmd : %s",
225 					i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
226 			}
227 		}
228 	}
229 
230 	/* Create 2 AESNI GCM devices if required */
231 	if (gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_GCM_PMD) {
232 #ifndef RTE_LIBRTE_PMD_AESNI_GCM
233 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM must be"
234 			" enabled in config file to run this testsuite.\n");
235 		return TEST_FAILED;
236 #endif
237 		nb_devs = rte_cryptodev_count_devtype(
238 				RTE_CRYPTODEV_AESNI_GCM_PMD);
239 		if (nb_devs < 2) {
240 			for (i = nb_devs; i < 2; i++) {
241 				TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
242 					RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
243 					"Failed to create instance %u of"
244 					" pmd : %s",
245 					i, RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
246 			}
247 		}
248 	}
249 
250 	/* Create 2 SNOW 3G devices if required */
251 	if (gbl_cryptodev_type == RTE_CRYPTODEV_SNOW3G_PMD) {
252 #ifndef RTE_LIBRTE_PMD_SNOW3G
253 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_SNOW3G must be"
254 			" enabled in config file to run this testsuite.\n");
255 		return TEST_FAILED;
256 #endif
257 		nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_SNOW3G_PMD);
258 		if (nb_devs < 2) {
259 			for (i = nb_devs; i < 2; i++) {
260 				TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
261 					RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
262 					"Failed to create instance %u of"
263 					" pmd : %s",
264 					i, RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
265 			}
266 		}
267 	}
268 
269 	/* Create 2 KASUMI devices if required */
270 	if (gbl_cryptodev_type == RTE_CRYPTODEV_KASUMI_PMD) {
271 #ifndef RTE_LIBRTE_PMD_KASUMI
272 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_KASUMI must be"
273 			" enabled in config file to run this testsuite.\n");
274 		return TEST_FAILED;
275 #endif
276 		nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_KASUMI_PMD);
277 		if (nb_devs < 2) {
278 			for (i = nb_devs; i < 2; i++) {
279 				TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
280 					RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
281 					"Failed to create instance %u of"
282 					" pmd : %s",
283 					i, RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
284 			}
285 		}
286 	}
287 
288 	/* Create 2 ZUC devices if required */
289 	if (gbl_cryptodev_type == RTE_CRYPTODEV_ZUC_PMD) {
290 #ifndef RTE_LIBRTE_PMD_ZUC
291 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_ZUC must be"
292 			" enabled in config file to run this testsuite.\n");
293 		return TEST_FAILED;
294 #endif
295 		nb_devs = rte_cryptodev_count_devtype(RTE_CRYPTODEV_ZUC_PMD);
296 		if (nb_devs < 2) {
297 			for (i = nb_devs; i < 2; i++) {
298 				TEST_ASSERT_SUCCESS(rte_eal_vdev_init(
299 					RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
300 					"Failed to create instance %u of"
301 					" pmd : %s",
302 					i, RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
303 			}
304 		}
305 	}
306 
307 	/* Create 2 NULL devices if required */
308 	if (gbl_cryptodev_type == RTE_CRYPTODEV_NULL_PMD) {
309 #ifndef RTE_LIBRTE_PMD_NULL_CRYPTO
310 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_NULL_CRYPTO must be"
311 			" enabled in config file to run this testsuite.\n");
312 		return TEST_FAILED;
313 #endif
314 		nb_devs = rte_cryptodev_count_devtype(
315 				RTE_CRYPTODEV_NULL_PMD);
316 		if (nb_devs < 2) {
317 			for (i = nb_devs; i < 2; i++) {
318 				int dev_id = rte_eal_vdev_init(
319 					RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
320 
321 				TEST_ASSERT(dev_id >= 0,
322 					"Failed to create instance %u of"
323 					" pmd : %s",
324 					i, RTE_STR(CRYPTODEV_NAME_NULL_PMD));
325 			}
326 		}
327 	}
328 
329 	/* Create 2 OPENSSL devices if required */
330 	if (gbl_cryptodev_type == RTE_CRYPTODEV_OPENSSL_PMD) {
331 #ifndef RTE_LIBRTE_PMD_OPENSSL
332 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_OPENSSL must be"
333 			" enabled in config file to run this testsuite.\n");
334 		return TEST_FAILED;
335 #endif
336 		nb_devs = rte_cryptodev_count_devtype(
337 				RTE_CRYPTODEV_OPENSSL_PMD);
338 		if (nb_devs < 2) {
339 			for (i = nb_devs; i < 2; i++) {
340 				ret = rte_eal_vdev_init(
341 					RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
342 					NULL);
343 
344 				TEST_ASSERT(ret == 0, "Failed to create "
345 					"instance %u of pmd : %s", i,
346 					RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
347 			}
348 		}
349 	}
350 
351 #ifndef RTE_LIBRTE_PMD_QAT
352 	if (gbl_cryptodev_type == RTE_CRYPTODEV_QAT_SYM_PMD) {
353 		RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_QAT must be enabled "
354 				"in config file to run this testsuite.\n");
355 		return TEST_FAILED;
356 	}
357 #endif
358 
359 	nb_devs = rte_cryptodev_count();
360 	if (nb_devs < 1) {
361 		RTE_LOG(ERR, USER1, "No crypto devices found?\n");
362 		return TEST_FAILED;
363 	}
364 
365 	/* Create list of valid crypto devs */
366 	for (i = 0; i < nb_devs; i++) {
367 		rte_cryptodev_info_get(i, &info);
368 		if (info.dev_type == gbl_cryptodev_type)
369 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
370 	}
371 
372 	if (ts_params->valid_dev_count < 1)
373 		return TEST_FAILED;
374 
375 	/* Set up all the qps on the first of the valid devices found */
376 
377 	dev_id = ts_params->valid_devs[0];
378 
379 	rte_cryptodev_info_get(dev_id, &info);
380 
381 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
382 	ts_params->conf.socket_id = SOCKET_ID_ANY;
383 	ts_params->conf.session_mp.nb_objs = info.sym.max_nb_sessions;
384 
385 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
386 			&ts_params->conf),
387 			"Failed to configure cryptodev %u with %u qps",
388 			dev_id, ts_params->conf.nb_queue_pairs);
389 
390 	ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
391 
392 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
393 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
394 			dev_id, qp_id, &ts_params->qp_conf,
395 			rte_cryptodev_socket_id(dev_id)),
396 			"Failed to setup queue pair %u on cryptodev %u",
397 			qp_id, dev_id);
398 	}
399 
400 	return TEST_SUCCESS;
401 }
402 
403 static void
404 testsuite_teardown(void)
405 {
406 	struct crypto_testsuite_params *ts_params = &testsuite_params;
407 
408 	if (ts_params->mbuf_pool != NULL) {
409 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
410 		rte_mempool_avail_count(ts_params->mbuf_pool));
411 	}
412 
413 	if (ts_params->op_mpool != NULL) {
414 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
415 		rte_mempool_avail_count(ts_params->op_mpool));
416 	}
417 
418 }
419 
420 static int
421 ut_setup(void)
422 {
423 	struct crypto_testsuite_params *ts_params = &testsuite_params;
424 	struct crypto_unittest_params *ut_params = &unittest_params;
425 
426 	uint16_t qp_id;
427 
428 	/* Clear unit test parameters before running test */
429 	memset(ut_params, 0, sizeof(*ut_params));
430 
431 	/* Reconfigure device to default parameters */
432 	ts_params->conf.socket_id = SOCKET_ID_ANY;
433 	ts_params->conf.session_mp.nb_objs = DEFAULT_NUM_OPS_INFLIGHT;
434 
435 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
436 			&ts_params->conf),
437 			"Failed to configure cryptodev %u",
438 			ts_params->valid_devs[0]);
439 
440 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
441 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
442 			ts_params->valid_devs[0], qp_id,
443 			&ts_params->qp_conf,
444 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
445 			"Failed to setup queue pair %u on cryptodev %u",
446 			qp_id, ts_params->valid_devs[0]);
447 	}
448 
449 
450 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
451 
452 	/* Start the device */
453 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
454 			"Failed to start cryptodev %u",
455 			ts_params->valid_devs[0]);
456 
457 	return TEST_SUCCESS;
458 }
459 
460 static void
461 ut_teardown(void)
462 {
463 	struct crypto_testsuite_params *ts_params = &testsuite_params;
464 	struct crypto_unittest_params *ut_params = &unittest_params;
465 	struct rte_cryptodev_stats stats;
466 
467 	/* free crypto session structure */
468 	if (ut_params->sess) {
469 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
470 				ut_params->sess);
471 		ut_params->sess = NULL;
472 	}
473 
474 	/* free crypto operation structure */
475 	if (ut_params->op)
476 		rte_crypto_op_free(ut_params->op);
477 
478 	/*
479 	 * free mbuf - both obuf and ibuf are usually the same,
480 	 * so check if they point at the same address is necessary,
481 	 * to avoid freeing the mbuf twice.
482 	 */
483 	if (ut_params->obuf) {
484 		rte_pktmbuf_free(ut_params->obuf);
485 		if (ut_params->ibuf == ut_params->obuf)
486 			ut_params->ibuf = 0;
487 		ut_params->obuf = 0;
488 	}
489 	if (ut_params->ibuf) {
490 		rte_pktmbuf_free(ut_params->ibuf);
491 		ut_params->ibuf = 0;
492 	}
493 
494 	if (ts_params->mbuf_pool != NULL)
495 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
496 			rte_mempool_avail_count(ts_params->mbuf_pool));
497 
498 	rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
499 
500 	/* Stop the device */
501 	rte_cryptodev_stop(ts_params->valid_devs[0]);
502 }
503 
504 static int
505 test_device_configure_invalid_dev_id(void)
506 {
507 	struct crypto_testsuite_params *ts_params = &testsuite_params;
508 	uint16_t dev_id, num_devs = 0;
509 
510 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
511 			"Need at least %d devices for test", 1);
512 
513 	/* valid dev_id values */
514 	dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
515 
516 	/* Stop the device in case it's started so it can be configured */
517 	rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
518 
519 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
520 			"Failed test for rte_cryptodev_configure: "
521 			"invalid dev_num %u", dev_id);
522 
523 	/* invalid dev_id values */
524 	dev_id = num_devs;
525 
526 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
527 			"Failed test for rte_cryptodev_configure: "
528 			"invalid dev_num %u", dev_id);
529 
530 	dev_id = 0xff;
531 
532 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
533 			"Failed test for rte_cryptodev_configure:"
534 			"invalid dev_num %u", dev_id);
535 
536 	return TEST_SUCCESS;
537 }
538 
539 static int
540 test_device_configure_invalid_queue_pair_ids(void)
541 {
542 	struct crypto_testsuite_params *ts_params = &testsuite_params;
543 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
544 
545 	/* Stop the device in case it's started so it can be configured */
546 	rte_cryptodev_stop(ts_params->valid_devs[0]);
547 
548 	/* valid - one queue pairs */
549 	ts_params->conf.nb_queue_pairs = 1;
550 
551 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
552 			&ts_params->conf),
553 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
554 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
555 
556 
557 	/* valid - max value queue pairs */
558 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
559 
560 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
561 			&ts_params->conf),
562 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
563 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
564 
565 
566 	/* invalid - zero queue pairs */
567 	ts_params->conf.nb_queue_pairs = 0;
568 
569 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
570 			&ts_params->conf),
571 			"Failed test for rte_cryptodev_configure, dev_id %u,"
572 			" invalid qps: %u",
573 			ts_params->valid_devs[0],
574 			ts_params->conf.nb_queue_pairs);
575 
576 
577 	/* invalid - max value supported by field queue pairs */
578 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
579 
580 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
581 			&ts_params->conf),
582 			"Failed test for rte_cryptodev_configure, dev_id %u,"
583 			" invalid qps: %u",
584 			ts_params->valid_devs[0],
585 			ts_params->conf.nb_queue_pairs);
586 
587 
588 	/* invalid - max value + 1 queue pairs */
589 	ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
590 
591 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
592 			&ts_params->conf),
593 			"Failed test for rte_cryptodev_configure, dev_id %u,"
594 			" invalid qps: %u",
595 			ts_params->valid_devs[0],
596 			ts_params->conf.nb_queue_pairs);
597 
598 	/* revert to original testsuite value */
599 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
600 
601 	return TEST_SUCCESS;
602 }
603 
604 static int
605 test_queue_pair_descriptor_setup(void)
606 {
607 	struct crypto_testsuite_params *ts_params = &testsuite_params;
608 	struct rte_cryptodev_info dev_info;
609 	struct rte_cryptodev_qp_conf qp_conf = {
610 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
611 	};
612 
613 	uint16_t qp_id;
614 
615 	/* Stop the device in case it's started so it can be configured */
616 	rte_cryptodev_stop(ts_params->valid_devs[0]);
617 
618 
619 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
620 
621 	ts_params->conf.session_mp.nb_objs = dev_info.sym.max_nb_sessions;
622 
623 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
624 			&ts_params->conf), "Failed to configure cryptodev %u",
625 			ts_params->valid_devs[0]);
626 
627 
628 	/*
629 	 * Test various ring sizes on this device. memzones can't be
630 	 * freed so are re-used if ring is released and re-created.
631 	 */
632 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
633 
634 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
635 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
636 				ts_params->valid_devs[0], qp_id, &qp_conf,
637 				rte_cryptodev_socket_id(
638 						ts_params->valid_devs[0])),
639 				"Failed test for "
640 				"rte_cryptodev_queue_pair_setup: num_inflights "
641 				"%u on qp %u on cryptodev %u",
642 				qp_conf.nb_descriptors, qp_id,
643 				ts_params->valid_devs[0]);
644 	}
645 
646 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
647 
648 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
649 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
650 				ts_params->valid_devs[0], qp_id, &qp_conf,
651 				rte_cryptodev_socket_id(
652 						ts_params->valid_devs[0])),
653 				"Failed test for"
654 				" rte_cryptodev_queue_pair_setup: num_inflights"
655 				" %u on qp %u on cryptodev %u",
656 				qp_conf.nb_descriptors, qp_id,
657 				ts_params->valid_devs[0]);
658 	}
659 
660 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
661 
662 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
663 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
664 				ts_params->valid_devs[0], qp_id, &qp_conf,
665 				rte_cryptodev_socket_id(
666 						ts_params->valid_devs[0])),
667 				"Failed test for "
668 				"rte_cryptodev_queue_pair_setup: num_inflights"
669 				" %u on qp %u on cryptodev %u",
670 				qp_conf.nb_descriptors, qp_id,
671 				ts_params->valid_devs[0]);
672 	}
673 
674 	/* invalid number of descriptors - max supported + 2 */
675 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
676 
677 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
678 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
679 				ts_params->valid_devs[0], qp_id, &qp_conf,
680 				rte_cryptodev_socket_id(
681 						ts_params->valid_devs[0])),
682 				"Unexpectedly passed test for "
683 				"rte_cryptodev_queue_pair_setup:"
684 				"num_inflights %u on qp %u on cryptodev %u",
685 				qp_conf.nb_descriptors, qp_id,
686 				ts_params->valid_devs[0]);
687 	}
688 
689 	/* invalid number of descriptors - max value of parameter */
690 	qp_conf.nb_descriptors = UINT32_MAX-1;
691 
692 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
693 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
694 				ts_params->valid_devs[0], qp_id, &qp_conf,
695 				rte_cryptodev_socket_id(
696 						ts_params->valid_devs[0])),
697 				"Unexpectedly passed test for "
698 				"rte_cryptodev_queue_pair_setup:"
699 				"num_inflights %u on qp %u on cryptodev %u",
700 				qp_conf.nb_descriptors, qp_id,
701 				ts_params->valid_devs[0]);
702 	}
703 
704 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
705 
706 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
707 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
708 				ts_params->valid_devs[0], qp_id, &qp_conf,
709 				rte_cryptodev_socket_id(
710 						ts_params->valid_devs[0])),
711 				"Failed test for"
712 				" rte_cryptodev_queue_pair_setup:"
713 				"num_inflights %u on qp %u on cryptodev %u",
714 				qp_conf.nb_descriptors, qp_id,
715 				ts_params->valid_devs[0]);
716 	}
717 
718 	/* invalid number of descriptors - max supported + 1 */
719 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
720 
721 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
722 		TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
723 				ts_params->valid_devs[0], qp_id, &qp_conf,
724 				rte_cryptodev_socket_id(
725 						ts_params->valid_devs[0])),
726 				"Unexpectedly passed test for "
727 				"rte_cryptodev_queue_pair_setup:"
728 				"num_inflights %u on qp %u on cryptodev %u",
729 				qp_conf.nb_descriptors, qp_id,
730 				ts_params->valid_devs[0]);
731 	}
732 
733 	/* test invalid queue pair id */
734 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
735 
736 	qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE;		/*invalid */
737 
738 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
739 			ts_params->valid_devs[0],
740 			qp_id, &qp_conf,
741 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
742 			"Failed test for rte_cryptodev_queue_pair_setup:"
743 			"invalid qp %u on cryptodev %u",
744 			qp_id, ts_params->valid_devs[0]);
745 
746 	qp_id = 0xffff; /*invalid*/
747 
748 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
749 			ts_params->valid_devs[0],
750 			qp_id, &qp_conf,
751 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
752 			"Failed test for rte_cryptodev_queue_pair_setup:"
753 			"invalid qp %u on cryptodev %u",
754 			qp_id, ts_params->valid_devs[0]);
755 
756 	return TEST_SUCCESS;
757 }
758 
759 /* ***** Plaintext data for tests ***** */
760 
761 const char catch_22_quote_1[] =
762 		"There was only one catch and that was Catch-22, which "
763 		"specified that a concern for one's safety in the face of "
764 		"dangers that were real and immediate was the process of a "
765 		"rational mind. Orr was crazy and could be grounded. All he "
766 		"had to do was ask; and as soon as he did, he would no longer "
767 		"be crazy and would have to fly more missions. Orr would be "
768 		"crazy to fly more missions and sane if he didn't, but if he "
769 		"was sane he had to fly them. If he flew them he was crazy "
770 		"and didn't have to; but if he didn't want to he was sane and "
771 		"had to. Yossarian was moved very deeply by the absolute "
772 		"simplicity of this clause of Catch-22 and let out a "
773 		"respectful whistle. \"That's some catch, that Catch-22\", he "
774 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
775 
776 const char catch_22_quote[] =
777 		"What a lousy earth! He wondered how many people were "
778 		"destitute that same night even in his own prosperous country, "
779 		"how many homes were shanties, how many husbands were drunk "
780 		"and wives socked, and how many children were bullied, abused, "
781 		"or abandoned. How many families hungered for food they could "
782 		"not afford to buy? How many hearts were broken? How many "
783 		"suicides would take place that same night, how many people "
784 		"would go insane? How many cockroaches and landlords would "
785 		"triumph? How many winners were losers, successes failures, "
786 		"and rich men poor men? How many wise guys were stupid? How "
787 		"many happy endings were unhappy endings? How many honest men "
788 		"were liars, brave men cowards, loyal men traitors, how many "
789 		"sainted men were corrupt, how many people in positions of "
790 		"trust had sold their souls to bodyguards, how many had never "
791 		"had souls? How many straight-and-narrow paths were crooked "
792 		"paths? How many best families were worst families and how "
793 		"many good people were bad people? When you added them all up "
794 		"and then subtracted, you might be left with only the children, "
795 		"and perhaps with Albert Einstein and an old violinist or "
796 		"sculptor somewhere.";
797 
798 #define QUOTE_480_BYTES		(480)
799 #define QUOTE_512_BYTES		(512)
800 #define QUOTE_768_BYTES		(768)
801 #define QUOTE_1024_BYTES	(1024)
802 
803 
804 
805 /* ***** SHA1 Hash Tests ***** */
806 
807 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
808 
809 static uint8_t hmac_sha1_key[] = {
810 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
811 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
812 	0xDE, 0xF4, 0xDE, 0xAD };
813 
814 /* ***** SHA224 Hash Tests ***** */
815 
816 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
817 
818 
819 /* ***** AES-CBC Cipher Tests ***** */
820 
821 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
822 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
823 
824 static uint8_t aes_cbc_key[] = {
825 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
826 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
827 
828 static uint8_t aes_cbc_iv[] = {
829 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
830 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
831 
832 
833 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
834 
835 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
836 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
837 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
838 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
839 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
840 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
841 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
842 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
843 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
844 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
845 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
846 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
847 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
848 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
849 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
850 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
851 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
852 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
853 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
854 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
855 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
856 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
857 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
858 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
859 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
860 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
861 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
862 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
863 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
864 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
865 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
866 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
867 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
868 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
869 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
870 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
871 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
872 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
873 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
874 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
875 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
876 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
877 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
878 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
879 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
880 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
881 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
882 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
883 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
884 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
885 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
886 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
887 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
888 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
889 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
890 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
891 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
892 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
893 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
894 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
895 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
896 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
897 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
898 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
899 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
900 };
901 
902 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
903 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
904 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
905 	0x18, 0x8c, 0x1d, 0x32
906 };
907 
908 
909 /* Multisession Vector context Test */
910 /*Begin Session 0 */
911 static uint8_t ms_aes_cbc_key0[] = {
912 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
913 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
914 };
915 
916 static uint8_t ms_aes_cbc_iv0[] = {
917 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
918 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
919 };
920 
921 static const uint8_t ms_aes_cbc_cipher0[] = {
922 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
923 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
924 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
925 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
926 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
927 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
928 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
929 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
930 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
931 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
932 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
933 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
934 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
935 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
936 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
937 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
938 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
939 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
940 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
941 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
942 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
943 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
944 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
945 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
946 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
947 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
948 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
949 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
950 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
951 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
952 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
953 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
954 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
955 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
956 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
957 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
958 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
959 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
960 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
961 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
962 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
963 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
964 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
965 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
966 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
967 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
968 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
969 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
970 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
971 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
972 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
973 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
974 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
975 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
976 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
977 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
978 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
979 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
980 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
981 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
982 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
983 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
984 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
985 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
986 };
987 
988 
989 static  uint8_t ms_hmac_key0[] = {
990 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
991 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
992 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
993 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
994 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
995 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
996 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
997 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
998 };
999 
1000 static const uint8_t ms_hmac_digest0[] = {
1001 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1002 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1003 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1004 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1005 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1006 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1007 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1008 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1009 		};
1010 
1011 /* End Session 0 */
1012 /* Begin session 1 */
1013 
1014 static  uint8_t ms_aes_cbc_key1[] = {
1015 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1016 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1017 };
1018 
1019 static  uint8_t ms_aes_cbc_iv1[] = {
1020 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1021 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1022 };
1023 
1024 static const uint8_t ms_aes_cbc_cipher1[] = {
1025 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1026 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1027 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1028 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1029 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1030 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1031 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1032 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1033 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1034 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1035 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1036 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1037 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1038 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1039 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1040 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1041 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1042 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1043 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1044 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1045 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1046 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1047 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1048 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1049 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1050 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1051 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1052 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1053 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1054 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1055 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1056 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1057 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1058 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1059 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1060 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1061 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1062 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1063 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1064 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1065 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1066 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1067 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1068 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1069 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1070 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1071 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1072 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1073 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1074 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1075 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1076 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1077 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1078 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1079 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1080 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1081 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1082 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1083 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1084 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1085 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1086 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1087 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1088 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1089 
1090 };
1091 
1092 static uint8_t ms_hmac_key1[] = {
1093 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1094 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1095 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1096 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1097 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1098 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1099 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1100 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1101 };
1102 
1103 static const uint8_t ms_hmac_digest1[] = {
1104 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1105 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1106 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1107 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1108 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1109 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1110 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1111 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1112 };
1113 /* End Session 1  */
1114 /* Begin Session 2 */
1115 static  uint8_t ms_aes_cbc_key2[] = {
1116 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1117 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1118 };
1119 
1120 static  uint8_t ms_aes_cbc_iv2[] = {
1121 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1122 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1123 };
1124 
1125 static const uint8_t ms_aes_cbc_cipher2[] = {
1126 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1127 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1128 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1129 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1130 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1131 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1132 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1133 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1134 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1135 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1136 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1137 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1138 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1139 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1140 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1141 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1142 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1143 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1144 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1145 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1146 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1147 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1148 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1149 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1150 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1151 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1152 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1153 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1154 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1155 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1156 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1157 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1158 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1159 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1160 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1161 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1162 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1163 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1164 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1165 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1166 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1167 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1168 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1169 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1170 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1171 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1172 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1173 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1174 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1175 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1176 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1177 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1178 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1179 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1180 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1181 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1182 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1183 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1184 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1185 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1186 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1187 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1188 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1189 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1190 };
1191 
1192 static  uint8_t ms_hmac_key2[] = {
1193 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1194 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1195 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1196 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1197 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1198 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1199 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1200 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1201 };
1202 
1203 static const uint8_t ms_hmac_digest2[] = {
1204 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1205 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1206 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1207 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1208 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1209 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1210 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1211 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1212 };
1213 
1214 /* End Session 2 */
1215 
1216 
1217 static int
1218 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1219 {
1220 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1221 	struct crypto_unittest_params *ut_params = &unittest_params;
1222 
1223 	/* Generate test mbuf data and space for digest */
1224 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1225 			catch_22_quote,	QUOTE_512_BYTES, 0);
1226 
1227 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1228 			DIGEST_BYTE_LENGTH_SHA1);
1229 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1230 
1231 	/* Setup Cipher Parameters */
1232 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1233 	ut_params->cipher_xform.next = &ut_params->auth_xform;
1234 
1235 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1236 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1237 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1238 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1239 
1240 	/* Setup HMAC Parameters */
1241 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1242 
1243 	ut_params->auth_xform.next = NULL;
1244 
1245 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1246 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1247 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1248 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1249 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1250 
1251 	/* Create crypto session*/
1252 	ut_params->sess = rte_cryptodev_sym_session_create(
1253 			ts_params->valid_devs[0],
1254 			&ut_params->cipher_xform);
1255 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1256 
1257 	/* Generate crypto op data structure */
1258 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1259 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1260 	TEST_ASSERT_NOT_NULL(ut_params->op,
1261 			"Failed to allocate symmetric crypto operation struct");
1262 
1263 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1264 
1265 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1266 
1267 	/* set crypto operation source mbuf */
1268 	sym_op->m_src = ut_params->ibuf;
1269 
1270 	/* Set crypto operation authentication parameters */
1271 	sym_op->auth.digest.data = ut_params->digest;
1272 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1273 			ut_params->ibuf, QUOTE_512_BYTES);
1274 	sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA1;
1275 
1276 	sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1277 	sym_op->auth.data.length = QUOTE_512_BYTES;
1278 
1279 	/* Set crypto operation cipher parameters */
1280 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1281 			CIPHER_IV_LENGTH_AES_CBC);
1282 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1283 	sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1284 
1285 	rte_memcpy(sym_op->cipher.iv.data, aes_cbc_iv,
1286 			CIPHER_IV_LENGTH_AES_CBC);
1287 
1288 	sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1289 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1290 
1291 	/* Process crypto operation */
1292 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1293 			ut_params->op), "failed to process sym crypto op");
1294 
1295 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1296 			"crypto op processing failed");
1297 
1298 	/* Validate obuf */
1299 	uint8_t *ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
1300 			uint8_t *, CIPHER_IV_LENGTH_AES_CBC);
1301 
1302 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1303 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1304 			QUOTE_512_BYTES,
1305 			"ciphertext data not as expected");
1306 
1307 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1308 
1309 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1310 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1311 			gbl_cryptodev_type == RTE_CRYPTODEV_AESNI_MB_PMD ?
1312 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1313 					DIGEST_BYTE_LENGTH_SHA1,
1314 			"Generated digest data not as expected");
1315 
1316 	return TEST_SUCCESS;
1317 }
1318 
1319 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1320 
1321 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
1322 
1323 static uint8_t hmac_sha512_key[] = {
1324 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1325 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1326 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1327 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1328 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1329 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1330 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1331 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1332 
1333 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1334 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1335 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1336 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1337 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1338 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1339 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1340 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1341 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1342 
1343 
1344 
1345 static int
1346 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1347 		struct crypto_unittest_params *ut_params,
1348 		uint8_t *cipher_key,
1349 		uint8_t *hmac_key);
1350 
1351 static int
1352 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1353 		struct crypto_unittest_params *ut_params,
1354 		struct crypto_testsuite_params *ts_params,
1355 		const uint8_t *cipher,
1356 		const uint8_t *digest,
1357 		const uint8_t *iv);
1358 
1359 
1360 static int
1361 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1362 		struct crypto_unittest_params *ut_params,
1363 		uint8_t *cipher_key,
1364 		uint8_t *hmac_key)
1365 {
1366 
1367 	/* Setup Cipher Parameters */
1368 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1369 	ut_params->cipher_xform.next = NULL;
1370 
1371 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1372 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1373 	ut_params->cipher_xform.cipher.key.data = cipher_key;
1374 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1375 
1376 	/* Setup HMAC Parameters */
1377 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1378 	ut_params->auth_xform.next = &ut_params->cipher_xform;
1379 
1380 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1381 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1382 	ut_params->auth_xform.auth.key.data = hmac_key;
1383 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1384 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1385 
1386 	return TEST_SUCCESS;
1387 }
1388 
1389 
1390 static int
1391 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1392 		struct crypto_unittest_params *ut_params,
1393 		struct crypto_testsuite_params *ts_params,
1394 		const uint8_t *cipher,
1395 		const uint8_t *digest,
1396 		const uint8_t *iv)
1397 {
1398 	/* Generate test mbuf data and digest */
1399 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1400 			(const char *)
1401 			cipher,
1402 			QUOTE_512_BYTES, 0);
1403 
1404 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1405 			DIGEST_BYTE_LENGTH_SHA512);
1406 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1407 
1408 	rte_memcpy(ut_params->digest,
1409 			digest,
1410 			DIGEST_BYTE_LENGTH_SHA512);
1411 
1412 	/* Generate Crypto op data structure */
1413 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1414 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1415 	TEST_ASSERT_NOT_NULL(ut_params->op,
1416 			"Failed to allocate symmetric crypto operation struct");
1417 
1418 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
1419 
1420 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1421 
1422 	/* set crypto operation source mbuf */
1423 	sym_op->m_src = ut_params->ibuf;
1424 
1425 	sym_op->auth.digest.data = ut_params->digest;
1426 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1427 			ut_params->ibuf, QUOTE_512_BYTES);
1428 	sym_op->auth.digest.length = DIGEST_BYTE_LENGTH_SHA512;
1429 
1430 	sym_op->auth.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1431 	sym_op->auth.data.length = QUOTE_512_BYTES;
1432 
1433 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1434 			ut_params->ibuf, CIPHER_IV_LENGTH_AES_CBC);
1435 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys_offset(
1436 			ut_params->ibuf, 0);
1437 	sym_op->cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1438 
1439 	rte_memcpy(sym_op->cipher.iv.data, iv,
1440 			CIPHER_IV_LENGTH_AES_CBC);
1441 
1442 	sym_op->cipher.data.offset = CIPHER_IV_LENGTH_AES_CBC;
1443 	sym_op->cipher.data.length = QUOTE_512_BYTES;
1444 
1445 	/* Process crypto operation */
1446 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1447 			ut_params->op), "failed to process sym crypto op");
1448 
1449 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1450 			"crypto op processing failed");
1451 
1452 	ut_params->obuf = ut_params->op->sym->m_src;
1453 
1454 	/* Validate obuf */
1455 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
1456 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *) +
1457 			CIPHER_IV_LENGTH_AES_CBC, catch_22_quote,
1458 			QUOTE_512_BYTES,
1459 			"Plaintext data not as expected");
1460 
1461 	/* Validate obuf */
1462 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1463 			"Digest verification failed");
1464 
1465 	return TEST_SUCCESS;
1466 }
1467 
1468 static int
1469 test_AES_chain_mb_all(void)
1470 {
1471 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1472 	int status;
1473 
1474 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1475 		ts_params->op_mpool, ts_params->valid_devs[0],
1476 		RTE_CRYPTODEV_AESNI_MB_PMD,
1477 		BLKCIPHER_AES_CHAIN_TYPE);
1478 
1479 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1480 
1481 	return TEST_SUCCESS;
1482 }
1483 
1484 static int
1485 test_AES_chain_openssl_all(void)
1486 {
1487 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1488 	int status;
1489 
1490 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1491 		ts_params->op_mpool, ts_params->valid_devs[0],
1492 		RTE_CRYPTODEV_OPENSSL_PMD,
1493 		BLKCIPHER_AES_CHAIN_TYPE);
1494 
1495 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1496 
1497 	return TEST_SUCCESS;
1498 }
1499 
1500 static int
1501 test_AES_cipheronly_openssl_all(void)
1502 {
1503 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1504 	int status;
1505 
1506 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1507 		ts_params->op_mpool, ts_params->valid_devs[0],
1508 		RTE_CRYPTODEV_OPENSSL_PMD,
1509 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1510 
1511 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1512 
1513 	return TEST_SUCCESS;
1514 }
1515 
1516 static int
1517 test_AES_chain_qat_all(void)
1518 {
1519 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1520 	int status;
1521 
1522 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1523 		ts_params->op_mpool, ts_params->valid_devs[0],
1524 		RTE_CRYPTODEV_QAT_SYM_PMD,
1525 		BLKCIPHER_AES_CHAIN_TYPE);
1526 
1527 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1528 
1529 	return TEST_SUCCESS;
1530 }
1531 
1532 static int
1533 test_AES_cipheronly_qat_all(void)
1534 {
1535 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1536 	int status;
1537 
1538 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1539 		ts_params->op_mpool, ts_params->valid_devs[0],
1540 		RTE_CRYPTODEV_QAT_SYM_PMD,
1541 		BLKCIPHER_AES_CIPHERONLY_TYPE);
1542 
1543 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1544 
1545 	return TEST_SUCCESS;
1546 }
1547 
1548 static int
1549 test_authonly_openssl_all(void)
1550 {
1551 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1552 	int status;
1553 
1554 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1555 		ts_params->op_mpool, ts_params->valid_devs[0],
1556 		RTE_CRYPTODEV_OPENSSL_PMD,
1557 		BLKCIPHER_AUTHONLY_TYPE);
1558 
1559 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
1560 
1561 	return TEST_SUCCESS;
1562 }
1563 
1564 /* ***** SNOW 3G Tests ***** */
1565 static int
1566 create_wireless_algo_hash_session(uint8_t dev_id,
1567 	const uint8_t *key, const uint8_t key_len,
1568 	const uint8_t aad_len, const uint8_t auth_len,
1569 	enum rte_crypto_auth_operation op,
1570 	enum rte_crypto_auth_algorithm algo)
1571 {
1572 	uint8_t hash_key[key_len];
1573 
1574 	struct crypto_unittest_params *ut_params = &unittest_params;
1575 
1576 	memcpy(hash_key, key, key_len);
1577 
1578 	TEST_HEXDUMP(stdout, "key:", key, key_len);
1579 
1580 	/* Setup Authentication Parameters */
1581 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1582 	ut_params->auth_xform.next = NULL;
1583 
1584 	ut_params->auth_xform.auth.op = op;
1585 	ut_params->auth_xform.auth.algo = algo;
1586 	ut_params->auth_xform.auth.key.length = key_len;
1587 	ut_params->auth_xform.auth.key.data = hash_key;
1588 	ut_params->auth_xform.auth.digest_length = auth_len;
1589 	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1590 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1591 				&ut_params->auth_xform);
1592 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1593 	return 0;
1594 }
1595 
1596 static int
1597 create_wireless_algo_cipher_session(uint8_t dev_id,
1598 			enum rte_crypto_cipher_operation op,
1599 			enum rte_crypto_cipher_algorithm algo,
1600 			const uint8_t *key, const uint8_t key_len)
1601 {
1602 	uint8_t cipher_key[key_len];
1603 
1604 	struct crypto_unittest_params *ut_params = &unittest_params;
1605 
1606 	memcpy(cipher_key, key, key_len);
1607 
1608 	/* Setup Cipher Parameters */
1609 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1610 	ut_params->cipher_xform.next = NULL;
1611 
1612 	ut_params->cipher_xform.cipher.algo = algo;
1613 	ut_params->cipher_xform.cipher.op = op;
1614 	ut_params->cipher_xform.cipher.key.data = cipher_key;
1615 	ut_params->cipher_xform.cipher.key.length = key_len;
1616 
1617 	TEST_HEXDUMP(stdout, "key:", key, key_len);
1618 
1619 	/* Create Crypto session */
1620 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1621 						&ut_params->
1622 						cipher_xform);
1623 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1624 	return 0;
1625 }
1626 
1627 static int
1628 create_wireless_algo_cipher_operation(const uint8_t *iv, const unsigned iv_len,
1629 			const unsigned cipher_len,
1630 			const unsigned cipher_offset,
1631 			enum rte_crypto_cipher_algorithm algo)
1632 {
1633 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1634 	struct crypto_unittest_params *ut_params = &unittest_params;
1635 	unsigned iv_pad_len = 0;
1636 
1637 	/* Generate Crypto op data structure */
1638 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1639 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1640 	TEST_ASSERT_NOT_NULL(ut_params->op,
1641 				"Failed to allocate pktmbuf offload");
1642 
1643 	/* Set crypto operation data parameters */
1644 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1645 
1646 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1647 
1648 	/* set crypto operation source mbuf */
1649 	sym_op->m_src = ut_params->ibuf;
1650 
1651 	/* iv */
1652 	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1653 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1654 	else
1655 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1656 
1657 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf
1658 			, iv_pad_len);
1659 
1660 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1661 
1662 	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1663 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1664 	sym_op->cipher.iv.length = iv_pad_len;
1665 
1666 	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1667 	sym_op->cipher.data.length = cipher_len;
1668 	sym_op->cipher.data.offset = cipher_offset;
1669 	return 0;
1670 }
1671 
1672 static int
1673 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, const uint8_t iv_len,
1674 			const unsigned cipher_len,
1675 			const unsigned cipher_offset,
1676 			enum rte_crypto_cipher_algorithm algo)
1677 {
1678 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1679 	struct crypto_unittest_params *ut_params = &unittest_params;
1680 	unsigned iv_pad_len = 0;
1681 
1682 	/* Generate Crypto op data structure */
1683 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1684 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1685 	TEST_ASSERT_NOT_NULL(ut_params->op,
1686 				"Failed to allocate pktmbuf offload");
1687 
1688 	/* Set crypto operation data parameters */
1689 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1690 
1691 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1692 
1693 	/* set crypto operation source mbuf */
1694 	sym_op->m_src = ut_params->ibuf;
1695 	sym_op->m_dst = ut_params->obuf;
1696 
1697 	/* iv */
1698 	if (algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1699 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1700 	else
1701 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1702 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(ut_params->ibuf,
1703 					iv_pad_len);
1704 
1705 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1706 
1707 	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1708 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1709 	sym_op->cipher.iv.length = iv_pad_len;
1710 
1711 	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1712 	sym_op->cipher.data.length = cipher_len;
1713 	sym_op->cipher.data.offset = cipher_offset;
1714 	return 0;
1715 }
1716 
1717 static int
1718 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
1719 		enum rte_crypto_cipher_operation cipher_op,
1720 		enum rte_crypto_auth_operation auth_op,
1721 		enum rte_crypto_auth_algorithm auth_algo,
1722 		enum rte_crypto_cipher_algorithm cipher_algo,
1723 		const uint8_t *key, const uint8_t key_len,
1724 		const uint8_t aad_len, const uint8_t auth_len)
1725 
1726 {
1727 	uint8_t cipher_auth_key[key_len];
1728 
1729 	struct crypto_unittest_params *ut_params = &unittest_params;
1730 
1731 	memcpy(cipher_auth_key, key, key_len);
1732 
1733 	/* Setup Authentication Parameters */
1734 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1735 	ut_params->auth_xform.next = NULL;
1736 
1737 	ut_params->auth_xform.auth.op = auth_op;
1738 	ut_params->auth_xform.auth.algo = auth_algo;
1739 	ut_params->auth_xform.auth.key.length = key_len;
1740 	/* Hash key = cipher key */
1741 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
1742 	ut_params->auth_xform.auth.digest_length = auth_len;
1743 	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1744 
1745 	/* Setup Cipher Parameters */
1746 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1747 	ut_params->cipher_xform.next = &ut_params->auth_xform;
1748 
1749 	ut_params->cipher_xform.cipher.algo = cipher_algo;
1750 	ut_params->cipher_xform.cipher.op = cipher_op;
1751 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
1752 	ut_params->cipher_xform.cipher.key.length = key_len;
1753 
1754 	TEST_HEXDUMP(stdout, "key:", key, key_len);
1755 
1756 	/* Create Crypto session*/
1757 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1758 				&ut_params->cipher_xform);
1759 
1760 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1761 	return 0;
1762 }
1763 
1764 static int
1765 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
1766 		enum rte_crypto_cipher_operation cipher_op,
1767 		enum rte_crypto_auth_operation auth_op,
1768 		enum rte_crypto_auth_algorithm auth_algo,
1769 		enum rte_crypto_cipher_algorithm cipher_algo,
1770 		const uint8_t *key, const uint8_t key_len,
1771 		const uint8_t aad_len, const uint8_t auth_len)
1772 {
1773 	uint8_t auth_cipher_key[key_len];
1774 
1775 	struct crypto_unittest_params *ut_params = &unittest_params;
1776 
1777 	memcpy(auth_cipher_key, key, key_len);
1778 
1779 	/* Setup Authentication Parameters */
1780 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1781 	ut_params->auth_xform.auth.op = auth_op;
1782 	ut_params->auth_xform.next = &ut_params->cipher_xform;
1783 	ut_params->auth_xform.auth.algo = auth_algo;
1784 	ut_params->auth_xform.auth.key.length = key_len;
1785 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
1786 	ut_params->auth_xform.auth.digest_length = auth_len;
1787 	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
1788 
1789 	/* Setup Cipher Parameters */
1790 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1791 	ut_params->cipher_xform.next = NULL;
1792 	ut_params->cipher_xform.cipher.algo = cipher_algo;
1793 	ut_params->cipher_xform.cipher.op = cipher_op;
1794 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
1795 	ut_params->cipher_xform.cipher.key.length = key_len;
1796 
1797 	TEST_HEXDUMP(stdout, "key:", key, key_len);
1798 
1799 	/* Create Crypto session*/
1800 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
1801 				&ut_params->auth_xform);
1802 
1803 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1804 
1805 	return 0;
1806 }
1807 
1808 static int
1809 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
1810 		const unsigned auth_tag_len,
1811 		const uint8_t *aad, const unsigned aad_len,
1812 		unsigned data_pad_len,
1813 		enum rte_crypto_auth_operation op,
1814 		enum rte_crypto_auth_algorithm algo,
1815 		const unsigned auth_len, const unsigned auth_offset)
1816 {
1817 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1818 
1819 	struct crypto_unittest_params *ut_params = &unittest_params;
1820 
1821 	unsigned aad_buffer_len;
1822 
1823 	/* Generate Crypto op data structure */
1824 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1825 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1826 	TEST_ASSERT_NOT_NULL(ut_params->op,
1827 		"Failed to allocate pktmbuf offload");
1828 
1829 	/* Set crypto operation data parameters */
1830 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1831 
1832 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1833 
1834 	/* set crypto operation source mbuf */
1835 	sym_op->m_src = ut_params->ibuf;
1836 
1837 	/* aad */
1838 	/*
1839 	* Always allocate the aad up to the block size.
1840 	* The cryptodev API calls out -
1841 	*  - the array must be big enough to hold the AAD, plus any
1842 	*   space to round this up to the nearest multiple of the
1843 	*   block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1844 	*/
1845 	if (algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1846 		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1847 	else
1848 		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1849 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
1850 			ut_params->ibuf, aad_buffer_len);
1851 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1852 					"no room to prepend aad");
1853 	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1854 			ut_params->ibuf);
1855 	sym_op->auth.aad.length = aad_len;
1856 
1857 	memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1858 	rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1859 
1860 	TEST_HEXDUMP(stdout, "aad:",
1861 			sym_op->auth.aad.data, aad_len);
1862 
1863 	/* digest */
1864 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1865 					ut_params->ibuf, auth_tag_len);
1866 
1867 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1868 				"no room to append auth tag");
1869 	ut_params->digest = sym_op->auth.digest.data;
1870 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1871 			ut_params->ibuf, data_pad_len + aad_len);
1872 	sym_op->auth.digest.length = auth_tag_len;
1873 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1874 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
1875 	else
1876 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1877 
1878 	TEST_HEXDUMP(stdout, "digest:",
1879 		sym_op->auth.digest.data,
1880 		sym_op->auth.digest.length);
1881 
1882 	sym_op->auth.data.length = auth_len;
1883 	sym_op->auth.data.offset = auth_offset;
1884 
1885 	return 0;
1886 }
1887 
1888 static int
1889 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
1890 		const unsigned auth_tag_len,
1891 		const uint8_t *aad, const uint8_t aad_len,
1892 		unsigned data_pad_len,
1893 		enum rte_crypto_auth_operation op,
1894 		enum rte_crypto_auth_algorithm auth_algo,
1895 		enum rte_crypto_cipher_algorithm cipher_algo,
1896 		const uint8_t *iv, const uint8_t iv_len,
1897 		const unsigned cipher_len, const unsigned cipher_offset,
1898 		const unsigned auth_len, const unsigned auth_offset)
1899 {
1900 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1901 	struct crypto_unittest_params *ut_params = &unittest_params;
1902 
1903 	unsigned iv_pad_len = 0;
1904 	unsigned aad_buffer_len;
1905 
1906 	/* Generate Crypto op data structure */
1907 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1908 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1909 	TEST_ASSERT_NOT_NULL(ut_params->op,
1910 			"Failed to allocate pktmbuf offload");
1911 	/* Set crypto operation data parameters */
1912 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1913 
1914 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1915 
1916 	/* set crypto operation source mbuf */
1917 	sym_op->m_src = ut_params->ibuf;
1918 
1919 	/* digest */
1920 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
1921 			ut_params->ibuf, auth_tag_len);
1922 
1923 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
1924 			"no room to append auth tag");
1925 	ut_params->digest = sym_op->auth.digest.data;
1926 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
1927 			ut_params->ibuf, data_pad_len);
1928 	sym_op->auth.digest.length = auth_tag_len;
1929 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
1930 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
1931 	else
1932 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
1933 
1934 	TEST_HEXDUMP(stdout, "digest:",
1935 		sym_op->auth.digest.data,
1936 		sym_op->auth.digest.length);
1937 
1938 	/* aad */
1939 	/*
1940 	* Always allocate the aad up to the block size.
1941 	* The cryptodev API calls out -
1942 	*  - the array must be big enough to hold the AAD, plus any
1943 	*   space to round this up to the nearest multiple of the
1944 	*   block size (8 bytes for KASUMI and 16 bytes for SNOW 3G).
1945 	*/
1946 	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
1947 		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
1948 	else
1949 		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
1950 	sym_op->auth.aad.data =
1951 		(uint8_t *)rte_pktmbuf_prepend(
1952 			ut_params->ibuf, aad_buffer_len);
1953 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
1954 			"no room to prepend aad");
1955 	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
1956 			ut_params->ibuf);
1957 	sym_op->auth.aad.length = aad_len;
1958 	memset(sym_op->auth.aad.data, 0, aad_buffer_len);
1959 	rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
1960 	TEST_HEXDUMP(stdout, "aad:", sym_op->auth.aad.data, aad_len);
1961 
1962 	/* iv */
1963 	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
1964 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
1965 	else
1966 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
1967 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
1968 		ut_params->ibuf, iv_pad_len);
1969 
1970 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
1971 	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
1972 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
1973 	sym_op->cipher.iv.length = iv_pad_len;
1974 	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
1975 	sym_op->cipher.data.length = cipher_len;
1976 	sym_op->cipher.data.offset = cipher_offset + auth_offset;
1977 	sym_op->auth.data.length = auth_len;
1978 	sym_op->auth.data.offset = auth_offset + cipher_offset;
1979 
1980 	return 0;
1981 }
1982 
1983 static int
1984 create_wireless_algo_auth_cipher_operation(const unsigned auth_tag_len,
1985 		const uint8_t *iv, const uint8_t iv_len,
1986 		const uint8_t *aad, const uint8_t aad_len,
1987 		unsigned data_pad_len,
1988 		const unsigned cipher_len, const unsigned cipher_offset,
1989 		const unsigned auth_len, const unsigned auth_offset,
1990 		enum rte_crypto_auth_algorithm auth_algo,
1991 		enum rte_crypto_cipher_algorithm cipher_algo)
1992 {
1993 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1994 	struct crypto_unittest_params *ut_params = &unittest_params;
1995 
1996 	unsigned iv_pad_len = 0;
1997 	unsigned aad_buffer_len = 0;
1998 
1999 	/* Generate Crypto op data structure */
2000 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2001 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2002 	TEST_ASSERT_NOT_NULL(ut_params->op,
2003 			"Failed to allocate pktmbuf offload");
2004 
2005 	/* Set crypto operation data parameters */
2006 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2007 
2008 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2009 
2010 	/* set crypto operation source mbuf */
2011 	sym_op->m_src = ut_params->ibuf;
2012 
2013 	/* digest */
2014 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2015 			ut_params->ibuf, auth_tag_len);
2016 
2017 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2018 			"no room to append auth tag");
2019 
2020 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
2021 			ut_params->ibuf, data_pad_len);
2022 	sym_op->auth.digest.length = auth_tag_len;
2023 
2024 	memset(sym_op->auth.digest.data, 0, auth_tag_len);
2025 
2026 	TEST_HEXDUMP(stdout, "digest:",
2027 			sym_op->auth.digest.data,
2028 			sym_op->auth.digest.length);
2029 
2030 	/* aad */
2031 	/*
2032 	* Always allocate the aad up to the block size.
2033 	* The cryptodev API calls out -
2034 	*  - the array must be big enough to hold the AAD, plus any
2035 	*   space to round this up to the nearest multiple of the
2036 	*   block size (8 bytes for KASUMI 16 bytes).
2037 	*/
2038 	if (auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9)
2039 		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 8);
2040 	else
2041 		aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
2042 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
2043 	ut_params->ibuf, aad_buffer_len);
2044 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
2045 				"no room to prepend aad");
2046 	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
2047 				ut_params->ibuf);
2048 	sym_op->auth.aad.length = aad_len;
2049 	memset(sym_op->auth.aad.data, 0, aad_buffer_len);
2050 	rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
2051 	TEST_HEXDUMP(stdout, "aad:",
2052 			sym_op->auth.aad.data, aad_len);
2053 
2054 	/* iv */
2055 	if (cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8)
2056 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 8);
2057 	else
2058 		iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
2059 
2060 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
2061 		ut_params->ibuf, iv_pad_len);
2062 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
2063 
2064 	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
2065 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
2066 	sym_op->cipher.iv.length = iv_pad_len;
2067 
2068 	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
2069 
2070 	sym_op->cipher.data.length = cipher_len;
2071 	sym_op->cipher.data.offset = auth_offset + cipher_offset;
2072 
2073 	sym_op->auth.data.length = auth_len;
2074 	sym_op->auth.data.offset = auth_offset + cipher_offset;
2075 
2076 	return 0;
2077 }
2078 
2079 static int
2080 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2081 {
2082 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2083 	struct crypto_unittest_params *ut_params = &unittest_params;
2084 
2085 	int retval;
2086 	unsigned plaintext_pad_len;
2087 	unsigned plaintext_len;
2088 	uint8_t *plaintext;
2089 
2090 	/* Create SNOW 3G session */
2091 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2092 			tdata->key.data, tdata->key.len,
2093 			tdata->aad.len, tdata->digest.len,
2094 			RTE_CRYPTO_AUTH_OP_GENERATE,
2095 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2096 	if (retval < 0)
2097 		return retval;
2098 
2099 	/* alloc mbuf and set payload */
2100 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2101 
2102 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2103 	rte_pktmbuf_tailroom(ut_params->ibuf));
2104 
2105 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2106 	/* Append data which is padded to a multiple of */
2107 	/* the algorithms block size */
2108 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2109 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2110 				plaintext_pad_len);
2111 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2112 
2113 	/* Create SNOW 3G operation */
2114 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2115 			tdata->aad.data, tdata->aad.len,
2116 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2117 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2118 			tdata->validAuthLenInBits.len,
2119 			tdata->validAuthOffsetLenInBits.len);
2120 	if (retval < 0)
2121 		return retval;
2122 
2123 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2124 				ut_params->op);
2125 	ut_params->obuf = ut_params->op->sym->m_src;
2126 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2127 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2128 			+ plaintext_pad_len + tdata->aad.len;
2129 
2130 	/* Validate obuf */
2131 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2132 	ut_params->digest,
2133 	tdata->digest.data,
2134 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2135 	"SNOW 3G Generated auth tag not as expected");
2136 
2137 	return 0;
2138 }
2139 
2140 static int
2141 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2142 {
2143 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2144 	struct crypto_unittest_params *ut_params = &unittest_params;
2145 
2146 	int retval;
2147 	unsigned plaintext_pad_len;
2148 	unsigned plaintext_len;
2149 	uint8_t *plaintext;
2150 
2151 	/* Create SNOW 3G session */
2152 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2153 				tdata->key.data, tdata->key.len,
2154 				tdata->aad.len, tdata->digest.len,
2155 				RTE_CRYPTO_AUTH_OP_VERIFY,
2156 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2157 	if (retval < 0)
2158 		return retval;
2159 	/* alloc mbuf and set payload */
2160 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2161 
2162 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2163 	rte_pktmbuf_tailroom(ut_params->ibuf));
2164 
2165 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2166 	/* Append data which is padded to a multiple of */
2167 	/* the algorithms block size */
2168 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2169 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2170 				plaintext_pad_len);
2171 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2172 
2173 	/* Create SNOW 3G operation */
2174 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
2175 			tdata->digest.len,
2176 			tdata->aad.data, tdata->aad.len,
2177 			plaintext_pad_len,
2178 			RTE_CRYPTO_AUTH_OP_VERIFY,
2179 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
2180 			tdata->validAuthLenInBits.len,
2181 			tdata->validAuthOffsetLenInBits.len);
2182 	if (retval < 0)
2183 		return retval;
2184 
2185 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2186 				ut_params->op);
2187 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2188 	ut_params->obuf = ut_params->op->sym->m_src;
2189 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2190 				+ plaintext_pad_len + tdata->aad.len;
2191 
2192 	/* Validate obuf */
2193 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2194 		return 0;
2195 	else
2196 		return -1;
2197 
2198 	return 0;
2199 }
2200 
2201 static int
2202 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2203 {
2204 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2205 	struct crypto_unittest_params *ut_params = &unittest_params;
2206 
2207 	int retval;
2208 	unsigned plaintext_pad_len;
2209 	unsigned plaintext_len;
2210 	uint8_t *plaintext;
2211 
2212 	/* Create KASUMI session */
2213 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2214 			tdata->key.data, tdata->key.len,
2215 			tdata->aad.len, tdata->digest.len,
2216 			RTE_CRYPTO_AUTH_OP_GENERATE,
2217 			RTE_CRYPTO_AUTH_KASUMI_F9);
2218 	if (retval < 0)
2219 		return retval;
2220 
2221 	/* alloc mbuf and set payload */
2222 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2223 
2224 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2225 	rte_pktmbuf_tailroom(ut_params->ibuf));
2226 
2227 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2228 	/* Append data which is padded to a multiple of */
2229 	/* the algorithms block size */
2230 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2231 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2232 				plaintext_pad_len);
2233 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2234 
2235 	/* Create KASUMI operation */
2236 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2237 			tdata->aad.data, tdata->aad.len,
2238 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2239 			RTE_CRYPTO_AUTH_KASUMI_F9,
2240 			tdata->validAuthLenInBits.len,
2241 			tdata->validAuthOffsetLenInBits.len);
2242 	if (retval < 0)
2243 		return retval;
2244 
2245 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2246 				ut_params->op);
2247 	ut_params->obuf = ut_params->op->sym->m_src;
2248 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2249 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2250 			+ plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
2251 
2252 	/* Validate obuf */
2253 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2254 	ut_params->digest,
2255 	tdata->digest.data,
2256 	DIGEST_BYTE_LENGTH_KASUMI_F9,
2257 	"KASUMI Generated auth tag not as expected");
2258 
2259 	return 0;
2260 }
2261 
2262 static int
2263 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2264 {
2265 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2266 	struct crypto_unittest_params *ut_params = &unittest_params;
2267 
2268 	int retval;
2269 	unsigned plaintext_pad_len;
2270 	unsigned plaintext_len;
2271 	uint8_t *plaintext;
2272 
2273 	/* Create KASUMI session */
2274 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2275 				tdata->key.data, tdata->key.len,
2276 				tdata->aad.len, tdata->digest.len,
2277 				RTE_CRYPTO_AUTH_OP_VERIFY,
2278 				RTE_CRYPTO_AUTH_KASUMI_F9);
2279 	if (retval < 0)
2280 		return retval;
2281 	/* alloc mbuf and set payload */
2282 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2283 
2284 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2285 	rte_pktmbuf_tailroom(ut_params->ibuf));
2286 
2287 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2288 	/* Append data which is padded to a multiple */
2289 	/* of the algorithms block size */
2290 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2291 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2292 				plaintext_pad_len);
2293 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2294 
2295 	/* Create KASUMI operation */
2296 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
2297 			tdata->digest.len,
2298 			tdata->aad.data, tdata->aad.len,
2299 			plaintext_pad_len,
2300 			RTE_CRYPTO_AUTH_OP_VERIFY,
2301 			RTE_CRYPTO_AUTH_KASUMI_F9,
2302 			tdata->validAuthLenInBits.len,
2303 			tdata->validAuthOffsetLenInBits.len);
2304 	if (retval < 0)
2305 		return retval;
2306 
2307 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2308 				ut_params->op);
2309 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2310 	ut_params->obuf = ut_params->op->sym->m_src;
2311 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2312 				+ plaintext_pad_len + tdata->aad.len;
2313 
2314 	/* Validate obuf */
2315 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2316 		return 0;
2317 	else
2318 		return -1;
2319 
2320 	return 0;
2321 }
2322 
2323 static int
2324 test_snow3g_hash_generate_test_case_1(void)
2325 {
2326 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
2327 }
2328 
2329 static int
2330 test_snow3g_hash_generate_test_case_2(void)
2331 {
2332 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
2333 }
2334 
2335 static int
2336 test_snow3g_hash_generate_test_case_3(void)
2337 {
2338 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
2339 }
2340 
2341 static int
2342 test_snow3g_hash_generate_test_case_4(void)
2343 {
2344 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
2345 }
2346 
2347 static int
2348 test_snow3g_hash_generate_test_case_5(void)
2349 {
2350 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
2351 }
2352 
2353 static int
2354 test_snow3g_hash_generate_test_case_6(void)
2355 {
2356 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
2357 }
2358 
2359 static int
2360 test_snow3g_hash_verify_test_case_1(void)
2361 {
2362 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2363 
2364 }
2365 
2366 static int
2367 test_snow3g_hash_verify_test_case_2(void)
2368 {
2369 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2370 }
2371 
2372 static int
2373 test_snow3g_hash_verify_test_case_3(void)
2374 {
2375 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2376 }
2377 
2378 static int
2379 test_snow3g_hash_verify_test_case_4(void)
2380 {
2381 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2382 }
2383 
2384 static int
2385 test_snow3g_hash_verify_test_case_5(void)
2386 {
2387 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2388 }
2389 
2390 static int
2391 test_snow3g_hash_verify_test_case_6(void)
2392 {
2393 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2394 }
2395 
2396 static int
2397 test_kasumi_hash_generate_test_case_1(void)
2398 {
2399 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
2400 }
2401 
2402 static int
2403 test_kasumi_hash_generate_test_case_2(void)
2404 {
2405 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
2406 }
2407 
2408 static int
2409 test_kasumi_hash_generate_test_case_3(void)
2410 {
2411 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
2412 }
2413 
2414 static int
2415 test_kasumi_hash_generate_test_case_4(void)
2416 {
2417 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
2418 }
2419 
2420 static int
2421 test_kasumi_hash_generate_test_case_5(void)
2422 {
2423 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
2424 }
2425 
2426 static int
2427 test_kasumi_hash_generate_test_case_6(void)
2428 {
2429 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
2430 }
2431 
2432 static int
2433 test_kasumi_hash_verify_test_case_1(void)
2434 {
2435 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2436 }
2437 
2438 static int
2439 test_kasumi_hash_verify_test_case_2(void)
2440 {
2441 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2442 }
2443 
2444 static int
2445 test_kasumi_hash_verify_test_case_3(void)
2446 {
2447 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2448 }
2449 
2450 static int
2451 test_kasumi_hash_verify_test_case_4(void)
2452 {
2453 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2454 }
2455 
2456 static int
2457 test_kasumi_hash_verify_test_case_5(void)
2458 {
2459 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2460 }
2461 
2462 static int
2463 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2464 {
2465 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2466 	struct crypto_unittest_params *ut_params = &unittest_params;
2467 
2468 	int retval;
2469 	uint8_t *plaintext, *ciphertext;
2470 	unsigned plaintext_pad_len;
2471 	unsigned plaintext_len;
2472 
2473 	/* Create KASUMI session */
2474 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2475 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2476 					RTE_CRYPTO_CIPHER_KASUMI_F8,
2477 					tdata->key.data, tdata->key.len);
2478 	if (retval < 0)
2479 		return retval;
2480 
2481 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2482 
2483 	/* Clear mbuf payload */
2484 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2485 	       rte_pktmbuf_tailroom(ut_params->ibuf));
2486 
2487 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2488 	/* Append data which is padded to a multiple */
2489 	/* of the algorithms block size */
2490 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2491 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2492 				plaintext_pad_len);
2493 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2494 
2495 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2496 
2497 	/* Create KASUMI operation */
2498 	retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2499 					tdata->plaintext.len,
2500 					tdata->validCipherOffsetLenInBits.len,
2501 					RTE_CRYPTO_CIPHER_KASUMI_F8);
2502 	if (retval < 0)
2503 		return retval;
2504 
2505 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2506 						ut_params->op);
2507 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2508 
2509 	ut_params->obuf = ut_params->op->sym->m_dst;
2510 	if (ut_params->obuf)
2511 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2512 				+ tdata->iv.len;
2513 	else
2514 		ciphertext = plaintext;
2515 
2516 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2517 
2518 	/* Validate obuf */
2519 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2520 		ciphertext,
2521 		tdata->ciphertext.data,
2522 		tdata->validCipherLenInBits.len,
2523 		"KASUMI Ciphertext data not as expected");
2524 	return 0;
2525 }
2526 
2527 static int
2528 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
2529 {
2530 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2531 	struct crypto_unittest_params *ut_params = &unittest_params;
2532 
2533 	int retval;
2534 	uint8_t *plaintext, *ciphertext;
2535 	unsigned plaintext_pad_len;
2536 	unsigned plaintext_len;
2537 
2538 	/* Create KASUMI session */
2539 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2540 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2541 					RTE_CRYPTO_CIPHER_KASUMI_F8,
2542 					tdata->key.data, tdata->key.len);
2543 	if (retval < 0)
2544 		return retval;
2545 
2546 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2547 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2548 
2549 	/* Clear mbuf payload */
2550 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2551 	       rte_pktmbuf_tailroom(ut_params->ibuf));
2552 
2553 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2554 	/* Append data which is padded to a multiple */
2555 	/* of the algorithms block size */
2556 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2557 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2558 				plaintext_pad_len);
2559 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2560 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2561 
2562 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2563 
2564 	/* Create KASUMI operation */
2565 	retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2566 					tdata->iv.len,
2567 					tdata->plaintext.len,
2568 					tdata->validCipherOffsetLenInBits.len,
2569 					RTE_CRYPTO_CIPHER_KASUMI_F8);
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 
2577 	ut_params->obuf = ut_params->op->sym->m_dst;
2578 	if (ut_params->obuf)
2579 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2580 				+ tdata->iv.len;
2581 	else
2582 		ciphertext = plaintext;
2583 
2584 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2585 
2586 	/* Validate obuf */
2587 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2588 		ciphertext,
2589 		tdata->ciphertext.data,
2590 		tdata->validCipherLenInBits.len,
2591 		"KASUMI Ciphertext data not as expected");
2592 	return 0;
2593 }
2594 
2595 static int
2596 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
2597 {
2598 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2599 	struct crypto_unittest_params *ut_params = &unittest_params;
2600 
2601 	int retval;
2602 	uint8_t *ciphertext, *plaintext;
2603 	unsigned ciphertext_pad_len;
2604 	unsigned ciphertext_len;
2605 
2606 	/* Create KASUMI session */
2607 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2608 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
2609 					RTE_CRYPTO_CIPHER_KASUMI_F8,
2610 					tdata->key.data, tdata->key.len);
2611 	if (retval < 0)
2612 		return retval;
2613 
2614 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2615 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2616 
2617 	/* Clear mbuf payload */
2618 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2619 	       rte_pktmbuf_tailroom(ut_params->ibuf));
2620 
2621 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2622 	/* Append data which is padded to a multiple */
2623 	/* of the algorithms block size */
2624 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2625 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2626 				ciphertext_pad_len);
2627 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
2628 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2629 
2630 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2631 
2632 	/* Create KASUMI operation */
2633 	retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2634 					tdata->iv.len,
2635 					tdata->ciphertext.len,
2636 					tdata->validCipherOffsetLenInBits.len,
2637 					RTE_CRYPTO_CIPHER_KASUMI_F8);
2638 	if (retval < 0)
2639 		return retval;
2640 
2641 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2642 						ut_params->op);
2643 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2644 
2645 	ut_params->obuf = ut_params->op->sym->m_dst;
2646 	if (ut_params->obuf)
2647 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2648 				+ tdata->iv.len;
2649 	else
2650 		plaintext = ciphertext;
2651 
2652 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2653 
2654 	/* Validate obuf */
2655 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2656 		plaintext,
2657 		tdata->plaintext.data,
2658 		tdata->validCipherLenInBits.len,
2659 		"KASUMI Plaintext data not as expected");
2660 	return 0;
2661 }
2662 
2663 static int
2664 test_kasumi_decryption(const struct kasumi_test_data *tdata)
2665 {
2666 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2667 	struct crypto_unittest_params *ut_params = &unittest_params;
2668 
2669 	int retval;
2670 	uint8_t *ciphertext, *plaintext;
2671 	unsigned ciphertext_pad_len;
2672 	unsigned ciphertext_len;
2673 
2674 	/* Create KASUMI session */
2675 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2676 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
2677 					RTE_CRYPTO_CIPHER_KASUMI_F8,
2678 					tdata->key.data, tdata->key.len);
2679 	if (retval < 0)
2680 		return retval;
2681 
2682 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2683 
2684 	/* Clear mbuf payload */
2685 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2686 	       rte_pktmbuf_tailroom(ut_params->ibuf));
2687 
2688 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
2689 	/* Append data which is padded to a multiple */
2690 	/* of the algorithms block size */
2691 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
2692 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2693 				ciphertext_pad_len);
2694 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
2695 
2696 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
2697 
2698 	/* Create KASUMI operation */
2699 	retval = create_wireless_algo_cipher_operation(tdata->iv.data,
2700 					tdata->iv.len,
2701 					tdata->ciphertext.len,
2702 					tdata->validCipherOffsetLenInBits.len,
2703 					RTE_CRYPTO_CIPHER_KASUMI_F8);
2704 	if (retval < 0)
2705 		return retval;
2706 
2707 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2708 						ut_params->op);
2709 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2710 
2711 	ut_params->obuf = ut_params->op->sym->m_dst;
2712 	if (ut_params->obuf)
2713 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2714 				+ tdata->iv.len;
2715 	else
2716 		plaintext = ciphertext;
2717 
2718 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
2719 
2720 	/* Validate obuf */
2721 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2722 		plaintext,
2723 		tdata->plaintext.data,
2724 		tdata->validCipherLenInBits.len,
2725 		"KASUMI Plaintext data not as expected");
2726 	return 0;
2727 }
2728 
2729 static int
2730 test_snow3g_encryption(const struct snow3g_test_data *tdata)
2731 {
2732 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2733 	struct crypto_unittest_params *ut_params = &unittest_params;
2734 
2735 	int retval;
2736 	uint8_t *plaintext, *ciphertext;
2737 	unsigned plaintext_pad_len;
2738 	unsigned plaintext_len;
2739 
2740 	/* Create SNOW 3G session */
2741 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2742 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2743 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2744 					tdata->key.data, tdata->key.len);
2745 	if (retval < 0)
2746 		return retval;
2747 
2748 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2749 
2750 	/* Clear mbuf payload */
2751 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2752 	       rte_pktmbuf_tailroom(ut_params->ibuf));
2753 
2754 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2755 	/* Append data which is padded to a multiple of */
2756 	/* the algorithms block size */
2757 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2758 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2759 				plaintext_pad_len);
2760 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2761 
2762 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2763 
2764 	/* Create SNOW 3G operation */
2765 	retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
2766 					tdata->validCipherLenInBits.len,
2767 					tdata->validCipherOffsetLenInBits.len,
2768 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2769 	if (retval < 0)
2770 		return retval;
2771 
2772 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2773 						ut_params->op);
2774 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2775 
2776 	ut_params->obuf = ut_params->op->sym->m_dst;
2777 	if (ut_params->obuf)
2778 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2779 				+ tdata->iv.len;
2780 	else
2781 		ciphertext = plaintext;
2782 
2783 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2784 
2785 	/* Validate obuf */
2786 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2787 		ciphertext,
2788 		tdata->ciphertext.data,
2789 		tdata->validDataLenInBits.len,
2790 		"SNOW 3G Ciphertext data not as expected");
2791 	return 0;
2792 }
2793 
2794 
2795 static int
2796 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
2797 {
2798 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2799 	struct crypto_unittest_params *ut_params = &unittest_params;
2800 	uint8_t *plaintext, *ciphertext;
2801 
2802 	int retval;
2803 	unsigned plaintext_pad_len;
2804 	unsigned plaintext_len;
2805 
2806 	/* Create SNOW 3G session */
2807 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2808 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2809 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2810 					tdata->key.data, tdata->key.len);
2811 	if (retval < 0)
2812 		return retval;
2813 
2814 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2815 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2816 
2817 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2818 			"Failed to allocate input buffer in mempool");
2819 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
2820 			"Failed to allocate output buffer in mempool");
2821 
2822 	/* Clear mbuf payload */
2823 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2824 	       rte_pktmbuf_tailroom(ut_params->ibuf));
2825 
2826 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
2827 	/* Append data which is padded to a multiple of */
2828 	/* the algorithms block size */
2829 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2830 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2831 				plaintext_pad_len);
2832 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2833 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2834 
2835 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2836 
2837 	/* Create SNOW 3G operation */
2838 	retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2839 					tdata->iv.len,
2840 					tdata->validCipherLenInBits.len,
2841 					tdata->validCipherOffsetLenInBits.len,
2842 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2843 	if (retval < 0)
2844 		return retval;
2845 
2846 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2847 						ut_params->op);
2848 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2849 
2850 	ut_params->obuf = ut_params->op->sym->m_dst;
2851 	if (ut_params->obuf)
2852 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2853 				+ tdata->iv.len;
2854 	else
2855 		ciphertext = plaintext;
2856 
2857 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
2858 
2859 	/* Validate obuf */
2860 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
2861 		ciphertext,
2862 		tdata->ciphertext.data,
2863 		tdata->validDataLenInBits.len,
2864 		"SNOW 3G Ciphertext data not as expected");
2865 	return 0;
2866 }
2867 
2868 /* Shift right a buffer by "offset" bits, "offset" < 8 */
2869 static void
2870 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
2871 {
2872 	uint8_t curr_byte, prev_byte;
2873 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
2874 	uint8_t lower_byte_mask = (1 << offset) - 1;
2875 	unsigned i;
2876 
2877 	prev_byte = buffer[0];
2878 	buffer[0] >>= offset;
2879 
2880 	for (i = 1; i < length_in_bytes; i++) {
2881 		curr_byte = buffer[i];
2882 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
2883 				(curr_byte >> offset);
2884 		prev_byte = curr_byte;
2885 	}
2886 }
2887 
2888 static int
2889 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
2890 {
2891 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2892 	struct crypto_unittest_params *ut_params = &unittest_params;
2893 	uint8_t *plaintext, *ciphertext;
2894 	int retval;
2895 	uint32_t plaintext_len;
2896 	uint32_t plaintext_pad_len;
2897 	uint8_t extra_offset = 4;
2898 	uint8_t *expected_ciphertext_shifted;
2899 
2900 	/* Create SNOW 3G session */
2901 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2902 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2903 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2904 					tdata->key.data, tdata->key.len);
2905 	if (retval < 0)
2906 		return retval;
2907 
2908 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2909 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2910 
2911 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
2912 			"Failed to allocate input buffer in mempool");
2913 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
2914 			"Failed to allocate output buffer in mempool");
2915 
2916 	/* Clear mbuf payload */
2917 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2918 	       rte_pktmbuf_tailroom(ut_params->ibuf));
2919 
2920 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
2921 	/*
2922 	 * Append data which is padded to a
2923 	 * multiple of the algorithms block size
2924 	 */
2925 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2926 
2927 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
2928 						plaintext_pad_len);
2929 
2930 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
2931 
2932 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
2933 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
2934 
2935 #ifdef RTE_APP_TEST_DEBUG
2936 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
2937 #endif
2938 	/* Create SNOW 3G operation */
2939 	retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
2940 					tdata->iv.len,
2941 					tdata->validCipherLenInBits.len,
2942 					tdata->validCipherOffsetLenInBits.len +
2943 					extra_offset,
2944 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
2945 	if (retval < 0)
2946 		return retval;
2947 
2948 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2949 						ut_params->op);
2950 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2951 
2952 	ut_params->obuf = ut_params->op->sym->m_dst;
2953 	if (ut_params->obuf)
2954 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2955 				+ tdata->iv.len;
2956 	else
2957 		ciphertext = plaintext;
2958 
2959 #ifdef RTE_APP_TEST_DEBUG
2960 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
2961 #endif
2962 
2963 	expected_ciphertext_shifted = rte_malloc(NULL,
2964 			ceil_byte_length(plaintext_len + extra_offset), 0);
2965 
2966 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
2967 			"failed to reserve memory for ciphertext shifted\n");
2968 
2969 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
2970 			ceil_byte_length(tdata->ciphertext.len));
2971 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
2972 			extra_offset);
2973 	/* Validate obuf */
2974 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
2975 		ciphertext,
2976 		expected_ciphertext_shifted,
2977 		tdata->validDataLenInBits.len,
2978 		extra_offset,
2979 		"SNOW 3G Ciphertext data not as expected");
2980 	return 0;
2981 }
2982 
2983 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
2984 {
2985 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2986 	struct crypto_unittest_params *ut_params = &unittest_params;
2987 
2988 	int retval;
2989 
2990 	uint8_t *plaintext, *ciphertext;
2991 	unsigned ciphertext_pad_len;
2992 	unsigned ciphertext_len;
2993 
2994 	/* Create SNOW 3G session */
2995 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2996 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
2997 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
2998 					tdata->key.data, tdata->key.len);
2999 	if (retval < 0)
3000 		return retval;
3001 
3002 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3003 
3004 	/* Clear mbuf payload */
3005 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3006 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3007 
3008 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3009 	/* Append data which is padded to a multiple of */
3010 	/* the algorithms block size */
3011 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3012 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3013 				ciphertext_pad_len);
3014 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3015 
3016 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3017 
3018 	/* Create SNOW 3G operation */
3019 	retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3020 					tdata->validCipherLenInBits.len,
3021 					tdata->validCipherOffsetLenInBits.len,
3022 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3023 	if (retval < 0)
3024 		return retval;
3025 
3026 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3027 						ut_params->op);
3028 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3029 	ut_params->obuf = ut_params->op->sym->m_dst;
3030 	if (ut_params->obuf)
3031 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3032 				+ tdata->iv.len;
3033 	else
3034 		plaintext = ciphertext;
3035 
3036 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3037 
3038 	/* Validate obuf */
3039 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3040 				tdata->plaintext.data,
3041 				tdata->validDataLenInBits.len,
3042 				"SNOW 3G Plaintext data not as expected");
3043 	return 0;
3044 }
3045 
3046 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3047 {
3048 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3049 	struct crypto_unittest_params *ut_params = &unittest_params;
3050 
3051 	int retval;
3052 
3053 	uint8_t *plaintext, *ciphertext;
3054 	unsigned ciphertext_pad_len;
3055 	unsigned ciphertext_len;
3056 
3057 	/* Create SNOW 3G session */
3058 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3059 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3060 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3061 					tdata->key.data, tdata->key.len);
3062 	if (retval < 0)
3063 		return retval;
3064 
3065 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3066 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3067 
3068 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3069 			"Failed to allocate input buffer");
3070 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
3071 			"Failed to allocate output buffer");
3072 
3073 	/* Clear mbuf payload */
3074 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3075 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3076 
3077 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3078 		       rte_pktmbuf_tailroom(ut_params->obuf));
3079 
3080 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3081 	/* Append data which is padded to a multiple of */
3082 	/* the algorithms block size */
3083 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3084 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3085 				ciphertext_pad_len);
3086 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3087 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3088 
3089 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3090 
3091 	/* Create SNOW 3G operation */
3092 	retval = create_wireless_algo_cipher_operation_oop(tdata->iv.data,
3093 					tdata->iv.len,
3094 					tdata->validCipherLenInBits.len,
3095 					tdata->validCipherOffsetLenInBits.len,
3096 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2);
3097 	if (retval < 0)
3098 		return retval;
3099 
3100 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3101 						ut_params->op);
3102 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3103 	ut_params->obuf = ut_params->op->sym->m_dst;
3104 	if (ut_params->obuf)
3105 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3106 				+ tdata->iv.len;
3107 	else
3108 		plaintext = ciphertext;
3109 
3110 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3111 
3112 	/* Validate obuf */
3113 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3114 				tdata->plaintext.data,
3115 				tdata->validDataLenInBits.len,
3116 				"SNOW 3G Plaintext data not as expected");
3117 	return 0;
3118 }
3119 
3120 static int
3121 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3122 {
3123 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3124 	struct crypto_unittest_params *ut_params = &unittest_params;
3125 
3126 	int retval;
3127 
3128 	uint8_t *plaintext, *ciphertext;
3129 	unsigned plaintext_pad_len;
3130 	unsigned plaintext_len;
3131 
3132 	/* Create SNOW 3G session */
3133 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3134 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3135 			RTE_CRYPTO_AUTH_OP_GENERATE,
3136 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3137 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3138 			tdata->key.data, tdata->key.len,
3139 			tdata->aad.len, tdata->digest.len);
3140 	if (retval < 0)
3141 		return retval;
3142 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3143 
3144 	/* clear mbuf payload */
3145 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3146 			rte_pktmbuf_tailroom(ut_params->ibuf));
3147 
3148 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3149 	/* Append data which is padded to a multiple of */
3150 	/* the algorithms block size */
3151 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3152 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3153 				plaintext_pad_len);
3154 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3155 
3156 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3157 
3158 	/* Create SNOW 3G operation */
3159 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3160 			tdata->digest.len, tdata->aad.data,
3161 			tdata->aad.len, /*tdata->plaintext.len,*/
3162 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3163 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3164 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3165 			tdata->iv.data, tdata->iv.len,
3166 			tdata->validCipherLenInBits.len,
3167 			tdata->validCipherOffsetLenInBits.len,
3168 			tdata->validAuthLenInBits.len,
3169 			tdata->validAuthOffsetLenInBits.len
3170 			);
3171 	if (retval < 0)
3172 		return retval;
3173 
3174 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3175 			ut_params->op);
3176 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3177 	ut_params->obuf = ut_params->op->sym->m_src;
3178 	if (ut_params->obuf)
3179 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3180 				+ tdata->iv.len + tdata->aad.len;
3181 	else
3182 		ciphertext = plaintext;
3183 
3184 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3185 	/* Validate obuf */
3186 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3187 			ciphertext,
3188 			tdata->ciphertext.data,
3189 			tdata->validDataLenInBits.len,
3190 			"SNOW 3G Ciphertext data not as expected");
3191 
3192 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3193 	    + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3194 
3195 	/* Validate obuf */
3196 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3197 			ut_params->digest,
3198 			tdata->digest.data,
3199 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3200 			"SNOW 3G Generated auth tag not as expected");
3201 	return 0;
3202 }
3203 static int
3204 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
3205 {
3206 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3207 	struct crypto_unittest_params *ut_params = &unittest_params;
3208 
3209 	int retval;
3210 
3211 	uint8_t *plaintext, *ciphertext;
3212 	unsigned plaintext_pad_len;
3213 	unsigned plaintext_len;
3214 
3215 	/* Create SNOW 3G session */
3216 	retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
3217 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3218 			RTE_CRYPTO_AUTH_OP_GENERATE,
3219 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3220 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3221 			tdata->key.data, tdata->key.len,
3222 			tdata->aad.len, tdata->digest.len);
3223 	if (retval < 0)
3224 		return retval;
3225 
3226 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3227 
3228 	/* clear mbuf payload */
3229 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3230 			rte_pktmbuf_tailroom(ut_params->ibuf));
3231 
3232 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3233 	/* Append data which is padded to a multiple of */
3234 	/* the algorithms block size */
3235 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3236 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3237 				plaintext_pad_len);
3238 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3239 
3240 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3241 
3242 	/* Create SNOW 3G operation */
3243 	retval = create_wireless_algo_auth_cipher_operation(
3244 		tdata->digest.len,
3245 		tdata->iv.data, tdata->iv.len,
3246 		tdata->aad.data, tdata->aad.len,
3247 		plaintext_pad_len,
3248 		tdata->validCipherLenInBits.len,
3249 		tdata->validCipherOffsetLenInBits.len,
3250 		tdata->validAuthLenInBits.len,
3251 		tdata->validAuthOffsetLenInBits.len,
3252 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3253 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
3254 	);
3255 
3256 	if (retval < 0)
3257 		return retval;
3258 
3259 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3260 			ut_params->op);
3261 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3262 	ut_params->obuf = ut_params->op->sym->m_src;
3263 	if (ut_params->obuf)
3264 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3265 				+ tdata->aad.len + tdata->iv.len;
3266 	else
3267 		ciphertext = plaintext;
3268 
3269 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3270 			+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3271 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3272 
3273 	/* Validate obuf */
3274 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3275 		ciphertext,
3276 		tdata->ciphertext.data,
3277 		tdata->validDataLenInBits.len,
3278 		"SNOW 3G Ciphertext data not as expected");
3279 
3280 	/* Validate obuf */
3281 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3282 		ut_params->digest,
3283 		tdata->digest.data,
3284 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3285 		"SNOW 3G Generated auth tag not as expected");
3286 	return 0;
3287 }
3288 
3289 static int
3290 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
3291 {
3292 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3293 	struct crypto_unittest_params *ut_params = &unittest_params;
3294 
3295 	int retval;
3296 
3297 	uint8_t *plaintext, *ciphertext;
3298 	unsigned plaintext_pad_len;
3299 	unsigned plaintext_len;
3300 
3301 	/* Create KASUMI session */
3302 	retval = create_wireless_algo_auth_cipher_session(
3303 			ts_params->valid_devs[0],
3304 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3305 			RTE_CRYPTO_AUTH_OP_GENERATE,
3306 			RTE_CRYPTO_AUTH_KASUMI_F9,
3307 			RTE_CRYPTO_CIPHER_KASUMI_F8,
3308 			tdata->key.data, tdata->key.len,
3309 			tdata->aad.len, tdata->digest.len);
3310 	if (retval < 0)
3311 		return retval;
3312 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3313 
3314 	/* clear mbuf payload */
3315 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3316 			rte_pktmbuf_tailroom(ut_params->ibuf));
3317 
3318 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3319 	/* Append data which is padded to a multiple of */
3320 	/* the algorithms block size */
3321 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3322 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3323 				plaintext_pad_len);
3324 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3325 
3326 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3327 
3328 	/* Create KASUMI operation */
3329 	retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
3330 				tdata->iv.data, tdata->iv.len,
3331 				tdata->aad.data, tdata->aad.len,
3332 				plaintext_pad_len,
3333 				tdata->validCipherLenInBits.len,
3334 				tdata->validCipherOffsetLenInBits.len,
3335 				tdata->validAuthLenInBits.len,
3336 				tdata->validAuthOffsetLenInBits.len,
3337 				RTE_CRYPTO_AUTH_KASUMI_F9,
3338 				RTE_CRYPTO_CIPHER_KASUMI_F8
3339 				);
3340 
3341 	if (retval < 0)
3342 		return retval;
3343 
3344 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3345 			ut_params->op);
3346 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3347 	ut_params->obuf = ut_params->op->sym->m_src;
3348 	if (ut_params->obuf)
3349 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3350 				+ tdata->iv.len + tdata->aad.len;
3351 	else
3352 		ciphertext = plaintext;
3353 
3354 	/* Validate obuf */
3355 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3356 			ciphertext,
3357 			tdata->ciphertext.data,
3358 			tdata->validCipherLenInBits.len,
3359 			"KASUMI Ciphertext data not as expected");
3360 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3361 	    + plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3362 
3363 	/* Validate obuf */
3364 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3365 			ut_params->digest,
3366 			tdata->digest.data,
3367 			DIGEST_BYTE_LENGTH_KASUMI_F9,
3368 			"KASUMI Generated auth tag not as expected");
3369 	return 0;
3370 }
3371 
3372 static int
3373 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
3374 {
3375 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3376 	struct crypto_unittest_params *ut_params = &unittest_params;
3377 
3378 	int retval;
3379 
3380 	uint8_t *plaintext, *ciphertext;
3381 	unsigned plaintext_pad_len;
3382 	unsigned plaintext_len;
3383 
3384 	/* Create KASUMI session */
3385 	retval = create_wireless_algo_cipher_auth_session(
3386 			ts_params->valid_devs[0],
3387 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3388 			RTE_CRYPTO_AUTH_OP_GENERATE,
3389 			RTE_CRYPTO_AUTH_KASUMI_F9,
3390 			RTE_CRYPTO_CIPHER_KASUMI_F8,
3391 			tdata->key.data, tdata->key.len,
3392 			tdata->aad.len, tdata->digest.len);
3393 	if (retval < 0)
3394 		return retval;
3395 
3396 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3397 
3398 	/* clear mbuf payload */
3399 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3400 			rte_pktmbuf_tailroom(ut_params->ibuf));
3401 
3402 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3403 	/* Append data which is padded to a multiple of */
3404 	/* the algorithms block size */
3405 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3406 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3407 				plaintext_pad_len);
3408 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3409 
3410 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3411 
3412 	/* Create KASUMI operation */
3413 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3414 				tdata->digest.len, tdata->aad.data,
3415 				tdata->aad.len,
3416 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3417 				RTE_CRYPTO_AUTH_KASUMI_F9,
3418 				RTE_CRYPTO_CIPHER_KASUMI_F8,
3419 				tdata->iv.data, tdata->iv.len,
3420 				tdata->validCipherLenInBits.len,
3421 				tdata->validCipherOffsetLenInBits.len,
3422 				tdata->validAuthLenInBits.len,
3423 				tdata->validAuthOffsetLenInBits.len
3424 				);
3425 	if (retval < 0)
3426 		return retval;
3427 
3428 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3429 			ut_params->op);
3430 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3431 	ut_params->obuf = ut_params->op->sym->m_src;
3432 	if (ut_params->obuf)
3433 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3434 				+ tdata->aad.len + tdata->iv.len;
3435 	else
3436 		ciphertext = plaintext;
3437 
3438 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3439 			+ plaintext_pad_len + tdata->aad.len + tdata->iv.len;
3440 
3441 	/* Validate obuf */
3442 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3443 		ciphertext,
3444 		tdata->ciphertext.data,
3445 		tdata->validCipherLenInBits.len,
3446 		"KASUMI Ciphertext data not as expected");
3447 
3448 	/* Validate obuf */
3449 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3450 		ut_params->digest,
3451 		tdata->digest.data,
3452 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3453 		"KASUMI Generated auth tag not as expected");
3454 	return 0;
3455 }
3456 
3457 static int
3458 test_zuc_encryption(const struct zuc_test_data *tdata)
3459 {
3460 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3461 	struct crypto_unittest_params *ut_params = &unittest_params;
3462 
3463 	int retval;
3464 	uint8_t *plaintext, *ciphertext;
3465 	unsigned plaintext_pad_len;
3466 	unsigned plaintext_len;
3467 
3468 	/* Create ZUC session */
3469 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3470 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3471 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
3472 					tdata->key.data, tdata->key.len);
3473 	if (retval < 0)
3474 		return retval;
3475 
3476 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3477 
3478 	/* Clear mbuf payload */
3479 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3480 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3481 
3482 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3483 	/* Append data which is padded to a multiple */
3484 	/* of the algorithms block size */
3485 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3486 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3487 				plaintext_pad_len);
3488 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3489 
3490 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3491 
3492 	/* Create ZUC operation */
3493 	retval = create_wireless_algo_cipher_operation(tdata->iv.data, tdata->iv.len,
3494 					tdata->plaintext.len,
3495 					tdata->validCipherOffsetLenInBits.len,
3496 					RTE_CRYPTO_CIPHER_ZUC_EEA3);
3497 	if (retval < 0)
3498 		return retval;
3499 
3500 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3501 						ut_params->op);
3502 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3503 
3504 	ut_params->obuf = ut_params->op->sym->m_dst;
3505 	if (ut_params->obuf)
3506 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3507 				+ tdata->iv.len;
3508 	else
3509 		ciphertext = plaintext;
3510 
3511 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3512 
3513 	/* Validate obuf */
3514 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3515 		ciphertext,
3516 		tdata->ciphertext.data,
3517 		tdata->validCipherLenInBits.len,
3518 		"ZUC Ciphertext data not as expected");
3519 	return 0;
3520 }
3521 
3522 static int
3523 test_zuc_authentication(const struct zuc_hash_test_data *tdata)
3524 {
3525 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3526 	struct crypto_unittest_params *ut_params = &unittest_params;
3527 
3528 	int retval;
3529 	unsigned plaintext_pad_len;
3530 	unsigned plaintext_len;
3531 	uint8_t *plaintext;
3532 
3533 	/* Create ZUC session */
3534 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3535 			tdata->key.data, tdata->key.len,
3536 			tdata->aad.len, tdata->digest.len,
3537 			RTE_CRYPTO_AUTH_OP_GENERATE,
3538 			RTE_CRYPTO_AUTH_ZUC_EIA3);
3539 	if (retval < 0)
3540 		return retval;
3541 
3542 	/* alloc mbuf and set payload */
3543 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3544 
3545 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3546 	rte_pktmbuf_tailroom(ut_params->ibuf));
3547 
3548 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3549 	/* Append data which is padded to a multiple of */
3550 	/* the algorithms block size */
3551 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3552 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3553 				plaintext_pad_len);
3554 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3555 
3556 	/* Create ZUC operation */
3557 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3558 			tdata->aad.data, tdata->aad.len,
3559 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3560 			RTE_CRYPTO_AUTH_ZUC_EIA3,
3561 			tdata->validAuthLenInBits.len,
3562 			tdata->validAuthOffsetLenInBits.len);
3563 	if (retval < 0)
3564 		return retval;
3565 
3566 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3567 				ut_params->op);
3568 	ut_params->obuf = ut_params->op->sym->m_src;
3569 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3570 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3571 			+ plaintext_pad_len + ALIGN_POW2_ROUNDUP(tdata->aad.len, 8);
3572 
3573 	/* Validate obuf */
3574 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3575 	ut_params->digest,
3576 	tdata->digest.data,
3577 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3578 	"ZUC Generated auth tag not as expected");
3579 
3580 	return 0;
3581 }
3582 
3583 static int
3584 test_kasumi_encryption_test_case_1(void)
3585 {
3586 	return test_kasumi_encryption(&kasumi_test_case_1);
3587 }
3588 
3589 static int
3590 test_kasumi_encryption_test_case_1_oop(void)
3591 {
3592 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
3593 }
3594 
3595 static int
3596 test_kasumi_encryption_test_case_2(void)
3597 {
3598 	return test_kasumi_encryption(&kasumi_test_case_2);
3599 }
3600 
3601 static int
3602 test_kasumi_encryption_test_case_3(void)
3603 {
3604 	return test_kasumi_encryption(&kasumi_test_case_3);
3605 }
3606 
3607 static int
3608 test_kasumi_encryption_test_case_4(void)
3609 {
3610 	return test_kasumi_encryption(&kasumi_test_case_4);
3611 }
3612 
3613 static int
3614 test_kasumi_encryption_test_case_5(void)
3615 {
3616 	return test_kasumi_encryption(&kasumi_test_case_5);
3617 }
3618 
3619 static int
3620 test_kasumi_decryption_test_case_1(void)
3621 {
3622 	return test_kasumi_decryption(&kasumi_test_case_1);
3623 }
3624 
3625 static int
3626 test_kasumi_decryption_test_case_1_oop(void)
3627 {
3628 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
3629 }
3630 
3631 static int
3632 test_kasumi_decryption_test_case_2(void)
3633 {
3634 	return test_kasumi_decryption(&kasumi_test_case_2);
3635 }
3636 
3637 static int
3638 test_kasumi_decryption_test_case_3(void)
3639 {
3640 	return test_kasumi_decryption(&kasumi_test_case_3);
3641 }
3642 
3643 static int
3644 test_kasumi_decryption_test_case_4(void)
3645 {
3646 	return test_kasumi_decryption(&kasumi_test_case_4);
3647 }
3648 
3649 static int
3650 test_kasumi_decryption_test_case_5(void)
3651 {
3652 	return test_kasumi_decryption(&kasumi_test_case_5);
3653 }
3654 static int
3655 test_snow3g_encryption_test_case_1(void)
3656 {
3657 	return test_snow3g_encryption(&snow3g_test_case_1);
3658 }
3659 
3660 static int
3661 test_snow3g_encryption_test_case_1_oop(void)
3662 {
3663 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
3664 }
3665 
3666 static int
3667 test_snow3g_encryption_test_case_1_offset_oop(void)
3668 {
3669 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
3670 }
3671 
3672 static int
3673 test_snow3g_encryption_test_case_2(void)
3674 {
3675 	return test_snow3g_encryption(&snow3g_test_case_2);
3676 }
3677 
3678 static int
3679 test_snow3g_encryption_test_case_3(void)
3680 {
3681 	return test_snow3g_encryption(&snow3g_test_case_3);
3682 }
3683 
3684 static int
3685 test_snow3g_encryption_test_case_4(void)
3686 {
3687 	return test_snow3g_encryption(&snow3g_test_case_4);
3688 }
3689 
3690 static int
3691 test_snow3g_encryption_test_case_5(void)
3692 {
3693 	return test_snow3g_encryption(&snow3g_test_case_5);
3694 }
3695 
3696 static int
3697 test_snow3g_decryption_test_case_1(void)
3698 {
3699 	return test_snow3g_decryption(&snow3g_test_case_1);
3700 }
3701 
3702 static int
3703 test_snow3g_decryption_test_case_1_oop(void)
3704 {
3705 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
3706 }
3707 
3708 static int
3709 test_snow3g_decryption_test_case_2(void)
3710 {
3711 	return test_snow3g_decryption(&snow3g_test_case_2);
3712 }
3713 
3714 static int
3715 test_snow3g_decryption_test_case_3(void)
3716 {
3717 	return test_snow3g_decryption(&snow3g_test_case_3);
3718 }
3719 
3720 static int
3721 test_snow3g_decryption_test_case_4(void)
3722 {
3723 	return test_snow3g_decryption(&snow3g_test_case_4);
3724 }
3725 
3726 static int
3727 test_snow3g_decryption_test_case_5(void)
3728 {
3729 	return test_snow3g_decryption(&snow3g_test_case_5);
3730 }
3731 static int
3732 test_snow3g_cipher_auth_test_case_1(void)
3733 {
3734 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
3735 }
3736 
3737 static int
3738 test_snow3g_auth_cipher_test_case_1(void)
3739 {
3740 	return test_snow3g_auth_cipher(&snow3g_test_case_6);
3741 }
3742 
3743 static int
3744 test_kasumi_auth_cipher_test_case_1(void)
3745 {
3746 	return test_kasumi_auth_cipher(&kasumi_test_case_3);
3747 }
3748 
3749 static int
3750 test_kasumi_cipher_auth_test_case_1(void)
3751 {
3752 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
3753 }
3754 
3755 static int
3756 test_zuc_encryption_test_case_1(void)
3757 {
3758 	return test_zuc_encryption(&zuc_test_case_1);
3759 }
3760 
3761 static int
3762 test_zuc_encryption_test_case_2(void)
3763 {
3764 	return test_zuc_encryption(&zuc_test_case_2);
3765 }
3766 
3767 static int
3768 test_zuc_encryption_test_case_3(void)
3769 {
3770 	return test_zuc_encryption(&zuc_test_case_3);
3771 }
3772 
3773 static int
3774 test_zuc_encryption_test_case_4(void)
3775 {
3776 	return test_zuc_encryption(&zuc_test_case_4);
3777 }
3778 
3779 static int
3780 test_zuc_encryption_test_case_5(void)
3781 {
3782 	return test_zuc_encryption(&zuc_test_case_5);
3783 }
3784 
3785 static int
3786 test_zuc_hash_generate_test_case_1(void)
3787 {
3788 	return test_zuc_authentication(&zuc_hash_test_case_1);
3789 }
3790 
3791 static int
3792 test_zuc_hash_generate_test_case_2(void)
3793 {
3794 	return test_zuc_authentication(&zuc_hash_test_case_2);
3795 }
3796 
3797 static int
3798 test_zuc_hash_generate_test_case_3(void)
3799 {
3800 	return test_zuc_authentication(&zuc_hash_test_case_3);
3801 }
3802 
3803 static int
3804 test_zuc_hash_generate_test_case_4(void)
3805 {
3806 	return test_zuc_authentication(&zuc_hash_test_case_4);
3807 }
3808 
3809 static int
3810 test_zuc_hash_generate_test_case_5(void)
3811 {
3812 	return test_zuc_authentication(&zuc_hash_test_case_5);
3813 }
3814 
3815 static int
3816 test_3DES_chain_qat_all(void)
3817 {
3818 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3819 	int status;
3820 
3821 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3822 		ts_params->op_mpool, ts_params->valid_devs[0],
3823 		RTE_CRYPTODEV_QAT_SYM_PMD,
3824 		BLKCIPHER_3DES_CHAIN_TYPE);
3825 
3826 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
3827 
3828 	return TEST_SUCCESS;
3829 }
3830 
3831 static int
3832 test_DES_cipheronly_qat_all(void)
3833 {
3834 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3835 	int status;
3836 
3837 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3838 		ts_params->op_mpool, ts_params->valid_devs[0],
3839 		RTE_CRYPTODEV_QAT_SYM_PMD,
3840 		BLKCIPHER_DES_CIPHERONLY_TYPE);
3841 
3842 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
3843 
3844 	return TEST_SUCCESS;
3845 }
3846 
3847 static int
3848 test_3DES_cipheronly_qat_all(void)
3849 {
3850 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3851 	int status;
3852 
3853 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3854 		ts_params->op_mpool, ts_params->valid_devs[0],
3855 		RTE_CRYPTODEV_QAT_SYM_PMD,
3856 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
3857 
3858 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
3859 
3860 	return TEST_SUCCESS;
3861 }
3862 
3863 static int
3864 test_3DES_chain_openssl_all(void)
3865 {
3866 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3867 	int status;
3868 
3869 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3870 		ts_params->op_mpool, ts_params->valid_devs[0],
3871 		RTE_CRYPTODEV_OPENSSL_PMD,
3872 		BLKCIPHER_3DES_CHAIN_TYPE);
3873 
3874 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
3875 
3876 	return TEST_SUCCESS;
3877 }
3878 
3879 static int
3880 test_3DES_cipheronly_openssl_all(void)
3881 {
3882 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3883 	int status;
3884 
3885 	status = test_blockcipher_all_tests(ts_params->mbuf_pool,
3886 		ts_params->op_mpool, ts_params->valid_devs[0],
3887 		RTE_CRYPTODEV_OPENSSL_PMD,
3888 		BLKCIPHER_3DES_CIPHERONLY_TYPE);
3889 
3890 	TEST_ASSERT_EQUAL(status, 0, "Test failed");
3891 
3892 	return TEST_SUCCESS;
3893 }
3894 
3895 /* ***** AES-GCM Tests ***** */
3896 
3897 static int
3898 create_gcm_session(uint8_t dev_id, enum rte_crypto_cipher_operation op,
3899 		const uint8_t *key, const uint8_t key_len,
3900 		const uint8_t aad_len, const uint8_t auth_len,
3901 		enum rte_crypto_auth_operation auth_op)
3902 {
3903 	uint8_t cipher_key[key_len];
3904 
3905 	struct crypto_unittest_params *ut_params = &unittest_params;
3906 
3907 	memcpy(cipher_key, key, key_len);
3908 
3909 	/* Setup Cipher Parameters */
3910 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3911 	ut_params->cipher_xform.next = NULL;
3912 
3913 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
3914 	ut_params->auth_xform.auth.op = auth_op;
3915 	ut_params->cipher_xform.cipher.op = op;
3916 	ut_params->cipher_xform.cipher.key.data = cipher_key;
3917 	ut_params->cipher_xform.cipher.key.length = key_len;
3918 
3919 	TEST_HEXDUMP(stdout, "key:", key, key_len);
3920 
3921 	/* Setup Authentication Parameters */
3922 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3923 	ut_params->auth_xform.next = NULL;
3924 
3925 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GCM;
3926 
3927 	ut_params->auth_xform.auth.digest_length = auth_len;
3928 	ut_params->auth_xform.auth.add_auth_data_length = aad_len;
3929 	ut_params->auth_xform.auth.key.length = 0;
3930 	ut_params->auth_xform.auth.key.data = NULL;
3931 
3932 	if (op == RTE_CRYPTO_CIPHER_OP_ENCRYPT) {
3933 		ut_params->cipher_xform.next = &ut_params->auth_xform;
3934 
3935 		/* Create Crypto session*/
3936 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3937 				&ut_params->cipher_xform);
3938 	} else {/* Create Crypto session*/
3939 		ut_params->auth_xform.next = &ut_params->cipher_xform;
3940 		ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
3941 				&ut_params->auth_xform);
3942 	}
3943 
3944 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
3945 
3946 	return 0;
3947 }
3948 
3949 static int
3950 create_gcm_operation(enum rte_crypto_cipher_operation op,
3951 		const uint8_t *auth_tag, const unsigned auth_tag_len,
3952 		const uint8_t *iv, const unsigned iv_len,
3953 		const uint8_t *aad, const unsigned aad_len,
3954 		const unsigned data_len, unsigned data_pad_len)
3955 {
3956 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3957 	struct crypto_unittest_params *ut_params = &unittest_params;
3958 
3959 	unsigned iv_pad_len = 0, aad_buffer_len;
3960 
3961 	/* Generate Crypto op data structure */
3962 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3963 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3964 	TEST_ASSERT_NOT_NULL(ut_params->op,
3965 			"Failed to allocate symmetric crypto operation struct");
3966 
3967 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3968 
3969 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3970 			ut_params->ibuf, auth_tag_len);
3971 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3972 			"no room to append digest");
3973 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
3974 			ut_params->ibuf, data_pad_len);
3975 	sym_op->auth.digest.length = auth_tag_len;
3976 
3977 	if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
3978 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3979 		TEST_HEXDUMP(stdout, "digest:",
3980 				sym_op->auth.digest.data,
3981 				sym_op->auth.digest.length);
3982 	}
3983 
3984 	/* iv */
3985 	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
3986 
3987 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
3988 			ut_params->ibuf, iv_pad_len);
3989 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
3990 
3991 	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
3992 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
3993 	sym_op->cipher.iv.length = iv_len;
3994 
3995 	rte_memcpy(sym_op->cipher.iv.data, iv, iv_len);
3996 
3997 	/*
3998 	 * Always allocate the aad up to the block size.
3999 	 * The cryptodev API calls out -
4000 	 *  - the array must be big enough to hold the AAD, plus any
4001 	 *   space to round this up to the nearest multiple of the
4002 	 *   block size (16 bytes).
4003 	 */
4004 	aad_buffer_len = ALIGN_POW2_ROUNDUP(aad_len, 16);
4005 
4006 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
4007 			ut_params->ibuf, aad_buffer_len);
4008 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
4009 			"no room to prepend aad");
4010 	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
4011 			ut_params->ibuf);
4012 	sym_op->auth.aad.length = aad_len;
4013 
4014 	memset(sym_op->auth.aad.data, 0, aad_buffer_len);
4015 	rte_memcpy(sym_op->auth.aad.data, aad, aad_len);
4016 
4017 	TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
4018 	TEST_HEXDUMP(stdout, "aad:",
4019 			sym_op->auth.aad.data, aad_len);
4020 
4021 	sym_op->cipher.data.length = data_len;
4022 	sym_op->cipher.data.offset = aad_buffer_len + iv_pad_len;
4023 
4024 	sym_op->auth.data.offset = aad_buffer_len + iv_pad_len;
4025 	sym_op->auth.data.length = data_len;
4026 
4027 	return 0;
4028 }
4029 
4030 static int
4031 test_mb_AES_GCM_authenticated_encryption(const struct gcm_test_data *tdata)
4032 {
4033 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4034 	struct crypto_unittest_params *ut_params = &unittest_params;
4035 
4036 	int retval;
4037 
4038 	uint8_t *plaintext, *ciphertext, *auth_tag;
4039 	uint16_t plaintext_pad_len;
4040 
4041 	/* Create GCM session */
4042 	retval = create_gcm_session(ts_params->valid_devs[0],
4043 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4044 			tdata->key.data, tdata->key.len,
4045 			tdata->aad.len, tdata->auth_tag.len,
4046 			RTE_CRYPTO_AUTH_OP_GENERATE);
4047 	if (retval < 0)
4048 		return retval;
4049 
4050 
4051 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4052 
4053 	/* clear mbuf payload */
4054 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4055 			rte_pktmbuf_tailroom(ut_params->ibuf));
4056 
4057 	/*
4058 	 * Append data which is padded to a multiple
4059 	 * of the algorithms block size
4060 	 */
4061 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
4062 
4063 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4064 			plaintext_pad_len);
4065 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
4066 
4067 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4068 
4069 	/* Create GCM opertaion */
4070 	retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4071 			tdata->auth_tag.data, tdata->auth_tag.len,
4072 			tdata->iv.data, tdata->iv.len,
4073 			tdata->aad.data, tdata->aad.len,
4074 			tdata->plaintext.len, plaintext_pad_len);
4075 	if (retval < 0)
4076 		return retval;
4077 
4078 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4079 
4080 	ut_params->op->sym->m_src = ut_params->ibuf;
4081 
4082 	/* Process crypto operation */
4083 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4084 			ut_params->op), "failed to process sym crypto op");
4085 
4086 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4087 			"crypto op processing failed");
4088 
4089 	if (ut_params->op->sym->m_dst) {
4090 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4091 				uint8_t *);
4092 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4093 				uint8_t *, plaintext_pad_len);
4094 	} else {
4095 		ciphertext = plaintext;
4096 		auth_tag = plaintext + plaintext_pad_len;
4097 	}
4098 
4099 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4100 	TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
4101 
4102 	/* Validate obuf */
4103 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4104 			ciphertext,
4105 			tdata->ciphertext.data,
4106 			tdata->ciphertext.len,
4107 			"GCM Ciphertext data not as expected");
4108 
4109 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4110 			auth_tag,
4111 			tdata->auth_tag.data,
4112 			tdata->auth_tag.len,
4113 			"GCM Generated auth tag not as expected");
4114 
4115 	return 0;
4116 
4117 }
4118 
4119 static int
4120 test_mb_AES_GCM_authenticated_encryption_test_case_1(void)
4121 {
4122 	return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_1);
4123 }
4124 
4125 static int
4126 test_mb_AES_GCM_authenticated_encryption_test_case_2(void)
4127 {
4128 	return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_2);
4129 }
4130 
4131 static int
4132 test_mb_AES_GCM_authenticated_encryption_test_case_3(void)
4133 {
4134 	return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_3);
4135 }
4136 
4137 static int
4138 test_mb_AES_GCM_authenticated_encryption_test_case_4(void)
4139 {
4140 	return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_4);
4141 }
4142 
4143 static int
4144 test_mb_AES_GCM_authenticated_encryption_test_case_5(void)
4145 {
4146 	return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_5);
4147 }
4148 
4149 static int
4150 test_mb_AES_GCM_authenticated_encryption_test_case_6(void)
4151 {
4152 	return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_6);
4153 }
4154 
4155 static int
4156 test_mb_AES_GCM_authenticated_encryption_test_case_7(void)
4157 {
4158 	return test_mb_AES_GCM_authenticated_encryption(&gcm_test_case_7);
4159 }
4160 
4161 static int
4162 test_mb_AES_GCM_authenticated_decryption(const struct gcm_test_data *tdata)
4163 {
4164 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4165 	struct crypto_unittest_params *ut_params = &unittest_params;
4166 
4167 	int retval;
4168 
4169 	uint8_t *plaintext, *ciphertext;
4170 	uint16_t ciphertext_pad_len;
4171 
4172 	/* Create GCM session */
4173 	retval = create_gcm_session(ts_params->valid_devs[0],
4174 			RTE_CRYPTO_CIPHER_OP_DECRYPT,
4175 			tdata->key.data, tdata->key.len,
4176 			tdata->aad.len, tdata->auth_tag.len,
4177 			RTE_CRYPTO_AUTH_OP_VERIFY);
4178 	if (retval < 0)
4179 		return retval;
4180 
4181 
4182 	/* alloc mbuf and set payload */
4183 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4184 
4185 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4186 			rte_pktmbuf_tailroom(ut_params->ibuf));
4187 
4188 	ciphertext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
4189 
4190 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4191 			ciphertext_pad_len);
4192 	memcpy(ciphertext, tdata->ciphertext.data, tdata->ciphertext.len);
4193 
4194 	TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
4195 
4196 	/* Create GCM opertaion */
4197 	retval = create_gcm_operation(RTE_CRYPTO_CIPHER_OP_DECRYPT,
4198 			tdata->auth_tag.data, tdata->auth_tag.len,
4199 			tdata->iv.data, tdata->iv.len,
4200 			tdata->aad.data, tdata->aad.len,
4201 			tdata->ciphertext.len, ciphertext_pad_len);
4202 	if (retval < 0)
4203 		return retval;
4204 
4205 
4206 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4207 
4208 	ut_params->op->sym->m_src = ut_params->ibuf;
4209 
4210 	/* Process crypto operation */
4211 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4212 			ut_params->op), "failed to process sym crypto op");
4213 
4214 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4215 			"crypto op processing failed");
4216 
4217 	if (ut_params->op->sym->m_dst)
4218 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
4219 				uint8_t *);
4220 	else
4221 		plaintext = ciphertext;
4222 
4223 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
4224 
4225 	/* Validate obuf */
4226 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4227 			plaintext,
4228 			tdata->plaintext.data,
4229 			tdata->plaintext.len,
4230 			"GCM plaintext data not as expected");
4231 
4232 	TEST_ASSERT_EQUAL(ut_params->op->status,
4233 			RTE_CRYPTO_OP_STATUS_SUCCESS,
4234 			"GCM authentication failed");
4235 	return 0;
4236 }
4237 
4238 static int
4239 test_mb_AES_GCM_authenticated_decryption_test_case_1(void)
4240 {
4241 	return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_1);
4242 }
4243 
4244 static int
4245 test_mb_AES_GCM_authenticated_decryption_test_case_2(void)
4246 {
4247 	return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_2);
4248 }
4249 
4250 static int
4251 test_mb_AES_GCM_authenticated_decryption_test_case_3(void)
4252 {
4253 	return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_3);
4254 }
4255 
4256 static int
4257 test_mb_AES_GCM_authenticated_decryption_test_case_4(void)
4258 {
4259 	return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_4);
4260 }
4261 
4262 static int
4263 test_mb_AES_GCM_authenticated_decryption_test_case_5(void)
4264 {
4265 	return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_5);
4266 }
4267 
4268 static int
4269 test_mb_AES_GCM_authenticated_decryption_test_case_6(void)
4270 {
4271 	return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_6);
4272 }
4273 
4274 static int
4275 test_mb_AES_GCM_authenticated_decryption_test_case_7(void)
4276 {
4277 	return test_mb_AES_GCM_authenticated_decryption(&gcm_test_case_7);
4278 }
4279 
4280 static int
4281 test_stats(void)
4282 {
4283 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4284 	struct rte_cryptodev_stats stats;
4285 	struct rte_cryptodev *dev;
4286 	cryptodev_stats_get_t temp_pfn;
4287 
4288 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4289 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
4290 			&stats) == -ENODEV),
4291 		"rte_cryptodev_stats_get invalid dev failed");
4292 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
4293 		"rte_cryptodev_stats_get invalid Param failed");
4294 	dev = &rte_cryptodevs[ts_params->valid_devs[0]];
4295 	temp_pfn = dev->dev_ops->stats_get;
4296 	dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
4297 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
4298 			== -ENOTSUP),
4299 		"rte_cryptodev_stats_get invalid Param failed");
4300 	dev->dev_ops->stats_get = temp_pfn;
4301 
4302 	/* Test expected values */
4303 	ut_setup();
4304 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
4305 	ut_teardown();
4306 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4307 			&stats),
4308 		"rte_cryptodev_stats_get failed");
4309 	TEST_ASSERT((stats.enqueued_count == 1),
4310 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
4311 	TEST_ASSERT((stats.dequeued_count == 1),
4312 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
4313 	TEST_ASSERT((stats.enqueue_err_count == 0),
4314 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
4315 	TEST_ASSERT((stats.dequeue_err_count == 0),
4316 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
4317 
4318 	/* invalid device but should ignore and not reset device stats*/
4319 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
4320 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4321 			&stats),
4322 		"rte_cryptodev_stats_get failed");
4323 	TEST_ASSERT((stats.enqueued_count == 1),
4324 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
4325 
4326 	/* check that a valid reset clears stats */
4327 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
4328 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
4329 			&stats),
4330 					  "rte_cryptodev_stats_get failed");
4331 	TEST_ASSERT((stats.enqueued_count == 0),
4332 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
4333 	TEST_ASSERT((stats.dequeued_count == 0),
4334 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
4335 
4336 	return TEST_SUCCESS;
4337 }
4338 
4339 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
4340 				   struct crypto_unittest_params *ut_params,
4341 				   enum rte_crypto_auth_operation op,
4342 				   const struct HMAC_MD5_vector *test_case)
4343 {
4344 	uint8_t key[64];
4345 
4346 	memcpy(key, test_case->key.data, test_case->key.len);
4347 
4348 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4349 	ut_params->auth_xform.next = NULL;
4350 	ut_params->auth_xform.auth.op = op;
4351 
4352 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
4353 
4354 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
4355 	ut_params->auth_xform.auth.add_auth_data_length = 0;
4356 	ut_params->auth_xform.auth.key.length = test_case->key.len;
4357 	ut_params->auth_xform.auth.key.data = key;
4358 
4359 	ut_params->sess = rte_cryptodev_sym_session_create(
4360 		ts_params->valid_devs[0], &ut_params->auth_xform);
4361 
4362 	if (ut_params->sess == NULL)
4363 		return TEST_FAILED;
4364 
4365 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4366 
4367 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4368 			rte_pktmbuf_tailroom(ut_params->ibuf));
4369 
4370 	return 0;
4371 }
4372 
4373 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
4374 			      const struct HMAC_MD5_vector *test_case,
4375 			      uint8_t **plaintext)
4376 {
4377 	uint16_t plaintext_pad_len;
4378 
4379 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4380 
4381 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4382 				16);
4383 
4384 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4385 			plaintext_pad_len);
4386 	memcpy(*plaintext, test_case->plaintext.data,
4387 			test_case->plaintext.len);
4388 
4389 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
4390 			ut_params->ibuf, MD5_DIGEST_LEN);
4391 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
4392 			"no room to append digest");
4393 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
4394 			ut_params->ibuf, plaintext_pad_len);
4395 	sym_op->auth.digest.length = MD5_DIGEST_LEN;
4396 
4397 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
4398 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
4399 			   test_case->auth_tag.len);
4400 	}
4401 
4402 	sym_op->auth.data.offset = 0;
4403 	sym_op->auth.data.length = test_case->plaintext.len;
4404 
4405 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4406 	ut_params->op->sym->m_src = ut_params->ibuf;
4407 
4408 	return 0;
4409 }
4410 
4411 static int
4412 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
4413 {
4414 	uint16_t plaintext_pad_len;
4415 	uint8_t *plaintext, *auth_tag;
4416 
4417 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4418 	struct crypto_unittest_params *ut_params = &unittest_params;
4419 
4420 	if (MD5_HMAC_create_session(ts_params, ut_params,
4421 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
4422 		return TEST_FAILED;
4423 
4424 	/* Generate Crypto op data structure */
4425 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4426 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4427 	TEST_ASSERT_NOT_NULL(ut_params->op,
4428 			"Failed to allocate symmetric crypto operation struct");
4429 
4430 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
4431 				16);
4432 
4433 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4434 		return TEST_FAILED;
4435 
4436 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4437 			ut_params->op), "failed to process sym crypto op");
4438 
4439 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4440 			"crypto op processing failed");
4441 
4442 	if (ut_params->op->sym->m_dst) {
4443 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
4444 				uint8_t *, plaintext_pad_len);
4445 	} else {
4446 		auth_tag = plaintext + plaintext_pad_len;
4447 	}
4448 
4449 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4450 			auth_tag,
4451 			test_case->auth_tag.data,
4452 			test_case->auth_tag.len,
4453 			"HMAC_MD5 generated tag not as expected");
4454 
4455 	return TEST_SUCCESS;
4456 }
4457 
4458 static int
4459 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
4460 {
4461 	uint8_t *plaintext;
4462 
4463 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4464 	struct crypto_unittest_params *ut_params = &unittest_params;
4465 
4466 	if (MD5_HMAC_create_session(ts_params, ut_params,
4467 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
4468 		return TEST_FAILED;
4469 	}
4470 
4471 	/* Generate Crypto op data structure */
4472 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4473 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4474 	TEST_ASSERT_NOT_NULL(ut_params->op,
4475 			"Failed to allocate symmetric crypto operation struct");
4476 
4477 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
4478 		return TEST_FAILED;
4479 
4480 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
4481 			ut_params->op), "failed to process sym crypto op");
4482 
4483 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4484 			"HMAC_MD5 crypto op processing failed");
4485 
4486 	return TEST_SUCCESS;
4487 }
4488 
4489 static int
4490 test_MD5_HMAC_generate_case_1(void)
4491 {
4492 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
4493 }
4494 
4495 static int
4496 test_MD5_HMAC_verify_case_1(void)
4497 {
4498 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
4499 }
4500 
4501 static int
4502 test_MD5_HMAC_generate_case_2(void)
4503 {
4504 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
4505 }
4506 
4507 static int
4508 test_MD5_HMAC_verify_case_2(void)
4509 {
4510 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
4511 }
4512 
4513 static int
4514 test_multi_session(void)
4515 {
4516 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4517 	struct crypto_unittest_params *ut_params = &unittest_params;
4518 
4519 	struct rte_cryptodev_info dev_info;
4520 	struct rte_cryptodev_sym_session **sessions;
4521 
4522 	uint16_t i;
4523 
4524 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
4525 			aes_cbc_key, hmac_sha512_key);
4526 
4527 
4528 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4529 
4530 	sessions = rte_malloc(NULL,
4531 			(sizeof(struct rte_cryptodev_sym_session *) *
4532 			dev_info.sym.max_nb_sessions) + 1, 0);
4533 
4534 	/* Create multiple crypto sessions*/
4535 	for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
4536 		sessions[i] = rte_cryptodev_sym_session_create(
4537 				ts_params->valid_devs[0],
4538 			&ut_params->auth_xform);
4539 		TEST_ASSERT_NOT_NULL(sessions[i],
4540 				"Session creation failed at session number %u",
4541 				i);
4542 
4543 		/* Attempt to send a request on each session */
4544 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
4545 			sessions[i],
4546 			ut_params,
4547 			ts_params,
4548 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
4549 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
4550 			aes_cbc_iv),
4551 			"Failed to perform decrypt on request number %u.", i);
4552 		/* free crypto operation structure */
4553 		if (ut_params->op)
4554 			rte_crypto_op_free(ut_params->op);
4555 
4556 		/*
4557 		 * free mbuf - both obuf and ibuf are usually the same,
4558 		 * so check if they point at the same address is necessary,
4559 		 * to avoid freeing the mbuf twice.
4560 		 */
4561 		if (ut_params->obuf) {
4562 			rte_pktmbuf_free(ut_params->obuf);
4563 			if (ut_params->ibuf == ut_params->obuf)
4564 				ut_params->ibuf = 0;
4565 			ut_params->obuf = 0;
4566 		}
4567 		if (ut_params->ibuf) {
4568 			rte_pktmbuf_free(ut_params->ibuf);
4569 			ut_params->ibuf = 0;
4570 		}
4571 	}
4572 
4573 	/* Next session create should fail */
4574 	sessions[i] = rte_cryptodev_sym_session_create(ts_params->valid_devs[0],
4575 			&ut_params->auth_xform);
4576 	TEST_ASSERT_NULL(sessions[i],
4577 			"Session creation succeeded unexpectedly!");
4578 
4579 	for (i = 0; i < dev_info.sym.max_nb_sessions; i++)
4580 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4581 				sessions[i]);
4582 
4583 	rte_free(sessions);
4584 
4585 	return TEST_SUCCESS;
4586 }
4587 
4588 struct multi_session_params {
4589 	struct crypto_unittest_params ut_params;
4590 	uint8_t *cipher_key;
4591 	uint8_t *hmac_key;
4592 	const uint8_t *cipher;
4593 	const uint8_t *digest;
4594 	uint8_t *iv;
4595 };
4596 
4597 #define MB_SESSION_NUMBER 3
4598 
4599 static int
4600 test_multi_session_random_usage(void)
4601 {
4602 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4603 	struct rte_cryptodev_info dev_info;
4604 	struct rte_cryptodev_sym_session **sessions;
4605 	uint32_t i, j;
4606 	struct multi_session_params ut_paramz[] = {
4607 
4608 		{
4609 			.cipher_key = ms_aes_cbc_key0,
4610 			.hmac_key = ms_hmac_key0,
4611 			.cipher = ms_aes_cbc_cipher0,
4612 			.digest = ms_hmac_digest0,
4613 			.iv = ms_aes_cbc_iv0
4614 		},
4615 		{
4616 			.cipher_key = ms_aes_cbc_key1,
4617 			.hmac_key = ms_hmac_key1,
4618 			.cipher = ms_aes_cbc_cipher1,
4619 			.digest = ms_hmac_digest1,
4620 			.iv = ms_aes_cbc_iv1
4621 		},
4622 		{
4623 			.cipher_key = ms_aes_cbc_key2,
4624 			.hmac_key = ms_hmac_key2,
4625 			.cipher = ms_aes_cbc_cipher2,
4626 			.digest = ms_hmac_digest2,
4627 			.iv = ms_aes_cbc_iv2
4628 		},
4629 
4630 	};
4631 
4632 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4633 
4634 	sessions = rte_malloc(NULL,
4635 			(sizeof(struct rte_cryptodev_sym_session *)
4636 					* dev_info.sym.max_nb_sessions) + 1, 0);
4637 
4638 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
4639 		rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
4640 				sizeof(struct crypto_unittest_params));
4641 
4642 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
4643 				&ut_paramz[i].ut_params,
4644 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
4645 
4646 		/* Create multiple crypto sessions*/
4647 		sessions[i] = rte_cryptodev_sym_session_create(
4648 				ts_params->valid_devs[0],
4649 				&ut_paramz[i].ut_params.auth_xform);
4650 
4651 		TEST_ASSERT_NOT_NULL(sessions[i],
4652 				"Session creation failed at session number %u",
4653 				i);
4654 
4655 	}
4656 
4657 	srand(time(NULL));
4658 	for (i = 0; i < 40000; i++) {
4659 
4660 		j = rand() % MB_SESSION_NUMBER;
4661 
4662 		TEST_ASSERT_SUCCESS(
4663 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
4664 					sessions[j],
4665 					&ut_paramz[j].ut_params,
4666 					ts_params, ut_paramz[j].cipher,
4667 					ut_paramz[j].digest,
4668 					ut_paramz[j].iv),
4669 			"Failed to perform decrypt on request number %u.", i);
4670 
4671 		if (ut_paramz[j].ut_params.op)
4672 			rte_crypto_op_free(ut_paramz[j].ut_params.op);
4673 
4674 		/*
4675 		 * free mbuf - both obuf and ibuf are usually the same,
4676 		 * so check if they point at the same address is necessary,
4677 		 * to avoid freeing the mbuf twice.
4678 		 */
4679 		if (ut_paramz[j].ut_params.obuf) {
4680 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
4681 			if (ut_paramz[j].ut_params.ibuf
4682 					== ut_paramz[j].ut_params.obuf)
4683 				ut_paramz[j].ut_params.ibuf = 0;
4684 			ut_paramz[j].ut_params.obuf = 0;
4685 		}
4686 		if (ut_paramz[j].ut_params.ibuf) {
4687 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
4688 			ut_paramz[j].ut_params.ibuf = 0;
4689 		}
4690 	}
4691 
4692 	for (i = 0; i < MB_SESSION_NUMBER; i++)
4693 		rte_cryptodev_sym_session_free(ts_params->valid_devs[0],
4694 				sessions[i]);
4695 
4696 	rte_free(sessions);
4697 
4698 	return TEST_SUCCESS;
4699 }
4700 
4701 static int
4702 test_null_cipher_only_operation(void)
4703 {
4704 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4705 	struct crypto_unittest_params *ut_params = &unittest_params;
4706 
4707 	/* Generate test mbuf data and space for digest */
4708 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4709 			catch_22_quote, QUOTE_512_BYTES, 0);
4710 
4711 	/* Setup Cipher Parameters */
4712 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4713 	ut_params->cipher_xform.next = NULL;
4714 
4715 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4716 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4717 
4718 	/* Create Crypto session*/
4719 	ut_params->sess = rte_cryptodev_sym_session_create(
4720 			ts_params->valid_devs[0], &ut_params->cipher_xform);
4721 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4722 
4723 	/* Generate Crypto op data structure */
4724 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4725 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4726 	TEST_ASSERT_NOT_NULL(ut_params->op,
4727 			"Failed to allocate symmetric crypto operation struct");
4728 
4729 	/* Set crypto operation data parameters */
4730 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4731 
4732 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4733 
4734 	/* set crypto operation source mbuf */
4735 	sym_op->m_src = ut_params->ibuf;
4736 
4737 	sym_op->cipher.data.offset = 0;
4738 	sym_op->cipher.data.length = QUOTE_512_BYTES;
4739 
4740 	/* Process crypto operation */
4741 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4742 			ut_params->op);
4743 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4744 
4745 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4746 			"crypto operation processing failed");
4747 
4748 	/* Validate obuf */
4749 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4750 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4751 			catch_22_quote,
4752 			QUOTE_512_BYTES,
4753 			"Ciphertext data not as expected");
4754 
4755 	return TEST_SUCCESS;
4756 }
4757 
4758 static int
4759 test_null_auth_only_operation(void)
4760 {
4761 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4762 	struct crypto_unittest_params *ut_params = &unittest_params;
4763 
4764 	/* Generate test mbuf data and space for digest */
4765 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4766 			catch_22_quote, QUOTE_512_BYTES, 0);
4767 
4768 	/* Setup HMAC Parameters */
4769 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4770 	ut_params->auth_xform.next = NULL;
4771 
4772 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4773 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4774 
4775 	/* Create Crypto session*/
4776 	ut_params->sess = rte_cryptodev_sym_session_create(
4777 			ts_params->valid_devs[0], &ut_params->auth_xform);
4778 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4779 
4780 	/* Generate Crypto op data structure */
4781 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4782 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4783 	TEST_ASSERT_NOT_NULL(ut_params->op,
4784 			"Failed to allocate symmetric crypto operation struct");
4785 
4786 	/* Set crypto operation data parameters */
4787 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4788 
4789 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4790 
4791 	sym_op->m_src = ut_params->ibuf;
4792 
4793 	sym_op->auth.data.offset = 0;
4794 	sym_op->auth.data.length = QUOTE_512_BYTES;
4795 
4796 	/* Process crypto operation */
4797 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4798 			ut_params->op);
4799 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4800 
4801 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4802 			"crypto operation processing failed");
4803 
4804 	return TEST_SUCCESS;
4805 }
4806 
4807 static int
4808 test_null_cipher_auth_operation(void)
4809 {
4810 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4811 	struct crypto_unittest_params *ut_params = &unittest_params;
4812 
4813 	/* Generate test mbuf data and space for digest */
4814 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4815 			catch_22_quote, QUOTE_512_BYTES, 0);
4816 
4817 	/* Setup Cipher Parameters */
4818 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4819 	ut_params->cipher_xform.next = &ut_params->auth_xform;
4820 
4821 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4822 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4823 
4824 	/* Setup HMAC Parameters */
4825 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4826 	ut_params->auth_xform.next = NULL;
4827 
4828 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4829 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4830 
4831 	/* Create Crypto session*/
4832 	ut_params->sess = rte_cryptodev_sym_session_create(
4833 			ts_params->valid_devs[0], &ut_params->cipher_xform);
4834 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4835 
4836 	/* Generate Crypto op data structure */
4837 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4838 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4839 	TEST_ASSERT_NOT_NULL(ut_params->op,
4840 			"Failed to allocate symmetric crypto operation struct");
4841 
4842 	/* Set crypto operation data parameters */
4843 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4844 
4845 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4846 
4847 	sym_op->m_src = ut_params->ibuf;
4848 
4849 	sym_op->cipher.data.offset = 0;
4850 	sym_op->cipher.data.length = QUOTE_512_BYTES;
4851 
4852 	sym_op->auth.data.offset = 0;
4853 	sym_op->auth.data.length = QUOTE_512_BYTES;
4854 
4855 	/* Process crypto operation */
4856 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4857 			ut_params->op);
4858 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4859 
4860 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4861 			"crypto operation processing failed");
4862 
4863 	/* Validate obuf */
4864 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4865 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4866 			catch_22_quote,
4867 			QUOTE_512_BYTES,
4868 			"Ciphertext data not as expected");
4869 
4870 	return TEST_SUCCESS;
4871 }
4872 
4873 static int
4874 test_null_auth_cipher_operation(void)
4875 {
4876 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4877 	struct crypto_unittest_params *ut_params = &unittest_params;
4878 
4879 	/* Generate test mbuf data and space for digest */
4880 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
4881 			catch_22_quote, QUOTE_512_BYTES, 0);
4882 
4883 	/* Setup Cipher Parameters */
4884 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4885 	ut_params->cipher_xform.next = NULL;
4886 
4887 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4888 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4889 
4890 	/* Setup HMAC Parameters */
4891 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4892 	ut_params->auth_xform.next = &ut_params->cipher_xform;
4893 
4894 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
4895 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4896 
4897 	/* Create Crypto session*/
4898 	ut_params->sess = rte_cryptodev_sym_session_create(
4899 			ts_params->valid_devs[0], &ut_params->cipher_xform);
4900 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
4901 
4902 	/* Generate Crypto op data structure */
4903 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
4904 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
4905 	TEST_ASSERT_NOT_NULL(ut_params->op,
4906 			"Failed to allocate symmetric crypto operation struct");
4907 
4908 	/* Set crypto operation data parameters */
4909 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
4910 
4911 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
4912 
4913 	sym_op->m_src = ut_params->ibuf;
4914 
4915 	sym_op->cipher.data.offset = 0;
4916 	sym_op->cipher.data.length = QUOTE_512_BYTES;
4917 
4918 	sym_op->auth.data.offset = 0;
4919 	sym_op->auth.data.length = QUOTE_512_BYTES;
4920 
4921 	/* Process crypto operation */
4922 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4923 			ut_params->op);
4924 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
4925 
4926 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
4927 			"crypto operation processing failed");
4928 
4929 	/* Validate obuf */
4930 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4931 			rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
4932 			catch_22_quote,
4933 			QUOTE_512_BYTES,
4934 			"Ciphertext data not as expected");
4935 
4936 	return TEST_SUCCESS;
4937 }
4938 
4939 
4940 static int
4941 test_null_invalid_operation(void)
4942 {
4943 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4944 	struct crypto_unittest_params *ut_params = &unittest_params;
4945 
4946 	/* Setup Cipher Parameters */
4947 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4948 	ut_params->cipher_xform.next = NULL;
4949 
4950 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
4951 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4952 
4953 	/* Create Crypto session*/
4954 	ut_params->sess = rte_cryptodev_sym_session_create(
4955 			ts_params->valid_devs[0], &ut_params->cipher_xform);
4956 	TEST_ASSERT_NULL(ut_params->sess,
4957 			"Session creation succeeded unexpectedly");
4958 
4959 
4960 	/* Setup HMAC Parameters */
4961 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4962 	ut_params->auth_xform.next = NULL;
4963 
4964 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
4965 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
4966 
4967 	/* Create Crypto session*/
4968 	ut_params->sess = rte_cryptodev_sym_session_create(
4969 			ts_params->valid_devs[0], &ut_params->auth_xform);
4970 	TEST_ASSERT_NULL(ut_params->sess,
4971 			"Session creation succeeded unexpectedly");
4972 
4973 	return TEST_SUCCESS;
4974 }
4975 
4976 
4977 #define NULL_BURST_LENGTH (32)
4978 
4979 static int
4980 test_null_burst_operation(void)
4981 {
4982 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4983 	struct crypto_unittest_params *ut_params = &unittest_params;
4984 
4985 	unsigned i, burst_len = NULL_BURST_LENGTH;
4986 
4987 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
4988 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
4989 
4990 	/* Setup Cipher Parameters */
4991 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4992 	ut_params->cipher_xform.next = &ut_params->auth_xform;
4993 
4994 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
4995 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
4996 
4997 	/* Setup HMAC Parameters */
4998 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4999 	ut_params->auth_xform.next = NULL;
5000 
5001 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
5002 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
5003 
5004 	/* Create Crypto session*/
5005 	ut_params->sess = rte_cryptodev_sym_session_create(
5006 			ts_params->valid_devs[0], &ut_params->cipher_xform);
5007 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5008 
5009 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
5010 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
5011 			burst_len, "failed to generate burst of crypto ops");
5012 
5013 	/* Generate an operation for each mbuf in burst */
5014 	for (i = 0; i < burst_len; i++) {
5015 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5016 
5017 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
5018 
5019 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
5020 				sizeof(unsigned));
5021 		*data = i;
5022 
5023 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
5024 
5025 		burst[i]->sym->m_src = m;
5026 	}
5027 
5028 	/* Process crypto operation */
5029 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
5030 			0, burst, burst_len),
5031 			burst_len,
5032 			"Error enqueuing burst");
5033 
5034 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
5035 			0, burst_dequeued, burst_len),
5036 			burst_len,
5037 			"Error dequeuing burst");
5038 
5039 
5040 	for (i = 0; i < burst_len; i++) {
5041 		TEST_ASSERT_EQUAL(
5042 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
5043 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
5044 					uint32_t *),
5045 			"data not as expected");
5046 
5047 		rte_pktmbuf_free(burst[i]->sym->m_src);
5048 		rte_crypto_op_free(burst[i]);
5049 	}
5050 
5051 	return TEST_SUCCESS;
5052 }
5053 
5054 static void
5055 generate_gmac_large_plaintext(uint8_t *data)
5056 {
5057 	uint16_t i;
5058 
5059 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
5060 		memcpy(&data[i], &data[0], 32);
5061 }
5062 
5063 static int
5064 create_gmac_operation(enum rte_crypto_auth_operation op,
5065 		const struct gmac_test_data *tdata)
5066 {
5067 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5068 	struct crypto_unittest_params *ut_params = &unittest_params;
5069 	struct rte_crypto_sym_op *sym_op;
5070 
5071 	unsigned iv_pad_len;
5072 	unsigned aad_pad_len;
5073 
5074 	iv_pad_len = RTE_ALIGN_CEIL(tdata->iv.len, 16);
5075 	aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5076 
5077 	/*
5078 	 * Runtime generate the large plain text instead of use hard code
5079 	 * plain text vector. It is done to avoid create huge source file
5080 	 * with the test vector.
5081 	 */
5082 	if (tdata->aad.len == GMAC_LARGE_PLAINTEXT_LENGTH)
5083 		generate_gmac_large_plaintext(tdata->aad.data);
5084 
5085 	/* Generate Crypto op data structure */
5086 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5087 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5088 	TEST_ASSERT_NOT_NULL(ut_params->op,
5089 			"Failed to allocate symmetric crypto operation struct");
5090 
5091 	sym_op = ut_params->op->sym;
5092 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5093 			aad_pad_len);
5094 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5095 			"no room to append aad");
5096 
5097 	sym_op->auth.aad.length = tdata->aad.len;
5098 	sym_op->auth.aad.phys_addr =
5099 			rte_pktmbuf_mtophys(ut_params->ibuf);
5100 	memcpy(sym_op->auth.aad.data, tdata->aad.data, tdata->aad.len);
5101 
5102 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5103 			ut_params->ibuf, tdata->gmac_tag.len);
5104 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5105 			"no room to append digest");
5106 
5107 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5108 			ut_params->ibuf, aad_pad_len);
5109 	sym_op->auth.digest.length = tdata->gmac_tag.len;
5110 
5111 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
5112 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
5113 				tdata->gmac_tag.len);
5114 		TEST_HEXDUMP(stdout, "digest:",
5115 				sym_op->auth.digest.data,
5116 				sym_op->auth.digest.length);
5117 	}
5118 
5119 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5120 			ut_params->ibuf, iv_pad_len);
5121 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5122 
5123 	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5124 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5125 	sym_op->cipher.iv.length = tdata->iv.len;
5126 
5127 	rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, tdata->iv.len);
5128 
5129 	TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
5130 
5131 	sym_op->cipher.data.length = 0;
5132 	sym_op->cipher.data.offset = 0;
5133 
5134 	sym_op->auth.data.offset = 0;
5135 	sym_op->auth.data.length = 0;
5136 
5137 	return 0;
5138 }
5139 
5140 static int create_gmac_session(uint8_t dev_id,
5141 		enum rte_crypto_cipher_operation op,
5142 		const struct gmac_test_data *tdata,
5143 		enum rte_crypto_auth_operation auth_op)
5144 {
5145 	uint8_t cipher_key[tdata->key.len];
5146 
5147 	struct crypto_unittest_params *ut_params = &unittest_params;
5148 
5149 	memcpy(cipher_key, tdata->key.data, tdata->key.len);
5150 
5151 	/* For GMAC we setup cipher parameters */
5152 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5153 	ut_params->cipher_xform.next = NULL;
5154 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_GCM;
5155 	ut_params->cipher_xform.cipher.op = op;
5156 	ut_params->cipher_xform.cipher.key.data = cipher_key;
5157 	ut_params->cipher_xform.cipher.key.length = tdata->key.len;
5158 
5159 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5160 	ut_params->auth_xform.next = NULL;
5161 
5162 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
5163 	ut_params->auth_xform.auth.op = auth_op;
5164 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
5165 	ut_params->auth_xform.auth.add_auth_data_length = 0;
5166 	ut_params->auth_xform.auth.key.length = 0;
5167 	ut_params->auth_xform.auth.key.data = NULL;
5168 
5169 	ut_params->cipher_xform.next = &ut_params->auth_xform;
5170 
5171 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5172 			&ut_params->cipher_xform);
5173 
5174 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5175 
5176 	return 0;
5177 }
5178 
5179 static int
5180 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
5181 {
5182 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5183 	struct crypto_unittest_params *ut_params = &unittest_params;
5184 
5185 	int retval;
5186 
5187 	uint8_t *auth_tag, *p;
5188 	uint16_t aad_pad_len;
5189 
5190 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5191 			      "No GMAC length in the source data");
5192 
5193 	retval = create_gmac_session(ts_params->valid_devs[0],
5194 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5195 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
5196 
5197 	if (retval < 0)
5198 		return retval;
5199 
5200 	if (tdata->aad.len > MBUF_SIZE)
5201 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5202 	else
5203 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5204 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5205 			"Failed to allocate input buffer in mempool");
5206 
5207 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5208 			rte_pktmbuf_tailroom(ut_params->ibuf));
5209 
5210 	aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5211 
5212 	p = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *);
5213 
5214 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
5215 			tdata);
5216 
5217 	if (retval < 0)
5218 		return retval;
5219 
5220 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5221 
5222 	ut_params->op->sym->m_src = ut_params->ibuf;
5223 
5224 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5225 			ut_params->op), "failed to process sym crypto op");
5226 
5227 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5228 			"crypto op processing failed");
5229 
5230 	if (ut_params->op->sym->m_dst) {
5231 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5232 				uint8_t *, aad_pad_len);
5233 	} else {
5234 		auth_tag = p + aad_pad_len;
5235 	}
5236 
5237 	TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
5238 
5239 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5240 			auth_tag,
5241 			tdata->gmac_tag.data,
5242 			tdata->gmac_tag.len,
5243 			"GMAC Generated auth tag not as expected");
5244 
5245 	return 0;
5246 }
5247 
5248 static int
5249 test_AES_GMAC_authentication_test_case_1(void)
5250 {
5251 	return test_AES_GMAC_authentication(&gmac_test_case_1);
5252 }
5253 
5254 static int
5255 test_AES_GMAC_authentication_test_case_2(void)
5256 {
5257 	return test_AES_GMAC_authentication(&gmac_test_case_2);
5258 }
5259 
5260 static int
5261 test_AES_GMAC_authentication_test_case_3(void)
5262 {
5263 	return test_AES_GMAC_authentication(&gmac_test_case_3);
5264 }
5265 
5266 static int
5267 test_AES_GMAC_authentication_test_case_4(void)
5268 {
5269 	return test_AES_GMAC_authentication(&gmac_test_case_4);
5270 }
5271 
5272 static int
5273 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
5274 {
5275 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5276 	struct crypto_unittest_params *ut_params = &unittest_params;
5277 	int retval;
5278 
5279 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
5280 			      "No GMAC length in the source data");
5281 
5282 	retval = create_gmac_session(ts_params->valid_devs[0],
5283 			RTE_CRYPTO_CIPHER_OP_DECRYPT,
5284 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
5285 
5286 	if (retval < 0)
5287 		return retval;
5288 
5289 	if (tdata->aad.len > MBUF_SIZE)
5290 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5291 	else
5292 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5293 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5294 			"Failed to allocate input buffer in mempool");
5295 
5296 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5297 			rte_pktmbuf_tailroom(ut_params->ibuf));
5298 
5299 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
5300 			tdata);
5301 
5302 	if (retval < 0)
5303 		return retval;
5304 
5305 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5306 
5307 	ut_params->op->sym->m_src = ut_params->ibuf;
5308 
5309 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5310 			ut_params->op), "failed to process sym crypto op");
5311 
5312 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5313 			"crypto op processing failed");
5314 
5315 	return 0;
5316 
5317 }
5318 
5319 static int
5320 test_AES_GMAC_authentication_verify_test_case_1(void)
5321 {
5322 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
5323 }
5324 
5325 static int
5326 test_AES_GMAC_authentication_verify_test_case_2(void)
5327 {
5328 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
5329 }
5330 
5331 static int
5332 test_AES_GMAC_authentication_verify_test_case_3(void)
5333 {
5334 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
5335 }
5336 
5337 static int
5338 test_AES_GMAC_authentication_verify_test_case_4(void)
5339 {
5340 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
5341 }
5342 
5343 struct test_crypto_vector {
5344 	enum rte_crypto_cipher_algorithm crypto_algo;
5345 
5346 	struct {
5347 		uint8_t data[64];
5348 		unsigned int len;
5349 	} cipher_key;
5350 
5351 	struct {
5352 		uint8_t data[64];
5353 		unsigned int len;
5354 	} iv;
5355 
5356 	struct {
5357 		const uint8_t *data;
5358 		unsigned int len;
5359 	} plaintext;
5360 
5361 	struct {
5362 		const uint8_t *data;
5363 		unsigned int len;
5364 	} ciphertext;
5365 
5366 	enum rte_crypto_auth_algorithm auth_algo;
5367 
5368 	struct {
5369 		uint8_t data[128];
5370 		unsigned int len;
5371 	} auth_key;
5372 
5373 	struct {
5374 		const uint8_t *data;
5375 		unsigned int len;
5376 	} aad;
5377 
5378 	struct {
5379 		uint8_t data[128];
5380 		unsigned int len;
5381 	} digest;
5382 };
5383 
5384 static const struct test_crypto_vector
5385 hmac_sha1_test_crypto_vector = {
5386 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5387 	.plaintext = {
5388 		.data = plaintext_hash,
5389 		.len = 512
5390 	},
5391 	.auth_key = {
5392 		.data = {
5393 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5394 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5395 			0xDE, 0xF4, 0xDE, 0xAD
5396 		},
5397 		.len = 20
5398 	},
5399 	.digest = {
5400 		.data = {
5401 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
5402 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
5403 			0x3F, 0x91, 0x64, 0x59
5404 		},
5405 		.len = 20
5406 	}
5407 };
5408 
5409 static const struct test_crypto_vector
5410 aes128_gmac_test_vector = {
5411 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
5412 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_GCM,
5413 	.aad = {
5414 		.data = plaintext_hash,
5415 		.len = 512
5416 	},
5417 	.iv = {
5418 		.data = {
5419 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5420 			0x08, 0x09, 0x0A, 0x0B
5421 		},
5422 		.len = 12
5423 	},
5424 	.cipher_key = {
5425 		.data = {
5426 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5427 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
5428 		},
5429 		.len = 16
5430 	},
5431 	.digest = {
5432 		.data = {
5433 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
5434 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
5435 		},
5436 		.len = 16
5437 	}
5438 };
5439 
5440 static const struct test_crypto_vector
5441 aes128cbc_hmac_sha1_test_vector = {
5442 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
5443 	.cipher_key = {
5444 		.data = {
5445 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
5446 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
5447 		},
5448 		.len = 16
5449 	},
5450 	.iv = {
5451 		.data = {
5452 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
5453 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
5454 		},
5455 		.len = 16
5456 	},
5457 	.plaintext = {
5458 		.data = plaintext_hash,
5459 		.len = 512
5460 	},
5461 	.ciphertext = {
5462 		.data = ciphertext512_aes128cbc,
5463 		.len = 512
5464 	},
5465 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
5466 	.auth_key = {
5467 		.data = {
5468 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
5469 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
5470 			0xDE, 0xF4, 0xDE, 0xAD
5471 		},
5472 		.len = 20
5473 	},
5474 	.digest = {
5475 		.data = {
5476 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
5477 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
5478 			0x18, 0x8C, 0x1D, 0x32
5479 		},
5480 		.len = 20
5481 	}
5482 };
5483 
5484 static void
5485 data_corruption(uint8_t *data)
5486 {
5487 	data[0] += 1;
5488 }
5489 
5490 static void
5491 tag_corruption(uint8_t *data, unsigned int tag_offset)
5492 {
5493 	data[tag_offset] += 1;
5494 }
5495 
5496 static int
5497 create_auth_session(struct crypto_unittest_params *ut_params,
5498 		uint8_t dev_id,
5499 		const struct test_crypto_vector *reference,
5500 		enum rte_crypto_auth_operation auth_op)
5501 {
5502 	uint8_t auth_key[reference->auth_key.len + 1];
5503 
5504 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5505 
5506 	/* Setup Authentication Parameters */
5507 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5508 	ut_params->auth_xform.auth.op = auth_op;
5509 	ut_params->auth_xform.next = NULL;
5510 	ut_params->auth_xform.auth.algo = reference->auth_algo;
5511 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5512 	ut_params->auth_xform.auth.key.data = auth_key;
5513 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
5514 	ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5515 
5516 	/* Create Crypto session*/
5517 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5518 				&ut_params->auth_xform);
5519 
5520 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5521 
5522 	return 0;
5523 }
5524 
5525 static int
5526 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
5527 		uint8_t dev_id,
5528 		const struct test_crypto_vector *reference,
5529 		enum rte_crypto_auth_operation auth_op,
5530 		enum rte_crypto_cipher_operation cipher_op)
5531 {
5532 	uint8_t cipher_key[reference->cipher_key.len + 1];
5533 	uint8_t auth_key[reference->auth_key.len + 1];
5534 
5535 	memcpy(cipher_key, reference->cipher_key.data,
5536 			reference->cipher_key.len);
5537 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
5538 
5539 	/* Setup Authentication Parameters */
5540 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5541 	ut_params->auth_xform.auth.op = auth_op;
5542 	ut_params->auth_xform.next = &ut_params->cipher_xform;
5543 	ut_params->auth_xform.auth.algo = reference->auth_algo;
5544 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
5545 	ut_params->auth_xform.auth.key.data = auth_key;
5546 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
5547 	ut_params->auth_xform.auth.add_auth_data_length = reference->aad.len;
5548 
5549 	/* Setup Cipher Parameters */
5550 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5551 	ut_params->cipher_xform.next = NULL;
5552 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
5553 	ut_params->cipher_xform.cipher.op = cipher_op;
5554 	ut_params->cipher_xform.cipher.key.data = cipher_key;
5555 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
5556 
5557 	/* Create Crypto session*/
5558 	ut_params->sess = rte_cryptodev_sym_session_create(dev_id,
5559 				&ut_params->auth_xform);
5560 
5561 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5562 
5563 	return 0;
5564 }
5565 
5566 static int
5567 create_auth_operation(struct crypto_testsuite_params *ts_params,
5568 		struct crypto_unittest_params *ut_params,
5569 		const struct test_crypto_vector *reference,
5570 		unsigned int auth_generate)
5571 {
5572 	/* Generate Crypto op data structure */
5573 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5574 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5575 	TEST_ASSERT_NOT_NULL(ut_params->op,
5576 			"Failed to allocate pktmbuf offload");
5577 
5578 	/* Set crypto operation data parameters */
5579 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5580 
5581 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5582 
5583 	/* set crypto operation source mbuf */
5584 	sym_op->m_src = ut_params->ibuf;
5585 
5586 	/* digest */
5587 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5588 			ut_params->ibuf, reference->digest.len);
5589 
5590 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5591 			"no room to append auth tag");
5592 
5593 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5594 			ut_params->ibuf, reference->plaintext.len);
5595 	sym_op->auth.digest.length = reference->digest.len;
5596 
5597 	if (auth_generate)
5598 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
5599 	else
5600 		memcpy(sym_op->auth.digest.data,
5601 				reference->digest.data,
5602 				reference->digest.len);
5603 
5604 	TEST_HEXDUMP(stdout, "digest:",
5605 			sym_op->auth.digest.data,
5606 			sym_op->auth.digest.length);
5607 
5608 	sym_op->auth.data.length = reference->plaintext.len;
5609 	sym_op->auth.data.offset = 0;
5610 
5611 	return 0;
5612 }
5613 
5614 static int
5615 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
5616 		struct crypto_unittest_params *ut_params,
5617 		const struct test_crypto_vector *reference,
5618 		unsigned int auth_generate)
5619 {
5620 	/* Generate Crypto op data structure */
5621 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5622 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5623 	TEST_ASSERT_NOT_NULL(ut_params->op,
5624 			"Failed to allocate pktmbuf offload");
5625 
5626 	/* Set crypto operation data parameters */
5627 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5628 
5629 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5630 
5631 	/* set crypto operation source mbuf */
5632 	sym_op->m_src = ut_params->ibuf;
5633 
5634 	/* aad */
5635 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5636 			reference->aad.len);
5637 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data, "no room to append AAD");
5638 	memcpy(sym_op->auth.aad.data, reference->aad.data, reference->aad.len);
5639 
5640 	TEST_HEXDUMP(stdout, "AAD:", sym_op->auth.aad.data, reference->aad.len);
5641 
5642 	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5643 	sym_op->auth.aad.length = reference->aad.len;
5644 
5645 	/* digest */
5646 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5647 			ut_params->ibuf, reference->digest.len);
5648 
5649 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5650 			"no room to append auth tag");
5651 
5652 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5653 			ut_params->ibuf, reference->ciphertext.len);
5654 	sym_op->auth.digest.length = reference->digest.len;
5655 
5656 	if (auth_generate)
5657 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
5658 	else
5659 		memcpy(sym_op->auth.digest.data,
5660 				reference->digest.data,
5661 				reference->digest.len);
5662 
5663 	TEST_HEXDUMP(stdout, "digest:",
5664 			sym_op->auth.digest.data,
5665 			sym_op->auth.digest.length);
5666 
5667 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5668 		ut_params->ibuf, reference->iv.len);
5669 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5670 
5671 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5672 	sym_op->cipher.iv.length = reference->iv.len;
5673 
5674 	memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5675 
5676 	sym_op->cipher.data.length = 0;
5677 	sym_op->cipher.data.offset = 0;
5678 
5679 	sym_op->auth.data.length = 0;
5680 	sym_op->auth.data.offset = 0;
5681 
5682 	return 0;
5683 }
5684 
5685 static int
5686 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
5687 		struct crypto_unittest_params *ut_params,
5688 		const struct test_crypto_vector *reference,
5689 		unsigned int auth_generate)
5690 {
5691 	/* Generate Crypto op data structure */
5692 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5693 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5694 	TEST_ASSERT_NOT_NULL(ut_params->op,
5695 			"Failed to allocate pktmbuf offload");
5696 
5697 	/* Set crypto operation data parameters */
5698 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5699 
5700 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5701 
5702 	/* set crypto operation source mbuf */
5703 	sym_op->m_src = ut_params->ibuf;
5704 
5705 	/* digest */
5706 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
5707 			ut_params->ibuf, reference->digest.len);
5708 
5709 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5710 			"no room to append auth tag");
5711 
5712 	sym_op->auth.digest.phys_addr = rte_pktmbuf_mtophys_offset(
5713 			ut_params->ibuf, reference->ciphertext.len);
5714 	sym_op->auth.digest.length = reference->digest.len;
5715 
5716 	if (auth_generate)
5717 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
5718 	else
5719 		memcpy(sym_op->auth.digest.data,
5720 				reference->digest.data,
5721 				reference->digest.len);
5722 
5723 	TEST_HEXDUMP(stdout, "digest:",
5724 			sym_op->auth.digest.data,
5725 			sym_op->auth.digest.length);
5726 
5727 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5728 		ut_params->ibuf, reference->iv.len);
5729 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data, "no room to prepend iv");
5730 
5731 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5732 	sym_op->cipher.iv.length = reference->iv.len;
5733 
5734 	memcpy(sym_op->cipher.iv.data, reference->iv.data, reference->iv.len);
5735 
5736 	sym_op->cipher.data.length = reference->ciphertext.len;
5737 	sym_op->cipher.data.offset = reference->iv.len;
5738 
5739 	sym_op->auth.data.length = reference->ciphertext.len;
5740 	sym_op->auth.data.offset = reference->iv.len;
5741 
5742 	return 0;
5743 }
5744 
5745 static int
5746 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5747 		struct crypto_unittest_params *ut_params,
5748 		const struct test_crypto_vector *reference)
5749 {
5750 	return create_auth_operation(ts_params, ut_params, reference, 0);
5751 }
5752 
5753 static int
5754 create_auth_verify_GMAC_operation(
5755 		struct crypto_testsuite_params *ts_params,
5756 		struct crypto_unittest_params *ut_params,
5757 		const struct test_crypto_vector *reference)
5758 {
5759 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
5760 }
5761 
5762 static int
5763 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
5764 		struct crypto_unittest_params *ut_params,
5765 		const struct test_crypto_vector *reference)
5766 {
5767 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
5768 }
5769 
5770 static int
5771 test_authentication_verify_fail_when_data_corruption(
5772 		struct crypto_testsuite_params *ts_params,
5773 		struct crypto_unittest_params *ut_params,
5774 		const struct test_crypto_vector *reference,
5775 		unsigned int data_corrupted)
5776 {
5777 	int retval;
5778 
5779 	uint8_t *plaintext;
5780 
5781 	/* Create session */
5782 	retval = create_auth_session(ut_params,
5783 			ts_params->valid_devs[0],
5784 			reference,
5785 			RTE_CRYPTO_AUTH_OP_VERIFY);
5786 	if (retval < 0)
5787 		return retval;
5788 
5789 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5790 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5791 			"Failed to allocate input buffer in mempool");
5792 
5793 	/* clear mbuf payload */
5794 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5795 			rte_pktmbuf_tailroom(ut_params->ibuf));
5796 
5797 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5798 			reference->plaintext.len);
5799 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5800 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
5801 
5802 	TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
5803 
5804 	/* Create operation */
5805 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
5806 
5807 	if (retval < 0)
5808 		return retval;
5809 
5810 	if (data_corrupted)
5811 		data_corruption(plaintext);
5812 	else
5813 		tag_corruption(plaintext, reference->plaintext.len);
5814 
5815 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5816 			ut_params->op);
5817 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5818 	TEST_ASSERT_EQUAL(ut_params->op->status,
5819 			RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5820 			"authentication not failed");
5821 
5822 	ut_params->obuf = ut_params->op->sym->m_src;
5823 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5824 
5825 	return 0;
5826 }
5827 
5828 static int
5829 test_authentication_verify_GMAC_fail_when_corruption(
5830 		struct crypto_testsuite_params *ts_params,
5831 		struct crypto_unittest_params *ut_params,
5832 		const struct test_crypto_vector *reference,
5833 		unsigned int data_corrupted)
5834 {
5835 	int retval;
5836 
5837 	/* Create session */
5838 	retval = create_auth_cipher_session(ut_params,
5839 			ts_params->valid_devs[0],
5840 			reference,
5841 			RTE_CRYPTO_AUTH_OP_VERIFY,
5842 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
5843 	if (retval < 0)
5844 		return retval;
5845 
5846 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5847 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5848 			"Failed to allocate input buffer in mempool");
5849 
5850 	/* clear mbuf payload */
5851 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5852 			rte_pktmbuf_tailroom(ut_params->ibuf));
5853 
5854 	/* Create operation */
5855 	retval = create_auth_verify_GMAC_operation(ts_params,
5856 			ut_params,
5857 			reference);
5858 
5859 	if (retval < 0)
5860 		return retval;
5861 
5862 	if (data_corrupted)
5863 		data_corruption(ut_params->op->sym->auth.aad.data);
5864 	else
5865 		tag_corruption(ut_params->op->sym->auth.aad.data,
5866 				reference->aad.len);
5867 
5868 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5869 			ut_params->op);
5870 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5871 	TEST_ASSERT_EQUAL(ut_params->op->status,
5872 			RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5873 			"authentication not failed");
5874 
5875 	ut_params->obuf = ut_params->op->sym->m_src;
5876 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5877 
5878 	return 0;
5879 }
5880 
5881 static int
5882 test_authenticated_decryption_fail_when_corruption(
5883 		struct crypto_testsuite_params *ts_params,
5884 		struct crypto_unittest_params *ut_params,
5885 		const struct test_crypto_vector *reference,
5886 		unsigned int data_corrupted)
5887 {
5888 	int retval;
5889 
5890 	uint8_t *ciphertext;
5891 
5892 	/* Create session */
5893 	retval = create_auth_cipher_session(ut_params,
5894 			ts_params->valid_devs[0],
5895 			reference,
5896 			RTE_CRYPTO_AUTH_OP_VERIFY,
5897 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
5898 	if (retval < 0)
5899 		return retval;
5900 
5901 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5902 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5903 			"Failed to allocate input buffer in mempool");
5904 
5905 	/* clear mbuf payload */
5906 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5907 			rte_pktmbuf_tailroom(ut_params->ibuf));
5908 
5909 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5910 			reference->ciphertext.len);
5911 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
5912 	memcpy(ciphertext, reference->ciphertext.data,
5913 			reference->ciphertext.len);
5914 
5915 	/* Create operation */
5916 	retval = create_cipher_auth_verify_operation(ts_params,
5917 			ut_params,
5918 			reference);
5919 
5920 	if (retval < 0)
5921 		return retval;
5922 
5923 	if (data_corrupted)
5924 		data_corruption(ciphertext);
5925 	else
5926 		tag_corruption(ciphertext, reference->ciphertext.len);
5927 
5928 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5929 			ut_params->op);
5930 
5931 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5932 	TEST_ASSERT_EQUAL(ut_params->op->status,
5933 			RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
5934 			"authentication not failed");
5935 
5936 	ut_params->obuf = ut_params->op->sym->m_src;
5937 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
5938 
5939 	return 0;
5940 }
5941 
5942 static int
5943 create_gcm_operation_SGL(enum rte_crypto_cipher_operation op,
5944 		const struct gcm_test_data *tdata,
5945 		void *digest_mem, uint64_t digest_phys)
5946 {
5947 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5948 	struct crypto_unittest_params *ut_params = &unittest_params;
5949 
5950 	const unsigned int auth_tag_len = tdata->auth_tag.len;
5951 	const unsigned int iv_len = tdata->iv.len;
5952 	const unsigned int aad_len = tdata->aad.len;
5953 
5954 	unsigned int iv_pad_len = 0;
5955 
5956 	/* Generate Crypto op data structure */
5957 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5958 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5959 	TEST_ASSERT_NOT_NULL(ut_params->op,
5960 		"Failed to allocate symmetric crypto operation struct");
5961 
5962 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5963 
5964 	sym_op->auth.digest.data = digest_mem;
5965 
5966 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
5967 			"no room to append digest");
5968 
5969 	sym_op->auth.digest.phys_addr = digest_phys;
5970 	sym_op->auth.digest.length = auth_tag_len;
5971 
5972 	if (op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
5973 		rte_memcpy(sym_op->auth.digest.data, tdata->auth_tag.data,
5974 				auth_tag_len);
5975 		TEST_HEXDUMP(stdout, "digest:",
5976 				sym_op->auth.digest.data,
5977 				sym_op->auth.digest.length);
5978 	}
5979 
5980 	iv_pad_len = RTE_ALIGN_CEIL(iv_len, 16);
5981 
5982 	sym_op->cipher.iv.data = (uint8_t *)rte_pktmbuf_prepend(
5983 			ut_params->ibuf, iv_pad_len);
5984 
5985 	TEST_ASSERT_NOT_NULL(sym_op->cipher.iv.data,
5986 			"no room to prepend iv");
5987 
5988 	memset(sym_op->cipher.iv.data, 0, iv_pad_len);
5989 	sym_op->cipher.iv.phys_addr = rte_pktmbuf_mtophys(ut_params->ibuf);
5990 	sym_op->cipher.iv.length = iv_len;
5991 
5992 	rte_memcpy(sym_op->cipher.iv.data, tdata->iv.data, iv_pad_len);
5993 
5994 	sym_op->auth.aad.data = (uint8_t *)rte_pktmbuf_prepend(
5995 			ut_params->ibuf, aad_len);
5996 	TEST_ASSERT_NOT_NULL(sym_op->auth.aad.data,
5997 			"no room to prepend aad");
5998 	sym_op->auth.aad.phys_addr = rte_pktmbuf_mtophys(
5999 			ut_params->ibuf);
6000 	sym_op->auth.aad.length = aad_len;
6001 
6002 	memset(sym_op->auth.aad.data, 0, aad_len);
6003 	rte_memcpy(sym_op->auth.aad.data, tdata->aad.data, aad_len);
6004 
6005 	TEST_HEXDUMP(stdout, "iv:", sym_op->cipher.iv.data, iv_pad_len);
6006 	TEST_HEXDUMP(stdout, "aad:",
6007 			sym_op->auth.aad.data, aad_len);
6008 
6009 	sym_op->cipher.data.length = tdata->plaintext.len;
6010 	sym_op->cipher.data.offset = aad_len + iv_pad_len;
6011 
6012 	sym_op->auth.data.offset = aad_len + iv_pad_len;
6013 	sym_op->auth.data.length = tdata->plaintext.len;
6014 
6015 	return 0;
6016 }
6017 
6018 #define SGL_MAX_NO	16
6019 
6020 static int
6021 test_AES_GCM_authenticated_encryption_SGL(const struct gcm_test_data *tdata,
6022 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
6023 {
6024 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6025 	struct crypto_unittest_params *ut_params = &unittest_params;
6026 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
6027 	int retval;
6028 	int to_trn = 0;
6029 	int to_trn_tbl[SGL_MAX_NO];
6030 	int segs = 1;
6031 	unsigned int trn_data = 0;
6032 	uint8_t *plaintext, *ciphertext, *auth_tag;
6033 
6034 	if (fragsz > tdata->plaintext.len)
6035 		fragsz = tdata->plaintext.len;
6036 
6037 	uint16_t plaintext_len = fragsz;
6038 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
6039 
6040 	if (fragsz_oop > tdata->plaintext.len)
6041 		frag_size_oop = tdata->plaintext.len;
6042 
6043 	int ecx = 0;
6044 	void *digest_mem = NULL;
6045 
6046 	uint32_t prepend_len = ALIGN_POW2_ROUNDUP(tdata->iv.len, 16)
6047 			+ tdata->aad.len;
6048 
6049 	if (tdata->plaintext.len % fragsz != 0) {
6050 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
6051 			return 1;
6052 	}	else {
6053 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
6054 			return 1;
6055 	}
6056 
6057 	/*
6058 	 * For out-op-place we need to alloc another mbuf
6059 	 */
6060 	if (oop) {
6061 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6062 		rte_pktmbuf_append(ut_params->obuf,
6063 				frag_size_oop + prepend_len);
6064 		buf_oop = ut_params->obuf;
6065 	}
6066 
6067 	/* Create GCM session */
6068 	retval = create_gcm_session(ts_params->valid_devs[0],
6069 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6070 			tdata->key.data, tdata->key.len,
6071 			tdata->aad.len, tdata->auth_tag.len,
6072 			RTE_CRYPTO_AUTH_OP_GENERATE);
6073 	if (retval < 0)
6074 		return retval;
6075 
6076 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6077 
6078 	/* clear mbuf payload */
6079 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6080 			rte_pktmbuf_tailroom(ut_params->ibuf));
6081 
6082 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6083 			plaintext_len);
6084 
6085 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6086 
6087 	trn_data += plaintext_len;
6088 
6089 	buf = ut_params->ibuf;
6090 
6091 	/*
6092 	 * Loop until no more fragments
6093 	 */
6094 
6095 	while (trn_data < tdata->plaintext.len) {
6096 		++segs;
6097 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
6098 				(tdata->plaintext.len - trn_data) : fragsz;
6099 
6100 		to_trn_tbl[ecx++] = to_trn;
6101 
6102 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6103 		buf = buf->next;
6104 
6105 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
6106 				rte_pktmbuf_tailroom(buf));
6107 
6108 		/* OOP */
6109 		if (oop && !fragsz_oop) {
6110 			buf_last_oop = buf_oop->next =
6111 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
6112 			buf_oop = buf_oop->next;
6113 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
6114 					0, rte_pktmbuf_tailroom(buf_oop));
6115 			rte_pktmbuf_append(buf_oop, to_trn);
6116 		}
6117 
6118 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
6119 				to_trn);
6120 
6121 		memcpy(plaintext, tdata->plaintext.data + trn_data,
6122 				to_trn);
6123 		trn_data += to_trn;
6124 		if (trn_data  == tdata->plaintext.len) {
6125 			if (oop) {
6126 				if (!fragsz_oop)
6127 					digest_mem = rte_pktmbuf_append(buf_oop,
6128 						tdata->auth_tag.len);
6129 			} else
6130 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
6131 					tdata->auth_tag.len);
6132 		}
6133 	}
6134 
6135 	uint64_t digest_phys = 0;
6136 
6137 	ut_params->ibuf->nb_segs = segs;
6138 
6139 	segs = 1;
6140 	if (fragsz_oop && oop) {
6141 		to_trn = 0;
6142 		ecx = 0;
6143 
6144 		if (frag_size_oop == tdata->plaintext.len) {
6145 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
6146 				tdata->auth_tag.len);
6147 
6148 			digest_phys = rte_pktmbuf_mtophys_offset(
6149 					ut_params->obuf,
6150 					tdata->plaintext.len + prepend_len);
6151 		}
6152 
6153 		trn_data = frag_size_oop;
6154 		while (trn_data < tdata->plaintext.len) {
6155 			++segs;
6156 			to_trn =
6157 				(tdata->plaintext.len - trn_data <
6158 						frag_size_oop) ?
6159 				(tdata->plaintext.len - trn_data) :
6160 						frag_size_oop;
6161 
6162 			to_trn_tbl[ecx++] = to_trn;
6163 
6164 			buf_last_oop = buf_oop->next =
6165 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
6166 			buf_oop = buf_oop->next;
6167 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
6168 					0, rte_pktmbuf_tailroom(buf_oop));
6169 			rte_pktmbuf_append(buf_oop, to_trn);
6170 
6171 			trn_data += to_trn;
6172 
6173 			if (trn_data  == tdata->plaintext.len) {
6174 				digest_mem = rte_pktmbuf_append(buf_oop,
6175 					tdata->auth_tag.len);
6176 			}
6177 		}
6178 
6179 		ut_params->obuf->nb_segs = segs;
6180 	}
6181 
6182 	/*
6183 	 * Place digest at the end of the last buffer
6184 	 */
6185 	if (!digest_phys)
6186 		digest_phys = rte_pktmbuf_mtophys(buf) + to_trn;
6187 	if (oop && buf_last_oop)
6188 		digest_phys = rte_pktmbuf_mtophys(buf_last_oop) + to_trn;
6189 
6190 	if (!digest_mem && !oop) {
6191 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6192 				+ tdata->auth_tag.len);
6193 		digest_phys = rte_pktmbuf_mtophys_offset(ut_params->ibuf,
6194 				tdata->plaintext.len);
6195 	}
6196 
6197 	/* Create GCM opertaion */
6198 	retval = create_gcm_operation_SGL(RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6199 			tdata, digest_mem, digest_phys);
6200 
6201 	if (retval < 0)
6202 		return retval;
6203 
6204 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6205 
6206 	ut_params->op->sym->m_src = ut_params->ibuf;
6207 	if (oop)
6208 		ut_params->op->sym->m_dst = ut_params->obuf;
6209 
6210 	/* Process crypto operation */
6211 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6212 			ut_params->op), "failed to process sym crypto op");
6213 
6214 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6215 			"crypto op processing failed");
6216 
6217 
6218 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6219 			uint8_t *, prepend_len);
6220 	if (oop) {
6221 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6222 				uint8_t *, prepend_len);
6223 	}
6224 
6225 	if (fragsz_oop)
6226 		fragsz = fragsz_oop;
6227 
6228 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6229 			ciphertext,
6230 			tdata->ciphertext.data,
6231 			fragsz,
6232 			"GCM Ciphertext data not as expected");
6233 
6234 	buf = ut_params->op->sym->m_src->next;
6235 	if (oop)
6236 		buf = ut_params->op->sym->m_dst->next;
6237 
6238 	unsigned int off = fragsz;
6239 
6240 	ecx = 0;
6241 	while (buf) {
6242 		ciphertext = rte_pktmbuf_mtod(buf,
6243 				uint8_t *);
6244 
6245 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6246 				ciphertext,
6247 				tdata->ciphertext.data + off,
6248 				to_trn_tbl[ecx],
6249 				"GCM Ciphertext data not as expected");
6250 
6251 		off += to_trn_tbl[ecx++];
6252 		buf = buf->next;
6253 	}
6254 
6255 	auth_tag = digest_mem;
6256 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6257 			auth_tag,
6258 			tdata->auth_tag.data,
6259 			tdata->auth_tag.len,
6260 			"GCM Generated auth tag not as expected");
6261 
6262 	return 0;
6263 }
6264 
6265 #define IN_PLACE	0
6266 #define OUT_OF_PLACE	1
6267 
6268 static int
6269 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
6270 {
6271 	return test_AES_GCM_authenticated_encryption_SGL(
6272 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
6273 }
6274 
6275 static int
6276 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
6277 {
6278 	return test_AES_GCM_authenticated_encryption_SGL(
6279 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
6280 }
6281 
6282 static int
6283 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
6284 {
6285 
6286 	return test_AES_GCM_authenticated_encryption_SGL(
6287 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
6288 }
6289 
6290 static int
6291 test_authentication_verify_fail_when_data_corrupted(
6292 		struct crypto_testsuite_params *ts_params,
6293 		struct crypto_unittest_params *ut_params,
6294 		const struct test_crypto_vector *reference)
6295 {
6296 	return test_authentication_verify_fail_when_data_corruption(
6297 			ts_params, ut_params, reference, 1);
6298 }
6299 
6300 static int
6301 test_authentication_verify_fail_when_tag_corrupted(
6302 		struct crypto_testsuite_params *ts_params,
6303 		struct crypto_unittest_params *ut_params,
6304 		const struct test_crypto_vector *reference)
6305 {
6306 	return test_authentication_verify_fail_when_data_corruption(
6307 			ts_params, ut_params, reference, 0);
6308 }
6309 
6310 static int
6311 test_authentication_verify_GMAC_fail_when_data_corrupted(
6312 		struct crypto_testsuite_params *ts_params,
6313 		struct crypto_unittest_params *ut_params,
6314 		const struct test_crypto_vector *reference)
6315 {
6316 	return test_authentication_verify_GMAC_fail_when_corruption(
6317 			ts_params, ut_params, reference, 1);
6318 }
6319 
6320 static int
6321 test_authentication_verify_GMAC_fail_when_tag_corrupted(
6322 		struct crypto_testsuite_params *ts_params,
6323 		struct crypto_unittest_params *ut_params,
6324 		const struct test_crypto_vector *reference)
6325 {
6326 	return test_authentication_verify_GMAC_fail_when_corruption(
6327 			ts_params, ut_params, reference, 0);
6328 }
6329 
6330 static int
6331 test_authenticated_decryption_fail_when_data_corrupted(
6332 		struct crypto_testsuite_params *ts_params,
6333 		struct crypto_unittest_params *ut_params,
6334 		const struct test_crypto_vector *reference)
6335 {
6336 	return test_authenticated_decryption_fail_when_corruption(
6337 			ts_params, ut_params, reference, 1);
6338 }
6339 
6340 static int
6341 test_authenticated_decryption_fail_when_tag_corrupted(
6342 		struct crypto_testsuite_params *ts_params,
6343 		struct crypto_unittest_params *ut_params,
6344 		const struct test_crypto_vector *reference)
6345 {
6346 	return test_authenticated_decryption_fail_when_corruption(
6347 			ts_params, ut_params, reference, 0);
6348 }
6349 
6350 static int
6351 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
6352 {
6353 	return test_authentication_verify_fail_when_data_corrupted(
6354 			&testsuite_params, &unittest_params,
6355 			&hmac_sha1_test_crypto_vector);
6356 }
6357 
6358 static int
6359 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
6360 {
6361 	return test_authentication_verify_fail_when_tag_corrupted(
6362 			&testsuite_params, &unittest_params,
6363 			&hmac_sha1_test_crypto_vector);
6364 }
6365 
6366 static int
6367 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
6368 {
6369 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
6370 			&testsuite_params, &unittest_params,
6371 			&aes128_gmac_test_vector);
6372 }
6373 
6374 static int
6375 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
6376 {
6377 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
6378 			&testsuite_params, &unittest_params,
6379 			&aes128_gmac_test_vector);
6380 }
6381 
6382 static int
6383 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
6384 {
6385 	return test_authenticated_decryption_fail_when_data_corrupted(
6386 			&testsuite_params,
6387 			&unittest_params,
6388 			&aes128cbc_hmac_sha1_test_vector);
6389 }
6390 
6391 static int
6392 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
6393 {
6394 	return test_authenticated_decryption_fail_when_tag_corrupted(
6395 			&testsuite_params,
6396 			&unittest_params,
6397 			&aes128cbc_hmac_sha1_test_vector);
6398 }
6399 
6400 static struct unit_test_suite cryptodev_qat_testsuite  = {
6401 	.suite_name = "Crypto QAT Unit Test Suite",
6402 	.setup = testsuite_setup,
6403 	.teardown = testsuite_teardown,
6404 	.unit_test_cases = {
6405 		TEST_CASE_ST(ut_setup, ut_teardown,
6406 				test_device_configure_invalid_dev_id),
6407 		TEST_CASE_ST(ut_setup, ut_teardown,
6408 				test_device_configure_invalid_queue_pair_ids),
6409 		TEST_CASE_ST(ut_setup, ut_teardown,
6410 				test_queue_pair_descriptor_setup),
6411 		TEST_CASE_ST(ut_setup, ut_teardown,
6412 				test_multi_session),
6413 
6414 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
6415 		TEST_CASE_ST(ut_setup, ut_teardown,
6416 						test_AES_cipheronly_qat_all),
6417 		TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
6418 		TEST_CASE_ST(ut_setup, ut_teardown,
6419 						test_3DES_cipheronly_qat_all),
6420 		TEST_CASE_ST(ut_setup, ut_teardown,
6421 						test_DES_cipheronly_qat_all),
6422 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
6423 
6424 		/** AES GCM Authenticated Encryption */
6425 		TEST_CASE_ST(ut_setup, ut_teardown,
6426 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
6427 		TEST_CASE_ST(ut_setup, ut_teardown,
6428 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
6429 		TEST_CASE_ST(ut_setup, ut_teardown,
6430 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
6431 		TEST_CASE_ST(ut_setup, ut_teardown,
6432 			test_mb_AES_GCM_authenticated_encryption_test_case_1),
6433 		TEST_CASE_ST(ut_setup, ut_teardown,
6434 			test_mb_AES_GCM_authenticated_encryption_test_case_2),
6435 		TEST_CASE_ST(ut_setup, ut_teardown,
6436 			test_mb_AES_GCM_authenticated_encryption_test_case_3),
6437 		TEST_CASE_ST(ut_setup, ut_teardown,
6438 			test_mb_AES_GCM_authenticated_encryption_test_case_4),
6439 		TEST_CASE_ST(ut_setup, ut_teardown,
6440 			test_mb_AES_GCM_authenticated_encryption_test_case_5),
6441 		TEST_CASE_ST(ut_setup, ut_teardown,
6442 			test_mb_AES_GCM_authenticated_encryption_test_case_6),
6443 		TEST_CASE_ST(ut_setup, ut_teardown,
6444 			test_mb_AES_GCM_authenticated_encryption_test_case_7),
6445 
6446 		/** AES GCM Authenticated Decryption */
6447 		TEST_CASE_ST(ut_setup, ut_teardown,
6448 			test_mb_AES_GCM_authenticated_decryption_test_case_1),
6449 		TEST_CASE_ST(ut_setup, ut_teardown,
6450 			test_mb_AES_GCM_authenticated_decryption_test_case_2),
6451 		TEST_CASE_ST(ut_setup, ut_teardown,
6452 			test_mb_AES_GCM_authenticated_decryption_test_case_3),
6453 		TEST_CASE_ST(ut_setup, ut_teardown,
6454 			test_mb_AES_GCM_authenticated_decryption_test_case_4),
6455 		TEST_CASE_ST(ut_setup, ut_teardown,
6456 			test_mb_AES_GCM_authenticated_decryption_test_case_5),
6457 		TEST_CASE_ST(ut_setup, ut_teardown,
6458 			test_mb_AES_GCM_authenticated_decryption_test_case_6),
6459 		TEST_CASE_ST(ut_setup, ut_teardown,
6460 			test_mb_AES_GCM_authenticated_decryption_test_case_7),
6461 
6462 		/** AES GMAC Authentication */
6463 		TEST_CASE_ST(ut_setup, ut_teardown,
6464 			test_AES_GMAC_authentication_test_case_1),
6465 		TEST_CASE_ST(ut_setup, ut_teardown,
6466 			test_AES_GMAC_authentication_verify_test_case_1),
6467 		TEST_CASE_ST(ut_setup, ut_teardown,
6468 			test_AES_GMAC_authentication_test_case_2),
6469 		TEST_CASE_ST(ut_setup, ut_teardown,
6470 			test_AES_GMAC_authentication_verify_test_case_2),
6471 		TEST_CASE_ST(ut_setup, ut_teardown,
6472 			test_AES_GMAC_authentication_test_case_3),
6473 		TEST_CASE_ST(ut_setup, ut_teardown,
6474 			test_AES_GMAC_authentication_verify_test_case_3),
6475 
6476 		/** SNOW 3G encrypt only (UEA2) */
6477 		TEST_CASE_ST(ut_setup, ut_teardown,
6478 			test_snow3g_encryption_test_case_1),
6479 		TEST_CASE_ST(ut_setup, ut_teardown,
6480 			test_snow3g_encryption_test_case_2),
6481 		TEST_CASE_ST(ut_setup, ut_teardown,
6482 			test_snow3g_encryption_test_case_3),
6483 		TEST_CASE_ST(ut_setup, ut_teardown,
6484 			test_snow3g_encryption_test_case_4),
6485 		TEST_CASE_ST(ut_setup, ut_teardown,
6486 			test_snow3g_encryption_test_case_5),
6487 
6488 		TEST_CASE_ST(ut_setup, ut_teardown,
6489 			test_snow3g_encryption_test_case_1_oop),
6490 		TEST_CASE_ST(ut_setup, ut_teardown,
6491 			test_snow3g_decryption_test_case_1_oop),
6492 
6493 		/** SNOW 3G decrypt only (UEA2) */
6494 		TEST_CASE_ST(ut_setup, ut_teardown,
6495 			test_snow3g_decryption_test_case_1),
6496 		TEST_CASE_ST(ut_setup, ut_teardown,
6497 			test_snow3g_decryption_test_case_2),
6498 		TEST_CASE_ST(ut_setup, ut_teardown,
6499 			test_snow3g_decryption_test_case_3),
6500 		TEST_CASE_ST(ut_setup, ut_teardown,
6501 			test_snow3g_decryption_test_case_4),
6502 		TEST_CASE_ST(ut_setup, ut_teardown,
6503 			test_snow3g_decryption_test_case_5),
6504 		TEST_CASE_ST(ut_setup, ut_teardown,
6505 			test_snow3g_hash_generate_test_case_1),
6506 		TEST_CASE_ST(ut_setup, ut_teardown,
6507 			test_snow3g_hash_generate_test_case_2),
6508 		TEST_CASE_ST(ut_setup, ut_teardown,
6509 			test_snow3g_hash_generate_test_case_3),
6510 		TEST_CASE_ST(ut_setup, ut_teardown,
6511 			test_snow3g_hash_verify_test_case_1),
6512 		TEST_CASE_ST(ut_setup, ut_teardown,
6513 			test_snow3g_hash_verify_test_case_2),
6514 		TEST_CASE_ST(ut_setup, ut_teardown,
6515 			test_snow3g_hash_verify_test_case_3),
6516 		TEST_CASE_ST(ut_setup, ut_teardown,
6517 			test_snow3g_cipher_auth_test_case_1),
6518 		TEST_CASE_ST(ut_setup, ut_teardown,
6519 			test_snow3g_auth_cipher_test_case_1),
6520 
6521 		/** HMAC_MD5 Authentication */
6522 		TEST_CASE_ST(ut_setup, ut_teardown,
6523 			test_MD5_HMAC_generate_case_1),
6524 		TEST_CASE_ST(ut_setup, ut_teardown,
6525 			test_MD5_HMAC_verify_case_1),
6526 		TEST_CASE_ST(ut_setup, ut_teardown,
6527 			test_MD5_HMAC_generate_case_2),
6528 		TEST_CASE_ST(ut_setup, ut_teardown,
6529 			test_MD5_HMAC_verify_case_2),
6530 
6531 		/** NULL tests */
6532 		TEST_CASE_ST(ut_setup, ut_teardown,
6533 			test_null_auth_only_operation),
6534 		TEST_CASE_ST(ut_setup, ut_teardown,
6535 			test_null_cipher_only_operation),
6536 		TEST_CASE_ST(ut_setup, ut_teardown,
6537 			test_null_cipher_auth_operation),
6538 		TEST_CASE_ST(ut_setup, ut_teardown,
6539 			test_null_auth_cipher_operation),
6540 
6541 		TEST_CASE_ST(ut_setup, ut_teardown,
6542 			test_kasumi_hash_generate_test_case_6),
6543 
6544 		/** KASUMI tests */
6545 		TEST_CASE_ST(ut_setup, ut_teardown,
6546 			test_kasumi_encryption_test_case_1),
6547 		TEST_CASE_ST(ut_setup, ut_teardown,
6548 			test_kasumi_encryption_test_case_3),
6549 		TEST_CASE_ST(ut_setup, ut_teardown,
6550 			test_kasumi_auth_cipher_test_case_1),
6551 		TEST_CASE_ST(ut_setup, ut_teardown,
6552 			test_kasumi_cipher_auth_test_case_1),
6553 
6554 		/** Negative tests */
6555 		TEST_CASE_ST(ut_setup, ut_teardown,
6556 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
6557 		TEST_CASE_ST(ut_setup, ut_teardown,
6558 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6559 		TEST_CASE_ST(ut_setup, ut_teardown,
6560 			authentication_verify_AES128_GMAC_fail_data_corrupt),
6561 		TEST_CASE_ST(ut_setup, ut_teardown,
6562 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
6563 		TEST_CASE_ST(ut_setup, ut_teardown,
6564 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6565 		TEST_CASE_ST(ut_setup, ut_teardown,
6566 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6567 
6568 		TEST_CASES_END() /**< NULL terminate unit test array */
6569 	}
6570 };
6571 
6572 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
6573 	.suite_name = "Crypto Device AESNI MB Unit Test Suite",
6574 	.setup = testsuite_setup,
6575 	.teardown = testsuite_teardown,
6576 	.unit_test_cases = {
6577 		TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
6578 
6579 		TEST_CASES_END() /**< NULL terminate unit test array */
6580 	}
6581 };
6582 
6583 static struct unit_test_suite cryptodev_openssl_testsuite  = {
6584 	.suite_name = "Crypto Device OPENSSL Unit Test Suite",
6585 	.setup = testsuite_setup,
6586 	.teardown = testsuite_teardown,
6587 	.unit_test_cases = {
6588 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
6589 		TEST_CASE_ST(ut_setup, ut_teardown,
6590 				test_multi_session_random_usage),
6591 		TEST_CASE_ST(ut_setup, ut_teardown,
6592 				test_AES_chain_openssl_all),
6593 		TEST_CASE_ST(ut_setup, ut_teardown,
6594 				test_AES_cipheronly_openssl_all),
6595 		TEST_CASE_ST(ut_setup, ut_teardown,
6596 				test_3DES_chain_openssl_all),
6597 		TEST_CASE_ST(ut_setup, ut_teardown,
6598 				test_3DES_cipheronly_openssl_all),
6599 		TEST_CASE_ST(ut_setup, ut_teardown,
6600 				test_authonly_openssl_all),
6601 
6602 		/** AES GCM Authenticated Encryption */
6603 		TEST_CASE_ST(ut_setup, ut_teardown,
6604 			test_mb_AES_GCM_authenticated_encryption_test_case_1),
6605 		TEST_CASE_ST(ut_setup, ut_teardown,
6606 			test_mb_AES_GCM_authenticated_encryption_test_case_2),
6607 		TEST_CASE_ST(ut_setup, ut_teardown,
6608 			test_mb_AES_GCM_authenticated_encryption_test_case_3),
6609 		TEST_CASE_ST(ut_setup, ut_teardown,
6610 			test_mb_AES_GCM_authenticated_encryption_test_case_4),
6611 		TEST_CASE_ST(ut_setup, ut_teardown,
6612 			test_mb_AES_GCM_authenticated_encryption_test_case_5),
6613 		TEST_CASE_ST(ut_setup, ut_teardown,
6614 			test_mb_AES_GCM_authenticated_encryption_test_case_6),
6615 		TEST_CASE_ST(ut_setup, ut_teardown,
6616 			test_mb_AES_GCM_authenticated_encryption_test_case_7),
6617 
6618 		/** AES GCM Authenticated Decryption */
6619 		TEST_CASE_ST(ut_setup, ut_teardown,
6620 			test_mb_AES_GCM_authenticated_decryption_test_case_1),
6621 		TEST_CASE_ST(ut_setup, ut_teardown,
6622 			test_mb_AES_GCM_authenticated_decryption_test_case_2),
6623 		TEST_CASE_ST(ut_setup, ut_teardown,
6624 			test_mb_AES_GCM_authenticated_decryption_test_case_3),
6625 		TEST_CASE_ST(ut_setup, ut_teardown,
6626 			test_mb_AES_GCM_authenticated_decryption_test_case_4),
6627 		TEST_CASE_ST(ut_setup, ut_teardown,
6628 			test_mb_AES_GCM_authenticated_decryption_test_case_5),
6629 		TEST_CASE_ST(ut_setup, ut_teardown,
6630 			test_mb_AES_GCM_authenticated_decryption_test_case_6),
6631 		TEST_CASE_ST(ut_setup, ut_teardown,
6632 			test_mb_AES_GCM_authenticated_decryption_test_case_7),
6633 
6634 		/** AES GMAC Authentication */
6635 		TEST_CASE_ST(ut_setup, ut_teardown,
6636 			test_AES_GMAC_authentication_test_case_1),
6637 		TEST_CASE_ST(ut_setup, ut_teardown,
6638 			test_AES_GMAC_authentication_verify_test_case_1),
6639 		TEST_CASE_ST(ut_setup, ut_teardown,
6640 			test_AES_GMAC_authentication_test_case_2),
6641 		TEST_CASE_ST(ut_setup, ut_teardown,
6642 			test_AES_GMAC_authentication_verify_test_case_2),
6643 		TEST_CASE_ST(ut_setup, ut_teardown,
6644 			test_AES_GMAC_authentication_test_case_3),
6645 		TEST_CASE_ST(ut_setup, ut_teardown,
6646 			test_AES_GMAC_authentication_verify_test_case_3),
6647 		TEST_CASE_ST(ut_setup, ut_teardown,
6648 			test_AES_GMAC_authentication_test_case_4),
6649 		TEST_CASE_ST(ut_setup, ut_teardown,
6650 			test_AES_GMAC_authentication_verify_test_case_4),
6651 
6652 		/** Negative tests */
6653 		TEST_CASE_ST(ut_setup, ut_teardown,
6654 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
6655 		TEST_CASE_ST(ut_setup, ut_teardown,
6656 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
6657 		TEST_CASE_ST(ut_setup, ut_teardown,
6658 			authentication_verify_AES128_GMAC_fail_data_corrupt),
6659 		TEST_CASE_ST(ut_setup, ut_teardown,
6660 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
6661 		TEST_CASE_ST(ut_setup, ut_teardown,
6662 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
6663 		TEST_CASE_ST(ut_setup, ut_teardown,
6664 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
6665 
6666 		TEST_CASES_END() /**< NULL terminate unit test array */
6667 	}
6668 };
6669 
6670 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
6671 	.suite_name = "Crypto Device AESNI GCM Unit Test Suite",
6672 	.setup = testsuite_setup,
6673 	.teardown = testsuite_teardown,
6674 	.unit_test_cases = {
6675 		/** AES GCM Authenticated Encryption */
6676 		TEST_CASE_ST(ut_setup, ut_teardown,
6677 			test_mb_AES_GCM_authenticated_encryption_test_case_1),
6678 		TEST_CASE_ST(ut_setup, ut_teardown,
6679 			test_mb_AES_GCM_authenticated_encryption_test_case_2),
6680 		TEST_CASE_ST(ut_setup, ut_teardown,
6681 			test_mb_AES_GCM_authenticated_encryption_test_case_3),
6682 		TEST_CASE_ST(ut_setup, ut_teardown,
6683 			test_mb_AES_GCM_authenticated_encryption_test_case_4),
6684 		TEST_CASE_ST(ut_setup, ut_teardown,
6685 			test_mb_AES_GCM_authenticated_encryption_test_case_5),
6686 		TEST_CASE_ST(ut_setup, ut_teardown,
6687 			test_mb_AES_GCM_authenticated_encryption_test_case_6),
6688 		TEST_CASE_ST(ut_setup, ut_teardown,
6689 			test_mb_AES_GCM_authenticated_encryption_test_case_7),
6690 
6691 		/** AES GCM Authenticated Decryption */
6692 		TEST_CASE_ST(ut_setup, ut_teardown,
6693 			test_mb_AES_GCM_authenticated_decryption_test_case_1),
6694 		TEST_CASE_ST(ut_setup, ut_teardown,
6695 			test_mb_AES_GCM_authenticated_decryption_test_case_2),
6696 		TEST_CASE_ST(ut_setup, ut_teardown,
6697 			test_mb_AES_GCM_authenticated_decryption_test_case_3),
6698 		TEST_CASE_ST(ut_setup, ut_teardown,
6699 			test_mb_AES_GCM_authenticated_decryption_test_case_4),
6700 		TEST_CASE_ST(ut_setup, ut_teardown,
6701 			test_mb_AES_GCM_authenticated_decryption_test_case_5),
6702 		TEST_CASE_ST(ut_setup, ut_teardown,
6703 			test_mb_AES_GCM_authenticated_decryption_test_case_6),
6704 		TEST_CASE_ST(ut_setup, ut_teardown,
6705 			test_mb_AES_GCM_authenticated_decryption_test_case_7),
6706 
6707 		TEST_CASES_END() /**< NULL terminate unit test array */
6708 	}
6709 };
6710 
6711 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
6712 	.suite_name = "Crypto Device SW KASUMI Unit Test Suite",
6713 	.setup = testsuite_setup,
6714 	.teardown = testsuite_teardown,
6715 	.unit_test_cases = {
6716 		/** KASUMI encrypt only (UEA1) */
6717 		TEST_CASE_ST(ut_setup, ut_teardown,
6718 			test_kasumi_encryption_test_case_1),
6719 		TEST_CASE_ST(ut_setup, ut_teardown,
6720 			test_kasumi_encryption_test_case_2),
6721 		TEST_CASE_ST(ut_setup, ut_teardown,
6722 			test_kasumi_encryption_test_case_3),
6723 		TEST_CASE_ST(ut_setup, ut_teardown,
6724 			test_kasumi_encryption_test_case_4),
6725 		TEST_CASE_ST(ut_setup, ut_teardown,
6726 			test_kasumi_encryption_test_case_5),
6727 		/** KASUMI decrypt only (UEA1) */
6728 		TEST_CASE_ST(ut_setup, ut_teardown,
6729 			test_kasumi_decryption_test_case_1),
6730 		TEST_CASE_ST(ut_setup, ut_teardown,
6731 			test_kasumi_decryption_test_case_2),
6732 		TEST_CASE_ST(ut_setup, ut_teardown,
6733 			test_kasumi_decryption_test_case_3),
6734 		TEST_CASE_ST(ut_setup, ut_teardown,
6735 			test_kasumi_decryption_test_case_4),
6736 		TEST_CASE_ST(ut_setup, ut_teardown,
6737 			test_kasumi_decryption_test_case_5),
6738 
6739 		TEST_CASE_ST(ut_setup, ut_teardown,
6740 			test_kasumi_encryption_test_case_1_oop),
6741 		TEST_CASE_ST(ut_setup, ut_teardown,
6742 			test_kasumi_decryption_test_case_1_oop),
6743 
6744 		/** KASUMI hash only (UIA1) */
6745 		TEST_CASE_ST(ut_setup, ut_teardown,
6746 			test_kasumi_hash_generate_test_case_1),
6747 		TEST_CASE_ST(ut_setup, ut_teardown,
6748 			test_kasumi_hash_generate_test_case_2),
6749 		TEST_CASE_ST(ut_setup, ut_teardown,
6750 			test_kasumi_hash_generate_test_case_3),
6751 		TEST_CASE_ST(ut_setup, ut_teardown,
6752 			test_kasumi_hash_generate_test_case_4),
6753 		TEST_CASE_ST(ut_setup, ut_teardown,
6754 			test_kasumi_hash_generate_test_case_5),
6755 		TEST_CASE_ST(ut_setup, ut_teardown,
6756 			test_kasumi_hash_generate_test_case_6),
6757 		TEST_CASE_ST(ut_setup, ut_teardown,
6758 			test_kasumi_hash_verify_test_case_1),
6759 		TEST_CASE_ST(ut_setup, ut_teardown,
6760 			test_kasumi_hash_verify_test_case_2),
6761 		TEST_CASE_ST(ut_setup, ut_teardown,
6762 			test_kasumi_hash_verify_test_case_3),
6763 		TEST_CASE_ST(ut_setup, ut_teardown,
6764 			test_kasumi_hash_verify_test_case_4),
6765 		TEST_CASE_ST(ut_setup, ut_teardown,
6766 			test_kasumi_hash_verify_test_case_5),
6767 		TEST_CASE_ST(ut_setup, ut_teardown,
6768 			test_kasumi_auth_cipher_test_case_1),
6769 		TEST_CASE_ST(ut_setup, ut_teardown,
6770 			test_kasumi_cipher_auth_test_case_1),
6771 		TEST_CASES_END() /**< NULL terminate unit test array */
6772 	}
6773 };
6774 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
6775 	.suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
6776 	.setup = testsuite_setup,
6777 	.teardown = testsuite_teardown,
6778 	.unit_test_cases = {
6779 		/** SNOW 3G encrypt only (UEA2) */
6780 		TEST_CASE_ST(ut_setup, ut_teardown,
6781 			test_snow3g_encryption_test_case_1),
6782 		TEST_CASE_ST(ut_setup, ut_teardown,
6783 			test_snow3g_encryption_test_case_2),
6784 		TEST_CASE_ST(ut_setup, ut_teardown,
6785 			test_snow3g_encryption_test_case_3),
6786 		TEST_CASE_ST(ut_setup, ut_teardown,
6787 			test_snow3g_encryption_test_case_4),
6788 		TEST_CASE_ST(ut_setup, ut_teardown,
6789 			test_snow3g_encryption_test_case_5),
6790 
6791 		TEST_CASE_ST(ut_setup, ut_teardown,
6792 			test_snow3g_encryption_test_case_1_oop),
6793 		TEST_CASE_ST(ut_setup, ut_teardown,
6794 			test_snow3g_decryption_test_case_1_oop),
6795 
6796 		TEST_CASE_ST(ut_setup, ut_teardown,
6797 			test_snow3g_encryption_test_case_1_offset_oop),
6798 
6799 		/** SNOW 3G decrypt only (UEA2) */
6800 		TEST_CASE_ST(ut_setup, ut_teardown,
6801 			test_snow3g_decryption_test_case_1),
6802 		TEST_CASE_ST(ut_setup, ut_teardown,
6803 			test_snow3g_decryption_test_case_2),
6804 		TEST_CASE_ST(ut_setup, ut_teardown,
6805 			test_snow3g_decryption_test_case_3),
6806 		TEST_CASE_ST(ut_setup, ut_teardown,
6807 			test_snow3g_decryption_test_case_4),
6808 		TEST_CASE_ST(ut_setup, ut_teardown,
6809 			test_snow3g_decryption_test_case_5),
6810 		TEST_CASE_ST(ut_setup, ut_teardown,
6811 			test_snow3g_hash_generate_test_case_1),
6812 		TEST_CASE_ST(ut_setup, ut_teardown,
6813 			test_snow3g_hash_generate_test_case_2),
6814 		TEST_CASE_ST(ut_setup, ut_teardown,
6815 			test_snow3g_hash_generate_test_case_3),
6816 		/* Tests with buffers which length is not byte-aligned */
6817 		TEST_CASE_ST(ut_setup, ut_teardown,
6818 			test_snow3g_hash_generate_test_case_4),
6819 		TEST_CASE_ST(ut_setup, ut_teardown,
6820 			test_snow3g_hash_generate_test_case_5),
6821 		TEST_CASE_ST(ut_setup, ut_teardown,
6822 			test_snow3g_hash_generate_test_case_6),
6823 		TEST_CASE_ST(ut_setup, ut_teardown,
6824 			test_snow3g_hash_verify_test_case_1),
6825 		TEST_CASE_ST(ut_setup, ut_teardown,
6826 			test_snow3g_hash_verify_test_case_2),
6827 		TEST_CASE_ST(ut_setup, ut_teardown,
6828 			test_snow3g_hash_verify_test_case_3),
6829 		/* Tests with buffers which length is not byte-aligned */
6830 		TEST_CASE_ST(ut_setup, ut_teardown,
6831 			test_snow3g_hash_verify_test_case_4),
6832 		TEST_CASE_ST(ut_setup, ut_teardown,
6833 			test_snow3g_hash_verify_test_case_5),
6834 		TEST_CASE_ST(ut_setup, ut_teardown,
6835 			test_snow3g_hash_verify_test_case_6),
6836 		TEST_CASE_ST(ut_setup, ut_teardown,
6837 			test_snow3g_cipher_auth_test_case_1),
6838 		TEST_CASE_ST(ut_setup, ut_teardown,
6839 			test_snow3g_auth_cipher_test_case_1),
6840 
6841 		TEST_CASES_END() /**< NULL terminate unit test array */
6842 	}
6843 };
6844 
6845 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
6846 	.suite_name = "Crypto Device SW ZUC Unit Test Suite",
6847 	.setup = testsuite_setup,
6848 	.teardown = testsuite_teardown,
6849 	.unit_test_cases = {
6850 		/** ZUC encrypt only (EEA3) */
6851 		TEST_CASE_ST(ut_setup, ut_teardown,
6852 			test_zuc_encryption_test_case_1),
6853 		TEST_CASE_ST(ut_setup, ut_teardown,
6854 			test_zuc_encryption_test_case_2),
6855 		TEST_CASE_ST(ut_setup, ut_teardown,
6856 			test_zuc_encryption_test_case_3),
6857 		TEST_CASE_ST(ut_setup, ut_teardown,
6858 			test_zuc_encryption_test_case_4),
6859 		TEST_CASE_ST(ut_setup, ut_teardown,
6860 			test_zuc_encryption_test_case_5),
6861 		TEST_CASE_ST(ut_setup, ut_teardown,
6862 			test_zuc_hash_generate_test_case_1),
6863 		TEST_CASE_ST(ut_setup, ut_teardown,
6864 			test_zuc_hash_generate_test_case_2),
6865 		TEST_CASE_ST(ut_setup, ut_teardown,
6866 			test_zuc_hash_generate_test_case_3),
6867 		TEST_CASE_ST(ut_setup, ut_teardown,
6868 			test_zuc_hash_generate_test_case_4),
6869 		TEST_CASE_ST(ut_setup, ut_teardown,
6870 			test_zuc_hash_generate_test_case_5),
6871 		TEST_CASES_END() /**< NULL terminate unit test array */
6872 	}
6873 };
6874 
6875 static struct unit_test_suite cryptodev_null_testsuite  = {
6876 	.suite_name = "Crypto Device NULL Unit Test Suite",
6877 	.setup = testsuite_setup,
6878 	.teardown = testsuite_teardown,
6879 	.unit_test_cases = {
6880 		TEST_CASE_ST(ut_setup, ut_teardown,
6881 			test_null_auth_only_operation),
6882 		TEST_CASE_ST(ut_setup, ut_teardown,
6883 			test_null_cipher_only_operation),
6884 		TEST_CASE_ST(ut_setup, ut_teardown,
6885 			test_null_cipher_auth_operation),
6886 		TEST_CASE_ST(ut_setup, ut_teardown,
6887 			test_null_auth_cipher_operation),
6888 		TEST_CASE_ST(ut_setup, ut_teardown,
6889 			test_null_invalid_operation),
6890 		TEST_CASE_ST(ut_setup, ut_teardown,
6891 			test_null_burst_operation),
6892 
6893 		TEST_CASES_END() /**< NULL terminate unit test array */
6894 	}
6895 };
6896 
6897 static int
6898 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
6899 {
6900 	gbl_cryptodev_type = RTE_CRYPTODEV_QAT_SYM_PMD;
6901 	return unit_test_suite_runner(&cryptodev_qat_testsuite);
6902 }
6903 
6904 static int
6905 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
6906 {
6907 	gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_MB_PMD;
6908 
6909 	return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
6910 }
6911 
6912 static int
6913 test_cryptodev_openssl(void)
6914 {
6915 	gbl_cryptodev_type = RTE_CRYPTODEV_OPENSSL_PMD;
6916 
6917 	return unit_test_suite_runner(&cryptodev_openssl_testsuite);
6918 }
6919 
6920 static int
6921 test_cryptodev_aesni_gcm(void)
6922 {
6923 	gbl_cryptodev_type = RTE_CRYPTODEV_AESNI_GCM_PMD;
6924 
6925 	return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
6926 }
6927 
6928 static int
6929 test_cryptodev_null(void)
6930 {
6931 	gbl_cryptodev_type = RTE_CRYPTODEV_NULL_PMD;
6932 
6933 	return unit_test_suite_runner(&cryptodev_null_testsuite);
6934 }
6935 
6936 static int
6937 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
6938 {
6939 	gbl_cryptodev_type = RTE_CRYPTODEV_SNOW3G_PMD;
6940 
6941 	return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
6942 }
6943 
6944 static int
6945 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
6946 {
6947 	gbl_cryptodev_type = RTE_CRYPTODEV_KASUMI_PMD;
6948 
6949 	return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
6950 }
6951 
6952 static int
6953 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
6954 {
6955 	gbl_cryptodev_type = RTE_CRYPTODEV_ZUC_PMD;
6956 
6957 	return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
6958 }
6959 
6960 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
6961 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
6962 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
6963 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
6964 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
6965 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
6966 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
6967 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
6968