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