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