xref: /dpdk/app/test/test_cryptodev.c (revision 5ffa60cd)
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2015-2020 Intel Corporation
3  * Copyright 2020 NXP
4  */
5 
6 #include <time.h>
7 
8 #include <rte_common.h>
9 #include <rte_hexdump.h>
10 #include <rte_mbuf.h>
11 #include <rte_malloc.h>
12 #include <rte_memcpy.h>
13 #include <rte_pause.h>
14 #include <rte_bus_vdev.h>
15 #include <rte_ether.h>
16 
17 #include <rte_crypto.h>
18 #include <rte_cryptodev.h>
19 #include <rte_cryptodev_pmd.h>
20 #include <rte_string_fns.h>
21 
22 #ifdef RTE_CRYPTO_SCHEDULER
23 #include <rte_cryptodev_scheduler.h>
24 #include <rte_cryptodev_scheduler_operations.h>
25 #endif
26 
27 #include <rte_lcore.h>
28 
29 #include "test.h"
30 #include "test_cryptodev.h"
31 
32 #include "test_cryptodev_blockcipher.h"
33 #include "test_cryptodev_aes_test_vectors.h"
34 #include "test_cryptodev_des_test_vectors.h"
35 #include "test_cryptodev_hash_test_vectors.h"
36 #include "test_cryptodev_kasumi_test_vectors.h"
37 #include "test_cryptodev_kasumi_hash_test_vectors.h"
38 #include "test_cryptodev_snow3g_test_vectors.h"
39 #include "test_cryptodev_snow3g_hash_test_vectors.h"
40 #include "test_cryptodev_zuc_test_vectors.h"
41 #include "test_cryptodev_aead_test_vectors.h"
42 #include "test_cryptodev_hmac_test_vectors.h"
43 #include "test_cryptodev_mixed_test_vectors.h"
44 #ifdef RTE_LIB_SECURITY
45 #include "test_cryptodev_security_pdcp_test_vectors.h"
46 #include "test_cryptodev_security_pdcp_sdap_test_vectors.h"
47 #include "test_cryptodev_security_pdcp_test_func.h"
48 #include "test_cryptodev_security_docsis_test_vectors.h"
49 
50 #define SDAP_DISABLED	0
51 #define SDAP_ENABLED	1
52 #endif
53 
54 #define VDEV_ARGS_SIZE 100
55 #define MAX_NB_SESSIONS 4
56 
57 #define MAX_DRV_SERVICE_CTX_SIZE 256
58 
59 #define MAX_RAW_DEQUEUE_COUNT	65535
60 
61 #define IN_PLACE 0
62 #define OUT_OF_PLACE 1
63 
64 #ifndef ARRAY_SIZE
65 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
66 #endif
67 
68 static int gbl_driver_id;
69 
70 static enum rte_security_session_action_type gbl_action_type =
71 	RTE_SECURITY_ACTION_TYPE_NONE;
72 
73 enum cryptodev_api_test_type global_api_test_type = CRYPTODEV_API_TEST;
74 
75 struct crypto_unittest_params {
76 	struct rte_crypto_sym_xform cipher_xform;
77 	struct rte_crypto_sym_xform auth_xform;
78 	struct rte_crypto_sym_xform aead_xform;
79 #ifdef RTE_LIB_SECURITY
80 	struct rte_security_docsis_xform docsis_xform;
81 #endif
82 
83 	union {
84 		struct rte_cryptodev_sym_session *sess;
85 #ifdef RTE_LIB_SECURITY
86 		struct rte_security_session *sec_session;
87 #endif
88 	};
89 #ifdef RTE_LIB_SECURITY
90 	enum rte_security_session_action_type type;
91 #endif
92 	struct rte_crypto_op *op;
93 
94 	struct rte_mbuf *obuf, *ibuf;
95 
96 	uint8_t *digest;
97 };
98 
99 #define ALIGN_POW2_ROUNDUP(num, align) \
100 	(((num) + (align) - 1) & ~((align) - 1))
101 
102 #define ADD_STATIC_TESTSUITE(index, parent_ts, child_ts, num_child_ts)	\
103 	for (j = 0; j < num_child_ts; index++, j++)			\
104 		parent_ts.unit_test_suites[index] = child_ts[j]
105 
106 #define ADD_BLOCKCIPHER_TESTSUITE(index, parent_ts, blk_types, num_blk_types)	\
107 	for (j = 0; j < num_blk_types; index++, j++)				\
108 		parent_ts.unit_test_suites[index] =				\
109 				build_blockcipher_test_suite(blk_types[j])
110 
111 #define FREE_BLOCKCIPHER_TESTSUITE(index, parent_ts, num_blk_types)		\
112 	for (j = index; j < index + num_blk_types; j++)				\
113 		free_blockcipher_test_suite(parent_ts.unit_test_suites[j])
114 
115 /*
116  * Forward declarations.
117  */
118 static int
119 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
120 		struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
121 		uint8_t *hmac_key);
122 
123 static int
124 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
125 		struct crypto_unittest_params *ut_params,
126 		struct crypto_testsuite_params *ts_param,
127 		const uint8_t *cipher,
128 		const uint8_t *digest,
129 		const uint8_t *iv);
130 
131 static struct rte_mbuf *
132 setup_test_string(struct rte_mempool *mpool,
133 		const char *string, size_t len, uint8_t blocksize)
134 {
135 	struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
136 	size_t t_len = len - (blocksize ? (len % blocksize) : 0);
137 
138 	memset(m->buf_addr, 0, m->buf_len);
139 	if (m) {
140 		char *dst = rte_pktmbuf_append(m, t_len);
141 
142 		if (!dst) {
143 			rte_pktmbuf_free(m);
144 			return NULL;
145 		}
146 		if (string != NULL)
147 			rte_memcpy(dst, string, t_len);
148 		else
149 			memset(dst, 0, t_len);
150 	}
151 
152 	return m;
153 }
154 
155 /* Get number of bytes in X bits (rounding up) */
156 static uint32_t
157 ceil_byte_length(uint32_t num_bits)
158 {
159 	if (num_bits % 8)
160 		return ((num_bits >> 3) + 1);
161 	else
162 		return (num_bits >> 3);
163 }
164 
165 static void
166 post_process_raw_dp_op(void *user_data,	uint32_t index __rte_unused,
167 		uint8_t is_op_success)
168 {
169 	struct rte_crypto_op *op = user_data;
170 	op->status = is_op_success ? RTE_CRYPTO_OP_STATUS_SUCCESS :
171 			RTE_CRYPTO_OP_STATUS_ERROR;
172 }
173 
174 void
175 process_sym_raw_dp_op(uint8_t dev_id, uint16_t qp_id,
176 		struct rte_crypto_op *op, uint8_t is_cipher, uint8_t is_auth,
177 		uint8_t len_in_bits, uint8_t cipher_iv_len)
178 {
179 	struct rte_crypto_sym_op *sop = op->sym;
180 	struct rte_crypto_op *ret_op = NULL;
181 	struct rte_crypto_vec data_vec[UINT8_MAX];
182 	struct rte_crypto_va_iova_ptr cipher_iv, digest, aad_auth_iv;
183 	union rte_crypto_sym_ofs ofs;
184 	struct rte_crypto_sym_vec vec;
185 	struct rte_crypto_sgl sgl;
186 	uint32_t max_len;
187 	union rte_cryptodev_session_ctx sess;
188 	uint32_t count = 0;
189 	struct rte_crypto_raw_dp_ctx *ctx;
190 	uint32_t cipher_offset = 0, cipher_len = 0, auth_offset = 0,
191 			auth_len = 0;
192 	int32_t n;
193 	uint32_t n_success;
194 	int ctx_service_size;
195 	int32_t status = 0;
196 	int enqueue_status, dequeue_status;
197 
198 	ctx_service_size = rte_cryptodev_get_raw_dp_ctx_size(dev_id);
199 	if (ctx_service_size < 0) {
200 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
201 		return;
202 	}
203 
204 	ctx = malloc(ctx_service_size);
205 	if (!ctx) {
206 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
207 		return;
208 	}
209 
210 	/* Both are enums, setting crypto_sess will suit any session type */
211 	sess.crypto_sess = op->sym->session;
212 
213 	if (rte_cryptodev_configure_raw_dp_ctx(dev_id, qp_id, ctx,
214 			op->sess_type, sess, 0) < 0) {
215 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
216 		goto exit;
217 	}
218 
219 	cipher_iv.iova = 0;
220 	cipher_iv.va = NULL;
221 	aad_auth_iv.iova = 0;
222 	aad_auth_iv.va = NULL;
223 	digest.iova = 0;
224 	digest.va = NULL;
225 	sgl.vec = data_vec;
226 	vec.num = 1;
227 	vec.sgl = &sgl;
228 	vec.iv = &cipher_iv;
229 	vec.digest = &digest;
230 	vec.aad = &aad_auth_iv;
231 	vec.status = &status;
232 
233 	ofs.raw = 0;
234 
235 	if (is_cipher && is_auth) {
236 		cipher_offset = sop->cipher.data.offset;
237 		cipher_len = sop->cipher.data.length;
238 		auth_offset = sop->auth.data.offset;
239 		auth_len = sop->auth.data.length;
240 		max_len = RTE_MAX(cipher_offset + cipher_len,
241 				auth_offset + auth_len);
242 		if (len_in_bits) {
243 			max_len = max_len >> 3;
244 			cipher_offset = cipher_offset >> 3;
245 			auth_offset = auth_offset >> 3;
246 			cipher_len = cipher_len >> 3;
247 			auth_len = auth_len >> 3;
248 		}
249 		ofs.ofs.cipher.head = cipher_offset;
250 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
251 		ofs.ofs.auth.head = auth_offset;
252 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
253 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
254 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
255 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
256 				op, void *, IV_OFFSET + cipher_iv_len);
257 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
258 				cipher_iv_len);
259 		digest.va = (void *)sop->auth.digest.data;
260 		digest.iova = sop->auth.digest.phys_addr;
261 
262 	} else if (is_cipher) {
263 		cipher_offset = sop->cipher.data.offset;
264 		cipher_len = sop->cipher.data.length;
265 		max_len = cipher_len + cipher_offset;
266 		if (len_in_bits) {
267 			max_len = max_len >> 3;
268 			cipher_offset = cipher_offset >> 3;
269 			cipher_len = cipher_len >> 3;
270 		}
271 		ofs.ofs.cipher.head = cipher_offset;
272 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
273 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
274 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
275 
276 	} else if (is_auth) {
277 		auth_offset = sop->auth.data.offset;
278 		auth_len = sop->auth.data.length;
279 		max_len = auth_len + auth_offset;
280 		if (len_in_bits) {
281 			max_len = max_len >> 3;
282 			auth_offset = auth_offset >> 3;
283 			auth_len = auth_len >> 3;
284 		}
285 		ofs.ofs.auth.head = auth_offset;
286 		ofs.ofs.auth.tail = max_len - auth_offset - auth_len;
287 		aad_auth_iv.va = rte_crypto_op_ctod_offset(
288 				op, void *, IV_OFFSET + cipher_iv_len);
289 		aad_auth_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET +
290 				cipher_iv_len);
291 		digest.va = (void *)sop->auth.digest.data;
292 		digest.iova = sop->auth.digest.phys_addr;
293 
294 	} else { /* aead */
295 		cipher_offset = sop->aead.data.offset;
296 		cipher_len = sop->aead.data.length;
297 		max_len = cipher_len + cipher_offset;
298 		if (len_in_bits) {
299 			max_len = max_len >> 3;
300 			cipher_offset = cipher_offset >> 3;
301 			cipher_len = cipher_len >> 3;
302 		}
303 		ofs.ofs.cipher.head = cipher_offset;
304 		ofs.ofs.cipher.tail = max_len - cipher_offset - cipher_len;
305 		cipher_iv.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
306 		cipher_iv.iova = rte_crypto_op_ctophys_offset(op, IV_OFFSET);
307 		aad_auth_iv.va = (void *)sop->aead.aad.data;
308 		aad_auth_iv.iova = sop->aead.aad.phys_addr;
309 		digest.va = (void *)sop->aead.digest.data;
310 		digest.iova = sop->aead.digest.phys_addr;
311 	}
312 
313 	n = rte_crypto_mbuf_to_vec(sop->m_src, 0, max_len,
314 			data_vec, RTE_DIM(data_vec));
315 	if (n < 0 || n > sop->m_src->nb_segs) {
316 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
317 		goto exit;
318 	}
319 
320 	sgl.num = n;
321 
322 	if (rte_cryptodev_raw_enqueue_burst(ctx, &vec, ofs, (void **)&op,
323 			&enqueue_status) < 1) {
324 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
325 		goto exit;
326 	}
327 
328 	if (enqueue_status == 0) {
329 		status = rte_cryptodev_raw_enqueue_done(ctx, 1);
330 		if (status < 0) {
331 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
332 			goto exit;
333 		}
334 	} else if (enqueue_status < 0) {
335 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
336 		goto exit;
337 	}
338 
339 	n = n_success = 0;
340 	while (count++ < MAX_RAW_DEQUEUE_COUNT && n == 0) {
341 		n = rte_cryptodev_raw_dequeue_burst(ctx,
342 			NULL, 1, post_process_raw_dp_op,
343 				(void **)&ret_op, 0, &n_success,
344 				&dequeue_status);
345 		if (dequeue_status < 0) {
346 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
347 			goto exit;
348 		}
349 		if (n == 0)
350 			rte_pause();
351 	}
352 
353 	if (n == 1 && dequeue_status == 0) {
354 		if (rte_cryptodev_raw_dequeue_done(ctx, 1) < 0) {
355 			op->status = RTE_CRYPTO_OP_STATUS_ERROR;
356 			goto exit;
357 		}
358 	}
359 
360 	op->status = (count == MAX_RAW_DEQUEUE_COUNT + 1 || ret_op != op ||
361 			n_success < 1) ? RTE_CRYPTO_OP_STATUS_ERROR :
362 					RTE_CRYPTO_OP_STATUS_SUCCESS;
363 
364 exit:
365 	free(ctx);
366 }
367 
368 static void
369 process_cpu_aead_op(uint8_t dev_id, struct rte_crypto_op *op)
370 {
371 	int32_t n, st;
372 	struct rte_crypto_sym_op *sop;
373 	union rte_crypto_sym_ofs ofs;
374 	struct rte_crypto_sgl sgl;
375 	struct rte_crypto_sym_vec symvec;
376 	struct rte_crypto_va_iova_ptr iv_ptr, aad_ptr, digest_ptr;
377 	struct rte_crypto_vec vec[UINT8_MAX];
378 
379 	sop = op->sym;
380 
381 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->aead.data.offset,
382 		sop->aead.data.length, vec, RTE_DIM(vec));
383 
384 	if (n < 0 || n != sop->m_src->nb_segs) {
385 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
386 		return;
387 	}
388 
389 	sgl.vec = vec;
390 	sgl.num = n;
391 	symvec.sgl = &sgl;
392 	symvec.iv = &iv_ptr;
393 	symvec.digest = &digest_ptr;
394 	symvec.aad = &aad_ptr;
395 	symvec.status = &st;
396 	symvec.num = 1;
397 
398 	/* for CPU crypto the IOVA address is not required */
399 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
400 	digest_ptr.va = (void *)sop->aead.digest.data;
401 	aad_ptr.va = (void *)sop->aead.aad.data;
402 
403 	ofs.raw = 0;
404 
405 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
406 		&symvec);
407 
408 	if (n != 1)
409 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
410 	else
411 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
412 }
413 
414 static void
415 process_cpu_crypt_auth_op(uint8_t dev_id, struct rte_crypto_op *op)
416 {
417 	int32_t n, st;
418 	struct rte_crypto_sym_op *sop;
419 	union rte_crypto_sym_ofs ofs;
420 	struct rte_crypto_sgl sgl;
421 	struct rte_crypto_sym_vec symvec;
422 	struct rte_crypto_va_iova_ptr iv_ptr, digest_ptr;
423 	struct rte_crypto_vec vec[UINT8_MAX];
424 
425 	sop = op->sym;
426 
427 	n = rte_crypto_mbuf_to_vec(sop->m_src, sop->auth.data.offset,
428 		sop->auth.data.length, vec, RTE_DIM(vec));
429 
430 	if (n < 0 || n != sop->m_src->nb_segs) {
431 		op->status = RTE_CRYPTO_OP_STATUS_ERROR;
432 		return;
433 	}
434 
435 	sgl.vec = vec;
436 	sgl.num = n;
437 	symvec.sgl = &sgl;
438 	symvec.iv = &iv_ptr;
439 	symvec.digest = &digest_ptr;
440 	symvec.status = &st;
441 	symvec.num = 1;
442 
443 	iv_ptr.va = rte_crypto_op_ctod_offset(op, void *, IV_OFFSET);
444 	digest_ptr.va = (void *)sop->auth.digest.data;
445 
446 	ofs.raw = 0;
447 	ofs.ofs.cipher.head = sop->cipher.data.offset - sop->auth.data.offset;
448 	ofs.ofs.cipher.tail = (sop->auth.data.offset + sop->auth.data.length) -
449 		(sop->cipher.data.offset + sop->cipher.data.length);
450 
451 	n = rte_cryptodev_sym_cpu_crypto_process(dev_id, sop->session, ofs,
452 		&symvec);
453 
454 	if (n != 1)
455 		op->status = RTE_CRYPTO_OP_STATUS_AUTH_FAILED;
456 	else
457 		op->status = RTE_CRYPTO_OP_STATUS_SUCCESS;
458 }
459 
460 static struct rte_crypto_op *
461 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
462 {
463 
464 	RTE_VERIFY(gbl_action_type != RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO);
465 
466 	if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
467 		RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
468 		return NULL;
469 	}
470 
471 	op = NULL;
472 
473 	while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
474 		rte_pause();
475 
476 	if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
477 		RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
478 		return NULL;
479 	}
480 
481 	return op;
482 }
483 
484 static struct crypto_testsuite_params testsuite_params = { NULL };
485 struct crypto_testsuite_params *p_testsuite_params = &testsuite_params;
486 static struct crypto_unittest_params unittest_params;
487 
488 static int
489 testsuite_setup(void)
490 {
491 	struct crypto_testsuite_params *ts_params = &testsuite_params;
492 	struct rte_cryptodev_info info;
493 	uint32_t i = 0, nb_devs, dev_id;
494 	uint16_t qp_id;
495 
496 	memset(ts_params, 0, sizeof(*ts_params));
497 
498 	ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
499 	if (ts_params->mbuf_pool == NULL) {
500 		/* Not already created so create */
501 		ts_params->mbuf_pool = rte_pktmbuf_pool_create(
502 				"CRYPTO_MBUFPOOL",
503 				NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
504 				rte_socket_id());
505 		if (ts_params->mbuf_pool == NULL) {
506 			RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
507 			return TEST_FAILED;
508 		}
509 	}
510 
511 	ts_params->large_mbuf_pool = rte_mempool_lookup(
512 			"CRYPTO_LARGE_MBUFPOOL");
513 	if (ts_params->large_mbuf_pool == NULL) {
514 		/* Not already created so create */
515 		ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
516 				"CRYPTO_LARGE_MBUFPOOL",
517 				1, 0, 0, UINT16_MAX,
518 				rte_socket_id());
519 		if (ts_params->large_mbuf_pool == NULL) {
520 			RTE_LOG(ERR, USER1,
521 				"Can't create CRYPTO_LARGE_MBUFPOOL\n");
522 			return TEST_FAILED;
523 		}
524 	}
525 
526 	ts_params->op_mpool = rte_crypto_op_pool_create(
527 			"MBUF_CRYPTO_SYM_OP_POOL",
528 			RTE_CRYPTO_OP_TYPE_SYMMETRIC,
529 			NUM_MBUFS, MBUF_CACHE_SIZE,
530 			DEFAULT_NUM_XFORMS *
531 			sizeof(struct rte_crypto_sym_xform) +
532 			MAXIMUM_IV_LENGTH,
533 			rte_socket_id());
534 	if (ts_params->op_mpool == NULL) {
535 		RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
536 		return TEST_FAILED;
537 	}
538 
539 	nb_devs = rte_cryptodev_count();
540 	if (nb_devs < 1) {
541 		RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
542 		return TEST_SKIPPED;
543 	}
544 
545 	if (rte_cryptodev_device_count_by_driver(gbl_driver_id) < 1) {
546 		RTE_LOG(WARNING, USER1, "No %s devices found?\n",
547 				rte_cryptodev_driver_name_get(gbl_driver_id));
548 		return TEST_SKIPPED;
549 	}
550 
551 	/* Create list of valid crypto devs */
552 	for (i = 0; i < nb_devs; i++) {
553 		rte_cryptodev_info_get(i, &info);
554 		if (info.driver_id == gbl_driver_id)
555 			ts_params->valid_devs[ts_params->valid_dev_count++] = i;
556 	}
557 
558 	if (ts_params->valid_dev_count < 1)
559 		return TEST_FAILED;
560 
561 	/* Set up all the qps on the first of the valid devices found */
562 
563 	dev_id = ts_params->valid_devs[0];
564 
565 	rte_cryptodev_info_get(dev_id, &info);
566 
567 	ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
568 	ts_params->conf.socket_id = SOCKET_ID_ANY;
569 	ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
570 
571 	unsigned int session_size =
572 		rte_cryptodev_sym_get_private_session_size(dev_id);
573 
574 #ifdef RTE_LIB_SECURITY
575 	unsigned int security_session_size = rte_security_session_get_size(
576 			rte_cryptodev_get_sec_ctx(dev_id));
577 
578 	if (session_size < security_session_size)
579 		session_size = security_session_size;
580 #endif
581 	/*
582 	 * Create mempool with maximum number of sessions.
583 	 */
584 	if (info.sym.max_nb_sessions != 0 &&
585 			info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
586 		RTE_LOG(ERR, USER1, "Device does not support "
587 				"at least %u sessions\n",
588 				MAX_NB_SESSIONS);
589 		return TEST_FAILED;
590 	}
591 
592 	ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
593 			"test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
594 			SOCKET_ID_ANY);
595 	TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
596 			"session mempool allocation failed");
597 
598 	ts_params->session_priv_mpool = rte_mempool_create(
599 			"test_sess_mp_priv",
600 			MAX_NB_SESSIONS,
601 			session_size,
602 			0, 0, NULL, NULL, NULL,
603 			NULL, SOCKET_ID_ANY,
604 			0);
605 	TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
606 			"session mempool allocation failed");
607 
608 
609 
610 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
611 			&ts_params->conf),
612 			"Failed to configure cryptodev %u with %u qps",
613 			dev_id, ts_params->conf.nb_queue_pairs);
614 
615 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
616 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
617 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
618 
619 	for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
620 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
621 			dev_id, qp_id, &ts_params->qp_conf,
622 			rte_cryptodev_socket_id(dev_id)),
623 			"Failed to setup queue pair %u on cryptodev %u",
624 			qp_id, dev_id);
625 	}
626 
627 	return TEST_SUCCESS;
628 }
629 
630 static void
631 testsuite_teardown(void)
632 {
633 	struct crypto_testsuite_params *ts_params = &testsuite_params;
634 	int res;
635 
636 	if (ts_params->mbuf_pool != NULL) {
637 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
638 		rte_mempool_avail_count(ts_params->mbuf_pool));
639 	}
640 
641 	if (ts_params->op_mpool != NULL) {
642 		RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
643 		rte_mempool_avail_count(ts_params->op_mpool));
644 	}
645 
646 	/* Free session mempools */
647 	if (ts_params->session_priv_mpool != NULL) {
648 		rte_mempool_free(ts_params->session_priv_mpool);
649 		ts_params->session_priv_mpool = NULL;
650 	}
651 
652 	if (ts_params->session_mpool != NULL) {
653 		rte_mempool_free(ts_params->session_mpool);
654 		ts_params->session_mpool = NULL;
655 	}
656 
657 	res = rte_cryptodev_close(ts_params->valid_devs[0]);
658 	if (res)
659 		RTE_LOG(ERR, USER1, "Crypto device close error %d\n", res);
660 }
661 
662 static int
663 check_capabilities_supported(enum rte_crypto_sym_xform_type type,
664 		const int *algs, uint16_t num_algs)
665 {
666 	uint8_t dev_id = testsuite_params.valid_devs[0];
667 	bool some_alg_supported = FALSE;
668 	uint16_t i;
669 
670 	for (i = 0; i < num_algs && !some_alg_supported; i++) {
671 		struct rte_cryptodev_sym_capability_idx alg = {
672 			type, {algs[i]}
673 		};
674 		if (rte_cryptodev_sym_capability_get(dev_id,
675 				&alg) != NULL)
676 			some_alg_supported = TRUE;
677 	}
678 	if (!some_alg_supported)
679 		return TEST_SKIPPED;
680 
681 	return 0;
682 }
683 
684 int
685 check_cipher_capabilities_supported(const enum rte_crypto_cipher_algorithm *ciphers,
686 		uint16_t num_ciphers)
687 {
688 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_CIPHER,
689 			(const int *) ciphers, num_ciphers);
690 }
691 
692 int
693 check_auth_capabilities_supported(const enum rte_crypto_auth_algorithm *auths,
694 		uint16_t num_auths)
695 {
696 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AUTH,
697 			(const int *) auths, num_auths);
698 }
699 
700 int
701 check_aead_capabilities_supported(const enum rte_crypto_aead_algorithm *aeads,
702 		uint16_t num_aeads)
703 {
704 	return check_capabilities_supported(RTE_CRYPTO_SYM_XFORM_AEAD,
705 			(const int *) aeads, num_aeads);
706 }
707 
708 static int
709 null_testsuite_setup(void)
710 {
711 	struct crypto_testsuite_params *ts_params = &testsuite_params;
712 	uint8_t dev_id = ts_params->valid_devs[0];
713 	struct rte_cryptodev_info dev_info;
714 	const enum rte_crypto_cipher_algorithm ciphers[] = {
715 		RTE_CRYPTO_CIPHER_NULL
716 	};
717 	const enum rte_crypto_auth_algorithm auths[] = {
718 		RTE_CRYPTO_AUTH_NULL
719 	};
720 
721 	rte_cryptodev_info_get(dev_id, &dev_info);
722 
723 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
724 		RTE_LOG(INFO, USER1, "Feature flag requirements for NULL "
725 				"testsuite not met\n");
726 		return TEST_SKIPPED;
727 	}
728 
729 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
730 			&& check_auth_capabilities_supported(auths,
731 			RTE_DIM(auths)) != 0) {
732 		RTE_LOG(INFO, USER1, "Capability requirements for NULL "
733 				"testsuite not met\n");
734 		return TEST_SKIPPED;
735 	}
736 
737 	return 0;
738 }
739 
740 static int
741 crypto_gen_testsuite_setup(void)
742 {
743 	struct crypto_testsuite_params *ts_params = &testsuite_params;
744 	uint8_t dev_id = ts_params->valid_devs[0];
745 	struct rte_cryptodev_info dev_info;
746 
747 	rte_cryptodev_info_get(dev_id, &dev_info);
748 
749 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
750 		RTE_LOG(INFO, USER1, "Feature flag requirements for Crypto Gen "
751 				"testsuite not met\n");
752 		return TEST_SKIPPED;
753 	}
754 
755 	return 0;
756 }
757 
758 #ifdef RTE_LIB_SECURITY
759 static int
760 pdcp_proto_testsuite_setup(void)
761 {
762 	struct crypto_testsuite_params *ts_params = &testsuite_params;
763 	uint8_t dev_id = ts_params->valid_devs[0];
764 	struct rte_cryptodev_info dev_info;
765 	const enum rte_crypto_cipher_algorithm ciphers[] = {
766 		RTE_CRYPTO_CIPHER_NULL,
767 		RTE_CRYPTO_CIPHER_AES_CTR,
768 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
769 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
770 	};
771 	const enum rte_crypto_auth_algorithm auths[] = {
772 		RTE_CRYPTO_AUTH_NULL,
773 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
774 		RTE_CRYPTO_AUTH_AES_CMAC,
775 		RTE_CRYPTO_AUTH_ZUC_EIA3
776 	};
777 
778 	rte_cryptodev_info_get(dev_id, &dev_info);
779 
780 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
781 			!(dev_info.feature_flags &
782 			RTE_CRYPTODEV_FF_SECURITY)) {
783 		RTE_LOG(INFO, USER1, "Feature flag requirements for PDCP Proto "
784 				"testsuite not met\n");
785 		return TEST_SKIPPED;
786 	}
787 
788 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
789 			&& check_auth_capabilities_supported(auths,
790 			RTE_DIM(auths)) != 0) {
791 		RTE_LOG(INFO, USER1, "Capability requirements for PDCP Proto "
792 				"testsuite not met\n");
793 		return TEST_SKIPPED;
794 	}
795 
796 	return 0;
797 }
798 
799 static int
800 docsis_proto_testsuite_setup(void)
801 {
802 	struct crypto_testsuite_params *ts_params = &testsuite_params;
803 	uint8_t dev_id = ts_params->valid_devs[0];
804 	struct rte_cryptodev_info dev_info;
805 	const enum rte_crypto_cipher_algorithm ciphers[] = {
806 		RTE_CRYPTO_CIPHER_AES_DOCSISBPI
807 	};
808 
809 	rte_cryptodev_info_get(dev_id, &dev_info);
810 
811 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
812 			!(dev_info.feature_flags &
813 			RTE_CRYPTODEV_FF_SECURITY)) {
814 		RTE_LOG(INFO, USER1, "Feature flag requirements for Docsis "
815 				"Proto testsuite not met\n");
816 		return TEST_SKIPPED;
817 	}
818 
819 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0) {
820 		RTE_LOG(INFO, USER1, "Capability requirements for Docsis Proto "
821 				"testsuite not met\n");
822 		return TEST_SKIPPED;
823 	}
824 
825 	return 0;
826 }
827 #endif
828 
829 static int
830 aes_ccm_auth_testsuite_setup(void)
831 {
832 	struct crypto_testsuite_params *ts_params = &testsuite_params;
833 	uint8_t dev_id = ts_params->valid_devs[0];
834 	struct rte_cryptodev_info dev_info;
835 	const enum rte_crypto_aead_algorithm aeads[] = {
836 		RTE_CRYPTO_AEAD_AES_CCM
837 	};
838 
839 	rte_cryptodev_info_get(dev_id, &dev_info);
840 
841 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
842 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
843 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
844 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES CCM "
845 				"testsuite not met\n");
846 		return TEST_SKIPPED;
847 	}
848 
849 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
850 		RTE_LOG(INFO, USER1, "Capability requirements for AES CCM "
851 				"testsuite not met\n");
852 		return TEST_SKIPPED;
853 	}
854 
855 	return 0;
856 }
857 
858 static int
859 aes_gcm_auth_testsuite_setup(void)
860 {
861 	struct crypto_testsuite_params *ts_params = &testsuite_params;
862 	uint8_t dev_id = ts_params->valid_devs[0];
863 	struct rte_cryptodev_info dev_info;
864 	const enum rte_crypto_aead_algorithm aeads[] = {
865 		RTE_CRYPTO_AEAD_AES_GCM
866 	};
867 
868 	rte_cryptodev_info_get(dev_id, &dev_info);
869 
870 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
871 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GCM "
872 				"testsuite not met\n");
873 		return TEST_SKIPPED;
874 	}
875 
876 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
877 		RTE_LOG(INFO, USER1, "Capability requirements for AES GCM "
878 				"testsuite not met\n");
879 		return TEST_SKIPPED;
880 	}
881 
882 	return 0;
883 }
884 
885 static int
886 aes_gmac_auth_testsuite_setup(void)
887 {
888 	struct crypto_testsuite_params *ts_params = &testsuite_params;
889 	uint8_t dev_id = ts_params->valid_devs[0];
890 	struct rte_cryptodev_info dev_info;
891 	const enum rte_crypto_auth_algorithm auths[] = {
892 		RTE_CRYPTO_AUTH_AES_GMAC
893 	};
894 
895 	rte_cryptodev_info_get(dev_id, &dev_info);
896 
897 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
898 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
899 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
900 		RTE_LOG(INFO, USER1, "Feature flag requirements for AES GMAC "
901 				"testsuite not met\n");
902 		return TEST_SKIPPED;
903 	}
904 
905 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
906 		RTE_LOG(INFO, USER1, "Capability requirements for AES GMAC "
907 				"testsuite not met\n");
908 		return TEST_SKIPPED;
909 	}
910 
911 	return 0;
912 }
913 
914 static int
915 chacha20_poly1305_testsuite_setup(void)
916 {
917 	struct crypto_testsuite_params *ts_params = &testsuite_params;
918 	uint8_t dev_id = ts_params->valid_devs[0];
919 	struct rte_cryptodev_info dev_info;
920 	const enum rte_crypto_aead_algorithm aeads[] = {
921 		RTE_CRYPTO_AEAD_CHACHA20_POLY1305
922 	};
923 
924 	rte_cryptodev_info_get(dev_id, &dev_info);
925 
926 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
927 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
928 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
929 		RTE_LOG(INFO, USER1, "Feature flag requirements for "
930 				"Chacha20-Poly1305 testsuite not met\n");
931 		return TEST_SKIPPED;
932 	}
933 
934 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
935 		RTE_LOG(INFO, USER1, "Capability requirements for "
936 				"Chacha20-Poly1305 testsuite not met\n");
937 		return TEST_SKIPPED;
938 	}
939 
940 	return 0;
941 }
942 
943 static int
944 snow3g_testsuite_setup(void)
945 {
946 	struct crypto_testsuite_params *ts_params = &testsuite_params;
947 	uint8_t dev_id = ts_params->valid_devs[0];
948 	struct rte_cryptodev_info dev_info;
949 	const enum rte_crypto_cipher_algorithm ciphers[] = {
950 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
951 
952 	};
953 	const enum rte_crypto_auth_algorithm auths[] = {
954 		RTE_CRYPTO_AUTH_SNOW3G_UIA2
955 	};
956 
957 	rte_cryptodev_info_get(dev_id, &dev_info);
958 
959 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
960 		RTE_LOG(INFO, USER1, "Feature flag requirements for Snow3G "
961 				"testsuite not met\n");
962 		return TEST_SKIPPED;
963 	}
964 
965 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
966 			&& check_auth_capabilities_supported(auths,
967 			RTE_DIM(auths)) != 0) {
968 		RTE_LOG(INFO, USER1, "Capability requirements for Snow3G "
969 				"testsuite not met\n");
970 		return TEST_SKIPPED;
971 	}
972 
973 	return 0;
974 }
975 
976 static int
977 zuc_testsuite_setup(void)
978 {
979 	struct crypto_testsuite_params *ts_params = &testsuite_params;
980 	uint8_t dev_id = ts_params->valid_devs[0];
981 	struct rte_cryptodev_info dev_info;
982 	const enum rte_crypto_cipher_algorithm ciphers[] = {
983 		RTE_CRYPTO_CIPHER_ZUC_EEA3
984 	};
985 	const enum rte_crypto_auth_algorithm auths[] = {
986 		RTE_CRYPTO_AUTH_ZUC_EIA3
987 	};
988 
989 	rte_cryptodev_info_get(dev_id, &dev_info);
990 
991 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
992 		RTE_LOG(INFO, USER1, "Feature flag requirements for ZUC "
993 				"testsuite not met\n");
994 		return TEST_SKIPPED;
995 	}
996 
997 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
998 			&& check_auth_capabilities_supported(auths,
999 			RTE_DIM(auths)) != 0) {
1000 		RTE_LOG(INFO, USER1, "Capability requirements for ZUC "
1001 				"testsuite not met\n");
1002 		return TEST_SKIPPED;
1003 	}
1004 
1005 	return 0;
1006 }
1007 
1008 static int
1009 hmac_md5_auth_testsuite_setup(void)
1010 {
1011 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1012 	uint8_t dev_id = ts_params->valid_devs[0];
1013 	struct rte_cryptodev_info dev_info;
1014 	const enum rte_crypto_auth_algorithm auths[] = {
1015 		RTE_CRYPTO_AUTH_MD5_HMAC
1016 	};
1017 
1018 	rte_cryptodev_info_get(dev_id, &dev_info);
1019 
1020 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1021 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1022 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1023 		RTE_LOG(INFO, USER1, "Feature flag requirements for HMAC MD5 "
1024 				"Auth testsuite not met\n");
1025 		return TEST_SKIPPED;
1026 	}
1027 
1028 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1029 		RTE_LOG(INFO, USER1, "Capability requirements for HMAC MD5 "
1030 				"testsuite not met\n");
1031 		return TEST_SKIPPED;
1032 	}
1033 
1034 	return 0;
1035 }
1036 
1037 static int
1038 kasumi_testsuite_setup(void)
1039 {
1040 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1041 	uint8_t dev_id = ts_params->valid_devs[0];
1042 	struct rte_cryptodev_info dev_info;
1043 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1044 		RTE_CRYPTO_CIPHER_KASUMI_F8
1045 	};
1046 	const enum rte_crypto_auth_algorithm auths[] = {
1047 		RTE_CRYPTO_AUTH_KASUMI_F9
1048 	};
1049 
1050 	rte_cryptodev_info_get(dev_id, &dev_info);
1051 
1052 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1053 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1054 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1055 		RTE_LOG(INFO, USER1, "Feature flag requirements for Kasumi "
1056 				"testsuite not met\n");
1057 		return TEST_SKIPPED;
1058 	}
1059 
1060 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1061 			&& check_auth_capabilities_supported(auths,
1062 			RTE_DIM(auths)) != 0) {
1063 		RTE_LOG(INFO, USER1, "Capability requirements for Kasumi "
1064 				"testsuite not met\n");
1065 		return TEST_SKIPPED;
1066 	}
1067 
1068 	return 0;
1069 }
1070 
1071 static int
1072 negative_aes_gcm_testsuite_setup(void)
1073 {
1074 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1075 	uint8_t dev_id = ts_params->valid_devs[0];
1076 	struct rte_cryptodev_info dev_info;
1077 	const enum rte_crypto_aead_algorithm aeads[] = {
1078 		RTE_CRYPTO_AEAD_AES_GCM
1079 	};
1080 
1081 	rte_cryptodev_info_get(dev_id, &dev_info);
1082 
1083 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1084 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1085 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1086 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1087 				"AES GCM testsuite not met\n");
1088 		return TEST_SKIPPED;
1089 	}
1090 
1091 	if (check_aead_capabilities_supported(aeads, RTE_DIM(aeads)) != 0) {
1092 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1093 				"AES GCM testsuite not met\n");
1094 		return TEST_SKIPPED;
1095 	}
1096 
1097 	return 0;
1098 }
1099 
1100 static int
1101 negative_aes_gmac_testsuite_setup(void)
1102 {
1103 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1104 	uint8_t dev_id = ts_params->valid_devs[0];
1105 	struct rte_cryptodev_info dev_info;
1106 	const enum rte_crypto_auth_algorithm auths[] = {
1107 		RTE_CRYPTO_AUTH_AES_GMAC
1108 	};
1109 
1110 	rte_cryptodev_info_get(dev_id, &dev_info);
1111 
1112 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1113 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1114 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1115 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1116 				"AES GMAC testsuite not met\n");
1117 		return TEST_SKIPPED;
1118 	}
1119 
1120 	if (check_auth_capabilities_supported(auths, RTE_DIM(auths)) != 0) {
1121 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1122 				"AES GMAC testsuite not met\n");
1123 		return TEST_SKIPPED;
1124 	}
1125 
1126 	return 0;
1127 }
1128 
1129 static int
1130 mixed_cipher_hash_testsuite_setup(void)
1131 {
1132 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1133 	uint8_t dev_id = ts_params->valid_devs[0];
1134 	struct rte_cryptodev_info dev_info;
1135 	uint64_t feat_flags;
1136 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1137 		RTE_CRYPTO_CIPHER_NULL,
1138 		RTE_CRYPTO_CIPHER_AES_CTR,
1139 		RTE_CRYPTO_CIPHER_ZUC_EEA3,
1140 		RTE_CRYPTO_CIPHER_SNOW3G_UEA2
1141 	};
1142 	const enum rte_crypto_auth_algorithm auths[] = {
1143 		RTE_CRYPTO_AUTH_NULL,
1144 		RTE_CRYPTO_AUTH_SNOW3G_UIA2,
1145 		RTE_CRYPTO_AUTH_AES_CMAC,
1146 		RTE_CRYPTO_AUTH_ZUC_EIA3
1147 	};
1148 
1149 	rte_cryptodev_info_get(dev_id, &dev_info);
1150 	feat_flags = dev_info.feature_flags;
1151 
1152 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1153 			(global_api_test_type == CRYPTODEV_RAW_API_TEST)) {
1154 		RTE_LOG(INFO, USER1, "Feature flag requirements for Mixed "
1155 				"Cipher Hash testsuite not met\n");
1156 		return TEST_SKIPPED;
1157 	}
1158 
1159 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1160 			&& check_auth_capabilities_supported(auths,
1161 			RTE_DIM(auths)) != 0) {
1162 		RTE_LOG(INFO, USER1, "Capability requirements for Mixed "
1163 				"Cipher Hash testsuite not met\n");
1164 		return TEST_SKIPPED;
1165 	}
1166 
1167 	return 0;
1168 }
1169 
1170 static int
1171 esn_testsuite_setup(void)
1172 {
1173 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1174 	uint8_t dev_id = ts_params->valid_devs[0];
1175 	struct rte_cryptodev_info dev_info;
1176 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1177 		RTE_CRYPTO_CIPHER_AES_CBC
1178 	};
1179 	const enum rte_crypto_auth_algorithm auths[] = {
1180 		RTE_CRYPTO_AUTH_SHA1_HMAC
1181 	};
1182 
1183 	rte_cryptodev_info_get(dev_id, &dev_info);
1184 
1185 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1186 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1187 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1188 		RTE_LOG(INFO, USER1, "Feature flag requirements for ESN "
1189 				"testsuite not met\n");
1190 		return TEST_SKIPPED;
1191 	}
1192 
1193 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1194 			&& check_auth_capabilities_supported(auths,
1195 			RTE_DIM(auths)) != 0) {
1196 		RTE_LOG(INFO, USER1, "Capability requirements for ESN "
1197 				"testsuite not met\n");
1198 		return TEST_SKIPPED;
1199 	}
1200 
1201 	return 0;
1202 }
1203 
1204 static int
1205 multi_session_testsuite_setup(void)
1206 {
1207 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1208 	uint8_t dev_id = ts_params->valid_devs[0];
1209 	struct rte_cryptodev_info dev_info;
1210 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1211 		RTE_CRYPTO_CIPHER_AES_CBC
1212 	};
1213 	const enum rte_crypto_auth_algorithm auths[] = {
1214 		RTE_CRYPTO_AUTH_SHA512_HMAC
1215 	};
1216 
1217 	rte_cryptodev_info_get(dev_id, &dev_info);
1218 
1219 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO)) {
1220 		RTE_LOG(INFO, USER1, "Feature flag requirements for Multi "
1221 				"Session testsuite not met\n");
1222 		return TEST_SKIPPED;
1223 	}
1224 
1225 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1226 			&& check_auth_capabilities_supported(auths,
1227 			RTE_DIM(auths)) != 0) {
1228 		RTE_LOG(INFO, USER1, "Capability requirements for Multi "
1229 				"Session testsuite not met\n");
1230 		return TEST_SKIPPED;
1231 	}
1232 
1233 	return 0;
1234 }
1235 
1236 static int
1237 negative_hmac_sha1_testsuite_setup(void)
1238 {
1239 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1240 	uint8_t dev_id = ts_params->valid_devs[0];
1241 	struct rte_cryptodev_info dev_info;
1242 	const enum rte_crypto_cipher_algorithm ciphers[] = {
1243 		RTE_CRYPTO_CIPHER_AES_CBC
1244 	};
1245 	const enum rte_crypto_auth_algorithm auths[] = {
1246 		RTE_CRYPTO_AUTH_SHA1_HMAC
1247 	};
1248 
1249 	rte_cryptodev_info_get(dev_id, &dev_info);
1250 
1251 	if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYMMETRIC_CRYPTO) ||
1252 			((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
1253 			!(dev_info.feature_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
1254 		RTE_LOG(INFO, USER1, "Feature flag requirements for Negative "
1255 				"HMAC SHA1 testsuite not met\n");
1256 		return TEST_SKIPPED;
1257 	}
1258 
1259 	if (check_cipher_capabilities_supported(ciphers, RTE_DIM(ciphers)) != 0
1260 			&& check_auth_capabilities_supported(auths,
1261 			RTE_DIM(auths)) != 0) {
1262 		RTE_LOG(INFO, USER1, "Capability requirements for Negative "
1263 				"HMAC SHA1 testsuite not met\n");
1264 		return TEST_SKIPPED;
1265 	}
1266 
1267 	return 0;
1268 }
1269 
1270 static int
1271 dev_configure_and_start(uint64_t ff_disable)
1272 {
1273 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1274 	struct crypto_unittest_params *ut_params = &unittest_params;
1275 
1276 	uint16_t qp_id;
1277 
1278 	/* Clear unit test parameters before running test */
1279 	memset(ut_params, 0, sizeof(*ut_params));
1280 
1281 	/* Reconfigure device to default parameters */
1282 	ts_params->conf.socket_id = SOCKET_ID_ANY;
1283 	ts_params->conf.ff_disable = ff_disable;
1284 	ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
1285 	ts_params->qp_conf.mp_session = ts_params->session_mpool;
1286 	ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
1287 
1288 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1289 			&ts_params->conf),
1290 			"Failed to configure cryptodev %u",
1291 			ts_params->valid_devs[0]);
1292 
1293 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
1294 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1295 			ts_params->valid_devs[0], qp_id,
1296 			&ts_params->qp_conf,
1297 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1298 			"Failed to setup queue pair %u on cryptodev %u",
1299 			qp_id, ts_params->valid_devs[0]);
1300 	}
1301 
1302 
1303 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
1304 
1305 	/* Start the device */
1306 	TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
1307 			"Failed to start cryptodev %u",
1308 			ts_params->valid_devs[0]);
1309 
1310 	return TEST_SUCCESS;
1311 }
1312 
1313 int
1314 ut_setup(void)
1315 {
1316 	/* Configure and start the device with security feature disabled */
1317 	return dev_configure_and_start(RTE_CRYPTODEV_FF_SECURITY);
1318 }
1319 
1320 static int
1321 ut_setup_security(void)
1322 {
1323 	/* Configure and start the device with no features disabled */
1324 	return dev_configure_and_start(0);
1325 }
1326 
1327 void
1328 ut_teardown(void)
1329 {
1330 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1331 	struct crypto_unittest_params *ut_params = &unittest_params;
1332 	struct rte_cryptodev_stats stats;
1333 
1334 	/* free crypto session structure */
1335 #ifdef RTE_LIB_SECURITY
1336 	if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
1337 		if (ut_params->sec_session) {
1338 			rte_security_session_destroy(rte_cryptodev_get_sec_ctx
1339 						(ts_params->valid_devs[0]),
1340 						ut_params->sec_session);
1341 			ut_params->sec_session = NULL;
1342 		}
1343 	} else
1344 #endif
1345 	{
1346 		if (ut_params->sess) {
1347 			rte_cryptodev_sym_session_clear(
1348 					ts_params->valid_devs[0],
1349 					ut_params->sess);
1350 			rte_cryptodev_sym_session_free(ut_params->sess);
1351 			ut_params->sess = NULL;
1352 		}
1353 	}
1354 
1355 	/* free crypto operation structure */
1356 	if (ut_params->op)
1357 		rte_crypto_op_free(ut_params->op);
1358 
1359 	/*
1360 	 * free mbuf - both obuf and ibuf are usually the same,
1361 	 * so check if they point at the same address is necessary,
1362 	 * to avoid freeing the mbuf twice.
1363 	 */
1364 	if (ut_params->obuf) {
1365 		rte_pktmbuf_free(ut_params->obuf);
1366 		if (ut_params->ibuf == ut_params->obuf)
1367 			ut_params->ibuf = 0;
1368 		ut_params->obuf = 0;
1369 	}
1370 	if (ut_params->ibuf) {
1371 		rte_pktmbuf_free(ut_params->ibuf);
1372 		ut_params->ibuf = 0;
1373 	}
1374 
1375 	if (ts_params->mbuf_pool != NULL)
1376 		RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
1377 			rte_mempool_avail_count(ts_params->mbuf_pool));
1378 
1379 	rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
1380 
1381 	/* Stop the device */
1382 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1383 }
1384 
1385 static int
1386 test_device_configure_invalid_dev_id(void)
1387 {
1388 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1389 	uint16_t dev_id, num_devs = 0;
1390 
1391 	TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
1392 			"Need at least %d devices for test", 1);
1393 
1394 	/* valid dev_id values */
1395 	dev_id = ts_params->valid_devs[0];
1396 
1397 	/* Stop the device in case it's started so it can be configured */
1398 	rte_cryptodev_stop(dev_id);
1399 
1400 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
1401 			"Failed test for rte_cryptodev_configure: "
1402 			"invalid dev_num %u", dev_id);
1403 
1404 	/* invalid dev_id values */
1405 	dev_id = num_devs;
1406 
1407 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1408 			"Failed test for rte_cryptodev_configure: "
1409 			"invalid dev_num %u", dev_id);
1410 
1411 	dev_id = 0xff;
1412 
1413 	TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
1414 			"Failed test for rte_cryptodev_configure:"
1415 			"invalid dev_num %u", dev_id);
1416 
1417 	return TEST_SUCCESS;
1418 }
1419 
1420 static int
1421 test_device_configure_invalid_queue_pair_ids(void)
1422 {
1423 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1424 	uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
1425 
1426 	/* Stop the device in case it's started so it can be configured */
1427 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1428 
1429 	/* valid - max value queue pairs */
1430 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1431 
1432 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1433 			&ts_params->conf),
1434 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1435 			ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
1436 
1437 	/* valid - one queue pairs */
1438 	ts_params->conf.nb_queue_pairs = 1;
1439 
1440 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1441 			&ts_params->conf),
1442 			"Failed to configure cryptodev: dev_id %u, qp_id %u",
1443 			ts_params->valid_devs[0],
1444 			ts_params->conf.nb_queue_pairs);
1445 
1446 
1447 	/* invalid - zero queue pairs */
1448 	ts_params->conf.nb_queue_pairs = 0;
1449 
1450 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1451 			&ts_params->conf),
1452 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1453 			" invalid qps: %u",
1454 			ts_params->valid_devs[0],
1455 			ts_params->conf.nb_queue_pairs);
1456 
1457 
1458 	/* invalid - max value supported by field queue pairs */
1459 	ts_params->conf.nb_queue_pairs = UINT16_MAX;
1460 
1461 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1462 			&ts_params->conf),
1463 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1464 			" invalid qps: %u",
1465 			ts_params->valid_devs[0],
1466 			ts_params->conf.nb_queue_pairs);
1467 
1468 
1469 	/* invalid - max value + 1 queue pairs */
1470 	ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
1471 
1472 	TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
1473 			&ts_params->conf),
1474 			"Failed test for rte_cryptodev_configure, dev_id %u,"
1475 			" invalid qps: %u",
1476 			ts_params->valid_devs[0],
1477 			ts_params->conf.nb_queue_pairs);
1478 
1479 	/* revert to original testsuite value */
1480 	ts_params->conf.nb_queue_pairs = orig_nb_qps;
1481 
1482 	return TEST_SUCCESS;
1483 }
1484 
1485 static int
1486 test_queue_pair_descriptor_setup(void)
1487 {
1488 	struct crypto_testsuite_params *ts_params = &testsuite_params;
1489 	struct rte_cryptodev_qp_conf qp_conf = {
1490 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
1491 	};
1492 	uint16_t qp_id;
1493 
1494 	/* Stop the device in case it's started so it can be configured */
1495 	rte_cryptodev_stop(ts_params->valid_devs[0]);
1496 
1497 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
1498 			&ts_params->conf),
1499 			"Failed to configure cryptodev %u",
1500 			ts_params->valid_devs[0]);
1501 
1502 	/*
1503 	 * Test various ring sizes on this device. memzones can't be
1504 	 * freed so are re-used if ring is released and re-created.
1505 	 */
1506 	qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
1507 	qp_conf.mp_session = ts_params->session_mpool;
1508 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
1509 
1510 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1511 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1512 				ts_params->valid_devs[0], qp_id, &qp_conf,
1513 				rte_cryptodev_socket_id(
1514 						ts_params->valid_devs[0])),
1515 				"Failed test for "
1516 				"rte_cryptodev_queue_pair_setup: num_inflights "
1517 				"%u on qp %u on cryptodev %u",
1518 				qp_conf.nb_descriptors, qp_id,
1519 				ts_params->valid_devs[0]);
1520 	}
1521 
1522 	qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
1523 
1524 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1525 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1526 				ts_params->valid_devs[0], qp_id, &qp_conf,
1527 				rte_cryptodev_socket_id(
1528 						ts_params->valid_devs[0])),
1529 				"Failed test for"
1530 				" rte_cryptodev_queue_pair_setup: num_inflights"
1531 				" %u on qp %u on cryptodev %u",
1532 				qp_conf.nb_descriptors, qp_id,
1533 				ts_params->valid_devs[0]);
1534 	}
1535 
1536 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
1537 
1538 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1539 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1540 				ts_params->valid_devs[0], qp_id, &qp_conf,
1541 				rte_cryptodev_socket_id(
1542 						ts_params->valid_devs[0])),
1543 				"Failed test for "
1544 				"rte_cryptodev_queue_pair_setup: num_inflights"
1545 				" %u on qp %u on cryptodev %u",
1546 				qp_conf.nb_descriptors, qp_id,
1547 				ts_params->valid_devs[0]);
1548 	}
1549 
1550 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
1551 
1552 	for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
1553 		TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
1554 				ts_params->valid_devs[0], qp_id, &qp_conf,
1555 				rte_cryptodev_socket_id(
1556 						ts_params->valid_devs[0])),
1557 				"Failed test for"
1558 				" rte_cryptodev_queue_pair_setup:"
1559 				"num_inflights %u on qp %u on cryptodev %u",
1560 				qp_conf.nb_descriptors, qp_id,
1561 				ts_params->valid_devs[0]);
1562 	}
1563 
1564 	/* test invalid queue pair id */
1565 	qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;	/*valid */
1566 
1567 	qp_id = ts_params->conf.nb_queue_pairs;		/*invalid */
1568 
1569 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1570 			ts_params->valid_devs[0],
1571 			qp_id, &qp_conf,
1572 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1573 			"Failed test for rte_cryptodev_queue_pair_setup:"
1574 			"invalid qp %u on cryptodev %u",
1575 			qp_id, ts_params->valid_devs[0]);
1576 
1577 	qp_id = 0xffff; /*invalid*/
1578 
1579 	TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
1580 			ts_params->valid_devs[0],
1581 			qp_id, &qp_conf,
1582 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
1583 			"Failed test for rte_cryptodev_queue_pair_setup:"
1584 			"invalid qp %u on cryptodev %u",
1585 			qp_id, ts_params->valid_devs[0]);
1586 
1587 	return TEST_SUCCESS;
1588 }
1589 
1590 /* ***** Plaintext data for tests ***** */
1591 
1592 const char catch_22_quote_1[] =
1593 		"There was only one catch and that was Catch-22, which "
1594 		"specified that a concern for one's safety in the face of "
1595 		"dangers that were real and immediate was the process of a "
1596 		"rational mind. Orr was crazy and could be grounded. All he "
1597 		"had to do was ask; and as soon as he did, he would no longer "
1598 		"be crazy and would have to fly more missions. Orr would be "
1599 		"crazy to fly more missions and sane if he didn't, but if he "
1600 		"was sane he had to fly them. If he flew them he was crazy "
1601 		"and didn't have to; but if he didn't want to he was sane and "
1602 		"had to. Yossarian was moved very deeply by the absolute "
1603 		"simplicity of this clause of Catch-22 and let out a "
1604 		"respectful whistle. \"That's some catch, that Catch-22\", he "
1605 		"observed. \"It's the best there is,\" Doc Daneeka agreed.";
1606 
1607 const char catch_22_quote[] =
1608 		"What a lousy earth! He wondered how many people were "
1609 		"destitute that same night even in his own prosperous country, "
1610 		"how many homes were shanties, how many husbands were drunk "
1611 		"and wives socked, and how many children were bullied, abused, "
1612 		"or abandoned. How many families hungered for food they could "
1613 		"not afford to buy? How many hearts were broken? How many "
1614 		"suicides would take place that same night, how many people "
1615 		"would go insane? How many cockroaches and landlords would "
1616 		"triumph? How many winners were losers, successes failures, "
1617 		"and rich men poor men? How many wise guys were stupid? How "
1618 		"many happy endings were unhappy endings? How many honest men "
1619 		"were liars, brave men cowards, loyal men traitors, how many "
1620 		"sainted men were corrupt, how many people in positions of "
1621 		"trust had sold their souls to bodyguards, how many had never "
1622 		"had souls? How many straight-and-narrow paths were crooked "
1623 		"paths? How many best families were worst families and how "
1624 		"many good people were bad people? When you added them all up "
1625 		"and then subtracted, you might be left with only the children, "
1626 		"and perhaps with Albert Einstein and an old violinist or "
1627 		"sculptor somewhere.";
1628 
1629 #define QUOTE_480_BYTES		(480)
1630 #define QUOTE_512_BYTES		(512)
1631 #define QUOTE_768_BYTES		(768)
1632 #define QUOTE_1024_BYTES	(1024)
1633 
1634 
1635 
1636 /* ***** SHA1 Hash Tests ***** */
1637 
1638 #define HMAC_KEY_LENGTH_SHA1	(DIGEST_BYTE_LENGTH_SHA1)
1639 
1640 static uint8_t hmac_sha1_key[] = {
1641 	0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
1642 	0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
1643 	0xDE, 0xF4, 0xDE, 0xAD };
1644 
1645 /* ***** SHA224 Hash Tests ***** */
1646 
1647 #define HMAC_KEY_LENGTH_SHA224	(DIGEST_BYTE_LENGTH_SHA224)
1648 
1649 
1650 /* ***** AES-CBC Cipher Tests ***** */
1651 
1652 #define CIPHER_KEY_LENGTH_AES_CBC	(16)
1653 #define CIPHER_IV_LENGTH_AES_CBC	(CIPHER_KEY_LENGTH_AES_CBC)
1654 
1655 static uint8_t aes_cbc_key[] = {
1656 	0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
1657 	0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
1658 
1659 static uint8_t aes_cbc_iv[] = {
1660 	0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
1661 	0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
1662 
1663 
1664 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
1665 
1666 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
1667 	0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
1668 	0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
1669 	0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
1670 	0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
1671 	0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
1672 	0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
1673 	0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
1674 	0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
1675 	0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
1676 	0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
1677 	0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
1678 	0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
1679 	0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
1680 	0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
1681 	0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
1682 	0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
1683 	0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
1684 	0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
1685 	0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
1686 	0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
1687 	0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
1688 	0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
1689 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1690 	0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
1691 	0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
1692 	0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
1693 	0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
1694 	0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
1695 	0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
1696 	0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
1697 	0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1698 	0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1699 	0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1700 	0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1701 	0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1702 	0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1703 	0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1704 	0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1705 	0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1706 	0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1707 	0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1708 	0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1709 	0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1710 	0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1711 	0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1712 	0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1713 	0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1714 	0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1715 	0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1716 	0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1717 	0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1718 	0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1719 	0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1720 	0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1721 	0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1722 	0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1723 	0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1724 	0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1725 	0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1726 	0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1727 	0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1728 	0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1729 	0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1730 	0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1731 };
1732 
1733 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1734 	0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1735 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1736 	0x18, 0x8c, 0x1d, 0x32
1737 };
1738 
1739 
1740 /* Multisession Vector context Test */
1741 /*Begin Session 0 */
1742 static uint8_t ms_aes_cbc_key0[] = {
1743 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1744 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1745 };
1746 
1747 static uint8_t ms_aes_cbc_iv0[] = {
1748 	0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1749 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1750 };
1751 
1752 static const uint8_t ms_aes_cbc_cipher0[] = {
1753 		0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1754 		0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1755 		0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1756 		0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1757 		0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1758 		0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1759 		0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1760 		0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1761 		0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1762 		0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1763 		0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1764 		0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1765 		0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1766 		0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1767 		0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1768 		0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1769 		0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1770 		0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1771 		0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1772 		0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1773 		0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1774 		0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1775 		0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1776 		0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1777 		0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1778 		0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1779 		0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1780 		0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1781 		0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1782 		0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1783 		0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1784 		0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1785 		0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1786 		0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1787 		0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1788 		0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1789 		0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1790 		0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1791 		0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1792 		0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1793 		0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1794 		0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1795 		0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1796 		0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1797 		0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1798 		0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1799 		0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1800 		0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1801 		0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1802 		0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1803 		0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1804 		0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1805 		0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1806 		0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1807 		0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1808 		0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1809 		0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1810 		0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1811 		0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1812 		0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1813 		0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1814 		0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1815 		0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1816 		0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1817 };
1818 
1819 
1820 static  uint8_t ms_hmac_key0[] = {
1821 		0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1822 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1823 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1824 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1825 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1826 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1827 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1828 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1829 };
1830 
1831 static const uint8_t ms_hmac_digest0[] = {
1832 		0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1833 		0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1834 		0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1835 		0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1836 		0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1837 		0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1838 		0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1839 		0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1840 		};
1841 
1842 /* End Session 0 */
1843 /* Begin session 1 */
1844 
1845 static  uint8_t ms_aes_cbc_key1[] = {
1846 		0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1847 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1848 };
1849 
1850 static  uint8_t ms_aes_cbc_iv1[] = {
1851 	0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1852 	0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1853 };
1854 
1855 static const uint8_t ms_aes_cbc_cipher1[] = {
1856 		0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1857 		0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1858 		0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1859 		0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1860 		0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1861 		0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1862 		0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1863 		0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1864 		0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1865 		0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1866 		0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1867 		0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1868 		0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1869 		0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1870 		0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1871 		0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1872 		0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1873 		0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1874 		0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1875 		0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1876 		0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1877 		0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1878 		0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1879 		0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1880 		0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1881 		0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1882 		0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1883 		0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1884 		0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1885 		0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1886 		0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1887 		0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1888 		0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1889 		0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1890 		0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1891 		0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1892 		0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1893 		0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1894 		0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1895 		0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1896 		0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1897 		0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1898 		0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1899 		0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1900 		0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1901 		0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1902 		0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1903 		0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1904 		0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1905 		0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1906 		0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1907 		0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1908 		0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1909 		0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1910 		0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1911 		0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1912 		0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1913 		0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1914 		0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1915 		0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1916 		0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1917 		0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1918 		0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1919 		0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1920 
1921 };
1922 
1923 static uint8_t ms_hmac_key1[] = {
1924 		0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1925 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1926 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1927 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1928 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1929 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1930 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1931 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1932 };
1933 
1934 static const uint8_t ms_hmac_digest1[] = {
1935 		0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1936 		0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1937 		0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1938 		0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1939 		0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1940 		0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1941 		0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1942 		0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1943 };
1944 /* End Session 1  */
1945 /* Begin Session 2 */
1946 static  uint8_t ms_aes_cbc_key2[] = {
1947 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1948 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1949 };
1950 
1951 static  uint8_t ms_aes_cbc_iv2[] = {
1952 		0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1953 		0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1954 };
1955 
1956 static const uint8_t ms_aes_cbc_cipher2[] = {
1957 		0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1958 		0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1959 		0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1960 		0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1961 		0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1962 		0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1963 		0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1964 		0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1965 		0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1966 		0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1967 		0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1968 		0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1969 		0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1970 		0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1971 		0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1972 		0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1973 		0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1974 		0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1975 		0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1976 		0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1977 		0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1978 		0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1979 		0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1980 		0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1981 		0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1982 		0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1983 		0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1984 		0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1985 		0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1986 		0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1987 		0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1988 		0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1989 		0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1990 		0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1991 		0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1992 		0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1993 		0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1994 		0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1995 		0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1996 		0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1997 		0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1998 		0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1999 		0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
2000 		0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
2001 		0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
2002 		0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
2003 		0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
2004 		0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
2005 		0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
2006 		0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
2007 		0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
2008 		0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
2009 		0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
2010 		0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
2011 		0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
2012 		0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
2013 		0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
2014 		0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
2015 		0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
2016 		0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
2017 		0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
2018 		0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
2019 		0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
2020 		0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
2021 };
2022 
2023 static  uint8_t ms_hmac_key2[] = {
2024 		0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
2025 		0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2026 		0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2027 		0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
2028 		0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
2029 		0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2030 		0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
2031 		0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
2032 };
2033 
2034 static const uint8_t ms_hmac_digest2[] = {
2035 		0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
2036 		0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
2037 		0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
2038 		0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
2039 		0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
2040 		0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
2041 		0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
2042 		0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
2043 };
2044 
2045 /* End Session 2 */
2046 
2047 
2048 static int
2049 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
2050 {
2051 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2052 	struct crypto_unittest_params *ut_params = &unittest_params;
2053 
2054 	/* Verify the capabilities */
2055 	struct rte_cryptodev_sym_capability_idx cap_idx;
2056 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2057 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
2058 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2059 			&cap_idx) == NULL)
2060 		return TEST_SKIPPED;
2061 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2062 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
2063 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
2064 			&cap_idx) == NULL)
2065 		return TEST_SKIPPED;
2066 
2067 	/* Generate test mbuf data and space for digest */
2068 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2069 			catch_22_quote,	QUOTE_512_BYTES, 0);
2070 
2071 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2072 			DIGEST_BYTE_LENGTH_SHA1);
2073 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2074 
2075 	/* Setup Cipher Parameters */
2076 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2077 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2078 
2079 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2080 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
2081 	ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
2082 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2083 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2084 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2085 
2086 	/* Setup HMAC Parameters */
2087 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2088 
2089 	ut_params->auth_xform.next = NULL;
2090 
2091 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
2092 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
2093 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
2094 	ut_params->auth_xform.auth.key.data = hmac_sha1_key;
2095 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
2096 
2097 	ut_params->sess = rte_cryptodev_sym_session_create(
2098 			ts_params->session_mpool);
2099 
2100 	/* Create crypto session*/
2101 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
2102 			ut_params->sess, &ut_params->cipher_xform,
2103 			ts_params->session_priv_mpool);
2104 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2105 
2106 	/* Generate crypto op data structure */
2107 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2108 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2109 	TEST_ASSERT_NOT_NULL(ut_params->op,
2110 			"Failed to allocate symmetric crypto operation struct");
2111 
2112 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2113 
2114 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2115 
2116 	/* set crypto operation source mbuf */
2117 	sym_op->m_src = ut_params->ibuf;
2118 
2119 	/* Set crypto operation authentication parameters */
2120 	sym_op->auth.digest.data = ut_params->digest;
2121 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2122 			ut_params->ibuf, QUOTE_512_BYTES);
2123 
2124 	sym_op->auth.data.offset = 0;
2125 	sym_op->auth.data.length = QUOTE_512_BYTES;
2126 
2127 	/* Copy IV at the end of the crypto operation */
2128 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2129 			aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
2130 
2131 	/* Set crypto operation cipher parameters */
2132 	sym_op->cipher.data.offset = 0;
2133 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2134 
2135 	/* Process crypto operation */
2136 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2137 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2138 			ut_params->op);
2139 	else
2140 		TEST_ASSERT_NOT_NULL(
2141 			process_crypto_request(ts_params->valid_devs[0],
2142 				ut_params->op),
2143 				"failed to process sym crypto op");
2144 
2145 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2146 			"crypto op processing failed");
2147 
2148 	/* Validate obuf */
2149 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
2150 			uint8_t *);
2151 
2152 	TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
2153 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
2154 			QUOTE_512_BYTES,
2155 			"ciphertext data not as expected");
2156 
2157 	uint8_t *digest = ciphertext + QUOTE_512_BYTES;
2158 
2159 	TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
2160 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
2161 			gbl_driver_id == rte_cryptodev_driver_id_get(
2162 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
2163 					TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
2164 					DIGEST_BYTE_LENGTH_SHA1,
2165 			"Generated digest data not as expected");
2166 
2167 	return TEST_SUCCESS;
2168 }
2169 
2170 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
2171 
2172 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
2173 
2174 static uint8_t hmac_sha512_key[] = {
2175 	0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
2176 	0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
2177 	0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
2178 	0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
2179 	0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
2180 	0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
2181 	0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
2182 	0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
2183 
2184 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
2185 	0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
2186 	0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
2187 	0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
2188 	0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
2189 	0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
2190 	0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
2191 	0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
2192 	0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
2193 
2194 
2195 
2196 static int
2197 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2198 		struct crypto_unittest_params *ut_params,
2199 		uint8_t *cipher_key,
2200 		uint8_t *hmac_key);
2201 
2202 static int
2203 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2204 		struct crypto_unittest_params *ut_params,
2205 		struct crypto_testsuite_params *ts_params,
2206 		const uint8_t *cipher,
2207 		const uint8_t *digest,
2208 		const uint8_t *iv);
2209 
2210 
2211 static int
2212 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
2213 		struct crypto_unittest_params *ut_params,
2214 		uint8_t *cipher_key,
2215 		uint8_t *hmac_key)
2216 {
2217 
2218 	/* Setup Cipher Parameters */
2219 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2220 	ut_params->cipher_xform.next = NULL;
2221 
2222 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
2223 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
2224 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2225 	ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
2226 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2227 	ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
2228 
2229 	/* Setup HMAC Parameters */
2230 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2231 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2232 
2233 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
2234 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
2235 	ut_params->auth_xform.auth.key.data = hmac_key;
2236 	ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
2237 	ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
2238 
2239 	return TEST_SUCCESS;
2240 }
2241 
2242 
2243 static int
2244 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
2245 		struct crypto_unittest_params *ut_params,
2246 		struct crypto_testsuite_params *ts_params,
2247 		const uint8_t *cipher,
2248 		const uint8_t *digest,
2249 		const uint8_t *iv)
2250 {
2251 	/* Generate test mbuf data and digest */
2252 	ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
2253 			(const char *)
2254 			cipher,
2255 			QUOTE_512_BYTES, 0);
2256 
2257 	ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2258 			DIGEST_BYTE_LENGTH_SHA512);
2259 	TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
2260 
2261 	rte_memcpy(ut_params->digest,
2262 			digest,
2263 			DIGEST_BYTE_LENGTH_SHA512);
2264 
2265 	/* Generate Crypto op data structure */
2266 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2267 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2268 	TEST_ASSERT_NOT_NULL(ut_params->op,
2269 			"Failed to allocate symmetric crypto operation struct");
2270 
2271 	rte_crypto_op_attach_sym_session(ut_params->op, sess);
2272 
2273 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2274 
2275 	/* set crypto operation source mbuf */
2276 	sym_op->m_src = ut_params->ibuf;
2277 
2278 	sym_op->auth.digest.data = ut_params->digest;
2279 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2280 			ut_params->ibuf, QUOTE_512_BYTES);
2281 
2282 	sym_op->auth.data.offset = 0;
2283 	sym_op->auth.data.length = QUOTE_512_BYTES;
2284 
2285 	/* Copy IV at the end of the crypto operation */
2286 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2287 			iv, CIPHER_IV_LENGTH_AES_CBC);
2288 
2289 	sym_op->cipher.data.offset = 0;
2290 	sym_op->cipher.data.length = QUOTE_512_BYTES;
2291 
2292 	/* Process crypto operation */
2293 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
2294 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
2295 			ut_params->op);
2296 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
2297 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
2298 				ut_params->op, 1, 1, 0, 0);
2299 	else
2300 		TEST_ASSERT_NOT_NULL(
2301 				process_crypto_request(ts_params->valid_devs[0],
2302 					ut_params->op),
2303 					"failed to process sym crypto op");
2304 
2305 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2306 			"crypto op processing failed");
2307 
2308 	ut_params->obuf = ut_params->op->sym->m_src;
2309 
2310 	/* Validate obuf */
2311 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
2312 			rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
2313 			catch_22_quote,
2314 			QUOTE_512_BYTES,
2315 			"Plaintext data not as expected");
2316 
2317 	/* Validate obuf */
2318 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
2319 			"Digest verification failed");
2320 
2321 	return TEST_SUCCESS;
2322 }
2323 
2324 /* ***** SNOW 3G Tests ***** */
2325 static int
2326 create_wireless_algo_hash_session(uint8_t dev_id,
2327 	const uint8_t *key, const uint8_t key_len,
2328 	const uint8_t iv_len, const uint8_t auth_len,
2329 	enum rte_crypto_auth_operation op,
2330 	enum rte_crypto_auth_algorithm algo)
2331 {
2332 	uint8_t hash_key[key_len];
2333 	int status;
2334 
2335 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2336 	struct crypto_unittest_params *ut_params = &unittest_params;
2337 
2338 	memcpy(hash_key, key, key_len);
2339 
2340 	debug_hexdump(stdout, "key:", key, key_len);
2341 
2342 	/* Setup Authentication Parameters */
2343 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2344 	ut_params->auth_xform.next = NULL;
2345 
2346 	ut_params->auth_xform.auth.op = op;
2347 	ut_params->auth_xform.auth.algo = algo;
2348 	ut_params->auth_xform.auth.key.length = key_len;
2349 	ut_params->auth_xform.auth.key.data = hash_key;
2350 	ut_params->auth_xform.auth.digest_length = auth_len;
2351 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2352 	ut_params->auth_xform.auth.iv.length = iv_len;
2353 	ut_params->sess = rte_cryptodev_sym_session_create(
2354 			ts_params->session_mpool);
2355 
2356 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2357 			&ut_params->auth_xform,
2358 			ts_params->session_priv_mpool);
2359 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2360 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2361 	return 0;
2362 }
2363 
2364 static int
2365 create_wireless_algo_cipher_session(uint8_t dev_id,
2366 			enum rte_crypto_cipher_operation op,
2367 			enum rte_crypto_cipher_algorithm algo,
2368 			const uint8_t *key, const uint8_t key_len,
2369 			uint8_t iv_len)
2370 {
2371 	uint8_t cipher_key[key_len];
2372 	int status;
2373 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2374 	struct crypto_unittest_params *ut_params = &unittest_params;
2375 
2376 	memcpy(cipher_key, key, key_len);
2377 
2378 	/* Setup Cipher Parameters */
2379 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2380 	ut_params->cipher_xform.next = NULL;
2381 
2382 	ut_params->cipher_xform.cipher.algo = algo;
2383 	ut_params->cipher_xform.cipher.op = op;
2384 	ut_params->cipher_xform.cipher.key.data = cipher_key;
2385 	ut_params->cipher_xform.cipher.key.length = key_len;
2386 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2387 	ut_params->cipher_xform.cipher.iv.length = iv_len;
2388 
2389 	debug_hexdump(stdout, "key:", key, key_len);
2390 
2391 	/* Create Crypto session */
2392 	ut_params->sess = rte_cryptodev_sym_session_create(
2393 			ts_params->session_mpool);
2394 
2395 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2396 			&ut_params->cipher_xform,
2397 			ts_params->session_priv_mpool);
2398 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2399 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2400 	return 0;
2401 }
2402 
2403 static int
2404 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2405 			unsigned int cipher_len,
2406 			unsigned int cipher_offset)
2407 {
2408 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2409 	struct crypto_unittest_params *ut_params = &unittest_params;
2410 
2411 	/* Generate Crypto op data structure */
2412 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2413 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2414 	TEST_ASSERT_NOT_NULL(ut_params->op,
2415 				"Failed to allocate pktmbuf offload");
2416 
2417 	/* Set crypto operation data parameters */
2418 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2419 
2420 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2421 
2422 	/* set crypto operation source mbuf */
2423 	sym_op->m_src = ut_params->ibuf;
2424 
2425 	/* iv */
2426 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2427 			iv, iv_len);
2428 	sym_op->cipher.data.length = cipher_len;
2429 	sym_op->cipher.data.offset = cipher_offset;
2430 	return 0;
2431 }
2432 
2433 static int
2434 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2435 			unsigned int cipher_len,
2436 			unsigned int cipher_offset)
2437 {
2438 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2439 	struct crypto_unittest_params *ut_params = &unittest_params;
2440 
2441 	/* Generate Crypto op data structure */
2442 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2443 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2444 	TEST_ASSERT_NOT_NULL(ut_params->op,
2445 				"Failed to allocate pktmbuf offload");
2446 
2447 	/* Set crypto operation data parameters */
2448 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2449 
2450 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2451 
2452 	/* set crypto operation source mbuf */
2453 	sym_op->m_src = ut_params->ibuf;
2454 	sym_op->m_dst = ut_params->obuf;
2455 
2456 	/* iv */
2457 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2458 			iv, iv_len);
2459 	sym_op->cipher.data.length = cipher_len;
2460 	sym_op->cipher.data.offset = cipher_offset;
2461 	return 0;
2462 }
2463 
2464 static int
2465 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2466 		enum rte_crypto_cipher_operation cipher_op,
2467 		enum rte_crypto_auth_operation auth_op,
2468 		enum rte_crypto_auth_algorithm auth_algo,
2469 		enum rte_crypto_cipher_algorithm cipher_algo,
2470 		const uint8_t *key, uint8_t key_len,
2471 		uint8_t auth_iv_len, uint8_t auth_len,
2472 		uint8_t cipher_iv_len)
2473 
2474 {
2475 	uint8_t cipher_auth_key[key_len];
2476 	int status;
2477 
2478 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2479 	struct crypto_unittest_params *ut_params = &unittest_params;
2480 
2481 	memcpy(cipher_auth_key, key, key_len);
2482 
2483 	/* Setup Authentication Parameters */
2484 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2485 	ut_params->auth_xform.next = NULL;
2486 
2487 	ut_params->auth_xform.auth.op = auth_op;
2488 	ut_params->auth_xform.auth.algo = auth_algo;
2489 	ut_params->auth_xform.auth.key.length = key_len;
2490 	/* Hash key = cipher key */
2491 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2492 	ut_params->auth_xform.auth.digest_length = auth_len;
2493 	/* Auth IV will be after cipher IV */
2494 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2495 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2496 
2497 	/* Setup Cipher Parameters */
2498 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2499 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2500 
2501 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2502 	ut_params->cipher_xform.cipher.op = cipher_op;
2503 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2504 	ut_params->cipher_xform.cipher.key.length = key_len;
2505 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2506 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2507 
2508 	debug_hexdump(stdout, "key:", key, key_len);
2509 
2510 	/* Create Crypto session*/
2511 	ut_params->sess = rte_cryptodev_sym_session_create(
2512 			ts_params->session_mpool);
2513 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2514 
2515 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2516 			&ut_params->cipher_xform,
2517 			ts_params->session_priv_mpool);
2518 	if (status == -ENOTSUP)
2519 		return TEST_SKIPPED;
2520 
2521 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2522 	return 0;
2523 }
2524 
2525 static int
2526 create_wireless_cipher_auth_session(uint8_t dev_id,
2527 		enum rte_crypto_cipher_operation cipher_op,
2528 		enum rte_crypto_auth_operation auth_op,
2529 		enum rte_crypto_auth_algorithm auth_algo,
2530 		enum rte_crypto_cipher_algorithm cipher_algo,
2531 		const struct wireless_test_data *tdata)
2532 {
2533 	const uint8_t key_len = tdata->key.len;
2534 	uint8_t cipher_auth_key[key_len];
2535 	int status;
2536 
2537 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2538 	struct crypto_unittest_params *ut_params = &unittest_params;
2539 	const uint8_t *key = tdata->key.data;
2540 	const uint8_t auth_len = tdata->digest.len;
2541 	uint8_t cipher_iv_len = tdata->cipher_iv.len;
2542 	uint8_t auth_iv_len = tdata->auth_iv.len;
2543 
2544 	memcpy(cipher_auth_key, key, key_len);
2545 
2546 	/* Setup Authentication Parameters */
2547 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2548 	ut_params->auth_xform.next = NULL;
2549 
2550 	ut_params->auth_xform.auth.op = auth_op;
2551 	ut_params->auth_xform.auth.algo = auth_algo;
2552 	ut_params->auth_xform.auth.key.length = key_len;
2553 	/* Hash key = cipher key */
2554 	ut_params->auth_xform.auth.key.data = cipher_auth_key;
2555 	ut_params->auth_xform.auth.digest_length = auth_len;
2556 	/* Auth IV will be after cipher IV */
2557 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2558 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2559 
2560 	/* Setup Cipher Parameters */
2561 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2562 	ut_params->cipher_xform.next = &ut_params->auth_xform;
2563 
2564 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2565 	ut_params->cipher_xform.cipher.op = cipher_op;
2566 	ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2567 	ut_params->cipher_xform.cipher.key.length = key_len;
2568 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2569 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2570 
2571 
2572 	debug_hexdump(stdout, "key:", key, key_len);
2573 
2574 	/* Create Crypto session*/
2575 	ut_params->sess = rte_cryptodev_sym_session_create(
2576 			ts_params->session_mpool);
2577 
2578 	status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2579 			&ut_params->cipher_xform,
2580 			ts_params->session_priv_mpool);
2581 	if (status == -ENOTSUP)
2582 		return TEST_SKIPPED;
2583 
2584 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2585 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2586 	return 0;
2587 }
2588 
2589 static int
2590 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2591 		const struct wireless_test_data *tdata)
2592 {
2593 	return create_wireless_cipher_auth_session(dev_id,
2594 		RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2595 		RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2596 		RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2597 }
2598 
2599 static int
2600 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2601 		enum rte_crypto_cipher_operation cipher_op,
2602 		enum rte_crypto_auth_operation auth_op,
2603 		enum rte_crypto_auth_algorithm auth_algo,
2604 		enum rte_crypto_cipher_algorithm cipher_algo,
2605 		const uint8_t *key, const uint8_t key_len,
2606 		uint8_t auth_iv_len, uint8_t auth_len,
2607 		uint8_t cipher_iv_len)
2608 {
2609 	uint8_t auth_cipher_key[key_len];
2610 	int status;
2611 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2612 	struct crypto_unittest_params *ut_params = &unittest_params;
2613 
2614 	memcpy(auth_cipher_key, key, key_len);
2615 
2616 	/* Setup Authentication Parameters */
2617 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2618 	ut_params->auth_xform.auth.op = auth_op;
2619 	ut_params->auth_xform.next = &ut_params->cipher_xform;
2620 	ut_params->auth_xform.auth.algo = auth_algo;
2621 	ut_params->auth_xform.auth.key.length = key_len;
2622 	ut_params->auth_xform.auth.key.data = auth_cipher_key;
2623 	ut_params->auth_xform.auth.digest_length = auth_len;
2624 	/* Auth IV will be after cipher IV */
2625 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2626 	ut_params->auth_xform.auth.iv.length = auth_iv_len;
2627 
2628 	/* Setup Cipher Parameters */
2629 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2630 	ut_params->cipher_xform.next = NULL;
2631 	ut_params->cipher_xform.cipher.algo = cipher_algo;
2632 	ut_params->cipher_xform.cipher.op = cipher_op;
2633 	ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2634 	ut_params->cipher_xform.cipher.key.length = key_len;
2635 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2636 	ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2637 
2638 	debug_hexdump(stdout, "key:", key, key_len);
2639 
2640 	/* Create Crypto session*/
2641 	ut_params->sess = rte_cryptodev_sym_session_create(
2642 			ts_params->session_mpool);
2643 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2644 
2645 	if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2646 		ut_params->auth_xform.next = NULL;
2647 		ut_params->cipher_xform.next = &ut_params->auth_xform;
2648 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2649 				&ut_params->cipher_xform,
2650 				ts_params->session_priv_mpool);
2651 
2652 	} else
2653 		status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2654 				&ut_params->auth_xform,
2655 				ts_params->session_priv_mpool);
2656 
2657 	if (status == -ENOTSUP)
2658 		return TEST_SKIPPED;
2659 
2660 	TEST_ASSERT_EQUAL(status, 0, "session init failed");
2661 
2662 	return 0;
2663 }
2664 
2665 static int
2666 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2667 		unsigned int auth_tag_len,
2668 		const uint8_t *iv, unsigned int iv_len,
2669 		unsigned int data_pad_len,
2670 		enum rte_crypto_auth_operation op,
2671 		unsigned int auth_len, unsigned int auth_offset)
2672 {
2673 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2674 
2675 	struct crypto_unittest_params *ut_params = &unittest_params;
2676 
2677 	/* Generate Crypto op data structure */
2678 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2679 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2680 	TEST_ASSERT_NOT_NULL(ut_params->op,
2681 		"Failed to allocate pktmbuf offload");
2682 
2683 	/* Set crypto operation data parameters */
2684 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2685 
2686 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2687 
2688 	/* set crypto operation source mbuf */
2689 	sym_op->m_src = ut_params->ibuf;
2690 
2691 	/* iv */
2692 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2693 			iv, iv_len);
2694 	/* digest */
2695 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2696 					ut_params->ibuf, auth_tag_len);
2697 
2698 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2699 				"no room to append auth tag");
2700 	ut_params->digest = sym_op->auth.digest.data;
2701 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2702 			ut_params->ibuf, data_pad_len);
2703 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2704 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2705 	else
2706 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2707 
2708 	debug_hexdump(stdout, "digest:",
2709 		sym_op->auth.digest.data,
2710 		auth_tag_len);
2711 
2712 	sym_op->auth.data.length = auth_len;
2713 	sym_op->auth.data.offset = auth_offset;
2714 
2715 	return 0;
2716 }
2717 
2718 static int
2719 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2720 	enum rte_crypto_auth_operation op)
2721 {
2722 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2723 	struct crypto_unittest_params *ut_params = &unittest_params;
2724 
2725 	const uint8_t *auth_tag = tdata->digest.data;
2726 	const unsigned int auth_tag_len = tdata->digest.len;
2727 	unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2728 	unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2729 
2730 	const uint8_t *cipher_iv = tdata->cipher_iv.data;
2731 	const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2732 	const uint8_t *auth_iv = tdata->auth_iv.data;
2733 	const uint8_t auth_iv_len = tdata->auth_iv.len;
2734 	const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2735 	const unsigned int auth_len = tdata->validAuthLenInBits.len;
2736 
2737 	/* Generate Crypto op data structure */
2738 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2739 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2740 	TEST_ASSERT_NOT_NULL(ut_params->op,
2741 			"Failed to allocate pktmbuf offload");
2742 	/* Set crypto operation data parameters */
2743 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2744 
2745 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2746 
2747 	/* set crypto operation source mbuf */
2748 	sym_op->m_src = ut_params->ibuf;
2749 
2750 	/* digest */
2751 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2752 			ut_params->ibuf, auth_tag_len);
2753 
2754 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2755 			"no room to append auth tag");
2756 	ut_params->digest = sym_op->auth.digest.data;
2757 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2758 			ut_params->ibuf, data_pad_len);
2759 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2760 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2761 	else
2762 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2763 
2764 	debug_hexdump(stdout, "digest:",
2765 		sym_op->auth.digest.data,
2766 		auth_tag_len);
2767 
2768 	/* Copy cipher and auth IVs at the end of the crypto operation */
2769 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2770 						IV_OFFSET);
2771 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2772 	iv_ptr += cipher_iv_len;
2773 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2774 
2775 	sym_op->cipher.data.length = cipher_len;
2776 	sym_op->cipher.data.offset = 0;
2777 	sym_op->auth.data.length = auth_len;
2778 	sym_op->auth.data.offset = 0;
2779 
2780 	return 0;
2781 }
2782 
2783 static int
2784 create_zuc_cipher_hash_generate_operation(
2785 		const struct wireless_test_data *tdata)
2786 {
2787 	return create_wireless_cipher_hash_operation(tdata,
2788 		RTE_CRYPTO_AUTH_OP_GENERATE);
2789 }
2790 
2791 static int
2792 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2793 		const unsigned auth_tag_len,
2794 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2795 		unsigned data_pad_len,
2796 		enum rte_crypto_auth_operation op,
2797 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2798 		const unsigned cipher_len, const unsigned cipher_offset,
2799 		const unsigned auth_len, const unsigned auth_offset)
2800 {
2801 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2802 	struct crypto_unittest_params *ut_params = &unittest_params;
2803 
2804 	enum rte_crypto_cipher_algorithm cipher_algo =
2805 			ut_params->cipher_xform.cipher.algo;
2806 	enum rte_crypto_auth_algorithm auth_algo =
2807 			ut_params->auth_xform.auth.algo;
2808 
2809 	/* Generate Crypto op data structure */
2810 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2811 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2812 	TEST_ASSERT_NOT_NULL(ut_params->op,
2813 			"Failed to allocate pktmbuf offload");
2814 	/* Set crypto operation data parameters */
2815 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2816 
2817 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2818 
2819 	/* set crypto operation source mbuf */
2820 	sym_op->m_src = ut_params->ibuf;
2821 
2822 	/* digest */
2823 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2824 			ut_params->ibuf, auth_tag_len);
2825 
2826 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2827 			"no room to append auth tag");
2828 	ut_params->digest = sym_op->auth.digest.data;
2829 
2830 	if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
2831 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2832 				ut_params->ibuf, data_pad_len);
2833 	} else {
2834 		struct rte_mbuf *m = ut_params->ibuf;
2835 		unsigned int offset = data_pad_len;
2836 
2837 		while (offset > m->data_len && m->next != NULL) {
2838 			offset -= m->data_len;
2839 			m = m->next;
2840 		}
2841 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2842 			m, offset);
2843 	}
2844 
2845 	if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2846 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2847 	else
2848 		rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2849 
2850 	debug_hexdump(stdout, "digest:",
2851 		sym_op->auth.digest.data,
2852 		auth_tag_len);
2853 
2854 	/* Copy cipher and auth IVs at the end of the crypto operation */
2855 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2856 						IV_OFFSET);
2857 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2858 	iv_ptr += cipher_iv_len;
2859 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2860 
2861 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2862 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2863 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2864 		sym_op->cipher.data.length = cipher_len;
2865 		sym_op->cipher.data.offset = cipher_offset;
2866 	} else {
2867 		sym_op->cipher.data.length = cipher_len >> 3;
2868 		sym_op->cipher.data.offset = cipher_offset >> 3;
2869 	}
2870 
2871 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2872 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2873 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2874 		sym_op->auth.data.length = auth_len;
2875 		sym_op->auth.data.offset = auth_offset;
2876 	} else {
2877 		sym_op->auth.data.length = auth_len >> 3;
2878 		sym_op->auth.data.offset = auth_offset >> 3;
2879 	}
2880 
2881 	return 0;
2882 }
2883 
2884 static int
2885 create_wireless_algo_auth_cipher_operation(
2886 		const uint8_t *auth_tag, unsigned int auth_tag_len,
2887 		const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2888 		const uint8_t *auth_iv, uint8_t auth_iv_len,
2889 		unsigned int data_pad_len,
2890 		unsigned int cipher_len, unsigned int cipher_offset,
2891 		unsigned int auth_len, unsigned int auth_offset,
2892 		uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
2893 {
2894 	struct crypto_testsuite_params *ts_params = &testsuite_params;
2895 	struct crypto_unittest_params *ut_params = &unittest_params;
2896 
2897 	enum rte_crypto_cipher_algorithm cipher_algo =
2898 			ut_params->cipher_xform.cipher.algo;
2899 	enum rte_crypto_auth_algorithm auth_algo =
2900 			ut_params->auth_xform.auth.algo;
2901 
2902 	/* Generate Crypto op data structure */
2903 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2904 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2905 	TEST_ASSERT_NOT_NULL(ut_params->op,
2906 			"Failed to allocate pktmbuf offload");
2907 
2908 	/* Set crypto operation data parameters */
2909 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2910 
2911 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2912 
2913 	/* set crypto operation mbufs */
2914 	sym_op->m_src = ut_params->ibuf;
2915 	if (op_mode == OUT_OF_PLACE)
2916 		sym_op->m_dst = ut_params->obuf;
2917 
2918 	/* digest */
2919 	if (!do_sgl) {
2920 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2921 			(op_mode == IN_PLACE ?
2922 				ut_params->ibuf : ut_params->obuf),
2923 			uint8_t *, data_pad_len);
2924 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2925 			(op_mode == IN_PLACE ?
2926 				ut_params->ibuf : ut_params->obuf),
2927 			data_pad_len);
2928 		memset(sym_op->auth.digest.data, 0, auth_tag_len);
2929 	} else {
2930 		uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2931 		struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2932 				sym_op->m_src : sym_op->m_dst);
2933 		while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2934 			remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2935 			sgl_buf = sgl_buf->next;
2936 		}
2937 		sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2938 				uint8_t *, remaining_off);
2939 		sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2940 				remaining_off);
2941 		memset(sym_op->auth.digest.data, 0, remaining_off);
2942 		while (sgl_buf->next != NULL) {
2943 			memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2944 				0, rte_pktmbuf_data_len(sgl_buf));
2945 			sgl_buf = sgl_buf->next;
2946 		}
2947 	}
2948 
2949 	/* Copy digest for the verification */
2950 	if (verify)
2951 		memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2952 
2953 	/* Copy cipher and auth IVs at the end of the crypto operation */
2954 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2955 			ut_params->op, uint8_t *, IV_OFFSET);
2956 
2957 	rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2958 	iv_ptr += cipher_iv_len;
2959 	rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2960 
2961 	/* Only copy over the offset data needed from src to dst in OOP,
2962 	 * if the auth and cipher offsets are not aligned
2963 	 */
2964 	if (op_mode == OUT_OF_PLACE) {
2965 		if (cipher_offset > auth_offset)
2966 			rte_memcpy(
2967 				rte_pktmbuf_mtod_offset(
2968 					sym_op->m_dst,
2969 					uint8_t *, auth_offset >> 3),
2970 				rte_pktmbuf_mtod_offset(
2971 					sym_op->m_src,
2972 					uint8_t *, auth_offset >> 3),
2973 				((cipher_offset >> 3) - (auth_offset >> 3)));
2974 	}
2975 
2976 	if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
2977 		cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
2978 		cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
2979 		sym_op->cipher.data.length = cipher_len;
2980 		sym_op->cipher.data.offset = cipher_offset;
2981 	} else {
2982 		sym_op->cipher.data.length = cipher_len >> 3;
2983 		sym_op->cipher.data.offset = cipher_offset >> 3;
2984 	}
2985 
2986 	if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
2987 		auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
2988 		auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
2989 		sym_op->auth.data.length = auth_len;
2990 		sym_op->auth.data.offset = auth_offset;
2991 	} else {
2992 		sym_op->auth.data.length = auth_len >> 3;
2993 		sym_op->auth.data.offset = auth_offset >> 3;
2994 	}
2995 
2996 	return 0;
2997 }
2998 
2999 static int
3000 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3001 {
3002 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3003 	struct crypto_unittest_params *ut_params = &unittest_params;
3004 
3005 	int retval;
3006 	unsigned plaintext_pad_len;
3007 	unsigned plaintext_len;
3008 	uint8_t *plaintext;
3009 	struct rte_cryptodev_info dev_info;
3010 
3011 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3012 	uint64_t feat_flags = dev_info.feature_flags;
3013 
3014 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3015 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3016 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3017 		return TEST_SKIPPED;
3018 	}
3019 
3020 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3021 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3022 		printf("Device doesn't support RAW data-path APIs.\n");
3023 		return TEST_SKIPPED;
3024 	}
3025 
3026 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3027 		return TEST_SKIPPED;
3028 
3029 	/* Verify the capabilities */
3030 	struct rte_cryptodev_sym_capability_idx cap_idx;
3031 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3032 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3033 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3034 			&cap_idx) == NULL)
3035 		return TEST_SKIPPED;
3036 
3037 	/* Create SNOW 3G session */
3038 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3039 			tdata->key.data, tdata->key.len,
3040 			tdata->auth_iv.len, tdata->digest.len,
3041 			RTE_CRYPTO_AUTH_OP_GENERATE,
3042 			RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3043 	if (retval < 0)
3044 		return retval;
3045 
3046 	/* alloc mbuf and set payload */
3047 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3048 
3049 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3050 	rte_pktmbuf_tailroom(ut_params->ibuf));
3051 
3052 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3053 	/* Append data which is padded to a multiple of */
3054 	/* the algorithms block size */
3055 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3056 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3057 				plaintext_pad_len);
3058 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3059 
3060 	/* Create SNOW 3G operation */
3061 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3062 			tdata->auth_iv.data, tdata->auth_iv.len,
3063 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3064 			tdata->validAuthLenInBits.len,
3065 			0);
3066 	if (retval < 0)
3067 		return retval;
3068 
3069 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3070 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3071 				ut_params->op, 0, 1, 1, 0);
3072 	else
3073 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3074 				ut_params->op);
3075 	ut_params->obuf = ut_params->op->sym->m_src;
3076 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3077 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3078 			+ plaintext_pad_len;
3079 
3080 	/* Validate obuf */
3081 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3082 	ut_params->digest,
3083 	tdata->digest.data,
3084 	DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3085 	"SNOW 3G Generated auth tag not as expected");
3086 
3087 	return 0;
3088 }
3089 
3090 static int
3091 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3092 {
3093 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3094 	struct crypto_unittest_params *ut_params = &unittest_params;
3095 
3096 	int retval;
3097 	unsigned plaintext_pad_len;
3098 	unsigned plaintext_len;
3099 	uint8_t *plaintext;
3100 	struct rte_cryptodev_info dev_info;
3101 
3102 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3103 	uint64_t feat_flags = dev_info.feature_flags;
3104 
3105 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
3106 			((tdata->validAuthLenInBits.len % 8) != 0)) {
3107 		printf("Device doesn't support NON-Byte Aligned Data.\n");
3108 		return TEST_SKIPPED;
3109 	}
3110 
3111 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3112 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3113 		printf("Device doesn't support RAW data-path APIs.\n");
3114 		return TEST_SKIPPED;
3115 	}
3116 
3117 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3118 		return TEST_SKIPPED;
3119 
3120 	/* Verify the capabilities */
3121 	struct rte_cryptodev_sym_capability_idx cap_idx;
3122 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3123 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
3124 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3125 			&cap_idx) == NULL)
3126 		return TEST_SKIPPED;
3127 
3128 	/* Create SNOW 3G session */
3129 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3130 				tdata->key.data, tdata->key.len,
3131 				tdata->auth_iv.len, tdata->digest.len,
3132 				RTE_CRYPTO_AUTH_OP_VERIFY,
3133 				RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3134 	if (retval < 0)
3135 		return retval;
3136 	/* alloc mbuf and set payload */
3137 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3138 
3139 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3140 	rte_pktmbuf_tailroom(ut_params->ibuf));
3141 
3142 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3143 	/* Append data which is padded to a multiple of */
3144 	/* the algorithms block size */
3145 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3146 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3147 				plaintext_pad_len);
3148 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3149 
3150 	/* Create SNOW 3G operation */
3151 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3152 			tdata->digest.len,
3153 			tdata->auth_iv.data, tdata->auth_iv.len,
3154 			plaintext_pad_len,
3155 			RTE_CRYPTO_AUTH_OP_VERIFY,
3156 			tdata->validAuthLenInBits.len,
3157 			0);
3158 	if (retval < 0)
3159 		return retval;
3160 
3161 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3162 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3163 				ut_params->op, 0, 1, 1, 0);
3164 	else
3165 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3166 				ut_params->op);
3167 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3168 	ut_params->obuf = ut_params->op->sym->m_src;
3169 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3170 				+ plaintext_pad_len;
3171 
3172 	/* Validate obuf */
3173 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3174 		return 0;
3175 	else
3176 		return -1;
3177 
3178 	return 0;
3179 }
3180 
3181 static int
3182 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3183 {
3184 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3185 	struct crypto_unittest_params *ut_params = &unittest_params;
3186 
3187 	int retval;
3188 	unsigned plaintext_pad_len;
3189 	unsigned plaintext_len;
3190 	uint8_t *plaintext;
3191 	struct rte_cryptodev_info dev_info;
3192 
3193 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3194 	uint64_t feat_flags = dev_info.feature_flags;
3195 
3196 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3197 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3198 		printf("Device doesn't support RAW data-path APIs.\n");
3199 		return TEST_SKIPPED;
3200 	}
3201 
3202 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3203 		return TEST_SKIPPED;
3204 
3205 	/* Verify the capabilities */
3206 	struct rte_cryptodev_sym_capability_idx cap_idx;
3207 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3208 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3209 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3210 			&cap_idx) == NULL)
3211 		return TEST_SKIPPED;
3212 
3213 	/* Create KASUMI session */
3214 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3215 			tdata->key.data, tdata->key.len,
3216 			0, tdata->digest.len,
3217 			RTE_CRYPTO_AUTH_OP_GENERATE,
3218 			RTE_CRYPTO_AUTH_KASUMI_F9);
3219 	if (retval < 0)
3220 		return retval;
3221 
3222 	/* alloc mbuf and set payload */
3223 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3224 
3225 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3226 	rte_pktmbuf_tailroom(ut_params->ibuf));
3227 
3228 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3229 	/* Append data which is padded to a multiple of */
3230 	/* the algorithms block size */
3231 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3232 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3233 				plaintext_pad_len);
3234 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3235 
3236 	/* Create KASUMI operation */
3237 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3238 			NULL, 0,
3239 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3240 			tdata->plaintext.len,
3241 			0);
3242 	if (retval < 0)
3243 		return retval;
3244 
3245 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3246 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
3247 			ut_params->op);
3248 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3249 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3250 				ut_params->op, 0, 1, 1, 0);
3251 	else
3252 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3253 			ut_params->op);
3254 
3255 	ut_params->obuf = ut_params->op->sym->m_src;
3256 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3257 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3258 			+ plaintext_pad_len;
3259 
3260 	/* Validate obuf */
3261 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
3262 	ut_params->digest,
3263 	tdata->digest.data,
3264 	DIGEST_BYTE_LENGTH_KASUMI_F9,
3265 	"KASUMI Generated auth tag not as expected");
3266 
3267 	return 0;
3268 }
3269 
3270 static int
3271 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3272 {
3273 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3274 	struct crypto_unittest_params *ut_params = &unittest_params;
3275 
3276 	int retval;
3277 	unsigned plaintext_pad_len;
3278 	unsigned plaintext_len;
3279 	uint8_t *plaintext;
3280 	struct rte_cryptodev_info dev_info;
3281 
3282 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3283 	uint64_t feat_flags = dev_info.feature_flags;
3284 
3285 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3286 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3287 		printf("Device doesn't support RAW data-path APIs.\n");
3288 		return TEST_SKIPPED;
3289 	}
3290 
3291 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3292 		return TEST_SKIPPED;
3293 
3294 	/* Verify the capabilities */
3295 	struct rte_cryptodev_sym_capability_idx cap_idx;
3296 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3297 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
3298 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3299 			&cap_idx) == NULL)
3300 		return TEST_SKIPPED;
3301 
3302 	/* Create KASUMI session */
3303 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3304 				tdata->key.data, tdata->key.len,
3305 				0, tdata->digest.len,
3306 				RTE_CRYPTO_AUTH_OP_VERIFY,
3307 				RTE_CRYPTO_AUTH_KASUMI_F9);
3308 	if (retval < 0)
3309 		return retval;
3310 	/* alloc mbuf and set payload */
3311 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3312 
3313 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3314 	rte_pktmbuf_tailroom(ut_params->ibuf));
3315 
3316 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3317 	/* Append data which is padded to a multiple */
3318 	/* of the algorithms block size */
3319 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3320 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3321 				plaintext_pad_len);
3322 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3323 
3324 	/* Create KASUMI operation */
3325 	retval = create_wireless_algo_hash_operation(tdata->digest.data,
3326 			tdata->digest.len,
3327 			NULL, 0,
3328 			plaintext_pad_len,
3329 			RTE_CRYPTO_AUTH_OP_VERIFY,
3330 			tdata->plaintext.len,
3331 			0);
3332 	if (retval < 0)
3333 		return retval;
3334 
3335 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3336 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3337 				ut_params->op, 0, 1, 1, 0);
3338 	else
3339 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3340 				ut_params->op);
3341 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3342 	ut_params->obuf = ut_params->op->sym->m_src;
3343 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3344 				+ plaintext_pad_len;
3345 
3346 	/* Validate obuf */
3347 	if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3348 		return 0;
3349 	else
3350 		return -1;
3351 
3352 	return 0;
3353 }
3354 
3355 static int
3356 test_snow3g_hash_generate_test_case_1(void)
3357 {
3358 	return test_snow3g_authentication(&snow3g_hash_test_case_1);
3359 }
3360 
3361 static int
3362 test_snow3g_hash_generate_test_case_2(void)
3363 {
3364 	return test_snow3g_authentication(&snow3g_hash_test_case_2);
3365 }
3366 
3367 static int
3368 test_snow3g_hash_generate_test_case_3(void)
3369 {
3370 	return test_snow3g_authentication(&snow3g_hash_test_case_3);
3371 }
3372 
3373 static int
3374 test_snow3g_hash_generate_test_case_4(void)
3375 {
3376 	return test_snow3g_authentication(&snow3g_hash_test_case_4);
3377 }
3378 
3379 static int
3380 test_snow3g_hash_generate_test_case_5(void)
3381 {
3382 	return test_snow3g_authentication(&snow3g_hash_test_case_5);
3383 }
3384 
3385 static int
3386 test_snow3g_hash_generate_test_case_6(void)
3387 {
3388 	return test_snow3g_authentication(&snow3g_hash_test_case_6);
3389 }
3390 
3391 static int
3392 test_snow3g_hash_verify_test_case_1(void)
3393 {
3394 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3395 
3396 }
3397 
3398 static int
3399 test_snow3g_hash_verify_test_case_2(void)
3400 {
3401 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3402 }
3403 
3404 static int
3405 test_snow3g_hash_verify_test_case_3(void)
3406 {
3407 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3408 }
3409 
3410 static int
3411 test_snow3g_hash_verify_test_case_4(void)
3412 {
3413 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3414 }
3415 
3416 static int
3417 test_snow3g_hash_verify_test_case_5(void)
3418 {
3419 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3420 }
3421 
3422 static int
3423 test_snow3g_hash_verify_test_case_6(void)
3424 {
3425 	return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3426 }
3427 
3428 static int
3429 test_kasumi_hash_generate_test_case_1(void)
3430 {
3431 	return test_kasumi_authentication(&kasumi_hash_test_case_1);
3432 }
3433 
3434 static int
3435 test_kasumi_hash_generate_test_case_2(void)
3436 {
3437 	return test_kasumi_authentication(&kasumi_hash_test_case_2);
3438 }
3439 
3440 static int
3441 test_kasumi_hash_generate_test_case_3(void)
3442 {
3443 	return test_kasumi_authentication(&kasumi_hash_test_case_3);
3444 }
3445 
3446 static int
3447 test_kasumi_hash_generate_test_case_4(void)
3448 {
3449 	return test_kasumi_authentication(&kasumi_hash_test_case_4);
3450 }
3451 
3452 static int
3453 test_kasumi_hash_generate_test_case_5(void)
3454 {
3455 	return test_kasumi_authentication(&kasumi_hash_test_case_5);
3456 }
3457 
3458 static int
3459 test_kasumi_hash_generate_test_case_6(void)
3460 {
3461 	return test_kasumi_authentication(&kasumi_hash_test_case_6);
3462 }
3463 
3464 static int
3465 test_kasumi_hash_verify_test_case_1(void)
3466 {
3467 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3468 }
3469 
3470 static int
3471 test_kasumi_hash_verify_test_case_2(void)
3472 {
3473 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3474 }
3475 
3476 static int
3477 test_kasumi_hash_verify_test_case_3(void)
3478 {
3479 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3480 }
3481 
3482 static int
3483 test_kasumi_hash_verify_test_case_4(void)
3484 {
3485 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3486 }
3487 
3488 static int
3489 test_kasumi_hash_verify_test_case_5(void)
3490 {
3491 	return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3492 }
3493 
3494 static int
3495 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3496 {
3497 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3498 	struct crypto_unittest_params *ut_params = &unittest_params;
3499 
3500 	int retval;
3501 	uint8_t *plaintext, *ciphertext;
3502 	unsigned plaintext_pad_len;
3503 	unsigned plaintext_len;
3504 	struct rte_cryptodev_info dev_info;
3505 
3506 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3507 	uint64_t feat_flags = dev_info.feature_flags;
3508 
3509 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3510 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3511 		printf("Device doesn't support RAW data-path APIs.\n");
3512 		return TEST_SKIPPED;
3513 	}
3514 
3515 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3516 		return TEST_SKIPPED;
3517 
3518 	/* Verify the capabilities */
3519 	struct rte_cryptodev_sym_capability_idx cap_idx;
3520 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3521 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3522 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3523 			&cap_idx) == NULL)
3524 		return TEST_SKIPPED;
3525 
3526 	/* Create KASUMI session */
3527 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3528 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3529 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3530 					tdata->key.data, tdata->key.len,
3531 					tdata->cipher_iv.len);
3532 	if (retval < 0)
3533 		return retval;
3534 
3535 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3536 
3537 	/* Clear mbuf payload */
3538 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3539 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3540 
3541 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3542 	/* Append data which is padded to a multiple */
3543 	/* of the algorithms block size */
3544 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3545 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3546 				plaintext_pad_len);
3547 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3548 
3549 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3550 
3551 	/* Create KASUMI operation */
3552 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3553 				tdata->cipher_iv.len,
3554 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3555 				tdata->validCipherOffsetInBits.len);
3556 	if (retval < 0)
3557 		return retval;
3558 
3559 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3560 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3561 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3562 	else
3563 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3564 				ut_params->op);
3565 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3566 
3567 	ut_params->obuf = ut_params->op->sym->m_dst;
3568 	if (ut_params->obuf)
3569 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3570 	else
3571 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3572 
3573 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3574 
3575 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3576 				(tdata->validCipherOffsetInBits.len >> 3);
3577 	/* Validate obuf */
3578 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3579 		ciphertext,
3580 		reference_ciphertext,
3581 		tdata->validCipherLenInBits.len,
3582 		"KASUMI Ciphertext data not as expected");
3583 	return 0;
3584 }
3585 
3586 static int
3587 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3588 {
3589 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3590 	struct crypto_unittest_params *ut_params = &unittest_params;
3591 
3592 	int retval;
3593 
3594 	unsigned int plaintext_pad_len;
3595 	unsigned int plaintext_len;
3596 
3597 	uint8_t buffer[10000];
3598 	const uint8_t *ciphertext;
3599 
3600 	struct rte_cryptodev_info dev_info;
3601 
3602 	/* Verify the capabilities */
3603 	struct rte_cryptodev_sym_capability_idx cap_idx;
3604 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3605 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3606 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3607 			&cap_idx) == NULL)
3608 		return TEST_SKIPPED;
3609 
3610 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3611 
3612 	uint64_t feat_flags = dev_info.feature_flags;
3613 
3614 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3615 		printf("Device doesn't support in-place scatter-gather. "
3616 				"Test Skipped.\n");
3617 		return TEST_SKIPPED;
3618 	}
3619 
3620 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3621 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3622 		printf("Device doesn't support RAW data-path APIs.\n");
3623 		return TEST_SKIPPED;
3624 	}
3625 
3626 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3627 		return TEST_SKIPPED;
3628 
3629 	/* Create KASUMI session */
3630 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3631 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3632 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3633 					tdata->key.data, tdata->key.len,
3634 					tdata->cipher_iv.len);
3635 	if (retval < 0)
3636 		return retval;
3637 
3638 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3639 
3640 
3641 	/* Append data which is padded to a multiple */
3642 	/* of the algorithms block size */
3643 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3644 
3645 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3646 			plaintext_pad_len, 10, 0);
3647 
3648 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3649 
3650 	/* Create KASUMI operation */
3651 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3652 				tdata->cipher_iv.len,
3653 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3654 				tdata->validCipherOffsetInBits.len);
3655 	if (retval < 0)
3656 		return retval;
3657 
3658 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3659 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
3660 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
3661 	else
3662 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3663 						ut_params->op);
3664 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3665 
3666 	ut_params->obuf = ut_params->op->sym->m_dst;
3667 
3668 	if (ut_params->obuf)
3669 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3670 				plaintext_len, buffer);
3671 	else
3672 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3673 				tdata->validCipherOffsetInBits.len >> 3,
3674 				plaintext_len, buffer);
3675 
3676 	/* Validate obuf */
3677 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3678 
3679 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3680 				(tdata->validCipherOffsetInBits.len >> 3);
3681 	/* Validate obuf */
3682 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3683 		ciphertext,
3684 		reference_ciphertext,
3685 		tdata->validCipherLenInBits.len,
3686 		"KASUMI Ciphertext data not as expected");
3687 	return 0;
3688 }
3689 
3690 static int
3691 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3692 {
3693 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3694 	struct crypto_unittest_params *ut_params = &unittest_params;
3695 
3696 	int retval;
3697 	uint8_t *plaintext, *ciphertext;
3698 	unsigned plaintext_pad_len;
3699 	unsigned plaintext_len;
3700 
3701 	/* Verify the capabilities */
3702 	struct rte_cryptodev_sym_capability_idx cap_idx;
3703 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3704 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3705 	/* Data-path service does not support OOP */
3706 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3707 			&cap_idx) == NULL)
3708 		return TEST_SKIPPED;
3709 
3710 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3711 		return TEST_SKIPPED;
3712 
3713 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3714 		return TEST_SKIPPED;
3715 
3716 	/* Create KASUMI session */
3717 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3718 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3719 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3720 					tdata->key.data, tdata->key.len,
3721 					tdata->cipher_iv.len);
3722 	if (retval < 0)
3723 		return retval;
3724 
3725 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3726 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3727 
3728 	/* Clear mbuf payload */
3729 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3730 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3731 
3732 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3733 	/* Append data which is padded to a multiple */
3734 	/* of the algorithms block size */
3735 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3736 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3737 				plaintext_pad_len);
3738 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3739 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3740 
3741 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3742 
3743 	/* Create KASUMI operation */
3744 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3745 				tdata->cipher_iv.len,
3746 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3747 				tdata->validCipherOffsetInBits.len);
3748 	if (retval < 0)
3749 		return retval;
3750 
3751 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3752 						ut_params->op);
3753 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3754 
3755 	ut_params->obuf = ut_params->op->sym->m_dst;
3756 	if (ut_params->obuf)
3757 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3758 	else
3759 		ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3760 
3761 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3762 
3763 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3764 				(tdata->validCipherOffsetInBits.len >> 3);
3765 	/* Validate obuf */
3766 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3767 		ciphertext,
3768 		reference_ciphertext,
3769 		tdata->validCipherLenInBits.len,
3770 		"KASUMI Ciphertext data not as expected");
3771 	return 0;
3772 }
3773 
3774 static int
3775 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3776 {
3777 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3778 	struct crypto_unittest_params *ut_params = &unittest_params;
3779 
3780 	int retval;
3781 	unsigned int plaintext_pad_len;
3782 	unsigned int plaintext_len;
3783 
3784 	const uint8_t *ciphertext;
3785 	uint8_t buffer[2048];
3786 
3787 	struct rte_cryptodev_info dev_info;
3788 
3789 	/* Verify the capabilities */
3790 	struct rte_cryptodev_sym_capability_idx cap_idx;
3791 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3792 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3793 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3794 			&cap_idx) == NULL)
3795 		return TEST_SKIPPED;
3796 
3797 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3798 		return TEST_SKIPPED;
3799 
3800 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3801 		return TEST_SKIPPED;
3802 
3803 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3804 
3805 	uint64_t feat_flags = dev_info.feature_flags;
3806 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3807 		printf("Device doesn't support out-of-place scatter-gather "
3808 				"in both input and output mbufs. "
3809 				"Test Skipped.\n");
3810 		return TEST_SKIPPED;
3811 	}
3812 
3813 	/* Create KASUMI session */
3814 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3815 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3816 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3817 					tdata->key.data, tdata->key.len,
3818 					tdata->cipher_iv.len);
3819 	if (retval < 0)
3820 		return retval;
3821 
3822 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
3823 	/* Append data which is padded to a multiple */
3824 	/* of the algorithms block size */
3825 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3826 
3827 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3828 			plaintext_pad_len, 10, 0);
3829 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3830 			plaintext_pad_len, 3, 0);
3831 
3832 	/* Append data which is padded to a multiple */
3833 	/* of the algorithms block size */
3834 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3835 
3836 	/* Create KASUMI operation */
3837 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3838 				tdata->cipher_iv.len,
3839 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3840 				tdata->validCipherOffsetInBits.len);
3841 	if (retval < 0)
3842 		return retval;
3843 
3844 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3845 						ut_params->op);
3846 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3847 
3848 	ut_params->obuf = ut_params->op->sym->m_dst;
3849 	if (ut_params->obuf)
3850 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3851 				plaintext_pad_len, buffer);
3852 	else
3853 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3854 				tdata->validCipherOffsetInBits.len >> 3,
3855 				plaintext_pad_len, buffer);
3856 
3857 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3858 				(tdata->validCipherOffsetInBits.len >> 3);
3859 	/* Validate obuf */
3860 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3861 		ciphertext,
3862 		reference_ciphertext,
3863 		tdata->validCipherLenInBits.len,
3864 		"KASUMI Ciphertext data not as expected");
3865 	return 0;
3866 }
3867 
3868 
3869 static int
3870 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3871 {
3872 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3873 	struct crypto_unittest_params *ut_params = &unittest_params;
3874 
3875 	int retval;
3876 	uint8_t *ciphertext, *plaintext;
3877 	unsigned ciphertext_pad_len;
3878 	unsigned ciphertext_len;
3879 
3880 	/* Verify the capabilities */
3881 	struct rte_cryptodev_sym_capability_idx cap_idx;
3882 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3883 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3884 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3885 			&cap_idx) == NULL)
3886 		return TEST_SKIPPED;
3887 
3888 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
3889 		return TEST_SKIPPED;
3890 
3891 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3892 		return TEST_SKIPPED;
3893 
3894 	/* Create KASUMI session */
3895 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3896 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3897 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3898 					tdata->key.data, tdata->key.len,
3899 					tdata->cipher_iv.len);
3900 	if (retval < 0)
3901 		return retval;
3902 
3903 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3904 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3905 
3906 	/* Clear mbuf payload */
3907 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3908 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3909 
3910 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3911 	/* Append data which is padded to a multiple */
3912 	/* of the algorithms block size */
3913 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3914 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3915 				ciphertext_pad_len);
3916 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3917 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3918 
3919 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3920 
3921 	/* Create KASUMI operation */
3922 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3923 				tdata->cipher_iv.len,
3924 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3925 				tdata->validCipherOffsetInBits.len);
3926 	if (retval < 0)
3927 		return retval;
3928 
3929 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3930 						ut_params->op);
3931 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3932 
3933 	ut_params->obuf = ut_params->op->sym->m_dst;
3934 	if (ut_params->obuf)
3935 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3936 	else
3937 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3938 
3939 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3940 
3941 	const uint8_t *reference_plaintext = tdata->plaintext.data +
3942 				(tdata->validCipherOffsetInBits.len >> 3);
3943 	/* Validate obuf */
3944 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3945 		plaintext,
3946 		reference_plaintext,
3947 		tdata->validCipherLenInBits.len,
3948 		"KASUMI Plaintext data not as expected");
3949 	return 0;
3950 }
3951 
3952 static int
3953 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3954 {
3955 	struct crypto_testsuite_params *ts_params = &testsuite_params;
3956 	struct crypto_unittest_params *ut_params = &unittest_params;
3957 
3958 	int retval;
3959 	uint8_t *ciphertext, *plaintext;
3960 	unsigned ciphertext_pad_len;
3961 	unsigned ciphertext_len;
3962 	struct rte_cryptodev_info dev_info;
3963 
3964 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3965 	uint64_t feat_flags = dev_info.feature_flags;
3966 
3967 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
3968 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
3969 		printf("Device doesn't support RAW data-path APIs.\n");
3970 		return TEST_SKIPPED;
3971 	}
3972 
3973 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
3974 		return TEST_SKIPPED;
3975 
3976 	/* Verify the capabilities */
3977 	struct rte_cryptodev_sym_capability_idx cap_idx;
3978 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3979 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
3980 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3981 			&cap_idx) == NULL)
3982 		return TEST_SKIPPED;
3983 
3984 	/* Create KASUMI session */
3985 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3986 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
3987 					RTE_CRYPTO_CIPHER_KASUMI_F8,
3988 					tdata->key.data, tdata->key.len,
3989 					tdata->cipher_iv.len);
3990 	if (retval < 0)
3991 		return retval;
3992 
3993 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3994 
3995 	/* Clear mbuf payload */
3996 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3997 	       rte_pktmbuf_tailroom(ut_params->ibuf));
3998 
3999 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4000 	/* Append data which is padded to a multiple */
4001 	/* of the algorithms block size */
4002 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
4003 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4004 				ciphertext_pad_len);
4005 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4006 
4007 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4008 
4009 	/* Create KASUMI operation */
4010 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4011 					tdata->cipher_iv.len,
4012 					tdata->ciphertext.len,
4013 					tdata->validCipherOffsetInBits.len);
4014 	if (retval < 0)
4015 		return retval;
4016 
4017 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4018 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4019 				ut_params->op, 1, 0, 1, 0);
4020 	else
4021 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4022 						ut_params->op);
4023 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4024 
4025 	ut_params->obuf = ut_params->op->sym->m_dst;
4026 	if (ut_params->obuf)
4027 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4028 	else
4029 		plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
4030 
4031 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4032 
4033 	const uint8_t *reference_plaintext = tdata->plaintext.data +
4034 				(tdata->validCipherOffsetInBits.len >> 3);
4035 	/* Validate obuf */
4036 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4037 		plaintext,
4038 		reference_plaintext,
4039 		tdata->validCipherLenInBits.len,
4040 		"KASUMI Plaintext data not as expected");
4041 	return 0;
4042 }
4043 
4044 static int
4045 test_snow3g_encryption(const struct snow3g_test_data *tdata)
4046 {
4047 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4048 	struct crypto_unittest_params *ut_params = &unittest_params;
4049 
4050 	int retval;
4051 	uint8_t *plaintext, *ciphertext;
4052 	unsigned plaintext_pad_len;
4053 	unsigned plaintext_len;
4054 	struct rte_cryptodev_info dev_info;
4055 
4056 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4057 	uint64_t feat_flags = dev_info.feature_flags;
4058 
4059 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4060 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4061 		printf("Device doesn't support RAW data-path APIs.\n");
4062 		return TEST_SKIPPED;
4063 	}
4064 
4065 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4066 		return TEST_SKIPPED;
4067 
4068 	/* Verify the capabilities */
4069 	struct rte_cryptodev_sym_capability_idx cap_idx;
4070 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4071 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4072 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4073 			&cap_idx) == NULL)
4074 		return TEST_SKIPPED;
4075 
4076 	/* Create SNOW 3G session */
4077 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4078 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4079 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4080 					tdata->key.data, tdata->key.len,
4081 					tdata->cipher_iv.len);
4082 	if (retval < 0)
4083 		return retval;
4084 
4085 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4086 
4087 	/* Clear mbuf payload */
4088 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4089 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4090 
4091 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4092 	/* Append data which is padded to a multiple of */
4093 	/* the algorithms block size */
4094 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4095 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4096 				plaintext_pad_len);
4097 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4098 
4099 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4100 
4101 	/* Create SNOW 3G operation */
4102 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4103 					tdata->cipher_iv.len,
4104 					tdata->validCipherLenInBits.len,
4105 					0);
4106 	if (retval < 0)
4107 		return retval;
4108 
4109 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4110 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4111 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4112 	else
4113 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4114 						ut_params->op);
4115 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4116 
4117 	ut_params->obuf = ut_params->op->sym->m_dst;
4118 	if (ut_params->obuf)
4119 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4120 	else
4121 		ciphertext = plaintext;
4122 
4123 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4124 
4125 	/* Validate obuf */
4126 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4127 		ciphertext,
4128 		tdata->ciphertext.data,
4129 		tdata->validDataLenInBits.len,
4130 		"SNOW 3G Ciphertext data not as expected");
4131 	return 0;
4132 }
4133 
4134 
4135 static int
4136 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4137 {
4138 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4139 	struct crypto_unittest_params *ut_params = &unittest_params;
4140 	uint8_t *plaintext, *ciphertext;
4141 
4142 	int retval;
4143 	unsigned plaintext_pad_len;
4144 	unsigned plaintext_len;
4145 
4146 	/* Verify the capabilities */
4147 	struct rte_cryptodev_sym_capability_idx cap_idx;
4148 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4149 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4150 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4151 			&cap_idx) == NULL)
4152 		return TEST_SKIPPED;
4153 
4154 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4155 		return TEST_SKIPPED;
4156 
4157 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4158 		return TEST_SKIPPED;
4159 
4160 	/* Create SNOW 3G session */
4161 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4162 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4163 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4164 					tdata->key.data, tdata->key.len,
4165 					tdata->cipher_iv.len);
4166 	if (retval < 0)
4167 		return retval;
4168 
4169 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4170 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4171 
4172 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4173 			"Failed to allocate input buffer in mempool");
4174 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4175 			"Failed to allocate output buffer in mempool");
4176 
4177 	/* Clear mbuf payload */
4178 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4179 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4180 
4181 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4182 	/* Append data which is padded to a multiple of */
4183 	/* the algorithms block size */
4184 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4185 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4186 				plaintext_pad_len);
4187 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4188 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4189 
4190 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4191 
4192 	/* Create SNOW 3G operation */
4193 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4194 					tdata->cipher_iv.len,
4195 					tdata->validCipherLenInBits.len,
4196 					0);
4197 	if (retval < 0)
4198 		return retval;
4199 
4200 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4201 						ut_params->op);
4202 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4203 
4204 	ut_params->obuf = ut_params->op->sym->m_dst;
4205 	if (ut_params->obuf)
4206 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4207 	else
4208 		ciphertext = plaintext;
4209 
4210 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4211 
4212 	/* Validate obuf */
4213 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4214 		ciphertext,
4215 		tdata->ciphertext.data,
4216 		tdata->validDataLenInBits.len,
4217 		"SNOW 3G Ciphertext data not as expected");
4218 	return 0;
4219 }
4220 
4221 static int
4222 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4223 {
4224 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4225 	struct crypto_unittest_params *ut_params = &unittest_params;
4226 
4227 	int retval;
4228 	unsigned int plaintext_pad_len;
4229 	unsigned int plaintext_len;
4230 	uint8_t buffer[10000];
4231 	const uint8_t *ciphertext;
4232 
4233 	struct rte_cryptodev_info dev_info;
4234 
4235 	/* Verify the capabilities */
4236 	struct rte_cryptodev_sym_capability_idx cap_idx;
4237 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4238 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4239 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4240 			&cap_idx) == NULL)
4241 		return TEST_SKIPPED;
4242 
4243 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4244 		return TEST_SKIPPED;
4245 
4246 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4247 		return TEST_SKIPPED;
4248 
4249 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4250 
4251 	uint64_t feat_flags = dev_info.feature_flags;
4252 
4253 	if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4254 		printf("Device doesn't support out-of-place scatter-gather "
4255 				"in both input and output mbufs. "
4256 				"Test Skipped.\n");
4257 		return TEST_SKIPPED;
4258 	}
4259 
4260 	/* Create SNOW 3G session */
4261 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4262 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4263 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4264 					tdata->key.data, tdata->key.len,
4265 					tdata->cipher_iv.len);
4266 	if (retval < 0)
4267 		return retval;
4268 
4269 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4270 	/* Append data which is padded to a multiple of */
4271 	/* the algorithms block size */
4272 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4273 
4274 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4275 			plaintext_pad_len, 10, 0);
4276 	ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4277 			plaintext_pad_len, 3, 0);
4278 
4279 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4280 			"Failed to allocate input buffer in mempool");
4281 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4282 			"Failed to allocate output buffer in mempool");
4283 
4284 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4285 
4286 	/* Create SNOW 3G operation */
4287 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4288 					tdata->cipher_iv.len,
4289 					tdata->validCipherLenInBits.len,
4290 					0);
4291 	if (retval < 0)
4292 		return retval;
4293 
4294 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4295 						ut_params->op);
4296 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4297 
4298 	ut_params->obuf = ut_params->op->sym->m_dst;
4299 	if (ut_params->obuf)
4300 		ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4301 				plaintext_len, buffer);
4302 	else
4303 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4304 				plaintext_len, buffer);
4305 
4306 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4307 
4308 	/* Validate obuf */
4309 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4310 		ciphertext,
4311 		tdata->ciphertext.data,
4312 		tdata->validDataLenInBits.len,
4313 		"SNOW 3G Ciphertext data not as expected");
4314 
4315 	return 0;
4316 }
4317 
4318 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4319 static void
4320 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4321 {
4322 	uint8_t curr_byte, prev_byte;
4323 	uint32_t length_in_bytes = ceil_byte_length(length + offset);
4324 	uint8_t lower_byte_mask = (1 << offset) - 1;
4325 	unsigned i;
4326 
4327 	prev_byte = buffer[0];
4328 	buffer[0] >>= offset;
4329 
4330 	for (i = 1; i < length_in_bytes; i++) {
4331 		curr_byte = buffer[i];
4332 		buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4333 				(curr_byte >> offset);
4334 		prev_byte = curr_byte;
4335 	}
4336 }
4337 
4338 static int
4339 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4340 {
4341 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4342 	struct crypto_unittest_params *ut_params = &unittest_params;
4343 	uint8_t *plaintext, *ciphertext;
4344 	int retval;
4345 	uint32_t plaintext_len;
4346 	uint32_t plaintext_pad_len;
4347 	uint8_t extra_offset = 4;
4348 	uint8_t *expected_ciphertext_shifted;
4349 	struct rte_cryptodev_info dev_info;
4350 
4351 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4352 	uint64_t feat_flags = dev_info.feature_flags;
4353 
4354 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4355 			((tdata->validDataLenInBits.len % 8) != 0)) {
4356 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4357 		return TEST_SKIPPED;
4358 	}
4359 
4360 	/* Verify the capabilities */
4361 	struct rte_cryptodev_sym_capability_idx cap_idx;
4362 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4363 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4364 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4365 			&cap_idx) == NULL)
4366 		return TEST_SKIPPED;
4367 
4368 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4369 		return TEST_SKIPPED;
4370 
4371 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4372 		return TEST_SKIPPED;
4373 
4374 	/* Create SNOW 3G session */
4375 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4376 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4377 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4378 					tdata->key.data, tdata->key.len,
4379 					tdata->cipher_iv.len);
4380 	if (retval < 0)
4381 		return retval;
4382 
4383 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4384 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4385 
4386 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4387 			"Failed to allocate input buffer in mempool");
4388 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4389 			"Failed to allocate output buffer in mempool");
4390 
4391 	/* Clear mbuf payload */
4392 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4393 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4394 
4395 	plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4396 	/*
4397 	 * Append data which is padded to a
4398 	 * multiple of the algorithms block size
4399 	 */
4400 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4401 
4402 	plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4403 						plaintext_pad_len);
4404 
4405 	rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4406 
4407 	memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4408 	buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4409 
4410 #ifdef RTE_APP_TEST_DEBUG
4411 	rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4412 #endif
4413 	/* Create SNOW 3G operation */
4414 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4415 					tdata->cipher_iv.len,
4416 					tdata->validCipherLenInBits.len,
4417 					extra_offset);
4418 	if (retval < 0)
4419 		return retval;
4420 
4421 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4422 						ut_params->op);
4423 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4424 
4425 	ut_params->obuf = ut_params->op->sym->m_dst;
4426 	if (ut_params->obuf)
4427 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4428 	else
4429 		ciphertext = plaintext;
4430 
4431 #ifdef RTE_APP_TEST_DEBUG
4432 	rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4433 #endif
4434 
4435 	expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4436 
4437 	TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4438 			"failed to reserve memory for ciphertext shifted\n");
4439 
4440 	memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4441 			ceil_byte_length(tdata->ciphertext.len));
4442 	buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4443 			extra_offset);
4444 	/* Validate obuf */
4445 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4446 		ciphertext,
4447 		expected_ciphertext_shifted,
4448 		tdata->validDataLenInBits.len,
4449 		extra_offset,
4450 		"SNOW 3G Ciphertext data not as expected");
4451 	return 0;
4452 }
4453 
4454 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4455 {
4456 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4457 	struct crypto_unittest_params *ut_params = &unittest_params;
4458 
4459 	int retval;
4460 
4461 	uint8_t *plaintext, *ciphertext;
4462 	unsigned ciphertext_pad_len;
4463 	unsigned ciphertext_len;
4464 	struct rte_cryptodev_info dev_info;
4465 
4466 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4467 	uint64_t feat_flags = dev_info.feature_flags;
4468 
4469 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4470 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4471 		printf("Device doesn't support RAW data-path APIs.\n");
4472 		return TEST_SKIPPED;
4473 	}
4474 
4475 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4476 		return TEST_SKIPPED;
4477 
4478 	/* Verify the capabilities */
4479 	struct rte_cryptodev_sym_capability_idx cap_idx;
4480 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4481 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4482 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4483 			&cap_idx) == NULL)
4484 		return TEST_SKIPPED;
4485 
4486 	/* Create SNOW 3G session */
4487 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4488 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4489 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4490 					tdata->key.data, tdata->key.len,
4491 					tdata->cipher_iv.len);
4492 	if (retval < 0)
4493 		return retval;
4494 
4495 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4496 
4497 	/* Clear mbuf payload */
4498 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4499 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4500 
4501 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4502 	/* Append data which is padded to a multiple of */
4503 	/* the algorithms block size */
4504 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4505 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4506 				ciphertext_pad_len);
4507 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4508 
4509 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4510 
4511 	/* Create SNOW 3G operation */
4512 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4513 					tdata->cipher_iv.len,
4514 					tdata->validCipherLenInBits.len,
4515 					tdata->cipher.offset_bits);
4516 	if (retval < 0)
4517 		return retval;
4518 
4519 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4520 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4521 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
4522 	else
4523 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4524 						ut_params->op);
4525 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4526 	ut_params->obuf = ut_params->op->sym->m_dst;
4527 	if (ut_params->obuf)
4528 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4529 	else
4530 		plaintext = ciphertext;
4531 
4532 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4533 
4534 	/* Validate obuf */
4535 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4536 				tdata->plaintext.data,
4537 				tdata->validDataLenInBits.len,
4538 				"SNOW 3G Plaintext data not as expected");
4539 	return 0;
4540 }
4541 
4542 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4543 {
4544 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4545 	struct crypto_unittest_params *ut_params = &unittest_params;
4546 
4547 	int retval;
4548 
4549 	uint8_t *plaintext, *ciphertext;
4550 	unsigned ciphertext_pad_len;
4551 	unsigned ciphertext_len;
4552 
4553 	/* Verify the capabilities */
4554 	struct rte_cryptodev_sym_capability_idx cap_idx;
4555 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4556 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4557 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4558 			&cap_idx) == NULL)
4559 		return TEST_SKIPPED;
4560 
4561 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4562 		return TEST_SKIPPED;
4563 
4564 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4565 		return TEST_SKIPPED;
4566 
4567 	/* Create SNOW 3G session */
4568 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4569 					RTE_CRYPTO_CIPHER_OP_DECRYPT,
4570 					RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4571 					tdata->key.data, tdata->key.len,
4572 					tdata->cipher_iv.len);
4573 	if (retval < 0)
4574 		return retval;
4575 
4576 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4577 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4578 
4579 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4580 			"Failed to allocate input buffer");
4581 	TEST_ASSERT_NOT_NULL(ut_params->obuf,
4582 			"Failed to allocate output buffer");
4583 
4584 	/* Clear mbuf payload */
4585 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4586 	       rte_pktmbuf_tailroom(ut_params->ibuf));
4587 
4588 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4589 		       rte_pktmbuf_tailroom(ut_params->obuf));
4590 
4591 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4592 	/* Append data which is padded to a multiple of */
4593 	/* the algorithms block size */
4594 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4595 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4596 				ciphertext_pad_len);
4597 	rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4598 	memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4599 
4600 	debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4601 
4602 	/* Create SNOW 3G operation */
4603 	retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4604 					tdata->cipher_iv.len,
4605 					tdata->validCipherLenInBits.len,
4606 					0);
4607 	if (retval < 0)
4608 		return retval;
4609 
4610 	ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4611 						ut_params->op);
4612 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4613 	ut_params->obuf = ut_params->op->sym->m_dst;
4614 	if (ut_params->obuf)
4615 		plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4616 	else
4617 		plaintext = ciphertext;
4618 
4619 	debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4620 
4621 	/* Validate obuf */
4622 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4623 				tdata->plaintext.data,
4624 				tdata->validDataLenInBits.len,
4625 				"SNOW 3G Plaintext data not as expected");
4626 	return 0;
4627 }
4628 
4629 static int
4630 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4631 {
4632 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4633 	struct crypto_unittest_params *ut_params = &unittest_params;
4634 
4635 	int retval;
4636 
4637 	uint8_t *plaintext, *ciphertext;
4638 	unsigned int plaintext_pad_len;
4639 	unsigned int plaintext_len;
4640 
4641 	struct rte_cryptodev_info dev_info;
4642 	struct rte_cryptodev_sym_capability_idx cap_idx;
4643 
4644 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4645 	uint64_t feat_flags = dev_info.feature_flags;
4646 
4647 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
4648 			((tdata->validAuthLenInBits.len % 8 != 0) ||
4649 			(tdata->validDataLenInBits.len % 8 != 0))) {
4650 		printf("Device doesn't support NON-Byte Aligned Data.\n");
4651 		return TEST_SKIPPED;
4652 	}
4653 
4654 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4655 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4656 		printf("Device doesn't support RAW data-path APIs.\n");
4657 		return TEST_SKIPPED;
4658 	}
4659 
4660 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4661 		return TEST_SKIPPED;
4662 
4663 	/* Check if device supports ZUC EEA3 */
4664 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4665 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4666 
4667 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4668 			&cap_idx) == NULL)
4669 		return TEST_SKIPPED;
4670 
4671 	/* Check if device supports ZUC EIA3 */
4672 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4673 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4674 
4675 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4676 			&cap_idx) == NULL)
4677 		return TEST_SKIPPED;
4678 
4679 	/* Create ZUC session */
4680 	retval = create_zuc_cipher_auth_encrypt_generate_session(
4681 			ts_params->valid_devs[0],
4682 			tdata);
4683 	if (retval != 0)
4684 		return retval;
4685 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4686 
4687 	/* clear mbuf payload */
4688 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4689 			rte_pktmbuf_tailroom(ut_params->ibuf));
4690 
4691 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4692 	/* Append data which is padded to a multiple of */
4693 	/* the algorithms block size */
4694 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4695 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4696 				plaintext_pad_len);
4697 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4698 
4699 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4700 
4701 	/* Create ZUC operation */
4702 	retval = create_zuc_cipher_hash_generate_operation(tdata);
4703 	if (retval < 0)
4704 		return retval;
4705 
4706 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4707 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4708 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4709 	else
4710 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4711 			ut_params->op);
4712 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4713 	ut_params->obuf = ut_params->op->sym->m_src;
4714 	if (ut_params->obuf)
4715 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4716 	else
4717 		ciphertext = plaintext;
4718 
4719 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4720 	/* Validate obuf */
4721 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4722 			ciphertext,
4723 			tdata->ciphertext.data,
4724 			tdata->validDataLenInBits.len,
4725 			"ZUC Ciphertext data not as expected");
4726 
4727 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4728 	    + plaintext_pad_len;
4729 
4730 	/* Validate obuf */
4731 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4732 			ut_params->digest,
4733 			tdata->digest.data,
4734 			4,
4735 			"ZUC Generated auth tag not as expected");
4736 	return 0;
4737 }
4738 
4739 static int
4740 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4741 {
4742 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4743 	struct crypto_unittest_params *ut_params = &unittest_params;
4744 
4745 	int retval;
4746 
4747 	uint8_t *plaintext, *ciphertext;
4748 	unsigned plaintext_pad_len;
4749 	unsigned plaintext_len;
4750 	struct rte_cryptodev_info dev_info;
4751 
4752 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4753 	uint64_t feat_flags = dev_info.feature_flags;
4754 
4755 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4756 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4757 		printf("Device doesn't support RAW data-path APIs.\n");
4758 		return TEST_SKIPPED;
4759 	}
4760 
4761 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4762 		return TEST_SKIPPED;
4763 
4764 	/* Verify the capabilities */
4765 	struct rte_cryptodev_sym_capability_idx cap_idx;
4766 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4767 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4768 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4769 			&cap_idx) == NULL)
4770 		return TEST_SKIPPED;
4771 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4772 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4773 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4774 			&cap_idx) == NULL)
4775 		return TEST_SKIPPED;
4776 
4777 	/* Create SNOW 3G session */
4778 	retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4779 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4780 			RTE_CRYPTO_AUTH_OP_GENERATE,
4781 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4782 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4783 			tdata->key.data, tdata->key.len,
4784 			tdata->auth_iv.len, tdata->digest.len,
4785 			tdata->cipher_iv.len);
4786 	if (retval != 0)
4787 		return retval;
4788 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4789 
4790 	/* clear mbuf payload */
4791 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4792 			rte_pktmbuf_tailroom(ut_params->ibuf));
4793 
4794 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4795 	/* Append data which is padded to a multiple of */
4796 	/* the algorithms block size */
4797 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4798 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4799 				plaintext_pad_len);
4800 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4801 
4802 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4803 
4804 	/* Create SNOW 3G operation */
4805 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4806 			tdata->digest.len, tdata->auth_iv.data,
4807 			tdata->auth_iv.len,
4808 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4809 			tdata->cipher_iv.data, tdata->cipher_iv.len,
4810 			tdata->validCipherLenInBits.len,
4811 			0,
4812 			tdata->validAuthLenInBits.len,
4813 			0
4814 			);
4815 	if (retval < 0)
4816 		return retval;
4817 
4818 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4819 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4820 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4821 	else
4822 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4823 			ut_params->op);
4824 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4825 	ut_params->obuf = ut_params->op->sym->m_src;
4826 	if (ut_params->obuf)
4827 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4828 	else
4829 		ciphertext = plaintext;
4830 
4831 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4832 	/* Validate obuf */
4833 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4834 			ciphertext,
4835 			tdata->ciphertext.data,
4836 			tdata->validDataLenInBits.len,
4837 			"SNOW 3G Ciphertext data not as expected");
4838 
4839 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4840 	    + plaintext_pad_len;
4841 
4842 	/* Validate obuf */
4843 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
4844 			ut_params->digest,
4845 			tdata->digest.data,
4846 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4847 			"SNOW 3G Generated auth tag not as expected");
4848 	return 0;
4849 }
4850 
4851 static int
4852 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4853 	uint8_t op_mode, uint8_t verify)
4854 {
4855 	struct crypto_testsuite_params *ts_params = &testsuite_params;
4856 	struct crypto_unittest_params *ut_params = &unittest_params;
4857 
4858 	int retval;
4859 
4860 	uint8_t *plaintext = NULL, *ciphertext = NULL;
4861 	unsigned int plaintext_pad_len;
4862 	unsigned int plaintext_len;
4863 	unsigned int ciphertext_pad_len;
4864 	unsigned int ciphertext_len;
4865 
4866 	struct rte_cryptodev_info dev_info;
4867 
4868 	/* Verify the capabilities */
4869 	struct rte_cryptodev_sym_capability_idx cap_idx;
4870 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4871 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
4872 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4873 			&cap_idx) == NULL)
4874 		return TEST_SKIPPED;
4875 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4876 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
4877 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4878 			&cap_idx) == NULL)
4879 		return TEST_SKIPPED;
4880 
4881 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
4882 		return TEST_SKIPPED;
4883 
4884 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4885 
4886 	uint64_t feat_flags = dev_info.feature_flags;
4887 
4888 	if (op_mode == OUT_OF_PLACE) {
4889 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4890 			printf("Device doesn't support digest encrypted.\n");
4891 			return TEST_SKIPPED;
4892 		}
4893 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4894 			return TEST_SKIPPED;
4895 	}
4896 
4897 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
4898 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
4899 		printf("Device doesn't support RAW data-path APIs.\n");
4900 		return TEST_SKIPPED;
4901 	}
4902 
4903 	/* Create SNOW 3G session */
4904 	retval = create_wireless_algo_auth_cipher_session(
4905 			ts_params->valid_devs[0],
4906 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4907 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4908 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4909 					: RTE_CRYPTO_AUTH_OP_GENERATE),
4910 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4911 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4912 			tdata->key.data, tdata->key.len,
4913 			tdata->auth_iv.len, tdata->digest.len,
4914 			tdata->cipher_iv.len);
4915 	if (retval != 0)
4916 		return retval;
4917 
4918 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4919 	if (op_mode == OUT_OF_PLACE)
4920 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4921 
4922 	/* clear mbuf payload */
4923 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4924 		rte_pktmbuf_tailroom(ut_params->ibuf));
4925 	if (op_mode == OUT_OF_PLACE)
4926 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4927 			rte_pktmbuf_tailroom(ut_params->obuf));
4928 
4929 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4930 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
4931 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4932 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4933 
4934 	if (verify) {
4935 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4936 					ciphertext_pad_len);
4937 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4938 		if (op_mode == OUT_OF_PLACE)
4939 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4940 		debug_hexdump(stdout, "ciphertext:", ciphertext,
4941 			ciphertext_len);
4942 	} else {
4943 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4944 					plaintext_pad_len);
4945 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4946 		if (op_mode == OUT_OF_PLACE)
4947 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4948 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4949 	}
4950 
4951 	/* Create SNOW 3G operation */
4952 	retval = create_wireless_algo_auth_cipher_operation(
4953 		tdata->digest.data, tdata->digest.len,
4954 		tdata->cipher_iv.data, tdata->cipher_iv.len,
4955 		tdata->auth_iv.data, tdata->auth_iv.len,
4956 		(tdata->digest.offset_bytes == 0 ?
4957 		(verify ? ciphertext_pad_len : plaintext_pad_len)
4958 			: tdata->digest.offset_bytes),
4959 		tdata->validCipherLenInBits.len,
4960 		tdata->cipher.offset_bits,
4961 		tdata->validAuthLenInBits.len,
4962 		tdata->auth.offset_bits,
4963 		op_mode, 0, verify);
4964 
4965 	if (retval < 0)
4966 		return retval;
4967 
4968 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
4969 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
4970 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
4971 	else
4972 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4973 			ut_params->op);
4974 
4975 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4976 
4977 	ut_params->obuf = (op_mode == IN_PLACE ?
4978 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4979 
4980 	if (verify) {
4981 		if (ut_params->obuf)
4982 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4983 							uint8_t *);
4984 		else
4985 			plaintext = ciphertext +
4986 				(tdata->cipher.offset_bits >> 3);
4987 
4988 		debug_hexdump(stdout, "plaintext:", plaintext,
4989 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4990 		debug_hexdump(stdout, "plaintext expected:",
4991 			tdata->plaintext.data,
4992 			(tdata->plaintext.len >> 3) - tdata->digest.len);
4993 	} else {
4994 		if (ut_params->obuf)
4995 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4996 							uint8_t *);
4997 		else
4998 			ciphertext = plaintext;
4999 
5000 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5001 			ciphertext_len);
5002 		debug_hexdump(stdout, "ciphertext expected:",
5003 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5004 
5005 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5006 			+ (tdata->digest.offset_bytes == 0 ?
5007 		plaintext_pad_len : tdata->digest.offset_bytes);
5008 
5009 		debug_hexdump(stdout, "digest:", ut_params->digest,
5010 			tdata->digest.len);
5011 		debug_hexdump(stdout, "digest expected:", tdata->digest.data,
5012 				tdata->digest.len);
5013 	}
5014 
5015 	/* Validate obuf */
5016 	if (verify) {
5017 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5018 			plaintext,
5019 			tdata->plaintext.data,
5020 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5021 			 (tdata->digest.len << 3)),
5022 			tdata->cipher.offset_bits,
5023 			"SNOW 3G Plaintext data not as expected");
5024 	} else {
5025 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5026 			ciphertext,
5027 			tdata->ciphertext.data,
5028 			(tdata->validDataLenInBits.len -
5029 			 tdata->cipher.offset_bits),
5030 			tdata->cipher.offset_bits,
5031 			"SNOW 3G Ciphertext data not as expected");
5032 
5033 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5034 			ut_params->digest,
5035 			tdata->digest.data,
5036 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5037 			"SNOW 3G Generated auth tag not as expected");
5038 	}
5039 	return 0;
5040 }
5041 
5042 static int
5043 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
5044 	uint8_t op_mode, uint8_t verify)
5045 {
5046 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5047 	struct crypto_unittest_params *ut_params = &unittest_params;
5048 
5049 	int retval;
5050 
5051 	const uint8_t *plaintext = NULL;
5052 	const uint8_t *ciphertext = NULL;
5053 	const uint8_t *digest = NULL;
5054 	unsigned int plaintext_pad_len;
5055 	unsigned int plaintext_len;
5056 	unsigned int ciphertext_pad_len;
5057 	unsigned int ciphertext_len;
5058 	uint8_t buffer[10000];
5059 	uint8_t digest_buffer[10000];
5060 
5061 	struct rte_cryptodev_info dev_info;
5062 
5063 	/* Verify the capabilities */
5064 	struct rte_cryptodev_sym_capability_idx cap_idx;
5065 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5066 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SNOW3G_UIA2;
5067 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5068 			&cap_idx) == NULL)
5069 		return TEST_SKIPPED;
5070 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5071 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_SNOW3G_UEA2;
5072 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5073 			&cap_idx) == NULL)
5074 		return TEST_SKIPPED;
5075 
5076 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5077 		return TEST_SKIPPED;
5078 
5079 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5080 
5081 	uint64_t feat_flags = dev_info.feature_flags;
5082 
5083 	if (op_mode == IN_PLACE) {
5084 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5085 			printf("Device doesn't support in-place scatter-gather "
5086 					"in both input and output mbufs.\n");
5087 			return TEST_SKIPPED;
5088 		}
5089 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5090 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5091 			printf("Device doesn't support RAW data-path APIs.\n");
5092 			return TEST_SKIPPED;
5093 		}
5094 	} else {
5095 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5096 			return TEST_SKIPPED;
5097 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5098 			printf("Device doesn't support out-of-place scatter-gather "
5099 					"in both input and output mbufs.\n");
5100 			return TEST_SKIPPED;
5101 		}
5102 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5103 			printf("Device doesn't support digest encrypted.\n");
5104 			return TEST_SKIPPED;
5105 		}
5106 	}
5107 
5108 	/* Create SNOW 3G session */
5109 	retval = create_wireless_algo_auth_cipher_session(
5110 			ts_params->valid_devs[0],
5111 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5112 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5113 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5114 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5115 			RTE_CRYPTO_AUTH_SNOW3G_UIA2,
5116 			RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
5117 			tdata->key.data, tdata->key.len,
5118 			tdata->auth_iv.len, tdata->digest.len,
5119 			tdata->cipher_iv.len);
5120 
5121 	if (retval != 0)
5122 		return retval;
5123 
5124 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5125 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5126 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5127 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5128 
5129 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5130 			plaintext_pad_len, 15, 0);
5131 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5132 			"Failed to allocate input buffer in mempool");
5133 
5134 	if (op_mode == OUT_OF_PLACE) {
5135 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5136 				plaintext_pad_len, 15, 0);
5137 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5138 				"Failed to allocate output buffer in mempool");
5139 	}
5140 
5141 	if (verify) {
5142 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5143 			tdata->ciphertext.data);
5144 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5145 					ciphertext_len, buffer);
5146 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5147 			ciphertext_len);
5148 	} else {
5149 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5150 			tdata->plaintext.data);
5151 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5152 					plaintext_len, buffer);
5153 		debug_hexdump(stdout, "plaintext:", plaintext,
5154 			plaintext_len);
5155 	}
5156 	memset(buffer, 0, sizeof(buffer));
5157 
5158 	/* Create SNOW 3G operation */
5159 	retval = create_wireless_algo_auth_cipher_operation(
5160 		tdata->digest.data, tdata->digest.len,
5161 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5162 		tdata->auth_iv.data, tdata->auth_iv.len,
5163 		(tdata->digest.offset_bytes == 0 ?
5164 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5165 			: tdata->digest.offset_bytes),
5166 		tdata->validCipherLenInBits.len,
5167 		tdata->cipher.offset_bits,
5168 		tdata->validAuthLenInBits.len,
5169 		tdata->auth.offset_bits,
5170 		op_mode, 1, verify);
5171 
5172 	if (retval < 0)
5173 		return retval;
5174 
5175 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5176 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5177 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5178 	else
5179 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5180 			ut_params->op);
5181 
5182 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5183 
5184 	ut_params->obuf = (op_mode == IN_PLACE ?
5185 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5186 
5187 	if (verify) {
5188 		if (ut_params->obuf)
5189 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5190 					plaintext_len, buffer);
5191 		else
5192 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5193 					plaintext_len, buffer);
5194 
5195 		debug_hexdump(stdout, "plaintext:", plaintext,
5196 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5197 		debug_hexdump(stdout, "plaintext expected:",
5198 			tdata->plaintext.data,
5199 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5200 	} else {
5201 		if (ut_params->obuf)
5202 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5203 					ciphertext_len, buffer);
5204 		else
5205 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5206 					ciphertext_len, buffer);
5207 
5208 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5209 			ciphertext_len);
5210 		debug_hexdump(stdout, "ciphertext expected:",
5211 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5212 
5213 		if (ut_params->obuf)
5214 			digest = rte_pktmbuf_read(ut_params->obuf,
5215 				(tdata->digest.offset_bytes == 0 ?
5216 				plaintext_pad_len : tdata->digest.offset_bytes),
5217 				tdata->digest.len, digest_buffer);
5218 		else
5219 			digest = rte_pktmbuf_read(ut_params->ibuf,
5220 				(tdata->digest.offset_bytes == 0 ?
5221 				plaintext_pad_len : tdata->digest.offset_bytes),
5222 				tdata->digest.len, digest_buffer);
5223 
5224 		debug_hexdump(stdout, "digest:", digest,
5225 			tdata->digest.len);
5226 		debug_hexdump(stdout, "digest expected:",
5227 			tdata->digest.data, tdata->digest.len);
5228 	}
5229 
5230 	/* Validate obuf */
5231 	if (verify) {
5232 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5233 			plaintext,
5234 			tdata->plaintext.data,
5235 			(tdata->plaintext.len - tdata->cipher.offset_bits -
5236 			 (tdata->digest.len << 3)),
5237 			tdata->cipher.offset_bits,
5238 			"SNOW 3G Plaintext data not as expected");
5239 	} else {
5240 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
5241 			ciphertext,
5242 			tdata->ciphertext.data,
5243 			(tdata->validDataLenInBits.len -
5244 			 tdata->cipher.offset_bits),
5245 			tdata->cipher.offset_bits,
5246 			"SNOW 3G Ciphertext data not as expected");
5247 
5248 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5249 			digest,
5250 			tdata->digest.data,
5251 			DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5252 			"SNOW 3G Generated auth tag not as expected");
5253 	}
5254 	return 0;
5255 }
5256 
5257 static int
5258 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
5259 	uint8_t op_mode, uint8_t verify)
5260 {
5261 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5262 	struct crypto_unittest_params *ut_params = &unittest_params;
5263 
5264 	int retval;
5265 
5266 	uint8_t *plaintext = NULL, *ciphertext = NULL;
5267 	unsigned int plaintext_pad_len;
5268 	unsigned int plaintext_len;
5269 	unsigned int ciphertext_pad_len;
5270 	unsigned int ciphertext_len;
5271 
5272 	struct rte_cryptodev_info dev_info;
5273 
5274 	/* Verify the capabilities */
5275 	struct rte_cryptodev_sym_capability_idx cap_idx;
5276 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5277 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5278 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5279 			&cap_idx) == NULL)
5280 		return TEST_SKIPPED;
5281 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5282 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5283 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5284 			&cap_idx) == NULL)
5285 		return TEST_SKIPPED;
5286 
5287 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5288 
5289 	uint64_t feat_flags = dev_info.feature_flags;
5290 
5291 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5292 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5293 		printf("Device doesn't support RAW data-path APIs.\n");
5294 		return TEST_SKIPPED;
5295 	}
5296 
5297 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5298 		return TEST_SKIPPED;
5299 
5300 	if (op_mode == OUT_OF_PLACE) {
5301 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5302 			return TEST_SKIPPED;
5303 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5304 			printf("Device doesn't support digest encrypted.\n");
5305 			return TEST_SKIPPED;
5306 		}
5307 	}
5308 
5309 	/* Create KASUMI session */
5310 	retval = create_wireless_algo_auth_cipher_session(
5311 			ts_params->valid_devs[0],
5312 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5313 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5314 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5315 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5316 			RTE_CRYPTO_AUTH_KASUMI_F9,
5317 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5318 			tdata->key.data, tdata->key.len,
5319 			0, tdata->digest.len,
5320 			tdata->cipher_iv.len);
5321 
5322 	if (retval != 0)
5323 		return retval;
5324 
5325 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5326 	if (op_mode == OUT_OF_PLACE)
5327 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5328 
5329 	/* clear mbuf payload */
5330 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5331 		rte_pktmbuf_tailroom(ut_params->ibuf));
5332 	if (op_mode == OUT_OF_PLACE)
5333 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5334 			rte_pktmbuf_tailroom(ut_params->obuf));
5335 
5336 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5337 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5338 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5339 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5340 
5341 	if (verify) {
5342 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5343 					ciphertext_pad_len);
5344 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5345 		if (op_mode == OUT_OF_PLACE)
5346 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5347 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5348 			ciphertext_len);
5349 	} else {
5350 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5351 					plaintext_pad_len);
5352 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5353 		if (op_mode == OUT_OF_PLACE)
5354 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5355 		debug_hexdump(stdout, "plaintext:", plaintext,
5356 			plaintext_len);
5357 	}
5358 
5359 	/* Create KASUMI operation */
5360 	retval = create_wireless_algo_auth_cipher_operation(
5361 		tdata->digest.data, tdata->digest.len,
5362 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5363 		NULL, 0,
5364 		(tdata->digest.offset_bytes == 0 ?
5365 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5366 			: tdata->digest.offset_bytes),
5367 		tdata->validCipherLenInBits.len,
5368 		tdata->validCipherOffsetInBits.len,
5369 		tdata->validAuthLenInBits.len,
5370 		0,
5371 		op_mode, 0, verify);
5372 
5373 	if (retval < 0)
5374 		return retval;
5375 
5376 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5377 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5378 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5379 	else
5380 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5381 			ut_params->op);
5382 
5383 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5384 
5385 	ut_params->obuf = (op_mode == IN_PLACE ?
5386 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5387 
5388 
5389 	if (verify) {
5390 		if (ut_params->obuf)
5391 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5392 							uint8_t *);
5393 		else
5394 			plaintext = ciphertext;
5395 
5396 		debug_hexdump(stdout, "plaintext:", plaintext,
5397 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5398 		debug_hexdump(stdout, "plaintext expected:",
5399 			tdata->plaintext.data,
5400 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5401 	} else {
5402 		if (ut_params->obuf)
5403 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5404 							uint8_t *);
5405 		else
5406 			ciphertext = plaintext;
5407 
5408 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5409 			ciphertext_len);
5410 		debug_hexdump(stdout, "ciphertext expected:",
5411 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5412 
5413 		ut_params->digest = rte_pktmbuf_mtod(
5414 			ut_params->obuf, uint8_t *) +
5415 			(tdata->digest.offset_bytes == 0 ?
5416 			plaintext_pad_len : tdata->digest.offset_bytes);
5417 
5418 		debug_hexdump(stdout, "digest:", ut_params->digest,
5419 			tdata->digest.len);
5420 		debug_hexdump(stdout, "digest expected:",
5421 			tdata->digest.data, tdata->digest.len);
5422 	}
5423 
5424 	/* Validate obuf */
5425 	if (verify) {
5426 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5427 			plaintext,
5428 			tdata->plaintext.data,
5429 			tdata->plaintext.len >> 3,
5430 			"KASUMI Plaintext data not as expected");
5431 	} else {
5432 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5433 			ciphertext,
5434 			tdata->ciphertext.data,
5435 			tdata->ciphertext.len >> 3,
5436 			"KASUMI Ciphertext data not as expected");
5437 
5438 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5439 			ut_params->digest,
5440 			tdata->digest.data,
5441 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5442 			"KASUMI Generated auth tag not as expected");
5443 	}
5444 	return 0;
5445 }
5446 
5447 static int
5448 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5449 	uint8_t op_mode, uint8_t verify)
5450 {
5451 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5452 	struct crypto_unittest_params *ut_params = &unittest_params;
5453 
5454 	int retval;
5455 
5456 	const uint8_t *plaintext = NULL;
5457 	const uint8_t *ciphertext = NULL;
5458 	const uint8_t *digest = NULL;
5459 	unsigned int plaintext_pad_len;
5460 	unsigned int plaintext_len;
5461 	unsigned int ciphertext_pad_len;
5462 	unsigned int ciphertext_len;
5463 	uint8_t buffer[10000];
5464 	uint8_t digest_buffer[10000];
5465 
5466 	struct rte_cryptodev_info dev_info;
5467 
5468 	/* Verify the capabilities */
5469 	struct rte_cryptodev_sym_capability_idx cap_idx;
5470 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5471 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5472 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5473 			&cap_idx) == NULL)
5474 		return TEST_SKIPPED;
5475 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5476 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5477 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5478 			&cap_idx) == NULL)
5479 		return TEST_SKIPPED;
5480 
5481 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5482 		return TEST_SKIPPED;
5483 
5484 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5485 
5486 	uint64_t feat_flags = dev_info.feature_flags;
5487 
5488 	if (op_mode == IN_PLACE) {
5489 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5490 			printf("Device doesn't support in-place scatter-gather "
5491 					"in both input and output mbufs.\n");
5492 			return TEST_SKIPPED;
5493 		}
5494 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5495 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5496 			printf("Device doesn't support RAW data-path APIs.\n");
5497 			return TEST_SKIPPED;
5498 		}
5499 	} else {
5500 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5501 			return TEST_SKIPPED;
5502 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5503 			printf("Device doesn't support out-of-place scatter-gather "
5504 					"in both input and output mbufs.\n");
5505 			return TEST_SKIPPED;
5506 		}
5507 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5508 			printf("Device doesn't support digest encrypted.\n");
5509 			return TEST_SKIPPED;
5510 		}
5511 	}
5512 
5513 	/* Create KASUMI session */
5514 	retval = create_wireless_algo_auth_cipher_session(
5515 			ts_params->valid_devs[0],
5516 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5517 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5518 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5519 					: RTE_CRYPTO_AUTH_OP_GENERATE),
5520 			RTE_CRYPTO_AUTH_KASUMI_F9,
5521 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5522 			tdata->key.data, tdata->key.len,
5523 			0, tdata->digest.len,
5524 			tdata->cipher_iv.len);
5525 
5526 	if (retval != 0)
5527 		return retval;
5528 
5529 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5530 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5531 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5532 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5533 
5534 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5535 			plaintext_pad_len, 15, 0);
5536 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5537 			"Failed to allocate input buffer in mempool");
5538 
5539 	if (op_mode == OUT_OF_PLACE) {
5540 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5541 				plaintext_pad_len, 15, 0);
5542 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
5543 				"Failed to allocate output buffer in mempool");
5544 	}
5545 
5546 	if (verify) {
5547 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5548 			tdata->ciphertext.data);
5549 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5550 					ciphertext_len, buffer);
5551 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5552 			ciphertext_len);
5553 	} else {
5554 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5555 			tdata->plaintext.data);
5556 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5557 					plaintext_len, buffer);
5558 		debug_hexdump(stdout, "plaintext:", plaintext,
5559 			plaintext_len);
5560 	}
5561 	memset(buffer, 0, sizeof(buffer));
5562 
5563 	/* Create KASUMI operation */
5564 	retval = create_wireless_algo_auth_cipher_operation(
5565 		tdata->digest.data, tdata->digest.len,
5566 		tdata->cipher_iv.data, tdata->cipher_iv.len,
5567 		NULL, 0,
5568 		(tdata->digest.offset_bytes == 0 ?
5569 		(verify ? ciphertext_pad_len : plaintext_pad_len)
5570 			: tdata->digest.offset_bytes),
5571 		tdata->validCipherLenInBits.len,
5572 		tdata->validCipherOffsetInBits.len,
5573 		tdata->validAuthLenInBits.len,
5574 		0,
5575 		op_mode, 1, verify);
5576 
5577 	if (retval < 0)
5578 		return retval;
5579 
5580 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5581 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5582 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5583 	else
5584 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5585 			ut_params->op);
5586 
5587 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5588 
5589 	ut_params->obuf = (op_mode == IN_PLACE ?
5590 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5591 
5592 	if (verify) {
5593 		if (ut_params->obuf)
5594 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5595 					plaintext_len, buffer);
5596 		else
5597 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5598 					plaintext_len, buffer);
5599 
5600 		debug_hexdump(stdout, "plaintext:", plaintext,
5601 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5602 		debug_hexdump(stdout, "plaintext expected:",
5603 			tdata->plaintext.data,
5604 			(tdata->plaintext.len >> 3) - tdata->digest.len);
5605 	} else {
5606 		if (ut_params->obuf)
5607 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5608 					ciphertext_len, buffer);
5609 		else
5610 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5611 					ciphertext_len, buffer);
5612 
5613 		debug_hexdump(stdout, "ciphertext:", ciphertext,
5614 			ciphertext_len);
5615 		debug_hexdump(stdout, "ciphertext expected:",
5616 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5617 
5618 		if (ut_params->obuf)
5619 			digest = rte_pktmbuf_read(ut_params->obuf,
5620 				(tdata->digest.offset_bytes == 0 ?
5621 				plaintext_pad_len : tdata->digest.offset_bytes),
5622 				tdata->digest.len, digest_buffer);
5623 		else
5624 			digest = rte_pktmbuf_read(ut_params->ibuf,
5625 				(tdata->digest.offset_bytes == 0 ?
5626 				plaintext_pad_len : tdata->digest.offset_bytes),
5627 				tdata->digest.len, digest_buffer);
5628 
5629 		debug_hexdump(stdout, "digest:", digest,
5630 			tdata->digest.len);
5631 		debug_hexdump(stdout, "digest expected:",
5632 			tdata->digest.data, tdata->digest.len);
5633 	}
5634 
5635 	/* Validate obuf */
5636 	if (verify) {
5637 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5638 			plaintext,
5639 			tdata->plaintext.data,
5640 			tdata->plaintext.len >> 3,
5641 			"KASUMI Plaintext data not as expected");
5642 	} else {
5643 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5644 			ciphertext,
5645 			tdata->ciphertext.data,
5646 			tdata->validDataLenInBits.len,
5647 			"KASUMI Ciphertext data not as expected");
5648 
5649 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
5650 			digest,
5651 			tdata->digest.data,
5652 			DIGEST_BYTE_LENGTH_KASUMI_F9,
5653 			"KASUMI Generated auth tag not as expected");
5654 	}
5655 	return 0;
5656 }
5657 
5658 static int
5659 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5660 {
5661 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5662 	struct crypto_unittest_params *ut_params = &unittest_params;
5663 
5664 	int retval;
5665 
5666 	uint8_t *plaintext, *ciphertext;
5667 	unsigned plaintext_pad_len;
5668 	unsigned plaintext_len;
5669 	struct rte_cryptodev_info dev_info;
5670 
5671 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5672 	uint64_t feat_flags = dev_info.feature_flags;
5673 
5674 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5675 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5676 		printf("Device doesn't support RAW data-path APIs.\n");
5677 		return TEST_SKIPPED;
5678 	}
5679 
5680 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5681 		return TEST_SKIPPED;
5682 
5683 	/* Verify the capabilities */
5684 	struct rte_cryptodev_sym_capability_idx cap_idx;
5685 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5686 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_KASUMI_F9;
5687 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5688 			&cap_idx) == NULL)
5689 		return TEST_SKIPPED;
5690 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5691 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_KASUMI_F8;
5692 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5693 			&cap_idx) == NULL)
5694 		return TEST_SKIPPED;
5695 
5696 	/* Create KASUMI session */
5697 	retval = create_wireless_algo_cipher_auth_session(
5698 			ts_params->valid_devs[0],
5699 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5700 			RTE_CRYPTO_AUTH_OP_GENERATE,
5701 			RTE_CRYPTO_AUTH_KASUMI_F9,
5702 			RTE_CRYPTO_CIPHER_KASUMI_F8,
5703 			tdata->key.data, tdata->key.len,
5704 			0, tdata->digest.len,
5705 			tdata->cipher_iv.len);
5706 	if (retval != 0)
5707 		return retval;
5708 
5709 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5710 
5711 	/* clear mbuf payload */
5712 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5713 			rte_pktmbuf_tailroom(ut_params->ibuf));
5714 
5715 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5716 	/* Append data which is padded to a multiple of */
5717 	/* the algorithms block size */
5718 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5719 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5720 				plaintext_pad_len);
5721 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5722 
5723 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5724 
5725 	/* Create KASUMI operation */
5726 	retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5727 				tdata->digest.len, NULL, 0,
5728 				plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5729 				tdata->cipher_iv.data, tdata->cipher_iv.len,
5730 				RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5731 				tdata->validCipherOffsetInBits.len,
5732 				tdata->validAuthLenInBits.len,
5733 				0
5734 				);
5735 	if (retval < 0)
5736 		return retval;
5737 
5738 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5739 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5740 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
5741 	else
5742 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5743 			ut_params->op);
5744 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5745 
5746 	if (ut_params->op->sym->m_dst)
5747 		ut_params->obuf = ut_params->op->sym->m_dst;
5748 	else
5749 		ut_params->obuf = ut_params->op->sym->m_src;
5750 
5751 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5752 				tdata->validCipherOffsetInBits.len >> 3);
5753 
5754 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5755 			+ plaintext_pad_len;
5756 
5757 	const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5758 				(tdata->validCipherOffsetInBits.len >> 3);
5759 	/* Validate obuf */
5760 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5761 		ciphertext,
5762 		reference_ciphertext,
5763 		tdata->validCipherLenInBits.len,
5764 		"KASUMI Ciphertext data not as expected");
5765 
5766 	/* Validate obuf */
5767 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
5768 		ut_params->digest,
5769 		tdata->digest.data,
5770 		DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5771 		"KASUMI Generated auth tag not as expected");
5772 	return 0;
5773 }
5774 
5775 static int
5776 test_zuc_encryption(const struct wireless_test_data *tdata)
5777 {
5778 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5779 	struct crypto_unittest_params *ut_params = &unittest_params;
5780 
5781 	int retval;
5782 	uint8_t *plaintext, *ciphertext;
5783 	unsigned plaintext_pad_len;
5784 	unsigned plaintext_len;
5785 	struct rte_cryptodev_info dev_info;
5786 
5787 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5788 	uint64_t feat_flags = dev_info.feature_flags;
5789 
5790 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5791 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5792 		printf("Device doesn't support RAW data-path APIs.\n");
5793 		return TEST_SKIPPED;
5794 	}
5795 
5796 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5797 		return TEST_SKIPPED;
5798 
5799 	struct rte_cryptodev_sym_capability_idx cap_idx;
5800 
5801 	/* Check if device supports ZUC EEA3 */
5802 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5803 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5804 
5805 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5806 			&cap_idx) == NULL)
5807 		return TEST_SKIPPED;
5808 
5809 	/* Create ZUC session */
5810 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5811 					RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5812 					RTE_CRYPTO_CIPHER_ZUC_EEA3,
5813 					tdata->key.data, tdata->key.len,
5814 					tdata->cipher_iv.len);
5815 	if (retval < 0)
5816 		return retval;
5817 
5818 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5819 
5820 	/* Clear mbuf payload */
5821 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5822 	       rte_pktmbuf_tailroom(ut_params->ibuf));
5823 
5824 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5825 	/* Append data which is padded to a multiple */
5826 	/* of the algorithms block size */
5827 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5828 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5829 				plaintext_pad_len);
5830 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5831 
5832 	debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5833 
5834 	/* Create ZUC operation */
5835 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5836 					tdata->cipher_iv.len,
5837 					tdata->plaintext.len,
5838 					0);
5839 	if (retval < 0)
5840 		return retval;
5841 
5842 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5843 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5844 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5845 	else
5846 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5847 						ut_params->op);
5848 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5849 
5850 	ut_params->obuf = ut_params->op->sym->m_dst;
5851 	if (ut_params->obuf)
5852 		ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5853 	else
5854 		ciphertext = plaintext;
5855 
5856 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5857 
5858 	/* Validate obuf */
5859 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5860 		ciphertext,
5861 		tdata->ciphertext.data,
5862 		tdata->validCipherLenInBits.len,
5863 		"ZUC Ciphertext data not as expected");
5864 	return 0;
5865 }
5866 
5867 static int
5868 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5869 {
5870 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5871 	struct crypto_unittest_params *ut_params = &unittest_params;
5872 
5873 	int retval;
5874 
5875 	unsigned int plaintext_pad_len;
5876 	unsigned int plaintext_len;
5877 	const uint8_t *ciphertext;
5878 	uint8_t ciphertext_buffer[2048];
5879 	struct rte_cryptodev_info dev_info;
5880 
5881 	struct rte_cryptodev_sym_capability_idx cap_idx;
5882 
5883 	/* Check if device supports ZUC EEA3 */
5884 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5885 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5886 
5887 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5888 			&cap_idx) == NULL)
5889 		return TEST_SKIPPED;
5890 
5891 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
5892 		return TEST_SKIPPED;
5893 
5894 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5895 
5896 	uint64_t feat_flags = dev_info.feature_flags;
5897 
5898 	if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5899 		printf("Device doesn't support in-place scatter-gather. "
5900 				"Test Skipped.\n");
5901 		return TEST_SKIPPED;
5902 	}
5903 
5904 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5905 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5906 		printf("Device doesn't support RAW data-path APIs.\n");
5907 		return TEST_SKIPPED;
5908 	}
5909 
5910 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
5911 
5912 	/* Append data which is padded to a multiple */
5913 	/* of the algorithms block size */
5914 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5915 
5916 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5917 			plaintext_pad_len, 10, 0);
5918 
5919 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5920 			tdata->plaintext.data);
5921 
5922 	/* Create ZUC session */
5923 	retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5924 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5925 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
5926 			tdata->key.data, tdata->key.len,
5927 			tdata->cipher_iv.len);
5928 	if (retval < 0)
5929 		return retval;
5930 
5931 	/* Clear mbuf payload */
5932 
5933 	pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5934 
5935 	/* Create ZUC operation */
5936 	retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5937 			tdata->cipher_iv.len, tdata->plaintext.len,
5938 			0);
5939 	if (retval < 0)
5940 		return retval;
5941 
5942 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
5943 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
5944 				ut_params->op, 1, 0, 1, tdata->cipher_iv.len);
5945 	else
5946 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5947 						ut_params->op);
5948 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5949 
5950 	ut_params->obuf = ut_params->op->sym->m_dst;
5951 	if (ut_params->obuf)
5952 		ciphertext = rte_pktmbuf_read(ut_params->obuf,
5953 			0, plaintext_len, ciphertext_buffer);
5954 	else
5955 		ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5956 			0, plaintext_len, ciphertext_buffer);
5957 
5958 	/* Validate obuf */
5959 	debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5960 
5961 	/* Validate obuf */
5962 	TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5963 		ciphertext,
5964 		tdata->ciphertext.data,
5965 		tdata->validCipherLenInBits.len,
5966 		"ZUC Ciphertext data not as expected");
5967 
5968 	return 0;
5969 }
5970 
5971 static int
5972 test_zuc_authentication(const struct wireless_test_data *tdata)
5973 {
5974 	struct crypto_testsuite_params *ts_params = &testsuite_params;
5975 	struct crypto_unittest_params *ut_params = &unittest_params;
5976 
5977 	int retval;
5978 	unsigned plaintext_pad_len;
5979 	unsigned plaintext_len;
5980 	uint8_t *plaintext;
5981 
5982 	struct rte_cryptodev_sym_capability_idx cap_idx;
5983 	struct rte_cryptodev_info dev_info;
5984 
5985 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5986 	uint64_t feat_flags = dev_info.feature_flags;
5987 
5988 	if (!(feat_flags & RTE_CRYPTODEV_FF_NON_BYTE_ALIGNED_DATA) &&
5989 			(tdata->validAuthLenInBits.len % 8 != 0)) {
5990 		printf("Device doesn't support NON-Byte Aligned Data.\n");
5991 		return TEST_SKIPPED;
5992 	}
5993 
5994 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
5995 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
5996 		printf("Device doesn't support RAW data-path APIs.\n");
5997 		return TEST_SKIPPED;
5998 	}
5999 
6000 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
6001 		return TEST_SKIPPED;
6002 
6003 	/* Check if device supports ZUC EIA3 */
6004 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6005 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6006 
6007 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6008 			&cap_idx) == NULL)
6009 		return TEST_SKIPPED;
6010 
6011 	/* Create ZUC session */
6012 	retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
6013 			tdata->key.data, tdata->key.len,
6014 			tdata->auth_iv.len, tdata->digest.len,
6015 			RTE_CRYPTO_AUTH_OP_GENERATE,
6016 			RTE_CRYPTO_AUTH_ZUC_EIA3);
6017 	if (retval < 0)
6018 		return retval;
6019 
6020 	/* alloc mbuf and set payload */
6021 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6022 
6023 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6024 	rte_pktmbuf_tailroom(ut_params->ibuf));
6025 
6026 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6027 	/* Append data which is padded to a multiple of */
6028 	/* the algorithms block size */
6029 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
6030 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6031 				plaintext_pad_len);
6032 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6033 
6034 	/* Create ZUC operation */
6035 	retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
6036 			tdata->auth_iv.data, tdata->auth_iv.len,
6037 			plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
6038 			tdata->validAuthLenInBits.len,
6039 			0);
6040 	if (retval < 0)
6041 		return retval;
6042 
6043 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6044 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6045 				ut_params->op, 0, 1, 1, 0);
6046 	else
6047 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6048 				ut_params->op);
6049 	ut_params->obuf = ut_params->op->sym->m_src;
6050 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6051 	ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6052 			+ plaintext_pad_len;
6053 
6054 	/* Validate obuf */
6055 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
6056 	ut_params->digest,
6057 	tdata->digest.data,
6058 	tdata->digest.len,
6059 	"ZUC Generated auth tag not as expected");
6060 
6061 	return 0;
6062 }
6063 
6064 static int
6065 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
6066 	uint8_t op_mode, uint8_t verify)
6067 {
6068 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6069 	struct crypto_unittest_params *ut_params = &unittest_params;
6070 
6071 	int retval;
6072 
6073 	uint8_t *plaintext = NULL, *ciphertext = NULL;
6074 	unsigned int plaintext_pad_len;
6075 	unsigned int plaintext_len;
6076 	unsigned int ciphertext_pad_len;
6077 	unsigned int ciphertext_len;
6078 
6079 	struct rte_cryptodev_info dev_info;
6080 	struct rte_cryptodev_sym_capability_idx cap_idx;
6081 
6082 	/* Check if device supports ZUC EIA3 */
6083 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6084 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6085 
6086 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6087 			&cap_idx) == NULL)
6088 		return TEST_SKIPPED;
6089 
6090 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6091 
6092 	uint64_t feat_flags = dev_info.feature_flags;
6093 
6094 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6095 		printf("Device doesn't support digest encrypted.\n");
6096 		return TEST_SKIPPED;
6097 	}
6098 	if (op_mode == IN_PLACE) {
6099 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6100 			printf("Device doesn't support in-place scatter-gather "
6101 					"in both input and output mbufs.\n");
6102 			return TEST_SKIPPED;
6103 		}
6104 
6105 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6106 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6107 			printf("Device doesn't support RAW data-path APIs.\n");
6108 			return TEST_SKIPPED;
6109 		}
6110 	} else {
6111 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6112 			return TEST_SKIPPED;
6113 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6114 			printf("Device doesn't support out-of-place scatter-gather "
6115 					"in both input and output mbufs.\n");
6116 			return TEST_SKIPPED;
6117 		}
6118 	}
6119 
6120 	/* Create ZUC session */
6121 	retval = create_wireless_algo_auth_cipher_session(
6122 			ts_params->valid_devs[0],
6123 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6124 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6125 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6126 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6127 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6128 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6129 			tdata->key.data, tdata->key.len,
6130 			tdata->auth_iv.len, tdata->digest.len,
6131 			tdata->cipher_iv.len);
6132 
6133 	if (retval != 0)
6134 		return retval;
6135 
6136 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6137 	if (op_mode == OUT_OF_PLACE)
6138 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6139 
6140 	/* clear mbuf payload */
6141 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6142 		rte_pktmbuf_tailroom(ut_params->ibuf));
6143 	if (op_mode == OUT_OF_PLACE)
6144 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6145 			rte_pktmbuf_tailroom(ut_params->obuf));
6146 
6147 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6148 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6149 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6150 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6151 
6152 	if (verify) {
6153 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6154 					ciphertext_pad_len);
6155 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6156 		if (op_mode == OUT_OF_PLACE)
6157 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6158 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6159 			ciphertext_len);
6160 	} else {
6161 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6162 					plaintext_pad_len);
6163 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6164 		if (op_mode == OUT_OF_PLACE)
6165 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6166 		debug_hexdump(stdout, "plaintext:", plaintext,
6167 			plaintext_len);
6168 	}
6169 
6170 	/* Create ZUC operation */
6171 	retval = create_wireless_algo_auth_cipher_operation(
6172 		tdata->digest.data, tdata->digest.len,
6173 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6174 		tdata->auth_iv.data, tdata->auth_iv.len,
6175 		(tdata->digest.offset_bytes == 0 ?
6176 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6177 			: tdata->digest.offset_bytes),
6178 		tdata->validCipherLenInBits.len,
6179 		tdata->validCipherOffsetInBits.len,
6180 		tdata->validAuthLenInBits.len,
6181 		0,
6182 		op_mode, 0, verify);
6183 
6184 	if (retval < 0)
6185 		return retval;
6186 
6187 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6188 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6189 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6190 	else
6191 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6192 			ut_params->op);
6193 
6194 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6195 
6196 	ut_params->obuf = (op_mode == IN_PLACE ?
6197 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6198 
6199 
6200 	if (verify) {
6201 		if (ut_params->obuf)
6202 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6203 							uint8_t *);
6204 		else
6205 			plaintext = ciphertext;
6206 
6207 		debug_hexdump(stdout, "plaintext:", plaintext,
6208 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6209 		debug_hexdump(stdout, "plaintext expected:",
6210 			tdata->plaintext.data,
6211 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6212 	} else {
6213 		if (ut_params->obuf)
6214 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6215 							uint8_t *);
6216 		else
6217 			ciphertext = plaintext;
6218 
6219 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6220 			ciphertext_len);
6221 		debug_hexdump(stdout, "ciphertext expected:",
6222 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6223 
6224 		ut_params->digest = rte_pktmbuf_mtod(
6225 			ut_params->obuf, uint8_t *) +
6226 			(tdata->digest.offset_bytes == 0 ?
6227 			plaintext_pad_len : tdata->digest.offset_bytes);
6228 
6229 		debug_hexdump(stdout, "digest:", ut_params->digest,
6230 			tdata->digest.len);
6231 		debug_hexdump(stdout, "digest expected:",
6232 			tdata->digest.data, tdata->digest.len);
6233 	}
6234 
6235 	/* Validate obuf */
6236 	if (verify) {
6237 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6238 			plaintext,
6239 			tdata->plaintext.data,
6240 			tdata->plaintext.len >> 3,
6241 			"ZUC Plaintext data not as expected");
6242 	} else {
6243 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6244 			ciphertext,
6245 			tdata->ciphertext.data,
6246 			tdata->ciphertext.len >> 3,
6247 			"ZUC Ciphertext data not as expected");
6248 
6249 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6250 			ut_params->digest,
6251 			tdata->digest.data,
6252 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6253 			"ZUC Generated auth tag not as expected");
6254 	}
6255 	return 0;
6256 }
6257 
6258 static int
6259 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
6260 	uint8_t op_mode, uint8_t verify)
6261 {
6262 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6263 	struct crypto_unittest_params *ut_params = &unittest_params;
6264 
6265 	int retval;
6266 
6267 	const uint8_t *plaintext = NULL;
6268 	const uint8_t *ciphertext = NULL;
6269 	const uint8_t *digest = NULL;
6270 	unsigned int plaintext_pad_len;
6271 	unsigned int plaintext_len;
6272 	unsigned int ciphertext_pad_len;
6273 	unsigned int ciphertext_len;
6274 	uint8_t buffer[10000];
6275 	uint8_t digest_buffer[10000];
6276 
6277 	struct rte_cryptodev_info dev_info;
6278 	struct rte_cryptodev_sym_capability_idx cap_idx;
6279 
6280 	/* Check if device supports ZUC EIA3 */
6281 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6282 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
6283 
6284 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
6285 			&cap_idx) == NULL)
6286 		return TEST_SKIPPED;
6287 
6288 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6289 
6290 	uint64_t feat_flags = dev_info.feature_flags;
6291 
6292 	if (op_mode == IN_PLACE) {
6293 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6294 			printf("Device doesn't support in-place scatter-gather "
6295 					"in both input and output mbufs.\n");
6296 			return TEST_SKIPPED;
6297 		}
6298 
6299 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
6300 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
6301 			printf("Device doesn't support RAW data-path APIs.\n");
6302 			return TEST_SKIPPED;
6303 		}
6304 	} else {
6305 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6306 			return TEST_SKIPPED;
6307 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6308 			printf("Device doesn't support out-of-place scatter-gather "
6309 					"in both input and output mbufs.\n");
6310 			return TEST_SKIPPED;
6311 		}
6312 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6313 			printf("Device doesn't support digest encrypted.\n");
6314 			return TEST_SKIPPED;
6315 		}
6316 	}
6317 
6318 	/* Create ZUC session */
6319 	retval = create_wireless_algo_auth_cipher_session(
6320 			ts_params->valid_devs[0],
6321 			(verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6322 					: RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6323 			(verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6324 					: RTE_CRYPTO_AUTH_OP_GENERATE),
6325 			RTE_CRYPTO_AUTH_ZUC_EIA3,
6326 			RTE_CRYPTO_CIPHER_ZUC_EEA3,
6327 			tdata->key.data, tdata->key.len,
6328 			tdata->auth_iv.len, tdata->digest.len,
6329 			tdata->cipher_iv.len);
6330 
6331 	if (retval != 0)
6332 		return retval;
6333 
6334 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
6335 	plaintext_len = ceil_byte_length(tdata->plaintext.len);
6336 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6337 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6338 
6339 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6340 			plaintext_pad_len, 15, 0);
6341 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6342 			"Failed to allocate input buffer in mempool");
6343 
6344 	if (op_mode == OUT_OF_PLACE) {
6345 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6346 				plaintext_pad_len, 15, 0);
6347 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
6348 				"Failed to allocate output buffer in mempool");
6349 	}
6350 
6351 	if (verify) {
6352 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6353 			tdata->ciphertext.data);
6354 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6355 					ciphertext_len, buffer);
6356 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6357 			ciphertext_len);
6358 	} else {
6359 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6360 			tdata->plaintext.data);
6361 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6362 					plaintext_len, buffer);
6363 		debug_hexdump(stdout, "plaintext:", plaintext,
6364 			plaintext_len);
6365 	}
6366 	memset(buffer, 0, sizeof(buffer));
6367 
6368 	/* Create ZUC operation */
6369 	retval = create_wireless_algo_auth_cipher_operation(
6370 		tdata->digest.data, tdata->digest.len,
6371 		tdata->cipher_iv.data, tdata->cipher_iv.len,
6372 		NULL, 0,
6373 		(tdata->digest.offset_bytes == 0 ?
6374 		(verify ? ciphertext_pad_len : plaintext_pad_len)
6375 			: tdata->digest.offset_bytes),
6376 		tdata->validCipherLenInBits.len,
6377 		tdata->validCipherOffsetInBits.len,
6378 		tdata->validAuthLenInBits.len,
6379 		0,
6380 		op_mode, 1, verify);
6381 
6382 	if (retval < 0)
6383 		return retval;
6384 
6385 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6386 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
6387 				ut_params->op, 1, 1, 1, tdata->cipher_iv.len);
6388 	else
6389 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6390 			ut_params->op);
6391 
6392 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6393 
6394 	ut_params->obuf = (op_mode == IN_PLACE ?
6395 		ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6396 
6397 	if (verify) {
6398 		if (ut_params->obuf)
6399 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6400 					plaintext_len, buffer);
6401 		else
6402 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6403 					plaintext_len, buffer);
6404 
6405 		debug_hexdump(stdout, "plaintext:", plaintext,
6406 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6407 		debug_hexdump(stdout, "plaintext expected:",
6408 			tdata->plaintext.data,
6409 			(tdata->plaintext.len >> 3) - tdata->digest.len);
6410 	} else {
6411 		if (ut_params->obuf)
6412 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6413 					ciphertext_len, buffer);
6414 		else
6415 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6416 					ciphertext_len, buffer);
6417 
6418 		debug_hexdump(stdout, "ciphertext:", ciphertext,
6419 			ciphertext_len);
6420 		debug_hexdump(stdout, "ciphertext expected:",
6421 			tdata->ciphertext.data, tdata->ciphertext.len >> 3);
6422 
6423 		if (ut_params->obuf)
6424 			digest = rte_pktmbuf_read(ut_params->obuf,
6425 				(tdata->digest.offset_bytes == 0 ?
6426 				plaintext_pad_len : tdata->digest.offset_bytes),
6427 				tdata->digest.len, digest_buffer);
6428 		else
6429 			digest = rte_pktmbuf_read(ut_params->ibuf,
6430 				(tdata->digest.offset_bytes == 0 ?
6431 				plaintext_pad_len : tdata->digest.offset_bytes),
6432 				tdata->digest.len, digest_buffer);
6433 
6434 		debug_hexdump(stdout, "digest:", digest,
6435 			tdata->digest.len);
6436 		debug_hexdump(stdout, "digest expected:",
6437 			tdata->digest.data, tdata->digest.len);
6438 	}
6439 
6440 	/* Validate obuf */
6441 	if (verify) {
6442 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6443 			plaintext,
6444 			tdata->plaintext.data,
6445 			tdata->plaintext.len >> 3,
6446 			"ZUC Plaintext data not as expected");
6447 	} else {
6448 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6449 			ciphertext,
6450 			tdata->ciphertext.data,
6451 			tdata->validDataLenInBits.len,
6452 			"ZUC Ciphertext data not as expected");
6453 
6454 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
6455 			digest,
6456 			tdata->digest.data,
6457 			DIGEST_BYTE_LENGTH_KASUMI_F9,
6458 			"ZUC Generated auth tag not as expected");
6459 	}
6460 	return 0;
6461 }
6462 
6463 static int
6464 test_kasumi_encryption_test_case_1(void)
6465 {
6466 	return test_kasumi_encryption(&kasumi_test_case_1);
6467 }
6468 
6469 static int
6470 test_kasumi_encryption_test_case_1_sgl(void)
6471 {
6472 	return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6473 }
6474 
6475 static int
6476 test_kasumi_encryption_test_case_1_oop(void)
6477 {
6478 	return test_kasumi_encryption_oop(&kasumi_test_case_1);
6479 }
6480 
6481 static int
6482 test_kasumi_encryption_test_case_1_oop_sgl(void)
6483 {
6484 	return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6485 }
6486 
6487 static int
6488 test_kasumi_encryption_test_case_2(void)
6489 {
6490 	return test_kasumi_encryption(&kasumi_test_case_2);
6491 }
6492 
6493 static int
6494 test_kasumi_encryption_test_case_3(void)
6495 {
6496 	return test_kasumi_encryption(&kasumi_test_case_3);
6497 }
6498 
6499 static int
6500 test_kasumi_encryption_test_case_4(void)
6501 {
6502 	return test_kasumi_encryption(&kasumi_test_case_4);
6503 }
6504 
6505 static int
6506 test_kasumi_encryption_test_case_5(void)
6507 {
6508 	return test_kasumi_encryption(&kasumi_test_case_5);
6509 }
6510 
6511 static int
6512 test_kasumi_decryption_test_case_1(void)
6513 {
6514 	return test_kasumi_decryption(&kasumi_test_case_1);
6515 }
6516 
6517 static int
6518 test_kasumi_decryption_test_case_1_oop(void)
6519 {
6520 	return test_kasumi_decryption_oop(&kasumi_test_case_1);
6521 }
6522 
6523 static int
6524 test_kasumi_decryption_test_case_2(void)
6525 {
6526 	return test_kasumi_decryption(&kasumi_test_case_2);
6527 }
6528 
6529 static int
6530 test_kasumi_decryption_test_case_3(void)
6531 {
6532 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6533 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6534 		return TEST_SKIPPED;
6535 	return test_kasumi_decryption(&kasumi_test_case_3);
6536 }
6537 
6538 static int
6539 test_kasumi_decryption_test_case_4(void)
6540 {
6541 	return test_kasumi_decryption(&kasumi_test_case_4);
6542 }
6543 
6544 static int
6545 test_kasumi_decryption_test_case_5(void)
6546 {
6547 	return test_kasumi_decryption(&kasumi_test_case_5);
6548 }
6549 static int
6550 test_snow3g_encryption_test_case_1(void)
6551 {
6552 	return test_snow3g_encryption(&snow3g_test_case_1);
6553 }
6554 
6555 static int
6556 test_snow3g_encryption_test_case_1_oop(void)
6557 {
6558 	return test_snow3g_encryption_oop(&snow3g_test_case_1);
6559 }
6560 
6561 static int
6562 test_snow3g_encryption_test_case_1_oop_sgl(void)
6563 {
6564 	return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6565 }
6566 
6567 
6568 static int
6569 test_snow3g_encryption_test_case_1_offset_oop(void)
6570 {
6571 	return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6572 }
6573 
6574 static int
6575 test_snow3g_encryption_test_case_2(void)
6576 {
6577 	return test_snow3g_encryption(&snow3g_test_case_2);
6578 }
6579 
6580 static int
6581 test_snow3g_encryption_test_case_3(void)
6582 {
6583 	return test_snow3g_encryption(&snow3g_test_case_3);
6584 }
6585 
6586 static int
6587 test_snow3g_encryption_test_case_4(void)
6588 {
6589 	return test_snow3g_encryption(&snow3g_test_case_4);
6590 }
6591 
6592 static int
6593 test_snow3g_encryption_test_case_5(void)
6594 {
6595 	return test_snow3g_encryption(&snow3g_test_case_5);
6596 }
6597 
6598 static int
6599 test_snow3g_decryption_test_case_1(void)
6600 {
6601 	return test_snow3g_decryption(&snow3g_test_case_1);
6602 }
6603 
6604 static int
6605 test_snow3g_decryption_test_case_1_oop(void)
6606 {
6607 	return test_snow3g_decryption_oop(&snow3g_test_case_1);
6608 }
6609 
6610 static int
6611 test_snow3g_decryption_test_case_2(void)
6612 {
6613 	return test_snow3g_decryption(&snow3g_test_case_2);
6614 }
6615 
6616 static int
6617 test_snow3g_decryption_test_case_3(void)
6618 {
6619 	return test_snow3g_decryption(&snow3g_test_case_3);
6620 }
6621 
6622 static int
6623 test_snow3g_decryption_test_case_4(void)
6624 {
6625 	return test_snow3g_decryption(&snow3g_test_case_4);
6626 }
6627 
6628 static int
6629 test_snow3g_decryption_test_case_5(void)
6630 {
6631 	return test_snow3g_decryption(&snow3g_test_case_5);
6632 }
6633 
6634 /*
6635  * Function prepares snow3g_hash_test_data from snow3g_test_data.
6636  * Pattern digest from snow3g_test_data must be allocated as
6637  * 4 last bytes in plaintext.
6638  */
6639 static void
6640 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6641 		struct snow3g_hash_test_data *output)
6642 {
6643 	if ((pattern != NULL) && (output != NULL)) {
6644 		output->key.len = pattern->key.len;
6645 
6646 		memcpy(output->key.data,
6647 		pattern->key.data, pattern->key.len);
6648 
6649 		output->auth_iv.len = pattern->auth_iv.len;
6650 
6651 		memcpy(output->auth_iv.data,
6652 		pattern->auth_iv.data, pattern->auth_iv.len);
6653 
6654 		output->plaintext.len = pattern->plaintext.len;
6655 
6656 		memcpy(output->plaintext.data,
6657 		pattern->plaintext.data, pattern->plaintext.len >> 3);
6658 
6659 		output->digest.len = pattern->digest.len;
6660 
6661 		memcpy(output->digest.data,
6662 		&pattern->plaintext.data[pattern->digest.offset_bytes],
6663 		pattern->digest.len);
6664 
6665 		output->validAuthLenInBits.len =
6666 		pattern->validAuthLenInBits.len;
6667 	}
6668 }
6669 
6670 /*
6671  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6672  */
6673 static int
6674 test_snow3g_decryption_with_digest_test_case_1(void)
6675 {
6676 	struct snow3g_hash_test_data snow3g_hash_data;
6677 	struct rte_cryptodev_info dev_info;
6678 	struct crypto_testsuite_params *ts_params = &testsuite_params;
6679 
6680 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6681 	uint64_t feat_flags = dev_info.feature_flags;
6682 
6683 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6684 		printf("Device doesn't support encrypted digest operations.\n");
6685 		return TEST_SKIPPED;
6686 	}
6687 
6688 	/*
6689 	 * Function prepare data for hash veryfication test case.
6690 	 * Digest is allocated in 4 last bytes in plaintext, pattern.
6691 	 */
6692 	snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6693 
6694 	return test_snow3g_decryption(&snow3g_test_case_7) &
6695 			test_snow3g_authentication_verify(&snow3g_hash_data);
6696 }
6697 
6698 static int
6699 test_snow3g_cipher_auth_test_case_1(void)
6700 {
6701 	return test_snow3g_cipher_auth(&snow3g_test_case_3);
6702 }
6703 
6704 static int
6705 test_snow3g_auth_cipher_test_case_1(void)
6706 {
6707 	return test_snow3g_auth_cipher(
6708 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6709 }
6710 
6711 static int
6712 test_snow3g_auth_cipher_test_case_2(void)
6713 {
6714 	return test_snow3g_auth_cipher(
6715 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6716 }
6717 
6718 static int
6719 test_snow3g_auth_cipher_test_case_2_oop(void)
6720 {
6721 	return test_snow3g_auth_cipher(
6722 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6723 }
6724 
6725 static int
6726 test_snow3g_auth_cipher_part_digest_enc(void)
6727 {
6728 	return test_snow3g_auth_cipher(
6729 		&snow3g_auth_cipher_partial_digest_encryption,
6730 			IN_PLACE, 0);
6731 }
6732 
6733 static int
6734 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6735 {
6736 	return test_snow3g_auth_cipher(
6737 		&snow3g_auth_cipher_partial_digest_encryption,
6738 			OUT_OF_PLACE, 0);
6739 }
6740 
6741 static int
6742 test_snow3g_auth_cipher_test_case_3_sgl(void)
6743 {
6744 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6745 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6746 		return TEST_SKIPPED;
6747 	return test_snow3g_auth_cipher_sgl(
6748 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6749 }
6750 
6751 static int
6752 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6753 {
6754 	return test_snow3g_auth_cipher_sgl(
6755 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6756 }
6757 
6758 static int
6759 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6760 {
6761 	/* rte_crypto_mbuf_to_vec does not support incomplete mbuf build */
6762 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
6763 		return TEST_SKIPPED;
6764 	return test_snow3g_auth_cipher_sgl(
6765 		&snow3g_auth_cipher_partial_digest_encryption,
6766 			IN_PLACE, 0);
6767 }
6768 
6769 static int
6770 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6771 {
6772 	return test_snow3g_auth_cipher_sgl(
6773 		&snow3g_auth_cipher_partial_digest_encryption,
6774 			OUT_OF_PLACE, 0);
6775 }
6776 
6777 static int
6778 test_snow3g_auth_cipher_verify_test_case_1(void)
6779 {
6780 	return test_snow3g_auth_cipher(
6781 		&snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6782 }
6783 
6784 static int
6785 test_snow3g_auth_cipher_verify_test_case_2(void)
6786 {
6787 	return test_snow3g_auth_cipher(
6788 		&snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6789 }
6790 
6791 static int
6792 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6793 {
6794 	return test_snow3g_auth_cipher(
6795 		&snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6796 }
6797 
6798 static int
6799 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6800 {
6801 	return test_snow3g_auth_cipher(
6802 		&snow3g_auth_cipher_partial_digest_encryption,
6803 			IN_PLACE, 1);
6804 }
6805 
6806 static int
6807 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6808 {
6809 	return test_snow3g_auth_cipher(
6810 		&snow3g_auth_cipher_partial_digest_encryption,
6811 			OUT_OF_PLACE, 1);
6812 }
6813 
6814 static int
6815 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6816 {
6817 	return test_snow3g_auth_cipher_sgl(
6818 		&snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6819 }
6820 
6821 static int
6822 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6823 {
6824 	return test_snow3g_auth_cipher_sgl(
6825 		&snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6826 }
6827 
6828 static int
6829 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6830 {
6831 	return test_snow3g_auth_cipher_sgl(
6832 		&snow3g_auth_cipher_partial_digest_encryption,
6833 			IN_PLACE, 1);
6834 }
6835 
6836 static int
6837 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6838 {
6839 	return test_snow3g_auth_cipher_sgl(
6840 		&snow3g_auth_cipher_partial_digest_encryption,
6841 			OUT_OF_PLACE, 1);
6842 }
6843 
6844 static int
6845 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6846 {
6847 	return test_snow3g_auth_cipher(
6848 		&snow3g_test_case_7, IN_PLACE, 0);
6849 }
6850 
6851 static int
6852 test_kasumi_auth_cipher_test_case_1(void)
6853 {
6854 	return test_kasumi_auth_cipher(
6855 		&kasumi_test_case_3, IN_PLACE, 0);
6856 }
6857 
6858 static int
6859 test_kasumi_auth_cipher_test_case_2(void)
6860 {
6861 	return test_kasumi_auth_cipher(
6862 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6863 }
6864 
6865 static int
6866 test_kasumi_auth_cipher_test_case_2_oop(void)
6867 {
6868 	return test_kasumi_auth_cipher(
6869 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6870 }
6871 
6872 static int
6873 test_kasumi_auth_cipher_test_case_2_sgl(void)
6874 {
6875 	return test_kasumi_auth_cipher_sgl(
6876 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6877 }
6878 
6879 static int
6880 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6881 {
6882 	return test_kasumi_auth_cipher_sgl(
6883 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6884 }
6885 
6886 static int
6887 test_kasumi_auth_cipher_verify_test_case_1(void)
6888 {
6889 	return test_kasumi_auth_cipher(
6890 		&kasumi_test_case_3, IN_PLACE, 1);
6891 }
6892 
6893 static int
6894 test_kasumi_auth_cipher_verify_test_case_2(void)
6895 {
6896 	return test_kasumi_auth_cipher(
6897 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6898 }
6899 
6900 static int
6901 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6902 {
6903 	return test_kasumi_auth_cipher(
6904 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6905 }
6906 
6907 static int
6908 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6909 {
6910 	return test_kasumi_auth_cipher_sgl(
6911 		&kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6912 }
6913 
6914 static int
6915 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6916 {
6917 	return test_kasumi_auth_cipher_sgl(
6918 		&kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6919 }
6920 
6921 static int
6922 test_kasumi_cipher_auth_test_case_1(void)
6923 {
6924 	return test_kasumi_cipher_auth(&kasumi_test_case_6);
6925 }
6926 
6927 static int
6928 test_zuc_encryption_test_case_1(void)
6929 {
6930 	return test_zuc_encryption(&zuc_test_case_cipher_193b);
6931 }
6932 
6933 static int
6934 test_zuc_encryption_test_case_2(void)
6935 {
6936 	return test_zuc_encryption(&zuc_test_case_cipher_800b);
6937 }
6938 
6939 static int
6940 test_zuc_encryption_test_case_3(void)
6941 {
6942 	return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6943 }
6944 
6945 static int
6946 test_zuc_encryption_test_case_4(void)
6947 {
6948 	return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6949 }
6950 
6951 static int
6952 test_zuc_encryption_test_case_5(void)
6953 {
6954 	return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6955 }
6956 
6957 static int
6958 test_zuc_encryption_test_case_6_sgl(void)
6959 {
6960 	return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6961 }
6962 
6963 static int
6964 test_zuc_hash_generate_test_case_1(void)
6965 {
6966 	return test_zuc_authentication(&zuc_test_case_auth_1b);
6967 }
6968 
6969 static int
6970 test_zuc_hash_generate_test_case_2(void)
6971 {
6972 	return test_zuc_authentication(&zuc_test_case_auth_90b);
6973 }
6974 
6975 static int
6976 test_zuc_hash_generate_test_case_3(void)
6977 {
6978 	return test_zuc_authentication(&zuc_test_case_auth_577b);
6979 }
6980 
6981 static int
6982 test_zuc_hash_generate_test_case_4(void)
6983 {
6984 	return test_zuc_authentication(&zuc_test_case_auth_2079b);
6985 }
6986 
6987 static int
6988 test_zuc_hash_generate_test_case_5(void)
6989 {
6990 	return test_zuc_authentication(&zuc_test_auth_5670b);
6991 }
6992 
6993 static int
6994 test_zuc_hash_generate_test_case_6(void)
6995 {
6996 	return test_zuc_authentication(&zuc_test_case_auth_128b);
6997 }
6998 
6999 static int
7000 test_zuc_hash_generate_test_case_7(void)
7001 {
7002 	return test_zuc_authentication(&zuc_test_case_auth_2080b);
7003 }
7004 
7005 static int
7006 test_zuc_hash_generate_test_case_8(void)
7007 {
7008 	return test_zuc_authentication(&zuc_test_case_auth_584b);
7009 }
7010 
7011 static int
7012 test_zuc_cipher_auth_test_case_1(void)
7013 {
7014 	return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
7015 }
7016 
7017 static int
7018 test_zuc_cipher_auth_test_case_2(void)
7019 {
7020 	return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
7021 }
7022 
7023 static int
7024 test_zuc_auth_cipher_test_case_1(void)
7025 {
7026 	return test_zuc_auth_cipher(
7027 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7028 }
7029 
7030 static int
7031 test_zuc_auth_cipher_test_case_1_oop(void)
7032 {
7033 	return test_zuc_auth_cipher(
7034 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7035 }
7036 
7037 static int
7038 test_zuc_auth_cipher_test_case_1_sgl(void)
7039 {
7040 	return test_zuc_auth_cipher_sgl(
7041 		&zuc_auth_cipher_test_case_1, IN_PLACE, 0);
7042 }
7043 
7044 static int
7045 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
7046 {
7047 	return test_zuc_auth_cipher_sgl(
7048 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
7049 }
7050 
7051 static int
7052 test_zuc_auth_cipher_verify_test_case_1(void)
7053 {
7054 	return test_zuc_auth_cipher(
7055 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7056 }
7057 
7058 static int
7059 test_zuc_auth_cipher_verify_test_case_1_oop(void)
7060 {
7061 	return test_zuc_auth_cipher(
7062 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7063 }
7064 
7065 static int
7066 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
7067 {
7068 	return test_zuc_auth_cipher_sgl(
7069 		&zuc_auth_cipher_test_case_1, IN_PLACE, 1);
7070 }
7071 
7072 static int
7073 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
7074 {
7075 	return test_zuc_auth_cipher_sgl(
7076 		&zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
7077 }
7078 
7079 static int
7080 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
7081 {
7082 	uint8_t dev_id = testsuite_params.valid_devs[0];
7083 
7084 	struct rte_cryptodev_sym_capability_idx cap_idx;
7085 
7086 	/* Check if device supports particular cipher algorithm */
7087 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7088 	cap_idx.algo.cipher = tdata->cipher_algo;
7089 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7090 		return TEST_SKIPPED;
7091 
7092 	/* Check if device supports particular hash algorithm */
7093 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7094 	cap_idx.algo.auth = tdata->auth_algo;
7095 	if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
7096 		return TEST_SKIPPED;
7097 
7098 	return 0;
7099 }
7100 
7101 static int
7102 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
7103 	uint8_t op_mode, uint8_t verify)
7104 {
7105 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7106 	struct crypto_unittest_params *ut_params = &unittest_params;
7107 
7108 	int retval;
7109 
7110 	uint8_t *plaintext = NULL, *ciphertext = NULL;
7111 	unsigned int plaintext_pad_len;
7112 	unsigned int plaintext_len;
7113 	unsigned int ciphertext_pad_len;
7114 	unsigned int ciphertext_len;
7115 
7116 	struct rte_cryptodev_info dev_info;
7117 	struct rte_crypto_op *op;
7118 
7119 	/* Check if device supports particular algorithms separately */
7120 	if (test_mixed_check_if_unsupported(tdata))
7121 		return TEST_SKIPPED;
7122 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7123 		return TEST_SKIPPED;
7124 
7125 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7126 
7127 	uint64_t feat_flags = dev_info.feature_flags;
7128 
7129 	if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7130 		printf("Device doesn't support digest encrypted.\n");
7131 		return TEST_SKIPPED;
7132 	}
7133 
7134 	/* Create the session */
7135 	if (verify)
7136 		retval = create_wireless_algo_cipher_auth_session(
7137 				ts_params->valid_devs[0],
7138 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
7139 				RTE_CRYPTO_AUTH_OP_VERIFY,
7140 				tdata->auth_algo,
7141 				tdata->cipher_algo,
7142 				tdata->auth_key.data, tdata->auth_key.len,
7143 				tdata->auth_iv.len, tdata->digest_enc.len,
7144 				tdata->cipher_iv.len);
7145 	else
7146 		retval = create_wireless_algo_auth_cipher_session(
7147 				ts_params->valid_devs[0],
7148 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7149 				RTE_CRYPTO_AUTH_OP_GENERATE,
7150 				tdata->auth_algo,
7151 				tdata->cipher_algo,
7152 				tdata->auth_key.data, tdata->auth_key.len,
7153 				tdata->auth_iv.len, tdata->digest_enc.len,
7154 				tdata->cipher_iv.len);
7155 	if (retval != 0)
7156 		return retval;
7157 
7158 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7159 	if (op_mode == OUT_OF_PLACE)
7160 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7161 
7162 	/* clear mbuf payload */
7163 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7164 		rte_pktmbuf_tailroom(ut_params->ibuf));
7165 	if (op_mode == OUT_OF_PLACE) {
7166 
7167 		memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
7168 				rte_pktmbuf_tailroom(ut_params->obuf));
7169 	}
7170 
7171 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7172 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7173 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7174 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7175 
7176 	if (verify) {
7177 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7178 				ciphertext_pad_len);
7179 		memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
7180 		if (op_mode == OUT_OF_PLACE)
7181 			rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
7182 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7183 				ciphertext_len);
7184 	} else {
7185 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7186 				plaintext_pad_len);
7187 		memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7188 		if (op_mode == OUT_OF_PLACE)
7189 			rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
7190 		debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
7191 	}
7192 
7193 	/* Create the operation */
7194 	retval = create_wireless_algo_auth_cipher_operation(
7195 			tdata->digest_enc.data, tdata->digest_enc.len,
7196 			tdata->cipher_iv.data, tdata->cipher_iv.len,
7197 			tdata->auth_iv.data, tdata->auth_iv.len,
7198 			(tdata->digest_enc.offset == 0 ?
7199 				plaintext_pad_len
7200 				: tdata->digest_enc.offset),
7201 			tdata->validCipherLen.len_bits,
7202 			tdata->cipher.offset_bits,
7203 			tdata->validAuthLen.len_bits,
7204 			tdata->auth.offset_bits,
7205 			op_mode, 0, verify);
7206 
7207 	if (retval < 0)
7208 		return retval;
7209 
7210 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7211 
7212 	/* Check if the op failed because the device doesn't */
7213 	/* support this particular combination of algorithms */
7214 	if (op == NULL && ut_params->op->status ==
7215 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7216 		printf("Device doesn't support this mixed combination. "
7217 				"Test Skipped.\n");
7218 		return TEST_SKIPPED;
7219 	}
7220 	ut_params->op = op;
7221 
7222 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7223 
7224 	ut_params->obuf = (op_mode == IN_PLACE ?
7225 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7226 
7227 	if (verify) {
7228 		if (ut_params->obuf)
7229 			plaintext = rte_pktmbuf_mtod(ut_params->obuf,
7230 							uint8_t *);
7231 		else
7232 			plaintext = ciphertext +
7233 					(tdata->cipher.offset_bits >> 3);
7234 
7235 		debug_hexdump(stdout, "plaintext:", plaintext,
7236 				tdata->plaintext.len_bits >> 3);
7237 		debug_hexdump(stdout, "plaintext expected:",
7238 				tdata->plaintext.data,
7239 				tdata->plaintext.len_bits >> 3);
7240 	} else {
7241 		if (ut_params->obuf)
7242 			ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
7243 					uint8_t *);
7244 		else
7245 			ciphertext = plaintext;
7246 
7247 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7248 				ciphertext_len);
7249 		debug_hexdump(stdout, "ciphertext expected:",
7250 				tdata->ciphertext.data,
7251 				tdata->ciphertext.len_bits >> 3);
7252 
7253 		ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
7254 				+ (tdata->digest_enc.offset == 0 ?
7255 		plaintext_pad_len : tdata->digest_enc.offset);
7256 
7257 		debug_hexdump(stdout, "digest:", ut_params->digest,
7258 				tdata->digest_enc.len);
7259 		debug_hexdump(stdout, "digest expected:",
7260 				tdata->digest_enc.data,
7261 				tdata->digest_enc.len);
7262 	}
7263 
7264 	/* Validate obuf */
7265 	if (verify) {
7266 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7267 				plaintext,
7268 				tdata->plaintext.data,
7269 				tdata->plaintext.len_bits >> 3,
7270 				"Plaintext data not as expected");
7271 	} else {
7272 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7273 				ciphertext,
7274 				tdata->ciphertext.data,
7275 				tdata->validDataLen.len_bits,
7276 				"Ciphertext data not as expected");
7277 
7278 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7279 				ut_params->digest,
7280 				tdata->digest_enc.data,
7281 				DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
7282 				"Generated auth tag not as expected");
7283 	}
7284 
7285 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7286 			"crypto op processing failed");
7287 
7288 	return 0;
7289 }
7290 
7291 static int
7292 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
7293 	uint8_t op_mode, uint8_t verify)
7294 {
7295 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7296 	struct crypto_unittest_params *ut_params = &unittest_params;
7297 
7298 	int retval;
7299 
7300 	const uint8_t *plaintext = NULL;
7301 	const uint8_t *ciphertext = NULL;
7302 	const uint8_t *digest = NULL;
7303 	unsigned int plaintext_pad_len;
7304 	unsigned int plaintext_len;
7305 	unsigned int ciphertext_pad_len;
7306 	unsigned int ciphertext_len;
7307 	uint8_t buffer[10000];
7308 	uint8_t digest_buffer[10000];
7309 
7310 	struct rte_cryptodev_info dev_info;
7311 	struct rte_crypto_op *op;
7312 
7313 	/* Check if device supports particular algorithms */
7314 	if (test_mixed_check_if_unsupported(tdata))
7315 		return TEST_SKIPPED;
7316 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
7317 		return TEST_SKIPPED;
7318 
7319 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7320 
7321 	uint64_t feat_flags = dev_info.feature_flags;
7322 
7323 	if (op_mode == IN_PLACE) {
7324 		if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
7325 			printf("Device doesn't support in-place scatter-gather "
7326 					"in both input and output mbufs.\n");
7327 			return TEST_SKIPPED;
7328 		}
7329 	} else {
7330 		if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
7331 			printf("Device doesn't support out-of-place scatter-gather "
7332 					"in both input and output mbufs.\n");
7333 			return TEST_SKIPPED;
7334 		}
7335 		if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
7336 			printf("Device doesn't support digest encrypted.\n");
7337 			return TEST_SKIPPED;
7338 		}
7339 	}
7340 
7341 	/* Create the session */
7342 	if (verify)
7343 		retval = create_wireless_algo_cipher_auth_session(
7344 				ts_params->valid_devs[0],
7345 				RTE_CRYPTO_CIPHER_OP_DECRYPT,
7346 				RTE_CRYPTO_AUTH_OP_VERIFY,
7347 				tdata->auth_algo,
7348 				tdata->cipher_algo,
7349 				tdata->auth_key.data, tdata->auth_key.len,
7350 				tdata->auth_iv.len, tdata->digest_enc.len,
7351 				tdata->cipher_iv.len);
7352 	else
7353 		retval = create_wireless_algo_auth_cipher_session(
7354 				ts_params->valid_devs[0],
7355 				RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7356 				RTE_CRYPTO_AUTH_OP_GENERATE,
7357 				tdata->auth_algo,
7358 				tdata->cipher_algo,
7359 				tdata->auth_key.data, tdata->auth_key.len,
7360 				tdata->auth_iv.len, tdata->digest_enc.len,
7361 				tdata->cipher_iv.len);
7362 	if (retval != 0)
7363 		return retval;
7364 
7365 	ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
7366 	plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
7367 	ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
7368 	plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
7369 
7370 	ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
7371 			ciphertext_pad_len, 15, 0);
7372 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7373 			"Failed to allocate input buffer in mempool");
7374 
7375 	if (op_mode == OUT_OF_PLACE) {
7376 		ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
7377 				plaintext_pad_len, 15, 0);
7378 		TEST_ASSERT_NOT_NULL(ut_params->obuf,
7379 				"Failed to allocate output buffer in mempool");
7380 	}
7381 
7382 	if (verify) {
7383 		pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
7384 			tdata->ciphertext.data);
7385 		ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7386 					ciphertext_len, buffer);
7387 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7388 			ciphertext_len);
7389 	} else {
7390 		pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
7391 			tdata->plaintext.data);
7392 		plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7393 					plaintext_len, buffer);
7394 		debug_hexdump(stdout, "plaintext:", plaintext,
7395 			plaintext_len);
7396 	}
7397 	memset(buffer, 0, sizeof(buffer));
7398 
7399 	/* Create the operation */
7400 	retval = create_wireless_algo_auth_cipher_operation(
7401 			tdata->digest_enc.data, tdata->digest_enc.len,
7402 			tdata->cipher_iv.data, tdata->cipher_iv.len,
7403 			tdata->auth_iv.data, tdata->auth_iv.len,
7404 			(tdata->digest_enc.offset == 0 ?
7405 				plaintext_pad_len
7406 				: tdata->digest_enc.offset),
7407 			tdata->validCipherLen.len_bits,
7408 			tdata->cipher.offset_bits,
7409 			tdata->validAuthLen.len_bits,
7410 			tdata->auth.offset_bits,
7411 			op_mode, 1, verify);
7412 
7413 	if (retval < 0)
7414 		return retval;
7415 
7416 	op = process_crypto_request(ts_params->valid_devs[0], ut_params->op);
7417 
7418 	/* Check if the op failed because the device doesn't */
7419 	/* support this particular combination of algorithms */
7420 	if (op == NULL && ut_params->op->status ==
7421 			RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
7422 		printf("Device doesn't support this mixed combination. "
7423 				"Test Skipped.\n");
7424 		return TEST_SKIPPED;
7425 	}
7426 	ut_params->op = op;
7427 
7428 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
7429 
7430 	ut_params->obuf = (op_mode == IN_PLACE ?
7431 			ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
7432 
7433 	if (verify) {
7434 		if (ut_params->obuf)
7435 			plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
7436 					plaintext_len, buffer);
7437 		else
7438 			plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
7439 					plaintext_len, buffer);
7440 
7441 		debug_hexdump(stdout, "plaintext:", plaintext,
7442 				(tdata->plaintext.len_bits >> 3) -
7443 				tdata->digest_enc.len);
7444 		debug_hexdump(stdout, "plaintext expected:",
7445 				tdata->plaintext.data,
7446 				(tdata->plaintext.len_bits >> 3) -
7447 				tdata->digest_enc.len);
7448 	} else {
7449 		if (ut_params->obuf)
7450 			ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
7451 					ciphertext_len, buffer);
7452 		else
7453 			ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
7454 					ciphertext_len, buffer);
7455 
7456 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7457 			ciphertext_len);
7458 		debug_hexdump(stdout, "ciphertext expected:",
7459 			tdata->ciphertext.data,
7460 			tdata->ciphertext.len_bits >> 3);
7461 
7462 		if (ut_params->obuf)
7463 			digest = rte_pktmbuf_read(ut_params->obuf,
7464 					(tdata->digest_enc.offset == 0 ?
7465 						plaintext_pad_len :
7466 						tdata->digest_enc.offset),
7467 					tdata->digest_enc.len, digest_buffer);
7468 		else
7469 			digest = rte_pktmbuf_read(ut_params->ibuf,
7470 					(tdata->digest_enc.offset == 0 ?
7471 						plaintext_pad_len :
7472 						tdata->digest_enc.offset),
7473 					tdata->digest_enc.len, digest_buffer);
7474 
7475 		debug_hexdump(stdout, "digest:", digest,
7476 				tdata->digest_enc.len);
7477 		debug_hexdump(stdout, "digest expected:",
7478 				tdata->digest_enc.data, tdata->digest_enc.len);
7479 	}
7480 
7481 	/* Validate obuf */
7482 	if (verify) {
7483 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7484 				plaintext,
7485 				tdata->plaintext.data,
7486 				tdata->plaintext.len_bits >> 3,
7487 				"Plaintext data not as expected");
7488 	} else {
7489 		TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7490 				ciphertext,
7491 				tdata->ciphertext.data,
7492 				tdata->validDataLen.len_bits,
7493 				"Ciphertext data not as expected");
7494 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
7495 				digest,
7496 				tdata->digest_enc.data,
7497 				tdata->digest_enc.len,
7498 				"Generated auth tag not as expected");
7499 	}
7500 
7501 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7502 			"crypto op processing failed");
7503 
7504 	return 0;
7505 }
7506 
7507 /** AUTH AES CMAC + CIPHER AES CTR */
7508 
7509 static int
7510 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7511 {
7512 	return test_mixed_auth_cipher(
7513 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7514 }
7515 
7516 static int
7517 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7518 {
7519 	return test_mixed_auth_cipher(
7520 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7521 }
7522 
7523 static int
7524 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7525 {
7526 	return test_mixed_auth_cipher_sgl(
7527 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7528 }
7529 
7530 static int
7531 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7532 {
7533 	return test_mixed_auth_cipher_sgl(
7534 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7535 }
7536 
7537 static int
7538 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7539 {
7540 	return test_mixed_auth_cipher(
7541 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7542 }
7543 
7544 static int
7545 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7546 {
7547 	return test_mixed_auth_cipher(
7548 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7549 }
7550 
7551 static int
7552 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7553 {
7554 	return test_mixed_auth_cipher_sgl(
7555 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7556 }
7557 
7558 static int
7559 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7560 {
7561 	return test_mixed_auth_cipher_sgl(
7562 		&auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7563 }
7564 
7565 /** MIXED AUTH + CIPHER */
7566 
7567 static int
7568 test_auth_zuc_cipher_snow_test_case_1(void)
7569 {
7570 	return test_mixed_auth_cipher(
7571 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7572 }
7573 
7574 static int
7575 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7576 {
7577 	return test_mixed_auth_cipher(
7578 		&auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7579 }
7580 
7581 static int
7582 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7583 {
7584 	return test_mixed_auth_cipher(
7585 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7586 }
7587 
7588 static int
7589 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7590 {
7591 	return test_mixed_auth_cipher(
7592 		&auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7593 }
7594 
7595 static int
7596 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7597 {
7598 	return test_mixed_auth_cipher(
7599 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7600 }
7601 
7602 static int
7603 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7604 {
7605 	return test_mixed_auth_cipher(
7606 		&auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7607 }
7608 
7609 static int
7610 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7611 {
7612 	return test_mixed_auth_cipher(
7613 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7614 }
7615 
7616 static int
7617 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7618 {
7619 	return test_mixed_auth_cipher(
7620 		&auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7621 }
7622 
7623 static int
7624 test_auth_snow_cipher_zuc_test_case_1(void)
7625 {
7626 	return test_mixed_auth_cipher(
7627 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7628 }
7629 
7630 static int
7631 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7632 {
7633 	return test_mixed_auth_cipher(
7634 		&auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7635 }
7636 
7637 static int
7638 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7639 {
7640 	return test_mixed_auth_cipher(
7641 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7642 }
7643 
7644 static int
7645 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7646 {
7647 	return test_mixed_auth_cipher(
7648 		&auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7649 }
7650 
7651 static int
7652 test_auth_null_cipher_snow_test_case_1(void)
7653 {
7654 	return test_mixed_auth_cipher(
7655 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7656 }
7657 
7658 static int
7659 test_verify_auth_null_cipher_snow_test_case_1(void)
7660 {
7661 	return test_mixed_auth_cipher(
7662 		&auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7663 }
7664 
7665 static int
7666 test_auth_null_cipher_zuc_test_case_1(void)
7667 {
7668 	return test_mixed_auth_cipher(
7669 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7670 }
7671 
7672 static int
7673 test_verify_auth_null_cipher_zuc_test_case_1(void)
7674 {
7675 	return test_mixed_auth_cipher(
7676 		&auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7677 }
7678 
7679 static int
7680 test_auth_snow_cipher_null_test_case_1(void)
7681 {
7682 	return test_mixed_auth_cipher(
7683 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7684 }
7685 
7686 static int
7687 test_verify_auth_snow_cipher_null_test_case_1(void)
7688 {
7689 	return test_mixed_auth_cipher(
7690 		&auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7691 }
7692 
7693 static int
7694 test_auth_zuc_cipher_null_test_case_1(void)
7695 {
7696 	return test_mixed_auth_cipher(
7697 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7698 }
7699 
7700 static int
7701 test_verify_auth_zuc_cipher_null_test_case_1(void)
7702 {
7703 	return test_mixed_auth_cipher(
7704 		&auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7705 }
7706 
7707 static int
7708 test_auth_null_cipher_aes_ctr_test_case_1(void)
7709 {
7710 	return test_mixed_auth_cipher(
7711 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7712 }
7713 
7714 static int
7715 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7716 {
7717 	return test_mixed_auth_cipher(
7718 		&auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7719 }
7720 
7721 static int
7722 test_auth_aes_cmac_cipher_null_test_case_1(void)
7723 {
7724 	return test_mixed_auth_cipher(
7725 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7726 }
7727 
7728 static int
7729 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7730 {
7731 	return test_mixed_auth_cipher(
7732 		&auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7733 }
7734 
7735 /* ***** AEAD algorithm Tests ***** */
7736 
7737 static int
7738 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7739 		enum rte_crypto_aead_operation op,
7740 		const uint8_t *key, const uint8_t key_len,
7741 		const uint16_t aad_len, const uint8_t auth_len,
7742 		uint8_t iv_len)
7743 {
7744 	uint8_t aead_key[key_len];
7745 
7746 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7747 	struct crypto_unittest_params *ut_params = &unittest_params;
7748 
7749 	memcpy(aead_key, key, key_len);
7750 
7751 	/* Setup AEAD Parameters */
7752 	ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7753 	ut_params->aead_xform.next = NULL;
7754 	ut_params->aead_xform.aead.algo = algo;
7755 	ut_params->aead_xform.aead.op = op;
7756 	ut_params->aead_xform.aead.key.data = aead_key;
7757 	ut_params->aead_xform.aead.key.length = key_len;
7758 	ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7759 	ut_params->aead_xform.aead.iv.length = iv_len;
7760 	ut_params->aead_xform.aead.digest_length = auth_len;
7761 	ut_params->aead_xform.aead.aad_length = aad_len;
7762 
7763 	debug_hexdump(stdout, "key:", key, key_len);
7764 
7765 	/* Create Crypto session*/
7766 	ut_params->sess = rte_cryptodev_sym_session_create(
7767 			ts_params->session_mpool);
7768 
7769 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7770 			&ut_params->aead_xform,
7771 			ts_params->session_priv_mpool);
7772 
7773 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7774 
7775 	return 0;
7776 }
7777 
7778 static int
7779 create_aead_xform(struct rte_crypto_op *op,
7780 		enum rte_crypto_aead_algorithm algo,
7781 		enum rte_crypto_aead_operation aead_op,
7782 		uint8_t *key, const uint8_t key_len,
7783 		const uint8_t aad_len, const uint8_t auth_len,
7784 		uint8_t iv_len)
7785 {
7786 	TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7787 			"failed to allocate space for crypto transform");
7788 
7789 	struct rte_crypto_sym_op *sym_op = op->sym;
7790 
7791 	/* Setup AEAD Parameters */
7792 	sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7793 	sym_op->xform->next = NULL;
7794 	sym_op->xform->aead.algo = algo;
7795 	sym_op->xform->aead.op = aead_op;
7796 	sym_op->xform->aead.key.data = key;
7797 	sym_op->xform->aead.key.length = key_len;
7798 	sym_op->xform->aead.iv.offset = IV_OFFSET;
7799 	sym_op->xform->aead.iv.length = iv_len;
7800 	sym_op->xform->aead.digest_length = auth_len;
7801 	sym_op->xform->aead.aad_length = aad_len;
7802 
7803 	debug_hexdump(stdout, "key:", key, key_len);
7804 
7805 	return 0;
7806 }
7807 
7808 static int
7809 create_aead_operation(enum rte_crypto_aead_operation op,
7810 		const struct aead_test_data *tdata)
7811 {
7812 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7813 	struct crypto_unittest_params *ut_params = &unittest_params;
7814 
7815 	uint8_t *plaintext, *ciphertext;
7816 	unsigned int aad_pad_len, plaintext_pad_len;
7817 
7818 	/* Generate Crypto op data structure */
7819 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7820 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7821 	TEST_ASSERT_NOT_NULL(ut_params->op,
7822 			"Failed to allocate symmetric crypto operation struct");
7823 
7824 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7825 
7826 	/* Append aad data */
7827 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7828 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7829 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7830 				aad_pad_len);
7831 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7832 				"no room to append aad");
7833 
7834 		sym_op->aead.aad.phys_addr =
7835 				rte_pktmbuf_iova(ut_params->ibuf);
7836 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
7837 		memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7838 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7839 			tdata->aad.len);
7840 
7841 		/* Append IV at the end of the crypto operation*/
7842 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7843 				uint8_t *, IV_OFFSET);
7844 
7845 		/* Copy IV 1 byte after the IV pointer, according to the API */
7846 		rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7847 		debug_hexdump(stdout, "iv:", iv_ptr,
7848 			tdata->iv.len);
7849 	} else {
7850 		aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7851 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7852 				aad_pad_len);
7853 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7854 				"no room to append aad");
7855 
7856 		sym_op->aead.aad.phys_addr =
7857 				rte_pktmbuf_iova(ut_params->ibuf);
7858 		memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7859 		debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7860 			tdata->aad.len);
7861 
7862 		/* Append IV at the end of the crypto operation*/
7863 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7864 				uint8_t *, IV_OFFSET);
7865 
7866 		if (tdata->iv.len == 0) {
7867 			rte_memcpy(iv_ptr, tdata->iv.data, AES_GCM_J0_LENGTH);
7868 			debug_hexdump(stdout, "iv:", iv_ptr,
7869 				AES_GCM_J0_LENGTH);
7870 		} else {
7871 			rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7872 			debug_hexdump(stdout, "iv:", iv_ptr,
7873 				tdata->iv.len);
7874 		}
7875 	}
7876 
7877 	/* Append plaintext/ciphertext */
7878 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7879 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7880 		plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7881 				plaintext_pad_len);
7882 		TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7883 
7884 		memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7885 		debug_hexdump(stdout, "plaintext:", plaintext,
7886 				tdata->plaintext.len);
7887 
7888 		if (ut_params->obuf) {
7889 			ciphertext = (uint8_t *)rte_pktmbuf_append(
7890 					ut_params->obuf,
7891 					plaintext_pad_len + aad_pad_len);
7892 			TEST_ASSERT_NOT_NULL(ciphertext,
7893 					"no room to append ciphertext");
7894 
7895 			memset(ciphertext + aad_pad_len, 0,
7896 					tdata->ciphertext.len);
7897 		}
7898 	} else {
7899 		plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7900 		ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7901 				plaintext_pad_len);
7902 		TEST_ASSERT_NOT_NULL(ciphertext,
7903 				"no room to append ciphertext");
7904 
7905 		memcpy(ciphertext, tdata->ciphertext.data,
7906 				tdata->ciphertext.len);
7907 		debug_hexdump(stdout, "ciphertext:", ciphertext,
7908 				tdata->ciphertext.len);
7909 
7910 		if (ut_params->obuf) {
7911 			plaintext = (uint8_t *)rte_pktmbuf_append(
7912 					ut_params->obuf,
7913 					plaintext_pad_len + aad_pad_len);
7914 			TEST_ASSERT_NOT_NULL(plaintext,
7915 					"no room to append plaintext");
7916 
7917 			memset(plaintext + aad_pad_len, 0,
7918 					tdata->plaintext.len);
7919 		}
7920 	}
7921 
7922 	/* Append digest data */
7923 	if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7924 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7925 				ut_params->obuf ? ut_params->obuf :
7926 						ut_params->ibuf,
7927 						tdata->auth_tag.len);
7928 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7929 				"no room to append digest");
7930 		memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7931 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7932 				ut_params->obuf ? ut_params->obuf :
7933 						ut_params->ibuf,
7934 						plaintext_pad_len +
7935 						aad_pad_len);
7936 	} else {
7937 		sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7938 				ut_params->ibuf, tdata->auth_tag.len);
7939 		TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7940 				"no room to append digest");
7941 		sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7942 				ut_params->ibuf,
7943 				plaintext_pad_len + aad_pad_len);
7944 
7945 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7946 			tdata->auth_tag.len);
7947 		debug_hexdump(stdout, "digest:",
7948 			sym_op->aead.digest.data,
7949 			tdata->auth_tag.len);
7950 	}
7951 
7952 	sym_op->aead.data.length = tdata->plaintext.len;
7953 	sym_op->aead.data.offset = aad_pad_len;
7954 
7955 	return 0;
7956 }
7957 
7958 static int
7959 test_authenticated_encryption(const struct aead_test_data *tdata)
7960 {
7961 	struct crypto_testsuite_params *ts_params = &testsuite_params;
7962 	struct crypto_unittest_params *ut_params = &unittest_params;
7963 
7964 	int retval;
7965 	uint8_t *ciphertext, *auth_tag;
7966 	uint16_t plaintext_pad_len;
7967 	uint32_t i;
7968 	struct rte_cryptodev_info dev_info;
7969 
7970 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7971 	uint64_t feat_flags = dev_info.feature_flags;
7972 
7973 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
7974 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
7975 		printf("Device doesn't support RAW data-path APIs.\n");
7976 		return TEST_SKIPPED;
7977 	}
7978 
7979 	/* Verify the capabilities */
7980 	struct rte_cryptodev_sym_capability_idx cap_idx;
7981 	const struct rte_cryptodev_symmetric_capability *capability;
7982 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7983 	cap_idx.algo.aead = tdata->algo;
7984 	capability = rte_cryptodev_sym_capability_get(
7985 			ts_params->valid_devs[0], &cap_idx);
7986 	if (capability == NULL)
7987 		return TEST_SKIPPED;
7988 	if (rte_cryptodev_sym_capability_check_aead(
7989 			capability, tdata->key.len, tdata->auth_tag.len,
7990 			tdata->aad.len, tdata->iv.len))
7991 		return TEST_SKIPPED;
7992 
7993 	/* Create AEAD session */
7994 	retval = create_aead_session(ts_params->valid_devs[0],
7995 			tdata->algo,
7996 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
7997 			tdata->key.data, tdata->key.len,
7998 			tdata->aad.len, tdata->auth_tag.len,
7999 			tdata->iv.len);
8000 	if (retval < 0)
8001 		return retval;
8002 
8003 	if (tdata->aad.len > MBUF_SIZE) {
8004 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8005 		/* Populate full size of add data */
8006 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8007 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8008 	} else
8009 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8010 
8011 	/* clear mbuf payload */
8012 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8013 			rte_pktmbuf_tailroom(ut_params->ibuf));
8014 
8015 	/* Create AEAD operation */
8016 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8017 	if (retval < 0)
8018 		return retval;
8019 
8020 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8021 
8022 	ut_params->op->sym->m_src = ut_params->ibuf;
8023 
8024 	/* Process crypto operation */
8025 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
8026 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
8027 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
8028 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
8029 				ut_params->op, 0, 0, 0, 0);
8030 	else
8031 		TEST_ASSERT_NOT_NULL(
8032 			process_crypto_request(ts_params->valid_devs[0],
8033 			ut_params->op), "failed to process sym crypto op");
8034 
8035 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8036 			"crypto op processing failed");
8037 
8038 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8039 
8040 	if (ut_params->op->sym->m_dst) {
8041 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8042 				uint8_t *);
8043 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8044 				uint8_t *, plaintext_pad_len);
8045 	} else {
8046 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8047 				uint8_t *,
8048 				ut_params->op->sym->cipher.data.offset);
8049 		auth_tag = ciphertext + plaintext_pad_len;
8050 	}
8051 
8052 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8053 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8054 
8055 	/* Validate obuf */
8056 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8057 			ciphertext,
8058 			tdata->ciphertext.data,
8059 			tdata->ciphertext.len,
8060 			"Ciphertext data not as expected");
8061 
8062 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
8063 			auth_tag,
8064 			tdata->auth_tag.data,
8065 			tdata->auth_tag.len,
8066 			"Generated auth tag not as expected");
8067 
8068 	return 0;
8069 
8070 }
8071 
8072 #ifdef RTE_LIB_SECURITY
8073 static int
8074 security_proto_supported(enum rte_security_session_action_type action,
8075 	enum rte_security_session_protocol proto)
8076 {
8077 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8078 
8079 	const struct rte_security_capability *capabilities;
8080 	const struct rte_security_capability *capability;
8081 	uint16_t i = 0;
8082 
8083 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8084 				rte_cryptodev_get_sec_ctx(
8085 				ts_params->valid_devs[0]);
8086 
8087 
8088 	capabilities = rte_security_capabilities_get(ctx);
8089 
8090 	if (capabilities == NULL)
8091 		return -ENOTSUP;
8092 
8093 	while ((capability = &capabilities[i++])->action !=
8094 			RTE_SECURITY_ACTION_TYPE_NONE) {
8095 		if (capability->action == action &&
8096 				capability->protocol == proto)
8097 			return 0;
8098 	}
8099 
8100 	return -ENOTSUP;
8101 }
8102 
8103 /* Basic algorithm run function for async inplace mode.
8104  * Creates a session from input parameters and runs one operation
8105  * on input_vec. Checks the output of the crypto operation against
8106  * output_vec.
8107  */
8108 static int test_pdcp_proto(int i, int oop, enum rte_crypto_cipher_operation opc,
8109 			   enum rte_crypto_auth_operation opa,
8110 			   const uint8_t *input_vec, unsigned int input_vec_len,
8111 			   const uint8_t *output_vec,
8112 			   unsigned int output_vec_len,
8113 			   enum rte_crypto_cipher_algorithm cipher_alg,
8114 			   const uint8_t *cipher_key, uint32_t cipher_key_len,
8115 			   enum rte_crypto_auth_algorithm auth_alg,
8116 			   const uint8_t *auth_key, uint32_t auth_key_len,
8117 			   uint8_t bearer, enum rte_security_pdcp_domain domain,
8118 			   uint8_t packet_direction, uint8_t sn_size,
8119 			   uint32_t hfn, uint32_t hfn_threshold, uint8_t sdap)
8120 {
8121 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8122 	struct crypto_unittest_params *ut_params = &unittest_params;
8123 	uint8_t *plaintext;
8124 	int ret = TEST_SUCCESS;
8125 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8126 				rte_cryptodev_get_sec_ctx(
8127 				ts_params->valid_devs[0]);
8128 
8129 	/* Verify the capabilities */
8130 	struct rte_security_capability_idx sec_cap_idx;
8131 
8132 	sec_cap_idx.action = ut_params->type;
8133 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8134 	sec_cap_idx.pdcp.domain = domain;
8135 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8136 		return TEST_SKIPPED;
8137 
8138 	/* Generate test mbuf data */
8139 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8140 
8141 	/* clear mbuf payload */
8142 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8143 			rte_pktmbuf_tailroom(ut_params->ibuf));
8144 
8145 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8146 						  input_vec_len);
8147 	memcpy(plaintext, input_vec, input_vec_len);
8148 
8149 	/* Out of place support */
8150 	if (oop) {
8151 		/*
8152 		 * For out-op-place we need to alloc another mbuf
8153 		 */
8154 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8155 		rte_pktmbuf_append(ut_params->obuf, output_vec_len);
8156 	}
8157 
8158 	/* Setup Cipher Parameters */
8159 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8160 	ut_params->cipher_xform.cipher.algo = cipher_alg;
8161 	ut_params->cipher_xform.cipher.op = opc;
8162 	ut_params->cipher_xform.cipher.key.data = cipher_key;
8163 	ut_params->cipher_xform.cipher.key.length = cipher_key_len;
8164 	ut_params->cipher_xform.cipher.iv.length =
8165 				packet_direction ? 4 : 0;
8166 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8167 
8168 	/* Setup HMAC Parameters if ICV header is required */
8169 	if (auth_alg != 0) {
8170 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8171 		ut_params->auth_xform.next = NULL;
8172 		ut_params->auth_xform.auth.algo = auth_alg;
8173 		ut_params->auth_xform.auth.op = opa;
8174 		ut_params->auth_xform.auth.key.data = auth_key;
8175 		ut_params->auth_xform.auth.key.length = auth_key_len;
8176 
8177 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8178 	} else {
8179 		ut_params->cipher_xform.next = NULL;
8180 	}
8181 
8182 	struct rte_security_session_conf sess_conf = {
8183 		.action_type = ut_params->type,
8184 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8185 		{.pdcp = {
8186 			.bearer = bearer,
8187 			.domain = domain,
8188 			.pkt_dir = packet_direction,
8189 			.sn_size = sn_size,
8190 			.hfn = packet_direction ? 0 : hfn,
8191 			/**
8192 			 * hfn can be set as pdcp_test_hfn[i]
8193 			 * if hfn_ovrd is not set. Here, PDCP
8194 			 * packet direction is just used to
8195 			 * run half of the cases with session
8196 			 * HFN and other half with per packet
8197 			 * HFN.
8198 			 */
8199 			.hfn_threshold = hfn_threshold,
8200 			.hfn_ovrd = packet_direction ? 1 : 0,
8201 			.sdap_enabled = sdap,
8202 		} },
8203 		.crypto_xform = &ut_params->cipher_xform
8204 	};
8205 
8206 	/* Create security session */
8207 	ut_params->sec_session = rte_security_session_create(ctx,
8208 				&sess_conf, ts_params->session_mpool,
8209 				ts_params->session_priv_mpool);
8210 
8211 	if (!ut_params->sec_session) {
8212 		printf("TestCase %s()-%d line %d failed %s: ",
8213 			__func__, i, __LINE__, "Failed to allocate session");
8214 		ret = TEST_FAILED;
8215 		goto on_err;
8216 	}
8217 
8218 	/* Generate crypto op data structure */
8219 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8220 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8221 	if (!ut_params->op) {
8222 		printf("TestCase %s()-%d line %d failed %s: ",
8223 			__func__, i, __LINE__,
8224 			"Failed to allocate symmetric crypto operation struct");
8225 		ret = TEST_FAILED;
8226 		goto on_err;
8227 	}
8228 
8229 	uint32_t *per_pkt_hfn = rte_crypto_op_ctod_offset(ut_params->op,
8230 					uint32_t *, IV_OFFSET);
8231 	*per_pkt_hfn = packet_direction ? hfn : 0;
8232 
8233 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8234 
8235 	/* set crypto operation source mbuf */
8236 	ut_params->op->sym->m_src = ut_params->ibuf;
8237 	if (oop)
8238 		ut_params->op->sym->m_dst = ut_params->obuf;
8239 
8240 	/* Process crypto operation */
8241 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8242 		== NULL) {
8243 		printf("TestCase %s()-%d line %d failed %s: ",
8244 			__func__, i, __LINE__,
8245 			"failed to process sym crypto op");
8246 		ret = TEST_FAILED;
8247 		goto on_err;
8248 	}
8249 
8250 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8251 		printf("TestCase %s()-%d line %d failed %s: ",
8252 			__func__, i, __LINE__, "crypto op processing failed");
8253 		ret = TEST_FAILED;
8254 		goto on_err;
8255 	}
8256 
8257 	/* Validate obuf */
8258 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8259 			uint8_t *);
8260 	if (oop) {
8261 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8262 				uint8_t *);
8263 	}
8264 
8265 	if (memcmp(ciphertext, output_vec, output_vec_len)) {
8266 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8267 		rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8268 		rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8269 		ret = TEST_FAILED;
8270 		goto on_err;
8271 	}
8272 
8273 on_err:
8274 	rte_crypto_op_free(ut_params->op);
8275 	ut_params->op = NULL;
8276 
8277 	if (ut_params->sec_session)
8278 		rte_security_session_destroy(ctx, ut_params->sec_session);
8279 	ut_params->sec_session = NULL;
8280 
8281 	rte_pktmbuf_free(ut_params->ibuf);
8282 	ut_params->ibuf = NULL;
8283 	if (oop) {
8284 		rte_pktmbuf_free(ut_params->obuf);
8285 		ut_params->obuf = NULL;
8286 	}
8287 
8288 	return ret;
8289 }
8290 
8291 static int
8292 test_pdcp_proto_SGL(int i, int oop,
8293 	enum rte_crypto_cipher_operation opc,
8294 	enum rte_crypto_auth_operation opa,
8295 	uint8_t *input_vec,
8296 	unsigned int input_vec_len,
8297 	uint8_t *output_vec,
8298 	unsigned int output_vec_len,
8299 	uint32_t fragsz,
8300 	uint32_t fragsz_oop)
8301 {
8302 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8303 	struct crypto_unittest_params *ut_params = &unittest_params;
8304 	uint8_t *plaintext;
8305 	struct rte_mbuf *buf, *buf_oop = NULL;
8306 	int ret = TEST_SUCCESS;
8307 	int to_trn = 0;
8308 	int to_trn_tbl[16];
8309 	int segs = 1;
8310 	unsigned int trn_data = 0;
8311 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8312 				rte_cryptodev_get_sec_ctx(
8313 				ts_params->valid_devs[0]);
8314 
8315 	/* Verify the capabilities */
8316 	struct rte_security_capability_idx sec_cap_idx;
8317 
8318 	sec_cap_idx.action = ut_params->type;
8319 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_PDCP;
8320 	sec_cap_idx.pdcp.domain = pdcp_test_params[i].domain;
8321 	if (rte_security_capability_get(ctx, &sec_cap_idx) == NULL)
8322 		return TEST_SKIPPED;
8323 
8324 	if (fragsz > input_vec_len)
8325 		fragsz = input_vec_len;
8326 
8327 	uint16_t plaintext_len = fragsz;
8328 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8329 
8330 	if (fragsz_oop > output_vec_len)
8331 		frag_size_oop = output_vec_len;
8332 
8333 	int ecx = 0;
8334 	if (input_vec_len % fragsz != 0) {
8335 		if (input_vec_len / fragsz + 1 > 16)
8336 			return 1;
8337 	} else if (input_vec_len / fragsz > 16)
8338 		return 1;
8339 
8340 	/* Out of place support */
8341 	if (oop) {
8342 		/*
8343 		 * For out-op-place we need to alloc another mbuf
8344 		 */
8345 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8346 		rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8347 		buf_oop = ut_params->obuf;
8348 	}
8349 
8350 	/* Generate test mbuf data */
8351 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8352 
8353 	/* clear mbuf payload */
8354 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8355 			rte_pktmbuf_tailroom(ut_params->ibuf));
8356 
8357 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8358 						  plaintext_len);
8359 	memcpy(plaintext, input_vec, plaintext_len);
8360 	trn_data += plaintext_len;
8361 
8362 	buf = ut_params->ibuf;
8363 
8364 	/*
8365 	 * Loop until no more fragments
8366 	 */
8367 
8368 	while (trn_data < input_vec_len) {
8369 		++segs;
8370 		to_trn = (input_vec_len - trn_data < fragsz) ?
8371 				(input_vec_len - trn_data) : fragsz;
8372 
8373 		to_trn_tbl[ecx++] = to_trn;
8374 
8375 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8376 		buf = buf->next;
8377 
8378 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8379 				rte_pktmbuf_tailroom(buf));
8380 
8381 		/* OOP */
8382 		if (oop && !fragsz_oop) {
8383 			buf_oop->next =
8384 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
8385 			buf_oop = buf_oop->next;
8386 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8387 					0, rte_pktmbuf_tailroom(buf_oop));
8388 			rte_pktmbuf_append(buf_oop, to_trn);
8389 		}
8390 
8391 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8392 				to_trn);
8393 
8394 		memcpy(plaintext, input_vec + trn_data, to_trn);
8395 		trn_data += to_trn;
8396 	}
8397 
8398 	ut_params->ibuf->nb_segs = segs;
8399 
8400 	segs = 1;
8401 	if (fragsz_oop && oop) {
8402 		to_trn = 0;
8403 		ecx = 0;
8404 
8405 		trn_data = frag_size_oop;
8406 		while (trn_data < output_vec_len) {
8407 			++segs;
8408 			to_trn =
8409 				(output_vec_len - trn_data <
8410 						frag_size_oop) ?
8411 				(output_vec_len - trn_data) :
8412 						frag_size_oop;
8413 
8414 			to_trn_tbl[ecx++] = to_trn;
8415 
8416 			buf_oop->next =
8417 				rte_pktmbuf_alloc(ts_params->mbuf_pool);
8418 			buf_oop = buf_oop->next;
8419 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8420 					0, rte_pktmbuf_tailroom(buf_oop));
8421 			rte_pktmbuf_append(buf_oop, to_trn);
8422 
8423 			trn_data += to_trn;
8424 		}
8425 		ut_params->obuf->nb_segs = segs;
8426 	}
8427 
8428 	/* Setup Cipher Parameters */
8429 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8430 	ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8431 	ut_params->cipher_xform.cipher.op = opc;
8432 	ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8433 	ut_params->cipher_xform.cipher.key.length =
8434 					pdcp_test_params[i].cipher_key_len;
8435 	ut_params->cipher_xform.cipher.iv.length = 0;
8436 
8437 	/* Setup HMAC Parameters if ICV header is required */
8438 	if (pdcp_test_params[i].auth_alg != 0) {
8439 		ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8440 		ut_params->auth_xform.next = NULL;
8441 		ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8442 		ut_params->auth_xform.auth.op = opa;
8443 		ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8444 		ut_params->auth_xform.auth.key.length =
8445 					pdcp_test_params[i].auth_key_len;
8446 
8447 		ut_params->cipher_xform.next = &ut_params->auth_xform;
8448 	} else {
8449 		ut_params->cipher_xform.next = NULL;
8450 	}
8451 
8452 	struct rte_security_session_conf sess_conf = {
8453 		.action_type = ut_params->type,
8454 		.protocol = RTE_SECURITY_PROTOCOL_PDCP,
8455 		{.pdcp = {
8456 			.bearer = pdcp_test_bearer[i],
8457 			.domain = pdcp_test_params[i].domain,
8458 			.pkt_dir = pdcp_test_packet_direction[i],
8459 			.sn_size = pdcp_test_data_sn_size[i],
8460 			.hfn = pdcp_test_hfn[i],
8461 			.hfn_threshold = pdcp_test_hfn_threshold[i],
8462 			.hfn_ovrd = 0,
8463 		} },
8464 		.crypto_xform = &ut_params->cipher_xform
8465 	};
8466 
8467 	/* Create security session */
8468 	ut_params->sec_session = rte_security_session_create(ctx,
8469 				&sess_conf, ts_params->session_mpool,
8470 				ts_params->session_priv_mpool);
8471 
8472 	if (!ut_params->sec_session) {
8473 		printf("TestCase %s()-%d line %d failed %s: ",
8474 			__func__, i, __LINE__, "Failed to allocate session");
8475 		ret = TEST_FAILED;
8476 		goto on_err;
8477 	}
8478 
8479 	/* Generate crypto op data structure */
8480 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8481 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8482 	if (!ut_params->op) {
8483 		printf("TestCase %s()-%d line %d failed %s: ",
8484 			__func__, i, __LINE__,
8485 			"Failed to allocate symmetric crypto operation struct");
8486 		ret = TEST_FAILED;
8487 		goto on_err;
8488 	}
8489 
8490 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8491 
8492 	/* set crypto operation source mbuf */
8493 	ut_params->op->sym->m_src = ut_params->ibuf;
8494 	if (oop)
8495 		ut_params->op->sym->m_dst = ut_params->obuf;
8496 
8497 	/* Process crypto operation */
8498 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8499 		== NULL) {
8500 		printf("TestCase %s()-%d line %d failed %s: ",
8501 			__func__, i, __LINE__,
8502 			"failed to process sym crypto op");
8503 		ret = TEST_FAILED;
8504 		goto on_err;
8505 	}
8506 
8507 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8508 		printf("TestCase %s()-%d line %d failed %s: ",
8509 			__func__, i, __LINE__, "crypto op processing failed");
8510 		ret = TEST_FAILED;
8511 		goto on_err;
8512 	}
8513 
8514 	/* Validate obuf */
8515 	uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8516 			uint8_t *);
8517 	if (oop) {
8518 		ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8519 				uint8_t *);
8520 	}
8521 	if (fragsz_oop)
8522 		fragsz = frag_size_oop;
8523 	if (memcmp(ciphertext, output_vec, fragsz)) {
8524 		printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8525 		rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8526 		rte_hexdump(stdout, "reference", output_vec, fragsz);
8527 		ret = TEST_FAILED;
8528 		goto on_err;
8529 	}
8530 
8531 	buf = ut_params->op->sym->m_src->next;
8532 	if (oop)
8533 		buf = ut_params->op->sym->m_dst->next;
8534 
8535 	unsigned int off = fragsz;
8536 
8537 	ecx = 0;
8538 	while (buf) {
8539 		ciphertext = rte_pktmbuf_mtod(buf,
8540 				uint8_t *);
8541 		if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8542 			printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8543 			rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8544 			rte_hexdump(stdout, "reference", output_vec + off,
8545 					to_trn_tbl[ecx]);
8546 			ret = TEST_FAILED;
8547 			goto on_err;
8548 		}
8549 		off += to_trn_tbl[ecx++];
8550 		buf = buf->next;
8551 	}
8552 on_err:
8553 	rte_crypto_op_free(ut_params->op);
8554 	ut_params->op = NULL;
8555 
8556 	if (ut_params->sec_session)
8557 		rte_security_session_destroy(ctx, ut_params->sec_session);
8558 	ut_params->sec_session = NULL;
8559 
8560 	rte_pktmbuf_free(ut_params->ibuf);
8561 	ut_params->ibuf = NULL;
8562 	if (oop) {
8563 		rte_pktmbuf_free(ut_params->obuf);
8564 		ut_params->obuf = NULL;
8565 	}
8566 
8567 	return ret;
8568 }
8569 
8570 int
8571 test_pdcp_proto_cplane_encap(int i)
8572 {
8573 	return test_pdcp_proto(
8574 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8575 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8576 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8577 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8578 		pdcp_test_params[i].cipher_key_len,
8579 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8580 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8581 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8582 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8583 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8584 }
8585 
8586 int
8587 test_pdcp_proto_uplane_encap(int i)
8588 {
8589 	return test_pdcp_proto(
8590 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8591 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8592 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8593 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8594 		pdcp_test_params[i].cipher_key_len,
8595 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8596 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8597 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8598 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8599 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8600 }
8601 
8602 int
8603 test_pdcp_proto_uplane_encap_with_int(int i)
8604 {
8605 	return test_pdcp_proto(
8606 		i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT, RTE_CRYPTO_AUTH_OP_GENERATE,
8607 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8608 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8609 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8610 		pdcp_test_params[i].cipher_key_len,
8611 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8612 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8613 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8614 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8615 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8616 }
8617 
8618 int
8619 test_pdcp_proto_cplane_decap(int i)
8620 {
8621 	return test_pdcp_proto(
8622 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8623 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8624 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8625 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8626 		pdcp_test_params[i].cipher_key_len,
8627 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8628 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8629 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8630 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8631 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8632 }
8633 
8634 int
8635 test_pdcp_proto_uplane_decap(int i)
8636 {
8637 	return test_pdcp_proto(
8638 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8639 		pdcp_test_data_out[i], pdcp_test_data_in_len[i],
8640 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8641 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8642 		pdcp_test_params[i].cipher_key_len,
8643 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8644 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8645 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8646 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8647 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8648 }
8649 
8650 int
8651 test_pdcp_proto_uplane_decap_with_int(int i)
8652 {
8653 	return test_pdcp_proto(
8654 		i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT, RTE_CRYPTO_AUTH_OP_VERIFY,
8655 		pdcp_test_data_out[i], pdcp_test_data_in_len[i] + 4,
8656 		pdcp_test_data_in[i], pdcp_test_data_in_len[i],
8657 		pdcp_test_params[i].cipher_alg, pdcp_test_crypto_key[i],
8658 		pdcp_test_params[i].cipher_key_len,
8659 		pdcp_test_params[i].auth_alg, pdcp_test_auth_key[i],
8660 		pdcp_test_params[i].auth_key_len, pdcp_test_bearer[i],
8661 		pdcp_test_params[i].domain, pdcp_test_packet_direction[i],
8662 		pdcp_test_data_sn_size[i], pdcp_test_hfn[i],
8663 		pdcp_test_hfn_threshold[i], SDAP_DISABLED);
8664 }
8665 
8666 static int
8667 test_PDCP_PROTO_SGL_in_place_32B(void)
8668 {
8669 	/* i can be used for running any PDCP case
8670 	 * In this case it is uplane 12-bit AES-SNOW DL encap
8671 	 */
8672 	int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8673 	return test_pdcp_proto_SGL(i, IN_PLACE,
8674 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8675 			RTE_CRYPTO_AUTH_OP_GENERATE,
8676 			pdcp_test_data_in[i],
8677 			pdcp_test_data_in_len[i],
8678 			pdcp_test_data_out[i],
8679 			pdcp_test_data_in_len[i]+4,
8680 			32, 0);
8681 }
8682 static int
8683 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8684 {
8685 	/* i can be used for running any PDCP case
8686 	 * In this case it is uplane 18-bit NULL-NULL DL encap
8687 	 */
8688 	int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8689 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8690 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8691 			RTE_CRYPTO_AUTH_OP_GENERATE,
8692 			pdcp_test_data_in[i],
8693 			pdcp_test_data_in_len[i],
8694 			pdcp_test_data_out[i],
8695 			pdcp_test_data_in_len[i]+4,
8696 			32, 128);
8697 }
8698 static int
8699 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8700 {
8701 	/* i can be used for running any PDCP case
8702 	 * In this case it is uplane 18-bit AES DL encap
8703 	 */
8704 	int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8705 			+ DOWNLINK;
8706 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8707 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8708 			RTE_CRYPTO_AUTH_OP_GENERATE,
8709 			pdcp_test_data_in[i],
8710 			pdcp_test_data_in_len[i],
8711 			pdcp_test_data_out[i],
8712 			pdcp_test_data_in_len[i],
8713 			32, 40);
8714 }
8715 static int
8716 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8717 {
8718 	/* i can be used for running any PDCP case
8719 	 * In this case it is cplane 12-bit AES-ZUC DL encap
8720 	 */
8721 	int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8722 	return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8723 			RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8724 			RTE_CRYPTO_AUTH_OP_GENERATE,
8725 			pdcp_test_data_in[i],
8726 			pdcp_test_data_in_len[i],
8727 			pdcp_test_data_out[i],
8728 			pdcp_test_data_in_len[i]+4,
8729 			128, 32);
8730 }
8731 
8732 static int
8733 test_PDCP_SDAP_PROTO_encap_all(void)
8734 {
8735 	int i = 0, size = 0;
8736 	int err, all_err = TEST_SUCCESS;
8737 	const struct pdcp_sdap_test *cur_test;
8738 
8739 	size = ARRAY_SIZE(list_pdcp_sdap_tests);
8740 
8741 	for (i = 0; i < size; i++) {
8742 		cur_test = &list_pdcp_sdap_tests[i];
8743 		err = test_pdcp_proto(
8744 			i, 0, RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8745 			RTE_CRYPTO_AUTH_OP_GENERATE, cur_test->data_in,
8746 			cur_test->in_len, cur_test->data_out,
8747 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8748 			cur_test->param.cipher_alg, cur_test->cipher_key,
8749 			cur_test->param.cipher_key_len,
8750 			cur_test->param.auth_alg,
8751 			cur_test->auth_key, cur_test->param.auth_key_len,
8752 			cur_test->bearer, cur_test->param.domain,
8753 			cur_test->packet_direction, cur_test->sn_size,
8754 			cur_test->hfn,
8755 			cur_test->hfn_threshold, SDAP_ENABLED);
8756 		if (err) {
8757 			printf("\t%d) %s: Encapsulation failed\n",
8758 					cur_test->test_idx,
8759 					cur_test->param.name);
8760 			err = TEST_FAILED;
8761 		} else {
8762 			printf("\t%d) %s: Encap PASS\n", cur_test->test_idx,
8763 					cur_test->param.name);
8764 			err = TEST_SUCCESS;
8765 		}
8766 		all_err += err;
8767 	}
8768 
8769 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8770 
8771 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8772 }
8773 
8774 static int
8775 test_PDCP_SDAP_PROTO_decap_all(void)
8776 {
8777 	int i = 0, size = 0;
8778 	int err, all_err = TEST_SUCCESS;
8779 	const struct pdcp_sdap_test *cur_test;
8780 
8781 	size = ARRAY_SIZE(list_pdcp_sdap_tests);
8782 
8783 	for (i = 0; i < size; i++) {
8784 		cur_test = &list_pdcp_sdap_tests[i];
8785 		err = test_pdcp_proto(
8786 			i, 0, RTE_CRYPTO_CIPHER_OP_DECRYPT,
8787 			RTE_CRYPTO_AUTH_OP_VERIFY,
8788 			cur_test->data_out,
8789 			cur_test->in_len + ((cur_test->auth_key) ? 4 : 0),
8790 			cur_test->data_in, cur_test->in_len,
8791 			cur_test->param.cipher_alg,
8792 			cur_test->cipher_key, cur_test->param.cipher_key_len,
8793 			cur_test->param.auth_alg, cur_test->auth_key,
8794 			cur_test->param.auth_key_len, cur_test->bearer,
8795 			cur_test->param.domain, cur_test->packet_direction,
8796 			cur_test->sn_size, cur_test->hfn,
8797 			cur_test->hfn_threshold, SDAP_ENABLED);
8798 		if (err) {
8799 			printf("\t%d) %s: Decapsulation failed\n",
8800 					cur_test->test_idx,
8801 					cur_test->param.name);
8802 			err = TEST_FAILED;
8803 		} else {
8804 			printf("\t%d) %s: Decap PASS\n", cur_test->test_idx,
8805 					cur_test->param.name);
8806 			err = TEST_SUCCESS;
8807 		}
8808 		all_err += err;
8809 	}
8810 
8811 	printf("Success: %d, Failure: %d\n", size + all_err, -all_err);
8812 
8813 	return (all_err == TEST_SUCCESS) ? TEST_SUCCESS : TEST_FAILED;
8814 }
8815 
8816 static int
8817 test_PDCP_PROTO_all(void)
8818 {
8819 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8820 	struct crypto_unittest_params *ut_params = &unittest_params;
8821 	struct rte_cryptodev_info dev_info;
8822 	int status;
8823 
8824 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8825 	uint64_t feat_flags = dev_info.feature_flags;
8826 
8827 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
8828 		return TEST_SKIPPED;
8829 
8830 	/* Set action type */
8831 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
8832 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
8833 		gbl_action_type;
8834 
8835 	if (security_proto_supported(ut_params->type,
8836 			RTE_SECURITY_PROTOCOL_PDCP) < 0)
8837 		return TEST_SKIPPED;
8838 
8839 	status = test_PDCP_PROTO_cplane_encap_all();
8840 	status += test_PDCP_PROTO_cplane_decap_all();
8841 	status += test_PDCP_PROTO_uplane_encap_all();
8842 	status += test_PDCP_PROTO_uplane_decap_all();
8843 	status += test_PDCP_PROTO_SGL_in_place_32B();
8844 	status += test_PDCP_PROTO_SGL_oop_32B_128B();
8845 	status += test_PDCP_PROTO_SGL_oop_32B_40B();
8846 	status += test_PDCP_PROTO_SGL_oop_128B_32B();
8847 	status += test_PDCP_SDAP_PROTO_encap_all();
8848 	status += test_PDCP_SDAP_PROTO_decap_all();
8849 
8850 	if (status)
8851 		return TEST_FAILED;
8852 	else
8853 		return TEST_SUCCESS;
8854 }
8855 
8856 static int
8857 test_docsis_proto_uplink(int i, struct docsis_test_data *d_td)
8858 {
8859 	struct crypto_testsuite_params *ts_params = &testsuite_params;
8860 	struct crypto_unittest_params *ut_params = &unittest_params;
8861 	uint8_t *plaintext, *ciphertext;
8862 	uint8_t *iv_ptr;
8863 	int32_t cipher_len, crc_len;
8864 	uint32_t crc_data_len;
8865 	int ret = TEST_SUCCESS;
8866 
8867 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8868 					rte_cryptodev_get_sec_ctx(
8869 						ts_params->valid_devs[0]);
8870 
8871 	/* Verify the capabilities */
8872 	struct rte_security_capability_idx sec_cap_idx;
8873 	const struct rte_security_capability *sec_cap;
8874 	const struct rte_cryptodev_capabilities *crypto_cap;
8875 	const struct rte_cryptodev_symmetric_capability *sym_cap;
8876 	int j = 0;
8877 
8878 	sec_cap_idx.action = ut_params->type;
8879 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
8880 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_UPLINK;
8881 
8882 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
8883 	if (sec_cap == NULL)
8884 		return TEST_SKIPPED;
8885 
8886 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
8887 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
8888 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
8889 				crypto_cap->sym.xform_type ==
8890 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
8891 				crypto_cap->sym.cipher.algo ==
8892 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
8893 			sym_cap = &crypto_cap->sym;
8894 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
8895 						d_td->key.len,
8896 						d_td->iv.len) == 0)
8897 				break;
8898 		}
8899 	}
8900 
8901 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
8902 		return TEST_SKIPPED;
8903 
8904 	/* Setup source mbuf payload */
8905 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8906 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8907 			rte_pktmbuf_tailroom(ut_params->ibuf));
8908 
8909 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8910 			d_td->ciphertext.len);
8911 
8912 	memcpy(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len);
8913 
8914 	/* Setup cipher session parameters */
8915 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8916 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
8917 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
8918 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
8919 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
8920 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
8921 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8922 	ut_params->cipher_xform.next = NULL;
8923 
8924 	/* Setup DOCSIS session parameters */
8925 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_UPLINK;
8926 
8927 	struct rte_security_session_conf sess_conf = {
8928 		.action_type = ut_params->type,
8929 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
8930 		.docsis = ut_params->docsis_xform,
8931 		.crypto_xform = &ut_params->cipher_xform,
8932 	};
8933 
8934 	/* Create security session */
8935 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
8936 					ts_params->session_mpool,
8937 					ts_params->session_priv_mpool);
8938 
8939 	if (!ut_params->sec_session) {
8940 		printf("TestCase %s(%d) line %d: %s\n",
8941 			__func__, i, __LINE__, "failed to allocate session");
8942 		ret = TEST_FAILED;
8943 		goto on_err;
8944 	}
8945 
8946 	/* Generate crypto op data structure */
8947 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8948 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8949 	if (!ut_params->op) {
8950 		printf("TestCase %s(%d) line %d: %s\n",
8951 			__func__, i, __LINE__,
8952 			"failed to allocate symmetric crypto operation");
8953 		ret = TEST_FAILED;
8954 		goto on_err;
8955 	}
8956 
8957 	/* Setup CRC operation parameters */
8958 	crc_len = d_td->ciphertext.no_crc == false ?
8959 			(d_td->ciphertext.len -
8960 				d_td->ciphertext.crc_offset -
8961 				RTE_ETHER_CRC_LEN) :
8962 			0;
8963 	crc_len = crc_len > 0 ? crc_len : 0;
8964 	crc_data_len = crc_len == 0 ? 0 : RTE_ETHER_CRC_LEN;
8965 	ut_params->op->sym->auth.data.length = crc_len;
8966 	ut_params->op->sym->auth.data.offset = d_td->ciphertext.crc_offset;
8967 
8968 	/* Setup cipher operation parameters */
8969 	cipher_len = d_td->ciphertext.no_cipher == false ?
8970 			(d_td->ciphertext.len -
8971 				d_td->ciphertext.cipher_offset) :
8972 			0;
8973 	cipher_len = cipher_len > 0 ? cipher_len : 0;
8974 	ut_params->op->sym->cipher.data.length = cipher_len;
8975 	ut_params->op->sym->cipher.data.offset = d_td->ciphertext.cipher_offset;
8976 
8977 	/* Setup cipher IV */
8978 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
8979 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
8980 
8981 	/* Attach session to operation */
8982 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
8983 
8984 	/* Set crypto operation mbufs */
8985 	ut_params->op->sym->m_src = ut_params->ibuf;
8986 	ut_params->op->sym->m_dst = NULL;
8987 
8988 	/* Process crypto operation */
8989 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
8990 			NULL) {
8991 		printf("TestCase %s(%d) line %d: %s\n",
8992 			__func__, i, __LINE__,
8993 			"failed to process security crypto op");
8994 		ret = TEST_FAILED;
8995 		goto on_err;
8996 	}
8997 
8998 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8999 		printf("TestCase %s(%d) line %d: %s\n",
9000 			__func__, i, __LINE__, "crypto op processing failed");
9001 		ret = TEST_FAILED;
9002 		goto on_err;
9003 	}
9004 
9005 	/* Validate plaintext */
9006 	plaintext = ciphertext;
9007 
9008 	if (memcmp(plaintext, d_td->plaintext.data,
9009 			d_td->plaintext.len - crc_data_len)) {
9010 		printf("TestCase %s(%d) line %d: %s\n",
9011 			__func__, i, __LINE__, "plaintext not as expected\n");
9012 		rte_hexdump(stdout, "expected", d_td->plaintext.data,
9013 				d_td->plaintext.len);
9014 		rte_hexdump(stdout, "actual", plaintext, d_td->plaintext.len);
9015 		ret = TEST_FAILED;
9016 		goto on_err;
9017 	}
9018 
9019 on_err:
9020 	rte_crypto_op_free(ut_params->op);
9021 	ut_params->op = NULL;
9022 
9023 	if (ut_params->sec_session)
9024 		rte_security_session_destroy(ctx, ut_params->sec_session);
9025 	ut_params->sec_session = NULL;
9026 
9027 	rte_pktmbuf_free(ut_params->ibuf);
9028 	ut_params->ibuf = NULL;
9029 
9030 	return ret;
9031 }
9032 
9033 static int
9034 test_docsis_proto_downlink(int i, struct docsis_test_data *d_td)
9035 {
9036 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9037 	struct crypto_unittest_params *ut_params = &unittest_params;
9038 	uint8_t *plaintext, *ciphertext;
9039 	uint8_t *iv_ptr;
9040 	int32_t cipher_len, crc_len;
9041 	int ret = TEST_SUCCESS;
9042 
9043 	struct rte_security_ctx *ctx = (struct rte_security_ctx *)
9044 					rte_cryptodev_get_sec_ctx(
9045 						ts_params->valid_devs[0]);
9046 
9047 	/* Verify the capabilities */
9048 	struct rte_security_capability_idx sec_cap_idx;
9049 	const struct rte_security_capability *sec_cap;
9050 	const struct rte_cryptodev_capabilities *crypto_cap;
9051 	const struct rte_cryptodev_symmetric_capability *sym_cap;
9052 	int j = 0;
9053 
9054 	sec_cap_idx.action = ut_params->type;
9055 	sec_cap_idx.protocol = RTE_SECURITY_PROTOCOL_DOCSIS;
9056 	sec_cap_idx.docsis.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9057 
9058 	sec_cap = rte_security_capability_get(ctx, &sec_cap_idx);
9059 	if (sec_cap == NULL)
9060 		return TEST_SKIPPED;
9061 
9062 	while ((crypto_cap = &sec_cap->crypto_capabilities[j++])->op !=
9063 			RTE_CRYPTO_OP_TYPE_UNDEFINED) {
9064 		if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_SYMMETRIC &&
9065 				crypto_cap->sym.xform_type ==
9066 					RTE_CRYPTO_SYM_XFORM_CIPHER &&
9067 				crypto_cap->sym.cipher.algo ==
9068 					RTE_CRYPTO_CIPHER_AES_DOCSISBPI) {
9069 			sym_cap = &crypto_cap->sym;
9070 			if (rte_cryptodev_sym_capability_check_cipher(sym_cap,
9071 						d_td->key.len,
9072 						d_td->iv.len) == 0)
9073 				break;
9074 		}
9075 	}
9076 
9077 	if (crypto_cap->op == RTE_CRYPTO_OP_TYPE_UNDEFINED)
9078 		return TEST_SKIPPED;
9079 
9080 	/* Setup source mbuf payload */
9081 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9082 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9083 			rte_pktmbuf_tailroom(ut_params->ibuf));
9084 
9085 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9086 			d_td->plaintext.len);
9087 
9088 	memcpy(plaintext, d_td->plaintext.data, d_td->plaintext.len);
9089 
9090 	/* Setup cipher session parameters */
9091 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9092 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_DOCSISBPI;
9093 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9094 	ut_params->cipher_xform.cipher.key.data = d_td->key.data;
9095 	ut_params->cipher_xform.cipher.key.length = d_td->key.len;
9096 	ut_params->cipher_xform.cipher.iv.length = d_td->iv.len;
9097 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9098 	ut_params->cipher_xform.next = NULL;
9099 
9100 	/* Setup DOCSIS session parameters */
9101 	ut_params->docsis_xform.direction = RTE_SECURITY_DOCSIS_DOWNLINK;
9102 
9103 	struct rte_security_session_conf sess_conf = {
9104 		.action_type = ut_params->type,
9105 		.protocol = RTE_SECURITY_PROTOCOL_DOCSIS,
9106 		.docsis = ut_params->docsis_xform,
9107 		.crypto_xform = &ut_params->cipher_xform,
9108 	};
9109 
9110 	/* Create security session */
9111 	ut_params->sec_session = rte_security_session_create(ctx, &sess_conf,
9112 					ts_params->session_mpool,
9113 					ts_params->session_priv_mpool);
9114 
9115 	if (!ut_params->sec_session) {
9116 		printf("TestCase %s(%d) line %d: %s\n",
9117 			__func__, i, __LINE__, "failed to allocate session");
9118 		ret = TEST_FAILED;
9119 		goto on_err;
9120 	}
9121 
9122 	/* Generate crypto op data structure */
9123 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9124 				RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9125 	if (!ut_params->op) {
9126 		printf("TestCase %s(%d) line %d: %s\n",
9127 			__func__, i, __LINE__,
9128 			"failed to allocate security crypto operation");
9129 		ret = TEST_FAILED;
9130 		goto on_err;
9131 	}
9132 
9133 	/* Setup CRC operation parameters */
9134 	crc_len = d_td->plaintext.no_crc == false ?
9135 			(d_td->plaintext.len -
9136 				d_td->plaintext.crc_offset -
9137 				RTE_ETHER_CRC_LEN) :
9138 			0;
9139 	crc_len = crc_len > 0 ? crc_len : 0;
9140 	ut_params->op->sym->auth.data.length = crc_len;
9141 	ut_params->op->sym->auth.data.offset = d_td->plaintext.crc_offset;
9142 
9143 	/* Setup cipher operation parameters */
9144 	cipher_len = d_td->plaintext.no_cipher == false ?
9145 			(d_td->plaintext.len -
9146 				d_td->plaintext.cipher_offset) :
9147 			0;
9148 	cipher_len = cipher_len > 0 ? cipher_len : 0;
9149 	ut_params->op->sym->cipher.data.length = cipher_len;
9150 	ut_params->op->sym->cipher.data.offset = d_td->plaintext.cipher_offset;
9151 
9152 	/* Setup cipher IV */
9153 	iv_ptr = (uint8_t *)ut_params->op + IV_OFFSET;
9154 	rte_memcpy(iv_ptr, d_td->iv.data, d_td->iv.len);
9155 
9156 	/* Attach session to operation */
9157 	rte_security_attach_session(ut_params->op, ut_params->sec_session);
9158 
9159 	/* Set crypto operation mbufs */
9160 	ut_params->op->sym->m_src = ut_params->ibuf;
9161 	ut_params->op->sym->m_dst = NULL;
9162 
9163 	/* Process crypto operation */
9164 	if (process_crypto_request(ts_params->valid_devs[0], ut_params->op) ==
9165 			NULL) {
9166 		printf("TestCase %s(%d) line %d: %s\n",
9167 			__func__, i, __LINE__,
9168 			"failed to process security crypto op");
9169 		ret = TEST_FAILED;
9170 		goto on_err;
9171 	}
9172 
9173 	if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
9174 		printf("TestCase %s(%d) line %d: %s\n",
9175 			__func__, i, __LINE__, "crypto op processing failed");
9176 		ret = TEST_FAILED;
9177 		goto on_err;
9178 	}
9179 
9180 	/* Validate ciphertext */
9181 	ciphertext = plaintext;
9182 
9183 	if (memcmp(ciphertext, d_td->ciphertext.data, d_td->ciphertext.len)) {
9184 		printf("TestCase %s(%d) line %d: %s\n",
9185 			__func__, i, __LINE__, "ciphertext not as expected\n");
9186 		rte_hexdump(stdout, "expected", d_td->ciphertext.data,
9187 				d_td->ciphertext.len);
9188 		rte_hexdump(stdout, "actual", ciphertext, d_td->ciphertext.len);
9189 		ret = TEST_FAILED;
9190 		goto on_err;
9191 	}
9192 
9193 on_err:
9194 	rte_crypto_op_free(ut_params->op);
9195 	ut_params->op = NULL;
9196 
9197 	if (ut_params->sec_session)
9198 		rte_security_session_destroy(ctx, ut_params->sec_session);
9199 	ut_params->sec_session = NULL;
9200 
9201 	rte_pktmbuf_free(ut_params->ibuf);
9202 	ut_params->ibuf = NULL;
9203 
9204 	return ret;
9205 }
9206 
9207 #define TEST_DOCSIS_COUNT(func) do {			\
9208 	int ret = func;					\
9209 	if (ret == TEST_SUCCESS)  {			\
9210 		printf("\t%2d)", n++);			\
9211 		printf("+++++ PASSED:" #func"\n");	\
9212 		p++;					\
9213 	} else if (ret == TEST_SKIPPED) {		\
9214 		printf("\t%2d)", n++);			\
9215 		printf("~~~~~ SKIPPED:" #func"\n");	\
9216 		s++;					\
9217 	} else {					\
9218 		printf("\t%2d)", n++);			\
9219 		printf("----- FAILED:" #func"\n");	\
9220 		f++;					\
9221 	}						\
9222 } while (0)
9223 
9224 static int
9225 test_DOCSIS_PROTO_uplink_all(void)
9226 {
9227 	int p = 0, s = 0, f = 0, n = 0;
9228 
9229 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(1, &docsis_test_case_1));
9230 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(2, &docsis_test_case_2));
9231 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(3, &docsis_test_case_3));
9232 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(4, &docsis_test_case_4));
9233 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(5, &docsis_test_case_5));
9234 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(6, &docsis_test_case_6));
9235 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(7, &docsis_test_case_7));
9236 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(8, &docsis_test_case_8));
9237 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(9, &docsis_test_case_9));
9238 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(10, &docsis_test_case_10));
9239 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(11, &docsis_test_case_11));
9240 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(12, &docsis_test_case_12));
9241 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(13, &docsis_test_case_13));
9242 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(14, &docsis_test_case_14));
9243 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(15, &docsis_test_case_15));
9244 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(16, &docsis_test_case_16));
9245 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(17, &docsis_test_case_17));
9246 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(18, &docsis_test_case_18));
9247 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(19, &docsis_test_case_19));
9248 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(20, &docsis_test_case_20));
9249 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(21, &docsis_test_case_21));
9250 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(22, &docsis_test_case_22));
9251 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(23, &docsis_test_case_23));
9252 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(24, &docsis_test_case_24));
9253 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(25, &docsis_test_case_25));
9254 	TEST_DOCSIS_COUNT(test_docsis_proto_uplink(26, &docsis_test_case_26));
9255 
9256 	if (f)
9257 		printf("## %s: %d passed out of %d (%d skipped)\n",
9258 			__func__, p, n, s);
9259 
9260 	return f;
9261 };
9262 
9263 static int
9264 test_DOCSIS_PROTO_downlink_all(void)
9265 {
9266 	int p = 0, s = 0, f = 0, n = 0;
9267 
9268 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(1, &docsis_test_case_1));
9269 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(2, &docsis_test_case_2));
9270 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(3, &docsis_test_case_3));
9271 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(4, &docsis_test_case_4));
9272 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(5, &docsis_test_case_5));
9273 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(6, &docsis_test_case_6));
9274 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(7, &docsis_test_case_7));
9275 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(8, &docsis_test_case_8));
9276 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(9, &docsis_test_case_9));
9277 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(10, &docsis_test_case_10));
9278 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(11, &docsis_test_case_11));
9279 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(12, &docsis_test_case_12));
9280 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(13, &docsis_test_case_13));
9281 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(14, &docsis_test_case_14));
9282 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(15, &docsis_test_case_15));
9283 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(16, &docsis_test_case_16));
9284 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(17, &docsis_test_case_17));
9285 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(18, &docsis_test_case_18));
9286 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(19, &docsis_test_case_19));
9287 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(20, &docsis_test_case_20));
9288 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(21, &docsis_test_case_21));
9289 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(22, &docsis_test_case_22));
9290 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(23, &docsis_test_case_23));
9291 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(24, &docsis_test_case_24));
9292 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(25, &docsis_test_case_25));
9293 	TEST_DOCSIS_COUNT(test_docsis_proto_downlink(26, &docsis_test_case_26));
9294 
9295 	if (f)
9296 		printf("## %s: %d passed out of %d (%d skipped)\n",
9297 			__func__, p, n, s);
9298 
9299 	return f;
9300 };
9301 
9302 static int
9303 test_DOCSIS_PROTO_all(void)
9304 {
9305 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9306 	struct crypto_unittest_params *ut_params = &unittest_params;
9307 	struct rte_cryptodev_info dev_info;
9308 	int status;
9309 
9310 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9311 	uint64_t feat_flags = dev_info.feature_flags;
9312 
9313 	if (!(feat_flags & RTE_CRYPTODEV_FF_SECURITY))
9314 		return TEST_SKIPPED;
9315 
9316 	/* Set action type */
9317 	ut_params->type = gbl_action_type == RTE_SECURITY_ACTION_TYPE_NONE ?
9318 		RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL :
9319 		gbl_action_type;
9320 
9321 	if (security_proto_supported(ut_params->type,
9322 			RTE_SECURITY_PROTOCOL_DOCSIS) < 0)
9323 		return TEST_SKIPPED;
9324 
9325 	status = test_DOCSIS_PROTO_uplink_all();
9326 	status += test_DOCSIS_PROTO_downlink_all();
9327 
9328 	if (status)
9329 		return TEST_FAILED;
9330 	else
9331 		return TEST_SUCCESS;
9332 }
9333 #endif
9334 
9335 static int
9336 test_AES_GCM_authenticated_encryption_test_case_1(void)
9337 {
9338 	return test_authenticated_encryption(&gcm_test_case_1);
9339 }
9340 
9341 static int
9342 test_AES_GCM_authenticated_encryption_test_case_2(void)
9343 {
9344 	return test_authenticated_encryption(&gcm_test_case_2);
9345 }
9346 
9347 static int
9348 test_AES_GCM_authenticated_encryption_test_case_3(void)
9349 {
9350 	return test_authenticated_encryption(&gcm_test_case_3);
9351 }
9352 
9353 static int
9354 test_AES_GCM_authenticated_encryption_test_case_4(void)
9355 {
9356 	return test_authenticated_encryption(&gcm_test_case_4);
9357 }
9358 
9359 static int
9360 test_AES_GCM_authenticated_encryption_test_case_5(void)
9361 {
9362 	return test_authenticated_encryption(&gcm_test_case_5);
9363 }
9364 
9365 static int
9366 test_AES_GCM_authenticated_encryption_test_case_6(void)
9367 {
9368 	return test_authenticated_encryption(&gcm_test_case_6);
9369 }
9370 
9371 static int
9372 test_AES_GCM_authenticated_encryption_test_case_7(void)
9373 {
9374 	return test_authenticated_encryption(&gcm_test_case_7);
9375 }
9376 
9377 static int
9378 test_AES_GCM_authenticated_encryption_test_case_8(void)
9379 {
9380 	return test_authenticated_encryption(&gcm_test_case_8);
9381 }
9382 
9383 static int
9384 test_AES_GCM_J0_authenticated_encryption_test_case_1(void)
9385 {
9386 	return test_authenticated_encryption(&gcm_J0_test_case_1);
9387 }
9388 
9389 static int
9390 test_AES_GCM_auth_encryption_test_case_192_1(void)
9391 {
9392 	return test_authenticated_encryption(&gcm_test_case_192_1);
9393 }
9394 
9395 static int
9396 test_AES_GCM_auth_encryption_test_case_192_2(void)
9397 {
9398 	return test_authenticated_encryption(&gcm_test_case_192_2);
9399 }
9400 
9401 static int
9402 test_AES_GCM_auth_encryption_test_case_192_3(void)
9403 {
9404 	return test_authenticated_encryption(&gcm_test_case_192_3);
9405 }
9406 
9407 static int
9408 test_AES_GCM_auth_encryption_test_case_192_4(void)
9409 {
9410 	return test_authenticated_encryption(&gcm_test_case_192_4);
9411 }
9412 
9413 static int
9414 test_AES_GCM_auth_encryption_test_case_192_5(void)
9415 {
9416 	return test_authenticated_encryption(&gcm_test_case_192_5);
9417 }
9418 
9419 static int
9420 test_AES_GCM_auth_encryption_test_case_192_6(void)
9421 {
9422 	return test_authenticated_encryption(&gcm_test_case_192_6);
9423 }
9424 
9425 static int
9426 test_AES_GCM_auth_encryption_test_case_192_7(void)
9427 {
9428 	return test_authenticated_encryption(&gcm_test_case_192_7);
9429 }
9430 
9431 static int
9432 test_AES_GCM_auth_encryption_test_case_256_1(void)
9433 {
9434 	return test_authenticated_encryption(&gcm_test_case_256_1);
9435 }
9436 
9437 static int
9438 test_AES_GCM_auth_encryption_test_case_256_2(void)
9439 {
9440 	return test_authenticated_encryption(&gcm_test_case_256_2);
9441 }
9442 
9443 static int
9444 test_AES_GCM_auth_encryption_test_case_256_3(void)
9445 {
9446 	return test_authenticated_encryption(&gcm_test_case_256_3);
9447 }
9448 
9449 static int
9450 test_AES_GCM_auth_encryption_test_case_256_4(void)
9451 {
9452 	return test_authenticated_encryption(&gcm_test_case_256_4);
9453 }
9454 
9455 static int
9456 test_AES_GCM_auth_encryption_test_case_256_5(void)
9457 {
9458 	return test_authenticated_encryption(&gcm_test_case_256_5);
9459 }
9460 
9461 static int
9462 test_AES_GCM_auth_encryption_test_case_256_6(void)
9463 {
9464 	return test_authenticated_encryption(&gcm_test_case_256_6);
9465 }
9466 
9467 static int
9468 test_AES_GCM_auth_encryption_test_case_256_7(void)
9469 {
9470 	return test_authenticated_encryption(&gcm_test_case_256_7);
9471 }
9472 
9473 static int
9474 test_AES_GCM_auth_encryption_test_case_aad_1(void)
9475 {
9476 	return test_authenticated_encryption(&gcm_test_case_aad_1);
9477 }
9478 
9479 static int
9480 test_AES_GCM_auth_encryption_test_case_aad_2(void)
9481 {
9482 	return test_authenticated_encryption(&gcm_test_case_aad_2);
9483 }
9484 
9485 static int
9486 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
9487 {
9488 	struct aead_test_data tdata;
9489 	int res;
9490 
9491 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9492 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9493 	tdata.iv.data[0] += 1;
9494 	res = test_authenticated_encryption(&tdata);
9495 	if (res == TEST_SKIPPED)
9496 		return res;
9497 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9498 	return TEST_SUCCESS;
9499 }
9500 
9501 static int
9502 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
9503 {
9504 	struct aead_test_data tdata;
9505 	int res;
9506 
9507 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9508 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9509 	tdata.plaintext.data[0] += 1;
9510 	res = test_authenticated_encryption(&tdata);
9511 	if (res == TEST_SKIPPED)
9512 		return res;
9513 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9514 	return TEST_SUCCESS;
9515 }
9516 
9517 static int
9518 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
9519 {
9520 	struct aead_test_data tdata;
9521 	int res;
9522 
9523 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9524 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9525 	tdata.ciphertext.data[0] += 1;
9526 	res = test_authenticated_encryption(&tdata);
9527 	if (res == TEST_SKIPPED)
9528 		return res;
9529 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9530 	return TEST_SUCCESS;
9531 }
9532 
9533 static int
9534 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
9535 {
9536 	struct aead_test_data tdata;
9537 	int res;
9538 
9539 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9540 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9541 	tdata.aad.len += 1;
9542 	res = test_authenticated_encryption(&tdata);
9543 	if (res == TEST_SKIPPED)
9544 		return res;
9545 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9546 	return TEST_SUCCESS;
9547 }
9548 
9549 static int
9550 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
9551 {
9552 	struct aead_test_data tdata;
9553 	uint8_t aad[gcm_test_case_7.aad.len];
9554 	int res;
9555 
9556 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9557 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9558 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9559 	aad[0] += 1;
9560 	tdata.aad.data = aad;
9561 	res = test_authenticated_encryption(&tdata);
9562 	if (res == TEST_SKIPPED)
9563 		return res;
9564 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9565 	return TEST_SUCCESS;
9566 }
9567 
9568 static int
9569 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
9570 {
9571 	struct aead_test_data tdata;
9572 	int res;
9573 
9574 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9575 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9576 	tdata.auth_tag.data[0] += 1;
9577 	res = test_authenticated_encryption(&tdata);
9578 	if (res == TEST_SKIPPED)
9579 		return res;
9580 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
9581 	return TEST_SUCCESS;
9582 }
9583 
9584 static int
9585 test_authenticated_decryption(const struct aead_test_data *tdata)
9586 {
9587 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9588 	struct crypto_unittest_params *ut_params = &unittest_params;
9589 
9590 	int retval;
9591 	uint8_t *plaintext;
9592 	uint32_t i;
9593 	struct rte_cryptodev_info dev_info;
9594 
9595 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9596 	uint64_t feat_flags = dev_info.feature_flags;
9597 
9598 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
9599 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
9600 		printf("Device doesn't support RAW data-path APIs.\n");
9601 		return TEST_SKIPPED;
9602 	}
9603 
9604 	/* Verify the capabilities */
9605 	struct rte_cryptodev_sym_capability_idx cap_idx;
9606 	const struct rte_cryptodev_symmetric_capability *capability;
9607 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9608 	cap_idx.algo.aead = tdata->algo;
9609 	capability = rte_cryptodev_sym_capability_get(
9610 			ts_params->valid_devs[0], &cap_idx);
9611 	if (capability == NULL)
9612 		return TEST_SKIPPED;
9613 	if (rte_cryptodev_sym_capability_check_aead(
9614 			capability, tdata->key.len, tdata->auth_tag.len,
9615 			tdata->aad.len, tdata->iv.len))
9616 		return TEST_SKIPPED;
9617 
9618 	/* Create AEAD session */
9619 	retval = create_aead_session(ts_params->valid_devs[0],
9620 			tdata->algo,
9621 			RTE_CRYPTO_AEAD_OP_DECRYPT,
9622 			tdata->key.data, tdata->key.len,
9623 			tdata->aad.len, tdata->auth_tag.len,
9624 			tdata->iv.len);
9625 	if (retval < 0)
9626 		return retval;
9627 
9628 	/* alloc mbuf and set payload */
9629 	if (tdata->aad.len > MBUF_SIZE) {
9630 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9631 		/* Populate full size of add data */
9632 		for (i = 32; i < MAX_AAD_LENGTH; i += 32)
9633 			memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
9634 	} else
9635 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9636 
9637 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9638 			rte_pktmbuf_tailroom(ut_params->ibuf));
9639 
9640 	/* Create AEAD operation */
9641 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9642 	if (retval < 0)
9643 		return retval;
9644 
9645 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9646 
9647 	ut_params->op->sym->m_src = ut_params->ibuf;
9648 
9649 	/* Process crypto operation */
9650 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9651 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
9652 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9653 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
9654 				ut_params->op, 0, 0, 0, 0);
9655 	else
9656 		TEST_ASSERT_NOT_NULL(
9657 			process_crypto_request(ts_params->valid_devs[0],
9658 			ut_params->op), "failed to process sym crypto op");
9659 
9660 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9661 			"crypto op processing failed");
9662 
9663 	if (ut_params->op->sym->m_dst)
9664 		plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
9665 				uint8_t *);
9666 	else
9667 		plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9668 				uint8_t *,
9669 				ut_params->op->sym->cipher.data.offset);
9670 
9671 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9672 
9673 	/* Validate obuf */
9674 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
9675 			plaintext,
9676 			tdata->plaintext.data,
9677 			tdata->plaintext.len,
9678 			"Plaintext data not as expected");
9679 
9680 	TEST_ASSERT_EQUAL(ut_params->op->status,
9681 			RTE_CRYPTO_OP_STATUS_SUCCESS,
9682 			"Authentication failed");
9683 
9684 	return 0;
9685 }
9686 
9687 static int
9688 test_AES_GCM_authenticated_decryption_test_case_1(void)
9689 {
9690 	return test_authenticated_decryption(&gcm_test_case_1);
9691 }
9692 
9693 static int
9694 test_AES_GCM_authenticated_decryption_test_case_2(void)
9695 {
9696 	return test_authenticated_decryption(&gcm_test_case_2);
9697 }
9698 
9699 static int
9700 test_AES_GCM_authenticated_decryption_test_case_3(void)
9701 {
9702 	return test_authenticated_decryption(&gcm_test_case_3);
9703 }
9704 
9705 static int
9706 test_AES_GCM_authenticated_decryption_test_case_4(void)
9707 {
9708 	return test_authenticated_decryption(&gcm_test_case_4);
9709 }
9710 
9711 static int
9712 test_AES_GCM_authenticated_decryption_test_case_5(void)
9713 {
9714 	return test_authenticated_decryption(&gcm_test_case_5);
9715 }
9716 
9717 static int
9718 test_AES_GCM_authenticated_decryption_test_case_6(void)
9719 {
9720 	return test_authenticated_decryption(&gcm_test_case_6);
9721 }
9722 
9723 static int
9724 test_AES_GCM_authenticated_decryption_test_case_7(void)
9725 {
9726 	return test_authenticated_decryption(&gcm_test_case_7);
9727 }
9728 
9729 static int
9730 test_AES_GCM_authenticated_decryption_test_case_8(void)
9731 {
9732 	return test_authenticated_decryption(&gcm_test_case_8);
9733 }
9734 
9735 static int
9736 test_AES_GCM_J0_authenticated_decryption_test_case_1(void)
9737 {
9738 	return test_authenticated_decryption(&gcm_J0_test_case_1);
9739 }
9740 
9741 static int
9742 test_AES_GCM_auth_decryption_test_case_192_1(void)
9743 {
9744 	return test_authenticated_decryption(&gcm_test_case_192_1);
9745 }
9746 
9747 static int
9748 test_AES_GCM_auth_decryption_test_case_192_2(void)
9749 {
9750 	return test_authenticated_decryption(&gcm_test_case_192_2);
9751 }
9752 
9753 static int
9754 test_AES_GCM_auth_decryption_test_case_192_3(void)
9755 {
9756 	return test_authenticated_decryption(&gcm_test_case_192_3);
9757 }
9758 
9759 static int
9760 test_AES_GCM_auth_decryption_test_case_192_4(void)
9761 {
9762 	return test_authenticated_decryption(&gcm_test_case_192_4);
9763 }
9764 
9765 static int
9766 test_AES_GCM_auth_decryption_test_case_192_5(void)
9767 {
9768 	return test_authenticated_decryption(&gcm_test_case_192_5);
9769 }
9770 
9771 static int
9772 test_AES_GCM_auth_decryption_test_case_192_6(void)
9773 {
9774 	return test_authenticated_decryption(&gcm_test_case_192_6);
9775 }
9776 
9777 static int
9778 test_AES_GCM_auth_decryption_test_case_192_7(void)
9779 {
9780 	return test_authenticated_decryption(&gcm_test_case_192_7);
9781 }
9782 
9783 static int
9784 test_AES_GCM_auth_decryption_test_case_256_1(void)
9785 {
9786 	return test_authenticated_decryption(&gcm_test_case_256_1);
9787 }
9788 
9789 static int
9790 test_AES_GCM_auth_decryption_test_case_256_2(void)
9791 {
9792 	return test_authenticated_decryption(&gcm_test_case_256_2);
9793 }
9794 
9795 static int
9796 test_AES_GCM_auth_decryption_test_case_256_3(void)
9797 {
9798 	return test_authenticated_decryption(&gcm_test_case_256_3);
9799 }
9800 
9801 static int
9802 test_AES_GCM_auth_decryption_test_case_256_4(void)
9803 {
9804 	return test_authenticated_decryption(&gcm_test_case_256_4);
9805 }
9806 
9807 static int
9808 test_AES_GCM_auth_decryption_test_case_256_5(void)
9809 {
9810 	return test_authenticated_decryption(&gcm_test_case_256_5);
9811 }
9812 
9813 static int
9814 test_AES_GCM_auth_decryption_test_case_256_6(void)
9815 {
9816 	return test_authenticated_decryption(&gcm_test_case_256_6);
9817 }
9818 
9819 static int
9820 test_AES_GCM_auth_decryption_test_case_256_7(void)
9821 {
9822 	return test_authenticated_decryption(&gcm_test_case_256_7);
9823 }
9824 
9825 static int
9826 test_AES_GCM_auth_decryption_test_case_aad_1(void)
9827 {
9828 	return test_authenticated_decryption(&gcm_test_case_aad_1);
9829 }
9830 
9831 static int
9832 test_AES_GCM_auth_decryption_test_case_aad_2(void)
9833 {
9834 	return test_authenticated_decryption(&gcm_test_case_aad_2);
9835 }
9836 
9837 static int
9838 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
9839 {
9840 	struct aead_test_data tdata;
9841 	int res;
9842 
9843 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9844 	tdata.iv.data[0] += 1;
9845 	res = test_authenticated_decryption(&tdata);
9846 	if (res == TEST_SKIPPED)
9847 		return res;
9848 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9849 	return TEST_SUCCESS;
9850 }
9851 
9852 static int
9853 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
9854 {
9855 	struct aead_test_data tdata;
9856 	int res;
9857 
9858 	RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
9859 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9860 	tdata.plaintext.data[0] += 1;
9861 	res = test_authenticated_decryption(&tdata);
9862 	if (res == TEST_SKIPPED)
9863 		return res;
9864 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9865 	return TEST_SUCCESS;
9866 }
9867 
9868 static int
9869 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
9870 {
9871 	struct aead_test_data tdata;
9872 	int res;
9873 
9874 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9875 	tdata.ciphertext.data[0] += 1;
9876 	res = test_authenticated_decryption(&tdata);
9877 	if (res == TEST_SKIPPED)
9878 		return res;
9879 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9880 	return TEST_SUCCESS;
9881 }
9882 
9883 static int
9884 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
9885 {
9886 	struct aead_test_data tdata;
9887 	int res;
9888 
9889 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9890 	tdata.aad.len += 1;
9891 	res = test_authenticated_decryption(&tdata);
9892 	if (res == TEST_SKIPPED)
9893 		return res;
9894 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9895 	return TEST_SUCCESS;
9896 }
9897 
9898 static int
9899 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9900 {
9901 	struct aead_test_data tdata;
9902 	uint8_t aad[gcm_test_case_7.aad.len];
9903 	int res;
9904 
9905 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9906 	memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9907 	aad[0] += 1;
9908 	tdata.aad.data = aad;
9909 	res = test_authenticated_decryption(&tdata);
9910 	if (res == TEST_SKIPPED)
9911 		return res;
9912 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9913 	return TEST_SUCCESS;
9914 }
9915 
9916 static int
9917 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9918 {
9919 	struct aead_test_data tdata;
9920 	int res;
9921 
9922 	memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9923 	tdata.auth_tag.data[0] += 1;
9924 	res = test_authenticated_decryption(&tdata);
9925 	if (res == TEST_SKIPPED)
9926 		return res;
9927 	TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9928 	return TEST_SUCCESS;
9929 }
9930 
9931 static int
9932 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9933 {
9934 	struct crypto_testsuite_params *ts_params = &testsuite_params;
9935 	struct crypto_unittest_params *ut_params = &unittest_params;
9936 
9937 	int retval;
9938 	uint8_t *ciphertext, *auth_tag;
9939 	uint16_t plaintext_pad_len;
9940 
9941 	/* Verify the capabilities */
9942 	struct rte_cryptodev_sym_capability_idx cap_idx;
9943 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
9944 	cap_idx.algo.aead = tdata->algo;
9945 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
9946 			&cap_idx) == NULL)
9947 		return TEST_SKIPPED;
9948 
9949 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
9950 		return TEST_SKIPPED;
9951 
9952 	/* not supported with CPU crypto */
9953 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
9954 		return TEST_SKIPPED;
9955 
9956 	/* Create AEAD session */
9957 	retval = create_aead_session(ts_params->valid_devs[0],
9958 			tdata->algo,
9959 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
9960 			tdata->key.data, tdata->key.len,
9961 			tdata->aad.len, tdata->auth_tag.len,
9962 			tdata->iv.len);
9963 	if (retval < 0)
9964 		return retval;
9965 
9966 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9967 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9968 
9969 	/* clear mbuf payload */
9970 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9971 			rte_pktmbuf_tailroom(ut_params->ibuf));
9972 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9973 			rte_pktmbuf_tailroom(ut_params->obuf));
9974 
9975 	/* Create AEAD operation */
9976 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9977 	if (retval < 0)
9978 		return retval;
9979 
9980 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9981 
9982 	ut_params->op->sym->m_src = ut_params->ibuf;
9983 	ut_params->op->sym->m_dst = ut_params->obuf;
9984 
9985 	/* Process crypto operation */
9986 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9987 			ut_params->op), "failed to process sym crypto op");
9988 
9989 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9990 			"crypto op processing failed");
9991 
9992 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9993 
9994 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9995 			ut_params->op->sym->cipher.data.offset);
9996 	auth_tag = ciphertext + plaintext_pad_len;
9997 
9998 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9999 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10000 
10001 	/* Validate obuf */
10002 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10003 			ciphertext,
10004 			tdata->ciphertext.data,
10005 			tdata->ciphertext.len,
10006 			"Ciphertext data not as expected");
10007 
10008 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10009 			auth_tag,
10010 			tdata->auth_tag.data,
10011 			tdata->auth_tag.len,
10012 			"Generated auth tag not as expected");
10013 
10014 	return 0;
10015 
10016 }
10017 
10018 static int
10019 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
10020 {
10021 	return test_authenticated_encryption_oop(&gcm_test_case_5);
10022 }
10023 
10024 static int
10025 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
10026 {
10027 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10028 	struct crypto_unittest_params *ut_params = &unittest_params;
10029 
10030 	int retval;
10031 	uint8_t *plaintext;
10032 
10033 	/* Verify the capabilities */
10034 	struct rte_cryptodev_sym_capability_idx cap_idx;
10035 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10036 	cap_idx.algo.aead = tdata->algo;
10037 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10038 			&cap_idx) == NULL)
10039 		return TEST_SKIPPED;
10040 
10041 	/* not supported with CPU crypto and raw data-path APIs*/
10042 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO ||
10043 			global_api_test_type == CRYPTODEV_RAW_API_TEST)
10044 		return TEST_SKIPPED;
10045 
10046 	/* Create AEAD session */
10047 	retval = create_aead_session(ts_params->valid_devs[0],
10048 			tdata->algo,
10049 			RTE_CRYPTO_AEAD_OP_DECRYPT,
10050 			tdata->key.data, tdata->key.len,
10051 			tdata->aad.len, tdata->auth_tag.len,
10052 			tdata->iv.len);
10053 	if (retval < 0)
10054 		return retval;
10055 
10056 	/* alloc mbuf and set payload */
10057 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10058 	ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10059 
10060 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10061 			rte_pktmbuf_tailroom(ut_params->ibuf));
10062 	memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
10063 			rte_pktmbuf_tailroom(ut_params->obuf));
10064 
10065 	/* Create AEAD operation */
10066 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10067 	if (retval < 0)
10068 		return retval;
10069 
10070 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10071 
10072 	ut_params->op->sym->m_src = ut_params->ibuf;
10073 	ut_params->op->sym->m_dst = ut_params->obuf;
10074 
10075 	/* Process crypto operation */
10076 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10077 			ut_params->op), "failed to process sym crypto op");
10078 
10079 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10080 			"crypto op processing failed");
10081 
10082 	plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
10083 			ut_params->op->sym->cipher.data.offset);
10084 
10085 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10086 
10087 	/* Validate obuf */
10088 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10089 			plaintext,
10090 			tdata->plaintext.data,
10091 			tdata->plaintext.len,
10092 			"Plaintext data not as expected");
10093 
10094 	TEST_ASSERT_EQUAL(ut_params->op->status,
10095 			RTE_CRYPTO_OP_STATUS_SUCCESS,
10096 			"Authentication failed");
10097 	return 0;
10098 }
10099 
10100 static int
10101 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
10102 {
10103 	return test_authenticated_decryption_oop(&gcm_test_case_5);
10104 }
10105 
10106 static int
10107 test_authenticated_encryption_sessionless(
10108 		const struct aead_test_data *tdata)
10109 {
10110 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10111 	struct crypto_unittest_params *ut_params = &unittest_params;
10112 
10113 	int retval;
10114 	uint8_t *ciphertext, *auth_tag;
10115 	uint16_t plaintext_pad_len;
10116 	uint8_t key[tdata->key.len + 1];
10117 	struct rte_cryptodev_info dev_info;
10118 
10119 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10120 	uint64_t feat_flags = dev_info.feature_flags;
10121 
10122 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10123 		printf("Device doesn't support Sessionless ops.\n");
10124 		return TEST_SKIPPED;
10125 	}
10126 
10127 	/* not supported with CPU crypto */
10128 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10129 		return TEST_SKIPPED;
10130 
10131 	/* Verify the capabilities */
10132 	struct rte_cryptodev_sym_capability_idx cap_idx;
10133 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10134 	cap_idx.algo.aead = tdata->algo;
10135 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10136 			&cap_idx) == NULL)
10137 		return TEST_SKIPPED;
10138 
10139 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10140 
10141 	/* clear mbuf payload */
10142 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10143 			rte_pktmbuf_tailroom(ut_params->ibuf));
10144 
10145 	/* Create AEAD operation */
10146 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
10147 	if (retval < 0)
10148 		return retval;
10149 
10150 	/* Create GCM xform */
10151 	memcpy(key, tdata->key.data, tdata->key.len);
10152 	retval = create_aead_xform(ut_params->op,
10153 			tdata->algo,
10154 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
10155 			key, tdata->key.len,
10156 			tdata->aad.len, tdata->auth_tag.len,
10157 			tdata->iv.len);
10158 	if (retval < 0)
10159 		return retval;
10160 
10161 	ut_params->op->sym->m_src = ut_params->ibuf;
10162 
10163 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10164 			RTE_CRYPTO_OP_SESSIONLESS,
10165 			"crypto op session type not sessionless");
10166 
10167 	/* Process crypto operation */
10168 	TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10169 			ut_params->op), "failed to process sym crypto op");
10170 
10171 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10172 
10173 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10174 			"crypto op status not success");
10175 
10176 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10177 
10178 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10179 			ut_params->op->sym->cipher.data.offset);
10180 	auth_tag = ciphertext + plaintext_pad_len;
10181 
10182 	debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
10183 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
10184 
10185 	/* Validate obuf */
10186 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10187 			ciphertext,
10188 			tdata->ciphertext.data,
10189 			tdata->ciphertext.len,
10190 			"Ciphertext data not as expected");
10191 
10192 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10193 			auth_tag,
10194 			tdata->auth_tag.data,
10195 			tdata->auth_tag.len,
10196 			"Generated auth tag not as expected");
10197 
10198 	return 0;
10199 
10200 }
10201 
10202 static int
10203 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
10204 {
10205 	return test_authenticated_encryption_sessionless(
10206 			&gcm_test_case_5);
10207 }
10208 
10209 static int
10210 test_authenticated_decryption_sessionless(
10211 		const struct aead_test_data *tdata)
10212 {
10213 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10214 	struct crypto_unittest_params *ut_params = &unittest_params;
10215 
10216 	int retval;
10217 	uint8_t *plaintext;
10218 	uint8_t key[tdata->key.len + 1];
10219 	struct rte_cryptodev_info dev_info;
10220 
10221 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10222 	uint64_t feat_flags = dev_info.feature_flags;
10223 
10224 	if (!(feat_flags & RTE_CRYPTODEV_FF_SYM_SESSIONLESS)) {
10225 		printf("Device doesn't support Sessionless ops.\n");
10226 		return TEST_SKIPPED;
10227 	}
10228 
10229 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10230 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10231 		printf("Device doesn't support RAW data-path APIs.\n");
10232 		return TEST_SKIPPED;
10233 	}
10234 
10235 	/* not supported with CPU crypto */
10236 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10237 		return TEST_SKIPPED;
10238 
10239 	/* Verify the capabilities */
10240 	struct rte_cryptodev_sym_capability_idx cap_idx;
10241 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
10242 	cap_idx.algo.aead = tdata->algo;
10243 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10244 			&cap_idx) == NULL)
10245 		return TEST_SKIPPED;
10246 
10247 	/* alloc mbuf and set payload */
10248 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10249 
10250 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10251 			rte_pktmbuf_tailroom(ut_params->ibuf));
10252 
10253 	/* Create AEAD operation */
10254 	retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
10255 	if (retval < 0)
10256 		return retval;
10257 
10258 	/* Create AEAD xform */
10259 	memcpy(key, tdata->key.data, tdata->key.len);
10260 	retval = create_aead_xform(ut_params->op,
10261 			tdata->algo,
10262 			RTE_CRYPTO_AEAD_OP_DECRYPT,
10263 			key, tdata->key.len,
10264 			tdata->aad.len, tdata->auth_tag.len,
10265 			tdata->iv.len);
10266 	if (retval < 0)
10267 		return retval;
10268 
10269 	ut_params->op->sym->m_src = ut_params->ibuf;
10270 
10271 	TEST_ASSERT_EQUAL(ut_params->op->sess_type,
10272 			RTE_CRYPTO_OP_SESSIONLESS,
10273 			"crypto op session type not sessionless");
10274 
10275 	/* Process crypto operation */
10276 	if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10277 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10278 				ut_params->op, 0, 0, 0, 0);
10279 	else
10280 		TEST_ASSERT_NOT_NULL(process_crypto_request(
10281 			ts_params->valid_devs[0], ut_params->op),
10282 				"failed to process sym crypto op");
10283 
10284 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10285 
10286 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10287 			"crypto op status not success");
10288 
10289 	plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10290 			ut_params->op->sym->cipher.data.offset);
10291 
10292 	debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
10293 
10294 	/* Validate obuf */
10295 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10296 			plaintext,
10297 			tdata->plaintext.data,
10298 			tdata->plaintext.len,
10299 			"Plaintext data not as expected");
10300 
10301 	TEST_ASSERT_EQUAL(ut_params->op->status,
10302 			RTE_CRYPTO_OP_STATUS_SUCCESS,
10303 			"Authentication failed");
10304 	return 0;
10305 }
10306 
10307 static int
10308 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
10309 {
10310 	return test_authenticated_decryption_sessionless(
10311 			&gcm_test_case_5);
10312 }
10313 
10314 static int
10315 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
10316 {
10317 	return test_authenticated_encryption(&ccm_test_case_128_1);
10318 }
10319 
10320 static int
10321 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
10322 {
10323 	return test_authenticated_encryption(&ccm_test_case_128_2);
10324 }
10325 
10326 static int
10327 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
10328 {
10329 	return test_authenticated_encryption(&ccm_test_case_128_3);
10330 }
10331 
10332 static int
10333 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
10334 {
10335 	return test_authenticated_decryption(&ccm_test_case_128_1);
10336 }
10337 
10338 static int
10339 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
10340 {
10341 	return test_authenticated_decryption(&ccm_test_case_128_2);
10342 }
10343 
10344 static int
10345 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
10346 {
10347 	return test_authenticated_decryption(&ccm_test_case_128_3);
10348 }
10349 
10350 static int
10351 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
10352 {
10353 	return test_authenticated_encryption(&ccm_test_case_192_1);
10354 }
10355 
10356 static int
10357 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
10358 {
10359 	return test_authenticated_encryption(&ccm_test_case_192_2);
10360 }
10361 
10362 static int
10363 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
10364 {
10365 	return test_authenticated_encryption(&ccm_test_case_192_3);
10366 }
10367 
10368 static int
10369 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
10370 {
10371 	return test_authenticated_decryption(&ccm_test_case_192_1);
10372 }
10373 
10374 static int
10375 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
10376 {
10377 	return test_authenticated_decryption(&ccm_test_case_192_2);
10378 }
10379 
10380 static int
10381 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
10382 {
10383 	return test_authenticated_decryption(&ccm_test_case_192_3);
10384 }
10385 
10386 static int
10387 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
10388 {
10389 	return test_authenticated_encryption(&ccm_test_case_256_1);
10390 }
10391 
10392 static int
10393 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
10394 {
10395 	return test_authenticated_encryption(&ccm_test_case_256_2);
10396 }
10397 
10398 static int
10399 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
10400 {
10401 	return test_authenticated_encryption(&ccm_test_case_256_3);
10402 }
10403 
10404 static int
10405 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
10406 {
10407 	return test_authenticated_decryption(&ccm_test_case_256_1);
10408 }
10409 
10410 static int
10411 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
10412 {
10413 	return test_authenticated_decryption(&ccm_test_case_256_2);
10414 }
10415 
10416 static int
10417 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
10418 {
10419 	return test_authenticated_decryption(&ccm_test_case_256_3);
10420 }
10421 
10422 static int
10423 test_stats(void)
10424 {
10425 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10426 	struct rte_cryptodev_stats stats;
10427 
10428 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10429 		return TEST_SKIPPED;
10430 
10431 	/* Verify the capabilities */
10432 	struct rte_cryptodev_sym_capability_idx cap_idx;
10433 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10434 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA1_HMAC;
10435 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10436 			&cap_idx) == NULL)
10437 		return TEST_SKIPPED;
10438 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10439 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10440 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10441 			&cap_idx) == NULL)
10442 		return TEST_SKIPPED;
10443 
10444 	if (rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
10445 			== -ENOTSUP)
10446 		return TEST_SKIPPED;
10447 
10448 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10449 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
10450 			&stats) == -ENODEV),
10451 		"rte_cryptodev_stats_get invalid dev failed");
10452 	TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
10453 		"rte_cryptodev_stats_get invalid Param failed");
10454 
10455 	/* Test expected values */
10456 	test_AES_CBC_HMAC_SHA1_encrypt_digest();
10457 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10458 			&stats),
10459 		"rte_cryptodev_stats_get failed");
10460 	TEST_ASSERT((stats.enqueued_count == 1),
10461 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
10462 	TEST_ASSERT((stats.dequeued_count == 1),
10463 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
10464 	TEST_ASSERT((stats.enqueue_err_count == 0),
10465 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
10466 	TEST_ASSERT((stats.dequeue_err_count == 0),
10467 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
10468 
10469 	/* invalid device but should ignore and not reset device stats*/
10470 	rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
10471 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10472 			&stats),
10473 		"rte_cryptodev_stats_get failed");
10474 	TEST_ASSERT((stats.enqueued_count == 1),
10475 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
10476 
10477 	/* check that a valid reset clears stats */
10478 	rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
10479 	TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
10480 			&stats),
10481 					  "rte_cryptodev_stats_get failed");
10482 	TEST_ASSERT((stats.enqueued_count == 0),
10483 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
10484 	TEST_ASSERT((stats.dequeued_count == 0),
10485 		"rte_cryptodev_stats_get returned unexpected enqueued stat");
10486 
10487 	return TEST_SUCCESS;
10488 }
10489 
10490 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
10491 				   struct crypto_unittest_params *ut_params,
10492 				   enum rte_crypto_auth_operation op,
10493 				   const struct HMAC_MD5_vector *test_case)
10494 {
10495 	uint8_t key[64];
10496 
10497 	memcpy(key, test_case->key.data, test_case->key.len);
10498 
10499 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10500 	ut_params->auth_xform.next = NULL;
10501 	ut_params->auth_xform.auth.op = op;
10502 
10503 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
10504 
10505 	ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
10506 	ut_params->auth_xform.auth.key.length = test_case->key.len;
10507 	ut_params->auth_xform.auth.key.data = key;
10508 
10509 	ut_params->sess = rte_cryptodev_sym_session_create(
10510 			ts_params->session_mpool);
10511 
10512 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10513 			ut_params->sess, &ut_params->auth_xform,
10514 			ts_params->session_priv_mpool);
10515 
10516 	if (ut_params->sess == NULL)
10517 		return TEST_FAILED;
10518 
10519 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10520 
10521 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10522 			rte_pktmbuf_tailroom(ut_params->ibuf));
10523 
10524 	return 0;
10525 }
10526 
10527 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
10528 			      const struct HMAC_MD5_vector *test_case,
10529 			      uint8_t **plaintext)
10530 {
10531 	uint16_t plaintext_pad_len;
10532 
10533 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10534 
10535 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10536 				16);
10537 
10538 	*plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10539 			plaintext_pad_len);
10540 	memcpy(*plaintext, test_case->plaintext.data,
10541 			test_case->plaintext.len);
10542 
10543 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10544 			ut_params->ibuf, MD5_DIGEST_LEN);
10545 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10546 			"no room to append digest");
10547 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10548 			ut_params->ibuf, plaintext_pad_len);
10549 
10550 	if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10551 		rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
10552 			   test_case->auth_tag.len);
10553 	}
10554 
10555 	sym_op->auth.data.offset = 0;
10556 	sym_op->auth.data.length = test_case->plaintext.len;
10557 
10558 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10559 	ut_params->op->sym->m_src = ut_params->ibuf;
10560 
10561 	return 0;
10562 }
10563 
10564 static int
10565 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
10566 {
10567 	uint16_t plaintext_pad_len;
10568 	uint8_t *plaintext, *auth_tag;
10569 
10570 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10571 	struct crypto_unittest_params *ut_params = &unittest_params;
10572 	struct rte_cryptodev_info dev_info;
10573 
10574 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10575 	uint64_t feat_flags = dev_info.feature_flags;
10576 
10577 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10578 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10579 		printf("Device doesn't support RAW data-path APIs.\n");
10580 		return TEST_SKIPPED;
10581 	}
10582 
10583 	/* Verify the capabilities */
10584 	struct rte_cryptodev_sym_capability_idx cap_idx;
10585 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10586 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10587 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10588 			&cap_idx) == NULL)
10589 		return TEST_SKIPPED;
10590 
10591 	if (MD5_HMAC_create_session(ts_params, ut_params,
10592 			RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
10593 		return TEST_FAILED;
10594 
10595 	/* Generate Crypto op data structure */
10596 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10597 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10598 	TEST_ASSERT_NOT_NULL(ut_params->op,
10599 			"Failed to allocate symmetric crypto operation struct");
10600 
10601 	plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
10602 				16);
10603 
10604 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10605 		return TEST_FAILED;
10606 
10607 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10608 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10609 			ut_params->op);
10610 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10611 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10612 				ut_params->op, 0, 1, 0, 0);
10613 	else
10614 		TEST_ASSERT_NOT_NULL(
10615 			process_crypto_request(ts_params->valid_devs[0],
10616 				ut_params->op),
10617 				"failed to process sym crypto op");
10618 
10619 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10620 			"crypto op processing failed");
10621 
10622 	if (ut_params->op->sym->m_dst) {
10623 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10624 				uint8_t *, plaintext_pad_len);
10625 	} else {
10626 		auth_tag = plaintext + plaintext_pad_len;
10627 	}
10628 
10629 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
10630 			auth_tag,
10631 			test_case->auth_tag.data,
10632 			test_case->auth_tag.len,
10633 			"HMAC_MD5 generated tag not as expected");
10634 
10635 	return TEST_SUCCESS;
10636 }
10637 
10638 static int
10639 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
10640 {
10641 	uint8_t *plaintext;
10642 
10643 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10644 	struct crypto_unittest_params *ut_params = &unittest_params;
10645 	struct rte_cryptodev_info dev_info;
10646 
10647 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10648 	uint64_t feat_flags = dev_info.feature_flags;
10649 
10650 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
10651 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
10652 		printf("Device doesn't support RAW data-path APIs.\n");
10653 		return TEST_SKIPPED;
10654 	}
10655 
10656 	/* Verify the capabilities */
10657 	struct rte_cryptodev_sym_capability_idx cap_idx;
10658 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10659 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_MD5_HMAC;
10660 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10661 			&cap_idx) == NULL)
10662 		return TEST_SKIPPED;
10663 
10664 	if (MD5_HMAC_create_session(ts_params, ut_params,
10665 			RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
10666 		return TEST_FAILED;
10667 	}
10668 
10669 	/* Generate Crypto op data structure */
10670 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10671 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10672 	TEST_ASSERT_NOT_NULL(ut_params->op,
10673 			"Failed to allocate symmetric crypto operation struct");
10674 
10675 	if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
10676 		return TEST_FAILED;
10677 
10678 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
10679 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
10680 			ut_params->op);
10681 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
10682 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
10683 				ut_params->op, 0, 1, 0, 0);
10684 	else
10685 		TEST_ASSERT_NOT_NULL(
10686 			process_crypto_request(ts_params->valid_devs[0],
10687 				ut_params->op),
10688 				"failed to process sym crypto op");
10689 
10690 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10691 			"HMAC_MD5 crypto op processing failed");
10692 
10693 	return TEST_SUCCESS;
10694 }
10695 
10696 static int
10697 test_MD5_HMAC_generate_case_1(void)
10698 {
10699 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
10700 }
10701 
10702 static int
10703 test_MD5_HMAC_verify_case_1(void)
10704 {
10705 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
10706 }
10707 
10708 static int
10709 test_MD5_HMAC_generate_case_2(void)
10710 {
10711 	return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
10712 }
10713 
10714 static int
10715 test_MD5_HMAC_verify_case_2(void)
10716 {
10717 	return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
10718 }
10719 
10720 static int
10721 test_multi_session(void)
10722 {
10723 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10724 	struct crypto_unittest_params *ut_params = &unittest_params;
10725 
10726 	struct rte_cryptodev_info dev_info;
10727 	struct rte_cryptodev_sym_session **sessions;
10728 
10729 	uint16_t i;
10730 
10731 	/* Verify the capabilities */
10732 	struct rte_cryptodev_sym_capability_idx cap_idx;
10733 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10734 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10735 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10736 			&cap_idx) == NULL)
10737 		return TEST_SKIPPED;
10738 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10739 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10740 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10741 			&cap_idx) == NULL)
10742 		return TEST_SKIPPED;
10743 
10744 	test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
10745 			aes_cbc_key, hmac_sha512_key);
10746 
10747 
10748 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10749 
10750 	sessions = rte_malloc(NULL,
10751 			(sizeof(struct rte_cryptodev_sym_session *) *
10752 			MAX_NB_SESSIONS) + 1, 0);
10753 
10754 	/* Create multiple crypto sessions*/
10755 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
10756 
10757 		sessions[i] = rte_cryptodev_sym_session_create(
10758 				ts_params->session_mpool);
10759 
10760 		rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10761 				sessions[i], &ut_params->auth_xform,
10762 				ts_params->session_priv_mpool);
10763 		TEST_ASSERT_NOT_NULL(sessions[i],
10764 				"Session creation failed at session number %u",
10765 				i);
10766 
10767 		/* Attempt to send a request on each session */
10768 		TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
10769 			sessions[i],
10770 			ut_params,
10771 			ts_params,
10772 			catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
10773 			catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
10774 			aes_cbc_iv),
10775 			"Failed to perform decrypt on request number %u.", i);
10776 		/* free crypto operation structure */
10777 		if (ut_params->op)
10778 			rte_crypto_op_free(ut_params->op);
10779 
10780 		/*
10781 		 * free mbuf - both obuf and ibuf are usually the same,
10782 		 * so check if they point at the same address is necessary,
10783 		 * to avoid freeing the mbuf twice.
10784 		 */
10785 		if (ut_params->obuf) {
10786 			rte_pktmbuf_free(ut_params->obuf);
10787 			if (ut_params->ibuf == ut_params->obuf)
10788 				ut_params->ibuf = 0;
10789 			ut_params->obuf = 0;
10790 		}
10791 		if (ut_params->ibuf) {
10792 			rte_pktmbuf_free(ut_params->ibuf);
10793 			ut_params->ibuf = 0;
10794 		}
10795 	}
10796 
10797 	/* Next session create should fail */
10798 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10799 			sessions[i], &ut_params->auth_xform,
10800 			ts_params->session_priv_mpool);
10801 	TEST_ASSERT_NULL(sessions[i],
10802 			"Session creation succeeded unexpectedly!");
10803 
10804 	for (i = 0; i < MAX_NB_SESSIONS; i++) {
10805 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10806 				sessions[i]);
10807 		rte_cryptodev_sym_session_free(sessions[i]);
10808 	}
10809 
10810 	rte_free(sessions);
10811 
10812 	return TEST_SUCCESS;
10813 }
10814 
10815 struct multi_session_params {
10816 	struct crypto_unittest_params ut_params;
10817 	uint8_t *cipher_key;
10818 	uint8_t *hmac_key;
10819 	const uint8_t *cipher;
10820 	const uint8_t *digest;
10821 	uint8_t *iv;
10822 };
10823 
10824 #define MB_SESSION_NUMBER 3
10825 
10826 static int
10827 test_multi_session_random_usage(void)
10828 {
10829 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10830 	struct rte_cryptodev_info dev_info;
10831 	struct rte_cryptodev_sym_session **sessions;
10832 	uint32_t i, j;
10833 	struct multi_session_params ut_paramz[] = {
10834 
10835 		{
10836 			.cipher_key = ms_aes_cbc_key0,
10837 			.hmac_key = ms_hmac_key0,
10838 			.cipher = ms_aes_cbc_cipher0,
10839 			.digest = ms_hmac_digest0,
10840 			.iv = ms_aes_cbc_iv0
10841 		},
10842 		{
10843 			.cipher_key = ms_aes_cbc_key1,
10844 			.hmac_key = ms_hmac_key1,
10845 			.cipher = ms_aes_cbc_cipher1,
10846 			.digest = ms_hmac_digest1,
10847 			.iv = ms_aes_cbc_iv1
10848 		},
10849 		{
10850 			.cipher_key = ms_aes_cbc_key2,
10851 			.hmac_key = ms_hmac_key2,
10852 			.cipher = ms_aes_cbc_cipher2,
10853 			.digest = ms_hmac_digest2,
10854 			.iv = ms_aes_cbc_iv2
10855 		},
10856 
10857 	};
10858 
10859 	/* Verify the capabilities */
10860 	struct rte_cryptodev_sym_capability_idx cap_idx;
10861 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10862 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_SHA512_HMAC;
10863 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10864 			&cap_idx) == NULL)
10865 		return TEST_SKIPPED;
10866 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10867 	cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_AES_CBC;
10868 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
10869 			&cap_idx) == NULL)
10870 		return TEST_SKIPPED;
10871 
10872 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
10873 
10874 	sessions = rte_malloc(NULL,
10875 			(sizeof(struct rte_cryptodev_sym_session *)
10876 					* MAX_NB_SESSIONS) + 1, 0);
10877 
10878 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
10879 		sessions[i] = rte_cryptodev_sym_session_create(
10880 				ts_params->session_mpool);
10881 
10882 		rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
10883 				sizeof(struct crypto_unittest_params));
10884 
10885 		test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
10886 				&ut_paramz[i].ut_params,
10887 				ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
10888 
10889 		/* Create multiple crypto sessions*/
10890 		rte_cryptodev_sym_session_init(
10891 				ts_params->valid_devs[0],
10892 				sessions[i],
10893 				&ut_paramz[i].ut_params.auth_xform,
10894 				ts_params->session_priv_mpool);
10895 
10896 		TEST_ASSERT_NOT_NULL(sessions[i],
10897 				"Session creation failed at session number %u",
10898 				i);
10899 
10900 	}
10901 
10902 	srand(time(NULL));
10903 	for (i = 0; i < 40000; i++) {
10904 
10905 		j = rand() % MB_SESSION_NUMBER;
10906 
10907 		TEST_ASSERT_SUCCESS(
10908 			test_AES_CBC_HMAC_SHA512_decrypt_perform(
10909 					sessions[j],
10910 					&ut_paramz[j].ut_params,
10911 					ts_params, ut_paramz[j].cipher,
10912 					ut_paramz[j].digest,
10913 					ut_paramz[j].iv),
10914 			"Failed to perform decrypt on request number %u.", i);
10915 
10916 		if (ut_paramz[j].ut_params.op)
10917 			rte_crypto_op_free(ut_paramz[j].ut_params.op);
10918 
10919 		/*
10920 		 * free mbuf - both obuf and ibuf are usually the same,
10921 		 * so check if they point at the same address is necessary,
10922 		 * to avoid freeing the mbuf twice.
10923 		 */
10924 		if (ut_paramz[j].ut_params.obuf) {
10925 			rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
10926 			if (ut_paramz[j].ut_params.ibuf
10927 					== ut_paramz[j].ut_params.obuf)
10928 				ut_paramz[j].ut_params.ibuf = 0;
10929 			ut_paramz[j].ut_params.obuf = 0;
10930 		}
10931 		if (ut_paramz[j].ut_params.ibuf) {
10932 			rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
10933 			ut_paramz[j].ut_params.ibuf = 0;
10934 		}
10935 	}
10936 
10937 	for (i = 0; i < MB_SESSION_NUMBER; i++) {
10938 		rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
10939 				sessions[i]);
10940 		rte_cryptodev_sym_session_free(sessions[i]);
10941 	}
10942 
10943 	rte_free(sessions);
10944 
10945 	return TEST_SUCCESS;
10946 }
10947 
10948 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
10949 			0xab, 0xab, 0xab, 0xab,
10950 			0xab, 0xab, 0xab, 0xab,
10951 			0xab, 0xab, 0xab, 0xab};
10952 
10953 static int
10954 test_null_invalid_operation(void)
10955 {
10956 	struct crypto_testsuite_params *ts_params = &testsuite_params;
10957 	struct crypto_unittest_params *ut_params = &unittest_params;
10958 	int ret;
10959 
10960 	/* This test is for NULL PMD only */
10961 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
10962 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
10963 		return TEST_SKIPPED;
10964 
10965 	/* Setup Cipher Parameters */
10966 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10967 	ut_params->cipher_xform.next = NULL;
10968 
10969 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10970 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10971 
10972 	ut_params->sess = rte_cryptodev_sym_session_create(
10973 			ts_params->session_mpool);
10974 
10975 	/* Create Crypto session*/
10976 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10977 			ut_params->sess, &ut_params->cipher_xform,
10978 			ts_params->session_priv_mpool);
10979 	TEST_ASSERT(ret < 0,
10980 			"Session creation succeeded unexpectedly");
10981 
10982 
10983 	/* Setup HMAC Parameters */
10984 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10985 	ut_params->auth_xform.next = NULL;
10986 
10987 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10988 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10989 
10990 	ut_params->sess = rte_cryptodev_sym_session_create(
10991 			ts_params->session_mpool);
10992 
10993 	/* Create Crypto session*/
10994 	ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10995 			ut_params->sess, &ut_params->auth_xform,
10996 			ts_params->session_priv_mpool);
10997 	TEST_ASSERT(ret < 0,
10998 			"Session creation succeeded unexpectedly");
10999 
11000 	return TEST_SUCCESS;
11001 }
11002 
11003 
11004 #define NULL_BURST_LENGTH (32)
11005 
11006 static int
11007 test_null_burst_operation(void)
11008 {
11009 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11010 	struct crypto_unittest_params *ut_params = &unittest_params;
11011 
11012 	unsigned i, burst_len = NULL_BURST_LENGTH;
11013 
11014 	struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
11015 	struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
11016 
11017 	/* This test is for NULL PMD only */
11018 	if (gbl_driver_id != rte_cryptodev_driver_id_get(
11019 			RTE_STR(CRYPTODEV_NAME_NULL_PMD)))
11020 		return TEST_SKIPPED;
11021 
11022 	/* Setup Cipher Parameters */
11023 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11024 	ut_params->cipher_xform.next = &ut_params->auth_xform;
11025 
11026 	ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
11027 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11028 
11029 	/* Setup HMAC Parameters */
11030 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11031 	ut_params->auth_xform.next = NULL;
11032 
11033 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
11034 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11035 
11036 	ut_params->sess = rte_cryptodev_sym_session_create(
11037 			ts_params->session_mpool);
11038 
11039 	/* Create Crypto session*/
11040 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11041 			ut_params->sess, &ut_params->cipher_xform,
11042 			ts_params->session_priv_mpool);
11043 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11044 
11045 	TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
11046 			RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
11047 			burst_len, "failed to generate burst of crypto ops");
11048 
11049 	/* Generate an operation for each mbuf in burst */
11050 	for (i = 0; i < burst_len; i++) {
11051 		struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11052 
11053 		TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
11054 
11055 		unsigned *data = (unsigned *)rte_pktmbuf_append(m,
11056 				sizeof(unsigned));
11057 		*data = i;
11058 
11059 		rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
11060 
11061 		burst[i]->sym->m_src = m;
11062 	}
11063 
11064 	/* Process crypto operation */
11065 	TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
11066 			0, burst, burst_len),
11067 			burst_len,
11068 			"Error enqueuing burst");
11069 
11070 	TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
11071 			0, burst_dequeued, burst_len),
11072 			burst_len,
11073 			"Error dequeuing burst");
11074 
11075 
11076 	for (i = 0; i < burst_len; i++) {
11077 		TEST_ASSERT_EQUAL(
11078 			*rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
11079 			*rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
11080 					uint32_t *),
11081 			"data not as expected");
11082 
11083 		rte_pktmbuf_free(burst[i]->sym->m_src);
11084 		rte_crypto_op_free(burst[i]);
11085 	}
11086 
11087 	return TEST_SUCCESS;
11088 }
11089 
11090 static uint16_t
11091 test_enq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11092 		  uint16_t nb_ops, void *user_param)
11093 {
11094 	RTE_SET_USED(dev_id);
11095 	RTE_SET_USED(qp_id);
11096 	RTE_SET_USED(ops);
11097 	RTE_SET_USED(user_param);
11098 
11099 	printf("crypto enqueue callback called\n");
11100 	return nb_ops;
11101 }
11102 
11103 static uint16_t
11104 test_deq_callback(uint16_t dev_id, uint16_t qp_id, struct rte_crypto_op **ops,
11105 		  uint16_t nb_ops, void *user_param)
11106 {
11107 	RTE_SET_USED(dev_id);
11108 	RTE_SET_USED(qp_id);
11109 	RTE_SET_USED(ops);
11110 	RTE_SET_USED(user_param);
11111 
11112 	printf("crypto dequeue callback called\n");
11113 	return nb_ops;
11114 }
11115 
11116 /*
11117  * Thread using enqueue/dequeue callback with RCU.
11118  */
11119 static int
11120 test_enqdeq_callback_thread(void *arg)
11121 {
11122 	RTE_SET_USED(arg);
11123 	/* DP thread calls rte_cryptodev_enqueue_burst()/
11124 	 * rte_cryptodev_dequeue_burst() and invokes callback.
11125 	 */
11126 	test_null_burst_operation();
11127 	return 0;
11128 }
11129 
11130 static int
11131 test_enq_callback_setup(void)
11132 {
11133 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11134 	struct rte_cryptodev_info dev_info;
11135 	struct rte_cryptodev_qp_conf qp_conf = {
11136 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
11137 	};
11138 
11139 	struct rte_cryptodev_cb *cb;
11140 	uint16_t qp_id = 0;
11141 
11142 	/* Stop the device in case it's started so it can be configured */
11143 	rte_cryptodev_stop(ts_params->valid_devs[0]);
11144 
11145 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11146 
11147 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11148 			&ts_params->conf),
11149 			"Failed to configure cryptodev %u",
11150 			ts_params->valid_devs[0]);
11151 
11152 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11153 	qp_conf.mp_session = ts_params->session_mpool;
11154 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
11155 
11156 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11157 			ts_params->valid_devs[0], qp_id, &qp_conf,
11158 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11159 			"Failed test for "
11160 			"rte_cryptodev_queue_pair_setup: num_inflights "
11161 			"%u on qp %u on cryptodev %u",
11162 			qp_conf.nb_descriptors, qp_id,
11163 			ts_params->valid_devs[0]);
11164 
11165 	/* Test with invalid crypto device */
11166 	cb = rte_cryptodev_add_enq_callback(RTE_CRYPTO_MAX_DEVS,
11167 			qp_id, test_enq_callback, NULL);
11168 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11169 			"cryptodev %u did not fail",
11170 			qp_id, RTE_CRYPTO_MAX_DEVS);
11171 
11172 	/* Test with invalid queue pair */
11173 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11174 			dev_info.max_nb_queue_pairs + 1,
11175 			test_enq_callback, NULL);
11176 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11177 			"cryptodev %u did not fail",
11178 			dev_info.max_nb_queue_pairs + 1,
11179 			ts_params->valid_devs[0]);
11180 
11181 	/* Test with NULL callback */
11182 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11183 			qp_id, NULL, NULL);
11184 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11185 			"cryptodev %u did not fail",
11186 			qp_id, ts_params->valid_devs[0]);
11187 
11188 	/* Test with valid configuration */
11189 	cb = rte_cryptodev_add_enq_callback(ts_params->valid_devs[0],
11190 			qp_id, test_enq_callback, NULL);
11191 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11192 			"qp %u on cryptodev %u",
11193 			qp_id, ts_params->valid_devs[0]);
11194 
11195 	rte_cryptodev_start(ts_params->valid_devs[0]);
11196 
11197 	/* Launch a thread */
11198 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11199 				rte_get_next_lcore(-1, 1, 0));
11200 
11201 	/* Wait until reader exited. */
11202 	rte_eal_mp_wait_lcore();
11203 
11204 	/* Test with invalid crypto device */
11205 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11206 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11207 			"Expected call to fail as crypto device is invalid");
11208 
11209 	/* Test with invalid queue pair */
11210 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11211 			ts_params->valid_devs[0],
11212 			dev_info.max_nb_queue_pairs + 1, cb),
11213 			"Expected call to fail as queue pair is invalid");
11214 
11215 	/* Test with NULL callback */
11216 	TEST_ASSERT_FAIL(rte_cryptodev_remove_enq_callback(
11217 			ts_params->valid_devs[0], qp_id, NULL),
11218 			"Expected call to fail as callback is NULL");
11219 
11220 	/* Test with valid configuration */
11221 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_enq_callback(
11222 			ts_params->valid_devs[0], qp_id, cb),
11223 			"Failed test to remove callback on "
11224 			"qp %u on cryptodev %u",
11225 			qp_id, ts_params->valid_devs[0]);
11226 
11227 	return TEST_SUCCESS;
11228 }
11229 
11230 static int
11231 test_deq_callback_setup(void)
11232 {
11233 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11234 	struct rte_cryptodev_info dev_info;
11235 	struct rte_cryptodev_qp_conf qp_conf = {
11236 		.nb_descriptors = MAX_NUM_OPS_INFLIGHT
11237 	};
11238 
11239 	struct rte_cryptodev_cb *cb;
11240 	uint16_t qp_id = 0;
11241 
11242 	/* Stop the device in case it's started so it can be configured */
11243 	rte_cryptodev_stop(ts_params->valid_devs[0]);
11244 
11245 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11246 
11247 	TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
11248 			&ts_params->conf),
11249 			"Failed to configure cryptodev %u",
11250 			ts_params->valid_devs[0]);
11251 
11252 	qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
11253 	qp_conf.mp_session = ts_params->session_mpool;
11254 	qp_conf.mp_session_private = ts_params->session_priv_mpool;
11255 
11256 	TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
11257 			ts_params->valid_devs[0], qp_id, &qp_conf,
11258 			rte_cryptodev_socket_id(ts_params->valid_devs[0])),
11259 			"Failed test for "
11260 			"rte_cryptodev_queue_pair_setup: num_inflights "
11261 			"%u on qp %u on cryptodev %u",
11262 			qp_conf.nb_descriptors, qp_id,
11263 			ts_params->valid_devs[0]);
11264 
11265 	/* Test with invalid crypto device */
11266 	cb = rte_cryptodev_add_deq_callback(RTE_CRYPTO_MAX_DEVS,
11267 			qp_id, test_deq_callback, NULL);
11268 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11269 			"cryptodev %u did not fail",
11270 			qp_id, RTE_CRYPTO_MAX_DEVS);
11271 
11272 	/* Test with invalid queue pair */
11273 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11274 			dev_info.max_nb_queue_pairs + 1,
11275 			test_deq_callback, NULL);
11276 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11277 			"cryptodev %u did not fail",
11278 			dev_info.max_nb_queue_pairs + 1,
11279 			ts_params->valid_devs[0]);
11280 
11281 	/* Test with NULL callback */
11282 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11283 			qp_id, NULL, NULL);
11284 	TEST_ASSERT_NULL(cb, "Add callback on qp %u on "
11285 			"cryptodev %u did not fail",
11286 			qp_id, ts_params->valid_devs[0]);
11287 
11288 	/* Test with valid configuration */
11289 	cb = rte_cryptodev_add_deq_callback(ts_params->valid_devs[0],
11290 			qp_id, test_deq_callback, NULL);
11291 	TEST_ASSERT_NOT_NULL(cb, "Failed test to add callback on "
11292 			"qp %u on cryptodev %u",
11293 			qp_id, ts_params->valid_devs[0]);
11294 
11295 	rte_cryptodev_start(ts_params->valid_devs[0]);
11296 
11297 	/* Launch a thread */
11298 	rte_eal_remote_launch(test_enqdeq_callback_thread, NULL,
11299 				rte_get_next_lcore(-1, 1, 0));
11300 
11301 	/* Wait until reader exited. */
11302 	rte_eal_mp_wait_lcore();
11303 
11304 	/* Test with invalid crypto device */
11305 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11306 			RTE_CRYPTO_MAX_DEVS, qp_id, cb),
11307 			"Expected call to fail as crypto device is invalid");
11308 
11309 	/* Test with invalid queue pair */
11310 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11311 			ts_params->valid_devs[0],
11312 			dev_info.max_nb_queue_pairs + 1, cb),
11313 			"Expected call to fail as queue pair is invalid");
11314 
11315 	/* Test with NULL callback */
11316 	TEST_ASSERT_FAIL(rte_cryptodev_remove_deq_callback(
11317 			ts_params->valid_devs[0], qp_id, NULL),
11318 			"Expected call to fail as callback is NULL");
11319 
11320 	/* Test with valid configuration */
11321 	TEST_ASSERT_SUCCESS(rte_cryptodev_remove_deq_callback(
11322 			ts_params->valid_devs[0], qp_id, cb),
11323 			"Failed test to remove callback on "
11324 			"qp %u on cryptodev %u",
11325 			qp_id, ts_params->valid_devs[0]);
11326 
11327 	return TEST_SUCCESS;
11328 }
11329 
11330 static void
11331 generate_gmac_large_plaintext(uint8_t *data)
11332 {
11333 	uint16_t i;
11334 
11335 	for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
11336 		memcpy(&data[i], &data[0], 32);
11337 }
11338 
11339 static int
11340 create_gmac_operation(enum rte_crypto_auth_operation op,
11341 		const struct gmac_test_data *tdata)
11342 {
11343 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11344 	struct crypto_unittest_params *ut_params = &unittest_params;
11345 	struct rte_crypto_sym_op *sym_op;
11346 
11347 	uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11348 
11349 	/* Generate Crypto op data structure */
11350 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11351 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11352 	TEST_ASSERT_NOT_NULL(ut_params->op,
11353 			"Failed to allocate symmetric crypto operation struct");
11354 
11355 	sym_op = ut_params->op->sym;
11356 
11357 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11358 			ut_params->ibuf, tdata->gmac_tag.len);
11359 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11360 			"no room to append digest");
11361 
11362 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11363 			ut_params->ibuf, plaintext_pad_len);
11364 
11365 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11366 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11367 				tdata->gmac_tag.len);
11368 		debug_hexdump(stdout, "digest:",
11369 				sym_op->auth.digest.data,
11370 				tdata->gmac_tag.len);
11371 	}
11372 
11373 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11374 			uint8_t *, IV_OFFSET);
11375 
11376 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11377 
11378 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11379 
11380 	sym_op->cipher.data.length = 0;
11381 	sym_op->cipher.data.offset = 0;
11382 
11383 	sym_op->auth.data.offset = 0;
11384 	sym_op->auth.data.length = tdata->plaintext.len;
11385 
11386 	return 0;
11387 }
11388 
11389 static int
11390 create_gmac_operation_sgl(enum rte_crypto_auth_operation op,
11391 		const struct gmac_test_data *tdata,
11392 		void *digest_mem, uint64_t digest_phys)
11393 {
11394 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11395 	struct crypto_unittest_params *ut_params = &unittest_params;
11396 	struct rte_crypto_sym_op *sym_op;
11397 
11398 	/* Generate Crypto op data structure */
11399 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11400 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11401 	TEST_ASSERT_NOT_NULL(ut_params->op,
11402 			"Failed to allocate symmetric crypto operation struct");
11403 
11404 	sym_op = ut_params->op->sym;
11405 
11406 	sym_op->auth.digest.data = digest_mem;
11407 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11408 			"no room to append digest");
11409 
11410 	sym_op->auth.digest.phys_addr = digest_phys;
11411 
11412 	if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
11413 		rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
11414 				tdata->gmac_tag.len);
11415 		debug_hexdump(stdout, "digest:",
11416 				sym_op->auth.digest.data,
11417 				tdata->gmac_tag.len);
11418 	}
11419 
11420 	uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11421 			uint8_t *, IV_OFFSET);
11422 
11423 	rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
11424 
11425 	debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
11426 
11427 	sym_op->cipher.data.length = 0;
11428 	sym_op->cipher.data.offset = 0;
11429 
11430 	sym_op->auth.data.offset = 0;
11431 	sym_op->auth.data.length = tdata->plaintext.len;
11432 
11433 	return 0;
11434 }
11435 
11436 static int create_gmac_session(uint8_t dev_id,
11437 		const struct gmac_test_data *tdata,
11438 		enum rte_crypto_auth_operation auth_op)
11439 {
11440 	uint8_t auth_key[tdata->key.len];
11441 
11442 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11443 	struct crypto_unittest_params *ut_params = &unittest_params;
11444 
11445 	memcpy(auth_key, tdata->key.data, tdata->key.len);
11446 
11447 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11448 	ut_params->auth_xform.next = NULL;
11449 
11450 	ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
11451 	ut_params->auth_xform.auth.op = auth_op;
11452 	ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
11453 	ut_params->auth_xform.auth.key.length = tdata->key.len;
11454 	ut_params->auth_xform.auth.key.data = auth_key;
11455 	ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
11456 	ut_params->auth_xform.auth.iv.length = tdata->iv.len;
11457 
11458 
11459 	ut_params->sess = rte_cryptodev_sym_session_create(
11460 			ts_params->session_mpool);
11461 
11462 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
11463 			&ut_params->auth_xform,
11464 			ts_params->session_priv_mpool);
11465 
11466 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11467 
11468 	return 0;
11469 }
11470 
11471 static int
11472 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
11473 {
11474 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11475 	struct crypto_unittest_params *ut_params = &unittest_params;
11476 	struct rte_cryptodev_info dev_info;
11477 
11478 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11479 	uint64_t feat_flags = dev_info.feature_flags;
11480 
11481 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11482 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11483 		printf("Device doesn't support RAW data-path APIs.\n");
11484 		return TEST_SKIPPED;
11485 	}
11486 
11487 	int retval;
11488 
11489 	uint8_t *auth_tag, *plaintext;
11490 	uint16_t plaintext_pad_len;
11491 
11492 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11493 			      "No GMAC length in the source data");
11494 
11495 	/* Verify the capabilities */
11496 	struct rte_cryptodev_sym_capability_idx cap_idx;
11497 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11498 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11499 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11500 			&cap_idx) == NULL)
11501 		return TEST_SKIPPED;
11502 
11503 	retval = create_gmac_session(ts_params->valid_devs[0],
11504 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11505 
11506 	if (retval < 0)
11507 		return retval;
11508 
11509 	if (tdata->plaintext.len > MBUF_SIZE)
11510 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11511 	else
11512 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11513 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11514 			"Failed to allocate input buffer in mempool");
11515 
11516 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11517 			rte_pktmbuf_tailroom(ut_params->ibuf));
11518 
11519 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11520 	/*
11521 	 * Runtime generate the large plain text instead of use hard code
11522 	 * plain text vector. It is done to avoid create huge source file
11523 	 * with the test vector.
11524 	 */
11525 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11526 		generate_gmac_large_plaintext(tdata->plaintext.data);
11527 
11528 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11529 				plaintext_pad_len);
11530 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11531 
11532 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11533 	debug_hexdump(stdout, "plaintext:", plaintext,
11534 			tdata->plaintext.len);
11535 
11536 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
11537 			tdata);
11538 
11539 	if (retval < 0)
11540 		return retval;
11541 
11542 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11543 
11544 	ut_params->op->sym->m_src = ut_params->ibuf;
11545 
11546 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11547 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11548 			ut_params->op);
11549 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11550 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11551 				ut_params->op, 0, 1, 0, 0);
11552 	else
11553 		TEST_ASSERT_NOT_NULL(
11554 			process_crypto_request(ts_params->valid_devs[0],
11555 			ut_params->op), "failed to process sym crypto op");
11556 
11557 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11558 			"crypto op processing failed");
11559 
11560 	if (ut_params->op->sym->m_dst) {
11561 		auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11562 				uint8_t *, plaintext_pad_len);
11563 	} else {
11564 		auth_tag = plaintext + plaintext_pad_len;
11565 	}
11566 
11567 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11568 
11569 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11570 			auth_tag,
11571 			tdata->gmac_tag.data,
11572 			tdata->gmac_tag.len,
11573 			"GMAC Generated auth tag not as expected");
11574 
11575 	return 0;
11576 }
11577 
11578 static int
11579 test_AES_GMAC_authentication_test_case_1(void)
11580 {
11581 	return test_AES_GMAC_authentication(&gmac_test_case_1);
11582 }
11583 
11584 static int
11585 test_AES_GMAC_authentication_test_case_2(void)
11586 {
11587 	return test_AES_GMAC_authentication(&gmac_test_case_2);
11588 }
11589 
11590 static int
11591 test_AES_GMAC_authentication_test_case_3(void)
11592 {
11593 	return test_AES_GMAC_authentication(&gmac_test_case_3);
11594 }
11595 
11596 static int
11597 test_AES_GMAC_authentication_test_case_4(void)
11598 {
11599 	return test_AES_GMAC_authentication(&gmac_test_case_4);
11600 }
11601 
11602 static int
11603 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
11604 {
11605 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11606 	struct crypto_unittest_params *ut_params = &unittest_params;
11607 	int retval;
11608 	uint32_t plaintext_pad_len;
11609 	uint8_t *plaintext;
11610 	struct rte_cryptodev_info dev_info;
11611 
11612 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11613 	uint64_t feat_flags = dev_info.feature_flags;
11614 
11615 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
11616 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
11617 		printf("Device doesn't support RAW data-path APIs.\n");
11618 		return TEST_SKIPPED;
11619 	}
11620 
11621 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11622 			      "No GMAC length in the source data");
11623 
11624 	/* Verify the capabilities */
11625 	struct rte_cryptodev_sym_capability_idx cap_idx;
11626 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11627 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11628 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11629 			&cap_idx) == NULL)
11630 		return TEST_SKIPPED;
11631 
11632 	retval = create_gmac_session(ts_params->valid_devs[0],
11633 			tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
11634 
11635 	if (retval < 0)
11636 		return retval;
11637 
11638 	if (tdata->plaintext.len > MBUF_SIZE)
11639 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
11640 	else
11641 		ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11642 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11643 			"Failed to allocate input buffer in mempool");
11644 
11645 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11646 			rte_pktmbuf_tailroom(ut_params->ibuf));
11647 
11648 	plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
11649 
11650 	/*
11651 	 * Runtime generate the large plain text instead of use hard code
11652 	 * plain text vector. It is done to avoid create huge source file
11653 	 * with the test vector.
11654 	 */
11655 	if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
11656 		generate_gmac_large_plaintext(tdata->plaintext.data);
11657 
11658 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11659 				plaintext_pad_len);
11660 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11661 
11662 	memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
11663 	debug_hexdump(stdout, "plaintext:", plaintext,
11664 			tdata->plaintext.len);
11665 
11666 	retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
11667 			tdata);
11668 
11669 	if (retval < 0)
11670 		return retval;
11671 
11672 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11673 
11674 	ut_params->op->sym->m_src = ut_params->ibuf;
11675 
11676 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11677 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
11678 			ut_params->op);
11679 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
11680 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
11681 				ut_params->op, 0, 1, 0, 0);
11682 	else
11683 		TEST_ASSERT_NOT_NULL(
11684 			process_crypto_request(ts_params->valid_devs[0],
11685 			ut_params->op), "failed to process sym crypto op");
11686 
11687 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11688 			"crypto op processing failed");
11689 
11690 	return 0;
11691 
11692 }
11693 
11694 static int
11695 test_AES_GMAC_authentication_verify_test_case_1(void)
11696 {
11697 	return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
11698 }
11699 
11700 static int
11701 test_AES_GMAC_authentication_verify_test_case_2(void)
11702 {
11703 	return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
11704 }
11705 
11706 static int
11707 test_AES_GMAC_authentication_verify_test_case_3(void)
11708 {
11709 	return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
11710 }
11711 
11712 static int
11713 test_AES_GMAC_authentication_verify_test_case_4(void)
11714 {
11715 	return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
11716 }
11717 
11718 static int
11719 test_AES_GMAC_authentication_SGL(const struct gmac_test_data *tdata,
11720 				uint32_t fragsz)
11721 {
11722 	struct crypto_testsuite_params *ts_params = &testsuite_params;
11723 	struct crypto_unittest_params *ut_params = &unittest_params;
11724 	struct rte_cryptodev_info dev_info;
11725 	uint64_t feature_flags;
11726 	unsigned int trn_data = 0;
11727 	void *digest_mem = NULL;
11728 	uint32_t segs = 1;
11729 	unsigned int to_trn = 0;
11730 	struct rte_mbuf *buf = NULL;
11731 	uint8_t *auth_tag, *plaintext;
11732 	int retval;
11733 
11734 	TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
11735 			      "No GMAC length in the source data");
11736 
11737 	/* Verify the capabilities */
11738 	struct rte_cryptodev_sym_capability_idx cap_idx;
11739 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11740 	cap_idx.algo.auth = RTE_CRYPTO_AUTH_AES_GMAC;
11741 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
11742 			&cap_idx) == NULL)
11743 		return TEST_SKIPPED;
11744 
11745 	/* Check for any input SGL support */
11746 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
11747 	feature_flags = dev_info.feature_flags;
11748 
11749 	if ((!(feature_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) ||
11750 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT)) ||
11751 			(!(feature_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)))
11752 		return TEST_SKIPPED;
11753 
11754 	if (fragsz > tdata->plaintext.len)
11755 		fragsz = tdata->plaintext.len;
11756 
11757 	uint16_t plaintext_len = fragsz;
11758 
11759 	retval = create_gmac_session(ts_params->valid_devs[0],
11760 			tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
11761 
11762 	if (retval < 0)
11763 		return retval;
11764 
11765 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11766 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11767 			"Failed to allocate input buffer in mempool");
11768 
11769 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11770 			rte_pktmbuf_tailroom(ut_params->ibuf));
11771 
11772 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11773 				plaintext_len);
11774 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11775 
11776 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11777 
11778 	trn_data += plaintext_len;
11779 
11780 	buf = ut_params->ibuf;
11781 
11782 	/*
11783 	 * Loop until no more fragments
11784 	 */
11785 
11786 	while (trn_data < tdata->plaintext.len) {
11787 		++segs;
11788 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11789 				(tdata->plaintext.len - trn_data) : fragsz;
11790 
11791 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11792 		buf = buf->next;
11793 
11794 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11795 				rte_pktmbuf_tailroom(buf));
11796 
11797 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11798 				to_trn);
11799 
11800 		memcpy(plaintext, tdata->plaintext.data + trn_data,
11801 				to_trn);
11802 		trn_data += to_trn;
11803 		if (trn_data  == tdata->plaintext.len)
11804 			digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11805 					tdata->gmac_tag.len);
11806 	}
11807 	ut_params->ibuf->nb_segs = segs;
11808 
11809 	/*
11810 	 * Place digest at the end of the last buffer
11811 	 */
11812 	uint64_t digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11813 
11814 	if (!digest_mem) {
11815 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11816 				+ tdata->gmac_tag.len);
11817 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11818 				tdata->plaintext.len);
11819 	}
11820 
11821 	retval = create_gmac_operation_sgl(RTE_CRYPTO_AUTH_OP_GENERATE,
11822 			tdata, digest_mem, digest_phys);
11823 
11824 	if (retval < 0)
11825 		return retval;
11826 
11827 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11828 
11829 	ut_params->op->sym->m_src = ut_params->ibuf;
11830 
11831 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
11832 		return TEST_SKIPPED;
11833 
11834 	TEST_ASSERT_NOT_NULL(
11835 		process_crypto_request(ts_params->valid_devs[0],
11836 		ut_params->op), "failed to process sym crypto op");
11837 
11838 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11839 			"crypto op processing failed");
11840 
11841 	auth_tag = digest_mem;
11842 	debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
11843 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
11844 			auth_tag,
11845 			tdata->gmac_tag.data,
11846 			tdata->gmac_tag.len,
11847 			"GMAC Generated auth tag not as expected");
11848 
11849 	return 0;
11850 }
11851 
11852 /* Segment size not multiple of block size (16B) */
11853 static int
11854 test_AES_GMAC_authentication_SGL_40B(void)
11855 {
11856 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 40);
11857 }
11858 
11859 static int
11860 test_AES_GMAC_authentication_SGL_80B(void)
11861 {
11862 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_1, 80);
11863 }
11864 
11865 static int
11866 test_AES_GMAC_authentication_SGL_2048B(void)
11867 {
11868 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2048);
11869 }
11870 
11871 /* Segment size not multiple of block size (16B) */
11872 static int
11873 test_AES_GMAC_authentication_SGL_2047B(void)
11874 {
11875 	return test_AES_GMAC_authentication_SGL(&gmac_test_case_5, 2047);
11876 }
11877 
11878 struct test_crypto_vector {
11879 	enum rte_crypto_cipher_algorithm crypto_algo;
11880 	unsigned int cipher_offset;
11881 	unsigned int cipher_len;
11882 
11883 	struct {
11884 		uint8_t data[64];
11885 		unsigned int len;
11886 	} cipher_key;
11887 
11888 	struct {
11889 		uint8_t data[64];
11890 		unsigned int len;
11891 	} iv;
11892 
11893 	struct {
11894 		const uint8_t *data;
11895 		unsigned int len;
11896 	} plaintext;
11897 
11898 	struct {
11899 		const uint8_t *data;
11900 		unsigned int len;
11901 	} ciphertext;
11902 
11903 	enum rte_crypto_auth_algorithm auth_algo;
11904 	unsigned int auth_offset;
11905 
11906 	struct {
11907 		uint8_t data[128];
11908 		unsigned int len;
11909 	} auth_key;
11910 
11911 	struct {
11912 		const uint8_t *data;
11913 		unsigned int len;
11914 	} aad;
11915 
11916 	struct {
11917 		uint8_t data[128];
11918 		unsigned int len;
11919 	} digest;
11920 };
11921 
11922 static const struct test_crypto_vector
11923 hmac_sha1_test_crypto_vector = {
11924 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
11925 	.plaintext = {
11926 		.data = plaintext_hash,
11927 		.len = 512
11928 	},
11929 	.auth_key = {
11930 		.data = {
11931 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
11932 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
11933 			0xDE, 0xF4, 0xDE, 0xAD
11934 		},
11935 		.len = 20
11936 	},
11937 	.digest = {
11938 		.data = {
11939 			0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
11940 			0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
11941 			0x3F, 0x91, 0x64, 0x59
11942 		},
11943 		.len = 20
11944 	}
11945 };
11946 
11947 static const struct test_crypto_vector
11948 aes128_gmac_test_vector = {
11949 	.auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
11950 	.plaintext = {
11951 		.data = plaintext_hash,
11952 		.len = 512
11953 	},
11954 	.iv = {
11955 		.data = {
11956 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11957 			0x08, 0x09, 0x0A, 0x0B
11958 		},
11959 		.len = 12
11960 	},
11961 	.auth_key = {
11962 		.data = {
11963 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
11964 			0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
11965 		},
11966 		.len = 16
11967 	},
11968 	.digest = {
11969 		.data = {
11970 			0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
11971 			0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
11972 		},
11973 		.len = 16
11974 	}
11975 };
11976 
11977 static const struct test_crypto_vector
11978 aes128cbc_hmac_sha1_test_vector = {
11979 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
11980 	.cipher_offset = 0,
11981 	.cipher_len = 512,
11982 	.cipher_key = {
11983 		.data = {
11984 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
11985 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
11986 		},
11987 		.len = 16
11988 	},
11989 	.iv = {
11990 		.data = {
11991 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
11992 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
11993 		},
11994 		.len = 16
11995 	},
11996 	.plaintext = {
11997 		.data = plaintext_hash,
11998 		.len = 512
11999 	},
12000 	.ciphertext = {
12001 		.data = ciphertext512_aes128cbc,
12002 		.len = 512
12003 	},
12004 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12005 	.auth_offset = 0,
12006 	.auth_key = {
12007 		.data = {
12008 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12009 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12010 			0xDE, 0xF4, 0xDE, 0xAD
12011 		},
12012 		.len = 20
12013 	},
12014 	.digest = {
12015 		.data = {
12016 			0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
12017 			0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
12018 			0x18, 0x8C, 0x1D, 0x32
12019 		},
12020 		.len = 20
12021 	}
12022 };
12023 
12024 static const struct test_crypto_vector
12025 aes128cbc_hmac_sha1_aad_test_vector = {
12026 	.crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
12027 	.cipher_offset = 8,
12028 	.cipher_len = 496,
12029 	.cipher_key = {
12030 		.data = {
12031 			0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
12032 			0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
12033 		},
12034 		.len = 16
12035 	},
12036 	.iv = {
12037 		.data = {
12038 			0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
12039 			0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
12040 		},
12041 		.len = 16
12042 	},
12043 	.plaintext = {
12044 		.data = plaintext_hash,
12045 		.len = 512
12046 	},
12047 	.ciphertext = {
12048 		.data = ciphertext512_aes128cbc_aad,
12049 		.len = 512
12050 	},
12051 	.auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
12052 	.auth_offset = 0,
12053 	.auth_key = {
12054 		.data = {
12055 			0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
12056 			0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
12057 			0xDE, 0xF4, 0xDE, 0xAD
12058 		},
12059 		.len = 20
12060 	},
12061 	.digest = {
12062 		.data = {
12063 			0x6D, 0xF3, 0x50, 0x79, 0x7A, 0x2A, 0xAC, 0x7F,
12064 			0xA6, 0xF0, 0xC6, 0x38, 0x1F, 0xA4, 0xDD, 0x9B,
12065 			0x62, 0x0F, 0xFB, 0x10
12066 		},
12067 		.len = 20
12068 	}
12069 };
12070 
12071 static void
12072 data_corruption(uint8_t *data)
12073 {
12074 	data[0] += 1;
12075 }
12076 
12077 static void
12078 tag_corruption(uint8_t *data, unsigned int tag_offset)
12079 {
12080 	data[tag_offset] += 1;
12081 }
12082 
12083 static int
12084 create_auth_session(struct crypto_unittest_params *ut_params,
12085 		uint8_t dev_id,
12086 		const struct test_crypto_vector *reference,
12087 		enum rte_crypto_auth_operation auth_op)
12088 {
12089 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12090 	uint8_t auth_key[reference->auth_key.len + 1];
12091 
12092 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12093 
12094 	/* Setup Authentication Parameters */
12095 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12096 	ut_params->auth_xform.auth.op = auth_op;
12097 	ut_params->auth_xform.next = NULL;
12098 	ut_params->auth_xform.auth.algo = reference->auth_algo;
12099 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12100 	ut_params->auth_xform.auth.key.data = auth_key;
12101 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
12102 
12103 	/* Create Crypto session*/
12104 	ut_params->sess = rte_cryptodev_sym_session_create(
12105 			ts_params->session_mpool);
12106 
12107 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12108 				&ut_params->auth_xform,
12109 				ts_params->session_priv_mpool);
12110 
12111 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12112 
12113 	return 0;
12114 }
12115 
12116 static int
12117 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
12118 		uint8_t dev_id,
12119 		const struct test_crypto_vector *reference,
12120 		enum rte_crypto_auth_operation auth_op,
12121 		enum rte_crypto_cipher_operation cipher_op)
12122 {
12123 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12124 	uint8_t cipher_key[reference->cipher_key.len + 1];
12125 	uint8_t auth_key[reference->auth_key.len + 1];
12126 
12127 	memcpy(cipher_key, reference->cipher_key.data,
12128 			reference->cipher_key.len);
12129 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12130 
12131 	/* Setup Authentication Parameters */
12132 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12133 	ut_params->auth_xform.auth.op = auth_op;
12134 	ut_params->auth_xform.auth.algo = reference->auth_algo;
12135 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12136 	ut_params->auth_xform.auth.key.data = auth_key;
12137 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
12138 
12139 	if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
12140 		ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
12141 		ut_params->auth_xform.auth.iv.length = reference->iv.len;
12142 	} else {
12143 		ut_params->auth_xform.next = &ut_params->cipher_xform;
12144 
12145 		/* Setup Cipher Parameters */
12146 		ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12147 		ut_params->cipher_xform.next = NULL;
12148 		ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12149 		ut_params->cipher_xform.cipher.op = cipher_op;
12150 		ut_params->cipher_xform.cipher.key.data = cipher_key;
12151 		ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12152 		ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12153 		ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12154 	}
12155 
12156 	/* Create Crypto session*/
12157 	ut_params->sess = rte_cryptodev_sym_session_create(
12158 			ts_params->session_mpool);
12159 
12160 	rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
12161 				&ut_params->auth_xform,
12162 				ts_params->session_priv_mpool);
12163 
12164 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12165 
12166 	return 0;
12167 }
12168 
12169 static int
12170 create_auth_operation(struct crypto_testsuite_params *ts_params,
12171 		struct crypto_unittest_params *ut_params,
12172 		const struct test_crypto_vector *reference,
12173 		unsigned int auth_generate)
12174 {
12175 	/* Generate Crypto op data structure */
12176 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12177 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12178 	TEST_ASSERT_NOT_NULL(ut_params->op,
12179 			"Failed to allocate pktmbuf offload");
12180 
12181 	/* Set crypto operation data parameters */
12182 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12183 
12184 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12185 
12186 	/* set crypto operation source mbuf */
12187 	sym_op->m_src = ut_params->ibuf;
12188 
12189 	/* digest */
12190 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12191 			ut_params->ibuf, reference->digest.len);
12192 
12193 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12194 			"no room to append auth tag");
12195 
12196 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12197 			ut_params->ibuf, reference->plaintext.len);
12198 
12199 	if (auth_generate)
12200 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
12201 	else
12202 		memcpy(sym_op->auth.digest.data,
12203 				reference->digest.data,
12204 				reference->digest.len);
12205 
12206 	debug_hexdump(stdout, "digest:",
12207 			sym_op->auth.digest.data,
12208 			reference->digest.len);
12209 
12210 	sym_op->auth.data.length = reference->plaintext.len;
12211 	sym_op->auth.data.offset = 0;
12212 
12213 	return 0;
12214 }
12215 
12216 static int
12217 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
12218 		struct crypto_unittest_params *ut_params,
12219 		const struct test_crypto_vector *reference,
12220 		unsigned int auth_generate)
12221 {
12222 	/* Generate Crypto op data structure */
12223 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12224 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12225 	TEST_ASSERT_NOT_NULL(ut_params->op,
12226 			"Failed to allocate pktmbuf offload");
12227 
12228 	/* Set crypto operation data parameters */
12229 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12230 
12231 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12232 
12233 	/* set crypto operation source mbuf */
12234 	sym_op->m_src = ut_params->ibuf;
12235 
12236 	/* digest */
12237 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12238 			ut_params->ibuf, reference->digest.len);
12239 
12240 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12241 			"no room to append auth tag");
12242 
12243 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12244 			ut_params->ibuf, reference->ciphertext.len);
12245 
12246 	if (auth_generate)
12247 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
12248 	else
12249 		memcpy(sym_op->auth.digest.data,
12250 				reference->digest.data,
12251 				reference->digest.len);
12252 
12253 	debug_hexdump(stdout, "digest:",
12254 			sym_op->auth.digest.data,
12255 			reference->digest.len);
12256 
12257 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12258 			reference->iv.data, reference->iv.len);
12259 
12260 	sym_op->cipher.data.length = 0;
12261 	sym_op->cipher.data.offset = 0;
12262 
12263 	sym_op->auth.data.length = reference->plaintext.len;
12264 	sym_op->auth.data.offset = 0;
12265 
12266 	return 0;
12267 }
12268 
12269 static int
12270 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
12271 		struct crypto_unittest_params *ut_params,
12272 		const struct test_crypto_vector *reference,
12273 		unsigned int auth_generate)
12274 {
12275 	/* Generate Crypto op data structure */
12276 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12277 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12278 	TEST_ASSERT_NOT_NULL(ut_params->op,
12279 			"Failed to allocate pktmbuf offload");
12280 
12281 	/* Set crypto operation data parameters */
12282 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
12283 
12284 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12285 
12286 	/* set crypto operation source mbuf */
12287 	sym_op->m_src = ut_params->ibuf;
12288 
12289 	/* digest */
12290 	sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
12291 			ut_params->ibuf, reference->digest.len);
12292 
12293 	TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
12294 			"no room to append auth tag");
12295 
12296 	sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
12297 			ut_params->ibuf, reference->ciphertext.len);
12298 
12299 	if (auth_generate)
12300 		memset(sym_op->auth.digest.data, 0, reference->digest.len);
12301 	else
12302 		memcpy(sym_op->auth.digest.data,
12303 				reference->digest.data,
12304 				reference->digest.len);
12305 
12306 	debug_hexdump(stdout, "digest:",
12307 			sym_op->auth.digest.data,
12308 			reference->digest.len);
12309 
12310 	rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
12311 			reference->iv.data, reference->iv.len);
12312 
12313 	sym_op->cipher.data.length = reference->cipher_len;
12314 	sym_op->cipher.data.offset = reference->cipher_offset;
12315 
12316 	sym_op->auth.data.length = reference->plaintext.len;
12317 	sym_op->auth.data.offset = reference->auth_offset;
12318 
12319 	return 0;
12320 }
12321 
12322 static int
12323 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12324 		struct crypto_unittest_params *ut_params,
12325 		const struct test_crypto_vector *reference)
12326 {
12327 	return create_auth_operation(ts_params, ut_params, reference, 0);
12328 }
12329 
12330 static int
12331 create_auth_verify_GMAC_operation(
12332 		struct crypto_testsuite_params *ts_params,
12333 		struct crypto_unittest_params *ut_params,
12334 		const struct test_crypto_vector *reference)
12335 {
12336 	return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
12337 }
12338 
12339 static int
12340 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
12341 		struct crypto_unittest_params *ut_params,
12342 		const struct test_crypto_vector *reference)
12343 {
12344 	return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
12345 }
12346 
12347 static int
12348 test_authentication_verify_fail_when_data_corruption(
12349 		struct crypto_testsuite_params *ts_params,
12350 		struct crypto_unittest_params *ut_params,
12351 		const struct test_crypto_vector *reference,
12352 		unsigned int data_corrupted)
12353 {
12354 	int retval;
12355 
12356 	uint8_t *plaintext;
12357 	struct rte_cryptodev_info dev_info;
12358 
12359 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12360 	uint64_t feat_flags = dev_info.feature_flags;
12361 
12362 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12363 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12364 		printf("Device doesn't support RAW data-path APIs.\n");
12365 		return TEST_SKIPPED;
12366 	}
12367 
12368 	/* Verify the capabilities */
12369 	struct rte_cryptodev_sym_capability_idx cap_idx;
12370 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12371 	cap_idx.algo.auth = reference->auth_algo;
12372 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12373 			&cap_idx) == NULL)
12374 		return TEST_SKIPPED;
12375 
12376 
12377 	/* Create session */
12378 	retval = create_auth_session(ut_params,
12379 			ts_params->valid_devs[0],
12380 			reference,
12381 			RTE_CRYPTO_AUTH_OP_VERIFY);
12382 	if (retval < 0)
12383 		return retval;
12384 
12385 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12386 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12387 			"Failed to allocate input buffer in mempool");
12388 
12389 	/* clear mbuf payload */
12390 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12391 			rte_pktmbuf_tailroom(ut_params->ibuf));
12392 
12393 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12394 			reference->plaintext.len);
12395 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12396 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12397 
12398 	debug_hexdump(stdout, "plaintext:", plaintext,
12399 		reference->plaintext.len);
12400 
12401 	/* Create operation */
12402 	retval = create_auth_verify_operation(ts_params, ut_params, reference);
12403 
12404 	if (retval < 0)
12405 		return retval;
12406 
12407 	if (data_corrupted)
12408 		data_corruption(plaintext);
12409 	else
12410 		tag_corruption(plaintext, reference->plaintext.len);
12411 
12412 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12413 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12414 			ut_params->op);
12415 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12416 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12417 			"authentication not failed");
12418 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12419 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12420 				ut_params->op, 0, 1, 0, 0);
12421 	else {
12422 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12423 			ut_params->op);
12424 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12425 	}
12426 
12427 	return 0;
12428 }
12429 
12430 static int
12431 test_authentication_verify_GMAC_fail_when_corruption(
12432 		struct crypto_testsuite_params *ts_params,
12433 		struct crypto_unittest_params *ut_params,
12434 		const struct test_crypto_vector *reference,
12435 		unsigned int data_corrupted)
12436 {
12437 	int retval;
12438 	uint8_t *plaintext;
12439 	struct rte_cryptodev_info dev_info;
12440 
12441 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12442 	uint64_t feat_flags = dev_info.feature_flags;
12443 
12444 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12445 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12446 		printf("Device doesn't support RAW data-path APIs.\n");
12447 		return TEST_SKIPPED;
12448 	}
12449 
12450 	/* Verify the capabilities */
12451 	struct rte_cryptodev_sym_capability_idx cap_idx;
12452 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12453 	cap_idx.algo.auth = reference->auth_algo;
12454 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12455 			&cap_idx) == NULL)
12456 		return TEST_SKIPPED;
12457 
12458 	/* Create session */
12459 	retval = create_auth_cipher_session(ut_params,
12460 			ts_params->valid_devs[0],
12461 			reference,
12462 			RTE_CRYPTO_AUTH_OP_VERIFY,
12463 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
12464 	if (retval < 0)
12465 		return retval;
12466 
12467 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12468 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12469 			"Failed to allocate input buffer in mempool");
12470 
12471 	/* clear mbuf payload */
12472 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12473 			rte_pktmbuf_tailroom(ut_params->ibuf));
12474 
12475 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12476 			reference->plaintext.len);
12477 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12478 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12479 
12480 	debug_hexdump(stdout, "plaintext:", plaintext,
12481 		reference->plaintext.len);
12482 
12483 	/* Create operation */
12484 	retval = create_auth_verify_GMAC_operation(ts_params,
12485 			ut_params,
12486 			reference);
12487 
12488 	if (retval < 0)
12489 		return retval;
12490 
12491 	if (data_corrupted)
12492 		data_corruption(plaintext);
12493 	else
12494 		tag_corruption(plaintext, reference->aad.len);
12495 
12496 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12497 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12498 			ut_params->op);
12499 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12500 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12501 			"authentication not failed");
12502 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12503 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12504 				ut_params->op, 0, 1, 0, 0);
12505 	else {
12506 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12507 			ut_params->op);
12508 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12509 	}
12510 
12511 	return 0;
12512 }
12513 
12514 static int
12515 test_authenticated_decryption_fail_when_corruption(
12516 		struct crypto_testsuite_params *ts_params,
12517 		struct crypto_unittest_params *ut_params,
12518 		const struct test_crypto_vector *reference,
12519 		unsigned int data_corrupted)
12520 {
12521 	int retval;
12522 
12523 	uint8_t *ciphertext;
12524 	struct rte_cryptodev_info dev_info;
12525 
12526 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12527 	uint64_t feat_flags = dev_info.feature_flags;
12528 
12529 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12530 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12531 		printf("Device doesn't support RAW data-path APIs.\n");
12532 		return TEST_SKIPPED;
12533 	}
12534 
12535 	/* Verify the capabilities */
12536 	struct rte_cryptodev_sym_capability_idx cap_idx;
12537 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12538 	cap_idx.algo.auth = reference->auth_algo;
12539 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12540 			&cap_idx) == NULL)
12541 		return TEST_SKIPPED;
12542 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12543 	cap_idx.algo.cipher = reference->crypto_algo;
12544 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12545 			&cap_idx) == NULL)
12546 		return TEST_SKIPPED;
12547 
12548 	/* Create session */
12549 	retval = create_auth_cipher_session(ut_params,
12550 			ts_params->valid_devs[0],
12551 			reference,
12552 			RTE_CRYPTO_AUTH_OP_VERIFY,
12553 			RTE_CRYPTO_CIPHER_OP_DECRYPT);
12554 	if (retval < 0)
12555 		return retval;
12556 
12557 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12558 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12559 			"Failed to allocate input buffer in mempool");
12560 
12561 	/* clear mbuf payload */
12562 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12563 			rte_pktmbuf_tailroom(ut_params->ibuf));
12564 
12565 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12566 			reference->ciphertext.len);
12567 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12568 	memcpy(ciphertext, reference->ciphertext.data,
12569 			reference->ciphertext.len);
12570 
12571 	/* Create operation */
12572 	retval = create_cipher_auth_verify_operation(ts_params,
12573 			ut_params,
12574 			reference);
12575 
12576 	if (retval < 0)
12577 		return retval;
12578 
12579 	if (data_corrupted)
12580 		data_corruption(ciphertext);
12581 	else
12582 		tag_corruption(ciphertext, reference->ciphertext.len);
12583 
12584 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO) {
12585 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12586 			ut_params->op);
12587 		TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
12588 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12589 			"authentication not failed");
12590 	} else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12591 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12592 				ut_params->op, 1, 1, 0, 0);
12593 	else {
12594 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12595 			ut_params->op);
12596 		TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
12597 	}
12598 
12599 	return 0;
12600 }
12601 
12602 static int
12603 test_authenticated_encryt_with_esn(
12604 		struct crypto_testsuite_params *ts_params,
12605 		struct crypto_unittest_params *ut_params,
12606 		const struct test_crypto_vector *reference)
12607 {
12608 	int retval;
12609 
12610 	uint8_t *authciphertext, *plaintext, *auth_tag;
12611 	uint16_t plaintext_pad_len;
12612 	uint8_t cipher_key[reference->cipher_key.len + 1];
12613 	uint8_t auth_key[reference->auth_key.len + 1];
12614 	struct rte_cryptodev_info dev_info;
12615 
12616 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12617 	uint64_t feat_flags = dev_info.feature_flags;
12618 
12619 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12620 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12621 		printf("Device doesn't support RAW data-path APIs.\n");
12622 		return TEST_SKIPPED;
12623 	}
12624 
12625 	/* Verify the capabilities */
12626 	struct rte_cryptodev_sym_capability_idx cap_idx;
12627 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12628 	cap_idx.algo.auth = reference->auth_algo;
12629 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12630 			&cap_idx) == NULL)
12631 		return TEST_SKIPPED;
12632 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12633 	cap_idx.algo.cipher = reference->crypto_algo;
12634 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12635 			&cap_idx) == NULL)
12636 		return TEST_SKIPPED;
12637 
12638 	/* Create session */
12639 	memcpy(cipher_key, reference->cipher_key.data,
12640 			reference->cipher_key.len);
12641 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12642 
12643 	/* Setup Cipher Parameters */
12644 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12645 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12646 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
12647 	ut_params->cipher_xform.cipher.key.data = cipher_key;
12648 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12649 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12650 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12651 
12652 	ut_params->cipher_xform.next = &ut_params->auth_xform;
12653 
12654 	/* Setup Authentication Parameters */
12655 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12656 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
12657 	ut_params->auth_xform.auth.algo = reference->auth_algo;
12658 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12659 	ut_params->auth_xform.auth.key.data = auth_key;
12660 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
12661 	ut_params->auth_xform.next = NULL;
12662 
12663 	/* Create Crypto session*/
12664 	ut_params->sess = rte_cryptodev_sym_session_create(
12665 			ts_params->session_mpool);
12666 
12667 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12668 				ut_params->sess,
12669 				&ut_params->cipher_xform,
12670 				ts_params->session_priv_mpool);
12671 
12672 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12673 
12674 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12675 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12676 			"Failed to allocate input buffer in mempool");
12677 
12678 	/* clear mbuf payload */
12679 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12680 			rte_pktmbuf_tailroom(ut_params->ibuf));
12681 
12682 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12683 			reference->plaintext.len);
12684 	TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
12685 	memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
12686 
12687 	/* Create operation */
12688 	retval = create_cipher_auth_operation(ts_params,
12689 			ut_params,
12690 			reference, 0);
12691 
12692 	if (retval < 0)
12693 		return retval;
12694 
12695 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12696 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12697 			ut_params->op);
12698 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12699 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12700 				ut_params->op, 1, 1, 0, 0);
12701 	else
12702 		ut_params->op = process_crypto_request(
12703 			ts_params->valid_devs[0], ut_params->op);
12704 
12705 	TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
12706 
12707 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
12708 			"crypto op processing failed");
12709 
12710 	plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
12711 
12712 	authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
12713 			ut_params->op->sym->auth.data.offset);
12714 	auth_tag = authciphertext + plaintext_pad_len;
12715 	debug_hexdump(stdout, "ciphertext:", authciphertext,
12716 			reference->ciphertext.len);
12717 	debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
12718 
12719 	/* Validate obuf */
12720 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12721 			authciphertext,
12722 			reference->ciphertext.data,
12723 			reference->ciphertext.len,
12724 			"Ciphertext data not as expected");
12725 
12726 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
12727 			auth_tag,
12728 			reference->digest.data,
12729 			reference->digest.len,
12730 			"Generated digest not as expected");
12731 
12732 	return TEST_SUCCESS;
12733 
12734 }
12735 
12736 static int
12737 test_authenticated_decrypt_with_esn(
12738 		struct crypto_testsuite_params *ts_params,
12739 		struct crypto_unittest_params *ut_params,
12740 		const struct test_crypto_vector *reference)
12741 {
12742 	int retval;
12743 
12744 	uint8_t *ciphertext;
12745 	uint8_t cipher_key[reference->cipher_key.len + 1];
12746 	uint8_t auth_key[reference->auth_key.len + 1];
12747 	struct rte_cryptodev_info dev_info;
12748 
12749 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12750 	uint64_t feat_flags = dev_info.feature_flags;
12751 
12752 	if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12753 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12754 		printf("Device doesn't support RAW data-path APIs.\n");
12755 		return TEST_SKIPPED;
12756 	}
12757 
12758 	/* Verify the capabilities */
12759 	struct rte_cryptodev_sym_capability_idx cap_idx;
12760 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12761 	cap_idx.algo.auth = reference->auth_algo;
12762 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12763 			&cap_idx) == NULL)
12764 		return TEST_SKIPPED;
12765 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12766 	cap_idx.algo.cipher = reference->crypto_algo;
12767 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12768 			&cap_idx) == NULL)
12769 		return TEST_SKIPPED;
12770 
12771 	/* Create session */
12772 	memcpy(cipher_key, reference->cipher_key.data,
12773 			reference->cipher_key.len);
12774 	memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
12775 
12776 	/* Setup Authentication Parameters */
12777 	ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
12778 	ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
12779 	ut_params->auth_xform.auth.algo = reference->auth_algo;
12780 	ut_params->auth_xform.auth.key.length = reference->auth_key.len;
12781 	ut_params->auth_xform.auth.key.data = auth_key;
12782 	ut_params->auth_xform.auth.digest_length = reference->digest.len;
12783 	ut_params->auth_xform.next = &ut_params->cipher_xform;
12784 
12785 	/* Setup Cipher Parameters */
12786 	ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
12787 	ut_params->cipher_xform.next = NULL;
12788 	ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
12789 	ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
12790 	ut_params->cipher_xform.cipher.key.data = cipher_key;
12791 	ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
12792 	ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
12793 	ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
12794 
12795 	/* Create Crypto session*/
12796 	ut_params->sess = rte_cryptodev_sym_session_create(
12797 			ts_params->session_mpool);
12798 
12799 	rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
12800 				ut_params->sess,
12801 				&ut_params->auth_xform,
12802 				ts_params->session_priv_mpool);
12803 
12804 	TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
12805 
12806 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
12807 	TEST_ASSERT_NOT_NULL(ut_params->ibuf,
12808 			"Failed to allocate input buffer in mempool");
12809 
12810 	/* clear mbuf payload */
12811 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
12812 			rte_pktmbuf_tailroom(ut_params->ibuf));
12813 
12814 	ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
12815 			reference->ciphertext.len);
12816 	TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
12817 	memcpy(ciphertext, reference->ciphertext.data,
12818 			reference->ciphertext.len);
12819 
12820 	/* Create operation */
12821 	retval = create_cipher_auth_verify_operation(ts_params,
12822 			ut_params,
12823 			reference);
12824 
12825 	if (retval < 0)
12826 		return retval;
12827 
12828 	if (gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12829 		process_cpu_crypt_auth_op(ts_params->valid_devs[0],
12830 			ut_params->op);
12831 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12832 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
12833 				ut_params->op, 1, 1, 0, 0);
12834 	else
12835 		ut_params->op = process_crypto_request(ts_params->valid_devs[0],
12836 			ut_params->op);
12837 
12838 	TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
12839 	TEST_ASSERT_EQUAL(ut_params->op->status,
12840 			RTE_CRYPTO_OP_STATUS_SUCCESS,
12841 			"crypto op processing passed");
12842 
12843 	ut_params->obuf = ut_params->op->sym->m_src;
12844 	TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
12845 
12846 	return 0;
12847 }
12848 
12849 static int
12850 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
12851 		const struct aead_test_data *tdata,
12852 		void *digest_mem, uint64_t digest_phys)
12853 {
12854 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12855 	struct crypto_unittest_params *ut_params = &unittest_params;
12856 
12857 	const unsigned int auth_tag_len = tdata->auth_tag.len;
12858 	const unsigned int iv_len = tdata->iv.len;
12859 	unsigned int aad_len = tdata->aad.len;
12860 	unsigned int aad_len_pad = 0;
12861 
12862 	/* Generate Crypto op data structure */
12863 	ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
12864 			RTE_CRYPTO_OP_TYPE_SYMMETRIC);
12865 	TEST_ASSERT_NOT_NULL(ut_params->op,
12866 		"Failed to allocate symmetric crypto operation struct");
12867 
12868 	struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
12869 
12870 	sym_op->aead.digest.data = digest_mem;
12871 
12872 	TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
12873 			"no room to append digest");
12874 
12875 	sym_op->aead.digest.phys_addr = digest_phys;
12876 
12877 	if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
12878 		rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
12879 				auth_tag_len);
12880 		debug_hexdump(stdout, "digest:",
12881 				sym_op->aead.digest.data,
12882 				auth_tag_len);
12883 	}
12884 
12885 	/* Append aad data */
12886 	if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
12887 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12888 				uint8_t *, IV_OFFSET);
12889 
12890 		/* Copy IV 1 byte after the IV pointer, according to the API */
12891 		rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
12892 
12893 		aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
12894 
12895 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12896 				ut_params->ibuf, aad_len);
12897 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12898 				"no room to prepend aad");
12899 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12900 				ut_params->ibuf);
12901 
12902 		memset(sym_op->aead.aad.data, 0, aad_len);
12903 		/* Copy AAD 18 bytes after the AAD pointer, according to the API */
12904 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12905 
12906 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12907 		debug_hexdump(stdout, "aad:",
12908 				sym_op->aead.aad.data, aad_len);
12909 	} else {
12910 		uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
12911 				uint8_t *, IV_OFFSET);
12912 
12913 		rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
12914 
12915 		aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
12916 
12917 		sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
12918 				ut_params->ibuf, aad_len_pad);
12919 		TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
12920 				"no room to prepend aad");
12921 		sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
12922 				ut_params->ibuf);
12923 
12924 		memset(sym_op->aead.aad.data, 0, aad_len);
12925 		rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
12926 
12927 		debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
12928 		debug_hexdump(stdout, "aad:",
12929 				sym_op->aead.aad.data, aad_len);
12930 	}
12931 
12932 	sym_op->aead.data.length = tdata->plaintext.len;
12933 	sym_op->aead.data.offset = aad_len_pad;
12934 
12935 	return 0;
12936 }
12937 
12938 #define SGL_MAX_NO	16
12939 
12940 static int
12941 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
12942 		const int oop, uint32_t fragsz, uint32_t fragsz_oop)
12943 {
12944 	struct crypto_testsuite_params *ts_params = &testsuite_params;
12945 	struct crypto_unittest_params *ut_params = &unittest_params;
12946 	struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
12947 	int retval;
12948 	int to_trn = 0;
12949 	int to_trn_tbl[SGL_MAX_NO];
12950 	int segs = 1;
12951 	unsigned int trn_data = 0;
12952 	uint8_t *plaintext, *ciphertext, *auth_tag;
12953 	struct rte_cryptodev_info dev_info;
12954 
12955 	/* Verify the capabilities */
12956 	struct rte_cryptodev_sym_capability_idx cap_idx;
12957 	cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
12958 	cap_idx.algo.aead = tdata->algo;
12959 	if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
12960 			&cap_idx) == NULL)
12961 		return TEST_SKIPPED;
12962 
12963 	/* OOP not supported with CPU crypto */
12964 	if (oop && gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
12965 		return TEST_SKIPPED;
12966 
12967 	/* Detailed check for the particular SGL support flag */
12968 	rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
12969 	if (!oop) {
12970 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
12971 		if (sgl_in && (!(dev_info.feature_flags &
12972 				RTE_CRYPTODEV_FF_IN_PLACE_SGL)))
12973 			return TEST_SKIPPED;
12974 
12975 		uint64_t feat_flags = dev_info.feature_flags;
12976 
12977 		if ((global_api_test_type == CRYPTODEV_RAW_API_TEST) &&
12978 			(!(feat_flags & RTE_CRYPTODEV_FF_SYM_RAW_DP))) {
12979 			printf("Device doesn't support RAW data-path APIs.\n");
12980 			return TEST_SKIPPED;
12981 		}
12982 	} else {
12983 		unsigned int sgl_in = fragsz < tdata->plaintext.len;
12984 		unsigned int sgl_out = (fragsz_oop ? fragsz_oop : fragsz) <
12985 				tdata->plaintext.len;
12986 		/* Raw data path API does not support OOP */
12987 		if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
12988 			return TEST_SKIPPED;
12989 		if (sgl_in && !sgl_out) {
12990 			if (!(dev_info.feature_flags &
12991 					RTE_CRYPTODEV_FF_OOP_SGL_IN_LB_OUT))
12992 				return TEST_SKIPPED;
12993 		} else if (!sgl_in && sgl_out) {
12994 			if (!(dev_info.feature_flags &
12995 					RTE_CRYPTODEV_FF_OOP_LB_IN_SGL_OUT))
12996 				return TEST_SKIPPED;
12997 		} else if (sgl_in && sgl_out) {
12998 			if (!(dev_info.feature_flags &
12999 					RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT))
13000 				return TEST_SKIPPED;
13001 		}
13002 	}
13003 
13004 	if (fragsz > tdata->plaintext.len)
13005 		fragsz = tdata->plaintext.len;
13006 
13007 	uint16_t plaintext_len = fragsz;
13008 	uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
13009 
13010 	if (fragsz_oop > tdata->plaintext.len)
13011 		frag_size_oop = tdata->plaintext.len;
13012 
13013 	int ecx = 0;
13014 	void *digest_mem = NULL;
13015 
13016 	uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
13017 
13018 	if (tdata->plaintext.len % fragsz != 0) {
13019 		if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
13020 			return 1;
13021 	}	else {
13022 		if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
13023 			return 1;
13024 	}
13025 
13026 	/*
13027 	 * For out-op-place we need to alloc another mbuf
13028 	 */
13029 	if (oop) {
13030 		ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13031 		rte_pktmbuf_append(ut_params->obuf,
13032 				frag_size_oop + prepend_len);
13033 		buf_oop = ut_params->obuf;
13034 	}
13035 
13036 	/* Create AEAD session */
13037 	retval = create_aead_session(ts_params->valid_devs[0],
13038 			tdata->algo,
13039 			RTE_CRYPTO_AEAD_OP_ENCRYPT,
13040 			tdata->key.data, tdata->key.len,
13041 			tdata->aad.len, tdata->auth_tag.len,
13042 			tdata->iv.len);
13043 	if (retval < 0)
13044 		return retval;
13045 
13046 	ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13047 
13048 	/* clear mbuf payload */
13049 	memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
13050 			rte_pktmbuf_tailroom(ut_params->ibuf));
13051 
13052 	plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13053 			plaintext_len);
13054 
13055 	memcpy(plaintext, tdata->plaintext.data, plaintext_len);
13056 
13057 	trn_data += plaintext_len;
13058 
13059 	buf = ut_params->ibuf;
13060 
13061 	/*
13062 	 * Loop until no more fragments
13063 	 */
13064 
13065 	while (trn_data < tdata->plaintext.len) {
13066 		++segs;
13067 		to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
13068 				(tdata->plaintext.len - trn_data) : fragsz;
13069 
13070 		to_trn_tbl[ecx++] = to_trn;
13071 
13072 		buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
13073 		buf = buf->next;
13074 
13075 		memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
13076 				rte_pktmbuf_tailroom(buf));
13077 
13078 		/* OOP */
13079 		if (oop && !fragsz_oop) {
13080 			buf_last_oop = buf_oop->next =
13081 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
13082 			buf_oop = buf_oop->next;
13083 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13084 					0, rte_pktmbuf_tailroom(buf_oop));
13085 			rte_pktmbuf_append(buf_oop, to_trn);
13086 		}
13087 
13088 		plaintext = (uint8_t *)rte_pktmbuf_append(buf,
13089 				to_trn);
13090 
13091 		memcpy(plaintext, tdata->plaintext.data + trn_data,
13092 				to_trn);
13093 		trn_data += to_trn;
13094 		if (trn_data  == tdata->plaintext.len) {
13095 			if (oop) {
13096 				if (!fragsz_oop)
13097 					digest_mem = rte_pktmbuf_append(buf_oop,
13098 						tdata->auth_tag.len);
13099 			} else
13100 				digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
13101 					tdata->auth_tag.len);
13102 		}
13103 	}
13104 
13105 	uint64_t digest_phys = 0;
13106 
13107 	ut_params->ibuf->nb_segs = segs;
13108 
13109 	segs = 1;
13110 	if (fragsz_oop && oop) {
13111 		to_trn = 0;
13112 		ecx = 0;
13113 
13114 		if (frag_size_oop == tdata->plaintext.len) {
13115 			digest_mem = rte_pktmbuf_append(ut_params->obuf,
13116 				tdata->auth_tag.len);
13117 
13118 			digest_phys = rte_pktmbuf_iova_offset(
13119 					ut_params->obuf,
13120 					tdata->plaintext.len + prepend_len);
13121 		}
13122 
13123 		trn_data = frag_size_oop;
13124 		while (trn_data < tdata->plaintext.len) {
13125 			++segs;
13126 			to_trn =
13127 				(tdata->plaintext.len - trn_data <
13128 						frag_size_oop) ?
13129 				(tdata->plaintext.len - trn_data) :
13130 						frag_size_oop;
13131 
13132 			to_trn_tbl[ecx++] = to_trn;
13133 
13134 			buf_last_oop = buf_oop->next =
13135 					rte_pktmbuf_alloc(ts_params->mbuf_pool);
13136 			buf_oop = buf_oop->next;
13137 			memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
13138 					0, rte_pktmbuf_tailroom(buf_oop));
13139 			rte_pktmbuf_append(buf_oop, to_trn);
13140 
13141 			trn_data += to_trn;
13142 
13143 			if (trn_data  == tdata->plaintext.len) {
13144 				digest_mem = rte_pktmbuf_append(buf_oop,
13145 					tdata->auth_tag.len);
13146 			}
13147 		}
13148 
13149 		ut_params->obuf->nb_segs = segs;
13150 	}
13151 
13152 	/*
13153 	 * Place digest at the end of the last buffer
13154 	 */
13155 	if (!digest_phys)
13156 		digest_phys = rte_pktmbuf_iova(buf) + to_trn;
13157 	if (oop && buf_last_oop)
13158 		digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
13159 
13160 	if (!digest_mem && !oop) {
13161 		digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
13162 				+ tdata->auth_tag.len);
13163 		digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
13164 				tdata->plaintext.len);
13165 	}
13166 
13167 	/* Create AEAD operation */
13168 	retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
13169 			tdata, digest_mem, digest_phys);
13170 
13171 	if (retval < 0)
13172 		return retval;
13173 
13174 	rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
13175 
13176 	ut_params->op->sym->m_src = ut_params->ibuf;
13177 	if (oop)
13178 		ut_params->op->sym->m_dst = ut_params->obuf;
13179 
13180 	/* Process crypto operation */
13181 	if (oop == IN_PLACE &&
13182 			gbl_action_type == RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO)
13183 		process_cpu_aead_op(ts_params->valid_devs[0], ut_params->op);
13184 	else if (global_api_test_type == CRYPTODEV_RAW_API_TEST)
13185 		process_sym_raw_dp_op(ts_params->valid_devs[0], 0,
13186 				ut_params->op, 0, 0, 0, 0);
13187 	else
13188 		TEST_ASSERT_NOT_NULL(
13189 			process_crypto_request(ts_params->valid_devs[0],
13190 			ut_params->op), "failed to process sym crypto op");
13191 
13192 	TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
13193 			"crypto op processing failed");
13194 
13195 
13196 	ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
13197 			uint8_t *, prepend_len);
13198 	if (oop) {
13199 		ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
13200 				uint8_t *, prepend_len);
13201 	}
13202 
13203 	if (fragsz_oop)
13204 		fragsz = fragsz_oop;
13205 
13206 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13207 			ciphertext,
13208 			tdata->ciphertext.data,
13209 			fragsz,
13210 			"Ciphertext data not as expected");
13211 
13212 	buf = ut_params->op->sym->m_src->next;
13213 	if (oop)
13214 		buf = ut_params->op->sym->m_dst->next;
13215 
13216 	unsigned int off = fragsz;
13217 
13218 	ecx = 0;
13219 	while (buf) {
13220 		ciphertext = rte_pktmbuf_mtod(buf,
13221 				uint8_t *);
13222 
13223 		TEST_ASSERT_BUFFERS_ARE_EQUAL(
13224 				ciphertext,
13225 				tdata->ciphertext.data + off,
13226 				to_trn_tbl[ecx],
13227 				"Ciphertext data not as expected");
13228 
13229 		off += to_trn_tbl[ecx++];
13230 		buf = buf->next;
13231 	}
13232 
13233 	auth_tag = digest_mem;
13234 	TEST_ASSERT_BUFFERS_ARE_EQUAL(
13235 			auth_tag,
13236 			tdata->auth_tag.data,
13237 			tdata->auth_tag.len,
13238 			"Generated auth tag not as expected");
13239 
13240 	return 0;
13241 }
13242 
13243 static int
13244 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
13245 {
13246 	return test_authenticated_encryption_SGL(
13247 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
13248 }
13249 
13250 static int
13251 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
13252 {
13253 	return test_authenticated_encryption_SGL(
13254 			&gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
13255 }
13256 
13257 static int
13258 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
13259 {
13260 	return test_authenticated_encryption_SGL(
13261 			&gcm_test_case_8, OUT_OF_PLACE, 400,
13262 			gcm_test_case_8.plaintext.len);
13263 }
13264 
13265 static int
13266 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
13267 {
13268 	/* This test is not for OPENSSL PMD */
13269 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
13270 			RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)))
13271 		return TEST_SKIPPED;
13272 
13273 	return test_authenticated_encryption_SGL(
13274 			&gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
13275 }
13276 
13277 static int
13278 test_authentication_verify_fail_when_data_corrupted(
13279 		struct crypto_testsuite_params *ts_params,
13280 		struct crypto_unittest_params *ut_params,
13281 		const struct test_crypto_vector *reference)
13282 {
13283 	return test_authentication_verify_fail_when_data_corruption(
13284 			ts_params, ut_params, reference, 1);
13285 }
13286 
13287 static int
13288 test_authentication_verify_fail_when_tag_corrupted(
13289 		struct crypto_testsuite_params *ts_params,
13290 		struct crypto_unittest_params *ut_params,
13291 		const struct test_crypto_vector *reference)
13292 {
13293 	return test_authentication_verify_fail_when_data_corruption(
13294 			ts_params, ut_params, reference, 0);
13295 }
13296 
13297 static int
13298 test_authentication_verify_GMAC_fail_when_data_corrupted(
13299 		struct crypto_testsuite_params *ts_params,
13300 		struct crypto_unittest_params *ut_params,
13301 		const struct test_crypto_vector *reference)
13302 {
13303 	return test_authentication_verify_GMAC_fail_when_corruption(
13304 			ts_params, ut_params, reference, 1);
13305 }
13306 
13307 static int
13308 test_authentication_verify_GMAC_fail_when_tag_corrupted(
13309 		struct crypto_testsuite_params *ts_params,
13310 		struct crypto_unittest_params *ut_params,
13311 		const struct test_crypto_vector *reference)
13312 {
13313 	return test_authentication_verify_GMAC_fail_when_corruption(
13314 			ts_params, ut_params, reference, 0);
13315 }
13316 
13317 static int
13318 test_authenticated_decryption_fail_when_data_corrupted(
13319 		struct crypto_testsuite_params *ts_params,
13320 		struct crypto_unittest_params *ut_params,
13321 		const struct test_crypto_vector *reference)
13322 {
13323 	return test_authenticated_decryption_fail_when_corruption(
13324 			ts_params, ut_params, reference, 1);
13325 }
13326 
13327 static int
13328 test_authenticated_decryption_fail_when_tag_corrupted(
13329 		struct crypto_testsuite_params *ts_params,
13330 		struct crypto_unittest_params *ut_params,
13331 		const struct test_crypto_vector *reference)
13332 {
13333 	return test_authenticated_decryption_fail_when_corruption(
13334 			ts_params, ut_params, reference, 0);
13335 }
13336 
13337 static int
13338 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
13339 {
13340 	return test_authentication_verify_fail_when_data_corrupted(
13341 			&testsuite_params, &unittest_params,
13342 			&hmac_sha1_test_crypto_vector);
13343 }
13344 
13345 static int
13346 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
13347 {
13348 	return test_authentication_verify_fail_when_tag_corrupted(
13349 			&testsuite_params, &unittest_params,
13350 			&hmac_sha1_test_crypto_vector);
13351 }
13352 
13353 static int
13354 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
13355 {
13356 	return test_authentication_verify_GMAC_fail_when_data_corrupted(
13357 			&testsuite_params, &unittest_params,
13358 			&aes128_gmac_test_vector);
13359 }
13360 
13361 static int
13362 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
13363 {
13364 	return test_authentication_verify_GMAC_fail_when_tag_corrupted(
13365 			&testsuite_params, &unittest_params,
13366 			&aes128_gmac_test_vector);
13367 }
13368 
13369 static int
13370 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
13371 {
13372 	return test_authenticated_decryption_fail_when_data_corrupted(
13373 			&testsuite_params,
13374 			&unittest_params,
13375 			&aes128cbc_hmac_sha1_test_vector);
13376 }
13377 
13378 static int
13379 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
13380 {
13381 	return test_authenticated_decryption_fail_when_tag_corrupted(
13382 			&testsuite_params,
13383 			&unittest_params,
13384 			&aes128cbc_hmac_sha1_test_vector);
13385 }
13386 
13387 static int
13388 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13389 {
13390 	return test_authenticated_encryt_with_esn(
13391 			&testsuite_params,
13392 			&unittest_params,
13393 			&aes128cbc_hmac_sha1_aad_test_vector);
13394 }
13395 
13396 static int
13397 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
13398 {
13399 	return test_authenticated_decrypt_with_esn(
13400 			&testsuite_params,
13401 			&unittest_params,
13402 			&aes128cbc_hmac_sha1_aad_test_vector);
13403 }
13404 
13405 static int
13406 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
13407 {
13408 	return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
13409 }
13410 
13411 static int
13412 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
13413 {
13414 	return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
13415 }
13416 
13417 #ifdef RTE_CRYPTO_SCHEDULER
13418 
13419 /* global AESNI worker IDs for the scheduler test */
13420 uint8_t aesni_ids[2];
13421 
13422 static int
13423 scheduler_testsuite_setup(void)
13424 {
13425 	uint32_t i = 0;
13426 	int32_t nb_devs, ret;
13427 	char vdev_args[VDEV_ARGS_SIZE] = {""};
13428 	char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
13429 		"ordering=enable,name=cryptodev_test_scheduler,corelist="};
13430 	uint16_t worker_core_count = 0;
13431 	uint16_t socket_id = 0;
13432 
13433 	if (gbl_driver_id == rte_cryptodev_driver_id_get(
13434 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
13435 
13436 		/* Identify the Worker Cores
13437 		 * Use 2 worker cores for the device args
13438 		 */
13439 		RTE_LCORE_FOREACH_WORKER(i) {
13440 			if (worker_core_count > 1)
13441 				break;
13442 			snprintf(vdev_args, sizeof(vdev_args),
13443 					"%s%d", temp_str, i);
13444 			strcpy(temp_str, vdev_args);
13445 			strlcat(temp_str, ";", sizeof(temp_str));
13446 			worker_core_count++;
13447 			socket_id = rte_lcore_to_socket_id(i);
13448 		}
13449 		if (worker_core_count != 2) {
13450 			RTE_LOG(ERR, USER1,
13451 				"Cryptodev scheduler test require at least "
13452 				"two worker cores to run. "
13453 				"Please use the correct coremask.\n");
13454 			return TEST_FAILED;
13455 		}
13456 		strcpy(temp_str, vdev_args);
13457 		snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
13458 				temp_str, socket_id);
13459 		RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
13460 		nb_devs = rte_cryptodev_device_count_by_driver(
13461 				rte_cryptodev_driver_id_get(
13462 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
13463 		if (nb_devs < 1) {
13464 			ret = rte_vdev_init(
13465 				RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
13466 					vdev_args);
13467 			TEST_ASSERT(ret == 0,
13468 				"Failed to create instance %u of pmd : %s",
13469 				i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
13470 		}
13471 	}
13472 	return testsuite_setup();
13473 }
13474 
13475 static int
13476 test_scheduler_attach_slave_op(void)
13477 {
13478 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13479 	uint8_t sched_id = ts_params->valid_devs[0];
13480 	uint32_t nb_devs, i, nb_devs_attached = 0;
13481 	int ret;
13482 	char vdev_name[32];
13483 
13484 	/* create 2 AESNI_MB if necessary */
13485 	nb_devs = rte_cryptodev_device_count_by_driver(
13486 			rte_cryptodev_driver_id_get(
13487 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
13488 	if (nb_devs < 2) {
13489 		for (i = nb_devs; i < 2; i++) {
13490 			snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
13491 					RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
13492 					i);
13493 			ret = rte_vdev_init(vdev_name, NULL);
13494 
13495 			TEST_ASSERT(ret == 0,
13496 				"Failed to create instance %u of"
13497 				" pmd : %s",
13498 				i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13499 		}
13500 	}
13501 
13502 	/* attach 2 AESNI_MB cdevs */
13503 	for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
13504 			i++) {
13505 		struct rte_cryptodev_info info;
13506 		unsigned int session_size;
13507 
13508 		rte_cryptodev_info_get(i, &info);
13509 		if (info.driver_id != rte_cryptodev_driver_id_get(
13510 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
13511 			continue;
13512 
13513 		session_size = rte_cryptodev_sym_get_private_session_size(i);
13514 		/*
13515 		 * Create the session mempool again, since now there are new devices
13516 		 * to use the mempool.
13517 		 */
13518 		if (ts_params->session_mpool) {
13519 			rte_mempool_free(ts_params->session_mpool);
13520 			ts_params->session_mpool = NULL;
13521 		}
13522 		if (ts_params->session_priv_mpool) {
13523 			rte_mempool_free(ts_params->session_priv_mpool);
13524 			ts_params->session_priv_mpool = NULL;
13525 		}
13526 
13527 		if (info.sym.max_nb_sessions != 0 &&
13528 				info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
13529 			RTE_LOG(ERR, USER1,
13530 					"Device does not support "
13531 					"at least %u sessions\n",
13532 					MAX_NB_SESSIONS);
13533 			return TEST_FAILED;
13534 		}
13535 		/*
13536 		 * Create mempool with maximum number of sessions,
13537 		 * to include the session headers
13538 		 */
13539 		if (ts_params->session_mpool == NULL) {
13540 			ts_params->session_mpool =
13541 				rte_cryptodev_sym_session_pool_create(
13542 						"test_sess_mp",
13543 						MAX_NB_SESSIONS, 0, 0, 0,
13544 						SOCKET_ID_ANY);
13545 			TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
13546 					"session mempool allocation failed");
13547 		}
13548 
13549 		/*
13550 		 * Create mempool with maximum number of sessions,
13551 		 * to include device specific session private data
13552 		 */
13553 		if (ts_params->session_priv_mpool == NULL) {
13554 			ts_params->session_priv_mpool = rte_mempool_create(
13555 					"test_sess_mp_priv",
13556 					MAX_NB_SESSIONS,
13557 					session_size,
13558 					0, 0, NULL, NULL, NULL,
13559 					NULL, SOCKET_ID_ANY,
13560 					0);
13561 
13562 			TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
13563 					"session mempool allocation failed");
13564 		}
13565 
13566 		ts_params->qp_conf.mp_session = ts_params->session_mpool;
13567 		ts_params->qp_conf.mp_session_private =
13568 				ts_params->session_priv_mpool;
13569 
13570 		ret = rte_cryptodev_scheduler_worker_attach(sched_id,
13571 				(uint8_t)i);
13572 
13573 		TEST_ASSERT(ret == 0,
13574 			"Failed to attach device %u of pmd : %s", i,
13575 			RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
13576 
13577 		aesni_ids[nb_devs_attached] = (uint8_t)i;
13578 
13579 		nb_devs_attached++;
13580 	}
13581 
13582 	return 0;
13583 }
13584 
13585 static int
13586 test_scheduler_detach_slave_op(void)
13587 {
13588 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13589 	uint8_t sched_id = ts_params->valid_devs[0];
13590 	uint32_t i;
13591 	int ret;
13592 
13593 	for (i = 0; i < 2; i++) {
13594 		ret = rte_cryptodev_scheduler_worker_detach(sched_id,
13595 				aesni_ids[i]);
13596 		TEST_ASSERT(ret == 0,
13597 			"Failed to detach device %u", aesni_ids[i]);
13598 	}
13599 
13600 	return 0;
13601 }
13602 
13603 static int
13604 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
13605 {
13606 	struct crypto_testsuite_params *ts_params = &testsuite_params;
13607 	uint8_t sched_id = ts_params->valid_devs[0];
13608 	/* set mode */
13609 	return rte_cryptodev_scheduler_mode_set(sched_id,
13610 		scheduler_mode);
13611 }
13612 
13613 static int
13614 test_scheduler_mode_roundrobin_op(void)
13615 {
13616 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
13617 			0, "Failed to set roundrobin mode");
13618 	return 0;
13619 
13620 }
13621 
13622 static int
13623 test_scheduler_mode_multicore_op(void)
13624 {
13625 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
13626 			0, "Failed to set multicore mode");
13627 
13628 	return 0;
13629 }
13630 
13631 static int
13632 test_scheduler_mode_failover_op(void)
13633 {
13634 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
13635 			0, "Failed to set failover mode");
13636 
13637 	return 0;
13638 }
13639 
13640 static int
13641 test_scheduler_mode_pkt_size_distr_op(void)
13642 {
13643 	TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
13644 			0, "Failed to set pktsize mode");
13645 
13646 	return 0;
13647 }
13648 
13649 static int
13650 scheduler_multicore_testsuite_setup(void)
13651 {
13652 	if (test_scheduler_attach_slave_op() < 0)
13653 		return TEST_SKIPPED;
13654 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) < 0)
13655 		return TEST_SKIPPED;
13656 	return 0;
13657 }
13658 
13659 static int
13660 scheduler_roundrobin_testsuite_setup(void)
13661 {
13662 	if (test_scheduler_attach_slave_op() < 0)
13663 		return TEST_SKIPPED;
13664 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) < 0)
13665 		return TEST_SKIPPED;
13666 	return 0;
13667 }
13668 
13669 static int
13670 scheduler_failover_testsuite_setup(void)
13671 {
13672 	if (test_scheduler_attach_slave_op() < 0)
13673 		return TEST_SKIPPED;
13674 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) < 0)
13675 		return TEST_SKIPPED;
13676 	return 0;
13677 }
13678 
13679 static int
13680 scheduler_pkt_size_distr_testsuite_setup(void)
13681 {
13682 	if (test_scheduler_attach_slave_op() < 0)
13683 		return TEST_SKIPPED;
13684 	if (test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) < 0)
13685 		return TEST_SKIPPED;
13686 	return 0;
13687 }
13688 
13689 static void
13690 scheduler_mode_testsuite_teardown(void)
13691 {
13692 	test_scheduler_detach_slave_op();
13693 }
13694 
13695 #endif /* RTE_CRYPTO_SCHEDULER */
13696 
13697 static struct unit_test_suite end_testsuite = {
13698 	.suite_name = NULL,
13699 	.setup = NULL,
13700 	.teardown = NULL,
13701 	.unit_test_suites = NULL
13702 };
13703 
13704 #ifdef RTE_LIB_SECURITY
13705 static struct unit_test_suite pdcp_proto_testsuite  = {
13706 	.suite_name = "PDCP Proto Unit Test Suite",
13707 	.setup = pdcp_proto_testsuite_setup,
13708 	.unit_test_cases = {
13709 		TEST_CASE_ST(ut_setup_security, ut_teardown,
13710 			test_PDCP_PROTO_all),
13711 		TEST_CASES_END() /**< NULL terminate unit test array */
13712 	}
13713 };
13714 
13715 static struct unit_test_suite docsis_proto_testsuite  = {
13716 	.suite_name = "Docsis Proto Unit Test Suite",
13717 	.setup = docsis_proto_testsuite_setup,
13718 	.unit_test_cases = {
13719 		TEST_CASE_ST(ut_setup_security, ut_teardown,
13720 			test_DOCSIS_PROTO_all),
13721 		TEST_CASES_END() /**< NULL terminate unit test array */
13722 	}
13723 };
13724 #endif
13725 
13726 static struct unit_test_suite cryptodev_gen_testsuite  = {
13727 	.suite_name = "Crypto General Unit Test Suite",
13728 	.setup = crypto_gen_testsuite_setup,
13729 	.unit_test_cases = {
13730 		TEST_CASE_ST(ut_setup, ut_teardown,
13731 				test_device_configure_invalid_dev_id),
13732 		TEST_CASE_ST(ut_setup, ut_teardown,
13733 				test_queue_pair_descriptor_setup),
13734 		TEST_CASE_ST(ut_setup, ut_teardown,
13735 				test_device_configure_invalid_queue_pair_ids),
13736 		TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
13737 		TEST_CASE_ST(ut_setup, ut_teardown, test_enq_callback_setup),
13738 		TEST_CASE_ST(ut_setup, ut_teardown, test_deq_callback_setup),
13739 		TEST_CASES_END() /**< NULL terminate unit test array */
13740 	}
13741 };
13742 
13743 static struct unit_test_suite cryptodev_negative_hmac_sha1_testsuite = {
13744 	.suite_name = "Negative HMAC SHA1 Unit Test Suite",
13745 	.setup = negative_hmac_sha1_testsuite_setup,
13746 	.unit_test_cases = {
13747 		/** Negative tests */
13748 		TEST_CASE_ST(ut_setup, ut_teardown,
13749 			authentication_verify_HMAC_SHA1_fail_data_corrupt),
13750 		TEST_CASE_ST(ut_setup, ut_teardown,
13751 			authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13752 		TEST_CASE_ST(ut_setup, ut_teardown,
13753 			auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13754 		TEST_CASE_ST(ut_setup, ut_teardown,
13755 			auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13756 
13757 		TEST_CASES_END() /**< NULL terminate unit test array */
13758 	}
13759 };
13760 
13761 static struct unit_test_suite cryptodev_multi_session_testsuite = {
13762 	.suite_name = "Multi Session Unit Test Suite",
13763 	.setup = multi_session_testsuite_setup,
13764 	.unit_test_cases = {
13765 		TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13766 		TEST_CASE_ST(ut_setup, ut_teardown,
13767 				test_multi_session_random_usage),
13768 
13769 		TEST_CASES_END() /**< NULL terminate unit test array */
13770 	}
13771 };
13772 
13773 static struct unit_test_suite cryptodev_null_testsuite  = {
13774 	.suite_name = "NULL Test Suite",
13775 	.setup = null_testsuite_setup,
13776 	.unit_test_cases = {
13777 		TEST_CASE_ST(ut_setup, ut_teardown,
13778 			test_null_invalid_operation),
13779 		TEST_CASE_ST(ut_setup, ut_teardown, test_null_burst_operation),
13780 		TEST_CASES_END()
13781 	}
13782 };
13783 
13784 static struct unit_test_suite cryptodev_aes_ccm_auth_testsuite  = {
13785 	.suite_name = "AES CCM Authenticated Test Suite",
13786 	.setup = aes_ccm_auth_testsuite_setup,
13787 	.unit_test_cases = {
13788 		/** AES CCM Authenticated Encryption 128 bits key*/
13789 		TEST_CASE_ST(ut_setup, ut_teardown,
13790 			test_AES_CCM_authenticated_encryption_test_case_128_1),
13791 		TEST_CASE_ST(ut_setup, ut_teardown,
13792 			test_AES_CCM_authenticated_encryption_test_case_128_2),
13793 		TEST_CASE_ST(ut_setup, ut_teardown,
13794 			test_AES_CCM_authenticated_encryption_test_case_128_3),
13795 
13796 		/** AES CCM Authenticated Decryption 128 bits key*/
13797 		TEST_CASE_ST(ut_setup, ut_teardown,
13798 			test_AES_CCM_authenticated_decryption_test_case_128_1),
13799 		TEST_CASE_ST(ut_setup, ut_teardown,
13800 			test_AES_CCM_authenticated_decryption_test_case_128_2),
13801 		TEST_CASE_ST(ut_setup, ut_teardown,
13802 			test_AES_CCM_authenticated_decryption_test_case_128_3),
13803 
13804 		/** AES CCM Authenticated Encryption 192 bits key */
13805 		TEST_CASE_ST(ut_setup, ut_teardown,
13806 			test_AES_CCM_authenticated_encryption_test_case_192_1),
13807 		TEST_CASE_ST(ut_setup, ut_teardown,
13808 			test_AES_CCM_authenticated_encryption_test_case_192_2),
13809 		TEST_CASE_ST(ut_setup, ut_teardown,
13810 			test_AES_CCM_authenticated_encryption_test_case_192_3),
13811 
13812 		/** AES CCM Authenticated Decryption 192 bits key*/
13813 		TEST_CASE_ST(ut_setup, ut_teardown,
13814 			test_AES_CCM_authenticated_decryption_test_case_192_1),
13815 		TEST_CASE_ST(ut_setup, ut_teardown,
13816 			test_AES_CCM_authenticated_decryption_test_case_192_2),
13817 		TEST_CASE_ST(ut_setup, ut_teardown,
13818 			test_AES_CCM_authenticated_decryption_test_case_192_3),
13819 
13820 		/** AES CCM Authenticated Encryption 256 bits key */
13821 		TEST_CASE_ST(ut_setup, ut_teardown,
13822 			test_AES_CCM_authenticated_encryption_test_case_256_1),
13823 		TEST_CASE_ST(ut_setup, ut_teardown,
13824 			test_AES_CCM_authenticated_encryption_test_case_256_2),
13825 		TEST_CASE_ST(ut_setup, ut_teardown,
13826 			test_AES_CCM_authenticated_encryption_test_case_256_3),
13827 
13828 		/** AES CCM Authenticated Decryption 256 bits key*/
13829 		TEST_CASE_ST(ut_setup, ut_teardown,
13830 			test_AES_CCM_authenticated_decryption_test_case_256_1),
13831 		TEST_CASE_ST(ut_setup, ut_teardown,
13832 			test_AES_CCM_authenticated_decryption_test_case_256_2),
13833 		TEST_CASE_ST(ut_setup, ut_teardown,
13834 			test_AES_CCM_authenticated_decryption_test_case_256_3),
13835 		TEST_CASES_END()
13836 	}
13837 };
13838 
13839 static struct unit_test_suite cryptodev_aes_gcm_auth_testsuite  = {
13840 	.suite_name = "AES GCM Authenticated Test Suite",
13841 	.setup = aes_gcm_auth_testsuite_setup,
13842 	.unit_test_cases = {
13843 		/** AES GCM Authenticated Encryption */
13844 		TEST_CASE_ST(ut_setup, ut_teardown,
13845 			test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13846 		TEST_CASE_ST(ut_setup, ut_teardown,
13847 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13848 		TEST_CASE_ST(ut_setup, ut_teardown,
13849 			test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13850 		TEST_CASE_ST(ut_setup, ut_teardown,
13851 			test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13852 		TEST_CASE_ST(ut_setup, ut_teardown,
13853 			test_AES_GCM_authenticated_encryption_test_case_1),
13854 		TEST_CASE_ST(ut_setup, ut_teardown,
13855 			test_AES_GCM_authenticated_encryption_test_case_2),
13856 		TEST_CASE_ST(ut_setup, ut_teardown,
13857 			test_AES_GCM_authenticated_encryption_test_case_3),
13858 		TEST_CASE_ST(ut_setup, ut_teardown,
13859 			test_AES_GCM_authenticated_encryption_test_case_4),
13860 		TEST_CASE_ST(ut_setup, ut_teardown,
13861 			test_AES_GCM_authenticated_encryption_test_case_5),
13862 		TEST_CASE_ST(ut_setup, ut_teardown,
13863 			test_AES_GCM_authenticated_encryption_test_case_6),
13864 		TEST_CASE_ST(ut_setup, ut_teardown,
13865 			test_AES_GCM_authenticated_encryption_test_case_7),
13866 		TEST_CASE_ST(ut_setup, ut_teardown,
13867 			test_AES_GCM_authenticated_encryption_test_case_8),
13868 		TEST_CASE_ST(ut_setup, ut_teardown,
13869 			test_AES_GCM_J0_authenticated_encryption_test_case_1),
13870 
13871 		/** AES GCM Authenticated Decryption */
13872 		TEST_CASE_ST(ut_setup, ut_teardown,
13873 			test_AES_GCM_authenticated_decryption_test_case_1),
13874 		TEST_CASE_ST(ut_setup, ut_teardown,
13875 			test_AES_GCM_authenticated_decryption_test_case_2),
13876 		TEST_CASE_ST(ut_setup, ut_teardown,
13877 			test_AES_GCM_authenticated_decryption_test_case_3),
13878 		TEST_CASE_ST(ut_setup, ut_teardown,
13879 			test_AES_GCM_authenticated_decryption_test_case_4),
13880 		TEST_CASE_ST(ut_setup, ut_teardown,
13881 			test_AES_GCM_authenticated_decryption_test_case_5),
13882 		TEST_CASE_ST(ut_setup, ut_teardown,
13883 			test_AES_GCM_authenticated_decryption_test_case_6),
13884 		TEST_CASE_ST(ut_setup, ut_teardown,
13885 			test_AES_GCM_authenticated_decryption_test_case_7),
13886 		TEST_CASE_ST(ut_setup, ut_teardown,
13887 			test_AES_GCM_authenticated_decryption_test_case_8),
13888 		TEST_CASE_ST(ut_setup, ut_teardown,
13889 			test_AES_GCM_J0_authenticated_decryption_test_case_1),
13890 
13891 		/** AES GCM Authenticated Encryption 192 bits key */
13892 		TEST_CASE_ST(ut_setup, ut_teardown,
13893 			test_AES_GCM_auth_encryption_test_case_192_1),
13894 		TEST_CASE_ST(ut_setup, ut_teardown,
13895 			test_AES_GCM_auth_encryption_test_case_192_2),
13896 		TEST_CASE_ST(ut_setup, ut_teardown,
13897 			test_AES_GCM_auth_encryption_test_case_192_3),
13898 		TEST_CASE_ST(ut_setup, ut_teardown,
13899 			test_AES_GCM_auth_encryption_test_case_192_4),
13900 		TEST_CASE_ST(ut_setup, ut_teardown,
13901 			test_AES_GCM_auth_encryption_test_case_192_5),
13902 		TEST_CASE_ST(ut_setup, ut_teardown,
13903 			test_AES_GCM_auth_encryption_test_case_192_6),
13904 		TEST_CASE_ST(ut_setup, ut_teardown,
13905 			test_AES_GCM_auth_encryption_test_case_192_7),
13906 
13907 		/** AES GCM Authenticated Decryption 192 bits key */
13908 		TEST_CASE_ST(ut_setup, ut_teardown,
13909 			test_AES_GCM_auth_decryption_test_case_192_1),
13910 		TEST_CASE_ST(ut_setup, ut_teardown,
13911 			test_AES_GCM_auth_decryption_test_case_192_2),
13912 		TEST_CASE_ST(ut_setup, ut_teardown,
13913 			test_AES_GCM_auth_decryption_test_case_192_3),
13914 		TEST_CASE_ST(ut_setup, ut_teardown,
13915 			test_AES_GCM_auth_decryption_test_case_192_4),
13916 		TEST_CASE_ST(ut_setup, ut_teardown,
13917 			test_AES_GCM_auth_decryption_test_case_192_5),
13918 		TEST_CASE_ST(ut_setup, ut_teardown,
13919 			test_AES_GCM_auth_decryption_test_case_192_6),
13920 		TEST_CASE_ST(ut_setup, ut_teardown,
13921 			test_AES_GCM_auth_decryption_test_case_192_7),
13922 
13923 		/** AES GCM Authenticated Encryption 256 bits key */
13924 		TEST_CASE_ST(ut_setup, ut_teardown,
13925 			test_AES_GCM_auth_encryption_test_case_256_1),
13926 		TEST_CASE_ST(ut_setup, ut_teardown,
13927 			test_AES_GCM_auth_encryption_test_case_256_2),
13928 		TEST_CASE_ST(ut_setup, ut_teardown,
13929 			test_AES_GCM_auth_encryption_test_case_256_3),
13930 		TEST_CASE_ST(ut_setup, ut_teardown,
13931 			test_AES_GCM_auth_encryption_test_case_256_4),
13932 		TEST_CASE_ST(ut_setup, ut_teardown,
13933 			test_AES_GCM_auth_encryption_test_case_256_5),
13934 		TEST_CASE_ST(ut_setup, ut_teardown,
13935 			test_AES_GCM_auth_encryption_test_case_256_6),
13936 		TEST_CASE_ST(ut_setup, ut_teardown,
13937 			test_AES_GCM_auth_encryption_test_case_256_7),
13938 
13939 		/** AES GCM Authenticated Decryption 256 bits key */
13940 		TEST_CASE_ST(ut_setup, ut_teardown,
13941 			test_AES_GCM_auth_decryption_test_case_256_1),
13942 		TEST_CASE_ST(ut_setup, ut_teardown,
13943 			test_AES_GCM_auth_decryption_test_case_256_2),
13944 		TEST_CASE_ST(ut_setup, ut_teardown,
13945 			test_AES_GCM_auth_decryption_test_case_256_3),
13946 		TEST_CASE_ST(ut_setup, ut_teardown,
13947 			test_AES_GCM_auth_decryption_test_case_256_4),
13948 		TEST_CASE_ST(ut_setup, ut_teardown,
13949 			test_AES_GCM_auth_decryption_test_case_256_5),
13950 		TEST_CASE_ST(ut_setup, ut_teardown,
13951 			test_AES_GCM_auth_decryption_test_case_256_6),
13952 		TEST_CASE_ST(ut_setup, ut_teardown,
13953 			test_AES_GCM_auth_decryption_test_case_256_7),
13954 
13955 		/** AES GCM Authenticated Encryption big aad size */
13956 		TEST_CASE_ST(ut_setup, ut_teardown,
13957 			test_AES_GCM_auth_encryption_test_case_aad_1),
13958 		TEST_CASE_ST(ut_setup, ut_teardown,
13959 			test_AES_GCM_auth_encryption_test_case_aad_2),
13960 
13961 		/** AES GCM Authenticated Decryption big aad size */
13962 		TEST_CASE_ST(ut_setup, ut_teardown,
13963 			test_AES_GCM_auth_decryption_test_case_aad_1),
13964 		TEST_CASE_ST(ut_setup, ut_teardown,
13965 			test_AES_GCM_auth_decryption_test_case_aad_2),
13966 
13967 		/** Out of place tests */
13968 		TEST_CASE_ST(ut_setup, ut_teardown,
13969 			test_AES_GCM_authenticated_encryption_oop_test_case_1),
13970 		TEST_CASE_ST(ut_setup, ut_teardown,
13971 			test_AES_GCM_authenticated_decryption_oop_test_case_1),
13972 
13973 		/** Session-less tests */
13974 		TEST_CASE_ST(ut_setup, ut_teardown,
13975 			test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13976 		TEST_CASE_ST(ut_setup, ut_teardown,
13977 			test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13978 
13979 		TEST_CASES_END()
13980 	}
13981 };
13982 
13983 static struct unit_test_suite cryptodev_aes_gmac_auth_testsuite  = {
13984 	.suite_name = "AES GMAC Authentication Test Suite",
13985 	.setup = aes_gmac_auth_testsuite_setup,
13986 	.unit_test_cases = {
13987 		TEST_CASE_ST(ut_setup, ut_teardown,
13988 			test_AES_GMAC_authentication_test_case_1),
13989 		TEST_CASE_ST(ut_setup, ut_teardown,
13990 			test_AES_GMAC_authentication_verify_test_case_1),
13991 		TEST_CASE_ST(ut_setup, ut_teardown,
13992 			test_AES_GMAC_authentication_test_case_2),
13993 		TEST_CASE_ST(ut_setup, ut_teardown,
13994 			test_AES_GMAC_authentication_verify_test_case_2),
13995 		TEST_CASE_ST(ut_setup, ut_teardown,
13996 			test_AES_GMAC_authentication_test_case_3),
13997 		TEST_CASE_ST(ut_setup, ut_teardown,
13998 			test_AES_GMAC_authentication_verify_test_case_3),
13999 		TEST_CASE_ST(ut_setup, ut_teardown,
14000 			test_AES_GMAC_authentication_test_case_4),
14001 		TEST_CASE_ST(ut_setup, ut_teardown,
14002 			test_AES_GMAC_authentication_verify_test_case_4),
14003 		TEST_CASE_ST(ut_setup, ut_teardown,
14004 			test_AES_GMAC_authentication_SGL_40B),
14005 		TEST_CASE_ST(ut_setup, ut_teardown,
14006 			test_AES_GMAC_authentication_SGL_80B),
14007 		TEST_CASE_ST(ut_setup, ut_teardown,
14008 			test_AES_GMAC_authentication_SGL_2048B),
14009 		TEST_CASE_ST(ut_setup, ut_teardown,
14010 			test_AES_GMAC_authentication_SGL_2047B),
14011 
14012 		TEST_CASES_END()
14013 	}
14014 };
14015 
14016 static struct unit_test_suite cryptodev_chacha20_poly1305_testsuite  = {
14017 	.suite_name = "Chacha20-Poly1305 Test Suite",
14018 	.setup = chacha20_poly1305_testsuite_setup,
14019 	.unit_test_cases = {
14020 		TEST_CASE_ST(ut_setup, ut_teardown,
14021 			test_chacha20_poly1305_encrypt_test_case_rfc8439),
14022 		TEST_CASE_ST(ut_setup, ut_teardown,
14023 			test_chacha20_poly1305_decrypt_test_case_rfc8439),
14024 		TEST_CASES_END()
14025 	}
14026 };
14027 
14028 static struct unit_test_suite cryptodev_snow3g_testsuite  = {
14029 	.suite_name = "SNOW 3G Test Suite",
14030 	.setup = snow3g_testsuite_setup,
14031 	.unit_test_cases = {
14032 		/** SNOW 3G encrypt only (UEA2) */
14033 		TEST_CASE_ST(ut_setup, ut_teardown,
14034 			test_snow3g_encryption_test_case_1),
14035 		TEST_CASE_ST(ut_setup, ut_teardown,
14036 			test_snow3g_encryption_test_case_2),
14037 		TEST_CASE_ST(ut_setup, ut_teardown,
14038 			test_snow3g_encryption_test_case_3),
14039 		TEST_CASE_ST(ut_setup, ut_teardown,
14040 			test_snow3g_encryption_test_case_4),
14041 		TEST_CASE_ST(ut_setup, ut_teardown,
14042 			test_snow3g_encryption_test_case_5),
14043 
14044 		TEST_CASE_ST(ut_setup, ut_teardown,
14045 			test_snow3g_encryption_test_case_1_oop),
14046 		TEST_CASE_ST(ut_setup, ut_teardown,
14047 			test_snow3g_encryption_test_case_1_oop_sgl),
14048 		TEST_CASE_ST(ut_setup, ut_teardown,
14049 			test_snow3g_encryption_test_case_1_offset_oop),
14050 		TEST_CASE_ST(ut_setup, ut_teardown,
14051 			test_snow3g_decryption_test_case_1_oop),
14052 
14053 		/** SNOW 3G generate auth, then encrypt (UEA2) */
14054 		TEST_CASE_ST(ut_setup, ut_teardown,
14055 			test_snow3g_auth_cipher_test_case_1),
14056 		TEST_CASE_ST(ut_setup, ut_teardown,
14057 			test_snow3g_auth_cipher_test_case_2),
14058 		TEST_CASE_ST(ut_setup, ut_teardown,
14059 			test_snow3g_auth_cipher_test_case_2_oop),
14060 		TEST_CASE_ST(ut_setup, ut_teardown,
14061 			test_snow3g_auth_cipher_part_digest_enc),
14062 		TEST_CASE_ST(ut_setup, ut_teardown,
14063 			test_snow3g_auth_cipher_part_digest_enc_oop),
14064 		TEST_CASE_ST(ut_setup, ut_teardown,
14065 			test_snow3g_auth_cipher_test_case_3_sgl),
14066 		TEST_CASE_ST(ut_setup, ut_teardown,
14067 			test_snow3g_auth_cipher_test_case_3_oop_sgl),
14068 		TEST_CASE_ST(ut_setup, ut_teardown,
14069 			test_snow3g_auth_cipher_part_digest_enc_sgl),
14070 		TEST_CASE_ST(ut_setup, ut_teardown,
14071 			test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
14072 
14073 		/** SNOW 3G decrypt (UEA2), then verify auth */
14074 		TEST_CASE_ST(ut_setup, ut_teardown,
14075 			test_snow3g_auth_cipher_verify_test_case_1),
14076 		TEST_CASE_ST(ut_setup, ut_teardown,
14077 			test_snow3g_auth_cipher_verify_test_case_2),
14078 		TEST_CASE_ST(ut_setup, ut_teardown,
14079 			test_snow3g_auth_cipher_verify_test_case_2_oop),
14080 		TEST_CASE_ST(ut_setup, ut_teardown,
14081 			test_snow3g_auth_cipher_verify_part_digest_enc),
14082 		TEST_CASE_ST(ut_setup, ut_teardown,
14083 			test_snow3g_auth_cipher_verify_part_digest_enc_oop),
14084 		TEST_CASE_ST(ut_setup, ut_teardown,
14085 			test_snow3g_auth_cipher_verify_test_case_3_sgl),
14086 		TEST_CASE_ST(ut_setup, ut_teardown,
14087 			test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
14088 		TEST_CASE_ST(ut_setup, ut_teardown,
14089 			test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
14090 		TEST_CASE_ST(ut_setup, ut_teardown,
14091 			test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
14092 
14093 		/** SNOW 3G decrypt only (UEA2) */
14094 		TEST_CASE_ST(ut_setup, ut_teardown,
14095 			test_snow3g_decryption_test_case_1),
14096 		TEST_CASE_ST(ut_setup, ut_teardown,
14097 			test_snow3g_decryption_test_case_2),
14098 		TEST_CASE_ST(ut_setup, ut_teardown,
14099 			test_snow3g_decryption_test_case_3),
14100 		TEST_CASE_ST(ut_setup, ut_teardown,
14101 			test_snow3g_decryption_test_case_4),
14102 		TEST_CASE_ST(ut_setup, ut_teardown,
14103 			test_snow3g_decryption_test_case_5),
14104 		TEST_CASE_ST(ut_setup, ut_teardown,
14105 			test_snow3g_decryption_with_digest_test_case_1),
14106 		TEST_CASE_ST(ut_setup, ut_teardown,
14107 			test_snow3g_hash_generate_test_case_1),
14108 		TEST_CASE_ST(ut_setup, ut_teardown,
14109 			test_snow3g_hash_generate_test_case_2),
14110 		TEST_CASE_ST(ut_setup, ut_teardown,
14111 			test_snow3g_hash_generate_test_case_3),
14112 
14113 		/* Tests with buffers which length is not byte-aligned */
14114 		TEST_CASE_ST(ut_setup, ut_teardown,
14115 			test_snow3g_hash_generate_test_case_4),
14116 		TEST_CASE_ST(ut_setup, ut_teardown,
14117 			test_snow3g_hash_generate_test_case_5),
14118 		TEST_CASE_ST(ut_setup, ut_teardown,
14119 			test_snow3g_hash_generate_test_case_6),
14120 		TEST_CASE_ST(ut_setup, ut_teardown,
14121 			test_snow3g_hash_verify_test_case_1),
14122 		TEST_CASE_ST(ut_setup, ut_teardown,
14123 			test_snow3g_hash_verify_test_case_2),
14124 		TEST_CASE_ST(ut_setup, ut_teardown,
14125 			test_snow3g_hash_verify_test_case_3),
14126 
14127 		/* Tests with buffers which length is not byte-aligned */
14128 		TEST_CASE_ST(ut_setup, ut_teardown,
14129 			test_snow3g_hash_verify_test_case_4),
14130 		TEST_CASE_ST(ut_setup, ut_teardown,
14131 			test_snow3g_hash_verify_test_case_5),
14132 		TEST_CASE_ST(ut_setup, ut_teardown,
14133 			test_snow3g_hash_verify_test_case_6),
14134 		TEST_CASE_ST(ut_setup, ut_teardown,
14135 			test_snow3g_cipher_auth_test_case_1),
14136 		TEST_CASE_ST(ut_setup, ut_teardown,
14137 			test_snow3g_auth_cipher_with_digest_test_case_1),
14138 		TEST_CASES_END()
14139 	}
14140 };
14141 
14142 static struct unit_test_suite cryptodev_zuc_testsuite  = {
14143 	.suite_name = "ZUC Test Suite",
14144 	.setup = zuc_testsuite_setup,
14145 	.unit_test_cases = {
14146 		/** ZUC encrypt only (EEA3) */
14147 		TEST_CASE_ST(ut_setup, ut_teardown,
14148 			test_zuc_encryption_test_case_1),
14149 		TEST_CASE_ST(ut_setup, ut_teardown,
14150 			test_zuc_encryption_test_case_2),
14151 		TEST_CASE_ST(ut_setup, ut_teardown,
14152 			test_zuc_encryption_test_case_3),
14153 		TEST_CASE_ST(ut_setup, ut_teardown,
14154 			test_zuc_encryption_test_case_4),
14155 		TEST_CASE_ST(ut_setup, ut_teardown,
14156 			test_zuc_encryption_test_case_5),
14157 		TEST_CASE_ST(ut_setup, ut_teardown,
14158 			test_zuc_encryption_test_case_6_sgl),
14159 
14160 		/** ZUC authenticate (EIA3) */
14161 		TEST_CASE_ST(ut_setup, ut_teardown,
14162 			test_zuc_hash_generate_test_case_1),
14163 		TEST_CASE_ST(ut_setup, ut_teardown,
14164 			test_zuc_hash_generate_test_case_2),
14165 		TEST_CASE_ST(ut_setup, ut_teardown,
14166 			test_zuc_hash_generate_test_case_3),
14167 		TEST_CASE_ST(ut_setup, ut_teardown,
14168 			test_zuc_hash_generate_test_case_4),
14169 		TEST_CASE_ST(ut_setup, ut_teardown,
14170 			test_zuc_hash_generate_test_case_5),
14171 		TEST_CASE_ST(ut_setup, ut_teardown,
14172 			test_zuc_hash_generate_test_case_6),
14173 		TEST_CASE_ST(ut_setup, ut_teardown,
14174 			test_zuc_hash_generate_test_case_7),
14175 		TEST_CASE_ST(ut_setup, ut_teardown,
14176 			test_zuc_hash_generate_test_case_8),
14177 
14178 		/** ZUC alg-chain (EEA3/EIA3) */
14179 		TEST_CASE_ST(ut_setup, ut_teardown,
14180 			test_zuc_cipher_auth_test_case_1),
14181 		TEST_CASE_ST(ut_setup, ut_teardown,
14182 			test_zuc_cipher_auth_test_case_2),
14183 
14184 		/** ZUC generate auth, then encrypt (EEA3) */
14185 		TEST_CASE_ST(ut_setup, ut_teardown,
14186 			test_zuc_auth_cipher_test_case_1),
14187 		TEST_CASE_ST(ut_setup, ut_teardown,
14188 			test_zuc_auth_cipher_test_case_1_oop),
14189 		TEST_CASE_ST(ut_setup, ut_teardown,
14190 			test_zuc_auth_cipher_test_case_1_sgl),
14191 		TEST_CASE_ST(ut_setup, ut_teardown,
14192 			test_zuc_auth_cipher_test_case_1_oop_sgl),
14193 
14194 		/** ZUC decrypt (EEA3), then verify auth */
14195 		TEST_CASE_ST(ut_setup, ut_teardown,
14196 			test_zuc_auth_cipher_verify_test_case_1),
14197 		TEST_CASE_ST(ut_setup, ut_teardown,
14198 			test_zuc_auth_cipher_verify_test_case_1_oop),
14199 		TEST_CASE_ST(ut_setup, ut_teardown,
14200 			test_zuc_auth_cipher_verify_test_case_1_sgl),
14201 		TEST_CASE_ST(ut_setup, ut_teardown,
14202 			test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
14203 		TEST_CASES_END()
14204 	}
14205 };
14206 
14207 static struct unit_test_suite cryptodev_hmac_md5_auth_testsuite  = {
14208 	.suite_name = "HMAC_MD5 Authentication Test Suite",
14209 	.setup = hmac_md5_auth_testsuite_setup,
14210 	.unit_test_cases = {
14211 		TEST_CASE_ST(ut_setup, ut_teardown,
14212 			test_MD5_HMAC_generate_case_1),
14213 		TEST_CASE_ST(ut_setup, ut_teardown,
14214 			test_MD5_HMAC_verify_case_1),
14215 		TEST_CASE_ST(ut_setup, ut_teardown,
14216 			test_MD5_HMAC_generate_case_2),
14217 		TEST_CASE_ST(ut_setup, ut_teardown,
14218 			test_MD5_HMAC_verify_case_2),
14219 		TEST_CASES_END()
14220 	}
14221 };
14222 
14223 static struct unit_test_suite cryptodev_kasumi_testsuite  = {
14224 	.suite_name = "Kasumi Test Suite",
14225 	.setup = kasumi_testsuite_setup,
14226 	.unit_test_cases = {
14227 		/** KASUMI hash only (UIA1) */
14228 		TEST_CASE_ST(ut_setup, ut_teardown,
14229 			test_kasumi_hash_generate_test_case_1),
14230 		TEST_CASE_ST(ut_setup, ut_teardown,
14231 			test_kasumi_hash_generate_test_case_2),
14232 		TEST_CASE_ST(ut_setup, ut_teardown,
14233 			test_kasumi_hash_generate_test_case_3),
14234 		TEST_CASE_ST(ut_setup, ut_teardown,
14235 			test_kasumi_hash_generate_test_case_4),
14236 		TEST_CASE_ST(ut_setup, ut_teardown,
14237 			test_kasumi_hash_generate_test_case_5),
14238 		TEST_CASE_ST(ut_setup, ut_teardown,
14239 			test_kasumi_hash_generate_test_case_6),
14240 
14241 		TEST_CASE_ST(ut_setup, ut_teardown,
14242 			test_kasumi_hash_verify_test_case_1),
14243 		TEST_CASE_ST(ut_setup, ut_teardown,
14244 			test_kasumi_hash_verify_test_case_2),
14245 		TEST_CASE_ST(ut_setup, ut_teardown,
14246 			test_kasumi_hash_verify_test_case_3),
14247 		TEST_CASE_ST(ut_setup, ut_teardown,
14248 			test_kasumi_hash_verify_test_case_4),
14249 		TEST_CASE_ST(ut_setup, ut_teardown,
14250 			test_kasumi_hash_verify_test_case_5),
14251 
14252 		/** KASUMI encrypt only (UEA1) */
14253 		TEST_CASE_ST(ut_setup, ut_teardown,
14254 			test_kasumi_encryption_test_case_1),
14255 		TEST_CASE_ST(ut_setup, ut_teardown,
14256 			test_kasumi_encryption_test_case_1_sgl),
14257 		TEST_CASE_ST(ut_setup, ut_teardown,
14258 			test_kasumi_encryption_test_case_1_oop),
14259 		TEST_CASE_ST(ut_setup, ut_teardown,
14260 			test_kasumi_encryption_test_case_1_oop_sgl),
14261 		TEST_CASE_ST(ut_setup, ut_teardown,
14262 			test_kasumi_encryption_test_case_2),
14263 		TEST_CASE_ST(ut_setup, ut_teardown,
14264 			test_kasumi_encryption_test_case_3),
14265 		TEST_CASE_ST(ut_setup, ut_teardown,
14266 			test_kasumi_encryption_test_case_4),
14267 		TEST_CASE_ST(ut_setup, ut_teardown,
14268 			test_kasumi_encryption_test_case_5),
14269 
14270 		/** KASUMI decrypt only (UEA1) */
14271 		TEST_CASE_ST(ut_setup, ut_teardown,
14272 			test_kasumi_decryption_test_case_1),
14273 		TEST_CASE_ST(ut_setup, ut_teardown,
14274 			test_kasumi_decryption_test_case_2),
14275 		TEST_CASE_ST(ut_setup, ut_teardown,
14276 			test_kasumi_decryption_test_case_3),
14277 		TEST_CASE_ST(ut_setup, ut_teardown,
14278 			test_kasumi_decryption_test_case_4),
14279 		TEST_CASE_ST(ut_setup, ut_teardown,
14280 			test_kasumi_decryption_test_case_5),
14281 		TEST_CASE_ST(ut_setup, ut_teardown,
14282 			test_kasumi_decryption_test_case_1_oop),
14283 
14284 		TEST_CASE_ST(ut_setup, ut_teardown,
14285 			test_kasumi_cipher_auth_test_case_1),
14286 
14287 		/** KASUMI generate auth, then encrypt (F8) */
14288 		TEST_CASE_ST(ut_setup, ut_teardown,
14289 			test_kasumi_auth_cipher_test_case_1),
14290 		TEST_CASE_ST(ut_setup, ut_teardown,
14291 			test_kasumi_auth_cipher_test_case_2),
14292 		TEST_CASE_ST(ut_setup, ut_teardown,
14293 			test_kasumi_auth_cipher_test_case_2_oop),
14294 		TEST_CASE_ST(ut_setup, ut_teardown,
14295 			test_kasumi_auth_cipher_test_case_2_sgl),
14296 		TEST_CASE_ST(ut_setup, ut_teardown,
14297 			test_kasumi_auth_cipher_test_case_2_oop_sgl),
14298 
14299 		/** KASUMI decrypt (F8), then verify auth */
14300 		TEST_CASE_ST(ut_setup, ut_teardown,
14301 			test_kasumi_auth_cipher_verify_test_case_1),
14302 		TEST_CASE_ST(ut_setup, ut_teardown,
14303 			test_kasumi_auth_cipher_verify_test_case_2),
14304 		TEST_CASE_ST(ut_setup, ut_teardown,
14305 			test_kasumi_auth_cipher_verify_test_case_2_oop),
14306 		TEST_CASE_ST(ut_setup, ut_teardown,
14307 			test_kasumi_auth_cipher_verify_test_case_2_sgl),
14308 		TEST_CASE_ST(ut_setup, ut_teardown,
14309 			test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
14310 
14311 		TEST_CASES_END()
14312 	}
14313 };
14314 
14315 static struct unit_test_suite cryptodev_esn_testsuite  = {
14316 	.suite_name = "ESN Test Suite",
14317 	.setup = esn_testsuite_setup,
14318 	.unit_test_cases = {
14319 		TEST_CASE_ST(ut_setup, ut_teardown,
14320 			auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
14321 		TEST_CASE_ST(ut_setup, ut_teardown,
14322 			auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
14323 		TEST_CASES_END()
14324 	}
14325 };
14326 
14327 static struct unit_test_suite cryptodev_negative_aes_gcm_testsuite  = {
14328 	.suite_name = "Negative AES GCM Test Suite",
14329 	.setup = negative_aes_gcm_testsuite_setup,
14330 	.unit_test_cases = {
14331 		TEST_CASE_ST(ut_setup, ut_teardown,
14332 			test_AES_GCM_auth_encryption_fail_iv_corrupt),
14333 		TEST_CASE_ST(ut_setup, ut_teardown,
14334 			test_AES_GCM_auth_encryption_fail_in_data_corrupt),
14335 		TEST_CASE_ST(ut_setup, ut_teardown,
14336 			test_AES_GCM_auth_encryption_fail_out_data_corrupt),
14337 		TEST_CASE_ST(ut_setup, ut_teardown,
14338 			test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
14339 		TEST_CASE_ST(ut_setup, ut_teardown,
14340 			test_AES_GCM_auth_encryption_fail_aad_corrupt),
14341 		TEST_CASE_ST(ut_setup, ut_teardown,
14342 			test_AES_GCM_auth_encryption_fail_tag_corrupt),
14343 		TEST_CASE_ST(ut_setup, ut_teardown,
14344 			test_AES_GCM_auth_decryption_fail_iv_corrupt),
14345 		TEST_CASE_ST(ut_setup, ut_teardown,
14346 			test_AES_GCM_auth_decryption_fail_in_data_corrupt),
14347 		TEST_CASE_ST(ut_setup, ut_teardown,
14348 			test_AES_GCM_auth_decryption_fail_out_data_corrupt),
14349 		TEST_CASE_ST(ut_setup, ut_teardown,
14350 			test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
14351 		TEST_CASE_ST(ut_setup, ut_teardown,
14352 			test_AES_GCM_auth_decryption_fail_aad_corrupt),
14353 		TEST_CASE_ST(ut_setup, ut_teardown,
14354 			test_AES_GCM_auth_decryption_fail_tag_corrupt),
14355 
14356 		TEST_CASES_END()
14357 	}
14358 };
14359 
14360 static struct unit_test_suite cryptodev_negative_aes_gmac_testsuite  = {
14361 	.suite_name = "Negative AES GMAC Test Suite",
14362 	.setup = negative_aes_gmac_testsuite_setup,
14363 	.unit_test_cases = {
14364 		TEST_CASE_ST(ut_setup, ut_teardown,
14365 			authentication_verify_AES128_GMAC_fail_data_corrupt),
14366 		TEST_CASE_ST(ut_setup, ut_teardown,
14367 			authentication_verify_AES128_GMAC_fail_tag_corrupt),
14368 
14369 		TEST_CASES_END()
14370 	}
14371 };
14372 
14373 static struct unit_test_suite cryptodev_mixed_cipher_hash_testsuite  = {
14374 	.suite_name = "Mixed CIPHER + HASH algorithms Test Suite",
14375 	.setup = mixed_cipher_hash_testsuite_setup,
14376 	.unit_test_cases = {
14377 		/** AUTH AES CMAC + CIPHER AES CTR */
14378 		TEST_CASE_ST(ut_setup, ut_teardown,
14379 			test_aes_cmac_aes_ctr_digest_enc_test_case_1),
14380 		TEST_CASE_ST(ut_setup, ut_teardown,
14381 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14382 		TEST_CASE_ST(ut_setup, ut_teardown,
14383 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14384 		TEST_CASE_ST(ut_setup, ut_teardown,
14385 			test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14386 		TEST_CASE_ST(ut_setup, ut_teardown,
14387 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
14388 		TEST_CASE_ST(ut_setup, ut_teardown,
14389 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
14390 		TEST_CASE_ST(ut_setup, ut_teardown,
14391 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
14392 		TEST_CASE_ST(ut_setup, ut_teardown,
14393 			test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
14394 
14395 		/** AUTH ZUC + CIPHER SNOW3G */
14396 		TEST_CASE_ST(ut_setup, ut_teardown,
14397 			test_auth_zuc_cipher_snow_test_case_1),
14398 		TEST_CASE_ST(ut_setup, ut_teardown,
14399 			test_verify_auth_zuc_cipher_snow_test_case_1),
14400 		/** AUTH AES CMAC + CIPHER SNOW3G */
14401 		TEST_CASE_ST(ut_setup, ut_teardown,
14402 			test_auth_aes_cmac_cipher_snow_test_case_1),
14403 		TEST_CASE_ST(ut_setup, ut_teardown,
14404 			test_verify_auth_aes_cmac_cipher_snow_test_case_1),
14405 		/** AUTH ZUC + CIPHER AES CTR */
14406 		TEST_CASE_ST(ut_setup, ut_teardown,
14407 			test_auth_zuc_cipher_aes_ctr_test_case_1),
14408 		TEST_CASE_ST(ut_setup, ut_teardown,
14409 			test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
14410 		/** AUTH SNOW3G + CIPHER AES CTR */
14411 		TEST_CASE_ST(ut_setup, ut_teardown,
14412 			test_auth_snow_cipher_aes_ctr_test_case_1),
14413 		TEST_CASE_ST(ut_setup, ut_teardown,
14414 			test_verify_auth_snow_cipher_aes_ctr_test_case_1),
14415 		/** AUTH SNOW3G + CIPHER ZUC */
14416 		TEST_CASE_ST(ut_setup, ut_teardown,
14417 			test_auth_snow_cipher_zuc_test_case_1),
14418 		TEST_CASE_ST(ut_setup, ut_teardown,
14419 			test_verify_auth_snow_cipher_zuc_test_case_1),
14420 		/** AUTH AES CMAC + CIPHER ZUC */
14421 		TEST_CASE_ST(ut_setup, ut_teardown,
14422 			test_auth_aes_cmac_cipher_zuc_test_case_1),
14423 		TEST_CASE_ST(ut_setup, ut_teardown,
14424 			test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
14425 
14426 		/** AUTH NULL + CIPHER SNOW3G */
14427 		TEST_CASE_ST(ut_setup, ut_teardown,
14428 			test_auth_null_cipher_snow_test_case_1),
14429 		TEST_CASE_ST(ut_setup, ut_teardown,
14430 			test_verify_auth_null_cipher_snow_test_case_1),
14431 		/** AUTH NULL + CIPHER ZUC */
14432 		TEST_CASE_ST(ut_setup, ut_teardown,
14433 			test_auth_null_cipher_zuc_test_case_1),
14434 		TEST_CASE_ST(ut_setup, ut_teardown,
14435 			test_verify_auth_null_cipher_zuc_test_case_1),
14436 		/** AUTH SNOW3G + CIPHER NULL */
14437 		TEST_CASE_ST(ut_setup, ut_teardown,
14438 			test_auth_snow_cipher_null_test_case_1),
14439 		TEST_CASE_ST(ut_setup, ut_teardown,
14440 			test_verify_auth_snow_cipher_null_test_case_1),
14441 		/** AUTH ZUC + CIPHER NULL */
14442 		TEST_CASE_ST(ut_setup, ut_teardown,
14443 			test_auth_zuc_cipher_null_test_case_1),
14444 		TEST_CASE_ST(ut_setup, ut_teardown,
14445 			test_verify_auth_zuc_cipher_null_test_case_1),
14446 		/** AUTH NULL + CIPHER AES CTR */
14447 		TEST_CASE_ST(ut_setup, ut_teardown,
14448 			test_auth_null_cipher_aes_ctr_test_case_1),
14449 		TEST_CASE_ST(ut_setup, ut_teardown,
14450 			test_verify_auth_null_cipher_aes_ctr_test_case_1),
14451 		/** AUTH AES CMAC + CIPHER NULL */
14452 		TEST_CASE_ST(ut_setup, ut_teardown,
14453 			test_auth_aes_cmac_cipher_null_test_case_1),
14454 		TEST_CASE_ST(ut_setup, ut_teardown,
14455 			test_verify_auth_aes_cmac_cipher_null_test_case_1),
14456 		TEST_CASES_END()
14457 	}
14458 };
14459 
14460 static int
14461 run_cryptodev_testsuite(const char *pmd_name)
14462 {
14463 	uint8_t ret, j, i = 0, blk_start_idx = 0;
14464 	const enum blockcipher_test_type blk_suites[] = {
14465 		BLKCIPHER_AES_CHAIN_TYPE,
14466 		BLKCIPHER_AES_CIPHERONLY_TYPE,
14467 		BLKCIPHER_AES_DOCSIS_TYPE,
14468 		BLKCIPHER_3DES_CHAIN_TYPE,
14469 		BLKCIPHER_3DES_CIPHERONLY_TYPE,
14470 		BLKCIPHER_DES_CIPHERONLY_TYPE,
14471 		BLKCIPHER_DES_DOCSIS_TYPE,
14472 		BLKCIPHER_AUTHONLY_TYPE};
14473 	struct unit_test_suite *static_suites[] = {
14474 		&cryptodev_multi_session_testsuite,
14475 		&cryptodev_null_testsuite,
14476 		&cryptodev_aes_ccm_auth_testsuite,
14477 		&cryptodev_aes_gcm_auth_testsuite,
14478 		&cryptodev_aes_gmac_auth_testsuite,
14479 		&cryptodev_snow3g_testsuite,
14480 		&cryptodev_chacha20_poly1305_testsuite,
14481 		&cryptodev_zuc_testsuite,
14482 		&cryptodev_hmac_md5_auth_testsuite,
14483 		&cryptodev_kasumi_testsuite,
14484 		&cryptodev_esn_testsuite,
14485 		&cryptodev_negative_aes_gcm_testsuite,
14486 		&cryptodev_negative_aes_gmac_testsuite,
14487 		&cryptodev_mixed_cipher_hash_testsuite,
14488 		&cryptodev_negative_hmac_sha1_testsuite,
14489 		&cryptodev_gen_testsuite,
14490 #ifdef RTE_LIB_SECURITY
14491 		&pdcp_proto_testsuite,
14492 		&docsis_proto_testsuite,
14493 #endif
14494 		&end_testsuite
14495 	};
14496 	static struct unit_test_suite ts = {
14497 		.suite_name = "Cryptodev Unit Test Suite",
14498 		.setup = testsuite_setup,
14499 		.teardown = testsuite_teardown,
14500 		.unit_test_cases = {TEST_CASES_END()}
14501 	};
14502 
14503 	gbl_driver_id = rte_cryptodev_driver_id_get(pmd_name);
14504 
14505 	if (gbl_driver_id == -1) {
14506 		RTE_LOG(ERR, USER1, "%s PMD must be loaded.\n", pmd_name);
14507 		return TEST_FAILED;
14508 	}
14509 
14510 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14511 			(RTE_DIM(blk_suites) + RTE_DIM(static_suites)));
14512 
14513 	ADD_BLOCKCIPHER_TESTSUITE(i, ts, blk_suites, RTE_DIM(blk_suites));
14514 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14515 	ret = unit_test_suite_runner(&ts);
14516 
14517 	FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx, ts, RTE_DIM(blk_suites));
14518 	free(ts.unit_test_suites);
14519 	return ret;
14520 }
14521 
14522 static int
14523 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14524 {
14525 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14526 }
14527 
14528 static int
14529 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14530 {
14531 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14532 }
14533 
14534 static int
14535 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14536 {
14537 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14538 }
14539 
14540 static int
14541 test_cryptodev_cpu_aesni_mb(void)
14542 {
14543 	int32_t rc;
14544 	enum rte_security_session_action_type at = gbl_action_type;
14545 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14546 	rc = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14547 	gbl_action_type = at;
14548 	return rc;
14549 }
14550 
14551 static int
14552 test_cryptodev_openssl(void)
14553 {
14554 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14555 }
14556 
14557 static int
14558 test_cryptodev_aesni_gcm(void)
14559 {
14560 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14561 }
14562 
14563 static int
14564 test_cryptodev_cpu_aesni_gcm(void)
14565 {
14566 	int32_t rc;
14567 	enum rte_security_session_action_type at = gbl_action_type;
14568 	gbl_action_type = RTE_SECURITY_ACTION_TYPE_CPU_CRYPTO;
14569 	rc  = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14570 	gbl_action_type = at;
14571 	return rc;
14572 }
14573 
14574 static int
14575 test_cryptodev_null(void)
14576 {
14577 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14578 }
14579 
14580 static int
14581 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14582 {
14583 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14584 }
14585 
14586 static int
14587 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14588 {
14589 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14590 }
14591 
14592 static int
14593 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14594 {
14595 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14596 }
14597 
14598 static int
14599 test_cryptodev_armv8(void)
14600 {
14601 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14602 }
14603 
14604 static int
14605 test_cryptodev_mrvl(void)
14606 {
14607 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14608 }
14609 
14610 #ifdef RTE_CRYPTO_SCHEDULER
14611 
14612 static int
14613 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14614 {
14615 	uint8_t ret, sched_i, j, i = 0, blk_start_idx = 0;
14616 	const enum blockcipher_test_type blk_suites[] = {
14617 		BLKCIPHER_AES_CHAIN_TYPE,
14618 		BLKCIPHER_AES_CIPHERONLY_TYPE,
14619 		BLKCIPHER_AUTHONLY_TYPE
14620 	};
14621 	static struct unit_test_suite scheduler_multicore = {
14622 		.suite_name = "Scheduler Multicore Unit Test Suite",
14623 		.setup = scheduler_multicore_testsuite_setup,
14624 		.teardown = scheduler_mode_testsuite_teardown,
14625 		.unit_test_cases = {TEST_CASES_END()}
14626 	};
14627 	static struct unit_test_suite scheduler_round_robin = {
14628 		.suite_name = "Scheduler Round Robin Unit Test Suite",
14629 		.setup = scheduler_roundrobin_testsuite_setup,
14630 		.teardown = scheduler_mode_testsuite_teardown,
14631 		.unit_test_cases = {TEST_CASES_END()}
14632 	};
14633 	static struct unit_test_suite scheduler_failover = {
14634 		.suite_name = "Scheduler Failover Unit Test Suite",
14635 		.setup = scheduler_failover_testsuite_setup,
14636 		.teardown = scheduler_mode_testsuite_teardown,
14637 		.unit_test_cases = {TEST_CASES_END()}
14638 	};
14639 	static struct unit_test_suite scheduler_pkt_size_distr = {
14640 		.suite_name = "Scheduler Pkt Size Distr Unit Test Suite",
14641 		.setup = scheduler_pkt_size_distr_testsuite_setup,
14642 		.teardown = scheduler_mode_testsuite_teardown,
14643 		.unit_test_cases = {TEST_CASES_END()}
14644 	};
14645 	struct unit_test_suite *sched_mode_suites[] = {
14646 		&scheduler_multicore,
14647 		&scheduler_round_robin,
14648 		&scheduler_failover,
14649 		&scheduler_pkt_size_distr
14650 	};
14651 	static struct unit_test_suite scheduler_config = {
14652 		.suite_name = "Crypto Device Scheduler Config Unit Test Suite",
14653 		.unit_test_cases = {
14654 			TEST_CASE(test_scheduler_attach_slave_op),
14655 			TEST_CASE(test_scheduler_mode_multicore_op),
14656 			TEST_CASE(test_scheduler_mode_roundrobin_op),
14657 			TEST_CASE(test_scheduler_mode_failover_op),
14658 			TEST_CASE(test_scheduler_mode_pkt_size_distr_op),
14659 			TEST_CASE(test_scheduler_detach_slave_op),
14660 
14661 			TEST_CASES_END() /**< NULL terminate array */
14662 		}
14663 	};
14664 	struct unit_test_suite *static_suites[] = {
14665 		&scheduler_config,
14666 		&end_testsuite
14667 	};
14668 	static struct unit_test_suite ts = {
14669 		.suite_name = "Scheduler Unit Test Suite",
14670 		.setup = scheduler_testsuite_setup,
14671 		.teardown = testsuite_teardown,
14672 		.unit_test_cases = {TEST_CASES_END()}
14673 	};
14674 
14675 	gbl_driver_id =	rte_cryptodev_driver_id_get(
14676 			RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14677 
14678 	if (gbl_driver_id == -1) {
14679 		RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded.\n");
14680 		return TEST_SKIPPED;
14681 	}
14682 
14683 	if (rte_cryptodev_driver_id_get(
14684 				RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14685 		RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded.\n");
14686 		return TEST_SKIPPED;
14687 	}
14688 
14689 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14690 		uint8_t blk_i = 0;
14691 		sched_mode_suites[sched_i]->unit_test_suites = malloc(sizeof
14692 				(struct unit_test_suite *) *
14693 				(RTE_DIM(blk_suites) + 1));
14694 		ADD_BLOCKCIPHER_TESTSUITE(blk_i, (*sched_mode_suites[sched_i]),
14695 				blk_suites, RTE_DIM(blk_suites));
14696 		sched_mode_suites[sched_i]->unit_test_suites[blk_i] = &end_testsuite;
14697 	}
14698 
14699 	ts.unit_test_suites = malloc(sizeof(struct unit_test_suite *) *
14700 			(RTE_DIM(static_suites) + RTE_DIM(sched_mode_suites)));
14701 	ADD_STATIC_TESTSUITE(i, ts, sched_mode_suites,
14702 			RTE_DIM(sched_mode_suites));
14703 	ADD_STATIC_TESTSUITE(i, ts, static_suites, RTE_DIM(static_suites));
14704 	ret = unit_test_suite_runner(&ts);
14705 
14706 	for (sched_i = 0; sched_i < RTE_DIM(sched_mode_suites); sched_i++) {
14707 		FREE_BLOCKCIPHER_TESTSUITE(blk_start_idx,
14708 				(*sched_mode_suites[sched_i]),
14709 				RTE_DIM(blk_suites));
14710 		free(sched_mode_suites[sched_i]->unit_test_suites);
14711 	}
14712 	free(ts.unit_test_suites);
14713 	return ret;
14714 }
14715 
14716 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14717 
14718 #endif
14719 
14720 static int
14721 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14722 {
14723 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14724 }
14725 
14726 static int
14727 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14728 {
14729 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14730 }
14731 
14732 static int
14733 test_cryptodev_ccp(void)
14734 {
14735 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14736 }
14737 
14738 static int
14739 test_cryptodev_octeontx(void)
14740 {
14741 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14742 }
14743 
14744 static int
14745 test_cryptodev_octeontx2(void)
14746 {
14747 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14748 }
14749 
14750 static int
14751 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14752 {
14753 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14754 }
14755 
14756 static int
14757 test_cryptodev_nitrox(void)
14758 {
14759 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14760 }
14761 
14762 static int
14763 test_cryptodev_bcmfs(void)
14764 {
14765 	return run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_BCMFS_PMD));
14766 }
14767 
14768 static int
14769 test_cryptodev_qat_raw_api(void /*argv __rte_unused, int argc __rte_unused*/)
14770 {
14771 	int ret;
14772 
14773 	global_api_test_type = CRYPTODEV_RAW_API_TEST;
14774 	ret = run_cryptodev_testsuite(RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14775 	global_api_test_type = CRYPTODEV_API_TEST;
14776 
14777 	return ret;
14778 }
14779 
14780 REGISTER_TEST_COMMAND(cryptodev_qat_raw_api_autotest,
14781 		test_cryptodev_qat_raw_api);
14782 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14783 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14784 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_mb_autotest,
14785 	test_cryptodev_cpu_aesni_mb);
14786 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14787 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14788 REGISTER_TEST_COMMAND(cryptodev_cpu_aesni_gcm_autotest,
14789 	test_cryptodev_cpu_aesni_gcm);
14790 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14791 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14792 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14793 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14794 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14795 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14796 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14797 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14798 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14799 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14800 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14801 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14802 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14803 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);
14804 REGISTER_TEST_COMMAND(cryptodev_bcmfs_autotest, test_cryptodev_bcmfs);
14805