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