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