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