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