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