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