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