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