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