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