518d3b5032979d47aa50f1b53774e245044408fa
[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)
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         sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2904                 (op_mode == IN_PLACE ?
2905                         ut_params->ibuf : ut_params->obuf),
2906                 uint8_t *, data_pad_len);
2907
2908         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2909                         "no room to append auth tag");
2910
2911         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2912                 (op_mode == IN_PLACE ?
2913                         ut_params->ibuf : ut_params->obuf),
2914                 data_pad_len);
2915
2916         memset(sym_op->auth.digest.data, 0, auth_tag_len);
2917
2918         /* Copy cipher and auth IVs at the end of the crypto operation */
2919         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2920                         ut_params->op, uint8_t *, IV_OFFSET);
2921
2922         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2923         iv_ptr += cipher_iv_len;
2924         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2925
2926         sym_op->cipher.data.length = cipher_len;
2927         sym_op->cipher.data.offset = cipher_offset;
2928
2929         sym_op->auth.data.length = auth_len;
2930         sym_op->auth.data.offset = auth_offset;
2931
2932         return 0;
2933 }
2934
2935 static int
2936 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2937 {
2938         struct crypto_testsuite_params *ts_params = &testsuite_params;
2939         struct crypto_unittest_params *ut_params = &unittest_params;
2940
2941         int retval;
2942         unsigned plaintext_pad_len;
2943         unsigned plaintext_len;
2944         uint8_t *plaintext;
2945
2946         /* Create SNOW 3G session */
2947         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2948                         tdata->key.data, tdata->key.len,
2949                         tdata->auth_iv.len, tdata->digest.len,
2950                         RTE_CRYPTO_AUTH_OP_GENERATE,
2951                         RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2952         if (retval < 0)
2953                 return retval;
2954
2955         /* alloc mbuf and set payload */
2956         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2957
2958         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2959         rte_pktmbuf_tailroom(ut_params->ibuf));
2960
2961         plaintext_len = ceil_byte_length(tdata->plaintext.len);
2962         /* Append data which is padded to a multiple of */
2963         /* the algorithms block size */
2964         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2965         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2966                                 plaintext_pad_len);
2967         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2968
2969         /* Create SNOW 3G operation */
2970         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2971                         tdata->auth_iv.data, tdata->auth_iv.len,
2972                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2973                         tdata->validAuthLenInBits.len,
2974                         0);
2975         if (retval < 0)
2976                 return retval;
2977
2978         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2979                                 ut_params->op);
2980         ut_params->obuf = ut_params->op->sym->m_src;
2981         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2982         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2983                         + plaintext_pad_len;
2984
2985         /* Validate obuf */
2986         TEST_ASSERT_BUFFERS_ARE_EQUAL(
2987         ut_params->digest,
2988         tdata->digest.data,
2989         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2990         "SNOW 3G Generated auth tag not as expected");
2991
2992         return 0;
2993 }
2994
2995 static int
2996 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2997 {
2998         struct crypto_testsuite_params *ts_params = &testsuite_params;
2999         struct crypto_unittest_params *ut_params = &unittest_params;
3000
3001         int retval;
3002         unsigned plaintext_pad_len;
3003         unsigned plaintext_len;
3004         uint8_t *plaintext;
3005
3006         /* Create SNOW 3G session */
3007         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3008                                 tdata->key.data, tdata->key.len,
3009                                 tdata->auth_iv.len, tdata->digest.len,
3010                                 RTE_CRYPTO_AUTH_OP_VERIFY,
3011                                 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3012         if (retval < 0)
3013                 return retval;
3014         /* alloc mbuf and set payload */
3015         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3016
3017         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3018         rte_pktmbuf_tailroom(ut_params->ibuf));
3019
3020         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3021         /* Append data which is padded to a multiple of */
3022         /* the algorithms block size */
3023         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3024         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3025                                 plaintext_pad_len);
3026         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3027
3028         /* Create SNOW 3G operation */
3029         retval = create_wireless_algo_hash_operation(tdata->digest.data,
3030                         tdata->digest.len,
3031                         tdata->auth_iv.data, tdata->auth_iv.len,
3032                         plaintext_pad_len,
3033                         RTE_CRYPTO_AUTH_OP_VERIFY,
3034                         tdata->validAuthLenInBits.len,
3035                         0);
3036         if (retval < 0)
3037                 return retval;
3038
3039         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3040                                 ut_params->op);
3041         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3042         ut_params->obuf = ut_params->op->sym->m_src;
3043         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3044                                 + plaintext_pad_len;
3045
3046         /* Validate obuf */
3047         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3048                 return 0;
3049         else
3050                 return -1;
3051
3052         return 0;
3053 }
3054
3055 static int
3056 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3057 {
3058         struct crypto_testsuite_params *ts_params = &testsuite_params;
3059         struct crypto_unittest_params *ut_params = &unittest_params;
3060
3061         int retval;
3062         unsigned plaintext_pad_len;
3063         unsigned plaintext_len;
3064         uint8_t *plaintext;
3065
3066         /* Create KASUMI session */
3067         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3068                         tdata->key.data, tdata->key.len,
3069                         0, tdata->digest.len,
3070                         RTE_CRYPTO_AUTH_OP_GENERATE,
3071                         RTE_CRYPTO_AUTH_KASUMI_F9);
3072         if (retval < 0)
3073                 return retval;
3074
3075         /* alloc mbuf and set payload */
3076         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3077
3078         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3079         rte_pktmbuf_tailroom(ut_params->ibuf));
3080
3081         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3082         /* Append data which is padded to a multiple of */
3083         /* the algorithms block size */
3084         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3085         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3086                                 plaintext_pad_len);
3087         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3088
3089         /* Create KASUMI operation */
3090         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3091                         NULL, 0,
3092                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3093                         tdata->plaintext.len,
3094                         0);
3095         if (retval < 0)
3096                 return retval;
3097
3098         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3099                                 ut_params->op);
3100         ut_params->obuf = ut_params->op->sym->m_src;
3101         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3102         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3103                         + plaintext_pad_len;
3104
3105         /* Validate obuf */
3106         TEST_ASSERT_BUFFERS_ARE_EQUAL(
3107         ut_params->digest,
3108         tdata->digest.data,
3109         DIGEST_BYTE_LENGTH_KASUMI_F9,
3110         "KASUMI Generated auth tag not as expected");
3111
3112         return 0;
3113 }
3114
3115 static int
3116 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3117 {
3118         struct crypto_testsuite_params *ts_params = &testsuite_params;
3119         struct crypto_unittest_params *ut_params = &unittest_params;
3120
3121         int retval;
3122         unsigned plaintext_pad_len;
3123         unsigned plaintext_len;
3124         uint8_t *plaintext;
3125
3126         /* Create KASUMI session */
3127         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3128                                 tdata->key.data, tdata->key.len,
3129                                 0, tdata->digest.len,
3130                                 RTE_CRYPTO_AUTH_OP_VERIFY,
3131                                 RTE_CRYPTO_AUTH_KASUMI_F9);
3132         if (retval < 0)
3133                 return retval;
3134         /* alloc mbuf and set payload */
3135         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3136
3137         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3138         rte_pktmbuf_tailroom(ut_params->ibuf));
3139
3140         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3141         /* Append data which is padded to a multiple */
3142         /* of the algorithms block size */
3143         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3144         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3145                                 plaintext_pad_len);
3146         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3147
3148         /* Create KASUMI operation */
3149         retval = create_wireless_algo_hash_operation(tdata->digest.data,
3150                         tdata->digest.len,
3151                         NULL, 0,
3152                         plaintext_pad_len,
3153                         RTE_CRYPTO_AUTH_OP_VERIFY,
3154                         tdata->plaintext.len,
3155                         0);
3156         if (retval < 0)
3157                 return retval;
3158
3159         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3160                                 ut_params->op);
3161         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3162         ut_params->obuf = ut_params->op->sym->m_src;
3163         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3164                                 + plaintext_pad_len;
3165
3166         /* Validate obuf */
3167         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3168                 return 0;
3169         else
3170                 return -1;
3171
3172         return 0;
3173 }
3174
3175 static int
3176 test_snow3g_hash_generate_test_case_1(void)
3177 {
3178         return test_snow3g_authentication(&snow3g_hash_test_case_1);
3179 }
3180
3181 static int
3182 test_snow3g_hash_generate_test_case_2(void)
3183 {
3184         return test_snow3g_authentication(&snow3g_hash_test_case_2);
3185 }
3186
3187 static int
3188 test_snow3g_hash_generate_test_case_3(void)
3189 {
3190         return test_snow3g_authentication(&snow3g_hash_test_case_3);
3191 }
3192
3193 static int
3194 test_snow3g_hash_generate_test_case_4(void)
3195 {
3196         return test_snow3g_authentication(&snow3g_hash_test_case_4);
3197 }
3198
3199 static int
3200 test_snow3g_hash_generate_test_case_5(void)
3201 {
3202         return test_snow3g_authentication(&snow3g_hash_test_case_5);
3203 }
3204
3205 static int
3206 test_snow3g_hash_generate_test_case_6(void)
3207 {
3208         return test_snow3g_authentication(&snow3g_hash_test_case_6);
3209 }
3210
3211 static int
3212 test_snow3g_hash_verify_test_case_1(void)
3213 {
3214         return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3215
3216 }
3217
3218 static int
3219 test_snow3g_hash_verify_test_case_2(void)
3220 {
3221         return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3222 }
3223
3224 static int
3225 test_snow3g_hash_verify_test_case_3(void)
3226 {
3227         return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3228 }
3229
3230 static int
3231 test_snow3g_hash_verify_test_case_4(void)
3232 {
3233         return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3234 }
3235
3236 static int
3237 test_snow3g_hash_verify_test_case_5(void)
3238 {
3239         return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3240 }
3241
3242 static int
3243 test_snow3g_hash_verify_test_case_6(void)
3244 {
3245         return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3246 }
3247
3248 static int
3249 test_kasumi_hash_generate_test_case_1(void)
3250 {
3251         return test_kasumi_authentication(&kasumi_hash_test_case_1);
3252 }
3253
3254 static int
3255 test_kasumi_hash_generate_test_case_2(void)
3256 {
3257         return test_kasumi_authentication(&kasumi_hash_test_case_2);
3258 }
3259
3260 static int
3261 test_kasumi_hash_generate_test_case_3(void)
3262 {
3263         return test_kasumi_authentication(&kasumi_hash_test_case_3);
3264 }
3265
3266 static int
3267 test_kasumi_hash_generate_test_case_4(void)
3268 {
3269         return test_kasumi_authentication(&kasumi_hash_test_case_4);
3270 }
3271
3272 static int
3273 test_kasumi_hash_generate_test_case_5(void)
3274 {
3275         return test_kasumi_authentication(&kasumi_hash_test_case_5);
3276 }
3277
3278 static int
3279 test_kasumi_hash_generate_test_case_6(void)
3280 {
3281         return test_kasumi_authentication(&kasumi_hash_test_case_6);
3282 }
3283
3284 static int
3285 test_kasumi_hash_verify_test_case_1(void)
3286 {
3287         return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3288 }
3289
3290 static int
3291 test_kasumi_hash_verify_test_case_2(void)
3292 {
3293         return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3294 }
3295
3296 static int
3297 test_kasumi_hash_verify_test_case_3(void)
3298 {
3299         return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3300 }
3301
3302 static int
3303 test_kasumi_hash_verify_test_case_4(void)
3304 {
3305         return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3306 }
3307
3308 static int
3309 test_kasumi_hash_verify_test_case_5(void)
3310 {
3311         return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3312 }
3313
3314 static int
3315 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3316 {
3317         struct crypto_testsuite_params *ts_params = &testsuite_params;
3318         struct crypto_unittest_params *ut_params = &unittest_params;
3319
3320         int retval;
3321         uint8_t *plaintext, *ciphertext;
3322         unsigned plaintext_pad_len;
3323         unsigned plaintext_len;
3324
3325         /* Create KASUMI session */
3326         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3327                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3328                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3329                                         tdata->key.data, tdata->key.len,
3330                                         tdata->cipher_iv.len);
3331         if (retval < 0)
3332                 return retval;
3333
3334         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3335
3336         /* Clear mbuf payload */
3337         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3338                rte_pktmbuf_tailroom(ut_params->ibuf));
3339
3340         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3341         /* Append data which is padded to a multiple */
3342         /* of the algorithms block size */
3343         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3344         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3345                                 plaintext_pad_len);
3346         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3347
3348         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3349
3350         /* Create KASUMI operation */
3351         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3352                                 tdata->cipher_iv.len,
3353                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3354                                 tdata->validCipherOffsetInBits.len);
3355         if (retval < 0)
3356                 return retval;
3357
3358         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3359                                                 ut_params->op);
3360         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3361
3362         ut_params->obuf = ut_params->op->sym->m_dst;
3363         if (ut_params->obuf)
3364                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3365         else
3366                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3367
3368         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3369
3370         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3371                                 (tdata->validCipherOffsetInBits.len >> 3);
3372         /* Validate obuf */
3373         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3374                 ciphertext,
3375                 reference_ciphertext,
3376                 tdata->validCipherLenInBits.len,
3377                 "KASUMI Ciphertext data not as expected");
3378         return 0;
3379 }
3380
3381 static int
3382 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3383 {
3384         struct crypto_testsuite_params *ts_params = &testsuite_params;
3385         struct crypto_unittest_params *ut_params = &unittest_params;
3386
3387         int retval;
3388
3389         unsigned int plaintext_pad_len;
3390         unsigned int plaintext_len;
3391
3392         uint8_t buffer[10000];
3393         const uint8_t *ciphertext;
3394
3395         struct rte_cryptodev_info dev_info;
3396
3397         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3398
3399         uint64_t feat_flags = dev_info.feature_flags;
3400
3401         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3402                 printf("Device doesn't support in-place scatter-gather. "
3403                                 "Test Skipped.\n");
3404                 return 0;
3405         }
3406
3407         /* Create KASUMI session */
3408         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3409                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3410                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3411                                         tdata->key.data, tdata->key.len,
3412                                         tdata->cipher_iv.len);
3413         if (retval < 0)
3414                 return retval;
3415
3416         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3417
3418
3419         /* Append data which is padded to a multiple */
3420         /* of the algorithms block size */
3421         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3422
3423         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3424                         plaintext_pad_len, 10, 0);
3425
3426         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3427
3428         /* Create KASUMI operation */
3429         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3430                                 tdata->cipher_iv.len,
3431                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3432                                 tdata->validCipherOffsetInBits.len);
3433         if (retval < 0)
3434                 return retval;
3435
3436         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3437                                                 ut_params->op);
3438         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3439
3440         ut_params->obuf = ut_params->op->sym->m_dst;
3441
3442         if (ut_params->obuf)
3443                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3444                                 plaintext_len, buffer);
3445         else
3446                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3447                                 tdata->validCipherOffsetInBits.len >> 3,
3448                                 plaintext_len, buffer);
3449
3450         /* Validate obuf */
3451         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3452
3453         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3454                                 (tdata->validCipherOffsetInBits.len >> 3);
3455         /* Validate obuf */
3456         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3457                 ciphertext,
3458                 reference_ciphertext,
3459                 tdata->validCipherLenInBits.len,
3460                 "KASUMI Ciphertext data not as expected");
3461         return 0;
3462 }
3463
3464 static int
3465 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3466 {
3467         struct crypto_testsuite_params *ts_params = &testsuite_params;
3468         struct crypto_unittest_params *ut_params = &unittest_params;
3469
3470         int retval;
3471         uint8_t *plaintext, *ciphertext;
3472         unsigned plaintext_pad_len;
3473         unsigned plaintext_len;
3474
3475         /* Create KASUMI session */
3476         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3477                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3478                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3479                                         tdata->key.data, tdata->key.len,
3480                                         tdata->cipher_iv.len);
3481         if (retval < 0)
3482                 return retval;
3483
3484         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3485         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3486
3487         /* Clear mbuf payload */
3488         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3489                rte_pktmbuf_tailroom(ut_params->ibuf));
3490
3491         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3492         /* Append data which is padded to a multiple */
3493         /* of the algorithms block size */
3494         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3495         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3496                                 plaintext_pad_len);
3497         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3498         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3499
3500         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3501
3502         /* Create KASUMI operation */
3503         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3504                                 tdata->cipher_iv.len,
3505                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3506                                 tdata->validCipherOffsetInBits.len);
3507         if (retval < 0)
3508                 return retval;
3509
3510         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3511                                                 ut_params->op);
3512         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3513
3514         ut_params->obuf = ut_params->op->sym->m_dst;
3515         if (ut_params->obuf)
3516                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3517         else
3518                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3519
3520         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3521
3522         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3523                                 (tdata->validCipherOffsetInBits.len >> 3);
3524         /* Validate obuf */
3525         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3526                 ciphertext,
3527                 reference_ciphertext,
3528                 tdata->validCipherLenInBits.len,
3529                 "KASUMI Ciphertext data not as expected");
3530         return 0;
3531 }
3532
3533 static int
3534 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3535 {
3536         struct crypto_testsuite_params *ts_params = &testsuite_params;
3537         struct crypto_unittest_params *ut_params = &unittest_params;
3538
3539         int retval;
3540         unsigned int plaintext_pad_len;
3541         unsigned int plaintext_len;
3542
3543         const uint8_t *ciphertext;
3544         uint8_t buffer[2048];
3545
3546         struct rte_cryptodev_info dev_info;
3547
3548         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3549
3550         uint64_t feat_flags = dev_info.feature_flags;
3551         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3552                 printf("Device doesn't support out-of-place scatter-gather "
3553                                 "in both input and output mbufs. "
3554                                 "Test Skipped.\n");
3555                 return 0;
3556         }
3557
3558         /* Create KASUMI session */
3559         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3560                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3561                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3562                                         tdata->key.data, tdata->key.len,
3563                                         tdata->cipher_iv.len);
3564         if (retval < 0)
3565                 return retval;
3566
3567         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3568         /* Append data which is padded to a multiple */
3569         /* of the algorithms block size */
3570         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3571
3572         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3573                         plaintext_pad_len, 10, 0);
3574         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3575                         plaintext_pad_len, 3, 0);
3576
3577         /* Append data which is padded to a multiple */
3578         /* of the algorithms block size */
3579         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3580
3581         /* Create KASUMI operation */
3582         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3583                                 tdata->cipher_iv.len,
3584                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3585                                 tdata->validCipherOffsetInBits.len);
3586         if (retval < 0)
3587                 return retval;
3588
3589         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3590                                                 ut_params->op);
3591         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3592
3593         ut_params->obuf = ut_params->op->sym->m_dst;
3594         if (ut_params->obuf)
3595                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3596                                 plaintext_pad_len, buffer);
3597         else
3598                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3599                                 tdata->validCipherOffsetInBits.len >> 3,
3600                                 plaintext_pad_len, buffer);
3601
3602         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3603                                 (tdata->validCipherOffsetInBits.len >> 3);
3604         /* Validate obuf */
3605         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3606                 ciphertext,
3607                 reference_ciphertext,
3608                 tdata->validCipherLenInBits.len,
3609                 "KASUMI Ciphertext data not as expected");
3610         return 0;
3611 }
3612
3613
3614 static int
3615 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3616 {
3617         struct crypto_testsuite_params *ts_params = &testsuite_params;
3618         struct crypto_unittest_params *ut_params = &unittest_params;
3619
3620         int retval;
3621         uint8_t *ciphertext, *plaintext;
3622         unsigned ciphertext_pad_len;
3623         unsigned ciphertext_len;
3624
3625         /* Create KASUMI session */
3626         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3627                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
3628                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3629                                         tdata->key.data, tdata->key.len,
3630                                         tdata->cipher_iv.len);
3631         if (retval < 0)
3632                 return retval;
3633
3634         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3635         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3636
3637         /* Clear mbuf payload */
3638         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3639                rte_pktmbuf_tailroom(ut_params->ibuf));
3640
3641         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3642         /* Append data which is padded to a multiple */
3643         /* of the algorithms block size */
3644         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3645         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3646                                 ciphertext_pad_len);
3647         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3648         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3649
3650         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3651
3652         /* Create KASUMI operation */
3653         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3654                                 tdata->cipher_iv.len,
3655                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3656                                 tdata->validCipherOffsetInBits.len);
3657         if (retval < 0)
3658                 return retval;
3659
3660         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3661                                                 ut_params->op);
3662         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3663
3664         ut_params->obuf = ut_params->op->sym->m_dst;
3665         if (ut_params->obuf)
3666                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3667         else
3668                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3669
3670         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3671
3672         const uint8_t *reference_plaintext = tdata->plaintext.data +
3673                                 (tdata->validCipherOffsetInBits.len >> 3);
3674         /* Validate obuf */
3675         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3676                 plaintext,
3677                 reference_plaintext,
3678                 tdata->validCipherLenInBits.len,
3679                 "KASUMI Plaintext data not as expected");
3680         return 0;
3681 }
3682
3683 static int
3684 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3685 {
3686         struct crypto_testsuite_params *ts_params = &testsuite_params;
3687         struct crypto_unittest_params *ut_params = &unittest_params;
3688
3689         int retval;
3690         uint8_t *ciphertext, *plaintext;
3691         unsigned ciphertext_pad_len;
3692         unsigned ciphertext_len;
3693
3694         /* Create KASUMI session */
3695         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3696                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
3697                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3698                                         tdata->key.data, tdata->key.len,
3699                                         tdata->cipher_iv.len);
3700         if (retval < 0)
3701                 return retval;
3702
3703         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3704
3705         /* Clear mbuf payload */
3706         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3707                rte_pktmbuf_tailroom(ut_params->ibuf));
3708
3709         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3710         /* Append data which is padded to a multiple */
3711         /* of the algorithms block size */
3712         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3713         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3714                                 ciphertext_pad_len);
3715         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3716
3717         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3718
3719         /* Create KASUMI operation */
3720         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3721                                         tdata->cipher_iv.len,
3722                                         tdata->ciphertext.len,
3723                                         tdata->validCipherOffsetInBits.len);
3724         if (retval < 0)
3725                 return retval;
3726
3727         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3728                                                 ut_params->op);
3729         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3730
3731         ut_params->obuf = ut_params->op->sym->m_dst;
3732         if (ut_params->obuf)
3733                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3734         else
3735                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3736
3737         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3738
3739         const uint8_t *reference_plaintext = tdata->plaintext.data +
3740                                 (tdata->validCipherOffsetInBits.len >> 3);
3741         /* Validate obuf */
3742         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3743                 plaintext,
3744                 reference_plaintext,
3745                 tdata->validCipherLenInBits.len,
3746                 "KASUMI Plaintext data not as expected");
3747         return 0;
3748 }
3749
3750 static int
3751 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3752 {
3753         struct crypto_testsuite_params *ts_params = &testsuite_params;
3754         struct crypto_unittest_params *ut_params = &unittest_params;
3755
3756         int retval;
3757         uint8_t *plaintext, *ciphertext;
3758         unsigned plaintext_pad_len;
3759         unsigned plaintext_len;
3760
3761         /* Create SNOW 3G session */
3762         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3763                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3764                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3765                                         tdata->key.data, tdata->key.len,
3766                                         tdata->cipher_iv.len);
3767         if (retval < 0)
3768                 return retval;
3769
3770         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3771
3772         /* Clear mbuf payload */
3773         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3774                rte_pktmbuf_tailroom(ut_params->ibuf));
3775
3776         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3777         /* Append data which is padded to a multiple of */
3778         /* the algorithms block size */
3779         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3780         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3781                                 plaintext_pad_len);
3782         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3783
3784         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3785
3786         /* Create SNOW 3G operation */
3787         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3788                                         tdata->cipher_iv.len,
3789                                         tdata->validCipherLenInBits.len,
3790                                         0);
3791         if (retval < 0)
3792                 return retval;
3793
3794         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3795                                                 ut_params->op);
3796         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3797
3798         ut_params->obuf = ut_params->op->sym->m_dst;
3799         if (ut_params->obuf)
3800                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3801         else
3802                 ciphertext = plaintext;
3803
3804         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3805
3806         /* Validate obuf */
3807         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3808                 ciphertext,
3809                 tdata->ciphertext.data,
3810                 tdata->validDataLenInBits.len,
3811                 "SNOW 3G Ciphertext data not as expected");
3812         return 0;
3813 }
3814
3815
3816 static int
3817 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3818 {
3819         struct crypto_testsuite_params *ts_params = &testsuite_params;
3820         struct crypto_unittest_params *ut_params = &unittest_params;
3821         uint8_t *plaintext, *ciphertext;
3822
3823         int retval;
3824         unsigned plaintext_pad_len;
3825         unsigned plaintext_len;
3826
3827         /* Create SNOW 3G session */
3828         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3829                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3830                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3831                                         tdata->key.data, tdata->key.len,
3832                                         tdata->cipher_iv.len);
3833         if (retval < 0)
3834                 return retval;
3835
3836         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3837         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3838
3839         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3840                         "Failed to allocate input buffer in mempool");
3841         TEST_ASSERT_NOT_NULL(ut_params->obuf,
3842                         "Failed to allocate output buffer in mempool");
3843
3844         /* Clear mbuf payload */
3845         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3846                rte_pktmbuf_tailroom(ut_params->ibuf));
3847
3848         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3849         /* Append data which is padded to a multiple of */
3850         /* the algorithms block size */
3851         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3852         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3853                                 plaintext_pad_len);
3854         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3855         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3856
3857         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3858
3859         /* Create SNOW 3G operation */
3860         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3861                                         tdata->cipher_iv.len,
3862                                         tdata->validCipherLenInBits.len,
3863                                         0);
3864         if (retval < 0)
3865                 return retval;
3866
3867         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3868                                                 ut_params->op);
3869         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3870
3871         ut_params->obuf = ut_params->op->sym->m_dst;
3872         if (ut_params->obuf)
3873                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3874         else
3875                 ciphertext = plaintext;
3876
3877         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3878
3879         /* Validate obuf */
3880         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3881                 ciphertext,
3882                 tdata->ciphertext.data,
3883                 tdata->validDataLenInBits.len,
3884                 "SNOW 3G Ciphertext data not as expected");
3885         return 0;
3886 }
3887
3888 static int
3889 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3890 {
3891         struct crypto_testsuite_params *ts_params = &testsuite_params;
3892         struct crypto_unittest_params *ut_params = &unittest_params;
3893
3894         int retval;
3895         unsigned int plaintext_pad_len;
3896         unsigned int plaintext_len;
3897         uint8_t buffer[10000];
3898         const uint8_t *ciphertext;
3899
3900         struct rte_cryptodev_info dev_info;
3901
3902         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3903
3904         uint64_t feat_flags = dev_info.feature_flags;
3905
3906         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3907                 printf("Device doesn't support out-of-place scatter-gather "
3908                                 "in both input and output mbufs. "
3909                                 "Test Skipped.\n");
3910                 return 0;
3911         }
3912
3913         /* Create SNOW 3G session */
3914         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3915                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3916                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3917                                         tdata->key.data, tdata->key.len,
3918                                         tdata->cipher_iv.len);
3919         if (retval < 0)
3920                 return retval;
3921
3922         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3923         /* Append data which is padded to a multiple of */
3924         /* the algorithms block size */
3925         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3926
3927         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3928                         plaintext_pad_len, 10, 0);
3929         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3930                         plaintext_pad_len, 3, 0);
3931
3932         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3933                         "Failed to allocate input buffer in mempool");
3934         TEST_ASSERT_NOT_NULL(ut_params->obuf,
3935                         "Failed to allocate output buffer in mempool");
3936
3937         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3938
3939         /* Create SNOW 3G operation */
3940         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3941                                         tdata->cipher_iv.len,
3942                                         tdata->validCipherLenInBits.len,
3943                                         0);
3944         if (retval < 0)
3945                 return retval;
3946
3947         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3948                                                 ut_params->op);
3949         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3950
3951         ut_params->obuf = ut_params->op->sym->m_dst;
3952         if (ut_params->obuf)
3953                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3954                                 plaintext_len, buffer);
3955         else
3956                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3957                                 plaintext_len, buffer);
3958
3959         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3960
3961         /* Validate obuf */
3962         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3963                 ciphertext,
3964                 tdata->ciphertext.data,
3965                 tdata->validDataLenInBits.len,
3966                 "SNOW 3G Ciphertext data not as expected");
3967
3968         return 0;
3969 }
3970
3971 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3972 static void
3973 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3974 {
3975         uint8_t curr_byte, prev_byte;
3976         uint32_t length_in_bytes = ceil_byte_length(length + offset);
3977         uint8_t lower_byte_mask = (1 << offset) - 1;
3978         unsigned i;
3979
3980         prev_byte = buffer[0];
3981         buffer[0] >>= offset;
3982
3983         for (i = 1; i < length_in_bytes; i++) {
3984                 curr_byte = buffer[i];
3985                 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3986                                 (curr_byte >> offset);
3987                 prev_byte = curr_byte;
3988         }
3989 }
3990
3991 static int
3992 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3993 {
3994         struct crypto_testsuite_params *ts_params = &testsuite_params;
3995         struct crypto_unittest_params *ut_params = &unittest_params;
3996         uint8_t *plaintext, *ciphertext;
3997         int retval;
3998         uint32_t plaintext_len;
3999         uint32_t plaintext_pad_len;
4000         uint8_t extra_offset = 4;
4001         uint8_t *expected_ciphertext_shifted;
4002
4003         /* Create SNOW 3G session */
4004         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4005                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4006                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4007                                         tdata->key.data, tdata->key.len,
4008                                         tdata->cipher_iv.len);
4009         if (retval < 0)
4010                 return retval;
4011
4012         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4013         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4014
4015         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4016                         "Failed to allocate input buffer in mempool");
4017         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4018                         "Failed to allocate output buffer in mempool");
4019
4020         /* Clear mbuf payload */
4021         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4022                rte_pktmbuf_tailroom(ut_params->ibuf));
4023
4024         plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4025         /*
4026          * Append data which is padded to a
4027          * multiple of the algorithms block size
4028          */
4029         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4030
4031         plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4032                                                 plaintext_pad_len);
4033
4034         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4035
4036         memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4037         buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4038
4039 #ifdef RTE_APP_TEST_DEBUG
4040         rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4041 #endif
4042         /* Create SNOW 3G operation */
4043         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4044                                         tdata->cipher_iv.len,
4045                                         tdata->validCipherLenInBits.len,
4046                                         extra_offset);
4047         if (retval < 0)
4048                 return retval;
4049
4050         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4051                                                 ut_params->op);
4052         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4053
4054         ut_params->obuf = ut_params->op->sym->m_dst;
4055         if (ut_params->obuf)
4056                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4057         else
4058                 ciphertext = plaintext;
4059
4060 #ifdef RTE_APP_TEST_DEBUG
4061         rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4062 #endif
4063
4064         expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4065
4066         TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4067                         "failed to reserve memory for ciphertext shifted\n");
4068
4069         memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4070                         ceil_byte_length(tdata->ciphertext.len));
4071         buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4072                         extra_offset);
4073         /* Validate obuf */
4074         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4075                 ciphertext,
4076                 expected_ciphertext_shifted,
4077                 tdata->validDataLenInBits.len,
4078                 extra_offset,
4079                 "SNOW 3G Ciphertext data not as expected");
4080         return 0;
4081 }
4082
4083 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4084 {
4085         struct crypto_testsuite_params *ts_params = &testsuite_params;
4086         struct crypto_unittest_params *ut_params = &unittest_params;
4087
4088         int retval;
4089
4090         uint8_t *plaintext, *ciphertext;
4091         unsigned ciphertext_pad_len;
4092         unsigned ciphertext_len;
4093
4094         /* Create SNOW 3G session */
4095         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4096                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
4097                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4098                                         tdata->key.data, tdata->key.len,
4099                                         tdata->cipher_iv.len);
4100         if (retval < 0)
4101                 return retval;
4102
4103         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4104
4105         /* Clear mbuf payload */
4106         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4107                rte_pktmbuf_tailroom(ut_params->ibuf));
4108
4109         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4110         /* Append data which is padded to a multiple of */
4111         /* the algorithms block size */
4112         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4113         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4114                                 ciphertext_pad_len);
4115         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4116
4117         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4118
4119         /* Create SNOW 3G operation */
4120         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4121                                         tdata->cipher_iv.len,
4122                                         tdata->validCipherLenInBits.len,
4123                                         tdata->cipher.offset_bits);
4124         if (retval < 0)
4125                 return retval;
4126
4127         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4128                                                 ut_params->op);
4129         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4130         ut_params->obuf = ut_params->op->sym->m_dst;
4131         if (ut_params->obuf)
4132                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4133         else
4134                 plaintext = ciphertext;
4135
4136         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4137
4138         /* Validate obuf */
4139         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4140                                 tdata->plaintext.data,
4141                                 tdata->validDataLenInBits.len,
4142                                 "SNOW 3G Plaintext data not as expected");
4143         return 0;
4144 }
4145
4146 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4147 {
4148         struct crypto_testsuite_params *ts_params = &testsuite_params;
4149         struct crypto_unittest_params *ut_params = &unittest_params;
4150
4151         int retval;
4152
4153         uint8_t *plaintext, *ciphertext;
4154         unsigned ciphertext_pad_len;
4155         unsigned ciphertext_len;
4156
4157         /* Create SNOW 3G session */
4158         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4159                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
4160                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4161                                         tdata->key.data, tdata->key.len,
4162                                         tdata->cipher_iv.len);
4163         if (retval < 0)
4164                 return retval;
4165
4166         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4167         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4168
4169         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4170                         "Failed to allocate input buffer");
4171         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4172                         "Failed to allocate output buffer");
4173
4174         /* Clear mbuf payload */
4175         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4176                rte_pktmbuf_tailroom(ut_params->ibuf));
4177
4178         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4179                        rte_pktmbuf_tailroom(ut_params->obuf));
4180
4181         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4182         /* Append data which is padded to a multiple of */
4183         /* the algorithms block size */
4184         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4185         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4186                                 ciphertext_pad_len);
4187         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4188         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4189
4190         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4191
4192         /* Create SNOW 3G operation */
4193         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4194                                         tdata->cipher_iv.len,
4195                                         tdata->validCipherLenInBits.len,
4196                                         0);
4197         if (retval < 0)
4198                 return retval;
4199
4200         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4201                                                 ut_params->op);
4202         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4203         ut_params->obuf = ut_params->op->sym->m_dst;
4204         if (ut_params->obuf)
4205                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4206         else
4207                 plaintext = ciphertext;
4208
4209         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4210
4211         /* Validate obuf */
4212         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4213                                 tdata->plaintext.data,
4214                                 tdata->validDataLenInBits.len,
4215                                 "SNOW 3G Plaintext data not as expected");
4216         return 0;
4217 }
4218
4219 static int
4220 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4221 {
4222         struct crypto_testsuite_params *ts_params = &testsuite_params;
4223         struct crypto_unittest_params *ut_params = &unittest_params;
4224
4225         int retval;
4226
4227         uint8_t *plaintext, *ciphertext;
4228         unsigned int plaintext_pad_len;
4229         unsigned int plaintext_len;
4230
4231         struct rte_cryptodev_sym_capability_idx cap_idx;
4232
4233         /* Check if device supports ZUC EEA3 */
4234         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4235         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4236
4237         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4238                         &cap_idx) == NULL)
4239                 return -ENOTSUP;
4240
4241         /* Check if device supports ZUC EIA3 */
4242         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4243         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4244
4245         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4246                         &cap_idx) == NULL)
4247                 return -ENOTSUP;
4248
4249         /* Create ZUC session */
4250         retval = create_zuc_cipher_auth_encrypt_generate_session(
4251                         ts_params->valid_devs[0],
4252                         tdata);
4253         if (retval < 0)
4254                 return retval;
4255         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4256
4257         /* clear mbuf payload */
4258         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4259                         rte_pktmbuf_tailroom(ut_params->ibuf));
4260
4261         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4262         /* Append data which is padded to a multiple of */
4263         /* the algorithms block size */
4264         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4265         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4266                                 plaintext_pad_len);
4267         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4268
4269         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4270
4271         /* Create ZUC operation */
4272         retval = create_zuc_cipher_hash_generate_operation(tdata);
4273         if (retval < 0)
4274                 return retval;
4275
4276         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4277                         ut_params->op);
4278         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4279         ut_params->obuf = ut_params->op->sym->m_src;
4280         if (ut_params->obuf)
4281                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4282         else
4283                 ciphertext = plaintext;
4284
4285         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4286         /* Validate obuf */
4287         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4288                         ciphertext,
4289                         tdata->ciphertext.data,
4290                         tdata->validDataLenInBits.len,
4291                         "ZUC Ciphertext data not as expected");
4292
4293         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4294             + plaintext_pad_len;
4295
4296         /* Validate obuf */
4297         TEST_ASSERT_BUFFERS_ARE_EQUAL(
4298                         ut_params->digest,
4299                         tdata->digest.data,
4300                         4,
4301                         "ZUC Generated auth tag not as expected");
4302         return 0;
4303 }
4304
4305 static int
4306 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4307 {
4308         struct crypto_testsuite_params *ts_params = &testsuite_params;
4309         struct crypto_unittest_params *ut_params = &unittest_params;
4310
4311         int retval;
4312
4313         uint8_t *plaintext, *ciphertext;
4314         unsigned plaintext_pad_len;
4315         unsigned plaintext_len;
4316
4317         /* Create SNOW 3G session */
4318         retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4319                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4320                         RTE_CRYPTO_AUTH_OP_GENERATE,
4321                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4322                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4323                         tdata->key.data, tdata->key.len,
4324                         tdata->auth_iv.len, tdata->digest.len,
4325                         tdata->cipher_iv.len);
4326         if (retval < 0)
4327                 return retval;
4328         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4329
4330         /* clear mbuf payload */
4331         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4332                         rte_pktmbuf_tailroom(ut_params->ibuf));
4333
4334         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4335         /* Append data which is padded to a multiple of */
4336         /* the algorithms block size */
4337         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4338         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4339                                 plaintext_pad_len);
4340         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4341
4342         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4343
4344         /* Create SNOW 3G operation */
4345         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4346                         tdata->digest.len, tdata->auth_iv.data,
4347                         tdata->auth_iv.len,
4348                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4349                         tdata->cipher_iv.data, tdata->cipher_iv.len,
4350                         tdata->validCipherLenInBits.len,
4351                         0,
4352                         tdata->validAuthLenInBits.len,
4353                         0
4354                         );
4355         if (retval < 0)
4356                 return retval;
4357
4358         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4359                         ut_params->op);
4360         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4361         ut_params->obuf = ut_params->op->sym->m_src;
4362         if (ut_params->obuf)
4363                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4364         else
4365                 ciphertext = plaintext;
4366
4367         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4368         /* Validate obuf */
4369         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4370                         ciphertext,
4371                         tdata->ciphertext.data,
4372                         tdata->validDataLenInBits.len,
4373                         "SNOW 3G Ciphertext data not as expected");
4374
4375         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4376             + plaintext_pad_len;
4377
4378         /* Validate obuf */
4379         TEST_ASSERT_BUFFERS_ARE_EQUAL(
4380                         ut_params->digest,
4381                         tdata->digest.data,
4382                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4383                         "SNOW 3G Generated auth tag not as expected");
4384         return 0;
4385 }
4386
4387 static int
4388 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4389         uint8_t op_mode, uint8_t verify)
4390 {
4391         struct crypto_testsuite_params *ts_params = &testsuite_params;
4392         struct crypto_unittest_params *ut_params = &unittest_params;
4393
4394         int retval;
4395
4396         uint8_t *plaintext = NULL, *ciphertext = NULL;
4397         unsigned int plaintext_pad_len;
4398         unsigned int plaintext_len;
4399         unsigned int ciphertext_pad_len;
4400         unsigned int ciphertext_len;
4401
4402         struct rte_cryptodev_info dev_info;
4403
4404         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4405
4406         uint64_t feat_flags = dev_info.feature_flags;
4407
4408         if (op_mode == OUT_OF_PLACE) {
4409                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4410                         printf("Device doesn't support digest encrypted.\n");
4411                         return -ENOTSUP;
4412                 }
4413         }
4414
4415         /* Create SNOW 3G session */
4416         retval = create_wireless_algo_auth_cipher_session(
4417                         ts_params->valid_devs[0],
4418                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4419                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4420                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4421                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4422                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4423                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4424                         tdata->key.data, tdata->key.len,
4425                         tdata->auth_iv.len, tdata->digest.len,
4426                         tdata->cipher_iv.len);
4427
4428         if (retval < 0)
4429                 return retval;
4430
4431         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4432         if (op_mode == OUT_OF_PLACE)
4433                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4434
4435         /* clear mbuf payload */
4436         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4437                 rte_pktmbuf_tailroom(ut_params->ibuf));
4438         if (op_mode == OUT_OF_PLACE)
4439                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4440                         rte_pktmbuf_tailroom(ut_params->obuf));
4441
4442         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4443         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4444         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4445         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4446
4447         if (verify) {
4448                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4449                                         ciphertext_pad_len);
4450                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4451                 if (op_mode == OUT_OF_PLACE)
4452                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4453                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4454                         ciphertext_len);
4455         } else {
4456                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4457                                         plaintext_pad_len);
4458                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4459                 if (op_mode == OUT_OF_PLACE)
4460                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4461                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4462         }
4463
4464         /* Create SNOW 3G operation */
4465         retval = create_wireless_algo_auth_cipher_operation(
4466                 tdata->digest.len,
4467                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4468                 tdata->auth_iv.data, tdata->auth_iv.len,
4469                 (tdata->digest.offset_bytes == 0 ?
4470                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4471                         : tdata->digest.offset_bytes),
4472                 tdata->validCipherLenInBits.len,
4473                 tdata->cipher.offset_bits,
4474                 tdata->validAuthLenInBits.len,
4475                 tdata->auth.offset_bits,
4476                 op_mode);
4477
4478         if (retval < 0)
4479                 return retval;
4480
4481         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4482                         ut_params->op);
4483
4484         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4485
4486         ut_params->obuf = (op_mode == IN_PLACE ?
4487                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4488
4489         if (verify) {
4490                 if (ut_params->obuf)
4491                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4492                                                         uint8_t *);
4493                 else
4494                         plaintext = ciphertext +
4495                                 (tdata->cipher.offset_bits >> 3);
4496
4497                 debug_hexdump(stdout, "plaintext:", plaintext,
4498                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4499                 debug_hexdump(stdout, "plaintext expected:",
4500                         tdata->plaintext.data,
4501                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4502         } else {
4503                 if (ut_params->obuf)
4504                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4505                                                         uint8_t *);
4506                 else
4507                         ciphertext = plaintext;
4508
4509                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4510                         ciphertext_len);
4511                 debug_hexdump(stdout, "ciphertext expected:",
4512                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4513
4514                 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4515                         + (tdata->digest.offset_bytes == 0 ?
4516                 plaintext_pad_len : tdata->digest.offset_bytes);
4517
4518                 debug_hexdump(stdout, "digest:", ut_params->digest,
4519                         tdata->digest.len);
4520                 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4521                                 tdata->digest.len);
4522         }
4523
4524         /* Validate obuf */
4525         if (verify) {
4526                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4527                         plaintext,
4528                         tdata->plaintext.data,
4529                         tdata->plaintext.len >> 3,
4530                         "SNOW 3G Plaintext data not as expected");
4531         } else {
4532                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4533                         ciphertext,
4534                         tdata->ciphertext.data,
4535                         tdata->validDataLenInBits.len,
4536                         "SNOW 3G Ciphertext data not as expected");
4537
4538                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4539                         ut_params->digest,
4540                         tdata->digest.data,
4541                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4542                         "SNOW 3G Generated auth tag not as expected");
4543         }
4544         return 0;
4545 }
4546
4547 static int
4548 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4549         uint8_t op_mode, uint8_t verify)
4550 {
4551         struct crypto_testsuite_params *ts_params = &testsuite_params;
4552         struct crypto_unittest_params *ut_params = &unittest_params;
4553
4554         int retval;
4555
4556         uint8_t *plaintext = NULL, *ciphertext = NULL;
4557         unsigned int plaintext_pad_len;
4558         unsigned int plaintext_len;
4559         unsigned int ciphertext_pad_len;
4560         unsigned int ciphertext_len;
4561
4562         struct rte_cryptodev_info dev_info;
4563
4564         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4565
4566         uint64_t feat_flags = dev_info.feature_flags;
4567
4568         if (op_mode == OUT_OF_PLACE) {
4569                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4570                         printf("Device doesn't support digest encrypted.\n");
4571                         return -ENOTSUP;
4572                 }
4573         }
4574
4575         /* Create KASUMI session */
4576         retval = create_wireless_algo_auth_cipher_session(
4577                         ts_params->valid_devs[0],
4578                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4579                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4580                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4581                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4582                         RTE_CRYPTO_AUTH_KASUMI_F9,
4583                         RTE_CRYPTO_CIPHER_KASUMI_F8,
4584                         tdata->key.data, tdata->key.len,
4585                         0, tdata->digest.len,
4586                         tdata->cipher_iv.len);
4587
4588         if (retval < 0)
4589                 return retval;
4590
4591         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4592         if (op_mode == OUT_OF_PLACE)
4593                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4594
4595         /* clear mbuf payload */
4596         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4597                 rte_pktmbuf_tailroom(ut_params->ibuf));
4598         if (op_mode == OUT_OF_PLACE)
4599                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4600                         rte_pktmbuf_tailroom(ut_params->obuf));
4601
4602         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4603         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4604         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4605         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4606
4607         if (verify) {
4608                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4609                                         ciphertext_pad_len);
4610                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4611                 if (op_mode == OUT_OF_PLACE)
4612                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4613                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4614                         ciphertext_len);
4615         } else {
4616                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4617                                         plaintext_pad_len);
4618                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4619                 if (op_mode == OUT_OF_PLACE)
4620                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4621                 debug_hexdump(stdout, "plaintext:", plaintext,
4622                         plaintext_len);
4623         }
4624
4625         /* Create KASUMI operation */
4626         retval = create_wireless_algo_auth_cipher_operation(
4627                 tdata->digest.len,
4628                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4629                 NULL, 0,
4630                 (tdata->digest.offset_bytes == 0 ?
4631                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4632                         : tdata->digest.offset_bytes),
4633                 tdata->validCipherLenInBits.len,
4634                 tdata->validCipherOffsetInBits.len,
4635                 tdata->validAuthLenInBits.len,
4636                 0,
4637                 op_mode);
4638
4639         if (retval < 0)
4640                 return retval;
4641
4642         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4643                         ut_params->op);
4644
4645         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4646
4647         ut_params->obuf = (op_mode == IN_PLACE ?
4648                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4649
4650
4651         if (verify) {
4652                 if (ut_params->obuf)
4653                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4654                                                         uint8_t *);
4655                 else
4656                         plaintext = ciphertext;
4657
4658                 debug_hexdump(stdout, "plaintext:", plaintext,
4659                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4660                 debug_hexdump(stdout, "plaintext expected:",
4661                         tdata->plaintext.data,
4662                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4663         } else {
4664                 if (ut_params->obuf)
4665                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4666                                                         uint8_t *);
4667                 else
4668                         ciphertext = plaintext;
4669
4670                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4671                         ciphertext_len);
4672                 debug_hexdump(stdout, "ciphertext expected:",
4673                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4674
4675                 ut_params->digest = rte_pktmbuf_mtod(
4676                         ut_params->obuf, uint8_t *) +
4677                         (tdata->digest.offset_bytes == 0 ?
4678                         plaintext_pad_len : tdata->digest.offset_bytes);
4679
4680                 debug_hexdump(stdout, "digest:", ut_params->digest,
4681                         tdata->digest.len);
4682                 debug_hexdump(stdout, "digest expected:",
4683                         tdata->digest.data, tdata->digest.len);
4684         }
4685
4686         /* Validate obuf */
4687         if (verify) {
4688                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4689                         plaintext,
4690                         tdata->plaintext.data,
4691                         tdata->plaintext.len >> 3,
4692                         "KASUMI Plaintext data not as expected");
4693         } else {
4694                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4695                         ciphertext,
4696                         tdata->ciphertext.data,
4697                         tdata->ciphertext.len >> 3,
4698                         "KASUMI Ciphertext data not as expected");
4699
4700                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4701                         ut_params->digest,
4702                         tdata->digest.data,
4703                         DIGEST_BYTE_LENGTH_KASUMI_F9,
4704                         "KASUMI Generated auth tag not as expected");
4705         }
4706         return 0;
4707 }
4708
4709 static int
4710 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4711 {
4712         struct crypto_testsuite_params *ts_params = &testsuite_params;
4713         struct crypto_unittest_params *ut_params = &unittest_params;
4714
4715         int retval;
4716
4717         uint8_t *plaintext, *ciphertext;
4718         unsigned plaintext_pad_len;
4719         unsigned plaintext_len;
4720
4721         /* Create KASUMI session */
4722         retval = create_wireless_algo_cipher_auth_session(
4723                         ts_params->valid_devs[0],
4724                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4725                         RTE_CRYPTO_AUTH_OP_GENERATE,
4726                         RTE_CRYPTO_AUTH_KASUMI_F9,
4727                         RTE_CRYPTO_CIPHER_KASUMI_F8,
4728                         tdata->key.data, tdata->key.len,
4729                         0, tdata->digest.len,
4730                         tdata->cipher_iv.len);
4731         if (retval < 0)
4732                 return retval;
4733
4734         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4735
4736         /* clear mbuf payload */
4737         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4738                         rte_pktmbuf_tailroom(ut_params->ibuf));
4739
4740         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4741         /* Append data which is padded to a multiple of */
4742         /* the algorithms block size */
4743         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4744         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4745                                 plaintext_pad_len);
4746         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4747
4748         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4749
4750         /* Create KASUMI operation */
4751         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4752                                 tdata->digest.len, NULL, 0,
4753                                 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4754                                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4755                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4756                                 tdata->validCipherOffsetInBits.len,
4757                                 tdata->validAuthLenInBits.len,
4758                                 0
4759                                 );
4760         if (retval < 0)
4761                 return retval;
4762
4763         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4764                         ut_params->op);
4765         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4766
4767         if (ut_params->op->sym->m_dst)
4768                 ut_params->obuf = ut_params->op->sym->m_dst;
4769         else
4770                 ut_params->obuf = ut_params->op->sym->m_src;
4771
4772         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4773                                 tdata->validCipherOffsetInBits.len >> 3);
4774
4775         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4776                         + plaintext_pad_len;
4777
4778         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4779                                 (tdata->validCipherOffsetInBits.len >> 3);
4780         /* Validate obuf */
4781         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4782                 ciphertext,
4783                 reference_ciphertext,
4784                 tdata->validCipherLenInBits.len,
4785                 "KASUMI Ciphertext data not as expected");
4786
4787         /* Validate obuf */
4788         TEST_ASSERT_BUFFERS_ARE_EQUAL(
4789                 ut_params->digest,
4790                 tdata->digest.data,
4791                 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4792                 "KASUMI Generated auth tag not as expected");
4793         return 0;
4794 }
4795
4796 static int
4797 test_zuc_encryption(const struct wireless_test_data *tdata)
4798 {
4799         struct crypto_testsuite_params *ts_params = &testsuite_params;
4800         struct crypto_unittest_params *ut_params = &unittest_params;
4801
4802         int retval;
4803         uint8_t *plaintext, *ciphertext;
4804         unsigned plaintext_pad_len;
4805         unsigned plaintext_len;
4806
4807         struct rte_cryptodev_sym_capability_idx cap_idx;
4808
4809         /* Check if device supports ZUC EEA3 */
4810         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4811         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4812
4813         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4814                         &cap_idx) == NULL)
4815                 return -ENOTSUP;
4816
4817         /* Create ZUC session */
4818         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4819                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4820                                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
4821                                         tdata->key.data, tdata->key.len,
4822                                         tdata->cipher_iv.len);
4823         if (retval < 0)
4824                 return retval;
4825
4826         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4827
4828         /* Clear mbuf payload */
4829         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4830                rte_pktmbuf_tailroom(ut_params->ibuf));
4831
4832         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4833         /* Append data which is padded to a multiple */
4834         /* of the algorithms block size */
4835         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4836         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4837                                 plaintext_pad_len);
4838         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4839
4840         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4841
4842         /* Create ZUC operation */
4843         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4844                                         tdata->cipher_iv.len,
4845                                         tdata->plaintext.len,
4846                                         0);
4847         if (retval < 0)
4848                 return retval;
4849
4850         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4851                                                 ut_params->op);
4852         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4853
4854         ut_params->obuf = ut_params->op->sym->m_dst;
4855         if (ut_params->obuf)
4856                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4857         else
4858                 ciphertext = plaintext;
4859
4860         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4861
4862         /* Validate obuf */
4863         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4864                 ciphertext,
4865                 tdata->ciphertext.data,
4866                 tdata->validCipherLenInBits.len,
4867                 "ZUC Ciphertext data not as expected");
4868         return 0;
4869 }
4870
4871 static int
4872 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4873 {
4874         struct crypto_testsuite_params *ts_params = &testsuite_params;
4875         struct crypto_unittest_params *ut_params = &unittest_params;
4876
4877         int retval;
4878
4879         unsigned int plaintext_pad_len;
4880         unsigned int plaintext_len;
4881         const uint8_t *ciphertext;
4882         uint8_t ciphertext_buffer[2048];
4883         struct rte_cryptodev_info dev_info;
4884
4885         struct rte_cryptodev_sym_capability_idx cap_idx;
4886
4887         /* Check if device supports ZUC EEA3 */
4888         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4889         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4890
4891         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4892                         &cap_idx) == NULL)
4893                 return -ENOTSUP;
4894
4895         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4896
4897         uint64_t feat_flags = dev_info.feature_flags;
4898
4899         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4900                 printf("Device doesn't support in-place scatter-gather. "
4901                                 "Test Skipped.\n");
4902                 return 0;
4903         }
4904
4905         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4906
4907         /* Append data which is padded to a multiple */
4908         /* of the algorithms block size */
4909         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4910
4911         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4912                         plaintext_pad_len, 10, 0);
4913
4914         pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4915                         tdata->plaintext.data);
4916
4917         /* Create ZUC session */
4918         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4919                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4920                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
4921                         tdata->key.data, tdata->key.len,
4922                         tdata->cipher_iv.len);
4923         if (retval < 0)
4924                 return retval;
4925
4926         /* Clear mbuf payload */
4927
4928         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4929
4930         /* Create ZUC operation */
4931         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4932                         tdata->cipher_iv.len, tdata->plaintext.len,
4933                         0);
4934         if (retval < 0)
4935                 return retval;
4936
4937         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4938                                                 ut_params->op);
4939         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4940
4941         ut_params->obuf = ut_params->op->sym->m_dst;
4942         if (ut_params->obuf)
4943                 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4944                         0, plaintext_len, ciphertext_buffer);
4945         else
4946                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4947                         0, plaintext_len, ciphertext_buffer);
4948
4949         /* Validate obuf */
4950         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4951
4952         /* Validate obuf */
4953         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4954                 ciphertext,
4955                 tdata->ciphertext.data,
4956                 tdata->validCipherLenInBits.len,
4957                 "ZUC Ciphertext data not as expected");
4958
4959         return 0;
4960 }
4961
4962 static int
4963 test_zuc_authentication(const struct wireless_test_data *tdata)
4964 {
4965         struct crypto_testsuite_params *ts_params = &testsuite_params;
4966         struct crypto_unittest_params *ut_params = &unittest_params;
4967
4968         int retval;
4969         unsigned plaintext_pad_len;
4970         unsigned plaintext_len;
4971         uint8_t *plaintext;
4972
4973         struct rte_cryptodev_sym_capability_idx cap_idx;
4974
4975         /* Check if device supports ZUC EIA3 */
4976         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4977         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4978
4979         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4980                         &cap_idx) == NULL)
4981                 return -ENOTSUP;
4982
4983         /* Create ZUC session */
4984         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4985                         tdata->key.data, tdata->key.len,
4986                         tdata->auth_iv.len, tdata->digest.len,
4987                         RTE_CRYPTO_AUTH_OP_GENERATE,
4988                         RTE_CRYPTO_AUTH_ZUC_EIA3);
4989         if (retval < 0)
4990                 return retval;
4991
4992         /* alloc mbuf and set payload */
4993         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4994
4995         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4996         rte_pktmbuf_tailroom(ut_params->ibuf));
4997
4998         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4999         /* Append data which is padded to a multiple of */
5000         /* the algorithms block size */
5001         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5002         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5003                                 plaintext_pad_len);
5004         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5005
5006         /* Create ZUC operation */
5007         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5008                         tdata->auth_iv.data, tdata->auth_iv.len,
5009                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5010                         tdata->validAuthLenInBits.len,
5011                         0);
5012         if (retval < 0)
5013                 return retval;
5014
5015         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5016                                 ut_params->op);
5017         ut_params->obuf = ut_params->op->sym->m_src;
5018         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5019         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5020                         + plaintext_pad_len;
5021
5022         /* Validate obuf */
5023         TEST_ASSERT_BUFFERS_ARE_EQUAL(
5024         ut_params->digest,
5025         tdata->digest.data,
5026         DIGEST_BYTE_LENGTH_KASUMI_F9,
5027         "ZUC Generated auth tag not as expected");
5028
5029         return 0;
5030 }
5031
5032 static int
5033 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5034         uint8_t op_mode, uint8_t verify)
5035 {
5036         struct crypto_testsuite_params *ts_params = &testsuite_params;
5037         struct crypto_unittest_params *ut_params = &unittest_params;
5038
5039         int retval;
5040
5041         uint8_t *plaintext = NULL, *ciphertext = NULL;
5042         unsigned int plaintext_pad_len;
5043         unsigned int plaintext_len;
5044         unsigned int ciphertext_pad_len;
5045         unsigned int ciphertext_len;
5046
5047         struct rte_cryptodev_info dev_info;
5048
5049         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5050
5051         uint64_t feat_flags = dev_info.feature_flags;
5052
5053         if (op_mode == OUT_OF_PLACE) {
5054                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5055                         printf("Device doesn't support digest encrypted.\n");
5056                         return -ENOTSUP;
5057                 }
5058         }
5059
5060         /* Create KASUMI session */
5061         retval = create_wireless_algo_auth_cipher_session(
5062                         ts_params->valid_devs[0],
5063                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5064                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5065                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5066                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
5067                         RTE_CRYPTO_AUTH_ZUC_EIA3,
5068                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5069                         tdata->key.data, tdata->key.len,
5070                         tdata->auth_iv.len, tdata->digest.len,
5071                         tdata->cipher_iv.len);
5072
5073         if (retval < 0)
5074                 return retval;
5075
5076         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5077         if (op_mode == OUT_OF_PLACE)
5078                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5079
5080         /* clear mbuf payload */
5081         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5082                 rte_pktmbuf_tailroom(ut_params->ibuf));
5083         if (op_mode == OUT_OF_PLACE)
5084                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5085                         rte_pktmbuf_tailroom(ut_params->obuf));
5086
5087         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5088         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5089         /* Append data which is padded to a multiple of */
5090         /* the algorithms block size */
5091         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5092         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5093
5094         if (verify) {
5095                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5096                                         ciphertext_pad_len);
5097                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5098                 if (op_mode == OUT_OF_PLACE)
5099                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5100                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5101                         ciphertext_len);
5102         } else {
5103                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5104                                         plaintext_pad_len);
5105                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5106                 if (op_mode == OUT_OF_PLACE)
5107                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5108                 debug_hexdump(stdout, "plaintext:", plaintext,
5109                         plaintext_len);
5110         }
5111
5112         /* Create ZUC operation */
5113         retval = create_wireless_algo_auth_cipher_operation(
5114                 tdata->digest.len,
5115                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5116                 tdata->auth_iv.data, tdata->auth_iv.len,
5117                 (tdata->digest.offset_bytes == 0 ?
5118                 (verify ? ciphertext_pad_len : plaintext_pad_len)
5119                         : tdata->digest.offset_bytes),
5120                 tdata->validCipherLenInBits.len,
5121                 tdata->validCipherOffsetInBits.len,
5122                 tdata->validAuthLenInBits.len,
5123                 0,
5124                 op_mode);
5125
5126         if (retval < 0)
5127                 return retval;
5128
5129         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5130                         ut_params->op);
5131
5132         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5133
5134         ut_params->obuf = (op_mode == IN_PLACE ?
5135                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5136
5137
5138         if (verify) {
5139                 if (ut_params->obuf)
5140                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5141                                                         uint8_t *);
5142                 else
5143                         plaintext = ciphertext;
5144
5145                 debug_hexdump(stdout, "plaintext:", plaintext,
5146                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5147                 debug_hexdump(stdout, "plaintext expected:",
5148                         tdata->plaintext.data,
5149                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5150         } else {
5151                 if (ut_params->obuf)
5152                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5153                                                         uint8_t *);
5154                 else
5155                         ciphertext = plaintext;
5156
5157                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5158                         ciphertext_len);
5159                 debug_hexdump(stdout, "ciphertext expected:",
5160                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5161
5162                 ut_params->digest = rte_pktmbuf_mtod(
5163                         ut_params->obuf, uint8_t *) +
5164                         (tdata->digest.offset_bytes == 0 ?
5165                         plaintext_pad_len : tdata->digest.offset_bytes);
5166
5167                 debug_hexdump(stdout, "digest:", ut_params->digest,
5168                         tdata->digest.len);
5169                 debug_hexdump(stdout, "digest expected:",
5170                         tdata->digest.data, tdata->digest.len);
5171         }
5172
5173         /* Validate obuf */
5174         if (verify) {
5175                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5176                         plaintext,
5177                         tdata->plaintext.data,
5178                         tdata->plaintext.len >> 3,
5179                         "ZUC Plaintext data not as expected");
5180         } else {
5181                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5182                         ciphertext,
5183                         tdata->ciphertext.data,
5184                         tdata->ciphertext.len >> 3,
5185                         "ZUC Ciphertext data not as expected");
5186
5187                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5188                         ut_params->digest,
5189                         tdata->digest.data,
5190                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5191                         "ZUC Generated auth tag not as expected");
5192         }
5193         return 0;
5194 }
5195
5196 static int
5197 test_kasumi_encryption_test_case_1(void)
5198 {
5199         return test_kasumi_encryption(&kasumi_test_case_1);
5200 }
5201
5202 static int
5203 test_kasumi_encryption_test_case_1_sgl(void)
5204 {
5205         return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5206 }
5207
5208 static int
5209 test_kasumi_encryption_test_case_1_oop(void)
5210 {
5211         return test_kasumi_encryption_oop(&kasumi_test_case_1);
5212 }
5213
5214 static int
5215 test_kasumi_encryption_test_case_1_oop_sgl(void)
5216 {
5217         return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5218 }
5219
5220 static int
5221 test_kasumi_encryption_test_case_2(void)
5222 {
5223         return test_kasumi_encryption(&kasumi_test_case_2);
5224 }
5225
5226 static int
5227 test_kasumi_encryption_test_case_3(void)
5228 {
5229         return test_kasumi_encryption(&kasumi_test_case_3);
5230 }
5231
5232 static int
5233 test_kasumi_encryption_test_case_4(void)
5234 {
5235         return test_kasumi_encryption(&kasumi_test_case_4);
5236 }
5237
5238 static int
5239 test_kasumi_encryption_test_case_5(void)
5240 {
5241         return test_kasumi_encryption(&kasumi_test_case_5);
5242 }
5243
5244 static int
5245 test_kasumi_decryption_test_case_1(void)
5246 {
5247         return test_kasumi_decryption(&kasumi_test_case_1);
5248 }
5249
5250 static int
5251 test_kasumi_decryption_test_case_1_oop(void)
5252 {
5253         return test_kasumi_decryption_oop(&kasumi_test_case_1);
5254 }
5255
5256 static int
5257 test_kasumi_decryption_test_case_2(void)
5258 {
5259         return test_kasumi_decryption(&kasumi_test_case_2);
5260 }
5261
5262 static int
5263 test_kasumi_decryption_test_case_3(void)
5264 {
5265         return test_kasumi_decryption(&kasumi_test_case_3);
5266 }
5267
5268 static int
5269 test_kasumi_decryption_test_case_4(void)
5270 {
5271         return test_kasumi_decryption(&kasumi_test_case_4);
5272 }
5273
5274 static int
5275 test_kasumi_decryption_test_case_5(void)
5276 {
5277         return test_kasumi_decryption(&kasumi_test_case_5);
5278 }
5279 static int
5280 test_snow3g_encryption_test_case_1(void)
5281 {
5282         return test_snow3g_encryption(&snow3g_test_case_1);
5283 }
5284
5285 static int
5286 test_snow3g_encryption_test_case_1_oop(void)
5287 {
5288         return test_snow3g_encryption_oop(&snow3g_test_case_1);
5289 }
5290
5291 static int
5292 test_snow3g_encryption_test_case_1_oop_sgl(void)
5293 {
5294         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5295 }
5296
5297
5298 static int
5299 test_snow3g_encryption_test_case_1_offset_oop(void)
5300 {
5301         return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5302 }
5303
5304 static int
5305 test_snow3g_encryption_test_case_2(void)
5306 {
5307         return test_snow3g_encryption(&snow3g_test_case_2);
5308 }
5309
5310 static int
5311 test_snow3g_encryption_test_case_3(void)
5312 {
5313         return test_snow3g_encryption(&snow3g_test_case_3);
5314 }
5315
5316 static int
5317 test_snow3g_encryption_test_case_4(void)
5318 {
5319         return test_snow3g_encryption(&snow3g_test_case_4);
5320 }
5321
5322 static int
5323 test_snow3g_encryption_test_case_5(void)
5324 {
5325         return test_snow3g_encryption(&snow3g_test_case_5);
5326 }
5327
5328 static int
5329 test_snow3g_decryption_test_case_1(void)
5330 {
5331         return test_snow3g_decryption(&snow3g_test_case_1);
5332 }
5333
5334 static int
5335 test_snow3g_decryption_test_case_1_oop(void)
5336 {
5337         return test_snow3g_decryption_oop(&snow3g_test_case_1);
5338 }
5339
5340 static int
5341 test_snow3g_decryption_test_case_2(void)
5342 {
5343         return test_snow3g_decryption(&snow3g_test_case_2);
5344 }
5345
5346 static int
5347 test_snow3g_decryption_test_case_3(void)
5348 {
5349         return test_snow3g_decryption(&snow3g_test_case_3);
5350 }
5351
5352 static int
5353 test_snow3g_decryption_test_case_4(void)
5354 {
5355         return test_snow3g_decryption(&snow3g_test_case_4);
5356 }
5357
5358 static int
5359 test_snow3g_decryption_test_case_5(void)
5360 {
5361         return test_snow3g_decryption(&snow3g_test_case_5);
5362 }
5363
5364 /*
5365  * Function prepares snow3g_hash_test_data from snow3g_test_data.
5366  * Pattern digest from snow3g_test_data must be allocated as
5367  * 4 last bytes in plaintext.
5368  */
5369 static void
5370 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5371                 struct snow3g_hash_test_data *output)
5372 {
5373         if ((pattern != NULL) && (output != NULL)) {
5374                 output->key.len = pattern->key.len;
5375
5376                 memcpy(output->key.data,
5377                 pattern->key.data, pattern->key.len);
5378
5379                 output->auth_iv.len = pattern->auth_iv.len;
5380
5381                 memcpy(output->auth_iv.data,
5382                 pattern->auth_iv.data, pattern->auth_iv.len);
5383
5384                 output->plaintext.len = pattern->plaintext.len;
5385
5386                 memcpy(output->plaintext.data,
5387                 pattern->plaintext.data, pattern->plaintext.len >> 3);
5388
5389                 output->digest.len = pattern->digest.len;
5390
5391                 memcpy(output->digest.data,
5392                 &pattern->plaintext.data[pattern->digest.offset_bytes],
5393                 pattern->digest.len);
5394
5395                 output->validAuthLenInBits.len =
5396                 pattern->validAuthLenInBits.len;
5397         }
5398 }
5399
5400 /*
5401  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
5402  */
5403 static int
5404 test_snow3g_decryption_with_digest_test_case_1(void)
5405 {
5406         struct snow3g_hash_test_data snow3g_hash_data;
5407
5408         /*
5409          * Function prepare data for hash veryfication test case.
5410          * Digest is allocated in 4 last bytes in plaintext, pattern.
5411          */
5412         snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
5413
5414         return test_snow3g_decryption(&snow3g_test_case_7) &
5415                         test_snow3g_authentication_verify(&snow3g_hash_data);
5416 }
5417
5418 static int
5419 test_snow3g_cipher_auth_test_case_1(void)
5420 {
5421         return test_snow3g_cipher_auth(&snow3g_test_case_3);
5422 }
5423
5424 static int
5425 test_snow3g_auth_cipher_test_case_1(void)
5426 {
5427         return test_snow3g_auth_cipher(
5428                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
5429 }
5430
5431 static int
5432 test_snow3g_auth_cipher_test_case_2(void)
5433 {
5434         return test_snow3g_auth_cipher(
5435                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
5436 }
5437
5438 static int
5439 test_snow3g_auth_cipher_test_case_2_oop(void)
5440 {
5441         return test_snow3g_auth_cipher(
5442                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5443 }
5444
5445 static int
5446 test_snow3g_auth_cipher_part_digest_enc(void)
5447 {
5448         return test_snow3g_auth_cipher(
5449                 &snow3g_auth_cipher_partial_digest_encryption,
5450                         IN_PLACE, 0);
5451 }
5452
5453 static int
5454 test_snow3g_auth_cipher_part_digest_enc_oop(void)
5455 {
5456         return test_snow3g_auth_cipher(
5457                 &snow3g_auth_cipher_partial_digest_encryption,
5458                         OUT_OF_PLACE, 0);
5459 }
5460
5461 static int
5462 test_snow3g_auth_cipher_verify_test_case_1(void)
5463 {
5464         return test_snow3g_auth_cipher(
5465                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
5466 }
5467
5468 static int
5469 test_snow3g_auth_cipher_verify_test_case_2(void)
5470 {
5471         return test_snow3g_auth_cipher(
5472                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
5473 }
5474
5475 static int
5476 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
5477 {
5478         return test_snow3g_auth_cipher(
5479                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5480 }
5481
5482 static int
5483 test_snow3g_auth_cipher_verify_part_digest_enc(void)
5484 {
5485         return test_snow3g_auth_cipher(
5486                 &snow3g_auth_cipher_partial_digest_encryption,
5487                         IN_PLACE, 1);
5488 }
5489
5490 static int
5491 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
5492 {
5493         return test_snow3g_auth_cipher(
5494                 &snow3g_auth_cipher_partial_digest_encryption,
5495                         OUT_OF_PLACE, 1);
5496 }
5497
5498 static int
5499 test_snow3g_auth_cipher_with_digest_test_case_1(void)
5500 {
5501         return test_snow3g_auth_cipher(
5502                 &snow3g_test_case_7, IN_PLACE, 0);
5503 }
5504
5505 static int
5506 test_kasumi_auth_cipher_test_case_1(void)
5507 {
5508         return test_kasumi_auth_cipher(
5509                 &kasumi_test_case_3, IN_PLACE, 0);
5510 }
5511
5512 static int
5513 test_kasumi_auth_cipher_test_case_2(void)
5514 {
5515         return test_kasumi_auth_cipher(
5516                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
5517 }
5518
5519 static int
5520 test_kasumi_auth_cipher_test_case_2_oop(void)
5521 {
5522         return test_kasumi_auth_cipher(
5523                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
5524 }
5525
5526 static int
5527 test_kasumi_auth_cipher_verify_test_case_1(void)
5528 {
5529         return test_kasumi_auth_cipher(
5530                 &kasumi_test_case_3, IN_PLACE, 1);
5531 }
5532
5533 static int
5534 test_kasumi_auth_cipher_verify_test_case_2(void)
5535 {
5536         return test_kasumi_auth_cipher(
5537                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
5538 }
5539
5540 static int
5541 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
5542 {
5543         return test_kasumi_auth_cipher(
5544                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
5545 }
5546
5547 static int
5548 test_kasumi_cipher_auth_test_case_1(void)
5549 {
5550         return test_kasumi_cipher_auth(&kasumi_test_case_6);
5551 }
5552
5553 static int
5554 test_zuc_encryption_test_case_1(void)
5555 {
5556         return test_zuc_encryption(&zuc_test_case_cipher_193b);
5557 }
5558
5559 static int
5560 test_zuc_encryption_test_case_2(void)
5561 {
5562         return test_zuc_encryption(&zuc_test_case_cipher_800b);
5563 }
5564
5565 static int
5566 test_zuc_encryption_test_case_3(void)
5567 {
5568         return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5569 }
5570
5571 static int
5572 test_zuc_encryption_test_case_4(void)
5573 {
5574         return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5575 }
5576
5577 static int
5578 test_zuc_encryption_test_case_5(void)
5579 {
5580         return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5581 }
5582
5583 static int
5584 test_zuc_encryption_test_case_6_sgl(void)
5585 {
5586         return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5587 }
5588
5589 static int
5590 test_zuc_hash_generate_test_case_1(void)
5591 {
5592         return test_zuc_authentication(&zuc_test_case_auth_1b);
5593 }
5594
5595 static int
5596 test_zuc_hash_generate_test_case_2(void)
5597 {
5598         return test_zuc_authentication(&zuc_test_case_auth_90b);
5599 }
5600
5601 static int
5602 test_zuc_hash_generate_test_case_3(void)
5603 {
5604         return test_zuc_authentication(&zuc_test_case_auth_577b);
5605 }
5606
5607 static int
5608 test_zuc_hash_generate_test_case_4(void)
5609 {
5610         return test_zuc_authentication(&zuc_test_case_auth_2079b);
5611 }
5612
5613 static int
5614 test_zuc_hash_generate_test_case_5(void)
5615 {
5616         return test_zuc_authentication(&zuc_test_auth_5670b);
5617 }
5618
5619 static int
5620 test_zuc_hash_generate_test_case_6(void)
5621 {
5622         return test_zuc_authentication(&zuc_test_case_auth_128b);
5623 }
5624
5625 static int
5626 test_zuc_hash_generate_test_case_7(void)
5627 {
5628         return test_zuc_authentication(&zuc_test_case_auth_2080b);
5629 }
5630
5631 static int
5632 test_zuc_hash_generate_test_case_8(void)
5633 {
5634         return test_zuc_authentication(&zuc_test_case_auth_584b);
5635 }
5636
5637 static int
5638 test_zuc_cipher_auth_test_case_1(void)
5639 {
5640         return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5641 }
5642
5643 static int
5644 test_zuc_cipher_auth_test_case_2(void)
5645 {
5646         return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5647 }
5648
5649 static int
5650 test_zuc_auth_cipher_test_case_1(void)
5651 {
5652         return test_zuc_auth_cipher(
5653                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
5654 }
5655
5656 static int
5657 test_zuc_auth_cipher_test_case_1_oop(void)
5658 {
5659         return test_zuc_auth_cipher(
5660                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
5661 }
5662
5663 static int
5664 test_zuc_auth_cipher_verify_test_case_1(void)
5665 {
5666         return test_zuc_auth_cipher(
5667                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
5668 }
5669
5670 static int
5671 test_zuc_auth_cipher_verify_test_case_1_oop(void)
5672 {
5673         return test_zuc_auth_cipher(
5674                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
5675 }
5676
5677 static int
5678 test_3DES_chain_qat_all(void)
5679 {
5680         struct crypto_testsuite_params *ts_params = &testsuite_params;
5681         int status;
5682
5683         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5684                 ts_params->op_mpool,
5685                 ts_params->session_mpool, ts_params->session_priv_mpool,
5686                 ts_params->valid_devs[0],
5687                 rte_cryptodev_driver_id_get(
5688                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5689                 BLKCIPHER_3DES_CHAIN_TYPE);
5690
5691         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5692
5693         return TEST_SUCCESS;
5694 }
5695
5696 static int
5697 test_DES_cipheronly_qat_all(void)
5698 {
5699         struct crypto_testsuite_params *ts_params = &testsuite_params;
5700         int status;
5701
5702         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5703                 ts_params->op_mpool,
5704                 ts_params->session_mpool, ts_params->session_priv_mpool,
5705                 ts_params->valid_devs[0],
5706                 rte_cryptodev_driver_id_get(
5707                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5708                 BLKCIPHER_DES_CIPHERONLY_TYPE);
5709
5710         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5711
5712         return TEST_SUCCESS;
5713 }
5714
5715 static int
5716 test_DES_cipheronly_openssl_all(void)
5717 {
5718         struct crypto_testsuite_params *ts_params = &testsuite_params;
5719         int status;
5720
5721         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5722                 ts_params->op_mpool,
5723                 ts_params->session_mpool, ts_params->session_priv_mpool,
5724                 ts_params->valid_devs[0],
5725                 rte_cryptodev_driver_id_get(
5726                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5727                 BLKCIPHER_DES_CIPHERONLY_TYPE);
5728
5729         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5730
5731         return TEST_SUCCESS;
5732 }
5733
5734 static int
5735 test_DES_docsis_openssl_all(void)
5736 {
5737         struct crypto_testsuite_params *ts_params = &testsuite_params;
5738         int status;
5739
5740         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5741                 ts_params->op_mpool,
5742                 ts_params->session_mpool, ts_params->session_priv_mpool,
5743                 ts_params->valid_devs[0],
5744                 rte_cryptodev_driver_id_get(
5745                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5746                 BLKCIPHER_DES_DOCSIS_TYPE);
5747
5748         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5749
5750         return TEST_SUCCESS;
5751 }
5752
5753 static int
5754 test_DES_cipheronly_mb_all(void)
5755 {
5756         struct crypto_testsuite_params *ts_params = &testsuite_params;
5757         int status;
5758
5759         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5760                 ts_params->op_mpool,
5761                 ts_params->session_mpool, ts_params->session_priv_mpool,
5762                 ts_params->valid_devs[0],
5763                 rte_cryptodev_driver_id_get(
5764                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5765                 BLKCIPHER_DES_CIPHERONLY_TYPE);
5766
5767         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5768
5769         return TEST_SUCCESS;
5770 }
5771 static int
5772 test_3DES_cipheronly_mb_all(void)
5773 {
5774         struct crypto_testsuite_params *ts_params = &testsuite_params;
5775         int status;
5776
5777         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5778                 ts_params->op_mpool,
5779                 ts_params->session_mpool, ts_params->session_priv_mpool,
5780                 ts_params->valid_devs[0],
5781                 rte_cryptodev_driver_id_get(
5782                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5783                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5784
5785         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5786
5787         return TEST_SUCCESS;
5788 }
5789
5790 static int
5791 test_DES_docsis_mb_all(void)
5792 {
5793         struct crypto_testsuite_params *ts_params = &testsuite_params;
5794         int status;
5795
5796         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5797                 ts_params->op_mpool,
5798                 ts_params->session_mpool, ts_params->session_priv_mpool,
5799                 ts_params->valid_devs[0],
5800                 rte_cryptodev_driver_id_get(
5801                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5802                 BLKCIPHER_DES_DOCSIS_TYPE);
5803
5804         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5805
5806         return TEST_SUCCESS;
5807 }
5808
5809 static int
5810 test_3DES_chain_caam_jr_all(void)
5811 {
5812         struct crypto_testsuite_params *ts_params = &testsuite_params;
5813         int status;
5814
5815         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5816                 ts_params->op_mpool,
5817                 ts_params->session_mpool, ts_params->session_priv_mpool,
5818                 ts_params->valid_devs[0],
5819                 rte_cryptodev_driver_id_get(
5820                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5821                 BLKCIPHER_3DES_CHAIN_TYPE);
5822
5823         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5824
5825         return TEST_SUCCESS;
5826 }
5827
5828 static int
5829 test_3DES_cipheronly_caam_jr_all(void)
5830 {
5831         struct crypto_testsuite_params *ts_params = &testsuite_params;
5832         int status;
5833
5834         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5835                 ts_params->op_mpool,
5836                 ts_params->session_mpool, ts_params->session_priv_mpool,
5837                 ts_params->valid_devs[0],
5838                 rte_cryptodev_driver_id_get(
5839                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5840                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5841
5842         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5843
5844         return TEST_SUCCESS;
5845 }
5846
5847 static int
5848 test_3DES_chain_dpaa_sec_all(void)
5849 {
5850         struct crypto_testsuite_params *ts_params = &testsuite_params;
5851         int status;
5852
5853         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5854                 ts_params->op_mpool,
5855                 ts_params->session_mpool, ts_params->session_priv_mpool,
5856                 ts_params->valid_devs[0],
5857                 rte_cryptodev_driver_id_get(
5858                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5859                 BLKCIPHER_3DES_CHAIN_TYPE);
5860
5861         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5862
5863         return TEST_SUCCESS;
5864 }
5865
5866 static int
5867 test_3DES_cipheronly_dpaa_sec_all(void)
5868 {
5869         struct crypto_testsuite_params *ts_params = &testsuite_params;
5870         int status;
5871
5872         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5873                 ts_params->op_mpool,
5874                 ts_params->session_mpool, ts_params->session_priv_mpool,
5875                 ts_params->valid_devs[0],
5876                 rte_cryptodev_driver_id_get(
5877                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5878                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5879
5880         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5881
5882         return TEST_SUCCESS;
5883 }
5884
5885 static int
5886 test_3DES_chain_dpaa2_sec_all(void)
5887 {
5888         struct crypto_testsuite_params *ts_params = &testsuite_params;
5889         int status;
5890
5891         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5892                 ts_params->op_mpool,
5893                 ts_params->session_mpool, ts_params->session_priv_mpool,
5894                 ts_params->valid_devs[0],
5895                 rte_cryptodev_driver_id_get(
5896                 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5897                 BLKCIPHER_3DES_CHAIN_TYPE);
5898
5899         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5900
5901         return TEST_SUCCESS;
5902 }
5903
5904 static int
5905 test_3DES_cipheronly_dpaa2_sec_all(void)
5906 {
5907         struct crypto_testsuite_params *ts_params = &testsuite_params;
5908         int status;
5909
5910         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5911                 ts_params->op_mpool,
5912                 ts_params->session_mpool, ts_params->session_priv_mpool,
5913                 ts_params->valid_devs[0],
5914                 rte_cryptodev_driver_id_get(
5915                 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5916                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5917
5918         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5919
5920         return TEST_SUCCESS;
5921 }
5922
5923 static int
5924 test_3DES_chain_ccp_all(void)
5925 {
5926         struct crypto_testsuite_params *ts_params = &testsuite_params;
5927         int status;
5928
5929         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5930                 ts_params->op_mpool,
5931                 ts_params->session_mpool, ts_params->session_priv_mpool,
5932                 ts_params->valid_devs[0],
5933                 rte_cryptodev_driver_id_get(
5934                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5935                 BLKCIPHER_3DES_CHAIN_TYPE);
5936
5937         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5938
5939         return TEST_SUCCESS;
5940 }
5941
5942 static int
5943 test_3DES_cipheronly_ccp_all(void)
5944 {
5945         struct crypto_testsuite_params *ts_params = &testsuite_params;
5946         int status;
5947
5948         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5949                 ts_params->op_mpool,
5950                 ts_params->session_mpool, ts_params->session_priv_mpool,
5951                 ts_params->valid_devs[0],
5952                 rte_cryptodev_driver_id_get(
5953                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5954                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5955
5956         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5957
5958         return TEST_SUCCESS;
5959 }
5960
5961 static int
5962 test_3DES_cipheronly_qat_all(void)
5963 {
5964         struct crypto_testsuite_params *ts_params = &testsuite_params;
5965         int status;
5966
5967         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5968                 ts_params->op_mpool,
5969                 ts_params->session_mpool, ts_params->session_priv_mpool,
5970                 ts_params->valid_devs[0],
5971                 rte_cryptodev_driver_id_get(
5972                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5973                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5974
5975         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5976
5977         return TEST_SUCCESS;
5978 }
5979
5980 static int
5981 test_3DES_chain_openssl_all(void)
5982 {
5983         struct crypto_testsuite_params *ts_params = &testsuite_params;
5984         int status;
5985
5986         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5987                 ts_params->op_mpool,
5988                 ts_params->session_mpool, ts_params->session_priv_mpool,
5989                 ts_params->valid_devs[0],
5990                 rte_cryptodev_driver_id_get(
5991                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5992                 BLKCIPHER_3DES_CHAIN_TYPE);
5993
5994         TEST_ASSERT_EQUAL(status, 0, "Test failed");
5995
5996         return TEST_SUCCESS;
5997 }
5998
5999 static int
6000 test_3DES_cipheronly_openssl_all(void)
6001 {
6002         struct crypto_testsuite_params *ts_params = &testsuite_params;
6003         int status;
6004
6005         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6006                 ts_params->op_mpool,
6007                 ts_params->session_mpool, ts_params->session_priv_mpool,
6008                 ts_params->valid_devs[0],
6009                 rte_cryptodev_driver_id_get(
6010                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6011                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6012
6013         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6014
6015         return TEST_SUCCESS;
6016 }
6017
6018 /* ***** AEAD algorithm Tests ***** */
6019
6020 static int
6021 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6022                 enum rte_crypto_aead_operation op,
6023                 const uint8_t *key, const uint8_t key_len,
6024                 const uint16_t aad_len, const uint8_t auth_len,
6025                 uint8_t iv_len)
6026 {
6027         uint8_t aead_key[key_len];
6028
6029         struct crypto_testsuite_params *ts_params = &testsuite_params;
6030         struct crypto_unittest_params *ut_params = &unittest_params;
6031
6032         memcpy(aead_key, key, key_len);
6033
6034         /* Setup AEAD Parameters */
6035         ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6036         ut_params->aead_xform.next = NULL;
6037         ut_params->aead_xform.aead.algo = algo;
6038         ut_params->aead_xform.aead.op = op;
6039         ut_params->aead_xform.aead.key.data = aead_key;
6040         ut_params->aead_xform.aead.key.length = key_len;
6041         ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6042         ut_params->aead_xform.aead.iv.length = iv_len;
6043         ut_params->aead_xform.aead.digest_length = auth_len;
6044         ut_params->aead_xform.aead.aad_length = aad_len;
6045
6046         debug_hexdump(stdout, "key:", key, key_len);
6047
6048         /* Create Crypto session*/
6049         ut_params->sess = rte_cryptodev_sym_session_create(
6050                         ts_params->session_mpool);
6051
6052         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6053                         &ut_params->aead_xform,
6054                         ts_params->session_priv_mpool);
6055
6056         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6057
6058         return 0;
6059 }
6060
6061 static int
6062 create_aead_xform(struct rte_crypto_op *op,
6063                 enum rte_crypto_aead_algorithm algo,
6064                 enum rte_crypto_aead_operation aead_op,
6065                 uint8_t *key, const uint8_t key_len,
6066                 const uint8_t aad_len, const uint8_t auth_len,
6067                 uint8_t iv_len)
6068 {
6069         TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6070                         "failed to allocate space for crypto transform");
6071
6072         struct rte_crypto_sym_op *sym_op = op->sym;
6073
6074         /* Setup AEAD Parameters */
6075         sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6076         sym_op->xform->next = NULL;
6077         sym_op->xform->aead.algo = algo;
6078         sym_op->xform->aead.op = aead_op;
6079         sym_op->xform->aead.key.data = key;
6080         sym_op->xform->aead.key.length = key_len;
6081         sym_op->xform->aead.iv.offset = IV_OFFSET;
6082         sym_op->xform->aead.iv.length = iv_len;
6083         sym_op->xform->aead.digest_length = auth_len;
6084         sym_op->xform->aead.aad_length = aad_len;
6085
6086         debug_hexdump(stdout, "key:", key, key_len);
6087
6088         return 0;
6089 }
6090
6091 static int
6092 create_aead_operation(enum rte_crypto_aead_operation op,
6093                 const struct aead_test_data *tdata)
6094 {
6095         struct crypto_testsuite_params *ts_params = &testsuite_params;
6096         struct crypto_unittest_params *ut_params = &unittest_params;
6097
6098         uint8_t *plaintext, *ciphertext;
6099         unsigned int aad_pad_len, plaintext_pad_len;
6100
6101         /* Generate Crypto op data structure */
6102         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6103                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6104         TEST_ASSERT_NOT_NULL(ut_params->op,
6105                         "Failed to allocate symmetric crypto operation struct");
6106
6107         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6108
6109         /* Append aad data */
6110         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6111                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6112                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6113                                 aad_pad_len);
6114                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6115                                 "no room to append aad");
6116
6117                 sym_op->aead.aad.phys_addr =
6118                                 rte_pktmbuf_iova(ut_params->ibuf);
6119                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6120                 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6121                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6122                         tdata->aad.len);
6123
6124                 /* Append IV at the end of the crypto operation*/
6125                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6126                                 uint8_t *, IV_OFFSET);
6127
6128                 /* Copy IV 1 byte after the IV pointer, according to the API */
6129                 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6130                 debug_hexdump(stdout, "iv:", iv_ptr,
6131                         tdata->iv.len);
6132         } else {
6133                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6134                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6135                                 aad_pad_len);
6136                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6137                                 "no room to append aad");
6138
6139                 sym_op->aead.aad.phys_addr =
6140                                 rte_pktmbuf_iova(ut_params->ibuf);
6141                 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6142                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6143                         tdata->aad.len);
6144
6145                 /* Append IV at the end of the crypto operation*/
6146                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6147                                 uint8_t *, IV_OFFSET);
6148
6149                 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6150                 debug_hexdump(stdout, "iv:", iv_ptr,
6151                         tdata->iv.len);
6152         }
6153
6154         /* Append plaintext/ciphertext */
6155         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6156                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6157                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6158                                 plaintext_pad_len);
6159                 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6160
6161                 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6162                 debug_hexdump(stdout, "plaintext:", plaintext,
6163                                 tdata->plaintext.len);
6164
6165                 if (ut_params->obuf) {
6166                         ciphertext = (uint8_t *)rte_pktmbuf_append(
6167                                         ut_params->obuf,
6168                                         plaintext_pad_len + aad_pad_len);
6169                         TEST_ASSERT_NOT_NULL(ciphertext,
6170                                         "no room to append ciphertext");
6171
6172                         memset(ciphertext + aad_pad_len, 0,
6173                                         tdata->ciphertext.len);
6174                 }
6175         } else {
6176                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6177                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6178                                 plaintext_pad_len);
6179                 TEST_ASSERT_NOT_NULL(ciphertext,
6180                                 "no room to append ciphertext");
6181
6182                 memcpy(ciphertext, tdata->ciphertext.data,
6183                                 tdata->ciphertext.len);
6184                 debug_hexdump(stdout, "ciphertext:", ciphertext,
6185                                 tdata->ciphertext.len);
6186
6187                 if (ut_params->obuf) {
6188                         plaintext = (uint8_t *)rte_pktmbuf_append(
6189                                         ut_params->obuf,
6190                                         plaintext_pad_len + aad_pad_len);
6191                         TEST_ASSERT_NOT_NULL(plaintext,
6192                                         "no room to append plaintext");
6193
6194                         memset(plaintext + aad_pad_len, 0,
6195                                         tdata->plaintext.len);
6196                 }
6197         }
6198
6199         /* Append digest data */
6200         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6201                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6202                                 ut_params->obuf ? ut_params->obuf :
6203                                                 ut_params->ibuf,
6204                                                 tdata->auth_tag.len);
6205                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6206                                 "no room to append digest");
6207                 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6208                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6209                                 ut_params->obuf ? ut_params->obuf :
6210                                                 ut_params->ibuf,
6211                                                 plaintext_pad_len +
6212                                                 aad_pad_len);
6213         } else {
6214                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6215                                 ut_params->ibuf, tdata->auth_tag.len);
6216                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6217                                 "no room to append digest");
6218                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6219                                 ut_params->ibuf,
6220                                 plaintext_pad_len + aad_pad_len);
6221
6222                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6223                         tdata->auth_tag.len);
6224                 debug_hexdump(stdout, "digest:",
6225                         sym_op->aead.digest.data,
6226                         tdata->auth_tag.len);
6227         }
6228
6229         sym_op->aead.data.length = tdata->plaintext.len;
6230         sym_op->aead.data.offset = aad_pad_len;
6231
6232         return 0;
6233 }
6234
6235 static int
6236 test_authenticated_encryption(const struct aead_test_data *tdata)
6237 {
6238         struct crypto_testsuite_params *ts_params = &testsuite_params;
6239         struct crypto_unittest_params *ut_params = &unittest_params;
6240
6241         int retval;
6242         uint8_t *ciphertext, *auth_tag;
6243         uint16_t plaintext_pad_len;
6244         uint32_t i;
6245
6246         /* Create AEAD session */
6247         retval = create_aead_session(ts_params->valid_devs[0],
6248                         tdata->algo,
6249                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
6250                         tdata->key.data, tdata->key.len,
6251                         tdata->aad.len, tdata->auth_tag.len,
6252                         tdata->iv.len);
6253         if (retval < 0)
6254                 return retval;
6255
6256         if (tdata->aad.len > MBUF_SIZE) {
6257                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6258                 /* Populate full size of add data */
6259                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6260                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6261         } else
6262                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6263
6264         /* clear mbuf payload */
6265         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6266                         rte_pktmbuf_tailroom(ut_params->ibuf));
6267
6268         /* Create AEAD operation */
6269         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6270         if (retval < 0)
6271                 return retval;
6272
6273         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6274
6275         ut_params->op->sym->m_src = ut_params->ibuf;
6276
6277         /* Process crypto operation */
6278         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6279                         ut_params->op), "failed to process sym crypto op");
6280
6281         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6282                         "crypto op processing failed");
6283
6284         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6285
6286         if (ut_params->op->sym->m_dst) {
6287                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6288                                 uint8_t *);
6289                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6290                                 uint8_t *, plaintext_pad_len);
6291         } else {
6292                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6293                                 uint8_t *,
6294                                 ut_params->op->sym->cipher.data.offset);
6295                 auth_tag = ciphertext + plaintext_pad_len;
6296         }
6297
6298         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6299         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6300
6301         /* Validate obuf */
6302         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6303                         ciphertext,
6304                         tdata->ciphertext.data,
6305                         tdata->ciphertext.len,
6306                         "Ciphertext data not as expected");
6307
6308         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6309                         auth_tag,
6310                         tdata->auth_tag.data,
6311                         tdata->auth_tag.len,
6312                         "Generated auth tag not as expected");
6313
6314         return 0;
6315
6316 }
6317
6318 static int
6319 test_AES_GCM_authenticated_encryption_test_case_1(void)
6320 {
6321         return test_authenticated_encryption(&gcm_test_case_1);
6322 }
6323
6324 static int
6325 test_AES_GCM_authenticated_encryption_test_case_2(void)
6326 {
6327         return test_authenticated_encryption(&gcm_test_case_2);
6328 }
6329
6330 static int
6331 test_AES_GCM_authenticated_encryption_test_case_3(void)
6332 {
6333         return test_authenticated_encryption(&gcm_test_case_3);
6334 }
6335
6336 static int
6337 test_AES_GCM_authenticated_encryption_test_case_4(void)
6338 {
6339         return test_authenticated_encryption(&gcm_test_case_4);
6340 }
6341
6342 static int
6343 test_AES_GCM_authenticated_encryption_test_case_5(void)
6344 {
6345         return test_authenticated_encryption(&gcm_test_case_5);
6346 }
6347
6348 static int
6349 test_AES_GCM_authenticated_encryption_test_case_6(void)
6350 {
6351         return test_authenticated_encryption(&gcm_test_case_6);
6352 }
6353
6354 static int
6355 test_AES_GCM_authenticated_encryption_test_case_7(void)
6356 {
6357         return test_authenticated_encryption(&gcm_test_case_7);
6358 }
6359
6360 static int
6361 test_AES_GCM_auth_encryption_test_case_192_1(void)
6362 {
6363         return test_authenticated_encryption(&gcm_test_case_192_1);
6364 }
6365
6366 static int
6367 test_AES_GCM_auth_encryption_test_case_192_2(void)
6368 {
6369         return test_authenticated_encryption(&gcm_test_case_192_2);
6370 }
6371
6372 static int
6373 test_AES_GCM_auth_encryption_test_case_192_3(void)
6374 {
6375         return test_authenticated_encryption(&gcm_test_case_192_3);
6376 }
6377
6378 static int
6379 test_AES_GCM_auth_encryption_test_case_192_4(void)
6380 {
6381         return test_authenticated_encryption(&gcm_test_case_192_4);
6382 }
6383
6384 static int
6385 test_AES_GCM_auth_encryption_test_case_192_5(void)
6386 {
6387         return test_authenticated_encryption(&gcm_test_case_192_5);
6388 }
6389
6390 static int
6391 test_AES_GCM_auth_encryption_test_case_192_6(void)
6392 {
6393         return test_authenticated_encryption(&gcm_test_case_192_6);
6394 }
6395
6396 static int
6397 test_AES_GCM_auth_encryption_test_case_192_7(void)
6398 {
6399         return test_authenticated_encryption(&gcm_test_case_192_7);
6400 }
6401
6402 static int
6403 test_AES_GCM_auth_encryption_test_case_256_1(void)
6404 {
6405         return test_authenticated_encryption(&gcm_test_case_256_1);
6406 }
6407
6408 static int
6409 test_AES_GCM_auth_encryption_test_case_256_2(void)
6410 {
6411         return test_authenticated_encryption(&gcm_test_case_256_2);
6412 }
6413
6414 static int
6415 test_AES_GCM_auth_encryption_test_case_256_3(void)
6416 {
6417         return test_authenticated_encryption(&gcm_test_case_256_3);
6418 }
6419
6420 static int
6421 test_AES_GCM_auth_encryption_test_case_256_4(void)
6422 {
6423         return test_authenticated_encryption(&gcm_test_case_256_4);
6424 }
6425
6426 static int
6427 test_AES_GCM_auth_encryption_test_case_256_5(void)
6428 {
6429         return test_authenticated_encryption(&gcm_test_case_256_5);
6430 }
6431
6432 static int
6433 test_AES_GCM_auth_encryption_test_case_256_6(void)
6434 {
6435         return test_authenticated_encryption(&gcm_test_case_256_6);
6436 }
6437
6438 static int
6439 test_AES_GCM_auth_encryption_test_case_256_7(void)
6440 {
6441         return test_authenticated_encryption(&gcm_test_case_256_7);
6442 }
6443
6444 static int
6445 test_AES_GCM_auth_encryption_test_case_aad_1(void)
6446 {
6447         return test_authenticated_encryption(&gcm_test_case_aad_1);
6448 }
6449
6450 static int
6451 test_AES_GCM_auth_encryption_test_case_aad_2(void)
6452 {
6453         return test_authenticated_encryption(&gcm_test_case_aad_2);
6454 }
6455
6456 static int
6457 test_authenticated_decryption(const struct aead_test_data *tdata)
6458 {
6459         struct crypto_testsuite_params *ts_params = &testsuite_params;
6460         struct crypto_unittest_params *ut_params = &unittest_params;
6461
6462         int retval;
6463         uint8_t *plaintext;
6464         uint32_t i;
6465
6466         /* Create AEAD session */
6467         retval = create_aead_session(ts_params->valid_devs[0],
6468                         tdata->algo,
6469                         RTE_CRYPTO_AEAD_OP_DECRYPT,
6470                         tdata->key.data, tdata->key.len,
6471                         tdata->aad.len, tdata->auth_tag.len,
6472                         tdata->iv.len);
6473         if (retval < 0)
6474                 return retval;
6475
6476         /* alloc mbuf and set payload */
6477         if (tdata->aad.len > MBUF_SIZE) {
6478                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
6479                 /* Populate full size of add data */
6480                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
6481                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
6482         } else
6483                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6484
6485         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6486                         rte_pktmbuf_tailroom(ut_params->ibuf));
6487
6488         /* Create AEAD operation */
6489         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6490         if (retval < 0)
6491                 return retval;
6492
6493         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6494
6495         ut_params->op->sym->m_src = ut_params->ibuf;
6496
6497         /* Process crypto operation */
6498         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6499                         ut_params->op), "failed to process sym crypto op");
6500
6501         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6502                         "crypto op processing failed");
6503
6504         if (ut_params->op->sym->m_dst)
6505                 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
6506                                 uint8_t *);
6507         else
6508                 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
6509                                 uint8_t *,
6510                                 ut_params->op->sym->cipher.data.offset);
6511
6512         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6513
6514         /* Validate obuf */
6515         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6516                         plaintext,
6517                         tdata->plaintext.data,
6518                         tdata->plaintext.len,
6519                         "Plaintext data not as expected");
6520
6521         TEST_ASSERT_EQUAL(ut_params->op->status,
6522                         RTE_CRYPTO_OP_STATUS_SUCCESS,
6523                         "Authentication failed");
6524         return 0;
6525 }
6526
6527 static int
6528 test_AES_GCM_authenticated_decryption_test_case_1(void)
6529 {
6530         return test_authenticated_decryption(&gcm_test_case_1);
6531 }
6532
6533 static int
6534 test_AES_GCM_authenticated_decryption_test_case_2(void)
6535 {
6536         return test_authenticated_decryption(&gcm_test_case_2);
6537 }
6538
6539 static int
6540 test_AES_GCM_authenticated_decryption_test_case_3(void)
6541 {
6542         return test_authenticated_decryption(&gcm_test_case_3);
6543 }
6544
6545 static int
6546 test_AES_GCM_authenticated_decryption_test_case_4(void)
6547 {
6548         return test_authenticated_decryption(&gcm_test_case_4);
6549 }
6550
6551 static int
6552 test_AES_GCM_authenticated_decryption_test_case_5(void)
6553 {
6554         return test_authenticated_decryption(&gcm_test_case_5);
6555 }
6556
6557 static int
6558 test_AES_GCM_authenticated_decryption_test_case_6(void)
6559 {
6560         return test_authenticated_decryption(&gcm_test_case_6);
6561 }
6562
6563 static int
6564 test_AES_GCM_authenticated_decryption_test_case_7(void)
6565 {
6566         return test_authenticated_decryption(&gcm_test_case_7);
6567 }
6568
6569 static int
6570 test_AES_GCM_auth_decryption_test_case_192_1(void)
6571 {
6572         return test_authenticated_decryption(&gcm_test_case_192_1);
6573 }
6574
6575 static int
6576 test_AES_GCM_auth_decryption_test_case_192_2(void)
6577 {
6578         return test_authenticated_decryption(&gcm_test_case_192_2);
6579 }
6580
6581 static int
6582 test_AES_GCM_auth_decryption_test_case_192_3(void)
6583 {
6584         return test_authenticated_decryption(&gcm_test_case_192_3);
6585 }
6586
6587 static int
6588 test_AES_GCM_auth_decryption_test_case_192_4(void)
6589 {
6590         return test_authenticated_decryption(&gcm_test_case_192_4);
6591 }
6592
6593 static int
6594 test_AES_GCM_auth_decryption_test_case_192_5(void)
6595 {
6596         return test_authenticated_decryption(&gcm_test_case_192_5);
6597 }
6598
6599 static int
6600 test_AES_GCM_auth_decryption_test_case_192_6(void)
6601 {
6602         return test_authenticated_decryption(&gcm_test_case_192_6);
6603 }
6604
6605 static int
6606 test_AES_GCM_auth_decryption_test_case_192_7(void)
6607 {
6608         return test_authenticated_decryption(&gcm_test_case_192_7);
6609 }
6610
6611 static int
6612 test_AES_GCM_auth_decryption_test_case_256_1(void)
6613 {
6614         return test_authenticated_decryption(&gcm_test_case_256_1);
6615 }
6616
6617 static int
6618 test_AES_GCM_auth_decryption_test_case_256_2(void)
6619 {
6620         return test_authenticated_decryption(&gcm_test_case_256_2);
6621 }
6622
6623 static int
6624 test_AES_GCM_auth_decryption_test_case_256_3(void)
6625 {
6626         return test_authenticated_decryption(&gcm_test_case_256_3);
6627 }
6628
6629 static int
6630 test_AES_GCM_auth_decryption_test_case_256_4(void)
6631 {
6632         return test_authenticated_decryption(&gcm_test_case_256_4);
6633 }
6634
6635 static int
6636 test_AES_GCM_auth_decryption_test_case_256_5(void)
6637 {
6638         return test_authenticated_decryption(&gcm_test_case_256_5);
6639 }
6640
6641 static int
6642 test_AES_GCM_auth_decryption_test_case_256_6(void)
6643 {
6644         return test_authenticated_decryption(&gcm_test_case_256_6);
6645 }
6646
6647 static int
6648 test_AES_GCM_auth_decryption_test_case_256_7(void)
6649 {
6650         return test_authenticated_decryption(&gcm_test_case_256_7);
6651 }
6652
6653 static int
6654 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6655 {
6656         return test_authenticated_decryption(&gcm_test_case_aad_1);
6657 }
6658
6659 static int
6660 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6661 {
6662         return test_authenticated_decryption(&gcm_test_case_aad_2);
6663 }
6664
6665 static int
6666 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6667 {
6668         struct crypto_testsuite_params *ts_params = &testsuite_params;
6669         struct crypto_unittest_params *ut_params = &unittest_params;
6670
6671         int retval;
6672         uint8_t *ciphertext, *auth_tag;
6673         uint16_t plaintext_pad_len;
6674
6675         /* Create AEAD session */
6676         retval = create_aead_session(ts_params->valid_devs[0],
6677                         tdata->algo,
6678                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
6679                         tdata->key.data, tdata->key.len,
6680                         tdata->aad.len, tdata->auth_tag.len,
6681                         tdata->iv.len);
6682         if (retval < 0)
6683                 return retval;
6684
6685         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6686         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6687
6688         /* clear mbuf payload */
6689         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6690                         rte_pktmbuf_tailroom(ut_params->ibuf));
6691         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6692                         rte_pktmbuf_tailroom(ut_params->obuf));
6693
6694         /* Create AEAD operation */
6695         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6696         if (retval < 0)
6697                 return retval;
6698
6699         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6700
6701         ut_params->op->sym->m_src = ut_params->ibuf;
6702         ut_params->op->sym->m_dst = ut_params->obuf;
6703
6704         /* Process crypto operation */
6705         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6706                         ut_params->op), "failed to process sym crypto op");
6707
6708         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6709                         "crypto op processing failed");
6710
6711         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6712
6713         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6714                         ut_params->op->sym->cipher.data.offset);
6715         auth_tag = ciphertext + plaintext_pad_len;
6716
6717         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6718         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6719
6720         /* Validate obuf */
6721         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6722                         ciphertext,
6723                         tdata->ciphertext.data,
6724                         tdata->ciphertext.len,
6725                         "Ciphertext data not as expected");
6726
6727         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6728                         auth_tag,
6729                         tdata->auth_tag.data,
6730                         tdata->auth_tag.len,
6731                         "Generated auth tag not as expected");
6732
6733         return 0;
6734
6735 }
6736
6737 static int
6738 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6739 {
6740         return test_authenticated_encryption_oop(&gcm_test_case_5);
6741 }
6742
6743 static int
6744 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6745 {
6746         struct crypto_testsuite_params *ts_params = &testsuite_params;
6747         struct crypto_unittest_params *ut_params = &unittest_params;
6748
6749         int retval;
6750         uint8_t *plaintext;
6751
6752         /* Create AEAD session */
6753         retval = create_aead_session(ts_params->valid_devs[0],
6754                         tdata->algo,
6755                         RTE_CRYPTO_AEAD_OP_DECRYPT,
6756                         tdata->key.data, tdata->key.len,
6757                         tdata->aad.len, tdata->auth_tag.len,
6758                         tdata->iv.len);
6759         if (retval < 0)
6760                 return retval;
6761
6762         /* alloc mbuf and set payload */
6763         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6764         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6765
6766         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6767                         rte_pktmbuf_tailroom(ut_params->ibuf));
6768         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6769                         rte_pktmbuf_tailroom(ut_params->obuf));
6770
6771         /* Create AEAD operation */
6772         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6773         if (retval < 0)
6774                 return retval;
6775
6776         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6777
6778         ut_params->op->sym->m_src = ut_params->ibuf;
6779         ut_params->op->sym->m_dst = ut_params->obuf;
6780
6781         /* Process crypto operation */
6782         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6783                         ut_params->op), "failed to process sym crypto op");
6784
6785         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6786                         "crypto op processing failed");
6787
6788         plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6789                         ut_params->op->sym->cipher.data.offset);
6790
6791         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6792
6793         /* Validate obuf */
6794         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6795                         plaintext,
6796                         tdata->plaintext.data,
6797                         tdata->plaintext.len,
6798                         "Plaintext data not as expected");
6799
6800         TEST_ASSERT_EQUAL(ut_params->op->status,
6801                         RTE_CRYPTO_OP_STATUS_SUCCESS,
6802                         "Authentication failed");
6803         return 0;
6804 }
6805
6806 static int
6807 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6808 {
6809         return test_authenticated_decryption_oop(&gcm_test_case_5);
6810 }
6811
6812 static int
6813 test_authenticated_encryption_sessionless(
6814                 const struct aead_test_data *tdata)
6815 {
6816         struct crypto_testsuite_params *ts_params = &testsuite_params;
6817         struct crypto_unittest_params *ut_params = &unittest_params;
6818
6819         int retval;
6820         uint8_t *ciphertext, *auth_tag;
6821         uint16_t plaintext_pad_len;
6822         uint8_t key[tdata->key.len + 1];
6823
6824         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6825
6826         /* clear mbuf payload */
6827         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6828                         rte_pktmbuf_tailroom(ut_params->ibuf));
6829
6830         /* Create AEAD operation */
6831         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6832         if (retval < 0)
6833                 return retval;
6834
6835         /* Create GCM xform */
6836         memcpy(key, tdata->key.data, tdata->key.len);
6837         retval = create_aead_xform(ut_params->op,
6838                         tdata->algo,
6839                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
6840                         key, tdata->key.len,
6841                         tdata->aad.len, tdata->auth_tag.len,
6842                         tdata->iv.len);
6843         if (retval < 0)
6844                 return retval;
6845
6846         ut_params->op->sym->m_src = ut_params->ibuf;
6847
6848         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6849                         RTE_CRYPTO_OP_SESSIONLESS,
6850                         "crypto op session type not sessionless");
6851
6852         /* Process crypto operation */
6853         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6854                         ut_params->op), "failed to process sym crypto op");
6855
6856         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6857
6858         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6859                         "crypto op status not success");
6860
6861         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6862
6863         ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6864                         ut_params->op->sym->cipher.data.offset);
6865         auth_tag = ciphertext + plaintext_pad_len;
6866
6867         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6868         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6869
6870         /* Validate obuf */
6871         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6872                         ciphertext,
6873                         tdata->ciphertext.data,
6874                         tdata->ciphertext.len,
6875                         "Ciphertext data not as expected");
6876
6877         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6878                         auth_tag,
6879                         tdata->auth_tag.data,
6880                         tdata->auth_tag.len,
6881                         "Generated auth tag not as expected");
6882
6883         return 0;
6884
6885 }
6886
6887 static int
6888 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6889 {
6890         return test_authenticated_encryption_sessionless(
6891                         &gcm_test_case_5);
6892 }
6893
6894 static int
6895 test_authenticated_decryption_sessionless(
6896                 const struct aead_test_data *tdata)
6897 {
6898         struct crypto_testsuite_params *ts_params = &testsuite_params;
6899         struct crypto_unittest_params *ut_params = &unittest_params;
6900
6901         int retval;
6902         uint8_t *plaintext;
6903         uint8_t key[tdata->key.len + 1];
6904
6905         /* alloc mbuf and set payload */
6906         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6907
6908         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6909                         rte_pktmbuf_tailroom(ut_params->ibuf));
6910
6911         /* Create AEAD operation */
6912         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6913         if (retval < 0)
6914                 return retval;
6915
6916         /* Create AEAD xform */
6917         memcpy(key, tdata->key.data, tdata->key.len);
6918         retval = create_aead_xform(ut_params->op,
6919                         tdata->algo,
6920                         RTE_CRYPTO_AEAD_OP_DECRYPT,
6921                         key, tdata->key.len,
6922                         tdata->aad.len, tdata->auth_tag.len,
6923                         tdata->iv.len);
6924         if (retval < 0)
6925                 return retval;
6926
6927         ut_params->op->sym->m_src = ut_params->ibuf;
6928
6929         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6930                         RTE_CRYPTO_OP_SESSIONLESS,
6931                         "crypto op session type not sessionless");
6932
6933         /* Process crypto operation */
6934         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6935                         ut_params->op), "failed to process sym crypto op");
6936
6937         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6938
6939         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6940                         "crypto op status not success");
6941
6942         plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6943                         ut_params->op->sym->cipher.data.offset);
6944
6945         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6946
6947         /* Validate obuf */
6948         TEST_ASSERT_BUFFERS_ARE_EQUAL(
6949                         plaintext,
6950                         tdata->plaintext.data,
6951                         tdata->plaintext.len,
6952                         "Plaintext data not as expected");
6953
6954         TEST_ASSERT_EQUAL(ut_params->op->status,
6955                         RTE_CRYPTO_OP_STATUS_SUCCESS,
6956                         "Authentication failed");
6957         return 0;
6958 }
6959
6960 static int
6961 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6962 {
6963         return test_authenticated_decryption_sessionless(
6964                         &gcm_test_case_5);
6965 }
6966
6967 static int
6968 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6969 {
6970         return test_authenticated_encryption(&ccm_test_case_128_1);
6971 }
6972
6973 static int
6974 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6975 {
6976         return test_authenticated_encryption(&ccm_test_case_128_2);
6977 }
6978
6979 static int
6980 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6981 {
6982         return test_authenticated_encryption(&ccm_test_case_128_3);
6983 }
6984
6985 static int
6986 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6987 {
6988         return test_authenticated_decryption(&ccm_test_case_128_1);
6989 }
6990
6991 static int
6992 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6993 {
6994         return test_authenticated_decryption(&ccm_test_case_128_2);
6995 }
6996
6997 static int
6998 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6999 {
7000         return test_authenticated_decryption(&ccm_test_case_128_3);
7001 }
7002
7003 static int
7004 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
7005 {
7006         return test_authenticated_encryption(&ccm_test_case_192_1);
7007 }
7008
7009 static int
7010 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
7011 {
7012         return test_authenticated_encryption(&ccm_test_case_192_2);
7013 }
7014
7015 static int
7016 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
7017 {
7018         return test_authenticated_encryption(&ccm_test_case_192_3);
7019 }
7020
7021 static int
7022 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
7023 {
7024         return test_authenticated_decryption(&ccm_test_case_192_1);
7025 }
7026
7027 static int
7028 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
7029 {
7030         return test_authenticated_decryption(&ccm_test_case_192_2);
7031 }
7032
7033 static int
7034 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
7035 {
7036         return test_authenticated_decryption(&ccm_test_case_192_3);
7037 }
7038
7039 static int
7040 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
7041 {
7042         return test_authenticated_encryption(&ccm_test_case_256_1);
7043 }
7044
7045 static int
7046 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
7047 {
7048         return test_authenticated_encryption(&ccm_test_case_256_2);
7049 }
7050
7051 static int
7052 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
7053 {
7054         return test_authenticated_encryption(&ccm_test_case_256_3);
7055 }
7056
7057 static int
7058 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
7059 {
7060         return test_authenticated_decryption(&ccm_test_case_256_1);
7061 }
7062
7063 static int
7064 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
7065 {
7066         return test_authenticated_decryption(&ccm_test_case_256_2);
7067 }
7068
7069 static int
7070 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
7071 {
7072         return test_authenticated_decryption(&ccm_test_case_256_3);
7073 }
7074
7075 static int
7076 test_stats(void)
7077 {
7078         struct crypto_testsuite_params *ts_params = &testsuite_params;
7079         struct rte_cryptodev_stats stats;
7080         struct rte_cryptodev *dev;
7081         cryptodev_stats_get_t temp_pfn;
7082
7083         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7084         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
7085                         &stats) == -ENODEV),
7086                 "rte_cryptodev_stats_get invalid dev failed");
7087         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
7088                 "rte_cryptodev_stats_get invalid Param failed");
7089         dev = &rte_cryptodevs[ts_params->valid_devs[0]];
7090         temp_pfn = dev->dev_ops->stats_get;
7091         dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
7092         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
7093                         == -ENOTSUP),
7094                 "rte_cryptodev_stats_get invalid Param failed");
7095         dev->dev_ops->stats_get = temp_pfn;
7096
7097         /* Test expected values */
7098         ut_setup();
7099         test_AES_CBC_HMAC_SHA1_encrypt_digest();
7100         ut_teardown();
7101         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7102                         &stats),
7103                 "rte_cryptodev_stats_get failed");
7104         TEST_ASSERT((stats.enqueued_count == 1),
7105                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7106         TEST_ASSERT((stats.dequeued_count == 1),
7107                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7108         TEST_ASSERT((stats.enqueue_err_count == 0),
7109                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7110         TEST_ASSERT((stats.dequeue_err_count == 0),
7111                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7112
7113         /* invalid device but should ignore and not reset device stats*/
7114         rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
7115         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7116                         &stats),
7117                 "rte_cryptodev_stats_get failed");
7118         TEST_ASSERT((stats.enqueued_count == 1),
7119                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7120
7121         /* check that a valid reset clears stats */
7122         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
7123         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
7124                         &stats),
7125                                           "rte_cryptodev_stats_get failed");
7126         TEST_ASSERT((stats.enqueued_count == 0),
7127                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7128         TEST_ASSERT((stats.dequeued_count == 0),
7129                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
7130
7131         return TEST_SUCCESS;
7132 }
7133
7134 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
7135                                    struct crypto_unittest_params *ut_params,
7136                                    enum rte_crypto_auth_operation op,
7137                                    const struct HMAC_MD5_vector *test_case)
7138 {
7139         uint8_t key[64];
7140
7141         memcpy(key, test_case->key.data, test_case->key.len);
7142
7143         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7144         ut_params->auth_xform.next = NULL;
7145         ut_params->auth_xform.auth.op = op;
7146
7147         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
7148
7149         ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
7150         ut_params->auth_xform.auth.key.length = test_case->key.len;
7151         ut_params->auth_xform.auth.key.data = key;
7152
7153         ut_params->sess = rte_cryptodev_sym_session_create(
7154                         ts_params->session_mpool);
7155
7156         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7157                         ut_params->sess, &ut_params->auth_xform,
7158                         ts_params->session_priv_mpool);
7159
7160         if (ut_params->sess == NULL)
7161                 return TEST_FAILED;
7162
7163         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7164
7165         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7166                         rte_pktmbuf_tailroom(ut_params->ibuf));
7167
7168         return 0;
7169 }
7170
7171 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
7172                               const struct HMAC_MD5_vector *test_case,
7173                               uint8_t **plaintext)
7174 {
7175         uint16_t plaintext_pad_len;
7176
7177         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7178
7179         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7180                                 16);
7181
7182         *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7183                         plaintext_pad_len);
7184         memcpy(*plaintext, test_case->plaintext.data,
7185                         test_case->plaintext.len);
7186
7187         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7188                         ut_params->ibuf, MD5_DIGEST_LEN);
7189         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7190                         "no room to append digest");
7191         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7192                         ut_params->ibuf, plaintext_pad_len);
7193
7194         if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7195                 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
7196                            test_case->auth_tag.len);
7197         }
7198
7199         sym_op->auth.data.offset = 0;
7200         sym_op->auth.data.length = test_case->plaintext.len;
7201
7202         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7203         ut_params->op->sym->m_src = ut_params->ibuf;
7204
7205         return 0;
7206 }
7207
7208 static int
7209 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
7210 {
7211         uint16_t plaintext_pad_len;
7212         uint8_t *plaintext, *auth_tag;
7213
7214         struct crypto_testsuite_params *ts_params = &testsuite_params;
7215         struct crypto_unittest_params *ut_params = &unittest_params;
7216
7217         if (MD5_HMAC_create_session(ts_params, ut_params,
7218                         RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
7219                 return TEST_FAILED;
7220
7221         /* Generate Crypto op data structure */
7222         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7223                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7224         TEST_ASSERT_NOT_NULL(ut_params->op,
7225                         "Failed to allocate symmetric crypto operation struct");
7226
7227         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
7228                                 16);
7229
7230         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7231                 return TEST_FAILED;
7232
7233         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7234                         ut_params->op), "failed to process sym crypto op");
7235
7236         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7237                         "crypto op processing failed");
7238
7239         if (ut_params->op->sym->m_dst) {
7240                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7241                                 uint8_t *, plaintext_pad_len);
7242         } else {
7243                 auth_tag = plaintext + plaintext_pad_len;
7244         }
7245
7246         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7247                         auth_tag,
7248                         test_case->auth_tag.data,
7249                         test_case->auth_tag.len,
7250                         "HMAC_MD5 generated tag not as expected");
7251
7252         return TEST_SUCCESS;
7253 }
7254
7255 static int
7256 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
7257 {
7258         uint8_t *plaintext;
7259
7260         struct crypto_testsuite_params *ts_params = &testsuite_params;
7261         struct crypto_unittest_params *ut_params = &unittest_params;
7262
7263         if (MD5_HMAC_create_session(ts_params, ut_params,
7264                         RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
7265                 return TEST_FAILED;
7266         }
7267
7268         /* Generate Crypto op data structure */
7269         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7270                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7271         TEST_ASSERT_NOT_NULL(ut_params->op,
7272                         "Failed to allocate symmetric crypto operation struct");
7273
7274         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
7275                 return TEST_FAILED;
7276
7277         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7278                         ut_params->op), "failed to process sym crypto op");
7279
7280         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7281                         "HMAC_MD5 crypto op processing failed");
7282
7283         return TEST_SUCCESS;
7284 }
7285
7286 static int
7287 test_MD5_HMAC_generate_case_1(void)
7288 {
7289         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
7290 }
7291
7292 static int
7293 test_MD5_HMAC_verify_case_1(void)
7294 {
7295         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
7296 }
7297
7298 static int
7299 test_MD5_HMAC_generate_case_2(void)
7300 {
7301         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
7302 }
7303
7304 static int
7305 test_MD5_HMAC_verify_case_2(void)
7306 {
7307         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
7308 }
7309
7310 static int
7311 test_multi_session(void)
7312 {
7313         struct crypto_testsuite_params *ts_params = &testsuite_params;
7314         struct crypto_unittest_params *ut_params = &unittest_params;
7315
7316         struct rte_cryptodev_info dev_info;
7317         struct rte_cryptodev_sym_session **sessions;
7318
7319         uint16_t i;
7320
7321         test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
7322                         aes_cbc_key, hmac_sha512_key);
7323
7324
7325         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7326
7327         sessions = rte_malloc(NULL,
7328                         (sizeof(struct rte_cryptodev_sym_session *) *
7329                         MAX_NB_SESSIONS) + 1, 0);
7330
7331         /* Create multiple crypto sessions*/
7332         for (i = 0; i < MAX_NB_SESSIONS; i++) {
7333
7334                 sessions[i] = rte_cryptodev_sym_session_create(
7335                                 ts_params->session_mpool);
7336
7337                 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7338                                 sessions[i], &ut_params->auth_xform,
7339                                 ts_params->session_priv_mpool);
7340                 TEST_ASSERT_NOT_NULL(sessions[i],
7341                                 "Session creation failed at session number %u",
7342                                 i);
7343
7344                 /* Attempt to send a request on each session */
7345                 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
7346                         sessions[i],
7347                         ut_params,
7348                         ts_params,
7349                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
7350                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
7351                         aes_cbc_iv),
7352                         "Failed to perform decrypt on request number %u.", i);
7353                 /* free crypto operation structure */
7354                 if (ut_params->op)
7355                         rte_crypto_op_free(ut_params->op);
7356
7357                 /*
7358                  * free mbuf - both obuf and ibuf are usually the same,
7359                  * so check if they point at the same address is necessary,
7360                  * to avoid freeing the mbuf twice.
7361                  */
7362                 if (ut_params->obuf) {
7363                         rte_pktmbuf_free(ut_params->obuf);
7364                         if (ut_params->ibuf == ut_params->obuf)
7365                                 ut_params->ibuf = 0;
7366                         ut_params->obuf = 0;
7367                 }
7368                 if (ut_params->ibuf) {
7369                         rte_pktmbuf_free(ut_params->ibuf);
7370                         ut_params->ibuf = 0;
7371                 }
7372         }
7373
7374         /* Next session create should fail */
7375         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7376                         sessions[i], &ut_params->auth_xform,
7377                         ts_params->session_priv_mpool);
7378         TEST_ASSERT_NULL(sessions[i],
7379                         "Session creation succeeded unexpectedly!");
7380
7381         for (i = 0; i < MAX_NB_SESSIONS; i++) {
7382                 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
7383                                 sessions[i]);
7384                 rte_cryptodev_sym_session_free(sessions[i]);
7385         }
7386
7387         rte_free(sessions);
7388
7389         return TEST_SUCCESS;
7390 }
7391
7392 struct multi_session_params {
7393         struct crypto_unittest_params ut_params;
7394         uint8_t *cipher_key;
7395         uint8_t *hmac_key;
7396         const uint8_t *cipher;
7397         const uint8_t *digest;
7398         uint8_t *iv;
7399 };
7400
7401 #define MB_SESSION_NUMBER 3
7402
7403 static int
7404 test_multi_session_random_usage(void)
7405 {
7406         struct crypto_testsuite_params *ts_params = &testsuite_params;
7407         struct rte_cryptodev_info dev_info;
7408         struct rte_cryptodev_sym_session **sessions;
7409         uint32_t i, j;
7410         struct multi_session_params ut_paramz[] = {
7411
7412                 {
7413                         .cipher_key = ms_aes_cbc_key0,
7414                         .hmac_key = ms_hmac_key0,
7415                         .cipher = ms_aes_cbc_cipher0,
7416                         .digest = ms_hmac_digest0,
7417                         .iv = ms_aes_cbc_iv0
7418                 },
7419                 {
7420                         .cipher_key = ms_aes_cbc_key1,
7421                         .hmac_key = ms_hmac_key1,
7422                         .cipher = ms_aes_cbc_cipher1,
7423                         .digest = ms_hmac_digest1,
7424                         .iv = ms_aes_cbc_iv1
7425                 },
7426                 {
7427                         .cipher_key = ms_aes_cbc_key2,
7428                         .hmac_key = ms_hmac_key2,
7429                         .cipher = ms_aes_cbc_cipher2,
7430                         .digest = ms_hmac_digest2,
7431                         .iv = ms_aes_cbc_iv2
7432                 },
7433
7434         };
7435
7436         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
7437
7438         sessions = rte_malloc(NULL,
7439                         (sizeof(struct rte_cryptodev_sym_session *)
7440                                         * MAX_NB_SESSIONS) + 1, 0);
7441
7442         for (i = 0; i < MB_SESSION_NUMBER; i++) {
7443                 sessions[i] = rte_cryptodev_sym_session_create(
7444                                 ts_params->session_mpool);
7445
7446                 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
7447                                 sizeof(struct crypto_unittest_params));
7448
7449                 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
7450                                 &ut_paramz[i].ut_params,
7451                                 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
7452
7453                 /* Create multiple crypto sessions*/
7454                 rte_cryptodev_sym_session_init(
7455                                 ts_params->valid_devs[0],
7456                                 sessions[i],
7457                                 &ut_paramz[i].ut_params.auth_xform,
7458                                 ts_params->session_priv_mpool);
7459
7460                 TEST_ASSERT_NOT_NULL(sessions[i],
7461                                 "Session creation failed at session number %u",
7462                                 i);
7463
7464         }
7465
7466         srand(time(NULL));
7467         for (i = 0; i < 40000; i++) {
7468
7469                 j = rand() % MB_SESSION_NUMBER;
7470
7471                 TEST_ASSERT_SUCCESS(
7472                         test_AES_CBC_HMAC_SHA512_decrypt_perform(
7473                                         sessions[j],
7474                                         &ut_paramz[j].ut_params,
7475                                         ts_params, ut_paramz[j].cipher,
7476                                         ut_paramz[j].digest,
7477                                         ut_paramz[j].iv),
7478                         "Failed to perform decrypt on request number %u.", i);
7479
7480                 if (ut_paramz[j].ut_params.op)
7481                         rte_crypto_op_free(ut_paramz[j].ut_params.op);
7482
7483                 /*
7484                  * free mbuf - both obuf and ibuf are usually the same,
7485                  * so check if they point at the same address is necessary,
7486                  * to avoid freeing the mbuf twice.
7487                  */
7488                 if (ut_paramz[j].ut_params.obuf) {
7489                         rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
7490                         if (ut_paramz[j].ut_params.ibuf
7491                                         == ut_paramz[j].ut_params.obuf)
7492                                 ut_paramz[j].ut_params.ibuf = 0;
7493                         ut_paramz[j].ut_params.obuf = 0;
7494                 }
7495                 if (ut_paramz[j].ut_params.ibuf) {
7496                         rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
7497                         ut_paramz[j].ut_params.ibuf = 0;
7498                 }
7499         }
7500
7501         for (i = 0; i < MB_SESSION_NUMBER; i++) {
7502                 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
7503                                 sessions[i]);
7504                 rte_cryptodev_sym_session_free(sessions[i]);
7505         }
7506
7507         rte_free(sessions);
7508
7509         return TEST_SUCCESS;
7510 }
7511
7512 static int
7513 test_null_cipher_only_operation(void)
7514 {
7515         struct crypto_testsuite_params *ts_params = &testsuite_params;
7516         struct crypto_unittest_params *ut_params = &unittest_params;
7517
7518         /* Generate test mbuf data and space for digest */
7519         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7520                         catch_22_quote, QUOTE_512_BYTES, 0);
7521
7522         /* Setup Cipher Parameters */
7523         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7524         ut_params->cipher_xform.next = NULL;
7525
7526         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7527         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7528
7529         ut_params->sess = rte_cryptodev_sym_session_create(
7530                         ts_params->session_mpool);
7531
7532         /* Create Crypto session*/
7533         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7534                                 ut_params->sess,
7535                                 &ut_params->cipher_xform,
7536                                 ts_params->session_priv_mpool);
7537         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7538
7539         /* Generate Crypto op data structure */
7540         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7541                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7542         TEST_ASSERT_NOT_NULL(ut_params->op,
7543                         "Failed to allocate symmetric crypto operation struct");
7544
7545         /* Set crypto operation data parameters */
7546         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7547
7548         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7549
7550         /* set crypto operation source mbuf */
7551         sym_op->m_src = ut_params->ibuf;
7552
7553         sym_op->cipher.data.offset = 0;
7554         sym_op->cipher.data.length = QUOTE_512_BYTES;
7555
7556         /* Process crypto operation */
7557         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7558                         ut_params->op);
7559         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7560
7561         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7562                         "crypto operation processing failed");
7563
7564         /* Validate obuf */
7565         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7566                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7567                         catch_22_quote,
7568                         QUOTE_512_BYTES,
7569                         "Ciphertext data not as expected");
7570
7571         return TEST_SUCCESS;
7572 }
7573 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
7574                         0xab, 0xab, 0xab, 0xab,
7575                         0xab, 0xab, 0xab, 0xab,
7576                         0xab, 0xab, 0xab, 0xab};
7577 static int
7578 test_null_auth_only_operation(void)
7579 {
7580         struct crypto_testsuite_params *ts_params = &testsuite_params;
7581         struct crypto_unittest_params *ut_params = &unittest_params;
7582         uint8_t *digest;
7583
7584         /* Generate test mbuf data and space for digest */
7585         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7586                         catch_22_quote, QUOTE_512_BYTES, 0);
7587
7588         /* create a pointer for digest, but don't expect anything to be written
7589          * here in a NULL auth algo so no mbuf append done.
7590          */
7591         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7592                         QUOTE_512_BYTES);
7593         /* prefill the memory pointed to by digest */
7594         memcpy(digest, orig_data, sizeof(orig_data));
7595
7596         /* Setup HMAC Parameters */
7597         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7598         ut_params->auth_xform.next = NULL;
7599
7600         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7601         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7602
7603         ut_params->sess = rte_cryptodev_sym_session_create(
7604                         ts_params->session_mpool);
7605
7606         /* Create Crypto session*/
7607         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7608                         ut_params->sess, &ut_params->auth_xform,
7609                         ts_params->session_priv_mpool);
7610         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7611
7612         /* Generate Crypto op data structure */
7613         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7614                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7615         TEST_ASSERT_NOT_NULL(ut_params->op,
7616                         "Failed to allocate symmetric crypto operation struct");
7617
7618         /* Set crypto operation data parameters */
7619         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7620
7621         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7622
7623         sym_op->m_src = ut_params->ibuf;
7624
7625         sym_op->auth.data.offset = 0;
7626         sym_op->auth.data.length = QUOTE_512_BYTES;
7627         sym_op->auth.digest.data = digest;
7628         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7629                         QUOTE_512_BYTES);
7630
7631         /* Process crypto operation */
7632         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7633                         ut_params->op);
7634         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7635
7636         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7637                         "crypto operation processing failed");
7638         /* Make sure memory pointed to by digest hasn't been overwritten */
7639         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7640                         orig_data,
7641                         digest,
7642                         sizeof(orig_data),
7643                         "Memory at digest ptr overwritten unexpectedly");
7644
7645         return TEST_SUCCESS;
7646 }
7647
7648
7649 static int
7650 test_null_cipher_auth_operation(void)
7651 {
7652         struct crypto_testsuite_params *ts_params = &testsuite_params;
7653         struct crypto_unittest_params *ut_params = &unittest_params;
7654         uint8_t *digest;
7655
7656         /* Generate test mbuf data and space for digest */
7657         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7658                         catch_22_quote, QUOTE_512_BYTES, 0);
7659
7660         /* create a pointer for digest, but don't expect anything to be written
7661          * here in a NULL auth algo so no mbuf append done.
7662          */
7663         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7664                         QUOTE_512_BYTES);
7665         /* prefill the memory pointed to by digest */
7666         memcpy(digest, orig_data, sizeof(orig_data));
7667
7668         /* Setup Cipher Parameters */
7669         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7670         ut_params->cipher_xform.next = &ut_params->auth_xform;
7671
7672         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7673         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7674
7675         /* Setup HMAC Parameters */
7676         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7677         ut_params->auth_xform.next = NULL;
7678
7679         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7680         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7681
7682         ut_params->sess = rte_cryptodev_sym_session_create(
7683                         ts_params->session_mpool);
7684
7685         /* Create Crypto session*/
7686         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7687                         ut_params->sess, &ut_params->cipher_xform,
7688                         ts_params->session_priv_mpool);
7689         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7690
7691         /* Generate Crypto op data structure */
7692         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7693                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7694         TEST_ASSERT_NOT_NULL(ut_params->op,
7695                         "Failed to allocate symmetric crypto operation struct");
7696
7697         /* Set crypto operation data parameters */
7698         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7699
7700         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7701
7702         sym_op->m_src = ut_params->ibuf;
7703
7704         sym_op->cipher.data.offset = 0;
7705         sym_op->cipher.data.length = QUOTE_512_BYTES;
7706
7707         sym_op->auth.data.offset = 0;
7708         sym_op->auth.data.length = QUOTE_512_BYTES;
7709         sym_op->auth.digest.data = digest;
7710         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7711                         QUOTE_512_BYTES);
7712
7713         /* Process crypto operation */
7714         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7715                         ut_params->op);
7716         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7717
7718         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7719                         "crypto operation processing failed");
7720
7721         /* Validate obuf */
7722         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7723                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7724                         catch_22_quote,
7725                         QUOTE_512_BYTES,
7726                         "Ciphertext data not as expected");
7727         /* Make sure memory pointed to by digest hasn't been overwritten */
7728         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7729                         orig_data,
7730                         digest,
7731                         sizeof(orig_data),
7732                         "Memory at digest ptr overwritten unexpectedly");
7733
7734         return TEST_SUCCESS;
7735 }
7736
7737 static int
7738 test_null_auth_cipher_operation(void)
7739 {
7740         struct crypto_testsuite_params *ts_params = &testsuite_params;
7741         struct crypto_unittest_params *ut_params = &unittest_params;
7742         uint8_t *digest;
7743
7744         /* Generate test mbuf data */
7745         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7746                         catch_22_quote, QUOTE_512_BYTES, 0);
7747
7748         /* create a pointer for digest, but don't expect anything to be written
7749          * here in a NULL auth algo so no mbuf append done.
7750          */
7751         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7752                                 QUOTE_512_BYTES);
7753         /* prefill the memory pointed to by digest */
7754         memcpy(digest, orig_data, sizeof(orig_data));
7755
7756         /* Setup Cipher Parameters */
7757         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7758         ut_params->cipher_xform.next = NULL;
7759
7760         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7761         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7762
7763         /* Setup HMAC Parameters */
7764         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7765         ut_params->auth_xform.next = &ut_params->cipher_xform;
7766
7767         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7768         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7769
7770         ut_params->sess = rte_cryptodev_sym_session_create(
7771                         ts_params->session_mpool);
7772
7773         /* Create Crypto session*/
7774         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7775                         ut_params->sess, &ut_params->cipher_xform,
7776                         ts_params->session_priv_mpool);
7777         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7778
7779         /* Generate Crypto op data structure */
7780         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7781                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7782         TEST_ASSERT_NOT_NULL(ut_params->op,
7783                         "Failed to allocate symmetric crypto operation struct");
7784
7785         /* Set crypto operation data parameters */
7786         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7787
7788         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7789
7790         sym_op->m_src = ut_params->ibuf;
7791
7792         sym_op->cipher.data.offset = 0;
7793         sym_op->cipher.data.length = QUOTE_512_BYTES;
7794
7795         sym_op->auth.data.offset = 0;
7796         sym_op->auth.data.length = QUOTE_512_BYTES;
7797         sym_op->auth.digest.data = digest;
7798         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7799                                         QUOTE_512_BYTES);
7800
7801         /* Process crypto operation */
7802         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7803                         ut_params->op);
7804         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7805
7806         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7807                         "crypto operation processing failed");
7808
7809         /* Validate obuf */
7810         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7811                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7812                         catch_22_quote,
7813                         QUOTE_512_BYTES,
7814                         "Ciphertext data not as expected");
7815         /* Make sure memory pointed to by digest hasn't been overwritten */
7816         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7817                         orig_data,
7818                         digest,
7819                         sizeof(orig_data),
7820                         "Memory at digest ptr overwritten unexpectedly");
7821
7822         return TEST_SUCCESS;
7823 }
7824
7825
7826 static int
7827 test_null_invalid_operation(void)
7828 {
7829         struct crypto_testsuite_params *ts_params = &testsuite_params;
7830         struct crypto_unittest_params *ut_params = &unittest_params;
7831         int ret;
7832
7833         /* Setup Cipher Parameters */
7834         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7835         ut_params->cipher_xform.next = NULL;
7836
7837         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7838         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7839
7840         ut_params->sess = rte_cryptodev_sym_session_create(
7841                         ts_params->session_mpool);
7842
7843         /* Create Crypto session*/
7844         ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7845                         ut_params->sess, &ut_params->cipher_xform,
7846                         ts_params->session_priv_mpool);
7847         TEST_ASSERT(ret < 0,
7848                         "Session creation succeeded unexpectedly");
7849
7850
7851         /* Setup HMAC Parameters */
7852         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7853         ut_params->auth_xform.next = NULL;
7854
7855         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7856         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7857
7858         ut_params->sess = rte_cryptodev_sym_session_create(
7859                         ts_params->session_mpool);
7860
7861         /* Create Crypto session*/
7862         ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7863                         ut_params->sess, &ut_params->auth_xform,
7864                         ts_params->session_priv_mpool);
7865         TEST_ASSERT(ret < 0,
7866                         "Session creation succeeded unexpectedly");
7867
7868         return TEST_SUCCESS;
7869 }
7870
7871
7872 #define NULL_BURST_LENGTH (32)
7873
7874 static int
7875 test_null_burst_operation(void)
7876 {
7877         struct crypto_testsuite_params *ts_params = &testsuite_params;
7878         struct crypto_unittest_params *ut_params = &unittest_params;
7879
7880         unsigned i, burst_len = NULL_BURST_LENGTH;
7881
7882         struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7883         struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7884
7885         /* Setup Cipher Parameters */
7886         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7887         ut_params->cipher_xform.next = &ut_params->auth_xform;
7888
7889         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7890         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7891
7892         /* Setup HMAC Parameters */
7893         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7894         ut_params->auth_xform.next = NULL;
7895
7896         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7897         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7898
7899         ut_params->sess = rte_cryptodev_sym_session_create(
7900                         ts_params->session_mpool);
7901
7902         /* Create Crypto session*/
7903         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7904                         ut_params->sess, &ut_params->cipher_xform,
7905                         ts_params->session_priv_mpool);
7906         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7907
7908         TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7909                         RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7910                         burst_len, "failed to generate burst of crypto ops");
7911
7912         /* Generate an operation for each mbuf in burst */
7913         for (i = 0; i < burst_len; i++) {
7914                 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7915
7916                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7917
7918                 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7919                                 sizeof(unsigned));
7920                 *data = i;
7921
7922                 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7923
7924                 burst[i]->sym->m_src = m;
7925         }
7926
7927         /* Process crypto operation */
7928         TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7929                         0, burst, burst_len),
7930                         burst_len,
7931                         "Error enqueuing burst");
7932
7933         TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7934                         0, burst_dequeued, burst_len),
7935                         burst_len,
7936                         "Error dequeuing burst");
7937
7938
7939         for (i = 0; i < burst_len; i++) {
7940                 TEST_ASSERT_EQUAL(
7941                         *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7942                         *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7943                                         uint32_t *),
7944                         "data not as expected");
7945
7946                 rte_pktmbuf_free(burst[i]->sym->m_src);
7947                 rte_crypto_op_free(burst[i]);
7948         }
7949
7950         return TEST_SUCCESS;
7951 }
7952
7953 static void
7954 generate_gmac_large_plaintext(uint8_t *data)
7955 {
7956         uint16_t i;
7957
7958         for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7959                 memcpy(&data[i], &data[0], 32);
7960 }
7961
7962 static int
7963 create_gmac_operation(enum rte_crypto_auth_operation op,
7964                 const struct gmac_test_data *tdata)
7965 {
7966         struct crypto_testsuite_params *ts_params = &testsuite_params;
7967         struct crypto_unittest_params *ut_params = &unittest_params;
7968         struct rte_crypto_sym_op *sym_op;
7969
7970         uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7971
7972         /* Generate Crypto op data structure */
7973         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7974                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7975         TEST_ASSERT_NOT_NULL(ut_params->op,
7976                         "Failed to allocate symmetric crypto operation struct");
7977
7978         sym_op = ut_params->op->sym;
7979
7980         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7981                         ut_params->ibuf, tdata->gmac_tag.len);
7982         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7983                         "no room to append digest");
7984
7985         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7986                         ut_params->ibuf, plaintext_pad_len);
7987
7988         if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7989                 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7990                                 tdata->gmac_tag.len);
7991                 debug_hexdump(stdout, "digest:",
7992                                 sym_op->auth.digest.data,
7993                                 tdata->gmac_tag.len);
7994         }
7995
7996         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7997                         uint8_t *, IV_OFFSET);
7998
7999         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
8000
8001         debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
8002
8003         sym_op->cipher.data.length = 0;
8004         sym_op->cipher.data.offset = 0;
8005
8006         sym_op->auth.data.offset = 0;
8007         sym_op->auth.data.length = tdata->plaintext.len;
8008
8009         return 0;
8010 }
8011
8012 static int create_gmac_session(uint8_t dev_id,
8013                 const struct gmac_test_data *tdata,
8014                 enum rte_crypto_auth_operation auth_op)
8015 {
8016         uint8_t auth_key[tdata->key.len];
8017
8018         struct crypto_testsuite_params *ts_params = &testsuite_params;
8019         struct crypto_unittest_params *ut_params = &unittest_params;
8020
8021         memcpy(auth_key, tdata->key.data, tdata->key.len);
8022
8023         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8024         ut_params->auth_xform.next = NULL;
8025
8026         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
8027         ut_params->auth_xform.auth.op = auth_op;
8028         ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
8029         ut_params->auth_xform.auth.key.length = tdata->key.len;
8030         ut_params->auth_xform.auth.key.data = auth_key;
8031         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8032         ut_params->auth_xform.auth.iv.length = tdata->iv.len;
8033
8034
8035         ut_params->sess = rte_cryptodev_sym_session_create(
8036                         ts_params->session_mpool);
8037
8038         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8039                         &ut_params->auth_xform,
8040                         ts_params->session_priv_mpool);
8041
8042         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8043
8044         return 0;
8045 }
8046
8047 static int
8048 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
8049 {
8050         struct crypto_testsuite_params *ts_params = &testsuite_params;
8051         struct crypto_unittest_params *ut_params = &unittest_params;
8052
8053         int retval;
8054
8055         uint8_t *auth_tag, *plaintext;
8056         uint16_t plaintext_pad_len;
8057
8058         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8059                               "No GMAC length in the source data");
8060
8061         retval = create_gmac_session(ts_params->valid_devs[0],
8062                         tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
8063
8064         if (retval < 0)
8065                 return retval;
8066
8067         if (tdata->plaintext.len > MBUF_SIZE)
8068                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8069         else
8070                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8071         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8072                         "Failed to allocate input buffer in mempool");
8073
8074         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8075                         rte_pktmbuf_tailroom(ut_params->ibuf));
8076
8077         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8078         /*
8079          * Runtime generate the large plain text instead of use hard code
8080          * plain text vector. It is done to avoid create huge source file
8081          * with the test vector.
8082          */
8083         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8084                 generate_gmac_large_plaintext(tdata->plaintext.data);
8085
8086         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8087                                 plaintext_pad_len);
8088         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8089
8090         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8091         debug_hexdump(stdout, "plaintext:", plaintext,
8092                         tdata->plaintext.len);
8093
8094         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
8095                         tdata);
8096
8097         if (retval < 0)
8098                 return retval;
8099
8100         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8101
8102         ut_params->op->sym->m_src = ut_params->ibuf;
8103
8104         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8105                         ut_params->op), "failed to process sym crypto op");
8106
8107         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8108                         "crypto op processing failed");
8109
8110         if (ut_params->op->sym->m_dst) {
8111                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8112                                 uint8_t *, plaintext_pad_len);
8113         } else {
8114                 auth_tag = plaintext + plaintext_pad_len;
8115         }
8116
8117         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
8118
8119         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8120                         auth_tag,
8121                         tdata->gmac_tag.data,
8122                         tdata->gmac_tag.len,
8123                         "GMAC Generated auth tag not as expected");
8124
8125         return 0;
8126 }
8127
8128 static int
8129 test_AES_GMAC_authentication_test_case_1(void)
8130 {
8131         return test_AES_GMAC_authentication(&gmac_test_case_1);
8132 }
8133
8134 static int
8135 test_AES_GMAC_authentication_test_case_2(void)
8136 {
8137         return test_AES_GMAC_authentication(&gmac_test_case_2);
8138 }
8139
8140 static int
8141 test_AES_GMAC_authentication_test_case_3(void)
8142 {
8143         return test_AES_GMAC_authentication(&gmac_test_case_3);
8144 }
8145
8146 static int
8147 test_AES_GMAC_authentication_test_case_4(void)
8148 {
8149         return test_AES_GMAC_authentication(&gmac_test_case_4);
8150 }
8151
8152 static int
8153 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
8154 {
8155         struct crypto_testsuite_params *ts_params = &testsuite_params;
8156         struct crypto_unittest_params *ut_params = &unittest_params;
8157         int retval;
8158         uint32_t plaintext_pad_len;
8159         uint8_t *plaintext;
8160
8161         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
8162                               "No GMAC length in the source data");
8163
8164         retval = create_gmac_session(ts_params->valid_devs[0],
8165                         tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
8166
8167         if (retval < 0)
8168                 return retval;
8169
8170         if (tdata->plaintext.len > MBUF_SIZE)
8171                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8172         else
8173                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8174         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8175                         "Failed to allocate input buffer in mempool");
8176
8177         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8178                         rte_pktmbuf_tailroom(ut_params->ibuf));
8179
8180         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8181
8182         /*
8183          * Runtime generate the large plain text instead of use hard code
8184          * plain text vector. It is done to avoid create huge source file
8185          * with the test vector.
8186          */
8187         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
8188                 generate_gmac_large_plaintext(tdata->plaintext.data);
8189
8190         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8191                                 plaintext_pad_len);
8192         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8193
8194         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
8195         debug_hexdump(stdout, "plaintext:", plaintext,
8196                         tdata->plaintext.len);
8197
8198         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
8199                         tdata);
8200
8201         if (retval < 0)
8202                 return retval;
8203
8204         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8205
8206         ut_params->op->sym->m_src = ut_params->ibuf;
8207
8208         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8209                         ut_params->op), "failed to process sym crypto op");
8210
8211         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8212                         "crypto op processing failed");
8213
8214         return 0;
8215
8216 }
8217
8218 static int
8219 test_AES_GMAC_authentication_verify_test_case_1(void)
8220 {
8221         return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
8222 }
8223
8224 static int
8225 test_AES_GMAC_authentication_verify_test_case_2(void)
8226 {
8227         return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
8228 }
8229
8230 static int
8231 test_AES_GMAC_authentication_verify_test_case_3(void)
8232 {
8233         return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
8234 }
8235
8236 static int
8237 test_AES_GMAC_authentication_verify_test_case_4(void)
8238 {
8239         return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
8240 }
8241
8242 struct test_crypto_vector {
8243         enum rte_crypto_cipher_algorithm crypto_algo;
8244
8245         struct {
8246                 uint8_t data[64];
8247                 unsigned int len;
8248         } cipher_key;
8249
8250         struct {
8251                 uint8_t data[64];
8252                 unsigned int len;
8253         } iv;
8254
8255         struct {
8256                 const uint8_t *data;
8257                 unsigned int len;
8258         } plaintext;
8259
8260         struct {
8261                 const uint8_t *data;
8262                 unsigned int len;
8263         } ciphertext;
8264
8265         enum rte_crypto_auth_algorithm auth_algo;
8266
8267         struct {
8268                 uint8_t data[128];
8269                 unsigned int len;
8270         } auth_key;
8271
8272         struct {
8273                 const uint8_t *data;
8274                 unsigned int len;
8275         } aad;
8276
8277         struct {
8278                 uint8_t data[128];
8279                 unsigned int len;
8280         } digest;
8281 };
8282
8283 static const struct test_crypto_vector
8284 hmac_sha1_test_crypto_vector = {
8285         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8286         .plaintext = {
8287                 .data = plaintext_hash,
8288                 .len = 512
8289         },
8290         .auth_key = {
8291                 .data = {
8292                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8293                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
8294                         0xDE, 0xF4, 0xDE, 0xAD
8295                 },
8296                 .len = 20
8297         },
8298         .digest = {
8299                 .data = {
8300                         0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
8301                         0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
8302                         0x3F, 0x91, 0x64, 0x59
8303                 },
8304                 .len = 20
8305         }
8306 };
8307
8308 static const struct test_crypto_vector
8309 aes128_gmac_test_vector = {
8310         .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
8311         .plaintext = {
8312                 .data = plaintext_hash,
8313                 .len = 512
8314         },
8315         .iv = {
8316                 .data = {
8317                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
8318                         0x08, 0x09, 0x0A, 0x0B
8319                 },
8320                 .len = 12
8321         },
8322         .auth_key = {
8323                 .data = {
8324                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
8325                         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
8326                 },
8327                 .len = 16
8328         },
8329         .digest = {
8330                 .data = {
8331                         0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
8332                         0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
8333                 },
8334                 .len = 16
8335         }
8336 };
8337
8338 static const struct test_crypto_vector
8339 aes128cbc_hmac_sha1_test_vector = {
8340         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
8341         .cipher_key = {
8342                 .data = {
8343                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
8344                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
8345                 },
8346                 .len = 16
8347         },
8348         .iv = {
8349                 .data = {
8350                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
8351                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
8352                 },
8353                 .len = 16
8354         },
8355         .plaintext = {
8356                 .data = plaintext_hash,
8357                 .len = 512
8358         },
8359         .ciphertext = {
8360                 .data = ciphertext512_aes128cbc,
8361                 .len = 512
8362         },
8363         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
8364         .auth_key = {
8365                 .data = {
8366                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
8367                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
8368                         0xDE, 0xF4, 0xDE, 0xAD
8369                 },
8370                 .len = 20
8371         },
8372         .digest = {
8373                 .data = {
8374                         0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
8375                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
8376                         0x18, 0x8C, 0x1D, 0x32
8377                 },
8378                 .len = 20
8379         }
8380 };
8381
8382 static void
8383 data_corruption(uint8_t *data)
8384 {
8385         data[0] += 1;
8386 }
8387
8388 static void
8389 tag_corruption(uint8_t *data, unsigned int tag_offset)
8390 {
8391         data[tag_offset] += 1;
8392 }
8393
8394 static int
8395 create_auth_session(struct crypto_unittest_params *ut_params,
8396                 uint8_t dev_id,
8397                 const struct test_crypto_vector *reference,
8398                 enum rte_crypto_auth_operation auth_op)
8399 {
8400         struct crypto_testsuite_params *ts_params = &testsuite_params;
8401         uint8_t auth_key[reference->auth_key.len + 1];
8402
8403         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
8404
8405         /* Setup Authentication Parameters */
8406         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8407         ut_params->auth_xform.auth.op = auth_op;
8408         ut_params->auth_xform.next = NULL;
8409         ut_params->auth_xform.auth.algo = reference->auth_algo;
8410         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
8411         ut_params->auth_xform.auth.key.data = auth_key;
8412         ut_params->auth_xform.auth.digest_length = reference->digest.len;
8413
8414         /* Create Crypto session*/
8415         ut_params->sess = rte_cryptodev_sym_session_create(
8416                         ts_params->session_mpool);
8417
8418         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8419                                 &ut_params->auth_xform,
8420                                 ts_params->session_priv_mpool);
8421
8422         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8423
8424         return 0;
8425 }
8426
8427 static int
8428 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
8429                 uint8_t dev_id,
8430                 const struct test_crypto_vector *reference,
8431                 enum rte_crypto_auth_operation auth_op,
8432                 enum rte_crypto_cipher_operation cipher_op)
8433 {
8434         struct crypto_testsuite_params *ts_params = &testsuite_params;
8435         uint8_t cipher_key[reference->cipher_key.len + 1];
8436         uint8_t auth_key[reference->auth_key.len + 1];
8437
8438         memcpy(cipher_key, reference->cipher_key.data,
8439                         reference->cipher_key.len);
8440         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
8441
8442         /* Setup Authentication Parameters */
8443         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8444         ut_params->auth_xform.auth.op = auth_op;
8445         ut_params->auth_xform.auth.algo = reference->auth_algo;
8446         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
8447         ut_params->auth_xform.auth.key.data = auth_key;
8448         ut_params->auth_xform.auth.digest_length = reference->digest.len;
8449
8450         if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
8451                 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
8452                 ut_params->auth_xform.auth.iv.length = reference->iv.len;
8453         } else {
8454                 ut_params->auth_xform.next = &ut_params->cipher_xform;
8455
8456                 /* Setup Cipher Parameters */
8457                 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8458                 ut_params->cipher_xform.next = NULL;
8459                 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
8460                 ut_params->cipher_xform.cipher.op = cipher_op;
8461                 ut_params->cipher_xform.cipher.key.data = cipher_key;
8462                 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
8463                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
8464                 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
8465         }
8466
8467         /* Create Crypto session*/
8468         ut_params->sess = rte_cryptodev_sym_session_create(
8469                         ts_params->session_mpool);
8470
8471         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
8472                                 &ut_params->auth_xform,
8473                                 ts_params->session_priv_mpool);
8474
8475         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8476
8477         return 0;
8478 }
8479
8480 static int
8481 create_auth_operation(struct crypto_testsuite_params *ts_params,
8482                 struct crypto_unittest_params *ut_params,
8483                 const struct test_crypto_vector *reference,
8484                 unsigned int auth_generate)
8485 {
8486         /* Generate Crypto op data structure */
8487         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8488                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8489         TEST_ASSERT_NOT_NULL(ut_params->op,
8490                         "Failed to allocate pktmbuf offload");
8491
8492         /* Set crypto operation data parameters */
8493         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8494
8495         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8496
8497         /* set crypto operation source mbuf */
8498         sym_op->m_src = ut_params->ibuf;
8499
8500         /* digest */
8501         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8502                         ut_params->ibuf, reference->digest.len);
8503
8504         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8505                         "no room to append auth tag");
8506
8507         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8508                         ut_params->ibuf, reference->plaintext.len);
8509
8510         if (auth_generate)
8511                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8512         else
8513                 memcpy(sym_op->auth.digest.data,
8514                                 reference->digest.data,
8515                                 reference->digest.len);
8516
8517         debug_hexdump(stdout, "digest:",
8518                         sym_op->auth.digest.data,
8519                         reference->digest.len);
8520
8521         sym_op->auth.data.length = reference->plaintext.len;
8522         sym_op->auth.data.offset = 0;
8523
8524         return 0;
8525 }
8526
8527 static int
8528 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
8529                 struct crypto_unittest_params *ut_params,
8530                 const struct test_crypto_vector *reference,
8531                 unsigned int auth_generate)
8532 {
8533         /* Generate Crypto op data structure */
8534         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8535                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8536         TEST_ASSERT_NOT_NULL(ut_params->op,
8537                         "Failed to allocate pktmbuf offload");
8538
8539         /* Set crypto operation data parameters */
8540         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8541
8542         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8543
8544         /* set crypto operation source mbuf */
8545         sym_op->m_src = ut_params->ibuf;
8546
8547         /* digest */
8548         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8549                         ut_params->ibuf, reference->digest.len);
8550
8551         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8552                         "no room to append auth tag");
8553
8554         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8555                         ut_params->ibuf, reference->ciphertext.len);
8556
8557         if (auth_generate)
8558                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8559         else
8560                 memcpy(sym_op->auth.digest.data,
8561                                 reference->digest.data,
8562                                 reference->digest.len);
8563
8564         debug_hexdump(stdout, "digest:",
8565                         sym_op->auth.digest.data,
8566                         reference->digest.len);
8567
8568         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8569                         reference->iv.data, reference->iv.len);
8570
8571         sym_op->cipher.data.length = 0;
8572         sym_op->cipher.data.offset = 0;
8573
8574         sym_op->auth.data.length = reference->plaintext.len;
8575         sym_op->auth.data.offset = 0;
8576
8577         return 0;
8578 }
8579
8580 static int
8581 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
8582                 struct crypto_unittest_params *ut_params,
8583                 const struct test_crypto_vector *reference,
8584                 unsigned int auth_generate)
8585 {
8586         /* Generate Crypto op data structure */
8587         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8588                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8589         TEST_ASSERT_NOT_NULL(ut_params->op,
8590                         "Failed to allocate pktmbuf offload");
8591
8592         /* Set crypto operation data parameters */
8593         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8594
8595         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8596
8597         /* set crypto operation source mbuf */
8598         sym_op->m_src = ut_params->ibuf;
8599
8600         /* digest */
8601         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8602                         ut_params->ibuf, reference->digest.len);
8603
8604         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8605                         "no room to append auth tag");
8606
8607         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8608                         ut_params->ibuf, reference->ciphertext.len);
8609
8610         if (auth_generate)
8611                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8612         else
8613                 memcpy(sym_op->auth.digest.data,
8614                                 reference->digest.data,
8615                                 reference->digest.len);
8616
8617         debug_hexdump(stdout, "digest:",
8618                         sym_op->auth.digest.data,
8619                         reference->digest.len);
8620
8621         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8622                         reference->iv.data, reference->iv.len);
8623
8624         sym_op->cipher.data.length = reference->ciphertext.len;
8625         sym_op->cipher.data.offset = 0;
8626
8627         sym_op->auth.data.length = reference->ciphertext.len;
8628         sym_op->auth.data.offset = 0;
8629
8630         return 0;
8631 }
8632
8633 static int
8634 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8635                 struct crypto_unittest_params *ut_params,
8636                 const struct test_crypto_vector *reference)
8637 {
8638         return create_auth_operation(ts_params, ut_params, reference, 0);
8639 }
8640
8641 static int
8642 create_auth_verify_GMAC_operation(
8643                 struct crypto_testsuite_params *ts_params,
8644                 struct crypto_unittest_params *ut_params,
8645                 const struct test_crypto_vector *reference)
8646 {
8647         return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8648 }
8649
8650 static int
8651 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8652                 struct crypto_unittest_params *ut_params,
8653                 const struct test_crypto_vector *reference)
8654 {
8655         return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8656 }
8657
8658 static int
8659 test_authentication_verify_fail_when_data_corruption(
8660                 struct crypto_testsuite_params *ts_params,
8661                 struct crypto_unittest_params *ut_params,
8662                 const struct test_crypto_vector *reference,
8663                 unsigned int data_corrupted)
8664 {
8665         int retval;
8666
8667         uint8_t *plaintext;
8668
8669         /* Create session */
8670         retval = create_auth_session(ut_params,
8671                         ts_params->valid_devs[0],
8672                         reference,
8673                         RTE_CRYPTO_AUTH_OP_VERIFY);
8674         if (retval < 0)
8675                 return retval;
8676
8677         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8678         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8679                         "Failed to allocate input buffer in mempool");
8680
8681         /* clear mbuf payload */
8682         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8683                         rte_pktmbuf_tailroom(ut_params->ibuf));
8684
8685         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8686                         reference->plaintext.len);
8687         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8688         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8689
8690         debug_hexdump(stdout, "plaintext:", plaintext,
8691                 reference->plaintext.len);
8692
8693         /* Create operation */
8694         retval = create_auth_verify_operation(ts_params, ut_params, reference);
8695
8696         if (retval < 0)
8697                 return retval;
8698
8699         if (data_corrupted)
8700                 data_corruption(plaintext);
8701         else
8702                 tag_corruption(plaintext, reference->plaintext.len);
8703
8704         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8705                         ut_params->op);
8706         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8707         TEST_ASSERT_EQUAL(ut_params->op->status,
8708                         RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8709                         "authentication not failed");
8710
8711         ut_params->obuf = ut_params->op->sym->m_src;
8712         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8713
8714         return 0;
8715 }
8716
8717 static int
8718 test_authentication_verify_GMAC_fail_when_corruption(
8719                 struct crypto_testsuite_params *ts_params,
8720                 struct crypto_unittest_params *ut_params,
8721                 const struct test_crypto_vector *reference,
8722                 unsigned int data_corrupted)
8723 {
8724         int retval;
8725         uint8_t *plaintext;
8726
8727         /* Create session */
8728         retval = create_auth_cipher_session(ut_params,
8729                         ts_params->valid_devs[0],
8730                         reference,
8731                         RTE_CRYPTO_AUTH_OP_VERIFY,
8732                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
8733         if (retval < 0)
8734                 return retval;
8735
8736         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8737         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8738                         "Failed to allocate input buffer in mempool");
8739
8740         /* clear mbuf payload */
8741         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8742                         rte_pktmbuf_tailroom(ut_params->ibuf));
8743
8744         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8745                         reference->plaintext.len);
8746         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8747         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8748
8749         debug_hexdump(stdout, "plaintext:", plaintext,
8750                 reference->plaintext.len);
8751
8752         /* Create operation */
8753         retval = create_auth_verify_GMAC_operation(ts_params,
8754                         ut_params,
8755                         reference);
8756
8757         if (retval < 0)
8758                 return retval;
8759
8760         if (data_corrupted)
8761                 data_corruption(plaintext);
8762         else
8763                 tag_corruption(plaintext, reference->aad.len);
8764
8765         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8766                         ut_params->op);
8767         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8768         TEST_ASSERT_EQUAL(ut_params->op->status,
8769                         RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8770                         "authentication not failed");
8771
8772         ut_params->obuf = ut_params->op->sym->m_src;
8773         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8774
8775         return 0;
8776 }
8777
8778 static int
8779 test_authenticated_decryption_fail_when_corruption(
8780                 struct crypto_testsuite_params *ts_params,
8781                 struct crypto_unittest_params *ut_params,
8782                 const struct test_crypto_vector *reference,
8783                 unsigned int data_corrupted)
8784 {
8785         int retval;
8786
8787         uint8_t *ciphertext;
8788
8789         /* Create session */
8790         retval = create_auth_cipher_session(ut_params,
8791                         ts_params->valid_devs[0],
8792                         reference,
8793                         RTE_CRYPTO_AUTH_OP_VERIFY,
8794                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
8795         if (retval < 0)
8796                 return retval;
8797
8798         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8799         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8800                         "Failed to allocate input buffer in mempool");
8801
8802         /* clear mbuf payload */
8803         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8804                         rte_pktmbuf_tailroom(ut_params->ibuf));
8805
8806         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8807                         reference->ciphertext.len);
8808         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8809         memcpy(ciphertext, reference->ciphertext.data,
8810                         reference->ciphertext.len);
8811
8812         /* Create operation */
8813         retval = create_cipher_auth_verify_operation(ts_params,
8814                         ut_params,
8815                         reference);
8816
8817         if (retval < 0)
8818                 return retval;
8819
8820         if (data_corrupted)
8821                 data_corruption(ciphertext);
8822         else
8823                 tag_corruption(ciphertext, reference->ciphertext.len);
8824
8825         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8826                         ut_params->op);
8827
8828         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8829         TEST_ASSERT_EQUAL(ut_params->op->status,
8830                         RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8831                         "authentication not failed");
8832
8833         ut_params->obuf = ut_params->op->sym->m_src;
8834         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8835
8836         return 0;
8837 }
8838
8839 static int
8840 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8841                 const struct aead_test_data *tdata,
8842                 void *digest_mem, uint64_t digest_phys)
8843 {
8844         struct crypto_testsuite_params *ts_params = &testsuite_params;
8845         struct crypto_unittest_params *ut_params = &unittest_params;
8846
8847         const unsigned int auth_tag_len = tdata->auth_tag.len;
8848         const unsigned int iv_len = tdata->iv.len;
8849         unsigned int aad_len = tdata->aad.len;
8850
8851         /* Generate Crypto op data structure */
8852         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8853                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8854         TEST_ASSERT_NOT_NULL(ut_params->op,
8855                 "Failed to allocate symmetric crypto operation struct");
8856
8857         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8858
8859         sym_op->aead.digest.data = digest_mem;
8860
8861         TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8862                         "no room to append digest");
8863
8864         sym_op->aead.digest.phys_addr = digest_phys;
8865
8866         if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8867                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8868                                 auth_tag_len);
8869                 debug_hexdump(stdout, "digest:",
8870                                 sym_op->aead.digest.data,
8871                                 auth_tag_len);
8872         }
8873
8874         /* Append aad data */
8875         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8876                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8877                                 uint8_t *, IV_OFFSET);
8878
8879                 /* Copy IV 1 byte after the IV pointer, according to the API */
8880                 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8881
8882                 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8883
8884                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8885                                 ut_params->ibuf, aad_len);
8886                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8887                                 "no room to prepend aad");
8888                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8889                                 ut_params->ibuf);
8890
8891                 memset(sym_op->aead.aad.data, 0, aad_len);
8892                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8893                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8894
8895                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8896                 debug_hexdump(stdout, "aad:",
8897                                 sym_op->aead.aad.data, aad_len);
8898         } else {
8899                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8900                                 uint8_t *, IV_OFFSET);
8901
8902                 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8903
8904                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8905                                 ut_params->ibuf, aad_len);
8906                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8907                                 "no room to prepend aad");
8908                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8909                                 ut_params->ibuf);
8910
8911                 memset(sym_op->aead.aad.data, 0, aad_len);
8912                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8913
8914                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8915                 debug_hexdump(stdout, "aad:",
8916                                 sym_op->aead.aad.data, aad_len);
8917         }
8918
8919         sym_op->aead.data.length = tdata->plaintext.len;
8920         sym_op->aead.data.offset = aad_len;
8921
8922         return 0;
8923 }
8924
8925 #define SGL_MAX_NO      16
8926
8927 static int
8928 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8929                 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8930 {
8931         struct crypto_testsuite_params *ts_params = &testsuite_params;
8932         struct crypto_unittest_params *ut_params = &unittest_params;
8933         struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8934         int retval;
8935         int to_trn = 0;
8936         int to_trn_tbl[SGL_MAX_NO];
8937         int segs = 1;
8938         unsigned int trn_data = 0;
8939         uint8_t *plaintext, *ciphertext, *auth_tag;
8940
8941         if (fragsz > tdata->plaintext.len)
8942                 fragsz = tdata->plaintext.len;
8943
8944         uint16_t plaintext_len = fragsz;
8945         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8946
8947         if (fragsz_oop > tdata->plaintext.len)
8948                 frag_size_oop = tdata->plaintext.len;
8949
8950         int ecx = 0;
8951         void *digest_mem = NULL;
8952
8953         uint32_t prepend_len = tdata->aad.len;
8954
8955         if (tdata->plaintext.len % fragsz != 0) {
8956                 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8957                         return 1;
8958         }       else {
8959                 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8960                         return 1;
8961         }
8962
8963         /*
8964          * For out-op-place we need to alloc another mbuf
8965          */
8966         if (oop) {
8967                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8968                 rte_pktmbuf_append(ut_params->obuf,
8969                                 frag_size_oop + prepend_len);
8970                 buf_oop = ut_params->obuf;
8971         }
8972
8973         /* Create AEAD session */
8974         retval = create_aead_session(ts_params->valid_devs[0],
8975                         tdata->algo,
8976                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
8977                         tdata->key.data, tdata->key.len,
8978                         tdata->aad.len, tdata->auth_tag.len,
8979                         tdata->iv.len);
8980         if (retval < 0)
8981                 return retval;
8982
8983         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8984
8985         /* clear mbuf payload */
8986         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8987                         rte_pktmbuf_tailroom(ut_params->ibuf));
8988
8989         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8990                         plaintext_len);
8991
8992         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8993
8994         trn_data += plaintext_len;
8995
8996         buf = ut_params->ibuf;
8997
8998         /*
8999          * Loop until no more fragments
9000          */
9001
9002         while (trn_data < tdata->plaintext.len) {
9003                 ++segs;
9004                 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
9005                                 (tdata->plaintext.len - trn_data) : fragsz;
9006
9007                 to_trn_tbl[ecx++] = to_trn;
9008
9009                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9010                 buf = buf->next;
9011
9012                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
9013                                 rte_pktmbuf_tailroom(buf));
9014
9015                 /* OOP */
9016                 if (oop && !fragsz_oop) {
9017                         buf_last_oop = buf_oop->next =
9018                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
9019                         buf_oop = buf_oop->next;
9020                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9021                                         0, rte_pktmbuf_tailroom(buf_oop));
9022                         rte_pktmbuf_append(buf_oop, to_trn);
9023                 }
9024
9025                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
9026                                 to_trn);
9027
9028                 memcpy(plaintext, tdata->plaintext.data + trn_data,
9029                                 to_trn);
9030                 trn_data += to_trn;
9031                 if (trn_data  == tdata->plaintext.len) {
9032                         if (oop) {
9033                                 if (!fragsz_oop)
9034                                         digest_mem = rte_pktmbuf_append(buf_oop,
9035                                                 tdata->auth_tag.len);
9036                         } else
9037                                 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
9038                                         tdata->auth_tag.len);
9039                 }
9040         }
9041
9042         uint64_t digest_phys = 0;
9043
9044         ut_params->ibuf->nb_segs = segs;
9045
9046         segs = 1;
9047         if (fragsz_oop && oop) {
9048                 to_trn = 0;
9049                 ecx = 0;
9050
9051                 if (frag_size_oop == tdata->plaintext.len) {
9052                         digest_mem = rte_pktmbuf_append(ut_params->obuf,
9053                                 tdata->auth_tag.len);
9054
9055                         digest_phys = rte_pktmbuf_iova_offset(
9056                                         ut_params->obuf,
9057                                         tdata->plaintext.len + prepend_len);
9058                 }
9059
9060                 trn_data = frag_size_oop;
9061                 while (trn_data < tdata->plaintext.len) {
9062                         ++segs;
9063                         to_trn =
9064                                 (tdata->plaintext.len - trn_data <
9065                                                 frag_size_oop) ?
9066                                 (tdata->plaintext.len - trn_data) :
9067                                                 frag_size_oop;
9068
9069                         to_trn_tbl[ecx++] = to_trn;
9070
9071                         buf_last_oop = buf_oop->next =
9072                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
9073                         buf_oop = buf_oop->next;
9074                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
9075                                         0, rte_pktmbuf_tailroom(buf_oop));
9076                         rte_pktmbuf_append(buf_oop, to_trn);
9077
9078                         trn_data += to_trn;
9079
9080                         if (trn_data  == tdata->plaintext.len) {
9081                                 digest_mem = rte_pktmbuf_append(buf_oop,
9082                                         tdata->auth_tag.len);
9083                         }
9084                 }
9085
9086                 ut_params->obuf->nb_segs = segs;
9087         }
9088
9089         /*
9090          * Place digest at the end of the last buffer
9091          */
9092         if (!digest_phys)
9093                 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
9094         if (oop && buf_last_oop)
9095                 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
9096
9097         if (!digest_mem && !oop) {
9098                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9099                                 + tdata->auth_tag.len);
9100                 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
9101                                 tdata->plaintext.len);
9102         }
9103
9104         /* Create AEAD operation */
9105         retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
9106                         tdata, digest_mem, digest_phys);
9107
9108         if (retval < 0)
9109                 return retval;
9110
9111         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9112
9113         ut_params->op->sym->m_src = ut_params->ibuf;
9114         if (oop)
9115                 ut_params->op->sym->m_dst = ut_params->obuf;
9116
9117         /* Process crypto operation */
9118         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9119                         ut_params->op), "failed to process sym crypto op");
9120
9121         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9122                         "crypto op processing failed");
9123
9124
9125         ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
9126                         uint8_t *, prepend_len);
9127         if (oop) {
9128                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9129                                 uint8_t *, prepend_len);
9130         }
9131
9132         if (fragsz_oop)
9133                 fragsz = fragsz_oop;
9134
9135         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9136                         ciphertext,
9137                         tdata->ciphertext.data,
9138                         fragsz,
9139                         "Ciphertext data not as expected");
9140
9141         buf = ut_params->op->sym->m_src->next;
9142         if (oop)
9143                 buf = ut_params->op->sym->m_dst->next;
9144
9145         unsigned int off = fragsz;
9146
9147         ecx = 0;
9148         while (buf) {
9149                 ciphertext = rte_pktmbuf_mtod(buf,
9150                                 uint8_t *);
9151
9152                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9153                                 ciphertext,
9154                                 tdata->ciphertext.data + off,
9155                                 to_trn_tbl[ecx],
9156                                 "Ciphertext data not as expected");
9157
9158                 off += to_trn_tbl[ecx++];
9159                 buf = buf->next;
9160         }
9161
9162         auth_tag = digest_mem;
9163         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9164                         auth_tag,
9165                         tdata->auth_tag.data,
9166                         tdata->auth_tag.len,
9167                         "Generated auth tag not as expected");
9168
9169         return 0;
9170 }
9171
9172 static int
9173 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
9174 {
9175         return test_authenticated_encryption_SGL(
9176                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
9177 }
9178
9179 static int
9180 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
9181 {
9182         return test_authenticated_encryption_SGL(
9183                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
9184 }
9185
9186 static int
9187 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
9188 {
9189         return test_authenticated_encryption_SGL(
9190                         &gcm_test_case_8, OUT_OF_PLACE, 400,
9191                         gcm_test_case_8.plaintext.len);
9192 }
9193
9194 static int
9195 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
9196 {
9197
9198         return test_authenticated_encryption_SGL(
9199                         &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
9200 }
9201
9202 static int
9203 test_authentication_verify_fail_when_data_corrupted(
9204                 struct crypto_testsuite_params *ts_params,
9205                 struct crypto_unittest_params *ut_params,
9206                 const struct test_crypto_vector *reference)
9207 {
9208         return test_authentication_verify_fail_when_data_corruption(
9209                         ts_params, ut_params, reference, 1);
9210 }
9211
9212 static int
9213 test_authentication_verify_fail_when_tag_corrupted(
9214                 struct crypto_testsuite_params *ts_params,
9215                 struct crypto_unittest_params *ut_params,
9216                 const struct test_crypto_vector *reference)
9217 {
9218         return test_authentication_verify_fail_when_data_corruption(
9219                         ts_params, ut_params, reference, 0);
9220 }
9221
9222 static int
9223 test_authentication_verify_GMAC_fail_when_data_corrupted(
9224                 struct crypto_testsuite_params *ts_params,
9225                 struct crypto_unittest_params *ut_params,
9226                 const struct test_crypto_vector *reference)
9227 {
9228         return test_authentication_verify_GMAC_fail_when_corruption(
9229                         ts_params, ut_params, reference, 1);
9230 }
9231
9232 static int
9233 test_authentication_verify_GMAC_fail_when_tag_corrupted(
9234                 struct crypto_testsuite_params *ts_params,
9235                 struct crypto_unittest_params *ut_params,
9236                 const struct test_crypto_vector *reference)
9237 {
9238         return test_authentication_verify_GMAC_fail_when_corruption(
9239                         ts_params, ut_params, reference, 0);
9240 }
9241
9242 static int
9243 test_authenticated_decryption_fail_when_data_corrupted(
9244                 struct crypto_testsuite_params *ts_params,
9245                 struct crypto_unittest_params *ut_params,
9246                 const struct test_crypto_vector *reference)
9247 {
9248         return test_authenticated_decryption_fail_when_corruption(
9249                         ts_params, ut_params, reference, 1);
9250 }
9251
9252 static int
9253 test_authenticated_decryption_fail_when_tag_corrupted(
9254                 struct crypto_testsuite_params *ts_params,
9255                 struct crypto_unittest_params *ut_params,
9256                 const struct test_crypto_vector *reference)
9257 {
9258         return test_authenticated_decryption_fail_when_corruption(
9259                         ts_params, ut_params, reference, 0);
9260 }
9261
9262 static int
9263 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
9264 {
9265         return test_authentication_verify_fail_when_data_corrupted(
9266                         &testsuite_params, &unittest_params,
9267                         &hmac_sha1_test_crypto_vector);
9268 }
9269
9270 static int
9271 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
9272 {
9273         return test_authentication_verify_fail_when_tag_corrupted(
9274                         &testsuite_params, &unittest_params,
9275                         &hmac_sha1_test_crypto_vector);
9276 }
9277
9278 static int
9279 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
9280 {
9281         return test_authentication_verify_GMAC_fail_when_data_corrupted(
9282                         &testsuite_params, &unittest_params,
9283                         &aes128_gmac_test_vector);
9284 }
9285
9286 static int
9287 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
9288 {
9289         return test_authentication_verify_GMAC_fail_when_tag_corrupted(
9290                         &testsuite_params, &unittest_params,
9291                         &aes128_gmac_test_vector);
9292 }
9293
9294 static int
9295 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
9296 {
9297         return test_authenticated_decryption_fail_when_data_corrupted(
9298                         &testsuite_params,
9299                         &unittest_params,
9300                         &aes128cbc_hmac_sha1_test_vector);
9301 }
9302
9303 static int
9304 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
9305 {
9306         return test_authenticated_decryption_fail_when_tag_corrupted(
9307                         &testsuite_params,
9308                         &unittest_params,
9309                         &aes128cbc_hmac_sha1_test_vector);
9310 }
9311
9312 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9313
9314 /* global AESNI slave IDs for the scheduler test */
9315 uint8_t aesni_ids[2];
9316
9317 static int
9318 test_scheduler_attach_slave_op(void)
9319 {
9320         struct crypto_testsuite_params *ts_params = &testsuite_params;
9321         uint8_t sched_id = ts_params->valid_devs[0];
9322         uint32_t nb_devs, i, nb_devs_attached = 0;
9323         int ret;
9324         char vdev_name[32];
9325
9326         /* create 2 AESNI_MB if necessary */
9327         nb_devs = rte_cryptodev_device_count_by_driver(
9328                         rte_cryptodev_driver_id_get(
9329                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
9330         if (nb_devs < 2) {
9331                 for (i = nb_devs; i < 2; i++) {
9332                         snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
9333                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
9334                                         i);
9335                         ret = rte_vdev_init(vdev_name, NULL);
9336
9337                         TEST_ASSERT(ret == 0,
9338                                 "Failed to create instance %u of"
9339                                 " pmd : %s",
9340                                 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9341                 }
9342         }
9343
9344         /* attach 2 AESNI_MB cdevs */
9345         for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
9346                         i++) {
9347                 struct rte_cryptodev_info info;
9348                 unsigned int session_size;
9349
9350                 rte_cryptodev_info_get(i, &info);
9351                 if (info.driver_id != rte_cryptodev_driver_id_get(
9352                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
9353                         continue;
9354
9355                 session_size = rte_cryptodev_sym_get_private_session_size(i);
9356                 /*
9357                  * Create the session mempool again, since now there are new devices
9358                  * to use the mempool.
9359                  */
9360                 if (ts_params->session_mpool) {
9361                         rte_mempool_free(ts_params->session_mpool);
9362                         ts_params->session_mpool = NULL;
9363                 }
9364                 if (ts_params->session_priv_mpool) {
9365                         rte_mempool_free(ts_params->session_priv_mpool);
9366                         ts_params->session_priv_mpool = NULL;
9367                 }
9368
9369                 if (info.sym.max_nb_sessions != 0 &&
9370                                 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
9371                         RTE_LOG(ERR, USER1,
9372                                         "Device does not support "
9373                                         "at least %u sessions\n",
9374                                         MAX_NB_SESSIONS);
9375                         return TEST_FAILED;
9376                 }
9377                 /*
9378                  * Create mempool with maximum number of sessions,
9379                  * to include the session headers
9380                  */
9381                 if (ts_params->session_mpool == NULL) {
9382                         ts_params->session_mpool =
9383                                 rte_cryptodev_sym_session_pool_create(
9384                                                 "test_sess_mp",
9385                                                 MAX_NB_SESSIONS, 0, 0, 0,
9386                                                 SOCKET_ID_ANY);
9387                         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
9388                                         "session mempool allocation failed");
9389                 }
9390
9391                 /*
9392                  * Create mempool with maximum number of sessions,
9393                  * to include device specific session private data
9394                  */
9395                 if (ts_params->session_priv_mpool == NULL) {
9396                         ts_params->session_priv_mpool = rte_mempool_create(
9397                                         "test_sess_mp_priv",
9398                                         MAX_NB_SESSIONS,
9399                                         session_size,
9400                                         0, 0, NULL, NULL, NULL,
9401                                         NULL, SOCKET_ID_ANY,
9402                                         0);
9403
9404                         TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
9405                                         "session mempool allocation failed");
9406                 }
9407
9408                 ts_params->qp_conf.mp_session = ts_params->session_mpool;
9409                 ts_params->qp_conf.mp_session_private =
9410                                 ts_params->session_priv_mpool;
9411
9412                 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
9413                                 (uint8_t)i);
9414
9415                 TEST_ASSERT(ret == 0,
9416                         "Failed to attach device %u of pmd : %s", i,
9417                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9418
9419                 aesni_ids[nb_devs_attached] = (uint8_t)i;
9420
9421                 nb_devs_attached++;
9422         }
9423
9424         return 0;
9425 }
9426
9427 static int
9428 test_scheduler_detach_slave_op(void)
9429 {
9430         struct crypto_testsuite_params *ts_params = &testsuite_params;
9431         uint8_t sched_id = ts_params->valid_devs[0];
9432         uint32_t i;
9433         int ret;
9434
9435         for (i = 0; i < 2; i++) {
9436                 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
9437                                 aesni_ids[i]);
9438                 TEST_ASSERT(ret == 0,
9439                         "Failed to detach device %u", aesni_ids[i]);
9440         }
9441
9442         return 0;
9443 }
9444
9445 static int
9446 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
9447 {
9448         struct crypto_testsuite_params *ts_params = &testsuite_params;
9449         uint8_t sched_id = ts_params->valid_devs[0];
9450         /* set mode */
9451         return rte_cryptodev_scheduler_mode_set(sched_id,
9452                 scheduler_mode);
9453 }
9454
9455 static int
9456 test_scheduler_mode_roundrobin_op(void)
9457 {
9458         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
9459                         0, "Failed to set roundrobin mode");
9460         return 0;
9461
9462 }
9463
9464 static int
9465 test_scheduler_mode_multicore_op(void)
9466 {
9467         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
9468                         0, "Failed to set multicore mode");
9469
9470         return 0;
9471 }
9472
9473 static int
9474 test_scheduler_mode_failover_op(void)
9475 {
9476         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
9477                         0, "Failed to set failover mode");
9478
9479         return 0;
9480 }
9481
9482 static int
9483 test_scheduler_mode_pkt_size_distr_op(void)
9484 {
9485         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
9486                         0, "Failed to set pktsize mode");
9487
9488         return 0;
9489 }
9490
9491 static struct unit_test_suite cryptodev_scheduler_testsuite  = {
9492         .suite_name = "Crypto Device Scheduler Unit Test Suite",
9493         .setup = testsuite_setup,
9494         .teardown = testsuite_teardown,
9495         .unit_test_cases = {
9496                 /* Multi Core */
9497                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9498                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
9499                 TEST_CASE_ST(ut_setup, ut_teardown,
9500                                         test_AES_chain_scheduler_all),
9501                 TEST_CASE_ST(ut_setup, ut_teardown,
9502                                         test_AES_cipheronly_scheduler_all),
9503                 TEST_CASE_ST(ut_setup, ut_teardown,
9504                                         test_authonly_scheduler_all),
9505                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9506
9507                 /* Round Robin */
9508                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9509                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
9510                 TEST_CASE_ST(ut_setup, ut_teardown,
9511                                 test_AES_chain_scheduler_all),
9512                 TEST_CASE_ST(ut_setup, ut_teardown,
9513                                 test_AES_cipheronly_scheduler_all),
9514                 TEST_CASE_ST(ut_setup, ut_teardown,
9515                                 test_authonly_scheduler_all),
9516                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9517
9518                 /* Fail over */
9519                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9520                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
9521                 TEST_CASE_ST(ut_setup, ut_teardown,
9522                                         test_AES_chain_scheduler_all),
9523                 TEST_CASE_ST(ut_setup, ut_teardown,
9524                                         test_AES_cipheronly_scheduler_all),
9525                 TEST_CASE_ST(ut_setup, ut_teardown,
9526                                         test_authonly_scheduler_all),
9527                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9528
9529                 /* PKT SIZE */
9530                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
9531                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
9532                 TEST_CASE_ST(ut_setup, ut_teardown,
9533                                         test_AES_chain_scheduler_all),
9534                 TEST_CASE_ST(ut_setup, ut_teardown,
9535                                         test_AES_cipheronly_scheduler_all),
9536                 TEST_CASE_ST(ut_setup, ut_teardown,
9537                                         test_authonly_scheduler_all),
9538                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
9539
9540                 TEST_CASES_END() /**< NULL terminate unit test array */
9541         }
9542 };
9543
9544 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
9545
9546 static struct unit_test_suite cryptodev_qat_testsuite  = {
9547         .suite_name = "Crypto QAT Unit Test Suite",
9548         .setup = testsuite_setup,
9549         .teardown = testsuite_teardown,
9550         .unit_test_cases = {
9551                 TEST_CASE_ST(ut_setup, ut_teardown,
9552                                 test_device_configure_invalid_dev_id),
9553                 TEST_CASE_ST(ut_setup, ut_teardown,
9554                                 test_device_configure_invalid_queue_pair_ids),
9555                 TEST_CASE_ST(ut_setup, ut_teardown,
9556                                 test_queue_pair_descriptor_setup),
9557                 TEST_CASE_ST(ut_setup, ut_teardown,
9558                                 test_multi_session),
9559
9560                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
9561                 TEST_CASE_ST(ut_setup, ut_teardown,
9562                                                 test_AES_cipheronly_qat_all),
9563                 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
9564                 TEST_CASE_ST(ut_setup, ut_teardown,
9565                                                 test_3DES_cipheronly_qat_all),
9566                 TEST_CASE_ST(ut_setup, ut_teardown,
9567                                                 test_DES_cipheronly_qat_all),
9568                 TEST_CASE_ST(ut_setup, ut_teardown,
9569                                                 test_AES_docsis_qat_all),
9570                 TEST_CASE_ST(ut_setup, ut_teardown,
9571                                                 test_DES_docsis_qat_all),
9572                 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
9573                 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
9574
9575                 /** AES CCM Authenticated Encryption 128 bits key */
9576                 TEST_CASE_ST(ut_setup, ut_teardown,
9577                         test_AES_CCM_authenticated_encryption_test_case_128_1),
9578                 TEST_CASE_ST(ut_setup, ut_teardown,
9579                         test_AES_CCM_authenticated_encryption_test_case_128_2),
9580                 TEST_CASE_ST(ut_setup, ut_teardown,
9581                         test_AES_CCM_authenticated_encryption_test_case_128_3),
9582
9583                 /** AES CCM Authenticated Decryption 128 bits key*/
9584                 TEST_CASE_ST(ut_setup, ut_teardown,
9585                         test_AES_CCM_authenticated_decryption_test_case_128_1),
9586                 TEST_CASE_ST(ut_setup, ut_teardown,
9587                         test_AES_CCM_authenticated_decryption_test_case_128_2),
9588                 TEST_CASE_ST(ut_setup, ut_teardown,
9589                         test_AES_CCM_authenticated_decryption_test_case_128_3),
9590
9591                 /** AES GCM Authenticated Encryption */
9592                 TEST_CASE_ST(ut_setup, ut_teardown,
9593                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9594                 TEST_CASE_ST(ut_setup, ut_teardown,
9595                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9596                 TEST_CASE_ST(ut_setup, ut_teardown,
9597                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9598                 TEST_CASE_ST(ut_setup, ut_teardown,
9599                         test_AES_GCM_authenticated_encryption_test_case_1),
9600                 TEST_CASE_ST(ut_setup, ut_teardown,
9601                         test_AES_GCM_authenticated_encryption_test_case_2),
9602                 TEST_CASE_ST(ut_setup, ut_teardown,
9603                         test_AES_GCM_authenticated_encryption_test_case_3),
9604                 TEST_CASE_ST(ut_setup, ut_teardown,
9605                         test_AES_GCM_authenticated_encryption_test_case_4),
9606                 TEST_CASE_ST(ut_setup, ut_teardown,
9607                         test_AES_GCM_authenticated_encryption_test_case_5),
9608                 TEST_CASE_ST(ut_setup, ut_teardown,
9609                         test_AES_GCM_authenticated_encryption_test_case_6),
9610                 TEST_CASE_ST(ut_setup, ut_teardown,
9611                         test_AES_GCM_authenticated_encryption_test_case_7),
9612
9613                 /** AES GCM Authenticated Decryption */
9614                 TEST_CASE_ST(ut_setup, ut_teardown,
9615                         test_AES_GCM_authenticated_decryption_test_case_1),
9616                 TEST_CASE_ST(ut_setup, ut_teardown,
9617                         test_AES_GCM_authenticated_decryption_test_case_2),
9618                 TEST_CASE_ST(ut_setup, ut_teardown,
9619                         test_AES_GCM_authenticated_decryption_test_case_3),
9620                 TEST_CASE_ST(ut_setup, ut_teardown,
9621                         test_AES_GCM_authenticated_decryption_test_case_4),
9622                 TEST_CASE_ST(ut_setup, ut_teardown,
9623                         test_AES_GCM_authenticated_decryption_test_case_5),
9624                 TEST_CASE_ST(ut_setup, ut_teardown,
9625                         test_AES_GCM_authenticated_decryption_test_case_6),
9626                 TEST_CASE_ST(ut_setup, ut_teardown,
9627                         test_AES_GCM_authenticated_decryption_test_case_7),
9628
9629                 /** AES GCM Authenticated Encryption 192 bits key */
9630                 TEST_CASE_ST(ut_setup, ut_teardown,
9631                         test_AES_GCM_auth_encryption_test_case_192_1),
9632                 TEST_CASE_ST(ut_setup, ut_teardown,
9633                         test_AES_GCM_auth_encryption_test_case_192_2),
9634                 TEST_CASE_ST(ut_setup, ut_teardown,
9635                         test_AES_GCM_auth_encryption_test_case_192_3),
9636                 TEST_CASE_ST(ut_setup, ut_teardown,
9637                         test_AES_GCM_auth_encryption_test_case_192_4),
9638                 TEST_CASE_ST(ut_setup, ut_teardown,
9639                         test_AES_GCM_auth_encryption_test_case_192_5),
9640                 TEST_CASE_ST(ut_setup, ut_teardown,
9641                         test_AES_GCM_auth_encryption_test_case_192_6),
9642                 TEST_CASE_ST(ut_setup, ut_teardown,
9643                         test_AES_GCM_auth_encryption_test_case_192_7),
9644
9645                 /** AES GCM Authenticated Decryption 192 bits key */
9646                 TEST_CASE_ST(ut_setup, ut_teardown,
9647                         test_AES_GCM_auth_decryption_test_case_192_1),
9648                 TEST_CASE_ST(ut_setup, ut_teardown,
9649                         test_AES_GCM_auth_decryption_test_case_192_2),
9650                 TEST_CASE_ST(ut_setup, ut_teardown,
9651                         test_AES_GCM_auth_decryption_test_case_192_3),
9652                 TEST_CASE_ST(ut_setup, ut_teardown,
9653                         test_AES_GCM_auth_decryption_test_case_192_4),
9654                 TEST_CASE_ST(ut_setup, ut_teardown,
9655                         test_AES_GCM_auth_decryption_test_case_192_5),
9656                 TEST_CASE_ST(ut_setup, ut_teardown,
9657                         test_AES_GCM_auth_decryption_test_case_192_6),
9658                 TEST_CASE_ST(ut_setup, ut_teardown,
9659                         test_AES_GCM_auth_decryption_test_case_192_7),
9660
9661                 /** AES GCM Authenticated Encryption 256 bits key */
9662                 TEST_CASE_ST(ut_setup, ut_teardown,
9663                         test_AES_GCM_auth_encryption_test_case_256_1),
9664                 TEST_CASE_ST(ut_setup, ut_teardown,
9665                         test_AES_GCM_auth_encryption_test_case_256_2),
9666                 TEST_CASE_ST(ut_setup, ut_teardown,
9667                         test_AES_GCM_auth_encryption_test_case_256_3),
9668                 TEST_CASE_ST(ut_setup, ut_teardown,
9669                         test_AES_GCM_auth_encryption_test_case_256_4),
9670                 TEST_CASE_ST(ut_setup, ut_teardown,
9671                         test_AES_GCM_auth_encryption_test_case_256_5),
9672                 TEST_CASE_ST(ut_setup, ut_teardown,
9673                         test_AES_GCM_auth_encryption_test_case_256_6),
9674                 TEST_CASE_ST(ut_setup, ut_teardown,
9675                         test_AES_GCM_auth_encryption_test_case_256_7),
9676
9677                 /** AES GMAC Authentication */
9678                 TEST_CASE_ST(ut_setup, ut_teardown,
9679                         test_AES_GMAC_authentication_test_case_1),
9680                 TEST_CASE_ST(ut_setup, ut_teardown,
9681                         test_AES_GMAC_authentication_verify_test_case_1),
9682                 TEST_CASE_ST(ut_setup, ut_teardown,
9683                         test_AES_GMAC_authentication_test_case_2),
9684                 TEST_CASE_ST(ut_setup, ut_teardown,
9685                         test_AES_GMAC_authentication_verify_test_case_2),
9686                 TEST_CASE_ST(ut_setup, ut_teardown,
9687                         test_AES_GMAC_authentication_test_case_3),
9688                 TEST_CASE_ST(ut_setup, ut_teardown,
9689                         test_AES_GMAC_authentication_verify_test_case_3),
9690
9691                 /** SNOW 3G encrypt only (UEA2) */
9692                 TEST_CASE_ST(ut_setup, ut_teardown,
9693                         test_snow3g_encryption_test_case_1),
9694                 TEST_CASE_ST(ut_setup, ut_teardown,
9695                         test_snow3g_encryption_test_case_2),
9696                 TEST_CASE_ST(ut_setup, ut_teardown,
9697                         test_snow3g_encryption_test_case_3),
9698                 TEST_CASE_ST(ut_setup, ut_teardown,
9699                         test_snow3g_encryption_test_case_4),
9700                 TEST_CASE_ST(ut_setup, ut_teardown,
9701                         test_snow3g_encryption_test_case_5),
9702
9703                 TEST_CASE_ST(ut_setup, ut_teardown,
9704                         test_snow3g_encryption_test_case_1_oop),
9705                 TEST_CASE_ST(ut_setup, ut_teardown,
9706                         test_snow3g_decryption_test_case_1_oop),
9707
9708                 /** SNOW 3G generate auth, then encrypt (UEA2) */
9709                 TEST_CASE_ST(ut_setup, ut_teardown,
9710                         test_snow3g_auth_cipher_test_case_1),
9711                 TEST_CASE_ST(ut_setup, ut_teardown,
9712                         test_snow3g_auth_cipher_test_case_2),
9713                 TEST_CASE_ST(ut_setup, ut_teardown,
9714                         test_snow3g_auth_cipher_test_case_2_oop),
9715                 TEST_CASE_ST(ut_setup, ut_teardown,
9716                         test_snow3g_auth_cipher_part_digest_enc),
9717                 TEST_CASE_ST(ut_setup, ut_teardown,
9718                         test_snow3g_auth_cipher_part_digest_enc_oop),
9719
9720                 /** SNOW 3G decrypt (UEA2), then verify auth */
9721                 TEST_CASE_ST(ut_setup, ut_teardown,
9722                         test_snow3g_auth_cipher_verify_test_case_1),
9723                 TEST_CASE_ST(ut_setup, ut_teardown,
9724                         test_snow3g_auth_cipher_verify_test_case_2),
9725                 TEST_CASE_ST(ut_setup, ut_teardown,
9726                         test_snow3g_auth_cipher_verify_test_case_2_oop),
9727                 TEST_CASE_ST(ut_setup, ut_teardown,
9728                         test_snow3g_auth_cipher_verify_part_digest_enc),
9729                 TEST_CASE_ST(ut_setup, ut_teardown,
9730                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
9731
9732                 /** SNOW 3G decrypt only (UEA2) */
9733                 TEST_CASE_ST(ut_setup, ut_teardown,
9734                         test_snow3g_decryption_test_case_1),
9735                 TEST_CASE_ST(ut_setup, ut_teardown,
9736                         test_snow3g_decryption_test_case_2),
9737                 TEST_CASE_ST(ut_setup, ut_teardown,
9738                         test_snow3g_decryption_test_case_3),
9739                 TEST_CASE_ST(ut_setup, ut_teardown,
9740                         test_snow3g_decryption_test_case_4),
9741                 TEST_CASE_ST(ut_setup, ut_teardown,
9742                         test_snow3g_decryption_test_case_5),
9743                 TEST_CASE_ST(ut_setup, ut_teardown,
9744                         test_snow3g_decryption_with_digest_test_case_1),
9745                 TEST_CASE_ST(ut_setup, ut_teardown,
9746                         test_snow3g_hash_generate_test_case_1),
9747                 TEST_CASE_ST(ut_setup, ut_teardown,
9748                         test_snow3g_hash_generate_test_case_2),
9749                 TEST_CASE_ST(ut_setup, ut_teardown,
9750                         test_snow3g_hash_generate_test_case_3),
9751                 TEST_CASE_ST(ut_setup, ut_teardown,
9752                         test_snow3g_hash_verify_test_case_1),
9753                 TEST_CASE_ST(ut_setup, ut_teardown,
9754                         test_snow3g_hash_verify_test_case_2),
9755                 TEST_CASE_ST(ut_setup, ut_teardown,
9756                         test_snow3g_hash_verify_test_case_3),
9757                 TEST_CASE_ST(ut_setup, ut_teardown,
9758                         test_snow3g_cipher_auth_test_case_1),
9759                 TEST_CASE_ST(ut_setup, ut_teardown,
9760                         test_snow3g_auth_cipher_with_digest_test_case_1),
9761
9762                 /** ZUC encrypt only (EEA3) */
9763                 TEST_CASE_ST(ut_setup, ut_teardown,
9764                         test_zuc_encryption_test_case_1),
9765                 TEST_CASE_ST(ut_setup, ut_teardown,
9766                         test_zuc_encryption_test_case_2),
9767                 TEST_CASE_ST(ut_setup, ut_teardown,
9768                         test_zuc_encryption_test_case_3),
9769                 TEST_CASE_ST(ut_setup, ut_teardown,
9770                         test_zuc_encryption_test_case_4),
9771                 TEST_CASE_ST(ut_setup, ut_teardown,
9772                         test_zuc_encryption_test_case_5),
9773
9774                 /** ZUC authenticate (EIA3) */
9775                 TEST_CASE_ST(ut_setup, ut_teardown,
9776                         test_zuc_hash_generate_test_case_6),
9777                 TEST_CASE_ST(ut_setup, ut_teardown,
9778                         test_zuc_hash_generate_test_case_7),
9779                 TEST_CASE_ST(ut_setup, ut_teardown,
9780                         test_zuc_hash_generate_test_case_8),
9781
9782                 /** ZUC alg-chain (EEA3/EIA3) */
9783                 TEST_CASE_ST(ut_setup, ut_teardown,
9784                         test_zuc_cipher_auth_test_case_1),
9785                 TEST_CASE_ST(ut_setup, ut_teardown,
9786                         test_zuc_cipher_auth_test_case_2),
9787
9788                 /** ZUC generate auth, then encrypt (EEA3) */
9789                 TEST_CASE_ST(ut_setup, ut_teardown,
9790                         test_zuc_auth_cipher_test_case_1),
9791                 TEST_CASE_ST(ut_setup, ut_teardown,
9792                         test_zuc_auth_cipher_test_case_1_oop),
9793
9794                 /** ZUC decrypt (EEA3), then verify auth */
9795                 TEST_CASE_ST(ut_setup, ut_teardown,
9796                         test_zuc_auth_cipher_verify_test_case_1),
9797                 TEST_CASE_ST(ut_setup, ut_teardown,
9798                         test_zuc_auth_cipher_verify_test_case_1_oop),
9799
9800                 /** HMAC_MD5 Authentication */
9801                 TEST_CASE_ST(ut_setup, ut_teardown,
9802                         test_MD5_HMAC_generate_case_1),
9803                 TEST_CASE_ST(ut_setup, ut_teardown,
9804                         test_MD5_HMAC_verify_case_1),
9805                 TEST_CASE_ST(ut_setup, ut_teardown,
9806                         test_MD5_HMAC_generate_case_2),
9807                 TEST_CASE_ST(ut_setup, ut_teardown,
9808                         test_MD5_HMAC_verify_case_2),
9809
9810                 /** NULL algo tests done in chain_all,
9811                  * cipheronly and authonly suites
9812                  */
9813
9814                 /** KASUMI tests */
9815                 TEST_CASE_ST(ut_setup, ut_teardown,
9816                         test_kasumi_hash_generate_test_case_1),
9817                 TEST_CASE_ST(ut_setup, ut_teardown,
9818                         test_kasumi_hash_generate_test_case_2),
9819                 TEST_CASE_ST(ut_setup, ut_teardown,
9820                         test_kasumi_hash_generate_test_case_3),
9821                 TEST_CASE_ST(ut_setup, ut_teardown,
9822                         test_kasumi_hash_generate_test_case_4),
9823                 TEST_CASE_ST(ut_setup, ut_teardown,
9824                         test_kasumi_hash_generate_test_case_5),
9825                 TEST_CASE_ST(ut_setup, ut_teardown,
9826                         test_kasumi_hash_generate_test_case_6),
9827
9828                 TEST_CASE_ST(ut_setup, ut_teardown,
9829                         test_kasumi_hash_verify_test_case_1),
9830                 TEST_CASE_ST(ut_setup, ut_teardown,
9831                         test_kasumi_hash_verify_test_case_2),
9832                 TEST_CASE_ST(ut_setup, ut_teardown,
9833                         test_kasumi_hash_verify_test_case_3),
9834                 TEST_CASE_ST(ut_setup, ut_teardown,
9835                         test_kasumi_hash_verify_test_case_4),
9836                 TEST_CASE_ST(ut_setup, ut_teardown,
9837                         test_kasumi_hash_verify_test_case_5),
9838
9839                 TEST_CASE_ST(ut_setup, ut_teardown,
9840                         test_kasumi_encryption_test_case_1),
9841                 TEST_CASE_ST(ut_setup, ut_teardown,
9842                         test_kasumi_encryption_test_case_3),
9843                 TEST_CASE_ST(ut_setup, ut_teardown,
9844                         test_kasumi_cipher_auth_test_case_1),
9845
9846                 /** KASUMI generate auth, then encrypt (F8) */
9847                 TEST_CASE_ST(ut_setup, ut_teardown,
9848                         test_kasumi_auth_cipher_test_case_1),
9849                 TEST_CASE_ST(ut_setup, ut_teardown,
9850                         test_kasumi_auth_cipher_test_case_2),
9851                 TEST_CASE_ST(ut_setup, ut_teardown,
9852                         test_kasumi_auth_cipher_test_case_2_oop),
9853
9854                 /** KASUMI decrypt (F8), then verify auth */
9855                 TEST_CASE_ST(ut_setup, ut_teardown,
9856                         test_kasumi_auth_cipher_verify_test_case_1),
9857                 TEST_CASE_ST(ut_setup, ut_teardown,
9858                         test_kasumi_auth_cipher_verify_test_case_2),
9859                 TEST_CASE_ST(ut_setup, ut_teardown,
9860                         test_kasumi_auth_cipher_verify_test_case_2_oop),
9861
9862                 /** Negative tests */
9863                 TEST_CASE_ST(ut_setup, ut_teardown,
9864                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
9865                 TEST_CASE_ST(ut_setup, ut_teardown,
9866                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9867                 TEST_CASE_ST(ut_setup, ut_teardown,
9868                         authentication_verify_AES128_GMAC_fail_data_corrupt),
9869                 TEST_CASE_ST(ut_setup, ut_teardown,
9870                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
9871                 TEST_CASE_ST(ut_setup, ut_teardown,
9872                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9873                 TEST_CASE_ST(ut_setup, ut_teardown,
9874                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9875
9876                 TEST_CASES_END() /**< NULL terminate unit test array */
9877         }
9878 };
9879
9880 static struct unit_test_suite cryptodev_virtio_testsuite = {
9881         .suite_name = "Crypto VIRTIO Unit Test Suite",
9882         .setup = testsuite_setup,
9883         .teardown = testsuite_teardown,
9884         .unit_test_cases = {
9885                 TEST_CASE_ST(ut_setup, ut_teardown,
9886                                 test_AES_cipheronly_virtio_all),
9887
9888                 TEST_CASES_END() /**< NULL terminate unit test array */
9889         }
9890 };
9891
9892 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
9893         .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9894         .setup = testsuite_setup,
9895         .teardown = testsuite_teardown,
9896         .unit_test_cases = {
9897 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
9898                 TEST_CASE_ST(ut_setup, ut_teardown,
9899                         test_AES_GCM_authenticated_encryption_test_case_1),
9900                 TEST_CASE_ST(ut_setup, ut_teardown,
9901                         test_AES_GCM_authenticated_encryption_test_case_2),
9902                 TEST_CASE_ST(ut_setup, ut_teardown,
9903                         test_AES_GCM_authenticated_encryption_test_case_3),
9904                 TEST_CASE_ST(ut_setup, ut_teardown,
9905                         test_AES_GCM_authenticated_encryption_test_case_4),
9906                 TEST_CASE_ST(ut_setup, ut_teardown,
9907                         test_AES_GCM_authenticated_encryption_test_case_5),
9908                 TEST_CASE_ST(ut_setup, ut_teardown,
9909                         test_AES_GCM_authenticated_encryption_test_case_6),
9910                 TEST_CASE_ST(ut_setup, ut_teardown,
9911                         test_AES_GCM_authenticated_encryption_test_case_7),
9912
9913                 /** AES GCM Authenticated Decryption */
9914                 TEST_CASE_ST(ut_setup, ut_teardown,
9915                         test_AES_GCM_authenticated_decryption_test_case_1),
9916                 TEST_CASE_ST(ut_setup, ut_teardown,
9917                         test_AES_GCM_authenticated_decryption_test_case_2),
9918                 TEST_CASE_ST(ut_setup, ut_teardown,
9919                         test_AES_GCM_authenticated_decryption_test_case_3),
9920                 TEST_CASE_ST(ut_setup, ut_teardown,
9921                         test_AES_GCM_authenticated_decryption_test_case_4),
9922                 TEST_CASE_ST(ut_setup, ut_teardown,
9923                         test_AES_GCM_authenticated_decryption_test_case_5),
9924                 TEST_CASE_ST(ut_setup, ut_teardown,
9925                         test_AES_GCM_authenticated_decryption_test_case_6),
9926                 TEST_CASE_ST(ut_setup, ut_teardown,
9927                         test_AES_GCM_authenticated_decryption_test_case_7),
9928
9929                 /** AES GCM Authenticated Encryption 192 bits key */
9930                 TEST_CASE_ST(ut_setup, ut_teardown,
9931                         test_AES_GCM_auth_encryption_test_case_192_1),
9932                 TEST_CASE_ST(ut_setup, ut_teardown,
9933                         test_AES_GCM_auth_encryption_test_case_192_2),
9934                 TEST_CASE_ST(ut_setup, ut_teardown,
9935                         test_AES_GCM_auth_encryption_test_case_192_3),
9936                 TEST_CASE_ST(ut_setup, ut_teardown,
9937                         test_AES_GCM_auth_encryption_test_case_192_4),
9938                 TEST_CASE_ST(ut_setup, ut_teardown,
9939                         test_AES_GCM_auth_encryption_test_case_192_5),
9940                 TEST_CASE_ST(ut_setup, ut_teardown,
9941                         test_AES_GCM_auth_encryption_test_case_192_6),
9942                 TEST_CASE_ST(ut_setup, ut_teardown,
9943                         test_AES_GCM_auth_encryption_test_case_192_7),
9944
9945                 /** AES GCM Authenticated Decryption 192 bits key */
9946                 TEST_CASE_ST(ut_setup, ut_teardown,
9947                         test_AES_GCM_auth_decryption_test_case_192_1),
9948                 TEST_CASE_ST(ut_setup, ut_teardown,
9949                         test_AES_GCM_auth_decryption_test_case_192_2),
9950                 TEST_CASE_ST(ut_setup, ut_teardown,
9951                         test_AES_GCM_auth_decryption_test_case_192_3),
9952                 TEST_CASE_ST(ut_setup, ut_teardown,
9953                         test_AES_GCM_auth_decryption_test_case_192_4),
9954                 TEST_CASE_ST(ut_setup, ut_teardown,
9955                         test_AES_GCM_auth_decryption_test_case_192_5),
9956                 TEST_CASE_ST(ut_setup, ut_teardown,
9957                         test_AES_GCM_auth_decryption_test_case_192_6),
9958                 TEST_CASE_ST(ut_setup, ut_teardown,
9959                         test_AES_GCM_auth_decryption_test_case_192_7),
9960
9961                 /** AES GCM Authenticated Encryption 256 bits key */
9962                 TEST_CASE_ST(ut_setup, ut_teardown,
9963                         test_AES_GCM_auth_encryption_test_case_256_1),
9964                 TEST_CASE_ST(ut_setup, ut_teardown,
9965                         test_AES_GCM_auth_encryption_test_case_256_2),
9966                 TEST_CASE_ST(ut_setup, ut_teardown,
9967                         test_AES_GCM_auth_encryption_test_case_256_3),
9968                 TEST_CASE_ST(ut_setup, ut_teardown,
9969                         test_AES_GCM_auth_encryption_test_case_256_4),
9970                 TEST_CASE_ST(ut_setup, ut_teardown,
9971                         test_AES_GCM_auth_encryption_test_case_256_5),
9972                 TEST_CASE_ST(ut_setup, ut_teardown,
9973                         test_AES_GCM_auth_encryption_test_case_256_6),
9974                 TEST_CASE_ST(ut_setup, ut_teardown,
9975                         test_AES_GCM_auth_encryption_test_case_256_7),
9976
9977                 /** AES GCM Authenticated Decryption 256 bits key */
9978                 TEST_CASE_ST(ut_setup, ut_teardown,
9979                         test_AES_GCM_auth_decryption_test_case_256_1),
9980                 TEST_CASE_ST(ut_setup, ut_teardown,
9981                         test_AES_GCM_auth_decryption_test_case_256_2),
9982                 TEST_CASE_ST(ut_setup, ut_teardown,
9983                         test_AES_GCM_auth_decryption_test_case_256_3),
9984                 TEST_CASE_ST(ut_setup, ut_teardown,
9985                         test_AES_GCM_auth_decryption_test_case_256_4),
9986                 TEST_CASE_ST(ut_setup, ut_teardown,
9987                         test_AES_GCM_auth_decryption_test_case_256_5),
9988                 TEST_CASE_ST(ut_setup, ut_teardown,
9989                         test_AES_GCM_auth_decryption_test_case_256_6),
9990                 TEST_CASE_ST(ut_setup, ut_teardown,
9991                         test_AES_GCM_auth_decryption_test_case_256_7),
9992
9993                 /** AES GCM Authenticated Encryption big aad size */
9994                 TEST_CASE_ST(ut_setup, ut_teardown,
9995                         test_AES_GCM_auth_encryption_test_case_aad_1),
9996                 TEST_CASE_ST(ut_setup, ut_teardown,
9997                         test_AES_GCM_auth_encryption_test_case_aad_2),
9998
9999                 /** AES GCM Authenticated Decryption big aad size */
10000                 TEST_CASE_ST(ut_setup, ut_teardown,
10001                         test_AES_GCM_auth_decryption_test_case_aad_1),
10002                 TEST_CASE_ST(ut_setup, ut_teardown,
10003                         test_AES_GCM_auth_decryption_test_case_aad_2),
10004
10005                 /** Session-less tests */
10006                 TEST_CASE_ST(ut_setup, ut_teardown,
10007                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10008                 TEST_CASE_ST(ut_setup, ut_teardown,
10009                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10010
10011                 /** AES GMAC Authentication */
10012                 TEST_CASE_ST(ut_setup, ut_teardown,
10013                         test_AES_GMAC_authentication_test_case_1),
10014                 TEST_CASE_ST(ut_setup, ut_teardown,
10015                         test_AES_GMAC_authentication_verify_test_case_1),
10016                 TEST_CASE_ST(ut_setup, ut_teardown,
10017                         test_AES_GMAC_authentication_test_case_2),
10018                 TEST_CASE_ST(ut_setup, ut_teardown,
10019                         test_AES_GMAC_authentication_verify_test_case_2),
10020                 TEST_CASE_ST(ut_setup, ut_teardown,
10021                         test_AES_GMAC_authentication_test_case_3),
10022                 TEST_CASE_ST(ut_setup, ut_teardown,
10023                         test_AES_GMAC_authentication_verify_test_case_3),
10024 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
10025
10026                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
10027                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
10028                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
10029                 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
10030                 TEST_CASE_ST(ut_setup, ut_teardown,
10031                                                 test_DES_cipheronly_mb_all),
10032                 TEST_CASE_ST(ut_setup, ut_teardown,
10033                                                 test_DES_docsis_mb_all),
10034                 TEST_CASE_ST(ut_setup, ut_teardown,
10035                                                 test_3DES_cipheronly_mb_all),
10036                 TEST_CASE_ST(ut_setup, ut_teardown,
10037                         test_AES_CCM_authenticated_encryption_test_case_128_1),
10038                 TEST_CASE_ST(ut_setup, ut_teardown,
10039                         test_AES_CCM_authenticated_decryption_test_case_128_1),
10040                 TEST_CASE_ST(ut_setup, ut_teardown,
10041                         test_AES_CCM_authenticated_encryption_test_case_128_2),
10042                 TEST_CASE_ST(ut_setup, ut_teardown,
10043                         test_AES_CCM_authenticated_decryption_test_case_128_2),
10044                 TEST_CASE_ST(ut_setup, ut_teardown,
10045                         test_AES_CCM_authenticated_encryption_test_case_128_3),
10046                 TEST_CASE_ST(ut_setup, ut_teardown,
10047                         test_AES_CCM_authenticated_decryption_test_case_128_3),
10048
10049                 TEST_CASES_END() /**< NULL terminate unit test array */
10050         }
10051 };
10052
10053 static struct unit_test_suite cryptodev_openssl_testsuite  = {
10054         .suite_name = "Crypto Device OPENSSL Unit Test Suite",
10055         .setup = testsuite_setup,
10056         .teardown = testsuite_teardown,
10057         .unit_test_cases = {
10058                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10059                 TEST_CASE_ST(ut_setup, ut_teardown,
10060                                 test_multi_session_random_usage),
10061                 TEST_CASE_ST(ut_setup, ut_teardown,
10062                                 test_AES_chain_openssl_all),
10063                 TEST_CASE_ST(ut_setup, ut_teardown,
10064                                 test_AES_cipheronly_openssl_all),
10065                 TEST_CASE_ST(ut_setup, ut_teardown,
10066                                 test_3DES_chain_openssl_all),
10067                 TEST_CASE_ST(ut_setup, ut_teardown,
10068                                 test_3DES_cipheronly_openssl_all),
10069                 TEST_CASE_ST(ut_setup, ut_teardown,
10070                                 test_DES_cipheronly_openssl_all),
10071                 TEST_CASE_ST(ut_setup, ut_teardown,
10072                                 test_DES_docsis_openssl_all),
10073                 TEST_CASE_ST(ut_setup, ut_teardown,
10074                                 test_authonly_openssl_all),
10075
10076                 /** AES GCM Authenticated Encryption */
10077                 TEST_CASE_ST(ut_setup, ut_teardown,
10078                         test_AES_GCM_authenticated_encryption_test_case_1),
10079                 TEST_CASE_ST(ut_setup, ut_teardown,
10080                         test_AES_GCM_authenticated_encryption_test_case_2),
10081                 TEST_CASE_ST(ut_setup, ut_teardown,
10082                         test_AES_GCM_authenticated_encryption_test_case_3),
10083                 TEST_CASE_ST(ut_setup, ut_teardown,
10084                         test_AES_GCM_authenticated_encryption_test_case_4),
10085                 TEST_CASE_ST(ut_setup, ut_teardown,
10086                         test_AES_GCM_authenticated_encryption_test_case_5),
10087                 TEST_CASE_ST(ut_setup, ut_teardown,
10088                         test_AES_GCM_authenticated_encryption_test_case_6),
10089                 TEST_CASE_ST(ut_setup, ut_teardown,
10090                         test_AES_GCM_authenticated_encryption_test_case_7),
10091
10092                 /** AES GCM Authenticated Decryption */
10093                 TEST_CASE_ST(ut_setup, ut_teardown,
10094                         test_AES_GCM_authenticated_decryption_test_case_1),
10095                 TEST_CASE_ST(ut_setup, ut_teardown,
10096                         test_AES_GCM_authenticated_decryption_test_case_2),
10097                 TEST_CASE_ST(ut_setup, ut_teardown,
10098                         test_AES_GCM_authenticated_decryption_test_case_3),
10099                 TEST_CASE_ST(ut_setup, ut_teardown,
10100                         test_AES_GCM_authenticated_decryption_test_case_4),
10101                 TEST_CASE_ST(ut_setup, ut_teardown,
10102                         test_AES_GCM_authenticated_decryption_test_case_5),
10103                 TEST_CASE_ST(ut_setup, ut_teardown,
10104                         test_AES_GCM_authenticated_decryption_test_case_6),
10105                 TEST_CASE_ST(ut_setup, ut_teardown,
10106                         test_AES_GCM_authenticated_decryption_test_case_7),
10107
10108
10109                 /** AES GCM Authenticated Encryption 192 bits key */
10110                 TEST_CASE_ST(ut_setup, ut_teardown,
10111                         test_AES_GCM_auth_encryption_test_case_192_1),
10112                 TEST_CASE_ST(ut_setup, ut_teardown,
10113                         test_AES_GCM_auth_encryption_test_case_192_2),
10114                 TEST_CASE_ST(ut_setup, ut_teardown,
10115                         test_AES_GCM_auth_encryption_test_case_192_3),
10116                 TEST_CASE_ST(ut_setup, ut_teardown,
10117                         test_AES_GCM_auth_encryption_test_case_192_4),
10118                 TEST_CASE_ST(ut_setup, ut_teardown,
10119                         test_AES_GCM_auth_encryption_test_case_192_5),
10120                 TEST_CASE_ST(ut_setup, ut_teardown,
10121                         test_AES_GCM_auth_encryption_test_case_192_6),
10122                 TEST_CASE_ST(ut_setup, ut_teardown,
10123                         test_AES_GCM_auth_encryption_test_case_192_7),
10124
10125                 /** AES GCM Authenticated Decryption 192 bits key */
10126                 TEST_CASE_ST(ut_setup, ut_teardown,
10127                         test_AES_GCM_auth_decryption_test_case_192_1),
10128                 TEST_CASE_ST(ut_setup, ut_teardown,
10129                         test_AES_GCM_auth_decryption_test_case_192_2),
10130                 TEST_CASE_ST(ut_setup, ut_teardown,
10131                         test_AES_GCM_auth_decryption_test_case_192_3),
10132                 TEST_CASE_ST(ut_setup, ut_teardown,
10133                         test_AES_GCM_auth_decryption_test_case_192_4),
10134                 TEST_CASE_ST(ut_setup, ut_teardown,
10135                         test_AES_GCM_auth_decryption_test_case_192_5),
10136                 TEST_CASE_ST(ut_setup, ut_teardown,
10137                         test_AES_GCM_auth_decryption_test_case_192_6),
10138                 TEST_CASE_ST(ut_setup, ut_teardown,
10139                         test_AES_GCM_auth_decryption_test_case_192_7),
10140
10141                 /** AES GCM Authenticated Encryption 256 bits key */
10142                 TEST_CASE_ST(ut_setup, ut_teardown,
10143                         test_AES_GCM_auth_encryption_test_case_256_1),
10144                 TEST_CASE_ST(ut_setup, ut_teardown,
10145                         test_AES_GCM_auth_encryption_test_case_256_2),
10146                 TEST_CASE_ST(ut_setup, ut_teardown,
10147                         test_AES_GCM_auth_encryption_test_case_256_3),
10148                 TEST_CASE_ST(ut_setup, ut_teardown,
10149                         test_AES_GCM_auth_encryption_test_case_256_4),
10150                 TEST_CASE_ST(ut_setup, ut_teardown,
10151                         test_AES_GCM_auth_encryption_test_case_256_5),
10152                 TEST_CASE_ST(ut_setup, ut_teardown,
10153                         test_AES_GCM_auth_encryption_test_case_256_6),
10154                 TEST_CASE_ST(ut_setup, ut_teardown,
10155                         test_AES_GCM_auth_encryption_test_case_256_7),
10156
10157                 /** AES GCM Authenticated Decryption 256 bits key */
10158                 TEST_CASE_ST(ut_setup, ut_teardown,
10159                         test_AES_GCM_auth_decryption_test_case_256_1),
10160                 TEST_CASE_ST(ut_setup, ut_teardown,
10161                         test_AES_GCM_auth_decryption_test_case_256_2),
10162                 TEST_CASE_ST(ut_setup, ut_teardown,
10163                         test_AES_GCM_auth_decryption_test_case_256_3),
10164                 TEST_CASE_ST(ut_setup, ut_teardown,
10165                         test_AES_GCM_auth_decryption_test_case_256_4),
10166                 TEST_CASE_ST(ut_setup, ut_teardown,
10167                         test_AES_GCM_auth_decryption_test_case_256_5),
10168                 TEST_CASE_ST(ut_setup, ut_teardown,
10169                         test_AES_GCM_auth_decryption_test_case_256_6),
10170                 TEST_CASE_ST(ut_setup, ut_teardown,
10171                         test_AES_GCM_auth_decryption_test_case_256_7),
10172
10173                 /** AES GMAC Authentication */
10174                 TEST_CASE_ST(ut_setup, ut_teardown,
10175                         test_AES_GMAC_authentication_test_case_1),
10176                 TEST_CASE_ST(ut_setup, ut_teardown,
10177                         test_AES_GMAC_authentication_verify_test_case_1),
10178                 TEST_CASE_ST(ut_setup, ut_teardown,
10179                         test_AES_GMAC_authentication_test_case_2),
10180                 TEST_CASE_ST(ut_setup, ut_teardown,
10181                         test_AES_GMAC_authentication_verify_test_case_2),
10182                 TEST_CASE_ST(ut_setup, ut_teardown,
10183                         test_AES_GMAC_authentication_test_case_3),
10184                 TEST_CASE_ST(ut_setup, ut_teardown,
10185                         test_AES_GMAC_authentication_verify_test_case_3),
10186                 TEST_CASE_ST(ut_setup, ut_teardown,
10187                         test_AES_GMAC_authentication_test_case_4),
10188                 TEST_CASE_ST(ut_setup, ut_teardown,
10189                         test_AES_GMAC_authentication_verify_test_case_4),
10190
10191                 /** AES CCM Authenticated Encryption 128 bits key */
10192                 TEST_CASE_ST(ut_setup, ut_teardown,
10193                         test_AES_CCM_authenticated_encryption_test_case_128_1),
10194                 TEST_CASE_ST(ut_setup, ut_teardown,
10195                         test_AES_CCM_authenticated_encryption_test_case_128_2),
10196                 TEST_CASE_ST(ut_setup, ut_teardown,
10197                         test_AES_CCM_authenticated_encryption_test_case_128_3),
10198
10199                 /** AES CCM Authenticated Decryption 128 bits key*/
10200                 TEST_CASE_ST(ut_setup, ut_teardown,
10201                         test_AES_CCM_authenticated_decryption_test_case_128_1),
10202                 TEST_CASE_ST(ut_setup, ut_teardown,
10203                         test_AES_CCM_authenticated_decryption_test_case_128_2),
10204                 TEST_CASE_ST(ut_setup, ut_teardown,
10205                         test_AES_CCM_authenticated_decryption_test_case_128_3),
10206
10207                 /** AES CCM Authenticated Encryption 192 bits key */
10208                 TEST_CASE_ST(ut_setup, ut_teardown,
10209                         test_AES_CCM_authenticated_encryption_test_case_192_1),
10210                 TEST_CASE_ST(ut_setup, ut_teardown,
10211                         test_AES_CCM_authenticated_encryption_test_case_192_2),
10212                 TEST_CASE_ST(ut_setup, ut_teardown,
10213                         test_AES_CCM_authenticated_encryption_test_case_192_3),
10214
10215                 /** AES CCM Authenticated Decryption 192 bits key*/
10216                 TEST_CASE_ST(ut_setup, ut_teardown,
10217                         test_AES_CCM_authenticated_decryption_test_case_192_1),
10218                 TEST_CASE_ST(ut_setup, ut_teardown,
10219                         test_AES_CCM_authenticated_decryption_test_case_192_2),
10220                 TEST_CASE_ST(ut_setup, ut_teardown,
10221                         test_AES_CCM_authenticated_decryption_test_case_192_3),
10222
10223                 /** AES CCM Authenticated Encryption 256 bits key */
10224                 TEST_CASE_ST(ut_setup, ut_teardown,
10225                         test_AES_CCM_authenticated_encryption_test_case_256_1),
10226                 TEST_CASE_ST(ut_setup, ut_teardown,
10227                         test_AES_CCM_authenticated_encryption_test_case_256_2),
10228                 TEST_CASE_ST(ut_setup, ut_teardown,
10229                         test_AES_CCM_authenticated_encryption_test_case_256_3),
10230
10231                 /** AES CCM Authenticated Decryption 256 bits key*/
10232                 TEST_CASE_ST(ut_setup, ut_teardown,
10233                         test_AES_CCM_authenticated_decryption_test_case_256_1),
10234                 TEST_CASE_ST(ut_setup, ut_teardown,
10235                         test_AES_CCM_authenticated_decryption_test_case_256_2),
10236                 TEST_CASE_ST(ut_setup, ut_teardown,
10237                         test_AES_CCM_authenticated_decryption_test_case_256_3),
10238
10239                 /** Scatter-Gather */
10240                 TEST_CASE_ST(ut_setup, ut_teardown,
10241                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10242
10243                 /** Negative tests */
10244                 TEST_CASE_ST(ut_setup, ut_teardown,
10245                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
10246                 TEST_CASE_ST(ut_setup, ut_teardown,
10247                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10248                 TEST_CASE_ST(ut_setup, ut_teardown,
10249                         authentication_verify_AES128_GMAC_fail_data_corrupt),
10250                 TEST_CASE_ST(ut_setup, ut_teardown,
10251                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
10252                 TEST_CASE_ST(ut_setup, ut_teardown,
10253                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10254                 TEST_CASE_ST(ut_setup, ut_teardown,
10255                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10256
10257                 TEST_CASES_END() /**< NULL terminate unit test array */
10258         }
10259 };
10260
10261 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
10262         .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
10263         .setup = testsuite_setup,
10264         .teardown = testsuite_teardown,
10265         .unit_test_cases = {
10266                 /** AES GCM Authenticated Encryption */
10267                 TEST_CASE_ST(ut_setup, ut_teardown,
10268                         test_AES_GCM_authenticated_encryption_test_case_1),
10269                 TEST_CASE_ST(ut_setup, ut_teardown,
10270                         test_AES_GCM_authenticated_encryption_test_case_2),
10271                 TEST_CASE_ST(ut_setup, ut_teardown,
10272                         test_AES_GCM_authenticated_encryption_test_case_3),
10273                 TEST_CASE_ST(ut_setup, ut_teardown,
10274                         test_AES_GCM_authenticated_encryption_test_case_4),
10275                 TEST_CASE_ST(ut_setup, ut_teardown,
10276                         test_AES_GCM_authenticated_encryption_test_case_5),
10277                 TEST_CASE_ST(ut_setup, ut_teardown,
10278                         test_AES_GCM_authenticated_encryption_test_case_6),
10279                 TEST_CASE_ST(ut_setup, ut_teardown,
10280                         test_AES_GCM_authenticated_encryption_test_case_7),
10281
10282                 /** AES GCM Authenticated Decryption */
10283                 TEST_CASE_ST(ut_setup, ut_teardown,
10284                         test_AES_GCM_authenticated_decryption_test_case_1),
10285                 TEST_CASE_ST(ut_setup, ut_teardown,
10286                         test_AES_GCM_authenticated_decryption_test_case_2),
10287                 TEST_CASE_ST(ut_setup, ut_teardown,
10288                         test_AES_GCM_authenticated_decryption_test_case_3),
10289                 TEST_CASE_ST(ut_setup, ut_teardown,
10290                         test_AES_GCM_authenticated_decryption_test_case_4),
10291                 TEST_CASE_ST(ut_setup, ut_teardown,
10292                         test_AES_GCM_authenticated_decryption_test_case_5),
10293                 TEST_CASE_ST(ut_setup, ut_teardown,
10294                         test_AES_GCM_authenticated_decryption_test_case_6),
10295                 TEST_CASE_ST(ut_setup, ut_teardown,
10296                         test_AES_GCM_authenticated_decryption_test_case_7),
10297
10298                 /** AES GCM Authenticated Encryption 192 bits key */
10299                 TEST_CASE_ST(ut_setup, ut_teardown,
10300                         test_AES_GCM_auth_encryption_test_case_192_1),
10301                 TEST_CASE_ST(ut_setup, ut_teardown,
10302                         test_AES_GCM_auth_encryption_test_case_192_2),
10303                 TEST_CASE_ST(ut_setup, ut_teardown,
10304                         test_AES_GCM_auth_encryption_test_case_192_3),
10305                 TEST_CASE_ST(ut_setup, ut_teardown,
10306                         test_AES_GCM_auth_encryption_test_case_192_4),
10307                 TEST_CASE_ST(ut_setup, ut_teardown,
10308                         test_AES_GCM_auth_encryption_test_case_192_5),
10309                 TEST_CASE_ST(ut_setup, ut_teardown,
10310                         test_AES_GCM_auth_encryption_test_case_192_6),
10311                 TEST_CASE_ST(ut_setup, ut_teardown,
10312                         test_AES_GCM_auth_encryption_test_case_192_7),
10313
10314                 /** AES GCM Authenticated Decryption 192 bits key */
10315                 TEST_CASE_ST(ut_setup, ut_teardown,
10316                         test_AES_GCM_auth_decryption_test_case_192_1),
10317                 TEST_CASE_ST(ut_setup, ut_teardown,
10318                         test_AES_GCM_auth_decryption_test_case_192_2),
10319                 TEST_CASE_ST(ut_setup, ut_teardown,
10320                         test_AES_GCM_auth_decryption_test_case_192_3),
10321                 TEST_CASE_ST(ut_setup, ut_teardown,
10322                         test_AES_GCM_auth_decryption_test_case_192_4),
10323                 TEST_CASE_ST(ut_setup, ut_teardown,
10324                         test_AES_GCM_auth_decryption_test_case_192_5),
10325                 TEST_CASE_ST(ut_setup, ut_teardown,
10326                         test_AES_GCM_auth_decryption_test_case_192_6),
10327                 TEST_CASE_ST(ut_setup, ut_teardown,
10328                         test_AES_GCM_auth_decryption_test_case_192_7),
10329
10330                 /** AES GCM Authenticated Encryption 256 bits key */
10331                 TEST_CASE_ST(ut_setup, ut_teardown,
10332                         test_AES_GCM_auth_encryption_test_case_256_1),
10333                 TEST_CASE_ST(ut_setup, ut_teardown,
10334                         test_AES_GCM_auth_encryption_test_case_256_2),
10335                 TEST_CASE_ST(ut_setup, ut_teardown,
10336                         test_AES_GCM_auth_encryption_test_case_256_3),
10337                 TEST_CASE_ST(ut_setup, ut_teardown,
10338                         test_AES_GCM_auth_encryption_test_case_256_4),
10339                 TEST_CASE_ST(ut_setup, ut_teardown,
10340                         test_AES_GCM_auth_encryption_test_case_256_5),
10341                 TEST_CASE_ST(ut_setup, ut_teardown,
10342                         test_AES_GCM_auth_encryption_test_case_256_6),
10343                 TEST_CASE_ST(ut_setup, ut_teardown,
10344                         test_AES_GCM_auth_encryption_test_case_256_7),
10345
10346                 /** AES GCM Authenticated Decryption 256 bits key */
10347                 TEST_CASE_ST(ut_setup, ut_teardown,
10348                         test_AES_GCM_auth_decryption_test_case_256_1),
10349                 TEST_CASE_ST(ut_setup, ut_teardown,
10350                         test_AES_GCM_auth_decryption_test_case_256_2),
10351                 TEST_CASE_ST(ut_setup, ut_teardown,
10352                         test_AES_GCM_auth_decryption_test_case_256_3),
10353                 TEST_CASE_ST(ut_setup, ut_teardown,
10354                         test_AES_GCM_auth_decryption_test_case_256_4),
10355                 TEST_CASE_ST(ut_setup, ut_teardown,
10356                         test_AES_GCM_auth_decryption_test_case_256_5),
10357                 TEST_CASE_ST(ut_setup, ut_teardown,
10358                         test_AES_GCM_auth_decryption_test_case_256_6),
10359                 TEST_CASE_ST(ut_setup, ut_teardown,
10360                         test_AES_GCM_auth_decryption_test_case_256_7),
10361
10362                 /** AES GCM Authenticated Encryption big aad size */
10363                 TEST_CASE_ST(ut_setup, ut_teardown,
10364                         test_AES_GCM_auth_encryption_test_case_aad_1),
10365                 TEST_CASE_ST(ut_setup, ut_teardown,
10366                         test_AES_GCM_auth_encryption_test_case_aad_2),
10367
10368                 /** AES GCM Authenticated Decryption big aad size */
10369                 TEST_CASE_ST(ut_setup, ut_teardown,
10370                         test_AES_GCM_auth_decryption_test_case_aad_1),
10371                 TEST_CASE_ST(ut_setup, ut_teardown,
10372                         test_AES_GCM_auth_decryption_test_case_aad_2),
10373
10374                 /** AES GMAC Authentication */
10375                 TEST_CASE_ST(ut_setup, ut_teardown,
10376                         test_AES_GMAC_authentication_test_case_1),
10377                 TEST_CASE_ST(ut_setup, ut_teardown,
10378                         test_AES_GMAC_authentication_verify_test_case_1),
10379                 TEST_CASE_ST(ut_setup, ut_teardown,
10380                         test_AES_GMAC_authentication_test_case_3),
10381                 TEST_CASE_ST(ut_setup, ut_teardown,
10382                         test_AES_GMAC_authentication_verify_test_case_3),
10383                 TEST_CASE_ST(ut_setup, ut_teardown,
10384                         test_AES_GMAC_authentication_test_case_4),
10385                 TEST_CASE_ST(ut_setup, ut_teardown,
10386                         test_AES_GMAC_authentication_verify_test_case_4),
10387
10388                 /** Negative tests */
10389                 TEST_CASE_ST(ut_setup, ut_teardown,
10390                         authentication_verify_AES128_GMAC_fail_data_corrupt),
10391                 TEST_CASE_ST(ut_setup, ut_teardown,
10392                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
10393
10394                 /** Out of place tests */
10395                 TEST_CASE_ST(ut_setup, ut_teardown,
10396                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
10397                 TEST_CASE_ST(ut_setup, ut_teardown,
10398                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
10399
10400                 /** Session-less tests */
10401                 TEST_CASE_ST(ut_setup, ut_teardown,
10402                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
10403                 TEST_CASE_ST(ut_setup, ut_teardown,
10404                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
10405
10406                 /** Scatter-Gather */
10407                 TEST_CASE_ST(ut_setup, ut_teardown,
10408                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10409
10410                 TEST_CASES_END() /**< NULL terminate unit test array */
10411         }
10412 };
10413
10414 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
10415         .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
10416         .setup = testsuite_setup,
10417         .teardown = testsuite_teardown,
10418         .unit_test_cases = {
10419                 /** KASUMI encrypt only (UEA1) */
10420                 TEST_CASE_ST(ut_setup, ut_teardown,
10421                         test_kasumi_encryption_test_case_1),
10422                 TEST_CASE_ST(ut_setup, ut_teardown,
10423                         test_kasumi_encryption_test_case_1_sgl),
10424                 TEST_CASE_ST(ut_setup, ut_teardown,
10425                         test_kasumi_encryption_test_case_2),
10426                 TEST_CASE_ST(ut_setup, ut_teardown,
10427                         test_kasumi_encryption_test_case_3),
10428                 TEST_CASE_ST(ut_setup, ut_teardown,
10429                         test_kasumi_encryption_test_case_4),
10430                 TEST_CASE_ST(ut_setup, ut_teardown,
10431                         test_kasumi_encryption_test_case_5),
10432                 /** KASUMI decrypt only (UEA1) */
10433                 TEST_CASE_ST(ut_setup, ut_teardown,
10434                         test_kasumi_decryption_test_case_1),
10435                 TEST_CASE_ST(ut_setup, ut_teardown,
10436                         test_kasumi_decryption_test_case_2),
10437                 TEST_CASE_ST(ut_setup, ut_teardown,
10438                         test_kasumi_decryption_test_case_3),
10439                 TEST_CASE_ST(ut_setup, ut_teardown,
10440                         test_kasumi_decryption_test_case_4),
10441                 TEST_CASE_ST(ut_setup, ut_teardown,
10442                         test_kasumi_decryption_test_case_5),
10443
10444                 TEST_CASE_ST(ut_setup, ut_teardown,
10445                         test_kasumi_encryption_test_case_1_oop),
10446                 TEST_CASE_ST(ut_setup, ut_teardown,
10447                         test_kasumi_encryption_test_case_1_oop_sgl),
10448
10449
10450                 TEST_CASE_ST(ut_setup, ut_teardown,
10451                         test_kasumi_decryption_test_case_1_oop),
10452
10453                 /** KASUMI hash only (UIA1) */
10454                 TEST_CASE_ST(ut_setup, ut_teardown,
10455                         test_kasumi_hash_generate_test_case_1),
10456                 TEST_CASE_ST(ut_setup, ut_teardown,
10457                         test_kasumi_hash_generate_test_case_2),
10458                 TEST_CASE_ST(ut_setup, ut_teardown,
10459                         test_kasumi_hash_generate_test_case_3),
10460                 TEST_CASE_ST(ut_setup, ut_teardown,
10461                         test_kasumi_hash_generate_test_case_4),
10462                 TEST_CASE_ST(ut_setup, ut_teardown,
10463                         test_kasumi_hash_generate_test_case_5),
10464                 TEST_CASE_ST(ut_setup, ut_teardown,
10465                         test_kasumi_hash_generate_test_case_6),
10466                 TEST_CASE_ST(ut_setup, ut_teardown,
10467                         test_kasumi_hash_verify_test_case_1),
10468                 TEST_CASE_ST(ut_setup, ut_teardown,
10469                         test_kasumi_hash_verify_test_case_2),
10470                 TEST_CASE_ST(ut_setup, ut_teardown,
10471                         test_kasumi_hash_verify_test_case_3),
10472                 TEST_CASE_ST(ut_setup, ut_teardown,
10473                         test_kasumi_hash_verify_test_case_4),
10474                 TEST_CASE_ST(ut_setup, ut_teardown,
10475                         test_kasumi_hash_verify_test_case_5),
10476                 TEST_CASE_ST(ut_setup, ut_teardown,
10477                         test_kasumi_cipher_auth_test_case_1),
10478
10479                 /** KASUMI generate auth, then encrypt (F8) */
10480                 TEST_CASE_ST(ut_setup, ut_teardown,
10481                         test_kasumi_auth_cipher_test_case_1),
10482                 TEST_CASE_ST(ut_setup, ut_teardown,
10483                         test_kasumi_auth_cipher_test_case_2),
10484                 TEST_CASE_ST(ut_setup, ut_teardown,
10485                         test_kasumi_auth_cipher_test_case_2_oop),
10486
10487                 /** KASUMI decrypt (F8), then verify auth */
10488                 TEST_CASE_ST(ut_setup, ut_teardown,
10489                         test_kasumi_auth_cipher_verify_test_case_1),
10490                 TEST_CASE_ST(ut_setup, ut_teardown,
10491                         test_kasumi_auth_cipher_verify_test_case_2),
10492                 TEST_CASE_ST(ut_setup, ut_teardown,
10493                         test_kasumi_auth_cipher_verify_test_case_2_oop),
10494                 TEST_CASES_END() /**< NULL terminate unit test array */
10495         }
10496 };
10497 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
10498         .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
10499         .setup = testsuite_setup,
10500         .teardown = testsuite_teardown,
10501         .unit_test_cases = {
10502                 /** SNOW 3G encrypt only (UEA2) */
10503                 TEST_CASE_ST(ut_setup, ut_teardown,
10504                         test_snow3g_encryption_test_case_1),
10505                 TEST_CASE_ST(ut_setup, ut_teardown,
10506                         test_snow3g_encryption_test_case_2),
10507                 TEST_CASE_ST(ut_setup, ut_teardown,
10508                         test_snow3g_encryption_test_case_3),
10509                 TEST_CASE_ST(ut_setup, ut_teardown,
10510                         test_snow3g_encryption_test_case_4),
10511                 TEST_CASE_ST(ut_setup, ut_teardown,
10512                         test_snow3g_encryption_test_case_5),
10513                 TEST_CASE_ST(ut_setup, ut_teardown,
10514                         test_snow3g_auth_cipher_with_digest_test_case_1),
10515
10516                 TEST_CASE_ST(ut_setup, ut_teardown,
10517                         test_snow3g_encryption_test_case_1_oop),
10518                 TEST_CASE_ST(ut_setup, ut_teardown,
10519                                 test_snow3g_encryption_test_case_1_oop_sgl),
10520                 TEST_CASE_ST(ut_setup, ut_teardown,
10521                         test_snow3g_decryption_test_case_1_oop),
10522
10523                 TEST_CASE_ST(ut_setup, ut_teardown,
10524                         test_snow3g_encryption_test_case_1_offset_oop),
10525
10526                 /** SNOW 3G decrypt only (UEA2) */
10527                 TEST_CASE_ST(ut_setup, ut_teardown,
10528                         test_snow3g_decryption_test_case_1),
10529                 TEST_CASE_ST(ut_setup, ut_teardown,
10530                         test_snow3g_decryption_test_case_2),
10531                 TEST_CASE_ST(ut_setup, ut_teardown,
10532                         test_snow3g_decryption_test_case_3),
10533                 TEST_CASE_ST(ut_setup, ut_teardown,
10534                         test_snow3g_decryption_test_case_4),
10535                 TEST_CASE_ST(ut_setup, ut_teardown,
10536                         test_snow3g_decryption_test_case_5),
10537                 TEST_CASE_ST(ut_setup, ut_teardown,
10538                         test_snow3g_decryption_with_digest_test_case_1),
10539                 TEST_CASE_ST(ut_setup, ut_teardown,
10540                         test_snow3g_hash_generate_test_case_1),
10541                 TEST_CASE_ST(ut_setup, ut_teardown,
10542                         test_snow3g_hash_generate_test_case_2),
10543                 TEST_CASE_ST(ut_setup, ut_teardown,
10544                         test_snow3g_hash_generate_test_case_3),
10545                 /* Tests with buffers which length is not byte-aligned */
10546                 TEST_CASE_ST(ut_setup, ut_teardown,
10547                         test_snow3g_hash_generate_test_case_4),
10548                 TEST_CASE_ST(ut_setup, ut_teardown,
10549                         test_snow3g_hash_generate_test_case_5),
10550                 TEST_CASE_ST(ut_setup, ut_teardown,
10551                         test_snow3g_hash_generate_test_case_6),
10552                 TEST_CASE_ST(ut_setup, ut_teardown,
10553                         test_snow3g_hash_verify_test_case_1),
10554                 TEST_CASE_ST(ut_setup, ut_teardown,
10555                         test_snow3g_hash_verify_test_case_2),
10556                 TEST_CASE_ST(ut_setup, ut_teardown,
10557                         test_snow3g_hash_verify_test_case_3),
10558                 /* Tests with buffers which length is not byte-aligned */
10559                 TEST_CASE_ST(ut_setup, ut_teardown,
10560                         test_snow3g_hash_verify_test_case_4),
10561                 TEST_CASE_ST(ut_setup, ut_teardown,
10562                         test_snow3g_hash_verify_test_case_5),
10563                 TEST_CASE_ST(ut_setup, ut_teardown,
10564                         test_snow3g_hash_verify_test_case_6),
10565                 TEST_CASE_ST(ut_setup, ut_teardown,
10566                         test_snow3g_cipher_auth_test_case_1),
10567
10568                 /** SNOW 3G generate auth, then encrypt (UEA2) */
10569                 TEST_CASE_ST(ut_setup, ut_teardown,
10570                         test_snow3g_auth_cipher_test_case_1),
10571                 TEST_CASE_ST(ut_setup, ut_teardown,
10572                         test_snow3g_auth_cipher_test_case_2),
10573                 TEST_CASE_ST(ut_setup, ut_teardown,
10574                         test_snow3g_auth_cipher_test_case_2_oop),
10575                 TEST_CASE_ST(ut_setup, ut_teardown,
10576                         test_snow3g_auth_cipher_part_digest_enc),
10577                 TEST_CASE_ST(ut_setup, ut_teardown,
10578                         test_snow3g_auth_cipher_part_digest_enc_oop),
10579
10580                 /** SNOW 3G decrypt (UEA2), then verify auth */
10581                 TEST_CASE_ST(ut_setup, ut_teardown,
10582                         test_snow3g_auth_cipher_verify_test_case_1),
10583                 TEST_CASE_ST(ut_setup, ut_teardown,
10584                         test_snow3g_auth_cipher_verify_test_case_2),
10585                 TEST_CASE_ST(ut_setup, ut_teardown,
10586                         test_snow3g_auth_cipher_verify_test_case_2_oop),
10587                 TEST_CASE_ST(ut_setup, ut_teardown,
10588                         test_snow3g_auth_cipher_verify_part_digest_enc),
10589                 TEST_CASE_ST(ut_setup, ut_teardown,
10590                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
10591
10592                 TEST_CASES_END() /**< NULL terminate unit test array */
10593         }
10594 };
10595
10596 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
10597         .suite_name = "Crypto Device SW ZUC Unit Test Suite",
10598         .setup = testsuite_setup,
10599         .teardown = testsuite_teardown,
10600         .unit_test_cases = {
10601                 /** ZUC encrypt only (EEA3) */
10602                 TEST_CASE_ST(ut_setup, ut_teardown,
10603                         test_zuc_encryption_test_case_1),
10604                 TEST_CASE_ST(ut_setup, ut_teardown,
10605                         test_zuc_encryption_test_case_2),
10606                 TEST_CASE_ST(ut_setup, ut_teardown,
10607                         test_zuc_encryption_test_case_3),
10608                 TEST_CASE_ST(ut_setup, ut_teardown,
10609                         test_zuc_encryption_test_case_4),
10610                 TEST_CASE_ST(ut_setup, ut_teardown,
10611                         test_zuc_encryption_test_case_5),
10612                 TEST_CASE_ST(ut_setup, ut_teardown,
10613                         test_zuc_hash_generate_test_case_1),
10614                 TEST_CASE_ST(ut_setup, ut_teardown,
10615                         test_zuc_hash_generate_test_case_2),
10616                 TEST_CASE_ST(ut_setup, ut_teardown,
10617                         test_zuc_hash_generate_test_case_3),
10618                 TEST_CASE_ST(ut_setup, ut_teardown,
10619                         test_zuc_hash_generate_test_case_4),
10620                 TEST_CASE_ST(ut_setup, ut_teardown,
10621                         test_zuc_hash_generate_test_case_5),
10622                 TEST_CASE_ST(ut_setup, ut_teardown,
10623                         test_zuc_encryption_test_case_6_sgl),
10624                 TEST_CASES_END() /**< NULL terminate unit test array */
10625         }
10626 };
10627
10628 static struct unit_test_suite cryptodev_caam_jr_testsuite  = {
10629         .suite_name = "Crypto CAAM JR Unit Test Suite",
10630         .setup = testsuite_setup,
10631         .teardown = testsuite_teardown,
10632         .unit_test_cases = {
10633                 TEST_CASE_ST(ut_setup, ut_teardown,
10634                              test_device_configure_invalid_dev_id),
10635                 TEST_CASE_ST(ut_setup, ut_teardown,
10636                              test_multi_session),
10637
10638                 TEST_CASE_ST(ut_setup, ut_teardown,
10639                              test_AES_chain_caam_jr_all),
10640                 TEST_CASE_ST(ut_setup, ut_teardown,
10641                              test_3DES_chain_caam_jr_all),
10642                 TEST_CASE_ST(ut_setup, ut_teardown,
10643                              test_AES_cipheronly_caam_jr_all),
10644                 TEST_CASE_ST(ut_setup, ut_teardown,
10645                              test_3DES_cipheronly_caam_jr_all),
10646                 TEST_CASE_ST(ut_setup, ut_teardown,
10647                              test_authonly_caam_jr_all),
10648
10649                 TEST_CASES_END() /**< NULL terminate unit test array */
10650         }
10651 };
10652
10653 static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
10654         .suite_name = "Crypto DPAA_SEC Unit Test Suite",
10655         .setup = testsuite_setup,
10656         .teardown = testsuite_teardown,
10657         .unit_test_cases = {
10658                 TEST_CASE_ST(ut_setup, ut_teardown,
10659                              test_device_configure_invalid_dev_id),
10660                 TEST_CASE_ST(ut_setup, ut_teardown,
10661                              test_multi_session),
10662
10663                 TEST_CASE_ST(ut_setup, ut_teardown,
10664                              test_AES_chain_dpaa_sec_all),
10665                 TEST_CASE_ST(ut_setup, ut_teardown,
10666                              test_3DES_chain_dpaa_sec_all),
10667                 TEST_CASE_ST(ut_setup, ut_teardown,
10668                              test_AES_cipheronly_dpaa_sec_all),
10669                 TEST_CASE_ST(ut_setup, ut_teardown,
10670                              test_3DES_cipheronly_dpaa_sec_all),
10671                 TEST_CASE_ST(ut_setup, ut_teardown,
10672                              test_authonly_dpaa_sec_all),
10673
10674                 /** AES GCM Authenticated Encryption */
10675                 TEST_CASE_ST(ut_setup, ut_teardown,
10676                         test_AES_GCM_authenticated_encryption_test_case_1),
10677                 TEST_CASE_ST(ut_setup, ut_teardown,
10678                         test_AES_GCM_authenticated_encryption_test_case_2),
10679                 TEST_CASE_ST(ut_setup, ut_teardown,
10680                         test_AES_GCM_authenticated_encryption_test_case_3),
10681                 TEST_CASE_ST(ut_setup, ut_teardown,
10682                         test_AES_GCM_authenticated_encryption_test_case_4),
10683                 TEST_CASE_ST(ut_setup, ut_teardown,
10684                         test_AES_GCM_authenticated_encryption_test_case_5),
10685                 TEST_CASE_ST(ut_setup, ut_teardown,
10686                         test_AES_GCM_authenticated_encryption_test_case_6),
10687                 TEST_CASE_ST(ut_setup, ut_teardown,
10688                         test_AES_GCM_authenticated_encryption_test_case_7),
10689
10690                 /** AES GCM Authenticated Decryption */
10691                 TEST_CASE_ST(ut_setup, ut_teardown,
10692                         test_AES_GCM_authenticated_decryption_test_case_1),
10693                 TEST_CASE_ST(ut_setup, ut_teardown,
10694                         test_AES_GCM_authenticated_decryption_test_case_2),
10695                 TEST_CASE_ST(ut_setup, ut_teardown,
10696                         test_AES_GCM_authenticated_decryption_test_case_3),
10697                 TEST_CASE_ST(ut_setup, ut_teardown,
10698                         test_AES_GCM_authenticated_decryption_test_case_4),
10699                 TEST_CASE_ST(ut_setup, ut_teardown,
10700                         test_AES_GCM_authenticated_decryption_test_case_5),
10701                 TEST_CASE_ST(ut_setup, ut_teardown,
10702                         test_AES_GCM_authenticated_decryption_test_case_6),
10703                 TEST_CASE_ST(ut_setup, ut_teardown,
10704                         test_AES_GCM_authenticated_decryption_test_case_7),
10705
10706                 /** AES GCM Authenticated Encryption 256 bits key */
10707                 TEST_CASE_ST(ut_setup, ut_teardown,
10708                         test_AES_GCM_auth_encryption_test_case_256_1),
10709                 TEST_CASE_ST(ut_setup, ut_teardown,
10710                         test_AES_GCM_auth_encryption_test_case_256_2),
10711                 TEST_CASE_ST(ut_setup, ut_teardown,
10712                         test_AES_GCM_auth_encryption_test_case_256_3),
10713                 TEST_CASE_ST(ut_setup, ut_teardown,
10714                         test_AES_GCM_auth_encryption_test_case_256_4),
10715                 TEST_CASE_ST(ut_setup, ut_teardown,
10716                         test_AES_GCM_auth_encryption_test_case_256_5),
10717                 TEST_CASE_ST(ut_setup, ut_teardown,
10718                         test_AES_GCM_auth_encryption_test_case_256_6),
10719                 TEST_CASE_ST(ut_setup, ut_teardown,
10720                         test_AES_GCM_auth_encryption_test_case_256_7),
10721
10722                 /** AES GCM Authenticated Decryption 256 bits key */
10723                 TEST_CASE_ST(ut_setup, ut_teardown,
10724                         test_AES_GCM_auth_decryption_test_case_256_1),
10725                 TEST_CASE_ST(ut_setup, ut_teardown,
10726                         test_AES_GCM_auth_decryption_test_case_256_2),
10727                 TEST_CASE_ST(ut_setup, ut_teardown,
10728                         test_AES_GCM_auth_decryption_test_case_256_3),
10729                 TEST_CASE_ST(ut_setup, ut_teardown,
10730                         test_AES_GCM_auth_decryption_test_case_256_4),
10731                 TEST_CASE_ST(ut_setup, ut_teardown,
10732                         test_AES_GCM_auth_decryption_test_case_256_5),
10733                 TEST_CASE_ST(ut_setup, ut_teardown,
10734                         test_AES_GCM_auth_decryption_test_case_256_6),
10735                 TEST_CASE_ST(ut_setup, ut_teardown,
10736                         test_AES_GCM_auth_decryption_test_case_256_7),
10737
10738                 /** Out of place tests */
10739                 TEST_CASE_ST(ut_setup, ut_teardown,
10740                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
10741                 TEST_CASE_ST(ut_setup, ut_teardown,
10742                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
10743
10744                 /** Scatter-Gather */
10745                 TEST_CASE_ST(ut_setup, ut_teardown,
10746                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10747                 TEST_CASE_ST(ut_setup, ut_teardown,
10748                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10749                 TEST_CASE_ST(ut_setup, ut_teardown,
10750                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10751                 TEST_CASE_ST(ut_setup, ut_teardown,
10752                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10753
10754                 TEST_CASES_END() /**< NULL terminate unit test array */
10755         }
10756 };
10757
10758 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
10759         .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10760         .setup = testsuite_setup,
10761         .teardown = testsuite_teardown,
10762         .unit_test_cases = {
10763                 TEST_CASE_ST(ut_setup, ut_teardown,
10764                         test_device_configure_invalid_dev_id),
10765                 TEST_CASE_ST(ut_setup, ut_teardown,
10766                         test_multi_session),
10767
10768                 TEST_CASE_ST(ut_setup, ut_teardown,
10769                         test_AES_chain_dpaa2_sec_all),
10770                 TEST_CASE_ST(ut_setup, ut_teardown,
10771                         test_3DES_chain_dpaa2_sec_all),
10772                 TEST_CASE_ST(ut_setup, ut_teardown,
10773                         test_AES_cipheronly_dpaa2_sec_all),
10774                 TEST_CASE_ST(ut_setup, ut_teardown,
10775                         test_3DES_cipheronly_dpaa2_sec_all),
10776                 TEST_CASE_ST(ut_setup, ut_teardown,
10777                         test_authonly_dpaa2_sec_all),
10778
10779                 /** AES GCM Authenticated Encryption */
10780                 TEST_CASE_ST(ut_setup, ut_teardown,
10781                         test_AES_GCM_authenticated_encryption_test_case_1),
10782                 TEST_CASE_ST(ut_setup, ut_teardown,
10783                         test_AES_GCM_authenticated_encryption_test_case_2),
10784                 TEST_CASE_ST(ut_setup, ut_teardown,
10785                         test_AES_GCM_authenticated_encryption_test_case_3),
10786                 TEST_CASE_ST(ut_setup, ut_teardown,
10787                         test_AES_GCM_authenticated_encryption_test_case_4),
10788                 TEST_CASE_ST(ut_setup, ut_teardown,
10789                         test_AES_GCM_authenticated_encryption_test_case_5),
10790                 TEST_CASE_ST(ut_setup, ut_teardown,
10791                         test_AES_GCM_authenticated_encryption_test_case_6),
10792                 TEST_CASE_ST(ut_setup, ut_teardown,
10793                         test_AES_GCM_authenticated_encryption_test_case_7),
10794
10795                 /** AES GCM Authenticated Decryption */
10796                 TEST_CASE_ST(ut_setup, ut_teardown,
10797                         test_AES_GCM_authenticated_decryption_test_case_1),
10798                 TEST_CASE_ST(ut_setup, ut_teardown,
10799                         test_AES_GCM_authenticated_decryption_test_case_2),
10800                 TEST_CASE_ST(ut_setup, ut_teardown,
10801                         test_AES_GCM_authenticated_decryption_test_case_3),
10802                 TEST_CASE_ST(ut_setup, ut_teardown,
10803                         test_AES_GCM_authenticated_decryption_test_case_4),
10804                 TEST_CASE_ST(ut_setup, ut_teardown,
10805                         test_AES_GCM_authenticated_decryption_test_case_5),
10806                 TEST_CASE_ST(ut_setup, ut_teardown,
10807                         test_AES_GCM_authenticated_decryption_test_case_6),
10808                 TEST_CASE_ST(ut_setup, ut_teardown,
10809                         test_AES_GCM_authenticated_decryption_test_case_7),
10810
10811                 /** AES GCM Authenticated Encryption 192 bits key */
10812                 TEST_CASE_ST(ut_setup, ut_teardown,
10813                         test_AES_GCM_auth_encryption_test_case_192_1),
10814                 TEST_CASE_ST(ut_setup, ut_teardown,
10815                         test_AES_GCM_auth_encryption_test_case_192_2),
10816                 TEST_CASE_ST(ut_setup, ut_teardown,
10817                         test_AES_GCM_auth_encryption_test_case_192_3),
10818                 TEST_CASE_ST(ut_setup, ut_teardown,
10819                         test_AES_GCM_auth_encryption_test_case_192_4),
10820                 TEST_CASE_ST(ut_setup, ut_teardown,
10821                         test_AES_GCM_auth_encryption_test_case_192_5),
10822                 TEST_CASE_ST(ut_setup, ut_teardown,
10823                         test_AES_GCM_auth_encryption_test_case_192_6),
10824                 TEST_CASE_ST(ut_setup, ut_teardown,
10825                         test_AES_GCM_auth_encryption_test_case_192_7),
10826
10827                 /** AES GCM Authenticated Decryption 192 bits key */
10828                 TEST_CASE_ST(ut_setup, ut_teardown,
10829                         test_AES_GCM_auth_decryption_test_case_192_1),
10830                 TEST_CASE_ST(ut_setup, ut_teardown,
10831                         test_AES_GCM_auth_decryption_test_case_192_2),
10832                 TEST_CASE_ST(ut_setup, ut_teardown,
10833                         test_AES_GCM_auth_decryption_test_case_192_3),
10834                 TEST_CASE_ST(ut_setup, ut_teardown,
10835                         test_AES_GCM_auth_decryption_test_case_192_4),
10836                 TEST_CASE_ST(ut_setup, ut_teardown,
10837                         test_AES_GCM_auth_decryption_test_case_192_5),
10838                 TEST_CASE_ST(ut_setup, ut_teardown,
10839                         test_AES_GCM_auth_decryption_test_case_192_6),
10840                 TEST_CASE_ST(ut_setup, ut_teardown,
10841                         test_AES_GCM_auth_decryption_test_case_192_7),
10842
10843                 /** AES GCM Authenticated Encryption 256 bits key */
10844                 TEST_CASE_ST(ut_setup, ut_teardown,
10845                         test_AES_GCM_auth_encryption_test_case_256_1),
10846                 TEST_CASE_ST(ut_setup, ut_teardown,
10847                         test_AES_GCM_auth_encryption_test_case_256_2),
10848                 TEST_CASE_ST(ut_setup, ut_teardown,
10849                         test_AES_GCM_auth_encryption_test_case_256_3),
10850                 TEST_CASE_ST(ut_setup, ut_teardown,
10851                         test_AES_GCM_auth_encryption_test_case_256_4),
10852                 TEST_CASE_ST(ut_setup, ut_teardown,
10853                         test_AES_GCM_auth_encryption_test_case_256_5),
10854                 TEST_CASE_ST(ut_setup, ut_teardown,
10855                         test_AES_GCM_auth_encryption_test_case_256_6),
10856                 TEST_CASE_ST(ut_setup, ut_teardown,
10857                         test_AES_GCM_auth_encryption_test_case_256_7),
10858
10859                 /** AES GCM Authenticated Decryption 256 bits key */
10860                 TEST_CASE_ST(ut_setup, ut_teardown,
10861                         test_AES_GCM_auth_decryption_test_case_256_1),
10862                 TEST_CASE_ST(ut_setup, ut_teardown,
10863                         test_AES_GCM_auth_decryption_test_case_256_2),
10864                 TEST_CASE_ST(ut_setup, ut_teardown,
10865                         test_AES_GCM_auth_decryption_test_case_256_3),
10866                 TEST_CASE_ST(ut_setup, ut_teardown,
10867                         test_AES_GCM_auth_decryption_test_case_256_4),
10868                 TEST_CASE_ST(ut_setup, ut_teardown,
10869                         test_AES_GCM_auth_decryption_test_case_256_5),
10870                 TEST_CASE_ST(ut_setup, ut_teardown,
10871                         test_AES_GCM_auth_decryption_test_case_256_6),
10872                 TEST_CASE_ST(ut_setup, ut_teardown,
10873                         test_AES_GCM_auth_decryption_test_case_256_7),
10874
10875                 /** Out of place tests */
10876                 TEST_CASE_ST(ut_setup, ut_teardown,
10877                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
10878                 TEST_CASE_ST(ut_setup, ut_teardown,
10879                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
10880
10881                 /** Scatter-Gather */
10882                 TEST_CASE_ST(ut_setup, ut_teardown,
10883                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10884                 TEST_CASE_ST(ut_setup, ut_teardown,
10885                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10886                 TEST_CASE_ST(ut_setup, ut_teardown,
10887                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10888                 TEST_CASE_ST(ut_setup, ut_teardown,
10889                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10890
10891                 TEST_CASES_END() /**< NULL terminate unit test array */
10892         }
10893 };
10894
10895 static struct unit_test_suite cryptodev_null_testsuite  = {
10896         .suite_name = "Crypto Device NULL Unit Test Suite",
10897         .setup = testsuite_setup,
10898         .teardown = testsuite_teardown,
10899         .unit_test_cases = {
10900                 TEST_CASE_ST(ut_setup, ut_teardown,
10901                         test_null_invalid_operation),
10902                 TEST_CASE_ST(ut_setup, ut_teardown,
10903                         test_null_burst_operation),
10904                 TEST_CASE_ST(ut_setup, ut_teardown,
10905                         test_AES_chain_null_all),
10906                 TEST_CASE_ST(ut_setup, ut_teardown,
10907                         test_AES_cipheronly_null_all),
10908                 TEST_CASE_ST(ut_setup, ut_teardown,
10909                                 test_authonly_null_all),
10910
10911                 TEST_CASES_END() /**< NULL terminate unit test array */
10912         }
10913 };
10914
10915 static struct unit_test_suite cryptodev_armv8_testsuite  = {
10916         .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10917         .setup = testsuite_setup,
10918         .teardown = testsuite_teardown,
10919         .unit_test_cases = {
10920                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10921
10922                 /** Negative tests */
10923                 TEST_CASE_ST(ut_setup, ut_teardown,
10924                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10925                 TEST_CASE_ST(ut_setup, ut_teardown,
10926                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10927
10928                 TEST_CASES_END() /**< NULL terminate unit test array */
10929         }
10930 };
10931
10932 static struct unit_test_suite cryptodev_mrvl_testsuite  = {
10933         .suite_name = "Crypto Device Marvell Component Test Suite",
10934         .setup = testsuite_setup,
10935         .teardown = testsuite_teardown,
10936         .unit_test_cases = {
10937                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10938                 TEST_CASE_ST(ut_setup, ut_teardown,
10939                                 test_multi_session_random_usage),
10940                 TEST_CASE_ST(ut_setup, ut_teardown,
10941                                 test_AES_chain_mrvl_all),
10942                 TEST_CASE_ST(ut_setup, ut_teardown,
10943                                 test_AES_cipheronly_mrvl_all),
10944                 TEST_CASE_ST(ut_setup, ut_teardown,
10945                                 test_authonly_mrvl_all),
10946                 TEST_CASE_ST(ut_setup, ut_teardown,
10947                                 test_3DES_chain_mrvl_all),
10948                 TEST_CASE_ST(ut_setup, ut_teardown,
10949                                 test_3DES_cipheronly_mrvl_all),
10950
10951                 /** Negative tests */
10952                 TEST_CASE_ST(ut_setup, ut_teardown,
10953                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
10954                 TEST_CASE_ST(ut_setup, ut_teardown,
10955                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10956                 TEST_CASE_ST(ut_setup, ut_teardown,
10957                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10958                 TEST_CASE_ST(ut_setup, ut_teardown,
10959                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10960
10961                 TEST_CASES_END() /**< NULL terminate unit test array */
10962         }
10963 };
10964
10965 static struct unit_test_suite cryptodev_ccp_testsuite  = {
10966         .suite_name = "Crypto Device CCP Unit Test Suite",
10967         .setup = testsuite_setup,
10968         .teardown = testsuite_teardown,
10969         .unit_test_cases = {
10970                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10971                 TEST_CASE_ST(ut_setup, ut_teardown,
10972                                 test_multi_session_random_usage),
10973                 TEST_CASE_ST(ut_setup, ut_teardown,
10974                                 test_AES_chain_ccp_all),
10975                 TEST_CASE_ST(ut_setup, ut_teardown,
10976                                 test_AES_cipheronly_ccp_all),
10977                 TEST_CASE_ST(ut_setup, ut_teardown,
10978                                 test_3DES_chain_ccp_all),
10979                 TEST_CASE_ST(ut_setup, ut_teardown,
10980                                 test_3DES_cipheronly_ccp_all),
10981                 TEST_CASE_ST(ut_setup, ut_teardown,
10982                                 test_authonly_ccp_all),
10983
10984                 /** Negative tests */
10985                 TEST_CASE_ST(ut_setup, ut_teardown,
10986                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
10987                 TEST_CASE_ST(ut_setup, ut_teardown,
10988                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10989                 TEST_CASE_ST(ut_setup, ut_teardown,
10990                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10991                 TEST_CASE_ST(ut_setup, ut_teardown,
10992                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10993
10994                 TEST_CASES_END() /**< NULL terminate unit test array */
10995         }
10996 };
10997
10998 static struct unit_test_suite cryptodev_octeontx_testsuite  = {
10999         .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
11000         .setup = testsuite_setup,
11001         .teardown = testsuite_teardown,
11002         .unit_test_cases = {
11003                 TEST_CASE_ST(ut_setup, ut_teardown,
11004                         test_AES_chain_octeontx_all),
11005                 TEST_CASE_ST(ut_setup, ut_teardown,
11006                         test_AES_cipheronly_octeontx_all),
11007                 TEST_CASE_ST(ut_setup, ut_teardown,
11008                         test_3DES_chain_octeontx_all),
11009                 TEST_CASE_ST(ut_setup, ut_teardown,
11010                         test_3DES_cipheronly_octeontx_all),
11011                 TEST_CASE_ST(ut_setup, ut_teardown,
11012                         test_authonly_octeontx_all),
11013
11014                 /** AES GCM Authenticated Encryption */
11015                 TEST_CASE_ST(ut_setup, ut_teardown,
11016                         test_AES_GCM_authenticated_encryption_test_case_1),
11017                 TEST_CASE_ST(ut_setup, ut_teardown,
11018                         test_AES_GCM_authenticated_encryption_test_case_2),
11019                 TEST_CASE_ST(ut_setup, ut_teardown,
11020                         test_AES_GCM_authenticated_encryption_test_case_3),
11021                 TEST_CASE_ST(ut_setup, ut_teardown,
11022                         test_AES_GCM_authenticated_encryption_test_case_4),
11023                 TEST_CASE_ST(ut_setup, ut_teardown,
11024                         test_AES_GCM_authenticated_encryption_test_case_5),
11025                 TEST_CASE_ST(ut_setup, ut_teardown,
11026                         test_AES_GCM_authenticated_encryption_test_case_6),
11027                 TEST_CASE_ST(ut_setup, ut_teardown,
11028                         test_AES_GCM_authenticated_encryption_test_case_7),
11029
11030                 /** AES GCM Authenticated Decryption */
11031                 TEST_CASE_ST(ut_setup, ut_teardown,
11032                         test_AES_GCM_authenticated_decryption_test_case_1),
11033                 TEST_CASE_ST(ut_setup, ut_teardown,
11034                         test_AES_GCM_authenticated_decryption_test_case_2),
11035                 TEST_CASE_ST(ut_setup, ut_teardown,
11036                         test_AES_GCM_authenticated_decryption_test_case_3),
11037                 TEST_CASE_ST(ut_setup, ut_teardown,
11038                         test_AES_GCM_authenticated_decryption_test_case_4),
11039                 TEST_CASE_ST(ut_setup, ut_teardown,
11040                         test_AES_GCM_authenticated_decryption_test_case_5),
11041                 TEST_CASE_ST(ut_setup, ut_teardown,
11042                         test_AES_GCM_authenticated_decryption_test_case_6),
11043                 TEST_CASE_ST(ut_setup, ut_teardown,
11044                         test_AES_GCM_authenticated_decryption_test_case_7),
11045                 /** AES GMAC Authentication */
11046                 TEST_CASE_ST(ut_setup, ut_teardown,
11047                         test_AES_GMAC_authentication_test_case_1),
11048                 TEST_CASE_ST(ut_setup, ut_teardown,
11049                         test_AES_GMAC_authentication_verify_test_case_1),
11050                 TEST_CASE_ST(ut_setup, ut_teardown,
11051                         test_AES_GMAC_authentication_test_case_2),
11052                 TEST_CASE_ST(ut_setup, ut_teardown,
11053                         test_AES_GMAC_authentication_verify_test_case_2),
11054                 TEST_CASE_ST(ut_setup, ut_teardown,
11055                         test_AES_GMAC_authentication_test_case_3),
11056                 TEST_CASE_ST(ut_setup, ut_teardown,
11057                         test_AES_GMAC_authentication_verify_test_case_3),
11058
11059                 /** SNOW 3G encrypt only (UEA2) */
11060                 TEST_CASE_ST(ut_setup, ut_teardown,
11061                         test_snow3g_encryption_test_case_1),
11062                 TEST_CASE_ST(ut_setup, ut_teardown,
11063                         test_snow3g_encryption_test_case_2),
11064                 TEST_CASE_ST(ut_setup, ut_teardown,
11065                         test_snow3g_encryption_test_case_3),
11066                 TEST_CASE_ST(ut_setup, ut_teardown,
11067                         test_snow3g_encryption_test_case_4),
11068                 TEST_CASE_ST(ut_setup, ut_teardown,
11069                         test_snow3g_encryption_test_case_5),
11070
11071                 TEST_CASE_ST(ut_setup, ut_teardown,
11072                         test_snow3g_encryption_test_case_1_oop),
11073                 TEST_CASE_ST(ut_setup, ut_teardown,
11074                         test_snow3g_decryption_test_case_1_oop),
11075                 TEST_CASE_ST(ut_setup, ut_teardown,
11076                         test_snow3g_encryption_test_case_1_oop_sgl),
11077
11078                 /** SNOW 3G decrypt only (UEA2) */
11079                 TEST_CASE_ST(ut_setup, ut_teardown,
11080                         test_snow3g_decryption_test_case_1),
11081                 TEST_CASE_ST(ut_setup, ut_teardown,
11082                         test_snow3g_decryption_test_case_2),
11083                 TEST_CASE_ST(ut_setup, ut_teardown,
11084                         test_snow3g_decryption_test_case_3),
11085                 TEST_CASE_ST(ut_setup, ut_teardown,
11086                         test_snow3g_decryption_test_case_4),
11087                 TEST_CASE_ST(ut_setup, ut_teardown,
11088                         test_snow3g_decryption_test_case_5),
11089
11090                 TEST_CASE_ST(ut_setup, ut_teardown,
11091                         test_snow3g_hash_generate_test_case_1),
11092                 TEST_CASE_ST(ut_setup, ut_teardown,
11093                         test_snow3g_hash_generate_test_case_2),
11094                 TEST_CASE_ST(ut_setup, ut_teardown,
11095                         test_snow3g_hash_generate_test_case_3),
11096                 TEST_CASE_ST(ut_setup, ut_teardown,
11097                         test_snow3g_hash_verify_test_case_1),
11098                 TEST_CASE_ST(ut_setup, ut_teardown,
11099                         test_snow3g_hash_verify_test_case_2),
11100                 TEST_CASE_ST(ut_setup, ut_teardown,
11101                         test_snow3g_hash_verify_test_case_3),
11102
11103                 /** ZUC encrypt only (EEA3) */
11104                 TEST_CASE_ST(ut_setup, ut_teardown,
11105                         test_zuc_encryption_test_case_1),
11106                 TEST_CASE_ST(ut_setup, ut_teardown,
11107                         test_zuc_encryption_test_case_2),
11108                 TEST_CASE_ST(ut_setup, ut_teardown,
11109                         test_zuc_encryption_test_case_3),
11110                 TEST_CASE_ST(ut_setup, ut_teardown,
11111                         test_zuc_encryption_test_case_4),
11112                 TEST_CASE_ST(ut_setup, ut_teardown,
11113                         test_zuc_encryption_test_case_5),
11114                 TEST_CASE_ST(ut_setup, ut_teardown,
11115                         test_zuc_hash_generate_test_case_1),
11116                 TEST_CASE_ST(ut_setup, ut_teardown,
11117                         test_zuc_hash_generate_test_case_2),
11118                 TEST_CASE_ST(ut_setup, ut_teardown,
11119                         test_zuc_hash_generate_test_case_3),
11120                 TEST_CASE_ST(ut_setup, ut_teardown,
11121                         test_zuc_hash_generate_test_case_4),
11122                 TEST_CASE_ST(ut_setup, ut_teardown,
11123                         test_zuc_hash_generate_test_case_5),
11124                 TEST_CASE_ST(ut_setup, ut_teardown,
11125                         test_zuc_encryption_test_case_6_sgl),
11126
11127                 /** KASUMI encrypt only (UEA1) */
11128                 TEST_CASE_ST(ut_setup, ut_teardown,
11129                         test_kasumi_encryption_test_case_1),
11130                 TEST_CASE_ST(ut_setup, ut_teardown,
11131                         test_kasumi_encryption_test_case_2),
11132                 TEST_CASE_ST(ut_setup, ut_teardown,
11133                         test_kasumi_encryption_test_case_3),
11134                 TEST_CASE_ST(ut_setup, ut_teardown,
11135                         test_kasumi_encryption_test_case_4),
11136                 TEST_CASE_ST(ut_setup, ut_teardown,
11137                         test_kasumi_encryption_test_case_5),
11138                 TEST_CASE_ST(ut_setup, ut_teardown,
11139                         test_kasumi_encryption_test_case_1_sgl),
11140                 TEST_CASE_ST(ut_setup, ut_teardown,
11141                         test_kasumi_encryption_test_case_1_oop_sgl),
11142                 /** KASUMI decrypt only (UEA1) */
11143                 TEST_CASE_ST(ut_setup, ut_teardown,
11144                         test_kasumi_decryption_test_case_1),
11145                 TEST_CASE_ST(ut_setup, ut_teardown,
11146                         test_kasumi_decryption_test_case_2),
11147                 TEST_CASE_ST(ut_setup, ut_teardown,
11148                         test_kasumi_decryption_test_case_3),
11149                 TEST_CASE_ST(ut_setup, ut_teardown,
11150                         test_kasumi_decryption_test_case_4),
11151                 TEST_CASE_ST(ut_setup, ut_teardown,
11152                         test_kasumi_decryption_test_case_5),
11153
11154                 TEST_CASE_ST(ut_setup, ut_teardown,
11155                         test_kasumi_encryption_test_case_1_oop),
11156                 TEST_CASE_ST(ut_setup, ut_teardown,
11157                         test_kasumi_decryption_test_case_1_oop),
11158
11159                 /** KASUMI hash only (UIA1) */
11160                 TEST_CASE_ST(ut_setup, ut_teardown,
11161                         test_kasumi_hash_generate_test_case_1),
11162                 TEST_CASE_ST(ut_setup, ut_teardown,
11163                         test_kasumi_hash_generate_test_case_2),
11164                 TEST_CASE_ST(ut_setup, ut_teardown,
11165                         test_kasumi_hash_generate_test_case_3),
11166                 TEST_CASE_ST(ut_setup, ut_teardown,
11167                         test_kasumi_hash_generate_test_case_4),
11168                 TEST_CASE_ST(ut_setup, ut_teardown,
11169                         test_kasumi_hash_generate_test_case_5),
11170                 TEST_CASE_ST(ut_setup, ut_teardown,
11171                         test_kasumi_hash_generate_test_case_6),
11172                 TEST_CASE_ST(ut_setup, ut_teardown,
11173                         test_kasumi_hash_verify_test_case_1),
11174                 TEST_CASE_ST(ut_setup, ut_teardown,
11175                         test_kasumi_hash_verify_test_case_2),
11176                 TEST_CASE_ST(ut_setup, ut_teardown,
11177                         test_kasumi_hash_verify_test_case_3),
11178                 TEST_CASE_ST(ut_setup, ut_teardown,
11179                         test_kasumi_hash_verify_test_case_4),
11180                 TEST_CASE_ST(ut_setup, ut_teardown,
11181                         test_kasumi_hash_verify_test_case_5),
11182
11183                 /** NULL tests */
11184                 TEST_CASE_ST(ut_setup, ut_teardown,
11185                         test_null_cipher_only_operation),
11186                 TEST_CASE_ST(ut_setup, ut_teardown,
11187                         test_null_auth_only_operation),
11188                 TEST_CASE_ST(ut_setup, ut_teardown,
11189                         test_null_cipher_auth_operation),
11190                 TEST_CASE_ST(ut_setup, ut_teardown,
11191                         test_null_auth_cipher_operation),
11192
11193                 /** Negative tests */
11194                 TEST_CASE_ST(ut_setup, ut_teardown,
11195                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
11196                 TEST_CASE_ST(ut_setup, ut_teardown,
11197                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11198                 TEST_CASE_ST(ut_setup, ut_teardown,
11199                         authentication_verify_AES128_GMAC_fail_data_corrupt),
11200                 TEST_CASE_ST(ut_setup, ut_teardown,
11201                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
11202                 TEST_CASE_ST(ut_setup, ut_teardown,
11203                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11204                 TEST_CASE_ST(ut_setup, ut_teardown,
11205                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11206                 TEST_CASES_END() /**< NULL terminate unit test array */
11207         }
11208 };
11209
11210 static int
11211 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
11212 {
11213         gbl_driver_id = rte_cryptodev_driver_id_get(
11214                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
11215
11216         if (gbl_driver_id == -1) {
11217                 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
11218                 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
11219                 "are enabled in config file to run this testsuite.\n");
11220                 return TEST_SKIPPED;
11221         }
11222
11223         return unit_test_suite_runner(&cryptodev_qat_testsuite);
11224 }
11225
11226 static int
11227 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
11228 {
11229         gbl_driver_id = rte_cryptodev_driver_id_get(
11230                         RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
11231
11232         if (gbl_driver_id == -1) {
11233                 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
11234                                 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
11235                                 "in config file to run this testsuite.\n");
11236                 return TEST_FAILED;
11237         }
11238
11239         return unit_test_suite_runner(&cryptodev_virtio_testsuite);
11240 }
11241
11242 static int
11243 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
11244 {
11245         gbl_driver_id = rte_cryptodev_driver_id_get(
11246                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11247
11248         if (gbl_driver_id == -1) {
11249                 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
11250                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
11251                                 "in config file to run this testsuite.\n");
11252                 return TEST_SKIPPED;
11253         }
11254
11255         return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
11256 }
11257
11258 static int
11259 test_cryptodev_openssl(void)
11260 {
11261         gbl_driver_id = rte_cryptodev_driver_id_get(
11262                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
11263
11264         if (gbl_driver_id == -1) {
11265                 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
11266                                 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
11267                                 "in config file to run this testsuite.\n");
11268                 return TEST_SKIPPED;
11269         }
11270
11271         return unit_test_suite_runner(&cryptodev_openssl_testsuite);
11272 }
11273
11274 static int
11275 test_cryptodev_aesni_gcm(void)
11276 {
11277         gbl_driver_id = rte_cryptodev_driver_id_get(
11278                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
11279
11280         if (gbl_driver_id == -1) {
11281                 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
11282                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
11283                                 "in config file to run this testsuite.\n");
11284                 return TEST_SKIPPED;
11285         }
11286
11287         return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
11288 }
11289
11290 static int
11291 test_cryptodev_null(void)
11292 {
11293         gbl_driver_id = rte_cryptodev_driver_id_get(
11294                         RTE_STR(CRYPTODEV_NAME_NULL_PMD));
11295
11296         if (gbl_driver_id == -1) {
11297                 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
11298                                 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
11299                                 "in config file to run this testsuite.\n");
11300                 return TEST_SKIPPED;
11301         }
11302
11303         return unit_test_suite_runner(&cryptodev_null_testsuite);
11304 }
11305
11306 static int
11307 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
11308 {
11309         gbl_driver_id = rte_cryptodev_driver_id_get(
11310                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
11311
11312         if (gbl_driver_id == -1) {
11313                 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
11314                                 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
11315                                 "in config file to run this testsuite.\n");
11316                 return TEST_SKIPPED;
11317         }
11318
11319         return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
11320 }
11321
11322 static int
11323 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
11324 {
11325         gbl_driver_id = rte_cryptodev_driver_id_get(
11326                         RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
11327
11328         if (gbl_driver_id == -1) {
11329                 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
11330                                 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
11331                                 "in config file to run this testsuite.\n");
11332                 return TEST_SKIPPED;
11333         }
11334
11335         return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
11336 }
11337
11338 static int
11339 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
11340 {
11341         gbl_driver_id = rte_cryptodev_driver_id_get(
11342                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
11343
11344         if (gbl_driver_id == -1) {
11345                 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
11346                                 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
11347                                 "in config file to run this testsuite.\n");
11348                 return TEST_SKIPPED;
11349         }
11350
11351         return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
11352 }
11353
11354 static int
11355 test_cryptodev_armv8(void)
11356 {
11357         gbl_driver_id = rte_cryptodev_driver_id_get(
11358                         RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
11359
11360         if (gbl_driver_id == -1) {
11361                 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
11362                                 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
11363                                 "in config file to run this testsuite.\n");
11364                 return TEST_SKIPPED;
11365         }
11366
11367         return unit_test_suite_runner(&cryptodev_armv8_testsuite);
11368 }
11369
11370 static int
11371 test_cryptodev_mrvl(void)
11372 {
11373         gbl_driver_id = rte_cryptodev_driver_id_get(
11374                         RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
11375
11376         if (gbl_driver_id == -1) {
11377                 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
11378                                 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
11379                                 "in config file to run this testsuite.\n");
11380                 return TEST_SKIPPED;
11381         }
11382
11383         return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
11384 }
11385
11386 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11387
11388 static int
11389 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
11390 {
11391         gbl_driver_id = rte_cryptodev_driver_id_get(
11392                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
11393
11394         if (gbl_driver_id == -1) {
11395                 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
11396                                 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
11397                                 "in config file to run this testsuite.\n");
11398                 return TEST_SKIPPED;
11399         }
11400
11401         if (rte_cryptodev_driver_id_get(
11402                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
11403                 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
11404                         " enabled in config file to run this testsuite.\n");
11405                 return TEST_SKIPPED;
11406 }
11407         return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
11408 }
11409
11410 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
11411
11412 #endif
11413
11414 static int
11415 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
11416 {
11417         gbl_driver_id = rte_cryptodev_driver_id_get(
11418                         RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
11419
11420         if (gbl_driver_id == -1) {
11421                 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
11422                                 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
11423                                 "in config file to run this testsuite.\n");
11424                 return TEST_SKIPPED;
11425         }
11426
11427         return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
11428 }
11429
11430 static int
11431 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
11432 {
11433         gbl_driver_id = rte_cryptodev_driver_id_get(
11434                         RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
11435
11436         if (gbl_driver_id == -1) {
11437                 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
11438                                 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
11439                                 "in config file to run this testsuite.\n");
11440                 return TEST_SKIPPED;
11441         }
11442
11443         return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
11444 }
11445
11446 static int
11447 test_cryptodev_ccp(void)
11448 {
11449         gbl_driver_id = rte_cryptodev_driver_id_get(
11450                         RTE_STR(CRYPTODEV_NAME_CCP_PMD));
11451
11452         if (gbl_driver_id == -1) {
11453                 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
11454                                 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
11455                                 "in config file to run this testsuite.\n");
11456                 return TEST_FAILED;
11457         }
11458
11459         return unit_test_suite_runner(&cryptodev_ccp_testsuite);
11460 }
11461
11462 static int
11463 test_cryptodev_octeontx(void)
11464 {
11465         gbl_driver_id = rte_cryptodev_driver_id_get(
11466                         RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
11467         if (gbl_driver_id == -1) {
11468                 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
11469                                 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
11470                                 "enabled in config file to run this "
11471                                 "testsuite.\n");
11472                 return TEST_FAILED;
11473         }
11474         return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
11475 }
11476
11477 static int
11478 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
11479 {
11480         gbl_driver_id = rte_cryptodev_driver_id_get(
11481                         RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
11482
11483         if (gbl_driver_id == -1) {
11484                 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
11485                                 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
11486                                 "in config file to run this testsuite.\n");
11487                 return TEST_FAILED;
11488         }
11489
11490         return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
11491 }
11492
11493 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
11494 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
11495 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
11496 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
11497 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
11498 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
11499 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
11500 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
11501 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
11502 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
11503 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
11504 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
11505 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
11506 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
11507 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
11508 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);