63cfa1af1f035bc8c58f48c508ab540da9493015
[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 /* ***** SNOW 3G Tests ***** */
2408 static int
2409 create_wireless_algo_hash_session(uint8_t dev_id,
2410         const uint8_t *key, const uint8_t key_len,
2411         const uint8_t iv_len, const uint8_t auth_len,
2412         enum rte_crypto_auth_operation op,
2413         enum rte_crypto_auth_algorithm algo)
2414 {
2415         uint8_t hash_key[key_len];
2416         int status;
2417
2418         struct crypto_testsuite_params *ts_params = &testsuite_params;
2419         struct crypto_unittest_params *ut_params = &unittest_params;
2420
2421         memcpy(hash_key, key, key_len);
2422
2423         debug_hexdump(stdout, "key:", key, key_len);
2424
2425         /* Setup Authentication Parameters */
2426         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2427         ut_params->auth_xform.next = NULL;
2428
2429         ut_params->auth_xform.auth.op = op;
2430         ut_params->auth_xform.auth.algo = algo;
2431         ut_params->auth_xform.auth.key.length = key_len;
2432         ut_params->auth_xform.auth.key.data = hash_key;
2433         ut_params->auth_xform.auth.digest_length = auth_len;
2434         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2435         ut_params->auth_xform.auth.iv.length = iv_len;
2436         ut_params->sess = rte_cryptodev_sym_session_create(
2437                         ts_params->session_mpool);
2438
2439         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2440                         &ut_params->auth_xform,
2441                         ts_params->session_priv_mpool);
2442         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2443         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2444         return 0;
2445 }
2446
2447 static int
2448 create_wireless_algo_cipher_session(uint8_t dev_id,
2449                         enum rte_crypto_cipher_operation op,
2450                         enum rte_crypto_cipher_algorithm algo,
2451                         const uint8_t *key, const uint8_t key_len,
2452                         uint8_t iv_len)
2453 {
2454         uint8_t cipher_key[key_len];
2455         int status;
2456         struct crypto_testsuite_params *ts_params = &testsuite_params;
2457         struct crypto_unittest_params *ut_params = &unittest_params;
2458
2459         memcpy(cipher_key, key, key_len);
2460
2461         /* Setup Cipher Parameters */
2462         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2463         ut_params->cipher_xform.next = NULL;
2464
2465         ut_params->cipher_xform.cipher.algo = algo;
2466         ut_params->cipher_xform.cipher.op = op;
2467         ut_params->cipher_xform.cipher.key.data = cipher_key;
2468         ut_params->cipher_xform.cipher.key.length = key_len;
2469         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2470         ut_params->cipher_xform.cipher.iv.length = iv_len;
2471
2472         debug_hexdump(stdout, "key:", key, key_len);
2473
2474         /* Create Crypto session */
2475         ut_params->sess = rte_cryptodev_sym_session_create(
2476                         ts_params->session_mpool);
2477
2478         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2479                         &ut_params->cipher_xform,
2480                         ts_params->session_priv_mpool);
2481         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2482         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2483         return 0;
2484 }
2485
2486 static int
2487 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2488                         unsigned int cipher_len,
2489                         unsigned int cipher_offset)
2490 {
2491         struct crypto_testsuite_params *ts_params = &testsuite_params;
2492         struct crypto_unittest_params *ut_params = &unittest_params;
2493
2494         /* Generate Crypto op data structure */
2495         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2496                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2497         TEST_ASSERT_NOT_NULL(ut_params->op,
2498                                 "Failed to allocate pktmbuf offload");
2499
2500         /* Set crypto operation data parameters */
2501         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2502
2503         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2504
2505         /* set crypto operation source mbuf */
2506         sym_op->m_src = ut_params->ibuf;
2507
2508         /* iv */
2509         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2510                         iv, iv_len);
2511         sym_op->cipher.data.length = cipher_len;
2512         sym_op->cipher.data.offset = cipher_offset;
2513         return 0;
2514 }
2515
2516 static int
2517 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2518                         unsigned int cipher_len,
2519                         unsigned int cipher_offset)
2520 {
2521         struct crypto_testsuite_params *ts_params = &testsuite_params;
2522         struct crypto_unittest_params *ut_params = &unittest_params;
2523
2524         /* Generate Crypto op data structure */
2525         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2526                                 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2527         TEST_ASSERT_NOT_NULL(ut_params->op,
2528                                 "Failed to allocate pktmbuf offload");
2529
2530         /* Set crypto operation data parameters */
2531         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2532
2533         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2534
2535         /* set crypto operation source mbuf */
2536         sym_op->m_src = ut_params->ibuf;
2537         sym_op->m_dst = ut_params->obuf;
2538
2539         /* iv */
2540         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2541                         iv, iv_len);
2542         sym_op->cipher.data.length = cipher_len;
2543         sym_op->cipher.data.offset = cipher_offset;
2544         return 0;
2545 }
2546
2547 static int
2548 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2549                 enum rte_crypto_cipher_operation cipher_op,
2550                 enum rte_crypto_auth_operation auth_op,
2551                 enum rte_crypto_auth_algorithm auth_algo,
2552                 enum rte_crypto_cipher_algorithm cipher_algo,
2553                 const uint8_t *key, uint8_t key_len,
2554                 uint8_t auth_iv_len, uint8_t auth_len,
2555                 uint8_t cipher_iv_len)
2556
2557 {
2558         uint8_t cipher_auth_key[key_len];
2559         int status;
2560
2561         struct crypto_testsuite_params *ts_params = &testsuite_params;
2562         struct crypto_unittest_params *ut_params = &unittest_params;
2563
2564         memcpy(cipher_auth_key, key, key_len);
2565
2566         /* Setup Authentication Parameters */
2567         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2568         ut_params->auth_xform.next = NULL;
2569
2570         ut_params->auth_xform.auth.op = auth_op;
2571         ut_params->auth_xform.auth.algo = auth_algo;
2572         ut_params->auth_xform.auth.key.length = key_len;
2573         /* Hash key = cipher key */
2574         ut_params->auth_xform.auth.key.data = cipher_auth_key;
2575         ut_params->auth_xform.auth.digest_length = auth_len;
2576         /* Auth IV will be after cipher IV */
2577         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2578         ut_params->auth_xform.auth.iv.length = auth_iv_len;
2579
2580         /* Setup Cipher Parameters */
2581         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2582         ut_params->cipher_xform.next = &ut_params->auth_xform;
2583
2584         ut_params->cipher_xform.cipher.algo = cipher_algo;
2585         ut_params->cipher_xform.cipher.op = cipher_op;
2586         ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2587         ut_params->cipher_xform.cipher.key.length = key_len;
2588         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2589         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2590
2591         debug_hexdump(stdout, "key:", key, key_len);
2592
2593         /* Create Crypto session*/
2594         ut_params->sess = rte_cryptodev_sym_session_create(
2595                         ts_params->session_mpool);
2596
2597         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2598                         &ut_params->cipher_xform,
2599                         ts_params->session_priv_mpool);
2600
2601         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2602         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2603         return 0;
2604 }
2605
2606 static int
2607 create_wireless_cipher_auth_session(uint8_t dev_id,
2608                 enum rte_crypto_cipher_operation cipher_op,
2609                 enum rte_crypto_auth_operation auth_op,
2610                 enum rte_crypto_auth_algorithm auth_algo,
2611                 enum rte_crypto_cipher_algorithm cipher_algo,
2612                 const struct wireless_test_data *tdata)
2613 {
2614         const uint8_t key_len = tdata->key.len;
2615         uint8_t cipher_auth_key[key_len];
2616         int status;
2617
2618         struct crypto_testsuite_params *ts_params = &testsuite_params;
2619         struct crypto_unittest_params *ut_params = &unittest_params;
2620         const uint8_t *key = tdata->key.data;
2621         const uint8_t auth_len = tdata->digest.len;
2622         uint8_t cipher_iv_len = tdata->cipher_iv.len;
2623         uint8_t auth_iv_len = tdata->auth_iv.len;
2624
2625         memcpy(cipher_auth_key, key, key_len);
2626
2627         /* Setup Authentication Parameters */
2628         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2629         ut_params->auth_xform.next = NULL;
2630
2631         ut_params->auth_xform.auth.op = auth_op;
2632         ut_params->auth_xform.auth.algo = auth_algo;
2633         ut_params->auth_xform.auth.key.length = key_len;
2634         /* Hash key = cipher key */
2635         ut_params->auth_xform.auth.key.data = cipher_auth_key;
2636         ut_params->auth_xform.auth.digest_length = auth_len;
2637         /* Auth IV will be after cipher IV */
2638         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2639         ut_params->auth_xform.auth.iv.length = auth_iv_len;
2640
2641         /* Setup Cipher Parameters */
2642         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2643         ut_params->cipher_xform.next = &ut_params->auth_xform;
2644
2645         ut_params->cipher_xform.cipher.algo = cipher_algo;
2646         ut_params->cipher_xform.cipher.op = cipher_op;
2647         ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2648         ut_params->cipher_xform.cipher.key.length = key_len;
2649         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2650         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2651
2652
2653         debug_hexdump(stdout, "key:", key, key_len);
2654
2655         /* Create Crypto session*/
2656         ut_params->sess = rte_cryptodev_sym_session_create(
2657                         ts_params->session_mpool);
2658
2659         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2660                         &ut_params->cipher_xform,
2661                         ts_params->session_priv_mpool);
2662
2663         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2664         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2665         return 0;
2666 }
2667
2668 static int
2669 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2670                 const struct wireless_test_data *tdata)
2671 {
2672         return create_wireless_cipher_auth_session(dev_id,
2673                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2674                 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2675                 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2676 }
2677
2678 static int
2679 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2680                 enum rte_crypto_cipher_operation cipher_op,
2681                 enum rte_crypto_auth_operation auth_op,
2682                 enum rte_crypto_auth_algorithm auth_algo,
2683                 enum rte_crypto_cipher_algorithm cipher_algo,
2684                 const uint8_t *key, const uint8_t key_len,
2685                 uint8_t auth_iv_len, uint8_t auth_len,
2686                 uint8_t cipher_iv_len)
2687 {
2688         uint8_t auth_cipher_key[key_len];
2689         int status;
2690         struct crypto_testsuite_params *ts_params = &testsuite_params;
2691         struct crypto_unittest_params *ut_params = &unittest_params;
2692
2693         memcpy(auth_cipher_key, key, key_len);
2694
2695         /* Setup Authentication Parameters */
2696         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2697         ut_params->auth_xform.auth.op = auth_op;
2698         ut_params->auth_xform.next = &ut_params->cipher_xform;
2699         ut_params->auth_xform.auth.algo = auth_algo;
2700         ut_params->auth_xform.auth.key.length = key_len;
2701         ut_params->auth_xform.auth.key.data = auth_cipher_key;
2702         ut_params->auth_xform.auth.digest_length = auth_len;
2703         /* Auth IV will be after cipher IV */
2704         ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2705         ut_params->auth_xform.auth.iv.length = auth_iv_len;
2706
2707         /* Setup Cipher Parameters */
2708         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2709         ut_params->cipher_xform.next = NULL;
2710         ut_params->cipher_xform.cipher.algo = cipher_algo;
2711         ut_params->cipher_xform.cipher.op = cipher_op;
2712         ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2713         ut_params->cipher_xform.cipher.key.length = key_len;
2714         ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2715         ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2716
2717         debug_hexdump(stdout, "key:", key, key_len);
2718
2719         /* Create Crypto session*/
2720         ut_params->sess = rte_cryptodev_sym_session_create(
2721                         ts_params->session_mpool);
2722
2723         status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2724                         &ut_params->auth_xform,
2725                         ts_params->session_priv_mpool);
2726         TEST_ASSERT_EQUAL(status, 0, "session init failed");
2727         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2728
2729         return 0;
2730 }
2731
2732 static int
2733 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2734                 unsigned int auth_tag_len,
2735                 const uint8_t *iv, unsigned int iv_len,
2736                 unsigned int data_pad_len,
2737                 enum rte_crypto_auth_operation op,
2738                 unsigned int auth_len, unsigned int auth_offset)
2739 {
2740         struct crypto_testsuite_params *ts_params = &testsuite_params;
2741
2742         struct crypto_unittest_params *ut_params = &unittest_params;
2743
2744         /* Generate Crypto op data structure */
2745         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2746                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2747         TEST_ASSERT_NOT_NULL(ut_params->op,
2748                 "Failed to allocate pktmbuf offload");
2749
2750         /* Set crypto operation data parameters */
2751         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2752
2753         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2754
2755         /* set crypto operation source mbuf */
2756         sym_op->m_src = ut_params->ibuf;
2757
2758         /* iv */
2759         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2760                         iv, iv_len);
2761         /* digest */
2762         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2763                                         ut_params->ibuf, auth_tag_len);
2764
2765         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2766                                 "no room to append auth tag");
2767         ut_params->digest = sym_op->auth.digest.data;
2768         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2769                         ut_params->ibuf, data_pad_len);
2770         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2771                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2772         else
2773                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2774
2775         debug_hexdump(stdout, "digest:",
2776                 sym_op->auth.digest.data,
2777                 auth_tag_len);
2778
2779         sym_op->auth.data.length = auth_len;
2780         sym_op->auth.data.offset = auth_offset;
2781
2782         return 0;
2783 }
2784
2785 static int
2786 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2787         enum rte_crypto_auth_operation op)
2788 {
2789         struct crypto_testsuite_params *ts_params = &testsuite_params;
2790         struct crypto_unittest_params *ut_params = &unittest_params;
2791
2792         const uint8_t *auth_tag = tdata->digest.data;
2793         const unsigned int auth_tag_len = tdata->digest.len;
2794         unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2795         unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2796
2797         const uint8_t *cipher_iv = tdata->cipher_iv.data;
2798         const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2799         const uint8_t *auth_iv = tdata->auth_iv.data;
2800         const uint8_t auth_iv_len = tdata->auth_iv.len;
2801         const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2802         const unsigned int auth_len = tdata->validAuthLenInBits.len;
2803
2804         /* Generate Crypto op data structure */
2805         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2806                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2807         TEST_ASSERT_NOT_NULL(ut_params->op,
2808                         "Failed to allocate pktmbuf offload");
2809         /* Set crypto operation data parameters */
2810         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2811
2812         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2813
2814         /* set crypto operation source mbuf */
2815         sym_op->m_src = ut_params->ibuf;
2816
2817         /* digest */
2818         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2819                         ut_params->ibuf, auth_tag_len);
2820
2821         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2822                         "no room to append auth tag");
2823         ut_params->digest = sym_op->auth.digest.data;
2824         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2825                         ut_params->ibuf, data_pad_len);
2826         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2827                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2828         else
2829                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2830
2831         debug_hexdump(stdout, "digest:",
2832                 sym_op->auth.digest.data,
2833                 auth_tag_len);
2834
2835         /* Copy cipher and auth IVs at the end of the crypto operation */
2836         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2837                                                 IV_OFFSET);
2838         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2839         iv_ptr += cipher_iv_len;
2840         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2841
2842         sym_op->cipher.data.length = cipher_len;
2843         sym_op->cipher.data.offset = 0;
2844         sym_op->auth.data.length = auth_len;
2845         sym_op->auth.data.offset = 0;
2846
2847         return 0;
2848 }
2849
2850 static int
2851 create_zuc_cipher_hash_generate_operation(
2852                 const struct wireless_test_data *tdata)
2853 {
2854         return create_wireless_cipher_hash_operation(tdata,
2855                 RTE_CRYPTO_AUTH_OP_GENERATE);
2856 }
2857
2858 static int
2859 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2860                 const unsigned auth_tag_len,
2861                 const uint8_t *auth_iv, uint8_t auth_iv_len,
2862                 unsigned data_pad_len,
2863                 enum rte_crypto_auth_operation op,
2864                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2865                 const unsigned cipher_len, const unsigned cipher_offset,
2866                 const unsigned auth_len, const unsigned auth_offset)
2867 {
2868         struct crypto_testsuite_params *ts_params = &testsuite_params;
2869         struct crypto_unittest_params *ut_params = &unittest_params;
2870
2871         /* Generate Crypto op data structure */
2872         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2873                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2874         TEST_ASSERT_NOT_NULL(ut_params->op,
2875                         "Failed to allocate pktmbuf offload");
2876         /* Set crypto operation data parameters */
2877         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2878
2879         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2880
2881         /* set crypto operation source mbuf */
2882         sym_op->m_src = ut_params->ibuf;
2883
2884         /* digest */
2885         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2886                         ut_params->ibuf, auth_tag_len);
2887
2888         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2889                         "no room to append auth tag");
2890         ut_params->digest = sym_op->auth.digest.data;
2891         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2892                         ut_params->ibuf, data_pad_len);
2893         if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2894                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2895         else
2896                 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2897
2898         debug_hexdump(stdout, "digest:",
2899                 sym_op->auth.digest.data,
2900                 auth_tag_len);
2901
2902         /* Copy cipher and auth IVs at the end of the crypto operation */
2903         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2904                                                 IV_OFFSET);
2905         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2906         iv_ptr += cipher_iv_len;
2907         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2908
2909         sym_op->cipher.data.length = cipher_len;
2910         sym_op->cipher.data.offset = cipher_offset;
2911         sym_op->auth.data.length = auth_len;
2912         sym_op->auth.data.offset = auth_offset;
2913
2914         return 0;
2915 }
2916
2917 static int
2918 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2919                 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2920                 const uint8_t *auth_iv, uint8_t auth_iv_len,
2921                 unsigned int data_pad_len,
2922                 unsigned int cipher_len, unsigned int cipher_offset,
2923                 unsigned int auth_len, unsigned int auth_offset,
2924                 uint8_t op_mode, uint8_t do_sgl)
2925 {
2926         struct crypto_testsuite_params *ts_params = &testsuite_params;
2927         struct crypto_unittest_params *ut_params = &unittest_params;
2928
2929         /* Generate Crypto op data structure */
2930         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2931                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2932         TEST_ASSERT_NOT_NULL(ut_params->op,
2933                         "Failed to allocate pktmbuf offload");
2934
2935         /* Set crypto operation data parameters */
2936         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2937
2938         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2939
2940         /* set crypto operation mbufs */
2941         sym_op->m_src = ut_params->ibuf;
2942         if (op_mode == OUT_OF_PLACE)
2943                 sym_op->m_dst = ut_params->obuf;
2944
2945         /* digest */
2946         if (!do_sgl) {
2947                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
2948                         (op_mode == IN_PLACE ?
2949                                 ut_params->ibuf : ut_params->obuf),
2950                         uint8_t *, data_pad_len);
2951                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2952                         (op_mode == IN_PLACE ?
2953                                 ut_params->ibuf : ut_params->obuf),
2954                         data_pad_len);
2955                 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2956         } else {
2957                 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
2958                 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
2959                                 sym_op->m_src : sym_op->m_dst);
2960                 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
2961                         remaining_off -= rte_pktmbuf_data_len(sgl_buf);
2962                         sgl_buf = sgl_buf->next;
2963                 }
2964                 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
2965                                 uint8_t *, remaining_off);
2966                 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
2967                                 remaining_off);
2968                 memset(sym_op->auth.digest.data, 0, remaining_off);
2969                 while (sgl_buf->next != NULL) {
2970                         memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
2971                                 0, rte_pktmbuf_data_len(sgl_buf));
2972                         sgl_buf = sgl_buf->next;
2973                 }
2974         }
2975
2976         /* Copy cipher and auth IVs at the end of the crypto operation */
2977         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
2978                         ut_params->op, uint8_t *, IV_OFFSET);
2979
2980         rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2981         iv_ptr += cipher_iv_len;
2982         rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2983
2984         sym_op->cipher.data.length = cipher_len;
2985         sym_op->cipher.data.offset = cipher_offset;
2986
2987         sym_op->auth.data.length = auth_len;
2988         sym_op->auth.data.offset = auth_offset;
2989
2990         return 0;
2991 }
2992
2993 static int
2994 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2995 {
2996         struct crypto_testsuite_params *ts_params = &testsuite_params;
2997         struct crypto_unittest_params *ut_params = &unittest_params;
2998
2999         int retval;
3000         unsigned plaintext_pad_len;
3001         unsigned plaintext_len;
3002         uint8_t *plaintext;
3003
3004         /* Create SNOW 3G session */
3005         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3006                         tdata->key.data, tdata->key.len,
3007                         tdata->auth_iv.len, tdata->digest.len,
3008                         RTE_CRYPTO_AUTH_OP_GENERATE,
3009                         RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3010         if (retval < 0)
3011                 return retval;
3012
3013         /* alloc mbuf and set payload */
3014         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3015
3016         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3017         rte_pktmbuf_tailroom(ut_params->ibuf));
3018
3019         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3020         /* Append data which is padded to a multiple of */
3021         /* the algorithms block size */
3022         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3023         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3024                                 plaintext_pad_len);
3025         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3026
3027         /* Create SNOW 3G operation */
3028         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3029                         tdata->auth_iv.data, tdata->auth_iv.len,
3030                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3031                         tdata->validAuthLenInBits.len,
3032                         0);
3033         if (retval < 0)
3034                 return retval;
3035
3036         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3037                                 ut_params->op);
3038         ut_params->obuf = ut_params->op->sym->m_src;
3039         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3040         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3041                         + plaintext_pad_len;
3042
3043         /* Validate obuf */
3044         TEST_ASSERT_BUFFERS_ARE_EQUAL(
3045         ut_params->digest,
3046         tdata->digest.data,
3047         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3048         "SNOW 3G Generated auth tag not as expected");
3049
3050         return 0;
3051 }
3052
3053 static int
3054 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3055 {
3056         struct crypto_testsuite_params *ts_params = &testsuite_params;
3057         struct crypto_unittest_params *ut_params = &unittest_params;
3058
3059         int retval;
3060         unsigned plaintext_pad_len;
3061         unsigned plaintext_len;
3062         uint8_t *plaintext;
3063
3064         /* Create SNOW 3G session */
3065         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3066                                 tdata->key.data, tdata->key.len,
3067                                 tdata->auth_iv.len, tdata->digest.len,
3068                                 RTE_CRYPTO_AUTH_OP_VERIFY,
3069                                 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3070         if (retval < 0)
3071                 return retval;
3072         /* alloc mbuf and set payload */
3073         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3074
3075         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3076         rte_pktmbuf_tailroom(ut_params->ibuf));
3077
3078         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3079         /* Append data which is padded to a multiple of */
3080         /* the algorithms block size */
3081         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3082         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3083                                 plaintext_pad_len);
3084         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3085
3086         /* Create SNOW 3G operation */
3087         retval = create_wireless_algo_hash_operation(tdata->digest.data,
3088                         tdata->digest.len,
3089                         tdata->auth_iv.data, tdata->auth_iv.len,
3090                         plaintext_pad_len,
3091                         RTE_CRYPTO_AUTH_OP_VERIFY,
3092                         tdata->validAuthLenInBits.len,
3093                         0);
3094         if (retval < 0)
3095                 return retval;
3096
3097         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3098                                 ut_params->op);
3099         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3100         ut_params->obuf = ut_params->op->sym->m_src;
3101         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3102                                 + plaintext_pad_len;
3103
3104         /* Validate obuf */
3105         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3106                 return 0;
3107         else
3108                 return -1;
3109
3110         return 0;
3111 }
3112
3113 static int
3114 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3115 {
3116         struct crypto_testsuite_params *ts_params = &testsuite_params;
3117         struct crypto_unittest_params *ut_params = &unittest_params;
3118
3119         int retval;
3120         unsigned plaintext_pad_len;
3121         unsigned plaintext_len;
3122         uint8_t *plaintext;
3123
3124         /* Create KASUMI session */
3125         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3126                         tdata->key.data, tdata->key.len,
3127                         0, tdata->digest.len,
3128                         RTE_CRYPTO_AUTH_OP_GENERATE,
3129                         RTE_CRYPTO_AUTH_KASUMI_F9);
3130         if (retval < 0)
3131                 return retval;
3132
3133         /* alloc mbuf and set payload */
3134         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3135
3136         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3137         rte_pktmbuf_tailroom(ut_params->ibuf));
3138
3139         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3140         /* Append data which is padded to a multiple of */
3141         /* the algorithms block size */
3142         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3143         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3144                                 plaintext_pad_len);
3145         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3146
3147         /* Create KASUMI operation */
3148         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3149                         NULL, 0,
3150                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3151                         tdata->plaintext.len,
3152                         0);
3153         if (retval < 0)
3154                 return retval;
3155
3156         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3157                                 ut_params->op);
3158         ut_params->obuf = ut_params->op->sym->m_src;
3159         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3160         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3161                         + plaintext_pad_len;
3162
3163         /* Validate obuf */
3164         TEST_ASSERT_BUFFERS_ARE_EQUAL(
3165         ut_params->digest,
3166         tdata->digest.data,
3167         DIGEST_BYTE_LENGTH_KASUMI_F9,
3168         "KASUMI Generated auth tag not as expected");
3169
3170         return 0;
3171 }
3172
3173 static int
3174 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3175 {
3176         struct crypto_testsuite_params *ts_params = &testsuite_params;
3177         struct crypto_unittest_params *ut_params = &unittest_params;
3178
3179         int retval;
3180         unsigned plaintext_pad_len;
3181         unsigned plaintext_len;
3182         uint8_t *plaintext;
3183
3184         /* Create KASUMI session */
3185         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3186                                 tdata->key.data, tdata->key.len,
3187                                 0, tdata->digest.len,
3188                                 RTE_CRYPTO_AUTH_OP_VERIFY,
3189                                 RTE_CRYPTO_AUTH_KASUMI_F9);
3190         if (retval < 0)
3191                 return retval;
3192         /* alloc mbuf and set payload */
3193         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3194
3195         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3196         rte_pktmbuf_tailroom(ut_params->ibuf));
3197
3198         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3199         /* Append data which is padded to a multiple */
3200         /* of the algorithms block size */
3201         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3202         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3203                                 plaintext_pad_len);
3204         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3205
3206         /* Create KASUMI operation */
3207         retval = create_wireless_algo_hash_operation(tdata->digest.data,
3208                         tdata->digest.len,
3209                         NULL, 0,
3210                         plaintext_pad_len,
3211                         RTE_CRYPTO_AUTH_OP_VERIFY,
3212                         tdata->plaintext.len,
3213                         0);
3214         if (retval < 0)
3215                 return retval;
3216
3217         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3218                                 ut_params->op);
3219         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3220         ut_params->obuf = ut_params->op->sym->m_src;
3221         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3222                                 + plaintext_pad_len;
3223
3224         /* Validate obuf */
3225         if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3226                 return 0;
3227         else
3228                 return -1;
3229
3230         return 0;
3231 }
3232
3233 static int
3234 test_snow3g_hash_generate_test_case_1(void)
3235 {
3236         return test_snow3g_authentication(&snow3g_hash_test_case_1);
3237 }
3238
3239 static int
3240 test_snow3g_hash_generate_test_case_2(void)
3241 {
3242         return test_snow3g_authentication(&snow3g_hash_test_case_2);
3243 }
3244
3245 static int
3246 test_snow3g_hash_generate_test_case_3(void)
3247 {
3248         return test_snow3g_authentication(&snow3g_hash_test_case_3);
3249 }
3250
3251 static int
3252 test_snow3g_hash_generate_test_case_4(void)
3253 {
3254         return test_snow3g_authentication(&snow3g_hash_test_case_4);
3255 }
3256
3257 static int
3258 test_snow3g_hash_generate_test_case_5(void)
3259 {
3260         return test_snow3g_authentication(&snow3g_hash_test_case_5);
3261 }
3262
3263 static int
3264 test_snow3g_hash_generate_test_case_6(void)
3265 {
3266         return test_snow3g_authentication(&snow3g_hash_test_case_6);
3267 }
3268
3269 static int
3270 test_snow3g_hash_verify_test_case_1(void)
3271 {
3272         return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3273
3274 }
3275
3276 static int
3277 test_snow3g_hash_verify_test_case_2(void)
3278 {
3279         return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3280 }
3281
3282 static int
3283 test_snow3g_hash_verify_test_case_3(void)
3284 {
3285         return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3286 }
3287
3288 static int
3289 test_snow3g_hash_verify_test_case_4(void)
3290 {
3291         return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3292 }
3293
3294 static int
3295 test_snow3g_hash_verify_test_case_5(void)
3296 {
3297         return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3298 }
3299
3300 static int
3301 test_snow3g_hash_verify_test_case_6(void)
3302 {
3303         return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3304 }
3305
3306 static int
3307 test_kasumi_hash_generate_test_case_1(void)
3308 {
3309         return test_kasumi_authentication(&kasumi_hash_test_case_1);
3310 }
3311
3312 static int
3313 test_kasumi_hash_generate_test_case_2(void)
3314 {
3315         return test_kasumi_authentication(&kasumi_hash_test_case_2);
3316 }
3317
3318 static int
3319 test_kasumi_hash_generate_test_case_3(void)
3320 {
3321         return test_kasumi_authentication(&kasumi_hash_test_case_3);
3322 }
3323
3324 static int
3325 test_kasumi_hash_generate_test_case_4(void)
3326 {
3327         return test_kasumi_authentication(&kasumi_hash_test_case_4);
3328 }
3329
3330 static int
3331 test_kasumi_hash_generate_test_case_5(void)
3332 {
3333         return test_kasumi_authentication(&kasumi_hash_test_case_5);
3334 }
3335
3336 static int
3337 test_kasumi_hash_generate_test_case_6(void)
3338 {
3339         return test_kasumi_authentication(&kasumi_hash_test_case_6);
3340 }
3341
3342 static int
3343 test_kasumi_hash_verify_test_case_1(void)
3344 {
3345         return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3346 }
3347
3348 static int
3349 test_kasumi_hash_verify_test_case_2(void)
3350 {
3351         return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3352 }
3353
3354 static int
3355 test_kasumi_hash_verify_test_case_3(void)
3356 {
3357         return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3358 }
3359
3360 static int
3361 test_kasumi_hash_verify_test_case_4(void)
3362 {
3363         return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3364 }
3365
3366 static int
3367 test_kasumi_hash_verify_test_case_5(void)
3368 {
3369         return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3370 }
3371
3372 static int
3373 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3374 {
3375         struct crypto_testsuite_params *ts_params = &testsuite_params;
3376         struct crypto_unittest_params *ut_params = &unittest_params;
3377
3378         int retval;
3379         uint8_t *plaintext, *ciphertext;
3380         unsigned plaintext_pad_len;
3381         unsigned plaintext_len;
3382
3383         /* Create KASUMI session */
3384         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3385                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3386                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3387                                         tdata->key.data, tdata->key.len,
3388                                         tdata->cipher_iv.len);
3389         if (retval < 0)
3390                 return retval;
3391
3392         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3393
3394         /* Clear mbuf payload */
3395         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3396                rte_pktmbuf_tailroom(ut_params->ibuf));
3397
3398         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3399         /* Append data which is padded to a multiple */
3400         /* of the algorithms block size */
3401         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3402         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3403                                 plaintext_pad_len);
3404         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3405
3406         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3407
3408         /* Create KASUMI operation */
3409         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3410                                 tdata->cipher_iv.len,
3411                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3412                                 tdata->validCipherOffsetInBits.len);
3413         if (retval < 0)
3414                 return retval;
3415
3416         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3417                                                 ut_params->op);
3418         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3419
3420         ut_params->obuf = ut_params->op->sym->m_dst;
3421         if (ut_params->obuf)
3422                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3423         else
3424                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3425
3426         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3427
3428         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3429                                 (tdata->validCipherOffsetInBits.len >> 3);
3430         /* Validate obuf */
3431         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3432                 ciphertext,
3433                 reference_ciphertext,
3434                 tdata->validCipherLenInBits.len,
3435                 "KASUMI Ciphertext data not as expected");
3436         return 0;
3437 }
3438
3439 static int
3440 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3441 {
3442         struct crypto_testsuite_params *ts_params = &testsuite_params;
3443         struct crypto_unittest_params *ut_params = &unittest_params;
3444
3445         int retval;
3446
3447         unsigned int plaintext_pad_len;
3448         unsigned int plaintext_len;
3449
3450         uint8_t buffer[10000];
3451         const uint8_t *ciphertext;
3452
3453         struct rte_cryptodev_info dev_info;
3454
3455         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3456
3457         uint64_t feat_flags = dev_info.feature_flags;
3458
3459         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3460                 printf("Device doesn't support in-place scatter-gather. "
3461                                 "Test Skipped.\n");
3462                 return -ENOTSUP;
3463         }
3464
3465         /* Create KASUMI session */
3466         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3467                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3468                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3469                                         tdata->key.data, tdata->key.len,
3470                                         tdata->cipher_iv.len);
3471         if (retval < 0)
3472                 return retval;
3473
3474         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3475
3476
3477         /* Append data which is padded to a multiple */
3478         /* of the algorithms block size */
3479         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3480
3481         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3482                         plaintext_pad_len, 10, 0);
3483
3484         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3485
3486         /* Create KASUMI operation */
3487         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3488                                 tdata->cipher_iv.len,
3489                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3490                                 tdata->validCipherOffsetInBits.len);
3491         if (retval < 0)
3492                 return retval;
3493
3494         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3495                                                 ut_params->op);
3496         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3497
3498         ut_params->obuf = ut_params->op->sym->m_dst;
3499
3500         if (ut_params->obuf)
3501                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3502                                 plaintext_len, buffer);
3503         else
3504                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3505                                 tdata->validCipherOffsetInBits.len >> 3,
3506                                 plaintext_len, buffer);
3507
3508         /* Validate obuf */
3509         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3510
3511         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3512                                 (tdata->validCipherOffsetInBits.len >> 3);
3513         /* Validate obuf */
3514         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3515                 ciphertext,
3516                 reference_ciphertext,
3517                 tdata->validCipherLenInBits.len,
3518                 "KASUMI Ciphertext data not as expected");
3519         return 0;
3520 }
3521
3522 static int
3523 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3524 {
3525         struct crypto_testsuite_params *ts_params = &testsuite_params;
3526         struct crypto_unittest_params *ut_params = &unittest_params;
3527
3528         int retval;
3529         uint8_t *plaintext, *ciphertext;
3530         unsigned plaintext_pad_len;
3531         unsigned plaintext_len;
3532
3533         /* Create KASUMI session */
3534         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3535                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3536                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3537                                         tdata->key.data, tdata->key.len,
3538                                         tdata->cipher_iv.len);
3539         if (retval < 0)
3540                 return retval;
3541
3542         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3543         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3544
3545         /* Clear mbuf payload */
3546         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3547                rte_pktmbuf_tailroom(ut_params->ibuf));
3548
3549         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3550         /* Append data which is padded to a multiple */
3551         /* of the algorithms block size */
3552         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3553         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3554                                 plaintext_pad_len);
3555         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3556         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3557
3558         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3559
3560         /* Create KASUMI operation */
3561         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3562                                 tdata->cipher_iv.len,
3563                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3564                                 tdata->validCipherOffsetInBits.len);
3565         if (retval < 0)
3566                 return retval;
3567
3568         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3569                                                 ut_params->op);
3570         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3571
3572         ut_params->obuf = ut_params->op->sym->m_dst;
3573         if (ut_params->obuf)
3574                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3575         else
3576                 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3577
3578         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3579
3580         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3581                                 (tdata->validCipherOffsetInBits.len >> 3);
3582         /* Validate obuf */
3583         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3584                 ciphertext,
3585                 reference_ciphertext,
3586                 tdata->validCipherLenInBits.len,
3587                 "KASUMI Ciphertext data not as expected");
3588         return 0;
3589 }
3590
3591 static int
3592 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3593 {
3594         struct crypto_testsuite_params *ts_params = &testsuite_params;
3595         struct crypto_unittest_params *ut_params = &unittest_params;
3596
3597         int retval;
3598         unsigned int plaintext_pad_len;
3599         unsigned int plaintext_len;
3600
3601         const uint8_t *ciphertext;
3602         uint8_t buffer[2048];
3603
3604         struct rte_cryptodev_info dev_info;
3605
3606         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3607
3608         uint64_t feat_flags = dev_info.feature_flags;
3609         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3610                 printf("Device doesn't support out-of-place scatter-gather "
3611                                 "in both input and output mbufs. "
3612                                 "Test Skipped.\n");
3613                 return -ENOTSUP;
3614         }
3615
3616         /* Create KASUMI session */
3617         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3618                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3619                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3620                                         tdata->key.data, tdata->key.len,
3621                                         tdata->cipher_iv.len);
3622         if (retval < 0)
3623                 return retval;
3624
3625         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3626         /* Append data which is padded to a multiple */
3627         /* of the algorithms block size */
3628         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3629
3630         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3631                         plaintext_pad_len, 10, 0);
3632         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3633                         plaintext_pad_len, 3, 0);
3634
3635         /* Append data which is padded to a multiple */
3636         /* of the algorithms block size */
3637         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3638
3639         /* Create KASUMI operation */
3640         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3641                                 tdata->cipher_iv.len,
3642                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3643                                 tdata->validCipherOffsetInBits.len);
3644         if (retval < 0)
3645                 return retval;
3646
3647         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3648                                                 ut_params->op);
3649         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3650
3651         ut_params->obuf = ut_params->op->sym->m_dst;
3652         if (ut_params->obuf)
3653                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3654                                 plaintext_pad_len, buffer);
3655         else
3656                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3657                                 tdata->validCipherOffsetInBits.len >> 3,
3658                                 plaintext_pad_len, buffer);
3659
3660         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3661                                 (tdata->validCipherOffsetInBits.len >> 3);
3662         /* Validate obuf */
3663         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3664                 ciphertext,
3665                 reference_ciphertext,
3666                 tdata->validCipherLenInBits.len,
3667                 "KASUMI Ciphertext data not as expected");
3668         return 0;
3669 }
3670
3671
3672 static int
3673 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3674 {
3675         struct crypto_testsuite_params *ts_params = &testsuite_params;
3676         struct crypto_unittest_params *ut_params = &unittest_params;
3677
3678         int retval;
3679         uint8_t *ciphertext, *plaintext;
3680         unsigned ciphertext_pad_len;
3681         unsigned ciphertext_len;
3682
3683         /* Create KASUMI session */
3684         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3685                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
3686                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3687                                         tdata->key.data, tdata->key.len,
3688                                         tdata->cipher_iv.len);
3689         if (retval < 0)
3690                 return retval;
3691
3692         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3693         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3694
3695         /* Clear mbuf payload */
3696         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3697                rte_pktmbuf_tailroom(ut_params->ibuf));
3698
3699         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3700         /* Append data which is padded to a multiple */
3701         /* of the algorithms block size */
3702         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3703         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3704                                 ciphertext_pad_len);
3705         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3706         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3707
3708         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3709
3710         /* Create KASUMI operation */
3711         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3712                                 tdata->cipher_iv.len,
3713                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3714                                 tdata->validCipherOffsetInBits.len);
3715         if (retval < 0)
3716                 return retval;
3717
3718         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3719                                                 ut_params->op);
3720         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3721
3722         ut_params->obuf = ut_params->op->sym->m_dst;
3723         if (ut_params->obuf)
3724                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3725         else
3726                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3727
3728         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3729
3730         const uint8_t *reference_plaintext = tdata->plaintext.data +
3731                                 (tdata->validCipherOffsetInBits.len >> 3);
3732         /* Validate obuf */
3733         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3734                 plaintext,
3735                 reference_plaintext,
3736                 tdata->validCipherLenInBits.len,
3737                 "KASUMI Plaintext data not as expected");
3738         return 0;
3739 }
3740
3741 static int
3742 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3743 {
3744         struct crypto_testsuite_params *ts_params = &testsuite_params;
3745         struct crypto_unittest_params *ut_params = &unittest_params;
3746
3747         int retval;
3748         uint8_t *ciphertext, *plaintext;
3749         unsigned ciphertext_pad_len;
3750         unsigned ciphertext_len;
3751
3752         /* Create KASUMI session */
3753         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3754                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
3755                                         RTE_CRYPTO_CIPHER_KASUMI_F8,
3756                                         tdata->key.data, tdata->key.len,
3757                                         tdata->cipher_iv.len);
3758         if (retval < 0)
3759                 return retval;
3760
3761         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3762
3763         /* Clear mbuf payload */
3764         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3765                rte_pktmbuf_tailroom(ut_params->ibuf));
3766
3767         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3768         /* Append data which is padded to a multiple */
3769         /* of the algorithms block size */
3770         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3771         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3772                                 ciphertext_pad_len);
3773         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3774
3775         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3776
3777         /* Create KASUMI operation */
3778         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3779                                         tdata->cipher_iv.len,
3780                                         tdata->ciphertext.len,
3781                                         tdata->validCipherOffsetInBits.len);
3782         if (retval < 0)
3783                 return retval;
3784
3785         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3786                                                 ut_params->op);
3787         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3788
3789         ut_params->obuf = ut_params->op->sym->m_dst;
3790         if (ut_params->obuf)
3791                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3792         else
3793                 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3794
3795         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3796
3797         const uint8_t *reference_plaintext = tdata->plaintext.data +
3798                                 (tdata->validCipherOffsetInBits.len >> 3);
3799         /* Validate obuf */
3800         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3801                 plaintext,
3802                 reference_plaintext,
3803                 tdata->validCipherLenInBits.len,
3804                 "KASUMI Plaintext data not as expected");
3805         return 0;
3806 }
3807
3808 static int
3809 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3810 {
3811         struct crypto_testsuite_params *ts_params = &testsuite_params;
3812         struct crypto_unittest_params *ut_params = &unittest_params;
3813
3814         int retval;
3815         uint8_t *plaintext, *ciphertext;
3816         unsigned plaintext_pad_len;
3817         unsigned plaintext_len;
3818
3819         /* Create SNOW 3G session */
3820         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3821                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3822                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3823                                         tdata->key.data, tdata->key.len,
3824                                         tdata->cipher_iv.len);
3825         if (retval < 0)
3826                 return retval;
3827
3828         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3829
3830         /* Clear mbuf payload */
3831         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3832                rte_pktmbuf_tailroom(ut_params->ibuf));
3833
3834         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3835         /* Append data which is padded to a multiple of */
3836         /* the algorithms block size */
3837         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3838         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3839                                 plaintext_pad_len);
3840         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3841
3842         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3843
3844         /* Create SNOW 3G operation */
3845         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3846                                         tdata->cipher_iv.len,
3847                                         tdata->validCipherLenInBits.len,
3848                                         0);
3849         if (retval < 0)
3850                 return retval;
3851
3852         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3853                                                 ut_params->op);
3854         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3855
3856         ut_params->obuf = ut_params->op->sym->m_dst;
3857         if (ut_params->obuf)
3858                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3859         else
3860                 ciphertext = plaintext;
3861
3862         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3863
3864         /* Validate obuf */
3865         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3866                 ciphertext,
3867                 tdata->ciphertext.data,
3868                 tdata->validDataLenInBits.len,
3869                 "SNOW 3G Ciphertext data not as expected");
3870         return 0;
3871 }
3872
3873
3874 static int
3875 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3876 {
3877         struct crypto_testsuite_params *ts_params = &testsuite_params;
3878         struct crypto_unittest_params *ut_params = &unittest_params;
3879         uint8_t *plaintext, *ciphertext;
3880
3881         int retval;
3882         unsigned plaintext_pad_len;
3883         unsigned plaintext_len;
3884
3885         /* Create SNOW 3G session */
3886         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3887                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3888                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3889                                         tdata->key.data, tdata->key.len,
3890                                         tdata->cipher_iv.len);
3891         if (retval < 0)
3892                 return retval;
3893
3894         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3895         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3896
3897         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3898                         "Failed to allocate input buffer in mempool");
3899         TEST_ASSERT_NOT_NULL(ut_params->obuf,
3900                         "Failed to allocate output buffer in mempool");
3901
3902         /* Clear mbuf payload */
3903         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3904                rte_pktmbuf_tailroom(ut_params->ibuf));
3905
3906         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3907         /* Append data which is padded to a multiple of */
3908         /* the algorithms block size */
3909         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3910         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3911                                 plaintext_pad_len);
3912         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3913         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3914
3915         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3916
3917         /* Create SNOW 3G operation */
3918         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3919                                         tdata->cipher_iv.len,
3920                                         tdata->validCipherLenInBits.len,
3921                                         0);
3922         if (retval < 0)
3923                 return retval;
3924
3925         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3926                                                 ut_params->op);
3927         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3928
3929         ut_params->obuf = ut_params->op->sym->m_dst;
3930         if (ut_params->obuf)
3931                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3932         else
3933                 ciphertext = plaintext;
3934
3935         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3936
3937         /* Validate obuf */
3938         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3939                 ciphertext,
3940                 tdata->ciphertext.data,
3941                 tdata->validDataLenInBits.len,
3942                 "SNOW 3G Ciphertext data not as expected");
3943         return 0;
3944 }
3945
3946 static int
3947 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3948 {
3949         struct crypto_testsuite_params *ts_params = &testsuite_params;
3950         struct crypto_unittest_params *ut_params = &unittest_params;
3951
3952         int retval;
3953         unsigned int plaintext_pad_len;
3954         unsigned int plaintext_len;
3955         uint8_t buffer[10000];
3956         const uint8_t *ciphertext;
3957
3958         struct rte_cryptodev_info dev_info;
3959
3960         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3961
3962         uint64_t feat_flags = dev_info.feature_flags;
3963
3964         if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3965                 printf("Device doesn't support out-of-place scatter-gather "
3966                                 "in both input and output mbufs. "
3967                                 "Test Skipped.\n");
3968                 return -ENOTSUP;
3969         }
3970
3971         /* Create SNOW 3G session */
3972         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3973                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3974                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3975                                         tdata->key.data, tdata->key.len,
3976                                         tdata->cipher_iv.len);
3977         if (retval < 0)
3978                 return retval;
3979
3980         plaintext_len = ceil_byte_length(tdata->plaintext.len);
3981         /* Append data which is padded to a multiple of */
3982         /* the algorithms block size */
3983         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3984
3985         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3986                         plaintext_pad_len, 10, 0);
3987         ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3988                         plaintext_pad_len, 3, 0);
3989
3990         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3991                         "Failed to allocate input buffer in mempool");
3992         TEST_ASSERT_NOT_NULL(ut_params->obuf,
3993                         "Failed to allocate output buffer in mempool");
3994
3995         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3996
3997         /* Create SNOW 3G operation */
3998         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3999                                         tdata->cipher_iv.len,
4000                                         tdata->validCipherLenInBits.len,
4001                                         0);
4002         if (retval < 0)
4003                 return retval;
4004
4005         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4006                                                 ut_params->op);
4007         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4008
4009         ut_params->obuf = ut_params->op->sym->m_dst;
4010         if (ut_params->obuf)
4011                 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4012                                 plaintext_len, buffer);
4013         else
4014                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4015                                 plaintext_len, buffer);
4016
4017         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4018
4019         /* Validate obuf */
4020         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4021                 ciphertext,
4022                 tdata->ciphertext.data,
4023                 tdata->validDataLenInBits.len,
4024                 "SNOW 3G Ciphertext data not as expected");
4025
4026         return 0;
4027 }
4028
4029 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4030 static void
4031 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4032 {
4033         uint8_t curr_byte, prev_byte;
4034         uint32_t length_in_bytes = ceil_byte_length(length + offset);
4035         uint8_t lower_byte_mask = (1 << offset) - 1;
4036         unsigned i;
4037
4038         prev_byte = buffer[0];
4039         buffer[0] >>= offset;
4040
4041         for (i = 1; i < length_in_bytes; i++) {
4042                 curr_byte = buffer[i];
4043                 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4044                                 (curr_byte >> offset);
4045                 prev_byte = curr_byte;
4046         }
4047 }
4048
4049 static int
4050 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4051 {
4052         struct crypto_testsuite_params *ts_params = &testsuite_params;
4053         struct crypto_unittest_params *ut_params = &unittest_params;
4054         uint8_t *plaintext, *ciphertext;
4055         int retval;
4056         uint32_t plaintext_len;
4057         uint32_t plaintext_pad_len;
4058         uint8_t extra_offset = 4;
4059         uint8_t *expected_ciphertext_shifted;
4060
4061         /* Create SNOW 3G session */
4062         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4063                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4064                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4065                                         tdata->key.data, tdata->key.len,
4066                                         tdata->cipher_iv.len);
4067         if (retval < 0)
4068                 return retval;
4069
4070         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4071         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4072
4073         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4074                         "Failed to allocate input buffer in mempool");
4075         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4076                         "Failed to allocate output buffer in mempool");
4077
4078         /* Clear mbuf payload */
4079         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4080                rte_pktmbuf_tailroom(ut_params->ibuf));
4081
4082         plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4083         /*
4084          * Append data which is padded to a
4085          * multiple of the algorithms block size
4086          */
4087         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4088
4089         plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4090                                                 plaintext_pad_len);
4091
4092         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093
4094         memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4095         buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4096
4097 #ifdef RTE_APP_TEST_DEBUG
4098         rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4099 #endif
4100         /* Create SNOW 3G operation */
4101         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4102                                         tdata->cipher_iv.len,
4103                                         tdata->validCipherLenInBits.len,
4104                                         extra_offset);
4105         if (retval < 0)
4106                 return retval;
4107
4108         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4109                                                 ut_params->op);
4110         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4111
4112         ut_params->obuf = ut_params->op->sym->m_dst;
4113         if (ut_params->obuf)
4114                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4115         else
4116                 ciphertext = plaintext;
4117
4118 #ifdef RTE_APP_TEST_DEBUG
4119         rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4120 #endif
4121
4122         expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4123
4124         TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4125                         "failed to reserve memory for ciphertext shifted\n");
4126
4127         memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4128                         ceil_byte_length(tdata->ciphertext.len));
4129         buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4130                         extra_offset);
4131         /* Validate obuf */
4132         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4133                 ciphertext,
4134                 expected_ciphertext_shifted,
4135                 tdata->validDataLenInBits.len,
4136                 extra_offset,
4137                 "SNOW 3G Ciphertext data not as expected");
4138         return 0;
4139 }
4140
4141 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4142 {
4143         struct crypto_testsuite_params *ts_params = &testsuite_params;
4144         struct crypto_unittest_params *ut_params = &unittest_params;
4145
4146         int retval;
4147
4148         uint8_t *plaintext, *ciphertext;
4149         unsigned ciphertext_pad_len;
4150         unsigned ciphertext_len;
4151
4152         /* Create SNOW 3G session */
4153         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4154                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
4155                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4156                                         tdata->key.data, tdata->key.len,
4157                                         tdata->cipher_iv.len);
4158         if (retval < 0)
4159                 return retval;
4160
4161         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4162
4163         /* Clear mbuf payload */
4164         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4165                rte_pktmbuf_tailroom(ut_params->ibuf));
4166
4167         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4168         /* Append data which is padded to a multiple of */
4169         /* the algorithms block size */
4170         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4171         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4172                                 ciphertext_pad_len);
4173         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4174
4175         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4176
4177         /* Create SNOW 3G operation */
4178         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4179                                         tdata->cipher_iv.len,
4180                                         tdata->validCipherLenInBits.len,
4181                                         tdata->cipher.offset_bits);
4182         if (retval < 0)
4183                 return retval;
4184
4185         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4186                                                 ut_params->op);
4187         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4188         ut_params->obuf = ut_params->op->sym->m_dst;
4189         if (ut_params->obuf)
4190                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4191         else
4192                 plaintext = ciphertext;
4193
4194         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4195
4196         /* Validate obuf */
4197         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4198                                 tdata->plaintext.data,
4199                                 tdata->validDataLenInBits.len,
4200                                 "SNOW 3G Plaintext data not as expected");
4201         return 0;
4202 }
4203
4204 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4205 {
4206         struct crypto_testsuite_params *ts_params = &testsuite_params;
4207         struct crypto_unittest_params *ut_params = &unittest_params;
4208
4209         int retval;
4210
4211         uint8_t *plaintext, *ciphertext;
4212         unsigned ciphertext_pad_len;
4213         unsigned ciphertext_len;
4214
4215         /* Create SNOW 3G session */
4216         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4217                                         RTE_CRYPTO_CIPHER_OP_DECRYPT,
4218                                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4219                                         tdata->key.data, tdata->key.len,
4220                                         tdata->cipher_iv.len);
4221         if (retval < 0)
4222                 return retval;
4223
4224         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4225         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4226
4227         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4228                         "Failed to allocate input buffer");
4229         TEST_ASSERT_NOT_NULL(ut_params->obuf,
4230                         "Failed to allocate output buffer");
4231
4232         /* Clear mbuf payload */
4233         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4234                rte_pktmbuf_tailroom(ut_params->ibuf));
4235
4236         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4237                        rte_pktmbuf_tailroom(ut_params->obuf));
4238
4239         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4240         /* Append data which is padded to a multiple of */
4241         /* the algorithms block size */
4242         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4243         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4244                                 ciphertext_pad_len);
4245         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4246         memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4247
4248         debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4249
4250         /* Create SNOW 3G operation */
4251         retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4252                                         tdata->cipher_iv.len,
4253                                         tdata->validCipherLenInBits.len,
4254                                         0);
4255         if (retval < 0)
4256                 return retval;
4257
4258         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4259                                                 ut_params->op);
4260         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4261         ut_params->obuf = ut_params->op->sym->m_dst;
4262         if (ut_params->obuf)
4263                 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4264         else
4265                 plaintext = ciphertext;
4266
4267         debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4268
4269         /* Validate obuf */
4270         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4271                                 tdata->plaintext.data,
4272                                 tdata->validDataLenInBits.len,
4273                                 "SNOW 3G Plaintext data not as expected");
4274         return 0;
4275 }
4276
4277 static int
4278 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4279 {
4280         struct crypto_testsuite_params *ts_params = &testsuite_params;
4281         struct crypto_unittest_params *ut_params = &unittest_params;
4282
4283         int retval;
4284
4285         uint8_t *plaintext, *ciphertext;
4286         unsigned int plaintext_pad_len;
4287         unsigned int plaintext_len;
4288
4289         struct rte_cryptodev_sym_capability_idx cap_idx;
4290
4291         /* Check if device supports ZUC EEA3 */
4292         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4293         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4294
4295         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4296                         &cap_idx) == NULL)
4297                 return -ENOTSUP;
4298
4299         /* Check if device supports ZUC EIA3 */
4300         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4301         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4302
4303         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4304                         &cap_idx) == NULL)
4305                 return -ENOTSUP;
4306
4307         /* Create ZUC session */
4308         retval = create_zuc_cipher_auth_encrypt_generate_session(
4309                         ts_params->valid_devs[0],
4310                         tdata);
4311         if (retval < 0)
4312                 return retval;
4313         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4314
4315         /* clear mbuf payload */
4316         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4317                         rte_pktmbuf_tailroom(ut_params->ibuf));
4318
4319         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4320         /* Append data which is padded to a multiple of */
4321         /* the algorithms block size */
4322         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4323         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4324                                 plaintext_pad_len);
4325         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4326
4327         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4328
4329         /* Create ZUC operation */
4330         retval = create_zuc_cipher_hash_generate_operation(tdata);
4331         if (retval < 0)
4332                 return retval;
4333
4334         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4335                         ut_params->op);
4336         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4337         ut_params->obuf = ut_params->op->sym->m_src;
4338         if (ut_params->obuf)
4339                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4340         else
4341                 ciphertext = plaintext;
4342
4343         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4344         /* Validate obuf */
4345         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4346                         ciphertext,
4347                         tdata->ciphertext.data,
4348                         tdata->validDataLenInBits.len,
4349                         "ZUC Ciphertext data not as expected");
4350
4351         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4352             + plaintext_pad_len;
4353
4354         /* Validate obuf */
4355         TEST_ASSERT_BUFFERS_ARE_EQUAL(
4356                         ut_params->digest,
4357                         tdata->digest.data,
4358                         4,
4359                         "ZUC Generated auth tag not as expected");
4360         return 0;
4361 }
4362
4363 static int
4364 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4365 {
4366         struct crypto_testsuite_params *ts_params = &testsuite_params;
4367         struct crypto_unittest_params *ut_params = &unittest_params;
4368
4369         int retval;
4370
4371         uint8_t *plaintext, *ciphertext;
4372         unsigned plaintext_pad_len;
4373         unsigned plaintext_len;
4374
4375         /* Create SNOW 3G session */
4376         retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4377                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4378                         RTE_CRYPTO_AUTH_OP_GENERATE,
4379                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4380                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4381                         tdata->key.data, tdata->key.len,
4382                         tdata->auth_iv.len, tdata->digest.len,
4383                         tdata->cipher_iv.len);
4384         if (retval < 0)
4385                 return retval;
4386         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4387
4388         /* clear mbuf payload */
4389         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4390                         rte_pktmbuf_tailroom(ut_params->ibuf));
4391
4392         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4393         /* Append data which is padded to a multiple of */
4394         /* the algorithms block size */
4395         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4396         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4397                                 plaintext_pad_len);
4398         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4399
4400         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4401
4402         /* Create SNOW 3G operation */
4403         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4404                         tdata->digest.len, tdata->auth_iv.data,
4405                         tdata->auth_iv.len,
4406                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4407                         tdata->cipher_iv.data, tdata->cipher_iv.len,
4408                         tdata->validCipherLenInBits.len,
4409                         0,
4410                         tdata->validAuthLenInBits.len,
4411                         0
4412                         );
4413         if (retval < 0)
4414                 return retval;
4415
4416         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4417                         ut_params->op);
4418         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4419         ut_params->obuf = ut_params->op->sym->m_src;
4420         if (ut_params->obuf)
4421                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4422         else
4423                 ciphertext = plaintext;
4424
4425         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4426         /* Validate obuf */
4427         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4428                         ciphertext,
4429                         tdata->ciphertext.data,
4430                         tdata->validDataLenInBits.len,
4431                         "SNOW 3G Ciphertext data not as expected");
4432
4433         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4434             + plaintext_pad_len;
4435
4436         /* Validate obuf */
4437         TEST_ASSERT_BUFFERS_ARE_EQUAL(
4438                         ut_params->digest,
4439                         tdata->digest.data,
4440                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4441                         "SNOW 3G Generated auth tag not as expected");
4442         return 0;
4443 }
4444
4445 static int
4446 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4447         uint8_t op_mode, uint8_t verify)
4448 {
4449         struct crypto_testsuite_params *ts_params = &testsuite_params;
4450         struct crypto_unittest_params *ut_params = &unittest_params;
4451
4452         int retval;
4453
4454         uint8_t *plaintext = NULL, *ciphertext = NULL;
4455         unsigned int plaintext_pad_len;
4456         unsigned int plaintext_len;
4457         unsigned int ciphertext_pad_len;
4458         unsigned int ciphertext_len;
4459
4460         struct rte_cryptodev_info dev_info;
4461
4462         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4463
4464         uint64_t feat_flags = dev_info.feature_flags;
4465
4466         if (op_mode == OUT_OF_PLACE) {
4467                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4468                         printf("Device doesn't support digest encrypted.\n");
4469                         return -ENOTSUP;
4470                 }
4471         }
4472
4473         /* Create SNOW 3G session */
4474         retval = create_wireless_algo_auth_cipher_session(
4475                         ts_params->valid_devs[0],
4476                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4477                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4478                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4479                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4480                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4481                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4482                         tdata->key.data, tdata->key.len,
4483                         tdata->auth_iv.len, tdata->digest.len,
4484                         tdata->cipher_iv.len);
4485
4486         if (retval < 0)
4487                 return retval;
4488
4489         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4490         if (op_mode == OUT_OF_PLACE)
4491                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4492
4493         /* clear mbuf payload */
4494         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4495                 rte_pktmbuf_tailroom(ut_params->ibuf));
4496         if (op_mode == OUT_OF_PLACE)
4497                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4498                         rte_pktmbuf_tailroom(ut_params->obuf));
4499
4500         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4501         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4502         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4503         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4504
4505         if (verify) {
4506                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4507                                         ciphertext_pad_len);
4508                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4509                 if (op_mode == OUT_OF_PLACE)
4510                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4511                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4512                         ciphertext_len);
4513         } else {
4514                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4515                                         plaintext_pad_len);
4516                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4517                 if (op_mode == OUT_OF_PLACE)
4518                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4519                 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4520         }
4521
4522         /* Create SNOW 3G operation */
4523         retval = create_wireless_algo_auth_cipher_operation(
4524                 tdata->digest.len,
4525                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4526                 tdata->auth_iv.data, tdata->auth_iv.len,
4527                 (tdata->digest.offset_bytes == 0 ?
4528                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4529                         : tdata->digest.offset_bytes),
4530                 tdata->validCipherLenInBits.len,
4531                 tdata->cipher.offset_bits,
4532                 tdata->validAuthLenInBits.len,
4533                 tdata->auth.offset_bits,
4534                 op_mode, 0);
4535
4536         if (retval < 0)
4537                 return retval;
4538
4539         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4540                         ut_params->op);
4541
4542         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4543
4544         ut_params->obuf = (op_mode == IN_PLACE ?
4545                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4546
4547         if (verify) {
4548                 if (ut_params->obuf)
4549                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4550                                                         uint8_t *);
4551                 else
4552                         plaintext = ciphertext +
4553                                 (tdata->cipher.offset_bits >> 3);
4554
4555                 debug_hexdump(stdout, "plaintext:", plaintext,
4556                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4557                 debug_hexdump(stdout, "plaintext expected:",
4558                         tdata->plaintext.data,
4559                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4560         } else {
4561                 if (ut_params->obuf)
4562                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4563                                                         uint8_t *);
4564                 else
4565                         ciphertext = plaintext;
4566
4567                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4568                         ciphertext_len);
4569                 debug_hexdump(stdout, "ciphertext expected:",
4570                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4571
4572                 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4573                         + (tdata->digest.offset_bytes == 0 ?
4574                 plaintext_pad_len : tdata->digest.offset_bytes);
4575
4576                 debug_hexdump(stdout, "digest:", ut_params->digest,
4577                         tdata->digest.len);
4578                 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4579                                 tdata->digest.len);
4580         }
4581
4582         /* Validate obuf */
4583         if (verify) {
4584                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4585                         plaintext,
4586                         tdata->plaintext.data,
4587                         tdata->plaintext.len >> 3,
4588                         "SNOW 3G Plaintext data not as expected");
4589         } else {
4590                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4591                         ciphertext,
4592                         tdata->ciphertext.data,
4593                         tdata->validDataLenInBits.len,
4594                         "SNOW 3G Ciphertext data not as expected");
4595
4596                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4597                         ut_params->digest,
4598                         tdata->digest.data,
4599                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4600                         "SNOW 3G Generated auth tag not as expected");
4601         }
4602         return 0;
4603 }
4604
4605 static int
4606 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4607         uint8_t op_mode, uint8_t verify)
4608 {
4609         struct crypto_testsuite_params *ts_params = &testsuite_params;
4610         struct crypto_unittest_params *ut_params = &unittest_params;
4611
4612         int retval;
4613
4614         const uint8_t *plaintext = NULL;
4615         const uint8_t *ciphertext = NULL;
4616         const uint8_t *digest = NULL;
4617         unsigned int plaintext_pad_len;
4618         unsigned int plaintext_len;
4619         unsigned int ciphertext_pad_len;
4620         unsigned int ciphertext_len;
4621         uint8_t buffer[10000];
4622         uint8_t digest_buffer[10000];
4623
4624         struct rte_cryptodev_info dev_info;
4625
4626         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4627
4628         uint64_t feat_flags = dev_info.feature_flags;
4629
4630         if (op_mode == IN_PLACE) {
4631                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4632                         printf("Device doesn't support in-place scatter-gather "
4633                                         "in both input and output mbufs.\n");
4634                         return -ENOTSUP;
4635                 }
4636         } else {
4637                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4638                         printf("Device doesn't support out-of-place scatter-gather "
4639                                         "in both input and output mbufs.\n");
4640                         return -ENOTSUP;
4641                 }
4642                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4643                         printf("Device doesn't support digest encrypted.\n");
4644                         return -ENOTSUP;
4645                 }
4646         }
4647
4648         /* Create SNOW 3G session */
4649         retval = create_wireless_algo_auth_cipher_session(
4650                         ts_params->valid_devs[0],
4651                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4652                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4653                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4654                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4655                         RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4656                         RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4657                         tdata->key.data, tdata->key.len,
4658                         tdata->auth_iv.len, tdata->digest.len,
4659                         tdata->cipher_iv.len);
4660
4661         if (retval < 0)
4662                 return retval;
4663
4664         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4665         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4666         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4667         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4668
4669         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4670                         plaintext_pad_len, 15, 0);
4671         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4672                         "Failed to allocate input buffer in mempool");
4673
4674         if (op_mode == OUT_OF_PLACE) {
4675                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4676                                 plaintext_pad_len, 15, 0);
4677                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4678                                 "Failed to allocate output buffer in mempool");
4679         }
4680
4681         if (verify) {
4682                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4683                         tdata->ciphertext.data);
4684                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4685                                         ciphertext_len, buffer);
4686                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4687                         ciphertext_len);
4688         } else {
4689                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4690                         tdata->plaintext.data);
4691                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4692                                         plaintext_len, buffer);
4693                 debug_hexdump(stdout, "plaintext:", plaintext,
4694                         plaintext_len);
4695         }
4696         memset(buffer, 0, sizeof(buffer));
4697
4698         /* Create SNOW 3G operation */
4699         retval = create_wireless_algo_auth_cipher_operation(
4700                 tdata->digest.len,
4701                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4702                 tdata->auth_iv.data, tdata->auth_iv.len,
4703                 (tdata->digest.offset_bytes == 0 ?
4704                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4705                         : tdata->digest.offset_bytes),
4706                 tdata->validCipherLenInBits.len,
4707                 tdata->cipher.offset_bits,
4708                 tdata->validAuthLenInBits.len,
4709                 tdata->auth.offset_bits,
4710                 op_mode, 1);
4711
4712         if (retval < 0)
4713                 return retval;
4714
4715         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4716                         ut_params->op);
4717
4718         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4719
4720         ut_params->obuf = (op_mode == IN_PLACE ?
4721                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4722
4723         if (verify) {
4724                 if (ut_params->obuf)
4725                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4726                                         plaintext_len, buffer);
4727                 else
4728                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4729                                         plaintext_len, buffer);
4730
4731                 debug_hexdump(stdout, "plaintext:", plaintext,
4732                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4733                 debug_hexdump(stdout, "plaintext expected:",
4734                         tdata->plaintext.data,
4735                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4736         } else {
4737                 if (ut_params->obuf)
4738                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4739                                         ciphertext_len, buffer);
4740                 else
4741                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4742                                         ciphertext_len, buffer);
4743
4744                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4745                         ciphertext_len);
4746                 debug_hexdump(stdout, "ciphertext expected:",
4747                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4748
4749                 if (ut_params->obuf)
4750                         digest = rte_pktmbuf_read(ut_params->obuf,
4751                                 (tdata->digest.offset_bytes == 0 ?
4752                                 plaintext_pad_len : tdata->digest.offset_bytes),
4753                                 tdata->digest.len, digest_buffer);
4754                 else
4755                         digest = rte_pktmbuf_read(ut_params->ibuf,
4756                                 (tdata->digest.offset_bytes == 0 ?
4757                                 plaintext_pad_len : tdata->digest.offset_bytes),
4758                                 tdata->digest.len, digest_buffer);
4759
4760                 debug_hexdump(stdout, "digest:", digest,
4761                         tdata->digest.len);
4762                 debug_hexdump(stdout, "digest expected:",
4763                         tdata->digest.data, tdata->digest.len);
4764         }
4765
4766         /* Validate obuf */
4767         if (verify) {
4768                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4769                         plaintext,
4770                         tdata->plaintext.data,
4771                         tdata->plaintext.len >> 3,
4772                         "SNOW 3G Plaintext data not as expected");
4773         } else {
4774                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4775                         ciphertext,
4776                         tdata->ciphertext.data,
4777                         tdata->validDataLenInBits.len,
4778                         "SNOW 3G Ciphertext data not as expected");
4779
4780                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4781                         digest,
4782                         tdata->digest.data,
4783                         DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4784                         "SNOW 3G Generated auth tag not as expected");
4785         }
4786         return 0;
4787 }
4788
4789 static int
4790 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4791         uint8_t op_mode, uint8_t verify)
4792 {
4793         struct crypto_testsuite_params *ts_params = &testsuite_params;
4794         struct crypto_unittest_params *ut_params = &unittest_params;
4795
4796         int retval;
4797
4798         uint8_t *plaintext = NULL, *ciphertext = NULL;
4799         unsigned int plaintext_pad_len;
4800         unsigned int plaintext_len;
4801         unsigned int ciphertext_pad_len;
4802         unsigned int ciphertext_len;
4803
4804         struct rte_cryptodev_info dev_info;
4805
4806         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4807
4808         uint64_t feat_flags = dev_info.feature_flags;
4809
4810         if (op_mode == OUT_OF_PLACE) {
4811                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4812                         printf("Device doesn't support digest encrypted.\n");
4813                         return -ENOTSUP;
4814                 }
4815         }
4816
4817         /* Create KASUMI session */
4818         retval = create_wireless_algo_auth_cipher_session(
4819                         ts_params->valid_devs[0],
4820                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4821                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4822                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4823                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
4824                         RTE_CRYPTO_AUTH_KASUMI_F9,
4825                         RTE_CRYPTO_CIPHER_KASUMI_F8,
4826                         tdata->key.data, tdata->key.len,
4827                         0, tdata->digest.len,
4828                         tdata->cipher_iv.len);
4829
4830         if (retval < 0)
4831                 return retval;
4832
4833         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4834         if (op_mode == OUT_OF_PLACE)
4835                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4836
4837         /* clear mbuf payload */
4838         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4839                 rte_pktmbuf_tailroom(ut_params->ibuf));
4840         if (op_mode == OUT_OF_PLACE)
4841                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4842                         rte_pktmbuf_tailroom(ut_params->obuf));
4843
4844         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4845         plaintext_len = ceil_byte_length(tdata->plaintext.len);
4846         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4847         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4848
4849         if (verify) {
4850                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4851                                         ciphertext_pad_len);
4852                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4853                 if (op_mode == OUT_OF_PLACE)
4854                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4855                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4856                         ciphertext_len);
4857         } else {
4858                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4859                                         plaintext_pad_len);
4860                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4861                 if (op_mode == OUT_OF_PLACE)
4862                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4863                 debug_hexdump(stdout, "plaintext:", plaintext,
4864                         plaintext_len);
4865         }
4866
4867         /* Create KASUMI operation */
4868         retval = create_wireless_algo_auth_cipher_operation(
4869                 tdata->digest.len,
4870                 tdata->cipher_iv.data, tdata->cipher_iv.len,
4871                 NULL, 0,
4872                 (tdata->digest.offset_bytes == 0 ?
4873                 (verify ? ciphertext_pad_len : plaintext_pad_len)
4874                         : tdata->digest.offset_bytes),
4875                 tdata->validCipherLenInBits.len,
4876                 tdata->validCipherOffsetInBits.len,
4877                 tdata->validAuthLenInBits.len,
4878                 0,
4879                 op_mode, 0);
4880
4881         if (retval < 0)
4882                 return retval;
4883
4884         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4885                         ut_params->op);
4886
4887         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4888
4889         ut_params->obuf = (op_mode == IN_PLACE ?
4890                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4891
4892
4893         if (verify) {
4894                 if (ut_params->obuf)
4895                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4896                                                         uint8_t *);
4897                 else
4898                         plaintext = ciphertext;
4899
4900                 debug_hexdump(stdout, "plaintext:", plaintext,
4901                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4902                 debug_hexdump(stdout, "plaintext expected:",
4903                         tdata->plaintext.data,
4904                         (tdata->plaintext.len >> 3) - tdata->digest.len);
4905         } else {
4906                 if (ut_params->obuf)
4907                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4908                                                         uint8_t *);
4909                 else
4910                         ciphertext = plaintext;
4911
4912                 debug_hexdump(stdout, "ciphertext:", ciphertext,
4913                         ciphertext_len);
4914                 debug_hexdump(stdout, "ciphertext expected:",
4915                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4916
4917                 ut_params->digest = rte_pktmbuf_mtod(
4918                         ut_params->obuf, uint8_t *) +
4919                         (tdata->digest.offset_bytes == 0 ?
4920                         plaintext_pad_len : tdata->digest.offset_bytes);
4921
4922                 debug_hexdump(stdout, "digest:", ut_params->digest,
4923                         tdata->digest.len);
4924                 debug_hexdump(stdout, "digest expected:",
4925                         tdata->digest.data, tdata->digest.len);
4926         }
4927
4928         /* Validate obuf */
4929         if (verify) {
4930                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4931                         plaintext,
4932                         tdata->plaintext.data,
4933                         tdata->plaintext.len >> 3,
4934                         "KASUMI Plaintext data not as expected");
4935         } else {
4936                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4937                         ciphertext,
4938                         tdata->ciphertext.data,
4939                         tdata->ciphertext.len >> 3,
4940                         "KASUMI Ciphertext data not as expected");
4941
4942                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4943                         ut_params->digest,
4944                         tdata->digest.data,
4945                         DIGEST_BYTE_LENGTH_KASUMI_F9,
4946                         "KASUMI Generated auth tag not as expected");
4947         }
4948         return 0;
4949 }
4950
4951 static int
4952 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
4953         uint8_t op_mode, uint8_t verify)
4954 {
4955         struct crypto_testsuite_params *ts_params = &testsuite_params;
4956         struct crypto_unittest_params *ut_params = &unittest_params;
4957
4958         int retval;
4959
4960         const uint8_t *plaintext = NULL;
4961         const uint8_t *ciphertext = NULL;
4962         const uint8_t *digest = NULL;
4963         unsigned int plaintext_pad_len;
4964         unsigned int plaintext_len;
4965         unsigned int ciphertext_pad_len;
4966         unsigned int ciphertext_len;
4967         uint8_t buffer[10000];
4968         uint8_t digest_buffer[10000];
4969
4970         struct rte_cryptodev_info dev_info;
4971
4972         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4973
4974         uint64_t feat_flags = dev_info.feature_flags;
4975
4976         if (op_mode == IN_PLACE) {
4977                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4978                         printf("Device doesn't support in-place scatter-gather "
4979                                         "in both input and output mbufs.\n");
4980                         return -ENOTSUP;
4981                 }
4982         } else {
4983                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4984                         printf("Device doesn't support out-of-place scatter-gather "
4985                                         "in both input and output mbufs.\n");
4986                         return -ENOTSUP;
4987                 }
4988                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4989                         printf("Device doesn't support digest encrypted.\n");
4990                         return -ENOTSUP;
4991                 }
4992         }
4993
4994         /* Create KASUMI session */
4995         retval = create_wireless_algo_auth_cipher_session(
4996                         ts_params->valid_devs[0],
4997                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4998                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4999                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5000                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
5001                         RTE_CRYPTO_AUTH_KASUMI_F9,
5002                         RTE_CRYPTO_CIPHER_KASUMI_F8,
5003                         tdata->key.data, tdata->key.len,
5004                         0, tdata->digest.len,
5005                         tdata->cipher_iv.len);
5006
5007         if (retval < 0)
5008                 return retval;
5009
5010         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5011         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5012         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5013         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5014
5015         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5016                         plaintext_pad_len, 15, 0);
5017         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5018                         "Failed to allocate input buffer in mempool");
5019
5020         if (op_mode == OUT_OF_PLACE) {
5021                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5022                                 plaintext_pad_len, 15, 0);
5023                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5024                                 "Failed to allocate output buffer in mempool");
5025         }
5026
5027         if (verify) {
5028                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5029                         tdata->ciphertext.data);
5030                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5031                                         ciphertext_len, buffer);
5032                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5033                         ciphertext_len);
5034         } else {
5035                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5036                         tdata->plaintext.data);
5037                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5038                                         plaintext_len, buffer);
5039                 debug_hexdump(stdout, "plaintext:", plaintext,
5040                         plaintext_len);
5041         }
5042         memset(buffer, 0, sizeof(buffer));
5043
5044         /* Create KASUMI operation */
5045         retval = create_wireless_algo_auth_cipher_operation(
5046                 tdata->digest.len,
5047                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5048                 NULL, 0,
5049                 (tdata->digest.offset_bytes == 0 ?
5050                 (verify ? ciphertext_pad_len : plaintext_pad_len)
5051                         : tdata->digest.offset_bytes),
5052                 tdata->validCipherLenInBits.len,
5053                 tdata->validCipherOffsetInBits.len,
5054                 tdata->validAuthLenInBits.len,
5055                 0,
5056                 op_mode, 1);
5057
5058         if (retval < 0)
5059                 return retval;
5060
5061         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5062                         ut_params->op);
5063
5064         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5065
5066         ut_params->obuf = (op_mode == IN_PLACE ?
5067                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5068
5069         if (verify) {
5070                 if (ut_params->obuf)
5071                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5072                                         plaintext_len, buffer);
5073                 else
5074                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5075                                         plaintext_len, buffer);
5076
5077                 debug_hexdump(stdout, "plaintext:", plaintext,
5078                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5079                 debug_hexdump(stdout, "plaintext expected:",
5080                         tdata->plaintext.data,
5081                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5082         } else {
5083                 if (ut_params->obuf)
5084                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5085                                         ciphertext_len, buffer);
5086                 else
5087                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5088                                         ciphertext_len, buffer);
5089
5090                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5091                         ciphertext_len);
5092                 debug_hexdump(stdout, "ciphertext expected:",
5093                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5094
5095                 if (ut_params->obuf)
5096                         digest = rte_pktmbuf_read(ut_params->obuf,
5097                                 (tdata->digest.offset_bytes == 0 ?
5098                                 plaintext_pad_len : tdata->digest.offset_bytes),
5099                                 tdata->digest.len, digest_buffer);
5100                 else
5101                         digest = rte_pktmbuf_read(ut_params->ibuf,
5102                                 (tdata->digest.offset_bytes == 0 ?
5103                                 plaintext_pad_len : tdata->digest.offset_bytes),
5104                                 tdata->digest.len, digest_buffer);
5105
5106                 debug_hexdump(stdout, "digest:", digest,
5107                         tdata->digest.len);
5108                 debug_hexdump(stdout, "digest expected:",
5109                         tdata->digest.data, tdata->digest.len);
5110         }
5111
5112         /* Validate obuf */
5113         if (verify) {
5114                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5115                         plaintext,
5116                         tdata->plaintext.data,
5117                         tdata->plaintext.len >> 3,
5118                         "KASUMI Plaintext data not as expected");
5119         } else {
5120                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5121                         ciphertext,
5122                         tdata->ciphertext.data,
5123                         tdata->validDataLenInBits.len,
5124                         "KASUMI Ciphertext data not as expected");
5125
5126                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5127                         digest,
5128                         tdata->digest.data,
5129                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5130                         "KASUMI Generated auth tag not as expected");
5131         }
5132         return 0;
5133 }
5134
5135 static int
5136 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5137 {
5138         struct crypto_testsuite_params *ts_params = &testsuite_params;
5139         struct crypto_unittest_params *ut_params = &unittest_params;
5140
5141         int retval;
5142
5143         uint8_t *plaintext, *ciphertext;
5144         unsigned plaintext_pad_len;
5145         unsigned plaintext_len;
5146
5147         /* Create KASUMI session */
5148         retval = create_wireless_algo_cipher_auth_session(
5149                         ts_params->valid_devs[0],
5150                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5151                         RTE_CRYPTO_AUTH_OP_GENERATE,
5152                         RTE_CRYPTO_AUTH_KASUMI_F9,
5153                         RTE_CRYPTO_CIPHER_KASUMI_F8,
5154                         tdata->key.data, tdata->key.len,
5155                         0, tdata->digest.len,
5156                         tdata->cipher_iv.len);
5157         if (retval < 0)
5158                 return retval;
5159
5160         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5161
5162         /* clear mbuf payload */
5163         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5164                         rte_pktmbuf_tailroom(ut_params->ibuf));
5165
5166         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5167         /* Append data which is padded to a multiple of */
5168         /* the algorithms block size */
5169         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5170         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5171                                 plaintext_pad_len);
5172         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5173
5174         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5175
5176         /* Create KASUMI operation */
5177         retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5178                                 tdata->digest.len, NULL, 0,
5179                                 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5180                                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5181                                 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5182                                 tdata->validCipherOffsetInBits.len,
5183                                 tdata->validAuthLenInBits.len,
5184                                 0
5185                                 );
5186         if (retval < 0)
5187                 return retval;
5188
5189         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5190                         ut_params->op);
5191         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5192
5193         if (ut_params->op->sym->m_dst)
5194                 ut_params->obuf = ut_params->op->sym->m_dst;
5195         else
5196                 ut_params->obuf = ut_params->op->sym->m_src;
5197
5198         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5199                                 tdata->validCipherOffsetInBits.len >> 3);
5200
5201         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5202                         + plaintext_pad_len;
5203
5204         const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5205                                 (tdata->validCipherOffsetInBits.len >> 3);
5206         /* Validate obuf */
5207         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5208                 ciphertext,
5209                 reference_ciphertext,
5210                 tdata->validCipherLenInBits.len,
5211                 "KASUMI Ciphertext data not as expected");
5212
5213         /* Validate obuf */
5214         TEST_ASSERT_BUFFERS_ARE_EQUAL(
5215                 ut_params->digest,
5216                 tdata->digest.data,
5217                 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5218                 "KASUMI Generated auth tag not as expected");
5219         return 0;
5220 }
5221
5222 static int
5223 test_zuc_encryption(const struct wireless_test_data *tdata)
5224 {
5225         struct crypto_testsuite_params *ts_params = &testsuite_params;
5226         struct crypto_unittest_params *ut_params = &unittest_params;
5227
5228         int retval;
5229         uint8_t *plaintext, *ciphertext;
5230         unsigned plaintext_pad_len;
5231         unsigned plaintext_len;
5232
5233         struct rte_cryptodev_sym_capability_idx cap_idx;
5234
5235         /* Check if device supports ZUC EEA3 */
5236         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5237         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5238
5239         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5240                         &cap_idx) == NULL)
5241                 return -ENOTSUP;
5242
5243         /* Create ZUC session */
5244         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5245                                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5246                                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5247                                         tdata->key.data, tdata->key.len,
5248                                         tdata->cipher_iv.len);
5249         if (retval < 0)
5250                 return retval;
5251
5252         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5253
5254         /* Clear mbuf payload */
5255         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5256                rte_pktmbuf_tailroom(ut_params->ibuf));
5257
5258         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5259         /* Append data which is padded to a multiple */
5260         /* of the algorithms block size */
5261         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5262         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5263                                 plaintext_pad_len);
5264         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5265
5266         debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5267
5268         /* Create ZUC operation */
5269         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5270                                         tdata->cipher_iv.len,
5271                                         tdata->plaintext.len,
5272                                         0);
5273         if (retval < 0)
5274                 return retval;
5275
5276         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5277                                                 ut_params->op);
5278         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5279
5280         ut_params->obuf = ut_params->op->sym->m_dst;
5281         if (ut_params->obuf)
5282                 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5283         else
5284                 ciphertext = plaintext;
5285
5286         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5287
5288         /* Validate obuf */
5289         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5290                 ciphertext,
5291                 tdata->ciphertext.data,
5292                 tdata->validCipherLenInBits.len,
5293                 "ZUC Ciphertext data not as expected");
5294         return 0;
5295 }
5296
5297 static int
5298 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5299 {
5300         struct crypto_testsuite_params *ts_params = &testsuite_params;
5301         struct crypto_unittest_params *ut_params = &unittest_params;
5302
5303         int retval;
5304
5305         unsigned int plaintext_pad_len;
5306         unsigned int plaintext_len;
5307         const uint8_t *ciphertext;
5308         uint8_t ciphertext_buffer[2048];
5309         struct rte_cryptodev_info dev_info;
5310
5311         struct rte_cryptodev_sym_capability_idx cap_idx;
5312
5313         /* Check if device supports ZUC EEA3 */
5314         cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5315         cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5316
5317         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5318                         &cap_idx) == NULL)
5319                 return -ENOTSUP;
5320
5321         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5322
5323         uint64_t feat_flags = dev_info.feature_flags;
5324
5325         if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5326                 printf("Device doesn't support in-place scatter-gather. "
5327                                 "Test Skipped.\n");
5328                 return -ENOTSUP;
5329         }
5330
5331         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5332
5333         /* Append data which is padded to a multiple */
5334         /* of the algorithms block size */
5335         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5336
5337         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5338                         plaintext_pad_len, 10, 0);
5339
5340         pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5341                         tdata->plaintext.data);
5342
5343         /* Create ZUC session */
5344         retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5345                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5346                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5347                         tdata->key.data, tdata->key.len,
5348                         tdata->cipher_iv.len);
5349         if (retval < 0)
5350                 return retval;
5351
5352         /* Clear mbuf payload */
5353
5354         pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5355
5356         /* Create ZUC operation */
5357         retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5358                         tdata->cipher_iv.len, tdata->plaintext.len,
5359                         0);
5360         if (retval < 0)
5361                 return retval;
5362
5363         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5364                                                 ut_params->op);
5365         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5366
5367         ut_params->obuf = ut_params->op->sym->m_dst;
5368         if (ut_params->obuf)
5369                 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5370                         0, plaintext_len, ciphertext_buffer);
5371         else
5372                 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5373                         0, plaintext_len, ciphertext_buffer);
5374
5375         /* Validate obuf */
5376         debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5377
5378         /* Validate obuf */
5379         TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5380                 ciphertext,
5381                 tdata->ciphertext.data,
5382                 tdata->validCipherLenInBits.len,
5383                 "ZUC Ciphertext data not as expected");
5384
5385         return 0;
5386 }
5387
5388 static int
5389 test_zuc_authentication(const struct wireless_test_data *tdata)
5390 {
5391         struct crypto_testsuite_params *ts_params = &testsuite_params;
5392         struct crypto_unittest_params *ut_params = &unittest_params;
5393
5394         int retval;
5395         unsigned plaintext_pad_len;
5396         unsigned plaintext_len;
5397         uint8_t *plaintext;
5398
5399         struct rte_cryptodev_sym_capability_idx cap_idx;
5400
5401         /* Check if device supports ZUC EIA3 */
5402         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5403         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5404
5405         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5406                         &cap_idx) == NULL)
5407                 return -ENOTSUP;
5408
5409         /* Create ZUC session */
5410         retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5411                         tdata->key.data, tdata->key.len,
5412                         tdata->auth_iv.len, tdata->digest.len,
5413                         RTE_CRYPTO_AUTH_OP_GENERATE,
5414                         RTE_CRYPTO_AUTH_ZUC_EIA3);
5415         if (retval < 0)
5416                 return retval;
5417
5418         /* alloc mbuf and set payload */
5419         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5420
5421         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5422         rte_pktmbuf_tailroom(ut_params->ibuf));
5423
5424         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5425         /* Append data which is padded to a multiple of */
5426         /* the algorithms block size */
5427         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5428         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5429                                 plaintext_pad_len);
5430         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5431
5432         /* Create ZUC operation */
5433         retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5434                         tdata->auth_iv.data, tdata->auth_iv.len,
5435                         plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5436                         tdata->validAuthLenInBits.len,
5437                         0);
5438         if (retval < 0)
5439                 return retval;
5440
5441         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5442                                 ut_params->op);
5443         ut_params->obuf = ut_params->op->sym->m_src;
5444         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5445         ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5446                         + plaintext_pad_len;
5447
5448         /* Validate obuf */
5449         TEST_ASSERT_BUFFERS_ARE_EQUAL(
5450         ut_params->digest,
5451         tdata->digest.data,
5452         DIGEST_BYTE_LENGTH_KASUMI_F9,
5453         "ZUC Generated auth tag not as expected");
5454
5455         return 0;
5456 }
5457
5458 static int
5459 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5460         uint8_t op_mode, uint8_t verify)
5461 {
5462         struct crypto_testsuite_params *ts_params = &testsuite_params;
5463         struct crypto_unittest_params *ut_params = &unittest_params;
5464
5465         int retval;
5466
5467         uint8_t *plaintext = NULL, *ciphertext = NULL;
5468         unsigned int plaintext_pad_len;
5469         unsigned int plaintext_len;
5470         unsigned int ciphertext_pad_len;
5471         unsigned int ciphertext_len;
5472
5473         struct rte_cryptodev_info dev_info;
5474         struct rte_cryptodev_sym_capability_idx cap_idx;
5475
5476         /* Check if device supports ZUC EIA3 */
5477         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5478         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5479
5480         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5481                         &cap_idx) == NULL)
5482                 return -ENOTSUP;
5483
5484         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5485
5486         uint64_t feat_flags = dev_info.feature_flags;
5487
5488         if (op_mode == OUT_OF_PLACE) {
5489                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5490                         printf("Device doesn't support digest encrypted.\n");
5491                         return -ENOTSUP;
5492                 }
5493         }
5494
5495         /* Create ZUC session */
5496         retval = create_wireless_algo_auth_cipher_session(
5497                         ts_params->valid_devs[0],
5498                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5499                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5500                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5501                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
5502                         RTE_CRYPTO_AUTH_ZUC_EIA3,
5503                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5504                         tdata->key.data, tdata->key.len,
5505                         tdata->auth_iv.len, tdata->digest.len,
5506                         tdata->cipher_iv.len);
5507
5508         if (retval < 0)
5509                 return retval;
5510
5511         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5512         if (op_mode == OUT_OF_PLACE)
5513                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5514
5515         /* clear mbuf payload */
5516         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5517                 rte_pktmbuf_tailroom(ut_params->ibuf));
5518         if (op_mode == OUT_OF_PLACE)
5519                 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5520                         rte_pktmbuf_tailroom(ut_params->obuf));
5521
5522         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5523         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5524         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5525         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5526
5527         if (verify) {
5528                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5529                                         ciphertext_pad_len);
5530                 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5531                 if (op_mode == OUT_OF_PLACE)
5532                         rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5533                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5534                         ciphertext_len);
5535         } else {
5536                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5537                                         plaintext_pad_len);
5538                 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5539                 if (op_mode == OUT_OF_PLACE)
5540                         rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5541                 debug_hexdump(stdout, "plaintext:", plaintext,
5542                         plaintext_len);
5543         }
5544
5545         /* Create ZUC operation */
5546         retval = create_wireless_algo_auth_cipher_operation(
5547                 tdata->digest.len,
5548                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5549                 tdata->auth_iv.data, tdata->auth_iv.len,
5550                 (tdata->digest.offset_bytes == 0 ?
5551                 (verify ? ciphertext_pad_len : plaintext_pad_len)
5552                         : tdata->digest.offset_bytes),
5553                 tdata->validCipherLenInBits.len,
5554                 tdata->validCipherOffsetInBits.len,
5555                 tdata->validAuthLenInBits.len,
5556                 0,
5557                 op_mode, 0);
5558
5559         if (retval < 0)
5560                 return retval;
5561
5562         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5563                         ut_params->op);
5564
5565         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5566
5567         ut_params->obuf = (op_mode == IN_PLACE ?
5568                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5569
5570
5571         if (verify) {
5572                 if (ut_params->obuf)
5573                         plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5574                                                         uint8_t *);
5575                 else
5576                         plaintext = ciphertext;
5577
5578                 debug_hexdump(stdout, "plaintext:", plaintext,
5579                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5580                 debug_hexdump(stdout, "plaintext expected:",
5581                         tdata->plaintext.data,
5582                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5583         } else {
5584                 if (ut_params->obuf)
5585                         ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5586                                                         uint8_t *);
5587                 else
5588                         ciphertext = plaintext;
5589
5590                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5591                         ciphertext_len);
5592                 debug_hexdump(stdout, "ciphertext expected:",
5593                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5594
5595                 ut_params->digest = rte_pktmbuf_mtod(
5596                         ut_params->obuf, uint8_t *) +
5597                         (tdata->digest.offset_bytes == 0 ?
5598                         plaintext_pad_len : tdata->digest.offset_bytes);
5599
5600                 debug_hexdump(stdout, "digest:", ut_params->digest,
5601                         tdata->digest.len);
5602                 debug_hexdump(stdout, "digest expected:",
5603                         tdata->digest.data, tdata->digest.len);
5604         }
5605
5606         /* Validate obuf */
5607         if (verify) {
5608                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5609                         plaintext,
5610                         tdata->plaintext.data,
5611                         tdata->plaintext.len >> 3,
5612                         "ZUC Plaintext data not as expected");
5613         } else {
5614                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5615                         ciphertext,
5616                         tdata->ciphertext.data,
5617                         tdata->ciphertext.len >> 3,
5618                         "ZUC Ciphertext data not as expected");
5619
5620                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5621                         ut_params->digest,
5622                         tdata->digest.data,
5623                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5624                         "ZUC Generated auth tag not as expected");
5625         }
5626         return 0;
5627 }
5628
5629 static int
5630 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5631         uint8_t op_mode, uint8_t verify)
5632 {
5633         struct crypto_testsuite_params *ts_params = &testsuite_params;
5634         struct crypto_unittest_params *ut_params = &unittest_params;
5635
5636         int retval;
5637
5638         const uint8_t *plaintext = NULL;
5639         const uint8_t *ciphertext = NULL;
5640         const uint8_t *digest = NULL;
5641         unsigned int plaintext_pad_len;
5642         unsigned int plaintext_len;
5643         unsigned int ciphertext_pad_len;
5644         unsigned int ciphertext_len;
5645         uint8_t buffer[10000];
5646         uint8_t digest_buffer[10000];
5647
5648         struct rte_cryptodev_info dev_info;
5649         struct rte_cryptodev_sym_capability_idx cap_idx;
5650
5651         /* Check if device supports ZUC EIA3 */
5652         cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5653         cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5654
5655         if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5656                         &cap_idx) == NULL)
5657                 return -ENOTSUP;
5658
5659         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5660
5661         uint64_t feat_flags = dev_info.feature_flags;
5662
5663         if (op_mode == IN_PLACE) {
5664                 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5665                         printf("Device doesn't support in-place scatter-gather "
5666                                         "in both input and output mbufs.\n");
5667                         return -ENOTSUP;
5668                 }
5669         } else {
5670                 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5671                         printf("Device doesn't support out-of-place scatter-gather "
5672                                         "in both input and output mbufs.\n");
5673                         return -ENOTSUP;
5674                 }
5675                 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5676                         printf("Device doesn't support digest encrypted.\n");
5677                         return -ENOTSUP;
5678                 }
5679         }
5680
5681         /* Create ZUC session */
5682         retval = create_wireless_algo_auth_cipher_session(
5683                         ts_params->valid_devs[0],
5684                         (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5685                                         : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5686                         (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5687                                         : RTE_CRYPTO_AUTH_OP_GENERATE),
5688                         RTE_CRYPTO_AUTH_ZUC_EIA3,
5689                         RTE_CRYPTO_CIPHER_ZUC_EEA3,
5690                         tdata->key.data, tdata->key.len,
5691                         tdata->auth_iv.len, tdata->digest.len,
5692                         tdata->cipher_iv.len);
5693
5694         if (retval < 0)
5695                 return retval;
5696
5697         ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5698         plaintext_len = ceil_byte_length(tdata->plaintext.len);
5699         ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5700         plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5701
5702         ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5703                         plaintext_pad_len, 15, 0);
5704         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5705                         "Failed to allocate input buffer in mempool");
5706
5707         if (op_mode == OUT_OF_PLACE) {
5708                 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5709                                 plaintext_pad_len, 15, 0);
5710                 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5711                                 "Failed to allocate output buffer in mempool");
5712         }
5713
5714         if (verify) {
5715                 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5716                         tdata->ciphertext.data);
5717                 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5718                                         ciphertext_len, buffer);
5719                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5720                         ciphertext_len);
5721         } else {
5722                 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5723                         tdata->plaintext.data);
5724                 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5725                                         plaintext_len, buffer);
5726                 debug_hexdump(stdout, "plaintext:", plaintext,
5727                         plaintext_len);
5728         }
5729         memset(buffer, 0, sizeof(buffer));
5730
5731         /* Create ZUC operation */
5732         retval = create_wireless_algo_auth_cipher_operation(
5733                 tdata->digest.len,
5734                 tdata->cipher_iv.data, tdata->cipher_iv.len,
5735                 NULL, 0,
5736                 (tdata->digest.offset_bytes == 0 ?
5737                 (verify ? ciphertext_pad_len : plaintext_pad_len)
5738                         : tdata->digest.offset_bytes),
5739                 tdata->validCipherLenInBits.len,
5740                 tdata->validCipherOffsetInBits.len,
5741                 tdata->validAuthLenInBits.len,
5742                 0,
5743                 op_mode, 1);
5744
5745         if (retval < 0)
5746                 return retval;
5747
5748         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5749                         ut_params->op);
5750
5751         TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5752
5753         ut_params->obuf = (op_mode == IN_PLACE ?
5754                 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5755
5756         if (verify) {
5757                 if (ut_params->obuf)
5758                         plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5759                                         plaintext_len, buffer);
5760                 else
5761                         plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5762                                         plaintext_len, buffer);
5763
5764                 debug_hexdump(stdout, "plaintext:", plaintext,
5765                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5766                 debug_hexdump(stdout, "plaintext expected:",
5767                         tdata->plaintext.data,
5768                         (tdata->plaintext.len >> 3) - tdata->digest.len);
5769         } else {
5770                 if (ut_params->obuf)
5771                         ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5772                                         ciphertext_len, buffer);
5773                 else
5774                         ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5775                                         ciphertext_len, buffer);
5776
5777                 debug_hexdump(stdout, "ciphertext:", ciphertext,
5778                         ciphertext_len);
5779                 debug_hexdump(stdout, "ciphertext expected:",
5780                         tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5781
5782                 if (ut_params->obuf)
5783                         digest = rte_pktmbuf_read(ut_params->obuf,
5784                                 (tdata->digest.offset_bytes == 0 ?
5785                                 plaintext_pad_len : tdata->digest.offset_bytes),
5786                                 tdata->digest.len, digest_buffer);
5787                 else
5788                         digest = rte_pktmbuf_read(ut_params->ibuf,
5789                                 (tdata->digest.offset_bytes == 0 ?
5790                                 plaintext_pad_len : tdata->digest.offset_bytes),
5791                                 tdata->digest.len, digest_buffer);
5792
5793                 debug_hexdump(stdout, "digest:", digest,
5794                         tdata->digest.len);
5795                 debug_hexdump(stdout, "digest expected:",
5796                         tdata->digest.data, tdata->digest.len);
5797         }
5798
5799         /* Validate obuf */
5800         if (verify) {
5801                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5802                         plaintext,
5803                         tdata->plaintext.data,
5804                         tdata->plaintext.len >> 3,
5805                         "ZUC Plaintext data not as expected");
5806         } else {
5807                 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5808                         ciphertext,
5809                         tdata->ciphertext.data,
5810                         tdata->validDataLenInBits.len,
5811                         "ZUC Ciphertext data not as expected");
5812
5813                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5814                         digest,
5815                         tdata->digest.data,
5816                         DIGEST_BYTE_LENGTH_KASUMI_F9,
5817                         "ZUC Generated auth tag not as expected");
5818         }
5819         return 0;
5820 }
5821
5822 static int
5823 test_kasumi_encryption_test_case_1(void)
5824 {
5825         return test_kasumi_encryption(&kasumi_test_case_1);
5826 }
5827
5828 static int
5829 test_kasumi_encryption_test_case_1_sgl(void)
5830 {
5831         return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5832 }
5833
5834 static int
5835 test_kasumi_encryption_test_case_1_oop(void)
5836 {
5837         return test_kasumi_encryption_oop(&kasumi_test_case_1);
5838 }
5839
5840 static int
5841 test_kasumi_encryption_test_case_1_oop_sgl(void)
5842 {
5843         return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5844 }
5845
5846 static int
5847 test_kasumi_encryption_test_case_2(void)
5848 {
5849         return test_kasumi_encryption(&kasumi_test_case_2);
5850 }
5851
5852 static int
5853 test_kasumi_encryption_test_case_3(void)
5854 {
5855         return test_kasumi_encryption(&kasumi_test_case_3);
5856 }
5857
5858 static int
5859 test_kasumi_encryption_test_case_4(void)
5860 {
5861         return test_kasumi_encryption(&kasumi_test_case_4);
5862 }
5863
5864 static int
5865 test_kasumi_encryption_test_case_5(void)
5866 {
5867         return test_kasumi_encryption(&kasumi_test_case_5);
5868 }
5869
5870 static int
5871 test_kasumi_decryption_test_case_1(void)
5872 {
5873         return test_kasumi_decryption(&kasumi_test_case_1);
5874 }
5875
5876 static int
5877 test_kasumi_decryption_test_case_1_oop(void)
5878 {
5879         return test_kasumi_decryption_oop(&kasumi_test_case_1);
5880 }
5881
5882 static int
5883 test_kasumi_decryption_test_case_2(void)
5884 {
5885         return test_kasumi_decryption(&kasumi_test_case_2);
5886 }
5887
5888 static int
5889 test_kasumi_decryption_test_case_3(void)
5890 {
5891         return test_kasumi_decryption(&kasumi_test_case_3);
5892 }
5893
5894 static int
5895 test_kasumi_decryption_test_case_4(void)
5896 {
5897         return test_kasumi_decryption(&kasumi_test_case_4);
5898 }
5899
5900 static int
5901 test_kasumi_decryption_test_case_5(void)
5902 {
5903         return test_kasumi_decryption(&kasumi_test_case_5);
5904 }
5905 static int
5906 test_snow3g_encryption_test_case_1(void)
5907 {
5908         return test_snow3g_encryption(&snow3g_test_case_1);
5909 }
5910
5911 static int
5912 test_snow3g_encryption_test_case_1_oop(void)
5913 {
5914         return test_snow3g_encryption_oop(&snow3g_test_case_1);
5915 }
5916
5917 static int
5918 test_snow3g_encryption_test_case_1_oop_sgl(void)
5919 {
5920         return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
5921 }
5922
5923
5924 static int
5925 test_snow3g_encryption_test_case_1_offset_oop(void)
5926 {
5927         return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
5928 }
5929
5930 static int
5931 test_snow3g_encryption_test_case_2(void)
5932 {
5933         return test_snow3g_encryption(&snow3g_test_case_2);
5934 }
5935
5936 static int
5937 test_snow3g_encryption_test_case_3(void)
5938 {
5939         return test_snow3g_encryption(&snow3g_test_case_3);
5940 }
5941
5942 static int
5943 test_snow3g_encryption_test_case_4(void)
5944 {
5945         return test_snow3g_encryption(&snow3g_test_case_4);
5946 }
5947
5948 static int
5949 test_snow3g_encryption_test_case_5(void)
5950 {
5951         return test_snow3g_encryption(&snow3g_test_case_5);
5952 }
5953
5954 static int
5955 test_snow3g_decryption_test_case_1(void)
5956 {
5957         return test_snow3g_decryption(&snow3g_test_case_1);
5958 }
5959
5960 static int
5961 test_snow3g_decryption_test_case_1_oop(void)
5962 {
5963         return test_snow3g_decryption_oop(&snow3g_test_case_1);
5964 }
5965
5966 static int
5967 test_snow3g_decryption_test_case_2(void)
5968 {
5969         return test_snow3g_decryption(&snow3g_test_case_2);
5970 }
5971
5972 static int
5973 test_snow3g_decryption_test_case_3(void)
5974 {
5975         return test_snow3g_decryption(&snow3g_test_case_3);
5976 }
5977
5978 static int
5979 test_snow3g_decryption_test_case_4(void)
5980 {
5981         return test_snow3g_decryption(&snow3g_test_case_4);
5982 }
5983
5984 static int
5985 test_snow3g_decryption_test_case_5(void)
5986 {
5987         return test_snow3g_decryption(&snow3g_test_case_5);
5988 }
5989
5990 /*
5991  * Function prepares snow3g_hash_test_data from snow3g_test_data.
5992  * Pattern digest from snow3g_test_data must be allocated as
5993  * 4 last bytes in plaintext.
5994  */
5995 static void
5996 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
5997                 struct snow3g_hash_test_data *output)
5998 {
5999         if ((pattern != NULL) && (output != NULL)) {
6000                 output->key.len = pattern->key.len;
6001
6002                 memcpy(output->key.data,
6003                 pattern->key.data, pattern->key.len);
6004
6005                 output->auth_iv.len = pattern->auth_iv.len;
6006
6007                 memcpy(output->auth_iv.data,
6008                 pattern->auth_iv.data, pattern->auth_iv.len);
6009
6010                 output->plaintext.len = pattern->plaintext.len;
6011
6012                 memcpy(output->plaintext.data,
6013                 pattern->plaintext.data, pattern->plaintext.len >> 3);
6014
6015                 output->digest.len = pattern->digest.len;
6016
6017                 memcpy(output->digest.data,
6018                 &pattern->plaintext.data[pattern->digest.offset_bytes],
6019                 pattern->digest.len);
6020
6021                 output->validAuthLenInBits.len =
6022                 pattern->validAuthLenInBits.len;
6023         }
6024 }
6025
6026 /*
6027  * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6028  */
6029 static int
6030 test_snow3g_decryption_with_digest_test_case_1(void)
6031 {
6032         struct snow3g_hash_test_data snow3g_hash_data;
6033
6034         /*
6035          * Function prepare data for hash veryfication test case.
6036          * Digest is allocated in 4 last bytes in plaintext, pattern.
6037          */
6038         snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6039
6040         return test_snow3g_decryption(&snow3g_test_case_7) &
6041                         test_snow3g_authentication_verify(&snow3g_hash_data);
6042 }
6043
6044 static int
6045 test_snow3g_cipher_auth_test_case_1(void)
6046 {
6047         return test_snow3g_cipher_auth(&snow3g_test_case_3);
6048 }
6049
6050 static int
6051 test_snow3g_auth_cipher_test_case_1(void)
6052 {
6053         return test_snow3g_auth_cipher(
6054                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6055 }
6056
6057 static int
6058 test_snow3g_auth_cipher_test_case_2(void)
6059 {
6060         return test_snow3g_auth_cipher(
6061                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6062 }
6063
6064 static int
6065 test_snow3g_auth_cipher_test_case_2_oop(void)
6066 {
6067         return test_snow3g_auth_cipher(
6068                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6069 }
6070
6071 static int
6072 test_snow3g_auth_cipher_part_digest_enc(void)
6073 {
6074         return test_snow3g_auth_cipher(
6075                 &snow3g_auth_cipher_partial_digest_encryption,
6076                         IN_PLACE, 0);
6077 }
6078
6079 static int
6080 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6081 {
6082         return test_snow3g_auth_cipher(
6083                 &snow3g_auth_cipher_partial_digest_encryption,
6084                         OUT_OF_PLACE, 0);
6085 }
6086
6087 static int
6088 test_snow3g_auth_cipher_test_case_3_sgl(void)
6089 {
6090         return test_snow3g_auth_cipher_sgl(
6091                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6092 }
6093
6094 static int
6095 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6096 {
6097         return test_snow3g_auth_cipher_sgl(
6098                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6099 }
6100
6101 static int
6102 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6103 {
6104         return test_snow3g_auth_cipher_sgl(
6105                 &snow3g_auth_cipher_partial_digest_encryption,
6106                         IN_PLACE, 0);
6107 }
6108
6109 static int
6110 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6111 {
6112         return test_snow3g_auth_cipher_sgl(
6113                 &snow3g_auth_cipher_partial_digest_encryption,
6114                         OUT_OF_PLACE, 0);
6115 }
6116
6117 static int
6118 test_snow3g_auth_cipher_verify_test_case_1(void)
6119 {
6120         return test_snow3g_auth_cipher(
6121                 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6122 }
6123
6124 static int
6125 test_snow3g_auth_cipher_verify_test_case_2(void)
6126 {
6127         return test_snow3g_auth_cipher(
6128                 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6129 }
6130
6131 static int
6132 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6133 {
6134         return test_snow3g_auth_cipher(
6135                 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6136 }
6137
6138 static int
6139 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6140 {
6141         return test_snow3g_auth_cipher(
6142                 &snow3g_auth_cipher_partial_digest_encryption,
6143                         IN_PLACE, 1);
6144 }
6145
6146 static int
6147 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6148 {
6149         return test_snow3g_auth_cipher(
6150                 &snow3g_auth_cipher_partial_digest_encryption,
6151                         OUT_OF_PLACE, 1);
6152 }
6153
6154 static int
6155 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6156 {
6157         return test_snow3g_auth_cipher_sgl(
6158                 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6159 }
6160
6161 static int
6162 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6163 {
6164         return test_snow3g_auth_cipher_sgl(
6165                 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6166 }
6167
6168 static int
6169 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6170 {
6171         return test_snow3g_auth_cipher_sgl(
6172                 &snow3g_auth_cipher_partial_digest_encryption,
6173                         IN_PLACE, 1);
6174 }
6175
6176 static int
6177 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6178 {
6179         return test_snow3g_auth_cipher_sgl(
6180                 &snow3g_auth_cipher_partial_digest_encryption,
6181                         OUT_OF_PLACE, 1);
6182 }
6183
6184 static int
6185 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6186 {
6187         return test_snow3g_auth_cipher(
6188                 &snow3g_test_case_7, IN_PLACE, 0);
6189 }
6190
6191 static int
6192 test_kasumi_auth_cipher_test_case_1(void)
6193 {
6194         return test_kasumi_auth_cipher(
6195                 &kasumi_test_case_3, IN_PLACE, 0);
6196 }
6197
6198 static int
6199 test_kasumi_auth_cipher_test_case_2(void)
6200 {
6201         return test_kasumi_auth_cipher(
6202                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6203 }
6204
6205 static int
6206 test_kasumi_auth_cipher_test_case_2_oop(void)
6207 {
6208         return test_kasumi_auth_cipher(
6209                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6210 }
6211
6212 static int
6213 test_kasumi_auth_cipher_test_case_2_sgl(void)
6214 {
6215         return test_kasumi_auth_cipher_sgl(
6216                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6217 }
6218
6219 static int
6220 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6221 {
6222         return test_kasumi_auth_cipher_sgl(
6223                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6224 }
6225
6226 static int
6227 test_kasumi_auth_cipher_verify_test_case_1(void)
6228 {
6229         return test_kasumi_auth_cipher(
6230                 &kasumi_test_case_3, IN_PLACE, 1);
6231 }
6232
6233 static int
6234 test_kasumi_auth_cipher_verify_test_case_2(void)
6235 {
6236         return test_kasumi_auth_cipher(
6237                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6238 }
6239
6240 static int
6241 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6242 {
6243         return test_kasumi_auth_cipher(
6244                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6245 }
6246
6247 static int
6248 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6249 {
6250         return test_kasumi_auth_cipher_sgl(
6251                 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6252 }
6253
6254 static int
6255 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6256 {
6257         return test_kasumi_auth_cipher_sgl(
6258                 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6259 }
6260
6261 static int
6262 test_kasumi_cipher_auth_test_case_1(void)
6263 {
6264         return test_kasumi_cipher_auth(&kasumi_test_case_6);
6265 }
6266
6267 static int
6268 test_zuc_encryption_test_case_1(void)
6269 {
6270         return test_zuc_encryption(&zuc_test_case_cipher_193b);
6271 }
6272
6273 static int
6274 test_zuc_encryption_test_case_2(void)
6275 {
6276         return test_zuc_encryption(&zuc_test_case_cipher_800b);
6277 }
6278
6279 static int
6280 test_zuc_encryption_test_case_3(void)
6281 {
6282         return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6283 }
6284
6285 static int
6286 test_zuc_encryption_test_case_4(void)
6287 {
6288         return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6289 }
6290
6291 static int
6292 test_zuc_encryption_test_case_5(void)
6293 {
6294         return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6295 }
6296
6297 static int
6298 test_zuc_encryption_test_case_6_sgl(void)
6299 {
6300         return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6301 }
6302
6303 static int
6304 test_zuc_hash_generate_test_case_1(void)
6305 {
6306         return test_zuc_authentication(&zuc_test_case_auth_1b);
6307 }
6308
6309 static int
6310 test_zuc_hash_generate_test_case_2(void)
6311 {
6312         return test_zuc_authentication(&zuc_test_case_auth_90b);
6313 }
6314
6315 static int
6316 test_zuc_hash_generate_test_case_3(void)
6317 {
6318         return test_zuc_authentication(&zuc_test_case_auth_577b);
6319 }
6320
6321 static int
6322 test_zuc_hash_generate_test_case_4(void)
6323 {
6324         return test_zuc_authentication(&zuc_test_case_auth_2079b);
6325 }
6326
6327 static int
6328 test_zuc_hash_generate_test_case_5(void)
6329 {
6330         return test_zuc_authentication(&zuc_test_auth_5670b);
6331 }
6332
6333 static int
6334 test_zuc_hash_generate_test_case_6(void)
6335 {
6336         return test_zuc_authentication(&zuc_test_case_auth_128b);
6337 }
6338
6339 static int
6340 test_zuc_hash_generate_test_case_7(void)
6341 {
6342         return test_zuc_authentication(&zuc_test_case_auth_2080b);
6343 }
6344
6345 static int
6346 test_zuc_hash_generate_test_case_8(void)
6347 {
6348         return test_zuc_authentication(&zuc_test_case_auth_584b);
6349 }
6350
6351 static int
6352 test_zuc_cipher_auth_test_case_1(void)
6353 {
6354         return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6355 }
6356
6357 static int
6358 test_zuc_cipher_auth_test_case_2(void)
6359 {
6360         return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6361 }
6362
6363 static int
6364 test_zuc_auth_cipher_test_case_1(void)
6365 {
6366         return test_zuc_auth_cipher(
6367                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6368 }
6369
6370 static int
6371 test_zuc_auth_cipher_test_case_1_oop(void)
6372 {
6373         return test_zuc_auth_cipher(
6374                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6375 }
6376
6377 static int
6378 test_zuc_auth_cipher_test_case_1_sgl(void)
6379 {
6380         return test_zuc_auth_cipher_sgl(
6381                 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6382 }
6383
6384 static int
6385 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6386 {
6387         return test_zuc_auth_cipher_sgl(
6388                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6389 }
6390
6391 static int
6392 test_zuc_auth_cipher_verify_test_case_1(void)
6393 {
6394         return test_zuc_auth_cipher(
6395                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6396 }
6397
6398 static int
6399 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6400 {
6401         return test_zuc_auth_cipher(
6402                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6403 }
6404
6405 static int
6406 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6407 {
6408         return test_zuc_auth_cipher_sgl(
6409                 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6410 }
6411
6412 static int
6413 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6414 {
6415         return test_zuc_auth_cipher_sgl(
6416                 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6417 }
6418
6419 static int
6420 test_3DES_chain_qat_all(void)
6421 {
6422         struct crypto_testsuite_params *ts_params = &testsuite_params;
6423         int status;
6424
6425         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6426                 ts_params->op_mpool,
6427                 ts_params->session_mpool, ts_params->session_priv_mpool,
6428                 ts_params->valid_devs[0],
6429                 rte_cryptodev_driver_id_get(
6430                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6431                 BLKCIPHER_3DES_CHAIN_TYPE);
6432
6433         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6434
6435         return TEST_SUCCESS;
6436 }
6437
6438 static int
6439 test_DES_cipheronly_qat_all(void)
6440 {
6441         struct crypto_testsuite_params *ts_params = &testsuite_params;
6442         int status;
6443
6444         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6445                 ts_params->op_mpool,
6446                 ts_params->session_mpool, ts_params->session_priv_mpool,
6447                 ts_params->valid_devs[0],
6448                 rte_cryptodev_driver_id_get(
6449                 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
6450                 BLKCIPHER_DES_CIPHERONLY_TYPE);
6451
6452         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6453
6454         return TEST_SUCCESS;
6455 }
6456
6457 static int
6458 test_DES_cipheronly_openssl_all(void)
6459 {
6460         struct crypto_testsuite_params *ts_params = &testsuite_params;
6461         int status;
6462
6463         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6464                 ts_params->op_mpool,
6465                 ts_params->session_mpool, ts_params->session_priv_mpool,
6466                 ts_params->valid_devs[0],
6467                 rte_cryptodev_driver_id_get(
6468                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6469                 BLKCIPHER_DES_CIPHERONLY_TYPE);
6470
6471         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6472
6473         return TEST_SUCCESS;
6474 }
6475
6476 static int
6477 test_DES_docsis_openssl_all(void)
6478 {
6479         struct crypto_testsuite_params *ts_params = &testsuite_params;
6480         int status;
6481
6482         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6483                 ts_params->op_mpool,
6484                 ts_params->session_mpool, ts_params->session_priv_mpool,
6485                 ts_params->valid_devs[0],
6486                 rte_cryptodev_driver_id_get(
6487                 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
6488                 BLKCIPHER_DES_DOCSIS_TYPE);
6489
6490         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6491
6492         return TEST_SUCCESS;
6493 }
6494
6495 static int
6496 test_DES_cipheronly_mb_all(void)
6497 {
6498         struct crypto_testsuite_params *ts_params = &testsuite_params;
6499         int status;
6500
6501         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6502                 ts_params->op_mpool,
6503                 ts_params->session_mpool, ts_params->session_priv_mpool,
6504                 ts_params->valid_devs[0],
6505                 rte_cryptodev_driver_id_get(
6506                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6507                 BLKCIPHER_DES_CIPHERONLY_TYPE);
6508
6509         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6510
6511         return TEST_SUCCESS;
6512 }
6513 static int
6514 test_3DES_cipheronly_mb_all(void)
6515 {
6516         struct crypto_testsuite_params *ts_params = &testsuite_params;
6517         int status;
6518
6519         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6520                 ts_params->op_mpool,
6521                 ts_params->session_mpool, ts_params->session_priv_mpool,
6522                 ts_params->valid_devs[0],
6523                 rte_cryptodev_driver_id_get(
6524                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6525                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6526
6527         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6528
6529         return TEST_SUCCESS;
6530 }
6531
6532 static int
6533 test_DES_docsis_mb_all(void)
6534 {
6535         struct crypto_testsuite_params *ts_params = &testsuite_params;
6536         int status;
6537
6538         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6539                 ts_params->op_mpool,
6540                 ts_params->session_mpool, ts_params->session_priv_mpool,
6541                 ts_params->valid_devs[0],
6542                 rte_cryptodev_driver_id_get(
6543                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
6544                 BLKCIPHER_DES_DOCSIS_TYPE);
6545
6546         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6547
6548         return TEST_SUCCESS;
6549 }
6550
6551 static int
6552 test_3DES_chain_caam_jr_all(void)
6553 {
6554         struct crypto_testsuite_params *ts_params = &testsuite_params;
6555         int status;
6556
6557         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6558                 ts_params->op_mpool,
6559                 ts_params->session_mpool, ts_params->session_priv_mpool,
6560                 ts_params->valid_devs[0],
6561                 rte_cryptodev_driver_id_get(
6562                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6563                 BLKCIPHER_3DES_CHAIN_TYPE);
6564
6565         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6566
6567         return TEST_SUCCESS;
6568 }
6569
6570 static int
6571 test_3DES_cipheronly_caam_jr_all(void)
6572 {
6573         struct crypto_testsuite_params *ts_params = &testsuite_params;
6574         int status;
6575
6576         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6577                 ts_params->op_mpool,
6578                 ts_params->session_mpool, ts_params->session_priv_mpool,
6579                 ts_params->valid_devs[0],
6580                 rte_cryptodev_driver_id_get(
6581                 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
6582                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6583
6584         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6585
6586         return TEST_SUCCESS;
6587 }
6588
6589 static int
6590 test_3DES_chain_dpaa_sec_all(void)
6591 {
6592         struct crypto_testsuite_params *ts_params = &testsuite_params;
6593         int status;
6594
6595         status = test_blockcipher_all_tests(ts_params->mbuf_pool,
6596                 ts_params->op_mpool,
6597                 ts_params->session_mpool, ts_params->session_priv_mpool,
6598                 ts_params->valid_devs[0],
6599                 rte_cryptodev_driver_id_get(
6600                 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
6601                 BLKCIPHER_3DES_CHAIN_TYPE);
6602
6603         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6604
6605         return TEST_SUCCESS;
6606 }
6607
6608 static int
6609 test_3DES_cipheronly_dpaa_sec_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_DPAA_SEC_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_3DES_chain_dpaa2_sec_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_DPAA2_SEC_PMD)),
6639                 BLKCIPHER_3DES_CHAIN_TYPE);
6640
6641         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6642
6643         return TEST_SUCCESS;
6644 }
6645
6646 static int
6647 test_3DES_cipheronly_dpaa2_sec_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_DPAA2_SEC_PMD)),
6658                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6659
6660         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6661
6662         return TEST_SUCCESS;
6663 }
6664
6665 static int
6666 test_3DES_chain_ccp_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_CCP_PMD)),
6677                 BLKCIPHER_3DES_CHAIN_TYPE);
6678
6679         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6680
6681         return TEST_SUCCESS;
6682 }
6683
6684 static int
6685 test_3DES_cipheronly_ccp_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_CCP_PMD)),
6696                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6697
6698         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6699
6700         return TEST_SUCCESS;
6701 }
6702
6703 static int
6704 test_3DES_cipheronly_qat_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_QAT_SYM_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_openssl_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_OPENSSL_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_openssl_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_OPENSSL_PMD)),
6753                 BLKCIPHER_3DES_CIPHERONLY_TYPE);
6754
6755         TEST_ASSERT_EQUAL(status, 0, "Test failed");
6756
6757         return TEST_SUCCESS;
6758 }
6759
6760 /* ***** AEAD algorithm Tests ***** */
6761
6762 static int
6763 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
6764                 enum rte_crypto_aead_operation op,
6765                 const uint8_t *key, const uint8_t key_len,
6766                 const uint16_t aad_len, const uint8_t auth_len,
6767                 uint8_t iv_len)
6768 {
6769         uint8_t aead_key[key_len];
6770
6771         struct crypto_testsuite_params *ts_params = &testsuite_params;
6772         struct crypto_unittest_params *ut_params = &unittest_params;
6773
6774         memcpy(aead_key, key, key_len);
6775
6776         /* Setup AEAD Parameters */
6777         ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
6778         ut_params->aead_xform.next = NULL;
6779         ut_params->aead_xform.aead.algo = algo;
6780         ut_params->aead_xform.aead.op = op;
6781         ut_params->aead_xform.aead.key.data = aead_key;
6782         ut_params->aead_xform.aead.key.length = key_len;
6783         ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
6784         ut_params->aead_xform.aead.iv.length = iv_len;
6785         ut_params->aead_xform.aead.digest_length = auth_len;
6786         ut_params->aead_xform.aead.aad_length = aad_len;
6787
6788         debug_hexdump(stdout, "key:", key, key_len);
6789
6790         /* Create Crypto session*/
6791         ut_params->sess = rte_cryptodev_sym_session_create(
6792                         ts_params->session_mpool);
6793
6794         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6795                         &ut_params->aead_xform,
6796                         ts_params->session_priv_mpool);
6797
6798         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6799
6800         return 0;
6801 }
6802
6803 static int
6804 create_aead_xform(struct rte_crypto_op *op,
6805                 enum rte_crypto_aead_algorithm algo,
6806                 enum rte_crypto_aead_operation aead_op,
6807                 uint8_t *key, const uint8_t key_len,
6808                 const uint8_t aad_len, const uint8_t auth_len,
6809                 uint8_t iv_len)
6810 {
6811         TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
6812                         "failed to allocate space for crypto transform");
6813
6814         struct rte_crypto_sym_op *sym_op = op->sym;
6815
6816         /* Setup AEAD Parameters */
6817         sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
6818         sym_op->xform->next = NULL;
6819         sym_op->xform->aead.algo = algo;
6820         sym_op->xform->aead.op = aead_op;
6821         sym_op->xform->aead.key.data = key;
6822         sym_op->xform->aead.key.length = key_len;
6823         sym_op->xform->aead.iv.offset = IV_OFFSET;
6824         sym_op->xform->aead.iv.length = iv_len;
6825         sym_op->xform->aead.digest_length = auth_len;
6826         sym_op->xform->aead.aad_length = aad_len;
6827
6828         debug_hexdump(stdout, "key:", key, key_len);
6829
6830         return 0;
6831 }
6832
6833 static int
6834 create_aead_operation(enum rte_crypto_aead_operation op,
6835                 const struct aead_test_data *tdata)
6836 {
6837         struct crypto_testsuite_params *ts_params = &testsuite_params;
6838         struct crypto_unittest_params *ut_params = &unittest_params;
6839
6840         uint8_t *plaintext, *ciphertext;
6841         unsigned int aad_pad_len, plaintext_pad_len;
6842
6843         /* Generate Crypto op data structure */
6844         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6845                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6846         TEST_ASSERT_NOT_NULL(ut_params->op,
6847                         "Failed to allocate symmetric crypto operation struct");
6848
6849         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6850
6851         /* Append aad data */
6852         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
6853                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
6854                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6855                                 aad_pad_len);
6856                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6857                                 "no room to append aad");
6858
6859                 sym_op->aead.aad.phys_addr =
6860                                 rte_pktmbuf_iova(ut_params->ibuf);
6861                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
6862                 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
6863                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6864                         tdata->aad.len);
6865
6866                 /* Append IV at the end of the crypto operation*/
6867                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6868                                 uint8_t *, IV_OFFSET);
6869
6870                 /* Copy IV 1 byte after the IV pointer, according to the API */
6871                 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
6872                 debug_hexdump(stdout, "iv:", iv_ptr,
6873                         tdata->iv.len);
6874         } else {
6875                 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
6876                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6877                                 aad_pad_len);
6878                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
6879                                 "no room to append aad");
6880
6881                 sym_op->aead.aad.phys_addr =
6882                                 rte_pktmbuf_iova(ut_params->ibuf);
6883                 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
6884                 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
6885                         tdata->aad.len);
6886
6887                 /* Append IV at the end of the crypto operation*/
6888                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6889                                 uint8_t *, IV_OFFSET);
6890
6891                 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6892                 debug_hexdump(stdout, "iv:", iv_ptr,
6893                         tdata->iv.len);
6894         }
6895
6896         /* Append plaintext/ciphertext */
6897         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6898                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6899                 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6900                                 plaintext_pad_len);
6901                 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
6902
6903                 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
6904                 debug_hexdump(stdout, "plaintext:", plaintext,
6905                                 tdata->plaintext.len);
6906
6907                 if (ut_params->obuf) {
6908                         ciphertext = (uint8_t *)rte_pktmbuf_append(
6909                                         ut_params->obuf,
6910                                         plaintext_pad_len + aad_pad_len);
6911                         TEST_ASSERT_NOT_NULL(ciphertext,
6912                                         "no room to append ciphertext");
6913
6914                         memset(ciphertext + aad_pad_len, 0,
6915                                         tdata->ciphertext.len);
6916                 }
6917         } else {
6918                 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
6919                 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6920                                 plaintext_pad_len);
6921                 TEST_ASSERT_NOT_NULL(ciphertext,
6922                                 "no room to append ciphertext");
6923
6924                 memcpy(ciphertext, tdata->ciphertext.data,
6925                                 tdata->ciphertext.len);
6926                 debug_hexdump(stdout, "ciphertext:", ciphertext,
6927                                 tdata->ciphertext.len);
6928
6929                 if (ut_params->obuf) {
6930                         plaintext = (uint8_t *)rte_pktmbuf_append(
6931                                         ut_params->obuf,
6932                                         plaintext_pad_len + aad_pad_len);
6933                         TEST_ASSERT_NOT_NULL(plaintext,
6934                                         "no room to append plaintext");
6935
6936                         memset(plaintext + aad_pad_len, 0,
6937                                         tdata->plaintext.len);
6938                 }
6939         }
6940
6941         /* Append digest data */
6942         if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
6943                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6944                                 ut_params->obuf ? ut_params->obuf :
6945                                                 ut_params->ibuf,
6946                                                 tdata->auth_tag.len);
6947                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6948                                 "no room to append digest");
6949                 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
6950                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6951                                 ut_params->obuf ? ut_params->obuf :
6952                                                 ut_params->ibuf,
6953                                                 plaintext_pad_len +
6954                                                 aad_pad_len);
6955         } else {
6956                 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
6957                                 ut_params->ibuf, tdata->auth_tag.len);
6958                 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
6959                                 "no room to append digest");
6960                 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
6961                                 ut_params->ibuf,
6962                                 plaintext_pad_len + aad_pad_len);
6963
6964                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
6965                         tdata->auth_tag.len);
6966                 debug_hexdump(stdout, "digest:",
6967                         sym_op->aead.digest.data,
6968                         tdata->auth_tag.len);
6969         }
6970
6971         sym_op->aead.data.length = tdata->plaintext.len;
6972         sym_op->aead.data.offset = aad_pad_len;
6973
6974         return 0;
6975 }
6976
6977 static int
6978 test_authenticated_encryption(const struct aead_test_data *tdata)
6979 {
6980         struct crypto_testsuite_params *ts_params = &testsuite_params;
6981         struct crypto_unittest_params *ut_params = &unittest_params;
6982
6983         int retval;
6984         uint8_t *ciphertext, *auth_tag;
6985         uint16_t plaintext_pad_len;
6986         uint32_t i;
6987
6988         /* Create AEAD session */
6989         retval = create_aead_session(ts_params->valid_devs[0],
6990                         tdata->algo,
6991                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
6992                         tdata->key.data, tdata->key.len,
6993                         tdata->aad.len, tdata->auth_tag.len,
6994                         tdata->iv.len);
6995         if (retval < 0)
6996                 return retval;
6997
6998         if (tdata->aad.len > MBUF_SIZE) {
6999                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7000                 /* Populate full size of add data */
7001                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7002                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7003         } else
7004                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7005
7006         /* clear mbuf payload */
7007         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7008                         rte_pktmbuf_tailroom(ut_params->ibuf));
7009
7010         /* Create AEAD operation */
7011         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7012         if (retval < 0)
7013                 return retval;
7014
7015         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7016
7017         ut_params->op->sym->m_src = ut_params->ibuf;
7018
7019         /* Process crypto operation */
7020         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7021                         ut_params->op), "failed to process sym crypto op");
7022
7023         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7024                         "crypto op processing failed");
7025
7026         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7027
7028         if (ut_params->op->sym->m_dst) {
7029                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7030                                 uint8_t *);
7031                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7032                                 uint8_t *, plaintext_pad_len);
7033         } else {
7034                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7035                                 uint8_t *,
7036                                 ut_params->op->sym->cipher.data.offset);
7037                 auth_tag = ciphertext + plaintext_pad_len;
7038         }
7039
7040         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7041         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7042
7043         /* Validate obuf */
7044         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7045                         ciphertext,
7046                         tdata->ciphertext.data,
7047                         tdata->ciphertext.len,
7048                         "Ciphertext data not as expected");
7049
7050         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7051                         auth_tag,
7052                         tdata->auth_tag.data,
7053                         tdata->auth_tag.len,
7054                         "Generated auth tag not as expected");
7055
7056         return 0;
7057
7058 }
7059
7060 #ifdef RTE_LIBRTE_SECURITY
7061 /* Basic algorithm run function for async inplace mode.
7062  * Creates a session from input parameters and runs one operation
7063  * on input_vec. Checks the output of the crypto operation against
7064  * output_vec.
7065  */
7066 static int
7067 test_pdcp_proto(int i, int oop,
7068         enum rte_crypto_cipher_operation opc,
7069         enum rte_crypto_auth_operation opa,
7070         uint8_t *input_vec,
7071         unsigned int input_vec_len,
7072         uint8_t *output_vec,
7073         unsigned int output_vec_len)
7074 {
7075         struct crypto_testsuite_params *ts_params = &testsuite_params;
7076         struct crypto_unittest_params *ut_params = &unittest_params;
7077         uint8_t *plaintext;
7078         int ret = TEST_SUCCESS;
7079
7080         /* Generate test mbuf data */
7081         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7082
7083         /* clear mbuf payload */
7084         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7085                         rte_pktmbuf_tailroom(ut_params->ibuf));
7086
7087         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7088                                                   input_vec_len);
7089         memcpy(plaintext, input_vec, input_vec_len);
7090
7091         /* Out of place support */
7092         if (oop) {
7093                 /*
7094                  * For out-op-place we need to alloc another mbuf
7095                  */
7096                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7097                 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7098         }
7099
7100         /* Set crypto type as IPSEC */
7101         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7102
7103         /* Setup Cipher Parameters */
7104         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7105         ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7106         ut_params->cipher_xform.cipher.op = opc;
7107         ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7108         ut_params->cipher_xform.cipher.key.length =
7109                                         pdcp_test_params[i].cipher_key_len;
7110         ut_params->cipher_xform.cipher.iv.length = 0;
7111
7112         /* Setup HMAC Parameters if ICV header is required */
7113         if (pdcp_test_params[i].auth_alg != 0) {
7114                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7115                 ut_params->auth_xform.next = NULL;
7116                 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7117                 ut_params->auth_xform.auth.op = opa;
7118                 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7119                 ut_params->auth_xform.auth.key.length =
7120                                         pdcp_test_params[i].auth_key_len;
7121
7122                 ut_params->cipher_xform.next = &ut_params->auth_xform;
7123         } else {
7124                 ut_params->cipher_xform.next = NULL;
7125         }
7126
7127         struct rte_security_session_conf sess_conf = {
7128                 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7129                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7130                 {.pdcp = {
7131                         .bearer = pdcp_test_bearer[i],
7132                         .domain = pdcp_test_params[i].domain,
7133                         .pkt_dir = pdcp_test_packet_direction[i],
7134                         .sn_size = pdcp_test_data_sn_size[i],
7135                         .hfn = pdcp_test_hfn[i],
7136                         .hfn_threshold = pdcp_test_hfn_threshold[i],
7137                 } },
7138                 .crypto_xform = &ut_params->cipher_xform
7139         };
7140
7141         struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7142                                 rte_cryptodev_get_sec_ctx(
7143                                 ts_params->valid_devs[0]);
7144
7145         /* Create security session */
7146         ut_params->sec_session = rte_security_session_create(ctx,
7147                                 &sess_conf, ts_params->session_mpool);
7148
7149         if (!ut_params->sec_session) {
7150                 printf("TestCase %s()-%d line %d failed %s: ",
7151                         __func__, i, __LINE__, "Failed to allocate session");
7152                 ret = TEST_FAILED;
7153                 goto on_err;
7154         }
7155
7156         /* Generate crypto op data structure */
7157         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7158                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7159         if (!ut_params->op) {
7160                 printf("TestCase %s()-%d line %d failed %s: ",
7161                         __func__, i, __LINE__,
7162                         "Failed to allocate symmetric crypto operation struct");
7163                 ret = TEST_FAILED;
7164                 goto on_err;
7165         }
7166
7167         rte_security_attach_session(ut_params->op, ut_params->sec_session);
7168
7169         /* set crypto operation source mbuf */
7170         ut_params->op->sym->m_src = ut_params->ibuf;
7171         if (oop)
7172                 ut_params->op->sym->m_dst = ut_params->obuf;
7173
7174         /* Process crypto operation */
7175         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7176                 == NULL) {
7177                 printf("TestCase %s()-%d line %d failed %s: ",
7178                         __func__, i, __LINE__,
7179                         "failed to process sym crypto op");
7180                 ret = TEST_FAILED;
7181                 goto on_err;
7182         }
7183
7184         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7185                 printf("TestCase %s()-%d line %d failed %s: ",
7186                         __func__, i, __LINE__, "crypto op processing failed");
7187                 ret = TEST_FAILED;
7188                 goto on_err;
7189         }
7190
7191         /* Validate obuf */
7192         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7193                         uint8_t *);
7194         if (oop) {
7195                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7196                                 uint8_t *);
7197         }
7198
7199         if (memcmp(ciphertext, output_vec, output_vec_len)) {
7200                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7201                 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7202                 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7203                 ret = TEST_FAILED;
7204                 goto on_err;
7205         }
7206
7207 on_err:
7208         rte_crypto_op_free(ut_params->op);
7209         ut_params->op = NULL;
7210
7211         if (ut_params->sec_session)
7212                 rte_security_session_destroy(ctx, ut_params->sec_session);
7213         ut_params->sec_session = NULL;
7214
7215         rte_pktmbuf_free(ut_params->ibuf);
7216         ut_params->ibuf = NULL;
7217         if (oop) {
7218                 rte_pktmbuf_free(ut_params->obuf);
7219                 ut_params->obuf = NULL;
7220         }
7221
7222         return ret;
7223 }
7224
7225 static int
7226 test_pdcp_proto_SGL(int i, int oop,
7227         enum rte_crypto_cipher_operation opc,
7228         enum rte_crypto_auth_operation opa,
7229         uint8_t *input_vec,
7230         unsigned int input_vec_len,
7231         uint8_t *output_vec,
7232         unsigned int output_vec_len,
7233         uint32_t fragsz,
7234         uint32_t fragsz_oop)
7235 {
7236         struct crypto_testsuite_params *ts_params = &testsuite_params;
7237         struct crypto_unittest_params *ut_params = &unittest_params;
7238         uint8_t *plaintext;
7239         struct rte_mbuf *buf, *buf_oop = NULL;
7240         int ret = TEST_SUCCESS;
7241         int to_trn = 0;
7242         int to_trn_tbl[16];
7243         int segs = 1;
7244         unsigned int trn_data = 0;
7245
7246         if (fragsz > input_vec_len)
7247                 fragsz = input_vec_len;
7248
7249         uint16_t plaintext_len = fragsz;
7250         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7251
7252         if (fragsz_oop > output_vec_len)
7253                 frag_size_oop = output_vec_len;
7254
7255         int ecx = 0;
7256         if (input_vec_len % fragsz != 0) {
7257                 if (input_vec_len / fragsz + 1 > 16)
7258                         return 1;
7259         } else if (input_vec_len / fragsz > 16)
7260                 return 1;
7261
7262         /* Out of place support */
7263         if (oop) {
7264                 /*
7265                  * For out-op-place we need to alloc another mbuf
7266                  */
7267                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7268                 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7269                 buf_oop = ut_params->obuf;
7270         }
7271
7272         /* Generate test mbuf data */
7273         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7274
7275         /* clear mbuf payload */
7276         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7277                         rte_pktmbuf_tailroom(ut_params->ibuf));
7278
7279         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7280                                                   plaintext_len);
7281         memcpy(plaintext, input_vec, plaintext_len);
7282         trn_data += plaintext_len;
7283
7284         buf = ut_params->ibuf;
7285
7286         /*
7287          * Loop until no more fragments
7288          */
7289
7290         while (trn_data < input_vec_len) {
7291                 ++segs;
7292                 to_trn = (input_vec_len - trn_data < fragsz) ?
7293                                 (input_vec_len - trn_data) : fragsz;
7294
7295                 to_trn_tbl[ecx++] = to_trn;
7296
7297                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7298                 buf = buf->next;
7299
7300                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7301                                 rte_pktmbuf_tailroom(buf));
7302
7303                 /* OOP */
7304                 if (oop && !fragsz_oop) {
7305                         buf_oop->next =
7306                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
7307                         buf_oop = buf_oop->next;
7308                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7309                                         0, rte_pktmbuf_tailroom(buf_oop));
7310                         rte_pktmbuf_append(buf_oop, to_trn);
7311                 }
7312
7313                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7314                                 to_trn);
7315
7316                 memcpy(plaintext, input_vec + trn_data, to_trn);
7317                 trn_data += to_trn;
7318         }
7319
7320         ut_params->ibuf->nb_segs = segs;
7321
7322         segs = 1;
7323         if (fragsz_oop && oop) {
7324                 to_trn = 0;
7325                 ecx = 0;
7326
7327                 trn_data = frag_size_oop;
7328                 while (trn_data < output_vec_len) {
7329                         ++segs;
7330                         to_trn =
7331                                 (output_vec_len - trn_data <
7332                                                 frag_size_oop) ?
7333                                 (output_vec_len - trn_data) :
7334                                                 frag_size_oop;
7335
7336                         to_trn_tbl[ecx++] = to_trn;
7337
7338                         buf_oop->next =
7339                                 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7340                         buf_oop = buf_oop->next;
7341                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7342                                         0, rte_pktmbuf_tailroom(buf_oop));
7343                         rte_pktmbuf_append(buf_oop, to_trn);
7344
7345                         trn_data += to_trn;
7346                 }
7347                 ut_params->obuf->nb_segs = segs;
7348         }
7349
7350         ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7351
7352         /* Setup Cipher Parameters */
7353         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7354         ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7355         ut_params->cipher_xform.cipher.op = opc;
7356         ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7357         ut_params->cipher_xform.cipher.key.length =
7358                                         pdcp_test_params[i].cipher_key_len;
7359         ut_params->cipher_xform.cipher.iv.length = 0;
7360
7361         /* Setup HMAC Parameters if ICV header is required */
7362         if (pdcp_test_params[i].auth_alg != 0) {
7363                 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7364                 ut_params->auth_xform.next = NULL;
7365                 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7366                 ut_params->auth_xform.auth.op = opa;
7367                 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7368                 ut_params->auth_xform.auth.key.length =
7369                                         pdcp_test_params[i].auth_key_len;
7370
7371                 ut_params->cipher_xform.next = &ut_params->auth_xform;
7372         } else {
7373                 ut_params->cipher_xform.next = NULL;
7374         }
7375
7376         struct rte_security_session_conf sess_conf = {
7377                 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7378                 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7379                 {.pdcp = {
7380                         .bearer = pdcp_test_bearer[i],
7381                         .domain = pdcp_test_params[i].domain,
7382                         .pkt_dir = pdcp_test_packet_direction[i],
7383                         .sn_size = pdcp_test_data_sn_size[i],
7384                         .hfn = pdcp_test_hfn[i],
7385                         .hfn_threshold = pdcp_test_hfn_threshold[i],
7386                 } },
7387                 .crypto_xform = &ut_params->cipher_xform
7388         };
7389
7390         struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7391                                 rte_cryptodev_get_sec_ctx(
7392                                 ts_params->valid_devs[0]);
7393
7394         /* Create security session */
7395         ut_params->sec_session = rte_security_session_create(ctx,
7396                                 &sess_conf, ts_params->session_mpool);
7397
7398         if (!ut_params->sec_session) {
7399                 printf("TestCase %s()-%d line %d failed %s: ",
7400                         __func__, i, __LINE__, "Failed to allocate session");
7401                 ret = TEST_FAILED;
7402                 goto on_err;
7403         }
7404
7405         /* Generate crypto op data structure */
7406         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7407                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7408         if (!ut_params->op) {
7409                 printf("TestCase %s()-%d line %d failed %s: ",
7410                         __func__, i, __LINE__,
7411                         "Failed to allocate symmetric crypto operation struct");
7412                 ret = TEST_FAILED;
7413                 goto on_err;
7414         }
7415
7416         rte_security_attach_session(ut_params->op, ut_params->sec_session);
7417
7418         /* set crypto operation source mbuf */
7419         ut_params->op->sym->m_src = ut_params->ibuf;
7420         if (oop)
7421                 ut_params->op->sym->m_dst = ut_params->obuf;
7422
7423         /* Process crypto operation */
7424         if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7425                 == NULL) {
7426                 printf("TestCase %s()-%d line %d failed %s: ",
7427                         __func__, i, __LINE__,
7428                         "failed to process sym crypto op");
7429                 ret = TEST_FAILED;
7430                 goto on_err;
7431         }
7432
7433         if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7434                 printf("TestCase %s()-%d line %d failed %s: ",
7435                         __func__, i, __LINE__, "crypto op processing failed");
7436                 ret = TEST_FAILED;
7437                 goto on_err;
7438         }
7439
7440         /* Validate obuf */
7441         uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7442                         uint8_t *);
7443         if (oop) {
7444                 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7445                                 uint8_t *);
7446         }
7447         if (fragsz_oop)
7448                 fragsz = frag_size_oop;
7449         if (memcmp(ciphertext, output_vec, fragsz)) {
7450                 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7451                 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
7452                 rte_hexdump(stdout, "reference", output_vec, fragsz);
7453                 ret = TEST_FAILED;
7454                 goto on_err;
7455         }
7456
7457         buf = ut_params->op->sym->m_src->next;
7458         if (oop)
7459                 buf = ut_params->op->sym->m_dst->next;
7460
7461         unsigned int off = fragsz;
7462
7463         ecx = 0;
7464         while (buf) {
7465                 ciphertext = rte_pktmbuf_mtod(buf,
7466                                 uint8_t *);
7467                 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
7468                         printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7469                         rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
7470                         rte_hexdump(stdout, "reference", output_vec + off,
7471                                         to_trn_tbl[ecx]);
7472                         ret = TEST_FAILED;
7473                         goto on_err;
7474                 }
7475                 off += to_trn_tbl[ecx++];
7476                 buf = buf->next;
7477         }
7478 on_err:
7479         rte_crypto_op_free(ut_params->op);
7480         ut_params->op = NULL;
7481
7482         if (ut_params->sec_session)
7483                 rte_security_session_destroy(ctx, ut_params->sec_session);
7484         ut_params->sec_session = NULL;
7485
7486         rte_pktmbuf_free(ut_params->ibuf);
7487         ut_params->ibuf = NULL;
7488         if (oop) {
7489                 rte_pktmbuf_free(ut_params->obuf);
7490                 ut_params->obuf = NULL;
7491         }
7492
7493         return ret;
7494 }
7495
7496 int
7497 test_pdcp_proto_cplane_encap(int i)
7498 {
7499         return test_pdcp_proto(i, 0,
7500                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7501                 RTE_CRYPTO_AUTH_OP_GENERATE,
7502                 pdcp_test_data_in[i],
7503                 pdcp_test_data_in_len[i],
7504                 pdcp_test_data_out[i],
7505                 pdcp_test_data_in_len[i]+4);
7506 }
7507
7508 int
7509 test_pdcp_proto_uplane_encap(int i)
7510 {
7511         return test_pdcp_proto(i, 0,
7512                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7513                 RTE_CRYPTO_AUTH_OP_GENERATE,
7514                 pdcp_test_data_in[i],
7515                 pdcp_test_data_in_len[i],
7516                 pdcp_test_data_out[i],
7517                 pdcp_test_data_in_len[i]);
7518
7519 }
7520
7521 int
7522 test_pdcp_proto_uplane_encap_with_int(int i)
7523 {
7524         return test_pdcp_proto(i, 0,
7525                 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7526                 RTE_CRYPTO_AUTH_OP_GENERATE,
7527                 pdcp_test_data_in[i],
7528                 pdcp_test_data_in_len[i],
7529                 pdcp_test_data_out[i],
7530                 pdcp_test_data_in_len[i] + 4);
7531 }
7532
7533 int
7534 test_pdcp_proto_cplane_decap(int i)
7535 {
7536         return test_pdcp_proto(i, 0,
7537                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7538                 RTE_CRYPTO_AUTH_OP_VERIFY,
7539                 pdcp_test_data_out[i],
7540                 pdcp_test_data_in_len[i] + 4,
7541                 pdcp_test_data_in[i],
7542                 pdcp_test_data_in_len[i]);
7543 }
7544
7545 int
7546 test_pdcp_proto_uplane_decap(int i)
7547 {
7548         return test_pdcp_proto(i, 0,
7549                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7550                 RTE_CRYPTO_AUTH_OP_VERIFY,
7551                 pdcp_test_data_out[i],
7552                 pdcp_test_data_in_len[i],
7553                 pdcp_test_data_in[i],
7554                 pdcp_test_data_in_len[i]);
7555 }
7556
7557 int
7558 test_pdcp_proto_uplane_decap_with_int(int i)
7559 {
7560         return test_pdcp_proto(i, 0,
7561                 RTE_CRYPTO_CIPHER_OP_DECRYPT,
7562                 RTE_CRYPTO_AUTH_OP_VERIFY,
7563                 pdcp_test_data_out[i],
7564                 pdcp_test_data_in_len[i] + 4,
7565                 pdcp_test_data_in[i],
7566                 pdcp_test_data_in_len[i]);
7567 }
7568
7569 static int
7570 test_PDCP_PROTO_SGL_in_place_32B(void)
7571 {
7572         /* i can be used for running any PDCP case
7573          * In this case it is uplane 12-bit AES-SNOW DL encap
7574          */
7575         int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
7576         return test_pdcp_proto_SGL(i, IN_PLACE,
7577                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7578                         RTE_CRYPTO_AUTH_OP_GENERATE,
7579                         pdcp_test_data_in[i],
7580                         pdcp_test_data_in_len[i],
7581                         pdcp_test_data_out[i],
7582                         pdcp_test_data_in_len[i]+4,
7583                         32, 0);
7584 }
7585 static int
7586 test_PDCP_PROTO_SGL_oop_32B_128B(void)
7587 {
7588         /* i can be used for running any PDCP case
7589          * In this case it is uplane 18-bit NULL-NULL DL encap
7590          */
7591         int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
7592         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7593                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7594                         RTE_CRYPTO_AUTH_OP_GENERATE,
7595                         pdcp_test_data_in[i],
7596                         pdcp_test_data_in_len[i],
7597                         pdcp_test_data_out[i],
7598                         pdcp_test_data_in_len[i]+4,
7599                         32, 128);
7600 }
7601 static int
7602 test_PDCP_PROTO_SGL_oop_32B_40B(void)
7603 {
7604         /* i can be used for running any PDCP case
7605          * In this case it is uplane 18-bit AES DL encap
7606          */
7607         int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
7608                         + DOWNLINK;
7609         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7610                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7611                         RTE_CRYPTO_AUTH_OP_GENERATE,
7612                         pdcp_test_data_in[i],
7613                         pdcp_test_data_in_len[i],
7614                         pdcp_test_data_out[i],
7615                         pdcp_test_data_in_len[i],
7616                         32, 40);
7617 }
7618 static int
7619 test_PDCP_PROTO_SGL_oop_128B_32B(void)
7620 {
7621         /* i can be used for running any PDCP case
7622          * In this case it is cplane 12-bit AES-ZUC DL encap
7623          */
7624         int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
7625         return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
7626                         RTE_CRYPTO_CIPHER_OP_ENCRYPT,
7627                         RTE_CRYPTO_AUTH_OP_GENERATE,
7628                         pdcp_test_data_in[i],
7629                         pdcp_test_data_in_len[i],
7630                         pdcp_test_data_out[i],
7631                         pdcp_test_data_in_len[i]+4,
7632                         128, 32);
7633 }
7634 #endif
7635
7636 static int
7637 test_AES_GCM_authenticated_encryption_test_case_1(void)
7638 {
7639         return test_authenticated_encryption(&gcm_test_case_1);
7640 }
7641
7642 static int
7643 test_AES_GCM_authenticated_encryption_test_case_2(void)
7644 {
7645         return test_authenticated_encryption(&gcm_test_case_2);
7646 }
7647
7648 static int
7649 test_AES_GCM_authenticated_encryption_test_case_3(void)
7650 {
7651         return test_authenticated_encryption(&gcm_test_case_3);
7652 }
7653
7654 static int
7655 test_AES_GCM_authenticated_encryption_test_case_4(void)
7656 {
7657         return test_authenticated_encryption(&gcm_test_case_4);
7658 }
7659
7660 static int
7661 test_AES_GCM_authenticated_encryption_test_case_5(void)
7662 {
7663         return test_authenticated_encryption(&gcm_test_case_5);
7664 }
7665
7666 static int
7667 test_AES_GCM_authenticated_encryption_test_case_6(void)
7668 {
7669         return test_authenticated_encryption(&gcm_test_case_6);
7670 }
7671
7672 static int
7673 test_AES_GCM_authenticated_encryption_test_case_7(void)
7674 {
7675         return test_authenticated_encryption(&gcm_test_case_7);
7676 }
7677
7678 static int
7679 test_AES_GCM_auth_encryption_test_case_192_1(void)
7680 {
7681         return test_authenticated_encryption(&gcm_test_case_192_1);
7682 }
7683
7684 static int
7685 test_AES_GCM_auth_encryption_test_case_192_2(void)
7686 {
7687         return test_authenticated_encryption(&gcm_test_case_192_2);
7688 }
7689
7690 static int
7691 test_AES_GCM_auth_encryption_test_case_192_3(void)
7692 {
7693         return test_authenticated_encryption(&gcm_test_case_192_3);
7694 }
7695
7696 static int
7697 test_AES_GCM_auth_encryption_test_case_192_4(void)
7698 {
7699         return test_authenticated_encryption(&gcm_test_case_192_4);
7700 }
7701
7702 static int
7703 test_AES_GCM_auth_encryption_test_case_192_5(void)
7704 {
7705         return test_authenticated_encryption(&gcm_test_case_192_5);
7706 }
7707
7708 static int
7709 test_AES_GCM_auth_encryption_test_case_192_6(void)
7710 {
7711         return test_authenticated_encryption(&gcm_test_case_192_6);
7712 }
7713
7714 static int
7715 test_AES_GCM_auth_encryption_test_case_192_7(void)
7716 {
7717         return test_authenticated_encryption(&gcm_test_case_192_7);
7718 }
7719
7720 static int
7721 test_AES_GCM_auth_encryption_test_case_256_1(void)
7722 {
7723         return test_authenticated_encryption(&gcm_test_case_256_1);
7724 }
7725
7726 static int
7727 test_AES_GCM_auth_encryption_test_case_256_2(void)
7728 {
7729         return test_authenticated_encryption(&gcm_test_case_256_2);
7730 }
7731
7732 static int
7733 test_AES_GCM_auth_encryption_test_case_256_3(void)
7734 {
7735         return test_authenticated_encryption(&gcm_test_case_256_3);
7736 }
7737
7738 static int
7739 test_AES_GCM_auth_encryption_test_case_256_4(void)
7740 {
7741         return test_authenticated_encryption(&gcm_test_case_256_4);
7742 }
7743
7744 static int
7745 test_AES_GCM_auth_encryption_test_case_256_5(void)
7746 {
7747         return test_authenticated_encryption(&gcm_test_case_256_5);
7748 }
7749
7750 static int
7751 test_AES_GCM_auth_encryption_test_case_256_6(void)
7752 {
7753         return test_authenticated_encryption(&gcm_test_case_256_6);
7754 }
7755
7756 static int
7757 test_AES_GCM_auth_encryption_test_case_256_7(void)
7758 {
7759         return test_authenticated_encryption(&gcm_test_case_256_7);
7760 }
7761
7762 static int
7763 test_AES_GCM_auth_encryption_test_case_aad_1(void)
7764 {
7765         return test_authenticated_encryption(&gcm_test_case_aad_1);
7766 }
7767
7768 static int
7769 test_AES_GCM_auth_encryption_test_case_aad_2(void)
7770 {
7771         return test_authenticated_encryption(&gcm_test_case_aad_2);
7772 }
7773
7774 static int
7775 test_authenticated_decryption(const struct aead_test_data *tdata)
7776 {
7777         struct crypto_testsuite_params *ts_params = &testsuite_params;
7778         struct crypto_unittest_params *ut_params = &unittest_params;
7779
7780         int retval;
7781         uint8_t *plaintext;
7782         uint32_t i;
7783
7784         /* Create AEAD session */
7785         retval = create_aead_session(ts_params->valid_devs[0],
7786                         tdata->algo,
7787                         RTE_CRYPTO_AEAD_OP_DECRYPT,
7788                         tdata->key.data, tdata->key.len,
7789                         tdata->aad.len, tdata->auth_tag.len,
7790                         tdata->iv.len);
7791         if (retval < 0)
7792                 return retval;
7793
7794         /* alloc mbuf and set payload */
7795         if (tdata->aad.len > MBUF_SIZE) {
7796                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7797                 /* Populate full size of add data */
7798                 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7799                         memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7800         } else
7801                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7802
7803         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7804                         rte_pktmbuf_tailroom(ut_params->ibuf));
7805
7806         /* Create AEAD operation */
7807         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
7808         if (retval < 0)
7809                 return retval;
7810
7811         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7812
7813         ut_params->op->sym->m_src = ut_params->ibuf;
7814
7815         /* Process crypto operation */
7816         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7817                         ut_params->op), "failed to process sym crypto op");
7818
7819         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7820                         "crypto op processing failed");
7821
7822         if (ut_params->op->sym->m_dst)
7823                 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7824                                 uint8_t *);
7825         else
7826                 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7827                                 uint8_t *,
7828                                 ut_params->op->sym->cipher.data.offset);
7829
7830         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
7831
7832         /* Validate obuf */
7833         TEST_ASSERT_BUFFERS_ARE_EQUAL(
7834                         plaintext,
7835                         tdata->plaintext.data,
7836                         tdata->plaintext.len,
7837                         "Plaintext data not as expected");
7838
7839         TEST_ASSERT_EQUAL(ut_params->op->status,
7840                         RTE_CRYPTO_OP_STATUS_SUCCESS,
7841                         "Authentication failed");
7842         return 0;
7843 }
7844
7845 static int
7846 test_AES_GCM_authenticated_decryption_test_case_1(void)
7847 {
7848         return test_authenticated_decryption(&gcm_test_case_1);
7849 }
7850
7851 static int
7852 test_AES_GCM_authenticated_decryption_test_case_2(void)
7853 {
7854         return test_authenticated_decryption(&gcm_test_case_2);
7855 }
7856
7857 static int
7858 test_AES_GCM_authenticated_decryption_test_case_3(void)
7859 {
7860         return test_authenticated_decryption(&gcm_test_case_3);
7861 }
7862
7863 static int
7864 test_AES_GCM_authenticated_decryption_test_case_4(void)
7865 {
7866         return test_authenticated_decryption(&gcm_test_case_4);
7867 }
7868
7869 static int
7870 test_AES_GCM_authenticated_decryption_test_case_5(void)
7871 {
7872         return test_authenticated_decryption(&gcm_test_case_5);
7873 }
7874
7875 static int
7876 test_AES_GCM_authenticated_decryption_test_case_6(void)
7877 {
7878         return test_authenticated_decryption(&gcm_test_case_6);
7879 }
7880
7881 static int
7882 test_AES_GCM_authenticated_decryption_test_case_7(void)
7883 {
7884         return test_authenticated_decryption(&gcm_test_case_7);
7885 }
7886
7887 static int
7888 test_AES_GCM_auth_decryption_test_case_192_1(void)
7889 {
7890         return test_authenticated_decryption(&gcm_test_case_192_1);
7891 }
7892
7893 static int
7894 test_AES_GCM_auth_decryption_test_case_192_2(void)
7895 {
7896         return test_authenticated_decryption(&gcm_test_case_192_2);
7897 }
7898
7899 static int
7900 test_AES_GCM_auth_decryption_test_case_192_3(void)
7901 {
7902         return test_authenticated_decryption(&gcm_test_case_192_3);
7903 }
7904
7905 static int
7906 test_AES_GCM_auth_decryption_test_case_192_4(void)
7907 {
7908         return test_authenticated_decryption(&gcm_test_case_192_4);
7909 }
7910
7911 static int
7912 test_AES_GCM_auth_decryption_test_case_192_5(void)
7913 {
7914         return test_authenticated_decryption(&gcm_test_case_192_5);
7915 }
7916
7917 static int
7918 test_AES_GCM_auth_decryption_test_case_192_6(void)
7919 {
7920         return test_authenticated_decryption(&gcm_test_case_192_6);
7921 }
7922
7923 static int
7924 test_AES_GCM_auth_decryption_test_case_192_7(void)
7925 {
7926         return test_authenticated_decryption(&gcm_test_case_192_7);
7927 }
7928
7929 static int
7930 test_AES_GCM_auth_decryption_test_case_256_1(void)
7931 {
7932         return test_authenticated_decryption(&gcm_test_case_256_1);
7933 }
7934
7935 static int
7936 test_AES_GCM_auth_decryption_test_case_256_2(void)
7937 {
7938         return test_authenticated_decryption(&gcm_test_case_256_2);
7939 }
7940
7941 static int
7942 test_AES_GCM_auth_decryption_test_case_256_3(void)
7943 {
7944         return test_authenticated_decryption(&gcm_test_case_256_3);
7945 }
7946
7947 static int
7948 test_AES_GCM_auth_decryption_test_case_256_4(void)
7949 {
7950         return test_authenticated_decryption(&gcm_test_case_256_4);
7951 }
7952
7953 static int
7954 test_AES_GCM_auth_decryption_test_case_256_5(void)
7955 {
7956         return test_authenticated_decryption(&gcm_test_case_256_5);
7957 }
7958
7959 static int
7960 test_AES_GCM_auth_decryption_test_case_256_6(void)
7961 {
7962         return test_authenticated_decryption(&gcm_test_case_256_6);
7963 }
7964
7965 static int
7966 test_AES_GCM_auth_decryption_test_case_256_7(void)
7967 {
7968         return test_authenticated_decryption(&gcm_test_case_256_7);
7969 }
7970
7971 static int
7972 test_AES_GCM_auth_decryption_test_case_aad_1(void)
7973 {
7974         return test_authenticated_decryption(&gcm_test_case_aad_1);
7975 }
7976
7977 static int
7978 test_AES_GCM_auth_decryption_test_case_aad_2(void)
7979 {
7980         return test_authenticated_decryption(&gcm_test_case_aad_2);
7981 }
7982
7983 static int
7984 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
7985 {
7986         struct crypto_testsuite_params *ts_params = &testsuite_params;
7987         struct crypto_unittest_params *ut_params = &unittest_params;
7988
7989         int retval;
7990         uint8_t *ciphertext, *auth_tag;
7991         uint16_t plaintext_pad_len;
7992
7993         /* Create AEAD session */
7994         retval = create_aead_session(ts_params->valid_devs[0],
7995                         tdata->algo,
7996                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
7997                         tdata->key.data, tdata->key.len,
7998                         tdata->aad.len, tdata->auth_tag.len,
7999                         tdata->iv.len);
8000         if (retval < 0)
8001                 return retval;
8002
8003         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8004         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8005
8006         /* clear mbuf payload */
8007         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8008                         rte_pktmbuf_tailroom(ut_params->ibuf));
8009         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8010                         rte_pktmbuf_tailroom(ut_params->obuf));
8011
8012         /* Create AEAD operation */
8013         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8014         if (retval < 0)
8015                 return retval;
8016
8017         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8018
8019         ut_params->op->sym->m_src = ut_params->ibuf;
8020         ut_params->op->sym->m_dst = ut_params->obuf;
8021
8022         /* Process crypto operation */
8023         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8024                         ut_params->op), "failed to process sym crypto op");
8025
8026         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8027                         "crypto op processing failed");
8028
8029         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8030
8031         ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8032                         ut_params->op->sym->cipher.data.offset);
8033         auth_tag = ciphertext + plaintext_pad_len;
8034
8035         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8036         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8037
8038         /* Validate obuf */
8039         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8040                         ciphertext,
8041                         tdata->ciphertext.data,
8042                         tdata->ciphertext.len,
8043                         "Ciphertext data not as expected");
8044
8045         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8046                         auth_tag,
8047                         tdata->auth_tag.data,
8048                         tdata->auth_tag.len,
8049                         "Generated auth tag not as expected");
8050
8051         return 0;
8052
8053 }
8054
8055 static int
8056 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8057 {
8058         return test_authenticated_encryption_oop(&gcm_test_case_5);
8059 }
8060
8061 static int
8062 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8063 {
8064         struct crypto_testsuite_params *ts_params = &testsuite_params;
8065         struct crypto_unittest_params *ut_params = &unittest_params;
8066
8067         int retval;
8068         uint8_t *plaintext;
8069
8070         /* Create AEAD session */
8071         retval = create_aead_session(ts_params->valid_devs[0],
8072                         tdata->algo,
8073                         RTE_CRYPTO_AEAD_OP_DECRYPT,
8074                         tdata->key.data, tdata->key.len,
8075                         tdata->aad.len, tdata->auth_tag.len,
8076                         tdata->iv.len);
8077         if (retval < 0)
8078                 return retval;
8079
8080         /* alloc mbuf and set payload */
8081         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8082         ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8083
8084         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8085                         rte_pktmbuf_tailroom(ut_params->ibuf));
8086         memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8087                         rte_pktmbuf_tailroom(ut_params->obuf));
8088
8089         /* Create AEAD operation */
8090         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8091         if (retval < 0)
8092                 return retval;
8093
8094         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8095
8096         ut_params->op->sym->m_src = ut_params->ibuf;
8097         ut_params->op->sym->m_dst = ut_params->obuf;
8098
8099         /* Process crypto operation */
8100         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8101                         ut_params->op), "failed to process sym crypto op");
8102
8103         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8104                         "crypto op processing failed");
8105
8106         plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8107                         ut_params->op->sym->cipher.data.offset);
8108
8109         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8110
8111         /* Validate obuf */
8112         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8113                         plaintext,
8114                         tdata->plaintext.data,
8115                         tdata->plaintext.len,
8116                         "Plaintext data not as expected");
8117
8118         TEST_ASSERT_EQUAL(ut_params->op->status,
8119                         RTE_CRYPTO_OP_STATUS_SUCCESS,
8120                         "Authentication failed");
8121         return 0;
8122 }
8123
8124 static int
8125 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8126 {
8127         return test_authenticated_decryption_oop(&gcm_test_case_5);
8128 }
8129
8130 static int
8131 test_authenticated_encryption_sessionless(
8132                 const struct aead_test_data *tdata)
8133 {
8134         struct crypto_testsuite_params *ts_params = &testsuite_params;
8135         struct crypto_unittest_params *ut_params = &unittest_params;
8136
8137         int retval;
8138         uint8_t *ciphertext, *auth_tag;
8139         uint16_t plaintext_pad_len;
8140         uint8_t key[tdata->key.len + 1];
8141
8142         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8143
8144         /* clear mbuf payload */
8145         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8146                         rte_pktmbuf_tailroom(ut_params->ibuf));
8147
8148         /* Create AEAD operation */
8149         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8150         if (retval < 0)
8151                 return retval;
8152
8153         /* Create GCM xform */
8154         memcpy(key, tdata->key.data, tdata->key.len);
8155         retval = create_aead_xform(ut_params->op,
8156                         tdata->algo,
8157                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
8158                         key, tdata->key.len,
8159                         tdata->aad.len, tdata->auth_tag.len,
8160                         tdata->iv.len);
8161         if (retval < 0)
8162                 return retval;
8163
8164         ut_params->op->sym->m_src = ut_params->ibuf;
8165
8166         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8167                         RTE_CRYPTO_OP_SESSIONLESS,
8168                         "crypto op session type not sessionless");
8169
8170         /* Process crypto operation */
8171         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8172                         ut_params->op), "failed to process sym crypto op");
8173
8174         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8175
8176         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8177                         "crypto op status not success");
8178
8179         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8180
8181         ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8182                         ut_params->op->sym->cipher.data.offset);
8183         auth_tag = ciphertext + plaintext_pad_len;
8184
8185         debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8186         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8187
8188         /* Validate obuf */
8189         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8190                         ciphertext,
8191                         tdata->ciphertext.data,
8192                         tdata->ciphertext.len,
8193                         "Ciphertext data not as expected");
8194
8195         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8196                         auth_tag,
8197                         tdata->auth_tag.data,
8198                         tdata->auth_tag.len,
8199                         "Generated auth tag not as expected");
8200
8201         return 0;
8202
8203 }
8204
8205 static int
8206 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8207 {
8208         return test_authenticated_encryption_sessionless(
8209                         &gcm_test_case_5);
8210 }
8211
8212 static int
8213 test_authenticated_decryption_sessionless(
8214                 const struct aead_test_data *tdata)
8215 {
8216         struct crypto_testsuite_params *ts_params = &testsuite_params;
8217         struct crypto_unittest_params *ut_params = &unittest_params;
8218
8219         int retval;
8220         uint8_t *plaintext;
8221         uint8_t key[tdata->key.len + 1];
8222
8223         /* alloc mbuf and set payload */
8224         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8225
8226         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8227                         rte_pktmbuf_tailroom(ut_params->ibuf));
8228
8229         /* Create AEAD operation */
8230         retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8231         if (retval < 0)
8232                 return retval;
8233
8234         /* Create AEAD xform */
8235         memcpy(key, tdata->key.data, tdata->key.len);
8236         retval = create_aead_xform(ut_params->op,
8237                         tdata->algo,
8238                         RTE_CRYPTO_AEAD_OP_DECRYPT,
8239                         key, tdata->key.len,
8240                         tdata->aad.len, tdata->auth_tag.len,
8241                         tdata->iv.len);
8242         if (retval < 0)
8243                 return retval;
8244
8245         ut_params->op->sym->m_src = ut_params->ibuf;
8246
8247         TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8248                         RTE_CRYPTO_OP_SESSIONLESS,
8249                         "crypto op session type not sessionless");
8250
8251         /* Process crypto operation */
8252         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8253                         ut_params->op), "failed to process sym crypto op");
8254
8255         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8256
8257         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8258                         "crypto op status not success");
8259
8260         plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8261                         ut_params->op->sym->cipher.data.offset);
8262
8263         debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8264
8265         /* Validate obuf */
8266         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8267                         plaintext,
8268                         tdata->plaintext.data,
8269                         tdata->plaintext.len,
8270                         "Plaintext data not as expected");
8271
8272         TEST_ASSERT_EQUAL(ut_params->op->status,
8273                         RTE_CRYPTO_OP_STATUS_SUCCESS,
8274                         "Authentication failed");
8275         return 0;
8276 }
8277
8278 static int
8279 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
8280 {
8281         return test_authenticated_decryption_sessionless(
8282                         &gcm_test_case_5);
8283 }
8284
8285 static int
8286 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
8287 {
8288         return test_authenticated_encryption(&ccm_test_case_128_1);
8289 }
8290
8291 static int
8292 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
8293 {
8294         return test_authenticated_encryption(&ccm_test_case_128_2);
8295 }
8296
8297 static int
8298 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
8299 {
8300         return test_authenticated_encryption(&ccm_test_case_128_3);
8301 }
8302
8303 static int
8304 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
8305 {
8306         return test_authenticated_decryption(&ccm_test_case_128_1);
8307 }
8308
8309 static int
8310 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
8311 {
8312         return test_authenticated_decryption(&ccm_test_case_128_2);
8313 }
8314
8315 static int
8316 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
8317 {
8318         return test_authenticated_decryption(&ccm_test_case_128_3);
8319 }
8320
8321 static int
8322 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
8323 {
8324         return test_authenticated_encryption(&ccm_test_case_192_1);
8325 }
8326
8327 static int
8328 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
8329 {
8330         return test_authenticated_encryption(&ccm_test_case_192_2);
8331 }
8332
8333 static int
8334 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
8335 {
8336         return test_authenticated_encryption(&ccm_test_case_192_3);
8337 }
8338
8339 static int
8340 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
8341 {
8342         return test_authenticated_decryption(&ccm_test_case_192_1);
8343 }
8344
8345 static int
8346 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
8347 {
8348         return test_authenticated_decryption(&ccm_test_case_192_2);
8349 }
8350
8351 static int
8352 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
8353 {
8354         return test_authenticated_decryption(&ccm_test_case_192_3);
8355 }
8356
8357 static int
8358 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
8359 {
8360         return test_authenticated_encryption(&ccm_test_case_256_1);
8361 }
8362
8363 static int
8364 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
8365 {
8366         return test_authenticated_encryption(&ccm_test_case_256_2);
8367 }
8368
8369 static int
8370 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
8371 {
8372         return test_authenticated_encryption(&ccm_test_case_256_3);
8373 }
8374
8375 static int
8376 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
8377 {
8378         return test_authenticated_decryption(&ccm_test_case_256_1);
8379 }
8380
8381 static int
8382 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
8383 {
8384         return test_authenticated_decryption(&ccm_test_case_256_2);
8385 }
8386
8387 static int
8388 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
8389 {
8390         return test_authenticated_decryption(&ccm_test_case_256_3);
8391 }
8392
8393 static int
8394 test_stats(void)
8395 {
8396         struct crypto_testsuite_params *ts_params = &testsuite_params;
8397         struct rte_cryptodev_stats stats;
8398         struct rte_cryptodev *dev;
8399         cryptodev_stats_get_t temp_pfn;
8400
8401         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8402         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
8403                         &stats) == -ENODEV),
8404                 "rte_cryptodev_stats_get invalid dev failed");
8405         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
8406                 "rte_cryptodev_stats_get invalid Param failed");
8407         dev = &rte_cryptodevs[ts_params->valid_devs[0]];
8408         temp_pfn = dev->dev_ops->stats_get;
8409         dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
8410         TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
8411                         == -ENOTSUP),
8412                 "rte_cryptodev_stats_get invalid Param failed");
8413         dev->dev_ops->stats_get = temp_pfn;
8414
8415         /* Test expected values */
8416         ut_setup();
8417         test_AES_CBC_HMAC_SHA1_encrypt_digest();
8418         ut_teardown();
8419         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8420                         &stats),
8421                 "rte_cryptodev_stats_get failed");
8422         TEST_ASSERT((stats.enqueued_count == 1),
8423                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8424         TEST_ASSERT((stats.dequeued_count == 1),
8425                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8426         TEST_ASSERT((stats.enqueue_err_count == 0),
8427                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8428         TEST_ASSERT((stats.dequeue_err_count == 0),
8429                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8430
8431         /* invalid device but should ignore and not reset device stats*/
8432         rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
8433         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8434                         &stats),
8435                 "rte_cryptodev_stats_get failed");
8436         TEST_ASSERT((stats.enqueued_count == 1),
8437                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8438
8439         /* check that a valid reset clears stats */
8440         rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
8441         TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
8442                         &stats),
8443                                           "rte_cryptodev_stats_get failed");
8444         TEST_ASSERT((stats.enqueued_count == 0),
8445                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8446         TEST_ASSERT((stats.dequeued_count == 0),
8447                 "rte_cryptodev_stats_get returned unexpected enqueued stat");
8448
8449         return TEST_SUCCESS;
8450 }
8451
8452 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
8453                                    struct crypto_unittest_params *ut_params,
8454                                    enum rte_crypto_auth_operation op,
8455                                    const struct HMAC_MD5_vector *test_case)
8456 {
8457         uint8_t key[64];
8458
8459         memcpy(key, test_case->key.data, test_case->key.len);
8460
8461         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8462         ut_params->auth_xform.next = NULL;
8463         ut_params->auth_xform.auth.op = op;
8464
8465         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
8466
8467         ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
8468         ut_params->auth_xform.auth.key.length = test_case->key.len;
8469         ut_params->auth_xform.auth.key.data = key;
8470
8471         ut_params->sess = rte_cryptodev_sym_session_create(
8472                         ts_params->session_mpool);
8473
8474         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8475                         ut_params->sess, &ut_params->auth_xform,
8476                         ts_params->session_priv_mpool);
8477
8478         if (ut_params->sess == NULL)
8479                 return TEST_FAILED;
8480
8481         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8482
8483         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8484                         rte_pktmbuf_tailroom(ut_params->ibuf));
8485
8486         return 0;
8487 }
8488
8489 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
8490                               const struct HMAC_MD5_vector *test_case,
8491                               uint8_t **plaintext)
8492 {
8493         uint16_t plaintext_pad_len;
8494
8495         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8496
8497         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8498                                 16);
8499
8500         *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8501                         plaintext_pad_len);
8502         memcpy(*plaintext, test_case->plaintext.data,
8503                         test_case->plaintext.len);
8504
8505         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8506                         ut_params->ibuf, MD5_DIGEST_LEN);
8507         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8508                         "no room to append digest");
8509         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8510                         ut_params->ibuf, plaintext_pad_len);
8511
8512         if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
8513                 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
8514                            test_case->auth_tag.len);
8515         }
8516
8517         sym_op->auth.data.offset = 0;
8518         sym_op->auth.data.length = test_case->plaintext.len;
8519
8520         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8521         ut_params->op->sym->m_src = ut_params->ibuf;
8522
8523         return 0;
8524 }
8525
8526 static int
8527 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
8528 {
8529         uint16_t plaintext_pad_len;
8530         uint8_t *plaintext, *auth_tag;
8531
8532         struct crypto_testsuite_params *ts_params = &testsuite_params;
8533         struct crypto_unittest_params *ut_params = &unittest_params;
8534
8535         if (MD5_HMAC_create_session(ts_params, ut_params,
8536                         RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
8537                 return TEST_FAILED;
8538
8539         /* Generate Crypto op data structure */
8540         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8541                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8542         TEST_ASSERT_NOT_NULL(ut_params->op,
8543                         "Failed to allocate symmetric crypto operation struct");
8544
8545         plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
8546                                 16);
8547
8548         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8549                 return TEST_FAILED;
8550
8551         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8552                         ut_params->op), "failed to process sym crypto op");
8553
8554         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8555                         "crypto op processing failed");
8556
8557         if (ut_params->op->sym->m_dst) {
8558                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8559                                 uint8_t *, plaintext_pad_len);
8560         } else {
8561                 auth_tag = plaintext + plaintext_pad_len;
8562         }
8563
8564         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8565                         auth_tag,
8566                         test_case->auth_tag.data,
8567                         test_case->auth_tag.len,
8568                         "HMAC_MD5 generated tag not as expected");
8569
8570         return TEST_SUCCESS;
8571 }
8572
8573 static int
8574 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
8575 {
8576         uint8_t *plaintext;
8577
8578         struct crypto_testsuite_params *ts_params = &testsuite_params;
8579         struct crypto_unittest_params *ut_params = &unittest_params;
8580
8581         if (MD5_HMAC_create_session(ts_params, ut_params,
8582                         RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
8583                 return TEST_FAILED;
8584         }
8585
8586         /* Generate Crypto op data structure */
8587         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8588                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8589         TEST_ASSERT_NOT_NULL(ut_params->op,
8590                         "Failed to allocate symmetric crypto operation struct");
8591
8592         if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
8593                 return TEST_FAILED;
8594
8595         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8596                         ut_params->op), "failed to process sym crypto op");
8597
8598         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8599                         "HMAC_MD5 crypto op processing failed");
8600
8601         return TEST_SUCCESS;
8602 }
8603
8604 static int
8605 test_MD5_HMAC_generate_case_1(void)
8606 {
8607         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
8608 }
8609
8610 static int
8611 test_MD5_HMAC_verify_case_1(void)
8612 {
8613         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
8614 }
8615
8616 static int
8617 test_MD5_HMAC_generate_case_2(void)
8618 {
8619         return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
8620 }
8621
8622 static int
8623 test_MD5_HMAC_verify_case_2(void)
8624 {
8625         return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
8626 }
8627
8628 static int
8629 test_multi_session(void)
8630 {
8631         struct crypto_testsuite_params *ts_params = &testsuite_params;
8632         struct crypto_unittest_params *ut_params = &unittest_params;
8633
8634         struct rte_cryptodev_info dev_info;
8635         struct rte_cryptodev_sym_session **sessions;
8636
8637         uint16_t i;
8638
8639         test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
8640                         aes_cbc_key, hmac_sha512_key);
8641
8642
8643         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8644
8645         sessions = rte_malloc(NULL,
8646                         (sizeof(struct rte_cryptodev_sym_session *) *
8647                         MAX_NB_SESSIONS) + 1, 0);
8648
8649         /* Create multiple crypto sessions*/
8650         for (i = 0; i < MAX_NB_SESSIONS; i++) {
8651
8652                 sessions[i] = rte_cryptodev_sym_session_create(
8653                                 ts_params->session_mpool);
8654
8655                 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8656                                 sessions[i], &ut_params->auth_xform,
8657                                 ts_params->session_priv_mpool);
8658                 TEST_ASSERT_NOT_NULL(sessions[i],
8659                                 "Session creation failed at session number %u",
8660                                 i);
8661
8662                 /* Attempt to send a request on each session */
8663                 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
8664                         sessions[i],
8665                         ut_params,
8666                         ts_params,
8667                         catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
8668                         catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
8669                         aes_cbc_iv),
8670                         "Failed to perform decrypt on request number %u.", i);
8671                 /* free crypto operation structure */
8672                 if (ut_params->op)
8673                         rte_crypto_op_free(ut_params->op);
8674
8675                 /*
8676                  * free mbuf - both obuf and ibuf are usually the same,
8677                  * so check if they point at the same address is necessary,
8678                  * to avoid freeing the mbuf twice.
8679                  */
8680                 if (ut_params->obuf) {
8681                         rte_pktmbuf_free(ut_params->obuf);
8682                         if (ut_params->ibuf == ut_params->obuf)
8683                                 ut_params->ibuf = 0;
8684                         ut_params->obuf = 0;
8685                 }
8686                 if (ut_params->ibuf) {
8687                         rte_pktmbuf_free(ut_params->ibuf);
8688                         ut_params->ibuf = 0;
8689                 }
8690         }
8691
8692         /* Next session create should fail */
8693         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8694                         sessions[i], &ut_params->auth_xform,
8695                         ts_params->session_priv_mpool);
8696         TEST_ASSERT_NULL(sessions[i],
8697                         "Session creation succeeded unexpectedly!");
8698
8699         for (i = 0; i < MAX_NB_SESSIONS; i++) {
8700                 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8701                                 sessions[i]);
8702                 rte_cryptodev_sym_session_free(sessions[i]);
8703         }
8704
8705         rte_free(sessions);
8706
8707         return TEST_SUCCESS;
8708 }
8709
8710 struct multi_session_params {
8711         struct crypto_unittest_params ut_params;
8712         uint8_t *cipher_key;
8713         uint8_t *hmac_key;
8714         const uint8_t *cipher;
8715         const uint8_t *digest;
8716         uint8_t *iv;
8717 };
8718
8719 #define MB_SESSION_NUMBER 3
8720
8721 static int
8722 test_multi_session_random_usage(void)
8723 {
8724         struct crypto_testsuite_params *ts_params = &testsuite_params;
8725         struct rte_cryptodev_info dev_info;
8726         struct rte_cryptodev_sym_session **sessions;
8727         uint32_t i, j;
8728         struct multi_session_params ut_paramz[] = {
8729
8730                 {
8731                         .cipher_key = ms_aes_cbc_key0,
8732                         .hmac_key = ms_hmac_key0,
8733                         .cipher = ms_aes_cbc_cipher0,
8734                         .digest = ms_hmac_digest0,
8735                         .iv = ms_aes_cbc_iv0
8736                 },
8737                 {
8738                         .cipher_key = ms_aes_cbc_key1,
8739                         .hmac_key = ms_hmac_key1,
8740                         .cipher = ms_aes_cbc_cipher1,
8741                         .digest = ms_hmac_digest1,
8742                         .iv = ms_aes_cbc_iv1
8743                 },
8744                 {
8745                         .cipher_key = ms_aes_cbc_key2,
8746                         .hmac_key = ms_hmac_key2,
8747                         .cipher = ms_aes_cbc_cipher2,
8748                         .digest = ms_hmac_digest2,
8749                         .iv = ms_aes_cbc_iv2
8750                 },
8751
8752         };
8753
8754         rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
8755
8756         sessions = rte_malloc(NULL,
8757                         (sizeof(struct rte_cryptodev_sym_session *)
8758                                         * MAX_NB_SESSIONS) + 1, 0);
8759
8760         for (i = 0; i < MB_SESSION_NUMBER; i++) {
8761                 sessions[i] = rte_cryptodev_sym_session_create(
8762                                 ts_params->session_mpool);
8763
8764                 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
8765                                 sizeof(struct crypto_unittest_params));
8766
8767                 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
8768                                 &ut_paramz[i].ut_params,
8769                                 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
8770
8771                 /* Create multiple crypto sessions*/
8772                 rte_cryptodev_sym_session_init(
8773                                 ts_params->valid_devs[0],
8774                                 sessions[i],
8775                                 &ut_paramz[i].ut_params.auth_xform,
8776                                 ts_params->session_priv_mpool);
8777
8778                 TEST_ASSERT_NOT_NULL(sessions[i],
8779                                 "Session creation failed at session number %u",
8780                                 i);
8781
8782         }
8783
8784         srand(time(NULL));
8785         for (i = 0; i < 40000; i++) {
8786
8787                 j = rand() % MB_SESSION_NUMBER;
8788
8789                 TEST_ASSERT_SUCCESS(
8790                         test_AES_CBC_HMAC_SHA512_decrypt_perform(
8791                                         sessions[j],
8792                                         &ut_paramz[j].ut_params,
8793                                         ts_params, ut_paramz[j].cipher,
8794                                         ut_paramz[j].digest,
8795                                         ut_paramz[j].iv),
8796                         "Failed to perform decrypt on request number %u.", i);
8797
8798                 if (ut_paramz[j].ut_params.op)
8799                         rte_crypto_op_free(ut_paramz[j].ut_params.op);
8800
8801                 /*
8802                  * free mbuf - both obuf and ibuf are usually the same,
8803                  * so check if they point at the same address is necessary,
8804                  * to avoid freeing the mbuf twice.
8805                  */
8806                 if (ut_paramz[j].ut_params.obuf) {
8807                         rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
8808                         if (ut_paramz[j].ut_params.ibuf
8809                                         == ut_paramz[j].ut_params.obuf)
8810                                 ut_paramz[j].ut_params.ibuf = 0;
8811                         ut_paramz[j].ut_params.obuf = 0;
8812                 }
8813                 if (ut_paramz[j].ut_params.ibuf) {
8814                         rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
8815                         ut_paramz[j].ut_params.ibuf = 0;
8816                 }
8817         }
8818
8819         for (i = 0; i < MB_SESSION_NUMBER; i++) {
8820                 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
8821                                 sessions[i]);
8822                 rte_cryptodev_sym_session_free(sessions[i]);
8823         }
8824
8825         rte_free(sessions);
8826
8827         return TEST_SUCCESS;
8828 }
8829
8830 static int
8831 test_null_cipher_only_operation(void)
8832 {
8833         struct crypto_testsuite_params *ts_params = &testsuite_params;
8834         struct crypto_unittest_params *ut_params = &unittest_params;
8835
8836         /* Generate test mbuf data and space for digest */
8837         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8838                         catch_22_quote, QUOTE_512_BYTES, 0);
8839
8840         /* Setup Cipher Parameters */
8841         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8842         ut_params->cipher_xform.next = NULL;
8843
8844         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8845         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8846
8847         ut_params->sess = rte_cryptodev_sym_session_create(
8848                         ts_params->session_mpool);
8849
8850         /* Create Crypto session*/
8851         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8852                                 ut_params->sess,
8853                                 &ut_params->cipher_xform,
8854                                 ts_params->session_priv_mpool);
8855         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8856
8857         /* Generate Crypto op data structure */
8858         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8859                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8860         TEST_ASSERT_NOT_NULL(ut_params->op,
8861                         "Failed to allocate symmetric crypto operation struct");
8862
8863         /* Set crypto operation data parameters */
8864         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8865
8866         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8867
8868         /* set crypto operation source mbuf */
8869         sym_op->m_src = ut_params->ibuf;
8870
8871         sym_op->cipher.data.offset = 0;
8872         sym_op->cipher.data.length = QUOTE_512_BYTES;
8873
8874         /* Process crypto operation */
8875         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8876                         ut_params->op);
8877         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8878
8879         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8880                         "crypto operation processing failed");
8881
8882         /* Validate obuf */
8883         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8884                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
8885                         catch_22_quote,
8886                         QUOTE_512_BYTES,
8887                         "Ciphertext data not as expected");
8888
8889         return TEST_SUCCESS;
8890 }
8891 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
8892                         0xab, 0xab, 0xab, 0xab,
8893                         0xab, 0xab, 0xab, 0xab,
8894                         0xab, 0xab, 0xab, 0xab};
8895 static int
8896 test_null_auth_only_operation(void)
8897 {
8898         struct crypto_testsuite_params *ts_params = &testsuite_params;
8899         struct crypto_unittest_params *ut_params = &unittest_params;
8900         uint8_t *digest;
8901
8902         /* Generate test mbuf data and space for digest */
8903         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8904                         catch_22_quote, QUOTE_512_BYTES, 0);
8905
8906         /* create a pointer for digest, but don't expect anything to be written
8907          * here in a NULL auth algo so no mbuf append done.
8908          */
8909         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8910                         QUOTE_512_BYTES);
8911         /* prefill the memory pointed to by digest */
8912         memcpy(digest, orig_data, sizeof(orig_data));
8913
8914         /* Setup HMAC Parameters */
8915         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8916         ut_params->auth_xform.next = NULL;
8917
8918         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8919         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8920
8921         ut_params->sess = rte_cryptodev_sym_session_create(
8922                         ts_params->session_mpool);
8923
8924         /* Create Crypto session*/
8925         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
8926                         ut_params->sess, &ut_params->auth_xform,
8927                         ts_params->session_priv_mpool);
8928         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
8929
8930         /* Generate Crypto op data structure */
8931         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8932                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8933         TEST_ASSERT_NOT_NULL(ut_params->op,
8934                         "Failed to allocate symmetric crypto operation struct");
8935
8936         /* Set crypto operation data parameters */
8937         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8938
8939         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8940
8941         sym_op->m_src = ut_params->ibuf;
8942
8943         sym_op->auth.data.offset = 0;
8944         sym_op->auth.data.length = QUOTE_512_BYTES;
8945         sym_op->auth.digest.data = digest;
8946         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
8947                         QUOTE_512_BYTES);
8948
8949         /* Process crypto operation */
8950         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8951                         ut_params->op);
8952         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
8953
8954         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8955                         "crypto operation processing failed");
8956         /* Make sure memory pointed to by digest hasn't been overwritten */
8957         TEST_ASSERT_BUFFERS_ARE_EQUAL(
8958                         orig_data,
8959                         digest,
8960                         sizeof(orig_data),
8961                         "Memory at digest ptr overwritten unexpectedly");
8962
8963         return TEST_SUCCESS;
8964 }
8965
8966
8967 static int
8968 test_null_cipher_auth_operation(void)
8969 {
8970         struct crypto_testsuite_params *ts_params = &testsuite_params;
8971         struct crypto_unittest_params *ut_params = &unittest_params;
8972         uint8_t *digest;
8973
8974         /* Generate test mbuf data and space for digest */
8975         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
8976                         catch_22_quote, QUOTE_512_BYTES, 0);
8977
8978         /* create a pointer for digest, but don't expect anything to be written
8979          * here in a NULL auth algo so no mbuf append done.
8980          */
8981         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8982                         QUOTE_512_BYTES);
8983         /* prefill the memory pointed to by digest */
8984         memcpy(digest, orig_data, sizeof(orig_data));
8985
8986         /* Setup Cipher Parameters */
8987         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8988         ut_params->cipher_xform.next = &ut_params->auth_xform;
8989
8990         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
8991         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
8992
8993         /* Setup HMAC Parameters */
8994         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8995         ut_params->auth_xform.next = NULL;
8996
8997         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
8998         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
8999
9000         ut_params->sess = rte_cryptodev_sym_session_create(
9001                         ts_params->session_mpool);
9002
9003         /* Create Crypto session*/
9004         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9005                         ut_params->sess, &ut_params->cipher_xform,
9006                         ts_params->session_priv_mpool);
9007         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9008
9009         /* Generate Crypto op data structure */
9010         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9011                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9012         TEST_ASSERT_NOT_NULL(ut_params->op,
9013                         "Failed to allocate symmetric crypto operation struct");
9014
9015         /* Set crypto operation data parameters */
9016         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9017
9018         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9019
9020         sym_op->m_src = ut_params->ibuf;
9021
9022         sym_op->cipher.data.offset = 0;
9023         sym_op->cipher.data.length = QUOTE_512_BYTES;
9024
9025         sym_op->auth.data.offset = 0;
9026         sym_op->auth.data.length = QUOTE_512_BYTES;
9027         sym_op->auth.digest.data = digest;
9028         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9029                         QUOTE_512_BYTES);
9030
9031         /* Process crypto operation */
9032         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9033                         ut_params->op);
9034         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9035
9036         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9037                         "crypto operation processing failed");
9038
9039         /* Validate obuf */
9040         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9041                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9042                         catch_22_quote,
9043                         QUOTE_512_BYTES,
9044                         "Ciphertext data not as expected");
9045         /* Make sure memory pointed to by digest hasn't been overwritten */
9046         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9047                         orig_data,
9048                         digest,
9049                         sizeof(orig_data),
9050                         "Memory at digest ptr overwritten unexpectedly");
9051
9052         return TEST_SUCCESS;
9053 }
9054
9055 static int
9056 test_null_auth_cipher_operation(void)
9057 {
9058         struct crypto_testsuite_params *ts_params = &testsuite_params;
9059         struct crypto_unittest_params *ut_params = &unittest_params;
9060         uint8_t *digest;
9061
9062         /* Generate test mbuf data */
9063         ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9064                         catch_22_quote, QUOTE_512_BYTES, 0);
9065
9066         /* create a pointer for digest, but don't expect anything to be written
9067          * here in a NULL auth algo so no mbuf append done.
9068          */
9069         digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9070                                 QUOTE_512_BYTES);
9071         /* prefill the memory pointed to by digest */
9072         memcpy(digest, orig_data, sizeof(orig_data));
9073
9074         /* Setup Cipher Parameters */
9075         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9076         ut_params->cipher_xform.next = NULL;
9077
9078         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9079         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9080
9081         /* Setup HMAC Parameters */
9082         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9083         ut_params->auth_xform.next = &ut_params->cipher_xform;
9084
9085         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9086         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9087
9088         ut_params->sess = rte_cryptodev_sym_session_create(
9089                         ts_params->session_mpool);
9090
9091         /* Create Crypto session*/
9092         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9093                         ut_params->sess, &ut_params->cipher_xform,
9094                         ts_params->session_priv_mpool);
9095         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9096
9097         /* Generate Crypto op data structure */
9098         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9099                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9100         TEST_ASSERT_NOT_NULL(ut_params->op,
9101                         "Failed to allocate symmetric crypto operation struct");
9102
9103         /* Set crypto operation data parameters */
9104         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9105
9106         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9107
9108         sym_op->m_src = ut_params->ibuf;
9109
9110         sym_op->cipher.data.offset = 0;
9111         sym_op->cipher.data.length = QUOTE_512_BYTES;
9112
9113         sym_op->auth.data.offset = 0;
9114         sym_op->auth.data.length = QUOTE_512_BYTES;
9115         sym_op->auth.digest.data = digest;
9116         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9117                                         QUOTE_512_BYTES);
9118
9119         /* Process crypto operation */
9120         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9121                         ut_params->op);
9122         TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9123
9124         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9125                         "crypto operation processing failed");
9126
9127         /* Validate obuf */
9128         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9129                         rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9130                         catch_22_quote,
9131                         QUOTE_512_BYTES,
9132                         "Ciphertext data not as expected");
9133         /* Make sure memory pointed to by digest hasn't been overwritten */
9134         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9135                         orig_data,
9136                         digest,
9137                         sizeof(orig_data),
9138                         "Memory at digest ptr overwritten unexpectedly");
9139
9140         return TEST_SUCCESS;
9141 }
9142
9143
9144 static int
9145 test_null_invalid_operation(void)
9146 {
9147         struct crypto_testsuite_params *ts_params = &testsuite_params;
9148         struct crypto_unittest_params *ut_params = &unittest_params;
9149         int ret;
9150
9151         /* Setup Cipher Parameters */
9152         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9153         ut_params->cipher_xform.next = NULL;
9154
9155         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9156         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9157
9158         ut_params->sess = rte_cryptodev_sym_session_create(
9159                         ts_params->session_mpool);
9160
9161         /* Create Crypto session*/
9162         ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9163                         ut_params->sess, &ut_params->cipher_xform,
9164                         ts_params->session_priv_mpool);
9165         TEST_ASSERT(ret < 0,
9166                         "Session creation succeeded unexpectedly");
9167
9168
9169         /* Setup HMAC Parameters */
9170         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9171         ut_params->auth_xform.next = NULL;
9172
9173         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9174         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9175
9176         ut_params->sess = rte_cryptodev_sym_session_create(
9177                         ts_params->session_mpool);
9178
9179         /* Create Crypto session*/
9180         ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9181                         ut_params->sess, &ut_params->auth_xform,
9182                         ts_params->session_priv_mpool);
9183         TEST_ASSERT(ret < 0,
9184                         "Session creation succeeded unexpectedly");
9185
9186         return TEST_SUCCESS;
9187 }
9188
9189
9190 #define NULL_BURST_LENGTH (32)
9191
9192 static int
9193 test_null_burst_operation(void)
9194 {
9195         struct crypto_testsuite_params *ts_params = &testsuite_params;
9196         struct crypto_unittest_params *ut_params = &unittest_params;
9197
9198         unsigned i, burst_len = NULL_BURST_LENGTH;
9199
9200         struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9201         struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9202
9203         /* Setup Cipher Parameters */
9204         ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9205         ut_params->cipher_xform.next = &ut_params->auth_xform;
9206
9207         ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9208         ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9209
9210         /* Setup HMAC Parameters */
9211         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9212         ut_params->auth_xform.next = NULL;
9213
9214         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9215         ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9216
9217         ut_params->sess = rte_cryptodev_sym_session_create(
9218                         ts_params->session_mpool);
9219
9220         /* Create Crypto session*/
9221         rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9222                         ut_params->sess, &ut_params->cipher_xform,
9223                         ts_params->session_priv_mpool);
9224         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9225
9226         TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9227                         RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9228                         burst_len, "failed to generate burst of crypto ops");
9229
9230         /* Generate an operation for each mbuf in burst */
9231         for (i = 0; i < burst_len; i++) {
9232                 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9233
9234                 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9235
9236                 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
9237                                 sizeof(unsigned));
9238                 *data = i;
9239
9240                 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
9241
9242                 burst[i]->sym->m_src = m;
9243         }
9244
9245         /* Process crypto operation */
9246         TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
9247                         0, burst, burst_len),
9248                         burst_len,
9249                         "Error enqueuing burst");
9250
9251         TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
9252                         0, burst_dequeued, burst_len),
9253                         burst_len,
9254                         "Error dequeuing burst");
9255
9256
9257         for (i = 0; i < burst_len; i++) {
9258                 TEST_ASSERT_EQUAL(
9259                         *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
9260                         *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
9261                                         uint32_t *),
9262                         "data not as expected");
9263
9264                 rte_pktmbuf_free(burst[i]->sym->m_src);
9265                 rte_crypto_op_free(burst[i]);
9266         }
9267
9268         return TEST_SUCCESS;
9269 }
9270
9271 static void
9272 generate_gmac_large_plaintext(uint8_t *data)
9273 {
9274         uint16_t i;
9275
9276         for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
9277                 memcpy(&data[i], &data[0], 32);
9278 }
9279
9280 static int
9281 create_gmac_operation(enum rte_crypto_auth_operation op,
9282                 const struct gmac_test_data *tdata)
9283 {
9284         struct crypto_testsuite_params *ts_params = &testsuite_params;
9285         struct crypto_unittest_params *ut_params = &unittest_params;
9286         struct rte_crypto_sym_op *sym_op;
9287
9288         uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9289
9290         /* Generate Crypto op data structure */
9291         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9292                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9293         TEST_ASSERT_NOT_NULL(ut_params->op,
9294                         "Failed to allocate symmetric crypto operation struct");
9295
9296         sym_op = ut_params->op->sym;
9297
9298         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9299                         ut_params->ibuf, tdata->gmac_tag.len);
9300         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9301                         "no room to append digest");
9302
9303         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9304                         ut_params->ibuf, plaintext_pad_len);
9305
9306         if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9307                 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
9308                                 tdata->gmac_tag.len);
9309                 debug_hexdump(stdout, "digest:",
9310                                 sym_op->auth.digest.data,
9311                                 tdata->gmac_tag.len);
9312         }
9313
9314         uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
9315                         uint8_t *, IV_OFFSET);
9316
9317         rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
9318
9319         debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
9320
9321         sym_op->cipher.data.length = 0;
9322         sym_op->cipher.data.offset = 0;
9323
9324         sym_op->auth.data.offset = 0;
9325         sym_op->auth.data.length = tdata->plaintext.len;
9326
9327         return 0;
9328 }
9329
9330 static int create_gmac_session(uint8_t dev_id,
9331                 const struct gmac_test_data *tdata,
9332                 enum rte_crypto_auth_operation auth_op)
9333 {
9334         uint8_t auth_key[tdata->key.len];
9335
9336         struct crypto_testsuite_params *ts_params = &testsuite_params;
9337         struct crypto_unittest_params *ut_params = &unittest_params;
9338
9339         memcpy(auth_key, tdata->key.data, tdata->key.len);
9340
9341         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9342         ut_params->auth_xform.next = NULL;
9343
9344         ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
9345         ut_params->auth_xform.auth.op = auth_op;
9346         ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
9347         ut_params->auth_xform.auth.key.length = tdata->key.len;
9348         ut_params->auth_xform.auth.key.data = auth_key;
9349         ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9350         ut_params->auth_xform.auth.iv.length = tdata->iv.len;
9351
9352
9353         ut_params->sess = rte_cryptodev_sym_session_create(
9354                         ts_params->session_mpool);
9355
9356         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9357                         &ut_params->auth_xform,
9358                         ts_params->session_priv_mpool);
9359
9360         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9361
9362         return 0;
9363 }
9364
9365 static int
9366 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
9367 {
9368         struct crypto_testsuite_params *ts_params = &testsuite_params;
9369         struct crypto_unittest_params *ut_params = &unittest_params;
9370
9371         int retval;
9372
9373         uint8_t *auth_tag, *plaintext;
9374         uint16_t plaintext_pad_len;
9375
9376         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9377                               "No GMAC length in the source data");
9378
9379         retval = create_gmac_session(ts_params->valid_devs[0],
9380                         tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
9381
9382         if (retval < 0)
9383                 return retval;
9384
9385         if (tdata->plaintext.len > MBUF_SIZE)
9386                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9387         else
9388                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9389         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9390                         "Failed to allocate input buffer in mempool");
9391
9392         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9393                         rte_pktmbuf_tailroom(ut_params->ibuf));
9394
9395         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9396         /*
9397          * Runtime generate the large plain text instead of use hard code
9398          * plain text vector. It is done to avoid create huge source file
9399          * with the test vector.
9400          */
9401         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9402                 generate_gmac_large_plaintext(tdata->plaintext.data);
9403
9404         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9405                                 plaintext_pad_len);
9406         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9407
9408         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9409         debug_hexdump(stdout, "plaintext:", plaintext,
9410                         tdata->plaintext.len);
9411
9412         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
9413                         tdata);
9414
9415         if (retval < 0)
9416                 return retval;
9417
9418         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9419
9420         ut_params->op->sym->m_src = ut_params->ibuf;
9421
9422         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9423                         ut_params->op), "failed to process sym crypto op");
9424
9425         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9426                         "crypto op processing failed");
9427
9428         if (ut_params->op->sym->m_dst) {
9429                 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9430                                 uint8_t *, plaintext_pad_len);
9431         } else {
9432                 auth_tag = plaintext + plaintext_pad_len;
9433         }
9434
9435         debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
9436
9437         TEST_ASSERT_BUFFERS_ARE_EQUAL(
9438                         auth_tag,
9439                         tdata->gmac_tag.data,
9440                         tdata->gmac_tag.len,
9441                         "GMAC Generated auth tag not as expected");
9442
9443         return 0;
9444 }
9445
9446 static int
9447 test_AES_GMAC_authentication_test_case_1(void)
9448 {
9449         return test_AES_GMAC_authentication(&gmac_test_case_1);
9450 }
9451
9452 static int
9453 test_AES_GMAC_authentication_test_case_2(void)
9454 {
9455         return test_AES_GMAC_authentication(&gmac_test_case_2);
9456 }
9457
9458 static int
9459 test_AES_GMAC_authentication_test_case_3(void)
9460 {
9461         return test_AES_GMAC_authentication(&gmac_test_case_3);
9462 }
9463
9464 static int
9465 test_AES_GMAC_authentication_test_case_4(void)
9466 {
9467         return test_AES_GMAC_authentication(&gmac_test_case_4);
9468 }
9469
9470 static int
9471 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
9472 {
9473         struct crypto_testsuite_params *ts_params = &testsuite_params;
9474         struct crypto_unittest_params *ut_params = &unittest_params;
9475         int retval;
9476         uint32_t plaintext_pad_len;
9477         uint8_t *plaintext;
9478
9479         TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
9480                               "No GMAC length in the source data");
9481
9482         retval = create_gmac_session(ts_params->valid_devs[0],
9483                         tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
9484
9485         if (retval < 0)
9486                 return retval;
9487
9488         if (tdata->plaintext.len > MBUF_SIZE)
9489                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
9490         else
9491                 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9492         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9493                         "Failed to allocate input buffer in mempool");
9494
9495         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9496                         rte_pktmbuf_tailroom(ut_params->ibuf));
9497
9498         plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9499
9500         /*
9501          * Runtime generate the large plain text instead of use hard code
9502          * plain text vector. It is done to avoid create huge source file
9503          * with the test vector.
9504          */
9505         if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
9506                 generate_gmac_large_plaintext(tdata->plaintext.data);
9507
9508         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9509                                 plaintext_pad_len);
9510         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
9511
9512         memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
9513         debug_hexdump(stdout, "plaintext:", plaintext,
9514                         tdata->plaintext.len);
9515
9516         retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
9517                         tdata);
9518
9519         if (retval < 0)
9520                 return retval;
9521
9522         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9523
9524         ut_params->op->sym->m_src = ut_params->ibuf;
9525
9526         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9527                         ut_params->op), "failed to process sym crypto op");
9528
9529         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9530                         "crypto op processing failed");
9531
9532         return 0;
9533
9534 }
9535
9536 static int
9537 test_AES_GMAC_authentication_verify_test_case_1(void)
9538 {
9539         return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
9540 }
9541
9542 static int
9543 test_AES_GMAC_authentication_verify_test_case_2(void)
9544 {
9545         return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
9546 }
9547
9548 static int
9549 test_AES_GMAC_authentication_verify_test_case_3(void)
9550 {
9551         return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
9552 }
9553
9554 static int
9555 test_AES_GMAC_authentication_verify_test_case_4(void)
9556 {
9557         return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
9558 }
9559
9560 struct test_crypto_vector {
9561         enum rte_crypto_cipher_algorithm crypto_algo;
9562
9563         struct {
9564                 uint8_t data[64];
9565                 unsigned int len;
9566         } cipher_key;
9567
9568         struct {
9569                 uint8_t data[64];
9570                 unsigned int len;
9571         } iv;
9572
9573         struct {
9574                 const uint8_t *data;
9575                 unsigned int len;
9576         } plaintext;
9577
9578         struct {
9579                 const uint8_t *data;
9580                 unsigned int len;
9581         } ciphertext;
9582
9583         enum rte_crypto_auth_algorithm auth_algo;
9584
9585         struct {
9586                 uint8_t data[128];
9587                 unsigned int len;
9588         } auth_key;
9589
9590         struct {
9591                 const uint8_t *data;
9592                 unsigned int len;
9593         } aad;
9594
9595         struct {
9596                 uint8_t data[128];
9597                 unsigned int len;
9598         } digest;
9599 };
9600
9601 static const struct test_crypto_vector
9602 hmac_sha1_test_crypto_vector = {
9603         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9604         .plaintext = {
9605                 .data = plaintext_hash,
9606                 .len = 512
9607         },
9608         .auth_key = {
9609                 .data = {
9610                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9611                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9612                         0xDE, 0xF4, 0xDE, 0xAD
9613                 },
9614                 .len = 20
9615         },
9616         .digest = {
9617                 .data = {
9618                         0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
9619                         0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
9620                         0x3F, 0x91, 0x64, 0x59
9621                 },
9622                 .len = 20
9623         }
9624 };
9625
9626 static const struct test_crypto_vector
9627 aes128_gmac_test_vector = {
9628         .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
9629         .plaintext = {
9630                 .data = plaintext_hash,
9631                 .len = 512
9632         },
9633         .iv = {
9634                 .data = {
9635                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9636                         0x08, 0x09, 0x0A, 0x0B
9637                 },
9638                 .len = 12
9639         },
9640         .auth_key = {
9641                 .data = {
9642                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9643                         0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
9644                 },
9645                 .len = 16
9646         },
9647         .digest = {
9648                 .data = {
9649                         0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
9650                         0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
9651                 },
9652                 .len = 16
9653         }
9654 };
9655
9656 static const struct test_crypto_vector
9657 aes128cbc_hmac_sha1_test_vector = {
9658         .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
9659         .cipher_key = {
9660                 .data = {
9661                         0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
9662                         0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
9663                 },
9664                 .len = 16
9665         },
9666         .iv = {
9667                 .data = {
9668                         0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
9669                         0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
9670                 },
9671                 .len = 16
9672         },
9673         .plaintext = {
9674                 .data = plaintext_hash,
9675                 .len = 512
9676         },
9677         .ciphertext = {
9678                 .data = ciphertext512_aes128cbc,
9679                 .len = 512
9680         },
9681         .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
9682         .auth_key = {
9683                 .data = {
9684                         0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
9685                         0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
9686                         0xDE, 0xF4, 0xDE, 0xAD
9687                 },
9688                 .len = 20
9689         },
9690         .digest = {
9691                 .data = {
9692                         0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
9693                         0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
9694                         0x18, 0x8C, 0x1D, 0x32
9695                 },
9696                 .len = 20
9697         }
9698 };
9699
9700 static void
9701 data_corruption(uint8_t *data)
9702 {
9703         data[0] += 1;
9704 }
9705
9706 static void
9707 tag_corruption(uint8_t *data, unsigned int tag_offset)
9708 {
9709         data[tag_offset] += 1;
9710 }
9711
9712 static int
9713 create_auth_session(struct crypto_unittest_params *ut_params,
9714                 uint8_t dev_id,
9715                 const struct test_crypto_vector *reference,
9716                 enum rte_crypto_auth_operation auth_op)
9717 {
9718         struct crypto_testsuite_params *ts_params = &testsuite_params;
9719         uint8_t auth_key[reference->auth_key.len + 1];
9720
9721         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9722
9723         /* Setup Authentication Parameters */
9724         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9725         ut_params->auth_xform.auth.op = auth_op;
9726         ut_params->auth_xform.next = NULL;
9727         ut_params->auth_xform.auth.algo = reference->auth_algo;
9728         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9729         ut_params->auth_xform.auth.key.data = auth_key;
9730         ut_params->auth_xform.auth.digest_length = reference->digest.len;
9731
9732         /* Create Crypto session*/
9733         ut_params->sess = rte_cryptodev_sym_session_create(
9734                         ts_params->session_mpool);
9735
9736         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9737                                 &ut_params->auth_xform,
9738                                 ts_params->session_priv_mpool);
9739
9740         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9741
9742         return 0;
9743 }
9744
9745 static int
9746 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
9747                 uint8_t dev_id,
9748                 const struct test_crypto_vector *reference,
9749                 enum rte_crypto_auth_operation auth_op,
9750                 enum rte_crypto_cipher_operation cipher_op)
9751 {
9752         struct crypto_testsuite_params *ts_params = &testsuite_params;
9753         uint8_t cipher_key[reference->cipher_key.len + 1];
9754         uint8_t auth_key[reference->auth_key.len + 1];
9755
9756         memcpy(cipher_key, reference->cipher_key.data,
9757                         reference->cipher_key.len);
9758         memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
9759
9760         /* Setup Authentication Parameters */
9761         ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9762         ut_params->auth_xform.auth.op = auth_op;
9763         ut_params->auth_xform.auth.algo = reference->auth_algo;
9764         ut_params->auth_xform.auth.key.length = reference->auth_key.len;
9765         ut_params->auth_xform.auth.key.data = auth_key;
9766         ut_params->auth_xform.auth.digest_length = reference->digest.len;
9767
9768         if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
9769                 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
9770                 ut_params->auth_xform.auth.iv.length = reference->iv.len;
9771         } else {
9772                 ut_params->auth_xform.next = &ut_params->cipher_xform;
9773
9774                 /* Setup Cipher Parameters */
9775                 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9776                 ut_params->cipher_xform.next = NULL;
9777                 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
9778                 ut_params->cipher_xform.cipher.op = cipher_op;
9779                 ut_params->cipher_xform.cipher.key.data = cipher_key;
9780                 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
9781                 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
9782                 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
9783         }
9784
9785         /* Create Crypto session*/
9786         ut_params->sess = rte_cryptodev_sym_session_create(
9787                         ts_params->session_mpool);
9788
9789         rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
9790                                 &ut_params->auth_xform,
9791                                 ts_params->session_priv_mpool);
9792
9793         TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9794
9795         return 0;
9796 }
9797
9798 static int
9799 create_auth_operation(struct crypto_testsuite_params *ts_params,
9800                 struct crypto_unittest_params *ut_params,
9801                 const struct test_crypto_vector *reference,
9802                 unsigned int auth_generate)
9803 {
9804         /* Generate Crypto op data structure */
9805         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9806                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9807         TEST_ASSERT_NOT_NULL(ut_params->op,
9808                         "Failed to allocate pktmbuf offload");
9809
9810         /* Set crypto operation data parameters */
9811         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9812
9813         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9814
9815         /* set crypto operation source mbuf */
9816         sym_op->m_src = ut_params->ibuf;
9817
9818         /* digest */
9819         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9820                         ut_params->ibuf, reference->digest.len);
9821
9822         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9823                         "no room to append auth tag");
9824
9825         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9826                         ut_params->ibuf, reference->plaintext.len);
9827
9828         if (auth_generate)
9829                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9830         else
9831                 memcpy(sym_op->auth.digest.data,
9832                                 reference->digest.data,
9833                                 reference->digest.len);
9834
9835         debug_hexdump(stdout, "digest:",
9836                         sym_op->auth.digest.data,
9837                         reference->digest.len);
9838
9839         sym_op->auth.data.length = reference->plaintext.len;
9840         sym_op->auth.data.offset = 0;
9841
9842         return 0;
9843 }
9844
9845 static int
9846 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
9847                 struct crypto_unittest_params *ut_params,
9848                 const struct test_crypto_vector *reference,
9849                 unsigned int auth_generate)
9850 {
9851         /* Generate Crypto op data structure */
9852         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9853                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9854         TEST_ASSERT_NOT_NULL(ut_params->op,
9855                         "Failed to allocate pktmbuf offload");
9856
9857         /* Set crypto operation data parameters */
9858         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9859
9860         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9861
9862         /* set crypto operation source mbuf */
9863         sym_op->m_src = ut_params->ibuf;
9864
9865         /* digest */
9866         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9867                         ut_params->ibuf, reference->digest.len);
9868
9869         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9870                         "no room to append auth tag");
9871
9872         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9873                         ut_params->ibuf, reference->ciphertext.len);
9874
9875         if (auth_generate)
9876                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9877         else
9878                 memcpy(sym_op->auth.digest.data,
9879                                 reference->digest.data,
9880                                 reference->digest.len);
9881
9882         debug_hexdump(stdout, "digest:",
9883                         sym_op->auth.digest.data,
9884                         reference->digest.len);
9885
9886         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9887                         reference->iv.data, reference->iv.len);
9888
9889         sym_op->cipher.data.length = 0;
9890         sym_op->cipher.data.offset = 0;
9891
9892         sym_op->auth.data.length = reference->plaintext.len;
9893         sym_op->auth.data.offset = 0;
9894
9895         return 0;
9896 }
9897
9898 static int
9899 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
9900                 struct crypto_unittest_params *ut_params,
9901                 const struct test_crypto_vector *reference,
9902                 unsigned int auth_generate)
9903 {
9904         /* Generate Crypto op data structure */
9905         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9906                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9907         TEST_ASSERT_NOT_NULL(ut_params->op,
9908                         "Failed to allocate pktmbuf offload");
9909
9910         /* Set crypto operation data parameters */
9911         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9912
9913         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9914
9915         /* set crypto operation source mbuf */
9916         sym_op->m_src = ut_params->ibuf;
9917
9918         /* digest */
9919         sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9920                         ut_params->ibuf, reference->digest.len);
9921
9922         TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9923                         "no room to append auth tag");
9924
9925         sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9926                         ut_params->ibuf, reference->ciphertext.len);
9927
9928         if (auth_generate)
9929                 memset(sym_op->auth.digest.data, 0, reference->digest.len);
9930         else
9931                 memcpy(sym_op->auth.digest.data,
9932                                 reference->digest.data,
9933                                 reference->digest.len);
9934
9935         debug_hexdump(stdout, "digest:",
9936                         sym_op->auth.digest.data,
9937                         reference->digest.len);
9938
9939         rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
9940                         reference->iv.data, reference->iv.len);
9941
9942         sym_op->cipher.data.length = reference->ciphertext.len;
9943         sym_op->cipher.data.offset = 0;
9944
9945         sym_op->auth.data.length = reference->ciphertext.len;
9946         sym_op->auth.data.offset = 0;
9947
9948         return 0;
9949 }
9950
9951 static int
9952 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9953                 struct crypto_unittest_params *ut_params,
9954                 const struct test_crypto_vector *reference)
9955 {
9956         return create_auth_operation(ts_params, ut_params, reference, 0);
9957 }
9958
9959 static int
9960 create_auth_verify_GMAC_operation(
9961                 struct crypto_testsuite_params *ts_params,
9962                 struct crypto_unittest_params *ut_params,
9963                 const struct test_crypto_vector *reference)
9964 {
9965         return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
9966 }
9967
9968 static int
9969 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
9970                 struct crypto_unittest_params *ut_params,
9971                 const struct test_crypto_vector *reference)
9972 {
9973         return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
9974 }
9975
9976 static int
9977 test_authentication_verify_fail_when_data_corruption(
9978                 struct crypto_testsuite_params *ts_params,
9979                 struct crypto_unittest_params *ut_params,
9980                 const struct test_crypto_vector *reference,
9981                 unsigned int data_corrupted)
9982 {
9983         int retval;
9984
9985         uint8_t *plaintext;
9986
9987         /* Create session */
9988         retval = create_auth_session(ut_params,
9989                         ts_params->valid_devs[0],
9990                         reference,
9991                         RTE_CRYPTO_AUTH_OP_VERIFY);
9992         if (retval < 0)
9993                 return retval;
9994
9995         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9996         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
9997                         "Failed to allocate input buffer in mempool");
9998
9999         /* clear mbuf payload */
10000         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10001                         rte_pktmbuf_tailroom(ut_params->ibuf));
10002
10003         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10004                         reference->plaintext.len);
10005         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10006         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10007
10008         debug_hexdump(stdout, "plaintext:", plaintext,
10009                 reference->plaintext.len);
10010
10011         /* Create operation */
10012         retval = create_auth_verify_operation(ts_params, ut_params, reference);
10013
10014         if (retval < 0)
10015                 return retval;
10016
10017         if (data_corrupted)
10018                 data_corruption(plaintext);
10019         else
10020                 tag_corruption(plaintext, reference->plaintext.len);
10021
10022         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10023                         ut_params->op);
10024         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10025         TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10026                         RTE_CRYPTO_OP_STATUS_SUCCESS,
10027                         "authentication not failed");
10028
10029         ut_params->obuf = ut_params->op->sym->m_src;
10030         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10031
10032         return 0;
10033 }
10034
10035 static int
10036 test_authentication_verify_GMAC_fail_when_corruption(
10037                 struct crypto_testsuite_params *ts_params,
10038                 struct crypto_unittest_params *ut_params,
10039                 const struct test_crypto_vector *reference,
10040                 unsigned int data_corrupted)
10041 {
10042         int retval;
10043         uint8_t *plaintext;
10044
10045         /* Create session */
10046         retval = create_auth_cipher_session(ut_params,
10047                         ts_params->valid_devs[0],
10048                         reference,
10049                         RTE_CRYPTO_AUTH_OP_VERIFY,
10050                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
10051         if (retval < 0)
10052                 return retval;
10053
10054         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10055         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10056                         "Failed to allocate input buffer in mempool");
10057
10058         /* clear mbuf payload */
10059         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10060                         rte_pktmbuf_tailroom(ut_params->ibuf));
10061
10062         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10063                         reference->plaintext.len);
10064         TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10065         memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10066
10067         debug_hexdump(stdout, "plaintext:", plaintext,
10068                 reference->plaintext.len);
10069
10070         /* Create operation */
10071         retval = create_auth_verify_GMAC_operation(ts_params,
10072                         ut_params,
10073                         reference);
10074
10075         if (retval < 0)
10076                 return retval;
10077
10078         if (data_corrupted)
10079                 data_corruption(plaintext);
10080         else
10081                 tag_corruption(plaintext, reference->aad.len);
10082
10083         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10084                         ut_params->op);
10085         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10086         TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10087                         RTE_CRYPTO_OP_STATUS_SUCCESS,
10088                         "authentication not failed");
10089
10090         ut_params->obuf = ut_params->op->sym->m_src;
10091         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10092
10093         return 0;
10094 }
10095
10096 static int
10097 test_authenticated_decryption_fail_when_corruption(
10098                 struct crypto_testsuite_params *ts_params,
10099                 struct crypto_unittest_params *ut_params,
10100                 const struct test_crypto_vector *reference,
10101                 unsigned int data_corrupted)
10102 {
10103         int retval;
10104
10105         uint8_t *ciphertext;
10106
10107         /* Create session */
10108         retval = create_auth_cipher_session(ut_params,
10109                         ts_params->valid_devs[0],
10110                         reference,
10111                         RTE_CRYPTO_AUTH_OP_VERIFY,
10112                         RTE_CRYPTO_CIPHER_OP_DECRYPT);
10113         if (retval < 0)
10114                 return retval;
10115
10116         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10117         TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10118                         "Failed to allocate input buffer in mempool");
10119
10120         /* clear mbuf payload */
10121         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10122                         rte_pktmbuf_tailroom(ut_params->ibuf));
10123
10124         ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10125                         reference->ciphertext.len);
10126         TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10127         memcpy(ciphertext, reference->ciphertext.data,
10128                         reference->ciphertext.len);
10129
10130         /* Create operation */
10131         retval = create_cipher_auth_verify_operation(ts_params,
10132                         ut_params,
10133                         reference);
10134
10135         if (retval < 0)
10136                 return retval;
10137
10138         if (data_corrupted)
10139                 data_corruption(ciphertext);
10140         else
10141                 tag_corruption(ciphertext, reference->ciphertext.len);
10142
10143         ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10144                         ut_params->op);
10145
10146         TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
10147         TEST_ASSERT_NOT_EQUAL(ut_params->op->status,
10148                         RTE_CRYPTO_OP_STATUS_SUCCESS,
10149                         "authentication not failed");
10150
10151         ut_params->obuf = ut_params->op->sym->m_src;
10152         TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
10153
10154         return 0;
10155 }
10156
10157 static int
10158 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
10159                 const struct aead_test_data *tdata,
10160                 void *digest_mem, uint64_t digest_phys)
10161 {
10162         struct crypto_testsuite_params *ts_params = &testsuite_params;
10163         struct crypto_unittest_params *ut_params = &unittest_params;
10164
10165         const unsigned int auth_tag_len = tdata->auth_tag.len;
10166         const unsigned int iv_len = tdata->iv.len;
10167         unsigned int aad_len = tdata->aad.len;
10168
10169         /* Generate Crypto op data structure */
10170         ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10171                         RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10172         TEST_ASSERT_NOT_NULL(ut_params->op,
10173                 "Failed to allocate symmetric crypto operation struct");
10174
10175         struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10176
10177         sym_op->aead.digest.data = digest_mem;
10178
10179         TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
10180                         "no room to append digest");
10181
10182         sym_op->aead.digest.phys_addr = digest_phys;
10183
10184         if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
10185                 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
10186                                 auth_tag_len);
10187                 debug_hexdump(stdout, "digest:",
10188                                 sym_op->aead.digest.data,
10189                                 auth_tag_len);
10190         }
10191
10192         /* Append aad data */
10193         if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
10194                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10195                                 uint8_t *, IV_OFFSET);
10196
10197                 /* Copy IV 1 byte after the IV pointer, according to the API */
10198                 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
10199
10200                 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
10201
10202                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10203                                 ut_params->ibuf, aad_len);
10204                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10205                                 "no room to prepend aad");
10206                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10207                                 ut_params->ibuf);
10208
10209                 memset(sym_op->aead.aad.data, 0, aad_len);
10210                 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
10211                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10212
10213                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10214                 debug_hexdump(stdout, "aad:",
10215                                 sym_op->aead.aad.data, aad_len);
10216         } else {
10217                 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10218                                 uint8_t *, IV_OFFSET);
10219
10220                 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
10221
10222                 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
10223                                 ut_params->ibuf, aad_len);
10224                 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
10225                                 "no room to prepend aad");
10226                 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
10227                                 ut_params->ibuf);
10228
10229                 memset(sym_op->aead.aad.data, 0, aad_len);
10230                 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
10231
10232                 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
10233                 debug_hexdump(stdout, "aad:",
10234                                 sym_op->aead.aad.data, aad_len);
10235         }
10236
10237         sym_op->aead.data.length = tdata->plaintext.len;
10238         sym_op->aead.data.offset = aad_len;
10239
10240         return 0;
10241 }
10242
10243 #define SGL_MAX_NO      16
10244
10245 static int
10246 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
10247                 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
10248 {
10249         struct crypto_testsuite_params *ts_params = &testsuite_params;
10250         struct crypto_unittest_params *ut_params = &unittest_params;
10251         struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
10252         int retval;
10253         int to_trn = 0;
10254         int to_trn_tbl[SGL_MAX_NO];
10255         int segs = 1;
10256         unsigned int trn_data = 0;
10257         uint8_t *plaintext, *ciphertext, *auth_tag;
10258
10259         if (fragsz > tdata->plaintext.len)
10260                 fragsz = tdata->plaintext.len;
10261
10262         uint16_t plaintext_len = fragsz;
10263         uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
10264
10265         if (fragsz_oop > tdata->plaintext.len)
10266                 frag_size_oop = tdata->plaintext.len;
10267
10268         int ecx = 0;
10269         void *digest_mem = NULL;
10270
10271         uint32_t prepend_len = tdata->aad.len;
10272
10273         if (tdata->plaintext.len % fragsz != 0) {
10274                 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
10275                         return 1;
10276         }       else {
10277                 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
10278                         return 1;
10279         }
10280
10281         /*
10282          * For out-op-place we need to alloc another mbuf
10283          */
10284         if (oop) {
10285                 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10286                 rte_pktmbuf_append(ut_params->obuf,
10287                                 frag_size_oop + prepend_len);
10288                 buf_oop = ut_params->obuf;
10289         }
10290
10291         /* Create AEAD session */
10292         retval = create_aead_session(ts_params->valid_devs[0],
10293                         tdata->algo,
10294                         RTE_CRYPTO_AEAD_OP_ENCRYPT,
10295                         tdata->key.data, tdata->key.len,
10296                         tdata->aad.len, tdata->auth_tag.len,
10297                         tdata->iv.len);
10298         if (retval < 0)
10299                 return retval;
10300
10301         ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10302
10303         /* clear mbuf payload */
10304         memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10305                         rte_pktmbuf_tailroom(ut_params->ibuf));
10306
10307         plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10308                         plaintext_len);
10309
10310         memcpy(plaintext, tdata->plaintext.data, plaintext_len);
10311
10312         trn_data += plaintext_len;
10313
10314         buf = ut_params->ibuf;
10315
10316         /*
10317          * Loop until no more fragments
10318          */
10319
10320         while (trn_data < tdata->plaintext.len) {
10321                 ++segs;
10322                 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
10323                                 (tdata->plaintext.len - trn_data) : fragsz;
10324
10325                 to_trn_tbl[ecx++] = to_trn;
10326
10327                 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10328                 buf = buf->next;
10329
10330                 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
10331                                 rte_pktmbuf_tailroom(buf));
10332
10333                 /* OOP */
10334                 if (oop && !fragsz_oop) {
10335                         buf_last_oop = buf_oop->next =
10336                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
10337                         buf_oop = buf_oop->next;
10338                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10339                                         0, rte_pktmbuf_tailroom(buf_oop));
10340                         rte_pktmbuf_append(buf_oop, to_trn);
10341                 }
10342
10343                 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
10344                                 to_trn);
10345
10346                 memcpy(plaintext, tdata->plaintext.data + trn_data,
10347                                 to_trn);
10348                 trn_data += to_trn;
10349                 if (trn_data  == tdata->plaintext.len) {
10350                         if (oop) {
10351                                 if (!fragsz_oop)
10352                                         digest_mem = rte_pktmbuf_append(buf_oop,
10353                                                 tdata->auth_tag.len);
10354                         } else
10355                                 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
10356                                         tdata->auth_tag.len);
10357                 }
10358         }
10359
10360         uint64_t digest_phys = 0;
10361
10362         ut_params->ibuf->nb_segs = segs;
10363
10364         segs = 1;
10365         if (fragsz_oop && oop) {
10366                 to_trn = 0;
10367                 ecx = 0;
10368
10369                 if (frag_size_oop == tdata->plaintext.len) {
10370                         digest_mem = rte_pktmbuf_append(ut_params->obuf,
10371                                 tdata->auth_tag.len);
10372
10373                         digest_phys = rte_pktmbuf_iova_offset(
10374                                         ut_params->obuf,
10375                                         tdata->plaintext.len + prepend_len);
10376                 }
10377
10378                 trn_data = frag_size_oop;
10379                 while (trn_data < tdata->plaintext.len) {
10380                         ++segs;
10381                         to_trn =
10382                                 (tdata->plaintext.len - trn_data <
10383                                                 frag_size_oop) ?
10384                                 (tdata->plaintext.len - trn_data) :
10385                                                 frag_size_oop;
10386
10387                         to_trn_tbl[ecx++] = to_trn;
10388
10389                         buf_last_oop = buf_oop->next =
10390                                         rte_pktmbuf_alloc(ts_params->mbuf_pool);
10391                         buf_oop = buf_oop->next;
10392                         memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
10393                                         0, rte_pktmbuf_tailroom(buf_oop));
10394                         rte_pktmbuf_append(buf_oop, to_trn);
10395
10396                         trn_data += to_trn;
10397
10398                         if (trn_data  == tdata->plaintext.len) {
10399                                 digest_mem = rte_pktmbuf_append(buf_oop,
10400                                         tdata->auth_tag.len);
10401                         }
10402                 }
10403
10404                 ut_params->obuf->nb_segs = segs;
10405         }
10406
10407         /*
10408          * Place digest at the end of the last buffer
10409          */
10410         if (!digest_phys)
10411                 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
10412         if (oop && buf_last_oop)
10413                 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
10414
10415         if (!digest_mem && !oop) {
10416                 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10417                                 + tdata->auth_tag.len);
10418                 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
10419                                 tdata->plaintext.len);
10420         }
10421
10422         /* Create AEAD operation */
10423         retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
10424                         tdata, digest_mem, digest_phys);
10425
10426         if (retval < 0)
10427                 return retval;
10428
10429         rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10430
10431         ut_params->op->sym->m_src = ut_params->ibuf;
10432         if (oop)
10433                 ut_params->op->sym->m_dst = ut_params->obuf;
10434
10435         /* Process crypto operation */
10436         TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10437                         ut_params->op), "failed to process sym crypto op");
10438
10439         TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10440                         "crypto op processing failed");
10441
10442
10443         ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
10444                         uint8_t *, prepend_len);
10445         if (oop) {
10446                 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10447                                 uint8_t *, prepend_len);
10448         }
10449
10450         if (fragsz_oop)
10451                 fragsz = fragsz_oop;
10452
10453         TEST_ASSERT_BUFFERS_ARE_EQUAL(
10454                         ciphertext,
10455                         tdata->ciphertext.data,
10456                         fragsz,
10457                         "Ciphertext data not as expected");
10458
10459         buf = ut_params->op->sym->m_src->next;
10460         if (oop)
10461                 buf = ut_params->op->sym->m_dst->next;
10462
10463         unsigned int off = fragsz;
10464
10465         ecx = 0;
10466         while (buf) {
10467                 ciphertext = rte_pktmbuf_mtod(buf,
10468                                 uint8_t *);
10469
10470                 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10471                                 ciphertext,
10472                                 tdata->ciphertext.data + off,
10473                                 to_trn_tbl[ecx],
10474                                 "Ciphertext data not as expected");
10475
10476                 off += to_trn_tbl[ecx++];
10477                 buf = buf->next;
10478         }
10479
10480         auth_tag = digest_mem;
10481         TEST_ASSERT_BUFFERS_ARE_EQUAL(
10482                         auth_tag,
10483                         tdata->auth_tag.data,
10484                         tdata->auth_tag.len,
10485                         "Generated auth tag not as expected");
10486
10487         return 0;
10488 }
10489
10490 static int
10491 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
10492 {
10493         return test_authenticated_encryption_SGL(
10494                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
10495 }
10496
10497 static int
10498 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
10499 {
10500         return test_authenticated_encryption_SGL(
10501                         &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
10502 }
10503
10504 static int
10505 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
10506 {
10507         return test_authenticated_encryption_SGL(
10508                         &gcm_test_case_8, OUT_OF_PLACE, 400,
10509                         gcm_test_case_8.plaintext.len);
10510 }
10511
10512 static int
10513 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
10514 {
10515
10516         return test_authenticated_encryption_SGL(
10517                         &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
10518 }
10519
10520 static int
10521 test_authentication_verify_fail_when_data_corrupted(
10522                 struct crypto_testsuite_params *ts_params,
10523                 struct crypto_unittest_params *ut_params,
10524                 const struct test_crypto_vector *reference)
10525 {
10526         return test_authentication_verify_fail_when_data_corruption(
10527                         ts_params, ut_params, reference, 1);
10528 }
10529
10530 static int
10531 test_authentication_verify_fail_when_tag_corrupted(
10532                 struct crypto_testsuite_params *ts_params,
10533                 struct crypto_unittest_params *ut_params,
10534                 const struct test_crypto_vector *reference)
10535 {
10536         return test_authentication_verify_fail_when_data_corruption(
10537                         ts_params, ut_params, reference, 0);
10538 }
10539
10540 static int
10541 test_authentication_verify_GMAC_fail_when_data_corrupted(
10542                 struct crypto_testsuite_params *ts_params,
10543                 struct crypto_unittest_params *ut_params,
10544                 const struct test_crypto_vector *reference)
10545 {
10546         return test_authentication_verify_GMAC_fail_when_corruption(
10547                         ts_params, ut_params, reference, 1);
10548 }
10549
10550 static int
10551 test_authentication_verify_GMAC_fail_when_tag_corrupted(
10552                 struct crypto_testsuite_params *ts_params,
10553                 struct crypto_unittest_params *ut_params,
10554                 const struct test_crypto_vector *reference)
10555 {
10556         return test_authentication_verify_GMAC_fail_when_corruption(
10557                         ts_params, ut_params, reference, 0);
10558 }
10559
10560 static int
10561 test_authenticated_decryption_fail_when_data_corrupted(
10562                 struct crypto_testsuite_params *ts_params,
10563                 struct crypto_unittest_params *ut_params,
10564                 const struct test_crypto_vector *reference)
10565 {
10566         return test_authenticated_decryption_fail_when_corruption(
10567                         ts_params, ut_params, reference, 1);
10568 }
10569
10570 static int
10571 test_authenticated_decryption_fail_when_tag_corrupted(
10572                 struct crypto_testsuite_params *ts_params,
10573                 struct crypto_unittest_params *ut_params,
10574                 const struct test_crypto_vector *reference)
10575 {
10576         return test_authenticated_decryption_fail_when_corruption(
10577                         ts_params, ut_params, reference, 0);
10578 }
10579
10580 static int
10581 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
10582 {
10583         return test_authentication_verify_fail_when_data_corrupted(
10584                         &testsuite_params, &unittest_params,
10585                         &hmac_sha1_test_crypto_vector);
10586 }
10587
10588 static int
10589 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
10590 {
10591         return test_authentication_verify_fail_when_tag_corrupted(
10592                         &testsuite_params, &unittest_params,
10593                         &hmac_sha1_test_crypto_vector);
10594 }
10595
10596 static int
10597 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
10598 {
10599         return test_authentication_verify_GMAC_fail_when_data_corrupted(
10600                         &testsuite_params, &unittest_params,
10601                         &aes128_gmac_test_vector);
10602 }
10603
10604 static int
10605 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
10606 {
10607         return test_authentication_verify_GMAC_fail_when_tag_corrupted(
10608                         &testsuite_params, &unittest_params,
10609                         &aes128_gmac_test_vector);
10610 }
10611
10612 static int
10613 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
10614 {
10615         return test_authenticated_decryption_fail_when_data_corrupted(
10616                         &testsuite_params,
10617                         &unittest_params,
10618                         &aes128cbc_hmac_sha1_test_vector);
10619 }
10620
10621 static int
10622 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
10623 {
10624         return test_authenticated_decryption_fail_when_tag_corrupted(
10625                         &testsuite_params,
10626                         &unittest_params,
10627                         &aes128cbc_hmac_sha1_test_vector);
10628 }
10629
10630 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10631
10632 /* global AESNI slave IDs for the scheduler test */
10633 uint8_t aesni_ids[2];
10634
10635 static int
10636 test_scheduler_attach_slave_op(void)
10637 {
10638         struct crypto_testsuite_params *ts_params = &testsuite_params;
10639         uint8_t sched_id = ts_params->valid_devs[0];
10640         uint32_t nb_devs, i, nb_devs_attached = 0;
10641         int ret;
10642         char vdev_name[32];
10643
10644         /* create 2 AESNI_MB if necessary */
10645         nb_devs = rte_cryptodev_device_count_by_driver(
10646                         rte_cryptodev_driver_id_get(
10647                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
10648         if (nb_devs < 2) {
10649                 for (i = nb_devs; i < 2; i++) {
10650                         snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
10651                                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
10652                                         i);
10653                         ret = rte_vdev_init(vdev_name, NULL);
10654
10655                         TEST_ASSERT(ret == 0,
10656                                 "Failed to create instance %u of"
10657                                 " pmd : %s",
10658                                 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10659                 }
10660         }
10661
10662         /* attach 2 AESNI_MB cdevs */
10663         for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
10664                         i++) {
10665                 struct rte_cryptodev_info info;
10666                 unsigned int session_size;
10667
10668                 rte_cryptodev_info_get(i, &info);
10669                 if (info.driver_id != rte_cryptodev_driver_id_get(
10670                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
10671                         continue;
10672
10673                 session_size = rte_cryptodev_sym_get_private_session_size(i);
10674                 /*
10675                  * Create the session mempool again, since now there are new devices
10676                  * to use the mempool.
10677                  */
10678                 if (ts_params->session_mpool) {
10679                         rte_mempool_free(ts_params->session_mpool);
10680                         ts_params->session_mpool = NULL;
10681                 }
10682                 if (ts_params->session_priv_mpool) {
10683                         rte_mempool_free(ts_params->session_priv_mpool);
10684                         ts_params->session_priv_mpool = NULL;
10685                 }
10686
10687                 if (info.sym.max_nb_sessions != 0 &&
10688                                 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
10689                         RTE_LOG(ERR, USER1,
10690                                         "Device does not support "
10691                                         "at least %u sessions\n",
10692                                         MAX_NB_SESSIONS);
10693                         return TEST_FAILED;
10694                 }
10695                 /*
10696                  * Create mempool with maximum number of sessions,
10697                  * to include the session headers
10698                  */
10699                 if (ts_params->session_mpool == NULL) {
10700                         ts_params->session_mpool =
10701                                 rte_cryptodev_sym_session_pool_create(
10702                                                 "test_sess_mp",
10703                                                 MAX_NB_SESSIONS, 0, 0, 0,
10704                                                 SOCKET_ID_ANY);
10705                         TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
10706                                         "session mempool allocation failed");
10707                 }
10708
10709                 /*
10710                  * Create mempool with maximum number of sessions,
10711                  * to include device specific session private data
10712                  */
10713                 if (ts_params->session_priv_mpool == NULL) {
10714                         ts_params->session_priv_mpool = rte_mempool_create(
10715                                         "test_sess_mp_priv",
10716                                         MAX_NB_SESSIONS,
10717                                         session_size,
10718                                         0, 0, NULL, NULL, NULL,
10719                                         NULL, SOCKET_ID_ANY,
10720                                         0);
10721
10722                         TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
10723                                         "session mempool allocation failed");
10724                 }
10725
10726                 ts_params->qp_conf.mp_session = ts_params->session_mpool;
10727                 ts_params->qp_conf.mp_session_private =
10728                                 ts_params->session_priv_mpool;
10729
10730                 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
10731                                 (uint8_t)i);
10732
10733                 TEST_ASSERT(ret == 0,
10734                         "Failed to attach device %u of pmd : %s", i,
10735                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10736
10737                 aesni_ids[nb_devs_attached] = (uint8_t)i;
10738
10739                 nb_devs_attached++;
10740         }
10741
10742         return 0;
10743 }
10744
10745 static int
10746 test_scheduler_detach_slave_op(void)
10747 {
10748         struct crypto_testsuite_params *ts_params = &testsuite_params;
10749         uint8_t sched_id = ts_params->valid_devs[0];
10750         uint32_t i;
10751         int ret;
10752
10753         for (i = 0; i < 2; i++) {
10754                 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
10755                                 aesni_ids[i]);
10756                 TEST_ASSERT(ret == 0,
10757                         "Failed to detach device %u", aesni_ids[i]);
10758         }
10759
10760         return 0;
10761 }
10762
10763 static int
10764 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
10765 {
10766         struct crypto_testsuite_params *ts_params = &testsuite_params;
10767         uint8_t sched_id = ts_params->valid_devs[0];
10768         /* set mode */
10769         return rte_cryptodev_scheduler_mode_set(sched_id,
10770                 scheduler_mode);
10771 }
10772
10773 static int
10774 test_scheduler_mode_roundrobin_op(void)
10775 {
10776         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
10777                         0, "Failed to set roundrobin mode");
10778         return 0;
10779
10780 }
10781
10782 static int
10783 test_scheduler_mode_multicore_op(void)
10784 {
10785         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
10786                         0, "Failed to set multicore mode");
10787
10788         return 0;
10789 }
10790
10791 static int
10792 test_scheduler_mode_failover_op(void)
10793 {
10794         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
10795                         0, "Failed to set failover mode");
10796
10797         return 0;
10798 }
10799
10800 static int
10801 test_scheduler_mode_pkt_size_distr_op(void)
10802 {
10803         TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
10804                         0, "Failed to set pktsize mode");
10805
10806         return 0;
10807 }
10808
10809 static struct unit_test_suite cryptodev_scheduler_testsuite  = {
10810         .suite_name = "Crypto Device Scheduler Unit Test Suite",
10811         .setup = testsuite_setup,
10812         .teardown = testsuite_teardown,
10813         .unit_test_cases = {
10814                 /* Multi Core */
10815                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10816                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
10817                 TEST_CASE_ST(ut_setup, ut_teardown,
10818                                         test_AES_chain_scheduler_all),
10819                 TEST_CASE_ST(ut_setup, ut_teardown,
10820                                         test_AES_cipheronly_scheduler_all),
10821                 TEST_CASE_ST(ut_setup, ut_teardown,
10822                                         test_authonly_scheduler_all),
10823                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10824
10825                 /* Round Robin */
10826                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10827                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
10828                 TEST_CASE_ST(ut_setup, ut_teardown,
10829                                 test_AES_chain_scheduler_all),
10830                 TEST_CASE_ST(ut_setup, ut_teardown,
10831                                 test_AES_cipheronly_scheduler_all),
10832                 TEST_CASE_ST(ut_setup, ut_teardown,
10833                                 test_authonly_scheduler_all),
10834                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10835
10836                 /* Fail over */
10837                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10838                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
10839                 TEST_CASE_ST(ut_setup, ut_teardown,
10840                                         test_AES_chain_scheduler_all),
10841                 TEST_CASE_ST(ut_setup, ut_teardown,
10842                                         test_AES_cipheronly_scheduler_all),
10843                 TEST_CASE_ST(ut_setup, ut_teardown,
10844                                         test_authonly_scheduler_all),
10845                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10846
10847                 /* PKT SIZE */
10848                 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
10849                 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
10850                 TEST_CASE_ST(ut_setup, ut_teardown,
10851                                         test_AES_chain_scheduler_all),
10852                 TEST_CASE_ST(ut_setup, ut_teardown,
10853                                         test_AES_cipheronly_scheduler_all),
10854                 TEST_CASE_ST(ut_setup, ut_teardown,
10855                                         test_authonly_scheduler_all),
10856                 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
10857
10858                 TEST_CASES_END() /**< NULL terminate unit test array */
10859         }
10860 };
10861
10862 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
10863
10864 static struct unit_test_suite cryptodev_qat_testsuite  = {
10865         .suite_name = "Crypto QAT Unit Test Suite",
10866         .setup = testsuite_setup,
10867         .teardown = testsuite_teardown,
10868         .unit_test_cases = {
10869                 TEST_CASE_ST(ut_setup, ut_teardown,
10870                                 test_device_configure_invalid_dev_id),
10871                 TEST_CASE_ST(ut_setup, ut_teardown,
10872                                 test_device_configure_invalid_queue_pair_ids),
10873                 TEST_CASE_ST(ut_setup, ut_teardown,
10874                                 test_queue_pair_descriptor_setup),
10875                 TEST_CASE_ST(ut_setup, ut_teardown,
10876                                 test_multi_session),
10877
10878                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
10879                 TEST_CASE_ST(ut_setup, ut_teardown,
10880                                                 test_AES_cipheronly_qat_all),
10881                 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
10882                 TEST_CASE_ST(ut_setup, ut_teardown,
10883                                                 test_3DES_cipheronly_qat_all),
10884                 TEST_CASE_ST(ut_setup, ut_teardown,
10885                                                 test_DES_cipheronly_qat_all),
10886                 TEST_CASE_ST(ut_setup, ut_teardown,
10887                                                 test_AES_docsis_qat_all),
10888                 TEST_CASE_ST(ut_setup, ut_teardown,
10889                                                 test_DES_docsis_qat_all),
10890                 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
10891                 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
10892
10893                 /** AES CCM Authenticated Encryption 128 bits key */
10894                 TEST_CASE_ST(ut_setup, ut_teardown,
10895                         test_AES_CCM_authenticated_encryption_test_case_128_1),
10896                 TEST_CASE_ST(ut_setup, ut_teardown,
10897                         test_AES_CCM_authenticated_encryption_test_case_128_2),
10898                 TEST_CASE_ST(ut_setup, ut_teardown,
10899                         test_AES_CCM_authenticated_encryption_test_case_128_3),
10900
10901                 /** AES CCM Authenticated Decryption 128 bits key*/
10902                 TEST_CASE_ST(ut_setup, ut_teardown,
10903                         test_AES_CCM_authenticated_decryption_test_case_128_1),
10904                 TEST_CASE_ST(ut_setup, ut_teardown,
10905                         test_AES_CCM_authenticated_decryption_test_case_128_2),
10906                 TEST_CASE_ST(ut_setup, ut_teardown,
10907                         test_AES_CCM_authenticated_decryption_test_case_128_3),
10908
10909                 /** AES GCM Authenticated Encryption */
10910                 TEST_CASE_ST(ut_setup, ut_teardown,
10911                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10912                 TEST_CASE_ST(ut_setup, ut_teardown,
10913                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10914                 TEST_CASE_ST(ut_setup, ut_teardown,
10915                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10916                 TEST_CASE_ST(ut_setup, ut_teardown,
10917                         test_AES_GCM_authenticated_encryption_test_case_1),
10918                 TEST_CASE_ST(ut_setup, ut_teardown,
10919                         test_AES_GCM_authenticated_encryption_test_case_2),
10920                 TEST_CASE_ST(ut_setup, ut_teardown,
10921                         test_AES_GCM_authenticated_encryption_test_case_3),
10922                 TEST_CASE_ST(ut_setup, ut_teardown,
10923                         test_AES_GCM_authenticated_encryption_test_case_4),
10924                 TEST_CASE_ST(ut_setup, ut_teardown,
10925                         test_AES_GCM_authenticated_encryption_test_case_5),
10926                 TEST_CASE_ST(ut_setup, ut_teardown,
10927                         test_AES_GCM_authenticated_encryption_test_case_6),
10928                 TEST_CASE_ST(ut_setup, ut_teardown,
10929                         test_AES_GCM_authenticated_encryption_test_case_7),
10930
10931                 /** AES GCM Authenticated Decryption */
10932                 TEST_CASE_ST(ut_setup, ut_teardown,
10933                         test_AES_GCM_authenticated_decryption_test_case_1),
10934                 TEST_CASE_ST(ut_setup, ut_teardown,
10935                         test_AES_GCM_authenticated_decryption_test_case_2),
10936                 TEST_CASE_ST(ut_setup, ut_teardown,
10937                         test_AES_GCM_authenticated_decryption_test_case_3),
10938                 TEST_CASE_ST(ut_setup, ut_teardown,
10939                         test_AES_GCM_authenticated_decryption_test_case_4),
10940                 TEST_CASE_ST(ut_setup, ut_teardown,
10941                         test_AES_GCM_authenticated_decryption_test_case_5),
10942                 TEST_CASE_ST(ut_setup, ut_teardown,
10943                         test_AES_GCM_authenticated_decryption_test_case_6),
10944                 TEST_CASE_ST(ut_setup, ut_teardown,
10945                         test_AES_GCM_authenticated_decryption_test_case_7),
10946
10947                 /** AES GCM Authenticated Encryption 192 bits key */
10948                 TEST_CASE_ST(ut_setup, ut_teardown,
10949                         test_AES_GCM_auth_encryption_test_case_192_1),
10950                 TEST_CASE_ST(ut_setup, ut_teardown,
10951                         test_AES_GCM_auth_encryption_test_case_192_2),
10952                 TEST_CASE_ST(ut_setup, ut_teardown,
10953                         test_AES_GCM_auth_encryption_test_case_192_3),
10954                 TEST_CASE_ST(ut_setup, ut_teardown,
10955                         test_AES_GCM_auth_encryption_test_case_192_4),
10956                 TEST_CASE_ST(ut_setup, ut_teardown,
10957                         test_AES_GCM_auth_encryption_test_case_192_5),
10958                 TEST_CASE_ST(ut_setup, ut_teardown,
10959                         test_AES_GCM_auth_encryption_test_case_192_6),
10960                 TEST_CASE_ST(ut_setup, ut_teardown,
10961                         test_AES_GCM_auth_encryption_test_case_192_7),
10962
10963                 /** AES GCM Authenticated Decryption 192 bits key */
10964                 TEST_CASE_ST(ut_setup, ut_teardown,
10965                         test_AES_GCM_auth_decryption_test_case_192_1),
10966                 TEST_CASE_ST(ut_setup, ut_teardown,
10967                         test_AES_GCM_auth_decryption_test_case_192_2),
10968                 TEST_CASE_ST(ut_setup, ut_teardown,
10969                         test_AES_GCM_auth_decryption_test_case_192_3),
10970                 TEST_CASE_ST(ut_setup, ut_teardown,
10971                         test_AES_GCM_auth_decryption_test_case_192_4),
10972                 TEST_CASE_ST(ut_setup, ut_teardown,
10973                         test_AES_GCM_auth_decryption_test_case_192_5),
10974                 TEST_CASE_ST(ut_setup, ut_teardown,
10975                         test_AES_GCM_auth_decryption_test_case_192_6),
10976                 TEST_CASE_ST(ut_setup, ut_teardown,
10977                         test_AES_GCM_auth_decryption_test_case_192_7),
10978
10979                 /** AES GCM Authenticated Encryption 256 bits key */
10980                 TEST_CASE_ST(ut_setup, ut_teardown,
10981                         test_AES_GCM_auth_encryption_test_case_256_1),
10982                 TEST_CASE_ST(ut_setup, ut_teardown,
10983                         test_AES_GCM_auth_encryption_test_case_256_2),
10984                 TEST_CASE_ST(ut_setup, ut_teardown,
10985                         test_AES_GCM_auth_encryption_test_case_256_3),
10986                 TEST_CASE_ST(ut_setup, ut_teardown,
10987                         test_AES_GCM_auth_encryption_test_case_256_4),
10988                 TEST_CASE_ST(ut_setup, ut_teardown,
10989                         test_AES_GCM_auth_encryption_test_case_256_5),
10990                 TEST_CASE_ST(ut_setup, ut_teardown,
10991                         test_AES_GCM_auth_encryption_test_case_256_6),
10992                 TEST_CASE_ST(ut_setup, ut_teardown,
10993                         test_AES_GCM_auth_encryption_test_case_256_7),
10994
10995                 /** AES GMAC Authentication */
10996                 TEST_CASE_ST(ut_setup, ut_teardown,
10997                         test_AES_GMAC_authentication_test_case_1),
10998                 TEST_CASE_ST(ut_setup, ut_teardown,
10999                         test_AES_GMAC_authentication_verify_test_case_1),
11000                 TEST_CASE_ST(ut_setup, ut_teardown,
11001                         test_AES_GMAC_authentication_test_case_2),
11002                 TEST_CASE_ST(ut_setup, ut_teardown,
11003                         test_AES_GMAC_authentication_verify_test_case_2),
11004                 TEST_CASE_ST(ut_setup, ut_teardown,
11005                         test_AES_GMAC_authentication_test_case_3),
11006                 TEST_CASE_ST(ut_setup, ut_teardown,
11007                         test_AES_GMAC_authentication_verify_test_case_3),
11008
11009                 /** SNOW 3G encrypt only (UEA2) */
11010                 TEST_CASE_ST(ut_setup, ut_teardown,
11011                         test_snow3g_encryption_test_case_1),
11012                 TEST_CASE_ST(ut_setup, ut_teardown,
11013                         test_snow3g_encryption_test_case_2),
11014                 TEST_CASE_ST(ut_setup, ut_teardown,
11015                         test_snow3g_encryption_test_case_3),
11016                 TEST_CASE_ST(ut_setup, ut_teardown,
11017                         test_snow3g_encryption_test_case_4),
11018                 TEST_CASE_ST(ut_setup, ut_teardown,
11019                         test_snow3g_encryption_test_case_5),
11020
11021                 TEST_CASE_ST(ut_setup, ut_teardown,
11022                         test_snow3g_encryption_test_case_1_oop),
11023                 TEST_CASE_ST(ut_setup, ut_teardown,
11024                         test_snow3g_decryption_test_case_1_oop),
11025
11026                 /** SNOW 3G generate auth, then encrypt (UEA2) */
11027                 TEST_CASE_ST(ut_setup, ut_teardown,
11028                         test_snow3g_auth_cipher_test_case_1),
11029                 TEST_CASE_ST(ut_setup, ut_teardown,
11030                         test_snow3g_auth_cipher_test_case_2),
11031                 TEST_CASE_ST(ut_setup, ut_teardown,
11032                         test_snow3g_auth_cipher_test_case_2_oop),
11033                 TEST_CASE_ST(ut_setup, ut_teardown,
11034                         test_snow3g_auth_cipher_part_digest_enc),
11035                 TEST_CASE_ST(ut_setup, ut_teardown,
11036                         test_snow3g_auth_cipher_part_digest_enc_oop),
11037                 TEST_CASE_ST(ut_setup, ut_teardown,
11038                         test_snow3g_auth_cipher_test_case_3_sgl),
11039                 TEST_CASE_ST(ut_setup, ut_teardown,
11040                         test_snow3g_auth_cipher_test_case_3_oop_sgl),
11041                 TEST_CASE_ST(ut_setup, ut_teardown,
11042                         test_snow3g_auth_cipher_part_digest_enc_sgl),
11043                 TEST_CASE_ST(ut_setup, ut_teardown,
11044                         test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11045
11046                 /** SNOW 3G decrypt (UEA2), then verify auth */
11047                 TEST_CASE_ST(ut_setup, ut_teardown,
11048                         test_snow3g_auth_cipher_verify_test_case_1),
11049                 TEST_CASE_ST(ut_setup, ut_teardown,
11050                         test_snow3g_auth_cipher_verify_test_case_2),
11051                 TEST_CASE_ST(ut_setup, ut_teardown,
11052                         test_snow3g_auth_cipher_verify_test_case_2_oop),
11053                 TEST_CASE_ST(ut_setup, ut_teardown,
11054                         test_snow3g_auth_cipher_verify_part_digest_enc),
11055                 TEST_CASE_ST(ut_setup, ut_teardown,
11056                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11057                 TEST_CASE_ST(ut_setup, ut_teardown,
11058                         test_snow3g_auth_cipher_verify_test_case_3_sgl),
11059                 TEST_CASE_ST(ut_setup, ut_teardown,
11060                         test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11061                 TEST_CASE_ST(ut_setup, ut_teardown,
11062                         test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11063                 TEST_CASE_ST(ut_setup, ut_teardown,
11064                         test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11065
11066                 /** SNOW 3G decrypt only (UEA2) */
11067                 TEST_CASE_ST(ut_setup, ut_teardown,
11068                         test_snow3g_decryption_test_case_1),
11069                 TEST_CASE_ST(ut_setup, ut_teardown,
11070                         test_snow3g_decryption_test_case_2),
11071                 TEST_CASE_ST(ut_setup, ut_teardown,
11072                         test_snow3g_decryption_test_case_3),
11073                 TEST_CASE_ST(ut_setup, ut_teardown,
11074                         test_snow3g_decryption_test_case_4),
11075                 TEST_CASE_ST(ut_setup, ut_teardown,
11076                         test_snow3g_decryption_test_case_5),
11077                 TEST_CASE_ST(ut_setup, ut_teardown,
11078                         test_snow3g_decryption_with_digest_test_case_1),
11079                 TEST_CASE_ST(ut_setup, ut_teardown,
11080                         test_snow3g_hash_generate_test_case_1),
11081                 TEST_CASE_ST(ut_setup, ut_teardown,
11082                         test_snow3g_hash_generate_test_case_2),
11083                 TEST_CASE_ST(ut_setup, ut_teardown,
11084                         test_snow3g_hash_generate_test_case_3),
11085                 TEST_CASE_ST(ut_setup, ut_teardown,
11086                         test_snow3g_hash_verify_test_case_1),
11087                 TEST_CASE_ST(ut_setup, ut_teardown,
11088                         test_snow3g_hash_verify_test_case_2),
11089                 TEST_CASE_ST(ut_setup, ut_teardown,
11090                         test_snow3g_hash_verify_test_case_3),
11091                 TEST_CASE_ST(ut_setup, ut_teardown,
11092                         test_snow3g_cipher_auth_test_case_1),
11093                 TEST_CASE_ST(ut_setup, ut_teardown,
11094                         test_snow3g_auth_cipher_with_digest_test_case_1),
11095
11096                 /** ZUC encrypt only (EEA3) */
11097                 TEST_CASE_ST(ut_setup, ut_teardown,
11098                         test_zuc_encryption_test_case_1),
11099                 TEST_CASE_ST(ut_setup, ut_teardown,
11100                         test_zuc_encryption_test_case_2),
11101                 TEST_CASE_ST(ut_setup, ut_teardown,
11102                         test_zuc_encryption_test_case_3),
11103                 TEST_CASE_ST(ut_setup, ut_teardown,
11104                         test_zuc_encryption_test_case_4),
11105                 TEST_CASE_ST(ut_setup, ut_teardown,
11106                         test_zuc_encryption_test_case_5),
11107
11108                 /** ZUC authenticate (EIA3) */
11109                 TEST_CASE_ST(ut_setup, ut_teardown,
11110                         test_zuc_hash_generate_test_case_6),
11111                 TEST_CASE_ST(ut_setup, ut_teardown,
11112                         test_zuc_hash_generate_test_case_7),
11113                 TEST_CASE_ST(ut_setup, ut_teardown,
11114                         test_zuc_hash_generate_test_case_8),
11115
11116                 /** ZUC alg-chain (EEA3/EIA3) */
11117                 TEST_CASE_ST(ut_setup, ut_teardown,
11118                         test_zuc_cipher_auth_test_case_1),
11119                 TEST_CASE_ST(ut_setup, ut_teardown,
11120                         test_zuc_cipher_auth_test_case_2),
11121
11122                 /** ZUC generate auth, then encrypt (EEA3) */
11123                 TEST_CASE_ST(ut_setup, ut_teardown,
11124                         test_zuc_auth_cipher_test_case_1),
11125                 TEST_CASE_ST(ut_setup, ut_teardown,
11126                         test_zuc_auth_cipher_test_case_1_oop),
11127                 TEST_CASE_ST(ut_setup, ut_teardown,
11128                         test_zuc_auth_cipher_test_case_1_sgl),
11129                 TEST_CASE_ST(ut_setup, ut_teardown,
11130                         test_zuc_auth_cipher_test_case_1_oop_sgl),
11131
11132                 /** ZUC decrypt (EEA3), then verify auth */
11133                 TEST_CASE_ST(ut_setup, ut_teardown,
11134                         test_zuc_auth_cipher_verify_test_case_1),
11135                 TEST_CASE_ST(ut_setup, ut_teardown,
11136                         test_zuc_auth_cipher_verify_test_case_1_oop),
11137                 TEST_CASE_ST(ut_setup, ut_teardown,
11138                         test_zuc_auth_cipher_verify_test_case_1_sgl),
11139                 TEST_CASE_ST(ut_setup, ut_teardown,
11140                         test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
11141
11142                 /** HMAC_MD5 Authentication */
11143                 TEST_CASE_ST(ut_setup, ut_teardown,
11144                         test_MD5_HMAC_generate_case_1),
11145                 TEST_CASE_ST(ut_setup, ut_teardown,
11146                         test_MD5_HMAC_verify_case_1),
11147                 TEST_CASE_ST(ut_setup, ut_teardown,
11148                         test_MD5_HMAC_generate_case_2),
11149                 TEST_CASE_ST(ut_setup, ut_teardown,
11150                         test_MD5_HMAC_verify_case_2),
11151
11152                 /** NULL algo tests done in chain_all,
11153                  * cipheronly and authonly suites
11154                  */
11155
11156                 /** KASUMI tests */
11157                 TEST_CASE_ST(ut_setup, ut_teardown,
11158                         test_kasumi_hash_generate_test_case_1),
11159                 TEST_CASE_ST(ut_setup, ut_teardown,
11160                         test_kasumi_hash_generate_test_case_2),
11161                 TEST_CASE_ST(ut_setup, ut_teardown,
11162                         test_kasumi_hash_generate_test_case_3),
11163                 TEST_CASE_ST(ut_setup, ut_teardown,
11164                         test_kasumi_hash_generate_test_case_4),
11165                 TEST_CASE_ST(ut_setup, ut_teardown,
11166                         test_kasumi_hash_generate_test_case_5),
11167                 TEST_CASE_ST(ut_setup, ut_teardown,
11168                         test_kasumi_hash_generate_test_case_6),
11169
11170                 TEST_CASE_ST(ut_setup, ut_teardown,
11171                         test_kasumi_hash_verify_test_case_1),
11172                 TEST_CASE_ST(ut_setup, ut_teardown,
11173                         test_kasumi_hash_verify_test_case_2),
11174                 TEST_CASE_ST(ut_setup, ut_teardown,
11175                         test_kasumi_hash_verify_test_case_3),
11176                 TEST_CASE_ST(ut_setup, ut_teardown,
11177                         test_kasumi_hash_verify_test_case_4),
11178                 TEST_CASE_ST(ut_setup, ut_teardown,
11179                         test_kasumi_hash_verify_test_case_5),
11180
11181                 TEST_CASE_ST(ut_setup, ut_teardown,
11182                         test_kasumi_encryption_test_case_1),
11183                 TEST_CASE_ST(ut_setup, ut_teardown,
11184                         test_kasumi_encryption_test_case_3),
11185                 TEST_CASE_ST(ut_setup, ut_teardown,
11186                         test_kasumi_cipher_auth_test_case_1),
11187
11188                 /** KASUMI generate auth, then encrypt (F8) */
11189                 TEST_CASE_ST(ut_setup, ut_teardown,
11190                         test_kasumi_auth_cipher_test_case_1),
11191                 TEST_CASE_ST(ut_setup, ut_teardown,
11192                         test_kasumi_auth_cipher_test_case_2),
11193                 TEST_CASE_ST(ut_setup, ut_teardown,
11194                         test_kasumi_auth_cipher_test_case_2_oop),
11195                 TEST_CASE_ST(ut_setup, ut_teardown,
11196                         test_kasumi_auth_cipher_test_case_2_sgl),
11197                 TEST_CASE_ST(ut_setup, ut_teardown,
11198                         test_kasumi_auth_cipher_test_case_2_oop_sgl),
11199
11200                 /** KASUMI decrypt (F8), then verify auth */
11201                 TEST_CASE_ST(ut_setup, ut_teardown,
11202                         test_kasumi_auth_cipher_verify_test_case_1),
11203                 TEST_CASE_ST(ut_setup, ut_teardown,
11204                         test_kasumi_auth_cipher_verify_test_case_2),
11205                 TEST_CASE_ST(ut_setup, ut_teardown,
11206                         test_kasumi_auth_cipher_verify_test_case_2_oop),
11207                 TEST_CASE_ST(ut_setup, ut_teardown,
11208                         test_kasumi_auth_cipher_verify_test_case_2_sgl),
11209                 TEST_CASE_ST(ut_setup, ut_teardown,
11210                         test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11211
11212                 /** Negative tests */
11213                 TEST_CASE_ST(ut_setup, ut_teardown,
11214                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
11215                 TEST_CASE_ST(ut_setup, ut_teardown,
11216                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11217                 TEST_CASE_ST(ut_setup, ut_teardown,
11218                         authentication_verify_AES128_GMAC_fail_data_corrupt),
11219                 TEST_CASE_ST(ut_setup, ut_teardown,
11220                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
11221                 TEST_CASE_ST(ut_setup, ut_teardown,
11222                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11223                 TEST_CASE_ST(ut_setup, ut_teardown,
11224                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11225
11226                 TEST_CASES_END() /**< NULL terminate unit test array */
11227         }
11228 };
11229
11230 static struct unit_test_suite cryptodev_virtio_testsuite = {
11231         .suite_name = "Crypto VIRTIO Unit Test Suite",
11232         .setup = testsuite_setup,
11233         .teardown = testsuite_teardown,
11234         .unit_test_cases = {
11235                 TEST_CASE_ST(ut_setup, ut_teardown,
11236                                 test_AES_cipheronly_virtio_all),
11237
11238                 TEST_CASES_END() /**< NULL terminate unit test array */
11239         }
11240 };
11241
11242 static struct unit_test_suite cryptodev_aesni_mb_testsuite  = {
11243         .suite_name = "Crypto Device AESNI MB Unit Test Suite",
11244         .setup = testsuite_setup,
11245         .teardown = testsuite_teardown,
11246         .unit_test_cases = {
11247 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
11248                 TEST_CASE_ST(ut_setup, ut_teardown,
11249                         test_AES_GCM_authenticated_encryption_test_case_1),
11250                 TEST_CASE_ST(ut_setup, ut_teardown,
11251                         test_AES_GCM_authenticated_encryption_test_case_2),
11252                 TEST_CASE_ST(ut_setup, ut_teardown,
11253                         test_AES_GCM_authenticated_encryption_test_case_3),
11254                 TEST_CASE_ST(ut_setup, ut_teardown,
11255                         test_AES_GCM_authenticated_encryption_test_case_4),
11256                 TEST_CASE_ST(ut_setup, ut_teardown,
11257                         test_AES_GCM_authenticated_encryption_test_case_5),
11258                 TEST_CASE_ST(ut_setup, ut_teardown,
11259                         test_AES_GCM_authenticated_encryption_test_case_6),
11260                 TEST_CASE_ST(ut_setup, ut_teardown,
11261                         test_AES_GCM_authenticated_encryption_test_case_7),
11262
11263                 /** AES GCM Authenticated Decryption */
11264                 TEST_CASE_ST(ut_setup, ut_teardown,
11265                         test_AES_GCM_authenticated_decryption_test_case_1),
11266                 TEST_CASE_ST(ut_setup, ut_teardown,
11267                         test_AES_GCM_authenticated_decryption_test_case_2),
11268                 TEST_CASE_ST(ut_setup, ut_teardown,
11269                         test_AES_GCM_authenticated_decryption_test_case_3),
11270                 TEST_CASE_ST(ut_setup, ut_teardown,
11271                         test_AES_GCM_authenticated_decryption_test_case_4),
11272                 TEST_CASE_ST(ut_setup, ut_teardown,
11273                         test_AES_GCM_authenticated_decryption_test_case_5),
11274                 TEST_CASE_ST(ut_setup, ut_teardown,
11275                         test_AES_GCM_authenticated_decryption_test_case_6),
11276                 TEST_CASE_ST(ut_setup, ut_teardown,
11277                         test_AES_GCM_authenticated_decryption_test_case_7),
11278
11279                 /** AES GCM Authenticated Encryption 192 bits key */
11280                 TEST_CASE_ST(ut_setup, ut_teardown,
11281                         test_AES_GCM_auth_encryption_test_case_192_1),
11282                 TEST_CASE_ST(ut_setup, ut_teardown,
11283                         test_AES_GCM_auth_encryption_test_case_192_2),
11284                 TEST_CASE_ST(ut_setup, ut_teardown,
11285                         test_AES_GCM_auth_encryption_test_case_192_3),
11286                 TEST_CASE_ST(ut_setup, ut_teardown,
11287                         test_AES_GCM_auth_encryption_test_case_192_4),
11288                 TEST_CASE_ST(ut_setup, ut_teardown,
11289                         test_AES_GCM_auth_encryption_test_case_192_5),
11290                 TEST_CASE_ST(ut_setup, ut_teardown,
11291                         test_AES_GCM_auth_encryption_test_case_192_6),
11292                 TEST_CASE_ST(ut_setup, ut_teardown,
11293                         test_AES_GCM_auth_encryption_test_case_192_7),
11294
11295                 /** AES GCM Authenticated Decryption 192 bits key */
11296                 TEST_CASE_ST(ut_setup, ut_teardown,
11297                         test_AES_GCM_auth_decryption_test_case_192_1),
11298                 TEST_CASE_ST(ut_setup, ut_teardown,
11299                         test_AES_GCM_auth_decryption_test_case_192_2),
11300                 TEST_CASE_ST(ut_setup, ut_teardown,
11301                         test_AES_GCM_auth_decryption_test_case_192_3),
11302                 TEST_CASE_ST(ut_setup, ut_teardown,
11303                         test_AES_GCM_auth_decryption_test_case_192_4),
11304                 TEST_CASE_ST(ut_setup, ut_teardown,
11305                         test_AES_GCM_auth_decryption_test_case_192_5),
11306                 TEST_CASE_ST(ut_setup, ut_teardown,
11307                         test_AES_GCM_auth_decryption_test_case_192_6),
11308                 TEST_CASE_ST(ut_setup, ut_teardown,
11309                         test_AES_GCM_auth_decryption_test_case_192_7),
11310
11311                 /** AES GCM Authenticated Encryption 256 bits key */
11312                 TEST_CASE_ST(ut_setup, ut_teardown,
11313                         test_AES_GCM_auth_encryption_test_case_256_1),
11314                 TEST_CASE_ST(ut_setup, ut_teardown,
11315                         test_AES_GCM_auth_encryption_test_case_256_2),
11316                 TEST_CASE_ST(ut_setup, ut_teardown,
11317                         test_AES_GCM_auth_encryption_test_case_256_3),
11318                 TEST_CASE_ST(ut_setup, ut_teardown,
11319                         test_AES_GCM_auth_encryption_test_case_256_4),
11320                 TEST_CASE_ST(ut_setup, ut_teardown,
11321                         test_AES_GCM_auth_encryption_test_case_256_5),
11322                 TEST_CASE_ST(ut_setup, ut_teardown,
11323                         test_AES_GCM_auth_encryption_test_case_256_6),
11324                 TEST_CASE_ST(ut_setup, ut_teardown,
11325                         test_AES_GCM_auth_encryption_test_case_256_7),
11326
11327                 /** AES GCM Authenticated Decryption 256 bits key */
11328                 TEST_CASE_ST(ut_setup, ut_teardown,
11329                         test_AES_GCM_auth_decryption_test_case_256_1),
11330                 TEST_CASE_ST(ut_setup, ut_teardown,
11331                         test_AES_GCM_auth_decryption_test_case_256_2),
11332                 TEST_CASE_ST(ut_setup, ut_teardown,
11333                         test_AES_GCM_auth_decryption_test_case_256_3),
11334                 TEST_CASE_ST(ut_setup, ut_teardown,
11335                         test_AES_GCM_auth_decryption_test_case_256_4),
11336                 TEST_CASE_ST(ut_setup, ut_teardown,
11337                         test_AES_GCM_auth_decryption_test_case_256_5),
11338                 TEST_CASE_ST(ut_setup, ut_teardown,
11339                         test_AES_GCM_auth_decryption_test_case_256_6),
11340                 TEST_CASE_ST(ut_setup, ut_teardown,
11341                         test_AES_GCM_auth_decryption_test_case_256_7),
11342
11343                 /** AES GCM Authenticated Encryption big aad size */
11344                 TEST_CASE_ST(ut_setup, ut_teardown,
11345                         test_AES_GCM_auth_encryption_test_case_aad_1),
11346                 TEST_CASE_ST(ut_setup, ut_teardown,
11347                         test_AES_GCM_auth_encryption_test_case_aad_2),
11348
11349                 /** AES GCM Authenticated Decryption big aad size */
11350                 TEST_CASE_ST(ut_setup, ut_teardown,
11351                         test_AES_GCM_auth_decryption_test_case_aad_1),
11352                 TEST_CASE_ST(ut_setup, ut_teardown,
11353                         test_AES_GCM_auth_decryption_test_case_aad_2),
11354
11355                 /** Session-less tests */
11356                 TEST_CASE_ST(ut_setup, ut_teardown,
11357                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11358                 TEST_CASE_ST(ut_setup, ut_teardown,
11359                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11360
11361                 /** AES GMAC Authentication */
11362                 TEST_CASE_ST(ut_setup, ut_teardown,
11363                         test_AES_GMAC_authentication_test_case_1),
11364                 TEST_CASE_ST(ut_setup, ut_teardown,
11365                         test_AES_GMAC_authentication_verify_test_case_1),
11366                 TEST_CASE_ST(ut_setup, ut_teardown,
11367                         test_AES_GMAC_authentication_test_case_2),
11368                 TEST_CASE_ST(ut_setup, ut_teardown,
11369                         test_AES_GMAC_authentication_verify_test_case_2),
11370                 TEST_CASE_ST(ut_setup, ut_teardown,
11371                         test_AES_GMAC_authentication_test_case_3),
11372                 TEST_CASE_ST(ut_setup, ut_teardown,
11373                         test_AES_GMAC_authentication_verify_test_case_3),
11374 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
11375
11376                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
11377                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
11378                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
11379                 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
11380                 TEST_CASE_ST(ut_setup, ut_teardown,
11381                                                 test_DES_cipheronly_mb_all),
11382                 TEST_CASE_ST(ut_setup, ut_teardown,
11383                                                 test_DES_docsis_mb_all),
11384                 TEST_CASE_ST(ut_setup, ut_teardown,
11385                                                 test_3DES_cipheronly_mb_all),
11386                 TEST_CASE_ST(ut_setup, ut_teardown,
11387                         test_AES_CCM_authenticated_encryption_test_case_128_1),
11388                 TEST_CASE_ST(ut_setup, ut_teardown,
11389                         test_AES_CCM_authenticated_decryption_test_case_128_1),
11390                 TEST_CASE_ST(ut_setup, ut_teardown,
11391                         test_AES_CCM_authenticated_encryption_test_case_128_2),
11392                 TEST_CASE_ST(ut_setup, ut_teardown,
11393                         test_AES_CCM_authenticated_decryption_test_case_128_2),
11394                 TEST_CASE_ST(ut_setup, ut_teardown,
11395                         test_AES_CCM_authenticated_encryption_test_case_128_3),
11396                 TEST_CASE_ST(ut_setup, ut_teardown,
11397                         test_AES_CCM_authenticated_decryption_test_case_128_3),
11398
11399                 TEST_CASES_END() /**< NULL terminate unit test array */
11400         }
11401 };
11402
11403 static struct unit_test_suite cryptodev_openssl_testsuite  = {
11404         .suite_name = "Crypto Device OPENSSL Unit Test Suite",
11405         .setup = testsuite_setup,
11406         .teardown = testsuite_teardown,
11407         .unit_test_cases = {
11408                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
11409                 TEST_CASE_ST(ut_setup, ut_teardown,
11410                                 test_multi_session_random_usage),
11411                 TEST_CASE_ST(ut_setup, ut_teardown,
11412                                 test_AES_chain_openssl_all),
11413                 TEST_CASE_ST(ut_setup, ut_teardown,
11414                                 test_AES_cipheronly_openssl_all),
11415                 TEST_CASE_ST(ut_setup, ut_teardown,
11416                                 test_3DES_chain_openssl_all),
11417                 TEST_CASE_ST(ut_setup, ut_teardown,
11418                                 test_3DES_cipheronly_openssl_all),
11419                 TEST_CASE_ST(ut_setup, ut_teardown,
11420                                 test_DES_cipheronly_openssl_all),
11421                 TEST_CASE_ST(ut_setup, ut_teardown,
11422                                 test_DES_docsis_openssl_all),
11423                 TEST_CASE_ST(ut_setup, ut_teardown,
11424                                 test_authonly_openssl_all),
11425
11426                 /** AES GCM Authenticated Encryption */
11427                 TEST_CASE_ST(ut_setup, ut_teardown,
11428                         test_AES_GCM_authenticated_encryption_test_case_1),
11429                 TEST_CASE_ST(ut_setup, ut_teardown,
11430                         test_AES_GCM_authenticated_encryption_test_case_2),
11431                 TEST_CASE_ST(ut_setup, ut_teardown,
11432                         test_AES_GCM_authenticated_encryption_test_case_3),
11433                 TEST_CASE_ST(ut_setup, ut_teardown,
11434                         test_AES_GCM_authenticated_encryption_test_case_4),
11435                 TEST_CASE_ST(ut_setup, ut_teardown,
11436                         test_AES_GCM_authenticated_encryption_test_case_5),
11437                 TEST_CASE_ST(ut_setup, ut_teardown,
11438                         test_AES_GCM_authenticated_encryption_test_case_6),
11439                 TEST_CASE_ST(ut_setup, ut_teardown,
11440                         test_AES_GCM_authenticated_encryption_test_case_7),
11441
11442                 /** AES GCM Authenticated Decryption */
11443                 TEST_CASE_ST(ut_setup, ut_teardown,
11444                         test_AES_GCM_authenticated_decryption_test_case_1),
11445                 TEST_CASE_ST(ut_setup, ut_teardown,
11446                         test_AES_GCM_authenticated_decryption_test_case_2),
11447                 TEST_CASE_ST(ut_setup, ut_teardown,
11448                         test_AES_GCM_authenticated_decryption_test_case_3),
11449                 TEST_CASE_ST(ut_setup, ut_teardown,
11450                         test_AES_GCM_authenticated_decryption_test_case_4),
11451                 TEST_CASE_ST(ut_setup, ut_teardown,
11452                         test_AES_GCM_authenticated_decryption_test_case_5),
11453                 TEST_CASE_ST(ut_setup, ut_teardown,
11454                         test_AES_GCM_authenticated_decryption_test_case_6),
11455                 TEST_CASE_ST(ut_setup, ut_teardown,
11456                         test_AES_GCM_authenticated_decryption_test_case_7),
11457
11458
11459                 /** AES GCM Authenticated Encryption 192 bits key */
11460                 TEST_CASE_ST(ut_setup, ut_teardown,
11461                         test_AES_GCM_auth_encryption_test_case_192_1),
11462                 TEST_CASE_ST(ut_setup, ut_teardown,
11463                         test_AES_GCM_auth_encryption_test_case_192_2),
11464                 TEST_CASE_ST(ut_setup, ut_teardown,
11465                         test_AES_GCM_auth_encryption_test_case_192_3),
11466                 TEST_CASE_ST(ut_setup, ut_teardown,
11467                         test_AES_GCM_auth_encryption_test_case_192_4),
11468                 TEST_CASE_ST(ut_setup, ut_teardown,
11469                         test_AES_GCM_auth_encryption_test_case_192_5),
11470                 TEST_CASE_ST(ut_setup, ut_teardown,
11471                         test_AES_GCM_auth_encryption_test_case_192_6),
11472                 TEST_CASE_ST(ut_setup, ut_teardown,
11473                         test_AES_GCM_auth_encryption_test_case_192_7),
11474
11475                 /** AES GCM Authenticated Decryption 192 bits key */
11476                 TEST_CASE_ST(ut_setup, ut_teardown,
11477                         test_AES_GCM_auth_decryption_test_case_192_1),
11478                 TEST_CASE_ST(ut_setup, ut_teardown,
11479                         test_AES_GCM_auth_decryption_test_case_192_2),
11480                 TEST_CASE_ST(ut_setup, ut_teardown,
11481                         test_AES_GCM_auth_decryption_test_case_192_3),
11482                 TEST_CASE_ST(ut_setup, ut_teardown,
11483                         test_AES_GCM_auth_decryption_test_case_192_4),
11484                 TEST_CASE_ST(ut_setup, ut_teardown,
11485                         test_AES_GCM_auth_decryption_test_case_192_5),
11486                 TEST_CASE_ST(ut_setup, ut_teardown,
11487                         test_AES_GCM_auth_decryption_test_case_192_6),
11488                 TEST_CASE_ST(ut_setup, ut_teardown,
11489                         test_AES_GCM_auth_decryption_test_case_192_7),
11490
11491                 /** AES GCM Authenticated Encryption 256 bits key */
11492                 TEST_CASE_ST(ut_setup, ut_teardown,
11493                         test_AES_GCM_auth_encryption_test_case_256_1),
11494                 TEST_CASE_ST(ut_setup, ut_teardown,
11495                         test_AES_GCM_auth_encryption_test_case_256_2),
11496                 TEST_CASE_ST(ut_setup, ut_teardown,
11497                         test_AES_GCM_auth_encryption_test_case_256_3),
11498                 TEST_CASE_ST(ut_setup, ut_teardown,
11499                         test_AES_GCM_auth_encryption_test_case_256_4),
11500                 TEST_CASE_ST(ut_setup, ut_teardown,
11501                         test_AES_GCM_auth_encryption_test_case_256_5),
11502                 TEST_CASE_ST(ut_setup, ut_teardown,
11503                         test_AES_GCM_auth_encryption_test_case_256_6),
11504                 TEST_CASE_ST(ut_setup, ut_teardown,
11505                         test_AES_GCM_auth_encryption_test_case_256_7),
11506
11507                 /** AES GCM Authenticated Decryption 256 bits key */
11508                 TEST_CASE_ST(ut_setup, ut_teardown,
11509                         test_AES_GCM_auth_decryption_test_case_256_1),
11510                 TEST_CASE_ST(ut_setup, ut_teardown,
11511                         test_AES_GCM_auth_decryption_test_case_256_2),
11512                 TEST_CASE_ST(ut_setup, ut_teardown,
11513                         test_AES_GCM_auth_decryption_test_case_256_3),
11514                 TEST_CASE_ST(ut_setup, ut_teardown,
11515                         test_AES_GCM_auth_decryption_test_case_256_4),
11516                 TEST_CASE_ST(ut_setup, ut_teardown,
11517                         test_AES_GCM_auth_decryption_test_case_256_5),
11518                 TEST_CASE_ST(ut_setup, ut_teardown,
11519                         test_AES_GCM_auth_decryption_test_case_256_6),
11520                 TEST_CASE_ST(ut_setup, ut_teardown,
11521                         test_AES_GCM_auth_decryption_test_case_256_7),
11522
11523                 /** AES GMAC Authentication */
11524                 TEST_CASE_ST(ut_setup, ut_teardown,
11525                         test_AES_GMAC_authentication_test_case_1),
11526                 TEST_CASE_ST(ut_setup, ut_teardown,
11527                         test_AES_GMAC_authentication_verify_test_case_1),
11528                 TEST_CASE_ST(ut_setup, ut_teardown,
11529                         test_AES_GMAC_authentication_test_case_2),
11530                 TEST_CASE_ST(ut_setup, ut_teardown,
11531                         test_AES_GMAC_authentication_verify_test_case_2),
11532                 TEST_CASE_ST(ut_setup, ut_teardown,
11533                         test_AES_GMAC_authentication_test_case_3),
11534                 TEST_CASE_ST(ut_setup, ut_teardown,
11535                         test_AES_GMAC_authentication_verify_test_case_3),
11536                 TEST_CASE_ST(ut_setup, ut_teardown,
11537                         test_AES_GMAC_authentication_test_case_4),
11538                 TEST_CASE_ST(ut_setup, ut_teardown,
11539                         test_AES_GMAC_authentication_verify_test_case_4),
11540
11541                 /** AES CCM Authenticated Encryption 128 bits key */
11542                 TEST_CASE_ST(ut_setup, ut_teardown,
11543                         test_AES_CCM_authenticated_encryption_test_case_128_1),
11544                 TEST_CASE_ST(ut_setup, ut_teardown,
11545                         test_AES_CCM_authenticated_encryption_test_case_128_2),
11546                 TEST_CASE_ST(ut_setup, ut_teardown,
11547                         test_AES_CCM_authenticated_encryption_test_case_128_3),
11548
11549                 /** AES CCM Authenticated Decryption 128 bits key*/
11550                 TEST_CASE_ST(ut_setup, ut_teardown,
11551                         test_AES_CCM_authenticated_decryption_test_case_128_1),
11552                 TEST_CASE_ST(ut_setup, ut_teardown,
11553                         test_AES_CCM_authenticated_decryption_test_case_128_2),
11554                 TEST_CASE_ST(ut_setup, ut_teardown,
11555                         test_AES_CCM_authenticated_decryption_test_case_128_3),
11556
11557                 /** AES CCM Authenticated Encryption 192 bits key */
11558                 TEST_CASE_ST(ut_setup, ut_teardown,
11559                         test_AES_CCM_authenticated_encryption_test_case_192_1),
11560                 TEST_CASE_ST(ut_setup, ut_teardown,
11561                         test_AES_CCM_authenticated_encryption_test_case_192_2),
11562                 TEST_CASE_ST(ut_setup, ut_teardown,
11563                         test_AES_CCM_authenticated_encryption_test_case_192_3),
11564
11565                 /** AES CCM Authenticated Decryption 192 bits key*/
11566                 TEST_CASE_ST(ut_setup, ut_teardown,
11567                         test_AES_CCM_authenticated_decryption_test_case_192_1),
11568                 TEST_CASE_ST(ut_setup, ut_teardown,
11569                         test_AES_CCM_authenticated_decryption_test_case_192_2),
11570                 TEST_CASE_ST(ut_setup, ut_teardown,
11571                         test_AES_CCM_authenticated_decryption_test_case_192_3),
11572
11573                 /** AES CCM Authenticated Encryption 256 bits key */
11574                 TEST_CASE_ST(ut_setup, ut_teardown,
11575                         test_AES_CCM_authenticated_encryption_test_case_256_1),
11576                 TEST_CASE_ST(ut_setup, ut_teardown,
11577                         test_AES_CCM_authenticated_encryption_test_case_256_2),
11578                 TEST_CASE_ST(ut_setup, ut_teardown,
11579                         test_AES_CCM_authenticated_encryption_test_case_256_3),
11580
11581                 /** AES CCM Authenticated Decryption 256 bits key*/
11582                 TEST_CASE_ST(ut_setup, ut_teardown,
11583                         test_AES_CCM_authenticated_decryption_test_case_256_1),
11584                 TEST_CASE_ST(ut_setup, ut_teardown,
11585                         test_AES_CCM_authenticated_decryption_test_case_256_2),
11586                 TEST_CASE_ST(ut_setup, ut_teardown,
11587                         test_AES_CCM_authenticated_decryption_test_case_256_3),
11588
11589                 /** Scatter-Gather */
11590                 TEST_CASE_ST(ut_setup, ut_teardown,
11591                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11592
11593                 /** Negative tests */
11594                 TEST_CASE_ST(ut_setup, ut_teardown,
11595                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
11596                 TEST_CASE_ST(ut_setup, ut_teardown,
11597                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
11598                 TEST_CASE_ST(ut_setup, ut_teardown,
11599                         authentication_verify_AES128_GMAC_fail_data_corrupt),
11600                 TEST_CASE_ST(ut_setup, ut_teardown,
11601                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
11602                 TEST_CASE_ST(ut_setup, ut_teardown,
11603                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
11604                 TEST_CASE_ST(ut_setup, ut_teardown,
11605                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
11606
11607                 TEST_CASES_END() /**< NULL terminate unit test array */
11608         }
11609 };
11610
11611 static struct unit_test_suite cryptodev_aesni_gcm_testsuite  = {
11612         .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
11613         .setup = testsuite_setup,
11614         .teardown = testsuite_teardown,
11615         .unit_test_cases = {
11616                 /** AES GCM Authenticated Encryption */
11617                 TEST_CASE_ST(ut_setup, ut_teardown,
11618                         test_AES_GCM_authenticated_encryption_test_case_1),
11619                 TEST_CASE_ST(ut_setup, ut_teardown,
11620                         test_AES_GCM_authenticated_encryption_test_case_2),
11621                 TEST_CASE_ST(ut_setup, ut_teardown,
11622                         test_AES_GCM_authenticated_encryption_test_case_3),
11623                 TEST_CASE_ST(ut_setup, ut_teardown,
11624                         test_AES_GCM_authenticated_encryption_test_case_4),
11625                 TEST_CASE_ST(ut_setup, ut_teardown,
11626                         test_AES_GCM_authenticated_encryption_test_case_5),
11627                 TEST_CASE_ST(ut_setup, ut_teardown,
11628                         test_AES_GCM_authenticated_encryption_test_case_6),
11629                 TEST_CASE_ST(ut_setup, ut_teardown,
11630                         test_AES_GCM_authenticated_encryption_test_case_7),
11631
11632                 /** AES GCM Authenticated Decryption */
11633                 TEST_CASE_ST(ut_setup, ut_teardown,
11634                         test_AES_GCM_authenticated_decryption_test_case_1),
11635                 TEST_CASE_ST(ut_setup, ut_teardown,
11636                         test_AES_GCM_authenticated_decryption_test_case_2),
11637                 TEST_CASE_ST(ut_setup, ut_teardown,
11638                         test_AES_GCM_authenticated_decryption_test_case_3),
11639                 TEST_CASE_ST(ut_setup, ut_teardown,
11640                         test_AES_GCM_authenticated_decryption_test_case_4),
11641                 TEST_CASE_ST(ut_setup, ut_teardown,
11642                         test_AES_GCM_authenticated_decryption_test_case_5),
11643                 TEST_CASE_ST(ut_setup, ut_teardown,
11644                         test_AES_GCM_authenticated_decryption_test_case_6),
11645                 TEST_CASE_ST(ut_setup, ut_teardown,
11646                         test_AES_GCM_authenticated_decryption_test_case_7),
11647
11648                 /** AES GCM Authenticated Encryption 192 bits key */
11649                 TEST_CASE_ST(ut_setup, ut_teardown,
11650                         test_AES_GCM_auth_encryption_test_case_192_1),
11651                 TEST_CASE_ST(ut_setup, ut_teardown,
11652                         test_AES_GCM_auth_encryption_test_case_192_2),
11653                 TEST_CASE_ST(ut_setup, ut_teardown,
11654                         test_AES_GCM_auth_encryption_test_case_192_3),
11655                 TEST_CASE_ST(ut_setup, ut_teardown,
11656                         test_AES_GCM_auth_encryption_test_case_192_4),
11657                 TEST_CASE_ST(ut_setup, ut_teardown,
11658                         test_AES_GCM_auth_encryption_test_case_192_5),
11659                 TEST_CASE_ST(ut_setup, ut_teardown,
11660                         test_AES_GCM_auth_encryption_test_case_192_6),
11661                 TEST_CASE_ST(ut_setup, ut_teardown,
11662                         test_AES_GCM_auth_encryption_test_case_192_7),
11663
11664                 /** AES GCM Authenticated Decryption 192 bits key */
11665                 TEST_CASE_ST(ut_setup, ut_teardown,
11666                         test_AES_GCM_auth_decryption_test_case_192_1),
11667                 TEST_CASE_ST(ut_setup, ut_teardown,
11668                         test_AES_GCM_auth_decryption_test_case_192_2),
11669                 TEST_CASE_ST(ut_setup, ut_teardown,
11670                         test_AES_GCM_auth_decryption_test_case_192_3),
11671                 TEST_CASE_ST(ut_setup, ut_teardown,
11672                         test_AES_GCM_auth_decryption_test_case_192_4),
11673                 TEST_CASE_ST(ut_setup, ut_teardown,
11674                         test_AES_GCM_auth_decryption_test_case_192_5),
11675                 TEST_CASE_ST(ut_setup, ut_teardown,
11676                         test_AES_GCM_auth_decryption_test_case_192_6),
11677                 TEST_CASE_ST(ut_setup, ut_teardown,
11678                         test_AES_GCM_auth_decryption_test_case_192_7),
11679
11680                 /** AES GCM Authenticated Encryption 256 bits key */
11681                 TEST_CASE_ST(ut_setup, ut_teardown,
11682                         test_AES_GCM_auth_encryption_test_case_256_1),
11683                 TEST_CASE_ST(ut_setup, ut_teardown,
11684                         test_AES_GCM_auth_encryption_test_case_256_2),
11685                 TEST_CASE_ST(ut_setup, ut_teardown,
11686                         test_AES_GCM_auth_encryption_test_case_256_3),
11687                 TEST_CASE_ST(ut_setup, ut_teardown,
11688                         test_AES_GCM_auth_encryption_test_case_256_4),
11689                 TEST_CASE_ST(ut_setup, ut_teardown,
11690                         test_AES_GCM_auth_encryption_test_case_256_5),
11691                 TEST_CASE_ST(ut_setup, ut_teardown,
11692                         test_AES_GCM_auth_encryption_test_case_256_6),
11693                 TEST_CASE_ST(ut_setup, ut_teardown,
11694                         test_AES_GCM_auth_encryption_test_case_256_7),
11695
11696                 /** AES GCM Authenticated Decryption 256 bits key */
11697                 TEST_CASE_ST(ut_setup, ut_teardown,
11698                         test_AES_GCM_auth_decryption_test_case_256_1),
11699                 TEST_CASE_ST(ut_setup, ut_teardown,
11700                         test_AES_GCM_auth_decryption_test_case_256_2),
11701                 TEST_CASE_ST(ut_setup, ut_teardown,
11702                         test_AES_GCM_auth_decryption_test_case_256_3),
11703                 TEST_CASE_ST(ut_setup, ut_teardown,
11704                         test_AES_GCM_auth_decryption_test_case_256_4),
11705                 TEST_CASE_ST(ut_setup, ut_teardown,
11706                         test_AES_GCM_auth_decryption_test_case_256_5),
11707                 TEST_CASE_ST(ut_setup, ut_teardown,
11708                         test_AES_GCM_auth_decryption_test_case_256_6),
11709                 TEST_CASE_ST(ut_setup, ut_teardown,
11710                         test_AES_GCM_auth_decryption_test_case_256_7),
11711
11712                 /** AES GCM Authenticated Encryption big aad size */
11713                 TEST_CASE_ST(ut_setup, ut_teardown,
11714                         test_AES_GCM_auth_encryption_test_case_aad_1),
11715                 TEST_CASE_ST(ut_setup, ut_teardown,
11716                         test_AES_GCM_auth_encryption_test_case_aad_2),
11717
11718                 /** AES GCM Authenticated Decryption big aad size */
11719                 TEST_CASE_ST(ut_setup, ut_teardown,
11720                         test_AES_GCM_auth_decryption_test_case_aad_1),
11721                 TEST_CASE_ST(ut_setup, ut_teardown,
11722                         test_AES_GCM_auth_decryption_test_case_aad_2),
11723
11724                 /** AES GMAC Authentication */
11725                 TEST_CASE_ST(ut_setup, ut_teardown,
11726                         test_AES_GMAC_authentication_test_case_1),
11727                 TEST_CASE_ST(ut_setup, ut_teardown,
11728                         test_AES_GMAC_authentication_verify_test_case_1),
11729                 TEST_CASE_ST(ut_setup, ut_teardown,
11730                         test_AES_GMAC_authentication_test_case_3),
11731                 TEST_CASE_ST(ut_setup, ut_teardown,
11732                         test_AES_GMAC_authentication_verify_test_case_3),
11733                 TEST_CASE_ST(ut_setup, ut_teardown,
11734                         test_AES_GMAC_authentication_test_case_4),
11735                 TEST_CASE_ST(ut_setup, ut_teardown,
11736                         test_AES_GMAC_authentication_verify_test_case_4),
11737
11738                 /** Negative tests */
11739                 TEST_CASE_ST(ut_setup, ut_teardown,
11740                         authentication_verify_AES128_GMAC_fail_data_corrupt),
11741                 TEST_CASE_ST(ut_setup, ut_teardown,
11742                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
11743
11744                 /** Out of place tests */
11745                 TEST_CASE_ST(ut_setup, ut_teardown,
11746                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
11747                 TEST_CASE_ST(ut_setup, ut_teardown,
11748                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
11749
11750                 /** Session-less tests */
11751                 TEST_CASE_ST(ut_setup, ut_teardown,
11752                         test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
11753                 TEST_CASE_ST(ut_setup, ut_teardown,
11754                         test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
11755
11756                 /** Scatter-Gather */
11757                 TEST_CASE_ST(ut_setup, ut_teardown,
11758                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11759
11760                 TEST_CASES_END() /**< NULL terminate unit test array */
11761         }
11762 };
11763
11764 static struct unit_test_suite cryptodev_sw_kasumi_testsuite  = {
11765         .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
11766         .setup = testsuite_setup,
11767         .teardown = testsuite_teardown,
11768         .unit_test_cases = {
11769                 /** KASUMI encrypt only (UEA1) */
11770                 TEST_CASE_ST(ut_setup, ut_teardown,
11771                         test_kasumi_encryption_test_case_1),
11772                 TEST_CASE_ST(ut_setup, ut_teardown,
11773                         test_kasumi_encryption_test_case_1_sgl),
11774                 TEST_CASE_ST(ut_setup, ut_teardown,
11775                         test_kasumi_encryption_test_case_2),
11776                 TEST_CASE_ST(ut_setup, ut_teardown,
11777                         test_kasumi_encryption_test_case_3),
11778                 TEST_CASE_ST(ut_setup, ut_teardown,
11779                         test_kasumi_encryption_test_case_4),
11780                 TEST_CASE_ST(ut_setup, ut_teardown,
11781                         test_kasumi_encryption_test_case_5),
11782                 /** KASUMI decrypt only (UEA1) */
11783                 TEST_CASE_ST(ut_setup, ut_teardown,
11784                         test_kasumi_decryption_test_case_1),
11785                 TEST_CASE_ST(ut_setup, ut_teardown,
11786                         test_kasumi_decryption_test_case_2),
11787                 TEST_CASE_ST(ut_setup, ut_teardown,
11788                         test_kasumi_decryption_test_case_3),
11789                 TEST_CASE_ST(ut_setup, ut_teardown,
11790                         test_kasumi_decryption_test_case_4),
11791                 TEST_CASE_ST(ut_setup, ut_teardown,
11792                         test_kasumi_decryption_test_case_5),
11793
11794                 TEST_CASE_ST(ut_setup, ut_teardown,
11795                         test_kasumi_encryption_test_case_1_oop),
11796                 TEST_CASE_ST(ut_setup, ut_teardown,
11797                         test_kasumi_encryption_test_case_1_oop_sgl),
11798
11799
11800                 TEST_CASE_ST(ut_setup, ut_teardown,
11801                         test_kasumi_decryption_test_case_1_oop),
11802
11803                 /** KASUMI hash only (UIA1) */
11804                 TEST_CASE_ST(ut_setup, ut_teardown,
11805                         test_kasumi_hash_generate_test_case_1),
11806                 TEST_CASE_ST(ut_setup, ut_teardown,
11807                         test_kasumi_hash_generate_test_case_2),
11808                 TEST_CASE_ST(ut_setup, ut_teardown,
11809                         test_kasumi_hash_generate_test_case_3),
11810                 TEST_CASE_ST(ut_setup, ut_teardown,
11811                         test_kasumi_hash_generate_test_case_4),
11812                 TEST_CASE_ST(ut_setup, ut_teardown,
11813                         test_kasumi_hash_generate_test_case_5),
11814                 TEST_CASE_ST(ut_setup, ut_teardown,
11815                         test_kasumi_hash_generate_test_case_6),
11816                 TEST_CASE_ST(ut_setup, ut_teardown,
11817                         test_kasumi_hash_verify_test_case_1),
11818                 TEST_CASE_ST(ut_setup, ut_teardown,
11819                         test_kasumi_hash_verify_test_case_2),
11820                 TEST_CASE_ST(ut_setup, ut_teardown,
11821                         test_kasumi_hash_verify_test_case_3),
11822                 TEST_CASE_ST(ut_setup, ut_teardown,
11823                         test_kasumi_hash_verify_test_case_4),
11824                 TEST_CASE_ST(ut_setup, ut_teardown,
11825                         test_kasumi_hash_verify_test_case_5),
11826                 TEST_CASE_ST(ut_setup, ut_teardown,
11827                         test_kasumi_cipher_auth_test_case_1),
11828
11829                 /** KASUMI generate auth, then encrypt (F8) */
11830                 TEST_CASE_ST(ut_setup, ut_teardown,
11831                         test_kasumi_auth_cipher_test_case_1),
11832                 TEST_CASE_ST(ut_setup, ut_teardown,
11833                         test_kasumi_auth_cipher_test_case_2),
11834                 TEST_CASE_ST(ut_setup, ut_teardown,
11835                         test_kasumi_auth_cipher_test_case_2_oop),
11836                 TEST_CASE_ST(ut_setup, ut_teardown,
11837                         test_kasumi_auth_cipher_test_case_2_sgl),
11838                 TEST_CASE_ST(ut_setup, ut_teardown,
11839                         test_kasumi_auth_cipher_test_case_2_oop_sgl),
11840
11841                 /** KASUMI decrypt (F8), then verify auth */
11842                 TEST_CASE_ST(ut_setup, ut_teardown,
11843                         test_kasumi_auth_cipher_verify_test_case_1),
11844                 TEST_CASE_ST(ut_setup, ut_teardown,
11845                         test_kasumi_auth_cipher_verify_test_case_2),
11846                 TEST_CASE_ST(ut_setup, ut_teardown,
11847                         test_kasumi_auth_cipher_verify_test_case_2_oop),
11848                 TEST_CASE_ST(ut_setup, ut_teardown,
11849                         test_kasumi_auth_cipher_verify_test_case_2_sgl),
11850                 TEST_CASE_ST(ut_setup, ut_teardown,
11851                         test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
11852                 TEST_CASES_END() /**< NULL terminate unit test array */
11853         }
11854 };
11855 static struct unit_test_suite cryptodev_sw_snow3g_testsuite  = {
11856         .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
11857         .setup = testsuite_setup,
11858         .teardown = testsuite_teardown,
11859         .unit_test_cases = {
11860                 /** SNOW 3G encrypt only (UEA2) */
11861                 TEST_CASE_ST(ut_setup, ut_teardown,
11862                         test_snow3g_encryption_test_case_1),
11863                 TEST_CASE_ST(ut_setup, ut_teardown,
11864                         test_snow3g_encryption_test_case_2),
11865                 TEST_CASE_ST(ut_setup, ut_teardown,
11866                         test_snow3g_encryption_test_case_3),
11867                 TEST_CASE_ST(ut_setup, ut_teardown,
11868                         test_snow3g_encryption_test_case_4),
11869                 TEST_CASE_ST(ut_setup, ut_teardown,
11870                         test_snow3g_encryption_test_case_5),
11871                 TEST_CASE_ST(ut_setup, ut_teardown,
11872                         test_snow3g_auth_cipher_with_digest_test_case_1),
11873
11874                 TEST_CASE_ST(ut_setup, ut_teardown,
11875                         test_snow3g_encryption_test_case_1_oop),
11876                 TEST_CASE_ST(ut_setup, ut_teardown,
11877                                 test_snow3g_encryption_test_case_1_oop_sgl),
11878                 TEST_CASE_ST(ut_setup, ut_teardown,
11879                         test_snow3g_decryption_test_case_1_oop),
11880
11881                 TEST_CASE_ST(ut_setup, ut_teardown,
11882                         test_snow3g_encryption_test_case_1_offset_oop),
11883
11884                 /** SNOW 3G decrypt only (UEA2) */
11885                 TEST_CASE_ST(ut_setup, ut_teardown,
11886                         test_snow3g_decryption_test_case_1),
11887                 TEST_CASE_ST(ut_setup, ut_teardown,
11888                         test_snow3g_decryption_test_case_2),
11889                 TEST_CASE_ST(ut_setup, ut_teardown,
11890                         test_snow3g_decryption_test_case_3),
11891                 TEST_CASE_ST(ut_setup, ut_teardown,
11892                         test_snow3g_decryption_test_case_4),
11893                 TEST_CASE_ST(ut_setup, ut_teardown,
11894                         test_snow3g_decryption_test_case_5),
11895                 TEST_CASE_ST(ut_setup, ut_teardown,
11896                         test_snow3g_decryption_with_digest_test_case_1),
11897                 TEST_CASE_ST(ut_setup, ut_teardown,
11898                         test_snow3g_hash_generate_test_case_1),
11899                 TEST_CASE_ST(ut_setup, ut_teardown,
11900                         test_snow3g_hash_generate_test_case_2),
11901                 TEST_CASE_ST(ut_setup, ut_teardown,
11902                         test_snow3g_hash_generate_test_case_3),
11903                 /* Tests with buffers which length is not byte-aligned */
11904                 TEST_CASE_ST(ut_setup, ut_teardown,
11905                         test_snow3g_hash_generate_test_case_4),
11906                 TEST_CASE_ST(ut_setup, ut_teardown,
11907                         test_snow3g_hash_generate_test_case_5),
11908                 TEST_CASE_ST(ut_setup, ut_teardown,
11909                         test_snow3g_hash_generate_test_case_6),
11910                 TEST_CASE_ST(ut_setup, ut_teardown,
11911                         test_snow3g_hash_verify_test_case_1),
11912                 TEST_CASE_ST(ut_setup, ut_teardown,
11913                         test_snow3g_hash_verify_test_case_2),
11914                 TEST_CASE_ST(ut_setup, ut_teardown,
11915                         test_snow3g_hash_verify_test_case_3),
11916                 /* Tests with buffers which length is not byte-aligned */
11917                 TEST_CASE_ST(ut_setup, ut_teardown,
11918                         test_snow3g_hash_verify_test_case_4),
11919                 TEST_CASE_ST(ut_setup, ut_teardown,
11920                         test_snow3g_hash_verify_test_case_5),
11921                 TEST_CASE_ST(ut_setup, ut_teardown,
11922                         test_snow3g_hash_verify_test_case_6),
11923                 TEST_CASE_ST(ut_setup, ut_teardown,
11924                         test_snow3g_cipher_auth_test_case_1),
11925
11926                 /** SNOW 3G generate auth, then encrypt (UEA2) */
11927                 TEST_CASE_ST(ut_setup, ut_teardown,
11928                         test_snow3g_auth_cipher_test_case_1),
11929                 TEST_CASE_ST(ut_setup, ut_teardown,
11930                         test_snow3g_auth_cipher_test_case_2),
11931                 TEST_CASE_ST(ut_setup, ut_teardown,
11932                         test_snow3g_auth_cipher_test_case_2_oop),
11933                 TEST_CASE_ST(ut_setup, ut_teardown,
11934                         test_snow3g_auth_cipher_part_digest_enc),
11935                 TEST_CASE_ST(ut_setup, ut_teardown,
11936                         test_snow3g_auth_cipher_part_digest_enc_oop),
11937                 TEST_CASE_ST(ut_setup, ut_teardown,
11938                         test_snow3g_auth_cipher_test_case_3_sgl),
11939                 TEST_CASE_ST(ut_setup, ut_teardown,
11940                         test_snow3g_auth_cipher_test_case_3_oop_sgl),
11941                 TEST_CASE_ST(ut_setup, ut_teardown,
11942                         test_snow3g_auth_cipher_part_digest_enc_sgl),
11943                 TEST_CASE_ST(ut_setup, ut_teardown,
11944                         test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
11945
11946                 /** SNOW 3G decrypt (UEA2), then verify auth */
11947                 TEST_CASE_ST(ut_setup, ut_teardown,
11948                         test_snow3g_auth_cipher_verify_test_case_1),
11949                 TEST_CASE_ST(ut_setup, ut_teardown,
11950                         test_snow3g_auth_cipher_verify_test_case_2),
11951                 TEST_CASE_ST(ut_setup, ut_teardown,
11952                         test_snow3g_auth_cipher_verify_test_case_2_oop),
11953                 TEST_CASE_ST(ut_setup, ut_teardown,
11954                         test_snow3g_auth_cipher_verify_part_digest_enc),
11955                 TEST_CASE_ST(ut_setup, ut_teardown,
11956                         test_snow3g_auth_cipher_verify_part_digest_enc_oop),
11957                 TEST_CASE_ST(ut_setup, ut_teardown,
11958                         test_snow3g_auth_cipher_verify_test_case_3_sgl),
11959                 TEST_CASE_ST(ut_setup, ut_teardown,
11960                         test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
11961                 TEST_CASE_ST(ut_setup, ut_teardown,
11962                         test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
11963                 TEST_CASE_ST(ut_setup, ut_teardown,
11964                         test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
11965
11966                 TEST_CASES_END() /**< NULL terminate unit test array */
11967         }
11968 };
11969
11970 static struct unit_test_suite cryptodev_sw_zuc_testsuite  = {
11971         .suite_name = "Crypto Device SW ZUC Unit Test Suite",
11972         .setup = testsuite_setup,
11973         .teardown = testsuite_teardown,
11974         .unit_test_cases = {
11975                 /** ZUC encrypt only (EEA3) */
11976                 TEST_CASE_ST(ut_setup, ut_teardown,
11977                         test_zuc_encryption_test_case_1),
11978                 TEST_CASE_ST(ut_setup, ut_teardown,
11979                         test_zuc_encryption_test_case_2),
11980                 TEST_CASE_ST(ut_setup, ut_teardown,
11981                         test_zuc_encryption_test_case_3),
11982                 TEST_CASE_ST(ut_setup, ut_teardown,
11983                         test_zuc_encryption_test_case_4),
11984                 TEST_CASE_ST(ut_setup, ut_teardown,
11985                         test_zuc_encryption_test_case_5),
11986                 TEST_CASE_ST(ut_setup, ut_teardown,
11987                         test_zuc_hash_generate_test_case_1),
11988                 TEST_CASE_ST(ut_setup, ut_teardown,
11989                         test_zuc_hash_generate_test_case_2),
11990                 TEST_CASE_ST(ut_setup, ut_teardown,
11991                         test_zuc_hash_generate_test_case_3),
11992                 TEST_CASE_ST(ut_setup, ut_teardown,
11993                         test_zuc_hash_generate_test_case_4),
11994                 TEST_CASE_ST(ut_setup, ut_teardown,
11995                         test_zuc_hash_generate_test_case_5),
11996                 TEST_CASE_ST(ut_setup, ut_teardown,
11997                         test_zuc_encryption_test_case_6_sgl),
11998                 TEST_CASES_END() /**< NULL terminate unit test array */
11999         }
12000 };
12001
12002 static struct unit_test_suite cryptodev_caam_jr_testsuite  = {
12003         .suite_name = "Crypto CAAM JR Unit Test Suite",
12004         .setup = testsuite_setup,
12005         .teardown = testsuite_teardown,
12006         .unit_test_cases = {
12007                 TEST_CASE_ST(ut_setup, ut_teardown,
12008                              test_device_configure_invalid_dev_id),
12009                 TEST_CASE_ST(ut_setup, ut_teardown,
12010                              test_multi_session),
12011
12012                 TEST_CASE_ST(ut_setup, ut_teardown,
12013                              test_AES_chain_caam_jr_all),
12014                 TEST_CASE_ST(ut_setup, ut_teardown,
12015                              test_3DES_chain_caam_jr_all),
12016                 TEST_CASE_ST(ut_setup, ut_teardown,
12017                              test_AES_cipheronly_caam_jr_all),
12018                 TEST_CASE_ST(ut_setup, ut_teardown,
12019                              test_3DES_cipheronly_caam_jr_all),
12020                 TEST_CASE_ST(ut_setup, ut_teardown,
12021                              test_authonly_caam_jr_all),
12022
12023                 TEST_CASES_END() /**< NULL terminate unit test array */
12024         }
12025 };
12026
12027 static struct unit_test_suite cryptodev_dpaa_sec_testsuite  = {
12028         .suite_name = "Crypto DPAA_SEC Unit Test Suite",
12029         .setup = testsuite_setup,
12030         .teardown = testsuite_teardown,
12031         .unit_test_cases = {
12032                 TEST_CASE_ST(ut_setup, ut_teardown,
12033                              test_device_configure_invalid_dev_id),
12034                 TEST_CASE_ST(ut_setup, ut_teardown,
12035                              test_multi_session),
12036
12037                 TEST_CASE_ST(ut_setup, ut_teardown,
12038                              test_AES_chain_dpaa_sec_all),
12039                 TEST_CASE_ST(ut_setup, ut_teardown,
12040                              test_3DES_chain_dpaa_sec_all),
12041                 TEST_CASE_ST(ut_setup, ut_teardown,
12042                              test_AES_cipheronly_dpaa_sec_all),
12043                 TEST_CASE_ST(ut_setup, ut_teardown,
12044                              test_3DES_cipheronly_dpaa_sec_all),
12045                 TEST_CASE_ST(ut_setup, ut_teardown,
12046                              test_authonly_dpaa_sec_all),
12047
12048 #ifdef RTE_LIBRTE_SECURITY
12049                 TEST_CASE_ST(ut_setup, ut_teardown,
12050                         test_PDCP_PROTO_cplane_encap_all),
12051
12052                 TEST_CASE_ST(ut_setup, ut_teardown,
12053                         test_PDCP_PROTO_cplane_decap_all),
12054
12055                 TEST_CASE_ST(ut_setup, ut_teardown,
12056                         test_PDCP_PROTO_uplane_encap_all),
12057
12058                 TEST_CASE_ST(ut_setup, ut_teardown,
12059                         test_PDCP_PROTO_uplane_decap_all),
12060
12061                 TEST_CASE_ST(ut_setup, ut_teardown,
12062                         test_PDCP_PROTO_SGL_in_place_32B),
12063                 TEST_CASE_ST(ut_setup, ut_teardown,
12064                         test_PDCP_PROTO_SGL_oop_32B_128B),
12065                 TEST_CASE_ST(ut_setup, ut_teardown,
12066                         test_PDCP_PROTO_SGL_oop_32B_40B),
12067                 TEST_CASE_ST(ut_setup, ut_teardown,
12068                         test_PDCP_PROTO_SGL_oop_128B_32B),
12069 #endif
12070                 /** AES GCM Authenticated Encryption */
12071                 TEST_CASE_ST(ut_setup, ut_teardown,
12072                         test_AES_GCM_authenticated_encryption_test_case_1),
12073                 TEST_CASE_ST(ut_setup, ut_teardown,
12074                         test_AES_GCM_authenticated_encryption_test_case_2),
12075                 TEST_CASE_ST(ut_setup, ut_teardown,
12076                         test_AES_GCM_authenticated_encryption_test_case_3),
12077                 TEST_CASE_ST(ut_setup, ut_teardown,
12078                         test_AES_GCM_authenticated_encryption_test_case_4),
12079                 TEST_CASE_ST(ut_setup, ut_teardown,
12080                         test_AES_GCM_authenticated_encryption_test_case_5),
12081                 TEST_CASE_ST(ut_setup, ut_teardown,
12082                         test_AES_GCM_authenticated_encryption_test_case_6),
12083                 TEST_CASE_ST(ut_setup, ut_teardown,
12084                         test_AES_GCM_authenticated_encryption_test_case_7),
12085
12086                 /** AES GCM Authenticated Decryption */
12087                 TEST_CASE_ST(ut_setup, ut_teardown,
12088                         test_AES_GCM_authenticated_decryption_test_case_1),
12089                 TEST_CASE_ST(ut_setup, ut_teardown,
12090                         test_AES_GCM_authenticated_decryption_test_case_2),
12091                 TEST_CASE_ST(ut_setup, ut_teardown,
12092                         test_AES_GCM_authenticated_decryption_test_case_3),
12093                 TEST_CASE_ST(ut_setup, ut_teardown,
12094                         test_AES_GCM_authenticated_decryption_test_case_4),
12095                 TEST_CASE_ST(ut_setup, ut_teardown,
12096                         test_AES_GCM_authenticated_decryption_test_case_5),
12097                 TEST_CASE_ST(ut_setup, ut_teardown,
12098                         test_AES_GCM_authenticated_decryption_test_case_6),
12099                 TEST_CASE_ST(ut_setup, ut_teardown,
12100                         test_AES_GCM_authenticated_decryption_test_case_7),
12101
12102                 /** AES GCM Authenticated Encryption 256 bits key */
12103                 TEST_CASE_ST(ut_setup, ut_teardown,
12104                         test_AES_GCM_auth_encryption_test_case_256_1),
12105                 TEST_CASE_ST(ut_setup, ut_teardown,
12106                         test_AES_GCM_auth_encryption_test_case_256_2),
12107                 TEST_CASE_ST(ut_setup, ut_teardown,
12108                         test_AES_GCM_auth_encryption_test_case_256_3),
12109                 TEST_CASE_ST(ut_setup, ut_teardown,
12110                         test_AES_GCM_auth_encryption_test_case_256_4),
12111                 TEST_CASE_ST(ut_setup, ut_teardown,
12112                         test_AES_GCM_auth_encryption_test_case_256_5),
12113                 TEST_CASE_ST(ut_setup, ut_teardown,
12114                         test_AES_GCM_auth_encryption_test_case_256_6),
12115                 TEST_CASE_ST(ut_setup, ut_teardown,
12116                         test_AES_GCM_auth_encryption_test_case_256_7),
12117
12118                 /** AES GCM Authenticated Decryption 256 bits key */
12119                 TEST_CASE_ST(ut_setup, ut_teardown,
12120                         test_AES_GCM_auth_decryption_test_case_256_1),
12121                 TEST_CASE_ST(ut_setup, ut_teardown,
12122                         test_AES_GCM_auth_decryption_test_case_256_2),
12123                 TEST_CASE_ST(ut_setup, ut_teardown,
12124                         test_AES_GCM_auth_decryption_test_case_256_3),
12125                 TEST_CASE_ST(ut_setup, ut_teardown,
12126                         test_AES_GCM_auth_decryption_test_case_256_4),
12127                 TEST_CASE_ST(ut_setup, ut_teardown,
12128                         test_AES_GCM_auth_decryption_test_case_256_5),
12129                 TEST_CASE_ST(ut_setup, ut_teardown,
12130                         test_AES_GCM_auth_decryption_test_case_256_6),
12131                 TEST_CASE_ST(ut_setup, ut_teardown,
12132                         test_AES_GCM_auth_decryption_test_case_256_7),
12133
12134                 /** Out of place tests */
12135                 TEST_CASE_ST(ut_setup, ut_teardown,
12136                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
12137                 TEST_CASE_ST(ut_setup, ut_teardown,
12138                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
12139
12140                 /** Scatter-Gather */
12141                 TEST_CASE_ST(ut_setup, ut_teardown,
12142                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12143                 TEST_CASE_ST(ut_setup, ut_teardown,
12144                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12145                 TEST_CASE_ST(ut_setup, ut_teardown,
12146                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12147                 TEST_CASE_ST(ut_setup, ut_teardown,
12148                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12149
12150                 /** Negative tests */
12151                 TEST_CASE_ST(ut_setup, ut_teardown,
12152                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
12153                 TEST_CASE_ST(ut_setup, ut_teardown,
12154                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12155                 TEST_CASE_ST(ut_setup, ut_teardown,
12156                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12157                 TEST_CASE_ST(ut_setup, ut_teardown,
12158                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12159
12160                 TEST_CASES_END() /**< NULL terminate unit test array */
12161         }
12162 };
12163
12164 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite  = {
12165         .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
12166         .setup = testsuite_setup,
12167         .teardown = testsuite_teardown,
12168         .unit_test_cases = {
12169                 TEST_CASE_ST(ut_setup, ut_teardown,
12170                         test_device_configure_invalid_dev_id),
12171                 TEST_CASE_ST(ut_setup, ut_teardown,
12172                         test_multi_session),
12173
12174                 TEST_CASE_ST(ut_setup, ut_teardown,
12175                         test_AES_chain_dpaa2_sec_all),
12176                 TEST_CASE_ST(ut_setup, ut_teardown,
12177                         test_3DES_chain_dpaa2_sec_all),
12178                 TEST_CASE_ST(ut_setup, ut_teardown,
12179                         test_AES_cipheronly_dpaa2_sec_all),
12180                 TEST_CASE_ST(ut_setup, ut_teardown,
12181                         test_3DES_cipheronly_dpaa2_sec_all),
12182                 TEST_CASE_ST(ut_setup, ut_teardown,
12183                         test_authonly_dpaa2_sec_all),
12184
12185 #ifdef RTE_LIBRTE_SECURITY
12186                 TEST_CASE_ST(ut_setup, ut_teardown,
12187                         test_PDCP_PROTO_cplane_encap_all),
12188
12189                 TEST_CASE_ST(ut_setup, ut_teardown,
12190                         test_PDCP_PROTO_cplane_decap_all),
12191
12192                 TEST_CASE_ST(ut_setup, ut_teardown,
12193                         test_PDCP_PROTO_uplane_encap_all),
12194
12195                 TEST_CASE_ST(ut_setup, ut_teardown,
12196                         test_PDCP_PROTO_uplane_decap_all),
12197
12198                 TEST_CASE_ST(ut_setup, ut_teardown,
12199                         test_PDCP_PROTO_SGL_in_place_32B),
12200                 TEST_CASE_ST(ut_setup, ut_teardown,
12201                         test_PDCP_PROTO_SGL_oop_32B_128B),
12202                 TEST_CASE_ST(ut_setup, ut_teardown,
12203                         test_PDCP_PROTO_SGL_oop_32B_40B),
12204                 TEST_CASE_ST(ut_setup, ut_teardown,
12205                         test_PDCP_PROTO_SGL_oop_128B_32B),
12206 #endif
12207                 /** AES GCM Authenticated Encryption */
12208                 TEST_CASE_ST(ut_setup, ut_teardown,
12209                         test_AES_GCM_authenticated_encryption_test_case_1),
12210                 TEST_CASE_ST(ut_setup, ut_teardown,
12211                         test_AES_GCM_authenticated_encryption_test_case_2),
12212                 TEST_CASE_ST(ut_setup, ut_teardown,
12213                         test_AES_GCM_authenticated_encryption_test_case_3),
12214                 TEST_CASE_ST(ut_setup, ut_teardown,
12215                         test_AES_GCM_authenticated_encryption_test_case_4),
12216                 TEST_CASE_ST(ut_setup, ut_teardown,
12217                         test_AES_GCM_authenticated_encryption_test_case_5),
12218                 TEST_CASE_ST(ut_setup, ut_teardown,
12219                         test_AES_GCM_authenticated_encryption_test_case_6),
12220                 TEST_CASE_ST(ut_setup, ut_teardown,
12221                         test_AES_GCM_authenticated_encryption_test_case_7),
12222
12223                 /** AES GCM Authenticated Decryption */
12224                 TEST_CASE_ST(ut_setup, ut_teardown,
12225                         test_AES_GCM_authenticated_decryption_test_case_1),
12226                 TEST_CASE_ST(ut_setup, ut_teardown,
12227                         test_AES_GCM_authenticated_decryption_test_case_2),
12228                 TEST_CASE_ST(ut_setup, ut_teardown,
12229                         test_AES_GCM_authenticated_decryption_test_case_3),
12230                 TEST_CASE_ST(ut_setup, ut_teardown,
12231                         test_AES_GCM_authenticated_decryption_test_case_4),
12232                 TEST_CASE_ST(ut_setup, ut_teardown,
12233                         test_AES_GCM_authenticated_decryption_test_case_5),
12234                 TEST_CASE_ST(ut_setup, ut_teardown,
12235                         test_AES_GCM_authenticated_decryption_test_case_6),
12236                 TEST_CASE_ST(ut_setup, ut_teardown,
12237                         test_AES_GCM_authenticated_decryption_test_case_7),
12238
12239                 /** AES GCM Authenticated Encryption 192 bits key */
12240                 TEST_CASE_ST(ut_setup, ut_teardown,
12241                         test_AES_GCM_auth_encryption_test_case_192_1),
12242                 TEST_CASE_ST(ut_setup, ut_teardown,
12243                         test_AES_GCM_auth_encryption_test_case_192_2),
12244                 TEST_CASE_ST(ut_setup, ut_teardown,
12245                         test_AES_GCM_auth_encryption_test_case_192_3),
12246                 TEST_CASE_ST(ut_setup, ut_teardown,
12247                         test_AES_GCM_auth_encryption_test_case_192_4),
12248                 TEST_CASE_ST(ut_setup, ut_teardown,
12249                         test_AES_GCM_auth_encryption_test_case_192_5),
12250                 TEST_CASE_ST(ut_setup, ut_teardown,
12251                         test_AES_GCM_auth_encryption_test_case_192_6),
12252                 TEST_CASE_ST(ut_setup, ut_teardown,
12253                         test_AES_GCM_auth_encryption_test_case_192_7),
12254
12255                 /** AES GCM Authenticated Decryption 192 bits key */
12256                 TEST_CASE_ST(ut_setup, ut_teardown,
12257                         test_AES_GCM_auth_decryption_test_case_192_1),
12258                 TEST_CASE_ST(ut_setup, ut_teardown,
12259                         test_AES_GCM_auth_decryption_test_case_192_2),
12260                 TEST_CASE_ST(ut_setup, ut_teardown,
12261                         test_AES_GCM_auth_decryption_test_case_192_3),
12262                 TEST_CASE_ST(ut_setup, ut_teardown,
12263                         test_AES_GCM_auth_decryption_test_case_192_4),
12264                 TEST_CASE_ST(ut_setup, ut_teardown,
12265                         test_AES_GCM_auth_decryption_test_case_192_5),
12266                 TEST_CASE_ST(ut_setup, ut_teardown,
12267                         test_AES_GCM_auth_decryption_test_case_192_6),
12268                 TEST_CASE_ST(ut_setup, ut_teardown,
12269                         test_AES_GCM_auth_decryption_test_case_192_7),
12270
12271                 /** AES GCM Authenticated Encryption 256 bits key */
12272                 TEST_CASE_ST(ut_setup, ut_teardown,
12273                         test_AES_GCM_auth_encryption_test_case_256_1),
12274                 TEST_CASE_ST(ut_setup, ut_teardown,
12275                         test_AES_GCM_auth_encryption_test_case_256_2),
12276                 TEST_CASE_ST(ut_setup, ut_teardown,
12277                         test_AES_GCM_auth_encryption_test_case_256_3),
12278                 TEST_CASE_ST(ut_setup, ut_teardown,
12279                         test_AES_GCM_auth_encryption_test_case_256_4),
12280                 TEST_CASE_ST(ut_setup, ut_teardown,
12281                         test_AES_GCM_auth_encryption_test_case_256_5),
12282                 TEST_CASE_ST(ut_setup, ut_teardown,
12283                         test_AES_GCM_auth_encryption_test_case_256_6),
12284                 TEST_CASE_ST(ut_setup, ut_teardown,
12285                         test_AES_GCM_auth_encryption_test_case_256_7),
12286
12287                 /** AES GCM Authenticated Decryption 256 bits key */
12288                 TEST_CASE_ST(ut_setup, ut_teardown,
12289                         test_AES_GCM_auth_decryption_test_case_256_1),
12290                 TEST_CASE_ST(ut_setup, ut_teardown,
12291                         test_AES_GCM_auth_decryption_test_case_256_2),
12292                 TEST_CASE_ST(ut_setup, ut_teardown,
12293                         test_AES_GCM_auth_decryption_test_case_256_3),
12294                 TEST_CASE_ST(ut_setup, ut_teardown,
12295                         test_AES_GCM_auth_decryption_test_case_256_4),
12296                 TEST_CASE_ST(ut_setup, ut_teardown,
12297                         test_AES_GCM_auth_decryption_test_case_256_5),
12298                 TEST_CASE_ST(ut_setup, ut_teardown,
12299                         test_AES_GCM_auth_decryption_test_case_256_6),
12300                 TEST_CASE_ST(ut_setup, ut_teardown,
12301                         test_AES_GCM_auth_decryption_test_case_256_7),
12302
12303                 /** Out of place tests */
12304                 TEST_CASE_ST(ut_setup, ut_teardown,
12305                         test_AES_GCM_authenticated_encryption_oop_test_case_1),
12306                 TEST_CASE_ST(ut_setup, ut_teardown,
12307                         test_AES_GCM_authenticated_decryption_oop_test_case_1),
12308
12309                 /** Scatter-Gather */
12310                 TEST_CASE_ST(ut_setup, ut_teardown,
12311                         test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12312                 TEST_CASE_ST(ut_setup, ut_teardown,
12313                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12314                 TEST_CASE_ST(ut_setup, ut_teardown,
12315                         test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12316                 TEST_CASE_ST(ut_setup, ut_teardown,
12317                         test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12318
12319                 /** SNOW 3G encrypt only (UEA2) */
12320                 TEST_CASE_ST(ut_setup, ut_teardown,
12321                         test_snow3g_encryption_test_case_1),
12322                 TEST_CASE_ST(ut_setup, ut_teardown,
12323                         test_snow3g_encryption_test_case_2),
12324                 TEST_CASE_ST(ut_setup, ut_teardown,
12325                         test_snow3g_encryption_test_case_3),
12326                 TEST_CASE_ST(ut_setup, ut_teardown,
12327                         test_snow3g_encryption_test_case_4),
12328                 TEST_CASE_ST(ut_setup, ut_teardown,
12329                         test_snow3g_encryption_test_case_5),
12330
12331                 TEST_CASE_ST(ut_setup, ut_teardown,
12332                         test_snow3g_encryption_test_case_1_oop),
12333                 TEST_CASE_ST(ut_setup, ut_teardown,
12334                         test_snow3g_decryption_test_case_1_oop),
12335                 TEST_CASE_ST(ut_setup, ut_teardown,
12336                         test_snow3g_encryption_test_case_1_oop_sgl),
12337
12338                 /** SNOW 3G decrypt only (UEA2) */
12339                 TEST_CASE_ST(ut_setup, ut_teardown,
12340                         test_snow3g_decryption_test_case_1),
12341                 TEST_CASE_ST(ut_setup, ut_teardown,
12342                         test_snow3g_decryption_test_case_2),
12343                 TEST_CASE_ST(ut_setup, ut_teardown,
12344                         test_snow3g_decryption_test_case_3),
12345                 TEST_CASE_ST(ut_setup, ut_teardown,
12346                         test_snow3g_decryption_test_case_4),
12347                 TEST_CASE_ST(ut_setup, ut_teardown,
12348                         test_snow3g_decryption_test_case_5),
12349
12350                 TEST_CASE_ST(ut_setup, ut_teardown,
12351                         test_snow3g_hash_generate_test_case_1),
12352                 TEST_CASE_ST(ut_setup, ut_teardown,
12353                         test_snow3g_hash_generate_test_case_2),
12354                 TEST_CASE_ST(ut_setup, ut_teardown,
12355                         test_snow3g_hash_generate_test_case_3),
12356                 TEST_CASE_ST(ut_setup, ut_teardown,
12357                         test_snow3g_hash_verify_test_case_1),
12358                 TEST_CASE_ST(ut_setup, ut_teardown,
12359                         test_snow3g_hash_verify_test_case_2),
12360                 TEST_CASE_ST(ut_setup, ut_teardown,
12361                         test_snow3g_hash_verify_test_case_3),
12362
12363                 /** ZUC encrypt only (EEA3) */
12364                 TEST_CASE_ST(ut_setup, ut_teardown,
12365                         test_zuc_encryption_test_case_1),
12366                 TEST_CASE_ST(ut_setup, ut_teardown,
12367                         test_zuc_encryption_test_case_2),
12368                 TEST_CASE_ST(ut_setup, ut_teardown,
12369                         test_zuc_encryption_test_case_3),
12370                 TEST_CASE_ST(ut_setup, ut_teardown,
12371                         test_zuc_encryption_test_case_4),
12372                 TEST_CASE_ST(ut_setup, ut_teardown,
12373                         test_zuc_encryption_test_case_5),
12374
12375                 /** ZUC authenticate (EIA3) */
12376                 TEST_CASE_ST(ut_setup, ut_teardown,
12377                         test_zuc_hash_generate_test_case_6),
12378                 TEST_CASE_ST(ut_setup, ut_teardown,
12379                         test_zuc_hash_generate_test_case_7),
12380                 TEST_CASE_ST(ut_setup, ut_teardown,
12381                         test_zuc_hash_generate_test_case_8),
12382
12383                 /** Negative tests */
12384                 TEST_CASE_ST(ut_setup, ut_teardown,
12385                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
12386                 TEST_CASE_ST(ut_setup, ut_teardown,
12387                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12388                 TEST_CASE_ST(ut_setup, ut_teardown,
12389                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12390                 TEST_CASE_ST(ut_setup, ut_teardown,
12391                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12392
12393                 TEST_CASES_END() /**< NULL terminate unit test array */
12394         }
12395 };
12396
12397 static struct unit_test_suite cryptodev_null_testsuite  = {
12398         .suite_name = "Crypto Device NULL Unit Test Suite",
12399         .setup = testsuite_setup,
12400         .teardown = testsuite_teardown,
12401         .unit_test_cases = {
12402                 TEST_CASE_ST(ut_setup, ut_teardown,
12403                         test_null_invalid_operation),
12404                 TEST_CASE_ST(ut_setup, ut_teardown,
12405                         test_null_burst_operation),
12406                 TEST_CASE_ST(ut_setup, ut_teardown,
12407                         test_AES_chain_null_all),
12408                 TEST_CASE_ST(ut_setup, ut_teardown,
12409                         test_AES_cipheronly_null_all),
12410                 TEST_CASE_ST(ut_setup, ut_teardown,
12411                                 test_authonly_null_all),
12412
12413                 TEST_CASES_END() /**< NULL terminate unit test array */
12414         }
12415 };
12416
12417 static struct unit_test_suite cryptodev_armv8_testsuite  = {
12418         .suite_name = "Crypto Device ARMv8 Unit Test Suite",
12419         .setup = testsuite_setup,
12420         .teardown = testsuite_teardown,
12421         .unit_test_cases = {
12422                 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
12423
12424                 /** Negative tests */
12425                 TEST_CASE_ST(ut_setup, ut_teardown,
12426                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12427                 TEST_CASE_ST(ut_setup, ut_teardown,
12428                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12429
12430                 TEST_CASES_END() /**< NULL terminate unit test array */
12431         }
12432 };
12433
12434 static struct unit_test_suite cryptodev_mrvl_testsuite  = {
12435         .suite_name = "Crypto Device Marvell Component Test Suite",
12436         .setup = testsuite_setup,
12437         .teardown = testsuite_teardown,
12438         .unit_test_cases = {
12439                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12440                 TEST_CASE_ST(ut_setup, ut_teardown,
12441                                 test_multi_session_random_usage),
12442                 TEST_CASE_ST(ut_setup, ut_teardown,
12443                                 test_AES_chain_mrvl_all),
12444                 TEST_CASE_ST(ut_setup, ut_teardown,
12445                                 test_AES_cipheronly_mrvl_all),
12446                 TEST_CASE_ST(ut_setup, ut_teardown,
12447                                 test_authonly_mrvl_all),
12448                 TEST_CASE_ST(ut_setup, ut_teardown,
12449                                 test_3DES_chain_mrvl_all),
12450                 TEST_CASE_ST(ut_setup, ut_teardown,
12451                                 test_3DES_cipheronly_mrvl_all),
12452
12453                 /** Negative tests */
12454                 TEST_CASE_ST(ut_setup, ut_teardown,
12455                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
12456                 TEST_CASE_ST(ut_setup, ut_teardown,
12457                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12458                 TEST_CASE_ST(ut_setup, ut_teardown,
12459                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12460                 TEST_CASE_ST(ut_setup, ut_teardown,
12461                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12462
12463                 TEST_CASES_END() /**< NULL terminate unit test array */
12464         }
12465 };
12466
12467 static struct unit_test_suite cryptodev_ccp_testsuite  = {
12468         .suite_name = "Crypto Device CCP Unit Test Suite",
12469         .setup = testsuite_setup,
12470         .teardown = testsuite_teardown,
12471         .unit_test_cases = {
12472                 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12473                 TEST_CASE_ST(ut_setup, ut_teardown,
12474                                 test_multi_session_random_usage),
12475                 TEST_CASE_ST(ut_setup, ut_teardown,
12476                                 test_AES_chain_ccp_all),
12477                 TEST_CASE_ST(ut_setup, ut_teardown,
12478                                 test_AES_cipheronly_ccp_all),
12479                 TEST_CASE_ST(ut_setup, ut_teardown,
12480                                 test_3DES_chain_ccp_all),
12481                 TEST_CASE_ST(ut_setup, ut_teardown,
12482                                 test_3DES_cipheronly_ccp_all),
12483                 TEST_CASE_ST(ut_setup, ut_teardown,
12484                                 test_authonly_ccp_all),
12485
12486                 /** Negative tests */
12487                 TEST_CASE_ST(ut_setup, ut_teardown,
12488                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
12489                 TEST_CASE_ST(ut_setup, ut_teardown,
12490                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12491                 TEST_CASE_ST(ut_setup, ut_teardown,
12492                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12493                 TEST_CASE_ST(ut_setup, ut_teardown,
12494                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12495
12496                 TEST_CASES_END() /**< NULL terminate unit test array */
12497         }
12498 };
12499
12500 static struct unit_test_suite cryptodev_octeontx_testsuite  = {
12501         .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
12502         .setup = testsuite_setup,
12503         .teardown = testsuite_teardown,
12504         .unit_test_cases = {
12505                 TEST_CASE_ST(ut_setup, ut_teardown,
12506                         test_AES_chain_octeontx_all),
12507                 TEST_CASE_ST(ut_setup, ut_teardown,
12508                         test_AES_cipheronly_octeontx_all),
12509                 TEST_CASE_ST(ut_setup, ut_teardown,
12510                         test_3DES_chain_octeontx_all),
12511                 TEST_CASE_ST(ut_setup, ut_teardown,
12512                         test_3DES_cipheronly_octeontx_all),
12513                 TEST_CASE_ST(ut_setup, ut_teardown,
12514                         test_authonly_octeontx_all),
12515
12516                 /** AES GCM Authenticated Encryption */
12517                 TEST_CASE_ST(ut_setup, ut_teardown,
12518                         test_AES_GCM_authenticated_encryption_test_case_1),
12519                 TEST_CASE_ST(ut_setup, ut_teardown,
12520                         test_AES_GCM_authenticated_encryption_test_case_2),
12521                 TEST_CASE_ST(ut_setup, ut_teardown,
12522                         test_AES_GCM_authenticated_encryption_test_case_3),
12523                 TEST_CASE_ST(ut_setup, ut_teardown,
12524                         test_AES_GCM_authenticated_encryption_test_case_4),
12525                 TEST_CASE_ST(ut_setup, ut_teardown,
12526                         test_AES_GCM_authenticated_encryption_test_case_5),
12527                 TEST_CASE_ST(ut_setup, ut_teardown,
12528                         test_AES_GCM_authenticated_encryption_test_case_6),
12529                 TEST_CASE_ST(ut_setup, ut_teardown,
12530                         test_AES_GCM_authenticated_encryption_test_case_7),
12531
12532                 /** AES GCM Authenticated Decryption */
12533                 TEST_CASE_ST(ut_setup, ut_teardown,
12534                         test_AES_GCM_authenticated_decryption_test_case_1),
12535                 TEST_CASE_ST(ut_setup, ut_teardown,
12536                         test_AES_GCM_authenticated_decryption_test_case_2),
12537                 TEST_CASE_ST(ut_setup, ut_teardown,
12538                         test_AES_GCM_authenticated_decryption_test_case_3),
12539                 TEST_CASE_ST(ut_setup, ut_teardown,
12540                         test_AES_GCM_authenticated_decryption_test_case_4),
12541                 TEST_CASE_ST(ut_setup, ut_teardown,
12542                         test_AES_GCM_authenticated_decryption_test_case_5),
12543                 TEST_CASE_ST(ut_setup, ut_teardown,
12544                         test_AES_GCM_authenticated_decryption_test_case_6),
12545                 TEST_CASE_ST(ut_setup, ut_teardown,
12546                         test_AES_GCM_authenticated_decryption_test_case_7),
12547                 /** AES GMAC Authentication */
12548                 TEST_CASE_ST(ut_setup, ut_teardown,
12549                         test_AES_GMAC_authentication_test_case_1),
12550                 TEST_CASE_ST(ut_setup, ut_teardown,
12551                         test_AES_GMAC_authentication_verify_test_case_1),
12552                 TEST_CASE_ST(ut_setup, ut_teardown,
12553                         test_AES_GMAC_authentication_test_case_2),
12554                 TEST_CASE_ST(ut_setup, ut_teardown,
12555                         test_AES_GMAC_authentication_verify_test_case_2),
12556                 TEST_CASE_ST(ut_setup, ut_teardown,
12557                         test_AES_GMAC_authentication_test_case_3),
12558                 TEST_CASE_ST(ut_setup, ut_teardown,
12559                         test_AES_GMAC_authentication_verify_test_case_3),
12560
12561                 /** SNOW 3G encrypt only (UEA2) */
12562                 TEST_CASE_ST(ut_setup, ut_teardown,
12563                         test_snow3g_encryption_test_case_1),
12564                 TEST_CASE_ST(ut_setup, ut_teardown,
12565                         test_snow3g_encryption_test_case_2),
12566                 TEST_CASE_ST(ut_setup, ut_teardown,
12567                         test_snow3g_encryption_test_case_3),
12568                 TEST_CASE_ST(ut_setup, ut_teardown,
12569                         test_snow3g_encryption_test_case_4),
12570                 TEST_CASE_ST(ut_setup, ut_teardown,
12571                         test_snow3g_encryption_test_case_5),
12572
12573                 TEST_CASE_ST(ut_setup, ut_teardown,
12574                         test_snow3g_encryption_test_case_1_oop),
12575                 TEST_CASE_ST(ut_setup, ut_teardown,
12576                         test_snow3g_decryption_test_case_1_oop),
12577                 TEST_CASE_ST(ut_setup, ut_teardown,
12578                         test_snow3g_encryption_test_case_1_oop_sgl),
12579
12580                 /** SNOW 3G decrypt only (UEA2) */
12581                 TEST_CASE_ST(ut_setup, ut_teardown,
12582                         test_snow3g_decryption_test_case_1),
12583                 TEST_CASE_ST(ut_setup, ut_teardown,
12584                         test_snow3g_decryption_test_case_2),
12585                 TEST_CASE_ST(ut_setup, ut_teardown,
12586                         test_snow3g_decryption_test_case_3),
12587                 TEST_CASE_ST(ut_setup, ut_teardown,
12588                         test_snow3g_decryption_test_case_4),
12589                 TEST_CASE_ST(ut_setup, ut_teardown,
12590                         test_snow3g_decryption_test_case_5),
12591
12592                 TEST_CASE_ST(ut_setup, ut_teardown,
12593                         test_snow3g_hash_generate_test_case_1),
12594                 TEST_CASE_ST(ut_setup, ut_teardown,
12595                         test_snow3g_hash_generate_test_case_2),
12596                 TEST_CASE_ST(ut_setup, ut_teardown,
12597                         test_snow3g_hash_generate_test_case_3),
12598                 TEST_CASE_ST(ut_setup, ut_teardown,
12599                         test_snow3g_hash_verify_test_case_1),
12600                 TEST_CASE_ST(ut_setup, ut_teardown,
12601                         test_snow3g_hash_verify_test_case_2),
12602                 TEST_CASE_ST(ut_setup, ut_teardown,
12603                         test_snow3g_hash_verify_test_case_3),
12604
12605                 /** ZUC encrypt only (EEA3) */
12606                 TEST_CASE_ST(ut_setup, ut_teardown,
12607                         test_zuc_encryption_test_case_1),
12608                 TEST_CASE_ST(ut_setup, ut_teardown,
12609                         test_zuc_encryption_test_case_2),
12610                 TEST_CASE_ST(ut_setup, ut_teardown,
12611                         test_zuc_encryption_test_case_3),
12612                 TEST_CASE_ST(ut_setup, ut_teardown,
12613                         test_zuc_encryption_test_case_4),
12614                 TEST_CASE_ST(ut_setup, ut_teardown,
12615                         test_zuc_encryption_test_case_5),
12616                 TEST_CASE_ST(ut_setup, ut_teardown,
12617                         test_zuc_hash_generate_test_case_1),
12618                 TEST_CASE_ST(ut_setup, ut_teardown,
12619                         test_zuc_hash_generate_test_case_2),
12620                 TEST_CASE_ST(ut_setup, ut_teardown,
12621                         test_zuc_hash_generate_test_case_3),
12622                 TEST_CASE_ST(ut_setup, ut_teardown,
12623                         test_zuc_hash_generate_test_case_4),
12624                 TEST_CASE_ST(ut_setup, ut_teardown,
12625                         test_zuc_hash_generate_test_case_5),
12626                 TEST_CASE_ST(ut_setup, ut_teardown,
12627                         test_zuc_encryption_test_case_6_sgl),
12628
12629                 /** KASUMI encrypt only (UEA1) */
12630                 TEST_CASE_ST(ut_setup, ut_teardown,
12631                         test_kasumi_encryption_test_case_1),
12632                 TEST_CASE_ST(ut_setup, ut_teardown,
12633                         test_kasumi_encryption_test_case_2),
12634                 TEST_CASE_ST(ut_setup, ut_teardown,
12635                         test_kasumi_encryption_test_case_3),
12636                 TEST_CASE_ST(ut_setup, ut_teardown,
12637                         test_kasumi_encryption_test_case_4),
12638                 TEST_CASE_ST(ut_setup, ut_teardown,
12639                         test_kasumi_encryption_test_case_5),
12640                 TEST_CASE_ST(ut_setup, ut_teardown,
12641                         test_kasumi_encryption_test_case_1_sgl),
12642                 TEST_CASE_ST(ut_setup, ut_teardown,
12643                         test_kasumi_encryption_test_case_1_oop_sgl),
12644                 /** KASUMI decrypt only (UEA1) */
12645                 TEST_CASE_ST(ut_setup, ut_teardown,
12646                         test_kasumi_decryption_test_case_1),
12647                 TEST_CASE_ST(ut_setup, ut_teardown,
12648                         test_kasumi_decryption_test_case_2),
12649                 TEST_CASE_ST(ut_setup, ut_teardown,
12650                         test_kasumi_decryption_test_case_3),
12651                 TEST_CASE_ST(ut_setup, ut_teardown,
12652                         test_kasumi_decryption_test_case_4),
12653                 TEST_CASE_ST(ut_setup, ut_teardown,
12654                         test_kasumi_decryption_test_case_5),
12655
12656                 TEST_CASE_ST(ut_setup, ut_teardown,
12657                         test_kasumi_encryption_test_case_1_oop),
12658                 TEST_CASE_ST(ut_setup, ut_teardown,
12659                         test_kasumi_decryption_test_case_1_oop),
12660
12661                 /** KASUMI hash only (UIA1) */
12662                 TEST_CASE_ST(ut_setup, ut_teardown,
12663                         test_kasumi_hash_generate_test_case_1),
12664                 TEST_CASE_ST(ut_setup, ut_teardown,
12665                         test_kasumi_hash_generate_test_case_2),
12666                 TEST_CASE_ST(ut_setup, ut_teardown,
12667                         test_kasumi_hash_generate_test_case_3),
12668                 TEST_CASE_ST(ut_setup, ut_teardown,
12669                         test_kasumi_hash_generate_test_case_4),
12670                 TEST_CASE_ST(ut_setup, ut_teardown,
12671                         test_kasumi_hash_generate_test_case_5),
12672                 TEST_CASE_ST(ut_setup, ut_teardown,
12673                         test_kasumi_hash_generate_test_case_6),
12674                 TEST_CASE_ST(ut_setup, ut_teardown,
12675                         test_kasumi_hash_verify_test_case_1),
12676                 TEST_CASE_ST(ut_setup, ut_teardown,
12677                         test_kasumi_hash_verify_test_case_2),
12678                 TEST_CASE_ST(ut_setup, ut_teardown,
12679                         test_kasumi_hash_verify_test_case_3),
12680                 TEST_CASE_ST(ut_setup, ut_teardown,
12681                         test_kasumi_hash_verify_test_case_4),
12682                 TEST_CASE_ST(ut_setup, ut_teardown,
12683                         test_kasumi_hash_verify_test_case_5),
12684
12685                 /** NULL tests */
12686                 TEST_CASE_ST(ut_setup, ut_teardown,
12687                         test_null_cipher_only_operation),
12688                 TEST_CASE_ST(ut_setup, ut_teardown,
12689                         test_null_auth_only_operation),
12690                 TEST_CASE_ST(ut_setup, ut_teardown,
12691                         test_null_cipher_auth_operation),
12692                 TEST_CASE_ST(ut_setup, ut_teardown,
12693                         test_null_auth_cipher_operation),
12694
12695                 /** Negative tests */
12696                 TEST_CASE_ST(ut_setup, ut_teardown,
12697                         authentication_verify_HMAC_SHA1_fail_data_corrupt),
12698                 TEST_CASE_ST(ut_setup, ut_teardown,
12699                         authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12700                 TEST_CASE_ST(ut_setup, ut_teardown,
12701                         authentication_verify_AES128_GMAC_fail_data_corrupt),
12702                 TEST_CASE_ST(ut_setup, ut_teardown,
12703                         authentication_verify_AES128_GMAC_fail_tag_corrupt),
12704                 TEST_CASE_ST(ut_setup, ut_teardown,
12705                         auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12706                 TEST_CASE_ST(ut_setup, ut_teardown,
12707                         auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12708                 TEST_CASES_END() /**< NULL terminate unit test array */
12709         }
12710 };
12711
12712 static struct unit_test_suite cryptodev_nitrox_testsuite  = {
12713         .suite_name = "Crypto NITROX Unit Test Suite",
12714         .setup = testsuite_setup,
12715         .teardown = testsuite_teardown,
12716         .unit_test_cases = {
12717                 TEST_CASE_ST(ut_setup, ut_teardown,
12718                              test_device_configure_invalid_dev_id),
12719                 TEST_CASE_ST(ut_setup, ut_teardown,
12720                                 test_device_configure_invalid_queue_pair_ids),
12721                 TEST_CASE_ST(ut_setup, ut_teardown,
12722                              test_AES_chain_nitrox_all),
12723
12724                 TEST_CASES_END() /**< NULL terminate unit test array */
12725         }
12726 };
12727
12728 static int
12729 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
12730 {
12731         gbl_driver_id = rte_cryptodev_driver_id_get(
12732                         RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
12733
12734         if (gbl_driver_id == -1) {
12735                 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
12736                 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
12737                 "are enabled in config file to run this testsuite.\n");
12738                 return TEST_SKIPPED;
12739         }
12740
12741         return unit_test_suite_runner(&cryptodev_qat_testsuite);
12742 }
12743
12744 static int
12745 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
12746 {
12747         gbl_driver_id = rte_cryptodev_driver_id_get(
12748                         RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
12749
12750         if (gbl_driver_id == -1) {
12751                 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
12752                                 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
12753                                 "in config file to run this testsuite.\n");
12754                 return TEST_FAILED;
12755         }
12756
12757         return unit_test_suite_runner(&cryptodev_virtio_testsuite);
12758 }
12759
12760 static int
12761 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
12762 {
12763         gbl_driver_id = rte_cryptodev_driver_id_get(
12764                         RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12765
12766         if (gbl_driver_id == -1) {
12767                 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
12768                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
12769                                 "in config file to run this testsuite.\n");
12770                 return TEST_SKIPPED;
12771         }
12772
12773         return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
12774 }
12775
12776 static int
12777 test_cryptodev_openssl(void)
12778 {
12779         gbl_driver_id = rte_cryptodev_driver_id_get(
12780                         RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
12781
12782         if (gbl_driver_id == -1) {
12783                 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
12784                                 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
12785                                 "in config file to run this testsuite.\n");
12786                 return TEST_SKIPPED;
12787         }
12788
12789         return unit_test_suite_runner(&cryptodev_openssl_testsuite);
12790 }
12791
12792 static int
12793 test_cryptodev_aesni_gcm(void)
12794 {
12795         gbl_driver_id = rte_cryptodev_driver_id_get(
12796                         RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
12797
12798         if (gbl_driver_id == -1) {
12799                 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
12800                                 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
12801                                 "in config file to run this testsuite.\n");
12802                 return TEST_SKIPPED;
12803         }
12804
12805         return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
12806 }
12807
12808 static int
12809 test_cryptodev_null(void)
12810 {
12811         gbl_driver_id = rte_cryptodev_driver_id_get(
12812                         RTE_STR(CRYPTODEV_NAME_NULL_PMD));
12813
12814         if (gbl_driver_id == -1) {
12815                 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
12816                                 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
12817                                 "in config file to run this testsuite.\n");
12818                 return TEST_SKIPPED;
12819         }
12820
12821         return unit_test_suite_runner(&cryptodev_null_testsuite);
12822 }
12823
12824 static int
12825 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
12826 {
12827         gbl_driver_id = rte_cryptodev_driver_id_get(
12828                         RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
12829
12830         if (gbl_driver_id == -1) {
12831                 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
12832                                 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
12833                                 "in config file to run this testsuite.\n");
12834                 return TEST_SKIPPED;
12835         }
12836
12837         return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
12838 }
12839
12840 static int
12841 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
12842 {
12843         gbl_driver_id = rte_cryptodev_driver_id_get(
12844                         RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
12845
12846         if (gbl_driver_id == -1) {
12847                 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12848                                 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
12849                                 "in config file to run this testsuite.\n");
12850                 return TEST_SKIPPED;
12851         }
12852
12853         return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
12854 }
12855
12856 static int
12857 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
12858 {
12859         gbl_driver_id = rte_cryptodev_driver_id_get(
12860                         RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
12861
12862         if (gbl_driver_id == -1) {
12863                 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
12864                                 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
12865                                 "in config file to run this testsuite.\n");
12866                 return TEST_SKIPPED;
12867         }
12868
12869         return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
12870 }
12871
12872 static int
12873 test_cryptodev_armv8(void)
12874 {
12875         gbl_driver_id = rte_cryptodev_driver_id_get(
12876                         RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
12877
12878         if (gbl_driver_id == -1) {
12879                 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
12880                                 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
12881                                 "in config file to run this testsuite.\n");
12882                 return TEST_SKIPPED;
12883         }
12884
12885         return unit_test_suite_runner(&cryptodev_armv8_testsuite);
12886 }
12887
12888 static int
12889 test_cryptodev_mrvl(void)
12890 {
12891         gbl_driver_id = rte_cryptodev_driver_id_get(
12892                         RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
12893
12894         if (gbl_driver_id == -1) {
12895                 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
12896                                 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
12897                                 "in config file to run this testsuite.\n");
12898                 return TEST_SKIPPED;
12899         }
12900
12901         return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
12902 }
12903
12904 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
12905
12906 static int
12907 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
12908 {
12909         gbl_driver_id = rte_cryptodev_driver_id_get(
12910                         RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
12911
12912         if (gbl_driver_id == -1) {
12913                 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
12914                                 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
12915                                 "in config file to run this testsuite.\n");
12916                 return TEST_SKIPPED;
12917         }
12918
12919         if (rte_cryptodev_driver_id_get(
12920                                 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
12921                 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
12922                         " enabled in config file to run this testsuite.\n");
12923                 return TEST_SKIPPED;
12924 }
12925         return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
12926 }
12927
12928 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
12929
12930 #endif
12931
12932 static int
12933 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12934 {
12935         gbl_driver_id = rte_cryptodev_driver_id_get(
12936                         RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
12937
12938         if (gbl_driver_id == -1) {
12939                 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
12940                                 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
12941                                 "in config file to run this testsuite.\n");
12942                 return TEST_SKIPPED;
12943         }
12944
12945         return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
12946 }
12947
12948 static int
12949 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
12950 {
12951         gbl_driver_id = rte_cryptodev_driver_id_get(
12952                         RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
12953
12954         if (gbl_driver_id == -1) {
12955                 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
12956                                 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
12957                                 "in config file to run this testsuite.\n");
12958                 return TEST_SKIPPED;
12959         }
12960
12961         return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
12962 }
12963
12964 static int
12965 test_cryptodev_ccp(void)
12966 {
12967         gbl_driver_id = rte_cryptodev_driver_id_get(
12968                         RTE_STR(CRYPTODEV_NAME_CCP_PMD));
12969
12970         if (gbl_driver_id == -1) {
12971                 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
12972                                 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
12973                                 "in config file to run this testsuite.\n");
12974                 return TEST_FAILED;
12975         }
12976
12977         return unit_test_suite_runner(&cryptodev_ccp_testsuite);
12978 }
12979
12980 static int
12981 test_cryptodev_octeontx(void)
12982 {
12983         gbl_driver_id = rte_cryptodev_driver_id_get(
12984                         RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
12985         if (gbl_driver_id == -1) {
12986                 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
12987                                 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
12988                                 "enabled in config file to run this "
12989                                 "testsuite.\n");
12990                 return TEST_FAILED;
12991         }
12992         return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
12993 }
12994
12995 static int
12996 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
12997 {
12998         gbl_driver_id = rte_cryptodev_driver_id_get(
12999                         RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
13000
13001         if (gbl_driver_id == -1) {
13002                 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
13003                                 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
13004                                 "in config file to run this testsuite.\n");
13005                 return TEST_FAILED;
13006         }
13007
13008         return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
13009 }
13010
13011 static int
13012 test_cryptodev_nitrox(void)
13013 {
13014         gbl_driver_id = rte_cryptodev_driver_id_get(
13015                         RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
13016
13017         if (gbl_driver_id == -1) {
13018                 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
13019                                 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
13020                                 "in config file to run this testsuite.\n");
13021                 return TEST_FAILED;
13022         }
13023
13024         return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
13025 }
13026
13027 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
13028 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
13029 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
13030 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
13031 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
13032 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
13033 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
13034 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
13035 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
13036 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
13037 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
13038 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
13039 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
13040 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
13041 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
13042 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
13043 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);