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