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