1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
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"
42 #define VDEV_ARGS_SIZE 100
43 #define MAX_NB_SESSIONS 4
45 static int gbl_driver_id;
47 struct crypto_testsuite_params {
48 struct rte_mempool *mbuf_pool;
49 struct rte_mempool *large_mbuf_pool;
50 struct rte_mempool *op_mpool;
51 struct rte_mempool *session_mpool;
52 struct rte_cryptodev_config conf;
53 struct rte_cryptodev_qp_conf qp_conf;
55 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
56 uint8_t valid_dev_count;
59 struct crypto_unittest_params {
60 struct rte_crypto_sym_xform cipher_xform;
61 struct rte_crypto_sym_xform auth_xform;
62 struct rte_crypto_sym_xform aead_xform;
64 struct rte_cryptodev_sym_session *sess;
66 struct rte_crypto_op *op;
68 struct rte_mbuf *obuf, *ibuf;
73 #define ALIGN_POW2_ROUNDUP(num, align) \
74 (((num) + (align) - 1) & ~((align) - 1))
77 * Forward declarations.
80 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
81 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
85 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
86 struct crypto_unittest_params *ut_params,
87 struct crypto_testsuite_params *ts_param,
88 const uint8_t *cipher,
89 const uint8_t *digest,
92 static struct rte_mbuf *
93 setup_test_string(struct rte_mempool *mpool,
94 const char *string, size_t len, uint8_t blocksize)
96 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
97 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
99 memset(m->buf_addr, 0, m->buf_len);
101 char *dst = rte_pktmbuf_append(m, t_len);
108 rte_memcpy(dst, string, t_len);
110 memset(dst, 0, t_len);
116 /* Get number of bytes in X bits (rounding up) */
118 ceil_byte_length(uint32_t num_bits)
121 return ((num_bits >> 3) + 1);
123 return (num_bits >> 3);
126 static struct rte_crypto_op *
127 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
129 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
130 printf("Error sending packet for encryption");
136 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
142 static struct crypto_testsuite_params testsuite_params = { NULL };
143 static struct crypto_unittest_params unittest_params;
146 testsuite_setup(void)
148 struct crypto_testsuite_params *ts_params = &testsuite_params;
149 struct rte_cryptodev_info info;
150 uint32_t i = 0, nb_devs, dev_id;
154 memset(ts_params, 0, sizeof(*ts_params));
156 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
157 if (ts_params->mbuf_pool == NULL) {
158 /* Not already created so create */
159 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
161 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
163 if (ts_params->mbuf_pool == NULL) {
164 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
169 ts_params->large_mbuf_pool = rte_mempool_lookup(
170 "CRYPTO_LARGE_MBUFPOOL");
171 if (ts_params->large_mbuf_pool == NULL) {
172 /* Not already created so create */
173 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
174 "CRYPTO_LARGE_MBUFPOOL",
177 if (ts_params->large_mbuf_pool == NULL) {
179 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
184 ts_params->op_mpool = rte_crypto_op_pool_create(
185 "MBUF_CRYPTO_SYM_OP_POOL",
186 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
187 NUM_MBUFS, MBUF_CACHE_SIZE,
189 sizeof(struct rte_crypto_sym_xform) +
192 if (ts_params->op_mpool == NULL) {
193 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
197 /* Create an AESNI MB device if required */
198 if (gbl_driver_id == rte_cryptodev_driver_id_get(
199 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
200 nb_devs = rte_cryptodev_device_count_by_driver(
201 rte_cryptodev_driver_id_get(
202 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
205 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
207 TEST_ASSERT(ret == 0,
208 "Failed to create instance of"
210 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
214 /* Create an AESNI GCM device if required */
215 if (gbl_driver_id == rte_cryptodev_driver_id_get(
216 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
217 nb_devs = rte_cryptodev_device_count_by_driver(
218 rte_cryptodev_driver_id_get(
219 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
221 TEST_ASSERT_SUCCESS(rte_vdev_init(
222 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
223 "Failed to create instance of"
225 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
229 /* Create a SNOW 3G device if required */
230 if (gbl_driver_id == rte_cryptodev_driver_id_get(
231 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
232 nb_devs = rte_cryptodev_device_count_by_driver(
233 rte_cryptodev_driver_id_get(
234 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
236 TEST_ASSERT_SUCCESS(rte_vdev_init(
237 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
238 "Failed to create instance of"
240 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
244 /* Create a KASUMI device if required */
245 if (gbl_driver_id == rte_cryptodev_driver_id_get(
246 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
247 nb_devs = rte_cryptodev_device_count_by_driver(
248 rte_cryptodev_driver_id_get(
249 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
251 TEST_ASSERT_SUCCESS(rte_vdev_init(
252 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
253 "Failed to create instance of"
255 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
259 /* Create a ZUC device if required */
260 if (gbl_driver_id == rte_cryptodev_driver_id_get(
261 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
262 nb_devs = rte_cryptodev_device_count_by_driver(
263 rte_cryptodev_driver_id_get(
264 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
266 TEST_ASSERT_SUCCESS(rte_vdev_init(
267 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
268 "Failed to create instance of"
270 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
274 /* Create a NULL device if required */
275 if (gbl_driver_id == rte_cryptodev_driver_id_get(
276 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
277 nb_devs = rte_cryptodev_device_count_by_driver(
278 rte_cryptodev_driver_id_get(
279 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
282 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
284 TEST_ASSERT(ret == 0,
285 "Failed to create instance of"
287 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
291 /* Create an OPENSSL device if required */
292 if (gbl_driver_id == rte_cryptodev_driver_id_get(
293 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
294 nb_devs = rte_cryptodev_device_count_by_driver(
295 rte_cryptodev_driver_id_get(
296 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
299 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
302 TEST_ASSERT(ret == 0, "Failed to create "
303 "instance of pmd : %s",
304 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
308 /* Create a ARMv8 device if required */
309 if (gbl_driver_id == rte_cryptodev_driver_id_get(
310 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
311 nb_devs = rte_cryptodev_device_count_by_driver(
312 rte_cryptodev_driver_id_get(
313 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
316 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
319 TEST_ASSERT(ret == 0, "Failed to create "
320 "instance of pmd : %s",
321 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
325 /* Create a MVSAM device if required */
326 if (gbl_driver_id == rte_cryptodev_driver_id_get(
327 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
328 nb_devs = rte_cryptodev_device_count_by_driver(
329 rte_cryptodev_driver_id_get(
330 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
333 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
336 TEST_ASSERT(ret == 0, "Failed to create "
337 "instance of pmd : %s",
338 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
342 /* Create an CCP device if required */
343 if (gbl_driver_id == rte_cryptodev_driver_id_get(
344 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
345 nb_devs = rte_cryptodev_device_count_by_driver(
346 rte_cryptodev_driver_id_get(
347 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
350 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
353 TEST_ASSERT(ret == 0, "Failed to create "
354 "instance of pmd : %s",
355 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
359 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
360 char vdev_args[VDEV_ARGS_SIZE] = {""};
361 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
362 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
363 uint16_t slave_core_count = 0;
364 uint16_t socket_id = 0;
366 if (gbl_driver_id == rte_cryptodev_driver_id_get(
367 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
369 /* Identify the Slave Cores
370 * Use 2 slave cores for the device args
372 RTE_LCORE_FOREACH_SLAVE(i) {
373 if (slave_core_count > 1)
375 snprintf(vdev_args, sizeof(vdev_args),
376 "%s%d", temp_str, i);
377 strcpy(temp_str, vdev_args);
378 strlcat(temp_str, ";", sizeof(temp_str));
380 socket_id = lcore_config[i].socket_id;
382 if (slave_core_count != 2) {
384 "Cryptodev scheduler test require at least "
385 "two slave cores to run. "
386 "Please use the correct coremask.\n");
389 strcpy(temp_str, vdev_args);
390 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
391 temp_str, socket_id);
392 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
393 nb_devs = rte_cryptodev_device_count_by_driver(
394 rte_cryptodev_driver_id_get(
395 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
398 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
400 TEST_ASSERT(ret == 0,
401 "Failed to create instance %u of"
403 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
406 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
408 nb_devs = rte_cryptodev_count();
410 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
414 /* Create list of valid crypto devs */
415 for (i = 0; i < nb_devs; i++) {
416 rte_cryptodev_info_get(i, &info);
417 if (info.driver_id == gbl_driver_id)
418 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
421 if (ts_params->valid_dev_count < 1)
424 /* Set up all the qps on the first of the valid devices found */
426 dev_id = ts_params->valid_devs[0];
428 rte_cryptodev_info_get(dev_id, &info);
430 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
431 ts_params->conf.socket_id = SOCKET_ID_ANY;
433 unsigned int session_size =
434 rte_cryptodev_sym_get_private_session_size(dev_id);
437 * Create mempool with maximum number of sessions * 2,
438 * to include the session headers
440 if (info.sym.max_nb_sessions != 0 &&
441 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
442 RTE_LOG(ERR, USER1, "Device does not support "
443 "at least %u sessions\n",
448 ts_params->session_mpool = rte_mempool_create(
452 0, 0, NULL, NULL, NULL,
456 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
457 "session mempool allocation failed");
459 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
461 "Failed to configure cryptodev %u with %u qps",
462 dev_id, ts_params->conf.nb_queue_pairs);
464 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
466 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
467 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
468 dev_id, qp_id, &ts_params->qp_conf,
469 rte_cryptodev_socket_id(dev_id),
470 ts_params->session_mpool),
471 "Failed to setup queue pair %u on cryptodev %u",
479 testsuite_teardown(void)
481 struct crypto_testsuite_params *ts_params = &testsuite_params;
483 if (ts_params->mbuf_pool != NULL) {
484 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
485 rte_mempool_avail_count(ts_params->mbuf_pool));
488 if (ts_params->op_mpool != NULL) {
489 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
490 rte_mempool_avail_count(ts_params->op_mpool));
493 /* Free session mempools */
494 if (ts_params->session_mpool != NULL) {
495 rte_mempool_free(ts_params->session_mpool);
496 ts_params->session_mpool = NULL;
503 struct crypto_testsuite_params *ts_params = &testsuite_params;
504 struct crypto_unittest_params *ut_params = &unittest_params;
508 /* Clear unit test parameters before running test */
509 memset(ut_params, 0, sizeof(*ut_params));
511 /* Reconfigure device to default parameters */
512 ts_params->conf.socket_id = SOCKET_ID_ANY;
514 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
516 "Failed to configure cryptodev %u",
517 ts_params->valid_devs[0]);
519 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
520 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
521 ts_params->valid_devs[0], qp_id,
523 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
524 ts_params->session_mpool),
525 "Failed to setup queue pair %u on cryptodev %u",
526 qp_id, ts_params->valid_devs[0]);
530 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
532 /* Start the device */
533 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
534 "Failed to start cryptodev %u",
535 ts_params->valid_devs[0]);
543 struct crypto_testsuite_params *ts_params = &testsuite_params;
544 struct crypto_unittest_params *ut_params = &unittest_params;
545 struct rte_cryptodev_stats stats;
547 /* free crypto session structure */
548 if (ut_params->sess) {
549 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
551 rte_cryptodev_sym_session_free(ut_params->sess);
552 ut_params->sess = NULL;
555 /* free crypto operation structure */
557 rte_crypto_op_free(ut_params->op);
560 * free mbuf - both obuf and ibuf are usually the same,
561 * so check if they point at the same address is necessary,
562 * to avoid freeing the mbuf twice.
564 if (ut_params->obuf) {
565 rte_pktmbuf_free(ut_params->obuf);
566 if (ut_params->ibuf == ut_params->obuf)
570 if (ut_params->ibuf) {
571 rte_pktmbuf_free(ut_params->ibuf);
575 if (ts_params->mbuf_pool != NULL)
576 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
577 rte_mempool_avail_count(ts_params->mbuf_pool));
579 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
581 /* Stop the device */
582 rte_cryptodev_stop(ts_params->valid_devs[0]);
586 test_device_configure_invalid_dev_id(void)
588 struct crypto_testsuite_params *ts_params = &testsuite_params;
589 uint16_t dev_id, num_devs = 0;
591 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
592 "Need at least %d devices for test", 1);
594 /* valid dev_id values */
595 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
597 /* Stop the device in case it's started so it can be configured */
598 rte_cryptodev_stop(dev_id);
600 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
601 "Failed test for rte_cryptodev_configure: "
602 "invalid dev_num %u", dev_id);
604 /* invalid dev_id values */
607 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
608 "Failed test for rte_cryptodev_configure: "
609 "invalid dev_num %u", dev_id);
613 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
614 "Failed test for rte_cryptodev_configure:"
615 "invalid dev_num %u", dev_id);
621 test_device_configure_invalid_queue_pair_ids(void)
623 struct crypto_testsuite_params *ts_params = &testsuite_params;
624 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
626 /* Stop the device in case it's started so it can be configured */
627 rte_cryptodev_stop(ts_params->valid_devs[0]);
629 /* valid - one queue pairs */
630 ts_params->conf.nb_queue_pairs = 1;
632 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
634 "Failed to configure cryptodev: dev_id %u, qp_id %u",
635 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
638 /* valid - max value queue pairs */
639 ts_params->conf.nb_queue_pairs = orig_nb_qps;
641 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
643 "Failed to configure cryptodev: dev_id %u, qp_id %u",
644 ts_params->valid_devs[0],
645 ts_params->conf.nb_queue_pairs);
648 /* invalid - zero queue pairs */
649 ts_params->conf.nb_queue_pairs = 0;
651 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
653 "Failed test for rte_cryptodev_configure, dev_id %u,"
655 ts_params->valid_devs[0],
656 ts_params->conf.nb_queue_pairs);
659 /* invalid - max value supported by field queue pairs */
660 ts_params->conf.nb_queue_pairs = UINT16_MAX;
662 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
664 "Failed test for rte_cryptodev_configure, dev_id %u,"
666 ts_params->valid_devs[0],
667 ts_params->conf.nb_queue_pairs);
670 /* invalid - max value + 1 queue pairs */
671 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
673 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
675 "Failed test for rte_cryptodev_configure, dev_id %u,"
677 ts_params->valid_devs[0],
678 ts_params->conf.nb_queue_pairs);
680 /* revert to original testsuite value */
681 ts_params->conf.nb_queue_pairs = orig_nb_qps;
687 test_queue_pair_descriptor_setup(void)
689 struct crypto_testsuite_params *ts_params = &testsuite_params;
690 struct rte_cryptodev_info dev_info;
691 struct rte_cryptodev_qp_conf qp_conf = {
692 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
697 /* Stop the device in case it's started so it can be configured */
698 rte_cryptodev_stop(ts_params->valid_devs[0]);
701 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
703 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
705 "Failed to configure cryptodev %u",
706 ts_params->valid_devs[0]);
709 * Test various ring sizes on this device. memzones can't be
710 * freed so are re-used if ring is released and re-created.
712 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
714 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
715 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
716 ts_params->valid_devs[0], qp_id, &qp_conf,
717 rte_cryptodev_socket_id(
718 ts_params->valid_devs[0]),
719 ts_params->session_mpool),
721 "rte_cryptodev_queue_pair_setup: num_inflights "
722 "%u on qp %u on cryptodev %u",
723 qp_conf.nb_descriptors, qp_id,
724 ts_params->valid_devs[0]);
727 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
729 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
730 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
731 ts_params->valid_devs[0], qp_id, &qp_conf,
732 rte_cryptodev_socket_id(
733 ts_params->valid_devs[0]),
734 ts_params->session_mpool),
736 " rte_cryptodev_queue_pair_setup: num_inflights"
737 " %u on qp %u on cryptodev %u",
738 qp_conf.nb_descriptors, qp_id,
739 ts_params->valid_devs[0]);
742 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
744 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
745 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
746 ts_params->valid_devs[0], qp_id, &qp_conf,
747 rte_cryptodev_socket_id(
748 ts_params->valid_devs[0]),
749 ts_params->session_mpool),
751 "rte_cryptodev_queue_pair_setup: num_inflights"
752 " %u on qp %u on cryptodev %u",
753 qp_conf.nb_descriptors, qp_id,
754 ts_params->valid_devs[0]);
757 /* invalid number of descriptors - max supported + 2 */
758 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
760 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
761 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
762 ts_params->valid_devs[0], qp_id, &qp_conf,
763 rte_cryptodev_socket_id(
764 ts_params->valid_devs[0]),
765 ts_params->session_mpool),
766 "Unexpectedly passed test for "
767 "rte_cryptodev_queue_pair_setup:"
768 "num_inflights %u on qp %u on cryptodev %u",
769 qp_conf.nb_descriptors, qp_id,
770 ts_params->valid_devs[0]);
773 /* invalid number of descriptors - max value of parameter */
774 qp_conf.nb_descriptors = UINT32_MAX-1;
776 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
777 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
778 ts_params->valid_devs[0], qp_id, &qp_conf,
779 rte_cryptodev_socket_id(
780 ts_params->valid_devs[0]),
781 ts_params->session_mpool),
782 "Unexpectedly passed test for "
783 "rte_cryptodev_queue_pair_setup:"
784 "num_inflights %u on qp %u on cryptodev %u",
785 qp_conf.nb_descriptors, qp_id,
786 ts_params->valid_devs[0]);
789 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
791 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
792 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
793 ts_params->valid_devs[0], qp_id, &qp_conf,
794 rte_cryptodev_socket_id(
795 ts_params->valid_devs[0]),
796 ts_params->session_mpool),
798 " rte_cryptodev_queue_pair_setup:"
799 "num_inflights %u on qp %u on cryptodev %u",
800 qp_conf.nb_descriptors, qp_id,
801 ts_params->valid_devs[0]);
804 /* invalid number of descriptors - max supported + 1 */
805 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
807 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
808 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
809 ts_params->valid_devs[0], qp_id, &qp_conf,
810 rte_cryptodev_socket_id(
811 ts_params->valid_devs[0]),
812 ts_params->session_mpool),
813 "Unexpectedly passed test for "
814 "rte_cryptodev_queue_pair_setup:"
815 "num_inflights %u on qp %u on cryptodev %u",
816 qp_conf.nb_descriptors, qp_id,
817 ts_params->valid_devs[0]);
820 /* test invalid queue pair id */
821 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
823 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
825 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
826 ts_params->valid_devs[0],
828 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
829 ts_params->session_mpool),
830 "Failed test for rte_cryptodev_queue_pair_setup:"
831 "invalid qp %u on cryptodev %u",
832 qp_id, ts_params->valid_devs[0]);
834 qp_id = 0xffff; /*invalid*/
836 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
837 ts_params->valid_devs[0],
839 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
840 ts_params->session_mpool),
841 "Failed test for rte_cryptodev_queue_pair_setup:"
842 "invalid qp %u on cryptodev %u",
843 qp_id, ts_params->valid_devs[0]);
848 /* ***** Plaintext data for tests ***** */
850 const char catch_22_quote_1[] =
851 "There was only one catch and that was Catch-22, which "
852 "specified that a concern for one's safety in the face of "
853 "dangers that were real and immediate was the process of a "
854 "rational mind. Orr was crazy and could be grounded. All he "
855 "had to do was ask; and as soon as he did, he would no longer "
856 "be crazy and would have to fly more missions. Orr would be "
857 "crazy to fly more missions and sane if he didn't, but if he "
858 "was sane he had to fly them. If he flew them he was crazy "
859 "and didn't have to; but if he didn't want to he was sane and "
860 "had to. Yossarian was moved very deeply by the absolute "
861 "simplicity of this clause of Catch-22 and let out a "
862 "respectful whistle. \"That's some catch, that Catch-22\", he "
863 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
865 const char catch_22_quote[] =
866 "What a lousy earth! He wondered how many people were "
867 "destitute that same night even in his own prosperous country, "
868 "how many homes were shanties, how many husbands were drunk "
869 "and wives socked, and how many children were bullied, abused, "
870 "or abandoned. How many families hungered for food they could "
871 "not afford to buy? How many hearts were broken? How many "
872 "suicides would take place that same night, how many people "
873 "would go insane? How many cockroaches and landlords would "
874 "triumph? How many winners were losers, successes failures, "
875 "and rich men poor men? How many wise guys were stupid? How "
876 "many happy endings were unhappy endings? How many honest men "
877 "were liars, brave men cowards, loyal men traitors, how many "
878 "sainted men were corrupt, how many people in positions of "
879 "trust had sold their souls to bodyguards, how many had never "
880 "had souls? How many straight-and-narrow paths were crooked "
881 "paths? How many best families were worst families and how "
882 "many good people were bad people? When you added them all up "
883 "and then subtracted, you might be left with only the children, "
884 "and perhaps with Albert Einstein and an old violinist or "
885 "sculptor somewhere.";
887 #define QUOTE_480_BYTES (480)
888 #define QUOTE_512_BYTES (512)
889 #define QUOTE_768_BYTES (768)
890 #define QUOTE_1024_BYTES (1024)
894 /* ***** SHA1 Hash Tests ***** */
896 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
898 static uint8_t hmac_sha1_key[] = {
899 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
900 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
901 0xDE, 0xF4, 0xDE, 0xAD };
903 /* ***** SHA224 Hash Tests ***** */
905 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
908 /* ***** AES-CBC Cipher Tests ***** */
910 #define CIPHER_KEY_LENGTH_AES_CBC (16)
911 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
913 static uint8_t aes_cbc_key[] = {
914 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
915 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
917 static uint8_t aes_cbc_iv[] = {
918 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
919 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
922 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
924 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
925 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
926 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
927 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
928 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
929 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
930 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
931 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
932 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
933 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
934 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
935 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
936 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
937 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
938 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
939 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
940 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
941 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
942 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
943 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
944 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
945 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
946 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
947 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
948 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
949 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
950 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
951 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
952 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
953 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
954 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
955 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
956 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
957 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
958 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
959 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
960 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
961 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
962 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
963 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
964 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
965 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
966 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
967 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
968 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
969 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
970 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
971 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
972 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
973 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
974 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
975 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
976 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
977 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
978 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
979 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
980 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
981 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
982 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
983 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
984 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
985 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
986 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
987 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
988 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
991 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
992 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
993 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
994 0x18, 0x8c, 0x1d, 0x32
998 /* Multisession Vector context Test */
1000 static uint8_t ms_aes_cbc_key0[] = {
1001 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1002 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1005 static uint8_t ms_aes_cbc_iv0[] = {
1006 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1007 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1010 static const uint8_t ms_aes_cbc_cipher0[] = {
1011 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1012 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1013 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1014 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1015 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1016 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1017 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1018 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1019 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1020 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1021 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1022 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1023 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1024 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1025 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1026 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1027 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1028 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1029 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1030 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1031 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1032 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1033 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1034 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1035 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1036 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1037 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1038 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1039 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1040 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1041 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1042 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1043 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1044 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1045 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1046 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1047 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1048 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1049 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1050 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1051 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1052 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1053 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1054 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1055 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1056 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1057 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1058 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1059 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1060 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1061 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1062 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1063 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1064 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1065 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1066 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1067 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1068 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1069 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1070 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1071 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1072 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1073 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1074 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1078 static uint8_t ms_hmac_key0[] = {
1079 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1080 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1081 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1082 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1083 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1084 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1085 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1086 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1089 static const uint8_t ms_hmac_digest0[] = {
1090 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1091 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1092 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1093 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1094 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1095 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1096 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1097 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1101 /* Begin session 1 */
1103 static uint8_t ms_aes_cbc_key1[] = {
1104 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1105 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1108 static uint8_t ms_aes_cbc_iv1[] = {
1109 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1110 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1113 static const uint8_t ms_aes_cbc_cipher1[] = {
1114 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1115 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1116 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1117 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1118 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1119 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1120 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1121 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1122 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1123 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1124 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1125 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1126 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1127 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1128 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1129 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1130 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1131 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1132 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1133 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1134 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1135 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1136 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1137 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1138 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1139 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1140 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1141 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1142 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1143 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1144 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1145 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1146 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1147 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1148 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1149 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1150 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1151 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1152 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1153 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1154 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1155 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1156 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1157 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1158 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1159 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1160 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1161 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1162 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1163 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1164 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1165 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1166 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1167 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1168 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1169 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1170 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1171 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1172 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1173 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1174 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1175 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1176 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1177 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1181 static uint8_t ms_hmac_key1[] = {
1182 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1183 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1184 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1185 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1186 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1187 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1188 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1189 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1192 static const uint8_t ms_hmac_digest1[] = {
1193 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1194 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1195 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1196 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1197 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1198 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1199 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1200 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1203 /* Begin Session 2 */
1204 static uint8_t ms_aes_cbc_key2[] = {
1205 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1206 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1209 static uint8_t ms_aes_cbc_iv2[] = {
1210 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1211 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1214 static const uint8_t ms_aes_cbc_cipher2[] = {
1215 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1216 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1217 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1218 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1219 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1220 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1221 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1222 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1223 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1224 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1225 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1226 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1227 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1228 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1229 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1230 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1231 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1232 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1233 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1234 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1235 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1236 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1237 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1238 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1239 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1240 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1241 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1242 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1243 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1244 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1245 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1246 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1247 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1248 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1249 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1250 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1251 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1252 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1253 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1254 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1255 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1256 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1257 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1258 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1259 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1260 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1261 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1262 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1263 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1264 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1265 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1266 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1267 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1268 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1269 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1270 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1271 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1272 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1273 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1274 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1275 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1276 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1277 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1278 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1281 static uint8_t ms_hmac_key2[] = {
1282 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1283 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1284 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1285 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1286 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1287 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1288 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1289 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1292 static const uint8_t ms_hmac_digest2[] = {
1293 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1294 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1295 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1296 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1297 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1298 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1299 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1300 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1307 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1309 struct crypto_testsuite_params *ts_params = &testsuite_params;
1310 struct crypto_unittest_params *ut_params = &unittest_params;
1312 /* Generate test mbuf data and space for digest */
1313 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1314 catch_22_quote, QUOTE_512_BYTES, 0);
1316 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1317 DIGEST_BYTE_LENGTH_SHA1);
1318 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1320 /* Setup Cipher Parameters */
1321 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1322 ut_params->cipher_xform.next = &ut_params->auth_xform;
1324 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1325 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1326 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1327 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1328 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1329 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1331 /* Setup HMAC Parameters */
1332 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1334 ut_params->auth_xform.next = NULL;
1336 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1337 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1338 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1339 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1340 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1342 ut_params->sess = rte_cryptodev_sym_session_create(
1343 ts_params->session_mpool);
1345 /* Create crypto session*/
1346 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1347 ut_params->sess, &ut_params->cipher_xform,
1348 ts_params->session_mpool);
1349 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1351 /* Generate crypto op data structure */
1352 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1353 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1354 TEST_ASSERT_NOT_NULL(ut_params->op,
1355 "Failed to allocate symmetric crypto operation struct");
1357 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1359 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1361 /* set crypto operation source mbuf */
1362 sym_op->m_src = ut_params->ibuf;
1364 /* Set crypto operation authentication parameters */
1365 sym_op->auth.digest.data = ut_params->digest;
1366 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1367 ut_params->ibuf, QUOTE_512_BYTES);
1369 sym_op->auth.data.offset = 0;
1370 sym_op->auth.data.length = QUOTE_512_BYTES;
1372 /* Copy IV at the end of the crypto operation */
1373 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1374 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1376 /* Set crypto operation cipher parameters */
1377 sym_op->cipher.data.offset = 0;
1378 sym_op->cipher.data.length = QUOTE_512_BYTES;
1380 /* Process crypto operation */
1381 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1382 ut_params->op), "failed to process sym crypto op");
1384 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1385 "crypto op processing failed");
1388 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1391 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1392 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1394 "ciphertext data not as expected");
1396 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1398 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1399 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1400 gbl_driver_id == rte_cryptodev_driver_id_get(
1401 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1402 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1403 DIGEST_BYTE_LENGTH_SHA1,
1404 "Generated digest data not as expected");
1406 return TEST_SUCCESS;
1409 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1411 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1413 static uint8_t hmac_sha512_key[] = {
1414 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1415 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1416 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1417 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1418 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1419 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1420 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1421 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1423 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1424 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1425 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1426 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1427 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1428 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1429 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1430 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1431 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1436 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1437 struct crypto_unittest_params *ut_params,
1438 uint8_t *cipher_key,
1442 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1443 struct crypto_unittest_params *ut_params,
1444 struct crypto_testsuite_params *ts_params,
1445 const uint8_t *cipher,
1446 const uint8_t *digest,
1451 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1452 struct crypto_unittest_params *ut_params,
1453 uint8_t *cipher_key,
1457 /* Setup Cipher Parameters */
1458 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1459 ut_params->cipher_xform.next = NULL;
1461 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1462 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1463 ut_params->cipher_xform.cipher.key.data = cipher_key;
1464 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1465 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1466 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1468 /* Setup HMAC Parameters */
1469 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1470 ut_params->auth_xform.next = &ut_params->cipher_xform;
1472 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1473 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1474 ut_params->auth_xform.auth.key.data = hmac_key;
1475 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1476 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1478 return TEST_SUCCESS;
1483 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1484 struct crypto_unittest_params *ut_params,
1485 struct crypto_testsuite_params *ts_params,
1486 const uint8_t *cipher,
1487 const uint8_t *digest,
1490 /* Generate test mbuf data and digest */
1491 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1494 QUOTE_512_BYTES, 0);
1496 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1497 DIGEST_BYTE_LENGTH_SHA512);
1498 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1500 rte_memcpy(ut_params->digest,
1502 DIGEST_BYTE_LENGTH_SHA512);
1504 /* Generate Crypto op data structure */
1505 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1506 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1507 TEST_ASSERT_NOT_NULL(ut_params->op,
1508 "Failed to allocate symmetric crypto operation struct");
1510 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1512 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1514 /* set crypto operation source mbuf */
1515 sym_op->m_src = ut_params->ibuf;
1517 sym_op->auth.digest.data = ut_params->digest;
1518 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1519 ut_params->ibuf, QUOTE_512_BYTES);
1521 sym_op->auth.data.offset = 0;
1522 sym_op->auth.data.length = QUOTE_512_BYTES;
1524 /* Copy IV at the end of the crypto operation */
1525 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1526 iv, CIPHER_IV_LENGTH_AES_CBC);
1528 sym_op->cipher.data.offset = 0;
1529 sym_op->cipher.data.length = QUOTE_512_BYTES;
1531 /* Process crypto operation */
1532 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1533 ut_params->op), "failed to process sym crypto op");
1535 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1536 "crypto op processing failed");
1538 ut_params->obuf = ut_params->op->sym->m_src;
1541 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1542 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1545 "Plaintext data not as expected");
1548 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1549 "Digest verification failed");
1551 return TEST_SUCCESS;
1555 test_AES_cipheronly_mb_all(void)
1557 struct crypto_testsuite_params *ts_params = &testsuite_params;
1560 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1561 ts_params->op_mpool,
1562 ts_params->session_mpool,
1563 ts_params->valid_devs[0],
1564 rte_cryptodev_driver_id_get(
1565 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1566 BLKCIPHER_AES_CIPHERONLY_TYPE);
1568 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1570 return TEST_SUCCESS;
1574 test_AES_docsis_mb_all(void)
1576 struct crypto_testsuite_params *ts_params = &testsuite_params;
1579 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1580 ts_params->op_mpool,
1581 ts_params->session_mpool,
1582 ts_params->valid_devs[0],
1583 rte_cryptodev_driver_id_get(
1584 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1585 BLKCIPHER_AES_DOCSIS_TYPE);
1587 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1589 return TEST_SUCCESS;
1593 test_AES_docsis_qat_all(void)
1595 struct crypto_testsuite_params *ts_params = &testsuite_params;
1598 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1599 ts_params->op_mpool,
1600 ts_params->session_mpool,
1601 ts_params->valid_devs[0],
1602 rte_cryptodev_driver_id_get(
1603 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1604 BLKCIPHER_AES_DOCSIS_TYPE);
1606 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1608 return TEST_SUCCESS;
1612 test_DES_docsis_qat_all(void)
1614 struct crypto_testsuite_params *ts_params = &testsuite_params;
1617 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1618 ts_params->op_mpool,
1619 ts_params->session_mpool,
1620 ts_params->valid_devs[0],
1621 rte_cryptodev_driver_id_get(
1622 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1623 BLKCIPHER_DES_DOCSIS_TYPE);
1625 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1627 return TEST_SUCCESS;
1631 test_authonly_mb_all(void)
1633 struct crypto_testsuite_params *ts_params = &testsuite_params;
1636 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1637 ts_params->op_mpool,
1638 ts_params->session_mpool,
1639 ts_params->valid_devs[0],
1640 rte_cryptodev_driver_id_get(
1641 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1642 BLKCIPHER_AUTHONLY_TYPE);
1644 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1646 return TEST_SUCCESS;
1650 test_authonly_qat_all(void)
1652 struct crypto_testsuite_params *ts_params = &testsuite_params;
1655 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1656 ts_params->op_mpool,
1657 ts_params->session_mpool,
1658 ts_params->valid_devs[0],
1659 rte_cryptodev_driver_id_get(
1660 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1661 BLKCIPHER_AUTHONLY_TYPE);
1663 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1665 return TEST_SUCCESS;
1668 test_AES_chain_mb_all(void)
1670 struct crypto_testsuite_params *ts_params = &testsuite_params;
1673 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1674 ts_params->op_mpool,
1675 ts_params->session_mpool,
1676 ts_params->valid_devs[0],
1677 rte_cryptodev_driver_id_get(
1678 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1679 BLKCIPHER_AES_CHAIN_TYPE);
1681 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1683 return TEST_SUCCESS;
1686 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1689 test_AES_cipheronly_scheduler_all(void)
1691 struct crypto_testsuite_params *ts_params = &testsuite_params;
1694 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1695 ts_params->op_mpool,
1696 ts_params->session_mpool,
1697 ts_params->valid_devs[0],
1698 rte_cryptodev_driver_id_get(
1699 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1700 BLKCIPHER_AES_CIPHERONLY_TYPE);
1702 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1704 return TEST_SUCCESS;
1708 test_AES_chain_scheduler_all(void)
1710 struct crypto_testsuite_params *ts_params = &testsuite_params;
1713 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1714 ts_params->op_mpool,
1715 ts_params->session_mpool,
1716 ts_params->valid_devs[0],
1717 rte_cryptodev_driver_id_get(
1718 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1719 BLKCIPHER_AES_CHAIN_TYPE);
1721 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1723 return TEST_SUCCESS;
1727 test_authonly_scheduler_all(void)
1729 struct crypto_testsuite_params *ts_params = &testsuite_params;
1732 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1733 ts_params->op_mpool,
1734 ts_params->session_mpool,
1735 ts_params->valid_devs[0],
1736 rte_cryptodev_driver_id_get(
1737 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1738 BLKCIPHER_AUTHONLY_TYPE);
1740 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1742 return TEST_SUCCESS;
1745 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1748 test_AES_chain_openssl_all(void)
1750 struct crypto_testsuite_params *ts_params = &testsuite_params;
1753 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1754 ts_params->op_mpool,
1755 ts_params->session_mpool,
1756 ts_params->valid_devs[0],
1757 rte_cryptodev_driver_id_get(
1758 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1759 BLKCIPHER_AES_CHAIN_TYPE);
1761 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1763 return TEST_SUCCESS;
1767 test_AES_cipheronly_openssl_all(void)
1769 struct crypto_testsuite_params *ts_params = &testsuite_params;
1772 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1773 ts_params->op_mpool,
1774 ts_params->session_mpool,
1775 ts_params->valid_devs[0],
1776 rte_cryptodev_driver_id_get(
1777 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1778 BLKCIPHER_AES_CIPHERONLY_TYPE);
1780 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1782 return TEST_SUCCESS;
1786 test_AES_chain_ccp_all(void)
1788 struct crypto_testsuite_params *ts_params = &testsuite_params;
1791 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1792 ts_params->op_mpool,
1793 ts_params->session_mpool,
1794 ts_params->valid_devs[0],
1795 rte_cryptodev_driver_id_get(
1796 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1797 BLKCIPHER_AES_CHAIN_TYPE);
1799 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1801 return TEST_SUCCESS;
1805 test_AES_cipheronly_ccp_all(void)
1807 struct crypto_testsuite_params *ts_params = &testsuite_params;
1810 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1811 ts_params->op_mpool,
1812 ts_params->session_mpool,
1813 ts_params->valid_devs[0],
1814 rte_cryptodev_driver_id_get(
1815 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1816 BLKCIPHER_AES_CIPHERONLY_TYPE);
1818 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1820 return TEST_SUCCESS;
1824 test_AES_chain_qat_all(void)
1826 struct crypto_testsuite_params *ts_params = &testsuite_params;
1829 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1830 ts_params->op_mpool,
1831 ts_params->session_mpool,
1832 ts_params->valid_devs[0],
1833 rte_cryptodev_driver_id_get(
1834 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1835 BLKCIPHER_AES_CHAIN_TYPE);
1837 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1839 return TEST_SUCCESS;
1843 test_AES_cipheronly_qat_all(void)
1845 struct crypto_testsuite_params *ts_params = &testsuite_params;
1848 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1849 ts_params->op_mpool,
1850 ts_params->session_mpool,
1851 ts_params->valid_devs[0],
1852 rte_cryptodev_driver_id_get(
1853 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1854 BLKCIPHER_AES_CIPHERONLY_TYPE);
1856 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1858 return TEST_SUCCESS;
1862 test_AES_cipheronly_virtio_all(void)
1864 struct crypto_testsuite_params *ts_params = &testsuite_params;
1867 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1868 ts_params->op_mpool,
1869 ts_params->session_mpool,
1870 ts_params->valid_devs[0],
1871 rte_cryptodev_driver_id_get(
1872 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1873 BLKCIPHER_AES_CIPHERONLY_TYPE);
1875 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1877 return TEST_SUCCESS;
1881 test_AES_chain_caam_jr_all(void)
1883 struct crypto_testsuite_params *ts_params = &testsuite_params;
1886 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1887 ts_params->op_mpool,
1888 ts_params->session_mpool,
1889 ts_params->valid_devs[0],
1890 rte_cryptodev_driver_id_get(
1891 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1892 BLKCIPHER_AES_CHAIN_TYPE);
1894 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1896 return TEST_SUCCESS;
1900 test_AES_cipheronly_caam_jr_all(void)
1902 struct crypto_testsuite_params *ts_params = &testsuite_params;
1905 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1906 ts_params->op_mpool,
1907 ts_params->session_mpool,
1908 ts_params->valid_devs[0],
1909 rte_cryptodev_driver_id_get(
1910 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1911 BLKCIPHER_AES_CIPHERONLY_TYPE);
1913 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1915 return TEST_SUCCESS;
1919 test_authonly_caam_jr_all(void)
1921 struct crypto_testsuite_params *ts_params = &testsuite_params;
1924 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1925 ts_params->op_mpool,
1926 ts_params->session_mpool,
1927 ts_params->valid_devs[0],
1928 rte_cryptodev_driver_id_get(
1929 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1930 BLKCIPHER_AUTHONLY_TYPE);
1932 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1934 return TEST_SUCCESS;
1939 test_AES_chain_dpaa_sec_all(void)
1941 struct crypto_testsuite_params *ts_params = &testsuite_params;
1944 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1945 ts_params->op_mpool,
1946 ts_params->session_mpool,
1947 ts_params->valid_devs[0],
1948 rte_cryptodev_driver_id_get(
1949 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1950 BLKCIPHER_AES_CHAIN_TYPE);
1952 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1954 return TEST_SUCCESS;
1958 test_AES_cipheronly_dpaa_sec_all(void)
1960 struct crypto_testsuite_params *ts_params = &testsuite_params;
1963 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1964 ts_params->op_mpool,
1965 ts_params->session_mpool,
1966 ts_params->valid_devs[0],
1967 rte_cryptodev_driver_id_get(
1968 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1969 BLKCIPHER_AES_CIPHERONLY_TYPE);
1971 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1973 return TEST_SUCCESS;
1977 test_authonly_dpaa_sec_all(void)
1979 struct crypto_testsuite_params *ts_params = &testsuite_params;
1982 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1983 ts_params->op_mpool,
1984 ts_params->session_mpool,
1985 ts_params->valid_devs[0],
1986 rte_cryptodev_driver_id_get(
1987 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1988 BLKCIPHER_AUTHONLY_TYPE);
1990 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1992 return TEST_SUCCESS;
1996 test_AES_chain_dpaa2_sec_all(void)
1998 struct crypto_testsuite_params *ts_params = &testsuite_params;
2001 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2002 ts_params->op_mpool,
2003 ts_params->session_mpool,
2004 ts_params->valid_devs[0],
2005 rte_cryptodev_driver_id_get(
2006 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2007 BLKCIPHER_AES_CHAIN_TYPE);
2009 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2011 return TEST_SUCCESS;
2015 test_AES_cipheronly_dpaa2_sec_all(void)
2017 struct crypto_testsuite_params *ts_params = &testsuite_params;
2020 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2021 ts_params->op_mpool,
2022 ts_params->session_mpool,
2023 ts_params->valid_devs[0],
2024 rte_cryptodev_driver_id_get(
2025 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2026 BLKCIPHER_AES_CIPHERONLY_TYPE);
2028 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2030 return TEST_SUCCESS;
2034 test_authonly_dpaa2_sec_all(void)
2036 struct crypto_testsuite_params *ts_params = &testsuite_params;
2039 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2040 ts_params->op_mpool,
2041 ts_params->session_mpool,
2042 ts_params->valid_devs[0],
2043 rte_cryptodev_driver_id_get(
2044 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2045 BLKCIPHER_AUTHONLY_TYPE);
2047 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2049 return TEST_SUCCESS;
2053 test_authonly_openssl_all(void)
2055 struct crypto_testsuite_params *ts_params = &testsuite_params;
2058 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2059 ts_params->op_mpool,
2060 ts_params->session_mpool,
2061 ts_params->valid_devs[0],
2062 rte_cryptodev_driver_id_get(
2063 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2064 BLKCIPHER_AUTHONLY_TYPE);
2066 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2068 return TEST_SUCCESS;
2072 test_authonly_ccp_all(void)
2074 struct crypto_testsuite_params *ts_params = &testsuite_params;
2077 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2078 ts_params->op_mpool,
2079 ts_params->session_mpool,
2080 ts_params->valid_devs[0],
2081 rte_cryptodev_driver_id_get(
2082 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2083 BLKCIPHER_AUTHONLY_TYPE);
2085 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2087 return TEST_SUCCESS;
2091 test_AES_chain_armv8_all(void)
2093 struct crypto_testsuite_params *ts_params = &testsuite_params;
2096 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2097 ts_params->op_mpool,
2098 ts_params->session_mpool,
2099 ts_params->valid_devs[0],
2100 rte_cryptodev_driver_id_get(
2101 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2102 BLKCIPHER_AES_CHAIN_TYPE);
2104 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2106 return TEST_SUCCESS;
2110 test_AES_chain_mrvl_all(void)
2112 struct crypto_testsuite_params *ts_params = &testsuite_params;
2115 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2116 ts_params->op_mpool,
2117 ts_params->session_mpool,
2118 ts_params->valid_devs[0],
2119 rte_cryptodev_driver_id_get(
2120 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2121 BLKCIPHER_AES_CHAIN_TYPE);
2123 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2125 return TEST_SUCCESS;
2129 test_AES_cipheronly_mrvl_all(void)
2131 struct crypto_testsuite_params *ts_params = &testsuite_params;
2134 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2135 ts_params->op_mpool,
2136 ts_params->session_mpool,
2137 ts_params->valid_devs[0],
2138 rte_cryptodev_driver_id_get(
2139 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2140 BLKCIPHER_AES_CIPHERONLY_TYPE);
2142 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2144 return TEST_SUCCESS;
2148 test_authonly_mrvl_all(void)
2150 struct crypto_testsuite_params *ts_params = &testsuite_params;
2153 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2154 ts_params->op_mpool,
2155 ts_params->session_mpool,
2156 ts_params->valid_devs[0],
2157 rte_cryptodev_driver_id_get(
2158 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2159 BLKCIPHER_AUTHONLY_TYPE);
2161 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2163 return TEST_SUCCESS;
2167 test_3DES_chain_mrvl_all(void)
2169 struct crypto_testsuite_params *ts_params = &testsuite_params;
2172 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2173 ts_params->op_mpool,
2174 ts_params->session_mpool,
2175 ts_params->valid_devs[0],
2176 rte_cryptodev_driver_id_get(
2177 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2178 BLKCIPHER_3DES_CHAIN_TYPE);
2180 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2182 return TEST_SUCCESS;
2186 test_3DES_cipheronly_mrvl_all(void)
2188 struct crypto_testsuite_params *ts_params = &testsuite_params;
2191 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2192 ts_params->op_mpool,
2193 ts_params->session_mpool,
2194 ts_params->valid_devs[0],
2195 rte_cryptodev_driver_id_get(
2196 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2197 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2199 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2201 return TEST_SUCCESS;
2205 test_AES_chain_octeontx_all(void)
2207 struct crypto_testsuite_params *ts_params = &testsuite_params;
2210 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2211 ts_params->op_mpool, ts_params->session_mpool,
2212 ts_params->valid_devs[0],
2213 rte_cryptodev_driver_id_get(
2214 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2215 BLKCIPHER_AES_CHAIN_TYPE);
2217 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2219 return TEST_SUCCESS;
2223 test_AES_cipheronly_octeontx_all(void)
2225 struct crypto_testsuite_params *ts_params = &testsuite_params;
2228 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2229 ts_params->op_mpool, ts_params->session_mpool,
2230 ts_params->valid_devs[0],
2231 rte_cryptodev_driver_id_get(
2232 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2233 BLKCIPHER_AES_CIPHERONLY_TYPE);
2235 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2237 return TEST_SUCCESS;
2241 test_3DES_chain_octeontx_all(void)
2243 struct crypto_testsuite_params *ts_params = &testsuite_params;
2246 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2247 ts_params->op_mpool, ts_params->session_mpool,
2248 ts_params->valid_devs[0],
2249 rte_cryptodev_driver_id_get(
2250 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2251 BLKCIPHER_3DES_CHAIN_TYPE);
2253 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2255 return TEST_SUCCESS;
2259 test_3DES_cipheronly_octeontx_all(void)
2261 struct crypto_testsuite_params *ts_params = &testsuite_params;
2264 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2265 ts_params->op_mpool, ts_params->session_mpool,
2266 ts_params->valid_devs[0],
2267 rte_cryptodev_driver_id_get(
2268 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2269 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2271 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2273 return TEST_SUCCESS;
2277 test_authonly_octeontx_all(void)
2279 struct crypto_testsuite_params *ts_params = &testsuite_params;
2282 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2283 ts_params->op_mpool, ts_params->session_mpool,
2284 ts_params->valid_devs[0],
2285 rte_cryptodev_driver_id_get(
2286 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2287 BLKCIPHER_AUTHONLY_TYPE);
2289 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2291 return TEST_SUCCESS;
2294 /* ***** SNOW 3G Tests ***** */
2296 create_wireless_algo_hash_session(uint8_t dev_id,
2297 const uint8_t *key, const uint8_t key_len,
2298 const uint8_t iv_len, const uint8_t auth_len,
2299 enum rte_crypto_auth_operation op,
2300 enum rte_crypto_auth_algorithm algo)
2302 uint8_t hash_key[key_len];
2304 struct crypto_testsuite_params *ts_params = &testsuite_params;
2305 struct crypto_unittest_params *ut_params = &unittest_params;
2307 memcpy(hash_key, key, key_len);
2309 debug_hexdump(stdout, "key:", key, key_len);
2311 /* Setup Authentication Parameters */
2312 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2313 ut_params->auth_xform.next = NULL;
2315 ut_params->auth_xform.auth.op = op;
2316 ut_params->auth_xform.auth.algo = algo;
2317 ut_params->auth_xform.auth.key.length = key_len;
2318 ut_params->auth_xform.auth.key.data = hash_key;
2319 ut_params->auth_xform.auth.digest_length = auth_len;
2320 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2321 ut_params->auth_xform.auth.iv.length = iv_len;
2322 ut_params->sess = rte_cryptodev_sym_session_create(
2323 ts_params->session_mpool);
2325 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2326 &ut_params->auth_xform, ts_params->session_mpool);
2327 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2332 create_wireless_algo_cipher_session(uint8_t dev_id,
2333 enum rte_crypto_cipher_operation op,
2334 enum rte_crypto_cipher_algorithm algo,
2335 const uint8_t *key, const uint8_t key_len,
2338 uint8_t cipher_key[key_len];
2340 struct crypto_testsuite_params *ts_params = &testsuite_params;
2341 struct crypto_unittest_params *ut_params = &unittest_params;
2343 memcpy(cipher_key, key, key_len);
2345 /* Setup Cipher Parameters */
2346 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2347 ut_params->cipher_xform.next = NULL;
2349 ut_params->cipher_xform.cipher.algo = algo;
2350 ut_params->cipher_xform.cipher.op = op;
2351 ut_params->cipher_xform.cipher.key.data = cipher_key;
2352 ut_params->cipher_xform.cipher.key.length = key_len;
2353 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2354 ut_params->cipher_xform.cipher.iv.length = iv_len;
2356 debug_hexdump(stdout, "key:", key, key_len);
2358 /* Create Crypto session */
2359 ut_params->sess = rte_cryptodev_sym_session_create(
2360 ts_params->session_mpool);
2362 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2363 &ut_params->cipher_xform, ts_params->session_mpool);
2364 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2369 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2370 unsigned int cipher_len,
2371 unsigned int cipher_offset)
2373 struct crypto_testsuite_params *ts_params = &testsuite_params;
2374 struct crypto_unittest_params *ut_params = &unittest_params;
2376 /* Generate Crypto op data structure */
2377 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2378 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2379 TEST_ASSERT_NOT_NULL(ut_params->op,
2380 "Failed to allocate pktmbuf offload");
2382 /* Set crypto operation data parameters */
2383 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2385 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2387 /* set crypto operation source mbuf */
2388 sym_op->m_src = ut_params->ibuf;
2391 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2393 sym_op->cipher.data.length = cipher_len;
2394 sym_op->cipher.data.offset = cipher_offset;
2399 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2400 unsigned int cipher_len,
2401 unsigned int cipher_offset)
2403 struct crypto_testsuite_params *ts_params = &testsuite_params;
2404 struct crypto_unittest_params *ut_params = &unittest_params;
2406 /* Generate Crypto op data structure */
2407 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2408 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2409 TEST_ASSERT_NOT_NULL(ut_params->op,
2410 "Failed to allocate pktmbuf offload");
2412 /* Set crypto operation data parameters */
2413 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2415 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2417 /* set crypto operation source mbuf */
2418 sym_op->m_src = ut_params->ibuf;
2419 sym_op->m_dst = ut_params->obuf;
2422 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2424 sym_op->cipher.data.length = cipher_len;
2425 sym_op->cipher.data.offset = cipher_offset;
2430 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2431 enum rte_crypto_cipher_operation cipher_op,
2432 enum rte_crypto_auth_operation auth_op,
2433 enum rte_crypto_auth_algorithm auth_algo,
2434 enum rte_crypto_cipher_algorithm cipher_algo,
2435 const uint8_t *key, uint8_t key_len,
2436 uint8_t auth_iv_len, uint8_t auth_len,
2437 uint8_t cipher_iv_len)
2440 uint8_t cipher_auth_key[key_len];
2442 struct crypto_testsuite_params *ts_params = &testsuite_params;
2443 struct crypto_unittest_params *ut_params = &unittest_params;
2445 memcpy(cipher_auth_key, key, key_len);
2447 /* Setup Authentication Parameters */
2448 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2449 ut_params->auth_xform.next = NULL;
2451 ut_params->auth_xform.auth.op = auth_op;
2452 ut_params->auth_xform.auth.algo = auth_algo;
2453 ut_params->auth_xform.auth.key.length = key_len;
2454 /* Hash key = cipher key */
2455 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2456 ut_params->auth_xform.auth.digest_length = auth_len;
2457 /* Auth IV will be after cipher IV */
2458 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2459 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2461 /* Setup Cipher Parameters */
2462 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2463 ut_params->cipher_xform.next = &ut_params->auth_xform;
2465 ut_params->cipher_xform.cipher.algo = cipher_algo;
2466 ut_params->cipher_xform.cipher.op = cipher_op;
2467 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2468 ut_params->cipher_xform.cipher.key.length = key_len;
2469 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2470 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2472 debug_hexdump(stdout, "key:", key, key_len);
2474 /* Create Crypto session*/
2475 ut_params->sess = rte_cryptodev_sym_session_create(
2476 ts_params->session_mpool);
2478 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2479 &ut_params->cipher_xform, ts_params->session_mpool);
2481 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2486 create_wireless_cipher_auth_session(uint8_t dev_id,
2487 enum rte_crypto_cipher_operation cipher_op,
2488 enum rte_crypto_auth_operation auth_op,
2489 enum rte_crypto_auth_algorithm auth_algo,
2490 enum rte_crypto_cipher_algorithm cipher_algo,
2491 const struct wireless_test_data *tdata)
2493 const uint8_t key_len = tdata->key.len;
2494 uint8_t cipher_auth_key[key_len];
2496 struct crypto_testsuite_params *ts_params = &testsuite_params;
2497 struct crypto_unittest_params *ut_params = &unittest_params;
2498 const uint8_t *key = tdata->key.data;
2499 const uint8_t auth_len = tdata->digest.len;
2500 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2501 uint8_t auth_iv_len = tdata->auth_iv.len;
2503 memcpy(cipher_auth_key, key, key_len);
2505 /* Setup Authentication Parameters */
2506 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2507 ut_params->auth_xform.next = NULL;
2509 ut_params->auth_xform.auth.op = auth_op;
2510 ut_params->auth_xform.auth.algo = auth_algo;
2511 ut_params->auth_xform.auth.key.length = key_len;
2512 /* Hash key = cipher key */
2513 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2514 ut_params->auth_xform.auth.digest_length = auth_len;
2515 /* Auth IV will be after cipher IV */
2516 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2517 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2519 /* Setup Cipher Parameters */
2520 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2521 ut_params->cipher_xform.next = &ut_params->auth_xform;
2523 ut_params->cipher_xform.cipher.algo = cipher_algo;
2524 ut_params->cipher_xform.cipher.op = cipher_op;
2525 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2526 ut_params->cipher_xform.cipher.key.length = key_len;
2527 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2528 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2531 debug_hexdump(stdout, "key:", key, key_len);
2533 /* Create Crypto session*/
2534 ut_params->sess = rte_cryptodev_sym_session_create(
2535 ts_params->session_mpool);
2537 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2538 &ut_params->cipher_xform, ts_params->session_mpool);
2540 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2545 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2546 const struct wireless_test_data *tdata)
2548 return create_wireless_cipher_auth_session(dev_id,
2549 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2550 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2551 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2555 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2556 enum rte_crypto_cipher_operation cipher_op,
2557 enum rte_crypto_auth_operation auth_op,
2558 enum rte_crypto_auth_algorithm auth_algo,
2559 enum rte_crypto_cipher_algorithm cipher_algo,
2560 const uint8_t *key, const uint8_t key_len,
2561 uint8_t auth_iv_len, uint8_t auth_len,
2562 uint8_t cipher_iv_len)
2564 uint8_t auth_cipher_key[key_len];
2566 struct crypto_testsuite_params *ts_params = &testsuite_params;
2567 struct crypto_unittest_params *ut_params = &unittest_params;
2569 memcpy(auth_cipher_key, key, key_len);
2571 /* Setup Authentication Parameters */
2572 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2573 ut_params->auth_xform.auth.op = auth_op;
2574 ut_params->auth_xform.next = &ut_params->cipher_xform;
2575 ut_params->auth_xform.auth.algo = auth_algo;
2576 ut_params->auth_xform.auth.key.length = key_len;
2577 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2578 ut_params->auth_xform.auth.digest_length = auth_len;
2579 /* Auth IV will be after cipher IV */
2580 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2581 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2583 /* Setup Cipher Parameters */
2584 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2585 ut_params->cipher_xform.next = NULL;
2586 ut_params->cipher_xform.cipher.algo = cipher_algo;
2587 ut_params->cipher_xform.cipher.op = cipher_op;
2588 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2589 ut_params->cipher_xform.cipher.key.length = key_len;
2590 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2591 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2593 debug_hexdump(stdout, "key:", key, key_len);
2595 /* Create Crypto session*/
2596 ut_params->sess = rte_cryptodev_sym_session_create(
2597 ts_params->session_mpool);
2599 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2600 &ut_params->auth_xform, ts_params->session_mpool);
2602 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2608 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2609 unsigned int auth_tag_len,
2610 const uint8_t *iv, unsigned int iv_len,
2611 unsigned int data_pad_len,
2612 enum rte_crypto_auth_operation op,
2613 unsigned int auth_len, unsigned int auth_offset)
2615 struct crypto_testsuite_params *ts_params = &testsuite_params;
2617 struct crypto_unittest_params *ut_params = &unittest_params;
2619 /* Generate Crypto op data structure */
2620 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2621 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2622 TEST_ASSERT_NOT_NULL(ut_params->op,
2623 "Failed to allocate pktmbuf offload");
2625 /* Set crypto operation data parameters */
2626 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2628 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2630 /* set crypto operation source mbuf */
2631 sym_op->m_src = ut_params->ibuf;
2634 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2637 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2638 ut_params->ibuf, auth_tag_len);
2640 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2641 "no room to append auth tag");
2642 ut_params->digest = sym_op->auth.digest.data;
2643 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2644 ut_params->ibuf, data_pad_len);
2645 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2646 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2648 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2650 debug_hexdump(stdout, "digest:",
2651 sym_op->auth.digest.data,
2654 sym_op->auth.data.length = auth_len;
2655 sym_op->auth.data.offset = auth_offset;
2661 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2662 enum rte_crypto_auth_operation op)
2664 struct crypto_testsuite_params *ts_params = &testsuite_params;
2665 struct crypto_unittest_params *ut_params = &unittest_params;
2667 const uint8_t *auth_tag = tdata->digest.data;
2668 const unsigned int auth_tag_len = tdata->digest.len;
2669 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2670 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2672 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2673 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2674 const uint8_t *auth_iv = tdata->auth_iv.data;
2675 const uint8_t auth_iv_len = tdata->auth_iv.len;
2676 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2677 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2679 /* Generate Crypto op data structure */
2680 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2681 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2682 TEST_ASSERT_NOT_NULL(ut_params->op,
2683 "Failed to allocate pktmbuf offload");
2684 /* Set crypto operation data parameters */
2685 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2687 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2689 /* set crypto operation source mbuf */
2690 sym_op->m_src = ut_params->ibuf;
2693 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2694 ut_params->ibuf, auth_tag_len);
2696 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2697 "no room to append auth tag");
2698 ut_params->digest = sym_op->auth.digest.data;
2699 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2700 ut_params->ibuf, data_pad_len);
2701 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2702 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2704 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2706 debug_hexdump(stdout, "digest:",
2707 sym_op->auth.digest.data,
2710 /* Copy cipher and auth IVs at the end of the crypto operation */
2711 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2713 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2714 iv_ptr += cipher_iv_len;
2715 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2717 sym_op->cipher.data.length = cipher_len;
2718 sym_op->cipher.data.offset = 0;
2719 sym_op->auth.data.length = auth_len;
2720 sym_op->auth.data.offset = 0;
2726 create_zuc_cipher_hash_generate_operation(
2727 const struct wireless_test_data *tdata)
2729 return create_wireless_cipher_hash_operation(tdata,
2730 RTE_CRYPTO_AUTH_OP_GENERATE);
2734 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2735 const unsigned auth_tag_len,
2736 const uint8_t *auth_iv, uint8_t auth_iv_len,
2737 unsigned data_pad_len,
2738 enum rte_crypto_auth_operation op,
2739 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2740 const unsigned cipher_len, const unsigned cipher_offset,
2741 const unsigned auth_len, const unsigned auth_offset)
2743 struct crypto_testsuite_params *ts_params = &testsuite_params;
2744 struct crypto_unittest_params *ut_params = &unittest_params;
2746 /* Generate Crypto op data structure */
2747 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2748 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2749 TEST_ASSERT_NOT_NULL(ut_params->op,
2750 "Failed to allocate pktmbuf offload");
2751 /* Set crypto operation data parameters */
2752 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2754 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2756 /* set crypto operation source mbuf */
2757 sym_op->m_src = ut_params->ibuf;
2760 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2761 ut_params->ibuf, auth_tag_len);
2763 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2764 "no room to append auth tag");
2765 ut_params->digest = sym_op->auth.digest.data;
2766 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2767 ut_params->ibuf, data_pad_len);
2768 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2769 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2771 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2773 debug_hexdump(stdout, "digest:",
2774 sym_op->auth.digest.data,
2777 /* Copy cipher and auth IVs at the end of the crypto operation */
2778 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2780 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2781 iv_ptr += cipher_iv_len;
2782 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2784 sym_op->cipher.data.length = cipher_len;
2785 sym_op->cipher.data.offset = cipher_offset;
2786 sym_op->auth.data.length = auth_len;
2787 sym_op->auth.data.offset = auth_offset;
2793 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2794 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2795 const uint8_t *auth_iv, uint8_t auth_iv_len,
2796 unsigned int data_pad_len,
2797 unsigned int cipher_len, unsigned int cipher_offset,
2798 unsigned int auth_len, unsigned int auth_offset)
2800 struct crypto_testsuite_params *ts_params = &testsuite_params;
2801 struct crypto_unittest_params *ut_params = &unittest_params;
2803 /* Generate Crypto op data structure */
2804 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2805 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2806 TEST_ASSERT_NOT_NULL(ut_params->op,
2807 "Failed to allocate pktmbuf offload");
2809 /* Set crypto operation data parameters */
2810 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2812 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2814 /* set crypto operation source mbuf */
2815 sym_op->m_src = ut_params->ibuf;
2818 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2819 ut_params->ibuf, auth_tag_len);
2821 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2822 "no room to append auth tag");
2824 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2825 ut_params->ibuf, data_pad_len);
2827 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2829 debug_hexdump(stdout, "digest:",
2830 sym_op->auth.digest.data,
2833 /* Copy cipher and auth IVs at the end of the crypto operation */
2834 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2836 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2837 iv_ptr += cipher_iv_len;
2838 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2840 sym_op->cipher.data.length = cipher_len;
2841 sym_op->cipher.data.offset = cipher_offset;
2843 sym_op->auth.data.length = auth_len;
2844 sym_op->auth.data.offset = auth_offset;
2850 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2852 struct crypto_testsuite_params *ts_params = &testsuite_params;
2853 struct crypto_unittest_params *ut_params = &unittest_params;
2856 unsigned plaintext_pad_len;
2857 unsigned plaintext_len;
2860 /* Create SNOW 3G session */
2861 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2862 tdata->key.data, tdata->key.len,
2863 tdata->auth_iv.len, tdata->digest.len,
2864 RTE_CRYPTO_AUTH_OP_GENERATE,
2865 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2869 /* alloc mbuf and set payload */
2870 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2872 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2873 rte_pktmbuf_tailroom(ut_params->ibuf));
2875 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2876 /* Append data which is padded to a multiple of */
2877 /* the algorithms block size */
2878 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2879 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2881 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2883 /* Create SNOW 3G operation */
2884 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2885 tdata->auth_iv.data, tdata->auth_iv.len,
2886 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2887 tdata->validAuthLenInBits.len,
2892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2894 ut_params->obuf = ut_params->op->sym->m_src;
2895 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2896 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2897 + plaintext_pad_len;
2900 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2903 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2904 "SNOW 3G Generated auth tag not as expected");
2910 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2912 struct crypto_testsuite_params *ts_params = &testsuite_params;
2913 struct crypto_unittest_params *ut_params = &unittest_params;
2916 unsigned plaintext_pad_len;
2917 unsigned plaintext_len;
2920 /* Create SNOW 3G session */
2921 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2922 tdata->key.data, tdata->key.len,
2923 tdata->auth_iv.len, tdata->digest.len,
2924 RTE_CRYPTO_AUTH_OP_VERIFY,
2925 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2928 /* alloc mbuf and set payload */
2929 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2931 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2932 rte_pktmbuf_tailroom(ut_params->ibuf));
2934 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2935 /* Append data which is padded to a multiple of */
2936 /* the algorithms block size */
2937 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2938 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2940 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2942 /* Create SNOW 3G operation */
2943 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2945 tdata->auth_iv.data, tdata->auth_iv.len,
2947 RTE_CRYPTO_AUTH_OP_VERIFY,
2948 tdata->validAuthLenInBits.len,
2953 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2955 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2956 ut_params->obuf = ut_params->op->sym->m_src;
2957 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2958 + plaintext_pad_len;
2961 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2970 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2972 struct crypto_testsuite_params *ts_params = &testsuite_params;
2973 struct crypto_unittest_params *ut_params = &unittest_params;
2976 unsigned plaintext_pad_len;
2977 unsigned plaintext_len;
2980 /* Create KASUMI session */
2981 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2982 tdata->key.data, tdata->key.len,
2983 0, tdata->digest.len,
2984 RTE_CRYPTO_AUTH_OP_GENERATE,
2985 RTE_CRYPTO_AUTH_KASUMI_F9);
2989 /* alloc mbuf and set payload */
2990 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2992 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2993 rte_pktmbuf_tailroom(ut_params->ibuf));
2995 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2996 /* Append data which is padded to a multiple of */
2997 /* the algorithms block size */
2998 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2999 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3001 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3003 /* Create KASUMI operation */
3004 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3006 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3007 tdata->plaintext.len,
3012 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3014 ut_params->obuf = ut_params->op->sym->m_src;
3015 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3016 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3017 + plaintext_pad_len;
3020 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3023 DIGEST_BYTE_LENGTH_KASUMI_F9,
3024 "KASUMI Generated auth tag not as expected");
3030 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3032 struct crypto_testsuite_params *ts_params = &testsuite_params;
3033 struct crypto_unittest_params *ut_params = &unittest_params;
3036 unsigned plaintext_pad_len;
3037 unsigned plaintext_len;
3040 /* Create KASUMI session */
3041 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3042 tdata->key.data, tdata->key.len,
3043 0, tdata->digest.len,
3044 RTE_CRYPTO_AUTH_OP_VERIFY,
3045 RTE_CRYPTO_AUTH_KASUMI_F9);
3048 /* alloc mbuf and set payload */
3049 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3051 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3052 rte_pktmbuf_tailroom(ut_params->ibuf));
3054 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3055 /* Append data which is padded to a multiple */
3056 /* of the algorithms block size */
3057 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3058 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3060 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3062 /* Create KASUMI operation */
3063 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3067 RTE_CRYPTO_AUTH_OP_VERIFY,
3068 tdata->plaintext.len,
3073 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3075 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3076 ut_params->obuf = ut_params->op->sym->m_src;
3077 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3078 + plaintext_pad_len;
3081 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3090 test_snow3g_hash_generate_test_case_1(void)
3092 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3096 test_snow3g_hash_generate_test_case_2(void)
3098 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3102 test_snow3g_hash_generate_test_case_3(void)
3104 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3108 test_snow3g_hash_generate_test_case_4(void)
3110 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3114 test_snow3g_hash_generate_test_case_5(void)
3116 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3120 test_snow3g_hash_generate_test_case_6(void)
3122 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3126 test_snow3g_hash_verify_test_case_1(void)
3128 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3133 test_snow3g_hash_verify_test_case_2(void)
3135 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3139 test_snow3g_hash_verify_test_case_3(void)
3141 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3145 test_snow3g_hash_verify_test_case_4(void)
3147 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3151 test_snow3g_hash_verify_test_case_5(void)
3153 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3157 test_snow3g_hash_verify_test_case_6(void)
3159 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3163 test_kasumi_hash_generate_test_case_1(void)
3165 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3169 test_kasumi_hash_generate_test_case_2(void)
3171 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3175 test_kasumi_hash_generate_test_case_3(void)
3177 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3181 test_kasumi_hash_generate_test_case_4(void)
3183 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3187 test_kasumi_hash_generate_test_case_5(void)
3189 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3193 test_kasumi_hash_generate_test_case_6(void)
3195 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3199 test_kasumi_hash_verify_test_case_1(void)
3201 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3205 test_kasumi_hash_verify_test_case_2(void)
3207 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3211 test_kasumi_hash_verify_test_case_3(void)
3213 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3217 test_kasumi_hash_verify_test_case_4(void)
3219 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3223 test_kasumi_hash_verify_test_case_5(void)
3225 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3229 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3231 struct crypto_testsuite_params *ts_params = &testsuite_params;
3232 struct crypto_unittest_params *ut_params = &unittest_params;
3235 uint8_t *plaintext, *ciphertext;
3236 unsigned plaintext_pad_len;
3237 unsigned plaintext_len;
3239 /* Create KASUMI session */
3240 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3241 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3242 RTE_CRYPTO_CIPHER_KASUMI_F8,
3243 tdata->key.data, tdata->key.len,
3244 tdata->cipher_iv.len);
3248 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3250 /* Clear mbuf payload */
3251 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3252 rte_pktmbuf_tailroom(ut_params->ibuf));
3254 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3255 /* Append data which is padded to a multiple */
3256 /* of the algorithms block size */
3257 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3258 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3260 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3262 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3264 /* Create KASUMI operation */
3265 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3266 tdata->cipher_iv.len,
3267 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3268 tdata->validCipherOffsetInBits.len);
3272 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3274 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3276 ut_params->obuf = ut_params->op->sym->m_dst;
3277 if (ut_params->obuf)
3278 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3280 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3282 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3284 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3285 (tdata->validCipherOffsetInBits.len >> 3);
3287 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3289 reference_ciphertext,
3290 tdata->validCipherLenInBits.len,
3291 "KASUMI Ciphertext data not as expected");
3296 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3298 struct crypto_testsuite_params *ts_params = &testsuite_params;
3299 struct crypto_unittest_params *ut_params = &unittest_params;
3303 unsigned int plaintext_pad_len;
3304 unsigned int plaintext_len;
3306 uint8_t buffer[10000];
3307 const uint8_t *ciphertext;
3309 struct rte_cryptodev_info dev_info;
3311 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3313 uint64_t feat_flags = dev_info.feature_flags;
3315 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3316 printf("Device doesn't support in-place scatter-gather. "
3321 /* Create KASUMI session */
3322 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3323 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3324 RTE_CRYPTO_CIPHER_KASUMI_F8,
3325 tdata->key.data, tdata->key.len,
3326 tdata->cipher_iv.len);
3330 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3333 /* Append data which is padded to a multiple */
3334 /* of the algorithms block size */
3335 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3337 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3338 plaintext_pad_len, 10, 0);
3340 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3342 /* Create KASUMI operation */
3343 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3344 tdata->cipher_iv.len,
3345 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3346 tdata->validCipherOffsetInBits.len);
3350 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3352 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3354 ut_params->obuf = ut_params->op->sym->m_dst;
3356 if (ut_params->obuf)
3357 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3358 plaintext_len, buffer);
3360 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3361 tdata->validCipherOffsetInBits.len >> 3,
3362 plaintext_len, buffer);
3365 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3367 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3368 (tdata->validCipherOffsetInBits.len >> 3);
3370 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3372 reference_ciphertext,
3373 tdata->validCipherLenInBits.len,
3374 "KASUMI Ciphertext data not as expected");
3379 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3381 struct crypto_testsuite_params *ts_params = &testsuite_params;
3382 struct crypto_unittest_params *ut_params = &unittest_params;
3385 uint8_t *plaintext, *ciphertext;
3386 unsigned plaintext_pad_len;
3387 unsigned plaintext_len;
3389 /* Create KASUMI session */
3390 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3391 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3392 RTE_CRYPTO_CIPHER_KASUMI_F8,
3393 tdata->key.data, tdata->key.len,
3394 tdata->cipher_iv.len);
3398 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3399 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3401 /* Clear mbuf payload */
3402 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3403 rte_pktmbuf_tailroom(ut_params->ibuf));
3405 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3406 /* Append data which is padded to a multiple */
3407 /* of the algorithms block size */
3408 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3409 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3411 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3412 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3414 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3416 /* Create KASUMI operation */
3417 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3418 tdata->cipher_iv.len,
3419 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3420 tdata->validCipherOffsetInBits.len);
3424 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3426 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3428 ut_params->obuf = ut_params->op->sym->m_dst;
3429 if (ut_params->obuf)
3430 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3432 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3434 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3436 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3437 (tdata->validCipherOffsetInBits.len >> 3);
3439 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3441 reference_ciphertext,
3442 tdata->validCipherLenInBits.len,
3443 "KASUMI Ciphertext data not as expected");
3448 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3450 struct crypto_testsuite_params *ts_params = &testsuite_params;
3451 struct crypto_unittest_params *ut_params = &unittest_params;
3454 unsigned int plaintext_pad_len;
3455 unsigned int plaintext_len;
3457 const uint8_t *ciphertext;
3458 uint8_t buffer[2048];
3460 struct rte_cryptodev_info dev_info;
3462 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3464 uint64_t feat_flags = dev_info.feature_flags;
3465 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3466 printf("Device doesn't support out-of-place scatter-gather "
3467 "in both input and output mbufs. "
3472 /* Create KASUMI session */
3473 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3474 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3475 RTE_CRYPTO_CIPHER_KASUMI_F8,
3476 tdata->key.data, tdata->key.len,
3477 tdata->cipher_iv.len);
3481 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3482 /* Append data which is padded to a multiple */
3483 /* of the algorithms block size */
3484 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3486 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3487 plaintext_pad_len, 10, 0);
3488 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3489 plaintext_pad_len, 3, 0);
3491 /* Append data which is padded to a multiple */
3492 /* of the algorithms block size */
3493 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3495 /* Create KASUMI operation */
3496 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3497 tdata->cipher_iv.len,
3498 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3499 tdata->validCipherOffsetInBits.len);
3503 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3505 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3507 ut_params->obuf = ut_params->op->sym->m_dst;
3508 if (ut_params->obuf)
3509 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3510 plaintext_pad_len, buffer);
3512 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3513 tdata->validCipherOffsetInBits.len >> 3,
3514 plaintext_pad_len, buffer);
3516 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3517 (tdata->validCipherOffsetInBits.len >> 3);
3519 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3521 reference_ciphertext,
3522 tdata->validCipherLenInBits.len,
3523 "KASUMI Ciphertext data not as expected");
3529 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3531 struct crypto_testsuite_params *ts_params = &testsuite_params;
3532 struct crypto_unittest_params *ut_params = &unittest_params;
3535 uint8_t *ciphertext, *plaintext;
3536 unsigned ciphertext_pad_len;
3537 unsigned ciphertext_len;
3539 /* Create KASUMI session */
3540 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3541 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3542 RTE_CRYPTO_CIPHER_KASUMI_F8,
3543 tdata->key.data, tdata->key.len,
3544 tdata->cipher_iv.len);
3548 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3549 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3551 /* Clear mbuf payload */
3552 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3553 rte_pktmbuf_tailroom(ut_params->ibuf));
3555 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3556 /* Append data which is padded to a multiple */
3557 /* of the algorithms block size */
3558 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3559 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3560 ciphertext_pad_len);
3561 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3562 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3564 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3566 /* Create KASUMI operation */
3567 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3568 tdata->cipher_iv.len,
3569 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3570 tdata->validCipherOffsetInBits.len);
3574 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3576 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3578 ut_params->obuf = ut_params->op->sym->m_dst;
3579 if (ut_params->obuf)
3580 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3582 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3584 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3586 const uint8_t *reference_plaintext = tdata->plaintext.data +
3587 (tdata->validCipherOffsetInBits.len >> 3);
3589 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3591 reference_plaintext,
3592 tdata->validCipherLenInBits.len,
3593 "KASUMI Plaintext data not as expected");
3598 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3600 struct crypto_testsuite_params *ts_params = &testsuite_params;
3601 struct crypto_unittest_params *ut_params = &unittest_params;
3604 uint8_t *ciphertext, *plaintext;
3605 unsigned ciphertext_pad_len;
3606 unsigned ciphertext_len;
3608 /* Create KASUMI session */
3609 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3610 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3611 RTE_CRYPTO_CIPHER_KASUMI_F8,
3612 tdata->key.data, tdata->key.len,
3613 tdata->cipher_iv.len);
3617 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3619 /* Clear mbuf payload */
3620 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3621 rte_pktmbuf_tailroom(ut_params->ibuf));
3623 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3624 /* Append data which is padded to a multiple */
3625 /* of the algorithms block size */
3626 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3627 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3628 ciphertext_pad_len);
3629 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3631 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3633 /* Create KASUMI operation */
3634 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3635 tdata->cipher_iv.len,
3636 tdata->ciphertext.len,
3637 tdata->validCipherOffsetInBits.len);
3641 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3643 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3645 ut_params->obuf = ut_params->op->sym->m_dst;
3646 if (ut_params->obuf)
3647 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3649 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3651 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3653 const uint8_t *reference_plaintext = tdata->plaintext.data +
3654 (tdata->validCipherOffsetInBits.len >> 3);
3656 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3658 reference_plaintext,
3659 tdata->validCipherLenInBits.len,
3660 "KASUMI Plaintext data not as expected");
3665 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3667 struct crypto_testsuite_params *ts_params = &testsuite_params;
3668 struct crypto_unittest_params *ut_params = &unittest_params;
3671 uint8_t *plaintext, *ciphertext;
3672 unsigned plaintext_pad_len;
3673 unsigned plaintext_len;
3675 /* Create SNOW 3G session */
3676 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3677 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3678 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3679 tdata->key.data, tdata->key.len,
3680 tdata->cipher_iv.len);
3684 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3686 /* Clear mbuf payload */
3687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3688 rte_pktmbuf_tailroom(ut_params->ibuf));
3690 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3691 /* Append data which is padded to a multiple of */
3692 /* the algorithms block size */
3693 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3694 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3696 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3698 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3700 /* Create SNOW 3G operation */
3701 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3702 tdata->cipher_iv.len,
3703 tdata->validCipherLenInBits.len,
3708 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3710 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3712 ut_params->obuf = ut_params->op->sym->m_dst;
3713 if (ut_params->obuf)
3714 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3716 ciphertext = plaintext;
3718 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3721 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3723 tdata->ciphertext.data,
3724 tdata->validDataLenInBits.len,
3725 "SNOW 3G Ciphertext data not as expected");
3731 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3733 struct crypto_testsuite_params *ts_params = &testsuite_params;
3734 struct crypto_unittest_params *ut_params = &unittest_params;
3735 uint8_t *plaintext, *ciphertext;
3738 unsigned plaintext_pad_len;
3739 unsigned plaintext_len;
3741 /* Create SNOW 3G session */
3742 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3743 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3744 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3745 tdata->key.data, tdata->key.len,
3746 tdata->cipher_iv.len);
3750 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3751 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3753 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3754 "Failed to allocate input buffer in mempool");
3755 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3756 "Failed to allocate output buffer in mempool");
3758 /* Clear mbuf payload */
3759 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3760 rte_pktmbuf_tailroom(ut_params->ibuf));
3762 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3763 /* Append data which is padded to a multiple of */
3764 /* the algorithms block size */
3765 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3766 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3768 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3769 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3771 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3773 /* Create SNOW 3G operation */
3774 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3775 tdata->cipher_iv.len,
3776 tdata->validCipherLenInBits.len,
3781 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3783 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3785 ut_params->obuf = ut_params->op->sym->m_dst;
3786 if (ut_params->obuf)
3787 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3789 ciphertext = plaintext;
3791 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3794 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3796 tdata->ciphertext.data,
3797 tdata->validDataLenInBits.len,
3798 "SNOW 3G Ciphertext data not as expected");
3803 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3805 struct crypto_testsuite_params *ts_params = &testsuite_params;
3806 struct crypto_unittest_params *ut_params = &unittest_params;
3809 unsigned int plaintext_pad_len;
3810 unsigned int plaintext_len;
3811 uint8_t buffer[10000];
3812 const uint8_t *ciphertext;
3814 struct rte_cryptodev_info dev_info;
3816 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3818 uint64_t feat_flags = dev_info.feature_flags;
3820 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3821 printf("Device doesn't support out-of-place scatter-gather "
3822 "in both input and output mbufs. "
3827 /* Create SNOW 3G session */
3828 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3829 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3830 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3831 tdata->key.data, tdata->key.len,
3832 tdata->cipher_iv.len);
3836 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3837 /* Append data which is padded to a multiple of */
3838 /* the algorithms block size */
3839 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3841 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3842 plaintext_pad_len, 10, 0);
3843 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3844 plaintext_pad_len, 3, 0);
3846 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3847 "Failed to allocate input buffer in mempool");
3848 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3849 "Failed to allocate output buffer in mempool");
3851 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3853 /* Create SNOW 3G operation */
3854 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3855 tdata->cipher_iv.len,
3856 tdata->validCipherLenInBits.len,
3861 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3863 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3865 ut_params->obuf = ut_params->op->sym->m_dst;
3866 if (ut_params->obuf)
3867 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3868 plaintext_len, buffer);
3870 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3871 plaintext_len, buffer);
3873 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3876 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3878 tdata->ciphertext.data,
3879 tdata->validDataLenInBits.len,
3880 "SNOW 3G Ciphertext data not as expected");
3885 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3887 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3889 uint8_t curr_byte, prev_byte;
3890 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3891 uint8_t lower_byte_mask = (1 << offset) - 1;
3894 prev_byte = buffer[0];
3895 buffer[0] >>= offset;
3897 for (i = 1; i < length_in_bytes; i++) {
3898 curr_byte = buffer[i];
3899 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3900 (curr_byte >> offset);
3901 prev_byte = curr_byte;
3906 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3908 struct crypto_testsuite_params *ts_params = &testsuite_params;
3909 struct crypto_unittest_params *ut_params = &unittest_params;
3910 uint8_t *plaintext, *ciphertext;
3912 uint32_t plaintext_len;
3913 uint32_t plaintext_pad_len;
3914 uint8_t extra_offset = 4;
3915 uint8_t *expected_ciphertext_shifted;
3917 /* Create SNOW 3G session */
3918 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3919 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3920 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3921 tdata->key.data, tdata->key.len,
3922 tdata->cipher_iv.len);
3926 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3927 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3929 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3930 "Failed to allocate input buffer in mempool");
3931 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3932 "Failed to allocate output buffer in mempool");
3934 /* Clear mbuf payload */
3935 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3936 rte_pktmbuf_tailroom(ut_params->ibuf));
3938 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3940 * Append data which is padded to a
3941 * multiple of the algorithms block size
3943 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3945 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3948 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3950 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3951 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3953 #ifdef RTE_APP_TEST_DEBUG
3954 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3956 /* Create SNOW 3G operation */
3957 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3958 tdata->cipher_iv.len,
3959 tdata->validCipherLenInBits.len,
3964 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3966 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3968 ut_params->obuf = ut_params->op->sym->m_dst;
3969 if (ut_params->obuf)
3970 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3972 ciphertext = plaintext;
3974 #ifdef RTE_APP_TEST_DEBUG
3975 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3978 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3980 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3981 "failed to reserve memory for ciphertext shifted\n");
3983 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3984 ceil_byte_length(tdata->ciphertext.len));
3985 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3988 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3990 expected_ciphertext_shifted,
3991 tdata->validDataLenInBits.len,
3993 "SNOW 3G Ciphertext data not as expected");
3997 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3999 struct crypto_testsuite_params *ts_params = &testsuite_params;
4000 struct crypto_unittest_params *ut_params = &unittest_params;
4004 uint8_t *plaintext, *ciphertext;
4005 unsigned ciphertext_pad_len;
4006 unsigned ciphertext_len;
4008 /* Create SNOW 3G session */
4009 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4010 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4011 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4012 tdata->key.data, tdata->key.len,
4013 tdata->cipher_iv.len);
4017 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4019 /* Clear mbuf payload */
4020 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4021 rte_pktmbuf_tailroom(ut_params->ibuf));
4023 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4024 /* Append data which is padded to a multiple of */
4025 /* the algorithms block size */
4026 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4027 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4028 ciphertext_pad_len);
4029 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4031 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4033 /* Create SNOW 3G operation */
4034 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4035 tdata->cipher_iv.len,
4036 tdata->validCipherLenInBits.len,
4041 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4043 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4044 ut_params->obuf = ut_params->op->sym->m_dst;
4045 if (ut_params->obuf)
4046 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4048 plaintext = ciphertext;
4050 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4053 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4054 tdata->plaintext.data,
4055 tdata->validDataLenInBits.len,
4056 "SNOW 3G Plaintext data not as expected");
4060 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4062 struct crypto_testsuite_params *ts_params = &testsuite_params;
4063 struct crypto_unittest_params *ut_params = &unittest_params;
4067 uint8_t *plaintext, *ciphertext;
4068 unsigned ciphertext_pad_len;
4069 unsigned ciphertext_len;
4071 /* Create SNOW 3G session */
4072 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4073 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4074 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4075 tdata->key.data, tdata->key.len,
4076 tdata->cipher_iv.len);
4080 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4081 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4083 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4084 "Failed to allocate input buffer");
4085 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4086 "Failed to allocate output buffer");
4088 /* Clear mbuf payload */
4089 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4090 rte_pktmbuf_tailroom(ut_params->ibuf));
4092 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4093 rte_pktmbuf_tailroom(ut_params->obuf));
4095 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4096 /* Append data which is padded to a multiple of */
4097 /* the algorithms block size */
4098 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4099 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4100 ciphertext_pad_len);
4101 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4102 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4104 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4106 /* Create SNOW 3G operation */
4107 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4108 tdata->cipher_iv.len,
4109 tdata->validCipherLenInBits.len,
4114 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4116 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4117 ut_params->obuf = ut_params->op->sym->m_dst;
4118 if (ut_params->obuf)
4119 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4121 plaintext = ciphertext;
4123 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4126 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4127 tdata->plaintext.data,
4128 tdata->validDataLenInBits.len,
4129 "SNOW 3G Plaintext data not as expected");
4134 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4136 struct crypto_testsuite_params *ts_params = &testsuite_params;
4137 struct crypto_unittest_params *ut_params = &unittest_params;
4141 uint8_t *plaintext, *ciphertext;
4142 unsigned int plaintext_pad_len;
4143 unsigned int plaintext_len;
4145 struct rte_cryptodev_sym_capability_idx cap_idx;
4147 /* Check if device supports ZUC EEA3 */
4148 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4149 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4151 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4155 /* Check if device supports ZUC EIA3 */
4156 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4157 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4159 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4163 /* Create ZUC session */
4164 retval = create_zuc_cipher_auth_encrypt_generate_session(
4165 ts_params->valid_devs[0],
4169 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4171 /* clear mbuf payload */
4172 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4173 rte_pktmbuf_tailroom(ut_params->ibuf));
4175 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4176 /* Append data which is padded to a multiple of */
4177 /* the algorithms block size */
4178 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4179 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4181 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4183 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4185 /* Create ZUC operation */
4186 retval = create_zuc_cipher_hash_generate_operation(tdata);
4190 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4192 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4193 ut_params->obuf = ut_params->op->sym->m_src;
4194 if (ut_params->obuf)
4195 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4197 ciphertext = plaintext;
4199 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4201 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4203 tdata->ciphertext.data,
4204 tdata->validDataLenInBits.len,
4205 "ZUC Ciphertext data not as expected");
4207 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4208 + plaintext_pad_len;
4211 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4215 "ZUC Generated auth tag not as expected");
4220 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4222 struct crypto_testsuite_params *ts_params = &testsuite_params;
4223 struct crypto_unittest_params *ut_params = &unittest_params;
4227 uint8_t *plaintext, *ciphertext;
4228 unsigned plaintext_pad_len;
4229 unsigned plaintext_len;
4231 /* Create SNOW 3G session */
4232 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4233 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4234 RTE_CRYPTO_AUTH_OP_GENERATE,
4235 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4236 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4237 tdata->key.data, tdata->key.len,
4238 tdata->auth_iv.len, tdata->digest.len,
4239 tdata->cipher_iv.len);
4242 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4244 /* clear mbuf payload */
4245 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4246 rte_pktmbuf_tailroom(ut_params->ibuf));
4248 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4249 /* Append data which is padded to a multiple of */
4250 /* the algorithms block size */
4251 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4252 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4254 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4256 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4258 /* Create SNOW 3G operation */
4259 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4260 tdata->digest.len, tdata->auth_iv.data,
4262 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4263 tdata->cipher_iv.data, tdata->cipher_iv.len,
4264 tdata->validCipherLenInBits.len,
4266 tdata->validAuthLenInBits.len,
4272 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4274 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4275 ut_params->obuf = ut_params->op->sym->m_src;
4276 if (ut_params->obuf)
4277 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4279 ciphertext = plaintext;
4281 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4283 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4285 tdata->ciphertext.data,
4286 tdata->validDataLenInBits.len,
4287 "SNOW 3G Ciphertext data not as expected");
4289 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4290 + plaintext_pad_len;
4293 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4296 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4297 "SNOW 3G Generated auth tag not as expected");
4301 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4303 struct crypto_testsuite_params *ts_params = &testsuite_params;
4304 struct crypto_unittest_params *ut_params = &unittest_params;
4308 uint8_t *plaintext, *ciphertext;
4309 unsigned plaintext_pad_len;
4310 unsigned plaintext_len;
4312 /* Create SNOW 3G session */
4313 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4314 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4315 RTE_CRYPTO_AUTH_OP_GENERATE,
4316 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4317 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4318 tdata->key.data, tdata->key.len,
4319 tdata->auth_iv.len, tdata->digest.len,
4320 tdata->cipher_iv.len);
4324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4326 /* clear mbuf payload */
4327 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4328 rte_pktmbuf_tailroom(ut_params->ibuf));
4330 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4331 /* Append data which is padded to a multiple of */
4332 /* the algorithms block size */
4333 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4334 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4336 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4338 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4340 /* Create SNOW 3G operation */
4341 retval = create_wireless_algo_auth_cipher_operation(
4343 tdata->cipher_iv.data, tdata->cipher_iv.len,
4344 tdata->auth_iv.data, tdata->auth_iv.len,
4346 tdata->validCipherLenInBits.len,
4348 tdata->validAuthLenInBits.len,
4354 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4356 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4357 ut_params->obuf = ut_params->op->sym->m_src;
4358 if (ut_params->obuf)
4359 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4361 ciphertext = plaintext;
4363 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4364 + plaintext_pad_len;
4365 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4368 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4370 tdata->ciphertext.data,
4371 tdata->validDataLenInBits.len,
4372 "SNOW 3G Ciphertext data not as expected");
4375 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4378 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4379 "SNOW 3G Generated auth tag not as expected");
4384 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4386 struct crypto_testsuite_params *ts_params = &testsuite_params;
4387 struct crypto_unittest_params *ut_params = &unittest_params;
4391 uint8_t *plaintext, *ciphertext;
4392 unsigned plaintext_pad_len;
4393 unsigned plaintext_len;
4395 /* Create KASUMI session */
4396 retval = create_wireless_algo_auth_cipher_session(
4397 ts_params->valid_devs[0],
4398 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4399 RTE_CRYPTO_AUTH_OP_GENERATE,
4400 RTE_CRYPTO_AUTH_KASUMI_F9,
4401 RTE_CRYPTO_CIPHER_KASUMI_F8,
4402 tdata->key.data, tdata->key.len,
4403 0, tdata->digest.len,
4404 tdata->cipher_iv.len);
4407 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4409 /* clear mbuf payload */
4410 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4411 rte_pktmbuf_tailroom(ut_params->ibuf));
4413 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4414 /* Append data which is padded to a multiple of */
4415 /* the algorithms block size */
4416 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4417 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4419 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4421 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4423 /* Create KASUMI operation */
4424 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4425 tdata->cipher_iv.data, tdata->cipher_iv.len,
4428 tdata->validCipherLenInBits.len,
4429 tdata->validCipherOffsetInBits.len,
4430 tdata->validAuthLenInBits.len,
4437 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4439 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4440 if (ut_params->op->sym->m_dst)
4441 ut_params->obuf = ut_params->op->sym->m_dst;
4443 ut_params->obuf = ut_params->op->sym->m_src;
4445 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4446 tdata->validCipherOffsetInBits.len >> 3);
4448 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4449 (tdata->validCipherOffsetInBits.len >> 3);
4451 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4453 reference_ciphertext,
4454 tdata->validCipherLenInBits.len,
4455 "KASUMI Ciphertext data not as expected");
4456 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4457 + plaintext_pad_len;
4460 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4463 DIGEST_BYTE_LENGTH_KASUMI_F9,
4464 "KASUMI Generated auth tag not as expected");
4469 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4471 struct crypto_testsuite_params *ts_params = &testsuite_params;
4472 struct crypto_unittest_params *ut_params = &unittest_params;
4476 uint8_t *plaintext, *ciphertext;
4477 unsigned plaintext_pad_len;
4478 unsigned plaintext_len;
4480 /* Create KASUMI session */
4481 retval = create_wireless_algo_cipher_auth_session(
4482 ts_params->valid_devs[0],
4483 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4484 RTE_CRYPTO_AUTH_OP_GENERATE,
4485 RTE_CRYPTO_AUTH_KASUMI_F9,
4486 RTE_CRYPTO_CIPHER_KASUMI_F8,
4487 tdata->key.data, tdata->key.len,
4488 0, tdata->digest.len,
4489 tdata->cipher_iv.len);
4493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4495 /* clear mbuf payload */
4496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4497 rte_pktmbuf_tailroom(ut_params->ibuf));
4499 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4500 /* Append data which is padded to a multiple of */
4501 /* the algorithms block size */
4502 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4503 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4505 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4507 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4509 /* Create KASUMI operation */
4510 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4511 tdata->digest.len, NULL, 0,
4512 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4513 tdata->cipher_iv.data, tdata->cipher_iv.len,
4514 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4515 tdata->validCipherOffsetInBits.len,
4516 tdata->validAuthLenInBits.len,
4522 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4524 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4526 if (ut_params->op->sym->m_dst)
4527 ut_params->obuf = ut_params->op->sym->m_dst;
4529 ut_params->obuf = ut_params->op->sym->m_src;
4531 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4532 tdata->validCipherOffsetInBits.len >> 3);
4534 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4535 + plaintext_pad_len;
4537 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4538 (tdata->validCipherOffsetInBits.len >> 3);
4540 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4542 reference_ciphertext,
4543 tdata->validCipherLenInBits.len,
4544 "KASUMI Ciphertext data not as expected");
4547 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4550 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4551 "KASUMI Generated auth tag not as expected");
4556 test_zuc_encryption(const struct wireless_test_data *tdata)
4558 struct crypto_testsuite_params *ts_params = &testsuite_params;
4559 struct crypto_unittest_params *ut_params = &unittest_params;
4562 uint8_t *plaintext, *ciphertext;
4563 unsigned plaintext_pad_len;
4564 unsigned plaintext_len;
4566 struct rte_cryptodev_sym_capability_idx cap_idx;
4568 /* Check if device supports ZUC EEA3 */
4569 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4570 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4572 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4576 /* Create ZUC session */
4577 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4578 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4579 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4580 tdata->key.data, tdata->key.len,
4581 tdata->cipher_iv.len);
4585 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4587 /* Clear mbuf payload */
4588 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4589 rte_pktmbuf_tailroom(ut_params->ibuf));
4591 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4592 /* Append data which is padded to a multiple */
4593 /* of the algorithms block size */
4594 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4595 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4597 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4599 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4601 /* Create ZUC operation */
4602 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4603 tdata->cipher_iv.len,
4604 tdata->plaintext.len,
4609 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4611 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4613 ut_params->obuf = ut_params->op->sym->m_dst;
4614 if (ut_params->obuf)
4615 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4617 ciphertext = plaintext;
4619 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4622 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4624 tdata->ciphertext.data,
4625 tdata->validCipherLenInBits.len,
4626 "ZUC Ciphertext data not as expected");
4631 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4633 struct crypto_testsuite_params *ts_params = &testsuite_params;
4634 struct crypto_unittest_params *ut_params = &unittest_params;
4638 unsigned int plaintext_pad_len;
4639 unsigned int plaintext_len;
4640 const uint8_t *ciphertext;
4641 uint8_t ciphertext_buffer[2048];
4642 struct rte_cryptodev_info dev_info;
4644 struct rte_cryptodev_sym_capability_idx cap_idx;
4646 /* Check if device supports ZUC EEA3 */
4647 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4648 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4650 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4654 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4656 uint64_t feat_flags = dev_info.feature_flags;
4658 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4659 printf("Device doesn't support in-place scatter-gather. "
4664 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4666 /* Append data which is padded to a multiple */
4667 /* of the algorithms block size */
4668 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4670 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4671 plaintext_pad_len, 10, 0);
4673 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4674 tdata->plaintext.data);
4676 /* Create ZUC session */
4677 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4678 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4679 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4680 tdata->key.data, tdata->key.len,
4681 tdata->cipher_iv.len);
4685 /* Clear mbuf payload */
4687 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4689 /* Create ZUC operation */
4690 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4691 tdata->cipher_iv.len, tdata->plaintext.len,
4696 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4698 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4700 ut_params->obuf = ut_params->op->sym->m_dst;
4701 if (ut_params->obuf)
4702 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4703 0, plaintext_len, ciphertext_buffer);
4705 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4706 0, plaintext_len, ciphertext_buffer);
4709 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4712 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4714 tdata->ciphertext.data,
4715 tdata->validCipherLenInBits.len,
4716 "ZUC Ciphertext data not as expected");
4722 test_zuc_authentication(const struct wireless_test_data *tdata)
4724 struct crypto_testsuite_params *ts_params = &testsuite_params;
4725 struct crypto_unittest_params *ut_params = &unittest_params;
4728 unsigned plaintext_pad_len;
4729 unsigned plaintext_len;
4732 struct rte_cryptodev_sym_capability_idx cap_idx;
4734 /* Check if device supports ZUC EIA3 */
4735 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4736 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4738 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4742 /* Create ZUC session */
4743 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4744 tdata->key.data, tdata->key.len,
4745 tdata->auth_iv.len, tdata->digest.len,
4746 RTE_CRYPTO_AUTH_OP_GENERATE,
4747 RTE_CRYPTO_AUTH_ZUC_EIA3);
4751 /* alloc mbuf and set payload */
4752 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4754 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4755 rte_pktmbuf_tailroom(ut_params->ibuf));
4757 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4758 /* Append data which is padded to a multiple of */
4759 /* the algorithms block size */
4760 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4761 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4763 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4765 /* Create ZUC operation */
4766 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4767 tdata->auth_iv.data, tdata->auth_iv.len,
4768 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4769 tdata->validAuthLenInBits.len,
4774 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4776 ut_params->obuf = ut_params->op->sym->m_src;
4777 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4778 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4779 + plaintext_pad_len;
4782 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4785 DIGEST_BYTE_LENGTH_KASUMI_F9,
4786 "ZUC Generated auth tag not as expected");
4792 test_kasumi_encryption_test_case_1(void)
4794 return test_kasumi_encryption(&kasumi_test_case_1);
4798 test_kasumi_encryption_test_case_1_sgl(void)
4800 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4804 test_kasumi_encryption_test_case_1_oop(void)
4806 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4810 test_kasumi_encryption_test_case_1_oop_sgl(void)
4812 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4816 test_kasumi_encryption_test_case_2(void)
4818 return test_kasumi_encryption(&kasumi_test_case_2);
4822 test_kasumi_encryption_test_case_3(void)
4824 return test_kasumi_encryption(&kasumi_test_case_3);
4828 test_kasumi_encryption_test_case_4(void)
4830 return test_kasumi_encryption(&kasumi_test_case_4);
4834 test_kasumi_encryption_test_case_5(void)
4836 return test_kasumi_encryption(&kasumi_test_case_5);
4840 test_kasumi_decryption_test_case_1(void)
4842 return test_kasumi_decryption(&kasumi_test_case_1);
4846 test_kasumi_decryption_test_case_1_oop(void)
4848 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4852 test_kasumi_decryption_test_case_2(void)
4854 return test_kasumi_decryption(&kasumi_test_case_2);
4858 test_kasumi_decryption_test_case_3(void)
4860 return test_kasumi_decryption(&kasumi_test_case_3);
4864 test_kasumi_decryption_test_case_4(void)
4866 return test_kasumi_decryption(&kasumi_test_case_4);
4870 test_kasumi_decryption_test_case_5(void)
4872 return test_kasumi_decryption(&kasumi_test_case_5);
4875 test_snow3g_encryption_test_case_1(void)
4877 return test_snow3g_encryption(&snow3g_test_case_1);
4881 test_snow3g_encryption_test_case_1_oop(void)
4883 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4887 test_snow3g_encryption_test_case_1_oop_sgl(void)
4889 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4894 test_snow3g_encryption_test_case_1_offset_oop(void)
4896 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4900 test_snow3g_encryption_test_case_2(void)
4902 return test_snow3g_encryption(&snow3g_test_case_2);
4906 test_snow3g_encryption_test_case_3(void)
4908 return test_snow3g_encryption(&snow3g_test_case_3);
4912 test_snow3g_encryption_test_case_4(void)
4914 return test_snow3g_encryption(&snow3g_test_case_4);
4918 test_snow3g_encryption_test_case_5(void)
4920 return test_snow3g_encryption(&snow3g_test_case_5);
4924 test_snow3g_decryption_test_case_1(void)
4926 return test_snow3g_decryption(&snow3g_test_case_1);
4930 test_snow3g_decryption_test_case_1_oop(void)
4932 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4936 test_snow3g_decryption_test_case_2(void)
4938 return test_snow3g_decryption(&snow3g_test_case_2);
4942 test_snow3g_decryption_test_case_3(void)
4944 return test_snow3g_decryption(&snow3g_test_case_3);
4948 test_snow3g_decryption_test_case_4(void)
4950 return test_snow3g_decryption(&snow3g_test_case_4);
4954 test_snow3g_decryption_test_case_5(void)
4956 return test_snow3g_decryption(&snow3g_test_case_5);
4959 test_snow3g_cipher_auth_test_case_1(void)
4961 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4965 test_snow3g_auth_cipher_test_case_1(void)
4967 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4971 test_kasumi_auth_cipher_test_case_1(void)
4973 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4977 test_kasumi_cipher_auth_test_case_1(void)
4979 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4983 test_zuc_encryption_test_case_1(void)
4985 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4989 test_zuc_encryption_test_case_2(void)
4991 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4995 test_zuc_encryption_test_case_3(void)
4997 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
5001 test_zuc_encryption_test_case_4(void)
5003 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
5007 test_zuc_encryption_test_case_5(void)
5009 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
5013 test_zuc_encryption_test_case_6_sgl(void)
5015 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
5019 test_zuc_hash_generate_test_case_1(void)
5021 return test_zuc_authentication(&zuc_test_case_auth_1b);
5025 test_zuc_hash_generate_test_case_2(void)
5027 return test_zuc_authentication(&zuc_test_case_auth_90b);
5031 test_zuc_hash_generate_test_case_3(void)
5033 return test_zuc_authentication(&zuc_test_case_auth_577b);
5037 test_zuc_hash_generate_test_case_4(void)
5039 return test_zuc_authentication(&zuc_test_case_auth_2079b);
5043 test_zuc_hash_generate_test_case_5(void)
5045 return test_zuc_authentication(&zuc_test_auth_5670b);
5049 test_zuc_hash_generate_test_case_6(void)
5051 return test_zuc_authentication(&zuc_test_case_auth_128b);
5055 test_zuc_hash_generate_test_case_7(void)
5057 return test_zuc_authentication(&zuc_test_case_auth_2080b);
5061 test_zuc_hash_generate_test_case_8(void)
5063 return test_zuc_authentication(&zuc_test_case_auth_584b);
5067 test_zuc_cipher_auth_test_case_1(void)
5069 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
5073 test_zuc_cipher_auth_test_case_2(void)
5075 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
5079 test_3DES_chain_qat_all(void)
5081 struct crypto_testsuite_params *ts_params = &testsuite_params;
5084 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5085 ts_params->op_mpool,
5086 ts_params->session_mpool,
5087 ts_params->valid_devs[0],
5088 rte_cryptodev_driver_id_get(
5089 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5090 BLKCIPHER_3DES_CHAIN_TYPE);
5092 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5094 return TEST_SUCCESS;
5098 test_DES_cipheronly_qat_all(void)
5100 struct crypto_testsuite_params *ts_params = &testsuite_params;
5103 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5104 ts_params->op_mpool,
5105 ts_params->session_mpool,
5106 ts_params->valid_devs[0],
5107 rte_cryptodev_driver_id_get(
5108 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5109 BLKCIPHER_DES_CIPHERONLY_TYPE);
5111 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5113 return TEST_SUCCESS;
5117 test_DES_cipheronly_openssl_all(void)
5119 struct crypto_testsuite_params *ts_params = &testsuite_params;
5122 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5123 ts_params->op_mpool,
5124 ts_params->session_mpool,
5125 ts_params->valid_devs[0],
5126 rte_cryptodev_driver_id_get(
5127 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5128 BLKCIPHER_DES_CIPHERONLY_TYPE);
5130 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5132 return TEST_SUCCESS;
5136 test_DES_docsis_openssl_all(void)
5138 struct crypto_testsuite_params *ts_params = &testsuite_params;
5141 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5142 ts_params->op_mpool,
5143 ts_params->session_mpool,
5144 ts_params->valid_devs[0],
5145 rte_cryptodev_driver_id_get(
5146 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5147 BLKCIPHER_DES_DOCSIS_TYPE);
5149 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5151 return TEST_SUCCESS;
5155 test_DES_cipheronly_mb_all(void)
5157 struct crypto_testsuite_params *ts_params = &testsuite_params;
5160 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5161 ts_params->op_mpool,
5162 ts_params->session_mpool,
5163 ts_params->valid_devs[0],
5164 rte_cryptodev_driver_id_get(
5165 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5166 BLKCIPHER_DES_CIPHERONLY_TYPE);
5168 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5170 return TEST_SUCCESS;
5173 test_3DES_cipheronly_mb_all(void)
5175 struct crypto_testsuite_params *ts_params = &testsuite_params;
5178 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5179 ts_params->op_mpool,
5180 ts_params->session_mpool,
5181 ts_params->valid_devs[0],
5182 rte_cryptodev_driver_id_get(
5183 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5184 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5186 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5188 return TEST_SUCCESS;
5192 test_DES_docsis_mb_all(void)
5194 struct crypto_testsuite_params *ts_params = &testsuite_params;
5197 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5198 ts_params->op_mpool,
5199 ts_params->session_mpool,
5200 ts_params->valid_devs[0],
5201 rte_cryptodev_driver_id_get(
5202 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5203 BLKCIPHER_DES_DOCSIS_TYPE);
5205 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5207 return TEST_SUCCESS;
5211 test_3DES_chain_caam_jr_all(void)
5213 struct crypto_testsuite_params *ts_params = &testsuite_params;
5216 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5217 ts_params->op_mpool,
5218 ts_params->session_mpool,
5219 ts_params->valid_devs[0],
5220 rte_cryptodev_driver_id_get(
5221 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5222 BLKCIPHER_3DES_CHAIN_TYPE);
5224 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5226 return TEST_SUCCESS;
5230 test_3DES_cipheronly_caam_jr_all(void)
5232 struct crypto_testsuite_params *ts_params = &testsuite_params;
5235 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5236 ts_params->op_mpool,
5237 ts_params->session_mpool,
5238 ts_params->valid_devs[0],
5239 rte_cryptodev_driver_id_get(
5240 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
5241 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5243 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5245 return TEST_SUCCESS;
5249 test_3DES_chain_dpaa_sec_all(void)
5251 struct crypto_testsuite_params *ts_params = &testsuite_params;
5254 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5255 ts_params->op_mpool,
5256 ts_params->session_mpool,
5257 ts_params->valid_devs[0],
5258 rte_cryptodev_driver_id_get(
5259 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5260 BLKCIPHER_3DES_CHAIN_TYPE);
5262 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5264 return TEST_SUCCESS;
5268 test_3DES_cipheronly_dpaa_sec_all(void)
5270 struct crypto_testsuite_params *ts_params = &testsuite_params;
5273 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5274 ts_params->op_mpool,
5275 ts_params->session_mpool,
5276 ts_params->valid_devs[0],
5277 rte_cryptodev_driver_id_get(
5278 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5279 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5281 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5283 return TEST_SUCCESS;
5287 test_3DES_chain_dpaa2_sec_all(void)
5289 struct crypto_testsuite_params *ts_params = &testsuite_params;
5292 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5293 ts_params->op_mpool,
5294 ts_params->session_mpool,
5295 ts_params->valid_devs[0],
5296 rte_cryptodev_driver_id_get(
5297 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5298 BLKCIPHER_3DES_CHAIN_TYPE);
5300 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5302 return TEST_SUCCESS;
5306 test_3DES_cipheronly_dpaa2_sec_all(void)
5308 struct crypto_testsuite_params *ts_params = &testsuite_params;
5311 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5312 ts_params->op_mpool,
5313 ts_params->session_mpool,
5314 ts_params->valid_devs[0],
5315 rte_cryptodev_driver_id_get(
5316 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5317 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5319 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5321 return TEST_SUCCESS;
5325 test_3DES_chain_ccp_all(void)
5327 struct crypto_testsuite_params *ts_params = &testsuite_params;
5330 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5331 ts_params->op_mpool,
5332 ts_params->session_mpool,
5333 ts_params->valid_devs[0],
5334 rte_cryptodev_driver_id_get(
5335 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5336 BLKCIPHER_3DES_CHAIN_TYPE);
5338 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5340 return TEST_SUCCESS;
5344 test_3DES_cipheronly_ccp_all(void)
5346 struct crypto_testsuite_params *ts_params = &testsuite_params;
5349 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5350 ts_params->op_mpool,
5351 ts_params->session_mpool,
5352 ts_params->valid_devs[0],
5353 rte_cryptodev_driver_id_get(
5354 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5355 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5357 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5359 return TEST_SUCCESS;
5363 test_3DES_cipheronly_qat_all(void)
5365 struct crypto_testsuite_params *ts_params = &testsuite_params;
5368 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5369 ts_params->op_mpool,
5370 ts_params->session_mpool,
5371 ts_params->valid_devs[0],
5372 rte_cryptodev_driver_id_get(
5373 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5374 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5376 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5378 return TEST_SUCCESS;
5382 test_3DES_chain_openssl_all(void)
5384 struct crypto_testsuite_params *ts_params = &testsuite_params;
5387 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5388 ts_params->op_mpool,
5389 ts_params->session_mpool,
5390 ts_params->valid_devs[0],
5391 rte_cryptodev_driver_id_get(
5392 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5393 BLKCIPHER_3DES_CHAIN_TYPE);
5395 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5397 return TEST_SUCCESS;
5401 test_3DES_cipheronly_openssl_all(void)
5403 struct crypto_testsuite_params *ts_params = &testsuite_params;
5406 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5407 ts_params->op_mpool,
5408 ts_params->session_mpool,
5409 ts_params->valid_devs[0],
5410 rte_cryptodev_driver_id_get(
5411 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5412 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5414 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5416 return TEST_SUCCESS;
5419 /* ***** AEAD algorithm Tests ***** */
5422 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5423 enum rte_crypto_aead_operation op,
5424 const uint8_t *key, const uint8_t key_len,
5425 const uint16_t aad_len, const uint8_t auth_len,
5428 uint8_t aead_key[key_len];
5430 struct crypto_testsuite_params *ts_params = &testsuite_params;
5431 struct crypto_unittest_params *ut_params = &unittest_params;
5433 memcpy(aead_key, key, key_len);
5435 /* Setup AEAD Parameters */
5436 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5437 ut_params->aead_xform.next = NULL;
5438 ut_params->aead_xform.aead.algo = algo;
5439 ut_params->aead_xform.aead.op = op;
5440 ut_params->aead_xform.aead.key.data = aead_key;
5441 ut_params->aead_xform.aead.key.length = key_len;
5442 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5443 ut_params->aead_xform.aead.iv.length = iv_len;
5444 ut_params->aead_xform.aead.digest_length = auth_len;
5445 ut_params->aead_xform.aead.aad_length = aad_len;
5447 debug_hexdump(stdout, "key:", key, key_len);
5449 /* Create Crypto session*/
5450 ut_params->sess = rte_cryptodev_sym_session_create(
5451 ts_params->session_mpool);
5453 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5454 &ut_params->aead_xform, ts_params->session_mpool);
5456 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5462 create_aead_xform(struct rte_crypto_op *op,
5463 enum rte_crypto_aead_algorithm algo,
5464 enum rte_crypto_aead_operation aead_op,
5465 uint8_t *key, const uint8_t key_len,
5466 const uint8_t aad_len, const uint8_t auth_len,
5469 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5470 "failed to allocate space for crypto transform");
5472 struct rte_crypto_sym_op *sym_op = op->sym;
5474 /* Setup AEAD Parameters */
5475 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5476 sym_op->xform->next = NULL;
5477 sym_op->xform->aead.algo = algo;
5478 sym_op->xform->aead.op = aead_op;
5479 sym_op->xform->aead.key.data = key;
5480 sym_op->xform->aead.key.length = key_len;
5481 sym_op->xform->aead.iv.offset = IV_OFFSET;
5482 sym_op->xform->aead.iv.length = iv_len;
5483 sym_op->xform->aead.digest_length = auth_len;
5484 sym_op->xform->aead.aad_length = aad_len;
5486 debug_hexdump(stdout, "key:", key, key_len);
5492 create_aead_operation(enum rte_crypto_aead_operation op,
5493 const struct aead_test_data *tdata)
5495 struct crypto_testsuite_params *ts_params = &testsuite_params;
5496 struct crypto_unittest_params *ut_params = &unittest_params;
5498 uint8_t *plaintext, *ciphertext;
5499 unsigned int aad_pad_len, plaintext_pad_len;
5501 /* Generate Crypto op data structure */
5502 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5503 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5504 TEST_ASSERT_NOT_NULL(ut_params->op,
5505 "Failed to allocate symmetric crypto operation struct");
5507 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5509 /* Append aad data */
5510 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5511 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5512 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5514 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5515 "no room to append aad");
5517 sym_op->aead.aad.phys_addr =
5518 rte_pktmbuf_iova(ut_params->ibuf);
5519 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5520 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5521 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5524 /* Append IV at the end of the crypto operation*/
5525 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5526 uint8_t *, IV_OFFSET);
5528 /* Copy IV 1 byte after the IV pointer, according to the API */
5529 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5530 debug_hexdump(stdout, "iv:", iv_ptr,
5533 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5534 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5536 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5537 "no room to append aad");
5539 sym_op->aead.aad.phys_addr =
5540 rte_pktmbuf_iova(ut_params->ibuf);
5541 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5542 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5545 /* Append IV at the end of the crypto operation*/
5546 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5547 uint8_t *, IV_OFFSET);
5549 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5550 debug_hexdump(stdout, "iv:", iv_ptr,
5554 /* Append plaintext/ciphertext */
5555 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5556 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5557 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5559 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5561 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5562 debug_hexdump(stdout, "plaintext:", plaintext,
5563 tdata->plaintext.len);
5565 if (ut_params->obuf) {
5566 ciphertext = (uint8_t *)rte_pktmbuf_append(
5568 plaintext_pad_len + aad_pad_len);
5569 TEST_ASSERT_NOT_NULL(ciphertext,
5570 "no room to append ciphertext");
5572 memset(ciphertext + aad_pad_len, 0,
5573 tdata->ciphertext.len);
5576 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5577 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5579 TEST_ASSERT_NOT_NULL(ciphertext,
5580 "no room to append ciphertext");
5582 memcpy(ciphertext, tdata->ciphertext.data,
5583 tdata->ciphertext.len);
5584 debug_hexdump(stdout, "ciphertext:", ciphertext,
5585 tdata->ciphertext.len);
5587 if (ut_params->obuf) {
5588 plaintext = (uint8_t *)rte_pktmbuf_append(
5590 plaintext_pad_len + aad_pad_len);
5591 TEST_ASSERT_NOT_NULL(plaintext,
5592 "no room to append plaintext");
5594 memset(plaintext + aad_pad_len, 0,
5595 tdata->plaintext.len);
5599 /* Append digest data */
5600 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5601 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5602 ut_params->obuf ? ut_params->obuf :
5604 tdata->auth_tag.len);
5605 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5606 "no room to append digest");
5607 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5608 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5609 ut_params->obuf ? ut_params->obuf :
5614 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5615 ut_params->ibuf, tdata->auth_tag.len);
5616 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5617 "no room to append digest");
5618 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5620 plaintext_pad_len + aad_pad_len);
5622 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5623 tdata->auth_tag.len);
5624 debug_hexdump(stdout, "digest:",
5625 sym_op->aead.digest.data,
5626 tdata->auth_tag.len);
5629 sym_op->aead.data.length = tdata->plaintext.len;
5630 sym_op->aead.data.offset = aad_pad_len;
5636 test_authenticated_encryption(const struct aead_test_data *tdata)
5638 struct crypto_testsuite_params *ts_params = &testsuite_params;
5639 struct crypto_unittest_params *ut_params = &unittest_params;
5642 uint8_t *ciphertext, *auth_tag;
5643 uint16_t plaintext_pad_len;
5646 /* Create AEAD session */
5647 retval = create_aead_session(ts_params->valid_devs[0],
5649 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5650 tdata->key.data, tdata->key.len,
5651 tdata->aad.len, tdata->auth_tag.len,
5656 if (tdata->aad.len > MBUF_SIZE) {
5657 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5658 /* Populate full size of add data */
5659 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5660 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5662 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5664 /* clear mbuf payload */
5665 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5666 rte_pktmbuf_tailroom(ut_params->ibuf));
5668 /* Create AEAD operation */
5669 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5673 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5675 ut_params->op->sym->m_src = ut_params->ibuf;
5677 /* Process crypto operation */
5678 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5679 ut_params->op), "failed to process sym crypto op");
5681 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5682 "crypto op processing failed");
5684 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5686 if (ut_params->op->sym->m_dst) {
5687 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5689 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5690 uint8_t *, plaintext_pad_len);
5692 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5694 ut_params->op->sym->cipher.data.offset);
5695 auth_tag = ciphertext + plaintext_pad_len;
5698 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5699 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5702 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5704 tdata->ciphertext.data,
5705 tdata->ciphertext.len,
5706 "Ciphertext data not as expected");
5708 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5710 tdata->auth_tag.data,
5711 tdata->auth_tag.len,
5712 "Generated auth tag not as expected");
5719 test_AES_GCM_authenticated_encryption_test_case_1(void)
5721 return test_authenticated_encryption(&gcm_test_case_1);
5725 test_AES_GCM_authenticated_encryption_test_case_2(void)
5727 return test_authenticated_encryption(&gcm_test_case_2);
5731 test_AES_GCM_authenticated_encryption_test_case_3(void)
5733 return test_authenticated_encryption(&gcm_test_case_3);
5737 test_AES_GCM_authenticated_encryption_test_case_4(void)
5739 return test_authenticated_encryption(&gcm_test_case_4);
5743 test_AES_GCM_authenticated_encryption_test_case_5(void)
5745 return test_authenticated_encryption(&gcm_test_case_5);
5749 test_AES_GCM_authenticated_encryption_test_case_6(void)
5751 return test_authenticated_encryption(&gcm_test_case_6);
5755 test_AES_GCM_authenticated_encryption_test_case_7(void)
5757 return test_authenticated_encryption(&gcm_test_case_7);
5761 test_AES_GCM_auth_encryption_test_case_192_1(void)
5763 return test_authenticated_encryption(&gcm_test_case_192_1);
5767 test_AES_GCM_auth_encryption_test_case_192_2(void)
5769 return test_authenticated_encryption(&gcm_test_case_192_2);
5773 test_AES_GCM_auth_encryption_test_case_192_3(void)
5775 return test_authenticated_encryption(&gcm_test_case_192_3);
5779 test_AES_GCM_auth_encryption_test_case_192_4(void)
5781 return test_authenticated_encryption(&gcm_test_case_192_4);
5785 test_AES_GCM_auth_encryption_test_case_192_5(void)
5787 return test_authenticated_encryption(&gcm_test_case_192_5);
5791 test_AES_GCM_auth_encryption_test_case_192_6(void)
5793 return test_authenticated_encryption(&gcm_test_case_192_6);
5797 test_AES_GCM_auth_encryption_test_case_192_7(void)
5799 return test_authenticated_encryption(&gcm_test_case_192_7);
5803 test_AES_GCM_auth_encryption_test_case_256_1(void)
5805 return test_authenticated_encryption(&gcm_test_case_256_1);
5809 test_AES_GCM_auth_encryption_test_case_256_2(void)
5811 return test_authenticated_encryption(&gcm_test_case_256_2);
5815 test_AES_GCM_auth_encryption_test_case_256_3(void)
5817 return test_authenticated_encryption(&gcm_test_case_256_3);
5821 test_AES_GCM_auth_encryption_test_case_256_4(void)
5823 return test_authenticated_encryption(&gcm_test_case_256_4);
5827 test_AES_GCM_auth_encryption_test_case_256_5(void)
5829 return test_authenticated_encryption(&gcm_test_case_256_5);
5833 test_AES_GCM_auth_encryption_test_case_256_6(void)
5835 return test_authenticated_encryption(&gcm_test_case_256_6);
5839 test_AES_GCM_auth_encryption_test_case_256_7(void)
5841 return test_authenticated_encryption(&gcm_test_case_256_7);
5845 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5847 return test_authenticated_encryption(&gcm_test_case_aad_1);
5851 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5853 return test_authenticated_encryption(&gcm_test_case_aad_2);
5857 test_authenticated_decryption(const struct aead_test_data *tdata)
5859 struct crypto_testsuite_params *ts_params = &testsuite_params;
5860 struct crypto_unittest_params *ut_params = &unittest_params;
5866 /* Create AEAD session */
5867 retval = create_aead_session(ts_params->valid_devs[0],
5869 RTE_CRYPTO_AEAD_OP_DECRYPT,
5870 tdata->key.data, tdata->key.len,
5871 tdata->aad.len, tdata->auth_tag.len,
5876 /* alloc mbuf and set payload */
5877 if (tdata->aad.len > MBUF_SIZE) {
5878 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5879 /* Populate full size of add data */
5880 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5881 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5883 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5885 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5886 rte_pktmbuf_tailroom(ut_params->ibuf));
5888 /* Create AEAD operation */
5889 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5895 ut_params->op->sym->m_src = ut_params->ibuf;
5897 /* Process crypto operation */
5898 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5899 ut_params->op), "failed to process sym crypto op");
5901 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5902 "crypto op processing failed");
5904 if (ut_params->op->sym->m_dst)
5905 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5908 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5910 ut_params->op->sym->cipher.data.offset);
5912 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5915 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5917 tdata->plaintext.data,
5918 tdata->plaintext.len,
5919 "Plaintext data not as expected");
5921 TEST_ASSERT_EQUAL(ut_params->op->status,
5922 RTE_CRYPTO_OP_STATUS_SUCCESS,
5923 "Authentication failed");
5928 test_AES_GCM_authenticated_decryption_test_case_1(void)
5930 return test_authenticated_decryption(&gcm_test_case_1);
5934 test_AES_GCM_authenticated_decryption_test_case_2(void)
5936 return test_authenticated_decryption(&gcm_test_case_2);
5940 test_AES_GCM_authenticated_decryption_test_case_3(void)
5942 return test_authenticated_decryption(&gcm_test_case_3);
5946 test_AES_GCM_authenticated_decryption_test_case_4(void)
5948 return test_authenticated_decryption(&gcm_test_case_4);
5952 test_AES_GCM_authenticated_decryption_test_case_5(void)
5954 return test_authenticated_decryption(&gcm_test_case_5);
5958 test_AES_GCM_authenticated_decryption_test_case_6(void)
5960 return test_authenticated_decryption(&gcm_test_case_6);
5964 test_AES_GCM_authenticated_decryption_test_case_7(void)
5966 return test_authenticated_decryption(&gcm_test_case_7);
5970 test_AES_GCM_auth_decryption_test_case_192_1(void)
5972 return test_authenticated_decryption(&gcm_test_case_192_1);
5976 test_AES_GCM_auth_decryption_test_case_192_2(void)
5978 return test_authenticated_decryption(&gcm_test_case_192_2);
5982 test_AES_GCM_auth_decryption_test_case_192_3(void)
5984 return test_authenticated_decryption(&gcm_test_case_192_3);
5988 test_AES_GCM_auth_decryption_test_case_192_4(void)
5990 return test_authenticated_decryption(&gcm_test_case_192_4);
5994 test_AES_GCM_auth_decryption_test_case_192_5(void)
5996 return test_authenticated_decryption(&gcm_test_case_192_5);
6000 test_AES_GCM_auth_decryption_test_case_192_6(void)
6002 return test_authenticated_decryption(&gcm_test_case_192_6);
6006 test_AES_GCM_auth_decryption_test_case_192_7(void)
6008 return test_authenticated_decryption(&gcm_test_case_192_7);
6012 test_AES_GCM_auth_decryption_test_case_256_1(void)
6014 return test_authenticated_decryption(&gcm_test_case_256_1);
6018 test_AES_GCM_auth_decryption_test_case_256_2(void)
6020 return test_authenticated_decryption(&gcm_test_case_256_2);
6024 test_AES_GCM_auth_decryption_test_case_256_3(void)
6026 return test_authenticated_decryption(&gcm_test_case_256_3);
6030 test_AES_GCM_auth_decryption_test_case_256_4(void)
6032 return test_authenticated_decryption(&gcm_test_case_256_4);
6036 test_AES_GCM_auth_decryption_test_case_256_5(void)
6038 return test_authenticated_decryption(&gcm_test_case_256_5);
6042 test_AES_GCM_auth_decryption_test_case_256_6(void)
6044 return test_authenticated_decryption(&gcm_test_case_256_6);
6048 test_AES_GCM_auth_decryption_test_case_256_7(void)
6050 return test_authenticated_decryption(&gcm_test_case_256_7);
6054 test_AES_GCM_auth_decryption_test_case_aad_1(void)
6056 return test_authenticated_decryption(&gcm_test_case_aad_1);
6060 test_AES_GCM_auth_decryption_test_case_aad_2(void)
6062 return test_authenticated_decryption(&gcm_test_case_aad_2);
6066 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
6068 struct crypto_testsuite_params *ts_params = &testsuite_params;
6069 struct crypto_unittest_params *ut_params = &unittest_params;
6072 uint8_t *ciphertext, *auth_tag;
6073 uint16_t plaintext_pad_len;
6075 /* Create AEAD session */
6076 retval = create_aead_session(ts_params->valid_devs[0],
6078 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6079 tdata->key.data, tdata->key.len,
6080 tdata->aad.len, tdata->auth_tag.len,
6085 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6086 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6088 /* clear mbuf payload */
6089 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6090 rte_pktmbuf_tailroom(ut_params->ibuf));
6091 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6092 rte_pktmbuf_tailroom(ut_params->obuf));
6094 /* Create AEAD operation */
6095 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6099 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6101 ut_params->op->sym->m_src = ut_params->ibuf;
6102 ut_params->op->sym->m_dst = ut_params->obuf;
6104 /* Process crypto operation */
6105 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6106 ut_params->op), "failed to process sym crypto op");
6108 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6109 "crypto op processing failed");
6111 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6113 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6114 ut_params->op->sym->cipher.data.offset);
6115 auth_tag = ciphertext + plaintext_pad_len;
6117 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6118 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6121 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6123 tdata->ciphertext.data,
6124 tdata->ciphertext.len,
6125 "Ciphertext data not as expected");
6127 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6129 tdata->auth_tag.data,
6130 tdata->auth_tag.len,
6131 "Generated auth tag not as expected");
6138 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
6140 return test_authenticated_encryption_oop(&gcm_test_case_5);
6144 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
6146 struct crypto_testsuite_params *ts_params = &testsuite_params;
6147 struct crypto_unittest_params *ut_params = &unittest_params;
6152 /* Create AEAD session */
6153 retval = create_aead_session(ts_params->valid_devs[0],
6155 RTE_CRYPTO_AEAD_OP_DECRYPT,
6156 tdata->key.data, tdata->key.len,
6157 tdata->aad.len, tdata->auth_tag.len,
6162 /* alloc mbuf and set payload */
6163 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6164 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6166 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6167 rte_pktmbuf_tailroom(ut_params->ibuf));
6168 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6169 rte_pktmbuf_tailroom(ut_params->obuf));
6171 /* Create AEAD operation */
6172 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6176 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6178 ut_params->op->sym->m_src = ut_params->ibuf;
6179 ut_params->op->sym->m_dst = ut_params->obuf;
6181 /* Process crypto operation */
6182 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6183 ut_params->op), "failed to process sym crypto op");
6185 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6186 "crypto op processing failed");
6188 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
6189 ut_params->op->sym->cipher.data.offset);
6191 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6194 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6196 tdata->plaintext.data,
6197 tdata->plaintext.len,
6198 "Plaintext data not as expected");
6200 TEST_ASSERT_EQUAL(ut_params->op->status,
6201 RTE_CRYPTO_OP_STATUS_SUCCESS,
6202 "Authentication failed");
6207 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
6209 return test_authenticated_decryption_oop(&gcm_test_case_5);
6213 test_authenticated_encryption_sessionless(
6214 const struct aead_test_data *tdata)
6216 struct crypto_testsuite_params *ts_params = &testsuite_params;
6217 struct crypto_unittest_params *ut_params = &unittest_params;
6220 uint8_t *ciphertext, *auth_tag;
6221 uint16_t plaintext_pad_len;
6222 uint8_t key[tdata->key.len + 1];
6224 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6226 /* clear mbuf payload */
6227 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6228 rte_pktmbuf_tailroom(ut_params->ibuf));
6230 /* Create AEAD operation */
6231 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6235 /* Create GCM xform */
6236 memcpy(key, tdata->key.data, tdata->key.len);
6237 retval = create_aead_xform(ut_params->op,
6239 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6240 key, tdata->key.len,
6241 tdata->aad.len, tdata->auth_tag.len,
6246 ut_params->op->sym->m_src = ut_params->ibuf;
6248 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6249 RTE_CRYPTO_OP_SESSIONLESS,
6250 "crypto op session type not sessionless");
6252 /* Process crypto operation */
6253 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6254 ut_params->op), "failed to process sym crypto op");
6256 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6258 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6259 "crypto op status not success");
6261 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6263 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6264 ut_params->op->sym->cipher.data.offset);
6265 auth_tag = ciphertext + plaintext_pad_len;
6267 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6268 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6271 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6273 tdata->ciphertext.data,
6274 tdata->ciphertext.len,
6275 "Ciphertext data not as expected");
6277 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6279 tdata->auth_tag.data,
6280 tdata->auth_tag.len,
6281 "Generated auth tag not as expected");
6288 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6290 return test_authenticated_encryption_sessionless(
6295 test_authenticated_decryption_sessionless(
6296 const struct aead_test_data *tdata)
6298 struct crypto_testsuite_params *ts_params = &testsuite_params;
6299 struct crypto_unittest_params *ut_params = &unittest_params;
6303 uint8_t key[tdata->key.len + 1];
6305 /* alloc mbuf and set payload */
6306 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6308 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6309 rte_pktmbuf_tailroom(ut_params->ibuf));
6311 /* Create AEAD operation */
6312 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6316 /* Create AEAD xform */
6317 memcpy(key, tdata->key.data, tdata->key.len);
6318 retval = create_aead_xform(ut_params->op,
6320 RTE_CRYPTO_AEAD_OP_DECRYPT,
6321 key, tdata->key.len,
6322 tdata->aad.len, tdata->auth_tag.len,
6327 ut_params->op->sym->m_src = ut_params->ibuf;
6329 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6330 RTE_CRYPTO_OP_SESSIONLESS,
6331 "crypto op session type not sessionless");
6333 /* Process crypto operation */
6334 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6335 ut_params->op), "failed to process sym crypto op");
6337 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6339 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6340 "crypto op status not success");
6342 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6343 ut_params->op->sym->cipher.data.offset);
6345 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6348 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6350 tdata->plaintext.data,
6351 tdata->plaintext.len,
6352 "Plaintext data not as expected");
6354 TEST_ASSERT_EQUAL(ut_params->op->status,
6355 RTE_CRYPTO_OP_STATUS_SUCCESS,
6356 "Authentication failed");
6361 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6363 return test_authenticated_decryption_sessionless(
6368 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6370 return test_authenticated_encryption(&ccm_test_case_128_1);
6374 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6376 return test_authenticated_encryption(&ccm_test_case_128_2);
6380 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6382 return test_authenticated_encryption(&ccm_test_case_128_3);
6386 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6388 return test_authenticated_decryption(&ccm_test_case_128_1);
6392 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6394 return test_authenticated_decryption(&ccm_test_case_128_2);
6398 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6400 return test_authenticated_decryption(&ccm_test_case_128_3);
6404 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6406 return test_authenticated_encryption(&ccm_test_case_192_1);
6410 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6412 return test_authenticated_encryption(&ccm_test_case_192_2);
6416 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6418 return test_authenticated_encryption(&ccm_test_case_192_3);
6422 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6424 return test_authenticated_decryption(&ccm_test_case_192_1);
6428 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6430 return test_authenticated_decryption(&ccm_test_case_192_2);
6434 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6436 return test_authenticated_decryption(&ccm_test_case_192_3);
6440 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6442 return test_authenticated_encryption(&ccm_test_case_256_1);
6446 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6448 return test_authenticated_encryption(&ccm_test_case_256_2);
6452 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6454 return test_authenticated_encryption(&ccm_test_case_256_3);
6458 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6460 return test_authenticated_decryption(&ccm_test_case_256_1);
6464 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6466 return test_authenticated_decryption(&ccm_test_case_256_2);
6470 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6472 return test_authenticated_decryption(&ccm_test_case_256_3);
6478 struct crypto_testsuite_params *ts_params = &testsuite_params;
6479 struct rte_cryptodev_stats stats;
6480 struct rte_cryptodev *dev;
6481 cryptodev_stats_get_t temp_pfn;
6483 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6484 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6485 &stats) == -ENODEV),
6486 "rte_cryptodev_stats_get invalid dev failed");
6487 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6488 "rte_cryptodev_stats_get invalid Param failed");
6489 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6490 temp_pfn = dev->dev_ops->stats_get;
6491 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6492 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6494 "rte_cryptodev_stats_get invalid Param failed");
6495 dev->dev_ops->stats_get = temp_pfn;
6497 /* Test expected values */
6499 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6501 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6503 "rte_cryptodev_stats_get failed");
6504 TEST_ASSERT((stats.enqueued_count == 1),
6505 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6506 TEST_ASSERT((stats.dequeued_count == 1),
6507 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6508 TEST_ASSERT((stats.enqueue_err_count == 0),
6509 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6510 TEST_ASSERT((stats.dequeue_err_count == 0),
6511 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6513 /* invalid device but should ignore and not reset device stats*/
6514 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6515 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6517 "rte_cryptodev_stats_get failed");
6518 TEST_ASSERT((stats.enqueued_count == 1),
6519 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6521 /* check that a valid reset clears stats */
6522 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6523 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6525 "rte_cryptodev_stats_get failed");
6526 TEST_ASSERT((stats.enqueued_count == 0),
6527 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6528 TEST_ASSERT((stats.dequeued_count == 0),
6529 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6531 return TEST_SUCCESS;
6534 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6535 struct crypto_unittest_params *ut_params,
6536 enum rte_crypto_auth_operation op,
6537 const struct HMAC_MD5_vector *test_case)
6541 memcpy(key, test_case->key.data, test_case->key.len);
6543 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6544 ut_params->auth_xform.next = NULL;
6545 ut_params->auth_xform.auth.op = op;
6547 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6549 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6550 ut_params->auth_xform.auth.key.length = test_case->key.len;
6551 ut_params->auth_xform.auth.key.data = key;
6553 ut_params->sess = rte_cryptodev_sym_session_create(
6554 ts_params->session_mpool);
6556 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6557 ut_params->sess, &ut_params->auth_xform,
6558 ts_params->session_mpool);
6560 if (ut_params->sess == NULL)
6563 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6565 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6566 rte_pktmbuf_tailroom(ut_params->ibuf));
6571 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6572 const struct HMAC_MD5_vector *test_case,
6573 uint8_t **plaintext)
6575 uint16_t plaintext_pad_len;
6577 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6579 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6582 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6584 memcpy(*plaintext, test_case->plaintext.data,
6585 test_case->plaintext.len);
6587 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6588 ut_params->ibuf, MD5_DIGEST_LEN);
6589 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6590 "no room to append digest");
6591 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6592 ut_params->ibuf, plaintext_pad_len);
6594 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6595 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6596 test_case->auth_tag.len);
6599 sym_op->auth.data.offset = 0;
6600 sym_op->auth.data.length = test_case->plaintext.len;
6602 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6603 ut_params->op->sym->m_src = ut_params->ibuf;
6609 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6611 uint16_t plaintext_pad_len;
6612 uint8_t *plaintext, *auth_tag;
6614 struct crypto_testsuite_params *ts_params = &testsuite_params;
6615 struct crypto_unittest_params *ut_params = &unittest_params;
6617 if (MD5_HMAC_create_session(ts_params, ut_params,
6618 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6621 /* Generate Crypto op data structure */
6622 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6623 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6624 TEST_ASSERT_NOT_NULL(ut_params->op,
6625 "Failed to allocate symmetric crypto operation struct");
6627 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6630 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6633 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6634 ut_params->op), "failed to process sym crypto op");
6636 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6637 "crypto op processing failed");
6639 if (ut_params->op->sym->m_dst) {
6640 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6641 uint8_t *, plaintext_pad_len);
6643 auth_tag = plaintext + plaintext_pad_len;
6646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6648 test_case->auth_tag.data,
6649 test_case->auth_tag.len,
6650 "HMAC_MD5 generated tag not as expected");
6652 return TEST_SUCCESS;
6656 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6660 struct crypto_testsuite_params *ts_params = &testsuite_params;
6661 struct crypto_unittest_params *ut_params = &unittest_params;
6663 if (MD5_HMAC_create_session(ts_params, ut_params,
6664 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6668 /* Generate Crypto op data structure */
6669 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6670 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6671 TEST_ASSERT_NOT_NULL(ut_params->op,
6672 "Failed to allocate symmetric crypto operation struct");
6674 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6677 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6678 ut_params->op), "failed to process sym crypto op");
6680 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6681 "HMAC_MD5 crypto op processing failed");
6683 return TEST_SUCCESS;
6687 test_MD5_HMAC_generate_case_1(void)
6689 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6693 test_MD5_HMAC_verify_case_1(void)
6695 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6699 test_MD5_HMAC_generate_case_2(void)
6701 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6705 test_MD5_HMAC_verify_case_2(void)
6707 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6711 test_multi_session(void)
6713 struct crypto_testsuite_params *ts_params = &testsuite_params;
6714 struct crypto_unittest_params *ut_params = &unittest_params;
6716 struct rte_cryptodev_info dev_info;
6717 struct rte_cryptodev_sym_session **sessions;
6721 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6722 aes_cbc_key, hmac_sha512_key);
6725 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6727 sessions = rte_malloc(NULL,
6728 (sizeof(struct rte_cryptodev_sym_session *) *
6729 MAX_NB_SESSIONS) + 1, 0);
6731 /* Create multiple crypto sessions*/
6732 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6734 sessions[i] = rte_cryptodev_sym_session_create(
6735 ts_params->session_mpool);
6737 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6738 sessions[i], &ut_params->auth_xform,
6739 ts_params->session_mpool);
6740 TEST_ASSERT_NOT_NULL(sessions[i],
6741 "Session creation failed at session number %u",
6744 /* Attempt to send a request on each session */
6745 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6749 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6750 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6752 "Failed to perform decrypt on request number %u.", i);
6753 /* free crypto operation structure */
6755 rte_crypto_op_free(ut_params->op);
6758 * free mbuf - both obuf and ibuf are usually the same,
6759 * so check if they point at the same address is necessary,
6760 * to avoid freeing the mbuf twice.
6762 if (ut_params->obuf) {
6763 rte_pktmbuf_free(ut_params->obuf);
6764 if (ut_params->ibuf == ut_params->obuf)
6765 ut_params->ibuf = 0;
6766 ut_params->obuf = 0;
6768 if (ut_params->ibuf) {
6769 rte_pktmbuf_free(ut_params->ibuf);
6770 ut_params->ibuf = 0;
6774 /* Next session create should fail */
6775 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6776 sessions[i], &ut_params->auth_xform,
6777 ts_params->session_mpool);
6778 TEST_ASSERT_NULL(sessions[i],
6779 "Session creation succeeded unexpectedly!");
6781 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6782 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6784 rte_cryptodev_sym_session_free(sessions[i]);
6789 return TEST_SUCCESS;
6792 struct multi_session_params {
6793 struct crypto_unittest_params ut_params;
6794 uint8_t *cipher_key;
6796 const uint8_t *cipher;
6797 const uint8_t *digest;
6801 #define MB_SESSION_NUMBER 3
6804 test_multi_session_random_usage(void)
6806 struct crypto_testsuite_params *ts_params = &testsuite_params;
6807 struct rte_cryptodev_info dev_info;
6808 struct rte_cryptodev_sym_session **sessions;
6810 struct multi_session_params ut_paramz[] = {
6813 .cipher_key = ms_aes_cbc_key0,
6814 .hmac_key = ms_hmac_key0,
6815 .cipher = ms_aes_cbc_cipher0,
6816 .digest = ms_hmac_digest0,
6817 .iv = ms_aes_cbc_iv0
6820 .cipher_key = ms_aes_cbc_key1,
6821 .hmac_key = ms_hmac_key1,
6822 .cipher = ms_aes_cbc_cipher1,
6823 .digest = ms_hmac_digest1,
6824 .iv = ms_aes_cbc_iv1
6827 .cipher_key = ms_aes_cbc_key2,
6828 .hmac_key = ms_hmac_key2,
6829 .cipher = ms_aes_cbc_cipher2,
6830 .digest = ms_hmac_digest2,
6831 .iv = ms_aes_cbc_iv2
6836 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6838 sessions = rte_malloc(NULL,
6839 (sizeof(struct rte_cryptodev_sym_session *)
6840 * MAX_NB_SESSIONS) + 1, 0);
6842 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6843 sessions[i] = rte_cryptodev_sym_session_create(
6844 ts_params->session_mpool);
6846 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6847 sizeof(struct crypto_unittest_params));
6849 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6850 &ut_paramz[i].ut_params,
6851 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6853 /* Create multiple crypto sessions*/
6854 rte_cryptodev_sym_session_init(
6855 ts_params->valid_devs[0],
6857 &ut_paramz[i].ut_params.auth_xform,
6858 ts_params->session_mpool);
6860 TEST_ASSERT_NOT_NULL(sessions[i],
6861 "Session creation failed at session number %u",
6867 for (i = 0; i < 40000; i++) {
6869 j = rand() % MB_SESSION_NUMBER;
6871 TEST_ASSERT_SUCCESS(
6872 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6874 &ut_paramz[j].ut_params,
6875 ts_params, ut_paramz[j].cipher,
6876 ut_paramz[j].digest,
6878 "Failed to perform decrypt on request number %u.", i);
6880 if (ut_paramz[j].ut_params.op)
6881 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6884 * free mbuf - both obuf and ibuf are usually the same,
6885 * so check if they point at the same address is necessary,
6886 * to avoid freeing the mbuf twice.
6888 if (ut_paramz[j].ut_params.obuf) {
6889 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6890 if (ut_paramz[j].ut_params.ibuf
6891 == ut_paramz[j].ut_params.obuf)
6892 ut_paramz[j].ut_params.ibuf = 0;
6893 ut_paramz[j].ut_params.obuf = 0;
6895 if (ut_paramz[j].ut_params.ibuf) {
6896 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6897 ut_paramz[j].ut_params.ibuf = 0;
6901 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6902 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6904 rte_cryptodev_sym_session_free(sessions[i]);
6909 return TEST_SUCCESS;
6913 test_null_cipher_only_operation(void)
6915 struct crypto_testsuite_params *ts_params = &testsuite_params;
6916 struct crypto_unittest_params *ut_params = &unittest_params;
6918 /* Generate test mbuf data and space for digest */
6919 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6920 catch_22_quote, QUOTE_512_BYTES, 0);
6922 /* Setup Cipher Parameters */
6923 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6924 ut_params->cipher_xform.next = NULL;
6926 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6927 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6929 ut_params->sess = rte_cryptodev_sym_session_create(
6930 ts_params->session_mpool);
6932 /* Create Crypto session*/
6933 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6935 &ut_params->cipher_xform,
6936 ts_params->session_mpool);
6937 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6939 /* Generate Crypto op data structure */
6940 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6941 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6942 TEST_ASSERT_NOT_NULL(ut_params->op,
6943 "Failed to allocate symmetric crypto operation struct");
6945 /* Set crypto operation data parameters */
6946 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6948 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6950 /* set crypto operation source mbuf */
6951 sym_op->m_src = ut_params->ibuf;
6953 sym_op->cipher.data.offset = 0;
6954 sym_op->cipher.data.length = QUOTE_512_BYTES;
6956 /* Process crypto operation */
6957 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6959 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6961 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6962 "crypto operation processing failed");
6965 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6966 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6969 "Ciphertext data not as expected");
6971 return TEST_SUCCESS;
6973 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6974 0xab, 0xab, 0xab, 0xab,
6975 0xab, 0xab, 0xab, 0xab,
6976 0xab, 0xab, 0xab, 0xab};
6978 test_null_auth_only_operation(void)
6980 struct crypto_testsuite_params *ts_params = &testsuite_params;
6981 struct crypto_unittest_params *ut_params = &unittest_params;
6984 /* Generate test mbuf data and space for digest */
6985 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6986 catch_22_quote, QUOTE_512_BYTES, 0);
6988 /* create a pointer for digest, but don't expect anything to be written
6989 * here in a NULL auth algo so no mbuf append done.
6991 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6993 /* prefill the memory pointed to by digest */
6994 memcpy(digest, orig_data, sizeof(orig_data));
6996 /* Setup HMAC Parameters */
6997 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6998 ut_params->auth_xform.next = NULL;
7000 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7001 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7003 ut_params->sess = rte_cryptodev_sym_session_create(
7004 ts_params->session_mpool);
7006 /* Create Crypto session*/
7007 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7008 ut_params->sess, &ut_params->auth_xform,
7009 ts_params->session_mpool);
7010 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7012 /* Generate Crypto op data structure */
7013 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7014 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7015 TEST_ASSERT_NOT_NULL(ut_params->op,
7016 "Failed to allocate symmetric crypto operation struct");
7018 /* Set crypto operation data parameters */
7019 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7021 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7023 sym_op->m_src = ut_params->ibuf;
7025 sym_op->auth.data.offset = 0;
7026 sym_op->auth.data.length = QUOTE_512_BYTES;
7027 sym_op->auth.digest.data = digest;
7028 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7031 /* Process crypto operation */
7032 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7034 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7036 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7037 "crypto operation processing failed");
7038 /* Make sure memory pointed to by digest hasn't been overwritten */
7039 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7043 "Memory at digest ptr overwritten unexpectedly");
7045 return TEST_SUCCESS;
7050 test_null_cipher_auth_operation(void)
7052 struct crypto_testsuite_params *ts_params = &testsuite_params;
7053 struct crypto_unittest_params *ut_params = &unittest_params;
7056 /* Generate test mbuf data and space for digest */
7057 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7058 catch_22_quote, QUOTE_512_BYTES, 0);
7060 /* create a pointer for digest, but don't expect anything to be written
7061 * here in a NULL auth algo so no mbuf append done.
7063 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7065 /* prefill the memory pointed to by digest */
7066 memcpy(digest, orig_data, sizeof(orig_data));
7068 /* Setup Cipher Parameters */
7069 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7070 ut_params->cipher_xform.next = &ut_params->auth_xform;
7072 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7073 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7075 /* Setup HMAC Parameters */
7076 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7077 ut_params->auth_xform.next = NULL;
7079 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7080 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7082 ut_params->sess = rte_cryptodev_sym_session_create(
7083 ts_params->session_mpool);
7085 /* Create Crypto session*/
7086 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7087 ut_params->sess, &ut_params->cipher_xform,
7088 ts_params->session_mpool);
7089 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7091 /* Generate Crypto op data structure */
7092 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7093 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7094 TEST_ASSERT_NOT_NULL(ut_params->op,
7095 "Failed to allocate symmetric crypto operation struct");
7097 /* Set crypto operation data parameters */
7098 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7100 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7102 sym_op->m_src = ut_params->ibuf;
7104 sym_op->cipher.data.offset = 0;
7105 sym_op->cipher.data.length = QUOTE_512_BYTES;
7107 sym_op->auth.data.offset = 0;
7108 sym_op->auth.data.length = QUOTE_512_BYTES;
7109 sym_op->auth.digest.data = digest;
7110 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7113 /* Process crypto operation */
7114 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7116 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7118 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7119 "crypto operation processing failed");
7122 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7123 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7126 "Ciphertext data not as expected");
7127 /* Make sure memory pointed to by digest hasn't been overwritten */
7128 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7132 "Memory at digest ptr overwritten unexpectedly");
7134 return TEST_SUCCESS;
7138 test_null_auth_cipher_operation(void)
7140 struct crypto_testsuite_params *ts_params = &testsuite_params;
7141 struct crypto_unittest_params *ut_params = &unittest_params;
7144 /* Generate test mbuf data */
7145 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
7146 catch_22_quote, QUOTE_512_BYTES, 0);
7148 /* create a pointer for digest, but don't expect anything to be written
7149 * here in a NULL auth algo so no mbuf append done.
7151 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
7153 /* prefill the memory pointed to by digest */
7154 memcpy(digest, orig_data, sizeof(orig_data));
7156 /* Setup Cipher Parameters */
7157 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7158 ut_params->cipher_xform.next = NULL;
7160 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7161 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7163 /* Setup HMAC Parameters */
7164 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7165 ut_params->auth_xform.next = &ut_params->cipher_xform;
7167 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7168 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7170 ut_params->sess = rte_cryptodev_sym_session_create(
7171 ts_params->session_mpool);
7173 /* Create Crypto session*/
7174 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7175 ut_params->sess, &ut_params->cipher_xform,
7176 ts_params->session_mpool);
7177 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7179 /* Generate Crypto op data structure */
7180 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7181 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7182 TEST_ASSERT_NOT_NULL(ut_params->op,
7183 "Failed to allocate symmetric crypto operation struct");
7185 /* Set crypto operation data parameters */
7186 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7188 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7190 sym_op->m_src = ut_params->ibuf;
7192 sym_op->cipher.data.offset = 0;
7193 sym_op->cipher.data.length = QUOTE_512_BYTES;
7195 sym_op->auth.data.offset = 0;
7196 sym_op->auth.data.length = QUOTE_512_BYTES;
7197 sym_op->auth.digest.data = digest;
7198 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
7201 /* Process crypto operation */
7202 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7204 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
7206 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7207 "crypto operation processing failed");
7210 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7211 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
7214 "Ciphertext data not as expected");
7215 /* Make sure memory pointed to by digest hasn't been overwritten */
7216 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7220 "Memory at digest ptr overwritten unexpectedly");
7222 return TEST_SUCCESS;
7227 test_null_invalid_operation(void)
7229 struct crypto_testsuite_params *ts_params = &testsuite_params;
7230 struct crypto_unittest_params *ut_params = &unittest_params;
7233 /* Setup Cipher Parameters */
7234 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7235 ut_params->cipher_xform.next = NULL;
7237 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7238 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7240 ut_params->sess = rte_cryptodev_sym_session_create(
7241 ts_params->session_mpool);
7243 /* Create Crypto session*/
7244 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7245 ut_params->sess, &ut_params->cipher_xform,
7246 ts_params->session_mpool);
7247 TEST_ASSERT(ret < 0,
7248 "Session creation succeeded unexpectedly");
7251 /* Setup HMAC Parameters */
7252 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7253 ut_params->auth_xform.next = NULL;
7255 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7256 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7258 ut_params->sess = rte_cryptodev_sym_session_create(
7259 ts_params->session_mpool);
7261 /* Create Crypto session*/
7262 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7263 ut_params->sess, &ut_params->auth_xform,
7264 ts_params->session_mpool);
7265 TEST_ASSERT(ret < 0,
7266 "Session creation succeeded unexpectedly");
7268 return TEST_SUCCESS;
7272 #define NULL_BURST_LENGTH (32)
7275 test_null_burst_operation(void)
7277 struct crypto_testsuite_params *ts_params = &testsuite_params;
7278 struct crypto_unittest_params *ut_params = &unittest_params;
7280 unsigned i, burst_len = NULL_BURST_LENGTH;
7282 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7283 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7285 /* Setup Cipher Parameters */
7286 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7287 ut_params->cipher_xform.next = &ut_params->auth_xform;
7289 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7290 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7292 /* Setup HMAC Parameters */
7293 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7294 ut_params->auth_xform.next = NULL;
7296 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7297 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7299 ut_params->sess = rte_cryptodev_sym_session_create(
7300 ts_params->session_mpool);
7302 /* Create Crypto session*/
7303 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7304 ut_params->sess, &ut_params->cipher_xform,
7305 ts_params->session_mpool);
7306 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7308 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7309 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7310 burst_len, "failed to generate burst of crypto ops");
7312 /* Generate an operation for each mbuf in burst */
7313 for (i = 0; i < burst_len; i++) {
7314 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7316 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7318 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7322 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7324 burst[i]->sym->m_src = m;
7327 /* Process crypto operation */
7328 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7329 0, burst, burst_len),
7331 "Error enqueuing burst");
7333 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7334 0, burst_dequeued, burst_len),
7336 "Error dequeuing burst");
7339 for (i = 0; i < burst_len; i++) {
7341 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7342 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7344 "data not as expected");
7346 rte_pktmbuf_free(burst[i]->sym->m_src);
7347 rte_crypto_op_free(burst[i]);
7350 return TEST_SUCCESS;
7354 generate_gmac_large_plaintext(uint8_t *data)
7358 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7359 memcpy(&data[i], &data[0], 32);
7363 create_gmac_operation(enum rte_crypto_auth_operation op,
7364 const struct gmac_test_data *tdata)
7366 struct crypto_testsuite_params *ts_params = &testsuite_params;
7367 struct crypto_unittest_params *ut_params = &unittest_params;
7368 struct rte_crypto_sym_op *sym_op;
7370 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7372 /* Generate Crypto op data structure */
7373 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7374 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7375 TEST_ASSERT_NOT_NULL(ut_params->op,
7376 "Failed to allocate symmetric crypto operation struct");
7378 sym_op = ut_params->op->sym;
7380 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7381 ut_params->ibuf, tdata->gmac_tag.len);
7382 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7383 "no room to append digest");
7385 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7386 ut_params->ibuf, plaintext_pad_len);
7388 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7389 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7390 tdata->gmac_tag.len);
7391 debug_hexdump(stdout, "digest:",
7392 sym_op->auth.digest.data,
7393 tdata->gmac_tag.len);
7396 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7397 uint8_t *, IV_OFFSET);
7399 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7401 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7403 sym_op->cipher.data.length = 0;
7404 sym_op->cipher.data.offset = 0;
7406 sym_op->auth.data.offset = 0;
7407 sym_op->auth.data.length = tdata->plaintext.len;
7412 static int create_gmac_session(uint8_t dev_id,
7413 const struct gmac_test_data *tdata,
7414 enum rte_crypto_auth_operation auth_op)
7416 uint8_t auth_key[tdata->key.len];
7418 struct crypto_testsuite_params *ts_params = &testsuite_params;
7419 struct crypto_unittest_params *ut_params = &unittest_params;
7421 memcpy(auth_key, tdata->key.data, tdata->key.len);
7423 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7424 ut_params->auth_xform.next = NULL;
7426 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7427 ut_params->auth_xform.auth.op = auth_op;
7428 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7429 ut_params->auth_xform.auth.key.length = tdata->key.len;
7430 ut_params->auth_xform.auth.key.data = auth_key;
7431 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7432 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7435 ut_params->sess = rte_cryptodev_sym_session_create(
7436 ts_params->session_mpool);
7438 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7439 &ut_params->auth_xform,
7440 ts_params->session_mpool);
7442 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7448 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7450 struct crypto_testsuite_params *ts_params = &testsuite_params;
7451 struct crypto_unittest_params *ut_params = &unittest_params;
7455 uint8_t *auth_tag, *plaintext;
7456 uint16_t plaintext_pad_len;
7458 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7459 "No GMAC length in the source data");
7461 retval = create_gmac_session(ts_params->valid_devs[0],
7462 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7467 if (tdata->plaintext.len > MBUF_SIZE)
7468 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7470 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7471 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7472 "Failed to allocate input buffer in mempool");
7474 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7475 rte_pktmbuf_tailroom(ut_params->ibuf));
7477 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7479 * Runtime generate the large plain text instead of use hard code
7480 * plain text vector. It is done to avoid create huge source file
7481 * with the test vector.
7483 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7484 generate_gmac_large_plaintext(tdata->plaintext.data);
7486 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7488 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7490 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7491 debug_hexdump(stdout, "plaintext:", plaintext,
7492 tdata->plaintext.len);
7494 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7500 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7502 ut_params->op->sym->m_src = ut_params->ibuf;
7504 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7505 ut_params->op), "failed to process sym crypto op");
7507 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7508 "crypto op processing failed");
7510 if (ut_params->op->sym->m_dst) {
7511 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7512 uint8_t *, plaintext_pad_len);
7514 auth_tag = plaintext + plaintext_pad_len;
7517 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7519 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7521 tdata->gmac_tag.data,
7522 tdata->gmac_tag.len,
7523 "GMAC Generated auth tag not as expected");
7529 test_AES_GMAC_authentication_test_case_1(void)
7531 return test_AES_GMAC_authentication(&gmac_test_case_1);
7535 test_AES_GMAC_authentication_test_case_2(void)
7537 return test_AES_GMAC_authentication(&gmac_test_case_2);
7541 test_AES_GMAC_authentication_test_case_3(void)
7543 return test_AES_GMAC_authentication(&gmac_test_case_3);
7547 test_AES_GMAC_authentication_test_case_4(void)
7549 return test_AES_GMAC_authentication(&gmac_test_case_4);
7553 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7555 struct crypto_testsuite_params *ts_params = &testsuite_params;
7556 struct crypto_unittest_params *ut_params = &unittest_params;
7558 uint32_t plaintext_pad_len;
7561 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7562 "No GMAC length in the source data");
7564 retval = create_gmac_session(ts_params->valid_devs[0],
7565 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7570 if (tdata->plaintext.len > MBUF_SIZE)
7571 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7573 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7574 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7575 "Failed to allocate input buffer in mempool");
7577 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7578 rte_pktmbuf_tailroom(ut_params->ibuf));
7580 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7583 * Runtime generate the large plain text instead of use hard code
7584 * plain text vector. It is done to avoid create huge source file
7585 * with the test vector.
7587 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7588 generate_gmac_large_plaintext(tdata->plaintext.data);
7590 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7592 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7594 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7595 debug_hexdump(stdout, "plaintext:", plaintext,
7596 tdata->plaintext.len);
7598 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7604 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7606 ut_params->op->sym->m_src = ut_params->ibuf;
7608 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7609 ut_params->op), "failed to process sym crypto op");
7611 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7612 "crypto op processing failed");
7619 test_AES_GMAC_authentication_verify_test_case_1(void)
7621 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7625 test_AES_GMAC_authentication_verify_test_case_2(void)
7627 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7631 test_AES_GMAC_authentication_verify_test_case_3(void)
7633 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7637 test_AES_GMAC_authentication_verify_test_case_4(void)
7639 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7642 struct test_crypto_vector {
7643 enum rte_crypto_cipher_algorithm crypto_algo;
7656 const uint8_t *data;
7661 const uint8_t *data;
7665 enum rte_crypto_auth_algorithm auth_algo;
7673 const uint8_t *data;
7683 static const struct test_crypto_vector
7684 hmac_sha1_test_crypto_vector = {
7685 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7687 .data = plaintext_hash,
7692 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7693 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7694 0xDE, 0xF4, 0xDE, 0xAD
7700 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7701 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7702 0x3F, 0x91, 0x64, 0x59
7708 static const struct test_crypto_vector
7709 aes128_gmac_test_vector = {
7710 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7712 .data = plaintext_hash,
7717 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7718 0x08, 0x09, 0x0A, 0x0B
7724 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7725 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7731 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7732 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7738 static const struct test_crypto_vector
7739 aes128cbc_hmac_sha1_test_vector = {
7740 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7743 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7744 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7750 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7751 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7756 .data = plaintext_hash,
7760 .data = ciphertext512_aes128cbc,
7763 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7766 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7767 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7768 0xDE, 0xF4, 0xDE, 0xAD
7774 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7775 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7776 0x18, 0x8C, 0x1D, 0x32
7783 data_corruption(uint8_t *data)
7789 tag_corruption(uint8_t *data, unsigned int tag_offset)
7791 data[tag_offset] += 1;
7795 create_auth_session(struct crypto_unittest_params *ut_params,
7797 const struct test_crypto_vector *reference,
7798 enum rte_crypto_auth_operation auth_op)
7800 struct crypto_testsuite_params *ts_params = &testsuite_params;
7801 uint8_t auth_key[reference->auth_key.len + 1];
7803 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7805 /* Setup Authentication Parameters */
7806 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7807 ut_params->auth_xform.auth.op = auth_op;
7808 ut_params->auth_xform.next = NULL;
7809 ut_params->auth_xform.auth.algo = reference->auth_algo;
7810 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7811 ut_params->auth_xform.auth.key.data = auth_key;
7812 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7814 /* Create Crypto session*/
7815 ut_params->sess = rte_cryptodev_sym_session_create(
7816 ts_params->session_mpool);
7818 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7819 &ut_params->auth_xform,
7820 ts_params->session_mpool);
7822 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7828 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7830 const struct test_crypto_vector *reference,
7831 enum rte_crypto_auth_operation auth_op,
7832 enum rte_crypto_cipher_operation cipher_op)
7834 struct crypto_testsuite_params *ts_params = &testsuite_params;
7835 uint8_t cipher_key[reference->cipher_key.len + 1];
7836 uint8_t auth_key[reference->auth_key.len + 1];
7838 memcpy(cipher_key, reference->cipher_key.data,
7839 reference->cipher_key.len);
7840 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7842 /* Setup Authentication Parameters */
7843 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7844 ut_params->auth_xform.auth.op = auth_op;
7845 ut_params->auth_xform.auth.algo = reference->auth_algo;
7846 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7847 ut_params->auth_xform.auth.key.data = auth_key;
7848 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7850 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7851 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7852 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7854 ut_params->auth_xform.next = &ut_params->cipher_xform;
7856 /* Setup Cipher Parameters */
7857 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7858 ut_params->cipher_xform.next = NULL;
7859 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7860 ut_params->cipher_xform.cipher.op = cipher_op;
7861 ut_params->cipher_xform.cipher.key.data = cipher_key;
7862 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7863 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7864 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7867 /* Create Crypto session*/
7868 ut_params->sess = rte_cryptodev_sym_session_create(
7869 ts_params->session_mpool);
7871 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7872 &ut_params->auth_xform,
7873 ts_params->session_mpool);
7875 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7881 create_auth_operation(struct crypto_testsuite_params *ts_params,
7882 struct crypto_unittest_params *ut_params,
7883 const struct test_crypto_vector *reference,
7884 unsigned int auth_generate)
7886 /* Generate Crypto op data structure */
7887 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7888 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7889 TEST_ASSERT_NOT_NULL(ut_params->op,
7890 "Failed to allocate pktmbuf offload");
7892 /* Set crypto operation data parameters */
7893 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7895 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7897 /* set crypto operation source mbuf */
7898 sym_op->m_src = ut_params->ibuf;
7901 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7902 ut_params->ibuf, reference->digest.len);
7904 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7905 "no room to append auth tag");
7907 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7908 ut_params->ibuf, reference->plaintext.len);
7911 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7913 memcpy(sym_op->auth.digest.data,
7914 reference->digest.data,
7915 reference->digest.len);
7917 debug_hexdump(stdout, "digest:",
7918 sym_op->auth.digest.data,
7919 reference->digest.len);
7921 sym_op->auth.data.length = reference->plaintext.len;
7922 sym_op->auth.data.offset = 0;
7928 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7929 struct crypto_unittest_params *ut_params,
7930 const struct test_crypto_vector *reference,
7931 unsigned int auth_generate)
7933 /* Generate Crypto op data structure */
7934 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7935 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7936 TEST_ASSERT_NOT_NULL(ut_params->op,
7937 "Failed to allocate pktmbuf offload");
7939 /* Set crypto operation data parameters */
7940 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7942 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7944 /* set crypto operation source mbuf */
7945 sym_op->m_src = ut_params->ibuf;
7948 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7949 ut_params->ibuf, reference->digest.len);
7951 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7952 "no room to append auth tag");
7954 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7955 ut_params->ibuf, reference->ciphertext.len);
7958 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7960 memcpy(sym_op->auth.digest.data,
7961 reference->digest.data,
7962 reference->digest.len);
7964 debug_hexdump(stdout, "digest:",
7965 sym_op->auth.digest.data,
7966 reference->digest.len);
7968 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7969 reference->iv.data, reference->iv.len);
7971 sym_op->cipher.data.length = 0;
7972 sym_op->cipher.data.offset = 0;
7974 sym_op->auth.data.length = reference->plaintext.len;
7975 sym_op->auth.data.offset = 0;
7981 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7982 struct crypto_unittest_params *ut_params,
7983 const struct test_crypto_vector *reference,
7984 unsigned int auth_generate)
7986 /* Generate Crypto op data structure */
7987 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7988 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7989 TEST_ASSERT_NOT_NULL(ut_params->op,
7990 "Failed to allocate pktmbuf offload");
7992 /* Set crypto operation data parameters */
7993 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7995 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7997 /* set crypto operation source mbuf */
7998 sym_op->m_src = ut_params->ibuf;
8001 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
8002 ut_params->ibuf, reference->digest.len);
8004 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
8005 "no room to append auth tag");
8007 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
8008 ut_params->ibuf, reference->ciphertext.len);
8011 memset(sym_op->auth.digest.data, 0, reference->digest.len);
8013 memcpy(sym_op->auth.digest.data,
8014 reference->digest.data,
8015 reference->digest.len);
8017 debug_hexdump(stdout, "digest:",
8018 sym_op->auth.digest.data,
8019 reference->digest.len);
8021 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
8022 reference->iv.data, reference->iv.len);
8024 sym_op->cipher.data.length = reference->ciphertext.len;
8025 sym_op->cipher.data.offset = 0;
8027 sym_op->auth.data.length = reference->ciphertext.len;
8028 sym_op->auth.data.offset = 0;
8034 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8035 struct crypto_unittest_params *ut_params,
8036 const struct test_crypto_vector *reference)
8038 return create_auth_operation(ts_params, ut_params, reference, 0);
8042 create_auth_verify_GMAC_operation(
8043 struct crypto_testsuite_params *ts_params,
8044 struct crypto_unittest_params *ut_params,
8045 const struct test_crypto_vector *reference)
8047 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
8051 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
8052 struct crypto_unittest_params *ut_params,
8053 const struct test_crypto_vector *reference)
8055 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
8059 test_authentication_verify_fail_when_data_corruption(
8060 struct crypto_testsuite_params *ts_params,
8061 struct crypto_unittest_params *ut_params,
8062 const struct test_crypto_vector *reference,
8063 unsigned int data_corrupted)
8069 /* Create session */
8070 retval = create_auth_session(ut_params,
8071 ts_params->valid_devs[0],
8073 RTE_CRYPTO_AUTH_OP_VERIFY);
8077 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8078 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8079 "Failed to allocate input buffer in mempool");
8081 /* clear mbuf payload */
8082 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8083 rte_pktmbuf_tailroom(ut_params->ibuf));
8085 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8086 reference->plaintext.len);
8087 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8088 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8090 debug_hexdump(stdout, "plaintext:", plaintext,
8091 reference->plaintext.len);
8093 /* Create operation */
8094 retval = create_auth_verify_operation(ts_params, ut_params, reference);
8100 data_corruption(plaintext);
8102 tag_corruption(plaintext, reference->plaintext.len);
8104 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8106 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8107 TEST_ASSERT_EQUAL(ut_params->op->status,
8108 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8109 "authentication not failed");
8111 ut_params->obuf = ut_params->op->sym->m_src;
8112 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8118 test_authentication_verify_GMAC_fail_when_corruption(
8119 struct crypto_testsuite_params *ts_params,
8120 struct crypto_unittest_params *ut_params,
8121 const struct test_crypto_vector *reference,
8122 unsigned int data_corrupted)
8127 /* Create session */
8128 retval = create_auth_cipher_session(ut_params,
8129 ts_params->valid_devs[0],
8131 RTE_CRYPTO_AUTH_OP_VERIFY,
8132 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8136 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8137 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8138 "Failed to allocate input buffer in mempool");
8140 /* clear mbuf payload */
8141 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8142 rte_pktmbuf_tailroom(ut_params->ibuf));
8144 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8145 reference->plaintext.len);
8146 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
8147 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
8149 debug_hexdump(stdout, "plaintext:", plaintext,
8150 reference->plaintext.len);
8152 /* Create operation */
8153 retval = create_auth_verify_GMAC_operation(ts_params,
8161 data_corruption(plaintext);
8163 tag_corruption(plaintext, reference->aad.len);
8165 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8167 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8168 TEST_ASSERT_EQUAL(ut_params->op->status,
8169 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8170 "authentication not failed");
8172 ut_params->obuf = ut_params->op->sym->m_src;
8173 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8179 test_authenticated_decryption_fail_when_corruption(
8180 struct crypto_testsuite_params *ts_params,
8181 struct crypto_unittest_params *ut_params,
8182 const struct test_crypto_vector *reference,
8183 unsigned int data_corrupted)
8187 uint8_t *ciphertext;
8189 /* Create session */
8190 retval = create_auth_cipher_session(ut_params,
8191 ts_params->valid_devs[0],
8193 RTE_CRYPTO_AUTH_OP_VERIFY,
8194 RTE_CRYPTO_CIPHER_OP_DECRYPT);
8198 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8199 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
8200 "Failed to allocate input buffer in mempool");
8202 /* clear mbuf payload */
8203 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8204 rte_pktmbuf_tailroom(ut_params->ibuf));
8206 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8207 reference->ciphertext.len);
8208 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
8209 memcpy(ciphertext, reference->ciphertext.data,
8210 reference->ciphertext.len);
8212 /* Create operation */
8213 retval = create_cipher_auth_verify_operation(ts_params,
8221 data_corruption(ciphertext);
8223 tag_corruption(ciphertext, reference->ciphertext.len);
8225 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8228 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8229 TEST_ASSERT_EQUAL(ut_params->op->status,
8230 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8231 "authentication not failed");
8233 ut_params->obuf = ut_params->op->sym->m_src;
8234 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8240 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8241 const struct aead_test_data *tdata,
8242 void *digest_mem, uint64_t digest_phys)
8244 struct crypto_testsuite_params *ts_params = &testsuite_params;
8245 struct crypto_unittest_params *ut_params = &unittest_params;
8247 const unsigned int auth_tag_len = tdata->auth_tag.len;
8248 const unsigned int iv_len = tdata->iv.len;
8249 unsigned int aad_len = tdata->aad.len;
8251 /* Generate Crypto op data structure */
8252 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8253 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8254 TEST_ASSERT_NOT_NULL(ut_params->op,
8255 "Failed to allocate symmetric crypto operation struct");
8257 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8259 sym_op->aead.digest.data = digest_mem;
8261 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8262 "no room to append digest");
8264 sym_op->aead.digest.phys_addr = digest_phys;
8266 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8267 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8269 debug_hexdump(stdout, "digest:",
8270 sym_op->aead.digest.data,
8274 /* Append aad data */
8275 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8276 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8277 uint8_t *, IV_OFFSET);
8279 /* Copy IV 1 byte after the IV pointer, according to the API */
8280 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8282 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8284 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8285 ut_params->ibuf, aad_len);
8286 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8287 "no room to prepend aad");
8288 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8291 memset(sym_op->aead.aad.data, 0, aad_len);
8292 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8293 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8295 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8296 debug_hexdump(stdout, "aad:",
8297 sym_op->aead.aad.data, aad_len);
8299 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8300 uint8_t *, IV_OFFSET);
8302 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8304 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8305 ut_params->ibuf, aad_len);
8306 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8307 "no room to prepend aad");
8308 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8311 memset(sym_op->aead.aad.data, 0, aad_len);
8312 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8314 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8315 debug_hexdump(stdout, "aad:",
8316 sym_op->aead.aad.data, aad_len);
8319 sym_op->aead.data.length = tdata->plaintext.len;
8320 sym_op->aead.data.offset = aad_len;
8325 #define SGL_MAX_NO 16
8328 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8329 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8331 struct crypto_testsuite_params *ts_params = &testsuite_params;
8332 struct crypto_unittest_params *ut_params = &unittest_params;
8333 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8336 int to_trn_tbl[SGL_MAX_NO];
8338 unsigned int trn_data = 0;
8339 uint8_t *plaintext, *ciphertext, *auth_tag;
8341 if (fragsz > tdata->plaintext.len)
8342 fragsz = tdata->plaintext.len;
8344 uint16_t plaintext_len = fragsz;
8345 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8347 if (fragsz_oop > tdata->plaintext.len)
8348 frag_size_oop = tdata->plaintext.len;
8351 void *digest_mem = NULL;
8353 uint32_t prepend_len = tdata->aad.len;
8355 if (tdata->plaintext.len % fragsz != 0) {
8356 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8359 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8364 * For out-op-place we need to alloc another mbuf
8367 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8368 rte_pktmbuf_append(ut_params->obuf,
8369 frag_size_oop + prepend_len);
8370 buf_oop = ut_params->obuf;
8373 /* Create AEAD session */
8374 retval = create_aead_session(ts_params->valid_devs[0],
8376 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8377 tdata->key.data, tdata->key.len,
8378 tdata->aad.len, tdata->auth_tag.len,
8383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8385 /* clear mbuf payload */
8386 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8387 rte_pktmbuf_tailroom(ut_params->ibuf));
8389 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8392 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8394 trn_data += plaintext_len;
8396 buf = ut_params->ibuf;
8399 * Loop until no more fragments
8402 while (trn_data < tdata->plaintext.len) {
8404 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8405 (tdata->plaintext.len - trn_data) : fragsz;
8407 to_trn_tbl[ecx++] = to_trn;
8409 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8412 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8413 rte_pktmbuf_tailroom(buf));
8416 if (oop && !fragsz_oop) {
8417 buf_last_oop = buf_oop->next =
8418 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8419 buf_oop = buf_oop->next;
8420 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8421 0, rte_pktmbuf_tailroom(buf_oop));
8422 rte_pktmbuf_append(buf_oop, to_trn);
8425 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8428 memcpy(plaintext, tdata->plaintext.data + trn_data,
8431 if (trn_data == tdata->plaintext.len) {
8434 digest_mem = rte_pktmbuf_append(buf_oop,
8435 tdata->auth_tag.len);
8437 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8438 tdata->auth_tag.len);
8442 uint64_t digest_phys = 0;
8444 ut_params->ibuf->nb_segs = segs;
8447 if (fragsz_oop && oop) {
8451 if (frag_size_oop == tdata->plaintext.len) {
8452 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8453 tdata->auth_tag.len);
8455 digest_phys = rte_pktmbuf_iova_offset(
8457 tdata->plaintext.len + prepend_len);
8460 trn_data = frag_size_oop;
8461 while (trn_data < tdata->plaintext.len) {
8464 (tdata->plaintext.len - trn_data <
8466 (tdata->plaintext.len - trn_data) :
8469 to_trn_tbl[ecx++] = to_trn;
8471 buf_last_oop = buf_oop->next =
8472 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8473 buf_oop = buf_oop->next;
8474 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8475 0, rte_pktmbuf_tailroom(buf_oop));
8476 rte_pktmbuf_append(buf_oop, to_trn);
8480 if (trn_data == tdata->plaintext.len) {
8481 digest_mem = rte_pktmbuf_append(buf_oop,
8482 tdata->auth_tag.len);
8486 ut_params->obuf->nb_segs = segs;
8490 * Place digest at the end of the last buffer
8493 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8494 if (oop && buf_last_oop)
8495 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8497 if (!digest_mem && !oop) {
8498 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8499 + tdata->auth_tag.len);
8500 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8501 tdata->plaintext.len);
8504 /* Create AEAD operation */
8505 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8506 tdata, digest_mem, digest_phys);
8511 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8513 ut_params->op->sym->m_src = ut_params->ibuf;
8515 ut_params->op->sym->m_dst = ut_params->obuf;
8517 /* Process crypto operation */
8518 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8519 ut_params->op), "failed to process sym crypto op");
8521 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8522 "crypto op processing failed");
8525 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8526 uint8_t *, prepend_len);
8528 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8529 uint8_t *, prepend_len);
8533 fragsz = fragsz_oop;
8535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8537 tdata->ciphertext.data,
8539 "Ciphertext data not as expected");
8541 buf = ut_params->op->sym->m_src->next;
8543 buf = ut_params->op->sym->m_dst->next;
8545 unsigned int off = fragsz;
8549 ciphertext = rte_pktmbuf_mtod(buf,
8552 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8554 tdata->ciphertext.data + off,
8556 "Ciphertext data not as expected");
8558 off += to_trn_tbl[ecx++];
8562 auth_tag = digest_mem;
8563 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8565 tdata->auth_tag.data,
8566 tdata->auth_tag.len,
8567 "Generated auth tag not as expected");
8573 #define OUT_OF_PLACE 1
8576 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8578 return test_authenticated_encryption_SGL(
8579 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8583 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8585 return test_authenticated_encryption_SGL(
8586 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8590 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8592 return test_authenticated_encryption_SGL(
8593 &gcm_test_case_8, OUT_OF_PLACE, 400,
8594 gcm_test_case_8.plaintext.len);
8598 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8601 return test_authenticated_encryption_SGL(
8602 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8606 test_authentication_verify_fail_when_data_corrupted(
8607 struct crypto_testsuite_params *ts_params,
8608 struct crypto_unittest_params *ut_params,
8609 const struct test_crypto_vector *reference)
8611 return test_authentication_verify_fail_when_data_corruption(
8612 ts_params, ut_params, reference, 1);
8616 test_authentication_verify_fail_when_tag_corrupted(
8617 struct crypto_testsuite_params *ts_params,
8618 struct crypto_unittest_params *ut_params,
8619 const struct test_crypto_vector *reference)
8621 return test_authentication_verify_fail_when_data_corruption(
8622 ts_params, ut_params, reference, 0);
8626 test_authentication_verify_GMAC_fail_when_data_corrupted(
8627 struct crypto_testsuite_params *ts_params,
8628 struct crypto_unittest_params *ut_params,
8629 const struct test_crypto_vector *reference)
8631 return test_authentication_verify_GMAC_fail_when_corruption(
8632 ts_params, ut_params, reference, 1);
8636 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8637 struct crypto_testsuite_params *ts_params,
8638 struct crypto_unittest_params *ut_params,
8639 const struct test_crypto_vector *reference)
8641 return test_authentication_verify_GMAC_fail_when_corruption(
8642 ts_params, ut_params, reference, 0);
8646 test_authenticated_decryption_fail_when_data_corrupted(
8647 struct crypto_testsuite_params *ts_params,
8648 struct crypto_unittest_params *ut_params,
8649 const struct test_crypto_vector *reference)
8651 return test_authenticated_decryption_fail_when_corruption(
8652 ts_params, ut_params, reference, 1);
8656 test_authenticated_decryption_fail_when_tag_corrupted(
8657 struct crypto_testsuite_params *ts_params,
8658 struct crypto_unittest_params *ut_params,
8659 const struct test_crypto_vector *reference)
8661 return test_authenticated_decryption_fail_when_corruption(
8662 ts_params, ut_params, reference, 0);
8666 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8668 return test_authentication_verify_fail_when_data_corrupted(
8669 &testsuite_params, &unittest_params,
8670 &hmac_sha1_test_crypto_vector);
8674 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8676 return test_authentication_verify_fail_when_tag_corrupted(
8677 &testsuite_params, &unittest_params,
8678 &hmac_sha1_test_crypto_vector);
8682 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8684 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8685 &testsuite_params, &unittest_params,
8686 &aes128_gmac_test_vector);
8690 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8692 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8693 &testsuite_params, &unittest_params,
8694 &aes128_gmac_test_vector);
8698 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8700 return test_authenticated_decryption_fail_when_data_corrupted(
8703 &aes128cbc_hmac_sha1_test_vector);
8707 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8709 return test_authenticated_decryption_fail_when_tag_corrupted(
8712 &aes128cbc_hmac_sha1_test_vector);
8715 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8717 /* global AESNI slave IDs for the scheduler test */
8718 uint8_t aesni_ids[2];
8721 test_scheduler_attach_slave_op(void)
8723 struct crypto_testsuite_params *ts_params = &testsuite_params;
8724 uint8_t sched_id = ts_params->valid_devs[0];
8725 uint32_t nb_devs, i, nb_devs_attached = 0;
8729 /* create 2 AESNI_MB if necessary */
8730 nb_devs = rte_cryptodev_device_count_by_driver(
8731 rte_cryptodev_driver_id_get(
8732 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8734 for (i = nb_devs; i < 2; i++) {
8735 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8736 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8738 ret = rte_vdev_init(vdev_name, NULL);
8740 TEST_ASSERT(ret == 0,
8741 "Failed to create instance %u of"
8743 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8747 /* attach 2 AESNI_MB cdevs */
8748 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8750 struct rte_cryptodev_info info;
8752 rte_cryptodev_info_get(i, &info);
8753 if (info.driver_id != rte_cryptodev_driver_id_get(
8754 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8758 * Create the session mempool again, since now there are new devices
8759 * to use the mempool.
8761 if (ts_params->session_mpool) {
8762 rte_mempool_free(ts_params->session_mpool);
8763 ts_params->session_mpool = NULL;
8765 unsigned int session_size =
8766 rte_cryptodev_sym_get_private_session_size(i);
8768 if (info.sym.max_nb_sessions != 0 &&
8769 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8771 "Device does not support "
8772 "at least %u sessions\n",
8777 * Create mempool with maximum number of sessions * 2,
8778 * to include the session headers
8780 if (ts_params->session_mpool == NULL) {
8781 ts_params->session_mpool = rte_mempool_create(
8783 MAX_NB_SESSIONS * 2,
8785 0, 0, NULL, NULL, NULL,
8786 NULL, SOCKET_ID_ANY,
8789 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8790 "session mempool allocation failed");
8793 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8796 TEST_ASSERT(ret == 0,
8797 "Failed to attach device %u of pmd : %s", i,
8798 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8800 aesni_ids[nb_devs_attached] = (uint8_t)i;
8809 test_scheduler_detach_slave_op(void)
8811 struct crypto_testsuite_params *ts_params = &testsuite_params;
8812 uint8_t sched_id = ts_params->valid_devs[0];
8816 for (i = 0; i < 2; i++) {
8817 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8819 TEST_ASSERT(ret == 0,
8820 "Failed to detach device %u", aesni_ids[i]);
8827 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8829 struct crypto_testsuite_params *ts_params = &testsuite_params;
8830 uint8_t sched_id = ts_params->valid_devs[0];
8832 return rte_cryptodev_scheduler_mode_set(sched_id,
8837 test_scheduler_mode_roundrobin_op(void)
8839 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8840 0, "Failed to set roundrobin mode");
8846 test_scheduler_mode_multicore_op(void)
8848 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8849 0, "Failed to set multicore mode");
8855 test_scheduler_mode_failover_op(void)
8857 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8858 0, "Failed to set failover mode");
8864 test_scheduler_mode_pkt_size_distr_op(void)
8866 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8867 0, "Failed to set pktsize mode");
8872 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8873 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8874 .setup = testsuite_setup,
8875 .teardown = testsuite_teardown,
8876 .unit_test_cases = {
8878 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8879 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8880 TEST_CASE_ST(ut_setup, ut_teardown,
8881 test_AES_chain_scheduler_all),
8882 TEST_CASE_ST(ut_setup, ut_teardown,
8883 test_AES_cipheronly_scheduler_all),
8884 TEST_CASE_ST(ut_setup, ut_teardown,
8885 test_authonly_scheduler_all),
8886 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8889 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8890 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_AES_chain_scheduler_all),
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_AES_cipheronly_scheduler_all),
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_authonly_scheduler_all),
8897 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8900 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8901 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8902 TEST_CASE_ST(ut_setup, ut_teardown,
8903 test_AES_chain_scheduler_all),
8904 TEST_CASE_ST(ut_setup, ut_teardown,
8905 test_AES_cipheronly_scheduler_all),
8906 TEST_CASE_ST(ut_setup, ut_teardown,
8907 test_authonly_scheduler_all),
8908 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8911 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8912 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_AES_chain_scheduler_all),
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_AES_cipheronly_scheduler_all),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_authonly_scheduler_all),
8919 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8921 TEST_CASES_END() /**< NULL terminate unit test array */
8925 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8927 static struct unit_test_suite cryptodev_qat_testsuite = {
8928 .suite_name = "Crypto QAT Unit Test Suite",
8929 .setup = testsuite_setup,
8930 .teardown = testsuite_teardown,
8931 .unit_test_cases = {
8932 TEST_CASE_ST(ut_setup, ut_teardown,
8933 test_device_configure_invalid_dev_id),
8934 TEST_CASE_ST(ut_setup, ut_teardown,
8935 test_device_configure_invalid_queue_pair_ids),
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_queue_pair_descriptor_setup),
8938 TEST_CASE_ST(ut_setup, ut_teardown,
8939 test_multi_session),
8941 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8942 TEST_CASE_ST(ut_setup, ut_teardown,
8943 test_AES_cipheronly_qat_all),
8944 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8945 TEST_CASE_ST(ut_setup, ut_teardown,
8946 test_3DES_cipheronly_qat_all),
8947 TEST_CASE_ST(ut_setup, ut_teardown,
8948 test_DES_cipheronly_qat_all),
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 test_AES_docsis_qat_all),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_DES_docsis_qat_all),
8953 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8954 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8956 /** AES CCM Authenticated Encryption 128 bits key */
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_AES_CCM_authenticated_encryption_test_case_128_1),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_AES_CCM_authenticated_encryption_test_case_128_2),
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 test_AES_CCM_authenticated_encryption_test_case_128_3),
8964 /** AES CCM Authenticated Decryption 128 bits key*/
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 test_AES_CCM_authenticated_decryption_test_case_128_1),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_AES_CCM_authenticated_decryption_test_case_128_2),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 test_AES_CCM_authenticated_decryption_test_case_128_3),
8972 /** AES GCM Authenticated Encryption */
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_AES_GCM_authenticated_encryption_test_case_1),
8981 TEST_CASE_ST(ut_setup, ut_teardown,
8982 test_AES_GCM_authenticated_encryption_test_case_2),
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_GCM_authenticated_encryption_test_case_3),
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_AES_GCM_authenticated_encryption_test_case_4),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_AES_GCM_authenticated_encryption_test_case_5),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_AES_GCM_authenticated_encryption_test_case_6),
8991 TEST_CASE_ST(ut_setup, ut_teardown,
8992 test_AES_GCM_authenticated_encryption_test_case_7),
8994 /** AES GCM Authenticated Decryption */
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 test_AES_GCM_authenticated_decryption_test_case_1),
8997 TEST_CASE_ST(ut_setup, ut_teardown,
8998 test_AES_GCM_authenticated_decryption_test_case_2),
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 test_AES_GCM_authenticated_decryption_test_case_3),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_AES_GCM_authenticated_decryption_test_case_4),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_AES_GCM_authenticated_decryption_test_case_5),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_GCM_authenticated_decryption_test_case_6),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_GCM_authenticated_decryption_test_case_7),
9010 /** AES GCM Authenticated Encryption 192 bits key */
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_GCM_auth_encryption_test_case_192_1),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 test_AES_GCM_auth_encryption_test_case_192_2),
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 test_AES_GCM_auth_encryption_test_case_192_3),
9017 TEST_CASE_ST(ut_setup, ut_teardown,
9018 test_AES_GCM_auth_encryption_test_case_192_4),
9019 TEST_CASE_ST(ut_setup, ut_teardown,
9020 test_AES_GCM_auth_encryption_test_case_192_5),
9021 TEST_CASE_ST(ut_setup, ut_teardown,
9022 test_AES_GCM_auth_encryption_test_case_192_6),
9023 TEST_CASE_ST(ut_setup, ut_teardown,
9024 test_AES_GCM_auth_encryption_test_case_192_7),
9026 /** AES GCM Authenticated Decryption 192 bits key */
9027 TEST_CASE_ST(ut_setup, ut_teardown,
9028 test_AES_GCM_auth_decryption_test_case_192_1),
9029 TEST_CASE_ST(ut_setup, ut_teardown,
9030 test_AES_GCM_auth_decryption_test_case_192_2),
9031 TEST_CASE_ST(ut_setup, ut_teardown,
9032 test_AES_GCM_auth_decryption_test_case_192_3),
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_AES_GCM_auth_decryption_test_case_192_4),
9035 TEST_CASE_ST(ut_setup, ut_teardown,
9036 test_AES_GCM_auth_decryption_test_case_192_5),
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_AES_GCM_auth_decryption_test_case_192_6),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_AES_GCM_auth_decryption_test_case_192_7),
9042 /** AES GCM Authenticated Encryption 256 bits key */
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_GCM_auth_encryption_test_case_256_1),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_GCM_auth_encryption_test_case_256_2),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_GCM_auth_encryption_test_case_256_3),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_AES_GCM_auth_encryption_test_case_256_4),
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_AES_GCM_auth_encryption_test_case_256_5),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_AES_GCM_auth_encryption_test_case_256_6),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_AES_GCM_auth_encryption_test_case_256_7),
9058 /** AES GMAC Authentication */
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_AES_GMAC_authentication_test_case_1),
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_AES_GMAC_authentication_verify_test_case_1),
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_GMAC_authentication_test_case_2),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_GMAC_authentication_verify_test_case_2),
9067 TEST_CASE_ST(ut_setup, ut_teardown,
9068 test_AES_GMAC_authentication_test_case_3),
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_AES_GMAC_authentication_verify_test_case_3),
9072 /** SNOW 3G encrypt only (UEA2) */
9073 TEST_CASE_ST(ut_setup, ut_teardown,
9074 test_snow3g_encryption_test_case_1),
9075 TEST_CASE_ST(ut_setup, ut_teardown,
9076 test_snow3g_encryption_test_case_2),
9077 TEST_CASE_ST(ut_setup, ut_teardown,
9078 test_snow3g_encryption_test_case_3),
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_snow3g_encryption_test_case_4),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_snow3g_encryption_test_case_5),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_snow3g_encryption_test_case_1_oop),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_snow3g_decryption_test_case_1_oop),
9089 /** SNOW 3G decrypt only (UEA2) */
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_snow3g_decryption_test_case_1),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_snow3g_decryption_test_case_2),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_snow3g_decryption_test_case_3),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_snow3g_decryption_test_case_4),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_snow3g_decryption_test_case_5),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_snow3g_hash_generate_test_case_1),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_snow3g_hash_generate_test_case_2),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_snow3g_hash_generate_test_case_3),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_snow3g_hash_verify_test_case_1),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_snow3g_hash_verify_test_case_2),
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_snow3g_hash_verify_test_case_3),
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_snow3g_cipher_auth_test_case_1),
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_snow3g_auth_cipher_test_case_1),
9117 /** ZUC encrypt only (EEA3) */
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_zuc_encryption_test_case_1),
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_zuc_encryption_test_case_2),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_zuc_encryption_test_case_3),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_zuc_encryption_test_case_4),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_zuc_encryption_test_case_5),
9129 /** ZUC authenticate (EIA3) */
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_zuc_hash_generate_test_case_6),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_zuc_hash_generate_test_case_7),
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_zuc_hash_generate_test_case_8),
9137 /** ZUC alg-chain (EEA3/EIA3) */
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_zuc_cipher_auth_test_case_1),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 test_zuc_cipher_auth_test_case_2),
9143 /** HMAC_MD5 Authentication */
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_MD5_HMAC_generate_case_1),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_MD5_HMAC_verify_case_1),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_MD5_HMAC_generate_case_2),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_MD5_HMAC_verify_case_2),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_null_auth_only_operation),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_null_cipher_only_operation),
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_null_cipher_auth_operation),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_null_auth_cipher_operation),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_kasumi_hash_generate_test_case_1),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_kasumi_hash_generate_test_case_2),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_kasumi_hash_generate_test_case_3),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_kasumi_hash_generate_test_case_4),
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_kasumi_hash_generate_test_case_5),
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_kasumi_hash_generate_test_case_6),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_kasumi_hash_verify_test_case_1),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_kasumi_hash_verify_test_case_2),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_kasumi_hash_verify_test_case_3),
9183 TEST_CASE_ST(ut_setup, ut_teardown,
9184 test_kasumi_hash_verify_test_case_4),
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_kasumi_hash_verify_test_case_5),
9188 TEST_CASE_ST(ut_setup, ut_teardown,
9189 test_kasumi_encryption_test_case_1),
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_kasumi_encryption_test_case_3),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_kasumi_auth_cipher_test_case_1),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_kasumi_cipher_auth_test_case_1),
9197 /** Negative tests */
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 authentication_verify_AES128_GMAC_fail_data_corrupt),
9204 TEST_CASE_ST(ut_setup, ut_teardown,
9205 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9206 TEST_CASE_ST(ut_setup, ut_teardown,
9207 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9211 TEST_CASES_END() /**< NULL terminate unit test array */
9215 static struct unit_test_suite cryptodev_virtio_testsuite = {
9216 .suite_name = "Crypto VIRTIO Unit Test Suite",
9217 .setup = testsuite_setup,
9218 .teardown = testsuite_teardown,
9219 .unit_test_cases = {
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_AES_cipheronly_virtio_all),
9223 TEST_CASES_END() /**< NULL terminate unit test array */
9227 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9228 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9229 .setup = testsuite_setup,
9230 .teardown = testsuite_teardown,
9231 .unit_test_cases = {
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 test_AES_GCM_authenticated_encryption_test_case_1),
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 test_AES_GCM_authenticated_encryption_test_case_2),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_AES_GCM_authenticated_encryption_test_case_3),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_AES_GCM_authenticated_encryption_test_case_4),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 test_AES_GCM_authenticated_encryption_test_case_5),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_AES_GCM_authenticated_encryption_test_case_6),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_AES_GCM_authenticated_encryption_test_case_7),
9247 /** AES GCM Authenticated Decryption */
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 test_AES_GCM_authenticated_decryption_test_case_1),
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 test_AES_GCM_authenticated_decryption_test_case_2),
9252 TEST_CASE_ST(ut_setup, ut_teardown,
9253 test_AES_GCM_authenticated_decryption_test_case_3),
9254 TEST_CASE_ST(ut_setup, ut_teardown,
9255 test_AES_GCM_authenticated_decryption_test_case_4),
9256 TEST_CASE_ST(ut_setup, ut_teardown,
9257 test_AES_GCM_authenticated_decryption_test_case_5),
9258 TEST_CASE_ST(ut_setup, ut_teardown,
9259 test_AES_GCM_authenticated_decryption_test_case_6),
9260 TEST_CASE_ST(ut_setup, ut_teardown,
9261 test_AES_GCM_authenticated_decryption_test_case_7),
9263 /** AES GCM Authenticated Encryption 192 bits key */
9264 TEST_CASE_ST(ut_setup, ut_teardown,
9265 test_AES_GCM_auth_encryption_test_case_192_1),
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_AES_GCM_auth_encryption_test_case_192_2),
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_AES_GCM_auth_encryption_test_case_192_3),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_AES_GCM_auth_encryption_test_case_192_4),
9272 TEST_CASE_ST(ut_setup, ut_teardown,
9273 test_AES_GCM_auth_encryption_test_case_192_5),
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 test_AES_GCM_auth_encryption_test_case_192_6),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 test_AES_GCM_auth_encryption_test_case_192_7),
9279 /** AES GCM Authenticated Decryption 192 bits key */
9280 TEST_CASE_ST(ut_setup, ut_teardown,
9281 test_AES_GCM_auth_decryption_test_case_192_1),
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_AES_GCM_auth_decryption_test_case_192_2),
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_AES_GCM_auth_decryption_test_case_192_3),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_auth_decryption_test_case_192_4),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_AES_GCM_auth_decryption_test_case_192_5),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_AES_GCM_auth_decryption_test_case_192_6),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_auth_decryption_test_case_192_7),
9295 /** AES GCM Authenticated Encryption 256 bits key */
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_AES_GCM_auth_encryption_test_case_256_1),
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_AES_GCM_auth_encryption_test_case_256_2),
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_AES_GCM_auth_encryption_test_case_256_3),
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_GCM_auth_encryption_test_case_256_4),
9304 TEST_CASE_ST(ut_setup, ut_teardown,
9305 test_AES_GCM_auth_encryption_test_case_256_5),
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_AES_GCM_auth_encryption_test_case_256_6),
9308 TEST_CASE_ST(ut_setup, ut_teardown,
9309 test_AES_GCM_auth_encryption_test_case_256_7),
9311 /** AES GCM Authenticated Decryption 256 bits key */
9312 TEST_CASE_ST(ut_setup, ut_teardown,
9313 test_AES_GCM_auth_decryption_test_case_256_1),
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_AES_GCM_auth_decryption_test_case_256_2),
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_AES_GCM_auth_decryption_test_case_256_3),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_auth_decryption_test_case_256_4),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_AES_GCM_auth_decryption_test_case_256_5),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_auth_decryption_test_case_256_6),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_AES_GCM_auth_decryption_test_case_256_7),
9327 /** AES GCM Authenticated Encryption big aad size */
9328 TEST_CASE_ST(ut_setup, ut_teardown,
9329 test_AES_GCM_auth_encryption_test_case_aad_1),
9330 TEST_CASE_ST(ut_setup, ut_teardown,
9331 test_AES_GCM_auth_encryption_test_case_aad_2),
9333 /** AES GCM Authenticated Decryption big aad size */
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_AES_GCM_auth_decryption_test_case_aad_1),
9336 TEST_CASE_ST(ut_setup, ut_teardown,
9337 test_AES_GCM_auth_decryption_test_case_aad_2),
9339 /** Session-less tests */
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9346 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9347 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9348 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9349 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_DES_cipheronly_mb_all),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_DES_docsis_mb_all),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_3DES_cipheronly_mb_all),
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_AES_CCM_authenticated_encryption_test_case_128_1),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_AES_CCM_authenticated_decryption_test_case_128_1),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 test_AES_CCM_authenticated_encryption_test_case_128_2),
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_CCM_authenticated_decryption_test_case_128_2),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_CCM_authenticated_encryption_test_case_128_3),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_CCM_authenticated_decryption_test_case_128_3),
9369 TEST_CASES_END() /**< NULL terminate unit test array */
9373 static struct unit_test_suite cryptodev_openssl_testsuite = {
9374 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9375 .setup = testsuite_setup,
9376 .teardown = testsuite_teardown,
9377 .unit_test_cases = {
9378 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_multi_session_random_usage),
9381 TEST_CASE_ST(ut_setup, ut_teardown,
9382 test_AES_chain_openssl_all),
9383 TEST_CASE_ST(ut_setup, ut_teardown,
9384 test_AES_cipheronly_openssl_all),
9385 TEST_CASE_ST(ut_setup, ut_teardown,
9386 test_3DES_chain_openssl_all),
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_3DES_cipheronly_openssl_all),
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_DES_cipheronly_openssl_all),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_DES_docsis_openssl_all),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_authonly_openssl_all),
9396 /** AES GCM Authenticated Encryption */
9397 TEST_CASE_ST(ut_setup, ut_teardown,
9398 test_AES_GCM_authenticated_encryption_test_case_1),
9399 TEST_CASE_ST(ut_setup, ut_teardown,
9400 test_AES_GCM_authenticated_encryption_test_case_2),
9401 TEST_CASE_ST(ut_setup, ut_teardown,
9402 test_AES_GCM_authenticated_encryption_test_case_3),
9403 TEST_CASE_ST(ut_setup, ut_teardown,
9404 test_AES_GCM_authenticated_encryption_test_case_4),
9405 TEST_CASE_ST(ut_setup, ut_teardown,
9406 test_AES_GCM_authenticated_encryption_test_case_5),
9407 TEST_CASE_ST(ut_setup, ut_teardown,
9408 test_AES_GCM_authenticated_encryption_test_case_6),
9409 TEST_CASE_ST(ut_setup, ut_teardown,
9410 test_AES_GCM_authenticated_encryption_test_case_7),
9412 /** AES GCM Authenticated Decryption */
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 test_AES_GCM_authenticated_decryption_test_case_1),
9415 TEST_CASE_ST(ut_setup, ut_teardown,
9416 test_AES_GCM_authenticated_decryption_test_case_2),
9417 TEST_CASE_ST(ut_setup, ut_teardown,
9418 test_AES_GCM_authenticated_decryption_test_case_3),
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_AES_GCM_authenticated_decryption_test_case_4),
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_AES_GCM_authenticated_decryption_test_case_5),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_AES_GCM_authenticated_decryption_test_case_6),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_AES_GCM_authenticated_decryption_test_case_7),
9429 /** AES GCM Authenticated Encryption 192 bits key */
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_auth_encryption_test_case_192_1),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_auth_encryption_test_case_192_2),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_AES_GCM_auth_encryption_test_case_192_3),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_AES_GCM_auth_encryption_test_case_192_4),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_GCM_auth_encryption_test_case_192_5),
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_AES_GCM_auth_encryption_test_case_192_6),
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_AES_GCM_auth_encryption_test_case_192_7),
9445 /** AES GCM Authenticated Decryption 192 bits key */
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_AES_GCM_auth_decryption_test_case_192_1),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_AES_GCM_auth_decryption_test_case_192_2),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_auth_decryption_test_case_192_3),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_AES_GCM_auth_decryption_test_case_192_4),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_GCM_auth_decryption_test_case_192_5),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_AES_GCM_auth_decryption_test_case_192_6),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GCM_auth_decryption_test_case_192_7),
9461 /** AES GCM Authenticated Encryption 256 bits key */
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_auth_encryption_test_case_256_1),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_auth_encryption_test_case_256_2),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_auth_encryption_test_case_256_3),
9468 TEST_CASE_ST(ut_setup, ut_teardown,
9469 test_AES_GCM_auth_encryption_test_case_256_4),
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_AES_GCM_auth_encryption_test_case_256_5),
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_AES_GCM_auth_encryption_test_case_256_6),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_auth_encryption_test_case_256_7),
9477 /** AES GCM Authenticated Decryption 256 bits key */
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_GCM_auth_decryption_test_case_256_1),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_GCM_auth_decryption_test_case_256_2),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_GCM_auth_decryption_test_case_256_3),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_AES_GCM_auth_decryption_test_case_256_4),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_GCM_auth_decryption_test_case_256_5),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_GCM_auth_decryption_test_case_256_6),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_GCM_auth_decryption_test_case_256_7),
9493 /** AES GMAC Authentication */
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_AES_GMAC_authentication_test_case_1),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_AES_GMAC_authentication_verify_test_case_1),
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_AES_GMAC_authentication_test_case_2),
9500 TEST_CASE_ST(ut_setup, ut_teardown,
9501 test_AES_GMAC_authentication_verify_test_case_2),
9502 TEST_CASE_ST(ut_setup, ut_teardown,
9503 test_AES_GMAC_authentication_test_case_3),
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_AES_GMAC_authentication_verify_test_case_3),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_AES_GMAC_authentication_test_case_4),
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_AES_GMAC_authentication_verify_test_case_4),
9511 /** AES CCM Authenticated Encryption 128 bits key */
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_AES_CCM_authenticated_encryption_test_case_128_1),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_AES_CCM_authenticated_encryption_test_case_128_2),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_AES_CCM_authenticated_encryption_test_case_128_3),
9519 /** AES CCM Authenticated Decryption 128 bits key*/
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_AES_CCM_authenticated_decryption_test_case_128_1),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_AES_CCM_authenticated_decryption_test_case_128_2),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_AES_CCM_authenticated_decryption_test_case_128_3),
9527 /** AES CCM Authenticated Encryption 192 bits key */
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_AES_CCM_authenticated_encryption_test_case_192_1),
9530 TEST_CASE_ST(ut_setup, ut_teardown,
9531 test_AES_CCM_authenticated_encryption_test_case_192_2),
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 test_AES_CCM_authenticated_encryption_test_case_192_3),
9535 /** AES CCM Authenticated Decryption 192 bits key*/
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_AES_CCM_authenticated_decryption_test_case_192_1),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 test_AES_CCM_authenticated_decryption_test_case_192_2),
9540 TEST_CASE_ST(ut_setup, ut_teardown,
9541 test_AES_CCM_authenticated_decryption_test_case_192_3),
9543 /** AES CCM Authenticated Encryption 256 bits key */
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 test_AES_CCM_authenticated_encryption_test_case_256_1),
9546 TEST_CASE_ST(ut_setup, ut_teardown,
9547 test_AES_CCM_authenticated_encryption_test_case_256_2),
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 test_AES_CCM_authenticated_encryption_test_case_256_3),
9551 /** AES CCM Authenticated Decryption 256 bits key*/
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_AES_CCM_authenticated_decryption_test_case_256_1),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_AES_CCM_authenticated_decryption_test_case_256_2),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_AES_CCM_authenticated_decryption_test_case_256_3),
9559 /** Scatter-Gather */
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9563 /** Negative tests */
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 authentication_verify_AES128_GMAC_fail_data_corrupt),
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9572 TEST_CASE_ST(ut_setup, ut_teardown,
9573 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9574 TEST_CASE_ST(ut_setup, ut_teardown,
9575 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9577 TEST_CASES_END() /**< NULL terminate unit test array */
9581 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9582 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9583 .setup = testsuite_setup,
9584 .teardown = testsuite_teardown,
9585 .unit_test_cases = {
9586 /** AES GCM Authenticated Encryption */
9587 TEST_CASE_ST(ut_setup, ut_teardown,
9588 test_AES_GCM_authenticated_encryption_test_case_1),
9589 TEST_CASE_ST(ut_setup, ut_teardown,
9590 test_AES_GCM_authenticated_encryption_test_case_2),
9591 TEST_CASE_ST(ut_setup, ut_teardown,
9592 test_AES_GCM_authenticated_encryption_test_case_3),
9593 TEST_CASE_ST(ut_setup, ut_teardown,
9594 test_AES_GCM_authenticated_encryption_test_case_4),
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_AES_GCM_authenticated_encryption_test_case_5),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_AES_GCM_authenticated_encryption_test_case_6),
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_AES_GCM_authenticated_encryption_test_case_7),
9602 /** AES GCM Authenticated Decryption */
9603 TEST_CASE_ST(ut_setup, ut_teardown,
9604 test_AES_GCM_authenticated_decryption_test_case_1),
9605 TEST_CASE_ST(ut_setup, ut_teardown,
9606 test_AES_GCM_authenticated_decryption_test_case_2),
9607 TEST_CASE_ST(ut_setup, ut_teardown,
9608 test_AES_GCM_authenticated_decryption_test_case_3),
9609 TEST_CASE_ST(ut_setup, ut_teardown,
9610 test_AES_GCM_authenticated_decryption_test_case_4),
9611 TEST_CASE_ST(ut_setup, ut_teardown,
9612 test_AES_GCM_authenticated_decryption_test_case_5),
9613 TEST_CASE_ST(ut_setup, ut_teardown,
9614 test_AES_GCM_authenticated_decryption_test_case_6),
9615 TEST_CASE_ST(ut_setup, ut_teardown,
9616 test_AES_GCM_authenticated_decryption_test_case_7),
9618 /** AES GCM Authenticated Encryption 192 bits key */
9619 TEST_CASE_ST(ut_setup, ut_teardown,
9620 test_AES_GCM_auth_encryption_test_case_192_1),
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 test_AES_GCM_auth_encryption_test_case_192_2),
9623 TEST_CASE_ST(ut_setup, ut_teardown,
9624 test_AES_GCM_auth_encryption_test_case_192_3),
9625 TEST_CASE_ST(ut_setup, ut_teardown,
9626 test_AES_GCM_auth_encryption_test_case_192_4),
9627 TEST_CASE_ST(ut_setup, ut_teardown,
9628 test_AES_GCM_auth_encryption_test_case_192_5),
9629 TEST_CASE_ST(ut_setup, ut_teardown,
9630 test_AES_GCM_auth_encryption_test_case_192_6),
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 test_AES_GCM_auth_encryption_test_case_192_7),
9634 /** AES GCM Authenticated Decryption 192 bits key */
9635 TEST_CASE_ST(ut_setup, ut_teardown,
9636 test_AES_GCM_auth_decryption_test_case_192_1),
9637 TEST_CASE_ST(ut_setup, ut_teardown,
9638 test_AES_GCM_auth_decryption_test_case_192_2),
9639 TEST_CASE_ST(ut_setup, ut_teardown,
9640 test_AES_GCM_auth_decryption_test_case_192_3),
9641 TEST_CASE_ST(ut_setup, ut_teardown,
9642 test_AES_GCM_auth_decryption_test_case_192_4),
9643 TEST_CASE_ST(ut_setup, ut_teardown,
9644 test_AES_GCM_auth_decryption_test_case_192_5),
9645 TEST_CASE_ST(ut_setup, ut_teardown,
9646 test_AES_GCM_auth_decryption_test_case_192_6),
9647 TEST_CASE_ST(ut_setup, ut_teardown,
9648 test_AES_GCM_auth_decryption_test_case_192_7),
9650 /** AES GCM Authenticated Encryption 256 bits key */
9651 TEST_CASE_ST(ut_setup, ut_teardown,
9652 test_AES_GCM_auth_encryption_test_case_256_1),
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_auth_encryption_test_case_256_2),
9655 TEST_CASE_ST(ut_setup, ut_teardown,
9656 test_AES_GCM_auth_encryption_test_case_256_3),
9657 TEST_CASE_ST(ut_setup, ut_teardown,
9658 test_AES_GCM_auth_encryption_test_case_256_4),
9659 TEST_CASE_ST(ut_setup, ut_teardown,
9660 test_AES_GCM_auth_encryption_test_case_256_5),
9661 TEST_CASE_ST(ut_setup, ut_teardown,
9662 test_AES_GCM_auth_encryption_test_case_256_6),
9663 TEST_CASE_ST(ut_setup, ut_teardown,
9664 test_AES_GCM_auth_encryption_test_case_256_7),
9666 /** AES GCM Authenticated Decryption 256 bits key */
9667 TEST_CASE_ST(ut_setup, ut_teardown,
9668 test_AES_GCM_auth_decryption_test_case_256_1),
9669 TEST_CASE_ST(ut_setup, ut_teardown,
9670 test_AES_GCM_auth_decryption_test_case_256_2),
9671 TEST_CASE_ST(ut_setup, ut_teardown,
9672 test_AES_GCM_auth_decryption_test_case_256_3),
9673 TEST_CASE_ST(ut_setup, ut_teardown,
9674 test_AES_GCM_auth_decryption_test_case_256_4),
9675 TEST_CASE_ST(ut_setup, ut_teardown,
9676 test_AES_GCM_auth_decryption_test_case_256_5),
9677 TEST_CASE_ST(ut_setup, ut_teardown,
9678 test_AES_GCM_auth_decryption_test_case_256_6),
9679 TEST_CASE_ST(ut_setup, ut_teardown,
9680 test_AES_GCM_auth_decryption_test_case_256_7),
9682 /** AES GCM Authenticated Encryption big aad size */
9683 TEST_CASE_ST(ut_setup, ut_teardown,
9684 test_AES_GCM_auth_encryption_test_case_aad_1),
9685 TEST_CASE_ST(ut_setup, ut_teardown,
9686 test_AES_GCM_auth_encryption_test_case_aad_2),
9688 /** AES GCM Authenticated Decryption big aad size */
9689 TEST_CASE_ST(ut_setup, ut_teardown,
9690 test_AES_GCM_auth_decryption_test_case_aad_1),
9691 TEST_CASE_ST(ut_setup, ut_teardown,
9692 test_AES_GCM_auth_decryption_test_case_aad_2),
9694 /** AES GMAC Authentication */
9695 TEST_CASE_ST(ut_setup, ut_teardown,
9696 test_AES_GMAC_authentication_test_case_1),
9697 TEST_CASE_ST(ut_setup, ut_teardown,
9698 test_AES_GMAC_authentication_verify_test_case_1),
9699 TEST_CASE_ST(ut_setup, ut_teardown,
9700 test_AES_GMAC_authentication_test_case_3),
9701 TEST_CASE_ST(ut_setup, ut_teardown,
9702 test_AES_GMAC_authentication_verify_test_case_3),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_AES_GMAC_authentication_test_case_4),
9705 TEST_CASE_ST(ut_setup, ut_teardown,
9706 test_AES_GMAC_authentication_verify_test_case_4),
9708 /** Negative tests */
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 authentication_verify_AES128_GMAC_fail_data_corrupt),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9714 /** Out of place tests */
9715 TEST_CASE_ST(ut_setup, ut_teardown,
9716 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9720 /** Session-less tests */
9721 TEST_CASE_ST(ut_setup, ut_teardown,
9722 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9723 TEST_CASE_ST(ut_setup, ut_teardown,
9724 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9726 /** Scatter-Gather */
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9730 TEST_CASES_END() /**< NULL terminate unit test array */
9734 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9735 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9736 .setup = testsuite_setup,
9737 .teardown = testsuite_teardown,
9738 .unit_test_cases = {
9739 /** KASUMI encrypt only (UEA1) */
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_kasumi_encryption_test_case_1),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_kasumi_encryption_test_case_1_sgl),
9744 TEST_CASE_ST(ut_setup, ut_teardown,
9745 test_kasumi_encryption_test_case_2),
9746 TEST_CASE_ST(ut_setup, ut_teardown,
9747 test_kasumi_encryption_test_case_3),
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 test_kasumi_encryption_test_case_4),
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 test_kasumi_encryption_test_case_5),
9752 /** KASUMI decrypt only (UEA1) */
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_kasumi_decryption_test_case_1),
9755 TEST_CASE_ST(ut_setup, ut_teardown,
9756 test_kasumi_decryption_test_case_2),
9757 TEST_CASE_ST(ut_setup, ut_teardown,
9758 test_kasumi_decryption_test_case_3),
9759 TEST_CASE_ST(ut_setup, ut_teardown,
9760 test_kasumi_decryption_test_case_4),
9761 TEST_CASE_ST(ut_setup, ut_teardown,
9762 test_kasumi_decryption_test_case_5),
9764 TEST_CASE_ST(ut_setup, ut_teardown,
9765 test_kasumi_encryption_test_case_1_oop),
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_kasumi_encryption_test_case_1_oop_sgl),
9770 TEST_CASE_ST(ut_setup, ut_teardown,
9771 test_kasumi_decryption_test_case_1_oop),
9773 /** KASUMI hash only (UIA1) */
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 test_kasumi_hash_generate_test_case_1),
9776 TEST_CASE_ST(ut_setup, ut_teardown,
9777 test_kasumi_hash_generate_test_case_2),
9778 TEST_CASE_ST(ut_setup, ut_teardown,
9779 test_kasumi_hash_generate_test_case_3),
9780 TEST_CASE_ST(ut_setup, ut_teardown,
9781 test_kasumi_hash_generate_test_case_4),
9782 TEST_CASE_ST(ut_setup, ut_teardown,
9783 test_kasumi_hash_generate_test_case_5),
9784 TEST_CASE_ST(ut_setup, ut_teardown,
9785 test_kasumi_hash_generate_test_case_6),
9786 TEST_CASE_ST(ut_setup, ut_teardown,
9787 test_kasumi_hash_verify_test_case_1),
9788 TEST_CASE_ST(ut_setup, ut_teardown,
9789 test_kasumi_hash_verify_test_case_2),
9790 TEST_CASE_ST(ut_setup, ut_teardown,
9791 test_kasumi_hash_verify_test_case_3),
9792 TEST_CASE_ST(ut_setup, ut_teardown,
9793 test_kasumi_hash_verify_test_case_4),
9794 TEST_CASE_ST(ut_setup, ut_teardown,
9795 test_kasumi_hash_verify_test_case_5),
9796 TEST_CASE_ST(ut_setup, ut_teardown,
9797 test_kasumi_auth_cipher_test_case_1),
9798 TEST_CASE_ST(ut_setup, ut_teardown,
9799 test_kasumi_cipher_auth_test_case_1),
9800 TEST_CASES_END() /**< NULL terminate unit test array */
9803 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9804 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9805 .setup = testsuite_setup,
9806 .teardown = testsuite_teardown,
9807 .unit_test_cases = {
9808 /** SNOW 3G encrypt only (UEA2) */
9809 TEST_CASE_ST(ut_setup, ut_teardown,
9810 test_snow3g_encryption_test_case_1),
9811 TEST_CASE_ST(ut_setup, ut_teardown,
9812 test_snow3g_encryption_test_case_2),
9813 TEST_CASE_ST(ut_setup, ut_teardown,
9814 test_snow3g_encryption_test_case_3),
9815 TEST_CASE_ST(ut_setup, ut_teardown,
9816 test_snow3g_encryption_test_case_4),
9817 TEST_CASE_ST(ut_setup, ut_teardown,
9818 test_snow3g_encryption_test_case_5),
9820 TEST_CASE_ST(ut_setup, ut_teardown,
9821 test_snow3g_encryption_test_case_1_oop),
9822 TEST_CASE_ST(ut_setup, ut_teardown,
9823 test_snow3g_encryption_test_case_1_oop_sgl),
9824 TEST_CASE_ST(ut_setup, ut_teardown,
9825 test_snow3g_decryption_test_case_1_oop),
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_snow3g_encryption_test_case_1_offset_oop),
9830 /** SNOW 3G decrypt only (UEA2) */
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 test_snow3g_decryption_test_case_1),
9833 TEST_CASE_ST(ut_setup, ut_teardown,
9834 test_snow3g_decryption_test_case_2),
9835 TEST_CASE_ST(ut_setup, ut_teardown,
9836 test_snow3g_decryption_test_case_3),
9837 TEST_CASE_ST(ut_setup, ut_teardown,
9838 test_snow3g_decryption_test_case_4),
9839 TEST_CASE_ST(ut_setup, ut_teardown,
9840 test_snow3g_decryption_test_case_5),
9841 TEST_CASE_ST(ut_setup, ut_teardown,
9842 test_snow3g_hash_generate_test_case_1),
9843 TEST_CASE_ST(ut_setup, ut_teardown,
9844 test_snow3g_hash_generate_test_case_2),
9845 TEST_CASE_ST(ut_setup, ut_teardown,
9846 test_snow3g_hash_generate_test_case_3),
9847 /* Tests with buffers which length is not byte-aligned */
9848 TEST_CASE_ST(ut_setup, ut_teardown,
9849 test_snow3g_hash_generate_test_case_4),
9850 TEST_CASE_ST(ut_setup, ut_teardown,
9851 test_snow3g_hash_generate_test_case_5),
9852 TEST_CASE_ST(ut_setup, ut_teardown,
9853 test_snow3g_hash_generate_test_case_6),
9854 TEST_CASE_ST(ut_setup, ut_teardown,
9855 test_snow3g_hash_verify_test_case_1),
9856 TEST_CASE_ST(ut_setup, ut_teardown,
9857 test_snow3g_hash_verify_test_case_2),
9858 TEST_CASE_ST(ut_setup, ut_teardown,
9859 test_snow3g_hash_verify_test_case_3),
9860 /* Tests with buffers which length is not byte-aligned */
9861 TEST_CASE_ST(ut_setup, ut_teardown,
9862 test_snow3g_hash_verify_test_case_4),
9863 TEST_CASE_ST(ut_setup, ut_teardown,
9864 test_snow3g_hash_verify_test_case_5),
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 test_snow3g_hash_verify_test_case_6),
9867 TEST_CASE_ST(ut_setup, ut_teardown,
9868 test_snow3g_cipher_auth_test_case_1),
9869 TEST_CASE_ST(ut_setup, ut_teardown,
9870 test_snow3g_auth_cipher_test_case_1),
9872 TEST_CASES_END() /**< NULL terminate unit test array */
9876 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9877 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9878 .setup = testsuite_setup,
9879 .teardown = testsuite_teardown,
9880 .unit_test_cases = {
9881 /** ZUC encrypt only (EEA3) */
9882 TEST_CASE_ST(ut_setup, ut_teardown,
9883 test_zuc_encryption_test_case_1),
9884 TEST_CASE_ST(ut_setup, ut_teardown,
9885 test_zuc_encryption_test_case_2),
9886 TEST_CASE_ST(ut_setup, ut_teardown,
9887 test_zuc_encryption_test_case_3),
9888 TEST_CASE_ST(ut_setup, ut_teardown,
9889 test_zuc_encryption_test_case_4),
9890 TEST_CASE_ST(ut_setup, ut_teardown,
9891 test_zuc_encryption_test_case_5),
9892 TEST_CASE_ST(ut_setup, ut_teardown,
9893 test_zuc_hash_generate_test_case_1),
9894 TEST_CASE_ST(ut_setup, ut_teardown,
9895 test_zuc_hash_generate_test_case_2),
9896 TEST_CASE_ST(ut_setup, ut_teardown,
9897 test_zuc_hash_generate_test_case_3),
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_zuc_hash_generate_test_case_4),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_zuc_hash_generate_test_case_5),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_zuc_encryption_test_case_6_sgl),
9904 TEST_CASES_END() /**< NULL terminate unit test array */
9908 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
9909 .suite_name = "Crypto CAAM JR Unit Test Suite",
9910 .setup = testsuite_setup,
9911 .teardown = testsuite_teardown,
9912 .unit_test_cases = {
9913 TEST_CASE_ST(ut_setup, ut_teardown,
9914 test_device_configure_invalid_dev_id),
9915 TEST_CASE_ST(ut_setup, ut_teardown,
9916 test_multi_session),
9918 TEST_CASE_ST(ut_setup, ut_teardown,
9919 test_AES_chain_caam_jr_all),
9920 TEST_CASE_ST(ut_setup, ut_teardown,
9921 test_3DES_chain_caam_jr_all),
9922 TEST_CASE_ST(ut_setup, ut_teardown,
9923 test_AES_cipheronly_caam_jr_all),
9924 TEST_CASE_ST(ut_setup, ut_teardown,
9925 test_3DES_cipheronly_caam_jr_all),
9926 TEST_CASE_ST(ut_setup, ut_teardown,
9927 test_authonly_caam_jr_all),
9929 TEST_CASES_END() /**< NULL terminate unit test array */
9933 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9934 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9935 .setup = testsuite_setup,
9936 .teardown = testsuite_teardown,
9937 .unit_test_cases = {
9938 TEST_CASE_ST(ut_setup, ut_teardown,
9939 test_device_configure_invalid_dev_id),
9940 TEST_CASE_ST(ut_setup, ut_teardown,
9941 test_multi_session),
9943 TEST_CASE_ST(ut_setup, ut_teardown,
9944 test_AES_chain_dpaa_sec_all),
9945 TEST_CASE_ST(ut_setup, ut_teardown,
9946 test_3DES_chain_dpaa_sec_all),
9947 TEST_CASE_ST(ut_setup, ut_teardown,
9948 test_AES_cipheronly_dpaa_sec_all),
9949 TEST_CASE_ST(ut_setup, ut_teardown,
9950 test_3DES_cipheronly_dpaa_sec_all),
9951 TEST_CASE_ST(ut_setup, ut_teardown,
9952 test_authonly_dpaa_sec_all),
9954 /** AES GCM Authenticated Encryption */
9955 TEST_CASE_ST(ut_setup, ut_teardown,
9956 test_AES_GCM_authenticated_encryption_test_case_1),
9957 TEST_CASE_ST(ut_setup, ut_teardown,
9958 test_AES_GCM_authenticated_encryption_test_case_2),
9959 TEST_CASE_ST(ut_setup, ut_teardown,
9960 test_AES_GCM_authenticated_encryption_test_case_3),
9961 TEST_CASE_ST(ut_setup, ut_teardown,
9962 test_AES_GCM_authenticated_encryption_test_case_4),
9963 TEST_CASE_ST(ut_setup, ut_teardown,
9964 test_AES_GCM_authenticated_encryption_test_case_5),
9965 TEST_CASE_ST(ut_setup, ut_teardown,
9966 test_AES_GCM_authenticated_encryption_test_case_6),
9967 TEST_CASE_ST(ut_setup, ut_teardown,
9968 test_AES_GCM_authenticated_encryption_test_case_7),
9970 /** AES GCM Authenticated Decryption */
9971 TEST_CASE_ST(ut_setup, ut_teardown,
9972 test_AES_GCM_authenticated_decryption_test_case_1),
9973 TEST_CASE_ST(ut_setup, ut_teardown,
9974 test_AES_GCM_authenticated_decryption_test_case_2),
9975 TEST_CASE_ST(ut_setup, ut_teardown,
9976 test_AES_GCM_authenticated_decryption_test_case_3),
9977 TEST_CASE_ST(ut_setup, ut_teardown,
9978 test_AES_GCM_authenticated_decryption_test_case_4),
9979 TEST_CASE_ST(ut_setup, ut_teardown,
9980 test_AES_GCM_authenticated_decryption_test_case_5),
9981 TEST_CASE_ST(ut_setup, ut_teardown,
9982 test_AES_GCM_authenticated_decryption_test_case_6),
9983 TEST_CASE_ST(ut_setup, ut_teardown,
9984 test_AES_GCM_authenticated_decryption_test_case_7),
9986 /** AES GCM Authenticated Encryption 256 bits key */
9987 TEST_CASE_ST(ut_setup, ut_teardown,
9988 test_AES_GCM_auth_encryption_test_case_256_1),
9989 TEST_CASE_ST(ut_setup, ut_teardown,
9990 test_AES_GCM_auth_encryption_test_case_256_2),
9991 TEST_CASE_ST(ut_setup, ut_teardown,
9992 test_AES_GCM_auth_encryption_test_case_256_3),
9993 TEST_CASE_ST(ut_setup, ut_teardown,
9994 test_AES_GCM_auth_encryption_test_case_256_4),
9995 TEST_CASE_ST(ut_setup, ut_teardown,
9996 test_AES_GCM_auth_encryption_test_case_256_5),
9997 TEST_CASE_ST(ut_setup, ut_teardown,
9998 test_AES_GCM_auth_encryption_test_case_256_6),
9999 TEST_CASE_ST(ut_setup, ut_teardown,
10000 test_AES_GCM_auth_encryption_test_case_256_7),
10002 /** AES GCM Authenticated Decryption 256 bits key */
10003 TEST_CASE_ST(ut_setup, ut_teardown,
10004 test_AES_GCM_auth_decryption_test_case_256_1),
10005 TEST_CASE_ST(ut_setup, ut_teardown,
10006 test_AES_GCM_auth_decryption_test_case_256_2),
10007 TEST_CASE_ST(ut_setup, ut_teardown,
10008 test_AES_GCM_auth_decryption_test_case_256_3),
10009 TEST_CASE_ST(ut_setup, ut_teardown,
10010 test_AES_GCM_auth_decryption_test_case_256_4),
10011 TEST_CASE_ST(ut_setup, ut_teardown,
10012 test_AES_GCM_auth_decryption_test_case_256_5),
10013 TEST_CASE_ST(ut_setup, ut_teardown,
10014 test_AES_GCM_auth_decryption_test_case_256_6),
10015 TEST_CASE_ST(ut_setup, ut_teardown,
10016 test_AES_GCM_auth_decryption_test_case_256_7),
10018 /** Out of place tests */
10019 TEST_CASE_ST(ut_setup, ut_teardown,
10020 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10021 TEST_CASE_ST(ut_setup, ut_teardown,
10022 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10024 /** Scatter-Gather */
10025 TEST_CASE_ST(ut_setup, ut_teardown,
10026 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10027 TEST_CASE_ST(ut_setup, ut_teardown,
10028 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10029 TEST_CASE_ST(ut_setup, ut_teardown,
10030 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10031 TEST_CASE_ST(ut_setup, ut_teardown,
10032 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10034 TEST_CASES_END() /**< NULL terminate unit test array */
10038 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
10039 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
10040 .setup = testsuite_setup,
10041 .teardown = testsuite_teardown,
10042 .unit_test_cases = {
10043 TEST_CASE_ST(ut_setup, ut_teardown,
10044 test_device_configure_invalid_dev_id),
10045 TEST_CASE_ST(ut_setup, ut_teardown,
10046 test_multi_session),
10048 TEST_CASE_ST(ut_setup, ut_teardown,
10049 test_AES_chain_dpaa2_sec_all),
10050 TEST_CASE_ST(ut_setup, ut_teardown,
10051 test_3DES_chain_dpaa2_sec_all),
10052 TEST_CASE_ST(ut_setup, ut_teardown,
10053 test_AES_cipheronly_dpaa2_sec_all),
10054 TEST_CASE_ST(ut_setup, ut_teardown,
10055 test_3DES_cipheronly_dpaa2_sec_all),
10056 TEST_CASE_ST(ut_setup, ut_teardown,
10057 test_authonly_dpaa2_sec_all),
10059 /** AES GCM Authenticated Encryption */
10060 TEST_CASE_ST(ut_setup, ut_teardown,
10061 test_AES_GCM_authenticated_encryption_test_case_1),
10062 TEST_CASE_ST(ut_setup, ut_teardown,
10063 test_AES_GCM_authenticated_encryption_test_case_2),
10064 TEST_CASE_ST(ut_setup, ut_teardown,
10065 test_AES_GCM_authenticated_encryption_test_case_3),
10066 TEST_CASE_ST(ut_setup, ut_teardown,
10067 test_AES_GCM_authenticated_encryption_test_case_4),
10068 TEST_CASE_ST(ut_setup, ut_teardown,
10069 test_AES_GCM_authenticated_encryption_test_case_5),
10070 TEST_CASE_ST(ut_setup, ut_teardown,
10071 test_AES_GCM_authenticated_encryption_test_case_6),
10072 TEST_CASE_ST(ut_setup, ut_teardown,
10073 test_AES_GCM_authenticated_encryption_test_case_7),
10075 /** AES GCM Authenticated Decryption */
10076 TEST_CASE_ST(ut_setup, ut_teardown,
10077 test_AES_GCM_authenticated_decryption_test_case_1),
10078 TEST_CASE_ST(ut_setup, ut_teardown,
10079 test_AES_GCM_authenticated_decryption_test_case_2),
10080 TEST_CASE_ST(ut_setup, ut_teardown,
10081 test_AES_GCM_authenticated_decryption_test_case_3),
10082 TEST_CASE_ST(ut_setup, ut_teardown,
10083 test_AES_GCM_authenticated_decryption_test_case_4),
10084 TEST_CASE_ST(ut_setup, ut_teardown,
10085 test_AES_GCM_authenticated_decryption_test_case_5),
10086 TEST_CASE_ST(ut_setup, ut_teardown,
10087 test_AES_GCM_authenticated_decryption_test_case_6),
10088 TEST_CASE_ST(ut_setup, ut_teardown,
10089 test_AES_GCM_authenticated_decryption_test_case_7),
10091 /** AES GCM Authenticated Encryption 192 bits key */
10092 TEST_CASE_ST(ut_setup, ut_teardown,
10093 test_AES_GCM_auth_encryption_test_case_192_1),
10094 TEST_CASE_ST(ut_setup, ut_teardown,
10095 test_AES_GCM_auth_encryption_test_case_192_2),
10096 TEST_CASE_ST(ut_setup, ut_teardown,
10097 test_AES_GCM_auth_encryption_test_case_192_3),
10098 TEST_CASE_ST(ut_setup, ut_teardown,
10099 test_AES_GCM_auth_encryption_test_case_192_4),
10100 TEST_CASE_ST(ut_setup, ut_teardown,
10101 test_AES_GCM_auth_encryption_test_case_192_5),
10102 TEST_CASE_ST(ut_setup, ut_teardown,
10103 test_AES_GCM_auth_encryption_test_case_192_6),
10104 TEST_CASE_ST(ut_setup, ut_teardown,
10105 test_AES_GCM_auth_encryption_test_case_192_7),
10107 /** AES GCM Authenticated Decryption 192 bits key */
10108 TEST_CASE_ST(ut_setup, ut_teardown,
10109 test_AES_GCM_auth_decryption_test_case_192_1),
10110 TEST_CASE_ST(ut_setup, ut_teardown,
10111 test_AES_GCM_auth_decryption_test_case_192_2),
10112 TEST_CASE_ST(ut_setup, ut_teardown,
10113 test_AES_GCM_auth_decryption_test_case_192_3),
10114 TEST_CASE_ST(ut_setup, ut_teardown,
10115 test_AES_GCM_auth_decryption_test_case_192_4),
10116 TEST_CASE_ST(ut_setup, ut_teardown,
10117 test_AES_GCM_auth_decryption_test_case_192_5),
10118 TEST_CASE_ST(ut_setup, ut_teardown,
10119 test_AES_GCM_auth_decryption_test_case_192_6),
10120 TEST_CASE_ST(ut_setup, ut_teardown,
10121 test_AES_GCM_auth_decryption_test_case_192_7),
10123 /** AES GCM Authenticated Encryption 256 bits key */
10124 TEST_CASE_ST(ut_setup, ut_teardown,
10125 test_AES_GCM_auth_encryption_test_case_256_1),
10126 TEST_CASE_ST(ut_setup, ut_teardown,
10127 test_AES_GCM_auth_encryption_test_case_256_2),
10128 TEST_CASE_ST(ut_setup, ut_teardown,
10129 test_AES_GCM_auth_encryption_test_case_256_3),
10130 TEST_CASE_ST(ut_setup, ut_teardown,
10131 test_AES_GCM_auth_encryption_test_case_256_4),
10132 TEST_CASE_ST(ut_setup, ut_teardown,
10133 test_AES_GCM_auth_encryption_test_case_256_5),
10134 TEST_CASE_ST(ut_setup, ut_teardown,
10135 test_AES_GCM_auth_encryption_test_case_256_6),
10136 TEST_CASE_ST(ut_setup, ut_teardown,
10137 test_AES_GCM_auth_encryption_test_case_256_7),
10139 /** AES GCM Authenticated Decryption 256 bits key */
10140 TEST_CASE_ST(ut_setup, ut_teardown,
10141 test_AES_GCM_auth_decryption_test_case_256_1),
10142 TEST_CASE_ST(ut_setup, ut_teardown,
10143 test_AES_GCM_auth_decryption_test_case_256_2),
10144 TEST_CASE_ST(ut_setup, ut_teardown,
10145 test_AES_GCM_auth_decryption_test_case_256_3),
10146 TEST_CASE_ST(ut_setup, ut_teardown,
10147 test_AES_GCM_auth_decryption_test_case_256_4),
10148 TEST_CASE_ST(ut_setup, ut_teardown,
10149 test_AES_GCM_auth_decryption_test_case_256_5),
10150 TEST_CASE_ST(ut_setup, ut_teardown,
10151 test_AES_GCM_auth_decryption_test_case_256_6),
10152 TEST_CASE_ST(ut_setup, ut_teardown,
10153 test_AES_GCM_auth_decryption_test_case_256_7),
10155 /** Out of place tests */
10156 TEST_CASE_ST(ut_setup, ut_teardown,
10157 test_AES_GCM_authenticated_encryption_oop_test_case_1),
10158 TEST_CASE_ST(ut_setup, ut_teardown,
10159 test_AES_GCM_authenticated_decryption_oop_test_case_1),
10161 /** Scatter-Gather */
10162 TEST_CASE_ST(ut_setup, ut_teardown,
10163 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
10164 TEST_CASE_ST(ut_setup, ut_teardown,
10165 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
10166 TEST_CASE_ST(ut_setup, ut_teardown,
10167 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
10168 TEST_CASE_ST(ut_setup, ut_teardown,
10169 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
10171 TEST_CASES_END() /**< NULL terminate unit test array */
10175 static struct unit_test_suite cryptodev_null_testsuite = {
10176 .suite_name = "Crypto Device NULL Unit Test Suite",
10177 .setup = testsuite_setup,
10178 .teardown = testsuite_teardown,
10179 .unit_test_cases = {
10180 TEST_CASE_ST(ut_setup, ut_teardown,
10181 test_null_auth_only_operation),
10182 TEST_CASE_ST(ut_setup, ut_teardown,
10183 test_null_cipher_only_operation),
10184 TEST_CASE_ST(ut_setup, ut_teardown,
10185 test_null_cipher_auth_operation),
10186 TEST_CASE_ST(ut_setup, ut_teardown,
10187 test_null_auth_cipher_operation),
10188 TEST_CASE_ST(ut_setup, ut_teardown,
10189 test_null_invalid_operation),
10190 TEST_CASE_ST(ut_setup, ut_teardown,
10191 test_null_burst_operation),
10193 TEST_CASES_END() /**< NULL terminate unit test array */
10197 static struct unit_test_suite cryptodev_armv8_testsuite = {
10198 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
10199 .setup = testsuite_setup,
10200 .teardown = testsuite_teardown,
10201 .unit_test_cases = {
10202 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
10204 /** Negative tests */
10205 TEST_CASE_ST(ut_setup, ut_teardown,
10206 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10207 TEST_CASE_ST(ut_setup, ut_teardown,
10208 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10210 TEST_CASES_END() /**< NULL terminate unit test array */
10214 static struct unit_test_suite cryptodev_mrvl_testsuite = {
10215 .suite_name = "Crypto Device Marvell Component Test Suite",
10216 .setup = testsuite_setup,
10217 .teardown = testsuite_teardown,
10218 .unit_test_cases = {
10219 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10220 TEST_CASE_ST(ut_setup, ut_teardown,
10221 test_multi_session_random_usage),
10222 TEST_CASE_ST(ut_setup, ut_teardown,
10223 test_AES_chain_mrvl_all),
10224 TEST_CASE_ST(ut_setup, ut_teardown,
10225 test_AES_cipheronly_mrvl_all),
10226 TEST_CASE_ST(ut_setup, ut_teardown,
10227 test_authonly_mrvl_all),
10228 TEST_CASE_ST(ut_setup, ut_teardown,
10229 test_3DES_chain_mrvl_all),
10230 TEST_CASE_ST(ut_setup, ut_teardown,
10231 test_3DES_cipheronly_mrvl_all),
10233 /** Negative tests */
10234 TEST_CASE_ST(ut_setup, ut_teardown,
10235 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10236 TEST_CASE_ST(ut_setup, ut_teardown,
10237 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10238 TEST_CASE_ST(ut_setup, ut_teardown,
10239 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10240 TEST_CASE_ST(ut_setup, ut_teardown,
10241 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10243 TEST_CASES_END() /**< NULL terminate unit test array */
10247 static struct unit_test_suite cryptodev_ccp_testsuite = {
10248 .suite_name = "Crypto Device CCP Unit Test Suite",
10249 .setup = testsuite_setup,
10250 .teardown = testsuite_teardown,
10251 .unit_test_cases = {
10252 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
10253 TEST_CASE_ST(ut_setup, ut_teardown,
10254 test_multi_session_random_usage),
10255 TEST_CASE_ST(ut_setup, ut_teardown,
10256 test_AES_chain_ccp_all),
10257 TEST_CASE_ST(ut_setup, ut_teardown,
10258 test_AES_cipheronly_ccp_all),
10259 TEST_CASE_ST(ut_setup, ut_teardown,
10260 test_3DES_chain_ccp_all),
10261 TEST_CASE_ST(ut_setup, ut_teardown,
10262 test_3DES_cipheronly_ccp_all),
10263 TEST_CASE_ST(ut_setup, ut_teardown,
10264 test_authonly_ccp_all),
10266 /** Negative tests */
10267 TEST_CASE_ST(ut_setup, ut_teardown,
10268 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10269 TEST_CASE_ST(ut_setup, ut_teardown,
10270 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10271 TEST_CASE_ST(ut_setup, ut_teardown,
10272 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10273 TEST_CASE_ST(ut_setup, ut_teardown,
10274 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10276 TEST_CASES_END() /**< NULL terminate unit test array */
10280 static struct unit_test_suite cryptodev_octeontx_testsuite = {
10281 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
10282 .setup = testsuite_setup,
10283 .teardown = testsuite_teardown,
10284 .unit_test_cases = {
10285 TEST_CASE_ST(ut_setup, ut_teardown,
10286 test_AES_chain_octeontx_all),
10287 TEST_CASE_ST(ut_setup, ut_teardown,
10288 test_AES_cipheronly_octeontx_all),
10289 TEST_CASE_ST(ut_setup, ut_teardown,
10290 test_3DES_chain_octeontx_all),
10291 TEST_CASE_ST(ut_setup, ut_teardown,
10292 test_3DES_cipheronly_octeontx_all),
10293 TEST_CASE_ST(ut_setup, ut_teardown,
10294 test_authonly_octeontx_all),
10296 /** AES GCM Authenticated Encryption */
10297 TEST_CASE_ST(ut_setup, ut_teardown,
10298 test_AES_GCM_authenticated_encryption_test_case_1),
10299 TEST_CASE_ST(ut_setup, ut_teardown,
10300 test_AES_GCM_authenticated_encryption_test_case_2),
10301 TEST_CASE_ST(ut_setup, ut_teardown,
10302 test_AES_GCM_authenticated_encryption_test_case_3),
10303 TEST_CASE_ST(ut_setup, ut_teardown,
10304 test_AES_GCM_authenticated_encryption_test_case_4),
10305 TEST_CASE_ST(ut_setup, ut_teardown,
10306 test_AES_GCM_authenticated_encryption_test_case_5),
10307 TEST_CASE_ST(ut_setup, ut_teardown,
10308 test_AES_GCM_authenticated_encryption_test_case_6),
10309 TEST_CASE_ST(ut_setup, ut_teardown,
10310 test_AES_GCM_authenticated_encryption_test_case_7),
10312 /** AES GCM Authenticated Decryption */
10313 TEST_CASE_ST(ut_setup, ut_teardown,
10314 test_AES_GCM_authenticated_decryption_test_case_1),
10315 TEST_CASE_ST(ut_setup, ut_teardown,
10316 test_AES_GCM_authenticated_decryption_test_case_2),
10317 TEST_CASE_ST(ut_setup, ut_teardown,
10318 test_AES_GCM_authenticated_decryption_test_case_3),
10319 TEST_CASE_ST(ut_setup, ut_teardown,
10320 test_AES_GCM_authenticated_decryption_test_case_4),
10321 TEST_CASE_ST(ut_setup, ut_teardown,
10322 test_AES_GCM_authenticated_decryption_test_case_5),
10323 TEST_CASE_ST(ut_setup, ut_teardown,
10324 test_AES_GCM_authenticated_decryption_test_case_6),
10325 TEST_CASE_ST(ut_setup, ut_teardown,
10326 test_AES_GCM_authenticated_decryption_test_case_7),
10327 /** AES GMAC Authentication */
10328 TEST_CASE_ST(ut_setup, ut_teardown,
10329 test_AES_GMAC_authentication_test_case_1),
10330 TEST_CASE_ST(ut_setup, ut_teardown,
10331 test_AES_GMAC_authentication_verify_test_case_1),
10332 TEST_CASE_ST(ut_setup, ut_teardown,
10333 test_AES_GMAC_authentication_test_case_2),
10334 TEST_CASE_ST(ut_setup, ut_teardown,
10335 test_AES_GMAC_authentication_verify_test_case_2),
10336 TEST_CASE_ST(ut_setup, ut_teardown,
10337 test_AES_GMAC_authentication_test_case_3),
10338 TEST_CASE_ST(ut_setup, ut_teardown,
10339 test_AES_GMAC_authentication_verify_test_case_3),
10341 /** SNOW 3G encrypt only (UEA2) */
10342 TEST_CASE_ST(ut_setup, ut_teardown,
10343 test_snow3g_encryption_test_case_1),
10344 TEST_CASE_ST(ut_setup, ut_teardown,
10345 test_snow3g_encryption_test_case_2),
10346 TEST_CASE_ST(ut_setup, ut_teardown,
10347 test_snow3g_encryption_test_case_3),
10348 TEST_CASE_ST(ut_setup, ut_teardown,
10349 test_snow3g_encryption_test_case_4),
10350 TEST_CASE_ST(ut_setup, ut_teardown,
10351 test_snow3g_encryption_test_case_5),
10353 TEST_CASE_ST(ut_setup, ut_teardown,
10354 test_snow3g_encryption_test_case_1_oop),
10355 TEST_CASE_ST(ut_setup, ut_teardown,
10356 test_snow3g_decryption_test_case_1_oop),
10357 TEST_CASE_ST(ut_setup, ut_teardown,
10358 test_snow3g_encryption_test_case_1_oop_sgl),
10360 /** SNOW 3G decrypt only (UEA2) */
10361 TEST_CASE_ST(ut_setup, ut_teardown,
10362 test_snow3g_decryption_test_case_1),
10363 TEST_CASE_ST(ut_setup, ut_teardown,
10364 test_snow3g_decryption_test_case_2),
10365 TEST_CASE_ST(ut_setup, ut_teardown,
10366 test_snow3g_decryption_test_case_3),
10367 TEST_CASE_ST(ut_setup, ut_teardown,
10368 test_snow3g_decryption_test_case_4),
10369 TEST_CASE_ST(ut_setup, ut_teardown,
10370 test_snow3g_decryption_test_case_5),
10372 TEST_CASE_ST(ut_setup, ut_teardown,
10373 test_snow3g_hash_generate_test_case_1),
10374 TEST_CASE_ST(ut_setup, ut_teardown,
10375 test_snow3g_hash_generate_test_case_2),
10376 TEST_CASE_ST(ut_setup, ut_teardown,
10377 test_snow3g_hash_generate_test_case_3),
10378 TEST_CASE_ST(ut_setup, ut_teardown,
10379 test_snow3g_hash_verify_test_case_1),
10380 TEST_CASE_ST(ut_setup, ut_teardown,
10381 test_snow3g_hash_verify_test_case_2),
10382 TEST_CASE_ST(ut_setup, ut_teardown,
10383 test_snow3g_hash_verify_test_case_3),
10385 /** ZUC encrypt only (EEA3) */
10386 TEST_CASE_ST(ut_setup, ut_teardown,
10387 test_zuc_encryption_test_case_1),
10388 TEST_CASE_ST(ut_setup, ut_teardown,
10389 test_zuc_encryption_test_case_2),
10390 TEST_CASE_ST(ut_setup, ut_teardown,
10391 test_zuc_encryption_test_case_3),
10392 TEST_CASE_ST(ut_setup, ut_teardown,
10393 test_zuc_encryption_test_case_4),
10394 TEST_CASE_ST(ut_setup, ut_teardown,
10395 test_zuc_encryption_test_case_5),
10396 TEST_CASE_ST(ut_setup, ut_teardown,
10397 test_zuc_hash_generate_test_case_1),
10398 TEST_CASE_ST(ut_setup, ut_teardown,
10399 test_zuc_hash_generate_test_case_2),
10400 TEST_CASE_ST(ut_setup, ut_teardown,
10401 test_zuc_hash_generate_test_case_3),
10402 TEST_CASE_ST(ut_setup, ut_teardown,
10403 test_zuc_hash_generate_test_case_4),
10404 TEST_CASE_ST(ut_setup, ut_teardown,
10405 test_zuc_hash_generate_test_case_5),
10406 TEST_CASE_ST(ut_setup, ut_teardown,
10407 test_zuc_encryption_test_case_6_sgl),
10409 /** KASUMI encrypt only (UEA1) */
10410 TEST_CASE_ST(ut_setup, ut_teardown,
10411 test_kasumi_encryption_test_case_1),
10412 TEST_CASE_ST(ut_setup, ut_teardown,
10413 test_kasumi_encryption_test_case_2),
10414 TEST_CASE_ST(ut_setup, ut_teardown,
10415 test_kasumi_encryption_test_case_3),
10416 TEST_CASE_ST(ut_setup, ut_teardown,
10417 test_kasumi_encryption_test_case_4),
10418 TEST_CASE_ST(ut_setup, ut_teardown,
10419 test_kasumi_encryption_test_case_5),
10420 TEST_CASE_ST(ut_setup, ut_teardown,
10421 test_kasumi_encryption_test_case_1_sgl),
10422 TEST_CASE_ST(ut_setup, ut_teardown,
10423 test_kasumi_encryption_test_case_1_oop_sgl),
10424 /** KASUMI decrypt only (UEA1) */
10425 TEST_CASE_ST(ut_setup, ut_teardown,
10426 test_kasumi_decryption_test_case_1),
10427 TEST_CASE_ST(ut_setup, ut_teardown,
10428 test_kasumi_decryption_test_case_2),
10429 TEST_CASE_ST(ut_setup, ut_teardown,
10430 test_kasumi_decryption_test_case_3),
10431 TEST_CASE_ST(ut_setup, ut_teardown,
10432 test_kasumi_decryption_test_case_4),
10433 TEST_CASE_ST(ut_setup, ut_teardown,
10434 test_kasumi_decryption_test_case_5),
10436 TEST_CASE_ST(ut_setup, ut_teardown,
10437 test_kasumi_encryption_test_case_1_oop),
10438 TEST_CASE_ST(ut_setup, ut_teardown,
10439 test_kasumi_decryption_test_case_1_oop),
10441 /** KASUMI hash only (UIA1) */
10442 TEST_CASE_ST(ut_setup, ut_teardown,
10443 test_kasumi_hash_generate_test_case_1),
10444 TEST_CASE_ST(ut_setup, ut_teardown,
10445 test_kasumi_hash_generate_test_case_2),
10446 TEST_CASE_ST(ut_setup, ut_teardown,
10447 test_kasumi_hash_generate_test_case_3),
10448 TEST_CASE_ST(ut_setup, ut_teardown,
10449 test_kasumi_hash_generate_test_case_4),
10450 TEST_CASE_ST(ut_setup, ut_teardown,
10451 test_kasumi_hash_generate_test_case_5),
10452 TEST_CASE_ST(ut_setup, ut_teardown,
10453 test_kasumi_hash_generate_test_case_6),
10454 TEST_CASE_ST(ut_setup, ut_teardown,
10455 test_kasumi_hash_verify_test_case_1),
10456 TEST_CASE_ST(ut_setup, ut_teardown,
10457 test_kasumi_hash_verify_test_case_2),
10458 TEST_CASE_ST(ut_setup, ut_teardown,
10459 test_kasumi_hash_verify_test_case_3),
10460 TEST_CASE_ST(ut_setup, ut_teardown,
10461 test_kasumi_hash_verify_test_case_4),
10462 TEST_CASE_ST(ut_setup, ut_teardown,
10463 test_kasumi_hash_verify_test_case_5),
10466 TEST_CASE_ST(ut_setup, ut_teardown,
10467 test_null_cipher_only_operation),
10468 TEST_CASE_ST(ut_setup, ut_teardown,
10469 test_null_auth_only_operation),
10470 TEST_CASE_ST(ut_setup, ut_teardown,
10471 test_null_cipher_auth_operation),
10472 TEST_CASE_ST(ut_setup, ut_teardown,
10473 test_null_auth_cipher_operation),
10475 /** Negative tests */
10476 TEST_CASE_ST(ut_setup, ut_teardown,
10477 authentication_verify_HMAC_SHA1_fail_data_corrupt),
10478 TEST_CASE_ST(ut_setup, ut_teardown,
10479 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
10480 TEST_CASE_ST(ut_setup, ut_teardown,
10481 authentication_verify_AES128_GMAC_fail_data_corrupt),
10482 TEST_CASE_ST(ut_setup, ut_teardown,
10483 authentication_verify_AES128_GMAC_fail_tag_corrupt),
10484 TEST_CASE_ST(ut_setup, ut_teardown,
10485 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
10486 TEST_CASE_ST(ut_setup, ut_teardown,
10487 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
10488 TEST_CASES_END() /**< NULL terminate unit test array */
10493 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
10495 gbl_driver_id = rte_cryptodev_driver_id_get(
10496 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
10498 if (gbl_driver_id == -1) {
10499 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
10500 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
10501 "are enabled in config file to run this testsuite.\n");
10502 return TEST_SKIPPED;
10505 return unit_test_suite_runner(&cryptodev_qat_testsuite);
10509 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
10511 gbl_driver_id = rte_cryptodev_driver_id_get(
10512 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
10514 if (gbl_driver_id == -1) {
10515 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
10516 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
10517 "in config file to run this testsuite.\n");
10518 return TEST_FAILED;
10521 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
10525 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
10527 gbl_driver_id = rte_cryptodev_driver_id_get(
10528 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
10530 if (gbl_driver_id == -1) {
10531 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
10532 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
10533 "in config file to run this testsuite.\n");
10534 return TEST_SKIPPED;
10537 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
10541 test_cryptodev_openssl(void)
10543 gbl_driver_id = rte_cryptodev_driver_id_get(
10544 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
10546 if (gbl_driver_id == -1) {
10547 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
10548 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
10549 "in config file to run this testsuite.\n");
10550 return TEST_SKIPPED;
10553 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
10557 test_cryptodev_aesni_gcm(void)
10559 gbl_driver_id = rte_cryptodev_driver_id_get(
10560 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
10562 if (gbl_driver_id == -1) {
10563 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
10564 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
10565 "in config file to run this testsuite.\n");
10566 return TEST_SKIPPED;
10569 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10573 test_cryptodev_null(void)
10575 gbl_driver_id = rte_cryptodev_driver_id_get(
10576 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10578 if (gbl_driver_id == -1) {
10579 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10580 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10581 "in config file to run this testsuite.\n");
10582 return TEST_SKIPPED;
10585 return unit_test_suite_runner(&cryptodev_null_testsuite);
10589 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10591 gbl_driver_id = rte_cryptodev_driver_id_get(
10592 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10594 if (gbl_driver_id == -1) {
10595 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10596 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10597 "in config file to run this testsuite.\n");
10598 return TEST_SKIPPED;
10601 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10605 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10607 gbl_driver_id = rte_cryptodev_driver_id_get(
10608 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10610 if (gbl_driver_id == -1) {
10611 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10612 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10613 "in config file to run this testsuite.\n");
10614 return TEST_SKIPPED;
10617 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10621 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10623 gbl_driver_id = rte_cryptodev_driver_id_get(
10624 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10626 if (gbl_driver_id == -1) {
10627 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10628 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10629 "in config file to run this testsuite.\n");
10630 return TEST_SKIPPED;
10633 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10637 test_cryptodev_armv8(void)
10639 gbl_driver_id = rte_cryptodev_driver_id_get(
10640 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10642 if (gbl_driver_id == -1) {
10643 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10644 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10645 "in config file to run this testsuite.\n");
10646 return TEST_SKIPPED;
10649 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10653 test_cryptodev_mrvl(void)
10655 gbl_driver_id = rte_cryptodev_driver_id_get(
10656 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10658 if (gbl_driver_id == -1) {
10659 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10660 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10661 "in config file to run this testsuite.\n");
10662 return TEST_SKIPPED;
10665 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10668 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10671 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10673 gbl_driver_id = rte_cryptodev_driver_id_get(
10674 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10676 if (gbl_driver_id == -1) {
10677 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10678 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10679 "in config file to run this testsuite.\n");
10680 return TEST_SKIPPED;
10683 if (rte_cryptodev_driver_id_get(
10684 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10685 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10686 " enabled in config file to run this testsuite.\n");
10687 return TEST_SKIPPED;
10689 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10692 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10697 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10699 gbl_driver_id = rte_cryptodev_driver_id_get(
10700 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10702 if (gbl_driver_id == -1) {
10703 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10704 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10705 "in config file to run this testsuite.\n");
10706 return TEST_SKIPPED;
10709 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10713 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10715 gbl_driver_id = rte_cryptodev_driver_id_get(
10716 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10718 if (gbl_driver_id == -1) {
10719 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10720 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10721 "in config file to run this testsuite.\n");
10722 return TEST_SKIPPED;
10725 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10729 test_cryptodev_ccp(void)
10731 gbl_driver_id = rte_cryptodev_driver_id_get(
10732 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10734 if (gbl_driver_id == -1) {
10735 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10736 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10737 "in config file to run this testsuite.\n");
10738 return TEST_FAILED;
10741 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10745 test_cryptodev_octeontx(void)
10747 gbl_driver_id = rte_cryptodev_driver_id_get(
10748 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
10749 if (gbl_driver_id == -1) {
10750 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
10751 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
10752 "enabled in config file to run this "
10754 return TEST_FAILED;
10756 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
10760 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
10762 gbl_driver_id = rte_cryptodev_driver_id_get(
10763 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
10765 if (gbl_driver_id == -1) {
10766 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
10767 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
10768 "in config file to run this testsuite.\n");
10769 return TEST_FAILED;
10772 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
10775 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10776 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10777 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10778 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10779 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10780 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10781 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10782 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10783 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10784 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10785 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10786 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10787 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10788 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
10789 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
10790 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);