test/crypto: add encrypted digest case for AES-CTR-CMAC
[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 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
45 #endif
46
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
49
50 #define IN_PLACE 0
51 #define OUT_OF_PLACE 1
52
53 static int gbl_driver_id;
54
55 struct crypto_testsuite_params {
56         struct rte_mempool *mbuf_pool;
57         struct rte_mempool *large_mbuf_pool;
58         struct rte_mempool *op_mpool;
59         struct rte_mempool *session_mpool;
60         struct rte_mempool *session_priv_mpool;
61         struct rte_cryptodev_config conf;
62         struct rte_cryptodev_qp_conf qp_conf;
63
64         uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
65         uint8_t valid_dev_count;
66 };
67
68 struct crypto_unittest_params {
69         struct rte_crypto_sym_xform cipher_xform;
70         struct rte_crypto_sym_xform auth_xform;
71         struct rte_crypto_sym_xform aead_xform;
72
73         union {
74                 struct rte_cryptodev_sym_session *sess;
75                 struct rte_security_session *sec_session;
76         };
77         enum rte_security_session_action_type type;
78         struct rte_crypto_op *op;
79
80         struct rte_mbuf *obuf, *ibuf;
81
82         uint8_t *digest;
83 };
84
85 #define ALIGN_POW2_ROUNDUP(num, align) \
86         (((num) + (align) - 1) & ~((align) - 1))
87
88 /*
89  * Forward declarations.
90  */
91 static int
92 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
93                 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
94                 uint8_t *hmac_key);
95
96 static int
97 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
98                 struct crypto_unittest_params *ut_params,
99                 struct crypto_testsuite_params *ts_param,
100                 const uint8_t *cipher,
101                 const uint8_t *digest,
102                 const uint8_t *iv);
103
104 static struct rte_mbuf *
105 setup_test_string(struct rte_mempool *mpool,
106                 const char *string, size_t len, uint8_t blocksize)
107 {
108         struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
109         size_t t_len = len - (blocksize ? (len % blocksize) : 0);
110
111         memset(m->buf_addr, 0, m->buf_len);
112         if (m) {
113                 char *dst = rte_pktmbuf_append(m, t_len);
114
115                 if (!dst) {
116                         rte_pktmbuf_free(m);
117                         return NULL;
118                 }
119                 if (string != NULL)
120                         rte_memcpy(dst, string, t_len);
121                 else
122                         memset(dst, 0, t_len);
123         }
124
125         return m;
126 }
127
128 /* Get number of bytes in X bits (rounding up) */
129 static uint32_t
130 ceil_byte_length(uint32_t num_bits)
131 {
132         if (num_bits % 8)
133                 return ((num_bits >> 3) + 1);
134         else
135                 return (num_bits >> 3);
136 }
137
138 static struct rte_crypto_op *
139 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
140 {
141         if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
142                 printf("Error sending packet for encryption");
143                 return NULL;
144         }
145
146         op = NULL;
147
148         while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
149                 rte_pause();
150
151         return op;
152 }
153
154 static struct crypto_testsuite_params testsuite_params = { NULL };
155 static struct crypto_unittest_params unittest_params;
156
157 static int
158 testsuite_setup(void)
159 {
160         struct crypto_testsuite_params *ts_params = &testsuite_params;
161         struct rte_cryptodev_info info;
162         uint32_t i = 0, nb_devs, dev_id;
163         int ret;
164         uint16_t qp_id;
165
166         memset(ts_params, 0, sizeof(*ts_params));
167
168         ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
169         if (ts_params->mbuf_pool == NULL) {
170                 /* Not already created so create */
171                 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
172                                 "CRYPTO_MBUFPOOL",
173                                 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
174                                 rte_socket_id());
175                 if (ts_params->mbuf_pool == NULL) {
176                         RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
177                         return TEST_FAILED;
178                 }
179         }
180
181         ts_params->large_mbuf_pool = rte_mempool_lookup(
182                         "CRYPTO_LARGE_MBUFPOOL");
183         if (ts_params->large_mbuf_pool == NULL) {
184                 /* Not already created so create */
185                 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
186                                 "CRYPTO_LARGE_MBUFPOOL",
187                                 1, 0, 0, UINT16_MAX,
188                                 rte_socket_id());
189                 if (ts_params->large_mbuf_pool == NULL) {
190                         RTE_LOG(ERR, USER1,
191                                 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
192                         return TEST_FAILED;
193                 }
194         }
195
196         ts_params->op_mpool = rte_crypto_op_pool_create(
197                         "MBUF_CRYPTO_SYM_OP_POOL",
198                         RTE_CRYPTO_OP_TYPE_SYMMETRIC,
199                         NUM_MBUFS, MBUF_CACHE_SIZE,
200                         DEFAULT_NUM_XFORMS *
201                         sizeof(struct rte_crypto_sym_xform) +
202                         MAXIMUM_IV_LENGTH,
203                         rte_socket_id());
204         if (ts_params->op_mpool == NULL) {
205                 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
206                 return TEST_FAILED;
207         }
208
209         /* Create an AESNI MB device if required */
210         if (gbl_driver_id == rte_cryptodev_driver_id_get(
211                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
212                 nb_devs = rte_cryptodev_device_count_by_driver(
213                                 rte_cryptodev_driver_id_get(
214                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
215                 if (nb_devs < 1) {
216                         ret = rte_vdev_init(
217                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
218
219                         TEST_ASSERT(ret == 0,
220                                 "Failed to create instance of"
221                                 " pmd : %s",
222                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
223                 }
224         }
225
226         /* Create an AESNI GCM device if required */
227         if (gbl_driver_id == rte_cryptodev_driver_id_get(
228                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
229                 nb_devs = rte_cryptodev_device_count_by_driver(
230                                 rte_cryptodev_driver_id_get(
231                                 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
232                 if (nb_devs < 1) {
233                         TEST_ASSERT_SUCCESS(rte_vdev_init(
234                                 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
235                                 "Failed to create instance of"
236                                 " pmd : %s",
237                                 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
238                 }
239         }
240
241         /* Create a SNOW 3G device if required */
242         if (gbl_driver_id == rte_cryptodev_driver_id_get(
243                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
244                 nb_devs = rte_cryptodev_device_count_by_driver(
245                                 rte_cryptodev_driver_id_get(
246                                 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
247                 if (nb_devs < 1) {
248                         TEST_ASSERT_SUCCESS(rte_vdev_init(
249                                 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
250                                 "Failed to create instance of"
251                                 " pmd : %s",
252                                 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
253                 }
254         }
255
256         /* Create a KASUMI device if required */
257         if (gbl_driver_id == rte_cryptodev_driver_id_get(
258                         RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
259                 nb_devs = rte_cryptodev_device_count_by_driver(
260                                 rte_cryptodev_driver_id_get(
261                                 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
262                 if (nb_devs < 1) {
263                         TEST_ASSERT_SUCCESS(rte_vdev_init(
264                                 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
265                                 "Failed to create instance of"
266                                 " pmd : %s",
267                                 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
268                 }
269         }
270
271         /* Create a ZUC device if required */
272         if (gbl_driver_id == rte_cryptodev_driver_id_get(
273                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
274                 nb_devs = rte_cryptodev_device_count_by_driver(
275                                 rte_cryptodev_driver_id_get(
276                                 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
277                 if (nb_devs < 1) {
278                         TEST_ASSERT_SUCCESS(rte_vdev_init(
279                                 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
280                                 "Failed to create instance of"
281                                 " pmd : %s",
282                                 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
283                 }
284         }
285
286         /* Create a NULL device if required */
287         if (gbl_driver_id == rte_cryptodev_driver_id_get(
288                         RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
289                 nb_devs = rte_cryptodev_device_count_by_driver(
290                                 rte_cryptodev_driver_id_get(
291                                 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
292                 if (nb_devs < 1) {
293                         ret = rte_vdev_init(
294                                 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
295
296                         TEST_ASSERT(ret == 0,
297                                 "Failed to create instance of"
298                                 " pmd : %s",
299                                 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
300                 }
301         }
302
303         /* Create an OPENSSL device if required */
304         if (gbl_driver_id == rte_cryptodev_driver_id_get(
305                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
306                 nb_devs = rte_cryptodev_device_count_by_driver(
307                                 rte_cryptodev_driver_id_get(
308                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
309                 if (nb_devs < 1) {
310                         ret = rte_vdev_init(
311                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
312                                 NULL);
313
314                         TEST_ASSERT(ret == 0, "Failed to create "
315                                 "instance of pmd : %s",
316                                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
317                 }
318         }
319
320         /* Create a ARMv8 device if required */
321         if (gbl_driver_id == rte_cryptodev_driver_id_get(
322                         RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
323                 nb_devs = rte_cryptodev_device_count_by_driver(
324                                 rte_cryptodev_driver_id_get(
325                                 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
326                 if (nb_devs < 1) {
327                         ret = rte_vdev_init(
328                                 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
329                                 NULL);
330
331                         TEST_ASSERT(ret == 0, "Failed to create "
332                                 "instance of pmd : %s",
333                                 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
334                 }
335         }
336
337         /* Create a MVSAM device if required */
338         if (gbl_driver_id == rte_cryptodev_driver_id_get(
339                         RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
340                 nb_devs = rte_cryptodev_device_count_by_driver(
341                                 rte_cryptodev_driver_id_get(
342                                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
343                 if (nb_devs < 1) {
344                         ret = rte_vdev_init(
345                                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
346                                 NULL);
347
348                         TEST_ASSERT(ret == 0, "Failed to create "
349                                 "instance of pmd : %s",
350                                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
351                 }
352         }
353
354         /* Create an CCP device if required */
355         if (gbl_driver_id == rte_cryptodev_driver_id_get(
356                         RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
357                 nb_devs = rte_cryptodev_device_count_by_driver(
358                                 rte_cryptodev_driver_id_get(
359                                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
360                 if (nb_devs < 1) {
361                         ret = rte_vdev_init(
362                                 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
363                                 NULL);
364
365                         TEST_ASSERT(ret == 0, "Failed to create "
366                                 "instance of pmd : %s",
367                                 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
368                 }
369         }
370
371 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
372         char vdev_args[VDEV_ARGS_SIZE] = {""};
373         char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
374                 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
375         uint16_t slave_core_count = 0;
376         uint16_t socket_id = 0;
377
378         if (gbl_driver_id == rte_cryptodev_driver_id_get(
379                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
380
381                 /* Identify the Slave Cores
382                  * Use 2 slave cores for the device args
383                  */
384                 RTE_LCORE_FOREACH_SLAVE(i) {
385                         if (slave_core_count > 1)
386                                 break;
387                         snprintf(vdev_args, sizeof(vdev_args),
388                                         "%s%d", temp_str, i);
389                         strcpy(temp_str, vdev_args);
390                         strlcat(temp_str, ";", sizeof(temp_str));
391                         slave_core_count++;
392                         socket_id = rte_lcore_to_socket_id(i);
393                 }
394                 if (slave_core_count != 2) {
395                         RTE_LOG(ERR, USER1,
396                                 "Cryptodev scheduler test require at least "
397                                 "two slave cores to run. "
398                                 "Please use the correct coremask.\n");
399                         return TEST_FAILED;
400                 }
401                 strcpy(temp_str, vdev_args);
402                 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
403                                 temp_str, socket_id);
404                 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
405                 nb_devs = rte_cryptodev_device_count_by_driver(
406                                 rte_cryptodev_driver_id_get(
407                                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
408                 if (nb_devs < 1) {
409                         ret = rte_vdev_init(
410                                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
411                                         vdev_args);
412                         TEST_ASSERT(ret == 0,
413                                 "Failed to create instance %u of"
414                                 " pmd : %s",
415                                 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
416                 }
417         }
418 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
419
420         nb_devs = rte_cryptodev_count();
421         if (nb_devs < 1) {
422                 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
423                 return TEST_SKIPPED;
424         }
425
426         /* Create list of valid crypto devs */
427         for (i = 0; i < nb_devs; i++) {
428                 rte_cryptodev_info_get(i, &info);
429                 if (info.driver_id == gbl_driver_id)
430                         ts_params->valid_devs[ts_params->valid_dev_count++] = i;
431         }
432
433         if (ts_params->valid_dev_count < 1)
434                 return TEST_FAILED;
435
436         /* Set up all the qps on the first of the valid devices found */
437
438         dev_id = ts_params->valid_devs[0];
439
440         rte_cryptodev_info_get(dev_id, &info);
441
442         ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
443         ts_params->conf.socket_id = SOCKET_ID_ANY;
444         ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
445
446         unsigned int session_size =
447                 rte_cryptodev_sym_get_private_session_size(dev_id);
448
449         /*
450          * Create mempool with maximum number of sessions * 2,
451          * to include the session headers
452          */
453         if (info.sym.max_nb_sessions != 0 &&
454                         info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
455                 RTE_LOG(ERR, USER1, "Device does not support "
456                                 "at least %u sessions\n",
457                                 MAX_NB_SESSIONS);
458                 return TEST_FAILED;
459         }
460
461         ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
462                         "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
463                         SOCKET_ID_ANY);
464         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
465                         "session mempool allocation failed");
466
467         ts_params->session_priv_mpool = rte_mempool_create(
468                         "test_sess_mp_priv",
469                         MAX_NB_SESSIONS,
470                         session_size,
471                         0, 0, NULL, NULL, NULL,
472                         NULL, SOCKET_ID_ANY,
473                         0);
474         TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
475                         "session mempool allocation failed");
476
477
478
479         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
480                         &ts_params->conf),
481                         "Failed to configure cryptodev %u with %u qps",
482                         dev_id, ts_params->conf.nb_queue_pairs);
483
484         ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
485         ts_params->qp_conf.mp_session = ts_params->session_mpool;
486         ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
487
488         for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
489                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
490                         dev_id, qp_id, &ts_params->qp_conf,
491                         rte_cryptodev_socket_id(dev_id)),
492                         "Failed to setup queue pair %u on cryptodev %u",
493                         qp_id, dev_id);
494         }
495
496         return TEST_SUCCESS;
497 }
498
499 static void
500 testsuite_teardown(void)
501 {
502         struct crypto_testsuite_params *ts_params = &testsuite_params;
503
504         if (ts_params->mbuf_pool != NULL) {
505                 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
506                 rte_mempool_avail_count(ts_params->mbuf_pool));
507         }
508
509         if (ts_params->op_mpool != NULL) {
510                 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
511                 rte_mempool_avail_count(ts_params->op_mpool));
512         }
513
514         /* Free session mempools */
515         if (ts_params->session_priv_mpool != NULL) {
516                 rte_mempool_free(ts_params->session_priv_mpool);
517                 ts_params->session_priv_mpool = NULL;
518         }
519
520         if (ts_params->session_mpool != NULL) {
521                 rte_mempool_free(ts_params->session_mpool);
522                 ts_params->session_mpool = NULL;
523         }
524 }
525
526 static int
527 ut_setup(void)
528 {
529         struct crypto_testsuite_params *ts_params = &testsuite_params;
530         struct crypto_unittest_params *ut_params = &unittest_params;
531
532         uint16_t qp_id;
533
534         /* Clear unit test parameters before running test */
535         memset(ut_params, 0, sizeof(*ut_params));
536
537         /* Reconfigure device to default parameters */
538         ts_params->conf.socket_id = SOCKET_ID_ANY;
539         ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
540         ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
541         ts_params->qp_conf.mp_session = ts_params->session_mpool;
542         ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
543
544         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
545                         &ts_params->conf),
546                         "Failed to configure cryptodev %u",
547                         ts_params->valid_devs[0]);
548
549         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
550                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
551                         ts_params->valid_devs[0], qp_id,
552                         &ts_params->qp_conf,
553                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
554                         "Failed to setup queue pair %u on cryptodev %u",
555                         qp_id, ts_params->valid_devs[0]);
556         }
557
558
559         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
560
561         /* Start the device */
562         TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
563                         "Failed to start cryptodev %u",
564                         ts_params->valid_devs[0]);
565
566         return TEST_SUCCESS;
567 }
568
569 static void
570 ut_teardown(void)
571 {
572         struct crypto_testsuite_params *ts_params = &testsuite_params;
573         struct crypto_unittest_params *ut_params = &unittest_params;
574         struct rte_cryptodev_stats stats;
575
576         /* free crypto session structure */
577         if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
578                 if (ut_params->sec_session) {
579                         rte_security_session_destroy(rte_cryptodev_get_sec_ctx
580                                                 (ts_params->valid_devs[0]),
581                                                 ut_params->sec_session);
582                         ut_params->sec_session = NULL;
583                 }
584         } else {
585                 if (ut_params->sess) {
586                         rte_cryptodev_sym_session_clear(
587                                         ts_params->valid_devs[0],
588                                         ut_params->sess);
589                         rte_cryptodev_sym_session_free(ut_params->sess);
590                         ut_params->sess = NULL;
591                 }
592         }
593
594         /* free crypto operation structure */
595         if (ut_params->op)
596                 rte_crypto_op_free(ut_params->op);
597
598         /*
599          * free mbuf - both obuf and ibuf are usually the same,
600          * so check if they point at the same address is necessary,
601          * to avoid freeing the mbuf twice.
602          */
603         if (ut_params->obuf) {
604                 rte_pktmbuf_free(ut_params->obuf);
605                 if (ut_params->ibuf == ut_params->obuf)
606                         ut_params->ibuf = 0;
607                 ut_params->obuf = 0;
608         }
609         if (ut_params->ibuf) {
610                 rte_pktmbuf_free(ut_params->ibuf);
611                 ut_params->ibuf = 0;
612         }
613
614         if (ts_params->mbuf_pool != NULL)
615                 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
616                         rte_mempool_avail_count(ts_params->mbuf_pool));
617
618         rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
619
620         /* Stop the device */
621         rte_cryptodev_stop(ts_params->valid_devs[0]);
622 }
623
624 static int
625 test_device_configure_invalid_dev_id(void)
626 {
627         struct crypto_testsuite_params *ts_params = &testsuite_params;
628         uint16_t dev_id, num_devs = 0;
629
630         TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
631                         "Need at least %d devices for test", 1);
632
633         /* valid dev_id values */
634         dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
635
636         /* Stop the device in case it's started so it can be configured */
637         rte_cryptodev_stop(dev_id);
638
639         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
640                         "Failed test for rte_cryptodev_configure: "
641                         "invalid dev_num %u", dev_id);
642
643         /* invalid dev_id values */
644         dev_id = num_devs;
645
646         TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
647                         "Failed test for rte_cryptodev_configure: "
648                         "invalid dev_num %u", dev_id);
649
650         dev_id = 0xff;
651
652         TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
653                         "Failed test for rte_cryptodev_configure:"
654                         "invalid dev_num %u", dev_id);
655
656         return TEST_SUCCESS;
657 }
658
659 static int
660 test_device_configure_invalid_queue_pair_ids(void)
661 {
662         struct crypto_testsuite_params *ts_params = &testsuite_params;
663         uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
664
665         /* Stop the device in case it's started so it can be configured */
666         rte_cryptodev_stop(ts_params->valid_devs[0]);
667
668         /* valid - one queue pairs */
669         ts_params->conf.nb_queue_pairs = 1;
670
671         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
672                         &ts_params->conf),
673                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
674                         ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
675
676
677         /* valid - max value queue pairs */
678         ts_params->conf.nb_queue_pairs = orig_nb_qps;
679
680         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
681                         &ts_params->conf),
682                         "Failed to configure cryptodev: dev_id %u, qp_id %u",
683                         ts_params->valid_devs[0],
684                         ts_params->conf.nb_queue_pairs);
685
686
687         /* invalid - zero queue pairs */
688         ts_params->conf.nb_queue_pairs = 0;
689
690         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
691                         &ts_params->conf),
692                         "Failed test for rte_cryptodev_configure, dev_id %u,"
693                         " invalid qps: %u",
694                         ts_params->valid_devs[0],
695                         ts_params->conf.nb_queue_pairs);
696
697
698         /* invalid - max value supported by field queue pairs */
699         ts_params->conf.nb_queue_pairs = UINT16_MAX;
700
701         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
702                         &ts_params->conf),
703                         "Failed test for rte_cryptodev_configure, dev_id %u,"
704                         " invalid qps: %u",
705                         ts_params->valid_devs[0],
706                         ts_params->conf.nb_queue_pairs);
707
708
709         /* invalid - max value + 1 queue pairs */
710         ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
711
712         TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
713                         &ts_params->conf),
714                         "Failed test for rte_cryptodev_configure, dev_id %u,"
715                         " invalid qps: %u",
716                         ts_params->valid_devs[0],
717                         ts_params->conf.nb_queue_pairs);
718
719         /* revert to original testsuite value */
720         ts_params->conf.nb_queue_pairs = orig_nb_qps;
721
722         return TEST_SUCCESS;
723 }
724
725 static int
726 test_queue_pair_descriptor_setup(void)
727 {
728         struct crypto_testsuite_params *ts_params = &testsuite_params;
729         struct rte_cryptodev_info dev_info;
730         struct rte_cryptodev_qp_conf qp_conf = {
731                 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
732         };
733
734         uint16_t qp_id;
735
736         /* Stop the device in case it's started so it can be configured */
737         rte_cryptodev_stop(ts_params->valid_devs[0]);
738
739
740         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
741
742         TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
743                         &ts_params->conf),
744                         "Failed to configure cryptodev %u",
745                         ts_params->valid_devs[0]);
746
747         /*
748          * Test various ring sizes on this device. memzones can't be
749          * freed so are re-used if ring is released and re-created.
750          */
751         qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
752         qp_conf.mp_session = ts_params->session_mpool;
753         qp_conf.mp_session_private = ts_params->session_priv_mpool;
754
755         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
756                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
757                                 ts_params->valid_devs[0], qp_id, &qp_conf,
758                                 rte_cryptodev_socket_id(
759                                                 ts_params->valid_devs[0])),
760                                 "Failed test for "
761                                 "rte_cryptodev_queue_pair_setup: num_inflights "
762                                 "%u on qp %u on cryptodev %u",
763                                 qp_conf.nb_descriptors, qp_id,
764                                 ts_params->valid_devs[0]);
765         }
766
767         qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
768
769         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
770                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
771                                 ts_params->valid_devs[0], qp_id, &qp_conf,
772                                 rte_cryptodev_socket_id(
773                                                 ts_params->valid_devs[0])),
774                                 "Failed test for"
775                                 " rte_cryptodev_queue_pair_setup: num_inflights"
776                                 " %u on qp %u on cryptodev %u",
777                                 qp_conf.nb_descriptors, qp_id,
778                                 ts_params->valid_devs[0]);
779         }
780
781         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
782
783         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
784                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
785                                 ts_params->valid_devs[0], qp_id, &qp_conf,
786                                 rte_cryptodev_socket_id(
787                                                 ts_params->valid_devs[0])),
788                                 "Failed test for "
789                                 "rte_cryptodev_queue_pair_setup: num_inflights"
790                                 " %u on qp %u on cryptodev %u",
791                                 qp_conf.nb_descriptors, qp_id,
792                                 ts_params->valid_devs[0]);
793         }
794
795         /* invalid number of descriptors - max supported + 2 */
796         qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
797
798         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
799                 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
800                                 ts_params->valid_devs[0], qp_id, &qp_conf,
801                                 rte_cryptodev_socket_id(
802                                                 ts_params->valid_devs[0])),
803                                 "Unexpectedly passed test for "
804                                 "rte_cryptodev_queue_pair_setup:"
805                                 "num_inflights %u on qp %u on cryptodev %u",
806                                 qp_conf.nb_descriptors, qp_id,
807                                 ts_params->valid_devs[0]);
808         }
809
810         /* invalid number of descriptors - max value of parameter */
811         qp_conf.nb_descriptors = UINT32_MAX-1;
812
813         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
814                 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
815                                 ts_params->valid_devs[0], qp_id, &qp_conf,
816                                 rte_cryptodev_socket_id(
817                                                 ts_params->valid_devs[0])),
818                                 "Unexpectedly passed test for "
819                                 "rte_cryptodev_queue_pair_setup:"
820                                 "num_inflights %u on qp %u on cryptodev %u",
821                                 qp_conf.nb_descriptors, qp_id,
822                                 ts_params->valid_devs[0]);
823         }
824
825         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
826
827         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
828                 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
829                                 ts_params->valid_devs[0], qp_id, &qp_conf,
830                                 rte_cryptodev_socket_id(
831                                                 ts_params->valid_devs[0])),
832                                 "Failed test for"
833                                 " rte_cryptodev_queue_pair_setup:"
834                                 "num_inflights %u on qp %u on cryptodev %u",
835                                 qp_conf.nb_descriptors, qp_id,
836                                 ts_params->valid_devs[0]);
837         }
838
839         /* invalid number of descriptors - max supported + 1 */
840         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
841
842         for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
843                 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
844                                 ts_params->valid_devs[0], qp_id, &qp_conf,
845                                 rte_cryptodev_socket_id(
846                                                 ts_params->valid_devs[0])),
847                                 "Unexpectedly passed test for "
848                                 "rte_cryptodev_queue_pair_setup:"
849                                 "num_inflights %u on qp %u on cryptodev %u",
850                                 qp_conf.nb_descriptors, qp_id,
851                                 ts_params->valid_devs[0]);
852         }
853
854         /* test invalid queue pair id */
855         qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;      /*valid */
856
857         qp_id = ts_params->conf.nb_queue_pairs;         /*invalid */
858
859         TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
860                         ts_params->valid_devs[0],
861                         qp_id, &qp_conf,
862                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
863                         "Failed test for rte_cryptodev_queue_pair_setup:"
864                         "invalid qp %u on cryptodev %u",
865                         qp_id, ts_params->valid_devs[0]);
866
867         qp_id = 0xffff; /*invalid*/
868
869         TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
870                         ts_params->valid_devs[0],
871                         qp_id, &qp_conf,
872                         rte_cryptodev_socket_id(ts_params->valid_devs[0])),
873                         "Failed test for rte_cryptodev_queue_pair_setup:"
874                         "invalid qp %u on cryptodev %u",
875                         qp_id, ts_params->valid_devs[0]);
876
877         return TEST_SUCCESS;
878 }
879
880 /* ***** Plaintext data for tests ***** */
881
882 const char catch_22_quote_1[] =
883                 "There was only one catch and that was Catch-22, which "
884                 "specified that a concern for one's safety in the face of "
885                 "dangers that were real and immediate was the process of a "
886                 "rational mind. Orr was crazy and could be grounded. All he "
887                 "had to do was ask; and as soon as he did, he would no longer "
888                 "be crazy and would have to fly more missions. Orr would be "
889                 "crazy to fly more missions and sane if he didn't, but if he "
890                 "was sane he had to fly them. If he flew them he was crazy "
891                 "and didn't have to; but if he didn't want to he was sane and "
892                 "had to. Yossarian was moved very deeply by the absolute "
893                 "simplicity of this clause of Catch-22 and let out a "
894                 "respectful whistle. \"That's some catch, that Catch-22\", he "
895                 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
896
897 const char catch_22_quote[] =
898                 "What a lousy earth! He wondered how many people were "
899                 "destitute that same night even in his own prosperous country, "
900                 "how many homes were shanties, how many husbands were drunk "
901                 "and wives socked, and how many children were bullied, abused, "
902                 "or abandoned. How many families hungered for food they could "
903                 "not afford to buy? How many hearts were broken? How many "
904                 "suicides would take place that same night, how many people "
905                 "would go insane? How many cockroaches and landlords would "
906                 "triumph? How many winners were losers, successes failures, "
907                 "and rich men poor men? How many wise guys were stupid? How "
908                 "many happy endings were unhappy endings? How many honest men "
909                 "were liars, brave men cowards, loyal men traitors, how many "
910                 "sainted men were corrupt, how many people in positions of "
911                 "trust had sold their souls to bodyguards, how many had never "
912                 "had souls? How many straight-and-narrow paths were crooked "
913                 "paths? How many best families were worst families and how "
914                 "many good people were bad people? When you added them all up "
915                 "and then subtracted, you might be left with only the children, "
916                 "and perhaps with Albert Einstein and an old violinist or "
917                 "sculptor somewhere.";
918
919 #define QUOTE_480_BYTES         (480)
920 #define QUOTE_512_BYTES         (512)
921 #define QUOTE_768_BYTES         (768)
922 #define QUOTE_1024_BYTES        (1024)
923
924
925
926 /* ***** SHA1 Hash Tests ***** */
927
928 #define HMAC_KEY_LENGTH_SHA1    (DIGEST_BYTE_LENGTH_SHA1)
929
930 static uint8_t hmac_sha1_key[] = {
931         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
932         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
933         0xDE, 0xF4, 0xDE, 0xAD };
934
935 /* ***** SHA224 Hash Tests ***** */
936
937 #define HMAC_KEY_LENGTH_SHA224  (DIGEST_BYTE_LENGTH_SHA224)
938
939
940 /* ***** AES-CBC Cipher Tests ***** */
941
942 #define CIPHER_KEY_LENGTH_AES_CBC       (16)
943 #define CIPHER_IV_LENGTH_AES_CBC        (CIPHER_KEY_LENGTH_AES_CBC)
944
945 static uint8_t aes_cbc_key[] = {
946         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
947         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
948
949 static uint8_t aes_cbc_iv[] = {
950         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
951         0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
952
953
954 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
955
956 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
957         0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
958         0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
959         0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
960         0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
961         0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
962         0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
963         0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
964         0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
965         0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
966         0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
967         0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
968         0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
969         0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
970         0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
971         0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
972         0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
973         0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
974         0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
975         0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
976         0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
977         0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
978         0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
979         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
980         0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
981         0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
982         0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
983         0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
984         0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
985         0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
986         0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
987         0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
988         0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
989         0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
990         0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
991         0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
992         0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
993         0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
994         0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
995         0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
996         0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
997         0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
998         0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
999         0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1000         0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1001         0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1002         0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1003         0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1004         0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1005         0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1006         0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1007         0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1008         0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1009         0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1010         0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1011         0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1012         0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1013         0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1014         0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1015         0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1016         0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1017         0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1018         0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1019         0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1020         0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1021 };
1022
1023 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1024         0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1025         0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1026         0x18, 0x8c, 0x1d, 0x32
1027 };
1028
1029
1030 /* Multisession Vector context Test */
1031 /*Begin Session 0 */
1032 static uint8_t ms_aes_cbc_key0[] = {
1033         0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1034         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1035 };
1036
1037 static uint8_t ms_aes_cbc_iv0[] = {
1038         0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1039         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1040 };
1041
1042 static const uint8_t ms_aes_cbc_cipher0[] = {
1043                 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1044                 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1045                 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1046                 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1047                 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1048                 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1049                 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1050                 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1051                 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1052                 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1053                 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1054                 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1055                 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1056                 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1057                 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1058                 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1059                 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1060                 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1061                 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1062                 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1063                 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1064                 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1065                 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1066                 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1067                 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1068                 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1069                 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1070                 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1071                 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1072                 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1073                 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1074                 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1075                 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1076                 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1077                 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1078                 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1079                 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1080                 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1081                 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1082                 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1083                 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1084                 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1085                 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1086                 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1087                 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1088                 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1089                 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1090                 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1091                 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1092                 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1093                 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1094                 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1095                 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1096                 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1097                 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1098                 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1099                 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1100                 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1101                 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1102                 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1103                 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1104                 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1105                 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1106                 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1107 };
1108
1109
1110 static  uint8_t ms_hmac_key0[] = {
1111                 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1112                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1113                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1114                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1115                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1116                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1117                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1118                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1119 };
1120
1121 static const uint8_t ms_hmac_digest0[] = {
1122                 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1123                 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1124                 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1125                 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1126                 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1127                 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1128                 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1129                 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1130                 };
1131
1132 /* End Session 0 */
1133 /* Begin session 1 */
1134
1135 static  uint8_t ms_aes_cbc_key1[] = {
1136                 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1137                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1138 };
1139
1140 static  uint8_t ms_aes_cbc_iv1[] = {
1141         0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1142         0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1143 };
1144
1145 static const uint8_t ms_aes_cbc_cipher1[] = {
1146                 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1147                 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1148                 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1149                 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1150                 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1151                 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1152                 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1153                 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1154                 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1155                 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1156                 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1157                 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1158                 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1159                 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1160                 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1161                 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1162                 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1163                 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1164                 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1165                 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1166                 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1167                 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1168                 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1169                 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1170                 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1171                 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1172                 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1173                 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1174                 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1175                 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1176                 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1177                 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1178                 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1179                 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1180                 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1181                 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1182                 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1183                 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1184                 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1185                 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1186                 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1187                 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1188                 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1189                 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1190                 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1191                 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1192                 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1193                 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1194                 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1195                 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1196                 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1197                 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1198                 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1199                 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1200                 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1201                 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1202                 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1203                 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1204                 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1205                 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1206                 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1207                 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1208                 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1209                 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1210
1211 };
1212
1213 static uint8_t ms_hmac_key1[] = {
1214                 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1215                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1216                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1217                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1218                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1219                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1220                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1221                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1222 };
1223
1224 static const uint8_t ms_hmac_digest1[] = {
1225                 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1226                 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1227                 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1228                 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1229                 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1230                 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1231                 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1232                 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1233 };
1234 /* End Session 1  */
1235 /* Begin Session 2 */
1236 static  uint8_t ms_aes_cbc_key2[] = {
1237                 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1238                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1239 };
1240
1241 static  uint8_t ms_aes_cbc_iv2[] = {
1242                 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1243                 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1244 };
1245
1246 static const uint8_t ms_aes_cbc_cipher2[] = {
1247                 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1248                 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1249                 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1250                 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1251                 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1252                 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1253                 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1254                 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1255                 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1256                 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1257                 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1258                 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1259                 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1260                 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1261                 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1262                 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1263                 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1264                 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1265                 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1266                 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1267                 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1268                 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1269                 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1270                 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1271                 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1272                 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1273                 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1274                 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1275                 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1276                 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1277                 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1278                 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1279                 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1280                 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1281                 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1282                 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1283                 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1284                 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1285                 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1286                 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1287                 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1288                 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1289                 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1290                 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1291                 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1292                 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1293                 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1294                 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1295                 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1296                 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1297                 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1298                 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1299                 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1300                 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1301                 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1302                 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1303                 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1304                 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1305                 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1306                 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1307                 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1308                 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1309                 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1310                 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1311 };
1312
1313 static  uint8_t ms_hmac_key2[] = {
1314                 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1315                 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1316                 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1317                 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1318                 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1319                 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1320                 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1321                 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1322 };
1323
1324 static const uint8_t ms_hmac_digest2[] = {
1325                 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1326                 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1327                 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1328                 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1329                 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1330                 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1331                 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1332                 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1333 };
1334
1335 /* End Session 2 */
1336
1337
1338 static int
1339 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1340 {
1341         struct crypto_testsuite_params *ts_params = &testsuite_params;
1342         struct crypto_unittest_params *ut_params = &unittest_params;
1343
1344         /* Generate test mbuf data and space for digest */
1345         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1346                         catch_22_quote, QUOTE_512_BYTES, 0);
1347
1348         ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1349                         DIGEST_BYTE_LENGTH_SHA1);
1350         TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1351
1352         /* Setup Cipher Parameters */
1353         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1354         ut_params->cipher_xform.next = &ut_params->auth_xform;
1355
1356         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1357         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1358         ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1359         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1360         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1361         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1362
1363         /* Setup HMAC Parameters */
1364         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1365
1366         ut_params->auth_xform.next = NULL;
1367
1368         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1369         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1370         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1371         ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1372         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1373
1374         ut_params->sess = rte_cryptodev_sym_session_create(
1375                         ts_params->session_mpool);
1376
1377         /* Create crypto session*/
1378         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1379                         ut_params->sess, &ut_params->cipher_xform,
1380                         ts_params->session_priv_mpool);
1381         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1382
1383         /* Generate crypto op data structure */
1384         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1385                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1386         TEST_ASSERT_NOT_NULL(ut_params->op,
1387                         "Failed to allocate symmetric crypto operation struct");
1388
1389         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1390
1391         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1392
1393         /* set crypto operation source mbuf */
1394         sym_op->m_src = ut_params->ibuf;
1395
1396         /* Set crypto operation authentication parameters */
1397         sym_op->auth.digest.data = ut_params->digest;
1398         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1399                         ut_params->ibuf, QUOTE_512_BYTES);
1400
1401         sym_op->auth.data.offset = 0;
1402         sym_op->auth.data.length = QUOTE_512_BYTES;
1403
1404         /* Copy IV at the end of the crypto operation */
1405         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1406                         aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1407
1408         /* Set crypto operation cipher parameters */
1409         sym_op->cipher.data.offset = 0;
1410         sym_op->cipher.data.length = QUOTE_512_BYTES;
1411
1412         /* Process crypto operation */
1413         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1414                         ut_params->op), "failed to process sym crypto op");
1415
1416         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1417                         "crypto op processing failed");
1418
1419         /* Validate obuf */
1420         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1421                         uint8_t *);
1422
1423         TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1424                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1425                         QUOTE_512_BYTES,
1426                         "ciphertext data not as expected");
1427
1428         uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1429
1430         TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1431                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1432                         gbl_driver_id == rte_cryptodev_driver_id_get(
1433                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1434                                         TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1435                                         DIGEST_BYTE_LENGTH_SHA1,
1436                         "Generated digest data not as expected");
1437
1438         return TEST_SUCCESS;
1439 }
1440
1441 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1442
1443 #define HMAC_KEY_LENGTH_SHA512  (DIGEST_BYTE_LENGTH_SHA512)
1444
1445 static uint8_t hmac_sha512_key[] = {
1446         0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1447         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1448         0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1449         0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1450         0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1451         0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1452         0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1453         0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1454
1455 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1456         0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1457         0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1458         0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1459         0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1460         0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1461         0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1462         0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1463         0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1464
1465
1466
1467 static int
1468 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1469                 struct crypto_unittest_params *ut_params,
1470                 uint8_t *cipher_key,
1471                 uint8_t *hmac_key);
1472
1473 static int
1474 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1475                 struct crypto_unittest_params *ut_params,
1476                 struct crypto_testsuite_params *ts_params,
1477                 const uint8_t *cipher,
1478                 const uint8_t *digest,
1479                 const uint8_t *iv);
1480
1481
1482 static int
1483 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1484                 struct crypto_unittest_params *ut_params,
1485                 uint8_t *cipher_key,
1486                 uint8_t *hmac_key)
1487 {
1488
1489         /* Setup Cipher Parameters */
1490         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1491         ut_params->cipher_xform.next = NULL;
1492
1493         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1494         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1495         ut_params->cipher_xform.cipher.key.data = cipher_key;
1496         ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1497         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1498         ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1499
1500         /* Setup HMAC Parameters */
1501         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1502         ut_params->auth_xform.next = &ut_params->cipher_xform;
1503
1504         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1505         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1506         ut_params->auth_xform.auth.key.data = hmac_key;
1507         ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1508         ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1509
1510         return TEST_SUCCESS;
1511 }
1512
1513
1514 static int
1515 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1516                 struct crypto_unittest_params *ut_params,
1517                 struct crypto_testsuite_params *ts_params,
1518                 const uint8_t *cipher,
1519                 const uint8_t *digest,
1520                 const uint8_t *iv)
1521 {
1522         /* Generate test mbuf data and digest */
1523         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1524                         (const char *)
1525                         cipher,
1526                         QUOTE_512_BYTES, 0);
1527
1528         ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1529                         DIGEST_BYTE_LENGTH_SHA512);
1530         TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1531
1532         rte_memcpy(ut_params->digest,
1533                         digest,
1534                         DIGEST_BYTE_LENGTH_SHA512);
1535
1536         /* Generate Crypto op data structure */
1537         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1538                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1539         TEST_ASSERT_NOT_NULL(ut_params->op,
1540                         "Failed to allocate symmetric crypto operation struct");
1541
1542         rte_crypto_op_attach_sym_session(ut_params->op, sess);
1543
1544         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1545
1546         /* set crypto operation source mbuf */
1547         sym_op->m_src = ut_params->ibuf;
1548
1549         sym_op->auth.digest.data = ut_params->digest;
1550         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1551                         ut_params->ibuf, QUOTE_512_BYTES);
1552
1553         sym_op->auth.data.offset = 0;
1554         sym_op->auth.data.length = QUOTE_512_BYTES;
1555
1556         /* Copy IV at the end of the crypto operation */
1557         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1558                         iv, CIPHER_IV_LENGTH_AES_CBC);
1559
1560         sym_op->cipher.data.offset = 0;
1561         sym_op->cipher.data.length = QUOTE_512_BYTES;
1562
1563         /* Process crypto operation */
1564         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1565                         ut_params->op), "failed to process sym crypto op");
1566
1567         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1568                         "crypto op processing failed");
1569
1570         ut_params->obuf = ut_params->op->sym->m_src;
1571
1572         /* Validate obuf */
1573         TEST_ASSERT_BUFFERS_ARE_EQUAL(
1574                         rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1575                         catch_22_quote,
1576                         QUOTE_512_BYTES,
1577                         "Plaintext data not as expected");
1578
1579         /* Validate obuf */
1580         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1581                         "Digest verification failed");
1582
1583         return TEST_SUCCESS;
1584 }
1585
1586 static int
1587 test_AES_cipheronly_mb_all(void)
1588 {
1589         struct crypto_testsuite_params *ts_params = &testsuite_params;
1590         int status;
1591
1592         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1593                 ts_params->op_mpool,
1594                 ts_params->session_mpool, ts_params->session_priv_mpool,
1595                 ts_params->valid_devs[0],
1596                 rte_cryptodev_driver_id_get(
1597                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1598                 BLKCIPHER_AES_CIPHERONLY_TYPE);
1599
1600         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1601
1602         return TEST_SUCCESS;
1603 }
1604
1605 static int
1606 test_AES_docsis_mb_all(void)
1607 {
1608         struct crypto_testsuite_params *ts_params = &testsuite_params;
1609         int status;
1610
1611         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1612                 ts_params->op_mpool,
1613                 ts_params->session_mpool, ts_params->session_priv_mpool,
1614                 ts_params->valid_devs[0],
1615                 rte_cryptodev_driver_id_get(
1616                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1617                 BLKCIPHER_AES_DOCSIS_TYPE);
1618
1619         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1620
1621         return TEST_SUCCESS;
1622 }
1623
1624 static int
1625 test_AES_docsis_qat_all(void)
1626 {
1627         struct crypto_testsuite_params *ts_params = &testsuite_params;
1628         int status;
1629
1630         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1631                 ts_params->op_mpool,
1632                 ts_params->session_mpool, ts_params->session_priv_mpool,
1633                 ts_params->valid_devs[0],
1634                 rte_cryptodev_driver_id_get(
1635                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1636                 BLKCIPHER_AES_DOCSIS_TYPE);
1637
1638         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1639
1640         return TEST_SUCCESS;
1641 }
1642
1643 static int
1644 test_DES_docsis_qat_all(void)
1645 {
1646         struct crypto_testsuite_params *ts_params = &testsuite_params;
1647         int status;
1648
1649         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1650                 ts_params->op_mpool,
1651                 ts_params->session_mpool, ts_params->session_priv_mpool,
1652                 ts_params->valid_devs[0],
1653                 rte_cryptodev_driver_id_get(
1654                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1655                 BLKCIPHER_DES_DOCSIS_TYPE);
1656
1657         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1658
1659         return TEST_SUCCESS;
1660 }
1661
1662 static int
1663 test_authonly_mb_all(void)
1664 {
1665         struct crypto_testsuite_params *ts_params = &testsuite_params;
1666         int status;
1667
1668         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1669                 ts_params->op_mpool,
1670                 ts_params->session_mpool, ts_params->session_priv_mpool,
1671                 ts_params->valid_devs[0],
1672                 rte_cryptodev_driver_id_get(
1673                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1674                 BLKCIPHER_AUTHONLY_TYPE);
1675
1676         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1677
1678         return TEST_SUCCESS;
1679 }
1680
1681 static int
1682 test_authonly_qat_all(void)
1683 {
1684         struct crypto_testsuite_params *ts_params = &testsuite_params;
1685         int status;
1686
1687         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1688                 ts_params->op_mpool,
1689                 ts_params->session_mpool, ts_params->session_priv_mpool,
1690                 ts_params->valid_devs[0],
1691                 rte_cryptodev_driver_id_get(
1692                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1693                 BLKCIPHER_AUTHONLY_TYPE);
1694
1695         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1696
1697         return TEST_SUCCESS;
1698 }
1699
1700 static int
1701 test_AES_chain_null_all(void)
1702 {
1703         struct crypto_testsuite_params *ts_params = &testsuite_params;
1704         int status;
1705
1706         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1707                 ts_params->op_mpool,
1708                 ts_params->session_mpool, ts_params->session_priv_mpool,
1709                 ts_params->valid_devs[0],
1710                 rte_cryptodev_driver_id_get(
1711                 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1712                 BLKCIPHER_AES_CHAIN_TYPE);
1713
1714         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1715
1716         return TEST_SUCCESS;
1717 }
1718
1719 static int
1720 test_AES_cipheronly_null_all(void)
1721 {
1722         struct crypto_testsuite_params *ts_params = &testsuite_params;
1723         int status;
1724
1725         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1726                 ts_params->op_mpool,
1727                 ts_params->session_mpool, ts_params->session_priv_mpool,
1728                 ts_params->valid_devs[0],
1729                 rte_cryptodev_driver_id_get(
1730                 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1731                 BLKCIPHER_AES_CIPHERONLY_TYPE);
1732
1733         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1734
1735         return TEST_SUCCESS;
1736 }
1737
1738 static int
1739 test_authonly_null_all(void)
1740 {
1741         struct crypto_testsuite_params *ts_params = &testsuite_params;
1742         int status;
1743
1744         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1745                 ts_params->op_mpool,
1746                 ts_params->session_mpool, ts_params->session_priv_mpool,
1747                 ts_params->valid_devs[0],
1748                 rte_cryptodev_driver_id_get(
1749                 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1750                 BLKCIPHER_AUTHONLY_TYPE);
1751
1752         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1753
1754         return TEST_SUCCESS;
1755 }
1756
1757 static int
1758 test_AES_chain_mb_all(void)
1759 {
1760         struct crypto_testsuite_params *ts_params = &testsuite_params;
1761         int status;
1762
1763         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1764                 ts_params->op_mpool,
1765                 ts_params->session_mpool, ts_params->session_priv_mpool,
1766                 ts_params->valid_devs[0],
1767                 rte_cryptodev_driver_id_get(
1768                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1769                 BLKCIPHER_AES_CHAIN_TYPE);
1770
1771         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1772
1773         return TEST_SUCCESS;
1774 }
1775
1776 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1777
1778 static int
1779 test_AES_cipheronly_scheduler_all(void)
1780 {
1781         struct crypto_testsuite_params *ts_params = &testsuite_params;
1782         int status;
1783
1784         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1785                 ts_params->op_mpool,
1786                 ts_params->session_mpool, ts_params->session_priv_mpool,
1787                 ts_params->valid_devs[0],
1788                 rte_cryptodev_driver_id_get(
1789                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1790                 BLKCIPHER_AES_CIPHERONLY_TYPE);
1791
1792         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1793
1794         return TEST_SUCCESS;
1795 }
1796
1797 static int
1798 test_AES_chain_scheduler_all(void)
1799 {
1800         struct crypto_testsuite_params *ts_params = &testsuite_params;
1801         int status;
1802
1803         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1804                 ts_params->op_mpool,
1805                 ts_params->session_mpool, ts_params->session_priv_mpool,
1806                 ts_params->valid_devs[0],
1807                 rte_cryptodev_driver_id_get(
1808                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1809                 BLKCIPHER_AES_CHAIN_TYPE);
1810
1811         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1812
1813         return TEST_SUCCESS;
1814 }
1815
1816 static int
1817 test_authonly_scheduler_all(void)
1818 {
1819         struct crypto_testsuite_params *ts_params = &testsuite_params;
1820         int status;
1821
1822         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1823                 ts_params->op_mpool,
1824                 ts_params->session_mpool, ts_params->session_priv_mpool,
1825                 ts_params->valid_devs[0],
1826                 rte_cryptodev_driver_id_get(
1827                 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1828                 BLKCIPHER_AUTHONLY_TYPE);
1829
1830         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1831
1832         return TEST_SUCCESS;
1833 }
1834
1835 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1836
1837 static int
1838 test_AES_chain_openssl_all(void)
1839 {
1840         struct crypto_testsuite_params *ts_params = &testsuite_params;
1841         int status;
1842
1843         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1844                 ts_params->op_mpool,
1845                 ts_params->session_mpool, ts_params->session_priv_mpool,
1846                 ts_params->valid_devs[0],
1847                 rte_cryptodev_driver_id_get(
1848                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1849                 BLKCIPHER_AES_CHAIN_TYPE);
1850
1851         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1852
1853         return TEST_SUCCESS;
1854 }
1855
1856 static int
1857 test_AES_cipheronly_openssl_all(void)
1858 {
1859         struct crypto_testsuite_params *ts_params = &testsuite_params;
1860         int status;
1861
1862         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1863                 ts_params->op_mpool,
1864                 ts_params->session_mpool, ts_params->session_priv_mpool,
1865                 ts_params->valid_devs[0],
1866                 rte_cryptodev_driver_id_get(
1867                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1868                 BLKCIPHER_AES_CIPHERONLY_TYPE);
1869
1870         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1871
1872         return TEST_SUCCESS;
1873 }
1874
1875 static int
1876 test_AES_chain_ccp_all(void)
1877 {
1878         struct crypto_testsuite_params *ts_params = &testsuite_params;
1879         int status;
1880
1881         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1882                 ts_params->op_mpool,
1883                 ts_params->session_mpool, ts_params->session_priv_mpool,
1884                 ts_params->valid_devs[0],
1885                 rte_cryptodev_driver_id_get(
1886                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1887                 BLKCIPHER_AES_CHAIN_TYPE);
1888
1889         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1890
1891         return TEST_SUCCESS;
1892 }
1893
1894 static int
1895 test_AES_cipheronly_ccp_all(void)
1896 {
1897         struct crypto_testsuite_params *ts_params = &testsuite_params;
1898         int status;
1899
1900         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1901                 ts_params->op_mpool,
1902                 ts_params->session_mpool, ts_params->session_priv_mpool,
1903                 ts_params->valid_devs[0],
1904                 rte_cryptodev_driver_id_get(
1905                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1906                 BLKCIPHER_AES_CIPHERONLY_TYPE);
1907
1908         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1909
1910         return TEST_SUCCESS;
1911 }
1912
1913 static int
1914 test_AES_chain_qat_all(void)
1915 {
1916         struct crypto_testsuite_params *ts_params = &testsuite_params;
1917         int status;
1918
1919         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1920                 ts_params->op_mpool,
1921                 ts_params->session_mpool, ts_params->session_priv_mpool,
1922                 ts_params->valid_devs[0],
1923                 rte_cryptodev_driver_id_get(
1924                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1925                 BLKCIPHER_AES_CHAIN_TYPE);
1926
1927         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1928
1929         return TEST_SUCCESS;
1930 }
1931
1932 static int
1933 test_AES_cipheronly_qat_all(void)
1934 {
1935         struct crypto_testsuite_params *ts_params = &testsuite_params;
1936         int status;
1937
1938         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1939                 ts_params->op_mpool,
1940                 ts_params->session_mpool, ts_params->session_priv_mpool,
1941                 ts_params->valid_devs[0],
1942                 rte_cryptodev_driver_id_get(
1943                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1944                 BLKCIPHER_AES_CIPHERONLY_TYPE);
1945
1946         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1947
1948         return TEST_SUCCESS;
1949 }
1950
1951 static int
1952 test_AES_cipheronly_virtio_all(void)
1953 {
1954         struct crypto_testsuite_params *ts_params = &testsuite_params;
1955         int status;
1956
1957         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1958                 ts_params->op_mpool,
1959                 ts_params->session_mpool, ts_params->session_priv_mpool,
1960                 ts_params->valid_devs[0],
1961                 rte_cryptodev_driver_id_get(
1962                 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1963                 BLKCIPHER_AES_CIPHERONLY_TYPE);
1964
1965         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1966
1967         return TEST_SUCCESS;
1968 }
1969
1970 static int
1971 test_AES_chain_caam_jr_all(void)
1972 {
1973         struct crypto_testsuite_params *ts_params = &testsuite_params;
1974         int status;
1975
1976         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1977                 ts_params->op_mpool,
1978                 ts_params->session_mpool, ts_params->session_priv_mpool,
1979                 ts_params->valid_devs[0],
1980                 rte_cryptodev_driver_id_get(
1981                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1982                 BLKCIPHER_AES_CHAIN_TYPE);
1983
1984         TEST_ASSERT_EQUAL(status, 0, "Test failed");
1985
1986         return TEST_SUCCESS;
1987 }
1988
1989 static int
1990 test_AES_cipheronly_caam_jr_all(void)
1991 {
1992         struct crypto_testsuite_params *ts_params = &testsuite_params;
1993         int status;
1994
1995         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1996                 ts_params->op_mpool,
1997                 ts_params->session_mpool, ts_params->session_priv_mpool,
1998                 ts_params->valid_devs[0],
1999                 rte_cryptodev_driver_id_get(
2000                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2001                 BLKCIPHER_AES_CIPHERONLY_TYPE);
2002
2003         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2004
2005         return TEST_SUCCESS;
2006 }
2007
2008 static int
2009 test_authonly_caam_jr_all(void)
2010 {
2011         struct crypto_testsuite_params *ts_params = &testsuite_params;
2012         int status;
2013
2014         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2015                 ts_params->op_mpool,
2016                 ts_params->session_mpool, ts_params->session_priv_mpool,
2017                 ts_params->valid_devs[0],
2018                 rte_cryptodev_driver_id_get(
2019                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2020                 BLKCIPHER_AUTHONLY_TYPE);
2021
2022         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2023
2024         return TEST_SUCCESS;
2025 }
2026
2027
2028 static int
2029 test_AES_chain_dpaa_sec_all(void)
2030 {
2031         struct crypto_testsuite_params *ts_params = &testsuite_params;
2032         int status;
2033
2034         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2035                 ts_params->op_mpool,
2036                 ts_params->session_mpool, ts_params->session_priv_mpool,
2037                 ts_params->valid_devs[0],
2038                 rte_cryptodev_driver_id_get(
2039                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2040                 BLKCIPHER_AES_CHAIN_TYPE);
2041
2042         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2043
2044         return TEST_SUCCESS;
2045 }
2046
2047 static int
2048 test_AES_cipheronly_dpaa_sec_all(void)
2049 {
2050         struct crypto_testsuite_params *ts_params = &testsuite_params;
2051         int status;
2052
2053         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2054                 ts_params->op_mpool,
2055                 ts_params->session_mpool, ts_params->session_priv_mpool,
2056                 ts_params->valid_devs[0],
2057                 rte_cryptodev_driver_id_get(
2058                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2059                 BLKCIPHER_AES_CIPHERONLY_TYPE);
2060
2061         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2062
2063         return TEST_SUCCESS;
2064 }
2065
2066 static int
2067 test_authonly_dpaa_sec_all(void)
2068 {
2069         struct crypto_testsuite_params *ts_params = &testsuite_params;
2070         int status;
2071
2072         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2073                 ts_params->op_mpool,
2074                 ts_params->session_mpool, ts_params->session_priv_mpool,
2075                 ts_params->valid_devs[0],
2076                 rte_cryptodev_driver_id_get(
2077                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2078                 BLKCIPHER_AUTHONLY_TYPE);
2079
2080         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2081
2082         return TEST_SUCCESS;
2083 }
2084
2085 static int
2086 test_AES_chain_dpaa2_sec_all(void)
2087 {
2088         struct crypto_testsuite_params *ts_params = &testsuite_params;
2089         int status;
2090
2091         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2092                 ts_params->op_mpool,
2093                 ts_params->session_mpool, ts_params->session_priv_mpool,
2094                 ts_params->valid_devs[0],
2095                 rte_cryptodev_driver_id_get(
2096                 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2097                 BLKCIPHER_AES_CHAIN_TYPE);
2098
2099         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2100
2101         return TEST_SUCCESS;
2102 }
2103
2104 static int
2105 test_AES_cipheronly_dpaa2_sec_all(void)
2106 {
2107         struct crypto_testsuite_params *ts_params = &testsuite_params;
2108         int status;
2109
2110         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2111                 ts_params->op_mpool,
2112                 ts_params->session_mpool, ts_params->session_priv_mpool,
2113                 ts_params->valid_devs[0],
2114                 rte_cryptodev_driver_id_get(
2115                 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2116                 BLKCIPHER_AES_CIPHERONLY_TYPE);
2117
2118         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2119
2120         return TEST_SUCCESS;
2121 }
2122
2123 static int
2124 test_authonly_dpaa2_sec_all(void)
2125 {
2126         struct crypto_testsuite_params *ts_params = &testsuite_params;
2127         int status;
2128
2129         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2130                 ts_params->op_mpool,
2131                 ts_params->session_mpool, ts_params->session_priv_mpool,
2132                 ts_params->valid_devs[0],
2133                 rte_cryptodev_driver_id_get(
2134                 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2135                 BLKCIPHER_AUTHONLY_TYPE);
2136
2137         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2138
2139         return TEST_SUCCESS;
2140 }
2141
2142 static int
2143 test_authonly_openssl_all(void)
2144 {
2145         struct crypto_testsuite_params *ts_params = &testsuite_params;
2146         int status;
2147
2148         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2149                 ts_params->op_mpool,
2150                 ts_params->session_mpool, ts_params->session_priv_mpool,
2151                 ts_params->valid_devs[0],
2152                 rte_cryptodev_driver_id_get(
2153                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2154                 BLKCIPHER_AUTHONLY_TYPE);
2155
2156         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2157
2158         return TEST_SUCCESS;
2159 }
2160
2161 static int
2162 test_authonly_ccp_all(void)
2163 {
2164         struct crypto_testsuite_params *ts_params = &testsuite_params;
2165         int status;
2166
2167         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2168                 ts_params->op_mpool,
2169                 ts_params->session_mpool, ts_params->session_priv_mpool,
2170                 ts_params->valid_devs[0],
2171                 rte_cryptodev_driver_id_get(
2172                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2173                 BLKCIPHER_AUTHONLY_TYPE);
2174
2175         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2176
2177         return TEST_SUCCESS;
2178 }
2179
2180 static int
2181 test_AES_chain_armv8_all(void)
2182 {
2183         struct crypto_testsuite_params *ts_params = &testsuite_params;
2184         int status;
2185
2186         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2187                 ts_params->op_mpool,
2188                 ts_params->session_mpool, ts_params->session_priv_mpool,
2189                 ts_params->valid_devs[0],
2190                 rte_cryptodev_driver_id_get(
2191                 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2192                 BLKCIPHER_AES_CHAIN_TYPE);
2193
2194         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2195
2196         return TEST_SUCCESS;
2197 }
2198
2199 static int
2200 test_AES_chain_mrvl_all(void)
2201 {
2202         struct crypto_testsuite_params *ts_params = &testsuite_params;
2203         int status;
2204
2205         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2206                 ts_params->op_mpool,
2207                 ts_params->session_mpool, ts_params->session_priv_mpool,
2208                 ts_params->valid_devs[0],
2209                 rte_cryptodev_driver_id_get(
2210                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2211                 BLKCIPHER_AES_CHAIN_TYPE);
2212
2213         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2214
2215         return TEST_SUCCESS;
2216 }
2217
2218 static int
2219 test_AES_cipheronly_mrvl_all(void)
2220 {
2221         struct crypto_testsuite_params *ts_params = &testsuite_params;
2222         int status;
2223
2224         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2225                 ts_params->op_mpool,
2226                 ts_params->session_mpool, ts_params->session_priv_mpool,
2227                 ts_params->valid_devs[0],
2228                 rte_cryptodev_driver_id_get(
2229                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2230                 BLKCIPHER_AES_CIPHERONLY_TYPE);
2231
2232         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2233
2234         return TEST_SUCCESS;
2235 }
2236
2237 static int
2238 test_authonly_mrvl_all(void)
2239 {
2240         struct crypto_testsuite_params *ts_params = &testsuite_params;
2241         int status;
2242
2243         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2244                 ts_params->op_mpool,
2245                 ts_params->session_mpool, ts_params->session_priv_mpool,
2246                 ts_params->valid_devs[0],
2247                 rte_cryptodev_driver_id_get(
2248                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2249                 BLKCIPHER_AUTHONLY_TYPE);
2250
2251         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2252
2253         return TEST_SUCCESS;
2254 }
2255
2256 static int
2257 test_3DES_chain_mrvl_all(void)
2258 {
2259         struct crypto_testsuite_params *ts_params = &testsuite_params;
2260         int status;
2261
2262         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2263                 ts_params->op_mpool,
2264                 ts_params->session_mpool, ts_params->session_priv_mpool,
2265                 ts_params->valid_devs[0],
2266                 rte_cryptodev_driver_id_get(
2267                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2268                 BLKCIPHER_3DES_CHAIN_TYPE);
2269
2270         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2271
2272         return TEST_SUCCESS;
2273 }
2274
2275 static int
2276 test_3DES_cipheronly_mrvl_all(void)
2277 {
2278         struct crypto_testsuite_params *ts_params = &testsuite_params;
2279         int status;
2280
2281         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2282                 ts_params->op_mpool,
2283                 ts_params->session_mpool, ts_params->session_priv_mpool,
2284                 ts_params->valid_devs[0],
2285                 rte_cryptodev_driver_id_get(
2286                 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2287                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2288
2289         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2290
2291         return TEST_SUCCESS;
2292 }
2293
2294 static int
2295 test_AES_chain_octeontx_all(void)
2296 {
2297         struct crypto_testsuite_params *ts_params = &testsuite_params;
2298         int status;
2299
2300         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2301                 ts_params->op_mpool, ts_params->session_mpool,
2302                 ts_params->session_priv_mpool,
2303                 ts_params->valid_devs[0],
2304                 rte_cryptodev_driver_id_get(
2305                 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2306                 BLKCIPHER_AES_CHAIN_TYPE);
2307
2308         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2309
2310         return TEST_SUCCESS;
2311 }
2312
2313 static int
2314 test_AES_cipheronly_octeontx_all(void)
2315 {
2316         struct crypto_testsuite_params *ts_params = &testsuite_params;
2317         int status;
2318
2319         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2320                 ts_params->op_mpool, ts_params->session_mpool,
2321                 ts_params->session_priv_mpool,
2322                 ts_params->valid_devs[0],
2323                 rte_cryptodev_driver_id_get(
2324                 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2325                 BLKCIPHER_AES_CIPHERONLY_TYPE);
2326
2327         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2328
2329         return TEST_SUCCESS;
2330 }
2331
2332 static int
2333 test_3DES_chain_octeontx_all(void)
2334 {
2335         struct crypto_testsuite_params *ts_params = &testsuite_params;
2336         int status;
2337
2338         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2339                 ts_params->op_mpool, ts_params->session_mpool,
2340                 ts_params->session_priv_mpool,
2341                 ts_params->valid_devs[0],
2342                 rte_cryptodev_driver_id_get(
2343                 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2344                 BLKCIPHER_3DES_CHAIN_TYPE);
2345
2346         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2347
2348         return TEST_SUCCESS;
2349 }
2350
2351 static int
2352 test_AES_chain_nitrox_all(void)
2353 {
2354         struct crypto_testsuite_params *ts_params = &testsuite_params;
2355         int status;
2356
2357         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2358                 ts_params->op_mpool,
2359                 ts_params->session_mpool, ts_params->session_priv_mpool,
2360                 ts_params->valid_devs[0],
2361                 rte_cryptodev_driver_id_get(
2362                 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2363                 BLKCIPHER_AES_CHAIN_TYPE);
2364
2365         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2366
2367         return TEST_SUCCESS;
2368 }
2369
2370 static int
2371 test_3DES_cipheronly_octeontx_all(void)
2372 {
2373         struct crypto_testsuite_params *ts_params = &testsuite_params;
2374         int status;
2375
2376         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2377                 ts_params->op_mpool, ts_params->session_mpool,
2378                 ts_params->session_priv_mpool,
2379                 ts_params->valid_devs[0],
2380                 rte_cryptodev_driver_id_get(
2381                 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2382                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2383
2384         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2385
2386         return TEST_SUCCESS;
2387 }
2388
2389 static int
2390 test_authonly_octeontx_all(void)
2391 {
2392         struct crypto_testsuite_params *ts_params = &testsuite_params;
2393         int status;
2394
2395         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2396                 ts_params->op_mpool, ts_params->session_mpool,
2397                 ts_params->session_priv_mpool,
2398                 ts_params->valid_devs[0],
2399                 rte_cryptodev_driver_id_get(
2400                 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2401                 BLKCIPHER_AUTHONLY_TYPE);
2402
2403         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2404
2405         return TEST_SUCCESS;
2406 }
2407
2408 static int
2409 test_AES_chain_octeontx2_all(void)
2410 {
2411         struct crypto_testsuite_params *ts_params = &testsuite_params;
2412         int status;
2413
2414         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2415                 ts_params->op_mpool, ts_params->session_mpool,
2416                 ts_params->session_priv_mpool,
2417                 ts_params->valid_devs[0],
2418                 rte_cryptodev_driver_id_get(
2419                 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2420                 BLKCIPHER_AES_CHAIN_TYPE);
2421
2422         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2423
2424         return TEST_SUCCESS;
2425 }
2426
2427 static int
2428 test_AES_cipheronly_octeontx2_all(void)
2429 {
2430         struct crypto_testsuite_params *ts_params = &testsuite_params;
2431         int status;
2432
2433         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2434                 ts_params->op_mpool, ts_params->session_mpool,
2435                 ts_params->session_priv_mpool,
2436                 ts_params->valid_devs[0],
2437                 rte_cryptodev_driver_id_get(
2438                 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2439                 BLKCIPHER_AES_CIPHERONLY_TYPE);
2440
2441         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2442
2443         return TEST_SUCCESS;
2444 }
2445
2446 static int
2447 test_3DES_chain_octeontx2_all(void)
2448 {
2449         struct crypto_testsuite_params *ts_params = &testsuite_params;
2450         int status;
2451
2452         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2453                 ts_params->op_mpool, ts_params->session_mpool,
2454                 ts_params->session_priv_mpool,
2455                 ts_params->valid_devs[0],
2456                 rte_cryptodev_driver_id_get(
2457                 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2458                 BLKCIPHER_3DES_CHAIN_TYPE);
2459
2460         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2461
2462         return TEST_SUCCESS;
2463 }
2464
2465 static int
2466 test_3DES_cipheronly_octeontx2_all(void)
2467 {
2468         struct crypto_testsuite_params *ts_params = &testsuite_params;
2469         int status;
2470
2471         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2472                 ts_params->op_mpool, ts_params->session_mpool,
2473                 ts_params->session_priv_mpool,
2474                 ts_params->valid_devs[0],
2475                 rte_cryptodev_driver_id_get(
2476                 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2477                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2478
2479         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2480
2481         return TEST_SUCCESS;
2482 }
2483
2484 static int
2485 test_authonly_octeontx2_all(void)
2486 {
2487         struct crypto_testsuite_params *ts_params = &testsuite_params;
2488         int status;
2489
2490         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2491                 ts_params->op_mpool, ts_params->session_mpool,
2492                 ts_params->session_priv_mpool,
2493                 ts_params->valid_devs[0],
2494                 rte_cryptodev_driver_id_get(
2495                 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2496                 BLKCIPHER_AUTHONLY_TYPE);
2497
2498         TEST_ASSERT_EQUAL(status, 0, "Test failed");
2499
2500         return TEST_SUCCESS;
2501 }
2502
2503 /* ***** SNOW 3G Tests ***** */
2504 static int
2505 create_wireless_algo_hash_session(uint8_t dev_id,
2506         const uint8_t *key, const uint8_t key_len,
2507         const uint8_t iv_len, const uint8_t auth_len,
2508         enum rte_crypto_auth_operation op,
2509         enum rte_crypto_auth_algorithm algo)
2510 {
2511         uint8_t hash_key[key_len];
2512         int status;
2513
2514         struct crypto_testsuite_params *ts_params = &testsuite_params;
2515         struct crypto_unittest_params *ut_params = &unittest_params;
2516
2517         memcpy(hash_key, key, key_len);
2518
2519         debug_hexdump(stdout, "key:", key, key_len);
2520
2521         /* Setup Authentication Parameters */
2522         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2523         ut_params->auth_xform.next = NULL;
2524
2525         ut_params->auth_xform.auth.op = op;
2526         ut_params->auth_xform.auth.algo = algo;
2527         ut_params->auth_xform.auth.key.length = key_len;
2528         ut_params->auth_xform.auth.key.data = hash_key;
2529         ut_params->auth_xform.auth.digest_length = auth_len;
2530         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2531         ut_params->auth_xform.auth.iv.length = iv_len;
2532         ut_params->sess = rte_cryptodev_sym_session_create(
2533                         ts_params->session_mpool);
2534
2535         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2536                         &ut_params->auth_xform,
2537                         ts_params->session_priv_mpool);
2538         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2539         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2540         return 0;
2541 }
2542
2543 static int
2544 create_wireless_algo_cipher_session(uint8_t dev_id,
2545                         enum rte_crypto_cipher_operation op,
2546                         enum rte_crypto_cipher_algorithm algo,
2547                         const uint8_t *key, const uint8_t key_len,
2548                         uint8_t iv_len)
2549 {
2550         uint8_t cipher_key[key_len];
2551         int status;
2552         struct crypto_testsuite_params *ts_params = &testsuite_params;
2553         struct crypto_unittest_params *ut_params = &unittest_params;
2554
2555         memcpy(cipher_key, key, key_len);
2556
2557         /* Setup Cipher Parameters */
2558         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2559         ut_params->cipher_xform.next = NULL;
2560
2561         ut_params->cipher_xform.cipher.algo = algo;
2562         ut_params->cipher_xform.cipher.op = op;
2563         ut_params->cipher_xform.cipher.key.data = cipher_key;
2564         ut_params->cipher_xform.cipher.key.length = key_len;
2565         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2566         ut_params->cipher_xform.cipher.iv.length = iv_len;
2567
2568         debug_hexdump(stdout, "key:", key, key_len);
2569
2570         /* Create Crypto session */
2571         ut_params->sess = rte_cryptodev_sym_session_create(
2572                         ts_params->session_mpool);
2573
2574         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2575                         &ut_params->cipher_xform,
2576                         ts_params->session_priv_mpool);
2577         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2578         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2579         return 0;
2580 }
2581
2582 static int
2583 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2584                         unsigned int cipher_len,
2585                         unsigned int cipher_offset)
2586 {
2587         struct crypto_testsuite_params *ts_params = &testsuite_params;
2588         struct crypto_unittest_params *ut_params = &unittest_params;
2589
2590         /* Generate Crypto op data structure */
2591         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2592                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2593         TEST_ASSERT_NOT_NULL(ut_params->op,
2594                                 "Failed to allocate pktmbuf offload");
2595
2596         /* Set crypto operation data parameters */
2597         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2598
2599         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2600
2601         /* set crypto operation source mbuf */
2602         sym_op->m_src = ut_params->ibuf;
2603
2604         /* iv */
2605         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2606                         iv, iv_len);
2607         sym_op->cipher.data.length = cipher_len;
2608         sym_op->cipher.data.offset = cipher_offset;
2609         return 0;
2610 }
2611
2612 static int
2613 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2614                         unsigned int cipher_len,
2615                         unsigned int cipher_offset)
2616 {
2617         struct crypto_testsuite_params *ts_params = &testsuite_params;
2618         struct crypto_unittest_params *ut_params = &unittest_params;
2619
2620         /* Generate Crypto op data structure */
2621         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2622                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2623         TEST_ASSERT_NOT_NULL(ut_params->op,
2624                                 "Failed to allocate pktmbuf offload");
2625
2626         /* Set crypto operation data parameters */
2627         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2628
2629         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2630
2631         /* set crypto operation source mbuf */
2632         sym_op->m_src = ut_params->ibuf;
2633         sym_op->m_dst = ut_params->obuf;
2634
2635         /* iv */
2636         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2637                         iv, iv_len);
2638         sym_op->cipher.data.length = cipher_len;
2639         sym_op->cipher.data.offset = cipher_offset;
2640         return 0;
2641 }
2642
2643 static int
2644 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2645                 enum rte_crypto_cipher_operation cipher_op,
2646                 enum rte_crypto_auth_operation auth_op,
2647                 enum rte_crypto_auth_algorithm auth_algo,
2648                 enum rte_crypto_cipher_algorithm cipher_algo,
2649                 const uint8_t *key, uint8_t key_len,
2650                 uint8_t auth_iv_len, uint8_t auth_len,
2651                 uint8_t cipher_iv_len)
2652
2653 {
2654         uint8_t cipher_auth_key[key_len];
2655         int status;
2656
2657         struct crypto_testsuite_params *ts_params = &testsuite_params;
2658         struct crypto_unittest_params *ut_params = &unittest_params;
2659
2660         memcpy(cipher_auth_key, key, key_len);
2661
2662         /* Setup Authentication Parameters */
2663         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2664         ut_params->auth_xform.next = NULL;
2665
2666         ut_params->auth_xform.auth.op = auth_op;
2667         ut_params->auth_xform.auth.algo = auth_algo;
2668         ut_params->auth_xform.auth.key.length = key_len;
2669         /* Hash key = cipher key */
2670         ut_params->auth_xform.auth.key.data = cipher_auth_key;
2671         ut_params->auth_xform.auth.digest_length = auth_len;
2672         /* Auth IV will be after cipher IV */
2673         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2674         ut_params->auth_xform.auth.iv.length = auth_iv_len;
2675
2676         /* Setup Cipher Parameters */
2677         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2678         ut_params->cipher_xform.next = &ut_params->auth_xform;
2679
2680         ut_params->cipher_xform.cipher.algo = cipher_algo;
2681         ut_params->cipher_xform.cipher.op = cipher_op;
2682         ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2683         ut_params->cipher_xform.cipher.key.length = key_len;
2684         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2685         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2686
2687         debug_hexdump(stdout, "key:", key, key_len);
2688
2689         /* Create Crypto session*/
2690         ut_params->sess = rte_cryptodev_sym_session_create(
2691                         ts_params->session_mpool);
2692
2693         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2694                         &ut_params->cipher_xform,
2695                         ts_params->session_priv_mpool);
2696
2697         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2698         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2699         return 0;
2700 }
2701
2702 static int
2703 create_wireless_cipher_auth_session(uint8_t dev_id,
2704                 enum rte_crypto_cipher_operation cipher_op,
2705                 enum rte_crypto_auth_operation auth_op,
2706                 enum rte_crypto_auth_algorithm auth_algo,
2707                 enum rte_crypto_cipher_algorithm cipher_algo,
2708                 const struct wireless_test_data *tdata)
2709 {
2710         const uint8_t key_len = tdata->key.len;
2711         uint8_t cipher_auth_key[key_len];
2712         int status;
2713
2714         struct crypto_testsuite_params *ts_params = &testsuite_params;
2715         struct crypto_unittest_params *ut_params = &unittest_params;
2716         const uint8_t *key = tdata->key.data;
2717         const uint8_t auth_len = tdata->digest.len;
2718         uint8_t cipher_iv_len = tdata->cipher_iv.len;
2719         uint8_t auth_iv_len = tdata->auth_iv.len;
2720
2721         memcpy(cipher_auth_key, key, key_len);
2722
2723         /* Setup Authentication Parameters */
2724         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2725         ut_params->auth_xform.next = NULL;
2726
2727         ut_params->auth_xform.auth.op = auth_op;
2728         ut_params->auth_xform.auth.algo = auth_algo;
2729         ut_params->auth_xform.auth.key.length = key_len;
2730         /* Hash key = cipher key */
2731         ut_params->auth_xform.auth.key.data = cipher_auth_key;
2732         ut_params->auth_xform.auth.digest_length = auth_len;
2733         /* Auth IV will be after cipher IV */
2734         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2735         ut_params->auth_xform.auth.iv.length = auth_iv_len;
2736
2737         /* Setup Cipher Parameters */
2738         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2739         ut_params->cipher_xform.next = &ut_params->auth_xform;
2740
2741         ut_params->cipher_xform.cipher.algo = cipher_algo;
2742         ut_params->cipher_xform.cipher.op = cipher_op;
2743         ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2744         ut_params->cipher_xform.cipher.key.length = key_len;
2745         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2746         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2747
2748
2749         debug_hexdump(stdout, "key:", key, key_len);
2750
2751         /* Create Crypto session*/
2752         ut_params->sess = rte_cryptodev_sym_session_create(
2753                         ts_params->session_mpool);
2754
2755         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2756                         &ut_params->cipher_xform,
2757                         ts_params->session_priv_mpool);
2758
2759         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2760         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2761         return 0;
2762 }
2763
2764 static int
2765 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2766                 const struct wireless_test_data *tdata)
2767 {
2768         return create_wireless_cipher_auth_session(dev_id,
2769                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2770                 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2771                 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2772 }
2773
2774 static int
2775 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2776                 enum rte_crypto_cipher_operation cipher_op,
2777                 enum rte_crypto_auth_operation auth_op,
2778                 enum rte_crypto_auth_algorithm auth_algo,
2779                 enum rte_crypto_cipher_algorithm cipher_algo,
2780                 const uint8_t *key, const uint8_t key_len,
2781                 uint8_t auth_iv_len, uint8_t auth_len,
2782                 uint8_t cipher_iv_len)
2783 {
2784         uint8_t auth_cipher_key[key_len];
2785         int status;
2786         struct crypto_testsuite_params *ts_params = &testsuite_params;
2787         struct crypto_unittest_params *ut_params = &unittest_params;
2788
2789         memcpy(auth_cipher_key, key, key_len);
2790
2791         /* Setup Authentication Parameters */
2792         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2793         ut_params->auth_xform.auth.op = auth_op;
2794         ut_params->auth_xform.next = &ut_params->cipher_xform;
2795         ut_params->auth_xform.auth.algo = auth_algo;
2796         ut_params->auth_xform.auth.key.length = key_len;
2797         ut_params->auth_xform.auth.key.data = auth_cipher_key;
2798         ut_params->auth_xform.auth.digest_length = auth_len;
2799         /* Auth IV will be after cipher IV */
2800         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2801         ut_params->auth_xform.auth.iv.length = auth_iv_len;
2802
2803         /* Setup Cipher Parameters */
2804         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2805         ut_params->cipher_xform.next = NULL;
2806         ut_params->cipher_xform.cipher.algo = cipher_algo;
2807         ut_params->cipher_xform.cipher.op = cipher_op;
2808         ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2809         ut_params->cipher_xform.cipher.key.length = key_len;
2810         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2811         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2812
2813         debug_hexdump(stdout, "key:", key, key_len);
2814
2815         /* Create Crypto session*/
2816         ut_params->sess = rte_cryptodev_sym_session_create(
2817                         ts_params->session_mpool);
2818
2819         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2820                         &ut_params->auth_xform,
2821                         ts_params->session_priv_mpool);
2822         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2823         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2824
2825         return 0;
2826 }
2827
2828 static int
2829 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2830                 unsigned int auth_tag_len,
2831                 const uint8_t *iv, unsigned int iv_len,
2832                 unsigned int data_pad_len,
2833                 enum rte_crypto_auth_operation op,
2834                 unsigned int auth_len, unsigned int auth_offset)
2835 {
2836         struct crypto_testsuite_params *ts_params = &testsuite_params;
2837
2838         struct crypto_unittest_params *ut_params = &unittest_params;
2839
2840         /* Generate Crypto op data structure */
2841         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2842                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2843         TEST_ASSERT_NOT_NULL(ut_params->op,
2844                 "Failed to allocate pktmbuf offload");
2845
2846         /* Set crypto operation data parameters */
2847         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2848
2849         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2850
2851         /* set crypto operation source mbuf */
2852         sym_op->m_src = ut_params->ibuf;
2853
2854         /* iv */
2855         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2856                         iv, iv_len);
2857         /* digest */
2858         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2859                                         ut_params->ibuf, auth_tag_len);
2860
2861         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2862                                 "no room to append auth tag");
2863         ut_params->digest = sym_op->auth.digest.data;
2864         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2865                         ut_params->ibuf, data_pad_len);
2866         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2867                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2868         else
2869                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2870
2871         debug_hexdump(stdout, "digest:",
2872                 sym_op->auth.digest.data,
2873                 auth_tag_len);
2874
2875         sym_op->auth.data.length = auth_len;
2876         sym_op->auth.data.offset = auth_offset;
2877
2878         return 0;
2879 }
2880
2881 static int
2882 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2883         enum rte_crypto_auth_operation op)
2884 {
2885         struct crypto_testsuite_params *ts_params = &testsuite_params;
2886         struct crypto_unittest_params *ut_params = &unittest_params;
2887
2888         const uint8_t *auth_tag = tdata->digest.data;
2889         const unsigned int auth_tag_len = tdata->digest.len;
2890         unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2891         unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2892
2893         const uint8_t *cipher_iv = tdata->cipher_iv.data;
2894         const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2895         const uint8_t *auth_iv = tdata->auth_iv.data;
2896         const uint8_t auth_iv_len = tdata->auth_iv.len;
2897         const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2898         const unsigned int auth_len = tdata->validAuthLenInBits.len;
2899
2900         /* Generate Crypto op data structure */
2901         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2902                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2903         TEST_ASSERT_NOT_NULL(ut_params->op,
2904                         "Failed to allocate pktmbuf offload");
2905         /* Set crypto operation data parameters */
2906         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2907
2908         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2909
2910         /* set crypto operation source mbuf */
2911         sym_op->m_src = ut_params->ibuf;
2912
2913         /* digest */
2914         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2915                         ut_params->ibuf, auth_tag_len);
2916
2917         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2918                         "no room to append auth tag");
2919         ut_params->digest = sym_op->auth.digest.data;
2920         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2921                         ut_params->ibuf, data_pad_len);
2922         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2923                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2924         else
2925                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2926
2927         debug_hexdump(stdout, "digest:",
2928                 sym_op->auth.digest.data,
2929                 auth_tag_len);
2930
2931         /* Copy cipher and auth IVs at the end of the crypto operation */
2932         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2933                                                 IV_OFFSET);
2934         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2935         iv_ptr += cipher_iv_len;
2936         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2937
2938         sym_op->cipher.data.length = cipher_len;
2939         sym_op->cipher.data.offset = 0;
2940         sym_op->auth.data.length = auth_len;
2941         sym_op->auth.data.offset = 0;
2942
2943         return 0;
2944 }
2945
2946 static int
2947 create_zuc_cipher_hash_generate_operation(
2948                 const struct wireless_test_data *tdata)
2949 {
2950         return create_wireless_cipher_hash_operation(tdata,
2951                 RTE_CRYPTO_AUTH_OP_GENERATE);
2952 }
2953
2954 static int
2955 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2956                 const unsigned auth_tag_len,
2957                 const uint8_t *auth_iv, uint8_t auth_iv_len,
2958                 unsigned data_pad_len,
2959                 enum rte_crypto_auth_operation op,
2960                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2961                 const unsigned cipher_len, const unsigned cipher_offset,
2962                 const unsigned auth_len, const unsigned auth_offset)
2963 {
2964         struct crypto_testsuite_params *ts_params = &testsuite_params;
2965         struct crypto_unittest_params *ut_params = &unittest_params;
2966
2967         /* Generate Crypto op data structure */
2968         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2969                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2970         TEST_ASSERT_NOT_NULL(ut_params->op,
2971                         "Failed to allocate pktmbuf offload");
2972         /* Set crypto operation data parameters */
2973         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2974
2975         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2976
2977         /* set crypto operation source mbuf */
2978         sym_op->m_src = ut_params->ibuf;
2979
2980         /* digest */
2981         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2982                         ut_params->ibuf, auth_tag_len);
2983
2984         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2985                         "no room to append auth tag");
2986         ut_params->digest = sym_op->auth.digest.data;
2987         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2988                         ut_params->ibuf, data_pad_len);
2989         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2990                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2991         else
2992                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2993
2994         debug_hexdump(stdout, "digest:",
2995                 sym_op->auth.digest.data,
2996                 auth_tag_len);
2997
2998         /* Copy cipher and auth IVs at the end of the crypto operation */
2999         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3000                                                 IV_OFFSET);
3001         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3002         iv_ptr += cipher_iv_len;
3003         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3004
3005         sym_op->cipher.data.length = cipher_len;
3006         sym_op->cipher.data.offset = cipher_offset;
3007         sym_op->auth.data.length = auth_len;
3008         sym_op->auth.data.offset = auth_offset;
3009
3010         return 0;
3011 }
3012
3013 static int
3014 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
3015                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3016                 const uint8_t *auth_iv, uint8_t auth_iv_len,
3017                 unsigned int data_pad_len,
3018                 unsigned int cipher_len, unsigned int cipher_offset,
3019                 unsigned int auth_len, unsigned int auth_offset,
3020                 uint8_t op_mode, uint8_t do_sgl)
3021 {
3022         struct crypto_testsuite_params *ts_params = &testsuite_params;
3023         struct crypto_unittest_params *ut_params = &unittest_params;
3024
3025         enum rte_crypto_cipher_algorithm cipher_algo =
3026                         ut_params->cipher_xform.cipher.algo;
3027         enum rte_crypto_auth_algorithm auth_algo =
3028                         ut_params->auth_xform.auth.algo;
3029
3030         /* Generate Crypto op data structure */
3031         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3032                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3033         TEST_ASSERT_NOT_NULL(ut_params->op,
3034                         "Failed to allocate pktmbuf offload");
3035
3036         /* Set crypto operation data parameters */
3037         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3038
3039         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3040
3041         /* set crypto operation mbufs */
3042         sym_op->m_src = ut_params->ibuf;
3043         if (op_mode == OUT_OF_PLACE)
3044                 sym_op->m_dst = ut_params->obuf;
3045
3046         /* digest */
3047         if (!do_sgl) {
3048                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3049                         (op_mode == IN_PLACE ?
3050                                 ut_params->ibuf : ut_params->obuf),
3051                         uint8_t *, data_pad_len);
3052                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3053                         (op_mode == IN_PLACE ?
3054                                 ut_params->ibuf : ut_params->obuf),
3055                         data_pad_len);
3056                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3057         } else {
3058                 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3059                 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3060                                 sym_op->m_src : sym_op->m_dst);
3061                 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3062                         remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3063                         sgl_buf = sgl_buf->next;
3064                 }
3065                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3066                                 uint8_t *, remaining_off);
3067                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3068                                 remaining_off);
3069                 memset(sym_op->auth.digest.data, 0, remaining_off);
3070                 while (sgl_buf->next != NULL) {
3071                         memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3072                                 0, rte_pktmbuf_data_len(sgl_buf));
3073                         sgl_buf = sgl_buf->next;
3074                 }
3075         }
3076
3077         /* Copy cipher and auth IVs at the end of the crypto operation */
3078         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3079                         ut_params->op, uint8_t *, IV_OFFSET);
3080
3081         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3082         iv_ptr += cipher_iv_len;
3083         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3084
3085         if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3086                 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3087                 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3088                 sym_op->cipher.data.length = cipher_len;
3089                 sym_op->cipher.data.offset = cipher_offset;
3090         } else {
3091                 sym_op->cipher.data.length = cipher_len >> 3;
3092                 sym_op->cipher.data.offset = cipher_offset >> 3;
3093         }
3094
3095         if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3096                 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3097                 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3098                 sym_op->auth.data.length = auth_len;
3099                 sym_op->auth.data.offset = auth_offset;
3100         } else {
3101                 sym_op->auth.data.length = auth_len >> 3;
3102                 sym_op->auth.data.offset = auth_offset >> 3;
3103         }
3104
3105         return 0;
3106 }
3107
3108 static int
3109 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3110 {
3111         struct crypto_testsuite_params *ts_params = &testsuite_params;
3112         struct crypto_unittest_params *ut_params = &unittest_params;
3113
3114         int retval;
3115         unsigned plaintext_pad_len;
3116         unsigned plaintext_len;
3117         uint8_t *plaintext;
3118
3119         /* Create SNOW 3G session */
3120         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3121                         tdata->key.data, tdata->key.len,
3122                         tdata->auth_iv.len, tdata->digest.len,
3123                         RTE_CRYPTO_AUTH_OP_GENERATE,
3124                         RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3125         if (retval < 0)
3126                 return retval;
3127
3128         /* alloc mbuf and set payload */
3129         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3130
3131         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3132         rte_pktmbuf_tailroom(ut_params->ibuf));
3133
3134         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3135         /* Append data which is padded to a multiple of */
3136         /* the algorithms block size */
3137         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3138         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3139                                 plaintext_pad_len);
3140         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3141
3142         /* Create SNOW 3G operation */
3143         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3144                         tdata->auth_iv.data, tdata->auth_iv.len,
3145                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3146                         tdata->validAuthLenInBits.len,
3147                         0);
3148         if (retval < 0)
3149                 return retval;
3150
3151         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3152                                 ut_params->op);
3153         ut_params->obuf = ut_params->op->sym->m_src;
3154         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3155         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3156                         + plaintext_pad_len;
3157
3158         /* Validate obuf */
3159         TEST_ASSERT_BUFFERS_ARE_EQUAL(
3160         ut_params->digest,
3161         tdata->digest.data,
3162         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3163         "SNOW 3G Generated auth tag not as expected");
3164
3165         return 0;
3166 }
3167
3168 static int
3169 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3170 {
3171         struct crypto_testsuite_params *ts_params = &testsuite_params;
3172         struct crypto_unittest_params *ut_params = &unittest_params;
3173
3174         int retval;
3175         unsigned plaintext_pad_len;
3176         unsigned plaintext_len;
3177         uint8_t *plaintext;
3178
3179         /* Create SNOW 3G session */
3180         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3181                                 tdata->key.data, tdata->key.len,
3182                                 tdata->auth_iv.len, tdata->digest.len,
3183                                 RTE_CRYPTO_AUTH_OP_VERIFY,
3184                                 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3185         if (retval < 0)
3186                 return retval;
3187         /* alloc mbuf and set payload */
3188         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3189
3190         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3191         rte_pktmbuf_tailroom(ut_params->ibuf));
3192
3193         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3194         /* Append data which is padded to a multiple of */
3195         /* the algorithms block size */
3196         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3197         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3198                                 plaintext_pad_len);
3199         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3200
3201         /* Create SNOW 3G operation */
3202         retval = create_wireless_algo_hash_operation(tdata->digest.data,
3203                         tdata->digest.len,
3204                         tdata->auth_iv.data, tdata->auth_iv.len,
3205                         plaintext_pad_len,
3206                         RTE_CRYPTO_AUTH_OP_VERIFY,
3207                         tdata->validAuthLenInBits.len,
3208                         0);
3209         if (retval < 0)
3210                 return retval;
3211
3212         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3213                                 ut_params->op);
3214         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3215         ut_params->obuf = ut_params->op->sym->m_src;
3216         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3217                                 + plaintext_pad_len;
3218
3219         /* Validate obuf */
3220         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3221                 return 0;
3222         else
3223                 return -1;
3224
3225         return 0;
3226 }
3227
3228 static int
3229 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3230 {
3231         struct crypto_testsuite_params *ts_params = &testsuite_params;
3232         struct crypto_unittest_params *ut_params = &unittest_params;
3233
3234         int retval;
3235         unsigned plaintext_pad_len;
3236         unsigned plaintext_len;
3237         uint8_t *plaintext;
3238
3239         /* Create KASUMI session */
3240         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3241                         tdata->key.data, tdata->key.len,
3242                         0, tdata->digest.len,
3243                         RTE_CRYPTO_AUTH_OP_GENERATE,
3244                         RTE_CRYPTO_AUTH_KASUMI_F9);
3245         if (retval < 0)
3246                 return retval;
3247
3248         /* alloc mbuf and set payload */
3249         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3250
3251         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3252         rte_pktmbuf_tailroom(ut_params->ibuf));
3253
3254         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3255         /* Append data which is padded to a multiple of */
3256         /* the algorithms block size */
3257         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3258         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3259                                 plaintext_pad_len);
3260         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3261
3262         /* Create KASUMI operation */
3263         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3264                         NULL, 0,
3265                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3266                         tdata->plaintext.len,
3267                         0);
3268         if (retval < 0)
3269                 return retval;
3270
3271         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3272                                 ut_params->op);
3273         ut_params->obuf = ut_params->op->sym->m_src;
3274         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3275         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3276                         + plaintext_pad_len;
3277
3278         /* Validate obuf */
3279         TEST_ASSERT_BUFFERS_ARE_EQUAL(
3280         ut_params->digest,
3281         tdata->digest.data,
3282         DIGEST_BYTE_LENGTH_KASUMI_F9,
3283         "KASUMI Generated auth tag not as expected");
3284
3285         return 0;
3286 }
3287
3288 static int
3289 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3290 {
3291         struct crypto_testsuite_params *ts_params = &testsuite_params;
3292         struct crypto_unittest_params *ut_params = &unittest_params;
3293
3294         int retval;
3295         unsigned plaintext_pad_len;
3296         unsigned plaintext_len;
3297         uint8_t *plaintext;
3298
3299         /* Create KASUMI session */
3300         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3301                                 tdata->key.data, tdata->key.len,
3302                                 0, tdata->digest.len,
3303                                 RTE_CRYPTO_AUTH_OP_VERIFY,
3304                                 RTE_CRYPTO_AUTH_KASUMI_F9);
3305         if (retval < 0)
3306                 return retval;
3307         /* alloc mbuf and set payload */
3308         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3309
3310         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3311         rte_pktmbuf_tailroom(ut_params->ibuf));
3312
3313         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3314         /* Append data which is padded to a multiple */
3315         /* of the algorithms block size */
3316         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3317         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3318                                 plaintext_pad_len);
3319         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3320
3321         /* Create KASUMI operation */
3322         retval = create_wireless_algo_hash_operation(tdata->digest.data,
3323                         tdata->digest.len,
3324                         NULL, 0,
3325                         plaintext_pad_len,
3326                         RTE_CRYPTO_AUTH_OP_VERIFY,
3327                         tdata->plaintext.len,
3328                         0);
3329         if (retval < 0)
3330                 return retval;
3331
3332         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3333                                 ut_params->op);
3334         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3335         ut_params->obuf = ut_params->op->sym->m_src;
3336         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3337                                 + plaintext_pad_len;
3338
3339         /* Validate obuf */
3340         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3341                 return 0;
3342         else
3343                 return -1;
3344
3345         return 0;
3346 }
3347
3348 static int
3349 test_snow3g_hash_generate_test_case_1(void)
3350 {
3351         return test_snow3g_authentication(&snow3g_hash_test_case_1);
3352 }
3353
3354 static int
3355 test_snow3g_hash_generate_test_case_2(void)
3356 {
3357         return test_snow3g_authentication(&snow3g_hash_test_case_2);
3358 }
3359
3360 static int
3361 test_snow3g_hash_generate_test_case_3(void)
3362 {
3363         return test_snow3g_authentication(&snow3g_hash_test_case_3);
3364 }
3365
3366 static int
3367 test_snow3g_hash_generate_test_case_4(void)
3368 {
3369         return test_snow3g_authentication(&snow3g_hash_test_case_4);
3370 }
3371
3372 static int
3373 test_snow3g_hash_generate_test_case_5(void)
3374 {
3375         return test_snow3g_authentication(&snow3g_hash_test_case_5);
3376 }
3377
3378 static int
3379 test_snow3g_hash_generate_test_case_6(void)
3380 {
3381         return test_snow3g_authentication(&snow3g_hash_test_case_6);
3382 }
3383
3384 static int
3385 test_snow3g_hash_verify_test_case_1(void)
3386 {
3387         return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3388
3389 }
3390
3391 static int
3392 test_snow3g_hash_verify_test_case_2(void)
3393 {
3394         return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3395 }
3396
3397 static int
3398 test_snow3g_hash_verify_test_case_3(void)
3399 {
3400         return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3401 }
3402
3403 static int
3404 test_snow3g_hash_verify_test_case_4(void)
3405 {
3406         return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3407 }
3408
3409 static int
3410 test_snow3g_hash_verify_test_case_5(void)
3411 {
3412         return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3413 }
3414
3415 static int
3416 test_snow3g_hash_verify_test_case_6(void)
3417 {
3418         return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3419 }
3420
3421 static int
3422 test_kasumi_hash_generate_test_case_1(void)
3423 {
3424         return test_kasumi_authentication(&kasumi_hash_test_case_1);
3425 }
3426
3427 static int
3428 test_kasumi_hash_generate_test_case_2(void)
3429 {
3430         return test_kasumi_authentication(&kasumi_hash_test_case_2);
3431 }
3432
3433 static int
3434 test_kasumi_hash_generate_test_case_3(void)
3435 {
3436         return test_kasumi_authentication(&kasumi_hash_test_case_3);
3437 }
3438
3439 static int
3440 test_kasumi_hash_generate_test_case_4(void)
3441 {
3442         return test_kasumi_authentication(&kasumi_hash_test_case_4);
3443 }
3444
3445 static int
3446 test_kasumi_hash_generate_test_case_5(void)
3447 {
3448         return test_kasumi_authentication(&kasumi_hash_test_case_5);
3449 }
3450
3451 static int
3452 test_kasumi_hash_generate_test_case_6(void)
3453 {
3454         return test_kasumi_authentication(&kasumi_hash_test_case_6);
3455 }
3456
3457 static int
3458 test_kasumi_hash_verify_test_case_1(void)
3459 {
3460         return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3461 }
3462
3463 static int
3464 test_kasumi_hash_verify_test_case_2(void)
3465 {
3466         return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3467 }
3468
3469 static int
3470 test_kasumi_hash_verify_test_case_3(void)
3471 {
3472         return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3473 }
3474
3475 static int
3476 test_kasumi_hash_verify_test_case_4(void)
3477 {
3478         return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3479 }
3480
3481 static int
3482 test_kasumi_hash_verify_test_case_5(void)
3483 {
3484         return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3485 }
3486
3487 static int
3488 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3489 {
3490         struct crypto_testsuite_params *ts_params = &testsuite_params;
3491         struct crypto_unittest_params *ut_params = &unittest_params;
3492
3493         int retval;
3494         uint8_t *plaintext, *ciphertext;
3495         unsigned plaintext_pad_len;
3496         unsigned plaintext_len;
3497
3498         /* Create KASUMI session */
3499         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3500                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3501                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3502                                         tdata->key.data, tdata->key.len,
3503                                         tdata->cipher_iv.len);
3504         if (retval < 0)
3505                 return retval;
3506
3507         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3508
3509         /* Clear mbuf payload */
3510         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3511                rte_pktmbuf_tailroom(ut_params->ibuf));
3512
3513         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3514         /* Append data which is padded to a multiple */
3515         /* of the algorithms block size */
3516         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3517         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3518                                 plaintext_pad_len);
3519         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3520
3521         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3522
3523         /* Create KASUMI operation */
3524         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3525                                 tdata->cipher_iv.len,
3526                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3527                                 tdata->validCipherOffsetInBits.len);
3528         if (retval < 0)
3529                 return retval;
3530
3531         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3532                                                 ut_params->op);
3533         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3534
3535         ut_params->obuf = ut_params->op->sym->m_dst;
3536         if (ut_params->obuf)
3537                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3538         else
3539                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3540
3541         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3542
3543         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3544                                 (tdata->validCipherOffsetInBits.len >> 3);
3545         /* Validate obuf */
3546         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3547                 ciphertext,
3548                 reference_ciphertext,
3549                 tdata->validCipherLenInBits.len,
3550                 "KASUMI Ciphertext data not as expected");
3551         return 0;
3552 }
3553
3554 static int
3555 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3556 {
3557         struct crypto_testsuite_params *ts_params = &testsuite_params;
3558         struct crypto_unittest_params *ut_params = &unittest_params;
3559
3560         int retval;
3561
3562         unsigned int plaintext_pad_len;
3563         unsigned int plaintext_len;
3564
3565         uint8_t buffer[10000];
3566         const uint8_t *ciphertext;
3567
3568         struct rte_cryptodev_info dev_info;
3569
3570         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3571
3572         uint64_t feat_flags = dev_info.feature_flags;
3573
3574         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3575                 printf("Device doesn't support in-place scatter-gather. "
3576                                 "Test Skipped.\n");
3577                 return -ENOTSUP;
3578         }
3579
3580         /* Create KASUMI session */
3581         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3582                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3583                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3584                                         tdata->key.data, tdata->key.len,
3585                                         tdata->cipher_iv.len);
3586         if (retval < 0)
3587                 return retval;
3588
3589         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3590
3591
3592         /* Append data which is padded to a multiple */
3593         /* of the algorithms block size */
3594         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3595
3596         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3597                         plaintext_pad_len, 10, 0);
3598
3599         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3600
3601         /* Create KASUMI operation */
3602         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3603                                 tdata->cipher_iv.len,
3604                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3605                                 tdata->validCipherOffsetInBits.len);
3606         if (retval < 0)
3607                 return retval;
3608
3609         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3610                                                 ut_params->op);
3611         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3612
3613         ut_params->obuf = ut_params->op->sym->m_dst;
3614
3615         if (ut_params->obuf)
3616                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3617                                 plaintext_len, buffer);
3618         else
3619                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3620                                 tdata->validCipherOffsetInBits.len >> 3,
3621                                 plaintext_len, buffer);
3622
3623         /* Validate obuf */
3624         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3625
3626         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3627                                 (tdata->validCipherOffsetInBits.len >> 3);
3628         /* Validate obuf */
3629         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3630                 ciphertext,
3631                 reference_ciphertext,
3632                 tdata->validCipherLenInBits.len,
3633                 "KASUMI Ciphertext data not as expected");
3634         return 0;
3635 }
3636
3637 static int
3638 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3639 {
3640         struct crypto_testsuite_params *ts_params = &testsuite_params;
3641         struct crypto_unittest_params *ut_params = &unittest_params;
3642
3643         int retval;
3644         uint8_t *plaintext, *ciphertext;
3645         unsigned plaintext_pad_len;
3646         unsigned plaintext_len;
3647
3648         /* Create KASUMI session */
3649         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3650                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3651                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3652                                         tdata->key.data, tdata->key.len,
3653                                         tdata->cipher_iv.len);
3654         if (retval < 0)
3655                 return retval;
3656
3657         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3658         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3659
3660         /* Clear mbuf payload */
3661         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3662                rte_pktmbuf_tailroom(ut_params->ibuf));
3663
3664         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3665         /* Append data which is padded to a multiple */
3666         /* of the algorithms block size */
3667         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3668         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3669                                 plaintext_pad_len);
3670         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3671         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3672
3673         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3674
3675         /* Create KASUMI operation */
3676         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3677                                 tdata->cipher_iv.len,
3678                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3679                                 tdata->validCipherOffsetInBits.len);
3680         if (retval < 0)
3681                 return retval;
3682
3683         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3684                                                 ut_params->op);
3685         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3686
3687         ut_params->obuf = ut_params->op->sym->m_dst;
3688         if (ut_params->obuf)
3689                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3690         else
3691                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3692
3693         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3694
3695         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3696                                 (tdata->validCipherOffsetInBits.len >> 3);
3697         /* Validate obuf */
3698         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3699                 ciphertext,
3700                 reference_ciphertext,
3701                 tdata->validCipherLenInBits.len,
3702                 "KASUMI Ciphertext data not as expected");
3703         return 0;
3704 }
3705
3706 static int
3707 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3708 {
3709         struct crypto_testsuite_params *ts_params = &testsuite_params;
3710         struct crypto_unittest_params *ut_params = &unittest_params;
3711
3712         int retval;
3713         unsigned int plaintext_pad_len;
3714         unsigned int plaintext_len;
3715
3716         const uint8_t *ciphertext;
3717         uint8_t buffer[2048];
3718
3719         struct rte_cryptodev_info dev_info;
3720
3721         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3722
3723         uint64_t feat_flags = dev_info.feature_flags;
3724         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3725                 printf("Device doesn't support out-of-place scatter-gather "
3726                                 "in both input and output mbufs. "
3727                                 "Test Skipped.\n");
3728                 return -ENOTSUP;
3729         }
3730
3731         /* Create KASUMI session */
3732         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3733                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3734                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3735                                         tdata->key.data, tdata->key.len,
3736                                         tdata->cipher_iv.len);
3737         if (retval < 0)
3738                 return retval;
3739
3740         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3741         /* Append data which is padded to a multiple */
3742         /* of the algorithms block size */
3743         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3744
3745         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3746                         plaintext_pad_len, 10, 0);
3747         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3748                         plaintext_pad_len, 3, 0);
3749
3750         /* Append data which is padded to a multiple */
3751         /* of the algorithms block size */
3752         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3753
3754         /* Create KASUMI operation */
3755         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3756                                 tdata->cipher_iv.len,
3757                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3758                                 tdata->validCipherOffsetInBits.len);
3759         if (retval < 0)
3760                 return retval;
3761
3762         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3763                                                 ut_params->op);
3764         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3765
3766         ut_params->obuf = ut_params->op->sym->m_dst;
3767         if (ut_params->obuf)
3768                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3769                                 plaintext_pad_len, buffer);
3770         else
3771                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3772                                 tdata->validCipherOffsetInBits.len >> 3,
3773                                 plaintext_pad_len, buffer);
3774
3775         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3776                                 (tdata->validCipherOffsetInBits.len >> 3);
3777         /* Validate obuf */
3778         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3779                 ciphertext,
3780                 reference_ciphertext,
3781                 tdata->validCipherLenInBits.len,
3782                 "KASUMI Ciphertext data not as expected");
3783         return 0;
3784 }
3785
3786
3787 static int
3788 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3789 {
3790         struct crypto_testsuite_params *ts_params = &testsuite_params;
3791         struct crypto_unittest_params *ut_params = &unittest_params;
3792
3793         int retval;
3794         uint8_t *ciphertext, *plaintext;
3795         unsigned ciphertext_pad_len;
3796         unsigned ciphertext_len;
3797
3798         /* Create KASUMI session */
3799         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3800                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
3801                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3802                                         tdata->key.data, tdata->key.len,
3803                                         tdata->cipher_iv.len);
3804         if (retval < 0)
3805                 return retval;
3806
3807         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3808         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3809
3810         /* Clear mbuf payload */
3811         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3812                rte_pktmbuf_tailroom(ut_params->ibuf));
3813
3814         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3815         /* Append data which is padded to a multiple */
3816         /* of the algorithms block size */
3817         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3818         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3819                                 ciphertext_pad_len);
3820         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3821         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3822
3823         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3824
3825         /* Create KASUMI operation */
3826         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3827                                 tdata->cipher_iv.len,
3828                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3829                                 tdata->validCipherOffsetInBits.len);
3830         if (retval < 0)
3831                 return retval;
3832
3833         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3834                                                 ut_params->op);
3835         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3836
3837         ut_params->obuf = ut_params->op->sym->m_dst;
3838         if (ut_params->obuf)
3839                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3840         else
3841                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3842
3843         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3844
3845         const uint8_t *reference_plaintext = tdata->plaintext.data +
3846                                 (tdata->validCipherOffsetInBits.len >> 3);
3847         /* Validate obuf */
3848         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3849                 plaintext,
3850                 reference_plaintext,
3851                 tdata->validCipherLenInBits.len,
3852                 "KASUMI Plaintext data not as expected");
3853         return 0;
3854 }
3855
3856 static int
3857 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3858 {
3859         struct crypto_testsuite_params *ts_params = &testsuite_params;
3860         struct crypto_unittest_params *ut_params = &unittest_params;
3861
3862         int retval;
3863         uint8_t *ciphertext, *plaintext;
3864         unsigned ciphertext_pad_len;
3865         unsigned ciphertext_len;
3866
3867         /* Create KASUMI session */
3868         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3869                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
3870                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3871                                         tdata->key.data, tdata->key.len,
3872                                         tdata->cipher_iv.len);
3873         if (retval < 0)
3874                 return retval;
3875
3876         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3877
3878         /* Clear mbuf payload */
3879         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3880                rte_pktmbuf_tailroom(ut_params->ibuf));
3881
3882         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3883         /* Append data which is padded to a multiple */
3884         /* of the algorithms block size */
3885         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3886         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3887                                 ciphertext_pad_len);
3888         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3889
3890         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3891
3892         /* Create KASUMI operation */
3893         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3894                                         tdata->cipher_iv.len,
3895                                         tdata->ciphertext.len,
3896                                         tdata->validCipherOffsetInBits.len);
3897         if (retval < 0)
3898                 return retval;
3899
3900         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3901                                                 ut_params->op);
3902         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3903
3904         ut_params->obuf = ut_params->op->sym->m_dst;
3905         if (ut_params->obuf)
3906                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3907         else
3908                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3909
3910         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3911
3912         const uint8_t *reference_plaintext = tdata->plaintext.data +
3913                                 (tdata->validCipherOffsetInBits.len >> 3);
3914         /* Validate obuf */
3915         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3916                 plaintext,
3917                 reference_plaintext,
3918                 tdata->validCipherLenInBits.len,
3919                 "KASUMI Plaintext data not as expected");
3920         return 0;
3921 }
3922
3923 static int
3924 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3925 {
3926         struct crypto_testsuite_params *ts_params = &testsuite_params;
3927         struct crypto_unittest_params *ut_params = &unittest_params;
3928
3929         int retval;
3930         uint8_t *plaintext, *ciphertext;
3931         unsigned plaintext_pad_len;
3932         unsigned plaintext_len;
3933
3934         /* Create SNOW 3G session */
3935         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3936                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3937                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3938                                         tdata->key.data, tdata->key.len,
3939                                         tdata->cipher_iv.len);
3940         if (retval < 0)
3941                 return retval;
3942
3943         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3944
3945         /* Clear mbuf payload */
3946         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3947                rte_pktmbuf_tailroom(ut_params->ibuf));
3948
3949         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3950         /* Append data which is padded to a multiple of */
3951         /* the algorithms block size */
3952         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3953         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3954                                 plaintext_pad_len);
3955         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3956
3957         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3958
3959         /* Create SNOW 3G operation */
3960         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3961                                         tdata->cipher_iv.len,
3962                                         tdata->validCipherLenInBits.len,
3963                                         0);
3964         if (retval < 0)
3965                 return retval;
3966
3967         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3968                                                 ut_params->op);
3969         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3970
3971         ut_params->obuf = ut_params->op->sym->m_dst;
3972         if (ut_params->obuf)
3973                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3974         else
3975                 ciphertext = plaintext;
3976
3977         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3978
3979         /* Validate obuf */
3980         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3981                 ciphertext,
3982                 tdata->ciphertext.data,
3983                 tdata->validDataLenInBits.len,
3984                 "SNOW 3G Ciphertext data not as expected");
3985         return 0;
3986 }
3987
3988
3989 static int
3990 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3991 {
3992         struct crypto_testsuite_params *ts_params = &testsuite_params;
3993         struct crypto_unittest_params *ut_params = &unittest_params;
3994         uint8_t *plaintext, *ciphertext;
3995
3996         int retval;
3997         unsigned plaintext_pad_len;
3998         unsigned plaintext_len;
3999
4000         /* Create SNOW 3G session */
4001         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4002                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4003                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4004                                         tdata->key.data, tdata->key.len,
4005                                         tdata->cipher_iv.len);
4006         if (retval < 0)
4007                 return retval;
4008
4009         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4010         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4011
4012         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4013                         "Failed to allocate input buffer in mempool");
4014         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4015                         "Failed to allocate output buffer in mempool");
4016
4017         /* Clear mbuf payload */
4018         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4019                rte_pktmbuf_tailroom(ut_params->ibuf));
4020
4021         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4022         /* Append data which is padded to a multiple of */
4023         /* the algorithms block size */
4024         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4025         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4026                                 plaintext_pad_len);
4027         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4028         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4029
4030         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4031
4032         /* Create SNOW 3G operation */
4033         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4034                                         tdata->cipher_iv.len,
4035                                         tdata->validCipherLenInBits.len,
4036                                         0);
4037         if (retval < 0)
4038                 return retval;
4039
4040         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4041                                                 ut_params->op);
4042         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4043
4044         ut_params->obuf = ut_params->op->sym->m_dst;
4045         if (ut_params->obuf)
4046                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4047         else
4048                 ciphertext = plaintext;
4049
4050         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4051
4052         /* Validate obuf */
4053         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4054                 ciphertext,
4055                 tdata->ciphertext.data,
4056                 tdata->validDataLenInBits.len,
4057                 "SNOW 3G Ciphertext data not as expected");
4058         return 0;
4059 }
4060
4061 static int
4062 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4063 {
4064         struct crypto_testsuite_params *ts_params = &testsuite_params;
4065         struct crypto_unittest_params *ut_params = &unittest_params;
4066
4067         int retval;
4068         unsigned int plaintext_pad_len;
4069         unsigned int plaintext_len;
4070         uint8_t buffer[10000];
4071         const uint8_t *ciphertext;
4072
4073         struct rte_cryptodev_info dev_info;
4074
4075         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4076
4077         uint64_t feat_flags = dev_info.feature_flags;
4078
4079         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4080                 printf("Device doesn't support out-of-place scatter-gather "
4081                                 "in both input and output mbufs. "
4082                                 "Test Skipped.\n");
4083                 return -ENOTSUP;
4084         }
4085
4086         /* Create SNOW 3G session */
4087         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4088                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4089                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4090                                         tdata->key.data, tdata->key.len,
4091                                         tdata->cipher_iv.len);
4092         if (retval < 0)
4093                 return retval;
4094
4095         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4096         /* Append data which is padded to a multiple of */
4097         /* the algorithms block size */
4098         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4099
4100         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4101                         plaintext_pad_len, 10, 0);
4102         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4103                         plaintext_pad_len, 3, 0);
4104
4105         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4106                         "Failed to allocate input buffer in mempool");
4107         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4108                         "Failed to allocate output buffer in mempool");
4109
4110         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4111
4112         /* Create SNOW 3G operation */
4113         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4114                                         tdata->cipher_iv.len,
4115                                         tdata->validCipherLenInBits.len,
4116                                         0);
4117         if (retval < 0)
4118                 return retval;
4119
4120         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4121                                                 ut_params->op);
4122         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4123
4124         ut_params->obuf = ut_params->op->sym->m_dst;
4125         if (ut_params->obuf)
4126                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4127                                 plaintext_len, buffer);
4128         else
4129                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4130                                 plaintext_len, buffer);
4131
4132         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4133
4134         /* Validate obuf */
4135         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4136                 ciphertext,
4137                 tdata->ciphertext.data,
4138                 tdata->validDataLenInBits.len,
4139                 "SNOW 3G Ciphertext data not as expected");
4140
4141         return 0;
4142 }
4143
4144 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4145 static void
4146 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4147 {
4148         uint8_t curr_byte, prev_byte;
4149         uint32_t length_in_bytes = ceil_byte_length(length + offset);
4150         uint8_t lower_byte_mask = (1 << offset) - 1;
4151         unsigned i;
4152
4153         prev_byte = buffer[0];
4154         buffer[0] >>= offset;
4155
4156         for (i = 1; i < length_in_bytes; i++) {
4157                 curr_byte = buffer[i];
4158                 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4159                                 (curr_byte >> offset);
4160                 prev_byte = curr_byte;
4161         }
4162 }
4163
4164 static int
4165 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4166 {
4167         struct crypto_testsuite_params *ts_params = &testsuite_params;
4168         struct crypto_unittest_params *ut_params = &unittest_params;
4169         uint8_t *plaintext, *ciphertext;
4170         int retval;
4171         uint32_t plaintext_len;
4172         uint32_t plaintext_pad_len;
4173         uint8_t extra_offset = 4;
4174         uint8_t *expected_ciphertext_shifted;
4175
4176         /* Create SNOW 3G session */
4177         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4178                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4179                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4180                                         tdata->key.data, tdata->key.len,
4181                                         tdata->cipher_iv.len);
4182         if (retval < 0)
4183                 return retval;
4184
4185         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4186         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4187
4188         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4189                         "Failed to allocate input buffer in mempool");
4190         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4191                         "Failed to allocate output buffer in mempool");
4192
4193         /* Clear mbuf payload */
4194         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4195                rte_pktmbuf_tailroom(ut_params->ibuf));
4196
4197         plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4198         /*
4199          * Append data which is padded to a
4200          * multiple of the algorithms block size
4201          */
4202         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4203
4204         plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4205                                                 plaintext_pad_len);
4206
4207         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4208
4209         memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4210         buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4211
4212 #ifdef RTE_APP_TEST_DEBUG
4213         rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4214 #endif
4215         /* Create SNOW 3G operation */
4216         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4217                                         tdata->cipher_iv.len,
4218                                         tdata->validCipherLenInBits.len,
4219                                         extra_offset);
4220         if (retval < 0)
4221                 return retval;
4222
4223         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4224                                                 ut_params->op);
4225         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4226
4227         ut_params->obuf = ut_params->op->sym->m_dst;
4228         if (ut_params->obuf)
4229                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4230         else
4231                 ciphertext = plaintext;
4232
4233 #ifdef RTE_APP_TEST_DEBUG
4234         rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4235 #endif
4236
4237         expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4238
4239         TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4240                         "failed to reserve memory for ciphertext shifted\n");
4241
4242         memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4243                         ceil_byte_length(tdata->ciphertext.len));
4244         buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4245                         extra_offset);
4246         /* Validate obuf */
4247         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4248                 ciphertext,
4249                 expected_ciphertext_shifted,
4250                 tdata->validDataLenInBits.len,
4251                 extra_offset,
4252                 "SNOW 3G Ciphertext data not as expected");
4253         return 0;
4254 }
4255
4256 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4257 {
4258         struct crypto_testsuite_params *ts_params = &testsuite_params;
4259         struct crypto_unittest_params *ut_params = &unittest_params;
4260
4261         int retval;
4262
4263         uint8_t *plaintext, *ciphertext;
4264         unsigned ciphertext_pad_len;
4265         unsigned ciphertext_len;
4266
4267         /* Create SNOW 3G session */
4268         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4269                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
4270                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4271                                         tdata->key.data, tdata->key.len,
4272                                         tdata->cipher_iv.len);
4273         if (retval < 0)
4274                 return retval;
4275
4276         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4277
4278         /* Clear mbuf payload */
4279         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4280                rte_pktmbuf_tailroom(ut_params->ibuf));
4281
4282         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4283         /* Append data which is padded to a multiple of */
4284         /* the algorithms block size */
4285         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4286         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4287                                 ciphertext_pad_len);
4288         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4289
4290         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4291
4292         /* Create SNOW 3G operation */
4293         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4294                                         tdata->cipher_iv.len,
4295                                         tdata->validCipherLenInBits.len,
4296                                         tdata->cipher.offset_bits);
4297         if (retval < 0)
4298                 return retval;
4299
4300         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4301                                                 ut_params->op);
4302         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4303         ut_params->obuf = ut_params->op->sym->m_dst;
4304         if (ut_params->obuf)
4305                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4306         else
4307                 plaintext = ciphertext;
4308
4309         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4310
4311         /* Validate obuf */
4312         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4313                                 tdata->plaintext.data,
4314                                 tdata->validDataLenInBits.len,
4315                                 "SNOW 3G Plaintext data not as expected");
4316         return 0;
4317 }
4318
4319 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4320 {
4321         struct crypto_testsuite_params *ts_params = &testsuite_params;
4322         struct crypto_unittest_params *ut_params = &unittest_params;
4323
4324         int retval;
4325
4326         uint8_t *plaintext, *ciphertext;
4327         unsigned ciphertext_pad_len;
4328         unsigned ciphertext_len;
4329
4330         /* Create SNOW 3G session */
4331         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4332                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
4333                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4334                                         tdata->key.data, tdata->key.len,
4335                                         tdata->cipher_iv.len);
4336         if (retval < 0)
4337                 return retval;
4338
4339         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4340         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4341
4342         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4343                         "Failed to allocate input buffer");
4344         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4345                         "Failed to allocate output buffer");
4346
4347         /* Clear mbuf payload */
4348         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4349                rte_pktmbuf_tailroom(ut_params->ibuf));
4350
4351         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4352                        rte_pktmbuf_tailroom(ut_params->obuf));
4353
4354         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4355         /* Append data which is padded to a multiple of */
4356         /* the algorithms block size */
4357         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4358         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4359                                 ciphertext_pad_len);
4360         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4361         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4362
4363         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4364
4365         /* Create SNOW 3G operation */
4366         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4367                                         tdata->cipher_iv.len,
4368                                         tdata->validCipherLenInBits.len,
4369                                         0);
4370         if (retval < 0)
4371                 return retval;
4372
4373         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4374                                                 ut_params->op);
4375         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4376         ut_params->obuf = ut_params->op->sym->m_dst;
4377         if (ut_params->obuf)
4378                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4379         else
4380                 plaintext = ciphertext;
4381
4382         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4383
4384         /* Validate obuf */
4385         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4386                                 tdata->plaintext.data,
4387                                 tdata->validDataLenInBits.len,
4388                                 "SNOW 3G Plaintext data not as expected");
4389         return 0;
4390 }
4391
4392 static int
4393 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4394 {
4395         struct crypto_testsuite_params *ts_params = &testsuite_params;
4396         struct crypto_unittest_params *ut_params = &unittest_params;
4397
4398         int retval;
4399
4400         uint8_t *plaintext, *ciphertext;
4401         unsigned int plaintext_pad_len;
4402         unsigned int plaintext_len;
4403
4404         struct rte_cryptodev_sym_capability_idx cap_idx;
4405
4406         /* Check if device supports ZUC EEA3 */
4407         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4408         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4409
4410         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4411                         &cap_idx) == NULL)
4412                 return -ENOTSUP;
4413
4414         /* Check if device supports ZUC EIA3 */
4415         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4416         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4417
4418         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4419                         &cap_idx) == NULL)
4420                 return -ENOTSUP;
4421
4422         /* Create ZUC session */
4423         retval = create_zuc_cipher_auth_encrypt_generate_session(
4424                         ts_params->valid_devs[0],
4425                         tdata);
4426         if (retval < 0)
4427                 return retval;
4428         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4429
4430         /* clear mbuf payload */
4431         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4432                         rte_pktmbuf_tailroom(ut_params->ibuf));
4433
4434         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4435         /* Append data which is padded to a multiple of */
4436         /* the algorithms block size */
4437         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4438         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4439                                 plaintext_pad_len);
4440         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4441
4442         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4443
4444         /* Create ZUC operation */
4445         retval = create_zuc_cipher_hash_generate_operation(tdata);
4446         if (retval < 0)
4447                 return retval;
4448
4449         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4450                         ut_params->op);
4451         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4452         ut_params->obuf = ut_params->op->sym->m_src;
4453         if (ut_params->obuf)
4454                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4455         else
4456                 ciphertext = plaintext;
4457
4458         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4459         /* Validate obuf */
4460         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4461                         ciphertext,
4462                         tdata->ciphertext.data,
4463                         tdata->validDataLenInBits.len,
4464                         "ZUC Ciphertext data not as expected");
4465
4466         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4467             + plaintext_pad_len;
4468
4469         /* Validate obuf */
4470         TEST_ASSERT_BUFFERS_ARE_EQUAL(
4471                         ut_params->digest,
4472                         tdata->digest.data,
4473                         4,
4474                         "ZUC Generated auth tag not as expected");
4475         return 0;
4476 }
4477
4478 static int
4479 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4480 {
4481         struct crypto_testsuite_params *ts_params = &testsuite_params;
4482         struct crypto_unittest_params *ut_params = &unittest_params;
4483
4484         int retval;
4485
4486         uint8_t *plaintext, *ciphertext;
4487         unsigned plaintext_pad_len;
4488         unsigned plaintext_len;
4489
4490         /* Create SNOW 3G session */
4491         retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4492                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4493                         RTE_CRYPTO_AUTH_OP_GENERATE,
4494                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4495                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4496                         tdata->key.data, tdata->key.len,
4497                         tdata->auth_iv.len, tdata->digest.len,
4498                         tdata->cipher_iv.len);
4499         if (retval < 0)
4500                 return retval;
4501         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4502
4503         /* clear mbuf payload */
4504         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4505                         rte_pktmbuf_tailroom(ut_params->ibuf));
4506
4507         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4508         /* Append data which is padded to a multiple of */
4509         /* the algorithms block size */
4510         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4511         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4512                                 plaintext_pad_len);
4513         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4514
4515         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4516
4517         /* Create SNOW 3G operation */
4518         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4519                         tdata->digest.len, tdata->auth_iv.data,
4520                         tdata->auth_iv.len,
4521                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4522                         tdata->cipher_iv.data, tdata->cipher_iv.len,
4523                         tdata->validCipherLenInBits.len,
4524                         0,
4525                         tdata->validAuthLenInBits.len,
4526                         0
4527                         );
4528         if (retval < 0)
4529                 return retval;
4530
4531         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4532                         ut_params->op);
4533         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4534         ut_params->obuf = ut_params->op->sym->m_src;
4535         if (ut_params->obuf)
4536                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4537         else
4538                 ciphertext = plaintext;
4539
4540         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4541         /* Validate obuf */
4542         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4543                         ciphertext,
4544                         tdata->ciphertext.data,
4545                         tdata->validDataLenInBits.len,
4546                         "SNOW 3G Ciphertext data not as expected");
4547
4548         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4549             + plaintext_pad_len;
4550
4551         /* Validate obuf */
4552         TEST_ASSERT_BUFFERS_ARE_EQUAL(
4553                         ut_params->digest,
4554                         tdata->digest.data,
4555                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4556                         "SNOW 3G Generated auth tag not as expected");
4557         return 0;
4558 }
4559
4560 static int
4561 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4562         uint8_t op_mode, uint8_t verify)
4563 {
4564         struct crypto_testsuite_params *ts_params = &testsuite_params;
4565         struct crypto_unittest_params *ut_params = &unittest_params;
4566
4567         int retval;
4568
4569         uint8_t *plaintext = NULL, *ciphertext = NULL;
4570         unsigned int plaintext_pad_len;
4571         unsigned int plaintext_len;
4572         unsigned int ciphertext_pad_len;
4573         unsigned int ciphertext_len;
4574
4575         struct rte_cryptodev_info dev_info;
4576
4577         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4578
4579         uint64_t feat_flags = dev_info.feature_flags;
4580
4581         if (op_mode == OUT_OF_PLACE) {
4582                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4583                         printf("Device doesn't support digest encrypted.\n");
4584                         return -ENOTSUP;
4585                 }
4586         }
4587
4588         /* Create SNOW 3G session */
4589         retval = create_wireless_algo_auth_cipher_session(
4590                         ts_params->valid_devs[0],
4591                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4592                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4593                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4594                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4595                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4596                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4597                         tdata->key.data, tdata->key.len,
4598                         tdata->auth_iv.len, tdata->digest.len,
4599                         tdata->cipher_iv.len);
4600
4601         if (retval < 0)
4602                 return retval;
4603
4604         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4605         if (op_mode == OUT_OF_PLACE)
4606                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4607
4608         /* clear mbuf payload */
4609         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4610                 rte_pktmbuf_tailroom(ut_params->ibuf));
4611         if (op_mode == OUT_OF_PLACE)
4612                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4613                         rte_pktmbuf_tailroom(ut_params->obuf));
4614
4615         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4616         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4617         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4618         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4619
4620         if (verify) {
4621                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4622                                         ciphertext_pad_len);
4623                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4624                 if (op_mode == OUT_OF_PLACE)
4625                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4626                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4627                         ciphertext_len);
4628         } else {
4629                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4630                                         plaintext_pad_len);
4631                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4632                 if (op_mode == OUT_OF_PLACE)
4633                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4634                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4635         }
4636
4637         /* Create SNOW 3G operation */
4638         retval = create_wireless_algo_auth_cipher_operation(
4639                 tdata->digest.len,
4640                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4641                 tdata->auth_iv.data, tdata->auth_iv.len,
4642                 (tdata->digest.offset_bytes == 0 ?
4643                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4644                         : tdata->digest.offset_bytes),
4645                 tdata->validCipherLenInBits.len,
4646                 tdata->cipher.offset_bits,
4647                 tdata->validAuthLenInBits.len,
4648                 tdata->auth.offset_bits,
4649                 op_mode, 0);
4650
4651         if (retval < 0)
4652                 return retval;
4653
4654         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4655                         ut_params->op);
4656
4657         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4658
4659         ut_params->obuf = (op_mode == IN_PLACE ?
4660                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4661
4662         if (verify) {
4663                 if (ut_params->obuf)
4664                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4665                                                         uint8_t *);
4666                 else
4667                         plaintext = ciphertext +
4668                                 (tdata->cipher.offset_bits >> 3);
4669
4670                 debug_hexdump(stdout, "plaintext:", plaintext,
4671                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4672                 debug_hexdump(stdout, "plaintext expected:",
4673                         tdata->plaintext.data,
4674                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4675         } else {
4676                 if (ut_params->obuf)
4677                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4678                                                         uint8_t *);
4679                 else
4680                         ciphertext = plaintext;
4681
4682                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4683                         ciphertext_len);
4684                 debug_hexdump(stdout, "ciphertext expected:",
4685                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4686
4687                 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4688                         + (tdata->digest.offset_bytes == 0 ?
4689                 plaintext_pad_len : tdata->digest.offset_bytes);
4690
4691                 debug_hexdump(stdout, "digest:", ut_params->digest,
4692                         tdata->digest.len);
4693                 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4694                                 tdata->digest.len);
4695         }
4696
4697         /* Validate obuf */
4698         if (verify) {
4699                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4700                         plaintext,
4701                         tdata->plaintext.data,
4702                         tdata->plaintext.len >> 3,
4703                         "SNOW 3G Plaintext data not as expected");
4704         } else {
4705                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4706                         ciphertext,
4707                         tdata->ciphertext.data,
4708                         tdata->validDataLenInBits.len,
4709                         "SNOW 3G Ciphertext data not as expected");
4710
4711                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4712                         ut_params->digest,
4713                         tdata->digest.data,
4714                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4715                         "SNOW 3G Generated auth tag not as expected");
4716         }
4717         return 0;
4718 }
4719
4720 static int
4721 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4722         uint8_t op_mode, uint8_t verify)
4723 {
4724         struct crypto_testsuite_params *ts_params = &testsuite_params;
4725         struct crypto_unittest_params *ut_params = &unittest_params;
4726
4727         int retval;
4728
4729         const uint8_t *plaintext = NULL;
4730         const uint8_t *ciphertext = NULL;
4731         const uint8_t *digest = NULL;
4732         unsigned int plaintext_pad_len;
4733         unsigned int plaintext_len;
4734         unsigned int ciphertext_pad_len;
4735         unsigned int ciphertext_len;
4736         uint8_t buffer[10000];
4737         uint8_t digest_buffer[10000];
4738
4739         struct rte_cryptodev_info dev_info;
4740
4741         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4742
4743         uint64_t feat_flags = dev_info.feature_flags;
4744
4745         if (op_mode == IN_PLACE) {
4746                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4747                         printf("Device doesn't support in-place scatter-gather "
4748                                         "in both input and output mbufs.\n");
4749                         return -ENOTSUP;
4750                 }
4751         } else {
4752                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4753                         printf("Device doesn't support out-of-place scatter-gather "
4754                                         "in both input and output mbufs.\n");
4755                         return -ENOTSUP;
4756                 }
4757                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4758                         printf("Device doesn't support digest encrypted.\n");
4759                         return -ENOTSUP;
4760                 }
4761         }
4762
4763         /* Create SNOW 3G session */
4764         retval = create_wireless_algo_auth_cipher_session(
4765                         ts_params->valid_devs[0],
4766                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4767                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4768                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4769                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4770                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4771                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4772                         tdata->key.data, tdata->key.len,
4773                         tdata->auth_iv.len, tdata->digest.len,
4774                         tdata->cipher_iv.len);
4775
4776         if (retval < 0)
4777                 return retval;
4778
4779         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4780         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4781         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4782         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4783
4784         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4785                         plaintext_pad_len, 15, 0);
4786         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4787                         "Failed to allocate input buffer in mempool");
4788
4789         if (op_mode == OUT_OF_PLACE) {
4790                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4791                                 plaintext_pad_len, 15, 0);
4792                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4793                                 "Failed to allocate output buffer in mempool");
4794         }
4795
4796         if (verify) {
4797                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4798                         tdata->ciphertext.data);
4799                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4800                                         ciphertext_len, buffer);
4801                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4802                         ciphertext_len);
4803         } else {
4804                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4805                         tdata->plaintext.data);
4806                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4807                                         plaintext_len, buffer);
4808                 debug_hexdump(stdout, "plaintext:", plaintext,
4809                         plaintext_len);
4810         }
4811         memset(buffer, 0, sizeof(buffer));
4812
4813         /* Create SNOW 3G operation */
4814         retval = create_wireless_algo_auth_cipher_operation(
4815                 tdata->digest.len,
4816                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4817                 tdata->auth_iv.data, tdata->auth_iv.len,
4818                 (tdata->digest.offset_bytes == 0 ?
4819                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4820                         : tdata->digest.offset_bytes),
4821                 tdata->validCipherLenInBits.len,
4822                 tdata->cipher.offset_bits,
4823                 tdata->validAuthLenInBits.len,
4824                 tdata->auth.offset_bits,
4825                 op_mode, 1);
4826
4827         if (retval < 0)
4828                 return retval;
4829
4830         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4831                         ut_params->op);
4832
4833         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4834
4835         ut_params->obuf = (op_mode == IN_PLACE ?
4836                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4837
4838         if (verify) {
4839                 if (ut_params->obuf)
4840                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4841                                         plaintext_len, buffer);
4842                 else
4843                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4844                                         plaintext_len, buffer);
4845
4846                 debug_hexdump(stdout, "plaintext:", plaintext,
4847                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4848                 debug_hexdump(stdout, "plaintext expected:",
4849                         tdata->plaintext.data,
4850                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4851         } else {
4852                 if (ut_params->obuf)
4853                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4854                                         ciphertext_len, buffer);
4855                 else
4856                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4857                                         ciphertext_len, buffer);
4858
4859                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4860                         ciphertext_len);
4861                 debug_hexdump(stdout, "ciphertext expected:",
4862                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4863
4864                 if (ut_params->obuf)
4865                         digest = rte_pktmbuf_read(ut_params->obuf,
4866                                 (tdata->digest.offset_bytes == 0 ?
4867                                 plaintext_pad_len : tdata->digest.offset_bytes),
4868                                 tdata->digest.len, digest_buffer);
4869                 else
4870                         digest = rte_pktmbuf_read(ut_params->ibuf,
4871                                 (tdata->digest.offset_bytes == 0 ?
4872                                 plaintext_pad_len : tdata->digest.offset_bytes),
4873                                 tdata->digest.len, digest_buffer);
4874
4875                 debug_hexdump(stdout, "digest:", digest,
4876                         tdata->digest.len);
4877                 debug_hexdump(stdout, "digest expected:",
4878                         tdata->digest.data, tdata->digest.len);
4879         }
4880
4881         /* Validate obuf */
4882         if (verify) {
4883                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4884                         plaintext,
4885                         tdata->plaintext.data,
4886                         tdata->plaintext.len >> 3,
4887                         "SNOW 3G Plaintext data not as expected");
4888         } else {
4889                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4890                         ciphertext,
4891                         tdata->ciphertext.data,
4892                         tdata->validDataLenInBits.len,
4893                         "SNOW 3G Ciphertext data not as expected");
4894
4895                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4896                         digest,
4897                         tdata->digest.data,
4898                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4899                         "SNOW 3G Generated auth tag not as expected");
4900         }
4901         return 0;
4902 }
4903
4904 static int
4905 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4906         uint8_t op_mode, uint8_t verify)
4907 {
4908         struct crypto_testsuite_params *ts_params = &testsuite_params;
4909         struct crypto_unittest_params *ut_params = &unittest_params;
4910
4911         int retval;
4912
4913         uint8_t *plaintext = NULL, *ciphertext = NULL;
4914         unsigned int plaintext_pad_len;
4915         unsigned int plaintext_len;
4916         unsigned int ciphertext_pad_len;
4917         unsigned int ciphertext_len;
4918
4919         struct rte_cryptodev_info dev_info;
4920
4921         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4922
4923         uint64_t feat_flags = dev_info.feature_flags;
4924
4925         if (op_mode == OUT_OF_PLACE) {
4926                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4927                         printf("Device doesn't support digest encrypted.\n");
4928                         return -ENOTSUP;
4929                 }
4930         }
4931
4932         /* Create KASUMI session */
4933         retval = create_wireless_algo_auth_cipher_session(
4934                         ts_params->valid_devs[0],
4935                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4936                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4937                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4938                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4939                         RTE_CRYPTO_AUTH_KASUMI_F9,
4940                         RTE_CRYPTO_CIPHER_KASUMI_F8,
4941                         tdata->key.data, tdata->key.len,
4942                         0, tdata->digest.len,
4943                         tdata->cipher_iv.len);
4944
4945         if (retval < 0)
4946                 return retval;
4947
4948         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4949         if (op_mode == OUT_OF_PLACE)
4950                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4951
4952         /* clear mbuf payload */
4953         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4954                 rte_pktmbuf_tailroom(ut_params->ibuf));
4955         if (op_mode == OUT_OF_PLACE)
4956                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4957                         rte_pktmbuf_tailroom(ut_params->obuf));
4958
4959         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4960         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4961         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4962         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4963
4964         if (verify) {
4965                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4966                                         ciphertext_pad_len);
4967                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4968                 if (op_mode == OUT_OF_PLACE)
4969                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4970                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4971                         ciphertext_len);
4972         } else {
4973                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4974                                         plaintext_pad_len);
4975                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4976                 if (op_mode == OUT_OF_PLACE)
4977                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4978                 debug_hexdump(stdout, "plaintext:", plaintext,
4979                         plaintext_len);
4980         }
4981
4982         /* Create KASUMI operation */
4983         retval = create_wireless_algo_auth_cipher_operation(
4984                 tdata->digest.len,
4985                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4986                 NULL, 0,
4987                 (tdata->digest.offset_bytes == 0 ?
4988                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4989                         : tdata->digest.offset_bytes),
4990                 tdata->validCipherLenInBits.len,
4991                 tdata->validCipherOffsetInBits.len,
4992                 tdata->validAuthLenInBits.len,
4993                 0,
4994                 op_mode, 0);
4995
4996         if (retval < 0)
4997                 return retval;
4998
4999         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5000                         ut_params->op);
5001
5002         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5003
5004         ut_params->obuf = (op_mode == IN_PLACE ?
5005                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5006
5007
5008         if (verify) {
5009                 if (ut_params->obuf)
5010                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5011                                                         uint8_t *);
5012                 else
5013                         plaintext = ciphertext;
5014
5015                 debug_hexdump(stdout, "plaintext:", plaintext,
5016                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5017                 debug_hexdump(stdout, "plaintext expected:",
5018                         tdata->plaintext.data,
5019                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5020         } else {
5021                 if (ut_params->obuf)
5022                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5023                                                         uint8_t *);
5024                 else
5025                         ciphertext = plaintext;
5026
5027                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5028                         ciphertext_len);
5029                 debug_hexdump(stdout, "ciphertext expected:",
5030                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5031
5032                 ut_params->digest = rte_pktmbuf_mtod(
5033                         ut_params->obuf, uint8_t *) +
5034                         (tdata->digest.offset_bytes == 0 ?
5035                         plaintext_pad_len : tdata->digest.offset_bytes);
5036
5037                 debug_hexdump(stdout, "digest:", ut_params->digest,
5038                         tdata->digest.len);
5039                 debug_hexdump(stdout, "digest expected:",
5040                         tdata->digest.data, tdata->digest.len);
5041         }
5042
5043         /* Validate obuf */
5044         if (verify) {
5045                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5046                         plaintext,
5047                         tdata->plaintext.data,
5048                         tdata->plaintext.len >> 3,
5049                         "KASUMI Plaintext data not as expected");
5050         } else {
5051                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5052                         ciphertext,
5053                         tdata->ciphertext.data,
5054                         tdata->ciphertext.len >> 3,
5055                         "KASUMI Ciphertext data not as expected");
5056
5057                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5058                         ut_params->digest,
5059                         tdata->digest.data,
5060                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5061                         "KASUMI Generated auth tag not as expected");
5062         }
5063         return 0;
5064 }
5065
5066 static int
5067 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5068         uint8_t op_mode, uint8_t verify)
5069 {
5070         struct crypto_testsuite_params *ts_params = &testsuite_params;
5071         struct crypto_unittest_params *ut_params = &unittest_params;
5072
5073         int retval;
5074
5075         const uint8_t *plaintext = NULL;
5076         const uint8_t *ciphertext = NULL;
5077         const uint8_t *digest = NULL;
5078         unsigned int plaintext_pad_len;
5079         unsigned int plaintext_len;
5080         unsigned int ciphertext_pad_len;
5081         unsigned int ciphertext_len;
5082         uint8_t buffer[10000];
5083         uint8_t digest_buffer[10000];
5084
5085         struct rte_cryptodev_info dev_info;
5086
5087         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5088
5089         uint64_t feat_flags = dev_info.feature_flags;
5090
5091         if (op_mode == IN_PLACE) {
5092                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5093                         printf("Device doesn't support in-place scatter-gather "
5094                                         "in both input and output mbufs.\n");
5095                         return -ENOTSUP;
5096                 }
5097         } else {
5098                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5099                         printf("Device doesn't support out-of-place scatter-gather "
5100                                         "in both input and output mbufs.\n");
5101                         return -ENOTSUP;
5102                 }
5103                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5104                         printf("Device doesn't support digest encrypted.\n");
5105                         return -ENOTSUP;
5106                 }
5107         }
5108
5109         /* Create KASUMI session */
5110         retval = create_wireless_algo_auth_cipher_session(
5111                         ts_params->valid_devs[0],
5112                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5113                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5114                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5115                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
5116                         RTE_CRYPTO_AUTH_KASUMI_F9,
5117                         RTE_CRYPTO_CIPHER_KASUMI_F8,
5118                         tdata->key.data, tdata->key.len,
5119                         0, tdata->digest.len,
5120                         tdata->cipher_iv.len);
5121
5122         if (retval < 0)
5123                 return retval;
5124
5125         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5126         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5127         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5128         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5129
5130         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5131                         plaintext_pad_len, 15, 0);
5132         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5133                         "Failed to allocate input buffer in mempool");
5134
5135         if (op_mode == OUT_OF_PLACE) {
5136                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5137                                 plaintext_pad_len, 15, 0);
5138                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5139                                 "Failed to allocate output buffer in mempool");
5140         }
5141
5142         if (verify) {
5143                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5144                         tdata->ciphertext.data);
5145                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5146                                         ciphertext_len, buffer);
5147                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5148                         ciphertext_len);
5149         } else {
5150                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5151                         tdata->plaintext.data);
5152                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5153                                         plaintext_len, buffer);
5154                 debug_hexdump(stdout, "plaintext:", plaintext,
5155                         plaintext_len);
5156         }
5157         memset(buffer, 0, sizeof(buffer));
5158
5159         /* Create KASUMI operation */
5160         retval = create_wireless_algo_auth_cipher_operation(
5161                 tdata->digest.len,
5162                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5163                 NULL, 0,
5164                 (tdata->digest.offset_bytes == 0 ?
5165                 (verify ? ciphertext_pad_len : plaintext_pad_len)
5166                         : tdata->digest.offset_bytes),
5167                 tdata->validCipherLenInBits.len,
5168                 tdata->validCipherOffsetInBits.len,
5169                 tdata->validAuthLenInBits.len,
5170                 0,
5171                 op_mode, 1);
5172
5173         if (retval < 0)
5174                 return retval;
5175
5176         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5177                         ut_params->op);
5178
5179         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5180
5181         ut_params->obuf = (op_mode == IN_PLACE ?
5182                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5183
5184         if (verify) {
5185                 if (ut_params->obuf)
5186                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5187                                         plaintext_len, buffer);
5188                 else
5189                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5190                                         plaintext_len, buffer);
5191
5192                 debug_hexdump(stdout, "plaintext:", plaintext,
5193                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5194                 debug_hexdump(stdout, "plaintext expected:",
5195                         tdata->plaintext.data,
5196                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5197         } else {
5198                 if (ut_params->obuf)
5199                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5200                                         ciphertext_len, buffer);
5201                 else
5202                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5203                                         ciphertext_len, buffer);
5204
5205                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5206                         ciphertext_len);
5207                 debug_hexdump(stdout, "ciphertext expected:",
5208                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5209
5210                 if (ut_params->obuf)
5211                         digest = rte_pktmbuf_read(ut_params->obuf,
5212                                 (tdata->digest.offset_bytes == 0 ?
5213                                 plaintext_pad_len : tdata->digest.offset_bytes),
5214                                 tdata->digest.len, digest_buffer);
5215                 else
5216                         digest = rte_pktmbuf_read(ut_params->ibuf,
5217                                 (tdata->digest.offset_bytes == 0 ?
5218                                 plaintext_pad_len : tdata->digest.offset_bytes),
5219                                 tdata->digest.len, digest_buffer);
5220
5221                 debug_hexdump(stdout, "digest:", digest,
5222                         tdata->digest.len);
5223                 debug_hexdump(stdout, "digest expected:",
5224                         tdata->digest.data, tdata->digest.len);
5225         }
5226
5227         /* Validate obuf */
5228         if (verify) {
5229                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5230                         plaintext,
5231                         tdata->plaintext.data,
5232                         tdata->plaintext.len >> 3,
5233                         "KASUMI Plaintext data not as expected");
5234         } else {
5235                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5236                         ciphertext,
5237                         tdata->ciphertext.data,
5238                         tdata->validDataLenInBits.len,
5239                         "KASUMI Ciphertext data not as expected");
5240
5241                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5242                         digest,
5243                         tdata->digest.data,
5244                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5245                         "KASUMI Generated auth tag not as expected");
5246         }
5247         return 0;
5248 }
5249
5250 static int
5251 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5252 {
5253         struct crypto_testsuite_params *ts_params = &testsuite_params;
5254         struct crypto_unittest_params *ut_params = &unittest_params;
5255
5256         int retval;
5257
5258         uint8_t *plaintext, *ciphertext;
5259         unsigned plaintext_pad_len;
5260         unsigned plaintext_len;
5261
5262         /* Create KASUMI session */
5263         retval = create_wireless_algo_cipher_auth_session(
5264                         ts_params->valid_devs[0],
5265                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5266                         RTE_CRYPTO_AUTH_OP_GENERATE,
5267                         RTE_CRYPTO_AUTH_KASUMI_F9,
5268                         RTE_CRYPTO_CIPHER_KASUMI_F8,
5269                         tdata->key.data, tdata->key.len,
5270                         0, tdata->digest.len,
5271                         tdata->cipher_iv.len);
5272         if (retval < 0)
5273                 return retval;
5274
5275         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5276
5277         /* clear mbuf payload */
5278         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5279                         rte_pktmbuf_tailroom(ut_params->ibuf));
5280
5281         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5282         /* Append data which is padded to a multiple of */
5283         /* the algorithms block size */
5284         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5285         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5286                                 plaintext_pad_len);
5287         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5288
5289         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5290
5291         /* Create KASUMI operation */
5292         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5293                                 tdata->digest.len, NULL, 0,
5294                                 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5295                                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5296                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5297                                 tdata->validCipherOffsetInBits.len,
5298                                 tdata->validAuthLenInBits.len,
5299                                 0
5300                                 );
5301         if (retval < 0)
5302                 return retval;
5303
5304         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5305                         ut_params->op);
5306         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5307
5308         if (ut_params->op->sym->m_dst)
5309                 ut_params->obuf = ut_params->op->sym->m_dst;
5310         else
5311                 ut_params->obuf = ut_params->op->sym->m_src;
5312
5313         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5314                                 tdata->validCipherOffsetInBits.len >> 3);
5315
5316         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5317                         + plaintext_pad_len;
5318
5319         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5320                                 (tdata->validCipherOffsetInBits.len >> 3);
5321         /* Validate obuf */
5322         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5323                 ciphertext,
5324                 reference_ciphertext,
5325                 tdata->validCipherLenInBits.len,
5326                 "KASUMI Ciphertext data not as expected");
5327
5328         /* Validate obuf */
5329         TEST_ASSERT_BUFFERS_ARE_EQUAL(
5330                 ut_params->digest,
5331                 tdata->digest.data,
5332                 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5333                 "KASUMI Generated auth tag not as expected");
5334         return 0;
5335 }
5336
5337 static int
5338 test_zuc_encryption(const struct wireless_test_data *tdata)
5339 {
5340         struct crypto_testsuite_params *ts_params = &testsuite_params;
5341         struct crypto_unittest_params *ut_params = &unittest_params;
5342
5343         int retval;
5344         uint8_t *plaintext, *ciphertext;
5345         unsigned plaintext_pad_len;
5346         unsigned plaintext_len;
5347
5348         struct rte_cryptodev_sym_capability_idx cap_idx;
5349
5350         /* Check if device supports ZUC EEA3 */
5351         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5352         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5353
5354         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5355                         &cap_idx) == NULL)
5356                 return -ENOTSUP;
5357
5358         /* Create ZUC session */
5359         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5360                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5361                                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5362                                         tdata->key.data, tdata->key.len,
5363                                         tdata->cipher_iv.len);
5364         if (retval < 0)
5365                 return retval;
5366
5367         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5368
5369         /* Clear mbuf payload */
5370         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5371                rte_pktmbuf_tailroom(ut_params->ibuf));
5372
5373         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5374         /* Append data which is padded to a multiple */
5375         /* of the algorithms block size */
5376         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5377         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5378                                 plaintext_pad_len);
5379         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5380
5381         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5382
5383         /* Create ZUC operation */
5384         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5385                                         tdata->cipher_iv.len,
5386                                         tdata->plaintext.len,
5387                                         0);
5388         if (retval < 0)
5389                 return retval;
5390
5391         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5392                                                 ut_params->op);
5393         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5394
5395         ut_params->obuf = ut_params->op->sym->m_dst;
5396         if (ut_params->obuf)
5397                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5398         else
5399                 ciphertext = plaintext;
5400
5401         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5402
5403         /* Validate obuf */
5404         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5405                 ciphertext,
5406                 tdata->ciphertext.data,
5407                 tdata->validCipherLenInBits.len,
5408                 "ZUC Ciphertext data not as expected");
5409         return 0;
5410 }
5411
5412 static int
5413 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5414 {
5415         struct crypto_testsuite_params *ts_params = &testsuite_params;
5416         struct crypto_unittest_params *ut_params = &unittest_params;
5417
5418         int retval;
5419
5420         unsigned int plaintext_pad_len;
5421         unsigned int plaintext_len;
5422         const uint8_t *ciphertext;
5423         uint8_t ciphertext_buffer[2048];
5424         struct rte_cryptodev_info dev_info;
5425
5426         struct rte_cryptodev_sym_capability_idx cap_idx;
5427
5428         /* Check if device supports ZUC EEA3 */
5429         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5430         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5431
5432         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5433                         &cap_idx) == NULL)
5434                 return -ENOTSUP;
5435
5436         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5437
5438         uint64_t feat_flags = dev_info.feature_flags;
5439
5440         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5441                 printf("Device doesn't support in-place scatter-gather. "
5442                                 "Test Skipped.\n");
5443                 return -ENOTSUP;
5444         }
5445
5446         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5447
5448         /* Append data which is padded to a multiple */
5449         /* of the algorithms block size */
5450         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5451
5452         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5453                         plaintext_pad_len, 10, 0);
5454
5455         pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5456                         tdata->plaintext.data);
5457
5458         /* Create ZUC session */
5459         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5460                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5461                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5462                         tdata->key.data, tdata->key.len,
5463                         tdata->cipher_iv.len);
5464         if (retval < 0)
5465                 return retval;
5466
5467         /* Clear mbuf payload */
5468
5469         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5470
5471         /* Create ZUC operation */
5472         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5473                         tdata->cipher_iv.len, tdata->plaintext.len,
5474                         0);
5475         if (retval < 0)
5476                 return retval;
5477
5478         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5479                                                 ut_params->op);
5480         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5481
5482         ut_params->obuf = ut_params->op->sym->m_dst;
5483         if (ut_params->obuf)
5484                 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5485                         0, plaintext_len, ciphertext_buffer);
5486         else
5487                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5488                         0, plaintext_len, ciphertext_buffer);
5489
5490         /* Validate obuf */
5491         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5492
5493         /* Validate obuf */
5494         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5495                 ciphertext,
5496                 tdata->ciphertext.data,
5497                 tdata->validCipherLenInBits.len,
5498                 "ZUC Ciphertext data not as expected");
5499
5500         return 0;
5501 }
5502
5503 static int
5504 test_zuc_authentication(const struct wireless_test_data *tdata)
5505 {
5506         struct crypto_testsuite_params *ts_params = &testsuite_params;
5507         struct crypto_unittest_params *ut_params = &unittest_params;
5508
5509         int retval;
5510         unsigned plaintext_pad_len;
5511         unsigned plaintext_len;
5512         uint8_t *plaintext;
5513
5514         struct rte_cryptodev_sym_capability_idx cap_idx;
5515
5516         /* Check if device supports ZUC EIA3 */
5517         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5518         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5519
5520         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5521                         &cap_idx) == NULL)
5522                 return -ENOTSUP;
5523
5524         /* Create ZUC session */
5525         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5526                         tdata->key.data, tdata->key.len,
5527                         tdata->auth_iv.len, tdata->digest.len,
5528                         RTE_CRYPTO_AUTH_OP_GENERATE,
5529                         RTE_CRYPTO_AUTH_ZUC_EIA3);
5530         if (retval < 0)
5531                 return retval;
5532
5533         /* alloc mbuf and set payload */
5534         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5535
5536         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5537         rte_pktmbuf_tailroom(ut_params->ibuf));
5538
5539         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5540         /* Append data which is padded to a multiple of */
5541         /* the algorithms block size */
5542         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5543         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5544                                 plaintext_pad_len);
5545         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5546
5547         /* Create ZUC operation */
5548         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5549                         tdata->auth_iv.data, tdata->auth_iv.len,
5550                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5551                         tdata->validAuthLenInBits.len,
5552                         0);
5553         if (retval < 0)
5554                 return retval;
5555
5556         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5557                                 ut_params->op);
5558         ut_params->obuf = ut_params->op->sym->m_src;
5559         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5560         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5561                         + plaintext_pad_len;
5562
5563         /* Validate obuf */
5564         TEST_ASSERT_BUFFERS_ARE_EQUAL(
5565         ut_params->digest,
5566         tdata->digest.data,
5567         DIGEST_BYTE_LENGTH_KASUMI_F9,
5568         "ZUC Generated auth tag not as expected");
5569
5570         return 0;
5571 }
5572
5573 static int
5574 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5575         uint8_t op_mode, uint8_t verify)
5576 {
5577         struct crypto_testsuite_params *ts_params = &testsuite_params;
5578         struct crypto_unittest_params *ut_params = &unittest_params;
5579
5580         int retval;
5581
5582         uint8_t *plaintext = NULL, *ciphertext = NULL;
5583         unsigned int plaintext_pad_len;
5584         unsigned int plaintext_len;
5585         unsigned int ciphertext_pad_len;
5586         unsigned int ciphertext_len;
5587
5588         struct rte_cryptodev_info dev_info;
5589         struct rte_cryptodev_sym_capability_idx cap_idx;
5590
5591         /* Check if device supports ZUC EIA3 */
5592         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5593         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5594
5595         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5596                         &cap_idx) == NULL)
5597                 return -ENOTSUP;
5598
5599         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5600
5601         uint64_t feat_flags = dev_info.feature_flags;
5602
5603         if (op_mode == OUT_OF_PLACE) {
5604                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5605                         printf("Device doesn't support digest encrypted.\n");
5606                         return -ENOTSUP;
5607                 }
5608         }
5609
5610         /* Create ZUC session */
5611         retval = create_wireless_algo_auth_cipher_session(
5612                         ts_params->valid_devs[0],
5613                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5614                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5615                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5616                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
5617                         RTE_CRYPTO_AUTH_ZUC_EIA3,
5618                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5619                         tdata->key.data, tdata->key.len,
5620                         tdata->auth_iv.len, tdata->digest.len,
5621                         tdata->cipher_iv.len);
5622
5623         if (retval < 0)
5624                 return retval;
5625
5626         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5627         if (op_mode == OUT_OF_PLACE)
5628                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5629
5630         /* clear mbuf payload */
5631         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5632                 rte_pktmbuf_tailroom(ut_params->ibuf));
5633         if (op_mode == OUT_OF_PLACE)
5634                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5635                         rte_pktmbuf_tailroom(ut_params->obuf));
5636
5637         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5638         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5639         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5640         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5641
5642         if (verify) {
5643                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5644                                         ciphertext_pad_len);
5645                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5646                 if (op_mode == OUT_OF_PLACE)
5647                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5648                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5649                         ciphertext_len);
5650         } else {
5651                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5652                                         plaintext_pad_len);
5653                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5654                 if (op_mode == OUT_OF_PLACE)
5655                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5656                 debug_hexdump(stdout, "plaintext:", plaintext,
5657                         plaintext_len);
5658         }
5659
5660         /* Create ZUC operation */
5661         retval = create_wireless_algo_auth_cipher_operation(
5662                 tdata->digest.len,
5663                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5664                 tdata->auth_iv.data, tdata->auth_iv.len,
5665                 (tdata->digest.offset_bytes == 0 ?
5666                 (verify ? ciphertext_pad_len : plaintext_pad_len)
5667                         : tdata->digest.offset_bytes),
5668                 tdata->validCipherLenInBits.len,
5669                 tdata->validCipherOffsetInBits.len,
5670                 tdata->validAuthLenInBits.len,
5671                 0,
5672                 op_mode, 0);
5673
5674         if (retval < 0)
5675                 return retval;
5676
5677         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5678                         ut_params->op);
5679
5680         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5681
5682         ut_params->obuf = (op_mode == IN_PLACE ?
5683                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5684
5685
5686         if (verify) {
5687                 if (ut_params->obuf)
5688                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5689                                                         uint8_t *);
5690                 else
5691                         plaintext = ciphertext;
5692
5693                 debug_hexdump(stdout, "plaintext:", plaintext,
5694                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5695                 debug_hexdump(stdout, "plaintext expected:",
5696                         tdata->plaintext.data,
5697                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5698         } else {
5699                 if (ut_params->obuf)
5700                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5701                                                         uint8_t *);
5702                 else
5703                         ciphertext = plaintext;
5704
5705                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5706                         ciphertext_len);
5707                 debug_hexdump(stdout, "ciphertext expected:",
5708                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5709
5710                 ut_params->digest = rte_pktmbuf_mtod(
5711                         ut_params->obuf, uint8_t *) +
5712                         (tdata->digest.offset_bytes == 0 ?
5713                         plaintext_pad_len : tdata->digest.offset_bytes);
5714
5715                 debug_hexdump(stdout, "digest:", ut_params->digest,
5716                         tdata->digest.len);
5717                 debug_hexdump(stdout, "digest expected:",
5718                         tdata->digest.data, tdata->digest.len);
5719         }
5720
5721         /* Validate obuf */
5722         if (verify) {
5723                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5724                         plaintext,
5725                         tdata->plaintext.data,
5726                         tdata->plaintext.len >> 3,
5727                         "ZUC Plaintext data not as expected");
5728         } else {
5729                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5730                         ciphertext,
5731                         tdata->ciphertext.data,
5732                         tdata->ciphertext.len >> 3,
5733                         "ZUC Ciphertext data not as expected");
5734
5735                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5736                         ut_params->digest,
5737                         tdata->digest.data,
5738                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5739                         "ZUC Generated auth tag not as expected");
5740         }
5741         return 0;
5742 }
5743
5744 static int
5745 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5746         uint8_t op_mode, uint8_t verify)
5747 {
5748         struct crypto_testsuite_params *ts_params = &testsuite_params;
5749         struct crypto_unittest_params *ut_params = &unittest_params;
5750
5751         int retval;
5752
5753         const uint8_t *plaintext = NULL;
5754         const uint8_t *ciphertext = NULL;
5755         const uint8_t *digest = NULL;
5756         unsigned int plaintext_pad_len;
5757         unsigned int plaintext_len;
5758         unsigned int ciphertext_pad_len;
5759         unsigned int ciphertext_len;
5760         uint8_t buffer[10000];
5761         uint8_t digest_buffer[10000];
5762
5763         struct rte_cryptodev_info dev_info;
5764         struct rte_cryptodev_sym_capability_idx cap_idx;
5765
5766         /* Check if device supports ZUC EIA3 */
5767         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5768         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5769
5770         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5771                         &cap_idx) == NULL)
5772                 return -ENOTSUP;
5773
5774         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5775
5776         uint64_t feat_flags = dev_info.feature_flags;
5777
5778         if (op_mode == IN_PLACE) {
5779                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5780                         printf("Device doesn't support in-place scatter-gather "
5781                                         "in both input and output mbufs.\n");
5782                         return -ENOTSUP;
5783                 }
5784         } else {
5785                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5786                         printf("Device doesn't support out-of-place scatter-gather "
5787                                         "in both input and output mbufs.\n");
5788                         return -ENOTSUP;
5789                 }
5790                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5791                         printf("Device doesn't support digest encrypted.\n");
5792                         return -ENOTSUP;
5793                 }
5794         }
5795
5796         /* Create ZUC session */
5797         retval = create_wireless_algo_auth_cipher_session(
5798                         ts_params->valid_devs[0],
5799                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5800                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5801                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5802                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
5803                         RTE_CRYPTO_AUTH_ZUC_EIA3,
5804                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5805                         tdata->key.data, tdata->key.len,
5806                         tdata->auth_iv.len, tdata->digest.len,
5807                         tdata->cipher_iv.len);
5808
5809         if (retval < 0)
5810                 return retval;
5811
5812         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5813         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5814         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5815         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5816
5817         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5818                         plaintext_pad_len, 15, 0);
5819         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5820                         "Failed to allocate input buffer in mempool");
5821
5822         if (op_mode == OUT_OF_PLACE) {
5823                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5824                                 plaintext_pad_len, 15, 0);
5825                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5826                                 "Failed to allocate output buffer in mempool");
5827         }
5828
5829         if (verify) {
5830                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5831                         tdata->ciphertext.data);
5832                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5833                                         ciphertext_len, buffer);
5834                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5835                         ciphertext_len);
5836         } else {
5837                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5838                         tdata->plaintext.data);
5839                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5840                                         plaintext_len, buffer);
5841                 debug_hexdump(stdout, "plaintext:", plaintext,
5842                         plaintext_len);
5843         }
5844         memset(buffer, 0, sizeof(buffer));
5845
5846         /* Create ZUC operation */
5847         retval = create_wireless_algo_auth_cipher_operation(
5848                 tdata->digest.len,
5849                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5850                 NULL, 0,
5851                 (tdata->digest.offset_bytes == 0 ?
5852                 (verify ? ciphertext_pad_len : plaintext_pad_len)
5853                         : tdata->digest.offset_bytes),
5854                 tdata->validCipherLenInBits.len,
5855                 tdata->validCipherOffsetInBits.len,
5856                 tdata->validAuthLenInBits.len,
5857                 0,
5858                 op_mode, 1);
5859
5860         if (retval < 0)
5861                 return retval;
5862
5863         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5864                         ut_params->op);
5865
5866         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5867
5868         ut_params->obuf = (op_mode == IN_PLACE ?
5869                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5870
5871         if (verify) {
5872                 if (ut_params->obuf)
5873                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5874                                         plaintext_len, buffer);
5875                 else
5876                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5877                                         plaintext_len, buffer);
5878
5879                 debug_hexdump(stdout, "plaintext:", plaintext,
5880                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5881                 debug_hexdump(stdout, "plaintext expected:",
5882                         tdata->plaintext.data,
5883                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5884         } else {
5885                 if (ut_params->obuf)
5886                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5887                                         ciphertext_len, buffer);
5888                 else
5889                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5890                                         ciphertext_len, buffer);
5891
5892                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5893                         ciphertext_len);
5894                 debug_hexdump(stdout, "ciphertext expected:",
5895                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5896
5897                 if (ut_params->obuf)
5898                         digest = rte_pktmbuf_read(ut_params->obuf,
5899                                 (tdata->digest.offset_bytes == 0 ?
5900                                 plaintext_pad_len : tdata->digest.offset_bytes),
5901                                 tdata->digest.len, digest_buffer);
5902                 else
5903                         digest = rte_pktmbuf_read(ut_params->ibuf,
5904                                 (tdata->digest.offset_bytes == 0 ?
5905                                 plaintext_pad_len : tdata->digest.offset_bytes),
5906                                 tdata->digest.len, digest_buffer);
5907
5908                 debug_hexdump(stdout, "digest:", digest,
5909                         tdata->digest.len);
5910                 debug_hexdump(stdout, "digest expected:",
5911                         tdata->digest.data, tdata->digest.len);
5912         }
5913
5914         /* Validate obuf */
5915         if (verify) {
5916                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5917                         plaintext,
5918                         tdata->plaintext.data,
5919                         tdata->plaintext.len >> 3,
5920                         "ZUC Plaintext data not as expected");
5921         } else {
5922                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5923                         ciphertext,
5924                         tdata->ciphertext.data,
5925                         tdata->validDataLenInBits.len,
5926                         "ZUC Ciphertext data not as expected");
5927
5928                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5929                         digest,
5930                         tdata->digest.data,
5931                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5932                         "ZUC Generated auth tag not as expected");
5933         }
5934         return 0;
5935 }
5936
5937 static int
5938 test_kasumi_encryption_test_case_1(void)
5939 {
5940         return test_kasumi_encryption(&kasumi_test_case_1);
5941 }
5942
5943 static int
5944 test_kasumi_encryption_test_case_1_sgl(void)
5945 {
5946         return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5947 }
5948
5949 static int
5950 test_kasumi_encryption_test_case_1_oop(void)
5951 {
5952         return test_kasumi_encryption_oop(&kasumi_test_case_1);
5953 }
5954
5955 static int
5956 test_kasumi_encryption_test_case_1_oop_sgl(void)
5957 {
5958         return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5959 }
5960
5961 static int
5962 test_kasumi_encryption_test_case_2(void)
5963 {
5964         return test_kasumi_encryption(&kasumi_test_case_2);
5965 }
5966
5967 static int
5968 test_kasumi_encryption_test_case_3(void)
5969 {
5970         return test_kasumi_encryption(&kasumi_test_case_3);
5971 }
5972
5973 static int
5974 test_kasumi_encryption_test_case_4(void)
5975 {
5976         return test_kasumi_encryption(&kasumi_test_case_4);
5977 }
5978
5979 static int
5980 test_kasumi_encryption_test_case_5(void)
5981 {
5982         return test_kasumi_encryption(&kasumi_test_case_5);
5983 }
5984
5985 static int
5986 test_kasumi_decryption_test_case_1(void)
5987 {
5988         return test_kasumi_decryption(&kasumi_test_case_1);
5989 }
5990
5991 static int
5992 test_kasumi_decryption_test_case_1_oop(void)
5993 {
5994         return test_kasumi_decryption_oop(&kasumi_test_case_1);
5995 }
5996
5997 static int
5998 test_kasumi_decryption_test_case_2(void)
5999 {
6000         return test_kasumi_decryption(&kasumi_test_case_2);
6001 }
6002
6003 static int
6004 test_kasumi_decryption_test_case_3(void)
6005 {
6006         return test_kasumi_decryption(&kasumi_test_case_3);
6007 }
6008
6009 static int
6010 test_kasumi_decryption_test_case_4(void)
6011 {
6012         return test_kasumi_decryption(&kasumi_test_case_4);
6013 }
6014
6015 static int
6016 test_kasumi_decryption_test_case_5(void)
6017 {
6018         return test_kasumi_decryption(&kasumi_test_case_5);
6019 }
6020 static int
6021 test_snow3g_encryption_test_case_1(void)
6022 {
6023         return test_snow3g_encryption(&snow3g_test_case_1);
6024 }
6025
6026 static int
6027 test_snow3g_encryption_test_case_1_oop(void)
6028 {
6029         return test_snow3g_encryption_oop(&snow3g_test_case_1);
6030 }
6031
6032 static int
6033 test_snow3g_encryption_test_case_1_oop_sgl(void)
6034 {
6035         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6036 }
6037
6038
6039 static int
6040 test_snow3g_encryption_test_case_1_offset_oop(void)
6041 {
6042         return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6043 }
6044
6045 static int
6046 test_snow3g_encryption_test_case_2(void)
6047 {
6048         return test_snow3g_encryption(&snow3g_test_case_2);
6049 }
6050
6051 static int
6052 test_snow3g_encryption_test_case_3(void)
6053 {
6054         return test_snow3g_encryption(&snow3g_test_case_3);
6055 }
6056
6057 static int
6058 test_snow3g_encryption_test_case_4(void)
6059 {
6060         return test_snow3g_encryption(&snow3g_test_case_4);
6061 }
6062
6063 static int
6064 test_snow3g_encryption_test_case_5(void)
6065 {
6066         return test_snow3g_encryption(&snow3g_test_case_5);
6067 }
6068
6069 static int
6070 test_snow3g_decryption_test_case_1(void)
6071 {
6072         return test_snow3g_decryption(&snow3g_test_case_1);
6073 }
6074
6075 static int
6076 test_snow3g_decryption_test_case_1_oop(void)
6077 {
6078         return test_snow3g_decryption_oop(&snow3g_test_case_1);
6079 }
6080
6081 static int
6082 test_snow3g_decryption_test_case_2(void)
6083 {
6084         return test_snow3g_decryption(&snow3g_test_case_2);
6085 }
6086
6087 static int
6088 test_snow3g_decryption_test_case_3(void)
6089 {
6090         return test_snow3g_decryption(&snow3g_test_case_3);
6091 }
6092
6093 static int
6094 test_snow3g_decryption_test_case_4(void)
6095 {
6096         return test_snow3g_decryption(&snow3g_test_case_4);
6097 }
6098
6099 static int
6100 test_snow3g_decryption_test_case_5(void)
6101 {
6102         return test_snow3g_decryption(&snow3g_test_case_5);
6103 }
6104
6105 /*
6106  * Function prepares snow3g_hash_test_data from snow3g_test_data.
6107  * Pattern digest from snow3g_test_data must be allocated as
6108  * 4 last bytes in plaintext.
6109  */
6110 static void
6111 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6112                 struct snow3g_hash_test_data *output)
6113 {
6114         if ((pattern != NULL) && (output != NULL)) {
6115                 output->key.len = pattern->key.len;
6116
6117                 memcpy(output->key.data,
6118                 pattern->key.data, pattern->key.len);
6119
6120                 output->auth_iv.len = pattern->auth_iv.len;
6121
6122                 memcpy(output->auth_iv.data,
6123                 pattern->auth_iv.data, pattern->auth_iv.len);
6124
6125                 output->plaintext.len = pattern->plaintext.len;
6126
6127                 memcpy(output->plaintext.data,
6128                 pattern->plaintext.data, pattern->plaintext.len >> 3);
6129
6130                 output->digest.len = pattern->digest.len;
6131
6132                 memcpy(output->digest.data,
6133                 &pattern->plaintext.data[pattern->digest.offset_bytes],
6134                 pattern->digest.len);
6135
6136                 output->validAuthLenInBits.len =
6137                 pattern->validAuthLenInBits.len;
6138         }
6139 }
6140
6141 /*
6142  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6143  */
6144 static int
6145 test_snow3g_decryption_with_digest_test_case_1(void)
6146 {
6147         struct snow3g_hash_test_data snow3g_hash_data;
6148
6149         /*
6150          * Function prepare data for hash veryfication test case.
6151          * Digest is allocated in 4 last bytes in plaintext, pattern.
6152          */
6153         snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6154
6155         return test_snow3g_decryption(&snow3g_test_case_7) &
6156                         test_snow3g_authentication_verify(&snow3g_hash_data);
6157 }
6158
6159 static int
6160 test_snow3g_cipher_auth_test_case_1(void)
6161 {
6162         return test_snow3g_cipher_auth(&snow3g_test_case_3);
6163 }
6164
6165 static int
6166 test_snow3g_auth_cipher_test_case_1(void)
6167 {
6168         return test_snow3g_auth_cipher(
6169                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6170 }
6171
6172 static int
6173 test_snow3g_auth_cipher_test_case_2(void)
6174 {
6175         return test_snow3g_auth_cipher(
6176                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6177 }
6178
6179 static int
6180 test_snow3g_auth_cipher_test_case_2_oop(void)
6181 {
6182         return test_snow3g_auth_cipher(
6183                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6184 }
6185
6186 static int
6187 test_snow3g_auth_cipher_part_digest_enc(void)
6188 {
6189         return test_snow3g_auth_cipher(
6190                 &snow3g_auth_cipher_partial_digest_encryption,
6191                         IN_PLACE, 0);
6192 }
6193
6194 static int
6195 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6196 {
6197         return test_snow3g_auth_cipher(
6198                 &snow3g_auth_cipher_partial_digest_encryption,
6199                         OUT_OF_PLACE, 0);
6200 }
6201
6202 static int
6203 test_snow3g_auth_cipher_test_case_3_sgl(void)
6204 {
6205         return test_snow3g_auth_cipher_sgl(
6206                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6207 }
6208
6209 static int
6210 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6211 {
6212         return test_snow3g_auth_cipher_sgl(
6213                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6214 }
6215
6216 static int
6217 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6218 {
6219         return test_snow3g_auth_cipher_sgl(
6220                 &snow3g_auth_cipher_partial_digest_encryption,
6221                         IN_PLACE, 0);
6222 }
6223
6224 static int
6225 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6226 {
6227         return test_snow3g_auth_cipher_sgl(
6228                 &snow3g_auth_cipher_partial_digest_encryption,
6229                         OUT_OF_PLACE, 0);
6230 }
6231
6232 static int
6233 test_snow3g_auth_cipher_verify_test_case_1(void)
6234 {
6235         return test_snow3g_auth_cipher(
6236                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6237 }
6238
6239 static int
6240 test_snow3g_auth_cipher_verify_test_case_2(void)
6241 {
6242         return test_snow3g_auth_cipher(
6243                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6244 }
6245
6246 static int
6247 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6248 {
6249         return test_snow3g_auth_cipher(
6250                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6251 }
6252
6253 static int
6254 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6255 {
6256         return test_snow3g_auth_cipher(
6257                 &snow3g_auth_cipher_partial_digest_encryption,
6258                         IN_PLACE, 1);
6259 }
6260
6261 static int
6262 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6263 {
6264         return test_snow3g_auth_cipher(
6265                 &snow3g_auth_cipher_partial_digest_encryption,
6266                         OUT_OF_PLACE, 1);
6267 }
6268
6269 static int
6270 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6271 {
6272         return test_snow3g_auth_cipher_sgl(
6273                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6274 }
6275
6276 static int
6277 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6278 {
6279         return test_snow3g_auth_cipher_sgl(
6280                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6281 }
6282
6283 static int
6284 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6285 {
6286         return test_snow3g_auth_cipher_sgl(
6287                 &snow3g_auth_cipher_partial_digest_encryption,
6288                         IN_PLACE, 1);
6289 }
6290
6291 static int
6292 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6293 {
6294         return test_snow3g_auth_cipher_sgl(
6295                 &snow3g_auth_cipher_partial_digest_encryption,
6296                         OUT_OF_PLACE, 1);
6297 }
6298
6299 static int
6300 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6301 {
6302         return test_snow3g_auth_cipher(
6303                 &snow3g_test_case_7, IN_PLACE, 0);
6304 }
6305
6306 static int
6307 test_kasumi_auth_cipher_test_case_1(void)
6308 {
6309         return test_kasumi_auth_cipher(
6310                 &kasumi_test_case_3, IN_PLACE, 0);
6311 }
6312
6313 static int
6314 test_kasumi_auth_cipher_test_case_2(void)
6315 {
6316         return test_kasumi_auth_cipher(
6317                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6318 }
6319
6320 static int
6321 test_kasumi_auth_cipher_test_case_2_oop(void)
6322 {
6323         return test_kasumi_auth_cipher(
6324                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6325 }
6326
6327 static int
6328 test_kasumi_auth_cipher_test_case_2_sgl(void)
6329 {
6330         return test_kasumi_auth_cipher_sgl(
6331                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6332 }
6333
6334 static int
6335 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6336 {
6337         return test_kasumi_auth_cipher_sgl(
6338                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6339 }
6340
6341 static int
6342 test_kasumi_auth_cipher_verify_test_case_1(void)
6343 {
6344         return test_kasumi_auth_cipher(
6345                 &kasumi_test_case_3, IN_PLACE, 1);
6346 }
6347
6348 static int
6349 test_kasumi_auth_cipher_verify_test_case_2(void)
6350 {
6351         return test_kasumi_auth_cipher(
6352                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6353 }
6354
6355 static int
6356 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6357 {
6358         return test_kasumi_auth_cipher(
6359                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6360 }
6361
6362 static int
6363 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6364 {
6365         return test_kasumi_auth_cipher_sgl(
6366                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6367 }
6368
6369 static int
6370 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6371 {
6372         return test_kasumi_auth_cipher_sgl(
6373                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6374 }
6375
6376 static int
6377 test_kasumi_cipher_auth_test_case_1(void)
6378 {
6379         return test_kasumi_cipher_auth(&kasumi_test_case_6);
6380 }
6381
6382 static int
6383 test_zuc_encryption_test_case_1(void)
6384 {
6385         return test_zuc_encryption(&zuc_test_case_cipher_193b);
6386 }
6387
6388 static int
6389 test_zuc_encryption_test_case_2(void)
6390 {
6391         return test_zuc_encryption(&zuc_test_case_cipher_800b);
6392 }
6393
6394 static int
6395 test_zuc_encryption_test_case_3(void)
6396 {
6397         return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6398 }
6399
6400 static int
6401 test_zuc_encryption_test_case_4(void)
6402 {
6403         return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6404 }
6405
6406 static int
6407 test_zuc_encryption_test_case_5(void)
6408 {
6409         return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6410 }
6411
6412 static int
6413 test_zuc_encryption_test_case_6_sgl(void)
6414 {
6415         return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6416 }
6417
6418 static int
6419 test_zuc_hash_generate_test_case_1(void)
6420 {
6421         return test_zuc_authentication(&zuc_test_case_auth_1b);
6422 }
6423
6424 static int
6425 test_zuc_hash_generate_test_case_2(void)
6426 {
6427         return test_zuc_authentication(&zuc_test_case_auth_90b);
6428 }
6429
6430 static int
6431 test_zuc_hash_generate_test_case_3(void)
6432 {
6433         return test_zuc_authentication(&zuc_test_case_auth_577b);
6434 }
6435
6436 static int
6437 test_zuc_hash_generate_test_case_4(void)
6438 {
6439         return test_zuc_authentication(&zuc_test_case_auth_2079b);
6440 }
6441
6442 static int
6443 test_zuc_hash_generate_test_case_5(void)
6444 {
6445         return test_zuc_authentication(&zuc_test_auth_5670b);
6446 }
6447
6448 static int
6449 test_zuc_hash_generate_test_case_6(void)
6450 {
6451         return test_zuc_authentication(&zuc_test_case_auth_128b);
6452 }
6453
6454 static int
6455 test_zuc_hash_generate_test_case_7(void)
6456 {
6457         return test_zuc_authentication(&zuc_test_case_auth_2080b);
6458 }
6459
6460 static int
6461 test_zuc_hash_generate_test_case_8(void)
6462 {
6463         return test_zuc_authentication(&zuc_test_case_auth_584b);
6464 }
6465
6466 static int
6467 test_zuc_cipher_auth_test_case_1(void)
6468 {
6469         return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6470 }
6471
6472 static int
6473 test_zuc_cipher_auth_test_case_2(void)
6474 {
6475         return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6476 }
6477
6478 static int
6479 test_zuc_auth_cipher_test_case_1(void)
6480 {
6481         return test_zuc_auth_cipher(
6482                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6483 }
6484
6485 static int
6486 test_zuc_auth_cipher_test_case_1_oop(void)
6487 {
6488         return test_zuc_auth_cipher(
6489                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6490 }
6491
6492 static int
6493 test_zuc_auth_cipher_test_case_1_sgl(void)
6494 {
6495         return test_zuc_auth_cipher_sgl(
6496                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6497 }
6498
6499 static int
6500 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6501 {
6502         return test_zuc_auth_cipher_sgl(
6503                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6504 }
6505
6506 static int
6507 test_zuc_auth_cipher_verify_test_case_1(void)
6508 {
6509         return test_zuc_auth_cipher(
6510                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6511 }
6512
6513 static int
6514 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6515 {
6516         return test_zuc_auth_cipher(
6517                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6518 }
6519
6520 static int
6521 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6522 {
6523         return test_zuc_auth_cipher_sgl(
6524                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6525 }
6526
6527 static int
6528 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6529 {
6530         return test_zuc_auth_cipher_sgl(
6531                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6532 }
6533
6534 static int
6535 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6536 {
6537         uint8_t dev_id = testsuite_params.valid_devs[0];
6538
6539         struct rte_cryptodev_sym_capability_idx cap_idx;
6540
6541         /* Check if device supports particular cipher algorithm */
6542         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6543         cap_idx.algo.cipher = tdata->cipher_algo;
6544         if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6545                 return -ENOTSUP;
6546
6547         /* Check if device supports particular hash algorithm */
6548         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6549         cap_idx.algo.auth = tdata->auth_algo;
6550         if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6551                 return -ENOTSUP;
6552
6553         return 0;
6554 }
6555
6556 static int
6557 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6558         uint8_t op_mode, uint8_t verify)
6559 {
6560         struct crypto_testsuite_params *ts_params = &testsuite_params;
6561         struct crypto_unittest_params *ut_params = &unittest_params;
6562
6563         int retval;
6564
6565         uint8_t *plaintext = NULL, *ciphertext = NULL;
6566         unsigned int plaintext_pad_len;
6567         unsigned int plaintext_len;
6568         unsigned int ciphertext_pad_len;
6569         unsigned int ciphertext_len;
6570
6571         struct rte_cryptodev_info dev_info;
6572
6573         /* Check if device supports particular algorithms */
6574         if (test_mixed_check_if_unsupported(tdata))
6575                 return -ENOTSUP;
6576
6577         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6578
6579         uint64_t feat_flags = dev_info.feature_flags;
6580
6581         if (op_mode == OUT_OF_PLACE) {
6582                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6583                         printf("Device doesn't support digest encrypted.\n");
6584                         return -ENOTSUP;
6585                 }
6586         }
6587
6588         /* Create the session */
6589         retval = create_wireless_algo_auth_cipher_session(
6590                         ts_params->valid_devs[0],
6591                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6592                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6593                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6594                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
6595                         tdata->auth_algo,
6596                         tdata->cipher_algo,
6597                         tdata->auth_key.data, tdata->auth_key.len,
6598                         tdata->auth_iv.len, tdata->digest_enc.len,
6599                         tdata->cipher_iv.len);
6600
6601         if (retval < 0)
6602                 return retval;
6603
6604         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6605         if (op_mode == OUT_OF_PLACE)
6606                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6607
6608         /* clear mbuf payload */
6609         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6610                 rte_pktmbuf_tailroom(ut_params->ibuf));
6611         if (op_mode == OUT_OF_PLACE)
6612                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6613                                 rte_pktmbuf_tailroom(ut_params->obuf));
6614
6615         ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6616         plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6617         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6618         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6619
6620         if (verify) {
6621                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6622                                 ciphertext_pad_len);
6623                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6624                 if (op_mode == OUT_OF_PLACE)
6625                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6626                 debug_hexdump(stdout, "ciphertext:", ciphertext,
6627                                 ciphertext_len);
6628         } else {
6629                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6630                                 plaintext_pad_len);
6631                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6632                 if (op_mode == OUT_OF_PLACE)
6633                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6634                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6635         }
6636
6637         /* Create the operation */
6638         retval = create_wireless_algo_auth_cipher_operation(
6639                         tdata->digest_enc.len,
6640                         tdata->cipher_iv.data, tdata->cipher_iv.len,
6641                         tdata->auth_iv.data, tdata->auth_iv.len,
6642                         (tdata->digest_enc.offset == 0 ?
6643                         (verify ? ciphertext_pad_len : plaintext_pad_len)
6644                                 : tdata->digest_enc.offset),
6645                         tdata->validCipherLen.len_bits,
6646                         tdata->cipher.offset_bits,
6647                         tdata->validAuthLen.len_bits,
6648                         tdata->auth.offset_bits,
6649                         op_mode, 0);
6650
6651         if (retval < 0)
6652                 return retval;
6653
6654         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6655                         ut_params->op);
6656
6657         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6658
6659         ut_params->obuf = (op_mode == IN_PLACE ?
6660                         ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6661
6662         if (verify) {
6663                 if (ut_params->obuf)
6664                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6665                                                         uint8_t *);
6666                 else
6667                         plaintext = ciphertext +
6668                                         (tdata->cipher.offset_bits >> 3);
6669
6670                 debug_hexdump(stdout, "plaintext:", plaintext,
6671                                 (tdata->plaintext.len_bits >> 3) -
6672                                 tdata->digest_enc.len);
6673                 debug_hexdump(stdout, "plaintext expected:",
6674                                 tdata->plaintext.data,
6675                                 (tdata->plaintext.len_bits >> 3) -
6676                                 tdata->digest_enc.len);
6677         } else {
6678                 if (ut_params->obuf)
6679                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6680                                         uint8_t *);
6681                 else
6682                         ciphertext = plaintext;
6683
6684                 debug_hexdump(stdout, "ciphertext:", ciphertext,
6685                                 ciphertext_len);
6686                 debug_hexdump(stdout, "ciphertext expected:",
6687                                 tdata->ciphertext.data,
6688                                 tdata->ciphertext.len_bits >> 3);
6689
6690                 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6691                                 + (tdata->digest_enc.offset == 0 ?
6692                 plaintext_pad_len : tdata->digest_enc.offset);
6693
6694                 debug_hexdump(stdout, "digest:", ut_params->digest,
6695                                 tdata->digest_enc.len);
6696                 debug_hexdump(stdout, "digest expected:",
6697                                 tdata->digest_enc.data,
6698                                 tdata->digest_enc.len);
6699         }
6700
6701         /* Validate obuf */
6702         if (verify) {
6703                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6704                                 plaintext,
6705                                 tdata->plaintext.data,
6706                                 tdata->plaintext.len_bits >> 3,
6707                                 "Plaintext data not as expected");
6708         } else {
6709                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6710                                 ciphertext,
6711                                 tdata->ciphertext.data,
6712                                 tdata->validDataLen.len_bits,
6713                                 "Ciphertext data not as expected");
6714
6715                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6716                                 ut_params->digest,
6717                                 tdata->digest_enc.data,
6718                                 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6719                                 "Generated auth tag not as expected");
6720         }
6721         return 0;
6722 }
6723
6724 static int
6725 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6726         uint8_t op_mode, uint8_t verify)
6727 {
6728         struct crypto_testsuite_params *ts_params = &testsuite_params;
6729         struct crypto_unittest_params *ut_params = &unittest_params;
6730
6731         int retval;
6732
6733         const uint8_t *plaintext = NULL;
6734         const uint8_t *ciphertext = NULL;
6735         const uint8_t *digest = NULL;
6736         unsigned int plaintext_pad_len;
6737         unsigned int plaintext_len;
6738         unsigned int ciphertext_pad_len;
6739         unsigned int ciphertext_len;
6740         uint8_t buffer[10000];
6741         uint8_t digest_buffer[10000];
6742
6743         struct rte_cryptodev_info dev_info;
6744
6745         /* Check if device supports particular algorithms */
6746         if (test_mixed_check_if_unsupported(tdata))
6747                 return -ENOTSUP;
6748
6749         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6750
6751         uint64_t feat_flags = dev_info.feature_flags;
6752
6753         if (op_mode == IN_PLACE) {
6754                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6755                         printf("Device doesn't support in-place scatter-gather "
6756                                         "in both input and output mbufs.\n");
6757                         return -ENOTSUP;
6758                 }
6759         } else {
6760                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6761                         printf("Device doesn't support out-of-place scatter-gather "
6762                                         "in both input and output mbufs.\n");
6763                         return -ENOTSUP;
6764                 }
6765                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6766                         printf("Device doesn't support digest encrypted.\n");
6767                         return -ENOTSUP;
6768                 }
6769         }
6770
6771         /* Create the session */
6772         retval = create_wireless_algo_auth_cipher_session(
6773                         ts_params->valid_devs[0],
6774                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6775                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6776                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6777                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
6778                         tdata->auth_algo,
6779                         tdata->cipher_algo,
6780                         tdata->auth_key.data, tdata->auth_key.len,
6781                         tdata->auth_iv.len, tdata->digest_enc.len,
6782                         tdata->cipher_iv.len);
6783
6784         if (retval < 0)
6785                 return retval;
6786
6787         ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6788         plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6789         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6790         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6791
6792         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6793                         plaintext_pad_len, 15, 0);
6794         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6795                         "Failed to allocate input buffer in mempool");
6796
6797         if (op_mode == OUT_OF_PLACE) {
6798                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6799                                 plaintext_pad_len, 15, 0);
6800                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6801                                 "Failed to allocate output buffer in mempool");
6802         }
6803
6804         if (verify) {
6805                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6806                         tdata->ciphertext.data);
6807                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6808                                         ciphertext_len, buffer);
6809                 debug_hexdump(stdout, "ciphertext:", ciphertext,
6810                         ciphertext_len);
6811         } else {
6812                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6813                         tdata->plaintext.data);
6814                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6815                                         plaintext_len, buffer);
6816                 debug_hexdump(stdout, "plaintext:", plaintext,
6817                         plaintext_len);
6818         }
6819         memset(buffer, 0, sizeof(buffer));
6820
6821         /* Create the operation */
6822         retval = create_wireless_algo_auth_cipher_operation(
6823                         tdata->digest_enc.len,
6824                         tdata->cipher_iv.data, tdata->cipher_iv.len,
6825                         tdata->auth_iv.data, tdata->auth_iv.len,
6826                         (tdata->digest_enc.offset == 0 ?
6827                         (verify ? ciphertext_pad_len : plaintext_pad_len)
6828                                 : tdata->digest_enc.offset),
6829                         tdata->validCipherLen.len_bits,
6830                         tdata->cipher.offset_bits,
6831                         tdata->validAuthLen.len_bits,
6832                         tdata->auth.offset_bits,
6833                         op_mode, 1);
6834
6835         if (retval < 0)
6836                 return retval;
6837
6838         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6839                         ut_params->op);
6840
6841         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6842
6843         ut_params->obuf = (op_mode == IN_PLACE ?
6844                         ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6845
6846         if (verify) {
6847                 if (ut_params->obuf)
6848                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6849                                         plaintext_len, buffer);
6850                 else
6851                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6852                                         plaintext_len, buffer);
6853
6854                 debug_hexdump(stdout, "plaintext:", plaintext,
6855                                 (tdata->plaintext.len_bits >> 3) -
6856                                 tdata->digest_enc.len);
6857                 debug_hexdump(stdout, "plaintext expected:",
6858                                 tdata->plaintext.data,
6859                                 (tdata->plaintext.len_bits >> 3) -
6860                                 tdata->digest_enc.len);
6861         } else {
6862                 if (ut_params->obuf)
6863                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6864                                         ciphertext_len, buffer);
6865                 else
6866                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6867                                         ciphertext_len, buffer);
6868
6869                 debug_hexdump(stdout, "ciphertext:", ciphertext,
6870                         ciphertext_len);
6871                 debug_hexdump(stdout, "ciphertext expected:",
6872                         tdata->ciphertext.data,
6873                         tdata->ciphertext.len_bits >> 3);
6874
6875                 if (ut_params->obuf)
6876                         digest = rte_pktmbuf_read(ut_params->obuf,
6877                                         (tdata->digest_enc.offset == 0 ?
6878                                                 plaintext_pad_len :
6879                                                 tdata->digest_enc.offset),
6880                                         tdata->digest_enc.len, digest_buffer);
6881                 else
6882                         digest = rte_pktmbuf_read(ut_params->ibuf,
6883                                         (tdata->digest_enc.offset == 0 ?
6884                                                 plaintext_pad_len :
6885                                                 tdata->digest_enc.offset),
6886                                         tdata->digest_enc.len, digest_buffer);
6887
6888                 debug_hexdump(stdout, "digest:", digest,
6889                                 tdata->digest_enc.len);
6890                 debug_hexdump(stdout, "digest expected:",
6891                                 tdata->digest_enc.data, tdata->digest_enc.len);
6892         }
6893
6894         /* Validate obuf */
6895         if (verify) {
6896                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6897                                 plaintext,
6898                                 tdata->plaintext.data,
6899                                 tdata->plaintext.len_bits >> 3,
6900                                 "Plaintext data not as expected");
6901         } else {
6902                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6903                                 ciphertext,
6904                                 tdata->ciphertext.data,
6905                                 tdata->validDataLen.len_bits,
6906                                 "Ciphertext data not as expected");
6907                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6908                                 digest,
6909                                 tdata->digest_enc.data,
6910                                 tdata->digest_enc.len,
6911                                 "Generated auth tag not as expected");
6912         }
6913         return 0;
6914 }
6915
6916 /** AUTH AES CMAC + CIPHER AES CTR */
6917
6918 static int
6919 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6920 {
6921         return test_mixed_auth_cipher(
6922                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6923 }
6924
6925 static int
6926 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6927 {
6928         return test_mixed_auth_cipher(
6929                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6930 }
6931
6932 static int
6933 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6934 {
6935         return test_mixed_auth_cipher_sgl(
6936                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6937 }
6938
6939 static int
6940 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6941 {
6942         return test_mixed_auth_cipher_sgl(
6943                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6944 }
6945
6946 static int
6947 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6948 {
6949         return test_mixed_auth_cipher(
6950                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6951 }
6952
6953 static int
6954 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6955 {
6956         return test_mixed_auth_cipher(
6957                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6958 }
6959
6960 static int
6961 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6962 {
6963         return test_mixed_auth_cipher_sgl(
6964                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6965 }
6966
6967 static int
6968 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6969 {
6970         return test_mixed_auth_cipher_sgl(
6971                 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6972 }
6973
6974 static int
6975 test_3DES_chain_qat_all(void)
6976 {
6977         struct crypto_testsuite_params *ts_params = &testsuite_params;
6978         int status;
6979
6980         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6981                 ts_params->op_mpool,
6982                 ts_params->session_mpool, ts_params->session_priv_mpool,
6983                 ts_params->valid_devs[0],
6984                 rte_cryptodev_driver_id_get(
6985                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6986                 BLKCIPHER_3DES_CHAIN_TYPE);
6987
6988         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6989
6990         return TEST_SUCCESS;
6991 }
6992
6993 static int
6994 test_DES_cipheronly_qat_all(void)
6995 {
6996         struct crypto_testsuite_params *ts_params = &testsuite_params;
6997         int status;
6998
6999         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7000                 ts_params->op_mpool,
7001                 ts_params->session_mpool, ts_params->session_priv_mpool,
7002                 ts_params->valid_devs[0],
7003                 rte_cryptodev_driver_id_get(
7004                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7005                 BLKCIPHER_DES_CIPHERONLY_TYPE);
7006
7007         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7008
7009         return TEST_SUCCESS;
7010 }
7011
7012 static int
7013 test_DES_cipheronly_openssl_all(void)
7014 {
7015         struct crypto_testsuite_params *ts_params = &testsuite_params;
7016         int status;
7017
7018         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7019                 ts_params->op_mpool,
7020                 ts_params->session_mpool, ts_params->session_priv_mpool,
7021                 ts_params->valid_devs[0],
7022                 rte_cryptodev_driver_id_get(
7023                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7024                 BLKCIPHER_DES_CIPHERONLY_TYPE);
7025
7026         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7027
7028         return TEST_SUCCESS;
7029 }
7030
7031 static int
7032 test_DES_docsis_openssl_all(void)
7033 {
7034         struct crypto_testsuite_params *ts_params = &testsuite_params;
7035         int status;
7036
7037         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7038                 ts_params->op_mpool,
7039                 ts_params->session_mpool, ts_params->session_priv_mpool,
7040                 ts_params->valid_devs[0],
7041                 rte_cryptodev_driver_id_get(
7042                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7043                 BLKCIPHER_DES_DOCSIS_TYPE);
7044
7045         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7046
7047         return TEST_SUCCESS;
7048 }
7049
7050 static int
7051 test_DES_cipheronly_mb_all(void)
7052 {
7053         struct crypto_testsuite_params *ts_params = &testsuite_params;
7054         int status;
7055
7056         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7057                 ts_params->op_mpool,
7058                 ts_params->session_mpool, ts_params->session_priv_mpool,
7059                 ts_params->valid_devs[0],
7060                 rte_cryptodev_driver_id_get(
7061                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7062                 BLKCIPHER_DES_CIPHERONLY_TYPE);
7063
7064         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7065
7066         return TEST_SUCCESS;
7067 }
7068 static int
7069 test_3DES_cipheronly_mb_all(void)
7070 {
7071         struct crypto_testsuite_params *ts_params = &testsuite_params;
7072         int status;
7073
7074         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7075                 ts_params->op_mpool,
7076                 ts_params->session_mpool, ts_params->session_priv_mpool,
7077                 ts_params->valid_devs[0],
7078                 rte_cryptodev_driver_id_get(
7079                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7080                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7081
7082         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7083
7084         return TEST_SUCCESS;
7085 }
7086
7087 static int
7088 test_DES_docsis_mb_all(void)
7089 {
7090         struct crypto_testsuite_params *ts_params = &testsuite_params;
7091         int status;
7092
7093         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7094                 ts_params->op_mpool,
7095                 ts_params->session_mpool, ts_params->session_priv_mpool,
7096                 ts_params->valid_devs[0],
7097                 rte_cryptodev_driver_id_get(
7098                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7099                 BLKCIPHER_DES_DOCSIS_TYPE);
7100
7101         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7102
7103         return TEST_SUCCESS;
7104 }
7105
7106 static int
7107 test_3DES_chain_caam_jr_all(void)
7108 {
7109         struct crypto_testsuite_params *ts_params = &testsuite_params;
7110         int status;
7111
7112         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7113                 ts_params->op_mpool,
7114                 ts_params->session_mpool, ts_params->session_priv_mpool,
7115                 ts_params->valid_devs[0],
7116                 rte_cryptodev_driver_id_get(
7117                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7118                 BLKCIPHER_3DES_CHAIN_TYPE);
7119
7120         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7121
7122         return TEST_SUCCESS;
7123 }
7124
7125 static int
7126 test_3DES_cipheronly_caam_jr_all(void)
7127 {
7128         struct crypto_testsuite_params *ts_params = &testsuite_params;
7129         int status;
7130
7131         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7132                 ts_params->op_mpool,
7133                 ts_params->session_mpool, ts_params->session_priv_mpool,
7134                 ts_params->valid_devs[0],
7135                 rte_cryptodev_driver_id_get(
7136                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7137                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7138
7139         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7140
7141         return TEST_SUCCESS;
7142 }
7143
7144 static int
7145 test_3DES_chain_dpaa_sec_all(void)
7146 {
7147         struct crypto_testsuite_params *ts_params = &testsuite_params;
7148         int status;
7149
7150         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7151                 ts_params->op_mpool,
7152                 ts_params->session_mpool, ts_params->session_priv_mpool,
7153                 ts_params->valid_devs[0],
7154                 rte_cryptodev_driver_id_get(
7155                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7156                 BLKCIPHER_3DES_CHAIN_TYPE);
7157
7158         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7159
7160         return TEST_SUCCESS;
7161 }
7162
7163 static int
7164 test_3DES_cipheronly_dpaa_sec_all(void)
7165 {
7166         struct crypto_testsuite_params *ts_params = &testsuite_params;
7167         int status;
7168
7169         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7170                 ts_params->op_mpool,
7171                 ts_params->session_mpool, ts_params->session_priv_mpool,
7172                 ts_params->valid_devs[0],
7173                 rte_cryptodev_driver_id_get(
7174                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7175                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7176
7177         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7178
7179         return TEST_SUCCESS;
7180 }
7181
7182 static int
7183 test_3DES_chain_dpaa2_sec_all(void)
7184 {
7185         struct crypto_testsuite_params *ts_params = &testsuite_params;
7186         int status;
7187
7188         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7189                 ts_params->op_mpool,
7190                 ts_params->session_mpool, ts_params->session_priv_mpool,
7191                 ts_params->valid_devs[0],
7192                 rte_cryptodev_driver_id_get(
7193                 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7194                 BLKCIPHER_3DES_CHAIN_TYPE);
7195
7196         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7197
7198         return TEST_SUCCESS;
7199 }
7200
7201 static int
7202 test_3DES_cipheronly_dpaa2_sec_all(void)
7203 {
7204         struct crypto_testsuite_params *ts_params = &testsuite_params;
7205         int status;
7206
7207         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7208                 ts_params->op_mpool,
7209                 ts_params->session_mpool, ts_params->session_priv_mpool,
7210                 ts_params->valid_devs[0],
7211                 rte_cryptodev_driver_id_get(
7212                 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7213                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7214
7215         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7216
7217         return TEST_SUCCESS;
7218 }
7219
7220 static int
7221 test_3DES_chain_ccp_all(void)
7222 {
7223         struct crypto_testsuite_params *ts_params = &testsuite_params;
7224         int status;
7225
7226         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7227                 ts_params->op_mpool,
7228                 ts_params->session_mpool, ts_params->session_priv_mpool,
7229                 ts_params->valid_devs[0],
7230                 rte_cryptodev_driver_id_get(
7231                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7232                 BLKCIPHER_3DES_CHAIN_TYPE);
7233
7234         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7235
7236         return TEST_SUCCESS;
7237 }
7238
7239 static int
7240 test_3DES_cipheronly_ccp_all(void)
7241 {
7242         struct crypto_testsuite_params *ts_params = &testsuite_params;
7243         int status;
7244
7245         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7246                 ts_params->op_mpool,
7247                 ts_params->session_mpool, ts_params->session_priv_mpool,
7248                 ts_params->valid_devs[0],
7249                 rte_cryptodev_driver_id_get(
7250                 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7251                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7252
7253         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7254
7255         return TEST_SUCCESS;
7256 }
7257
7258 static int
7259 test_3DES_cipheronly_qat_all(void)
7260 {
7261         struct crypto_testsuite_params *ts_params = &testsuite_params;
7262         int status;
7263
7264         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7265                 ts_params->op_mpool,
7266                 ts_params->session_mpool, ts_params->session_priv_mpool,
7267                 ts_params->valid_devs[0],
7268                 rte_cryptodev_driver_id_get(
7269                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7270                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7271
7272         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7273
7274         return TEST_SUCCESS;
7275 }
7276
7277 static int
7278 test_3DES_chain_openssl_all(void)
7279 {
7280         struct crypto_testsuite_params *ts_params = &testsuite_params;
7281         int status;
7282
7283         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7284                 ts_params->op_mpool,
7285                 ts_params->session_mpool, ts_params->session_priv_mpool,
7286                 ts_params->valid_devs[0],
7287                 rte_cryptodev_driver_id_get(
7288                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7289                 BLKCIPHER_3DES_CHAIN_TYPE);
7290
7291         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7292
7293         return TEST_SUCCESS;
7294 }
7295
7296 static int
7297 test_3DES_cipheronly_openssl_all(void)
7298 {
7299         struct crypto_testsuite_params *ts_params = &testsuite_params;
7300         int status;
7301
7302         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7303                 ts_params->op_mpool,
7304                 ts_params->session_mpool, ts_params->session_priv_mpool,
7305                 ts_params->valid_devs[0],
7306                 rte_cryptodev_driver_id_get(
7307                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7308                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7309
7310         TEST_ASSERT_EQUAL(status, 0, "Test failed");
7311
7312         return TEST_SUCCESS;
7313 }
7314
7315 /* ***** AEAD algorithm Tests ***** */
7316
7317 static int
7318 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7319                 enum rte_crypto_aead_operation op,
7320                 const uint8_t *key, const uint8_t key_len,
7321                 const uint16_t aad_len, const uint8_t auth_len,
7322                 uint8_t iv_len)
7323 {
7324         uint8_t aead_key[key_len];
7325
7326         struct crypto_testsuite_params *ts_params = &testsuite_params;
7327         struct crypto_unittest_params *ut_params = &unittest_params;
7328
7329         memcpy(aead_key, key, key_len);
7330
7331         /* Setup AEAD Parameters */
7332         ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7333         ut_params->aead_xform.next = NULL;
7334         ut_params->aead_xform.aead.algo = algo;
7335         ut_params->aead_xform.aead.op = op;
7336         ut_params->aead_xform.aead.key.data = aead_key;
7337         ut_params->aead_xform.aead.key.length = key_len;
7338         ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7339         ut_params->aead_xform.aead.iv.length = iv_len;
7340         ut_params->aead_xform.aead.digest_length = auth_len;
7341         ut_params->aead_xform.aead.aad_length = aad_len;
7342
7343         debug_hexdump(stdout, "key:", key, key_len);
7344
7345         /* Create Crypto session*/
7346         ut_params->sess = rte_cryptodev_sym_session_create(
7347                         ts_params->session_mpool);
7348
7349         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7350                         &ut_params->aead_xform,
7351                         ts_params->session_priv_mpool);
7352
7353         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7354
7355         return 0;
7356 }
7357
7358 static int
7359 create_aead_xform(struct rte_crypto_op *op,
7360                 enum rte_crypto_aead_algorithm algo,
7361                 enum rte_crypto_aead_operation aead_op,
7362                 uint8_t *key, const uint8_t key_len,
7363                 const uint8_t aad_len, const uint8_t auth_len,
7364                 uint8_t iv_len)
7365 {
7366         TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7367                         "failed to allocate space for crypto transform");
7368
7369         struct rte_crypto_sym_op *sym_op = op->sym;
7370
7371         /* Setup AEAD Parameters */
7372         sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7373         sym_op->xform->next = NULL;
7374         sym_op->xform->aead.algo = algo;
7375         sym_op->xform->aead.op = aead_op;
7376         sym_op->xform->aead.key.data = key;
7377         sym_op->xform->aead.key.length = key_len;
7378         sym_op->xform->aead.iv.offset = IV_OFFSET;
7379         sym_op->xform->aead.iv.length = iv_len;
7380         sym_op->xform->aead.digest_length = auth_len;
7381         sym_op->xform->aead.aad_length = aad_len;
7382
7383         debug_hexdump(stdout, "key:", key, key_len);
7384
7385         return 0;
7386 }
7387
7388 static int
7389 create_aead_operation(enum rte_crypto_aead_operation op,
7390                 const struct aead_test_data *tdata)
7391 {
7392         struct crypto_testsuite_params *ts_params = &testsuite_params;
7393         struct crypto_unittest_params *ut_params = &unittest_params;
7394
7395         uint8_t *plaintext, *ciphertext;
7396         unsigned int aad_pad_len, plaintext_pad_len;
7397
7398         /* Generate Crypto op data structure */
7399         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7400                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7401         TEST_ASSERT_NOT_NULL(ut_params->op,
7402                         "Failed to allocate symmetric crypto operation struct");
7403
7404         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7405
7406         /* Append aad data */
7407         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7408                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7409                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7410                                 aad_pad_len);
7411                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7412                                 "no room to append aad");
7413
7414                 sym_op->aead.aad.phys_addr =
7415                                 rte_pktmbuf_iova(ut_params->ibuf);
7416                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7417                 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7418                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7419                         tdata->aad.len);
7420
7421                 /* Append IV at the end of the crypto operation*/
7422                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7423                                 uint8_t *, IV_OFFSET);
7424
7425                 /* Copy IV 1 byte after the IV pointer, according to the API */
7426                 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7427                 debug_hexdump(stdout, "iv:", iv_ptr,
7428                         tdata->iv.len);
7429         } else {
7430                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7431                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7432                                 aad_pad_len);
7433                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7434                                 "no room to append aad");
7435
7436                 sym_op->aead.aad.phys_addr =
7437                                 rte_pktmbuf_iova(ut_params->ibuf);
7438                 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7439                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7440                         tdata->aad.len);
7441
7442                 /* Append IV at the end of the crypto operation*/
7443                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7444                                 uint8_t *, IV_OFFSET);
7445
7446                 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7447                 debug_hexdump(stdout, "iv:", iv_ptr,
7448                         tdata->iv.len);
7449         }
7450
7451         /* Append plaintext/ciphertext */
7452         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7453                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7454                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7455                                 plaintext_pad_len);
7456                 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7457
7458                 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7459                 debug_hexdump(stdout, "plaintext:", plaintext,
7460                                 tdata->plaintext.len);
7461
7462                 if (ut_params->obuf) {
7463                         ciphertext = (uint8_t *)rte_pktmbuf_append(
7464                                         ut_params->obuf,
7465                                         plaintext_pad_len + aad_pad_len);
7466                         TEST_ASSERT_NOT_NULL(ciphertext,
7467                                         "no room to append ciphertext");
7468
7469                         memset(ciphertext + aad_pad_len, 0,
7470                                         tdata->ciphertext.len);
7471                 }
7472         } else {
7473                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7474                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7475                                 plaintext_pad_len);
7476                 TEST_ASSERT_NOT_NULL(ciphertext,
7477                                 "no room to append ciphertext");
7478
7479                 memcpy(ciphertext, tdata->ciphertext.data,
7480                                 tdata->ciphertext.len);
7481                 debug_hexdump(stdout, "ciphertext:", ciphertext,
7482                                 tdata->ciphertext.len);
7483
7484                 if (ut_params->obuf) {
7485                         plaintext = (uint8_t *)rte_pktmbuf_append(
7486                                         ut_params->obuf,
7487                                         plaintext_pad_len + aad_pad_len);
7488                         TEST_ASSERT_NOT_NULL(plaintext,
7489                                         "no room to append plaintext");
7490
7491                         memset(plaintext + aad_pad_len, 0,
7492                                         tdata->plaintext.len);
7493                 }
7494         }
7495
7496         /* Append digest data */
7497         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7498                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7499                                 ut_params->obuf ? ut_params->obuf :
7500                                                 ut_params->ibuf,
7501                                                 tdata->auth_tag.len);
7502                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7503                                 "no room to append digest");
7504                 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7505                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7506                                 ut_params->obuf ? ut_params->obuf :
7507                                                 ut_params->ibuf,
7508                                                 plaintext_pad_len +
7509                                                 aad_pad_len);
7510         } else {
7511                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7512                                 ut_params->ibuf, tdata->auth_tag.len);
7513                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7514                                 "no room to append digest");
7515                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7516                                 ut_params->ibuf,
7517                                 plaintext_pad_len + aad_pad_len);
7518
7519                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7520                         tdata->auth_tag.len);
7521                 debug_hexdump(stdout, "digest:",
7522                         sym_op->aead.digest.data,
7523                         tdata->auth_tag.len);
7524         }
7525
7526         sym_op->aead.data.length = tdata->plaintext.len;
7527         sym_op->aead.data.offset = aad_pad_len;
7528
7529         return 0;
7530 }
7531
7532 static int
7533 test_authenticated_encryption(const struct aead_test_data *tdata)
7534 {
7535         struct crypto_testsuite_params *ts_params = &testsuite_params;
7536         struct crypto_unittest_params *ut_params = &unittest_params;
7537
7538         int retval;
7539         uint8_t *ciphertext, *auth_tag;
7540         uint16_t plaintext_pad_len;
7541         uint32_t i;
7542
7543         /* Create AEAD session */
7544         retval = create_aead_session(ts_params->valid_devs[0],
7545                         tdata->algo,
7546                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
7547                         tdata->key.data, tdata->key.len,
7548                         tdata->aad.len, tdata->auth_tag.len,
7549                         tdata->iv.len);
7550         if (retval < 0)
7551                 return retval;
7552
7553         if (tdata->aad.len > MBUF_SIZE) {
7554                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7555                 /* Populate full size of add data */
7556                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7557                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7558         } else
7559                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7560
7561         /* clear mbuf payload */
7562         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7563                         rte_pktmbuf_tailroom(ut_params->ibuf));
7564
7565         /* Create AEAD operation */
7566         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7567         if (retval < 0)
7568                 return retval;
7569
7570         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7571
7572         ut_params->op->sym->m_src = ut_params->ibuf;
7573
7574         /* Process crypto operation */
7575         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7576                         ut_params->op), "failed to process sym crypto op");
7577
7578         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7579                         "crypto op processing failed");
7580
7581         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7582
7583         if (ut_params->op->sym->m_dst) {
7584                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7585                                 uint8_t *);
7586                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7587                                 uint8_t *, plaintext_pad_len);
7588         } else {
7589                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7590                                 uint8_t *,
7591                                 ut_params->op->sym->cipher.data.offset);
7592                 auth_tag = ciphertext + plaintext_pad_len;
7593         }
7594
7595         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7596         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7597
7598         /* Validate obuf */
7599         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7600                         ciphertext,
7601                         tdata->ciphertext.data,
7602                         tdata->ciphertext.len,
7603                         "Ciphertext data not as expected");
7604
7605         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7606                         auth_tag,
7607                         tdata->auth_tag.data,
7608                         tdata->auth_tag.len,
7609                         "Generated auth tag not as expected");
7610
7611         return 0;
7612
7613 }
7614
7615 #ifdef RTE_LIBRTE_SECURITY
7616 /* Basic algorithm run function for async inplace mode.
7617  * Creates a session from input parameters and runs one operation
7618  * on input_vec. Checks the output of the crypto operation against
7619  * output_vec.
7620  */
7621 static int
7622 test_pdcp_proto(int i, int oop,
7623         enum rte_crypto_cipher_operation opc,
7624         enum rte_crypto_auth_operation opa,
7625         uint8_t *input_vec,
7626         unsigned int input_vec_len,
7627         uint8_t *output_vec,
7628         unsigned int output_vec_len)
7629 {
7630         struct crypto_testsuite_params *ts_params = &testsuite_params;
7631         struct crypto_unittest_params *ut_params = &unittest_params;
7632         uint8_t *plaintext;
7633         int ret = TEST_SUCCESS;
7634
7635         /* Generate test mbuf data */
7636         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7637
7638         /* clear mbuf payload */
7639         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7640                         rte_pktmbuf_tailroom(ut_params->ibuf));
7641
7642         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7643                                                   input_vec_len);
7644         memcpy(plaintext, input_vec, input_vec_len);
7645
7646         /* Out of place support */
7647         if (oop) {
7648                 /*
7649                  * For out-op-place we need to alloc another mbuf
7650                  */
7651                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7652                 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7653         }
7654
7655         /* Set crypto type as IPSEC */
7656         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7657
7658         /* Setup Cipher Parameters */
7659         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7660         ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7661         ut_params->cipher_xform.cipher.op = opc;
7662         ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7663         ut_params->cipher_xform.cipher.key.length =
7664                                         pdcp_test_params[i].cipher_key_len;
7665         ut_params->cipher_xform.cipher.iv.length = 0;
7666
7667         /* Setup HMAC Parameters if ICV header is required */
7668         if (pdcp_test_params[i].auth_alg != 0) {
7669                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7670                 ut_params->auth_xform.next = NULL;
7671                 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7672                 ut_params->auth_xform.auth.op = opa;
7673                 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7674                 ut_params->auth_xform.auth.key.length =
7675                                         pdcp_test_params[i].auth_key_len;
7676
7677                 ut_params->cipher_xform.next = &ut_params->auth_xform;
7678         } else {
7679                 ut_params->cipher_xform.next = NULL;
7680         }
7681
7682         struct rte_security_session_conf sess_conf = {
7683                 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7684                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7685                 {.pdcp = {
7686                         .bearer = pdcp_test_bearer[i],
7687                         .domain = pdcp_test_params[i].domain,
7688                         .pkt_dir = pdcp_test_packet_direction[i],
7689                         .sn_size = pdcp_test_data_sn_size[i],
7690                         .hfn = pdcp_test_hfn[i],
7691                         .hfn_threshold = pdcp_test_hfn_threshold[i],
7692                 } },
7693                 .crypto_xform = &ut_params->cipher_xform
7694         };
7695
7696         struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7697                                 rte_cryptodev_get_sec_ctx(
7698                                 ts_params->valid_devs[0]);
7699
7700         /* Create security session */
7701         ut_params->sec_session = rte_security_session_create(ctx,
7702                                 &sess_conf, ts_params->session_priv_mpool);
7703
7704         if (!ut_params->sec_session) {
7705                 printf("TestCase %s()-%d line %d failed %s: ",
7706                         __func__, i, __LINE__, "Failed to allocate session");
7707                 ret = TEST_FAILED;
7708                 goto on_err;
7709         }
7710
7711         /* Generate crypto op data structure */
7712         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7713                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7714         if (!ut_params->op) {
7715                 printf("TestCase %s()-%d line %d failed %s: ",
7716                         __func__, i, __LINE__,
7717                         "Failed to allocate symmetric crypto operation struct");
7718                 ret = TEST_FAILED;
7719                 goto on_err;
7720         }
7721
7722         rte_security_attach_session(ut_params->op, ut_params->sec_session);
7723
7724         /* set crypto operation source mbuf */
7725         ut_params->op->sym->m_src = ut_params->ibuf;
7726         if (oop)
7727                 ut_params->op->sym->m_dst = ut_params->obuf;
7728
7729         /* Process crypto operation */
7730         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7731                 == NULL) {
7732                 printf("TestCase %s()-%d line %d failed %s: ",
7733                         __func__, i, __LINE__,
7734                         "failed to process sym crypto op");
7735                 ret = TEST_FAILED;
7736                 goto on_err;
7737         }
7738
7739         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7740                 printf("TestCase %s()-%d line %d failed %s: ",
7741                         __func__, i, __LINE__, "crypto op processing failed");
7742                 ret = TEST_FAILED;
7743                 goto on_err;
7744         }
7745
7746         /* Validate obuf */
7747         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7748                         uint8_t *);
7749         if (oop) {
7750                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7751                                 uint8_t *);
7752         }
7753
7754         if (memcmp(ciphertext, output_vec, output_vec_len)) {
7755                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7756                 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7757                 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7758                 ret = TEST_FAILED;
7759                 goto on_err;
7760         }
7761
7762 on_err:
7763         rte_crypto_op_free(ut_params->op);
7764         ut_params->op = NULL;
7765
7766         if (ut_params->sec_session)
7767                 rte_security_session_destroy(ctx, ut_params->sec_session);
7768         ut_params->sec_session = NULL;
7769
7770         rte_pktmbuf_free(ut_params->ibuf);
7771         ut_params->ibuf = NULL;
7772         if (oop) {
7773                 rte_pktmbuf_free(ut_params->obuf);
7774                 ut_params->obuf = NULL;
7775         }
7776
7777         return ret;
7778 }
7779
7780 static int
7781 test_pdcp_proto_SGL(int i, int oop,
7782         enum rte_crypto_cipher_operation opc,
7783         enum rte_crypto_auth_operation opa,
7784         uint8_t *input_vec,
7785         unsigned int input_vec_len,
7786         uint8_t *output_vec,
7787         unsigned int output_vec_len,
7788         uint32_t fragsz,
7789         uint32_t fragsz_oop)
7790 {
7791         struct crypto_testsuite_params *ts_params = &testsuite_params;
7792         struct crypto_unittest_params *ut_params = &unittest_params;
7793         uint8_t *plaintext;
7794         struct rte_mbuf *buf, *buf_oop = NULL;
7795         int ret = TEST_SUCCESS;
7796         int to_trn = 0;
7797         int to_trn_tbl[16];
7798         int segs = 1;
7799         unsigned int trn_data = 0;
7800
7801         if (fragsz > input_vec_len)
7802                 fragsz = input_vec_len;
7803
7804         uint16_t plaintext_len = fragsz;
7805         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7806
7807         if (fragsz_oop > output_vec_len)
7808                 frag_size_oop = output_vec_len;
7809
7810         int ecx = 0;
7811         if (input_vec_len % fragsz != 0) {
7812                 if (input_vec_len / fragsz + 1 > 16)
7813                         return 1;
7814         } else if (input_vec_len / fragsz > 16)
7815                 return 1;
7816
7817         /* Out of place support */
7818         if (oop) {
7819                 /*
7820                  * For out-op-place we need to alloc another mbuf
7821                  */
7822                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7823                 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7824                 buf_oop = ut_params->obuf;
7825         }
7826
7827         /* Generate test mbuf data */
7828         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7829
7830         /* clear mbuf payload */
7831         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7832                         rte_pktmbuf_tailroom(ut_params->ibuf));
7833
7834         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7835                                                   plaintext_len);
7836         memcpy(plaintext, input_vec, plaintext_len);
7837         trn_data += plaintext_len;
7838
7839         buf = ut_params->ibuf;
7840
7841         /*
7842          * Loop until no more fragments
7843          */
7844
7845         while (trn_data < input_vec_len) {
7846                 ++segs;
7847                 to_trn = (input_vec_len - trn_data < fragsz) ?
7848                                 (input_vec_len - trn_data) : fragsz;
7849
7850                 to_trn_tbl[ecx++] = to_trn;
7851
7852                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7853                 buf = buf->next;
7854
7855                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7856                                 rte_pktmbuf_tailroom(buf));
7857
7858                 /* OOP */
7859                 if (oop && !fragsz_oop) {
7860                         buf_oop->next =
7861                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
7862                         buf_oop = buf_oop->next;
7863                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7864                                         0, rte_pktmbuf_tailroom(buf_oop));
7865                         rte_pktmbuf_append(buf_oop, to_trn);
7866                 }
7867
7868                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7869                                 to_trn);
7870
7871                 memcpy(plaintext, input_vec + trn_data, to_trn);
7872                 trn_data += to_trn;
7873         }
7874
7875         ut_params->ibuf->nb_segs = segs;
7876
7877         segs = 1;
7878         if (fragsz_oop && oop) {
7879                 to_trn = 0;
7880                 ecx = 0;
7881
7882                 trn_data = frag_size_oop;
7883                 while (trn_data < output_vec_len) {
7884                         ++segs;
7885                         to_trn =
7886                                 (output_vec_len - trn_data <
7887                                                 frag_size_oop) ?
7888                                 (output_vec_len - trn_data) :
7889                                                 frag_size_oop;
7890
7891                         to_trn_tbl[ecx++] = to_trn;
7892
7893                         buf_oop->next =
7894                                 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7895                         buf_oop = buf_oop->next;
7896                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7897                                         0, rte_pktmbuf_tailroom(buf_oop));
7898                         rte_pktmbuf_append(buf_oop, to_trn);
7899
7900                         trn_data += to_trn;
7901                 }
7902                 ut_params->obuf->nb_segs = segs;
7903         }
7904
7905         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7906
7907         /* Setup Cipher Parameters */
7908         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7909         ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7910         ut_params->cipher_xform.cipher.op = opc;
7911         ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7912         ut_params->cipher_xform.cipher.key.length =
7913                                         pdcp_test_params[i].cipher_key_len;
7914         ut_params->cipher_xform.cipher.iv.length = 0;
7915
7916         /* Setup HMAC Parameters if ICV header is required */
7917         if (pdcp_test_params[i].auth_alg != 0) {
7918                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7919                 ut_params->auth_xform.next = NULL;
7920                 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7921                 ut_params->auth_xform.auth.op = opa;
7922                 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7923                 ut_params->auth_xform.auth.key.length =
7924                                         pdcp_test_params[i].auth_key_len;
7925
7926                 ut_params->cipher_xform.next = &ut_params->auth_xform;
7927         } else {
7928                 ut_params->cipher_xform.next = NULL;
7929         }
7930
7931         struct rte_security_session_conf sess_conf = {
7932                 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7933                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7934                 {.pdcp = {
7935                         .bearer = pdcp_test_bearer[i],
7936                         .domain = pdcp_test_params[i].domain,
7937                         .pkt_dir = pdcp_test_packet_direction[i],
7938                         .sn_size = pdcp_test_data_sn_size[i],
7939                         .hfn = pdcp_test_hfn[i],
7940                         .hfn_threshold = pdcp_test_hfn_threshold[i],
7941                 } },
7942                 .crypto_xform = &ut_params->cipher_xform
7943         };
7944
7945         struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7946                                 rte_cryptodev_get_sec_ctx(
7947                                 ts_params->valid_devs[0]);
7948
7949         /* Create security session */
7950         ut_params->sec_session = rte_security_session_create(ctx,
7951                                 &sess_conf, ts_params->session_priv_mpool);
7952
7953         if (!ut_params->sec_session) {
7954                 printf("TestCase %s()-%d line %d failed %s: ",
7955                         __func__, i, __LINE__, "Failed to allocate session");
7956                 ret = TEST_FAILED;
7957                 goto on_err;
7958         }
7959
7960         /* Generate crypto op data structure */
7961         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7962                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7963         if (!ut_params->op) {
7964                 printf("TestCase %s()-%d line %d failed %s: ",
7965                         __func__, i, __LINE__,
7966                         "Failed to allocate symmetric crypto operation struct");
7967                 ret = TEST_FAILED;
7968                 goto on_err;
7969         }
7970
7971         rte_security_attach_session(ut_params->op, ut_params->sec_session);
7972
7973         /* set crypto operation source mbuf */
7974         ut_params->op->sym->m_src = ut_params->ibuf;
7975         if (oop)
7976                 ut_params->op->sym->m_dst = ut_params->obuf;
7977
7978         /* Process crypto operation */
7979         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7980                 == NULL) {
7981                 printf("TestCase %s()-%d line %d failed %s: ",
7982                         __func__, i, __LINE__,
7983                         "failed to process sym crypto op");
7984                 ret = TEST_FAILED;
7985                 goto on_err;
7986         }
7987
7988         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7989                 printf("TestCase %s()-%d line %d failed %s: ",
7990                         __func__, i, __LINE__, "crypto op processing failed");
7991                 ret = TEST_FAILED;
7992                 goto on_err;
7993         }
7994
7995         /* Validate obuf */
7996         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7997                         uint8_t *);
7998         if (oop) {
7999                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8000                                 uint8_t *);
8001         }
8002         if (fragsz_oop)
8003                 fragsz = frag_size_oop;
8004         if (memcmp(ciphertext, output_vec, fragsz)) {
8005                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8006                 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8007                 rte_hexdump(stdout, "reference", output_vec, fragsz);
8008                 ret = TEST_FAILED;
8009                 goto on_err;
8010         }
8011
8012         buf = ut_params->op->sym->m_src->next;
8013         if (oop)
8014                 buf = ut_params->op->sym->m_dst->next;
8015
8016         unsigned int off = fragsz;
8017
8018         ecx = 0;
8019         while (buf) {
8020                 ciphertext = rte_pktmbuf_mtod(buf,
8021                                 uint8_t *);
8022                 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8023                         printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8024                         rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8025                         rte_hexdump(stdout, "reference", output_vec + off,
8026                                         to_trn_tbl[ecx]);
8027                         ret = TEST_FAILED;
8028                         goto on_err;
8029                 }
8030                 off += to_trn_tbl[ecx++];
8031                 buf = buf->next;
8032         }
8033 on_err:
8034         rte_crypto_op_free(ut_params->op);
8035         ut_params->op = NULL;
8036
8037         if (ut_params->sec_session)
8038                 rte_security_session_destroy(ctx, ut_params->sec_session);
8039         ut_params->sec_session = NULL;
8040
8041         rte_pktmbuf_free(ut_params->ibuf);
8042         ut_params->ibuf = NULL;
8043         if (oop) {
8044                 rte_pktmbuf_free(ut_params->obuf);
8045                 ut_params->obuf = NULL;
8046         }
8047
8048         return ret;
8049 }
8050
8051 int
8052 test_pdcp_proto_cplane_encap(int i)
8053 {
8054         return test_pdcp_proto(i, 0,
8055                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8056                 RTE_CRYPTO_AUTH_OP_GENERATE,
8057                 pdcp_test_data_in[i],
8058                 pdcp_test_data_in_len[i],
8059                 pdcp_test_data_out[i],
8060                 pdcp_test_data_in_len[i]+4);
8061 }
8062
8063 int
8064 test_pdcp_proto_uplane_encap(int i)
8065 {
8066         return test_pdcp_proto(i, 0,
8067                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8068                 RTE_CRYPTO_AUTH_OP_GENERATE,
8069                 pdcp_test_data_in[i],
8070                 pdcp_test_data_in_len[i],
8071                 pdcp_test_data_out[i],
8072                 pdcp_test_data_in_len[i]);
8073
8074 }
8075
8076 int
8077 test_pdcp_proto_uplane_encap_with_int(int i)
8078 {
8079         return test_pdcp_proto(i, 0,
8080                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8081                 RTE_CRYPTO_AUTH_OP_GENERATE,
8082                 pdcp_test_data_in[i],
8083                 pdcp_test_data_in_len[i],
8084                 pdcp_test_data_out[i],
8085                 pdcp_test_data_in_len[i] + 4);
8086 }
8087
8088 int
8089 test_pdcp_proto_cplane_decap(int i)
8090 {
8091         return test_pdcp_proto(i, 0,
8092                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8093                 RTE_CRYPTO_AUTH_OP_VERIFY,
8094                 pdcp_test_data_out[i],
8095                 pdcp_test_data_in_len[i] + 4,
8096                 pdcp_test_data_in[i],
8097                 pdcp_test_data_in_len[i]);
8098 }
8099
8100 int
8101 test_pdcp_proto_uplane_decap(int i)
8102 {
8103         return test_pdcp_proto(i, 0,
8104                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8105                 RTE_CRYPTO_AUTH_OP_VERIFY,
8106                 pdcp_test_data_out[i],
8107                 pdcp_test_data_in_len[i],
8108                 pdcp_test_data_in[i],
8109                 pdcp_test_data_in_len[i]);
8110 }
8111
8112 int
8113 test_pdcp_proto_uplane_decap_with_int(int i)
8114 {
8115         return test_pdcp_proto(i, 0,
8116                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8117                 RTE_CRYPTO_AUTH_OP_VERIFY,
8118                 pdcp_test_data_out[i],
8119                 pdcp_test_data_in_len[i] + 4,
8120                 pdcp_test_data_in[i],
8121                 pdcp_test_data_in_len[i]);
8122 }
8123
8124 static int
8125 test_PDCP_PROTO_SGL_in_place_32B(void)
8126 {
8127         /* i can be used for running any PDCP case
8128          * In this case it is uplane 12-bit AES-SNOW DL encap
8129          */
8130         int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8131         return test_pdcp_proto_SGL(i, IN_PLACE,
8132                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8133                         RTE_CRYPTO_AUTH_OP_GENERATE,
8134                         pdcp_test_data_in[i],
8135                         pdcp_test_data_in_len[i],
8136                         pdcp_test_data_out[i],
8137                         pdcp_test_data_in_len[i]+4,
8138                         32, 0);
8139 }
8140 static int
8141 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8142 {
8143         /* i can be used for running any PDCP case
8144          * In this case it is uplane 18-bit NULL-NULL DL encap
8145          */
8146         int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8147         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8148                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8149                         RTE_CRYPTO_AUTH_OP_GENERATE,
8150                         pdcp_test_data_in[i],
8151                         pdcp_test_data_in_len[i],
8152                         pdcp_test_data_out[i],
8153                         pdcp_test_data_in_len[i]+4,
8154                         32, 128);
8155 }
8156 static int
8157 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8158 {
8159         /* i can be used for running any PDCP case
8160          * In this case it is uplane 18-bit AES DL encap
8161          */
8162         int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8163                         + DOWNLINK;
8164         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8165                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8166                         RTE_CRYPTO_AUTH_OP_GENERATE,
8167                         pdcp_test_data_in[i],
8168                         pdcp_test_data_in_len[i],
8169                         pdcp_test_data_out[i],
8170                         pdcp_test_data_in_len[i],
8171                         32, 40);
8172 }
8173 static int
8174 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8175 {
8176         /* i can be used for running any PDCP case
8177          * In this case it is cplane 12-bit AES-ZUC DL encap
8178          */
8179         int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8180         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8181                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8182                         RTE_CRYPTO_AUTH_OP_GENERATE,
8183                         pdcp_test_data_in[i],
8184                         pdcp_test_data_in_len[i],
8185                         pdcp_test_data_out[i],
8186                         pdcp_test_data_in_len[i]+4,
8187                         128, 32);
8188 }
8189 #endif
8190
8191 static int
8192 test_AES_GCM_authenticated_encryption_test_case_1(void)
8193 {
8194         return test_authenticated_encryption(&gcm_test_case_1);
8195 }
8196
8197 static int
8198 test_AES_GCM_authenticated_encryption_test_case_2(void)
8199 {
8200         return test_authenticated_encryption(&gcm_test_case_2);
8201 }
8202
8203 static int
8204 test_AES_GCM_authenticated_encryption_test_case_3(void)
8205 {
8206         return test_authenticated_encryption(&gcm_test_case_3);
8207 }
8208
8209 static int
8210 test_AES_GCM_authenticated_encryption_test_case_4(void)
8211 {
8212         return test_authenticated_encryption(&gcm_test_case_4);
8213 }
8214
8215 static int
8216 test_AES_GCM_authenticated_encryption_test_case_5(void)
8217 {
8218         return test_authenticated_encryption(&gcm_test_case_5);
8219 }
8220
8221 static int
8222 test_AES_GCM_authenticated_encryption_test_case_6(void)
8223 {
8224         return test_authenticated_encryption(&gcm_test_case_6);
8225 }
8226
8227 static int
8228 test_AES_GCM_authenticated_encryption_test_case_7(void)
8229 {
8230         return test_authenticated_encryption(&gcm_test_case_7);
8231 }
8232
8233 static int
8234 test_AES_GCM_authenticated_encryption_test_case_8(void)
8235 {
8236         return test_authenticated_encryption(&gcm_test_case_8);
8237 }
8238
8239 static int
8240 test_AES_GCM_auth_encryption_test_case_192_1(void)
8241 {
8242         return test_authenticated_encryption(&gcm_test_case_192_1);
8243 }
8244
8245 static int
8246 test_AES_GCM_auth_encryption_test_case_192_2(void)
8247 {
8248         return test_authenticated_encryption(&gcm_test_case_192_2);
8249 }
8250
8251 static int
8252 test_AES_GCM_auth_encryption_test_case_192_3(void)
8253 {
8254         return test_authenticated_encryption(&gcm_test_case_192_3);
8255 }
8256
8257 static int
8258 test_AES_GCM_auth_encryption_test_case_192_4(void)
8259 {
8260         return test_authenticated_encryption(&gcm_test_case_192_4);
8261 }
8262
8263 static int
8264 test_AES_GCM_auth_encryption_test_case_192_5(void)
8265 {
8266         return test_authenticated_encryption(&gcm_test_case_192_5);
8267 }
8268
8269 static int
8270 test_AES_GCM_auth_encryption_test_case_192_6(void)
8271 {
8272         return test_authenticated_encryption(&gcm_test_case_192_6);
8273 }
8274
8275 static int
8276 test_AES_GCM_auth_encryption_test_case_192_7(void)
8277 {
8278         return test_authenticated_encryption(&gcm_test_case_192_7);
8279 }
8280
8281 static int
8282 test_AES_GCM_auth_encryption_test_case_256_1(void)
8283 {
8284         return test_authenticated_encryption(&gcm_test_case_256_1);
8285 }
8286
8287 static int
8288 test_AES_GCM_auth_encryption_test_case_256_2(void)
8289 {
8290         return test_authenticated_encryption(&gcm_test_case_256_2);
8291 }
8292
8293 static int
8294 test_AES_GCM_auth_encryption_test_case_256_3(void)
8295 {
8296         return test_authenticated_encryption(&gcm_test_case_256_3);
8297 }
8298
8299 static int
8300 test_AES_GCM_auth_encryption_test_case_256_4(void)
8301 {
8302         return test_authenticated_encryption(&gcm_test_case_256_4);
8303 }
8304
8305 static int
8306 test_AES_GCM_auth_encryption_test_case_256_5(void)
8307 {
8308         return test_authenticated_encryption(&gcm_test_case_256_5);
8309 }
8310
8311 static int
8312 test_AES_GCM_auth_encryption_test_case_256_6(void)
8313 {
8314         return test_authenticated_encryption(&gcm_test_case_256_6);
8315 }
8316
8317 static int
8318 test_AES_GCM_auth_encryption_test_case_256_7(void)
8319 {
8320         return test_authenticated_encryption(&gcm_test_case_256_7);
8321 }
8322
8323 static int
8324 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8325 {
8326         return test_authenticated_encryption(&gcm_test_case_aad_1);
8327 }
8328
8329 static int
8330 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8331 {
8332         return test_authenticated_encryption(&gcm_test_case_aad_2);
8333 }
8334
8335 static int
8336 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8337 {
8338         struct aead_test_data tdata;
8339         int res;
8340
8341         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8342         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8343         tdata.iv.data[0] += 1;
8344         res = test_authenticated_encryption(&tdata);
8345         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8346         return TEST_SUCCESS;
8347 }
8348
8349 static int
8350 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8351 {
8352         struct aead_test_data tdata;
8353         int res;
8354
8355         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8356         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8357         tdata.plaintext.data[0] += 1;
8358         res = test_authenticated_encryption(&tdata);
8359         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8360         return TEST_SUCCESS;
8361 }
8362
8363 static int
8364 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8365 {
8366         struct aead_test_data tdata;
8367         int res;
8368
8369         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8370         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8371         tdata.ciphertext.data[0] += 1;
8372         res = test_authenticated_encryption(&tdata);
8373         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8374         return TEST_SUCCESS;
8375 }
8376
8377 static int
8378 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8379 {
8380         struct aead_test_data tdata;
8381         int res;
8382
8383         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8384         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8385         tdata.aad.len += 1;
8386         res = test_authenticated_encryption(&tdata);
8387         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8388         return TEST_SUCCESS;
8389 }
8390
8391 static int
8392 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8393 {
8394         struct aead_test_data tdata;
8395         uint8_t aad[gcm_test_case_7.aad.len];
8396         int res;
8397
8398         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8399         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8400         memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8401         aad[0] += 1;
8402         tdata.aad.data = aad;
8403         res = test_authenticated_encryption(&tdata);
8404         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8405         return TEST_SUCCESS;
8406 }
8407
8408 static int
8409 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8410 {
8411         struct aead_test_data tdata;
8412         int res;
8413
8414         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8415         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8416         tdata.auth_tag.data[0] += 1;
8417         res = test_authenticated_encryption(&tdata);
8418         TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8419         return TEST_SUCCESS;
8420 }
8421
8422 static int
8423 test_authenticated_decryption(const struct aead_test_data *tdata)
8424 {
8425         struct crypto_testsuite_params *ts_params = &testsuite_params;
8426         struct crypto_unittest_params *ut_params = &unittest_params;
8427
8428         int retval;
8429         uint8_t *plaintext;
8430         uint32_t i;
8431
8432         /* Create AEAD session */
8433         retval = create_aead_session(ts_params->valid_devs[0],
8434                         tdata->algo,
8435                         RTE_CRYPTO_AEAD_OP_DECRYPT,
8436                         tdata->key.data, tdata->key.len,
8437                         tdata->aad.len, tdata->auth_tag.len,
8438                         tdata->iv.len);
8439         if (retval < 0)
8440                 return retval;
8441
8442         /* alloc mbuf and set payload */
8443         if (tdata->aad.len > MBUF_SIZE) {
8444                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8445                 /* Populate full size of add data */
8446                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8447                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8448         } else
8449                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8450
8451         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8452                         rte_pktmbuf_tailroom(ut_params->ibuf));
8453
8454         /* Create AEAD operation */
8455         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8456         if (retval < 0)
8457                 return retval;
8458
8459         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8460
8461         ut_params->op->sym->m_src = ut_params->ibuf;
8462
8463         /* Process crypto operation */
8464         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8465                         ut_params->op), "failed to process sym crypto op");
8466
8467         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8468                         "crypto op processing failed");
8469
8470         if (ut_params->op->sym->m_dst)
8471                 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8472                                 uint8_t *);
8473         else
8474                 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8475                                 uint8_t *,
8476                                 ut_params->op->sym->cipher.data.offset);
8477
8478         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8479
8480         /* Validate obuf */
8481         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8482                         plaintext,
8483                         tdata->plaintext.data,
8484                         tdata->plaintext.len,
8485                         "Plaintext data not as expected");
8486
8487         TEST_ASSERT_EQUAL(ut_params->op->status,
8488                         RTE_CRYPTO_OP_STATUS_SUCCESS,
8489                         "Authentication failed");
8490
8491         return 0;
8492 }
8493
8494 static int
8495 test_AES_GCM_authenticated_decryption_test_case_1(void)
8496 {
8497         return test_authenticated_decryption(&gcm_test_case_1);
8498 }
8499
8500 static int
8501 test_AES_GCM_authenticated_decryption_test_case_2(void)
8502 {
8503         return test_authenticated_decryption(&gcm_test_case_2);
8504 }
8505
8506 static int
8507 test_AES_GCM_authenticated_decryption_test_case_3(void)
8508 {
8509         return test_authenticated_decryption(&gcm_test_case_3);
8510 }
8511
8512 static int
8513 test_AES_GCM_authenticated_decryption_test_case_4(void)
8514 {
8515         return test_authenticated_decryption(&gcm_test_case_4);
8516 }
8517
8518 static int
8519 test_AES_GCM_authenticated_decryption_test_case_5(void)
8520 {
8521         return test_authenticated_decryption(&gcm_test_case_5);
8522 }
8523
8524 static int
8525 test_AES_GCM_authenticated_decryption_test_case_6(void)
8526 {
8527         return test_authenticated_decryption(&gcm_test_case_6);
8528 }
8529
8530 static int
8531 test_AES_GCM_authenticated_decryption_test_case_7(void)
8532 {
8533         return test_authenticated_decryption(&gcm_test_case_7);
8534 }
8535
8536 static int
8537 test_AES_GCM_authenticated_decryption_test_case_8(void)
8538 {
8539         return test_authenticated_decryption(&gcm_test_case_8);
8540 }
8541
8542 static int
8543 test_AES_GCM_auth_decryption_test_case_192_1(void)
8544 {
8545         return test_authenticated_decryption(&gcm_test_case_192_1);
8546 }
8547
8548 static int
8549 test_AES_GCM_auth_decryption_test_case_192_2(void)
8550 {
8551         return test_authenticated_decryption(&gcm_test_case_192_2);
8552 }
8553
8554 static int
8555 test_AES_GCM_auth_decryption_test_case_192_3(void)
8556 {
8557         return test_authenticated_decryption(&gcm_test_case_192_3);
8558 }
8559
8560 static int
8561 test_AES_GCM_auth_decryption_test_case_192_4(void)
8562 {
8563         return test_authenticated_decryption(&gcm_test_case_192_4);
8564 }
8565
8566 static int
8567 test_AES_GCM_auth_decryption_test_case_192_5(void)
8568 {
8569         return test_authenticated_decryption(&gcm_test_case_192_5);
8570 }
8571
8572 static int
8573 test_AES_GCM_auth_decryption_test_case_192_6(void)
8574 {
8575         return test_authenticated_decryption(&gcm_test_case_192_6);
8576 }
8577
8578 static int
8579 test_AES_GCM_auth_decryption_test_case_192_7(void)
8580 {
8581         return test_authenticated_decryption(&gcm_test_case_192_7);
8582 }
8583
8584 static int
8585 test_AES_GCM_auth_decryption_test_case_256_1(void)
8586 {
8587         return test_authenticated_decryption(&gcm_test_case_256_1);
8588 }
8589
8590 static int
8591 test_AES_GCM_auth_decryption_test_case_256_2(void)
8592 {
8593         return test_authenticated_decryption(&gcm_test_case_256_2);
8594 }
8595
8596 static int
8597 test_AES_GCM_auth_decryption_test_case_256_3(void)
8598 {
8599         return test_authenticated_decryption(&gcm_test_case_256_3);
8600 }
8601
8602 static int
8603 test_AES_GCM_auth_decryption_test_case_256_4(void)
8604 {
8605         return test_authenticated_decryption(&gcm_test_case_256_4);
8606 }
8607
8608 static int
8609 test_AES_GCM_auth_decryption_test_case_256_5(void)
8610 {
8611         return test_authenticated_decryption(&gcm_test_case_256_5);
8612 }
8613
8614 static int
8615 test_AES_GCM_auth_decryption_test_case_256_6(void)
8616 {
8617         return test_authenticated_decryption(&gcm_test_case_256_6);
8618 }
8619
8620 static int
8621 test_AES_GCM_auth_decryption_test_case_256_7(void)
8622 {
8623         return test_authenticated_decryption(&gcm_test_case_256_7);
8624 }
8625
8626 static int
8627 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8628 {
8629         return test_authenticated_decryption(&gcm_test_case_aad_1);
8630 }
8631
8632 static int
8633 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8634 {
8635         return test_authenticated_decryption(&gcm_test_case_aad_2);
8636 }
8637
8638 static int
8639 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8640 {
8641         struct aead_test_data tdata;
8642         int res;
8643
8644         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8645         tdata.iv.data[0] += 1;
8646         res = test_authenticated_decryption(&tdata);
8647         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8648         return TEST_SUCCESS;
8649 }
8650
8651 static int
8652 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8653 {
8654         struct aead_test_data tdata;
8655         int res;
8656
8657         RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8658         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8659         tdata.plaintext.data[0] += 1;
8660         res = test_authenticated_decryption(&tdata);
8661         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8662         return TEST_SUCCESS;
8663 }
8664
8665 static int
8666 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8667 {
8668         struct aead_test_data tdata;
8669         int res;
8670
8671         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8672         tdata.ciphertext.data[0] += 1;
8673         res = test_authenticated_decryption(&tdata);
8674         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8675         return TEST_SUCCESS;
8676 }
8677
8678 static int
8679 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8680 {
8681         struct aead_test_data tdata;
8682         int res;
8683
8684         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8685         tdata.aad.len += 1;
8686         res = test_authenticated_decryption(&tdata);
8687         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8688         return TEST_SUCCESS;
8689 }
8690
8691 static int
8692 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8693 {
8694         struct aead_test_data tdata;
8695         uint8_t aad[gcm_test_case_7.aad.len];
8696         int res;
8697
8698         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8699         memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8700         aad[0] += 1;
8701         tdata.aad.data = aad;
8702         res = test_authenticated_decryption(&tdata);
8703         TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8704         return TEST_SUCCESS;
8705 }
8706
8707 static int
8708 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8709 {
8710         struct aead_test_data tdata;
8711         int res;
8712
8713         memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8714         tdata.auth_tag.data[0] += 1;
8715         res = test_authenticated_decryption(&tdata);
8716         TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8717         return TEST_SUCCESS;
8718 }
8719
8720 static int
8721 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8722 {
8723         struct crypto_testsuite_params *ts_params = &testsuite_params;
8724         struct crypto_unittest_params *ut_params = &unittest_params;
8725
8726         int retval;
8727         uint8_t *ciphertext, *auth_tag;
8728         uint16_t plaintext_pad_len;
8729
8730         /* Create AEAD session */
8731         retval = create_aead_session(ts_params->valid_devs[0],
8732                         tdata->algo,
8733                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
8734                         tdata->key.data, tdata->key.len,
8735                         tdata->aad.len, tdata->auth_tag.len,
8736                         tdata->iv.len);
8737         if (retval < 0)
8738                 return retval;
8739
8740         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8741         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8742
8743         /* clear mbuf payload */
8744         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8745                         rte_pktmbuf_tailroom(ut_params->ibuf));
8746         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8747                         rte_pktmbuf_tailroom(ut_params->obuf));
8748
8749         /* Create AEAD operation */
8750         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8751         if (retval < 0)
8752                 return retval;
8753
8754         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8755
8756         ut_params->op->sym->m_src = ut_params->ibuf;
8757         ut_params->op->sym->m_dst = ut_params->obuf;
8758
8759         /* Process crypto operation */
8760         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8761                         ut_params->op), "failed to process sym crypto op");
8762
8763         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8764                         "crypto op processing failed");
8765
8766         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8767
8768         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8769                         ut_params->op->sym->cipher.data.offset);
8770         auth_tag = ciphertext + plaintext_pad_len;
8771
8772         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8773         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8774
8775         /* Validate obuf */
8776         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8777                         ciphertext,
8778                         tdata->ciphertext.data,
8779                         tdata->ciphertext.len,
8780                         "Ciphertext data not as expected");
8781
8782         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8783                         auth_tag,
8784                         tdata->auth_tag.data,
8785                         tdata->auth_tag.len,
8786                         "Generated auth tag not as expected");
8787
8788         return 0;
8789
8790 }
8791
8792 static int
8793 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8794 {
8795         return test_authenticated_encryption_oop(&gcm_test_case_5);
8796 }
8797
8798 static int
8799 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8800 {
8801         struct crypto_testsuite_params *ts_params = &testsuite_params;
8802         struct crypto_unittest_params *ut_params = &unittest_params;
8803
8804         int retval;
8805         uint8_t *plaintext;
8806
8807         /* Create AEAD session */
8808         retval = create_aead_session(ts_params->valid_devs[0],
8809                         tdata->algo,
8810                         RTE_CRYPTO_AEAD_OP_DECRYPT,
8811                         tdata->key.data, tdata->key.len,
8812                         tdata->aad.len, tdata->auth_tag.len,
8813                         tdata->iv.len);
8814         if (retval < 0)
8815                 return retval;
8816
8817         /* alloc mbuf and set payload */
8818         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8819         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8820
8821         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8822                         rte_pktmbuf_tailroom(ut_params->ibuf));
8823         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8824                         rte_pktmbuf_tailroom(ut_params->obuf));
8825
8826         /* Create AEAD operation */
8827         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8828         if (retval < 0)
8829                 return retval;
8830
8831         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8832
8833         ut_params->op->sym->m_src = ut_params->ibuf;
8834         ut_params->op->sym->m_dst = ut_params->obuf;
8835
8836         /* Process crypto operation */
8837         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8838                         ut_params->op), "failed to process sym crypto op");
8839
8840         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8841                         "crypto op processing failed");
8842
8843         plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8844                         ut_params->op->sym->cipher.data.offset);
8845
8846         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8847
8848         /* Validate obuf */
8849         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8850                         plaintext,
8851                         tdata->plaintext.data,
8852                         tdata->plaintext.len,
8853                         "Plaintext data not as expected");
8854
8855         TEST_ASSERT_EQUAL(ut_params->op->status,
8856                         RTE_CRYPTO_OP_STATUS_SUCCESS,
8857                         "Authentication failed");
8858         return 0;
8859 }
8860
8861 static int
8862 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8863 {
8864         return test_authenticated_decryption_oop(&gcm_test_case_5);
8865 }
8866
8867 static int
8868 test_authenticated_encryption_sessionless(
8869                 const struct aead_test_data *tdata)
8870 {
8871         struct crypto_testsuite_params *ts_params = &testsuite_params;
8872         struct crypto_unittest_params *ut_params = &unittest_params;
8873
8874         int retval;
8875         uint8_t *ciphertext, *auth_tag;
8876         uint16_t plaintext_pad_len;
8877         uint8_t key[tdata->key.len + 1];
8878
8879         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8880
8881         /* clear mbuf payload */
8882         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8883                         rte_pktmbuf_tailroom(ut_params->ibuf));
8884
8885         /* Create AEAD operation */
8886         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8887         if (retval < 0)
8888                 return retval;
8889
8890         /* Create GCM xform */
8891         memcpy(key, tdata->key.data, tdata->key.len);
8892         retval = create_aead_xform(ut_params->op,
8893                         tdata->algo,
8894                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
8895                         key, tdata->key.len,
8896                         tdata->aad.len, tdata->auth_tag.len,
8897                         tdata->iv.len);
8898         if (retval < 0)
8899                 return retval;
8900
8901         ut_params->op->sym->m_src = ut_params->ibuf;
8902
8903         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8904                         RTE_CRYPTO_OP_SESSIONLESS,
8905                         "crypto op session type not sessionless");
8906
8907         /* Process crypto operation */
8908         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8909                         ut_params->op), "failed to process sym crypto op");
8910
8911         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8912
8913         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8914                         "crypto op status not success");
8915
8916         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8917
8918         ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8919                         ut_params->op->sym->cipher.data.offset);
8920         auth_tag = ciphertext + plaintext_pad_len;
8921
8922         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8923         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8924
8925         /* Validate obuf */
8926         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8927                         ciphertext,
8928                         tdata->ciphertext.data,
8929                         tdata->ciphertext.len,
8930                         "Ciphertext data not as expected");
8931
8932         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8933                         auth_tag,
8934                         tdata->auth_tag.data,
8935                         tdata->auth_tag.len,
8936                         "Generated auth tag not as expected");
8937
8938         return 0;
8939
8940 }
8941
8942 static int
8943 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8944 {
8945         return test_authenticated_encryption_sessionless(
8946                         &gcm_test_case_5);
8947 }
8948
8949 static int
8950 test_authenticated_decryption_sessionless(
8951                 const struct aead_test_data *tdata)
8952 {
8953         struct crypto_testsuite_params *ts_params = &testsuite_params;
8954         struct crypto_unittest_params *ut_params = &unittest_params;
8955
8956         int retval;
8957         uint8_t *plaintext;
8958         uint8_t key[tdata->key.len + 1];
8959
8960         /* alloc mbuf and set payload */
8961         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8962
8963         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8964                         rte_pktmbuf_tailroom(ut_params->ibuf));
8965
8966         /* Create AEAD operation */
8967         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8968         if (retval < 0)
8969                 return retval;
8970
8971         /* Create AEAD xform */
8972         memcpy(key, tdata->key.data, tdata->key.len);
8973         retval = create_aead_xform(ut_params->op,
8974                         tdata->algo,
8975                         RTE_CRYPTO_AEAD_OP_DECRYPT,
8976                         key, tdata->key.len,
8977                         tdata->aad.len, tdata->auth_tag.len,
8978                         tdata->iv.len);
8979         if (retval < 0)
8980                 return retval;
8981
8982         ut_params->op->sym->m_src = ut_params->ibuf;
8983
8984         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8985                         RTE_CRYPTO_OP_SESSIONLESS,
8986                         "crypto op session type not sessionless");
8987
8988         /* Process crypto operation */
8989         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8990                         ut_params->op), "failed to process sym crypto op");
8991
8992         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8993
8994         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8995                         "crypto op status not success");
8996
8997         plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8998                         ut_params->op->sym->cipher.data.offset);
8999
9000         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9001
9002         /* Validate obuf */
9003         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9004                         plaintext,
9005                         tdata->plaintext.data,
9006                         tdata->plaintext.len,
9007                         "Plaintext data not as expected");
9008
9009         TEST_ASSERT_EQUAL(ut_params->op->status,
9010                         RTE_CRYPTO_OP_STATUS_SUCCESS,
9011                         "Authentication failed");
9012         return 0;
9013 }
9014
9015 static int
9016 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9017 {
9018         return test_authenticated_decryption_sessionless(
9019                         &gcm_test_case_5);
9020 }
9021
9022 static int
9023 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9024 {
9025         return test_authenticated_encryption(&ccm_test_case_128_1);
9026 }
9027
9028 static int
9029 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9030 {
9031         return test_authenticated_encryption(&ccm_test_case_128_2);
9032 }
9033
9034 static int
9035 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9036 {
9037         return test_authenticated_encryption(&ccm_test_case_128_3);
9038 }
9039
9040 static int
9041 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9042 {
9043         return test_authenticated_decryption(&ccm_test_case_128_1);
9044 }
9045
9046 static int
9047 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9048 {
9049         return test_authenticated_decryption(&ccm_test_case_128_2);
9050 }
9051
9052 static int
9053 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9054 {
9055         return test_authenticated_decryption(&ccm_test_case_128_3);
9056 }
9057
9058 static int
9059 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9060 {
9061         return test_authenticated_encryption(&ccm_test_case_192_1);
9062 }
9063
9064 static int
9065 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9066 {
9067         return test_authenticated_encryption(&ccm_test_case_192_2);
9068 }
9069
9070 static int
9071 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9072 {
9073         return test_authenticated_encryption(&ccm_test_case_192_3);
9074 }
9075
9076 static int
9077 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9078 {
9079         return test_authenticated_decryption(&ccm_test_case_192_1);
9080 }
9081
9082 static int
9083 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9084 {
9085         return test_authenticated_decryption(&ccm_test_case_192_2);
9086 }
9087
9088 static int
9089 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9090 {
9091         return test_authenticated_decryption(&ccm_test_case_192_3);
9092 }
9093
9094 static int
9095 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9096 {
9097         return test_authenticated_encryption(&ccm_test_case_256_1);
9098 }
9099
9100 static int
9101 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9102 {
9103         return test_authenticated_encryption(&ccm_test_case_256_2);
9104 }
9105
9106 static int
9107 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9108 {
9109         return test_authenticated_encryption(&ccm_test_case_256_3);
9110 }
9111
9112 static int
9113 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9114 {
9115         return test_authenticated_decryption(&ccm_test_case_256_1);
9116 }
9117
9118 static int
9119 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9120 {
9121         return test_authenticated_decryption(&ccm_test_case_256_2);
9122 }
9123
9124 static int
9125 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9126 {
9127         return test_authenticated_decryption(&ccm_test_case_256_3);
9128 }
9129
9130 static int
9131 test_stats(void)
9132 {
9133         struct crypto_testsuite_params *ts_params = &testsuite_params;
9134         struct rte_cryptodev_stats stats;
9135         struct rte_cryptodev *dev;
9136         cryptodev_stats_get_t temp_pfn;
9137
9138         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9139         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9140                         &stats) == -ENODEV),
9141                 "rte_cryptodev_stats_get invalid dev failed");
9142         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9143                 "rte_cryptodev_stats_get invalid Param failed");
9144         dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9145         temp_pfn = dev->dev_ops->stats_get;
9146         dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9147         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9148                         == -ENOTSUP),
9149                 "rte_cryptodev_stats_get invalid Param failed");
9150         dev->dev_ops->stats_get = temp_pfn;
9151
9152         /* Test expected values */
9153         ut_setup();
9154         test_AES_CBC_HMAC_SHA1_encrypt_digest();
9155         ut_teardown();
9156         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9157                         &stats),
9158                 "rte_cryptodev_stats_get failed");
9159         TEST_ASSERT((stats.enqueued_count == 1),
9160                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9161         TEST_ASSERT((stats.dequeued_count == 1),
9162                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9163         TEST_ASSERT((stats.enqueue_err_count == 0),
9164                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9165         TEST_ASSERT((stats.dequeue_err_count == 0),
9166                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9167
9168         /* invalid device but should ignore and not reset device stats*/
9169         rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9170         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9171                         &stats),
9172                 "rte_cryptodev_stats_get failed");
9173         TEST_ASSERT((stats.enqueued_count == 1),
9174                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9175
9176         /* check that a valid reset clears stats */
9177         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9178         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9179                         &stats),
9180                                           "rte_cryptodev_stats_get failed");
9181         TEST_ASSERT((stats.enqueued_count == 0),
9182                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9183         TEST_ASSERT((stats.dequeued_count == 0),
9184                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9185
9186         return TEST_SUCCESS;
9187 }
9188
9189 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9190                                    struct crypto_unittest_params *ut_params,
9191                                    enum rte_crypto_auth_operation op,
9192                                    const struct HMAC_MD5_vector *test_case)
9193 {
9194         uint8_t key[64];
9195
9196         memcpy(key, test_case->key.data, test_case->key.len);
9197
9198         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9199         ut_params->auth_xform.next = NULL;
9200         ut_params->auth_xform.auth.op = op;
9201
9202         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9203
9204         ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9205         ut_params->auth_xform.auth.key.length = test_case->key.len;
9206         ut_params->auth_xform.auth.key.data = key;
9207
9208         ut_params->sess = rte_cryptodev_sym_session_create(
9209                         ts_params->session_mpool);
9210
9211         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9212                         ut_params->sess, &ut_params->auth_xform,
9213                         ts_params->session_priv_mpool);
9214
9215         if (ut_params->sess == NULL)
9216                 return TEST_FAILED;
9217
9218         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9219
9220         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9221                         rte_pktmbuf_tailroom(ut_params->ibuf));
9222
9223         return 0;
9224 }
9225
9226 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9227                               const struct HMAC_MD5_vector *test_case,
9228                               uint8_t **plaintext)
9229 {
9230         uint16_t plaintext_pad_len;
9231
9232         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9233
9234         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9235                                 16);
9236
9237         *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9238                         plaintext_pad_len);
9239         memcpy(*plaintext, test_case->plaintext.data,
9240                         test_case->plaintext.len);
9241
9242         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9243                         ut_params->ibuf, MD5_DIGEST_LEN);
9244         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9245                         "no room to append digest");
9246         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9247                         ut_params->ibuf, plaintext_pad_len);
9248
9249         if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9250                 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9251                            test_case->auth_tag.len);
9252         }
9253
9254         sym_op->auth.data.offset = 0;
9255         sym_op->auth.data.length = test_case->plaintext.len;
9256
9257         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9258         ut_params->op->sym->m_src = ut_params->ibuf;
9259
9260         return 0;
9261 }
9262
9263 static int
9264 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9265 {
9266         uint16_t plaintext_pad_len;
9267         uint8_t *plaintext, *auth_tag;
9268
9269         struct crypto_testsuite_params *ts_params = &testsuite_params;
9270         struct crypto_unittest_params *ut_params = &unittest_params;
9271
9272         if (MD5_HMAC_create_session(ts_params, ut_params,
9273                         RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9274                 return TEST_FAILED;
9275
9276         /* Generate Crypto op data structure */
9277         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9278                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9279         TEST_ASSERT_NOT_NULL(ut_params->op,
9280                         "Failed to allocate symmetric crypto operation struct");
9281
9282         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9283                                 16);
9284
9285         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9286                 return TEST_FAILED;
9287
9288         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9289                         ut_params->op), "failed to process sym crypto op");
9290
9291         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9292                         "crypto op processing failed");
9293
9294         if (ut_params->op->sym->m_dst) {
9295                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9296                                 uint8_t *, plaintext_pad_len);
9297         } else {
9298                 auth_tag = plaintext + plaintext_pad_len;
9299         }
9300
9301         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9302                         auth_tag,
9303                         test_case->auth_tag.data,
9304                         test_case->auth_tag.len,
9305                         "HMAC_MD5 generated tag not as expected");
9306
9307         return TEST_SUCCESS;
9308 }
9309
9310 static int
9311 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9312 {
9313         uint8_t *plaintext;
9314
9315         struct crypto_testsuite_params *ts_params = &testsuite_params;
9316         struct crypto_unittest_params *ut_params = &unittest_params;
9317
9318         if (MD5_HMAC_create_session(ts_params, ut_params,
9319                         RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9320                 return TEST_FAILED;
9321         }
9322
9323         /* Generate Crypto op data structure */
9324         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9325                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9326         TEST_ASSERT_NOT_NULL(ut_params->op,
9327                         "Failed to allocate symmetric crypto operation struct");
9328
9329         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9330                 return TEST_FAILED;
9331
9332         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9333                         ut_params->op), "failed to process sym crypto op");
9334
9335         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9336                         "HMAC_MD5 crypto op processing failed");
9337
9338         return TEST_SUCCESS;
9339 }
9340
9341 static int
9342 test_MD5_HMAC_generate_case_1(void)
9343 {
9344         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9345 }
9346
9347 static int
9348 test_MD5_HMAC_verify_case_1(void)
9349 {
9350         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9351 }
9352
9353 static int
9354 test_MD5_HMAC_generate_case_2(void)
9355 {
9356         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9357 }
9358
9359 static int
9360 test_MD5_HMAC_verify_case_2(void)
9361 {
9362         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9363 }
9364
9365 static int
9366 test_multi_session(void)
9367 {
9368         struct crypto_testsuite_params *ts_params = &testsuite_params;
9369         struct crypto_unittest_params *ut_params = &unittest_params;
9370
9371         struct rte_cryptodev_info dev_info;
9372         struct rte_cryptodev_sym_session **sessions;
9373
9374         uint16_t i;
9375
9376         test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9377                         aes_cbc_key, hmac_sha512_key);
9378
9379
9380         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9381
9382         sessions = rte_malloc(NULL,
9383                         (sizeof(struct rte_cryptodev_sym_session *) *
9384                         MAX_NB_SESSIONS) + 1, 0);
9385
9386         /* Create multiple crypto sessions*/
9387         for (i = 0; i < MAX_NB_SESSIONS; i++) {
9388
9389                 sessions[i] = rte_cryptodev_sym_session_create(
9390                                 ts_params->session_mpool);
9391
9392                 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9393                                 sessions[i], &ut_params->auth_xform,
9394                                 ts_params->session_priv_mpool);
9395                 TEST_ASSERT_NOT_NULL(sessions[i],
9396                                 "Session creation failed at session number %u",
9397                                 i);
9398
9399                 /* Attempt to send a request on each session */
9400                 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9401                         sessions[i],
9402                         ut_params,
9403                         ts_params,
9404                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9405                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9406                         aes_cbc_iv),
9407                         "Failed to perform decrypt on request number %u.", i);
9408                 /* free crypto operation structure */
9409                 if (ut_params->op)
9410                         rte_crypto_op_free(ut_params->op);
9411
9412                 /*
9413                  * free mbuf - both obuf and ibuf are usually the same,
9414                  * so check if they point at the same address is necessary,
9415                  * to avoid freeing the mbuf twice.
9416                  */
9417                 if (ut_params->obuf) {
9418                         rte_pktmbuf_free(ut_params->obuf);
9419                         if (ut_params->ibuf == ut_params->obuf)
9420                                 ut_params->ibuf = 0;
9421                         ut_params->obuf = 0;
9422                 }
9423                 if (ut_params->ibuf) {
9424                         rte_pktmbuf_free(ut_params->ibuf);
9425                         ut_params->ibuf = 0;
9426                 }
9427         }
9428
9429         /* Next session create should fail */
9430         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9431                         sessions[i], &ut_params->auth_xform,
9432                         ts_params->session_priv_mpool);
9433         TEST_ASSERT_NULL(sessions[i],
9434                         "Session creation succeeded unexpectedly!");
9435
9436         for (i = 0; i < MAX_NB_SESSIONS; i++) {
9437                 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9438                                 sessions[i]);
9439                 rte_cryptodev_sym_session_free(sessions[i]);
9440         }
9441
9442         rte_free(sessions);
9443
9444         return TEST_SUCCESS;
9445 }
9446
9447 struct multi_session_params {
9448         struct crypto_unittest_params ut_params;
9449         uint8_t *cipher_key;
9450         uint8_t *hmac_key;
9451         const uint8_t *cipher;
9452         const uint8_t *digest;
9453         uint8_t *iv;
9454 };
9455
9456 #define MB_SESSION_NUMBER 3
9457
9458 static int
9459 test_multi_session_random_usage(void)
9460 {
9461         struct crypto_testsuite_params *ts_params = &testsuite_params;
9462         struct rte_cryptodev_info dev_info;
9463         struct rte_cryptodev_sym_session **sessions;
9464         uint32_t i, j;
9465         struct multi_session_params ut_paramz[] = {
9466
9467                 {
9468                         .cipher_key = ms_aes_cbc_key0,
9469                         .hmac_key = ms_hmac_key0,
9470                         .cipher = ms_aes_cbc_cipher0,
9471                         .digest = ms_hmac_digest0,
9472                         .iv = ms_aes_cbc_iv0
9473                 },
9474                 {
9475                         .cipher_key = ms_aes_cbc_key1,
9476                         .hmac_key = ms_hmac_key1,
9477                         .cipher = ms_aes_cbc_cipher1,
9478                         .digest = ms_hmac_digest1,
9479                         .iv = ms_aes_cbc_iv1
9480                 },
9481                 {
9482                         .cipher_key = ms_aes_cbc_key2,
9483                         .hmac_key = ms_hmac_key2,
9484                         .cipher = ms_aes_cbc_cipher2,
9485                         .digest = ms_hmac_digest2,
9486                         .iv = ms_aes_cbc_iv2
9487                 },
9488
9489         };
9490
9491         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9492
9493         sessions = rte_malloc(NULL,
9494                         (sizeof(struct rte_cryptodev_sym_session *)
9495                                         * MAX_NB_SESSIONS) + 1, 0);
9496
9497         for (i = 0; i < MB_SESSION_NUMBER; i++) {
9498                 sessions[i] = rte_cryptodev_sym_session_create(
9499                                 ts_params->session_mpool);
9500
9501                 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9502                                 sizeof(struct crypto_unittest_params));
9503
9504                 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9505                                 &ut_paramz[i].ut_params,
9506                                 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9507
9508                 /* Create multiple crypto sessions*/
9509                 rte_cryptodev_sym_session_init(
9510                                 ts_params->valid_devs[0],
9511                                 sessions[i],
9512                                 &ut_paramz[i].ut_params.auth_xform,
9513                                 ts_params->session_priv_mpool);
9514
9515                 TEST_ASSERT_NOT_NULL(sessions[i],
9516                                 "Session creation failed at session number %u",
9517                                 i);
9518
9519         }
9520
9521         srand(time(NULL));
9522         for (i = 0; i < 40000; i++) {
9523
9524                 j = rand() % MB_SESSION_NUMBER;
9525
9526                 TEST_ASSERT_SUCCESS(
9527                         test_AES_CBC_HMAC_SHA512_decrypt_perform(
9528                                         sessions[j],
9529                                         &ut_paramz[j].ut_params,
9530                                         ts_params, ut_paramz[j].cipher,
9531                                         ut_paramz[j].digest,
9532                                         ut_paramz[j].iv),
9533                         "Failed to perform decrypt on request number %u.", i);
9534
9535                 if (ut_paramz[j].ut_params.op)
9536                         rte_crypto_op_free(ut_paramz[j].ut_params.op);
9537
9538                 /*
9539                  * free mbuf - both obuf and ibuf are usually the same,
9540                  * so check if they point at the same address is necessary,
9541                  * to avoid freeing the mbuf twice.
9542                  */
9543                 if (ut_paramz[j].ut_params.obuf) {
9544                         rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9545                         if (ut_paramz[j].ut_params.ibuf
9546                                         == ut_paramz[j].ut_params.obuf)
9547                                 ut_paramz[j].ut_params.ibuf = 0;
9548                         ut_paramz[j].ut_params.obuf = 0;
9549                 }
9550                 if (ut_paramz[j].ut_params.ibuf) {
9551                         rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9552                         ut_paramz[j].ut_params.ibuf = 0;
9553                 }
9554         }
9555
9556         for (i = 0; i < MB_SESSION_NUMBER; i++) {
9557                 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9558                                 sessions[i]);
9559                 rte_cryptodev_sym_session_free(sessions[i]);
9560         }
9561
9562         rte_free(sessions);
9563
9564         return TEST_SUCCESS;
9565 }
9566
9567 static int
9568 test_null_cipher_only_operation(void)
9569 {
9570         struct crypto_testsuite_params *ts_params = &testsuite_params;
9571         struct crypto_unittest_params *ut_params = &unittest_params;
9572
9573         /* Generate test mbuf data and space for digest */
9574         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9575                         catch_22_quote, QUOTE_512_BYTES, 0);
9576
9577         /* Setup Cipher Parameters */
9578         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9579         ut_params->cipher_xform.next = NULL;
9580
9581         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9582         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9583
9584         ut_params->sess = rte_cryptodev_sym_session_create(
9585                         ts_params->session_mpool);
9586
9587         /* Create Crypto session*/
9588         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9589                                 ut_params->sess,
9590                                 &ut_params->cipher_xform,
9591                                 ts_params->session_priv_mpool);
9592         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9593
9594         /* Generate Crypto op data structure */
9595         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9596                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9597         TEST_ASSERT_NOT_NULL(ut_params->op,
9598                         "Failed to allocate symmetric crypto operation struct");
9599
9600         /* Set crypto operation data parameters */
9601         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9602
9603         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9604
9605         /* set crypto operation source mbuf */
9606         sym_op->m_src = ut_params->ibuf;
9607
9608         sym_op->cipher.data.offset = 0;
9609         sym_op->cipher.data.length = QUOTE_512_BYTES;
9610
9611         /* Process crypto operation */
9612         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9613                         ut_params->op);
9614         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9615
9616         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9617                         "crypto operation processing failed");
9618
9619         /* Validate obuf */
9620         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9621                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9622                         catch_22_quote,
9623                         QUOTE_512_BYTES,
9624                         "Ciphertext data not as expected");
9625
9626         return TEST_SUCCESS;
9627 }
9628 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9629                         0xab, 0xab, 0xab, 0xab,
9630                         0xab, 0xab, 0xab, 0xab,
9631                         0xab, 0xab, 0xab, 0xab};
9632 static int
9633 test_null_auth_only_operation(void)
9634 {
9635         struct crypto_testsuite_params *ts_params = &testsuite_params;
9636         struct crypto_unittest_params *ut_params = &unittest_params;
9637         uint8_t *digest;
9638
9639         /* Generate test mbuf data and space for digest */
9640         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9641                         catch_22_quote, QUOTE_512_BYTES, 0);
9642
9643         /* create a pointer for digest, but don't expect anything to be written
9644          * here in a NULL auth algo so no mbuf append done.
9645          */
9646         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9647                         QUOTE_512_BYTES);
9648         /* prefill the memory pointed to by digest */
9649         memcpy(digest, orig_data, sizeof(orig_data));
9650
9651         /* Setup HMAC Parameters */
9652         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9653         ut_params->auth_xform.next = NULL;
9654
9655         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9656         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9657
9658         ut_params->sess = rte_cryptodev_sym_session_create(
9659                         ts_params->session_mpool);
9660
9661         /* Create Crypto session*/
9662         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9663                         ut_params->sess, &ut_params->auth_xform,
9664                         ts_params->session_priv_mpool);
9665         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9666
9667         /* Generate Crypto op data structure */
9668         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9669                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9670         TEST_ASSERT_NOT_NULL(ut_params->op,
9671                         "Failed to allocate symmetric crypto operation struct");
9672
9673         /* Set crypto operation data parameters */
9674         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9675
9676         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9677
9678         sym_op->m_src = ut_params->ibuf;
9679
9680         sym_op->auth.data.offset = 0;
9681         sym_op->auth.data.length = QUOTE_512_BYTES;
9682         sym_op->auth.digest.data = digest;
9683         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9684                         QUOTE_512_BYTES);
9685
9686         /* Process crypto operation */
9687         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9688                         ut_params->op);
9689         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9690
9691         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9692                         "crypto operation processing failed");
9693         /* Make sure memory pointed to by digest hasn't been overwritten */
9694         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9695                         orig_data,
9696                         digest,
9697                         sizeof(orig_data),
9698                         "Memory at digest ptr overwritten unexpectedly");
9699
9700         return TEST_SUCCESS;
9701 }
9702
9703
9704 static int
9705 test_null_cipher_auth_operation(void)
9706 {
9707         struct crypto_testsuite_params *ts_params = &testsuite_params;
9708         struct crypto_unittest_params *ut_params = &unittest_params;
9709         uint8_t *digest;
9710
9711         /* Generate test mbuf data and space for digest */
9712         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9713                         catch_22_quote, QUOTE_512_BYTES, 0);
9714
9715         /* create a pointer for digest, but don't expect anything to be written
9716          * here in a NULL auth algo so no mbuf append done.
9717          */
9718         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9719                         QUOTE_512_BYTES);
9720         /* prefill the memory pointed to by digest */
9721         memcpy(digest, orig_data, sizeof(orig_data));
9722
9723         /* Setup Cipher Parameters */
9724         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9725         ut_params->cipher_xform.next = &ut_params->auth_xform;
9726
9727         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9728         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9729
9730         /* Setup HMAC Parameters */
9731         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9732         ut_params->auth_xform.next = NULL;
9733
9734         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9735         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9736
9737         ut_params->sess = rte_cryptodev_sym_session_create(
9738                         ts_params->session_mpool);
9739
9740         /* Create Crypto session*/
9741         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9742                         ut_params->sess, &ut_params->cipher_xform,
9743                         ts_params->session_priv_mpool);
9744         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9745
9746         /* Generate Crypto op data structure */
9747         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9748                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9749         TEST_ASSERT_NOT_NULL(ut_params->op,
9750                         "Failed to allocate symmetric crypto operation struct");
9751
9752         /* Set crypto operation data parameters */
9753         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9754
9755         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9756
9757         sym_op->m_src = ut_params->ibuf;
9758
9759         sym_op->cipher.data.offset = 0;
9760         sym_op->cipher.data.length = QUOTE_512_BYTES;
9761
9762         sym_op->auth.data.offset = 0;
9763         sym_op->auth.data.length = QUOTE_512_BYTES;
9764         sym_op->auth.digest.data = digest;
9765         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9766                         QUOTE_512_BYTES);
9767
9768         /* Process crypto operation */
9769         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9770                         ut_params->op);
9771         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9772
9773         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9774                         "crypto operation processing failed");
9775
9776         /* Validate obuf */
9777         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9778                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9779                         catch_22_quote,
9780                         QUOTE_512_BYTES,
9781                         "Ciphertext data not as expected");
9782         /* Make sure memory pointed to by digest hasn't been overwritten */
9783         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9784                         orig_data,
9785                         digest,
9786                         sizeof(orig_data),
9787                         "Memory at digest ptr overwritten unexpectedly");
9788
9789         return TEST_SUCCESS;
9790 }
9791
9792 static int
9793 test_null_auth_cipher_operation(void)
9794 {
9795         struct crypto_testsuite_params *ts_params = &testsuite_params;
9796         struct crypto_unittest_params *ut_params = &unittest_params;
9797         uint8_t *digest;
9798
9799         /* Generate test mbuf data */
9800         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9801                         catch_22_quote, QUOTE_512_BYTES, 0);
9802
9803         /* create a pointer for digest, but don't expect anything to be written
9804          * here in a NULL auth algo so no mbuf append done.
9805          */
9806         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9807                                 QUOTE_512_BYTES);
9808         /* prefill the memory pointed to by digest */
9809         memcpy(digest, orig_data, sizeof(orig_data));
9810
9811         /* Setup Cipher Parameters */
9812         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9813         ut_params->cipher_xform.next = NULL;
9814
9815         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9816         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9817
9818         /* Setup HMAC Parameters */
9819         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9820         ut_params->auth_xform.next = &ut_params->cipher_xform;
9821
9822         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9823         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9824
9825         ut_params->sess = rte_cryptodev_sym_session_create(
9826                         ts_params->session_mpool);
9827
9828         /* Create Crypto session*/
9829         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9830                         ut_params->sess, &ut_params->cipher_xform,
9831                         ts_params->session_priv_mpool);
9832         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9833
9834         /* Generate Crypto op data structure */
9835         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9836                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9837         TEST_ASSERT_NOT_NULL(ut_params->op,
9838                         "Failed to allocate symmetric crypto operation struct");
9839
9840         /* Set crypto operation data parameters */
9841         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9842
9843         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9844
9845         sym_op->m_src = ut_params->ibuf;
9846
9847         sym_op->cipher.data.offset = 0;
9848         sym_op->cipher.data.length = QUOTE_512_BYTES;
9849
9850         sym_op->auth.data.offset = 0;
9851         sym_op->auth.data.length = QUOTE_512_BYTES;
9852         sym_op->auth.digest.data = digest;
9853         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9854                                         QUOTE_512_BYTES);
9855
9856         /* Process crypto operation */
9857         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9858                         ut_params->op);
9859         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9860
9861         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9862                         "crypto operation processing failed");
9863
9864         /* Validate obuf */
9865         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9866                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9867                         catch_22_quote,
9868                         QUOTE_512_BYTES,
9869                         "Ciphertext data not as expected");
9870         /* Make sure memory pointed to by digest hasn't been overwritten */
9871         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9872                         orig_data,
9873                         digest,
9874                         sizeof(orig_data),
9875                         "Memory at digest ptr overwritten unexpectedly");
9876
9877         return TEST_SUCCESS;
9878 }
9879
9880
9881 static int
9882 test_null_invalid_operation(void)
9883 {
9884         struct crypto_testsuite_params *ts_params = &testsuite_params;
9885         struct crypto_unittest_params *ut_params = &unittest_params;
9886         int ret;
9887
9888         /* Setup Cipher Parameters */
9889         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9890         ut_params->cipher_xform.next = NULL;
9891
9892         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9893         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9894
9895         ut_params->sess = rte_cryptodev_sym_session_create(
9896                         ts_params->session_mpool);
9897
9898         /* Create Crypto session*/
9899         ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9900                         ut_params->sess, &ut_params->cipher_xform,
9901                         ts_params->session_priv_mpool);
9902         TEST_ASSERT(ret < 0,
9903                         "Session creation succeeded unexpectedly");
9904
9905
9906         /* Setup HMAC Parameters */
9907         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9908         ut_params->auth_xform.next = NULL;
9909
9910         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9911         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9912
9913         ut_params->sess = rte_cryptodev_sym_session_create(
9914                         ts_params->session_mpool);
9915
9916         /* Create Crypto session*/
9917         ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9918                         ut_params->sess, &ut_params->auth_xform,
9919                         ts_params->session_priv_mpool);
9920         TEST_ASSERT(ret < 0,
9921                         "Session creation succeeded unexpectedly");
9922
9923         return TEST_SUCCESS;
9924 }
9925
9926
9927 #define NULL_BURST_LENGTH (32)
9928
9929 static int
9930 test_null_burst_operation(void)
9931 {
9932         struct crypto_testsuite_params *ts_params = &testsuite_params;
9933         struct crypto_unittest_params *ut_params = &unittest_params;
9934
9935         unsigned i, burst_len = NULL_BURST_LENGTH;
9936
9937         struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9938         struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9939
9940         /* Setup Cipher Parameters */
9941         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9942         ut_params->cipher_xform.next = &ut_params->auth_xform;
9943
9944         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9945         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9946
9947         /* Setup HMAC Parameters */
9948         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9949         ut_params->auth_xform.next = NULL;
9950
9951         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9952         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9953
9954         ut_params->sess = rte_cryptodev_sym_session_create(
9955                         ts_params->session_mpool);
9956
9957         /* Create Crypto session*/
9958         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9959                         ut_params->sess, &ut_params->cipher_xform,
9960                         ts_params->session_priv_mpool);
9961         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9962
9963         TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9964                         RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9965                         burst_len, "failed to generate burst of crypto ops");
9966
9967         /* Generate an operation for each mbuf in burst */
9968         for (i = 0; i < burst_len; i++) {
9969                 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9970
9971                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9972
9973                 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9974                                 sizeof(unsigned));
9975                 *data = i;
9976
9977                 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9978
9979                 burst[i]->sym->m_src = m;
9980         }
9981
9982         /* Process crypto operation */
9983         TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9984                         0, burst, burst_len),
9985                         burst_len,
9986                         "Error enqueuing burst");
9987
9988         TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9989                         0, burst_dequeued, burst_len),
9990                         burst_len,
9991                         "Error dequeuing burst");
9992
9993
9994         for (i = 0; i < burst_len; i++) {
9995                 TEST_ASSERT_EQUAL(
9996                         *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9997                         *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9998                                         uint32_t *),
9999                         "data not as expected");
10000
10001                 rte_pktmbuf_free(burst[i]->sym->m_src);
10002                 rte_crypto_op_free(burst[i]);
10003         }
10004
10005         return TEST_SUCCESS;
10006 }
10007
10008 static void
10009 generate_gmac_large_plaintext(uint8_t *data)
10010 {
10011         uint16_t i;
10012
10013         for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10014                 memcpy(&data[i], &data[0], 32);
10015 }
10016
10017 static int
10018 create_gmac_operation(enum rte_crypto_auth_operation op,
10019                 const struct gmac_test_data *tdata)
10020 {
10021         struct crypto_testsuite_params *ts_params = &testsuite_params;
10022         struct crypto_unittest_params *ut_params = &unittest_params;
10023         struct rte_crypto_sym_op *sym_op;
10024
10025         uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10026
10027         /* Generate Crypto op data structure */
10028         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10029                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10030         TEST_ASSERT_NOT_NULL(ut_params->op,
10031                         "Failed to allocate symmetric crypto operation struct");
10032
10033         sym_op = ut_params->op->sym;
10034
10035         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10036                         ut_params->ibuf, tdata->gmac_tag.len);
10037         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10038                         "no room to append digest");
10039
10040         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10041                         ut_params->ibuf, plaintext_pad_len);
10042
10043         if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10044                 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10045                                 tdata->gmac_tag.len);
10046                 debug_hexdump(stdout, "digest:",
10047                                 sym_op->auth.digest.data,
10048                                 tdata->gmac_tag.len);
10049         }
10050
10051         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10052                         uint8_t *, IV_OFFSET);
10053
10054         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10055
10056         debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10057
10058         sym_op->cipher.data.length = 0;
10059         sym_op->cipher.data.offset = 0;
10060
10061         sym_op->auth.data.offset = 0;
10062         sym_op->auth.data.length = tdata->plaintext.len;
10063
10064         return 0;
10065 }
10066
10067 static int create_gmac_session(uint8_t dev_id,
10068                 const struct gmac_test_data *tdata,
10069                 enum rte_crypto_auth_operation auth_op)
10070 {
10071         uint8_t auth_key[tdata->key.len];
10072
10073         struct crypto_testsuite_params *ts_params = &testsuite_params;
10074         struct crypto_unittest_params *ut_params = &unittest_params;
10075
10076         memcpy(auth_key, tdata->key.data, tdata->key.len);
10077
10078         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10079         ut_params->auth_xform.next = NULL;
10080
10081         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10082         ut_params->auth_xform.auth.op = auth_op;
10083         ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10084         ut_params->auth_xform.auth.key.length = tdata->key.len;
10085         ut_params->auth_xform.auth.key.data = auth_key;
10086         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10087         ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10088
10089
10090         ut_params->sess = rte_cryptodev_sym_session_create(
10091                         ts_params->session_mpool);
10092
10093         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10094                         &ut_params->auth_xform,
10095                         ts_params->session_priv_mpool);
10096
10097         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10098
10099         return 0;
10100 }
10101
10102 static int
10103 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10104 {
10105         struct crypto_testsuite_params *ts_params = &testsuite_params;
10106         struct crypto_unittest_params *ut_params = &unittest_params;
10107
10108         int retval;
10109
10110         uint8_t *auth_tag, *plaintext;
10111         uint16_t plaintext_pad_len;
10112
10113         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10114                               "No GMAC length in the source data");
10115
10116         retval = create_gmac_session(ts_params->valid_devs[0],
10117                         tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10118
10119         if (retval < 0)
10120                 return retval;
10121
10122         if (tdata->plaintext.len > MBUF_SIZE)
10123                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10124         else
10125                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10126         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10127                         "Failed to allocate input buffer in mempool");
10128
10129         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10130                         rte_pktmbuf_tailroom(ut_params->ibuf));
10131
10132         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10133         /*
10134          * Runtime generate the large plain text instead of use hard code
10135          * plain text vector. It is done to avoid create huge source file
10136          * with the test vector.
10137          */
10138         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10139                 generate_gmac_large_plaintext(tdata->plaintext.data);
10140
10141         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10142                                 plaintext_pad_len);
10143         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10144
10145         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10146         debug_hexdump(stdout, "plaintext:", plaintext,
10147                         tdata->plaintext.len);
10148
10149         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10150                         tdata);
10151
10152         if (retval < 0)
10153                 return retval;
10154
10155         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10156
10157         ut_params->op->sym->m_src = ut_params->ibuf;
10158
10159         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10160                         ut_params->op), "failed to process sym crypto op");
10161
10162         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10163                         "crypto op processing failed");
10164
10165         if (ut_params->op->sym->m_dst) {
10166                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10167                                 uint8_t *, plaintext_pad_len);
10168         } else {
10169                 auth_tag = plaintext + plaintext_pad_len;
10170         }
10171
10172         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10173
10174         TEST_ASSERT_BUFFERS_ARE_EQUAL(
10175                         auth_tag,
10176                         tdata->gmac_tag.data,
10177                         tdata->gmac_tag.len,
10178                         "GMAC Generated auth tag not as expected");
10179
10180         return 0;
10181 }
10182
10183 static int
10184 test_AES_GMAC_authentication_test_case_1(void)
10185 {
10186         return test_AES_GMAC_authentication(&gmac_test_case_1);
10187 }
10188
10189 static int
10190 test_AES_GMAC_authentication_test_case_2(void)
10191 {
10192         return test_AES_GMAC_authentication(&gmac_test_case_2);
10193 }
10194
10195 static int
10196 test_AES_GMAC_authentication_test_case_3(void)
10197 {
10198         return test_AES_GMAC_authentication(&gmac_test_case_3);
10199 }
10200
10201 static int
10202 test_AES_GMAC_authentication_test_case_4(void)
10203 {
10204         return test_AES_GMAC_authentication(&gmac_test_case_4);
10205 }
10206
10207 static int
10208 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10209 {
10210         struct crypto_testsuite_params *ts_params = &testsuite_params;
10211         struct crypto_unittest_params *ut_params = &unittest_params;
10212         int retval;
10213         uint32_t plaintext_pad_len;
10214         uint8_t *plaintext;
10215
10216         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10217                               "No GMAC length in the source data");
10218
10219         retval = create_gmac_session(ts_params->valid_devs[0],
10220                         tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10221
10222         if (retval < 0)
10223                 return retval;
10224
10225         if (tdata->plaintext.len > MBUF_SIZE)
10226                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10227         else
10228                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10229         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10230                         "Failed to allocate input buffer in mempool");
10231
10232         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10233                         rte_pktmbuf_tailroom(ut_params->ibuf));
10234
10235         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10236
10237         /*
10238          * Runtime generate the large plain text instead of use hard code
10239          * plain text vector. It is done to avoid create huge source file
10240          * with the test vector.
10241          */
10242         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10243                 generate_gmac_large_plaintext(tdata->plaintext.data);
10244
10245         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10246                                 plaintext_pad_len);
10247         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10248
10249         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10250         debug_hexdump(stdout, "plaintext:", plaintext,
10251                         tdata->plaintext.len);
10252
10253         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10254                         tdata);
10255
10256         if (retval < 0)
10257                 return retval;
10258
10259         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10260
10261         ut_params->op->sym->m_src = ut_params->ibuf;
10262
10263         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10264                         ut_params->op), "failed to process sym crypto op");
10265
10266         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10267                         "crypto op processing failed");
10268
10269         return 0;
10270
10271 }
10272
10273 static int
10274 test_AES_GMAC_authentication_verify_test_case_1(void)
10275 {
10276         return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10277 }
10278
10279 static int
10280 test_AES_GMAC_authentication_verify_test_case_2(void)
10281 {
10282         return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10283 }
10284
10285 static int
10286 test_AES_GMAC_authentication_verify_test_case_3(void)
10287 {
10288         return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10289 }
10290
10291 static int
10292 test_AES_GMAC_authentication_verify_test_case_4(void)
10293 {
10294         return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10295 }
10296
10297 struct test_crypto_vector {
10298         enum rte_crypto_cipher_algorithm crypto_algo;
10299         unsigned int cipher_offset;
10300         unsigned int cipher_len;
10301
10302         struct {
10303                 uint8_t data[64];
10304                 unsigned int len;
10305         } cipher_key;
10306
10307         struct {
10308                 uint8_t data[64];
10309                 unsigned int len;
10310         } iv;
10311
10312         struct {
10313                 const uint8_t *data;
10314                 unsigned int len;
10315         } plaintext;
10316
10317         struct {
10318                 const uint8_t *data;
10319                 unsigned int len;
10320         } ciphertext;
10321
10322         enum rte_crypto_auth_algorithm auth_algo;
10323         unsigned int auth_offset;
10324
10325         struct {
10326                 uint8_t data[128];
10327                 unsigned int len;
10328         } auth_key;
10329
10330         struct {
10331                 const uint8_t *data;
10332                 unsigned int len;
10333         } aad;
10334
10335         struct {
10336                 uint8_t data[128];
10337                 unsigned int len;
10338         } digest;
10339 };
10340
10341 static const struct test_crypto_vector
10342 hmac_sha1_test_crypto_vector = {
10343         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10344         .plaintext = {
10345                 .data = plaintext_hash,
10346                 .len = 512
10347         },
10348         .auth_key = {
10349                 .data = {
10350                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10351                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10352                         0xDE, 0xF4, 0xDE, 0xAD
10353                 },
10354                 .len = 20
10355         },
10356         .digest = {
10357                 .data = {
10358                         0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10359                         0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10360                         0x3F, 0x91, 0x64, 0x59
10361                 },
10362                 .len = 20
10363         }
10364 };
10365
10366 static const struct test_crypto_vector
10367 aes128_gmac_test_vector = {
10368         .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10369         .plaintext = {
10370                 .data = plaintext_hash,
10371                 .len = 512
10372         },
10373         .iv = {
10374                 .data = {
10375                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10376                         0x08, 0x09, 0x0A, 0x0B
10377                 },
10378                 .len = 12
10379         },
10380         .auth_key = {
10381                 .data = {
10382                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10383                         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10384                 },
10385                 .len = 16
10386         },
10387         .digest = {
10388                 .data = {
10389                         0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10390                         0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10391                 },
10392                 .len = 16
10393         }
10394 };
10395
10396 static const struct test_crypto_vector
10397 aes128cbc_hmac_sha1_test_vector = {
10398         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10399         .cipher_offset = 0,
10400         .cipher_len = 512,
10401         .cipher_key = {
10402                 .data = {
10403                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10404                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10405                 },
10406                 .len = 16
10407         },
10408         .iv = {
10409                 .data = {
10410                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10411                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10412                 },
10413                 .len = 16
10414         },
10415         .plaintext = {
10416                 .data = plaintext_hash,
10417                 .len = 512
10418         },
10419         .ciphertext = {
10420                 .data = ciphertext512_aes128cbc,
10421                 .len = 512
10422         },
10423         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10424         .auth_offset = 0,
10425         .auth_key = {
10426                 .data = {
10427                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10428                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10429                         0xDE, 0xF4, 0xDE, 0xAD
10430                 },
10431                 .len = 20
10432         },
10433         .digest = {
10434                 .data = {
10435                         0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10436                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10437                         0x18, 0x8C, 0x1D, 0x32
10438                 },
10439                 .len = 20
10440         }
10441 };
10442
10443 static const struct test_crypto_vector
10444 aes128cbc_hmac_sha1_aad_test_vector = {
10445         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10446         .cipher_offset = 12,
10447         .cipher_len = 496,
10448         .cipher_key = {
10449                 .data = {
10450                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10451                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10452                 },
10453                 .len = 16
10454         },
10455         .iv = {
10456                 .data = {
10457                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10458                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10459                 },
10460                 .len = 16
10461         },
10462         .plaintext = {
10463                 .data = plaintext_hash,
10464                 .len = 512
10465         },
10466         .ciphertext = {
10467                 .data = ciphertext512_aes128cbc_aad,
10468                 .len = 512
10469         },
10470         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10471         .auth_offset = 0,
10472         .auth_key = {
10473                 .data = {
10474                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10475                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10476                         0xDE, 0xF4, 0xDE, 0xAD
10477                 },
10478                 .len = 20
10479         },
10480         .digest = {
10481                 .data = {
10482                         0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10483                         0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10484                         0x62, 0x8D, 0x62, 0x65
10485                 },
10486                 .len = 20
10487         }
10488 };
10489
10490 static void
10491 data_corruption(uint8_t *data)
10492 {
10493         data[0] += 1;
10494 }
10495
10496 static void
10497 tag_corruption(uint8_t *data, unsigned int tag_offset)
10498 {
10499         data[tag_offset] += 1;
10500 }
10501
10502 static int
10503 create_auth_session(struct crypto_unittest_params *ut_params,
10504                 uint8_t dev_id,
10505                 const struct test_crypto_vector *reference,
10506                 enum rte_crypto_auth_operation auth_op)
10507 {
10508         struct crypto_testsuite_params *ts_params = &testsuite_params;
10509         uint8_t auth_key[reference->auth_key.len + 1];
10510
10511         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10512
10513         /* Setup Authentication Parameters */
10514         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10515         ut_params->auth_xform.auth.op = auth_op;
10516         ut_params->auth_xform.next = NULL;
10517         ut_params->auth_xform.auth.algo = reference->auth_algo;
10518         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10519         ut_params->auth_xform.auth.key.data = auth_key;
10520         ut_params->auth_xform.auth.digest_length = reference->digest.len;
10521
10522         /* Create Crypto session*/
10523         ut_params->sess = rte_cryptodev_sym_session_create(
10524                         ts_params->session_mpool);
10525
10526         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10527                                 &ut_params->auth_xform,
10528                                 ts_params->session_priv_mpool);
10529
10530         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10531
10532         return 0;
10533 }
10534
10535 static int
10536 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10537                 uint8_t dev_id,
10538                 const struct test_crypto_vector *reference,
10539                 enum rte_crypto_auth_operation auth_op,
10540                 enum rte_crypto_cipher_operation cipher_op)
10541 {
10542         struct crypto_testsuite_params *ts_params = &testsuite_params;
10543         uint8_t cipher_key[reference->cipher_key.len + 1];
10544         uint8_t auth_key[reference->auth_key.len + 1];
10545
10546         memcpy(cipher_key, reference->cipher_key.data,
10547                         reference->cipher_key.len);
10548         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10549
10550         /* Setup Authentication Parameters */
10551         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10552         ut_params->auth_xform.auth.op = auth_op;
10553         ut_params->auth_xform.auth.algo = reference->auth_algo;
10554         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10555         ut_params->auth_xform.auth.key.data = auth_key;
10556         ut_params->auth_xform.auth.digest_length = reference->digest.len;
10557
10558         if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10559                 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10560                 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10561         } else {
10562                 ut_params->auth_xform.next = &ut_params->cipher_xform;
10563
10564                 /* Setup Cipher Parameters */
10565                 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10566                 ut_params->cipher_xform.next = NULL;
10567                 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10568                 ut_params->cipher_xform.cipher.op = cipher_op;
10569                 ut_params->cipher_xform.cipher.key.data = cipher_key;
10570                 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10571                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10572                 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10573         }
10574
10575         /* Create Crypto session*/
10576         ut_params->sess = rte_cryptodev_sym_session_create(
10577                         ts_params->session_mpool);
10578
10579         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10580                                 &ut_params->auth_xform,
10581                                 ts_params->session_priv_mpool);
10582
10583         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10584
10585         return 0;
10586 }
10587
10588 static int
10589 create_auth_operation(struct crypto_testsuite_params *ts_params,
10590                 struct crypto_unittest_params *ut_params,
10591                 const struct test_crypto_vector *reference,
10592                 unsigned int auth_generate)
10593 {
10594         /* Generate Crypto op data structure */
10595         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10596                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10597         TEST_ASSERT_NOT_NULL(ut_params->op,
10598                         "Failed to allocate pktmbuf offload");
10599
10600         /* Set crypto operation data parameters */
10601         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10602
10603         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10604
10605         /* set crypto operation source mbuf */
10606         sym_op->m_src = ut_params->ibuf;
10607
10608         /* digest */
10609         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10610                         ut_params->ibuf, reference->digest.len);
10611
10612         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10613                         "no room to append auth tag");
10614
10615         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10616                         ut_params->ibuf, reference->plaintext.len);
10617
10618         if (auth_generate)
10619                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10620         else
10621                 memcpy(sym_op->auth.digest.data,
10622                                 reference->digest.data,
10623                                 reference->digest.len);
10624
10625         debug_hexdump(stdout, "digest:",
10626                         sym_op->auth.digest.data,
10627                         reference->digest.len);
10628
10629         sym_op->auth.data.length = reference->plaintext.len;
10630         sym_op->auth.data.offset = 0;
10631
10632         return 0;
10633 }
10634
10635 static int
10636 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10637                 struct crypto_unittest_params *ut_params,
10638                 const struct test_crypto_vector *reference,
10639                 unsigned int auth_generate)
10640 {
10641         /* Generate Crypto op data structure */
10642         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10643                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10644         TEST_ASSERT_NOT_NULL(ut_params->op,
10645                         "Failed to allocate pktmbuf offload");
10646
10647         /* Set crypto operation data parameters */
10648         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10649
10650         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10651
10652         /* set crypto operation source mbuf */
10653         sym_op->m_src = ut_params->ibuf;
10654
10655         /* digest */
10656         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10657                         ut_params->ibuf, reference->digest.len);
10658
10659         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10660                         "no room to append auth tag");
10661
10662         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10663                         ut_params->ibuf, reference->ciphertext.len);
10664
10665         if (auth_generate)
10666                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10667         else
10668                 memcpy(sym_op->auth.digest.data,
10669                                 reference->digest.data,
10670                                 reference->digest.len);
10671
10672         debug_hexdump(stdout, "digest:",
10673                         sym_op->auth.digest.data,
10674                         reference->digest.len);
10675
10676         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10677                         reference->iv.data, reference->iv.len);
10678
10679         sym_op->cipher.data.length = 0;
10680         sym_op->cipher.data.offset = 0;
10681
10682         sym_op->auth.data.length = reference->plaintext.len;
10683         sym_op->auth.data.offset = 0;
10684
10685         return 0;
10686 }
10687
10688 static int
10689 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10690                 struct crypto_unittest_params *ut_params,
10691                 const struct test_crypto_vector *reference,
10692                 unsigned int auth_generate)
10693 {
10694         /* Generate Crypto op data structure */
10695         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10696                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10697         TEST_ASSERT_NOT_NULL(ut_params->op,
10698                         "Failed to allocate pktmbuf offload");
10699
10700         /* Set crypto operation data parameters */
10701         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10702
10703         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10704
10705         /* set crypto operation source mbuf */
10706         sym_op->m_src = ut_params->ibuf;
10707
10708         /* digest */
10709         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10710                         ut_params->ibuf, reference->digest.len);
10711
10712         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10713                         "no room to append auth tag");
10714
10715         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10716                         ut_params->ibuf, reference->ciphertext.len);
10717
10718         if (auth_generate)
10719                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10720         else
10721                 memcpy(sym_op->auth.digest.data,
10722                                 reference->digest.data,
10723                                 reference->digest.len);
10724
10725         debug_hexdump(stdout, "digest:",
10726                         sym_op->auth.digest.data,
10727                         reference->digest.len);
10728
10729         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10730                         reference->iv.data, reference->iv.len);
10731
10732         sym_op->cipher.data.length = reference->cipher_len;
10733         sym_op->cipher.data.offset = reference->cipher_offset;
10734
10735         sym_op->auth.data.length = reference->plaintext.len;
10736         sym_op->auth.data.offset = reference->auth_offset;
10737
10738         return 0;
10739 }
10740
10741 static int
10742 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10743                 struct crypto_unittest_params *ut_params,
10744                 const struct test_crypto_vector *reference)
10745 {
10746         return create_auth_operation(ts_params, ut_params, reference, 0);
10747 }
10748
10749 static int
10750 create_auth_verify_GMAC_operation(
10751                 struct crypto_testsuite_params *ts_params,
10752                 struct crypto_unittest_params *ut_params,
10753                 const struct test_crypto_vector *reference)
10754 {
10755         return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10756 }
10757
10758 static int
10759 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10760                 struct crypto_unittest_params *ut_params,
10761                 const struct test_crypto_vector *reference)
10762 {
10763         return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10764 }
10765
10766 static int
10767 test_authentication_verify_fail_when_data_corruption(
10768                 struct crypto_testsuite_params *ts_params,
10769                 struct crypto_unittest_params *ut_params,
10770                 const struct test_crypto_vector *reference,
10771                 unsigned int data_corrupted)
10772 {
10773         int retval;
10774
10775         uint8_t *plaintext;
10776
10777         /* Create session */
10778         retval = create_auth_session(ut_params,
10779                         ts_params->valid_devs[0],
10780                         reference,
10781                         RTE_CRYPTO_AUTH_OP_VERIFY);
10782         if (retval < 0)
10783                 return retval;
10784
10785         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10786         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10787                         "Failed to allocate input buffer in mempool");
10788
10789         /* clear mbuf payload */
10790         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10791                         rte_pktmbuf_tailroom(ut_params->ibuf));
10792
10793         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10794                         reference->plaintext.len);
10795         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10796         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10797
10798         debug_hexdump(stdout, "plaintext:", plaintext,
10799                 reference->plaintext.len);
10800
10801         /* Create operation */
10802         retval = create_auth_verify_operation(ts_params, ut_params, reference);
10803
10804         if (retval < 0)
10805                 return retval;
10806
10807         if (data_corrupted)
10808                 data_corruption(plaintext);
10809         else
10810                 tag_corruption(plaintext, reference->plaintext.len);
10811
10812         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10813                         ut_params->op);
10814         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10815         TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10816                         RTE_CRYPTO_OP_STATUS_SUCCESS,
10817                         "authentication not failed");
10818
10819         ut_params->obuf = ut_params->op->sym->m_src;
10820         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10821
10822         return 0;
10823 }
10824
10825 static int
10826 test_authentication_verify_GMAC_fail_when_corruption(
10827                 struct crypto_testsuite_params *ts_params,
10828                 struct crypto_unittest_params *ut_params,
10829                 const struct test_crypto_vector *reference,
10830                 unsigned int data_corrupted)
10831 {
10832         int retval;
10833         uint8_t *plaintext;
10834
10835         /* Create session */
10836         retval = create_auth_cipher_session(ut_params,
10837                         ts_params->valid_devs[0],
10838                         reference,
10839                         RTE_CRYPTO_AUTH_OP_VERIFY,
10840                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
10841         if (retval < 0)
10842                 return retval;
10843
10844         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10845         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10846                         "Failed to allocate input buffer in mempool");
10847
10848         /* clear mbuf payload */
10849         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10850                         rte_pktmbuf_tailroom(ut_params->ibuf));
10851
10852         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10853                         reference->plaintext.len);
10854         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10855         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10856
10857         debug_hexdump(stdout, "plaintext:", plaintext,
10858                 reference->plaintext.len);
10859
10860         /* Create operation */
10861         retval = create_auth_verify_GMAC_operation(ts_params,
10862                         ut_params,
10863                         reference);
10864
10865         if (retval < 0)
10866                 return retval;
10867
10868         if (data_corrupted)
10869                 data_corruption(plaintext);
10870         else
10871                 tag_corruption(plaintext, reference->aad.len);
10872
10873         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10874                         ut_params->op);
10875         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10876         TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10877                         RTE_CRYPTO_OP_STATUS_SUCCESS,
10878                         "authentication not failed");
10879
10880         ut_params->obuf = ut_params->op->sym->m_src;
10881         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10882
10883         return 0;
10884 }
10885
10886 static int
10887 test_authenticated_decryption_fail_when_corruption(
10888                 struct crypto_testsuite_params *ts_params,
10889                 struct crypto_unittest_params *ut_params,
10890                 const struct test_crypto_vector *reference,
10891                 unsigned int data_corrupted)
10892 {
10893         int retval;
10894
10895         uint8_t *ciphertext;
10896
10897         /* Create session */
10898         retval = create_auth_cipher_session(ut_params,
10899                         ts_params->valid_devs[0],
10900                         reference,
10901                         RTE_CRYPTO_AUTH_OP_VERIFY,
10902                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
10903         if (retval < 0)
10904                 return retval;
10905
10906         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10907         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10908                         "Failed to allocate input buffer in mempool");
10909
10910         /* clear mbuf payload */
10911         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10912                         rte_pktmbuf_tailroom(ut_params->ibuf));
10913
10914         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10915                         reference->ciphertext.len);
10916         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10917         memcpy(ciphertext, reference->ciphertext.data,
10918                         reference->ciphertext.len);
10919
10920         /* Create operation */
10921         retval = create_cipher_auth_verify_operation(ts_params,
10922                         ut_params,
10923                         reference);
10924
10925         if (retval < 0)
10926                 return retval;
10927
10928         if (data_corrupted)
10929                 data_corruption(ciphertext);
10930         else
10931                 tag_corruption(ciphertext, reference->ciphertext.len);
10932
10933         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10934                         ut_params->op);
10935
10936         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10937         TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10938                         RTE_CRYPTO_OP_STATUS_SUCCESS,
10939                         "authentication not failed");
10940
10941         ut_params->obuf = ut_params->op->sym->m_src;
10942         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10943
10944         return 0;
10945 }
10946
10947 static int
10948 test_authenticated_encryt_with_esn(
10949                 struct crypto_testsuite_params *ts_params,
10950                 struct crypto_unittest_params *ut_params,
10951                 const struct test_crypto_vector *reference)
10952 {
10953         int retval;
10954
10955         uint8_t *authciphertext, *plaintext, *auth_tag;
10956         uint16_t plaintext_pad_len;
10957         uint8_t cipher_key[reference->cipher_key.len + 1];
10958         uint8_t auth_key[reference->auth_key.len + 1];
10959
10960         /* Create session */
10961         memcpy(cipher_key, reference->cipher_key.data,
10962                         reference->cipher_key.len);
10963         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10964
10965         /* Setup Cipher Parameters */
10966         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10967         ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10968         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10969         ut_params->cipher_xform.cipher.key.data = cipher_key;
10970         ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10971         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10972         ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10973
10974         ut_params->cipher_xform.next = &ut_params->auth_xform;
10975
10976         /* Setup Authentication Parameters */
10977         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10978         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10979         ut_params->auth_xform.auth.algo = reference->auth_algo;
10980         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10981         ut_params->auth_xform.auth.key.data = auth_key;
10982         ut_params->auth_xform.auth.digest_length = reference->digest.len;
10983         ut_params->auth_xform.next = NULL;
10984
10985         /* Create Crypto session*/
10986         ut_params->sess = rte_cryptodev_sym_session_create(
10987                         ts_params->session_mpool);
10988
10989         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10990                                 ut_params->sess,
10991                                 &ut_params->cipher_xform,
10992                                 ts_params->session_priv_mpool);
10993
10994         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10995
10996         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10997         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10998                         "Failed to allocate input buffer in mempool");
10999
11000         /* clear mbuf payload */
11001         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11002                         rte_pktmbuf_tailroom(ut_params->ibuf));
11003
11004         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11005                         reference->plaintext.len);
11006         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11007         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11008
11009         /* Create operation */
11010         retval = create_cipher_auth_operation(ts_params,
11011                         ut_params,
11012                         reference, 0);
11013
11014         if (retval < 0)
11015                 return retval;
11016
11017         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11018                         ut_params->op);
11019
11020         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11021
11022         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11023                         "crypto op processing failed");
11024
11025         plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11026
11027         authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11028                         ut_params->op->sym->auth.data.offset);
11029         auth_tag = authciphertext + plaintext_pad_len;
11030         debug_hexdump(stdout, "ciphertext:", authciphertext,
11031                         reference->ciphertext.len);
11032         debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11033
11034         /* Validate obuf */
11035         TEST_ASSERT_BUFFERS_ARE_EQUAL(
11036                         authciphertext,
11037                         reference->ciphertext.data,
11038                         reference->ciphertext.len,
11039                         "Ciphertext data not as expected");
11040
11041         TEST_ASSERT_BUFFERS_ARE_EQUAL(
11042                         auth_tag,
11043                         reference->digest.data,
11044                         reference->digest.len,
11045                         "Generated digest not as expected");
11046
11047         return TEST_SUCCESS;
11048
11049 }
11050
11051 static int
11052 test_authenticated_decrypt_with_esn(
11053                 struct crypto_testsuite_params *ts_params,
11054                 struct crypto_unittest_params *ut_params,
11055                 const struct test_crypto_vector *reference)
11056 {
11057         int retval;
11058
11059         uint8_t *ciphertext;
11060         uint8_t cipher_key[reference->cipher_key.len + 1];
11061         uint8_t auth_key[reference->auth_key.len + 1];
11062
11063         /* Create session */
11064         memcpy(cipher_key, reference->cipher_key.data,
11065                         reference->cipher_key.len);
11066         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11067
11068         /* Setup Authentication Parameters */
11069         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11070         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11071         ut_params->auth_xform.auth.algo = reference->auth_algo;
11072         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11073         ut_params->auth_xform.auth.key.data = auth_key;
11074         ut_params->auth_xform.auth.digest_length = reference->digest.len;
11075         ut_params->auth_xform.next = &ut_params->cipher_xform;
11076
11077         /* Setup Cipher Parameters */
11078         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11079         ut_params->cipher_xform.next = NULL;
11080         ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11081         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11082         ut_params->cipher_xform.cipher.key.data = cipher_key;
11083         ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11084         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11085         ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11086
11087         /* Create Crypto session*/
11088         ut_params->sess = rte_cryptodev_sym_session_create(
11089                         ts_params->session_mpool);
11090
11091         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11092                                 ut_params->sess,
11093                                 &ut_params->auth_xform,
11094                                 ts_params->session_priv_mpool);
11095
11096         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11097
11098         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11099         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11100                         "Failed to allocate input buffer in mempool");
11101
11102         /* clear mbuf payload */
11103         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11104                         rte_pktmbuf_tailroom(ut_params->ibuf));
11105
11106         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11107                         reference->ciphertext.len);
11108         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11109         memcpy(ciphertext, reference->ciphertext.data,
11110                         reference->ciphertext.len);
11111
11112         /* Create operation */
11113         retval = create_cipher_auth_verify_operation(ts_params,
11114                         ut_params,
11115                         reference);
11116
11117         if (retval < 0)
11118                 return retval;
11119
11120         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11121                         ut_params->op);
11122
11123         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11124         TEST_ASSERT_EQUAL(ut_params->op->status,
11125                         RTE_CRYPTO_OP_STATUS_SUCCESS,
11126                         "crypto op processing passed");
11127
11128         ut_params->obuf = ut_params->op->sym->m_src;
11129         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11130
11131         return 0;
11132 }
11133
11134 static int
11135 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11136                 const struct aead_test_data *tdata,
11137                 void *digest_mem, uint64_t digest_phys)
11138 {
11139         struct crypto_testsuite_params *ts_params = &testsuite_params;
11140         struct crypto_unittest_params *ut_params = &unittest_params;
11141
11142         const unsigned int auth_tag_len = tdata->auth_tag.len;
11143         const unsigned int iv_len = tdata->iv.len;
11144         unsigned int aad_len = tdata->aad.len;
11145
11146         /* Generate Crypto op data structure */
11147         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11148                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11149         TEST_ASSERT_NOT_NULL(ut_params->op,
11150                 "Failed to allocate symmetric crypto operation struct");
11151
11152         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11153
11154         sym_op->aead.digest.data = digest_mem;
11155
11156         TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11157                         "no room to append digest");
11158
11159         sym_op->aead.digest.phys_addr = digest_phys;
11160
11161         if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11162                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11163                                 auth_tag_len);
11164                 debug_hexdump(stdout, "digest:",
11165                                 sym_op->aead.digest.data,
11166                                 auth_tag_len);
11167         }
11168
11169         /* Append aad data */
11170         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11171                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11172                                 uint8_t *, IV_OFFSET);
11173
11174                 /* Copy IV 1 byte after the IV pointer, according to the API */
11175                 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11176
11177                 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11178
11179                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11180                                 ut_params->ibuf, aad_len);
11181                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11182                                 "no room to prepend aad");
11183                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11184                                 ut_params->ibuf);
11185
11186                 memset(sym_op->aead.aad.data, 0, aad_len);
11187                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11188                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11189
11190                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11191                 debug_hexdump(stdout, "aad:",
11192                                 sym_op->aead.aad.data, aad_len);
11193         } else {
11194                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11195                                 uint8_t *, IV_OFFSET);
11196
11197                 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11198
11199                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11200                                 ut_params->ibuf, aad_len);
11201                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11202                                 "no room to prepend aad");
11203                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11204                                 ut_params->ibuf);
11205
11206                 memset(sym_op->aead.aad.data, 0, aad_len);
11207                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11208
11209                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11210                 debug_hexdump(stdout, "aad:",
11211                                 sym_op->aead.aad.data, aad_len);
11212         }
11213
11214         sym_op->aead.data.length = tdata->plaintext.len;
11215         sym_op->aead.data.offset = aad_len;
11216
11217         return 0;
11218 }
11219
11220 #define SGL_MAX_NO      16
11221
11222 static int
11223 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11224                 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11225 {
11226         struct crypto_testsuite_params *ts_params = &testsuite_params;
11227         struct crypto_unittest_params *ut_params = &unittest_params;
11228         struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11229         int retval;
11230         int to_trn = 0;
11231         int to_trn_tbl[SGL_MAX_NO];
11232         int segs = 1;
11233         unsigned int trn_data = 0;
11234         uint8_t *plaintext, *ciphertext, *auth_tag;
11235
11236         if (fragsz > tdata->plaintext.len)
11237                 fragsz = tdata->plaintext.len;
11238
11239         uint16_t plaintext_len = fragsz;
11240         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11241
11242         if (fragsz_oop > tdata->plaintext.len)
11243                 frag_size_oop = tdata->plaintext.len;
11244
11245         int ecx = 0;
11246         void *digest_mem = NULL;
11247
11248         uint32_t prepend_len = tdata->aad.len;
11249
11250         if (tdata->plaintext.len % fragsz != 0) {
11251                 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11252                         return 1;
11253         }       else {
11254                 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11255                         return 1;
11256         }
11257
11258         /*
11259          * For out-op-place we need to alloc another mbuf
11260          */
11261         if (oop) {
11262                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11263                 rte_pktmbuf_append(ut_params->obuf,
11264                                 frag_size_oop + prepend_len);
11265                 buf_oop = ut_params->obuf;
11266         }
11267
11268         /* Create AEAD session */
11269         retval = create_aead_session(ts_params->valid_devs[0],
11270                         tdata->algo,
11271                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
11272                         tdata->key.data, tdata->key.len,
11273                         tdata->aad.len, tdata->auth_tag.len,
11274                         tdata->iv.len);
11275         if (retval < 0)
11276                 return retval;
11277
11278         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11279
11280         /* clear mbuf payload */
11281         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11282                         rte_pktmbuf_tailroom(ut_params->ibuf));
11283
11284         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11285                         plaintext_len);
11286
11287         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11288
11289         trn_data += plaintext_len;
11290
11291         buf = ut_params->ibuf;
11292
11293         /*
11294          * Loop until no more fragments
11295          */
11296
11297         while (trn_data < tdata->plaintext.len) {
11298                 ++segs;
11299                 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11300                                 (tdata->plaintext.len - trn_data) : fragsz;
11301
11302                 to_trn_tbl[ecx++] = to_trn;
11303
11304                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11305                 buf = buf->next;
11306
11307                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11308                                 rte_pktmbuf_tailroom(buf));
11309
11310                 /* OOP */
11311                 if (oop && !fragsz_oop) {
11312                         buf_last_oop = buf_oop->next =
11313                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
11314                         buf_oop = buf_oop->next;
11315                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11316                                         0, rte_pktmbuf_tailroom(buf_oop));
11317                         rte_pktmbuf_append(buf_oop, to_trn);
11318                 }
11319
11320                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11321                                 to_trn);
11322
11323                 memcpy(plaintext, tdata->plaintext.data + trn_data,
11324                                 to_trn);
11325                 trn_data += to_trn;
11326                 if (trn_data  == tdata->plaintext.len) {
11327                         if (oop) {
11328                                 if (!fragsz_oop)
11329                                         digest_mem = rte_pktmbuf_append(buf_oop,
11330                                                 tdata->auth_tag.len);
11331                         } else
11332                                 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11333                                         tdata->auth_tag.len);
11334                 }
11335         }
11336
11337         uint64_t digest_phys = 0;
11338
11339         ut_params->ibuf->nb_segs = segs;
11340
11341         segs = 1;
11342         if (fragsz_oop && oop) {
11343                 to_trn = 0;
11344                 ecx = 0;
11345
11346                 if (frag_size_oop == tdata->plaintext.len) {
11347                         digest_mem = rte_pktmbuf_append(ut_params->obuf,
11348                                 tdata->auth_tag.len);
11349
11350                         digest_phys = rte_pktmbuf_iova_offset(
11351                                         ut_params->obuf,
11352                                         tdata->plaintext.len + prepend_len);
11353                 }
11354
11355                 trn_data = frag_size_oop;
11356                 while (trn_data < tdata->plaintext.len) {
11357                         ++segs;
11358                         to_trn =
11359                                 (tdata->plaintext.len - trn_data <
11360                                                 frag_size_oop) ?
11361                                 (tdata->plaintext.len - trn_data) :
11362                                                 frag_size_oop;
11363
11364                         to_trn_tbl[ecx++] = to_trn;
11365
11366                         buf_last_oop = buf_oop->next =
11367                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
11368                         buf_oop = buf_oop->next;
11369                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11370                                         0, rte_pktmbuf_tailroom(buf_oop));
11371                         rte_pktmbuf_append(buf_oop, to_trn);
11372
11373                         trn_data += to_trn;
11374
11375                         if (trn_data  == tdata->plaintext.len) {
11376                                 digest_mem = rte_pktmbuf_append(buf_oop,
11377                                         tdata->auth_tag.len);
11378                         }
11379                 }
11380
11381                 ut_params->obuf->nb_segs = segs;
11382         }
11383
11384         /*
11385          * Place digest at the end of the last buffer
11386          */
11387         if (!digest_phys)
11388                 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11389         if (oop && buf_last_oop)
11390                 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11391
11392         if (!digest_mem && !oop) {
11393                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11394                                 + tdata->auth_tag.len);
11395                 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11396                                 tdata->plaintext.len);
11397         }
11398
11399         /* Create AEAD operation */
11400         retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11401                         tdata, digest_mem, digest_phys);
11402
11403         if (retval < 0)
11404                 return retval;
11405
11406         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11407
11408         ut_params->op->sym->m_src = ut_params->ibuf;
11409         if (oop)
11410                 ut_params->op->sym->m_dst = ut_params->obuf;
11411
11412         /* Process crypto operation */
11413         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11414                         ut_params->op), "failed to process sym crypto op");
11415
11416         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11417                         "crypto op processing failed");
11418
11419
11420         ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11421                         uint8_t *, prepend_len);
11422         if (oop) {
11423                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11424                                 uint8_t *, prepend_len);
11425         }
11426
11427         if (fragsz_oop)
11428                 fragsz = fragsz_oop;
11429
11430         TEST_ASSERT_BUFFERS_ARE_EQUAL(
11431                         ciphertext,
11432                         tdata->ciphertext.data,
11433                         fragsz,
11434                         "Ciphertext data not as expected");
11435
11436         buf = ut_params->op->sym->m_src->next;
11437         if (oop)
11438                 buf = ut_params->op->sym->m_dst->next;
11439
11440         unsigned int off = fragsz;
11441
11442         ecx = 0;
11443         while (buf) {
11444                 ciphertext = rte_pktmbuf_mtod(buf,
11445                                 uint8_t *);
11446
11447                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11448                                 ciphertext,
11449                                 tdata->ciphertext.data + off,
11450                                 to_trn_tbl[ecx],
11451                                 "Ciphertext data not as expected");
11452
11453                 off += to_trn_tbl[ecx++];
11454                 buf = buf->next;
11455         }
11456
11457         auth_tag = digest_mem;
11458         TEST_ASSERT_BUFFERS_ARE_EQUAL(
11459                         auth_tag,
11460                         tdata->auth_tag.data,
11461                         tdata->auth_tag.len,
11462                         "Generated auth tag not as expected");
11463
11464         return 0;
11465 }
11466
11467 static int
11468 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11469 {
11470         return test_authenticated_encryption_SGL(
11471                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11472 }
11473
11474 static int
11475 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11476 {
11477         return test_authenticated_encryption_SGL(
11478                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11479 }
11480
11481 static int
11482 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11483 {
11484         return test_authenticated_encryption_SGL(
11485                         &gcm_test_case_8, OUT_OF_PLACE, 400,
11486                         gcm_test_case_8.plaintext.len);
11487 }
11488
11489 static int
11490 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11491 {
11492
11493         return test_authenticated_encryption_SGL(
11494                         &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11495 }
11496
11497 static int
11498 test_authentication_verify_fail_when_data_corrupted(
11499                 struct crypto_testsuite_params *ts_params,
11500                 struct crypto_unittest_params *ut_params,
11501                 const struct test_crypto_vector *reference)
11502 {
11503         return test_authentication_verify_fail_when_data_corruption(
11504                         ts_params, ut_params, reference, 1);
11505 }
11506
11507 static int
11508 test_authentication_verify_fail_when_tag_corrupted(
11509                 struct crypto_testsuite_params *ts_params,
11510                 struct crypto_unittest_params *ut_params,
11511                 const struct test_crypto_vector *reference)
11512 {
11513         return test_authentication_verify_fail_when_data_corruption(
11514                         ts_params, ut_params, reference, 0);
11515 }
11516
11517 static int
11518 test_authentication_verify_GMAC_fail_when_data_corrupted(
11519                 struct crypto_testsuite_params *ts_params,
11520                 struct crypto_unittest_params *ut_params,
11521                 const struct test_crypto_vector *reference)
11522 {
11523         return test_authentication_verify_GMAC_fail_when_corruption(
11524                         ts_params, ut_params, reference, 1);
11525 }
11526
11527 static int
11528 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11529                 struct crypto_testsuite_params *ts_params,
11530                 struct crypto_unittest_params *ut_params,
11531                 const struct test_crypto_vector *reference)
11532 {
11533         return test_authentication_verify_GMAC_fail_when_corruption(
11534                         ts_params, ut_params, reference, 0);
11535 }
11536
11537 static int
11538 test_authenticated_decryption_fail_when_data_corrupted(
11539                 struct crypto_testsuite_params *ts_params,
11540                 struct crypto_unittest_params *ut_params,
11541                 const struct test_crypto_vector *reference)
11542 {
11543         return test_authenticated_decryption_fail_when_corruption(
11544                         ts_params, ut_params, reference, 1);
11545 }
11546
11547 static int
11548 test_authenticated_decryption_fail_when_tag_corrupted(
11549                 struct crypto_testsuite_params *ts_params,
11550                 struct crypto_unittest_params *ut_params,
11551                 const struct test_crypto_vector *reference)
11552 {
11553         return test_authenticated_decryption_fail_when_corruption(
11554                         ts_params, ut_params, reference, 0);
11555 }
11556
11557 static int
11558 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11559 {
11560         return test_authentication_verify_fail_when_data_corrupted(
11561                         &testsuite_params, &unittest_params,
11562                         &hmac_sha1_test_crypto_vector);
11563 }
11564
11565 static int
11566 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11567 {
11568         return test_authentication_verify_fail_when_tag_corrupted(
11569                         &testsuite_params, &unittest_params,
11570                         &hmac_sha1_test_crypto_vector);
11571 }
11572
11573 static int
11574 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11575 {
11576         return test_authentication_verify_GMAC_fail_when_data_corrupted(
11577                         &testsuite_params, &unittest_params,
11578                         &aes128_gmac_test_vector);
11579 }
11580
11581 static int
11582 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11583 {
11584         return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11585                         &testsuite_params, &unittest_params,
11586                         &aes128_gmac_test_vector);
11587 }
11588
11589 static int
11590 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11591 {
11592         return test_authenticated_decryption_fail_when_data_corrupted(
11593                         &testsuite_params,
11594                         &unittest_params,
11595                         &aes128cbc_hmac_sha1_test_vector);
11596 }
11597
11598 static int
11599 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11600 {
11601         return test_authenticated_decryption_fail_when_tag_corrupted(
11602                         &testsuite_params,
11603                         &unittest_params,
11604                         &aes128cbc_hmac_sha1_test_vector);
11605 }
11606
11607 static int
11608 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11609 {
11610         return test_authenticated_encryt_with_esn(
11611                         &testsuite_params,
11612                         &unittest_params,
11613                         &aes128cbc_hmac_sha1_aad_test_vector);
11614 }
11615
11616 static int
11617 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11618 {
11619         return test_authenticated_decrypt_with_esn(
11620                         &testsuite_params,
11621                         &unittest_params,
11622                         &aes128cbc_hmac_sha1_aad_test_vector);
11623 }
11624
11625 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11626
11627 /* global AESNI slave IDs for the scheduler test */
11628 uint8_t aesni_ids[2];
11629
11630 static int
11631 test_scheduler_attach_slave_op(void)
11632 {
11633         struct crypto_testsuite_params *ts_params = &testsuite_params;
11634         uint8_t sched_id = ts_params->valid_devs[0];
11635         uint32_t nb_devs, i, nb_devs_attached = 0;
11636         int ret;
11637         char vdev_name[32];
11638
11639         /* create 2 AESNI_MB if necessary */
11640         nb_devs = rte_cryptodev_device_count_by_driver(
11641                         rte_cryptodev_driver_id_get(
11642                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11643         if (nb_devs < 2) {
11644                 for (i = nb_devs; i < 2; i++) {
11645                         snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11646                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11647                                         i);
11648                         ret = rte_vdev_init(vdev_name, NULL);
11649
11650                         TEST_ASSERT(ret == 0,
11651                                 "Failed to create instance %u of"
11652                                 " pmd : %s",
11653                                 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11654                 }
11655         }
11656
11657         /* attach 2 AESNI_MB cdevs */
11658         for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11659                         i++) {
11660                 struct rte_cryptodev_info info;
11661                 unsigned int session_size;
11662
11663                 rte_cryptodev_info_get(i, &info);
11664                 if (info.driver_id != rte_cryptodev_driver_id_get(
11665                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11666                         continue;
11667
11668                 session_size = rte_cryptodev_sym_get_private_session_size(i);
11669                 /*
11670                  * Create the session mempool again, since now there are new devices
11671                  * to use the mempool.
11672                  */
11673                 if (ts_params->session_mpool) {
11674                         rte_mempool_free(ts_params->session_mpool);
11675                         ts_params->session_mpool = NULL;
11676                 }
11677                 if (ts_params->session_priv_mpool) {
11678                         rte_mempool_free(ts_params->session_priv_mpool);
11679                         ts_params->session_priv_mpool = NULL;
11680                 }
11681
11682                 if (info.sym.max_nb_sessions != 0 &&
11683                                 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11684                         RTE_LOG(ERR, USER1,
11685                                         "Device does not support "
11686                                         "at least %u sessions\n",
11687                                         MAX_NB_SESSIONS);
11688                         return TEST_FAILED;
11689                 }
11690                 /*
11691                  * Create mempool with maximum number of sessions,
11692                  * to include the session headers
11693                  */
11694                 if (ts_params->session_mpool == NULL) {
11695                         ts_params->session_mpool =
11696                                 rte_cryptodev_sym_session_pool_create(
11697                                                 "test_sess_mp",
11698                                                 MAX_NB_SESSIONS, 0, 0, 0,
11699                                                 SOCKET_ID_ANY);
11700                         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11701                                         "session mempool allocation failed");
11702                 }
11703
11704                 /*
11705                  * Create mempool with maximum number of sessions,
11706                  * to include device specific session private data
11707                  */
11708                 if (ts_params->session_priv_mpool == NULL) {
11709                         ts_params->session_priv_mpool = rte_mempool_create(
11710                                         "test_sess_mp_priv",
11711                                         MAX_NB_SESSIONS,
11712                                         session_size,
11713                                         0, 0, NULL, NULL, NULL,
11714                                         NULL, SOCKET_ID_ANY,
11715                                         0);
11716
11717                         TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11718                                         "session mempool allocation failed");
11719                 }
11720
11721                 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11722                 ts_params->qp_conf.mp_session_private =
11723                                 ts_params->session_priv_mpool;
11724
11725                 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11726                                 (uint8_t)i);
11727
11728                 TEST_ASSERT(ret == 0,
11729                         "Failed to attach device %u of pmd : %s", i,
11730                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11731
11732                 aesni_ids[nb_devs_attached] = (uint8_t)i;
11733
11734                 nb_devs_attached++;
11735         }
11736
11737         return 0;
11738 }
11739
11740 static int
11741 test_scheduler_detach_slave_op(void)
11742 {
11743         struct crypto_testsuite_params *ts_params = &testsuite_params;
11744         uint8_t sched_id = ts_params->valid_devs[0];
11745         uint32_t i;
11746         int ret;
11747
11748         for (i = 0; i < 2; i++) {
11749                 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11750                                 aesni_ids[i]);
11751                 TEST_ASSERT(ret == 0,
11752                         "Failed to detach device %u", aesni_ids[i]);
11753         }
11754
11755         return 0;
11756 }
11757
11758 static int
11759 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11760 {
11761         struct crypto_testsuite_params *ts_params = &testsuite_params;
11762         uint8_t sched_id = ts_params->valid_devs[0];
11763         /* set mode */
11764         return rte_cryptodev_scheduler_mode_set(sched_id,
11765                 scheduler_mode);
11766 }
11767
11768 static int
11769 test_scheduler_mode_roundrobin_op(void)
11770 {
11771         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11772                         0, "Failed to set roundrobin mode");
11773         return 0;
11774
11775 }
11776
11777 static int
11778 test_scheduler_mode_multicore_op(void)
11779 {
11780         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11781                         0, "Failed to set multicore mode");
11782
11783         return 0;
11784 }
11785
11786 static int
11787 test_scheduler_mode_failover_op(void)
11788 {
11789         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11790                         0, "Failed to set failover mode");
11791
11792         return 0;
11793 }
11794
11795 static int
11796 test_scheduler_mode_pkt_size_distr_op(void)
11797 {
11798         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11799                         0, "Failed to set pktsize mode");
11800
11801         return 0;
11802 }
11803
11804 static struct unit_test_suite cryptodev_scheduler_testsuite  = {
11805         .suite_name = "Crypto Device Scheduler Unit Test Suite",
11806         .setup = testsuite_setup,
11807         .teardown = testsuite_teardown,
11808         .unit_test_cases = {
11809                 /* Multi Core */
11810                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11811                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11812                 TEST_CASE_ST(ut_setup, ut_teardown,
11813                                         test_AES_chain_scheduler_all),
11814                 TEST_CASE_ST(ut_setup, ut_teardown,
11815                                         test_AES_cipheronly_scheduler_all),
11816                 TEST_CASE_ST(ut_setup, ut_teardown,
11817                                         test_authonly_scheduler_all),
11818                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11819
11820                 /* Round Robin */
11821                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11822                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11823                 TEST_CASE_ST(ut_setup, ut_teardown,
11824                                 test_AES_chain_scheduler_all),
11825                 TEST_CASE_ST(ut_setup, ut_teardown,
11826                                 test_AES_cipheronly_scheduler_all),
11827                 TEST_CASE_ST(ut_setup, ut_teardown,
11828                                 test_authonly_scheduler_all),
11829                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11830
11831                 /* Fail over */
11832                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11833                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11834                 TEST_CASE_ST(ut_setup, ut_teardown,
11835                                         test_AES_chain_scheduler_all),
11836                 TEST_CASE_ST(ut_setup, ut_teardown,
11837                                         test_AES_cipheronly_scheduler_all),
11838                 TEST_CASE_ST(ut_setup, ut_teardown,
11839                                         test_authonly_scheduler_all),
11840                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11841
11842                 /* PKT SIZE */
11843                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11844                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11845                 TEST_CASE_ST(ut_setup, ut_teardown,
11846                                         test_AES_chain_scheduler_all),
11847                 TEST_CASE_ST(ut_setup, ut_teardown,
11848                                         test_AES_cipheronly_scheduler_all),
11849                 TEST_CASE_ST(ut_setup, ut_teardown,
11850                                         test_authonly_scheduler_all),
11851                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11852
11853                 TEST_CASES_END() /**< NULL terminate unit test array */
11854         }
11855 };
11856
11857 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11858
11859 static struct unit_test_suite cryptodev_qat_testsuite  = {
11860         .suite_name = "Crypto QAT Unit Test Suite",
11861         .setup = testsuite_setup,
11862         .teardown = testsuite_teardown,
11863         .unit_test_cases = {
11864                 TEST_CASE_ST(ut_setup, ut_teardown,
11865                                 test_device_configure_invalid_dev_id),
11866                 TEST_CASE_ST(ut_setup, ut_teardown,
11867                                 test_device_configure_invalid_queue_pair_ids),
11868                 TEST_CASE_ST(ut_setup, ut_teardown,
11869                                 test_queue_pair_descriptor_setup),
11870                 TEST_CASE_ST(ut_setup, ut_teardown,
11871                                 test_multi_session),
11872
11873                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
11874                 TEST_CASE_ST(ut_setup, ut_teardown,
11875                                                 test_AES_cipheronly_qat_all),
11876                 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
11877                 TEST_CASE_ST(ut_setup, ut_teardown,
11878                                                 test_3DES_cipheronly_qat_all),
11879                 TEST_CASE_ST(ut_setup, ut_teardown,
11880                                                 test_DES_cipheronly_qat_all),
11881                 TEST_CASE_ST(ut_setup, ut_teardown,
11882                                                 test_AES_docsis_qat_all),
11883                 TEST_CASE_ST(ut_setup, ut_teardown,
11884                                                 test_DES_docsis_qat_all),
11885                 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
11886                 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11887
11888                 /** AES CCM Authenticated Encryption 128 bits key */
11889                 TEST_CASE_ST(ut_setup, ut_teardown,
11890                         test_AES_CCM_authenticated_encryption_test_case_128_1),
11891                 TEST_CASE_ST(ut_setup, ut_teardown,
11892                         test_AES_CCM_authenticated_encryption_test_case_128_2),
11893                 TEST_CASE_ST(ut_setup, ut_teardown,
11894                         test_AES_CCM_authenticated_encryption_test_case_128_3),
11895
11896                 /** AES CCM Authenticated Decryption 128 bits key*/
11897                 TEST_CASE_ST(ut_setup, ut_teardown,
11898                         test_AES_CCM_authenticated_decryption_test_case_128_1),
11899                 TEST_CASE_ST(ut_setup, ut_teardown,
11900                         test_AES_CCM_authenticated_decryption_test_case_128_2),
11901                 TEST_CASE_ST(ut_setup, ut_teardown,
11902                         test_AES_CCM_authenticated_decryption_test_case_128_3),
11903
11904                 /** AES GCM Authenticated Encryption */
11905                 TEST_CASE_ST(ut_setup, ut_teardown,
11906                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11907                 TEST_CASE_ST(ut_setup, ut_teardown,
11908                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11909                 TEST_CASE_ST(ut_setup, ut_teardown,
11910                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11911                 TEST_CASE_ST(ut_setup, ut_teardown,
11912                         test_AES_GCM_authenticated_encryption_test_case_1),
11913                 TEST_CASE_ST(ut_setup, ut_teardown,
11914                         test_AES_GCM_authenticated_encryption_test_case_2),
11915                 TEST_CASE_ST(ut_setup, ut_teardown,
11916                         test_AES_GCM_authenticated_encryption_test_case_3),
11917                 TEST_CASE_ST(ut_setup, ut_teardown,
11918                         test_AES_GCM_authenticated_encryption_test_case_4),
11919                 TEST_CASE_ST(ut_setup, ut_teardown,
11920                         test_AES_GCM_authenticated_encryption_test_case_5),
11921                 TEST_CASE_ST(ut_setup, ut_teardown,
11922                         test_AES_GCM_authenticated_encryption_test_case_6),
11923                 TEST_CASE_ST(ut_setup, ut_teardown,
11924                         test_AES_GCM_authenticated_encryption_test_case_7),
11925                 TEST_CASE_ST(ut_setup, ut_teardown,
11926                         test_AES_GCM_authenticated_encryption_test_case_8),
11927
11928                 /** AES GCM Authenticated Decryption */
11929                 TEST_CASE_ST(ut_setup, ut_teardown,
11930                         test_AES_GCM_authenticated_decryption_test_case_1),
11931                 TEST_CASE_ST(ut_setup, ut_teardown,
11932                         test_AES_GCM_authenticated_decryption_test_case_2),
11933                 TEST_CASE_ST(ut_setup, ut_teardown,
11934                         test_AES_GCM_authenticated_decryption_test_case_3),
11935                 TEST_CASE_ST(ut_setup, ut_teardown,
11936                         test_AES_GCM_authenticated_decryption_test_case_4),
11937                 TEST_CASE_ST(ut_setup, ut_teardown,
11938                         test_AES_GCM_authenticated_decryption_test_case_5),
11939                 TEST_CASE_ST(ut_setup, ut_teardown,
11940                         test_AES_GCM_authenticated_decryption_test_case_6),
11941                 TEST_CASE_ST(ut_setup, ut_teardown,
11942                         test_AES_GCM_authenticated_decryption_test_case_7),
11943                 TEST_CASE_ST(ut_setup, ut_teardown,
11944                         test_AES_GCM_authenticated_decryption_test_case_8),
11945
11946                 /** AES GCM Authenticated Encryption 192 bits key */
11947                 TEST_CASE_ST(ut_setup, ut_teardown,
11948                         test_AES_GCM_auth_encryption_test_case_192_1),
11949                 TEST_CASE_ST(ut_setup, ut_teardown,
11950                         test_AES_GCM_auth_encryption_test_case_192_2),
11951                 TEST_CASE_ST(ut_setup, ut_teardown,
11952                         test_AES_GCM_auth_encryption_test_case_192_3),
11953                 TEST_CASE_ST(ut_setup, ut_teardown,
11954                         test_AES_GCM_auth_encryption_test_case_192_4),
11955                 TEST_CASE_ST(ut_setup, ut_teardown,
11956                         test_AES_GCM_auth_encryption_test_case_192_5),
11957                 TEST_CASE_ST(ut_setup, ut_teardown,
11958                         test_AES_GCM_auth_encryption_test_case_192_6),
11959                 TEST_CASE_ST(ut_setup, ut_teardown,
11960                         test_AES_GCM_auth_encryption_test_case_192_7),
11961
11962                 /** AES GCM Authenticated Decryption 192 bits key */
11963                 TEST_CASE_ST(ut_setup, ut_teardown,
11964                         test_AES_GCM_auth_decryption_test_case_192_1),
11965                 TEST_CASE_ST(ut_setup, ut_teardown,
11966                         test_AES_GCM_auth_decryption_test_case_192_2),
11967                 TEST_CASE_ST(ut_setup, ut_teardown,
11968                         test_AES_GCM_auth_decryption_test_case_192_3),
11969                 TEST_CASE_ST(ut_setup, ut_teardown,
11970                         test_AES_GCM_auth_decryption_test_case_192_4),
11971                 TEST_CASE_ST(ut_setup, ut_teardown,
11972                         test_AES_GCM_auth_decryption_test_case_192_5),
11973                 TEST_CASE_ST(ut_setup, ut_teardown,
11974                         test_AES_GCM_auth_decryption_test_case_192_6),
11975                 TEST_CASE_ST(ut_setup, ut_teardown,
11976                         test_AES_GCM_auth_decryption_test_case_192_7),
11977
11978                 /** AES GCM Authenticated Encryption 256 bits key */
11979                 TEST_CASE_ST(ut_setup, ut_teardown,
11980                         test_AES_GCM_auth_encryption_test_case_256_1),
11981                 TEST_CASE_ST(ut_setup, ut_teardown,
11982                         test_AES_GCM_auth_encryption_test_case_256_2),
11983                 TEST_CASE_ST(ut_setup, ut_teardown,
11984                         test_AES_GCM_auth_encryption_test_case_256_3),
11985                 TEST_CASE_ST(ut_setup, ut_teardown,
11986                         test_AES_GCM_auth_encryption_test_case_256_4),
11987                 TEST_CASE_ST(ut_setup, ut_teardown,
11988                         test_AES_GCM_auth_encryption_test_case_256_5),
11989                 TEST_CASE_ST(ut_setup, ut_teardown,
11990                         test_AES_GCM_auth_encryption_test_case_256_6),
11991                 TEST_CASE_ST(ut_setup, ut_teardown,
11992                         test_AES_GCM_auth_encryption_test_case_256_7),
11993
11994                 /** AES GCM Authenticated Decryption 256 bits key */
11995                 TEST_CASE_ST(ut_setup, ut_teardown,
11996                         test_AES_GCM_auth_decryption_test_case_256_1),
11997                 TEST_CASE_ST(ut_setup, ut_teardown,
11998                         test_AES_GCM_auth_decryption_test_case_256_2),
11999                 TEST_CASE_ST(ut_setup, ut_teardown,
12000                         test_AES_GCM_auth_decryption_test_case_256_3),
12001                 TEST_CASE_ST(ut_setup, ut_teardown,
12002                         test_AES_GCM_auth_decryption_test_case_256_4),
12003                 TEST_CASE_ST(ut_setup, ut_teardown,
12004                         test_AES_GCM_auth_decryption_test_case_256_5),
12005                 TEST_CASE_ST(ut_setup, ut_teardown,
12006                         test_AES_GCM_auth_decryption_test_case_256_6),
12007                 TEST_CASE_ST(ut_setup, ut_teardown,
12008                         test_AES_GCM_auth_decryption_test_case_256_7),
12009
12010                 /** AES GMAC Authentication */
12011                 TEST_CASE_ST(ut_setup, ut_teardown,
12012                         test_AES_GMAC_authentication_test_case_1),
12013                 TEST_CASE_ST(ut_setup, ut_teardown,
12014                         test_AES_GMAC_authentication_verify_test_case_1),
12015                 TEST_CASE_ST(ut_setup, ut_teardown,
12016                         test_AES_GMAC_authentication_test_case_2),
12017                 TEST_CASE_ST(ut_setup, ut_teardown,
12018                         test_AES_GMAC_authentication_verify_test_case_2),
12019                 TEST_CASE_ST(ut_setup, ut_teardown,
12020                         test_AES_GMAC_authentication_test_case_3),
12021                 TEST_CASE_ST(ut_setup, ut_teardown,
12022                         test_AES_GMAC_authentication_verify_test_case_3),
12023
12024                 /** SNOW 3G encrypt only (UEA2) */
12025                 TEST_CASE_ST(ut_setup, ut_teardown,
12026                         test_snow3g_encryption_test_case_1),
12027                 TEST_CASE_ST(ut_setup, ut_teardown,
12028                         test_snow3g_encryption_test_case_2),
12029                 TEST_CASE_ST(ut_setup, ut_teardown,
12030                         test_snow3g_encryption_test_case_3),
12031                 TEST_CASE_ST(ut_setup, ut_teardown,
12032                         test_snow3g_encryption_test_case_4),
12033                 TEST_CASE_ST(ut_setup, ut_teardown,
12034                         test_snow3g_encryption_test_case_5),
12035
12036                 TEST_CASE_ST(ut_setup, ut_teardown,
12037                         test_snow3g_encryption_test_case_1_oop),
12038                 TEST_CASE_ST(ut_setup, ut_teardown,
12039                         test_snow3g_decryption_test_case_1_oop),
12040
12041                 /** SNOW 3G generate auth, then encrypt (UEA2) */
12042                 TEST_CASE_ST(ut_setup, ut_teardown,
12043                         test_snow3g_auth_cipher_test_case_1),
12044                 TEST_CASE_ST(ut_setup, ut_teardown,
12045                         test_snow3g_auth_cipher_test_case_2),
12046                 TEST_CASE_ST(ut_setup, ut_teardown,
12047                         test_snow3g_auth_cipher_test_case_2_oop),
12048                 TEST_CASE_ST(ut_setup, ut_teardown,
12049                         test_snow3g_auth_cipher_part_digest_enc),
12050                 TEST_CASE_ST(ut_setup, ut_teardown,
12051                         test_snow3g_auth_cipher_part_digest_enc_oop),
12052                 TEST_CASE_ST(ut_setup, ut_teardown,
12053                         test_snow3g_auth_cipher_test_case_3_sgl),
12054                 TEST_CASE_ST(ut_setup, ut_teardown,
12055                         test_snow3g_auth_cipher_test_case_3_oop_sgl),
12056                 TEST_CASE_ST(ut_setup, ut_teardown,
12057                         test_snow3g_auth_cipher_part_digest_enc_sgl),
12058                 TEST_CASE_ST(ut_setup, ut_teardown,
12059                         test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12060
12061                 /** SNOW 3G decrypt (UEA2), then verify auth */
12062                 TEST_CASE_ST(ut_setup, ut_teardown,
12063                         test_snow3g_auth_cipher_verify_test_case_1),
12064                 TEST_CASE_ST(ut_setup, ut_teardown,
12065                         test_snow3g_auth_cipher_verify_test_case_2),
12066                 TEST_CASE_ST(ut_setup, ut_teardown,
12067                         test_snow3g_auth_cipher_verify_test_case_2_oop),
12068                 TEST_CASE_ST(ut_setup, ut_teardown,
12069                         test_snow3g_auth_cipher_verify_part_digest_enc),
12070                 TEST_CASE_ST(ut_setup, ut_teardown,
12071                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12072                 TEST_CASE_ST(ut_setup, ut_teardown,
12073                         test_snow3g_auth_cipher_verify_test_case_3_sgl),
12074                 TEST_CASE_ST(ut_setup, ut_teardown,
12075                         test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12076                 TEST_CASE_ST(ut_setup, ut_teardown,
12077                         test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12078                 TEST_CASE_ST(ut_setup, ut_teardown,
12079                         test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12080
12081                 /** SNOW 3G decrypt only (UEA2) */
12082                 TEST_CASE_ST(ut_setup, ut_teardown,
12083                         test_snow3g_decryption_test_case_1),
12084                 TEST_CASE_ST(ut_setup, ut_teardown,
12085                         test_snow3g_decryption_test_case_2),
12086                 TEST_CASE_ST(ut_setup, ut_teardown,
12087                         test_snow3g_decryption_test_case_3),
12088                 TEST_CASE_ST(ut_setup, ut_teardown,
12089                         test_snow3g_decryption_test_case_4),
12090                 TEST_CASE_ST(ut_setup, ut_teardown,
12091                         test_snow3g_decryption_test_case_5),
12092                 TEST_CASE_ST(ut_setup, ut_teardown,
12093                         test_snow3g_decryption_with_digest_test_case_1),
12094                 TEST_CASE_ST(ut_setup, ut_teardown,
12095                         test_snow3g_hash_generate_test_case_1),
12096                 TEST_CASE_ST(ut_setup, ut_teardown,
12097                         test_snow3g_hash_generate_test_case_2),
12098                 TEST_CASE_ST(ut_setup, ut_teardown,
12099                         test_snow3g_hash_generate_test_case_3),
12100                 TEST_CASE_ST(ut_setup, ut_teardown,
12101                         test_snow3g_hash_verify_test_case_1),
12102                 TEST_CASE_ST(ut_setup, ut_teardown,
12103                         test_snow3g_hash_verify_test_case_2),
12104                 TEST_CASE_ST(ut_setup, ut_teardown,
12105                         test_snow3g_hash_verify_test_case_3),
12106                 TEST_CASE_ST(ut_setup, ut_teardown,
12107                         test_snow3g_cipher_auth_test_case_1),
12108                 TEST_CASE_ST(ut_setup, ut_teardown,
12109                         test_snow3g_auth_cipher_with_digest_test_case_1),
12110
12111                 /** ZUC encrypt only (EEA3) */
12112                 TEST_CASE_ST(ut_setup, ut_teardown,
12113                         test_zuc_encryption_test_case_1),
12114                 TEST_CASE_ST(ut_setup, ut_teardown,
12115                         test_zuc_encryption_test_case_2),
12116                 TEST_CASE_ST(ut_setup, ut_teardown,
12117                         test_zuc_encryption_test_case_3),
12118                 TEST_CASE_ST(ut_setup, ut_teardown,
12119                         test_zuc_encryption_test_case_4),
12120                 TEST_CASE_ST(ut_setup, ut_teardown,
12121                         test_zuc_encryption_test_case_5),
12122
12123                 /** ZUC authenticate (EIA3) */
12124                 TEST_CASE_ST(ut_setup, ut_teardown,
12125                         test_zuc_hash_generate_test_case_6),
12126                 TEST_CASE_ST(ut_setup, ut_teardown,
12127                         test_zuc_hash_generate_test_case_7),
12128                 TEST_CASE_ST(ut_setup, ut_teardown,
12129                         test_zuc_hash_generate_test_case_8),
12130
12131                 /** ZUC alg-chain (EEA3/EIA3) */
12132                 TEST_CASE_ST(ut_setup, ut_teardown,
12133                         test_zuc_cipher_auth_test_case_1),
12134                 TEST_CASE_ST(ut_setup, ut_teardown,
12135                         test_zuc_cipher_auth_test_case_2),
12136
12137                 /** ZUC generate auth, then encrypt (EEA3) */
12138                 TEST_CASE_ST(ut_setup, ut_teardown,
12139                         test_zuc_auth_cipher_test_case_1),
12140                 TEST_CASE_ST(ut_setup, ut_teardown,
12141                         test_zuc_auth_cipher_test_case_1_oop),
12142                 TEST_CASE_ST(ut_setup, ut_teardown,
12143                         test_zuc_auth_cipher_test_case_1_sgl),
12144                 TEST_CASE_ST(ut_setup, ut_teardown,
12145                         test_zuc_auth_cipher_test_case_1_oop_sgl),
12146
12147                 /** ZUC decrypt (EEA3), then verify auth */
12148                 TEST_CASE_ST(ut_setup, ut_teardown,
12149                         test_zuc_auth_cipher_verify_test_case_1),
12150                 TEST_CASE_ST(ut_setup, ut_teardown,
12151                         test_zuc_auth_cipher_verify_test_case_1_oop),
12152                 TEST_CASE_ST(ut_setup, ut_teardown,
12153                         test_zuc_auth_cipher_verify_test_case_1_sgl),
12154                 TEST_CASE_ST(ut_setup, ut_teardown,
12155                         test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12156
12157                 /** HMAC_MD5 Authentication */
12158                 TEST_CASE_ST(ut_setup, ut_teardown,
12159                         test_MD5_HMAC_generate_case_1),
12160                 TEST_CASE_ST(ut_setup, ut_teardown,
12161                         test_MD5_HMAC_verify_case_1),
12162                 TEST_CASE_ST(ut_setup, ut_teardown,
12163                         test_MD5_HMAC_generate_case_2),
12164                 TEST_CASE_ST(ut_setup, ut_teardown,
12165                         test_MD5_HMAC_verify_case_2),
12166
12167                 /** NULL algo tests done in chain_all,
12168                  * cipheronly and authonly suites
12169                  */
12170
12171                 /** KASUMI tests */
12172                 TEST_CASE_ST(ut_setup, ut_teardown,
12173                         test_kasumi_hash_generate_test_case_1),
12174                 TEST_CASE_ST(ut_setup, ut_teardown,
12175                         test_kasumi_hash_generate_test_case_2),
12176                 TEST_CASE_ST(ut_setup, ut_teardown,
12177                         test_kasumi_hash_generate_test_case_3),
12178                 TEST_CASE_ST(ut_setup, ut_teardown,
12179                         test_kasumi_hash_generate_test_case_4),
12180                 TEST_CASE_ST(ut_setup, ut_teardown,
12181                         test_kasumi_hash_generate_test_case_5),
12182                 TEST_CASE_ST(ut_setup, ut_teardown,
12183                         test_kasumi_hash_generate_test_case_6),
12184
12185                 TEST_CASE_ST(ut_setup, ut_teardown,
12186                         test_kasumi_hash_verify_test_case_1),
12187                 TEST_CASE_ST(ut_setup, ut_teardown,
12188                         test_kasumi_hash_verify_test_case_2),
12189                 TEST_CASE_ST(ut_setup, ut_teardown,
12190                         test_kasumi_hash_verify_test_case_3),
12191                 TEST_CASE_ST(ut_setup, ut_teardown,
12192                         test_kasumi_hash_verify_test_case_4),
12193                 TEST_CASE_ST(ut_setup, ut_teardown,
12194                         test_kasumi_hash_verify_test_case_5),
12195
12196                 TEST_CASE_ST(ut_setup, ut_teardown,
12197                         test_kasumi_encryption_test_case_1),
12198                 TEST_CASE_ST(ut_setup, ut_teardown,
12199                         test_kasumi_encryption_test_case_3),
12200                 TEST_CASE_ST(ut_setup, ut_teardown,
12201                         test_kasumi_cipher_auth_test_case_1),
12202
12203                 /** KASUMI generate auth, then encrypt (F8) */
12204                 TEST_CASE_ST(ut_setup, ut_teardown,
12205                         test_kasumi_auth_cipher_test_case_1),
12206                 TEST_CASE_ST(ut_setup, ut_teardown,
12207                         test_kasumi_auth_cipher_test_case_2),
12208                 TEST_CASE_ST(ut_setup, ut_teardown,
12209                         test_kasumi_auth_cipher_test_case_2_oop),
12210                 TEST_CASE_ST(ut_setup, ut_teardown,
12211                         test_kasumi_auth_cipher_test_case_2_sgl),
12212                 TEST_CASE_ST(ut_setup, ut_teardown,
12213                         test_kasumi_auth_cipher_test_case_2_oop_sgl),
12214
12215                 /** KASUMI decrypt (F8), then verify auth */
12216                 TEST_CASE_ST(ut_setup, ut_teardown,
12217                         test_kasumi_auth_cipher_verify_test_case_1),
12218                 TEST_CASE_ST(ut_setup, ut_teardown,
12219                         test_kasumi_auth_cipher_verify_test_case_2),
12220                 TEST_CASE_ST(ut_setup, ut_teardown,
12221                         test_kasumi_auth_cipher_verify_test_case_2_oop),
12222                 TEST_CASE_ST(ut_setup, ut_teardown,
12223                         test_kasumi_auth_cipher_verify_test_case_2_sgl),
12224                 TEST_CASE_ST(ut_setup, ut_teardown,
12225                         test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12226
12227                 /** Negative tests */
12228                 TEST_CASE_ST(ut_setup, ut_teardown,
12229                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
12230                 TEST_CASE_ST(ut_setup, ut_teardown,
12231                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12232                 TEST_CASE_ST(ut_setup, ut_teardown,
12233                         test_AES_GCM_auth_encryption_fail_iv_corrupt),
12234                 TEST_CASE_ST(ut_setup, ut_teardown,
12235                         test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12236                 TEST_CASE_ST(ut_setup, ut_teardown,
12237                         test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12238                 TEST_CASE_ST(ut_setup, ut_teardown,
12239                         test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12240                 TEST_CASE_ST(ut_setup, ut_teardown,
12241                         test_AES_GCM_auth_encryption_fail_aad_corrupt),
12242                 TEST_CASE_ST(ut_setup, ut_teardown,
12243                         test_AES_GCM_auth_encryption_fail_tag_corrupt),
12244                 TEST_CASE_ST(ut_setup, ut_teardown,
12245                         test_AES_GCM_auth_decryption_fail_iv_corrupt),
12246                 TEST_CASE_ST(ut_setup, ut_teardown,
12247                         test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12248                 TEST_CASE_ST(ut_setup, ut_teardown,
12249                         test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12250                 TEST_CASE_ST(ut_setup, ut_teardown,
12251                         test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12252                 TEST_CASE_ST(ut_setup, ut_teardown,
12253                         test_AES_GCM_auth_decryption_fail_aad_corrupt),
12254                 TEST_CASE_ST(ut_setup, ut_teardown,
12255                         test_AES_GCM_auth_decryption_fail_tag_corrupt),
12256                 TEST_CASE_ST(ut_setup, ut_teardown,
12257                         authentication_verify_AES128_GMAC_fail_data_corrupt),
12258                 TEST_CASE_ST(ut_setup, ut_teardown,
12259                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
12260                 TEST_CASE_ST(ut_setup, ut_teardown,
12261                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12262                 TEST_CASE_ST(ut_setup, ut_teardown,
12263                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12264
12265                 /** Mixed CIPHER + HASH algorithms */
12266                 /** AUTH AES CMAC + CIPHER AES CTR */
12267                 TEST_CASE_ST(ut_setup, ut_teardown,
12268                         test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12269                 TEST_CASE_ST(ut_setup, ut_teardown,
12270                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12271                 TEST_CASE_ST(ut_setup, ut_teardown,
12272                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12273                 TEST_CASE_ST(ut_setup, ut_teardown,
12274                         test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12275                 TEST_CASE_ST(ut_setup, ut_teardown,
12276                         test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12277                 TEST_CASE_ST(ut_setup, ut_teardown,
12278                        test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12279                 TEST_CASE_ST(ut_setup, ut_teardown,
12280                        test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12281                 TEST_CASE_ST(ut_setup, ut_teardown,
12282                    test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12283
12284                 TEST_CASES_END() /**< NULL terminate unit test array */
12285         }
12286 };
12287
12288 static struct unit_test_suite cryptodev_virtio_testsuite = {
12289         .suite_name = "Crypto VIRTIO Unit Test Suite",
12290         .setup = testsuite_setup,
12291         .teardown = testsuite_teardown,
12292         .unit_test_cases = {
12293                 TEST_CASE_ST(ut_setup, ut_teardown,
12294                                 test_AES_cipheronly_virtio_all),
12295
12296                 TEST_CASES_END() /**< NULL terminate unit test array */
12297         }
12298 };
12299
12300 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
12301         .suite_name = "Crypto Device AESNI MB Unit Test Suite",
12302         .setup = testsuite_setup,
12303         .teardown = testsuite_teardown,
12304         .unit_test_cases = {
12305 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12306                 TEST_CASE_ST(ut_setup, ut_teardown,
12307                         test_AES_GCM_authenticated_encryption_test_case_1),
12308                 TEST_CASE_ST(ut_setup, ut_teardown,
12309                         test_AES_GCM_authenticated_encryption_test_case_2),
12310                 TEST_CASE_ST(ut_setup, ut_teardown,
12311                         test_AES_GCM_authenticated_encryption_test_case_3),
12312                 TEST_CASE_ST(ut_setup, ut_teardown,
12313                         test_AES_GCM_authenticated_encryption_test_case_4),
12314                 TEST_CASE_ST(ut_setup, ut_teardown,
12315                         test_AES_GCM_authenticated_encryption_test_case_5),
12316                 TEST_CASE_ST(ut_setup, ut_teardown,
12317                         test_AES_GCM_authenticated_encryption_test_case_6),
12318                 TEST_CASE_ST(ut_setup, ut_teardown,
12319                         test_AES_GCM_authenticated_encryption_test_case_7),
12320
12321                 /** AES GCM Authenticated Decryption */
12322                 TEST_CASE_ST(ut_setup, ut_teardown,
12323                         test_AES_GCM_authenticated_decryption_test_case_1),
12324                 TEST_CASE_ST(ut_setup, ut_teardown,
12325                         test_AES_GCM_authenticated_decryption_test_case_2),
12326                 TEST_CASE_ST(ut_setup, ut_teardown,
12327                         test_AES_GCM_authenticated_decryption_test_case_3),
12328                 TEST_CASE_ST(ut_setup, ut_teardown,
12329                         test_AES_GCM_authenticated_decryption_test_case_4),
12330                 TEST_CASE_ST(ut_setup, ut_teardown,
12331                         test_AES_GCM_authenticated_decryption_test_case_5),
12332                 TEST_CASE_ST(ut_setup, ut_teardown,
12333                         test_AES_GCM_authenticated_decryption_test_case_6),
12334                 TEST_CASE_ST(ut_setup, ut_teardown,
12335                         test_AES_GCM_authenticated_decryption_test_case_7),
12336
12337                 /** AES GCM Authenticated Encryption 192 bits key */
12338                 TEST_CASE_ST(ut_setup, ut_teardown,
12339                         test_AES_GCM_auth_encryption_test_case_192_1),
12340                 TEST_CASE_ST(ut_setup, ut_teardown,
12341                         test_AES_GCM_auth_encryption_test_case_192_2),
12342                 TEST_CASE_ST(ut_setup, ut_teardown,
12343                         test_AES_GCM_auth_encryption_test_case_192_3),
12344                 TEST_CASE_ST(ut_setup, ut_teardown,
12345                         test_AES_GCM_auth_encryption_test_case_192_4),
12346                 TEST_CASE_ST(ut_setup, ut_teardown,
12347                         test_AES_GCM_auth_encryption_test_case_192_5),
12348                 TEST_CASE_ST(ut_setup, ut_teardown,
12349                         test_AES_GCM_auth_encryption_test_case_192_6),
12350                 TEST_CASE_ST(ut_setup, ut_teardown,
12351                         test_AES_GCM_auth_encryption_test_case_192_7),
12352
12353                 /** AES GCM Authenticated Decryption 192 bits key */
12354                 TEST_CASE_ST(ut_setup, ut_teardown,
12355                         test_AES_GCM_auth_decryption_test_case_192_1),
12356                 TEST_CASE_ST(ut_setup, ut_teardown,
12357                         test_AES_GCM_auth_decryption_test_case_192_2),
12358                 TEST_CASE_ST(ut_setup, ut_teardown,
12359                         test_AES_GCM_auth_decryption_test_case_192_3),
12360                 TEST_CASE_ST(ut_setup, ut_teardown,
12361                         test_AES_GCM_auth_decryption_test_case_192_4),
12362                 TEST_CASE_ST(ut_setup, ut_teardown,
12363                         test_AES_GCM_auth_decryption_test_case_192_5),
12364                 TEST_CASE_ST(ut_setup, ut_teardown,
12365                         test_AES_GCM_auth_decryption_test_case_192_6),
12366                 TEST_CASE_ST(ut_setup, ut_teardown,
12367                         test_AES_GCM_auth_decryption_test_case_192_7),
12368
12369                 /** AES GCM Authenticated Encryption 256 bits key */
12370                 TEST_CASE_ST(ut_setup, ut_teardown,
12371                         test_AES_GCM_auth_encryption_test_case_256_1),
12372                 TEST_CASE_ST(ut_setup, ut_teardown,
12373                         test_AES_GCM_auth_encryption_test_case_256_2),
12374                 TEST_CASE_ST(ut_setup, ut_teardown,
12375                         test_AES_GCM_auth_encryption_test_case_256_3),
12376                 TEST_CASE_ST(ut_setup, ut_teardown,
12377                         test_AES_GCM_auth_encryption_test_case_256_4),
12378                 TEST_CASE_ST(ut_setup, ut_teardown,
12379                         test_AES_GCM_auth_encryption_test_case_256_5),
12380                 TEST_CASE_ST(ut_setup, ut_teardown,
12381                         test_AES_GCM_auth_encryption_test_case_256_6),
12382                 TEST_CASE_ST(ut_setup, ut_teardown,
12383                         test_AES_GCM_auth_encryption_test_case_256_7),
12384
12385                 /** AES GCM Authenticated Decryption 256 bits key */
12386                 TEST_CASE_ST(ut_setup, ut_teardown,
12387                         test_AES_GCM_auth_decryption_test_case_256_1),
12388                 TEST_CASE_ST(ut_setup, ut_teardown,
12389                         test_AES_GCM_auth_decryption_test_case_256_2),
12390                 TEST_CASE_ST(ut_setup, ut_teardown,
12391                         test_AES_GCM_auth_decryption_test_case_256_3),
12392                 TEST_CASE_ST(ut_setup, ut_teardown,
12393                         test_AES_GCM_auth_decryption_test_case_256_4),
12394                 TEST_CASE_ST(ut_setup, ut_teardown,
12395                         test_AES_GCM_auth_decryption_test_case_256_5),
12396                 TEST_CASE_ST(ut_setup, ut_teardown,
12397                         test_AES_GCM_auth_decryption_test_case_256_6),
12398                 TEST_CASE_ST(ut_setup, ut_teardown,
12399                         test_AES_GCM_auth_decryption_test_case_256_7),
12400
12401                 /** AES GCM Authenticated Encryption big aad size */
12402                 TEST_CASE_ST(ut_setup, ut_teardown,
12403                         test_AES_GCM_auth_encryption_test_case_aad_1),
12404                 TEST_CASE_ST(ut_setup, ut_teardown,
12405                         test_AES_GCM_auth_encryption_test_case_aad_2),
12406
12407                 /** AES GCM Authenticated Decryption big aad size */
12408                 TEST_CASE_ST(ut_setup, ut_teardown,
12409                         test_AES_GCM_auth_decryption_test_case_aad_1),
12410                 TEST_CASE_ST(ut_setup, ut_teardown,
12411                         test_AES_GCM_auth_decryption_test_case_aad_2),
12412
12413                 /** Session-less tests */
12414                 TEST_CASE_ST(ut_setup, ut_teardown,
12415                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12416                 TEST_CASE_ST(ut_setup, ut_teardown,
12417                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12418
12419                 /** AES GMAC Authentication */
12420                 TEST_CASE_ST(ut_setup, ut_teardown,
12421                         test_AES_GMAC_authentication_test_case_1),
12422                 TEST_CASE_ST(ut_setup, ut_teardown,
12423                         test_AES_GMAC_authentication_verify_test_case_1),
12424                 TEST_CASE_ST(ut_setup, ut_teardown,
12425                         test_AES_GMAC_authentication_test_case_2),
12426                 TEST_CASE_ST(ut_setup, ut_teardown,
12427                         test_AES_GMAC_authentication_verify_test_case_2),
12428                 TEST_CASE_ST(ut_setup, ut_teardown,
12429                         test_AES_GMAC_authentication_test_case_3),
12430                 TEST_CASE_ST(ut_setup, ut_teardown,
12431                         test_AES_GMAC_authentication_verify_test_case_3),
12432 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12433
12434                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12435                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12436                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12437                 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12438                 TEST_CASE_ST(ut_setup, ut_teardown,
12439                                                 test_DES_cipheronly_mb_all),
12440                 TEST_CASE_ST(ut_setup, ut_teardown,
12441                                                 test_DES_docsis_mb_all),
12442                 TEST_CASE_ST(ut_setup, ut_teardown,
12443                                                 test_3DES_cipheronly_mb_all),
12444                 TEST_CASE_ST(ut_setup, ut_teardown,
12445                         test_AES_CCM_authenticated_encryption_test_case_128_1),
12446                 TEST_CASE_ST(ut_setup, ut_teardown,
12447                         test_AES_CCM_authenticated_decryption_test_case_128_1),
12448                 TEST_CASE_ST(ut_setup, ut_teardown,
12449                         test_AES_CCM_authenticated_encryption_test_case_128_2),
12450                 TEST_CASE_ST(ut_setup, ut_teardown,
12451                         test_AES_CCM_authenticated_decryption_test_case_128_2),
12452                 TEST_CASE_ST(ut_setup, ut_teardown,
12453                         test_AES_CCM_authenticated_encryption_test_case_128_3),
12454                 TEST_CASE_ST(ut_setup, ut_teardown,
12455                         test_AES_CCM_authenticated_decryption_test_case_128_3),
12456
12457                 TEST_CASES_END() /**< NULL terminate unit test array */
12458         }
12459 };
12460
12461 static struct unit_test_suite cryptodev_openssl_testsuite  = {
12462         .suite_name = "Crypto Device OPENSSL Unit Test Suite",
12463         .setup = testsuite_setup,
12464         .teardown = testsuite_teardown,
12465         .unit_test_cases = {
12466                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12467                 TEST_CASE_ST(ut_setup, ut_teardown,
12468                                 test_multi_session_random_usage),
12469                 TEST_CASE_ST(ut_setup, ut_teardown,
12470                                 test_AES_chain_openssl_all),
12471                 TEST_CASE_ST(ut_setup, ut_teardown,
12472                                 test_AES_cipheronly_openssl_all),
12473                 TEST_CASE_ST(ut_setup, ut_teardown,
12474                                 test_3DES_chain_openssl_all),
12475                 TEST_CASE_ST(ut_setup, ut_teardown,
12476                                 test_3DES_cipheronly_openssl_all),
12477                 TEST_CASE_ST(ut_setup, ut_teardown,
12478                                 test_DES_cipheronly_openssl_all),
12479                 TEST_CASE_ST(ut_setup, ut_teardown,
12480                                 test_DES_docsis_openssl_all),
12481                 TEST_CASE_ST(ut_setup, ut_teardown,
12482                                 test_authonly_openssl_all),
12483
12484                 /** AES GCM Authenticated Encryption */
12485                 TEST_CASE_ST(ut_setup, ut_teardown,
12486                         test_AES_GCM_authenticated_encryption_test_case_1),
12487                 TEST_CASE_ST(ut_setup, ut_teardown,
12488                         test_AES_GCM_authenticated_encryption_test_case_2),
12489                 TEST_CASE_ST(ut_setup, ut_teardown,
12490                         test_AES_GCM_authenticated_encryption_test_case_3),
12491                 TEST_CASE_ST(ut_setup, ut_teardown,
12492                         test_AES_GCM_authenticated_encryption_test_case_4),
12493                 TEST_CASE_ST(ut_setup, ut_teardown,
12494                         test_AES_GCM_authenticated_encryption_test_case_5),
12495                 TEST_CASE_ST(ut_setup, ut_teardown,
12496                         test_AES_GCM_authenticated_encryption_test_case_6),
12497                 TEST_CASE_ST(ut_setup, ut_teardown,
12498                         test_AES_GCM_authenticated_encryption_test_case_7),
12499
12500                 /** AES GCM Authenticated Decryption */
12501                 TEST_CASE_ST(ut_setup, ut_teardown,
12502                         test_AES_GCM_authenticated_decryption_test_case_1),
12503                 TEST_CASE_ST(ut_setup, ut_teardown,
12504                         test_AES_GCM_authenticated_decryption_test_case_2),
12505                 TEST_CASE_ST(ut_setup, ut_teardown,
12506                         test_AES_GCM_authenticated_decryption_test_case_3),
12507                 TEST_CASE_ST(ut_setup, ut_teardown,
12508                         test_AES_GCM_authenticated_decryption_test_case_4),
12509                 TEST_CASE_ST(ut_setup, ut_teardown,
12510                         test_AES_GCM_authenticated_decryption_test_case_5),
12511                 TEST_CASE_ST(ut_setup, ut_teardown,
12512                         test_AES_GCM_authenticated_decryption_test_case_6),
12513                 TEST_CASE_ST(ut_setup, ut_teardown,
12514                         test_AES_GCM_authenticated_decryption_test_case_7),
12515
12516
12517                 /** AES GCM Authenticated Encryption 192 bits key */
12518                 TEST_CASE_ST(ut_setup, ut_teardown,
12519                         test_AES_GCM_auth_encryption_test_case_192_1),
12520                 TEST_CASE_ST(ut_setup, ut_teardown,
12521                         test_AES_GCM_auth_encryption_test_case_192_2),
12522                 TEST_CASE_ST(ut_setup, ut_teardown,
12523                         test_AES_GCM_auth_encryption_test_case_192_3),
12524                 TEST_CASE_ST(ut_setup, ut_teardown,
12525                         test_AES_GCM_auth_encryption_test_case_192_4),
12526                 TEST_CASE_ST(ut_setup, ut_teardown,
12527                         test_AES_GCM_auth_encryption_test_case_192_5),
12528                 TEST_CASE_ST(ut_setup, ut_teardown,
12529                         test_AES_GCM_auth_encryption_test_case_192_6),
12530                 TEST_CASE_ST(ut_setup, ut_teardown,
12531                         test_AES_GCM_auth_encryption_test_case_192_7),
12532
12533                 /** AES GCM Authenticated Decryption 192 bits key */
12534                 TEST_CASE_ST(ut_setup, ut_teardown,
12535                         test_AES_GCM_auth_decryption_test_case_192_1),
12536                 TEST_CASE_ST(ut_setup, ut_teardown,
12537                         test_AES_GCM_auth_decryption_test_case_192_2),
12538                 TEST_CASE_ST(ut_setup, ut_teardown,
12539                         test_AES_GCM_auth_decryption_test_case_192_3),
12540                 TEST_CASE_ST(ut_setup, ut_teardown,
12541                         test_AES_GCM_auth_decryption_test_case_192_4),
12542                 TEST_CASE_ST(ut_setup, ut_teardown,
12543                         test_AES_GCM_auth_decryption_test_case_192_5),
12544                 TEST_CASE_ST(ut_setup, ut_teardown,
12545                         test_AES_GCM_auth_decryption_test_case_192_6),
12546                 TEST_CASE_ST(ut_setup, ut_teardown,
12547                         test_AES_GCM_auth_decryption_test_case_192_7),
12548
12549                 /** AES GCM Authenticated Encryption 256 bits key */
12550                 TEST_CASE_ST(ut_setup, ut_teardown,
12551                         test_AES_GCM_auth_encryption_test_case_256_1),
12552                 TEST_CASE_ST(ut_setup, ut_teardown,
12553                         test_AES_GCM_auth_encryption_test_case_256_2),
12554                 TEST_CASE_ST(ut_setup, ut_teardown,
12555                         test_AES_GCM_auth_encryption_test_case_256_3),
12556                 TEST_CASE_ST(ut_setup, ut_teardown,
12557                         test_AES_GCM_auth_encryption_test_case_256_4),
12558                 TEST_CASE_ST(ut_setup, ut_teardown,
12559                         test_AES_GCM_auth_encryption_test_case_256_5),
12560                 TEST_CASE_ST(ut_setup, ut_teardown,
12561                         test_AES_GCM_auth_encryption_test_case_256_6),
12562                 TEST_CASE_ST(ut_setup, ut_teardown,
12563                         test_AES_GCM_auth_encryption_test_case_256_7),
12564
12565                 /** AES GCM Authenticated Decryption 256 bits key */
12566                 TEST_CASE_ST(ut_setup, ut_teardown,
12567                         test_AES_GCM_auth_decryption_test_case_256_1),
12568                 TEST_CASE_ST(ut_setup, ut_teardown,
12569                         test_AES_GCM_auth_decryption_test_case_256_2),
12570                 TEST_CASE_ST(ut_setup, ut_teardown,
12571                         test_AES_GCM_auth_decryption_test_case_256_3),
12572                 TEST_CASE_ST(ut_setup, ut_teardown,
12573                         test_AES_GCM_auth_decryption_test_case_256_4),
12574                 TEST_CASE_ST(ut_setup, ut_teardown,
12575                         test_AES_GCM_auth_decryption_test_case_256_5),
12576                 TEST_CASE_ST(ut_setup, ut_teardown,
12577                         test_AES_GCM_auth_decryption_test_case_256_6),
12578                 TEST_CASE_ST(ut_setup, ut_teardown,
12579                         test_AES_GCM_auth_decryption_test_case_256_7),
12580
12581                 /** AES GMAC Authentication */
12582                 TEST_CASE_ST(ut_setup, ut_teardown,
12583                         test_AES_GMAC_authentication_test_case_1),
12584                 TEST_CASE_ST(ut_setup, ut_teardown,
12585                         test_AES_GMAC_authentication_verify_test_case_1),
12586                 TEST_CASE_ST(ut_setup, ut_teardown,
12587                         test_AES_GMAC_authentication_test_case_2),
12588                 TEST_CASE_ST(ut_setup, ut_teardown,
12589                         test_AES_GMAC_authentication_verify_test_case_2),
12590                 TEST_CASE_ST(ut_setup, ut_teardown,
12591                         test_AES_GMAC_authentication_test_case_3),
12592                 TEST_CASE_ST(ut_setup, ut_teardown,
12593                         test_AES_GMAC_authentication_verify_test_case_3),
12594                 TEST_CASE_ST(ut_setup, ut_teardown,
12595                         test_AES_GMAC_authentication_test_case_4),
12596                 TEST_CASE_ST(ut_setup, ut_teardown,
12597                         test_AES_GMAC_authentication_verify_test_case_4),
12598
12599                 /** AES CCM Authenticated Encryption 128 bits key */
12600                 TEST_CASE_ST(ut_setup, ut_teardown,
12601                         test_AES_CCM_authenticated_encryption_test_case_128_1),
12602                 TEST_CASE_ST(ut_setup, ut_teardown,
12603                         test_AES_CCM_authenticated_encryption_test_case_128_2),
12604                 TEST_CASE_ST(ut_setup, ut_teardown,
12605                         test_AES_CCM_authenticated_encryption_test_case_128_3),
12606
12607                 /** AES CCM Authenticated Decryption 128 bits key*/
12608                 TEST_CASE_ST(ut_setup, ut_teardown,
12609                         test_AES_CCM_authenticated_decryption_test_case_128_1),
12610                 TEST_CASE_ST(ut_setup, ut_teardown,
12611                         test_AES_CCM_authenticated_decryption_test_case_128_2),
12612                 TEST_CASE_ST(ut_setup, ut_teardown,
12613                         test_AES_CCM_authenticated_decryption_test_case_128_3),
12614
12615                 /** AES CCM Authenticated Encryption 192 bits key */
12616                 TEST_CASE_ST(ut_setup, ut_teardown,
12617                         test_AES_CCM_authenticated_encryption_test_case_192_1),
12618                 TEST_CASE_ST(ut_setup, ut_teardown,
12619                         test_AES_CCM_authenticated_encryption_test_case_192_2),
12620                 TEST_CASE_ST(ut_setup, ut_teardown,
12621                         test_AES_CCM_authenticated_encryption_test_case_192_3),
12622
12623                 /** AES CCM Authenticated Decryption 192 bits key*/
12624                 TEST_CASE_ST(ut_setup, ut_teardown,
12625                         test_AES_CCM_authenticated_decryption_test_case_192_1),
12626                 TEST_CASE_ST(ut_setup, ut_teardown,
12627                         test_AES_CCM_authenticated_decryption_test_case_192_2),
12628                 TEST_CASE_ST(ut_setup, ut_teardown,
12629                         test_AES_CCM_authenticated_decryption_test_case_192_3),
12630
12631                 /** AES CCM Authenticated Encryption 256 bits key */
12632                 TEST_CASE_ST(ut_setup, ut_teardown,
12633                         test_AES_CCM_authenticated_encryption_test_case_256_1),
12634                 TEST_CASE_ST(ut_setup, ut_teardown,
12635                         test_AES_CCM_authenticated_encryption_test_case_256_2),
12636                 TEST_CASE_ST(ut_setup, ut_teardown,
12637                         test_AES_CCM_authenticated_encryption_test_case_256_3),
12638
12639                 /** AES CCM Authenticated Decryption 256 bits key*/
12640                 TEST_CASE_ST(ut_setup, ut_teardown,
12641                         test_AES_CCM_authenticated_decryption_test_case_256_1),
12642                 TEST_CASE_ST(ut_setup, ut_teardown,
12643                         test_AES_CCM_authenticated_decryption_test_case_256_2),
12644                 TEST_CASE_ST(ut_setup, ut_teardown,
12645                         test_AES_CCM_authenticated_decryption_test_case_256_3),
12646
12647                 /** Scatter-Gather */
12648                 TEST_CASE_ST(ut_setup, ut_teardown,
12649                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12650
12651                 /** Negative tests */
12652                 TEST_CASE_ST(ut_setup, ut_teardown,
12653                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
12654                 TEST_CASE_ST(ut_setup, ut_teardown,
12655                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12656                 TEST_CASE_ST(ut_setup, ut_teardown,
12657                         authentication_verify_AES128_GMAC_fail_data_corrupt),
12658                 TEST_CASE_ST(ut_setup, ut_teardown,
12659                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
12660                 TEST_CASE_ST(ut_setup, ut_teardown,
12661                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12662                 TEST_CASE_ST(ut_setup, ut_teardown,
12663                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12664
12665                 /* ESN Testcase */
12666                 TEST_CASE_ST(ut_setup, ut_teardown,
12667                         auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12668
12669                 TEST_CASE_ST(ut_setup, ut_teardown,
12670                         auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12671
12672                 TEST_CASES_END() /**< NULL terminate unit test array */
12673         }
12674 };
12675
12676 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
12677         .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12678         .setup = testsuite_setup,
12679         .teardown = testsuite_teardown,
12680         .unit_test_cases = {
12681                 /** AES GCM Authenticated Encryption */
12682                 TEST_CASE_ST(ut_setup, ut_teardown,
12683                         test_AES_GCM_authenticated_encryption_test_case_1),
12684                 TEST_CASE_ST(ut_setup, ut_teardown,
12685                         test_AES_GCM_authenticated_encryption_test_case_2),
12686                 TEST_CASE_ST(ut_setup, ut_teardown,
12687                         test_AES_GCM_authenticated_encryption_test_case_3),
12688                 TEST_CASE_ST(ut_setup, ut_teardown,
12689                         test_AES_GCM_authenticated_encryption_test_case_4),
12690                 TEST_CASE_ST(ut_setup, ut_teardown,
12691                         test_AES_GCM_authenticated_encryption_test_case_5),
12692                 TEST_CASE_ST(ut_setup, ut_teardown,
12693                         test_AES_GCM_authenticated_encryption_test_case_6),
12694                 TEST_CASE_ST(ut_setup, ut_teardown,
12695                         test_AES_GCM_authenticated_encryption_test_case_7),
12696
12697                 /** AES GCM Authenticated Decryption */
12698                 TEST_CASE_ST(ut_setup, ut_teardown,
12699                         test_AES_GCM_authenticated_decryption_test_case_1),
12700                 TEST_CASE_ST(ut_setup, ut_teardown,
12701                         test_AES_GCM_authenticated_decryption_test_case_2),
12702                 TEST_CASE_ST(ut_setup, ut_teardown,
12703                         test_AES_GCM_authenticated_decryption_test_case_3),
12704                 TEST_CASE_ST(ut_setup, ut_teardown,
12705                         test_AES_GCM_authenticated_decryption_test_case_4),
12706                 TEST_CASE_ST(ut_setup, ut_teardown,
12707                         test_AES_GCM_authenticated_decryption_test_case_5),
12708                 TEST_CASE_ST(ut_setup, ut_teardown,
12709                         test_AES_GCM_authenticated_decryption_test_case_6),
12710                 TEST_CASE_ST(ut_setup, ut_teardown,
12711                         test_AES_GCM_authenticated_decryption_test_case_7),
12712
12713                 /** AES GCM Authenticated Encryption 192 bits key */
12714                 TEST_CASE_ST(ut_setup, ut_teardown,
12715                         test_AES_GCM_auth_encryption_test_case_192_1),
12716                 TEST_CASE_ST(ut_setup, ut_teardown,
12717                         test_AES_GCM_auth_encryption_test_case_192_2),
12718                 TEST_CASE_ST(ut_setup, ut_teardown,
12719                         test_AES_GCM_auth_encryption_test_case_192_3),
12720                 TEST_CASE_ST(ut_setup, ut_teardown,
12721                         test_AES_GCM_auth_encryption_test_case_192_4),
12722                 TEST_CASE_ST(ut_setup, ut_teardown,
12723                         test_AES_GCM_auth_encryption_test_case_192_5),
12724                 TEST_CASE_ST(ut_setup, ut_teardown,
12725                         test_AES_GCM_auth_encryption_test_case_192_6),
12726                 TEST_CASE_ST(ut_setup, ut_teardown,
12727                         test_AES_GCM_auth_encryption_test_case_192_7),
12728
12729                 /** AES GCM Authenticated Decryption 192 bits key */
12730                 TEST_CASE_ST(ut_setup, ut_teardown,
12731                         test_AES_GCM_auth_decryption_test_case_192_1),
12732                 TEST_CASE_ST(ut_setup, ut_teardown,
12733                         test_AES_GCM_auth_decryption_test_case_192_2),
12734                 TEST_CASE_ST(ut_setup, ut_teardown,
12735                         test_AES_GCM_auth_decryption_test_case_192_3),
12736                 TEST_CASE_ST(ut_setup, ut_teardown,
12737                         test_AES_GCM_auth_decryption_test_case_192_4),
12738                 TEST_CASE_ST(ut_setup, ut_teardown,
12739                         test_AES_GCM_auth_decryption_test_case_192_5),
12740                 TEST_CASE_ST(ut_setup, ut_teardown,
12741                         test_AES_GCM_auth_decryption_test_case_192_6),
12742                 TEST_CASE_ST(ut_setup, ut_teardown,
12743                         test_AES_GCM_auth_decryption_test_case_192_7),
12744
12745                 /** AES GCM Authenticated Encryption 256 bits key */
12746                 TEST_CASE_ST(ut_setup, ut_teardown,
12747                         test_AES_GCM_auth_encryption_test_case_256_1),
12748                 TEST_CASE_ST(ut_setup, ut_teardown,
12749                         test_AES_GCM_auth_encryption_test_case_256_2),
12750                 TEST_CASE_ST(ut_setup, ut_teardown,
12751                         test_AES_GCM_auth_encryption_test_case_256_3),
12752                 TEST_CASE_ST(ut_setup, ut_teardown,
12753                         test_AES_GCM_auth_encryption_test_case_256_4),
12754                 TEST_CASE_ST(ut_setup, ut_teardown,
12755                         test_AES_GCM_auth_encryption_test_case_256_5),
12756                 TEST_CASE_ST(ut_setup, ut_teardown,
12757                         test_AES_GCM_auth_encryption_test_case_256_6),
12758                 TEST_CASE_ST(ut_setup, ut_teardown,
12759                         test_AES_GCM_auth_encryption_test_case_256_7),
12760
12761                 /** AES GCM Authenticated Decryption 256 bits key */
12762                 TEST_CASE_ST(ut_setup, ut_teardown,
12763                         test_AES_GCM_auth_decryption_test_case_256_1),
12764                 TEST_CASE_ST(ut_setup, ut_teardown,
12765                         test_AES_GCM_auth_decryption_test_case_256_2),
12766                 TEST_CASE_ST(ut_setup, ut_teardown,
12767                         test_AES_GCM_auth_decryption_test_case_256_3),
12768                 TEST_CASE_ST(ut_setup, ut_teardown,
12769                         test_AES_GCM_auth_decryption_test_case_256_4),
12770                 TEST_CASE_ST(ut_setup, ut_teardown,
12771                         test_AES_GCM_auth_decryption_test_case_256_5),
12772                 TEST_CASE_ST(ut_setup, ut_teardown,
12773                         test_AES_GCM_auth_decryption_test_case_256_6),
12774                 TEST_CASE_ST(ut_setup, ut_teardown,
12775                         test_AES_GCM_auth_decryption_test_case_256_7),
12776
12777                 /** AES GCM Authenticated Encryption big aad size */
12778                 TEST_CASE_ST(ut_setup, ut_teardown,
12779                         test_AES_GCM_auth_encryption_test_case_aad_1),
12780                 TEST_CASE_ST(ut_setup, ut_teardown,
12781                         test_AES_GCM_auth_encryption_test_case_aad_2),
12782
12783                 /** AES GCM Authenticated Decryption big aad size */
12784                 TEST_CASE_ST(ut_setup, ut_teardown,
12785                         test_AES_GCM_auth_decryption_test_case_aad_1),
12786                 TEST_CASE_ST(ut_setup, ut_teardown,
12787                         test_AES_GCM_auth_decryption_test_case_aad_2),
12788
12789                 /** AES GMAC Authentication */
12790                 TEST_CASE_ST(ut_setup, ut_teardown,
12791                         test_AES_GMAC_authentication_test_case_1),
12792                 TEST_CASE_ST(ut_setup, ut_teardown,
12793                         test_AES_GMAC_authentication_verify_test_case_1),
12794                 TEST_CASE_ST(ut_setup, ut_teardown,
12795                         test_AES_GMAC_authentication_test_case_3),
12796                 TEST_CASE_ST(ut_setup, ut_teardown,
12797                         test_AES_GMAC_authentication_verify_test_case_3),
12798                 TEST_CASE_ST(ut_setup, ut_teardown,
12799                         test_AES_GMAC_authentication_test_case_4),
12800                 TEST_CASE_ST(ut_setup, ut_teardown,
12801                         test_AES_GMAC_authentication_verify_test_case_4),
12802
12803                 /** Negative tests */
12804                 TEST_CASE_ST(ut_setup, ut_teardown,
12805                         authentication_verify_AES128_GMAC_fail_data_corrupt),
12806                 TEST_CASE_ST(ut_setup, ut_teardown,
12807                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
12808
12809                 /** Out of place tests */
12810                 TEST_CASE_ST(ut_setup, ut_teardown,
12811                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
12812                 TEST_CASE_ST(ut_setup, ut_teardown,
12813                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
12814
12815                 /** Session-less tests */
12816                 TEST_CASE_ST(ut_setup, ut_teardown,
12817                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12818                 TEST_CASE_ST(ut_setup, ut_teardown,
12819                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12820
12821                 /** Scatter-Gather */
12822                 TEST_CASE_ST(ut_setup, ut_teardown,
12823                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12824
12825                 TEST_CASES_END() /**< NULL terminate unit test array */
12826         }
12827 };
12828
12829 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
12830         .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12831         .setup = testsuite_setup,
12832         .teardown = testsuite_teardown,
12833         .unit_test_cases = {
12834                 /** KASUMI encrypt only (UEA1) */
12835                 TEST_CASE_ST(ut_setup, ut_teardown,
12836                         test_kasumi_encryption_test_case_1),
12837                 TEST_CASE_ST(ut_setup, ut_teardown,
12838                         test_kasumi_encryption_test_case_1_sgl),
12839                 TEST_CASE_ST(ut_setup, ut_teardown,
12840                         test_kasumi_encryption_test_case_2),
12841                 TEST_CASE_ST(ut_setup, ut_teardown,
12842                         test_kasumi_encryption_test_case_3),
12843                 TEST_CASE_ST(ut_setup, ut_teardown,
12844                         test_kasumi_encryption_test_case_4),
12845                 TEST_CASE_ST(ut_setup, ut_teardown,
12846                         test_kasumi_encryption_test_case_5),
12847                 /** KASUMI decrypt only (UEA1) */
12848                 TEST_CASE_ST(ut_setup, ut_teardown,
12849                         test_kasumi_decryption_test_case_1),
12850                 TEST_CASE_ST(ut_setup, ut_teardown,
12851                         test_kasumi_decryption_test_case_2),
12852                 TEST_CASE_ST(ut_setup, ut_teardown,
12853                         test_kasumi_decryption_test_case_3),
12854                 TEST_CASE_ST(ut_setup, ut_teardown,
12855                         test_kasumi_decryption_test_case_4),
12856                 TEST_CASE_ST(ut_setup, ut_teardown,
12857                         test_kasumi_decryption_test_case_5),
12858
12859                 TEST_CASE_ST(ut_setup, ut_teardown,
12860                         test_kasumi_encryption_test_case_1_oop),
12861                 TEST_CASE_ST(ut_setup, ut_teardown,
12862                         test_kasumi_encryption_test_case_1_oop_sgl),
12863
12864
12865                 TEST_CASE_ST(ut_setup, ut_teardown,
12866                         test_kasumi_decryption_test_case_1_oop),
12867
12868                 /** KASUMI hash only (UIA1) */
12869                 TEST_CASE_ST(ut_setup, ut_teardown,
12870                         test_kasumi_hash_generate_test_case_1),
12871                 TEST_CASE_ST(ut_setup, ut_teardown,
12872                         test_kasumi_hash_generate_test_case_2),
12873                 TEST_CASE_ST(ut_setup, ut_teardown,
12874                         test_kasumi_hash_generate_test_case_3),
12875                 TEST_CASE_ST(ut_setup, ut_teardown,
12876                         test_kasumi_hash_generate_test_case_4),
12877                 TEST_CASE_ST(ut_setup, ut_teardown,
12878                         test_kasumi_hash_generate_test_case_5),
12879                 TEST_CASE_ST(ut_setup, ut_teardown,
12880                         test_kasumi_hash_generate_test_case_6),
12881                 TEST_CASE_ST(ut_setup, ut_teardown,
12882                         test_kasumi_hash_verify_test_case_1),
12883                 TEST_CASE_ST(ut_setup, ut_teardown,
12884                         test_kasumi_hash_verify_test_case_2),
12885                 TEST_CASE_ST(ut_setup, ut_teardown,
12886                         test_kasumi_hash_verify_test_case_3),
12887                 TEST_CASE_ST(ut_setup, ut_teardown,
12888                         test_kasumi_hash_verify_test_case_4),
12889                 TEST_CASE_ST(ut_setup, ut_teardown,
12890                         test_kasumi_hash_verify_test_case_5),
12891                 TEST_CASE_ST(ut_setup, ut_teardown,
12892                         test_kasumi_cipher_auth_test_case_1),
12893
12894                 /** KASUMI generate auth, then encrypt (F8) */
12895                 TEST_CASE_ST(ut_setup, ut_teardown,
12896                         test_kasumi_auth_cipher_test_case_1),
12897                 TEST_CASE_ST(ut_setup, ut_teardown,
12898                         test_kasumi_auth_cipher_test_case_2),
12899                 TEST_CASE_ST(ut_setup, ut_teardown,
12900                         test_kasumi_auth_cipher_test_case_2_oop),
12901                 TEST_CASE_ST(ut_setup, ut_teardown,
12902                         test_kasumi_auth_cipher_test_case_2_sgl),
12903                 TEST_CASE_ST(ut_setup, ut_teardown,
12904                         test_kasumi_auth_cipher_test_case_2_oop_sgl),
12905
12906                 /** KASUMI decrypt (F8), then verify auth */
12907                 TEST_CASE_ST(ut_setup, ut_teardown,
12908                         test_kasumi_auth_cipher_verify_test_case_1),
12909                 TEST_CASE_ST(ut_setup, ut_teardown,
12910                         test_kasumi_auth_cipher_verify_test_case_2),
12911                 TEST_CASE_ST(ut_setup, ut_teardown,
12912                         test_kasumi_auth_cipher_verify_test_case_2_oop),
12913                 TEST_CASE_ST(ut_setup, ut_teardown,
12914                         test_kasumi_auth_cipher_verify_test_case_2_sgl),
12915                 TEST_CASE_ST(ut_setup, ut_teardown,
12916                         test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12917                 TEST_CASES_END() /**< NULL terminate unit test array */
12918         }
12919 };
12920 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
12921         .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12922         .setup = testsuite_setup,
12923         .teardown = testsuite_teardown,
12924         .unit_test_cases = {
12925                 /** SNOW 3G encrypt only (UEA2) */
12926                 TEST_CASE_ST(ut_setup, ut_teardown,
12927                         test_snow3g_encryption_test_case_1),
12928                 TEST_CASE_ST(ut_setup, ut_teardown,
12929                         test_snow3g_encryption_test_case_2),
12930                 TEST_CASE_ST(ut_setup, ut_teardown,
12931                         test_snow3g_encryption_test_case_3),
12932                 TEST_CASE_ST(ut_setup, ut_teardown,
12933                         test_snow3g_encryption_test_case_4),
12934                 TEST_CASE_ST(ut_setup, ut_teardown,
12935                         test_snow3g_encryption_test_case_5),
12936                 TEST_CASE_ST(ut_setup, ut_teardown,
12937                         test_snow3g_auth_cipher_with_digest_test_case_1),
12938
12939                 TEST_CASE_ST(ut_setup, ut_teardown,
12940                         test_snow3g_encryption_test_case_1_oop),
12941                 TEST_CASE_ST(ut_setup, ut_teardown,
12942                                 test_snow3g_encryption_test_case_1_oop_sgl),
12943                 TEST_CASE_ST(ut_setup, ut_teardown,
12944                         test_snow3g_decryption_test_case_1_oop),
12945
12946                 TEST_CASE_ST(ut_setup, ut_teardown,
12947                         test_snow3g_encryption_test_case_1_offset_oop),
12948
12949                 /** SNOW 3G decrypt only (UEA2) */
12950                 TEST_CASE_ST(ut_setup, ut_teardown,
12951                         test_snow3g_decryption_test_case_1),
12952                 TEST_CASE_ST(ut_setup, ut_teardown,
12953                         test_snow3g_decryption_test_case_2),
12954                 TEST_CASE_ST(ut_setup, ut_teardown,
12955                         test_snow3g_decryption_test_case_3),
12956                 TEST_CASE_ST(ut_setup, ut_teardown,
12957                         test_snow3g_decryption_test_case_4),
12958                 TEST_CASE_ST(ut_setup, ut_teardown,
12959                         test_snow3g_decryption_test_case_5),
12960                 TEST_CASE_ST(ut_setup, ut_teardown,
12961                         test_snow3g_decryption_with_digest_test_case_1),
12962                 TEST_CASE_ST(ut_setup, ut_teardown,
12963                         test_snow3g_hash_generate_test_case_1),
12964                 TEST_CASE_ST(ut_setup, ut_teardown,
12965                         test_snow3g_hash_generate_test_case_2),
12966                 TEST_CASE_ST(ut_setup, ut_teardown,
12967                         test_snow3g_hash_generate_test_case_3),
12968                 /* Tests with buffers which length is not byte-aligned */
12969                 TEST_CASE_ST(ut_setup, ut_teardown,
12970                         test_snow3g_hash_generate_test_case_4),
12971                 TEST_CASE_ST(ut_setup, ut_teardown,
12972                         test_snow3g_hash_generate_test_case_5),
12973                 TEST_CASE_ST(ut_setup, ut_teardown,
12974                         test_snow3g_hash_generate_test_case_6),
12975                 TEST_CASE_ST(ut_setup, ut_teardown,
12976                         test_snow3g_hash_verify_test_case_1),
12977                 TEST_CASE_ST(ut_setup, ut_teardown,
12978                         test_snow3g_hash_verify_test_case_2),
12979                 TEST_CASE_ST(ut_setup, ut_teardown,
12980                         test_snow3g_hash_verify_test_case_3),
12981                 /* Tests with buffers which length is not byte-aligned */
12982                 TEST_CASE_ST(ut_setup, ut_teardown,
12983                         test_snow3g_hash_verify_test_case_4),
12984                 TEST_CASE_ST(ut_setup, ut_teardown,
12985                         test_snow3g_hash_verify_test_case_5),
12986                 TEST_CASE_ST(ut_setup, ut_teardown,
12987                         test_snow3g_hash_verify_test_case_6),
12988                 TEST_CASE_ST(ut_setup, ut_teardown,
12989                         test_snow3g_cipher_auth_test_case_1),
12990
12991                 /** SNOW 3G generate auth, then encrypt (UEA2) */
12992                 TEST_CASE_ST(ut_setup, ut_teardown,
12993                         test_snow3g_auth_cipher_test_case_1),
12994                 TEST_CASE_ST(ut_setup, ut_teardown,
12995                         test_snow3g_auth_cipher_test_case_2),
12996                 TEST_CASE_ST(ut_setup, ut_teardown,
12997                         test_snow3g_auth_cipher_test_case_2_oop),
12998                 TEST_CASE_ST(ut_setup, ut_teardown,
12999                         test_snow3g_auth_cipher_part_digest_enc),
13000                 TEST_CASE_ST(ut_setup, ut_teardown,
13001                         test_snow3g_auth_cipher_part_digest_enc_oop),
13002                 TEST_CASE_ST(ut_setup, ut_teardown,
13003                         test_snow3g_auth_cipher_test_case_3_sgl),
13004                 TEST_CASE_ST(ut_setup, ut_teardown,
13005                         test_snow3g_auth_cipher_test_case_3_oop_sgl),
13006                 TEST_CASE_ST(ut_setup, ut_teardown,
13007                         test_snow3g_auth_cipher_part_digest_enc_sgl),
13008                 TEST_CASE_ST(ut_setup, ut_teardown,
13009                         test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13010
13011                 /** SNOW 3G decrypt (UEA2), then verify auth */
13012                 TEST_CASE_ST(ut_setup, ut_teardown,
13013                         test_snow3g_auth_cipher_verify_test_case_1),
13014                 TEST_CASE_ST(ut_setup, ut_teardown,
13015                         test_snow3g_auth_cipher_verify_test_case_2),
13016                 TEST_CASE_ST(ut_setup, ut_teardown,
13017                         test_snow3g_auth_cipher_verify_test_case_2_oop),
13018                 TEST_CASE_ST(ut_setup, ut_teardown,
13019                         test_snow3g_auth_cipher_verify_part_digest_enc),
13020                 TEST_CASE_ST(ut_setup, ut_teardown,
13021                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13022                 TEST_CASE_ST(ut_setup, ut_teardown,
13023                         test_snow3g_auth_cipher_verify_test_case_3_sgl),
13024                 TEST_CASE_ST(ut_setup, ut_teardown,
13025                         test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13026                 TEST_CASE_ST(ut_setup, ut_teardown,
13027                         test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13028                 TEST_CASE_ST(ut_setup, ut_teardown,
13029                         test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13030
13031                 TEST_CASES_END() /**< NULL terminate unit test array */
13032         }
13033 };
13034
13035 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
13036         .suite_name = "Crypto Device SW ZUC Unit Test Suite",
13037         .setup = testsuite_setup,
13038         .teardown = testsuite_teardown,
13039         .unit_test_cases = {
13040                 /** ZUC encrypt only (EEA3) */
13041                 TEST_CASE_ST(ut_setup, ut_teardown,
13042                         test_zuc_encryption_test_case_1),
13043                 TEST_CASE_ST(ut_setup, ut_teardown,
13044                         test_zuc_encryption_test_case_2),
13045                 TEST_CASE_ST(ut_setup, ut_teardown,
13046                         test_zuc_encryption_test_case_3),
13047                 TEST_CASE_ST(ut_setup, ut_teardown,
13048                         test_zuc_encryption_test_case_4),
13049                 TEST_CASE_ST(ut_setup, ut_teardown,
13050                         test_zuc_encryption_test_case_5),
13051                 TEST_CASE_ST(ut_setup, ut_teardown,
13052                         test_zuc_hash_generate_test_case_1),
13053                 TEST_CASE_ST(ut_setup, ut_teardown,
13054                         test_zuc_hash_generate_test_case_2),
13055                 TEST_CASE_ST(ut_setup, ut_teardown,
13056                         test_zuc_hash_generate_test_case_3),
13057                 TEST_CASE_ST(ut_setup, ut_teardown,
13058                         test_zuc_hash_generate_test_case_4),
13059                 TEST_CASE_ST(ut_setup, ut_teardown,
13060                         test_zuc_hash_generate_test_case_5),
13061                 TEST_CASE_ST(ut_setup, ut_teardown,
13062                         test_zuc_encryption_test_case_6_sgl),
13063                 TEST_CASES_END() /**< NULL terminate unit test array */
13064         }
13065 };
13066
13067 static struct unit_test_suite cryptodev_caam_jr_testsuite  = {
13068         .suite_name = "Crypto CAAM JR Unit Test Suite",
13069         .setup = testsuite_setup,
13070         .teardown = testsuite_teardown,
13071         .unit_test_cases = {
13072                 TEST_CASE_ST(ut_setup, ut_teardown,
13073                              test_device_configure_invalid_dev_id),
13074                 TEST_CASE_ST(ut_setup, ut_teardown,
13075                              test_multi_session),
13076
13077                 TEST_CASE_ST(ut_setup, ut_teardown,
13078                              test_AES_chain_caam_jr_all),
13079                 TEST_CASE_ST(ut_setup, ut_teardown,
13080                              test_3DES_chain_caam_jr_all),
13081                 TEST_CASE_ST(ut_setup, ut_teardown,
13082                              test_AES_cipheronly_caam_jr_all),
13083                 TEST_CASE_ST(ut_setup, ut_teardown,
13084                              test_3DES_cipheronly_caam_jr_all),
13085                 TEST_CASE_ST(ut_setup, ut_teardown,
13086                              test_authonly_caam_jr_all),
13087
13088                 TEST_CASES_END() /**< NULL terminate unit test array */
13089         }
13090 };
13091
13092 static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
13093         .suite_name = "Crypto DPAA_SEC Unit Test Suite",
13094         .setup = testsuite_setup,
13095         .teardown = testsuite_teardown,
13096         .unit_test_cases = {
13097                 TEST_CASE_ST(ut_setup, ut_teardown,
13098                              test_device_configure_invalid_dev_id),
13099                 TEST_CASE_ST(ut_setup, ut_teardown,
13100                              test_multi_session),
13101
13102                 TEST_CASE_ST(ut_setup, ut_teardown,
13103                              test_AES_chain_dpaa_sec_all),
13104                 TEST_CASE_ST(ut_setup, ut_teardown,
13105                              test_3DES_chain_dpaa_sec_all),
13106                 TEST_CASE_ST(ut_setup, ut_teardown,
13107                              test_AES_cipheronly_dpaa_sec_all),
13108                 TEST_CASE_ST(ut_setup, ut_teardown,
13109                              test_3DES_cipheronly_dpaa_sec_all),
13110                 TEST_CASE_ST(ut_setup, ut_teardown,
13111                              test_authonly_dpaa_sec_all),
13112
13113 #ifdef RTE_LIBRTE_SECURITY
13114                 TEST_CASE_ST(ut_setup, ut_teardown,
13115                         test_PDCP_PROTO_cplane_encap_all),
13116
13117                 TEST_CASE_ST(ut_setup, ut_teardown,
13118                         test_PDCP_PROTO_cplane_decap_all),
13119
13120                 TEST_CASE_ST(ut_setup, ut_teardown,
13121                         test_PDCP_PROTO_uplane_encap_all),
13122
13123                 TEST_CASE_ST(ut_setup, ut_teardown,
13124                         test_PDCP_PROTO_uplane_decap_all),
13125
13126                 TEST_CASE_ST(ut_setup, ut_teardown,
13127                         test_PDCP_PROTO_SGL_in_place_32B),
13128                 TEST_CASE_ST(ut_setup, ut_teardown,
13129                         test_PDCP_PROTO_SGL_oop_32B_128B),
13130                 TEST_CASE_ST(ut_setup, ut_teardown,
13131                         test_PDCP_PROTO_SGL_oop_32B_40B),
13132                 TEST_CASE_ST(ut_setup, ut_teardown,
13133                         test_PDCP_PROTO_SGL_oop_128B_32B),
13134 #endif
13135                 /** AES GCM Authenticated Encryption */
13136                 TEST_CASE_ST(ut_setup, ut_teardown,
13137                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13138                 TEST_CASE_ST(ut_setup, ut_teardown,
13139                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13140                 TEST_CASE_ST(ut_setup, ut_teardown,
13141                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13142                 TEST_CASE_ST(ut_setup, ut_teardown,
13143                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13144                 TEST_CASE_ST(ut_setup, ut_teardown,
13145                         test_AES_GCM_authenticated_encryption_test_case_1),
13146                 TEST_CASE_ST(ut_setup, ut_teardown,
13147                         test_AES_GCM_authenticated_encryption_test_case_2),
13148                 TEST_CASE_ST(ut_setup, ut_teardown,
13149                         test_AES_GCM_authenticated_encryption_test_case_3),
13150                 TEST_CASE_ST(ut_setup, ut_teardown,
13151                         test_AES_GCM_authenticated_encryption_test_case_4),
13152                 TEST_CASE_ST(ut_setup, ut_teardown,
13153                         test_AES_GCM_authenticated_encryption_test_case_5),
13154                 TEST_CASE_ST(ut_setup, ut_teardown,
13155                         test_AES_GCM_authenticated_encryption_test_case_6),
13156                 TEST_CASE_ST(ut_setup, ut_teardown,
13157                         test_AES_GCM_authenticated_encryption_test_case_7),
13158                 TEST_CASE_ST(ut_setup, ut_teardown,
13159                         test_AES_GCM_authenticated_encryption_test_case_8),
13160
13161                 /** AES GCM Authenticated Decryption */
13162                 TEST_CASE_ST(ut_setup, ut_teardown,
13163                         test_AES_GCM_authenticated_decryption_test_case_1),
13164                 TEST_CASE_ST(ut_setup, ut_teardown,
13165                         test_AES_GCM_authenticated_decryption_test_case_2),
13166                 TEST_CASE_ST(ut_setup, ut_teardown,
13167                         test_AES_GCM_authenticated_decryption_test_case_3),
13168                 TEST_CASE_ST(ut_setup, ut_teardown,
13169                         test_AES_GCM_authenticated_decryption_test_case_4),
13170                 TEST_CASE_ST(ut_setup, ut_teardown,
13171                         test_AES_GCM_authenticated_decryption_test_case_5),
13172                 TEST_CASE_ST(ut_setup, ut_teardown,
13173                         test_AES_GCM_authenticated_decryption_test_case_6),
13174                 TEST_CASE_ST(ut_setup, ut_teardown,
13175                         test_AES_GCM_authenticated_decryption_test_case_7),
13176                 TEST_CASE_ST(ut_setup, ut_teardown,
13177                         test_AES_GCM_authenticated_decryption_test_case_8),
13178
13179                 /** AES GCM Authenticated Encryption 192 bits key */
13180                 TEST_CASE_ST(ut_setup, ut_teardown,
13181                         test_AES_GCM_auth_encryption_test_case_192_1),
13182                 TEST_CASE_ST(ut_setup, ut_teardown,
13183                         test_AES_GCM_auth_encryption_test_case_192_2),
13184                 TEST_CASE_ST(ut_setup, ut_teardown,
13185                         test_AES_GCM_auth_encryption_test_case_192_3),
13186                 TEST_CASE_ST(ut_setup, ut_teardown,
13187                         test_AES_GCM_auth_encryption_test_case_192_4),
13188                 TEST_CASE_ST(ut_setup, ut_teardown,
13189                         test_AES_GCM_auth_encryption_test_case_192_5),
13190                 TEST_CASE_ST(ut_setup, ut_teardown,
13191                         test_AES_GCM_auth_encryption_test_case_192_6),
13192                 TEST_CASE_ST(ut_setup, ut_teardown,
13193                         test_AES_GCM_auth_encryption_test_case_192_7),
13194
13195                 /** AES GCM Authenticated Decryption 192 bits key */
13196                 TEST_CASE_ST(ut_setup, ut_teardown,
13197                         test_AES_GCM_auth_decryption_test_case_192_1),
13198                 TEST_CASE_ST(ut_setup, ut_teardown,
13199                         test_AES_GCM_auth_decryption_test_case_192_2),
13200                 TEST_CASE_ST(ut_setup, ut_teardown,
13201                         test_AES_GCM_auth_decryption_test_case_192_3),
13202                 TEST_CASE_ST(ut_setup, ut_teardown,
13203                         test_AES_GCM_auth_decryption_test_case_192_4),
13204                 TEST_CASE_ST(ut_setup, ut_teardown,
13205                         test_AES_GCM_auth_decryption_test_case_192_5),
13206                 TEST_CASE_ST(ut_setup, ut_teardown,
13207                         test_AES_GCM_auth_decryption_test_case_192_6),
13208                 TEST_CASE_ST(ut_setup, ut_teardown,
13209                         test_AES_GCM_auth_decryption_test_case_192_7),
13210
13211                 /** AES GCM Authenticated Encryption 256 bits key */
13212                 TEST_CASE_ST(ut_setup, ut_teardown,
13213                         test_AES_GCM_auth_encryption_test_case_256_1),
13214                 TEST_CASE_ST(ut_setup, ut_teardown,
13215                         test_AES_GCM_auth_encryption_test_case_256_2),
13216                 TEST_CASE_ST(ut_setup, ut_teardown,
13217                         test_AES_GCM_auth_encryption_test_case_256_3),
13218                 TEST_CASE_ST(ut_setup, ut_teardown,
13219                         test_AES_GCM_auth_encryption_test_case_256_4),
13220                 TEST_CASE_ST(ut_setup, ut_teardown,
13221                         test_AES_GCM_auth_encryption_test_case_256_5),
13222                 TEST_CASE_ST(ut_setup, ut_teardown,
13223                         test_AES_GCM_auth_encryption_test_case_256_6),
13224                 TEST_CASE_ST(ut_setup, ut_teardown,
13225                         test_AES_GCM_auth_encryption_test_case_256_7),
13226
13227                 /** AES GCM Authenticated Decryption 256 bits key */
13228                 TEST_CASE_ST(ut_setup, ut_teardown,
13229                         test_AES_GCM_auth_decryption_test_case_256_1),
13230                 TEST_CASE_ST(ut_setup, ut_teardown,
13231                         test_AES_GCM_auth_decryption_test_case_256_2),
13232                 TEST_CASE_ST(ut_setup, ut_teardown,
13233                         test_AES_GCM_auth_decryption_test_case_256_3),
13234                 TEST_CASE_ST(ut_setup, ut_teardown,
13235                         test_AES_GCM_auth_decryption_test_case_256_4),
13236                 TEST_CASE_ST(ut_setup, ut_teardown,
13237                         test_AES_GCM_auth_decryption_test_case_256_5),
13238                 TEST_CASE_ST(ut_setup, ut_teardown,
13239                         test_AES_GCM_auth_decryption_test_case_256_6),
13240                 TEST_CASE_ST(ut_setup, ut_teardown,
13241                         test_AES_GCM_auth_decryption_test_case_256_7),
13242
13243                 /** Out of place tests */
13244                 TEST_CASE_ST(ut_setup, ut_teardown,
13245                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
13246                 TEST_CASE_ST(ut_setup, ut_teardown,
13247                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
13248
13249                 /** SNOW 3G encrypt only (UEA2) */
13250                 TEST_CASE_ST(ut_setup, ut_teardown,
13251                         test_snow3g_encryption_test_case_1),
13252                 TEST_CASE_ST(ut_setup, ut_teardown,
13253                         test_snow3g_encryption_test_case_2),
13254                 TEST_CASE_ST(ut_setup, ut_teardown,
13255                         test_snow3g_encryption_test_case_3),
13256                 TEST_CASE_ST(ut_setup, ut_teardown,
13257                         test_snow3g_encryption_test_case_4),
13258                 TEST_CASE_ST(ut_setup, ut_teardown,
13259                         test_snow3g_encryption_test_case_5),
13260
13261                 TEST_CASE_ST(ut_setup, ut_teardown,
13262                         test_snow3g_encryption_test_case_1_oop),
13263                 TEST_CASE_ST(ut_setup, ut_teardown,
13264                                 test_snow3g_encryption_test_case_1_oop_sgl),
13265                 TEST_CASE_ST(ut_setup, ut_teardown,
13266                         test_snow3g_decryption_test_case_1_oop),
13267
13268                 /** SNOW 3G decrypt only (UEA2) */
13269                 TEST_CASE_ST(ut_setup, ut_teardown,
13270                         test_snow3g_decryption_test_case_1),
13271                 TEST_CASE_ST(ut_setup, ut_teardown,
13272                         test_snow3g_decryption_test_case_2),
13273                 TEST_CASE_ST(ut_setup, ut_teardown,
13274                         test_snow3g_decryption_test_case_3),
13275                 TEST_CASE_ST(ut_setup, ut_teardown,
13276                         test_snow3g_decryption_test_case_4),
13277                 TEST_CASE_ST(ut_setup, ut_teardown,
13278                         test_snow3g_decryption_test_case_5),
13279
13280                 TEST_CASE_ST(ut_setup, ut_teardown,
13281                         test_snow3g_hash_generate_test_case_1),
13282                 TEST_CASE_ST(ut_setup, ut_teardown,
13283                         test_snow3g_hash_generate_test_case_2),
13284                 TEST_CASE_ST(ut_setup, ut_teardown,
13285                         test_snow3g_hash_generate_test_case_3),
13286                 TEST_CASE_ST(ut_setup, ut_teardown,
13287                         test_snow3g_hash_verify_test_case_1),
13288                 TEST_CASE_ST(ut_setup, ut_teardown,
13289                         test_snow3g_hash_verify_test_case_2),
13290                 TEST_CASE_ST(ut_setup, ut_teardown,
13291                         test_snow3g_hash_verify_test_case_3),
13292
13293                 /** ZUC encrypt only (EEA3) */
13294                 TEST_CASE_ST(ut_setup, ut_teardown,
13295                         test_zuc_encryption_test_case_1),
13296                 TEST_CASE_ST(ut_setup, ut_teardown,
13297                         test_zuc_encryption_test_case_2),
13298                 TEST_CASE_ST(ut_setup, ut_teardown,
13299                         test_zuc_encryption_test_case_3),
13300                 TEST_CASE_ST(ut_setup, ut_teardown,
13301                         test_zuc_encryption_test_case_4),
13302                 TEST_CASE_ST(ut_setup, ut_teardown,
13303                         test_zuc_encryption_test_case_5),
13304
13305                 /** ZUC authenticate (EIA3) */
13306                 TEST_CASE_ST(ut_setup, ut_teardown,
13307                         test_zuc_hash_generate_test_case_6),
13308                 TEST_CASE_ST(ut_setup, ut_teardown,
13309                         test_zuc_hash_generate_test_case_7),
13310                 TEST_CASE_ST(ut_setup, ut_teardown,
13311                         test_zuc_hash_generate_test_case_8),
13312
13313                 /** Negative tests */
13314                 TEST_CASE_ST(ut_setup, ut_teardown,
13315                         test_AES_GCM_auth_encryption_fail_iv_corrupt),
13316                 TEST_CASE_ST(ut_setup, ut_teardown,
13317                         test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13318                 TEST_CASE_ST(ut_setup, ut_teardown,
13319                         test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13320                 TEST_CASE_ST(ut_setup, ut_teardown,
13321                         test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13322                 TEST_CASE_ST(ut_setup, ut_teardown,
13323                         test_AES_GCM_auth_encryption_fail_aad_corrupt),
13324                 TEST_CASE_ST(ut_setup, ut_teardown,
13325                         test_AES_GCM_auth_encryption_fail_tag_corrupt),
13326                 TEST_CASE_ST(ut_setup, ut_teardown,
13327                         test_AES_GCM_auth_decryption_fail_iv_corrupt),
13328                 TEST_CASE_ST(ut_setup, ut_teardown,
13329                         test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13330                 TEST_CASE_ST(ut_setup, ut_teardown,
13331                         test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13332                 TEST_CASE_ST(ut_setup, ut_teardown,
13333                         test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13334                 TEST_CASE_ST(ut_setup, ut_teardown,
13335                         test_AES_GCM_auth_decryption_fail_aad_corrupt),
13336                 TEST_CASE_ST(ut_setup, ut_teardown,
13337                         test_AES_GCM_auth_decryption_fail_tag_corrupt),
13338                 TEST_CASE_ST(ut_setup, ut_teardown,
13339                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
13340                 TEST_CASE_ST(ut_setup, ut_teardown,
13341                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13342                 TEST_CASE_ST(ut_setup, ut_teardown,
13343                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13344                 TEST_CASE_ST(ut_setup, ut_teardown,
13345                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13346
13347                 /* ESN Testcase */
13348                 TEST_CASE_ST(ut_setup, ut_teardown,
13349                         auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13350                 TEST_CASE_ST(ut_setup, ut_teardown,
13351                         auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13352
13353                 TEST_CASES_END() /**< NULL terminate unit test array */
13354         }
13355 };
13356
13357 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
13358         .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13359         .setup = testsuite_setup,
13360         .teardown = testsuite_teardown,
13361         .unit_test_cases = {
13362                 TEST_CASE_ST(ut_setup, ut_teardown,
13363                         test_device_configure_invalid_dev_id),
13364                 TEST_CASE_ST(ut_setup, ut_teardown,
13365                         test_multi_session),
13366                 TEST_CASE_ST(ut_setup, ut_teardown,
13367                         test_AES_chain_dpaa2_sec_all),
13368                 TEST_CASE_ST(ut_setup, ut_teardown,
13369                         test_3DES_chain_dpaa2_sec_all),
13370                 TEST_CASE_ST(ut_setup, ut_teardown,
13371                         test_AES_cipheronly_dpaa2_sec_all),
13372                 TEST_CASE_ST(ut_setup, ut_teardown,
13373                         test_3DES_cipheronly_dpaa2_sec_all),
13374                 TEST_CASE_ST(ut_setup, ut_teardown,
13375                         test_authonly_dpaa2_sec_all),
13376
13377 #ifdef RTE_LIBRTE_SECURITY
13378                 TEST_CASE_ST(ut_setup, ut_teardown,
13379                         test_PDCP_PROTO_cplane_encap_all),
13380
13381                 TEST_CASE_ST(ut_setup, ut_teardown,
13382                         test_PDCP_PROTO_cplane_decap_all),
13383
13384                 TEST_CASE_ST(ut_setup, ut_teardown,
13385                         test_PDCP_PROTO_uplane_encap_all),
13386
13387                 TEST_CASE_ST(ut_setup, ut_teardown,
13388                         test_PDCP_PROTO_uplane_decap_all),
13389
13390                 TEST_CASE_ST(ut_setup, ut_teardown,
13391                         test_PDCP_PROTO_SGL_in_place_32B),
13392                 TEST_CASE_ST(ut_setup, ut_teardown,
13393                         test_PDCP_PROTO_SGL_oop_32B_128B),
13394                 TEST_CASE_ST(ut_setup, ut_teardown,
13395                         test_PDCP_PROTO_SGL_oop_32B_40B),
13396                 TEST_CASE_ST(ut_setup, ut_teardown,
13397                         test_PDCP_PROTO_SGL_oop_128B_32B),
13398 #endif
13399                 /** AES GCM Authenticated Encryption */
13400                 TEST_CASE_ST(ut_setup, ut_teardown,
13401                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13402                 TEST_CASE_ST(ut_setup, ut_teardown,
13403                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13404                 TEST_CASE_ST(ut_setup, ut_teardown,
13405                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13406                 TEST_CASE_ST(ut_setup, ut_teardown,
13407                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13408                 TEST_CASE_ST(ut_setup, ut_teardown,
13409                         test_AES_GCM_authenticated_encryption_test_case_1),
13410                 TEST_CASE_ST(ut_setup, ut_teardown,
13411                         test_AES_GCM_authenticated_encryption_test_case_2),
13412                 TEST_CASE_ST(ut_setup, ut_teardown,
13413                         test_AES_GCM_authenticated_encryption_test_case_3),
13414                 TEST_CASE_ST(ut_setup, ut_teardown,
13415                         test_AES_GCM_authenticated_encryption_test_case_4),
13416                 TEST_CASE_ST(ut_setup, ut_teardown,
13417                         test_AES_GCM_authenticated_encryption_test_case_5),
13418                 TEST_CASE_ST(ut_setup, ut_teardown,
13419                         test_AES_GCM_authenticated_encryption_test_case_6),
13420                 TEST_CASE_ST(ut_setup, ut_teardown,
13421                         test_AES_GCM_authenticated_encryption_test_case_7),
13422                 TEST_CASE_ST(ut_setup, ut_teardown,
13423                         test_AES_GCM_authenticated_encryption_test_case_8),
13424
13425                 /** AES GCM Authenticated Decryption */
13426                 TEST_CASE_ST(ut_setup, ut_teardown,
13427                         test_AES_GCM_authenticated_decryption_test_case_1),
13428                 TEST_CASE_ST(ut_setup, ut_teardown,
13429                         test_AES_GCM_authenticated_decryption_test_case_2),
13430                 TEST_CASE_ST(ut_setup, ut_teardown,
13431                         test_AES_GCM_authenticated_decryption_test_case_3),
13432                 TEST_CASE_ST(ut_setup, ut_teardown,
13433                         test_AES_GCM_authenticated_decryption_test_case_4),
13434                 TEST_CASE_ST(ut_setup, ut_teardown,
13435                         test_AES_GCM_authenticated_decryption_test_case_5),
13436                 TEST_CASE_ST(ut_setup, ut_teardown,
13437                         test_AES_GCM_authenticated_decryption_test_case_6),
13438                 TEST_CASE_ST(ut_setup, ut_teardown,
13439                         test_AES_GCM_authenticated_decryption_test_case_7),
13440                 TEST_CASE_ST(ut_setup, ut_teardown,
13441                         test_AES_GCM_authenticated_decryption_test_case_8),
13442
13443                 /** AES GCM Authenticated Encryption 192 bits key */
13444                 TEST_CASE_ST(ut_setup, ut_teardown,
13445                         test_AES_GCM_auth_encryption_test_case_192_1),
13446                 TEST_CASE_ST(ut_setup, ut_teardown,
13447                         test_AES_GCM_auth_encryption_test_case_192_2),
13448                 TEST_CASE_ST(ut_setup, ut_teardown,
13449                         test_AES_GCM_auth_encryption_test_case_192_3),
13450                 TEST_CASE_ST(ut_setup, ut_teardown,
13451                         test_AES_GCM_auth_encryption_test_case_192_4),
13452                 TEST_CASE_ST(ut_setup, ut_teardown,
13453                         test_AES_GCM_auth_encryption_test_case_192_5),
13454                 TEST_CASE_ST(ut_setup, ut_teardown,
13455                         test_AES_GCM_auth_encryption_test_case_192_6),
13456                 TEST_CASE_ST(ut_setup, ut_teardown,
13457                         test_AES_GCM_auth_encryption_test_case_192_7),
13458
13459                 /** AES GCM Authenticated Decryption 192 bits key */
13460                 TEST_CASE_ST(ut_setup, ut_teardown,
13461                         test_AES_GCM_auth_decryption_test_case_192_1),
13462                 TEST_CASE_ST(ut_setup, ut_teardown,
13463                         test_AES_GCM_auth_decryption_test_case_192_2),
13464                 TEST_CASE_ST(ut_setup, ut_teardown,
13465                         test_AES_GCM_auth_decryption_test_case_192_3),
13466                 TEST_CASE_ST(ut_setup, ut_teardown,
13467                         test_AES_GCM_auth_decryption_test_case_192_4),
13468                 TEST_CASE_ST(ut_setup, ut_teardown,
13469                         test_AES_GCM_auth_decryption_test_case_192_5),
13470                 TEST_CASE_ST(ut_setup, ut_teardown,
13471                         test_AES_GCM_auth_decryption_test_case_192_6),
13472                 TEST_CASE_ST(ut_setup, ut_teardown,
13473                         test_AES_GCM_auth_decryption_test_case_192_7),
13474
13475                 /** AES GCM Authenticated Encryption 256 bits key */
13476                 TEST_CASE_ST(ut_setup, ut_teardown,
13477                         test_AES_GCM_auth_encryption_test_case_256_1),
13478                 TEST_CASE_ST(ut_setup, ut_teardown,
13479                         test_AES_GCM_auth_encryption_test_case_256_2),
13480                 TEST_CASE_ST(ut_setup, ut_teardown,
13481                         test_AES_GCM_auth_encryption_test_case_256_3),
13482                 TEST_CASE_ST(ut_setup, ut_teardown,
13483                         test_AES_GCM_auth_encryption_test_case_256_4),
13484                 TEST_CASE_ST(ut_setup, ut_teardown,
13485                         test_AES_GCM_auth_encryption_test_case_256_5),
13486                 TEST_CASE_ST(ut_setup, ut_teardown,
13487                         test_AES_GCM_auth_encryption_test_case_256_6),
13488                 TEST_CASE_ST(ut_setup, ut_teardown,
13489                         test_AES_GCM_auth_encryption_test_case_256_7),
13490
13491                 /** AES GCM Authenticated Decryption 256 bits key */
13492                 TEST_CASE_ST(ut_setup, ut_teardown,
13493                         test_AES_GCM_auth_decryption_test_case_256_1),
13494                 TEST_CASE_ST(ut_setup, ut_teardown,
13495                         test_AES_GCM_auth_decryption_test_case_256_2),
13496                 TEST_CASE_ST(ut_setup, ut_teardown,
13497                         test_AES_GCM_auth_decryption_test_case_256_3),
13498                 TEST_CASE_ST(ut_setup, ut_teardown,
13499                         test_AES_GCM_auth_decryption_test_case_256_4),
13500                 TEST_CASE_ST(ut_setup, ut_teardown,
13501                         test_AES_GCM_auth_decryption_test_case_256_5),
13502                 TEST_CASE_ST(ut_setup, ut_teardown,
13503                         test_AES_GCM_auth_decryption_test_case_256_6),
13504                 TEST_CASE_ST(ut_setup, ut_teardown,
13505                         test_AES_GCM_auth_decryption_test_case_256_7),
13506
13507                 /** Out of place tests */
13508                 TEST_CASE_ST(ut_setup, ut_teardown,
13509                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
13510                 TEST_CASE_ST(ut_setup, ut_teardown,
13511                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
13512
13513                 /** SNOW 3G encrypt only (UEA2) */
13514                 TEST_CASE_ST(ut_setup, ut_teardown,
13515                         test_snow3g_encryption_test_case_1),
13516                 TEST_CASE_ST(ut_setup, ut_teardown,
13517                         test_snow3g_encryption_test_case_2),
13518                 TEST_CASE_ST(ut_setup, ut_teardown,
13519                         test_snow3g_encryption_test_case_3),
13520                 TEST_CASE_ST(ut_setup, ut_teardown,
13521                         test_snow3g_encryption_test_case_4),
13522                 TEST_CASE_ST(ut_setup, ut_teardown,
13523                         test_snow3g_encryption_test_case_5),
13524
13525                 TEST_CASE_ST(ut_setup, ut_teardown,
13526                         test_snow3g_encryption_test_case_1_oop),
13527                 TEST_CASE_ST(ut_setup, ut_teardown,
13528                                 test_snow3g_encryption_test_case_1_oop_sgl),
13529                 TEST_CASE_ST(ut_setup, ut_teardown,
13530                         test_snow3g_decryption_test_case_1_oop),
13531
13532                 /** SNOW 3G decrypt only (UEA2) */
13533                 TEST_CASE_ST(ut_setup, ut_teardown,
13534                         test_snow3g_decryption_test_case_1),
13535                 TEST_CASE_ST(ut_setup, ut_teardown,
13536                         test_snow3g_decryption_test_case_2),
13537                 TEST_CASE_ST(ut_setup, ut_teardown,
13538                         test_snow3g_decryption_test_case_3),
13539                 TEST_CASE_ST(ut_setup, ut_teardown,
13540                         test_snow3g_decryption_test_case_4),
13541                 TEST_CASE_ST(ut_setup, ut_teardown,
13542                         test_snow3g_decryption_test_case_5),
13543
13544                 TEST_CASE_ST(ut_setup, ut_teardown,
13545                         test_snow3g_hash_generate_test_case_1),
13546                 TEST_CASE_ST(ut_setup, ut_teardown,
13547                         test_snow3g_hash_generate_test_case_2),
13548                 TEST_CASE_ST(ut_setup, ut_teardown,
13549                         test_snow3g_hash_generate_test_case_3),
13550                 TEST_CASE_ST(ut_setup, ut_teardown,
13551                         test_snow3g_hash_verify_test_case_1),
13552                 TEST_CASE_ST(ut_setup, ut_teardown,
13553                         test_snow3g_hash_verify_test_case_2),
13554                 TEST_CASE_ST(ut_setup, ut_teardown,
13555                         test_snow3g_hash_verify_test_case_3),
13556
13557                 /** ZUC encrypt only (EEA3) */
13558                 TEST_CASE_ST(ut_setup, ut_teardown,
13559                         test_zuc_encryption_test_case_1),
13560                 TEST_CASE_ST(ut_setup, ut_teardown,
13561                         test_zuc_encryption_test_case_2),
13562                 TEST_CASE_ST(ut_setup, ut_teardown,
13563                         test_zuc_encryption_test_case_3),
13564                 TEST_CASE_ST(ut_setup, ut_teardown,
13565                         test_zuc_encryption_test_case_4),
13566                 TEST_CASE_ST(ut_setup, ut_teardown,
13567                         test_zuc_encryption_test_case_5),
13568
13569                 /** ZUC authenticate (EIA3) */
13570                 TEST_CASE_ST(ut_setup, ut_teardown,
13571                         test_zuc_hash_generate_test_case_6),
13572                 TEST_CASE_ST(ut_setup, ut_teardown,
13573                         test_zuc_hash_generate_test_case_7),
13574                 TEST_CASE_ST(ut_setup, ut_teardown,
13575                         test_zuc_hash_generate_test_case_8),
13576
13577                 /** HMAC_MD5 Authentication */
13578                 TEST_CASE_ST(ut_setup, ut_teardown,
13579                         test_MD5_HMAC_generate_case_1),
13580                 TEST_CASE_ST(ut_setup, ut_teardown,
13581                         test_MD5_HMAC_verify_case_1),
13582                 TEST_CASE_ST(ut_setup, ut_teardown,
13583                         test_MD5_HMAC_generate_case_2),
13584                 TEST_CASE_ST(ut_setup, ut_teardown,
13585                         test_MD5_HMAC_verify_case_2),
13586
13587                 /** Negative tests */
13588                 TEST_CASE_ST(ut_setup, ut_teardown,
13589                         test_AES_GCM_auth_encryption_fail_iv_corrupt),
13590                 TEST_CASE_ST(ut_setup, ut_teardown,
13591                         test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13592                 TEST_CASE_ST(ut_setup, ut_teardown,
13593                         test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13594                 TEST_CASE_ST(ut_setup, ut_teardown,
13595                         test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13596                 TEST_CASE_ST(ut_setup, ut_teardown,
13597                         test_AES_GCM_auth_encryption_fail_aad_corrupt),
13598                 TEST_CASE_ST(ut_setup, ut_teardown,
13599                         test_AES_GCM_auth_encryption_fail_tag_corrupt),
13600                 TEST_CASE_ST(ut_setup, ut_teardown,
13601                         test_AES_GCM_auth_decryption_fail_iv_corrupt),
13602                 TEST_CASE_ST(ut_setup, ut_teardown,
13603                         test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13604                 TEST_CASE_ST(ut_setup, ut_teardown,
13605                         test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13606                 TEST_CASE_ST(ut_setup, ut_teardown,
13607                         test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13608                 TEST_CASE_ST(ut_setup, ut_teardown,
13609                         test_AES_GCM_auth_decryption_fail_aad_corrupt),
13610                 TEST_CASE_ST(ut_setup, ut_teardown,
13611                         test_AES_GCM_auth_decryption_fail_tag_corrupt),
13612                 TEST_CASE_ST(ut_setup, ut_teardown,
13613                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
13614                 TEST_CASE_ST(ut_setup, ut_teardown,
13615                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13616                 TEST_CASE_ST(ut_setup, ut_teardown,
13617                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13618                 TEST_CASE_ST(ut_setup, ut_teardown,
13619                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13620
13621                 /* ESN Testcase */
13622                 TEST_CASE_ST(ut_setup, ut_teardown,
13623                         auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13624
13625                 TEST_CASE_ST(ut_setup, ut_teardown,
13626                         auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13627
13628                 TEST_CASES_END() /**< NULL terminate unit test array */
13629         }
13630 };
13631
13632 static struct unit_test_suite cryptodev_null_testsuite  = {
13633         .suite_name = "Crypto Device NULL Unit Test Suite",
13634         .setup = testsuite_setup,
13635         .teardown = testsuite_teardown,
13636         .unit_test_cases = {
13637                 TEST_CASE_ST(ut_setup, ut_teardown,
13638                         test_null_invalid_operation),
13639                 TEST_CASE_ST(ut_setup, ut_teardown,
13640                         test_null_burst_operation),
13641                 TEST_CASE_ST(ut_setup, ut_teardown,
13642                         test_AES_chain_null_all),
13643                 TEST_CASE_ST(ut_setup, ut_teardown,
13644                         test_AES_cipheronly_null_all),
13645                 TEST_CASE_ST(ut_setup, ut_teardown,
13646                                 test_authonly_null_all),
13647
13648                 TEST_CASES_END() /**< NULL terminate unit test array */
13649         }
13650 };
13651
13652 static struct unit_test_suite cryptodev_armv8_testsuite  = {
13653         .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13654         .setup = testsuite_setup,
13655         .teardown = testsuite_teardown,
13656         .unit_test_cases = {
13657                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13658
13659                 /** Negative tests */
13660                 TEST_CASE_ST(ut_setup, ut_teardown,
13661                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13662                 TEST_CASE_ST(ut_setup, ut_teardown,
13663                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13664
13665                 TEST_CASES_END() /**< NULL terminate unit test array */
13666         }
13667 };
13668
13669 static struct unit_test_suite cryptodev_mrvl_testsuite  = {
13670         .suite_name = "Crypto Device Marvell Component Test Suite",
13671         .setup = testsuite_setup,
13672         .teardown = testsuite_teardown,
13673         .unit_test_cases = {
13674                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13675                 TEST_CASE_ST(ut_setup, ut_teardown,
13676                                 test_multi_session_random_usage),
13677                 TEST_CASE_ST(ut_setup, ut_teardown,
13678                                 test_AES_chain_mrvl_all),
13679                 TEST_CASE_ST(ut_setup, ut_teardown,
13680                                 test_AES_cipheronly_mrvl_all),
13681                 TEST_CASE_ST(ut_setup, ut_teardown,
13682                                 test_authonly_mrvl_all),
13683                 TEST_CASE_ST(ut_setup, ut_teardown,
13684                                 test_3DES_chain_mrvl_all),
13685                 TEST_CASE_ST(ut_setup, ut_teardown,
13686                                 test_3DES_cipheronly_mrvl_all),
13687
13688                 /** Negative tests */
13689                 TEST_CASE_ST(ut_setup, ut_teardown,
13690                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
13691                 TEST_CASE_ST(ut_setup, ut_teardown,
13692                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13693                 TEST_CASE_ST(ut_setup, ut_teardown,
13694                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13695                 TEST_CASE_ST(ut_setup, ut_teardown,
13696                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13697
13698                 TEST_CASES_END() /**< NULL terminate unit test array */
13699         }
13700 };
13701
13702 static struct unit_test_suite cryptodev_ccp_testsuite  = {
13703         .suite_name = "Crypto Device CCP Unit Test Suite",
13704         .setup = testsuite_setup,
13705         .teardown = testsuite_teardown,
13706         .unit_test_cases = {
13707                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13708                 TEST_CASE_ST(ut_setup, ut_teardown,
13709                                 test_multi_session_random_usage),
13710                 TEST_CASE_ST(ut_setup, ut_teardown,
13711                                 test_AES_chain_ccp_all),
13712                 TEST_CASE_ST(ut_setup, ut_teardown,
13713                                 test_AES_cipheronly_ccp_all),
13714                 TEST_CASE_ST(ut_setup, ut_teardown,
13715                                 test_3DES_chain_ccp_all),
13716                 TEST_CASE_ST(ut_setup, ut_teardown,
13717                                 test_3DES_cipheronly_ccp_all),
13718                 TEST_CASE_ST(ut_setup, ut_teardown,
13719                                 test_authonly_ccp_all),
13720
13721                 /** Negative tests */
13722                 TEST_CASE_ST(ut_setup, ut_teardown,
13723                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
13724                 TEST_CASE_ST(ut_setup, ut_teardown,
13725                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13726                 TEST_CASE_ST(ut_setup, ut_teardown,
13727                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13728                 TEST_CASE_ST(ut_setup, ut_teardown,
13729                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13730
13731                 TEST_CASES_END() /**< NULL terminate unit test array */
13732         }
13733 };
13734
13735 static struct unit_test_suite cryptodev_octeontx_testsuite  = {
13736         .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13737         .setup = testsuite_setup,
13738         .teardown = testsuite_teardown,
13739         .unit_test_cases = {
13740                 TEST_CASE_ST(ut_setup, ut_teardown,
13741                         test_AES_chain_octeontx_all),
13742                 TEST_CASE_ST(ut_setup, ut_teardown,
13743                         test_AES_cipheronly_octeontx_all),
13744                 TEST_CASE_ST(ut_setup, ut_teardown,
13745                         test_3DES_chain_octeontx_all),
13746                 TEST_CASE_ST(ut_setup, ut_teardown,
13747                         test_3DES_cipheronly_octeontx_all),
13748                 TEST_CASE_ST(ut_setup, ut_teardown,
13749                         test_authonly_octeontx_all),
13750
13751                 /** AES GCM Authenticated Encryption */
13752                 TEST_CASE_ST(ut_setup, ut_teardown,
13753                         test_AES_GCM_authenticated_encryption_test_case_1),
13754                 TEST_CASE_ST(ut_setup, ut_teardown,
13755                         test_AES_GCM_authenticated_encryption_test_case_2),
13756                 TEST_CASE_ST(ut_setup, ut_teardown,
13757                         test_AES_GCM_authenticated_encryption_test_case_3),
13758                 TEST_CASE_ST(ut_setup, ut_teardown,
13759                         test_AES_GCM_authenticated_encryption_test_case_4),
13760                 TEST_CASE_ST(ut_setup, ut_teardown,
13761                         test_AES_GCM_authenticated_encryption_test_case_5),
13762                 TEST_CASE_ST(ut_setup, ut_teardown,
13763                         test_AES_GCM_authenticated_encryption_test_case_6),
13764                 TEST_CASE_ST(ut_setup, ut_teardown,
13765                         test_AES_GCM_authenticated_encryption_test_case_7),
13766
13767                 /** AES GCM Authenticated Decryption */
13768                 TEST_CASE_ST(ut_setup, ut_teardown,
13769                         test_AES_GCM_authenticated_decryption_test_case_1),
13770                 TEST_CASE_ST(ut_setup, ut_teardown,
13771                         test_AES_GCM_authenticated_decryption_test_case_2),
13772                 TEST_CASE_ST(ut_setup, ut_teardown,
13773                         test_AES_GCM_authenticated_decryption_test_case_3),
13774                 TEST_CASE_ST(ut_setup, ut_teardown,
13775                         test_AES_GCM_authenticated_decryption_test_case_4),
13776                 TEST_CASE_ST(ut_setup, ut_teardown,
13777                         test_AES_GCM_authenticated_decryption_test_case_5),
13778                 TEST_CASE_ST(ut_setup, ut_teardown,
13779                         test_AES_GCM_authenticated_decryption_test_case_6),
13780                 TEST_CASE_ST(ut_setup, ut_teardown,
13781                         test_AES_GCM_authenticated_decryption_test_case_7),
13782                 /** AES GMAC Authentication */
13783                 TEST_CASE_ST(ut_setup, ut_teardown,
13784                         test_AES_GMAC_authentication_test_case_1),
13785                 TEST_CASE_ST(ut_setup, ut_teardown,
13786                         test_AES_GMAC_authentication_verify_test_case_1),
13787                 TEST_CASE_ST(ut_setup, ut_teardown,
13788                         test_AES_GMAC_authentication_test_case_2),
13789                 TEST_CASE_ST(ut_setup, ut_teardown,
13790                         test_AES_GMAC_authentication_verify_test_case_2),
13791                 TEST_CASE_ST(ut_setup, ut_teardown,
13792                         test_AES_GMAC_authentication_test_case_3),
13793                 TEST_CASE_ST(ut_setup, ut_teardown,
13794                         test_AES_GMAC_authentication_verify_test_case_3),
13795
13796                 /** SNOW 3G encrypt only (UEA2) */
13797                 TEST_CASE_ST(ut_setup, ut_teardown,
13798                         test_snow3g_encryption_test_case_1),
13799                 TEST_CASE_ST(ut_setup, ut_teardown,
13800                         test_snow3g_encryption_test_case_2),
13801                 TEST_CASE_ST(ut_setup, ut_teardown,
13802                         test_snow3g_encryption_test_case_3),
13803                 TEST_CASE_ST(ut_setup, ut_teardown,
13804                         test_snow3g_encryption_test_case_4),
13805                 TEST_CASE_ST(ut_setup, ut_teardown,
13806                         test_snow3g_encryption_test_case_5),
13807
13808                 TEST_CASE_ST(ut_setup, ut_teardown,
13809                         test_snow3g_encryption_test_case_1_oop),
13810                 TEST_CASE_ST(ut_setup, ut_teardown,
13811                         test_snow3g_decryption_test_case_1_oop),
13812                 TEST_CASE_ST(ut_setup, ut_teardown,
13813                         test_snow3g_encryption_test_case_1_oop_sgl),
13814
13815                 /** SNOW 3G decrypt only (UEA2) */
13816                 TEST_CASE_ST(ut_setup, ut_teardown,
13817                         test_snow3g_decryption_test_case_1),
13818                 TEST_CASE_ST(ut_setup, ut_teardown,
13819                         test_snow3g_decryption_test_case_2),
13820                 TEST_CASE_ST(ut_setup, ut_teardown,
13821                         test_snow3g_decryption_test_case_3),
13822                 TEST_CASE_ST(ut_setup, ut_teardown,
13823                         test_snow3g_decryption_test_case_4),
13824                 TEST_CASE_ST(ut_setup, ut_teardown,
13825                         test_snow3g_decryption_test_case_5),
13826
13827                 TEST_CASE_ST(ut_setup, ut_teardown,
13828                         test_snow3g_hash_generate_test_case_1),
13829                 TEST_CASE_ST(ut_setup, ut_teardown,
13830                         test_snow3g_hash_generate_test_case_2),
13831                 TEST_CASE_ST(ut_setup, ut_teardown,
13832                         test_snow3g_hash_generate_test_case_3),
13833                 TEST_CASE_ST(ut_setup, ut_teardown,
13834                         test_snow3g_hash_verify_test_case_1),
13835                 TEST_CASE_ST(ut_setup, ut_teardown,
13836                         test_snow3g_hash_verify_test_case_2),
13837                 TEST_CASE_ST(ut_setup, ut_teardown,
13838                         test_snow3g_hash_verify_test_case_3),
13839
13840                 /** ZUC encrypt only (EEA3) */
13841                 TEST_CASE_ST(ut_setup, ut_teardown,
13842                         test_zuc_encryption_test_case_1),
13843                 TEST_CASE_ST(ut_setup, ut_teardown,
13844                         test_zuc_encryption_test_case_2),
13845                 TEST_CASE_ST(ut_setup, ut_teardown,
13846                         test_zuc_encryption_test_case_3),
13847                 TEST_CASE_ST(ut_setup, ut_teardown,
13848                         test_zuc_encryption_test_case_4),
13849                 TEST_CASE_ST(ut_setup, ut_teardown,
13850                         test_zuc_encryption_test_case_5),
13851                 TEST_CASE_ST(ut_setup, ut_teardown,
13852                         test_zuc_hash_generate_test_case_1),
13853                 TEST_CASE_ST(ut_setup, ut_teardown,
13854                         test_zuc_hash_generate_test_case_2),
13855                 TEST_CASE_ST(ut_setup, ut_teardown,
13856                         test_zuc_hash_generate_test_case_3),
13857                 TEST_CASE_ST(ut_setup, ut_teardown,
13858                         test_zuc_hash_generate_test_case_4),
13859                 TEST_CASE_ST(ut_setup, ut_teardown,
13860                         test_zuc_hash_generate_test_case_5),
13861                 TEST_CASE_ST(ut_setup, ut_teardown,
13862                         test_zuc_encryption_test_case_6_sgl),
13863
13864                 /** KASUMI encrypt only (UEA1) */
13865                 TEST_CASE_ST(ut_setup, ut_teardown,
13866                         test_kasumi_encryption_test_case_1),
13867                 TEST_CASE_ST(ut_setup, ut_teardown,
13868                         test_kasumi_encryption_test_case_2),
13869                 TEST_CASE_ST(ut_setup, ut_teardown,
13870                         test_kasumi_encryption_test_case_3),
13871                 TEST_CASE_ST(ut_setup, ut_teardown,
13872                         test_kasumi_encryption_test_case_4),
13873                 TEST_CASE_ST(ut_setup, ut_teardown,
13874                         test_kasumi_encryption_test_case_5),
13875                 TEST_CASE_ST(ut_setup, ut_teardown,
13876                         test_kasumi_encryption_test_case_1_sgl),
13877                 TEST_CASE_ST(ut_setup, ut_teardown,
13878                         test_kasumi_encryption_test_case_1_oop_sgl),
13879                 /** KASUMI decrypt only (UEA1) */
13880                 TEST_CASE_ST(ut_setup, ut_teardown,
13881                         test_kasumi_decryption_test_case_1),
13882                 TEST_CASE_ST(ut_setup, ut_teardown,
13883                         test_kasumi_decryption_test_case_2),
13884                 TEST_CASE_ST(ut_setup, ut_teardown,
13885                         test_kasumi_decryption_test_case_3),
13886                 TEST_CASE_ST(ut_setup, ut_teardown,
13887                         test_kasumi_decryption_test_case_4),
13888                 TEST_CASE_ST(ut_setup, ut_teardown,
13889                         test_kasumi_decryption_test_case_5),
13890
13891                 TEST_CASE_ST(ut_setup, ut_teardown,
13892                         test_kasumi_encryption_test_case_1_oop),
13893                 TEST_CASE_ST(ut_setup, ut_teardown,
13894                         test_kasumi_decryption_test_case_1_oop),
13895
13896                 /** KASUMI hash only (UIA1) */
13897                 TEST_CASE_ST(ut_setup, ut_teardown,
13898                         test_kasumi_hash_generate_test_case_1),
13899                 TEST_CASE_ST(ut_setup, ut_teardown,
13900                         test_kasumi_hash_generate_test_case_2),
13901                 TEST_CASE_ST(ut_setup, ut_teardown,
13902                         test_kasumi_hash_generate_test_case_3),
13903                 TEST_CASE_ST(ut_setup, ut_teardown,
13904                         test_kasumi_hash_generate_test_case_4),
13905                 TEST_CASE_ST(ut_setup, ut_teardown,
13906                         test_kasumi_hash_generate_test_case_5),
13907                 TEST_CASE_ST(ut_setup, ut_teardown,
13908                         test_kasumi_hash_generate_test_case_6),
13909                 TEST_CASE_ST(ut_setup, ut_teardown,
13910                         test_kasumi_hash_verify_test_case_1),
13911                 TEST_CASE_ST(ut_setup, ut_teardown,
13912                         test_kasumi_hash_verify_test_case_2),
13913                 TEST_CASE_ST(ut_setup, ut_teardown,
13914                         test_kasumi_hash_verify_test_case_3),
13915                 TEST_CASE_ST(ut_setup, ut_teardown,
13916                         test_kasumi_hash_verify_test_case_4),
13917                 TEST_CASE_ST(ut_setup, ut_teardown,
13918                         test_kasumi_hash_verify_test_case_5),
13919
13920                 /** NULL tests */
13921                 TEST_CASE_ST(ut_setup, ut_teardown,
13922                         test_null_cipher_only_operation),
13923                 TEST_CASE_ST(ut_setup, ut_teardown,
13924                         test_null_auth_only_operation),
13925                 TEST_CASE_ST(ut_setup, ut_teardown,
13926                         test_null_cipher_auth_operation),
13927                 TEST_CASE_ST(ut_setup, ut_teardown,
13928                         test_null_auth_cipher_operation),
13929
13930                 /** Negative tests */
13931                 TEST_CASE_ST(ut_setup, ut_teardown,
13932                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
13933                 TEST_CASE_ST(ut_setup, ut_teardown,
13934                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13935                 TEST_CASE_ST(ut_setup, ut_teardown,
13936                         authentication_verify_AES128_GMAC_fail_data_corrupt),
13937                 TEST_CASE_ST(ut_setup, ut_teardown,
13938                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
13939                 TEST_CASE_ST(ut_setup, ut_teardown,
13940                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13941                 TEST_CASE_ST(ut_setup, ut_teardown,
13942                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13943                 TEST_CASES_END() /**< NULL terminate unit test array */
13944         }
13945 };
13946
13947 static struct unit_test_suite cryptodev_nitrox_testsuite  = {
13948         .suite_name = "Crypto NITROX Unit Test Suite",
13949         .setup = testsuite_setup,
13950         .teardown = testsuite_teardown,
13951         .unit_test_cases = {
13952                 TEST_CASE_ST(ut_setup, ut_teardown,
13953                              test_device_configure_invalid_dev_id),
13954                 TEST_CASE_ST(ut_setup, ut_teardown,
13955                                 test_device_configure_invalid_queue_pair_ids),
13956                 TEST_CASE_ST(ut_setup, ut_teardown,
13957                              test_AES_chain_nitrox_all),
13958
13959                 TEST_CASES_END() /**< NULL terminate unit test array */
13960         }
13961 };
13962
13963 static struct unit_test_suite cryptodev_octeontx2_testsuite  = {
13964         .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13965         .setup = testsuite_setup,
13966         .teardown = testsuite_teardown,
13967         .unit_test_cases = {
13968                 TEST_CASE_ST(ut_setup, ut_teardown,
13969                         test_AES_chain_octeontx2_all),
13970                 TEST_CASE_ST(ut_setup, ut_teardown,
13971                         test_AES_cipheronly_octeontx2_all),
13972                 TEST_CASE_ST(ut_setup, ut_teardown,
13973                         test_3DES_chain_octeontx2_all),
13974                 TEST_CASE_ST(ut_setup, ut_teardown,
13975                         test_3DES_cipheronly_octeontx2_all),
13976                 TEST_CASE_ST(ut_setup, ut_teardown,
13977                         test_authonly_octeontx2_all),
13978
13979                 /** AES GCM Authenticated Encryption */
13980                 TEST_CASE_ST(ut_setup, ut_teardown,
13981                         test_AES_GCM_authenticated_encryption_test_case_1),
13982                 TEST_CASE_ST(ut_setup, ut_teardown,
13983                         test_AES_GCM_authenticated_encryption_test_case_2),
13984                 TEST_CASE_ST(ut_setup, ut_teardown,
13985                         test_AES_GCM_authenticated_encryption_test_case_3),
13986                 TEST_CASE_ST(ut_setup, ut_teardown,
13987                         test_AES_GCM_authenticated_encryption_test_case_4),
13988                 TEST_CASE_ST(ut_setup, ut_teardown,
13989                         test_AES_GCM_authenticated_encryption_test_case_5),
13990                 TEST_CASE_ST(ut_setup, ut_teardown,
13991                         test_AES_GCM_authenticated_encryption_test_case_6),
13992                 TEST_CASE_ST(ut_setup, ut_teardown,
13993                         test_AES_GCM_authenticated_encryption_test_case_7),
13994
13995                 /** AES GCM Authenticated Decryption */
13996                 TEST_CASE_ST(ut_setup, ut_teardown,
13997                         test_AES_GCM_authenticated_decryption_test_case_1),
13998                 TEST_CASE_ST(ut_setup, ut_teardown,
13999                         test_AES_GCM_authenticated_decryption_test_case_2),
14000                 TEST_CASE_ST(ut_setup, ut_teardown,
14001                         test_AES_GCM_authenticated_decryption_test_case_3),
14002                 TEST_CASE_ST(ut_setup, ut_teardown,
14003                         test_AES_GCM_authenticated_decryption_test_case_4),
14004                 TEST_CASE_ST(ut_setup, ut_teardown,
14005                         test_AES_GCM_authenticated_decryption_test_case_5),
14006                 TEST_CASE_ST(ut_setup, ut_teardown,
14007                         test_AES_GCM_authenticated_decryption_test_case_6),
14008                 TEST_CASE_ST(ut_setup, ut_teardown,
14009                         test_AES_GCM_authenticated_decryption_test_case_7),
14010                 /** AES GMAC Authentication */
14011                 TEST_CASE_ST(ut_setup, ut_teardown,
14012                         test_AES_GMAC_authentication_test_case_1),
14013                 TEST_CASE_ST(ut_setup, ut_teardown,
14014                         test_AES_GMAC_authentication_verify_test_case_1),
14015                 TEST_CASE_ST(ut_setup, ut_teardown,
14016                         test_AES_GMAC_authentication_test_case_2),
14017                 TEST_CASE_ST(ut_setup, ut_teardown,
14018                         test_AES_GMAC_authentication_verify_test_case_2),
14019                 TEST_CASE_ST(ut_setup, ut_teardown,
14020                         test_AES_GMAC_authentication_test_case_3),
14021                 TEST_CASE_ST(ut_setup, ut_teardown,
14022                         test_AES_GMAC_authentication_verify_test_case_3),
14023
14024                 /** SNOW 3G encrypt only (UEA2) */
14025                 TEST_CASE_ST(ut_setup, ut_teardown,
14026                         test_snow3g_encryption_test_case_1),
14027                 TEST_CASE_ST(ut_setup, ut_teardown,
14028                         test_snow3g_encryption_test_case_2),
14029                 TEST_CASE_ST(ut_setup, ut_teardown,
14030                         test_snow3g_encryption_test_case_3),
14031                 TEST_CASE_ST(ut_setup, ut_teardown,
14032                         test_snow3g_encryption_test_case_4),
14033                 TEST_CASE_ST(ut_setup, ut_teardown,
14034                         test_snow3g_encryption_test_case_5),
14035
14036                 TEST_CASE_ST(ut_setup, ut_teardown,
14037                         test_snow3g_encryption_test_case_1_oop),
14038                 TEST_CASE_ST(ut_setup, ut_teardown,
14039                         test_snow3g_decryption_test_case_1_oop),
14040                 TEST_CASE_ST(ut_setup, ut_teardown,
14041                         test_snow3g_encryption_test_case_1_oop_sgl),
14042
14043                 /** SNOW 3G decrypt only (UEA2) */
14044                 TEST_CASE_ST(ut_setup, ut_teardown,
14045                         test_snow3g_decryption_test_case_1),
14046                 TEST_CASE_ST(ut_setup, ut_teardown,
14047                         test_snow3g_decryption_test_case_2),
14048                 TEST_CASE_ST(ut_setup, ut_teardown,
14049                         test_snow3g_decryption_test_case_3),
14050                 TEST_CASE_ST(ut_setup, ut_teardown,
14051                         test_snow3g_decryption_test_case_4),
14052                 TEST_CASE_ST(ut_setup, ut_teardown,
14053                         test_snow3g_decryption_test_case_5),
14054
14055                 TEST_CASE_ST(ut_setup, ut_teardown,
14056                         test_snow3g_hash_generate_test_case_1),
14057                 TEST_CASE_ST(ut_setup, ut_teardown,
14058                         test_snow3g_hash_generate_test_case_2),
14059                 TEST_CASE_ST(ut_setup, ut_teardown,
14060                         test_snow3g_hash_generate_test_case_3),
14061                 TEST_CASE_ST(ut_setup, ut_teardown,
14062                         test_snow3g_hash_verify_test_case_1),
14063                 TEST_CASE_ST(ut_setup, ut_teardown,
14064                         test_snow3g_hash_verify_test_case_2),
14065                 TEST_CASE_ST(ut_setup, ut_teardown,
14066                         test_snow3g_hash_verify_test_case_3),
14067
14068                 /** ZUC encrypt only (EEA3) */
14069                 TEST_CASE_ST(ut_setup, ut_teardown,
14070                         test_zuc_encryption_test_case_1),
14071                 TEST_CASE_ST(ut_setup, ut_teardown,
14072                         test_zuc_encryption_test_case_2),
14073                 TEST_CASE_ST(ut_setup, ut_teardown,
14074                         test_zuc_encryption_test_case_3),
14075                 TEST_CASE_ST(ut_setup, ut_teardown,
14076                         test_zuc_encryption_test_case_4),
14077                 TEST_CASE_ST(ut_setup, ut_teardown,
14078                         test_zuc_encryption_test_case_5),
14079                 TEST_CASE_ST(ut_setup, ut_teardown,
14080                         test_zuc_hash_generate_test_case_1),
14081                 TEST_CASE_ST(ut_setup, ut_teardown,
14082                         test_zuc_hash_generate_test_case_2),
14083                 TEST_CASE_ST(ut_setup, ut_teardown,
14084                         test_zuc_hash_generate_test_case_3),
14085                 TEST_CASE_ST(ut_setup, ut_teardown,
14086                         test_zuc_hash_generate_test_case_4),
14087                 TEST_CASE_ST(ut_setup, ut_teardown,
14088                         test_zuc_hash_generate_test_case_5),
14089                 TEST_CASE_ST(ut_setup, ut_teardown,
14090                         test_zuc_encryption_test_case_6_sgl),
14091
14092                 /** KASUMI encrypt only (UEA1) */
14093                 TEST_CASE_ST(ut_setup, ut_teardown,
14094                         test_kasumi_encryption_test_case_1),
14095                 TEST_CASE_ST(ut_setup, ut_teardown,
14096                         test_kasumi_encryption_test_case_2),
14097                 TEST_CASE_ST(ut_setup, ut_teardown,
14098                         test_kasumi_encryption_test_case_3),
14099                 TEST_CASE_ST(ut_setup, ut_teardown,
14100                         test_kasumi_encryption_test_case_4),
14101                 TEST_CASE_ST(ut_setup, ut_teardown,
14102                         test_kasumi_encryption_test_case_5),
14103                 TEST_CASE_ST(ut_setup, ut_teardown,
14104                         test_kasumi_encryption_test_case_1_sgl),
14105                 TEST_CASE_ST(ut_setup, ut_teardown,
14106                         test_kasumi_encryption_test_case_1_oop_sgl),
14107                 /** KASUMI decrypt only (UEA1) */
14108                 TEST_CASE_ST(ut_setup, ut_teardown,
14109                         test_kasumi_decryption_test_case_1),
14110                 TEST_CASE_ST(ut_setup, ut_teardown,
14111                         test_kasumi_decryption_test_case_2),
14112                 TEST_CASE_ST(ut_setup, ut_teardown,
14113                         test_kasumi_decryption_test_case_3),
14114                 TEST_CASE_ST(ut_setup, ut_teardown,
14115                         test_kasumi_decryption_test_case_4),
14116                 TEST_CASE_ST(ut_setup, ut_teardown,
14117                         test_kasumi_decryption_test_case_5),
14118
14119                 TEST_CASE_ST(ut_setup, ut_teardown,
14120                         test_kasumi_encryption_test_case_1_oop),
14121                 TEST_CASE_ST(ut_setup, ut_teardown,
14122                         test_kasumi_decryption_test_case_1_oop),
14123
14124                 /** KASUMI hash only (UIA1) */
14125                 TEST_CASE_ST(ut_setup, ut_teardown,
14126                         test_kasumi_hash_generate_test_case_1),
14127                 TEST_CASE_ST(ut_setup, ut_teardown,
14128                         test_kasumi_hash_generate_test_case_2),
14129                 TEST_CASE_ST(ut_setup, ut_teardown,
14130                         test_kasumi_hash_generate_test_case_3),
14131                 TEST_CASE_ST(ut_setup, ut_teardown,
14132                         test_kasumi_hash_generate_test_case_4),
14133                 TEST_CASE_ST(ut_setup, ut_teardown,
14134                         test_kasumi_hash_generate_test_case_5),
14135                 TEST_CASE_ST(ut_setup, ut_teardown,
14136                         test_kasumi_hash_generate_test_case_6),
14137                 TEST_CASE_ST(ut_setup, ut_teardown,
14138                         test_kasumi_hash_verify_test_case_1),
14139                 TEST_CASE_ST(ut_setup, ut_teardown,
14140                         test_kasumi_hash_verify_test_case_2),
14141                 TEST_CASE_ST(ut_setup, ut_teardown,
14142                         test_kasumi_hash_verify_test_case_3),
14143                 TEST_CASE_ST(ut_setup, ut_teardown,
14144                         test_kasumi_hash_verify_test_case_4),
14145                 TEST_CASE_ST(ut_setup, ut_teardown,
14146                         test_kasumi_hash_verify_test_case_5),
14147
14148                 /** NULL tests */
14149                 TEST_CASE_ST(ut_setup, ut_teardown,
14150                         test_null_cipher_only_operation),
14151                 TEST_CASE_ST(ut_setup, ut_teardown,
14152                         test_null_auth_only_operation),
14153                 TEST_CASE_ST(ut_setup, ut_teardown,
14154                         test_null_cipher_auth_operation),
14155                 TEST_CASE_ST(ut_setup, ut_teardown,
14156                         test_null_auth_cipher_operation),
14157
14158                 /** Negative tests */
14159                 TEST_CASE_ST(ut_setup, ut_teardown,
14160                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
14161                 TEST_CASE_ST(ut_setup, ut_teardown,
14162                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14163                 TEST_CASE_ST(ut_setup, ut_teardown,
14164                         authentication_verify_AES128_GMAC_fail_data_corrupt),
14165                 TEST_CASE_ST(ut_setup, ut_teardown,
14166                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
14167                 TEST_CASE_ST(ut_setup, ut_teardown,
14168                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14169                 TEST_CASE_ST(ut_setup, ut_teardown,
14170                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14171                 TEST_CASES_END() /**< NULL terminate unit test array */
14172         }
14173 };
14174
14175 static int
14176 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14177 {
14178         gbl_driver_id = rte_cryptodev_driver_id_get(
14179                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14180
14181         if (gbl_driver_id == -1) {
14182                 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14183                 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14184                 "are enabled in config file to run this testsuite.\n");
14185                 return TEST_SKIPPED;
14186         }
14187
14188         return unit_test_suite_runner(&cryptodev_qat_testsuite);
14189 }
14190
14191 static int
14192 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14193 {
14194         gbl_driver_id = rte_cryptodev_driver_id_get(
14195                         RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14196
14197         if (gbl_driver_id == -1) {
14198                 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14199                                 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14200                                 "in config file to run this testsuite.\n");
14201                 return TEST_FAILED;
14202         }
14203
14204         return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14205 }
14206
14207 static int
14208 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14209 {
14210         gbl_driver_id = rte_cryptodev_driver_id_get(
14211                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14212
14213         if (gbl_driver_id == -1) {
14214                 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14215                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14216                                 "in config file to run this testsuite.\n");
14217                 return TEST_SKIPPED;
14218         }
14219
14220         return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14221 }
14222
14223 static int
14224 test_cryptodev_openssl(void)
14225 {
14226         gbl_driver_id = rte_cryptodev_driver_id_get(
14227                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14228
14229         if (gbl_driver_id == -1) {
14230                 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14231                                 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14232                                 "in config file to run this testsuite.\n");
14233                 return TEST_SKIPPED;
14234         }
14235
14236         return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14237 }
14238
14239 static int
14240 test_cryptodev_aesni_gcm(void)
14241 {
14242         gbl_driver_id = rte_cryptodev_driver_id_get(
14243                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14244
14245         if (gbl_driver_id == -1) {
14246                 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14247                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14248                                 "in config file to run this testsuite.\n");
14249                 return TEST_SKIPPED;
14250         }
14251
14252         return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14253 }
14254
14255 static int
14256 test_cryptodev_null(void)
14257 {
14258         gbl_driver_id = rte_cryptodev_driver_id_get(
14259                         RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14260
14261         if (gbl_driver_id == -1) {
14262                 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14263                                 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14264                                 "in config file to run this testsuite.\n");
14265                 return TEST_SKIPPED;
14266         }
14267
14268         return unit_test_suite_runner(&cryptodev_null_testsuite);
14269 }
14270
14271 static int
14272 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14273 {
14274         gbl_driver_id = rte_cryptodev_driver_id_get(
14275                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14276
14277         if (gbl_driver_id == -1) {
14278                 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14279                                 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14280                                 "in config file to run this testsuite.\n");
14281                 return TEST_SKIPPED;
14282         }
14283
14284         return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14285 }
14286
14287 static int
14288 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14289 {
14290         gbl_driver_id = rte_cryptodev_driver_id_get(
14291                         RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14292
14293         if (gbl_driver_id == -1) {
14294                 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14295                                 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14296                                 "in config file to run this testsuite.\n");
14297                 return TEST_SKIPPED;
14298         }
14299
14300         return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14301 }
14302
14303 static int
14304 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14305 {
14306         gbl_driver_id = rte_cryptodev_driver_id_get(
14307                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14308
14309         if (gbl_driver_id == -1) {
14310                 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14311                                 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14312                                 "in config file to run this testsuite.\n");
14313                 return TEST_SKIPPED;
14314         }
14315
14316         return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14317 }
14318
14319 static int
14320 test_cryptodev_armv8(void)
14321 {
14322         gbl_driver_id = rte_cryptodev_driver_id_get(
14323                         RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14324
14325         if (gbl_driver_id == -1) {
14326                 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14327                                 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14328                                 "in config file to run this testsuite.\n");
14329                 return TEST_SKIPPED;
14330         }
14331
14332         return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14333 }
14334
14335 static int
14336 test_cryptodev_mrvl(void)
14337 {
14338         gbl_driver_id = rte_cryptodev_driver_id_get(
14339                         RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14340
14341         if (gbl_driver_id == -1) {
14342                 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14343                                 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14344                                 "in config file to run this testsuite.\n");
14345                 return TEST_SKIPPED;
14346         }
14347
14348         return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14349 }
14350
14351 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14352
14353 static int
14354 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14355 {
14356         gbl_driver_id = rte_cryptodev_driver_id_get(
14357                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14358
14359         if (gbl_driver_id == -1) {
14360                 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14361                                 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14362                                 "in config file to run this testsuite.\n");
14363                 return TEST_SKIPPED;
14364         }
14365
14366         if (rte_cryptodev_driver_id_get(
14367                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14368                 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14369                         " enabled in config file to run this testsuite.\n");
14370                 return TEST_SKIPPED;
14371 }
14372         return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14373 }
14374
14375 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14376
14377 #endif
14378
14379 static int
14380 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14381 {
14382         gbl_driver_id = rte_cryptodev_driver_id_get(
14383                         RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14384
14385         if (gbl_driver_id == -1) {
14386                 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14387                                 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14388                                 "in config file to run this testsuite.\n");
14389                 return TEST_SKIPPED;
14390         }
14391
14392         return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14393 }
14394
14395 static int
14396 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14397 {
14398         gbl_driver_id = rte_cryptodev_driver_id_get(
14399                         RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14400
14401         if (gbl_driver_id == -1) {
14402                 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14403                                 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14404                                 "in config file to run this testsuite.\n");
14405                 return TEST_SKIPPED;
14406         }
14407
14408         return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14409 }
14410
14411 static int
14412 test_cryptodev_ccp(void)
14413 {
14414         gbl_driver_id = rte_cryptodev_driver_id_get(
14415                         RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14416
14417         if (gbl_driver_id == -1) {
14418                 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14419                                 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14420                                 "in config file to run this testsuite.\n");
14421                 return TEST_FAILED;
14422         }
14423
14424         return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14425 }
14426
14427 static int
14428 test_cryptodev_octeontx(void)
14429 {
14430         gbl_driver_id = rte_cryptodev_driver_id_get(
14431                         RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14432         if (gbl_driver_id == -1) {
14433                 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14434                                 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14435                                 "enabled in config file to run this "
14436                                 "testsuite.\n");
14437                 return TEST_FAILED;
14438         }
14439         return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14440 }
14441
14442 static int
14443 test_cryptodev_octeontx2(void)
14444 {
14445         gbl_driver_id = rte_cryptodev_driver_id_get(
14446                         RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14447         if (gbl_driver_id == -1) {
14448                 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14449                                 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14450                                 "enabled in config file to run this "
14451                                 "testsuite.\n");
14452                 return TEST_FAILED;
14453         }
14454         return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14455 }
14456
14457 static int
14458 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14459 {
14460         gbl_driver_id = rte_cryptodev_driver_id_get(
14461                         RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14462
14463         if (gbl_driver_id == -1) {
14464                 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14465                                 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14466                                 "in config file to run this testsuite.\n");
14467                 return TEST_FAILED;
14468         }
14469
14470         return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14471 }
14472
14473 static int
14474 test_cryptodev_nitrox(void)
14475 {
14476         gbl_driver_id = rte_cryptodev_driver_id_get(
14477                         RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14478
14479         if (gbl_driver_id == -1) {
14480                 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14481                                 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14482                                 "in config file to run this testsuite.\n");
14483                 return TEST_FAILED;
14484         }
14485
14486         return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14487 }
14488
14489 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14490 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14491 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14492 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14493 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14494 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14495 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14496 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14497 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14498 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14499 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14500 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14501 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14502 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14503 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14504 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14505 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14506 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);