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