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>
19 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
20 #include <rte_cryptodev_scheduler.h>
21 #include <rte_cryptodev_scheduler_operations.h>
25 #include "test_cryptodev.h"
27 #include "test_cryptodev_blockcipher.h"
28 #include "test_cryptodev_aes_test_vectors.h"
29 #include "test_cryptodev_des_test_vectors.h"
30 #include "test_cryptodev_hash_test_vectors.h"
31 #include "test_cryptodev_kasumi_test_vectors.h"
32 #include "test_cryptodev_kasumi_hash_test_vectors.h"
33 #include "test_cryptodev_snow3g_test_vectors.h"
34 #include "test_cryptodev_snow3g_hash_test_vectors.h"
35 #include "test_cryptodev_zuc_test_vectors.h"
36 #include "test_cryptodev_aead_test_vectors.h"
37 #include "test_cryptodev_hmac_test_vectors.h"
39 static int gbl_driver_id;
41 struct crypto_testsuite_params {
42 struct rte_mempool *mbuf_pool;
43 struct rte_mempool *large_mbuf_pool;
44 struct rte_mempool *op_mpool;
45 struct rte_mempool *session_mpool;
46 struct rte_cryptodev_config conf;
47 struct rte_cryptodev_qp_conf qp_conf;
49 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
50 uint8_t valid_dev_count;
53 struct crypto_unittest_params {
54 struct rte_crypto_sym_xform cipher_xform;
55 struct rte_crypto_sym_xform auth_xform;
56 struct rte_crypto_sym_xform aead_xform;
58 struct rte_cryptodev_sym_session *sess;
60 struct rte_crypto_op *op;
62 struct rte_mbuf *obuf, *ibuf;
67 #define ALIGN_POW2_ROUNDUP(num, align) \
68 (((num) + (align) - 1) & ~((align) - 1))
71 * Forward declarations.
74 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
75 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
79 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
80 struct crypto_unittest_params *ut_params,
81 struct crypto_testsuite_params *ts_param,
82 const uint8_t *cipher,
83 const uint8_t *digest,
86 static struct rte_mbuf *
87 setup_test_string(struct rte_mempool *mpool,
88 const char *string, size_t len, uint8_t blocksize)
90 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
91 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
93 memset(m->buf_addr, 0, m->buf_len);
95 char *dst = rte_pktmbuf_append(m, t_len);
102 rte_memcpy(dst, string, t_len);
104 memset(dst, 0, t_len);
110 /* Get number of bytes in X bits (rounding up) */
112 ceil_byte_length(uint32_t num_bits)
115 return ((num_bits >> 3) + 1);
117 return (num_bits >> 3);
120 static struct rte_crypto_op *
121 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
123 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
124 printf("Error sending packet for encryption");
130 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
136 static struct crypto_testsuite_params testsuite_params = { NULL };
137 static struct crypto_unittest_params unittest_params;
140 testsuite_setup(void)
142 struct crypto_testsuite_params *ts_params = &testsuite_params;
143 struct rte_cryptodev_info info;
144 uint32_t i = 0, nb_devs, dev_id;
148 memset(ts_params, 0, sizeof(*ts_params));
150 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
151 if (ts_params->mbuf_pool == NULL) {
152 /* Not already created so create */
153 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
155 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
157 if (ts_params->mbuf_pool == NULL) {
158 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
163 ts_params->large_mbuf_pool = rte_mempool_lookup(
164 "CRYPTO_LARGE_MBUFPOOL");
165 if (ts_params->large_mbuf_pool == NULL) {
166 /* Not already created so create */
167 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
168 "CRYPTO_LARGE_MBUFPOOL",
171 if (ts_params->large_mbuf_pool == NULL) {
173 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
178 ts_params->op_mpool = rte_crypto_op_pool_create(
179 "MBUF_CRYPTO_SYM_OP_POOL",
180 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
181 NUM_MBUFS, MBUF_CACHE_SIZE,
183 sizeof(struct rte_crypto_sym_xform) +
186 if (ts_params->op_mpool == NULL) {
187 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
191 /* Create an AESNI MB device if required */
192 if (gbl_driver_id == rte_cryptodev_driver_id_get(
193 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
194 nb_devs = rte_cryptodev_device_count_by_driver(
195 rte_cryptodev_driver_id_get(
196 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
199 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
201 TEST_ASSERT(ret == 0,
202 "Failed to create instance of"
204 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
208 /* Create an AESNI GCM device if required */
209 if (gbl_driver_id == rte_cryptodev_driver_id_get(
210 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
211 nb_devs = rte_cryptodev_device_count_by_driver(
212 rte_cryptodev_driver_id_get(
213 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
215 TEST_ASSERT_SUCCESS(rte_vdev_init(
216 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
217 "Failed to create instance of"
219 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
223 /* Create a SNOW 3G device if required */
224 if (gbl_driver_id == rte_cryptodev_driver_id_get(
225 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
226 nb_devs = rte_cryptodev_device_count_by_driver(
227 rte_cryptodev_driver_id_get(
228 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
230 TEST_ASSERT_SUCCESS(rte_vdev_init(
231 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
232 "Failed to create instance of"
234 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
238 /* Create a KASUMI device if required */
239 if (gbl_driver_id == rte_cryptodev_driver_id_get(
240 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
241 nb_devs = rte_cryptodev_device_count_by_driver(
242 rte_cryptodev_driver_id_get(
243 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
245 TEST_ASSERT_SUCCESS(rte_vdev_init(
246 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
247 "Failed to create instance of"
249 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
253 /* Create a ZUC device if required */
254 if (gbl_driver_id == rte_cryptodev_driver_id_get(
255 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
256 nb_devs = rte_cryptodev_device_count_by_driver(
257 rte_cryptodev_driver_id_get(
258 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
260 TEST_ASSERT_SUCCESS(rte_vdev_init(
261 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
262 "Failed to create instance of"
264 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
268 /* Create a NULL device if required */
269 if (gbl_driver_id == rte_cryptodev_driver_id_get(
270 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
271 nb_devs = rte_cryptodev_device_count_by_driver(
272 rte_cryptodev_driver_id_get(
273 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
276 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
278 TEST_ASSERT(ret == 0,
279 "Failed to create instance of"
281 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
285 /* Create an OPENSSL device if required */
286 if (gbl_driver_id == rte_cryptodev_driver_id_get(
287 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
288 nb_devs = rte_cryptodev_device_count_by_driver(
289 rte_cryptodev_driver_id_get(
290 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
293 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
296 TEST_ASSERT(ret == 0, "Failed to create "
297 "instance of pmd : %s",
298 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
302 /* Create a ARMv8 device if required */
303 if (gbl_driver_id == rte_cryptodev_driver_id_get(
304 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
305 nb_devs = rte_cryptodev_device_count_by_driver(
306 rte_cryptodev_driver_id_get(
307 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
310 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
313 TEST_ASSERT(ret == 0, "Failed to create "
314 "instance of pmd : %s",
315 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
319 /* Create a MRVL device if required */
320 if (gbl_driver_id == rte_cryptodev_driver_id_get(
321 RTE_STR(CRYPTODEV_MRVL_PMD))) {
322 #ifndef RTE_LIBRTE_PMD_MRVL_CRYPTO
323 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO must be"
324 " enabled in config file to run this testsuite.\n");
327 nb_devs = rte_cryptodev_device_count_by_driver(
328 rte_cryptodev_driver_id_get(
329 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)));
332 RTE_STR(CRYPTODEV_NAME_MRVL_PMD),
335 TEST_ASSERT(ret == 0, "Failed to create "
336 "instance of pmd : %s",
337 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
341 /* Create an CCP device if required */
342 if (gbl_driver_id == rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
344 nb_devs = rte_cryptodev_device_count_by_driver(
345 rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
349 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
352 TEST_ASSERT(ret == 0, "Failed to create "
353 "instance of pmd : %s",
354 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
358 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
359 if (gbl_driver_id == rte_cryptodev_driver_id_get(
360 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
362 nb_devs = rte_cryptodev_device_count_by_driver(
363 rte_cryptodev_driver_id_get(
364 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
367 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
370 TEST_ASSERT(ret == 0,
371 "Failed to create instance %u of"
373 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
376 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
378 nb_devs = rte_cryptodev_count();
380 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
384 /* Create list of valid crypto devs */
385 for (i = 0; i < nb_devs; i++) {
386 rte_cryptodev_info_get(i, &info);
387 if (info.driver_id == gbl_driver_id)
388 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
391 if (ts_params->valid_dev_count < 1)
394 /* Set up all the qps on the first of the valid devices found */
396 dev_id = ts_params->valid_devs[0];
398 rte_cryptodev_info_get(dev_id, &info);
400 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
401 ts_params->conf.socket_id = SOCKET_ID_ANY;
403 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
406 * Create mempool with maximum number of sessions * 2,
407 * to include the session headers
409 ts_params->session_mpool = rte_mempool_create(
411 info.sym.max_nb_sessions * 2,
413 0, 0, NULL, NULL, NULL,
417 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
418 "session mempool allocation failed");
420 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
422 "Failed to configure cryptodev %u with %u qps",
423 dev_id, ts_params->conf.nb_queue_pairs);
425 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
427 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
428 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
429 dev_id, qp_id, &ts_params->qp_conf,
430 rte_cryptodev_socket_id(dev_id),
431 ts_params->session_mpool),
432 "Failed to setup queue pair %u on cryptodev %u",
440 testsuite_teardown(void)
442 struct crypto_testsuite_params *ts_params = &testsuite_params;
444 if (ts_params->mbuf_pool != NULL) {
445 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
446 rte_mempool_avail_count(ts_params->mbuf_pool));
449 if (ts_params->op_mpool != NULL) {
450 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
451 rte_mempool_avail_count(ts_params->op_mpool));
454 /* Free session mempools */
455 if (ts_params->session_mpool != NULL) {
456 rte_mempool_free(ts_params->session_mpool);
457 ts_params->session_mpool = NULL;
464 struct crypto_testsuite_params *ts_params = &testsuite_params;
465 struct crypto_unittest_params *ut_params = &unittest_params;
469 /* Clear unit test parameters before running test */
470 memset(ut_params, 0, sizeof(*ut_params));
472 /* Reconfigure device to default parameters */
473 ts_params->conf.socket_id = SOCKET_ID_ANY;
475 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
477 "Failed to configure cryptodev %u",
478 ts_params->valid_devs[0]);
480 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
481 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
482 ts_params->valid_devs[0], qp_id,
484 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
485 ts_params->session_mpool),
486 "Failed to setup queue pair %u on cryptodev %u",
487 qp_id, ts_params->valid_devs[0]);
491 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
493 /* Start the device */
494 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
495 "Failed to start cryptodev %u",
496 ts_params->valid_devs[0]);
504 struct crypto_testsuite_params *ts_params = &testsuite_params;
505 struct crypto_unittest_params *ut_params = &unittest_params;
506 struct rte_cryptodev_stats stats;
508 /* free crypto session structure */
509 if (ut_params->sess) {
510 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
512 rte_cryptodev_sym_session_free(ut_params->sess);
513 ut_params->sess = NULL;
516 /* free crypto operation structure */
518 rte_crypto_op_free(ut_params->op);
521 * free mbuf - both obuf and ibuf are usually the same,
522 * so check if they point at the same address is necessary,
523 * to avoid freeing the mbuf twice.
525 if (ut_params->obuf) {
526 rte_pktmbuf_free(ut_params->obuf);
527 if (ut_params->ibuf == ut_params->obuf)
531 if (ut_params->ibuf) {
532 rte_pktmbuf_free(ut_params->ibuf);
536 if (ts_params->mbuf_pool != NULL)
537 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
538 rte_mempool_avail_count(ts_params->mbuf_pool));
540 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
542 /* Stop the device */
543 rte_cryptodev_stop(ts_params->valid_devs[0]);
547 test_device_configure_invalid_dev_id(void)
549 struct crypto_testsuite_params *ts_params = &testsuite_params;
550 uint16_t dev_id, num_devs = 0;
552 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
553 "Need at least %d devices for test", 1);
555 /* valid dev_id values */
556 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
558 /* Stop the device in case it's started so it can be configured */
559 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
561 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
562 "Failed test for rte_cryptodev_configure: "
563 "invalid dev_num %u", dev_id);
565 /* invalid dev_id values */
568 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
569 "Failed test for rte_cryptodev_configure: "
570 "invalid dev_num %u", dev_id);
574 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
575 "Failed test for rte_cryptodev_configure:"
576 "invalid dev_num %u", dev_id);
582 test_device_configure_invalid_queue_pair_ids(void)
584 struct crypto_testsuite_params *ts_params = &testsuite_params;
585 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
587 /* Stop the device in case it's started so it can be configured */
588 rte_cryptodev_stop(ts_params->valid_devs[0]);
590 /* valid - one queue pairs */
591 ts_params->conf.nb_queue_pairs = 1;
593 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
595 "Failed to configure cryptodev: dev_id %u, qp_id %u",
596 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
599 /* valid - max value queue pairs */
600 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
602 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
604 "Failed to configure cryptodev: dev_id %u, qp_id %u",
605 ts_params->valid_devs[0],
606 ts_params->conf.nb_queue_pairs);
609 /* invalid - zero queue pairs */
610 ts_params->conf.nb_queue_pairs = 0;
612 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
614 "Failed test for rte_cryptodev_configure, dev_id %u,"
616 ts_params->valid_devs[0],
617 ts_params->conf.nb_queue_pairs);
620 /* invalid - max value supported by field queue pairs */
621 ts_params->conf.nb_queue_pairs = UINT16_MAX;
623 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
625 "Failed test for rte_cryptodev_configure, dev_id %u,"
627 ts_params->valid_devs[0],
628 ts_params->conf.nb_queue_pairs);
631 /* invalid - max value + 1 queue pairs */
632 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
634 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
636 "Failed test for rte_cryptodev_configure, dev_id %u,"
638 ts_params->valid_devs[0],
639 ts_params->conf.nb_queue_pairs);
641 /* revert to original testsuite value */
642 ts_params->conf.nb_queue_pairs = orig_nb_qps;
648 test_queue_pair_descriptor_setup(void)
650 struct crypto_testsuite_params *ts_params = &testsuite_params;
651 struct rte_cryptodev_info dev_info;
652 struct rte_cryptodev_qp_conf qp_conf = {
653 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
658 /* Stop the device in case it's started so it can be configured */
659 rte_cryptodev_stop(ts_params->valid_devs[0]);
662 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
664 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
666 "Failed to configure cryptodev %u",
667 ts_params->valid_devs[0]);
670 * Test various ring sizes on this device. memzones can't be
671 * freed so are re-used if ring is released and re-created.
673 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
675 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
676 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
677 ts_params->valid_devs[0], qp_id, &qp_conf,
678 rte_cryptodev_socket_id(
679 ts_params->valid_devs[0]),
680 ts_params->session_mpool),
682 "rte_cryptodev_queue_pair_setup: num_inflights "
683 "%u on qp %u on cryptodev %u",
684 qp_conf.nb_descriptors, qp_id,
685 ts_params->valid_devs[0]);
688 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
690 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
691 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
692 ts_params->valid_devs[0], qp_id, &qp_conf,
693 rte_cryptodev_socket_id(
694 ts_params->valid_devs[0]),
695 ts_params->session_mpool),
697 " rte_cryptodev_queue_pair_setup: num_inflights"
698 " %u on qp %u on cryptodev %u",
699 qp_conf.nb_descriptors, qp_id,
700 ts_params->valid_devs[0]);
703 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
705 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
706 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
707 ts_params->valid_devs[0], qp_id, &qp_conf,
708 rte_cryptodev_socket_id(
709 ts_params->valid_devs[0]),
710 ts_params->session_mpool),
712 "rte_cryptodev_queue_pair_setup: num_inflights"
713 " %u on qp %u on cryptodev %u",
714 qp_conf.nb_descriptors, qp_id,
715 ts_params->valid_devs[0]);
718 /* invalid number of descriptors - max supported + 2 */
719 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
721 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
722 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
723 ts_params->valid_devs[0], qp_id, &qp_conf,
724 rte_cryptodev_socket_id(
725 ts_params->valid_devs[0]),
726 ts_params->session_mpool),
727 "Unexpectedly passed test for "
728 "rte_cryptodev_queue_pair_setup:"
729 "num_inflights %u on qp %u on cryptodev %u",
730 qp_conf.nb_descriptors, qp_id,
731 ts_params->valid_devs[0]);
734 /* invalid number of descriptors - max value of parameter */
735 qp_conf.nb_descriptors = UINT32_MAX-1;
737 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
738 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
739 ts_params->valid_devs[0], qp_id, &qp_conf,
740 rte_cryptodev_socket_id(
741 ts_params->valid_devs[0]),
742 ts_params->session_mpool),
743 "Unexpectedly passed test for "
744 "rte_cryptodev_queue_pair_setup:"
745 "num_inflights %u on qp %u on cryptodev %u",
746 qp_conf.nb_descriptors, qp_id,
747 ts_params->valid_devs[0]);
750 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
752 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
753 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
754 ts_params->valid_devs[0], qp_id, &qp_conf,
755 rte_cryptodev_socket_id(
756 ts_params->valid_devs[0]),
757 ts_params->session_mpool),
759 " rte_cryptodev_queue_pair_setup:"
760 "num_inflights %u on qp %u on cryptodev %u",
761 qp_conf.nb_descriptors, qp_id,
762 ts_params->valid_devs[0]);
765 /* invalid number of descriptors - max supported + 1 */
766 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
768 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
769 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
770 ts_params->valid_devs[0], qp_id, &qp_conf,
771 rte_cryptodev_socket_id(
772 ts_params->valid_devs[0]),
773 ts_params->session_mpool),
774 "Unexpectedly passed test for "
775 "rte_cryptodev_queue_pair_setup:"
776 "num_inflights %u on qp %u on cryptodev %u",
777 qp_conf.nb_descriptors, qp_id,
778 ts_params->valid_devs[0]);
781 /* test invalid queue pair id */
782 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
784 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
786 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
787 ts_params->valid_devs[0],
789 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
790 ts_params->session_mpool),
791 "Failed test for rte_cryptodev_queue_pair_setup:"
792 "invalid qp %u on cryptodev %u",
793 qp_id, ts_params->valid_devs[0]);
795 qp_id = 0xffff; /*invalid*/
797 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
798 ts_params->valid_devs[0],
800 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
801 ts_params->session_mpool),
802 "Failed test for rte_cryptodev_queue_pair_setup:"
803 "invalid qp %u on cryptodev %u",
804 qp_id, ts_params->valid_devs[0]);
809 /* ***** Plaintext data for tests ***** */
811 const char catch_22_quote_1[] =
812 "There was only one catch and that was Catch-22, which "
813 "specified that a concern for one's safety in the face of "
814 "dangers that were real and immediate was the process of a "
815 "rational mind. Orr was crazy and could be grounded. All he "
816 "had to do was ask; and as soon as he did, he would no longer "
817 "be crazy and would have to fly more missions. Orr would be "
818 "crazy to fly more missions and sane if he didn't, but if he "
819 "was sane he had to fly them. If he flew them he was crazy "
820 "and didn't have to; but if he didn't want to he was sane and "
821 "had to. Yossarian was moved very deeply by the absolute "
822 "simplicity of this clause of Catch-22 and let out a "
823 "respectful whistle. \"That's some catch, that Catch-22\", he "
824 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
826 const char catch_22_quote[] =
827 "What a lousy earth! He wondered how many people were "
828 "destitute that same night even in his own prosperous country, "
829 "how many homes were shanties, how many husbands were drunk "
830 "and wives socked, and how many children were bullied, abused, "
831 "or abandoned. How many families hungered for food they could "
832 "not afford to buy? How many hearts were broken? How many "
833 "suicides would take place that same night, how many people "
834 "would go insane? How many cockroaches and landlords would "
835 "triumph? How many winners were losers, successes failures, "
836 "and rich men poor men? How many wise guys were stupid? How "
837 "many happy endings were unhappy endings? How many honest men "
838 "were liars, brave men cowards, loyal men traitors, how many "
839 "sainted men were corrupt, how many people in positions of "
840 "trust had sold their souls to bodyguards, how many had never "
841 "had souls? How many straight-and-narrow paths were crooked "
842 "paths? How many best families were worst families and how "
843 "many good people were bad people? When you added them all up "
844 "and then subtracted, you might be left with only the children, "
845 "and perhaps with Albert Einstein and an old violinist or "
846 "sculptor somewhere.";
848 #define QUOTE_480_BYTES (480)
849 #define QUOTE_512_BYTES (512)
850 #define QUOTE_768_BYTES (768)
851 #define QUOTE_1024_BYTES (1024)
855 /* ***** SHA1 Hash Tests ***** */
857 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
859 static uint8_t hmac_sha1_key[] = {
860 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
861 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
862 0xDE, 0xF4, 0xDE, 0xAD };
864 /* ***** SHA224 Hash Tests ***** */
866 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
869 /* ***** AES-CBC Cipher Tests ***** */
871 #define CIPHER_KEY_LENGTH_AES_CBC (16)
872 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
874 static uint8_t aes_cbc_key[] = {
875 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
876 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
878 static uint8_t aes_cbc_iv[] = {
879 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
880 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
883 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
885 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
886 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
887 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
888 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
889 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
890 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
891 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
892 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
893 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
894 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
895 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
896 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
897 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
898 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
899 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
900 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
901 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
902 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
903 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
904 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
905 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
906 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
907 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
908 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
909 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
910 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
911 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
912 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
913 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
914 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
915 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
916 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
917 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
918 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
919 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
920 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
921 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
922 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
923 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
924 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
925 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
926 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
927 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
928 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
929 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
930 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
931 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
932 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
933 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
934 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
935 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
936 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
937 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
938 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
939 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
940 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
941 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
942 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
943 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
944 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
945 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
946 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
947 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
948 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
949 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
952 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
953 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
954 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
955 0x18, 0x8c, 0x1d, 0x32
959 /* Multisession Vector context Test */
961 static uint8_t ms_aes_cbc_key0[] = {
962 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
963 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
966 static uint8_t ms_aes_cbc_iv0[] = {
967 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
968 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
971 static const uint8_t ms_aes_cbc_cipher0[] = {
972 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
973 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
974 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
975 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
976 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
977 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
978 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
979 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
980 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
981 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
982 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
983 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
984 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
985 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
986 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
987 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
988 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
989 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
990 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
991 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
992 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
993 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
994 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
995 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
996 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
997 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
998 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
999 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1000 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1001 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1002 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1003 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1004 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1005 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1006 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1007 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1008 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1009 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1010 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1011 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1012 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1013 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1014 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1015 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1016 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1017 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1018 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1019 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1020 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1021 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1022 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1023 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1024 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1025 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1026 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1027 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1028 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1029 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1030 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1031 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1032 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1033 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1034 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1035 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1039 static uint8_t ms_hmac_key0[] = {
1040 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1041 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1042 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1043 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1044 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1045 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1046 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1047 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1050 static const uint8_t ms_hmac_digest0[] = {
1051 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1052 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1053 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1054 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1055 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1056 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1057 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1058 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1062 /* Begin session 1 */
1064 static uint8_t ms_aes_cbc_key1[] = {
1065 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1066 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1069 static uint8_t ms_aes_cbc_iv1[] = {
1070 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1071 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1074 static const uint8_t ms_aes_cbc_cipher1[] = {
1075 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1076 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1077 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1078 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1079 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1080 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1081 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1082 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1083 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1084 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1085 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1086 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1087 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1088 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1089 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1090 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1091 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1092 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1093 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1094 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1095 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1096 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1097 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1098 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1099 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1100 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1101 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1102 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1103 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1104 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1105 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1106 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1107 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1108 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1109 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1110 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1111 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1112 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1113 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1114 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1115 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1116 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1117 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1118 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1119 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1120 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1121 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1122 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1123 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1124 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1125 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1126 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1127 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1128 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1129 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1130 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1131 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1132 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1133 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1134 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1135 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1136 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1137 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1138 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1142 static uint8_t ms_hmac_key1[] = {
1143 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1144 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1145 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1146 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1147 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1148 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1149 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1150 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1153 static const uint8_t ms_hmac_digest1[] = {
1154 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1155 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1156 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1157 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1158 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1159 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1160 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1161 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1164 /* Begin Session 2 */
1165 static uint8_t ms_aes_cbc_key2[] = {
1166 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1167 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1170 static uint8_t ms_aes_cbc_iv2[] = {
1171 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1172 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1175 static const uint8_t ms_aes_cbc_cipher2[] = {
1176 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1177 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1178 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1179 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1180 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1181 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1182 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1183 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1184 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1185 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1186 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1187 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1188 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1189 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1190 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1191 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1192 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1193 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1194 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1195 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1196 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1197 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1198 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1199 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1200 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1201 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1202 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1203 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1204 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1205 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1206 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1207 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1208 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1209 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1210 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1211 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1212 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1213 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1214 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1215 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1216 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1217 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1218 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1219 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1220 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1221 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1222 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1223 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1224 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1225 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1226 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1227 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1228 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1229 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1230 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1231 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1232 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1233 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1234 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1235 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1236 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1237 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1238 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1239 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1242 static uint8_t ms_hmac_key2[] = {
1243 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1244 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1245 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1246 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1247 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1248 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1249 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1250 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1253 static const uint8_t ms_hmac_digest2[] = {
1254 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1255 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1256 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1257 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1258 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1259 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1260 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1261 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1268 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1270 struct crypto_testsuite_params *ts_params = &testsuite_params;
1271 struct crypto_unittest_params *ut_params = &unittest_params;
1273 /* Generate test mbuf data and space for digest */
1274 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1275 catch_22_quote, QUOTE_512_BYTES, 0);
1277 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1278 DIGEST_BYTE_LENGTH_SHA1);
1279 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1281 /* Setup Cipher Parameters */
1282 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1283 ut_params->cipher_xform.next = &ut_params->auth_xform;
1285 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1286 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1287 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1288 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1289 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1290 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1292 /* Setup HMAC Parameters */
1293 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1295 ut_params->auth_xform.next = NULL;
1297 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1298 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1299 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1300 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1301 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1303 ut_params->sess = rte_cryptodev_sym_session_create(
1304 ts_params->session_mpool);
1306 /* Create crypto session*/
1307 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1308 ut_params->sess, &ut_params->cipher_xform,
1309 ts_params->session_mpool);
1310 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1312 /* Generate crypto op data structure */
1313 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1314 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1315 TEST_ASSERT_NOT_NULL(ut_params->op,
1316 "Failed to allocate symmetric crypto operation struct");
1318 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1320 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1322 /* set crypto operation source mbuf */
1323 sym_op->m_src = ut_params->ibuf;
1325 /* Set crypto operation authentication parameters */
1326 sym_op->auth.digest.data = ut_params->digest;
1327 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1328 ut_params->ibuf, QUOTE_512_BYTES);
1330 sym_op->auth.data.offset = 0;
1331 sym_op->auth.data.length = QUOTE_512_BYTES;
1333 /* Copy IV at the end of the crypto operation */
1334 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1335 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1337 /* Set crypto operation cipher parameters */
1338 sym_op->cipher.data.offset = 0;
1339 sym_op->cipher.data.length = QUOTE_512_BYTES;
1341 /* Process crypto operation */
1342 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1343 ut_params->op), "failed to process sym crypto op");
1345 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1346 "crypto op processing failed");
1349 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1352 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1353 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1355 "ciphertext data not as expected");
1357 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1359 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1360 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1361 gbl_driver_id == rte_cryptodev_driver_id_get(
1362 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1363 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1364 DIGEST_BYTE_LENGTH_SHA1,
1365 "Generated digest data not as expected");
1367 return TEST_SUCCESS;
1370 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1372 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1374 static uint8_t hmac_sha512_key[] = {
1375 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1376 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1377 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1378 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1379 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1380 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1381 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1382 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1384 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1385 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1386 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1387 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1388 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1389 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1390 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1391 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1392 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1397 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1398 struct crypto_unittest_params *ut_params,
1399 uint8_t *cipher_key,
1403 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1404 struct crypto_unittest_params *ut_params,
1405 struct crypto_testsuite_params *ts_params,
1406 const uint8_t *cipher,
1407 const uint8_t *digest,
1412 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1413 struct crypto_unittest_params *ut_params,
1414 uint8_t *cipher_key,
1418 /* Setup Cipher Parameters */
1419 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1420 ut_params->cipher_xform.next = NULL;
1422 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1423 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1424 ut_params->cipher_xform.cipher.key.data = cipher_key;
1425 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1426 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1427 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1429 /* Setup HMAC Parameters */
1430 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1431 ut_params->auth_xform.next = &ut_params->cipher_xform;
1433 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1434 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1435 ut_params->auth_xform.auth.key.data = hmac_key;
1436 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1437 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1439 return TEST_SUCCESS;
1444 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1445 struct crypto_unittest_params *ut_params,
1446 struct crypto_testsuite_params *ts_params,
1447 const uint8_t *cipher,
1448 const uint8_t *digest,
1451 /* Generate test mbuf data and digest */
1452 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1455 QUOTE_512_BYTES, 0);
1457 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1458 DIGEST_BYTE_LENGTH_SHA512);
1459 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1461 rte_memcpy(ut_params->digest,
1463 DIGEST_BYTE_LENGTH_SHA512);
1465 /* Generate Crypto op data structure */
1466 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1467 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1468 TEST_ASSERT_NOT_NULL(ut_params->op,
1469 "Failed to allocate symmetric crypto operation struct");
1471 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1473 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1475 /* set crypto operation source mbuf */
1476 sym_op->m_src = ut_params->ibuf;
1478 sym_op->auth.digest.data = ut_params->digest;
1479 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1480 ut_params->ibuf, QUOTE_512_BYTES);
1482 sym_op->auth.data.offset = 0;
1483 sym_op->auth.data.length = QUOTE_512_BYTES;
1485 /* Copy IV at the end of the crypto operation */
1486 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1487 iv, CIPHER_IV_LENGTH_AES_CBC);
1489 sym_op->cipher.data.offset = 0;
1490 sym_op->cipher.data.length = QUOTE_512_BYTES;
1492 /* Process crypto operation */
1493 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1494 ut_params->op), "failed to process sym crypto op");
1496 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1497 "crypto op processing failed");
1499 ut_params->obuf = ut_params->op->sym->m_src;
1502 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1503 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1506 "Plaintext data not as expected");
1509 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1510 "Digest verification failed");
1512 return TEST_SUCCESS;
1516 test_AES_cipheronly_mb_all(void)
1518 struct crypto_testsuite_params *ts_params = &testsuite_params;
1521 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1522 ts_params->op_mpool,
1523 ts_params->session_mpool,
1524 ts_params->valid_devs[0],
1525 rte_cryptodev_driver_id_get(
1526 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1527 BLKCIPHER_AES_CIPHERONLY_TYPE);
1529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1531 return TEST_SUCCESS;
1535 test_AES_docsis_mb_all(void)
1537 struct crypto_testsuite_params *ts_params = &testsuite_params;
1540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1541 ts_params->op_mpool,
1542 ts_params->session_mpool,
1543 ts_params->valid_devs[0],
1544 rte_cryptodev_driver_id_get(
1545 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1546 BLKCIPHER_AES_DOCSIS_TYPE);
1548 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1550 return TEST_SUCCESS;
1554 test_AES_docsis_qat_all(void)
1556 struct crypto_testsuite_params *ts_params = &testsuite_params;
1559 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1560 ts_params->op_mpool,
1561 ts_params->session_mpool,
1562 ts_params->valid_devs[0],
1563 rte_cryptodev_driver_id_get(
1564 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1565 BLKCIPHER_AES_DOCSIS_TYPE);
1567 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1569 return TEST_SUCCESS;
1573 test_DES_docsis_qat_all(void)
1575 struct crypto_testsuite_params *ts_params = &testsuite_params;
1578 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1579 ts_params->op_mpool,
1580 ts_params->session_mpool,
1581 ts_params->valid_devs[0],
1582 rte_cryptodev_driver_id_get(
1583 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1584 BLKCIPHER_DES_DOCSIS_TYPE);
1586 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1588 return TEST_SUCCESS;
1592 test_authonly_mb_all(void)
1594 struct crypto_testsuite_params *ts_params = &testsuite_params;
1597 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1598 ts_params->op_mpool,
1599 ts_params->session_mpool,
1600 ts_params->valid_devs[0],
1601 rte_cryptodev_driver_id_get(
1602 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1603 BLKCIPHER_AUTHONLY_TYPE);
1605 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1607 return TEST_SUCCESS;
1611 test_authonly_qat_all(void)
1613 struct crypto_testsuite_params *ts_params = &testsuite_params;
1616 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1617 ts_params->op_mpool,
1618 ts_params->session_mpool,
1619 ts_params->valid_devs[0],
1620 rte_cryptodev_driver_id_get(
1621 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1622 BLKCIPHER_AUTHONLY_TYPE);
1624 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1626 return TEST_SUCCESS;
1629 test_AES_chain_mb_all(void)
1631 struct crypto_testsuite_params *ts_params = &testsuite_params;
1634 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1635 ts_params->op_mpool,
1636 ts_params->session_mpool,
1637 ts_params->valid_devs[0],
1638 rte_cryptodev_driver_id_get(
1639 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1640 BLKCIPHER_AES_CHAIN_TYPE);
1642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1644 return TEST_SUCCESS;
1647 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1650 test_AES_cipheronly_scheduler_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_SCHEDULER_PMD)),
1661 BLKCIPHER_AES_CIPHERONLY_TYPE);
1663 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1665 return TEST_SUCCESS;
1669 test_AES_chain_scheduler_all(void)
1671 struct crypto_testsuite_params *ts_params = &testsuite_params;
1674 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1675 ts_params->op_mpool,
1676 ts_params->session_mpool,
1677 ts_params->valid_devs[0],
1678 rte_cryptodev_driver_id_get(
1679 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1680 BLKCIPHER_AES_CHAIN_TYPE);
1682 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1684 return TEST_SUCCESS;
1688 test_authonly_scheduler_all(void)
1690 struct crypto_testsuite_params *ts_params = &testsuite_params;
1693 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1694 ts_params->op_mpool,
1695 ts_params->session_mpool,
1696 ts_params->valid_devs[0],
1697 rte_cryptodev_driver_id_get(
1698 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1699 BLKCIPHER_AUTHONLY_TYPE);
1701 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1703 return TEST_SUCCESS;
1706 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1709 test_AES_chain_openssl_all(void)
1711 struct crypto_testsuite_params *ts_params = &testsuite_params;
1714 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1715 ts_params->op_mpool,
1716 ts_params->session_mpool,
1717 ts_params->valid_devs[0],
1718 rte_cryptodev_driver_id_get(
1719 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1720 BLKCIPHER_AES_CHAIN_TYPE);
1722 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1724 return TEST_SUCCESS;
1728 test_AES_cipheronly_openssl_all(void)
1730 struct crypto_testsuite_params *ts_params = &testsuite_params;
1733 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1734 ts_params->op_mpool,
1735 ts_params->session_mpool,
1736 ts_params->valid_devs[0],
1737 rte_cryptodev_driver_id_get(
1738 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1739 BLKCIPHER_AES_CIPHERONLY_TYPE);
1741 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1743 return TEST_SUCCESS;
1747 test_AES_chain_ccp_all(void)
1749 struct crypto_testsuite_params *ts_params = &testsuite_params;
1752 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1753 ts_params->op_mpool,
1754 ts_params->session_mpool,
1755 ts_params->valid_devs[0],
1756 rte_cryptodev_driver_id_get(
1757 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1758 BLKCIPHER_AES_CHAIN_TYPE);
1760 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1762 return TEST_SUCCESS;
1766 test_AES_cipheronly_ccp_all(void)
1768 struct crypto_testsuite_params *ts_params = &testsuite_params;
1771 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1772 ts_params->op_mpool,
1773 ts_params->session_mpool,
1774 ts_params->valid_devs[0],
1775 rte_cryptodev_driver_id_get(
1776 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1777 BLKCIPHER_AES_CIPHERONLY_TYPE);
1779 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1781 return TEST_SUCCESS;
1785 test_AES_chain_qat_all(void)
1787 struct crypto_testsuite_params *ts_params = &testsuite_params;
1790 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1791 ts_params->op_mpool,
1792 ts_params->session_mpool,
1793 ts_params->valid_devs[0],
1794 rte_cryptodev_driver_id_get(
1795 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1796 BLKCIPHER_AES_CHAIN_TYPE);
1798 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1800 return TEST_SUCCESS;
1804 test_AES_cipheronly_qat_all(void)
1806 struct crypto_testsuite_params *ts_params = &testsuite_params;
1809 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1810 ts_params->op_mpool,
1811 ts_params->session_mpool,
1812 ts_params->valid_devs[0],
1813 rte_cryptodev_driver_id_get(
1814 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1815 BLKCIPHER_AES_CIPHERONLY_TYPE);
1817 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1819 return TEST_SUCCESS;
1823 test_AES_chain_dpaa_sec_all(void)
1825 struct crypto_testsuite_params *ts_params = &testsuite_params;
1828 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1829 ts_params->op_mpool,
1830 ts_params->session_mpool,
1831 ts_params->valid_devs[0],
1832 rte_cryptodev_driver_id_get(
1833 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1834 BLKCIPHER_AES_CHAIN_TYPE);
1836 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1838 return TEST_SUCCESS;
1842 test_AES_cipheronly_dpaa_sec_all(void)
1844 struct crypto_testsuite_params *ts_params = &testsuite_params;
1847 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1848 ts_params->op_mpool,
1849 ts_params->session_mpool,
1850 ts_params->valid_devs[0],
1851 rte_cryptodev_driver_id_get(
1852 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1853 BLKCIPHER_AES_CIPHERONLY_TYPE);
1855 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1857 return TEST_SUCCESS;
1861 test_authonly_dpaa_sec_all(void)
1863 struct crypto_testsuite_params *ts_params = &testsuite_params;
1866 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1867 ts_params->op_mpool,
1868 ts_params->session_mpool,
1869 ts_params->valid_devs[0],
1870 rte_cryptodev_driver_id_get(
1871 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1872 BLKCIPHER_AUTHONLY_TYPE);
1874 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1876 return TEST_SUCCESS;
1880 test_AES_chain_dpaa2_sec_all(void)
1882 struct crypto_testsuite_params *ts_params = &testsuite_params;
1885 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1886 ts_params->op_mpool,
1887 ts_params->session_mpool,
1888 ts_params->valid_devs[0],
1889 rte_cryptodev_driver_id_get(
1890 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1891 BLKCIPHER_AES_CHAIN_TYPE);
1893 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1895 return TEST_SUCCESS;
1899 test_AES_cipheronly_dpaa2_sec_all(void)
1901 struct crypto_testsuite_params *ts_params = &testsuite_params;
1904 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1905 ts_params->op_mpool,
1906 ts_params->session_mpool,
1907 ts_params->valid_devs[0],
1908 rte_cryptodev_driver_id_get(
1909 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1910 BLKCIPHER_AES_CIPHERONLY_TYPE);
1912 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1914 return TEST_SUCCESS;
1918 test_authonly_dpaa2_sec_all(void)
1920 struct crypto_testsuite_params *ts_params = &testsuite_params;
1923 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1924 ts_params->op_mpool,
1925 ts_params->session_mpool,
1926 ts_params->valid_devs[0],
1927 rte_cryptodev_driver_id_get(
1928 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1929 BLKCIPHER_AUTHONLY_TYPE);
1931 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1933 return TEST_SUCCESS;
1937 test_authonly_openssl_all(void)
1939 struct crypto_testsuite_params *ts_params = &testsuite_params;
1942 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1943 ts_params->op_mpool,
1944 ts_params->session_mpool,
1945 ts_params->valid_devs[0],
1946 rte_cryptodev_driver_id_get(
1947 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1948 BLKCIPHER_AUTHONLY_TYPE);
1950 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1952 return TEST_SUCCESS;
1956 test_authonly_ccp_all(void)
1958 struct crypto_testsuite_params *ts_params = &testsuite_params;
1961 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1962 ts_params->op_mpool,
1963 ts_params->session_mpool,
1964 ts_params->valid_devs[0],
1965 rte_cryptodev_driver_id_get(
1966 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1967 BLKCIPHER_AUTHONLY_TYPE);
1969 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1971 return TEST_SUCCESS;
1975 test_AES_chain_armv8_all(void)
1977 struct crypto_testsuite_params *ts_params = &testsuite_params;
1980 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1981 ts_params->op_mpool,
1982 ts_params->session_mpool,
1983 ts_params->valid_devs[0],
1984 rte_cryptodev_driver_id_get(
1985 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1986 BLKCIPHER_AES_CHAIN_TYPE);
1988 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1990 return TEST_SUCCESS;
1994 test_AES_chain_mrvl_all(void)
1996 struct crypto_testsuite_params *ts_params = &testsuite_params;
1999 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2000 ts_params->op_mpool,
2001 ts_params->session_mpool,
2002 ts_params->valid_devs[0],
2003 rte_cryptodev_driver_id_get(
2004 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2005 BLKCIPHER_AES_CHAIN_TYPE);
2007 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2009 return TEST_SUCCESS;
2013 test_AES_cipheronly_mrvl_all(void)
2015 struct crypto_testsuite_params *ts_params = &testsuite_params;
2018 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2019 ts_params->op_mpool,
2020 ts_params->session_mpool,
2021 ts_params->valid_devs[0],
2022 rte_cryptodev_driver_id_get(
2023 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2024 BLKCIPHER_AES_CIPHERONLY_TYPE);
2026 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2028 return TEST_SUCCESS;
2032 test_authonly_mrvl_all(void)
2034 struct crypto_testsuite_params *ts_params = &testsuite_params;
2037 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2038 ts_params->op_mpool,
2039 ts_params->session_mpool,
2040 ts_params->valid_devs[0],
2041 rte_cryptodev_driver_id_get(
2042 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2043 BLKCIPHER_AUTHONLY_TYPE);
2045 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2047 return TEST_SUCCESS;
2051 test_3DES_chain_mrvl_all(void)
2053 struct crypto_testsuite_params *ts_params = &testsuite_params;
2056 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2057 ts_params->op_mpool,
2058 ts_params->session_mpool,
2059 ts_params->valid_devs[0],
2060 rte_cryptodev_driver_id_get(
2061 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2062 BLKCIPHER_3DES_CHAIN_TYPE);
2064 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2066 return TEST_SUCCESS;
2070 test_3DES_cipheronly_mrvl_all(void)
2072 struct crypto_testsuite_params *ts_params = &testsuite_params;
2075 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2076 ts_params->op_mpool,
2077 ts_params->session_mpool,
2078 ts_params->valid_devs[0],
2079 rte_cryptodev_driver_id_get(
2080 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2081 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2083 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2085 return TEST_SUCCESS;
2088 /* ***** SNOW 3G Tests ***** */
2090 create_wireless_algo_hash_session(uint8_t dev_id,
2091 const uint8_t *key, const uint8_t key_len,
2092 const uint8_t iv_len, const uint8_t auth_len,
2093 enum rte_crypto_auth_operation op,
2094 enum rte_crypto_auth_algorithm algo)
2096 uint8_t hash_key[key_len];
2098 struct crypto_testsuite_params *ts_params = &testsuite_params;
2099 struct crypto_unittest_params *ut_params = &unittest_params;
2101 memcpy(hash_key, key, key_len);
2103 debug_hexdump(stdout, "key:", key, key_len);
2105 /* Setup Authentication Parameters */
2106 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2107 ut_params->auth_xform.next = NULL;
2109 ut_params->auth_xform.auth.op = op;
2110 ut_params->auth_xform.auth.algo = algo;
2111 ut_params->auth_xform.auth.key.length = key_len;
2112 ut_params->auth_xform.auth.key.data = hash_key;
2113 ut_params->auth_xform.auth.digest_length = auth_len;
2114 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2115 ut_params->auth_xform.auth.iv.length = iv_len;
2116 ut_params->sess = rte_cryptodev_sym_session_create(
2117 ts_params->session_mpool);
2119 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2120 &ut_params->auth_xform, ts_params->session_mpool);
2121 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2126 create_wireless_algo_cipher_session(uint8_t dev_id,
2127 enum rte_crypto_cipher_operation op,
2128 enum rte_crypto_cipher_algorithm algo,
2129 const uint8_t *key, const uint8_t key_len,
2132 uint8_t cipher_key[key_len];
2134 struct crypto_testsuite_params *ts_params = &testsuite_params;
2135 struct crypto_unittest_params *ut_params = &unittest_params;
2137 memcpy(cipher_key, key, key_len);
2139 /* Setup Cipher Parameters */
2140 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2141 ut_params->cipher_xform.next = NULL;
2143 ut_params->cipher_xform.cipher.algo = algo;
2144 ut_params->cipher_xform.cipher.op = op;
2145 ut_params->cipher_xform.cipher.key.data = cipher_key;
2146 ut_params->cipher_xform.cipher.key.length = key_len;
2147 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2148 ut_params->cipher_xform.cipher.iv.length = iv_len;
2150 debug_hexdump(stdout, "key:", key, key_len);
2152 /* Create Crypto session */
2153 ut_params->sess = rte_cryptodev_sym_session_create(
2154 ts_params->session_mpool);
2156 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2157 &ut_params->cipher_xform, ts_params->session_mpool);
2158 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2163 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2164 unsigned int cipher_len,
2165 unsigned int cipher_offset)
2167 struct crypto_testsuite_params *ts_params = &testsuite_params;
2168 struct crypto_unittest_params *ut_params = &unittest_params;
2170 /* Generate Crypto op data structure */
2171 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2172 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2173 TEST_ASSERT_NOT_NULL(ut_params->op,
2174 "Failed to allocate pktmbuf offload");
2176 /* Set crypto operation data parameters */
2177 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2179 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2181 /* set crypto operation source mbuf */
2182 sym_op->m_src = ut_params->ibuf;
2185 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2187 sym_op->cipher.data.length = cipher_len;
2188 sym_op->cipher.data.offset = cipher_offset;
2193 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2194 unsigned int cipher_len,
2195 unsigned int cipher_offset)
2197 struct crypto_testsuite_params *ts_params = &testsuite_params;
2198 struct crypto_unittest_params *ut_params = &unittest_params;
2200 /* Generate Crypto op data structure */
2201 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2202 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2203 TEST_ASSERT_NOT_NULL(ut_params->op,
2204 "Failed to allocate pktmbuf offload");
2206 /* Set crypto operation data parameters */
2207 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2209 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2211 /* set crypto operation source mbuf */
2212 sym_op->m_src = ut_params->ibuf;
2213 sym_op->m_dst = ut_params->obuf;
2216 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2218 sym_op->cipher.data.length = cipher_len;
2219 sym_op->cipher.data.offset = cipher_offset;
2224 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2225 enum rte_crypto_cipher_operation cipher_op,
2226 enum rte_crypto_auth_operation auth_op,
2227 enum rte_crypto_auth_algorithm auth_algo,
2228 enum rte_crypto_cipher_algorithm cipher_algo,
2229 const uint8_t *key, uint8_t key_len,
2230 uint8_t auth_iv_len, uint8_t auth_len,
2231 uint8_t cipher_iv_len)
2234 uint8_t cipher_auth_key[key_len];
2236 struct crypto_testsuite_params *ts_params = &testsuite_params;
2237 struct crypto_unittest_params *ut_params = &unittest_params;
2239 memcpy(cipher_auth_key, key, key_len);
2241 /* Setup Authentication Parameters */
2242 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2243 ut_params->auth_xform.next = NULL;
2245 ut_params->auth_xform.auth.op = auth_op;
2246 ut_params->auth_xform.auth.algo = auth_algo;
2247 ut_params->auth_xform.auth.key.length = key_len;
2248 /* Hash key = cipher key */
2249 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2250 ut_params->auth_xform.auth.digest_length = auth_len;
2251 /* Auth IV will be after cipher IV */
2252 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2253 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2255 /* Setup Cipher Parameters */
2256 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2257 ut_params->cipher_xform.next = &ut_params->auth_xform;
2259 ut_params->cipher_xform.cipher.algo = cipher_algo;
2260 ut_params->cipher_xform.cipher.op = cipher_op;
2261 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2262 ut_params->cipher_xform.cipher.key.length = key_len;
2263 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2264 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2266 debug_hexdump(stdout, "key:", key, key_len);
2268 /* Create Crypto session*/
2269 ut_params->sess = rte_cryptodev_sym_session_create(
2270 ts_params->session_mpool);
2272 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2273 &ut_params->cipher_xform, ts_params->session_mpool);
2275 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2280 create_wireless_cipher_auth_session(uint8_t dev_id,
2281 enum rte_crypto_cipher_operation cipher_op,
2282 enum rte_crypto_auth_operation auth_op,
2283 enum rte_crypto_auth_algorithm auth_algo,
2284 enum rte_crypto_cipher_algorithm cipher_algo,
2285 const struct wireless_test_data *tdata)
2287 const uint8_t key_len = tdata->key.len;
2288 uint8_t cipher_auth_key[key_len];
2290 struct crypto_testsuite_params *ts_params = &testsuite_params;
2291 struct crypto_unittest_params *ut_params = &unittest_params;
2292 const uint8_t *key = tdata->key.data;
2293 const uint8_t auth_len = tdata->digest.len;
2294 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2295 uint8_t auth_iv_len = tdata->auth_iv.len;
2297 memcpy(cipher_auth_key, key, key_len);
2299 /* Setup Authentication Parameters */
2300 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2301 ut_params->auth_xform.next = NULL;
2303 ut_params->auth_xform.auth.op = auth_op;
2304 ut_params->auth_xform.auth.algo = auth_algo;
2305 ut_params->auth_xform.auth.key.length = key_len;
2306 /* Hash key = cipher key */
2307 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2308 ut_params->auth_xform.auth.digest_length = auth_len;
2309 /* Auth IV will be after cipher IV */
2310 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2311 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2313 /* Setup Cipher Parameters */
2314 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2315 ut_params->cipher_xform.next = &ut_params->auth_xform;
2317 ut_params->cipher_xform.cipher.algo = cipher_algo;
2318 ut_params->cipher_xform.cipher.op = cipher_op;
2319 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2320 ut_params->cipher_xform.cipher.key.length = key_len;
2321 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2322 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2325 debug_hexdump(stdout, "key:", key, key_len);
2327 /* Create Crypto session*/
2328 ut_params->sess = rte_cryptodev_sym_session_create(
2329 ts_params->session_mpool);
2331 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2332 &ut_params->cipher_xform, ts_params->session_mpool);
2334 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2339 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2340 const struct wireless_test_data *tdata)
2342 return create_wireless_cipher_auth_session(dev_id,
2343 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2344 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2345 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2349 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2350 enum rte_crypto_cipher_operation cipher_op,
2351 enum rte_crypto_auth_operation auth_op,
2352 enum rte_crypto_auth_algorithm auth_algo,
2353 enum rte_crypto_cipher_algorithm cipher_algo,
2354 const uint8_t *key, const uint8_t key_len,
2355 uint8_t auth_iv_len, uint8_t auth_len,
2356 uint8_t cipher_iv_len)
2358 uint8_t auth_cipher_key[key_len];
2360 struct crypto_testsuite_params *ts_params = &testsuite_params;
2361 struct crypto_unittest_params *ut_params = &unittest_params;
2363 memcpy(auth_cipher_key, key, key_len);
2365 /* Setup Authentication Parameters */
2366 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2367 ut_params->auth_xform.auth.op = auth_op;
2368 ut_params->auth_xform.next = &ut_params->cipher_xform;
2369 ut_params->auth_xform.auth.algo = auth_algo;
2370 ut_params->auth_xform.auth.key.length = key_len;
2371 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2372 ut_params->auth_xform.auth.digest_length = auth_len;
2373 /* Auth IV will be after cipher IV */
2374 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2375 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2377 /* Setup Cipher Parameters */
2378 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2379 ut_params->cipher_xform.next = NULL;
2380 ut_params->cipher_xform.cipher.algo = cipher_algo;
2381 ut_params->cipher_xform.cipher.op = cipher_op;
2382 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2383 ut_params->cipher_xform.cipher.key.length = key_len;
2384 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2385 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2387 debug_hexdump(stdout, "key:", key, key_len);
2389 /* Create Crypto session*/
2390 ut_params->sess = rte_cryptodev_sym_session_create(
2391 ts_params->session_mpool);
2393 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2394 &ut_params->auth_xform, ts_params->session_mpool);
2396 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2402 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2403 unsigned int auth_tag_len,
2404 const uint8_t *iv, unsigned int iv_len,
2405 unsigned int data_pad_len,
2406 enum rte_crypto_auth_operation op,
2407 unsigned int auth_len, unsigned int auth_offset)
2409 struct crypto_testsuite_params *ts_params = &testsuite_params;
2411 struct crypto_unittest_params *ut_params = &unittest_params;
2413 /* Generate Crypto op data structure */
2414 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2415 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2416 TEST_ASSERT_NOT_NULL(ut_params->op,
2417 "Failed to allocate pktmbuf offload");
2419 /* Set crypto operation data parameters */
2420 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2422 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2424 /* set crypto operation source mbuf */
2425 sym_op->m_src = ut_params->ibuf;
2428 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2431 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2432 ut_params->ibuf, auth_tag_len);
2434 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2435 "no room to append auth tag");
2436 ut_params->digest = sym_op->auth.digest.data;
2437 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2438 ut_params->ibuf, data_pad_len);
2439 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2440 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2442 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2444 debug_hexdump(stdout, "digest:",
2445 sym_op->auth.digest.data,
2448 sym_op->auth.data.length = auth_len;
2449 sym_op->auth.data.offset = auth_offset;
2455 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2456 enum rte_crypto_auth_operation op)
2458 struct crypto_testsuite_params *ts_params = &testsuite_params;
2459 struct crypto_unittest_params *ut_params = &unittest_params;
2461 const uint8_t *auth_tag = tdata->digest.data;
2462 const unsigned int auth_tag_len = tdata->digest.len;
2463 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2464 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2466 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2467 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2468 const uint8_t *auth_iv = tdata->auth_iv.data;
2469 const uint8_t auth_iv_len = tdata->auth_iv.len;
2470 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2471 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2473 /* Generate Crypto op data structure */
2474 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2475 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2476 TEST_ASSERT_NOT_NULL(ut_params->op,
2477 "Failed to allocate pktmbuf offload");
2478 /* Set crypto operation data parameters */
2479 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2481 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2483 /* set crypto operation source mbuf */
2484 sym_op->m_src = ut_params->ibuf;
2487 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2488 ut_params->ibuf, auth_tag_len);
2490 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2491 "no room to append auth tag");
2492 ut_params->digest = sym_op->auth.digest.data;
2493 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2494 ut_params->ibuf, data_pad_len);
2495 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2496 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2498 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2500 debug_hexdump(stdout, "digest:",
2501 sym_op->auth.digest.data,
2504 /* Copy cipher and auth IVs at the end of the crypto operation */
2505 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2507 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2508 iv_ptr += cipher_iv_len;
2509 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2511 sym_op->cipher.data.length = cipher_len;
2512 sym_op->cipher.data.offset = 0;
2513 sym_op->auth.data.length = auth_len;
2514 sym_op->auth.data.offset = 0;
2520 create_zuc_cipher_hash_generate_operation(
2521 const struct wireless_test_data *tdata)
2523 return create_wireless_cipher_hash_operation(tdata,
2524 RTE_CRYPTO_AUTH_OP_GENERATE);
2528 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2529 const unsigned auth_tag_len,
2530 const uint8_t *auth_iv, uint8_t auth_iv_len,
2531 unsigned data_pad_len,
2532 enum rte_crypto_auth_operation op,
2533 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2534 const unsigned cipher_len, const unsigned cipher_offset,
2535 const unsigned auth_len, const unsigned auth_offset)
2537 struct crypto_testsuite_params *ts_params = &testsuite_params;
2538 struct crypto_unittest_params *ut_params = &unittest_params;
2540 /* Generate Crypto op data structure */
2541 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2542 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2543 TEST_ASSERT_NOT_NULL(ut_params->op,
2544 "Failed to allocate pktmbuf offload");
2545 /* Set crypto operation data parameters */
2546 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2548 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2550 /* set crypto operation source mbuf */
2551 sym_op->m_src = ut_params->ibuf;
2554 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2555 ut_params->ibuf, auth_tag_len);
2557 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2558 "no room to append auth tag");
2559 ut_params->digest = sym_op->auth.digest.data;
2560 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2561 ut_params->ibuf, data_pad_len);
2562 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2563 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2565 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2567 debug_hexdump(stdout, "digest:",
2568 sym_op->auth.digest.data,
2571 /* Copy cipher and auth IVs at the end of the crypto operation */
2572 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2574 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2575 iv_ptr += cipher_iv_len;
2576 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2578 sym_op->cipher.data.length = cipher_len;
2579 sym_op->cipher.data.offset = cipher_offset;
2580 sym_op->auth.data.length = auth_len;
2581 sym_op->auth.data.offset = auth_offset;
2587 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2588 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2589 const uint8_t *auth_iv, uint8_t auth_iv_len,
2590 unsigned int data_pad_len,
2591 unsigned int cipher_len, unsigned int cipher_offset,
2592 unsigned int auth_len, unsigned int auth_offset)
2594 struct crypto_testsuite_params *ts_params = &testsuite_params;
2595 struct crypto_unittest_params *ut_params = &unittest_params;
2597 /* Generate Crypto op data structure */
2598 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2599 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2600 TEST_ASSERT_NOT_NULL(ut_params->op,
2601 "Failed to allocate pktmbuf offload");
2603 /* Set crypto operation data parameters */
2604 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2606 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2608 /* set crypto operation source mbuf */
2609 sym_op->m_src = ut_params->ibuf;
2612 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2613 ut_params->ibuf, auth_tag_len);
2615 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2616 "no room to append auth tag");
2618 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2619 ut_params->ibuf, data_pad_len);
2621 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2623 debug_hexdump(stdout, "digest:",
2624 sym_op->auth.digest.data,
2627 /* Copy cipher and auth IVs at the end of the crypto operation */
2628 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2630 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2631 iv_ptr += cipher_iv_len;
2632 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2634 sym_op->cipher.data.length = cipher_len;
2635 sym_op->cipher.data.offset = cipher_offset;
2637 sym_op->auth.data.length = auth_len;
2638 sym_op->auth.data.offset = auth_offset;
2644 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2646 struct crypto_testsuite_params *ts_params = &testsuite_params;
2647 struct crypto_unittest_params *ut_params = &unittest_params;
2650 unsigned plaintext_pad_len;
2651 unsigned plaintext_len;
2654 /* Create SNOW 3G session */
2655 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2656 tdata->key.data, tdata->key.len,
2657 tdata->auth_iv.len, tdata->digest.len,
2658 RTE_CRYPTO_AUTH_OP_GENERATE,
2659 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2663 /* alloc mbuf and set payload */
2664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2666 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2667 rte_pktmbuf_tailroom(ut_params->ibuf));
2669 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2670 /* Append data which is padded to a multiple of */
2671 /* the algorithms block size */
2672 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2673 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2675 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2677 /* Create SNOW 3G operation */
2678 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2679 tdata->auth_iv.data, tdata->auth_iv.len,
2680 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2681 tdata->validAuthLenInBits.len,
2686 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2688 ut_params->obuf = ut_params->op->sym->m_src;
2689 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2690 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2691 + plaintext_pad_len;
2694 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2697 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2698 "SNOW 3G Generated auth tag not as expected");
2704 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2706 struct crypto_testsuite_params *ts_params = &testsuite_params;
2707 struct crypto_unittest_params *ut_params = &unittest_params;
2710 unsigned plaintext_pad_len;
2711 unsigned plaintext_len;
2714 /* Create SNOW 3G session */
2715 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2716 tdata->key.data, tdata->key.len,
2717 tdata->auth_iv.len, tdata->digest.len,
2718 RTE_CRYPTO_AUTH_OP_VERIFY,
2719 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2722 /* alloc mbuf and set payload */
2723 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2725 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2726 rte_pktmbuf_tailroom(ut_params->ibuf));
2728 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2729 /* Append data which is padded to a multiple of */
2730 /* the algorithms block size */
2731 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2732 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2734 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2736 /* Create SNOW 3G operation */
2737 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2739 tdata->auth_iv.data, tdata->auth_iv.len,
2741 RTE_CRYPTO_AUTH_OP_VERIFY,
2742 tdata->validAuthLenInBits.len,
2747 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2749 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2750 ut_params->obuf = ut_params->op->sym->m_src;
2751 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2752 + plaintext_pad_len;
2755 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2764 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2766 struct crypto_testsuite_params *ts_params = &testsuite_params;
2767 struct crypto_unittest_params *ut_params = &unittest_params;
2770 unsigned plaintext_pad_len;
2771 unsigned plaintext_len;
2774 /* Create KASUMI session */
2775 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2776 tdata->key.data, tdata->key.len,
2777 0, tdata->digest.len,
2778 RTE_CRYPTO_AUTH_OP_GENERATE,
2779 RTE_CRYPTO_AUTH_KASUMI_F9);
2783 /* alloc mbuf and set payload */
2784 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2786 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2787 rte_pktmbuf_tailroom(ut_params->ibuf));
2789 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2790 /* Append data which is padded to a multiple of */
2791 /* the algorithms block size */
2792 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2793 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2795 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2797 /* Create KASUMI operation */
2798 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2800 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2801 tdata->plaintext.len,
2806 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2808 ut_params->obuf = ut_params->op->sym->m_src;
2809 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2810 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2811 + plaintext_pad_len;
2814 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2817 DIGEST_BYTE_LENGTH_KASUMI_F9,
2818 "KASUMI Generated auth tag not as expected");
2824 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2826 struct crypto_testsuite_params *ts_params = &testsuite_params;
2827 struct crypto_unittest_params *ut_params = &unittest_params;
2830 unsigned plaintext_pad_len;
2831 unsigned plaintext_len;
2834 /* Create KASUMI session */
2835 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2836 tdata->key.data, tdata->key.len,
2837 0, tdata->digest.len,
2838 RTE_CRYPTO_AUTH_OP_VERIFY,
2839 RTE_CRYPTO_AUTH_KASUMI_F9);
2842 /* alloc mbuf and set payload */
2843 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2845 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2846 rte_pktmbuf_tailroom(ut_params->ibuf));
2848 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2849 /* Append data which is padded to a multiple */
2850 /* of the algorithms block size */
2851 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2852 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2854 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2856 /* Create KASUMI operation */
2857 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2861 RTE_CRYPTO_AUTH_OP_VERIFY,
2862 tdata->plaintext.len,
2867 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2869 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2870 ut_params->obuf = ut_params->op->sym->m_src;
2871 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2872 + plaintext_pad_len;
2875 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2884 test_snow3g_hash_generate_test_case_1(void)
2886 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2890 test_snow3g_hash_generate_test_case_2(void)
2892 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2896 test_snow3g_hash_generate_test_case_3(void)
2898 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2902 test_snow3g_hash_generate_test_case_4(void)
2904 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2908 test_snow3g_hash_generate_test_case_5(void)
2910 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2914 test_snow3g_hash_generate_test_case_6(void)
2916 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2920 test_snow3g_hash_verify_test_case_1(void)
2922 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2927 test_snow3g_hash_verify_test_case_2(void)
2929 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2933 test_snow3g_hash_verify_test_case_3(void)
2935 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2939 test_snow3g_hash_verify_test_case_4(void)
2941 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2945 test_snow3g_hash_verify_test_case_5(void)
2947 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2951 test_snow3g_hash_verify_test_case_6(void)
2953 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2957 test_kasumi_hash_generate_test_case_1(void)
2959 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2963 test_kasumi_hash_generate_test_case_2(void)
2965 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2969 test_kasumi_hash_generate_test_case_3(void)
2971 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2975 test_kasumi_hash_generate_test_case_4(void)
2977 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2981 test_kasumi_hash_generate_test_case_5(void)
2983 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2987 test_kasumi_hash_generate_test_case_6(void)
2989 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2993 test_kasumi_hash_verify_test_case_1(void)
2995 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2999 test_kasumi_hash_verify_test_case_2(void)
3001 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3005 test_kasumi_hash_verify_test_case_3(void)
3007 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3011 test_kasumi_hash_verify_test_case_4(void)
3013 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3017 test_kasumi_hash_verify_test_case_5(void)
3019 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3023 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3025 struct crypto_testsuite_params *ts_params = &testsuite_params;
3026 struct crypto_unittest_params *ut_params = &unittest_params;
3029 uint8_t *plaintext, *ciphertext;
3030 unsigned plaintext_pad_len;
3031 unsigned plaintext_len;
3033 /* Create KASUMI session */
3034 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3035 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3036 RTE_CRYPTO_CIPHER_KASUMI_F8,
3037 tdata->key.data, tdata->key.len,
3038 tdata->cipher_iv.len);
3042 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3044 /* Clear mbuf payload */
3045 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3046 rte_pktmbuf_tailroom(ut_params->ibuf));
3048 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3049 /* Append data which is padded to a multiple */
3050 /* of the algorithms block size */
3051 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3052 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3054 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3056 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3058 /* Create KASUMI operation */
3059 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3060 tdata->cipher_iv.len,
3061 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3062 tdata->validCipherOffsetInBits.len);
3066 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3068 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3070 ut_params->obuf = ut_params->op->sym->m_dst;
3071 if (ut_params->obuf)
3072 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3074 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3076 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3078 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3079 (tdata->validCipherOffsetInBits.len >> 3);
3081 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3083 reference_ciphertext,
3084 tdata->validCipherLenInBits.len,
3085 "KASUMI Ciphertext data not as expected");
3090 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3092 struct crypto_testsuite_params *ts_params = &testsuite_params;
3093 struct crypto_unittest_params *ut_params = &unittest_params;
3097 unsigned int plaintext_pad_len;
3098 unsigned int plaintext_len;
3100 uint8_t buffer[10000];
3101 const uint8_t *ciphertext;
3103 struct rte_cryptodev_info dev_info;
3105 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3106 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3107 printf("Device doesn't support scatter-gather. "
3112 /* Create KASUMI session */
3113 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3114 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3115 RTE_CRYPTO_CIPHER_KASUMI_F8,
3116 tdata->key.data, tdata->key.len,
3117 tdata->cipher_iv.len);
3121 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3124 /* Append data which is padded to a multiple */
3125 /* of the algorithms block size */
3126 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3128 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3129 plaintext_pad_len, 10, 0);
3131 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3133 /* Create KASUMI operation */
3134 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3135 tdata->cipher_iv.len,
3136 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3137 tdata->validCipherOffsetInBits.len);
3141 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3143 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3145 ut_params->obuf = ut_params->op->sym->m_dst;
3147 if (ut_params->obuf)
3148 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3149 plaintext_len, buffer);
3151 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3152 tdata->validCipherOffsetInBits.len >> 3,
3153 plaintext_len, buffer);
3156 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3158 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3159 (tdata->validCipherOffsetInBits.len >> 3);
3161 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3163 reference_ciphertext,
3164 tdata->validCipherLenInBits.len,
3165 "KASUMI Ciphertext data not as expected");
3170 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3172 struct crypto_testsuite_params *ts_params = &testsuite_params;
3173 struct crypto_unittest_params *ut_params = &unittest_params;
3176 uint8_t *plaintext, *ciphertext;
3177 unsigned plaintext_pad_len;
3178 unsigned plaintext_len;
3180 /* Create KASUMI session */
3181 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3182 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3183 RTE_CRYPTO_CIPHER_KASUMI_F8,
3184 tdata->key.data, tdata->key.len,
3185 tdata->cipher_iv.len);
3189 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3190 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3192 /* Clear mbuf payload */
3193 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3194 rte_pktmbuf_tailroom(ut_params->ibuf));
3196 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3197 /* Append data which is padded to a multiple */
3198 /* of the algorithms block size */
3199 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3200 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3202 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3203 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3205 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3207 /* Create KASUMI operation */
3208 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3209 tdata->cipher_iv.len,
3210 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3211 tdata->validCipherOffsetInBits.len);
3215 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3217 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3219 ut_params->obuf = ut_params->op->sym->m_dst;
3220 if (ut_params->obuf)
3221 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3223 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3225 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3227 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3228 (tdata->validCipherOffsetInBits.len >> 3);
3230 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3232 reference_ciphertext,
3233 tdata->validCipherLenInBits.len,
3234 "KASUMI Ciphertext data not as expected");
3239 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3241 struct crypto_testsuite_params *ts_params = &testsuite_params;
3242 struct crypto_unittest_params *ut_params = &unittest_params;
3245 unsigned int plaintext_pad_len;
3246 unsigned int plaintext_len;
3248 const uint8_t *ciphertext;
3249 uint8_t buffer[2048];
3251 struct rte_cryptodev_info dev_info;
3253 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3254 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3255 printf("Device doesn't support scatter-gather. "
3260 /* Create KASUMI session */
3261 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3262 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3263 RTE_CRYPTO_CIPHER_KASUMI_F8,
3264 tdata->key.data, tdata->key.len,
3265 tdata->cipher_iv.len);
3269 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3270 /* Append data which is padded to a multiple */
3271 /* of the algorithms block size */
3272 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3274 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3275 plaintext_pad_len, 10, 0);
3276 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3277 plaintext_pad_len, 3, 0);
3279 /* Append data which is padded to a multiple */
3280 /* of the algorithms block size */
3281 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3283 /* Create KASUMI operation */
3284 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3285 tdata->cipher_iv.len,
3286 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3287 tdata->validCipherOffsetInBits.len);
3291 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3293 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3295 ut_params->obuf = ut_params->op->sym->m_dst;
3296 if (ut_params->obuf)
3297 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3298 plaintext_pad_len, buffer);
3300 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3301 tdata->validCipherOffsetInBits.len >> 3,
3302 plaintext_pad_len, buffer);
3304 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3305 (tdata->validCipherOffsetInBits.len >> 3);
3307 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3309 reference_ciphertext,
3310 tdata->validCipherLenInBits.len,
3311 "KASUMI Ciphertext data not as expected");
3317 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3319 struct crypto_testsuite_params *ts_params = &testsuite_params;
3320 struct crypto_unittest_params *ut_params = &unittest_params;
3323 uint8_t *ciphertext, *plaintext;
3324 unsigned ciphertext_pad_len;
3325 unsigned ciphertext_len;
3327 /* Create KASUMI session */
3328 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3329 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3330 RTE_CRYPTO_CIPHER_KASUMI_F8,
3331 tdata->key.data, tdata->key.len,
3332 tdata->cipher_iv.len);
3336 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3337 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3339 /* Clear mbuf payload */
3340 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3341 rte_pktmbuf_tailroom(ut_params->ibuf));
3343 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3344 /* Append data which is padded to a multiple */
3345 /* of the algorithms block size */
3346 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3347 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3348 ciphertext_pad_len);
3349 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3350 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3352 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3354 /* Create KASUMI operation */
3355 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3356 tdata->cipher_iv.len,
3357 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3358 tdata->validCipherOffsetInBits.len);
3362 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3364 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3366 ut_params->obuf = ut_params->op->sym->m_dst;
3367 if (ut_params->obuf)
3368 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3370 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3372 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3374 const uint8_t *reference_plaintext = tdata->plaintext.data +
3375 (tdata->validCipherOffsetInBits.len >> 3);
3377 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3379 reference_plaintext,
3380 tdata->validCipherLenInBits.len,
3381 "KASUMI Plaintext data not as expected");
3386 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3388 struct crypto_testsuite_params *ts_params = &testsuite_params;
3389 struct crypto_unittest_params *ut_params = &unittest_params;
3392 uint8_t *ciphertext, *plaintext;
3393 unsigned ciphertext_pad_len;
3394 unsigned ciphertext_len;
3396 /* Create KASUMI session */
3397 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3398 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3399 RTE_CRYPTO_CIPHER_KASUMI_F8,
3400 tdata->key.data, tdata->key.len,
3401 tdata->cipher_iv.len);
3405 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3407 /* Clear mbuf payload */
3408 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3409 rte_pktmbuf_tailroom(ut_params->ibuf));
3411 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3412 /* Append data which is padded to a multiple */
3413 /* of the algorithms block size */
3414 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3415 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3416 ciphertext_pad_len);
3417 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3419 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3421 /* Create KASUMI operation */
3422 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3423 tdata->cipher_iv.len,
3424 tdata->ciphertext.len,
3425 tdata->validCipherOffsetInBits.len);
3429 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3431 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3433 ut_params->obuf = ut_params->op->sym->m_dst;
3434 if (ut_params->obuf)
3435 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3437 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3439 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3441 const uint8_t *reference_plaintext = tdata->plaintext.data +
3442 (tdata->validCipherOffsetInBits.len >> 3);
3444 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3446 reference_plaintext,
3447 tdata->validCipherLenInBits.len,
3448 "KASUMI Plaintext data not as expected");
3453 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3455 struct crypto_testsuite_params *ts_params = &testsuite_params;
3456 struct crypto_unittest_params *ut_params = &unittest_params;
3459 uint8_t *plaintext, *ciphertext;
3460 unsigned plaintext_pad_len;
3461 unsigned plaintext_len;
3463 /* Create SNOW 3G session */
3464 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3465 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3466 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3467 tdata->key.data, tdata->key.len,
3468 tdata->cipher_iv.len);
3472 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3474 /* Clear mbuf payload */
3475 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3476 rte_pktmbuf_tailroom(ut_params->ibuf));
3478 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3479 /* Append data which is padded to a multiple of */
3480 /* the algorithms block size */
3481 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3482 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3484 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3486 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3488 /* Create SNOW 3G operation */
3489 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3490 tdata->cipher_iv.len,
3491 tdata->validCipherLenInBits.len,
3496 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3498 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3500 ut_params->obuf = ut_params->op->sym->m_dst;
3501 if (ut_params->obuf)
3502 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3504 ciphertext = plaintext;
3506 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3509 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3511 tdata->ciphertext.data,
3512 tdata->validDataLenInBits.len,
3513 "SNOW 3G Ciphertext data not as expected");
3519 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3521 struct crypto_testsuite_params *ts_params = &testsuite_params;
3522 struct crypto_unittest_params *ut_params = &unittest_params;
3523 uint8_t *plaintext, *ciphertext;
3526 unsigned plaintext_pad_len;
3527 unsigned plaintext_len;
3529 /* Create SNOW 3G session */
3530 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3531 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3532 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3533 tdata->key.data, tdata->key.len,
3534 tdata->cipher_iv.len);
3538 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3539 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3541 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3542 "Failed to allocate input buffer in mempool");
3543 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3544 "Failed to allocate output buffer in mempool");
3546 /* Clear mbuf payload */
3547 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3548 rte_pktmbuf_tailroom(ut_params->ibuf));
3550 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3551 /* Append data which is padded to a multiple of */
3552 /* the algorithms block size */
3553 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3554 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3556 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3557 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3559 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3561 /* Create SNOW 3G operation */
3562 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3563 tdata->cipher_iv.len,
3564 tdata->validCipherLenInBits.len,
3569 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3571 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3573 ut_params->obuf = ut_params->op->sym->m_dst;
3574 if (ut_params->obuf)
3575 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3577 ciphertext = plaintext;
3579 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3582 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3584 tdata->ciphertext.data,
3585 tdata->validDataLenInBits.len,
3586 "SNOW 3G Ciphertext data not as expected");
3591 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3593 struct crypto_testsuite_params *ts_params = &testsuite_params;
3594 struct crypto_unittest_params *ut_params = &unittest_params;
3597 unsigned int plaintext_pad_len;
3598 unsigned int plaintext_len;
3599 uint8_t buffer[10000];
3600 const uint8_t *ciphertext;
3602 struct rte_cryptodev_info dev_info;
3604 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3605 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3606 printf("Device doesn't support scatter-gather. "
3611 /* Create SNOW 3G session */
3612 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3613 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3614 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3615 tdata->key.data, tdata->key.len,
3616 tdata->cipher_iv.len);
3620 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3621 /* Append data which is padded to a multiple of */
3622 /* the algorithms block size */
3623 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3625 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3626 plaintext_pad_len, 10, 0);
3627 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3628 plaintext_pad_len, 3, 0);
3630 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3631 "Failed to allocate input buffer in mempool");
3632 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3633 "Failed to allocate output buffer in mempool");
3635 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3637 /* Create SNOW 3G operation */
3638 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3639 tdata->cipher_iv.len,
3640 tdata->validCipherLenInBits.len,
3645 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3647 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3649 ut_params->obuf = ut_params->op->sym->m_dst;
3650 if (ut_params->obuf)
3651 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3652 plaintext_len, buffer);
3654 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3655 plaintext_len, buffer);
3657 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3660 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3662 tdata->ciphertext.data,
3663 tdata->validDataLenInBits.len,
3664 "SNOW 3G Ciphertext data not as expected");
3669 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3671 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3673 uint8_t curr_byte, prev_byte;
3674 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3675 uint8_t lower_byte_mask = (1 << offset) - 1;
3678 prev_byte = buffer[0];
3679 buffer[0] >>= offset;
3681 for (i = 1; i < length_in_bytes; i++) {
3682 curr_byte = buffer[i];
3683 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3684 (curr_byte >> offset);
3685 prev_byte = curr_byte;
3690 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3692 struct crypto_testsuite_params *ts_params = &testsuite_params;
3693 struct crypto_unittest_params *ut_params = &unittest_params;
3694 uint8_t *plaintext, *ciphertext;
3696 uint32_t plaintext_len;
3697 uint32_t plaintext_pad_len;
3698 uint8_t extra_offset = 4;
3699 uint8_t *expected_ciphertext_shifted;
3701 /* Create SNOW 3G session */
3702 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3703 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3704 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3705 tdata->key.data, tdata->key.len,
3706 tdata->cipher_iv.len);
3710 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3711 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3713 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3714 "Failed to allocate input buffer in mempool");
3715 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3716 "Failed to allocate output buffer in mempool");
3718 /* Clear mbuf payload */
3719 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3720 rte_pktmbuf_tailroom(ut_params->ibuf));
3722 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3724 * Append data which is padded to a
3725 * multiple of the algorithms block size
3727 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3729 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3732 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3734 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3735 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3737 #ifdef RTE_APP_TEST_DEBUG
3738 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3740 /* Create SNOW 3G operation */
3741 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3742 tdata->cipher_iv.len,
3743 tdata->validCipherLenInBits.len,
3748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3752 ut_params->obuf = ut_params->op->sym->m_dst;
3753 if (ut_params->obuf)
3754 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3756 ciphertext = plaintext;
3758 #ifdef RTE_APP_TEST_DEBUG
3759 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3762 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3764 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3765 "failed to reserve memory for ciphertext shifted\n");
3767 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3768 ceil_byte_length(tdata->ciphertext.len));
3769 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3772 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3774 expected_ciphertext_shifted,
3775 tdata->validDataLenInBits.len,
3777 "SNOW 3G Ciphertext data not as expected");
3781 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3783 struct crypto_testsuite_params *ts_params = &testsuite_params;
3784 struct crypto_unittest_params *ut_params = &unittest_params;
3788 uint8_t *plaintext, *ciphertext;
3789 unsigned ciphertext_pad_len;
3790 unsigned ciphertext_len;
3792 /* Create SNOW 3G session */
3793 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3794 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3795 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3796 tdata->key.data, tdata->key.len,
3797 tdata->cipher_iv.len);
3801 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3803 /* Clear mbuf payload */
3804 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3805 rte_pktmbuf_tailroom(ut_params->ibuf));
3807 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3808 /* Append data which is padded to a multiple of */
3809 /* the algorithms block size */
3810 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3811 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3812 ciphertext_pad_len);
3813 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3815 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3817 /* Create SNOW 3G operation */
3818 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3819 tdata->cipher_iv.len,
3820 tdata->validCipherLenInBits.len,
3825 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3827 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3828 ut_params->obuf = ut_params->op->sym->m_dst;
3829 if (ut_params->obuf)
3830 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3832 plaintext = ciphertext;
3834 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3837 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3838 tdata->plaintext.data,
3839 tdata->validDataLenInBits.len,
3840 "SNOW 3G Plaintext data not as expected");
3844 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3846 struct crypto_testsuite_params *ts_params = &testsuite_params;
3847 struct crypto_unittest_params *ut_params = &unittest_params;
3851 uint8_t *plaintext, *ciphertext;
3852 unsigned ciphertext_pad_len;
3853 unsigned ciphertext_len;
3855 /* Create SNOW 3G session */
3856 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3857 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3858 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3859 tdata->key.data, tdata->key.len,
3860 tdata->cipher_iv.len);
3864 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3865 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3867 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3868 "Failed to allocate input buffer");
3869 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3870 "Failed to allocate output buffer");
3872 /* Clear mbuf payload */
3873 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3874 rte_pktmbuf_tailroom(ut_params->ibuf));
3876 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3877 rte_pktmbuf_tailroom(ut_params->obuf));
3879 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3880 /* Append data which is padded to a multiple of */
3881 /* the algorithms block size */
3882 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3883 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3884 ciphertext_pad_len);
3885 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3886 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3888 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3890 /* Create SNOW 3G operation */
3891 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3892 tdata->cipher_iv.len,
3893 tdata->validCipherLenInBits.len,
3898 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3900 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3901 ut_params->obuf = ut_params->op->sym->m_dst;
3902 if (ut_params->obuf)
3903 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3905 plaintext = ciphertext;
3907 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3910 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3911 tdata->plaintext.data,
3912 tdata->validDataLenInBits.len,
3913 "SNOW 3G Plaintext data not as expected");
3918 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3920 struct crypto_testsuite_params *ts_params = &testsuite_params;
3921 struct crypto_unittest_params *ut_params = &unittest_params;
3925 uint8_t *plaintext, *ciphertext;
3926 unsigned int plaintext_pad_len;
3927 unsigned int plaintext_len;
3929 struct rte_cryptodev_sym_capability_idx cap_idx;
3931 /* Check if device supports ZUC EEA3 */
3932 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3933 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3935 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3939 /* Check if device supports ZUC EIA3 */
3940 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3941 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3943 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3947 /* Create ZUC session */
3948 retval = create_zuc_cipher_auth_encrypt_generate_session(
3949 ts_params->valid_devs[0],
3953 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3955 /* clear mbuf payload */
3956 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3957 rte_pktmbuf_tailroom(ut_params->ibuf));
3959 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3960 /* Append data which is padded to a multiple of */
3961 /* the algorithms block size */
3962 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3963 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3965 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3967 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3969 /* Create ZUC operation */
3970 retval = create_zuc_cipher_hash_generate_operation(tdata);
3974 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3976 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3977 ut_params->obuf = ut_params->op->sym->m_src;
3978 if (ut_params->obuf)
3979 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3981 ciphertext = plaintext;
3983 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3985 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3987 tdata->ciphertext.data,
3988 tdata->validDataLenInBits.len,
3989 "ZUC Ciphertext data not as expected");
3991 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3992 + plaintext_pad_len;
3995 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3999 "ZUC Generated auth tag not as expected");
4004 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4006 struct crypto_testsuite_params *ts_params = &testsuite_params;
4007 struct crypto_unittest_params *ut_params = &unittest_params;
4011 uint8_t *plaintext, *ciphertext;
4012 unsigned plaintext_pad_len;
4013 unsigned plaintext_len;
4015 /* Create SNOW 3G session */
4016 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4017 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4018 RTE_CRYPTO_AUTH_OP_GENERATE,
4019 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4020 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4021 tdata->key.data, tdata->key.len,
4022 tdata->auth_iv.len, tdata->digest.len,
4023 tdata->cipher_iv.len);
4026 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4028 /* clear mbuf payload */
4029 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4030 rte_pktmbuf_tailroom(ut_params->ibuf));
4032 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4033 /* Append data which is padded to a multiple of */
4034 /* the algorithms block size */
4035 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4036 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4038 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4040 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4042 /* Create SNOW 3G operation */
4043 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4044 tdata->digest.len, tdata->auth_iv.data,
4046 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4047 tdata->cipher_iv.data, tdata->cipher_iv.len,
4048 tdata->validCipherLenInBits.len,
4050 tdata->validAuthLenInBits.len,
4056 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4058 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4059 ut_params->obuf = ut_params->op->sym->m_src;
4060 if (ut_params->obuf)
4061 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4063 ciphertext = plaintext;
4065 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4067 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4069 tdata->ciphertext.data,
4070 tdata->validDataLenInBits.len,
4071 "SNOW 3G Ciphertext data not as expected");
4073 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4074 + plaintext_pad_len;
4077 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4080 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4081 "SNOW 3G Generated auth tag not as expected");
4085 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4087 struct crypto_testsuite_params *ts_params = &testsuite_params;
4088 struct crypto_unittest_params *ut_params = &unittest_params;
4092 uint8_t *plaintext, *ciphertext;
4093 unsigned plaintext_pad_len;
4094 unsigned plaintext_len;
4096 /* Create SNOW 3G session */
4097 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4098 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4099 RTE_CRYPTO_AUTH_OP_GENERATE,
4100 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4101 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4102 tdata->key.data, tdata->key.len,
4103 tdata->auth_iv.len, tdata->digest.len,
4104 tdata->cipher_iv.len);
4108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4110 /* clear mbuf payload */
4111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4112 rte_pktmbuf_tailroom(ut_params->ibuf));
4114 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4115 /* Append data which is padded to a multiple of */
4116 /* the algorithms block size */
4117 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4118 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4120 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4122 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4124 /* Create SNOW 3G operation */
4125 retval = create_wireless_algo_auth_cipher_operation(
4127 tdata->cipher_iv.data, tdata->cipher_iv.len,
4128 tdata->auth_iv.data, tdata->auth_iv.len,
4130 tdata->validCipherLenInBits.len,
4132 tdata->validAuthLenInBits.len,
4138 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4140 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4141 ut_params->obuf = ut_params->op->sym->m_src;
4142 if (ut_params->obuf)
4143 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4145 ciphertext = plaintext;
4147 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4148 + plaintext_pad_len;
4149 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4152 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4154 tdata->ciphertext.data,
4155 tdata->validDataLenInBits.len,
4156 "SNOW 3G Ciphertext data not as expected");
4159 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4162 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4163 "SNOW 3G Generated auth tag not as expected");
4168 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4170 struct crypto_testsuite_params *ts_params = &testsuite_params;
4171 struct crypto_unittest_params *ut_params = &unittest_params;
4175 uint8_t *plaintext, *ciphertext;
4176 unsigned plaintext_pad_len;
4177 unsigned plaintext_len;
4179 /* Create KASUMI session */
4180 retval = create_wireless_algo_auth_cipher_session(
4181 ts_params->valid_devs[0],
4182 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4183 RTE_CRYPTO_AUTH_OP_GENERATE,
4184 RTE_CRYPTO_AUTH_KASUMI_F9,
4185 RTE_CRYPTO_CIPHER_KASUMI_F8,
4186 tdata->key.data, tdata->key.len,
4187 0, tdata->digest.len,
4188 tdata->cipher_iv.len);
4191 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4193 /* clear mbuf payload */
4194 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4195 rte_pktmbuf_tailroom(ut_params->ibuf));
4197 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4198 /* Append data which is padded to a multiple of */
4199 /* the algorithms block size */
4200 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4201 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4203 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4205 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4207 /* Create KASUMI operation */
4208 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4209 tdata->cipher_iv.data, tdata->cipher_iv.len,
4212 tdata->validCipherLenInBits.len,
4213 tdata->validCipherOffsetInBits.len,
4214 tdata->validAuthLenInBits.len,
4221 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4223 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4224 if (ut_params->op->sym->m_dst)
4225 ut_params->obuf = ut_params->op->sym->m_dst;
4227 ut_params->obuf = ut_params->op->sym->m_src;
4229 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4230 tdata->validCipherOffsetInBits.len >> 3);
4232 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4233 (tdata->validCipherOffsetInBits.len >> 3);
4235 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4237 reference_ciphertext,
4238 tdata->validCipherLenInBits.len,
4239 "KASUMI Ciphertext data not as expected");
4240 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4241 + plaintext_pad_len;
4244 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4247 DIGEST_BYTE_LENGTH_KASUMI_F9,
4248 "KASUMI Generated auth tag not as expected");
4253 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4255 struct crypto_testsuite_params *ts_params = &testsuite_params;
4256 struct crypto_unittest_params *ut_params = &unittest_params;
4260 uint8_t *plaintext, *ciphertext;
4261 unsigned plaintext_pad_len;
4262 unsigned plaintext_len;
4264 /* Create KASUMI session */
4265 retval = create_wireless_algo_cipher_auth_session(
4266 ts_params->valid_devs[0],
4267 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4268 RTE_CRYPTO_AUTH_OP_GENERATE,
4269 RTE_CRYPTO_AUTH_KASUMI_F9,
4270 RTE_CRYPTO_CIPHER_KASUMI_F8,
4271 tdata->key.data, tdata->key.len,
4272 0, tdata->digest.len,
4273 tdata->cipher_iv.len);
4277 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4279 /* clear mbuf payload */
4280 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4281 rte_pktmbuf_tailroom(ut_params->ibuf));
4283 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4284 /* Append data which is padded to a multiple of */
4285 /* the algorithms block size */
4286 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4287 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4289 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4291 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4293 /* Create KASUMI operation */
4294 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4295 tdata->digest.len, NULL, 0,
4296 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4297 tdata->cipher_iv.data, tdata->cipher_iv.len,
4298 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4299 tdata->validCipherOffsetInBits.len,
4300 tdata->validAuthLenInBits.len,
4306 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4308 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4310 if (ut_params->op->sym->m_dst)
4311 ut_params->obuf = ut_params->op->sym->m_dst;
4313 ut_params->obuf = ut_params->op->sym->m_src;
4315 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4316 tdata->validCipherOffsetInBits.len >> 3);
4318 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4319 + plaintext_pad_len;
4321 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4322 (tdata->validCipherOffsetInBits.len >> 3);
4324 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4326 reference_ciphertext,
4327 tdata->validCipherLenInBits.len,
4328 "KASUMI Ciphertext data not as expected");
4331 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4334 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4335 "KASUMI Generated auth tag not as expected");
4340 test_zuc_encryption(const struct wireless_test_data *tdata)
4342 struct crypto_testsuite_params *ts_params = &testsuite_params;
4343 struct crypto_unittest_params *ut_params = &unittest_params;
4346 uint8_t *plaintext, *ciphertext;
4347 unsigned plaintext_pad_len;
4348 unsigned plaintext_len;
4350 struct rte_cryptodev_sym_capability_idx cap_idx;
4352 /* Check if device supports ZUC EEA3 */
4353 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4354 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4356 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4360 /* Create ZUC session */
4361 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4362 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4363 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4364 tdata->key.data, tdata->key.len,
4365 tdata->cipher_iv.len);
4369 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4371 /* Clear mbuf payload */
4372 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4373 rte_pktmbuf_tailroom(ut_params->ibuf));
4375 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4376 /* Append data which is padded to a multiple */
4377 /* of the algorithms block size */
4378 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4379 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4381 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4383 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4385 /* Create ZUC operation */
4386 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4387 tdata->cipher_iv.len,
4388 tdata->plaintext.len,
4393 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4395 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4397 ut_params->obuf = ut_params->op->sym->m_dst;
4398 if (ut_params->obuf)
4399 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4401 ciphertext = plaintext;
4403 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4406 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4408 tdata->ciphertext.data,
4409 tdata->validCipherLenInBits.len,
4410 "ZUC Ciphertext data not as expected");
4415 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4417 struct crypto_testsuite_params *ts_params = &testsuite_params;
4418 struct crypto_unittest_params *ut_params = &unittest_params;
4422 unsigned int plaintext_pad_len;
4423 unsigned int plaintext_len;
4424 const uint8_t *ciphertext;
4425 uint8_t ciphertext_buffer[2048];
4426 struct rte_cryptodev_info dev_info;
4428 struct rte_cryptodev_sym_capability_idx cap_idx;
4430 /* Check if device supports ZUC EEA3 */
4431 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4432 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4434 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4438 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4439 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4440 printf("Device doesn't support scatter-gather. "
4445 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4447 /* Append data which is padded to a multiple */
4448 /* of the algorithms block size */
4449 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4451 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4452 plaintext_pad_len, 10, 0);
4454 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4455 tdata->plaintext.data);
4457 /* Create ZUC session */
4458 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4459 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4460 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4461 tdata->key.data, tdata->key.len,
4462 tdata->cipher_iv.len);
4466 /* Clear mbuf payload */
4468 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4470 /* Create ZUC operation */
4471 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4472 tdata->cipher_iv.len, tdata->plaintext.len,
4477 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4479 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4481 ut_params->obuf = ut_params->op->sym->m_dst;
4482 if (ut_params->obuf)
4483 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4484 0, plaintext_len, ciphertext_buffer);
4486 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4487 0, plaintext_len, ciphertext_buffer);
4490 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4493 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4495 tdata->ciphertext.data,
4496 tdata->validCipherLenInBits.len,
4497 "ZUC Ciphertext data not as expected");
4503 test_zuc_authentication(const struct wireless_test_data *tdata)
4505 struct crypto_testsuite_params *ts_params = &testsuite_params;
4506 struct crypto_unittest_params *ut_params = &unittest_params;
4509 unsigned plaintext_pad_len;
4510 unsigned plaintext_len;
4513 struct rte_cryptodev_sym_capability_idx cap_idx;
4515 /* Check if device supports ZUC EIA3 */
4516 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4517 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4519 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4523 /* Create ZUC session */
4524 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4525 tdata->key.data, tdata->key.len,
4526 tdata->auth_iv.len, tdata->digest.len,
4527 RTE_CRYPTO_AUTH_OP_GENERATE,
4528 RTE_CRYPTO_AUTH_ZUC_EIA3);
4532 /* alloc mbuf and set payload */
4533 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4535 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4536 rte_pktmbuf_tailroom(ut_params->ibuf));
4538 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4539 /* Append data which is padded to a multiple of */
4540 /* the algorithms block size */
4541 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4542 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4544 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4546 /* Create ZUC operation */
4547 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4548 tdata->auth_iv.data, tdata->auth_iv.len,
4549 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4550 tdata->validAuthLenInBits.len,
4555 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4557 ut_params->obuf = ut_params->op->sym->m_src;
4558 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4559 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4560 + plaintext_pad_len;
4563 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4566 DIGEST_BYTE_LENGTH_KASUMI_F9,
4567 "ZUC Generated auth tag not as expected");
4573 test_kasumi_encryption_test_case_1(void)
4575 return test_kasumi_encryption(&kasumi_test_case_1);
4579 test_kasumi_encryption_test_case_1_sgl(void)
4581 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4585 test_kasumi_encryption_test_case_1_oop(void)
4587 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4591 test_kasumi_encryption_test_case_1_oop_sgl(void)
4593 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4597 test_kasumi_encryption_test_case_2(void)
4599 return test_kasumi_encryption(&kasumi_test_case_2);
4603 test_kasumi_encryption_test_case_3(void)
4605 return test_kasumi_encryption(&kasumi_test_case_3);
4609 test_kasumi_encryption_test_case_4(void)
4611 return test_kasumi_encryption(&kasumi_test_case_4);
4615 test_kasumi_encryption_test_case_5(void)
4617 return test_kasumi_encryption(&kasumi_test_case_5);
4621 test_kasumi_decryption_test_case_1(void)
4623 return test_kasumi_decryption(&kasumi_test_case_1);
4627 test_kasumi_decryption_test_case_1_oop(void)
4629 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4633 test_kasumi_decryption_test_case_2(void)
4635 return test_kasumi_decryption(&kasumi_test_case_2);
4639 test_kasumi_decryption_test_case_3(void)
4641 return test_kasumi_decryption(&kasumi_test_case_3);
4645 test_kasumi_decryption_test_case_4(void)
4647 return test_kasumi_decryption(&kasumi_test_case_4);
4651 test_kasumi_decryption_test_case_5(void)
4653 return test_kasumi_decryption(&kasumi_test_case_5);
4656 test_snow3g_encryption_test_case_1(void)
4658 return test_snow3g_encryption(&snow3g_test_case_1);
4662 test_snow3g_encryption_test_case_1_oop(void)
4664 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4668 test_snow3g_encryption_test_case_1_oop_sgl(void)
4670 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4675 test_snow3g_encryption_test_case_1_offset_oop(void)
4677 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4681 test_snow3g_encryption_test_case_2(void)
4683 return test_snow3g_encryption(&snow3g_test_case_2);
4687 test_snow3g_encryption_test_case_3(void)
4689 return test_snow3g_encryption(&snow3g_test_case_3);
4693 test_snow3g_encryption_test_case_4(void)
4695 return test_snow3g_encryption(&snow3g_test_case_4);
4699 test_snow3g_encryption_test_case_5(void)
4701 return test_snow3g_encryption(&snow3g_test_case_5);
4705 test_snow3g_decryption_test_case_1(void)
4707 return test_snow3g_decryption(&snow3g_test_case_1);
4711 test_snow3g_decryption_test_case_1_oop(void)
4713 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4717 test_snow3g_decryption_test_case_2(void)
4719 return test_snow3g_decryption(&snow3g_test_case_2);
4723 test_snow3g_decryption_test_case_3(void)
4725 return test_snow3g_decryption(&snow3g_test_case_3);
4729 test_snow3g_decryption_test_case_4(void)
4731 return test_snow3g_decryption(&snow3g_test_case_4);
4735 test_snow3g_decryption_test_case_5(void)
4737 return test_snow3g_decryption(&snow3g_test_case_5);
4740 test_snow3g_cipher_auth_test_case_1(void)
4742 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4746 test_snow3g_auth_cipher_test_case_1(void)
4748 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4752 test_kasumi_auth_cipher_test_case_1(void)
4754 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4758 test_kasumi_cipher_auth_test_case_1(void)
4760 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4764 test_zuc_encryption_test_case_1(void)
4766 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4770 test_zuc_encryption_test_case_2(void)
4772 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4776 test_zuc_encryption_test_case_3(void)
4778 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4782 test_zuc_encryption_test_case_4(void)
4784 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4788 test_zuc_encryption_test_case_5(void)
4790 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4794 test_zuc_encryption_test_case_6_sgl(void)
4796 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4800 test_zuc_hash_generate_test_case_1(void)
4802 return test_zuc_authentication(&zuc_test_case_auth_1b);
4806 test_zuc_hash_generate_test_case_2(void)
4808 return test_zuc_authentication(&zuc_test_case_auth_90b);
4812 test_zuc_hash_generate_test_case_3(void)
4814 return test_zuc_authentication(&zuc_test_case_auth_577b);
4818 test_zuc_hash_generate_test_case_4(void)
4820 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4824 test_zuc_hash_generate_test_case_5(void)
4826 return test_zuc_authentication(&zuc_test_auth_5670b);
4830 test_zuc_hash_generate_test_case_6(void)
4832 return test_zuc_authentication(&zuc_test_case_auth_128b);
4836 test_zuc_hash_generate_test_case_7(void)
4838 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4842 test_zuc_hash_generate_test_case_8(void)
4844 return test_zuc_authentication(&zuc_test_case_auth_584b);
4848 test_zuc_cipher_auth_test_case_1(void)
4850 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4854 test_zuc_cipher_auth_test_case_2(void)
4856 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4860 test_3DES_chain_qat_all(void)
4862 struct crypto_testsuite_params *ts_params = &testsuite_params;
4865 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4866 ts_params->op_mpool,
4867 ts_params->session_mpool,
4868 ts_params->valid_devs[0],
4869 rte_cryptodev_driver_id_get(
4870 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4871 BLKCIPHER_3DES_CHAIN_TYPE);
4873 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4875 return TEST_SUCCESS;
4879 test_DES_cipheronly_qat_all(void)
4881 struct crypto_testsuite_params *ts_params = &testsuite_params;
4884 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4885 ts_params->op_mpool,
4886 ts_params->session_mpool,
4887 ts_params->valid_devs[0],
4888 rte_cryptodev_driver_id_get(
4889 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4890 BLKCIPHER_DES_CIPHERONLY_TYPE);
4892 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4894 return TEST_SUCCESS;
4898 test_DES_cipheronly_openssl_all(void)
4900 struct crypto_testsuite_params *ts_params = &testsuite_params;
4903 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4904 ts_params->op_mpool,
4905 ts_params->session_mpool,
4906 ts_params->valid_devs[0],
4907 rte_cryptodev_driver_id_get(
4908 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4909 BLKCIPHER_DES_CIPHERONLY_TYPE);
4911 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4913 return TEST_SUCCESS;
4917 test_DES_docsis_openssl_all(void)
4919 struct crypto_testsuite_params *ts_params = &testsuite_params;
4922 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4923 ts_params->op_mpool,
4924 ts_params->session_mpool,
4925 ts_params->valid_devs[0],
4926 rte_cryptodev_driver_id_get(
4927 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4928 BLKCIPHER_DES_DOCSIS_TYPE);
4930 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4932 return TEST_SUCCESS;
4936 test_DES_cipheronly_mb_all(void)
4938 struct crypto_testsuite_params *ts_params = &testsuite_params;
4941 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4942 ts_params->op_mpool,
4943 ts_params->session_mpool,
4944 ts_params->valid_devs[0],
4945 rte_cryptodev_driver_id_get(
4946 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4947 BLKCIPHER_DES_CIPHERONLY_TYPE);
4949 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4951 return TEST_SUCCESS;
4955 test_DES_docsis_mb_all(void)
4957 struct crypto_testsuite_params *ts_params = &testsuite_params;
4960 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4961 ts_params->op_mpool,
4962 ts_params->session_mpool,
4963 ts_params->valid_devs[0],
4964 rte_cryptodev_driver_id_get(
4965 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4966 BLKCIPHER_DES_DOCSIS_TYPE);
4968 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4970 return TEST_SUCCESS;
4974 test_3DES_chain_dpaa_sec_all(void)
4976 struct crypto_testsuite_params *ts_params = &testsuite_params;
4979 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4980 ts_params->op_mpool,
4981 ts_params->session_mpool,
4982 ts_params->valid_devs[0],
4983 rte_cryptodev_driver_id_get(
4984 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4985 BLKCIPHER_3DES_CHAIN_TYPE);
4987 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4989 return TEST_SUCCESS;
4993 test_3DES_cipheronly_dpaa_sec_all(void)
4995 struct crypto_testsuite_params *ts_params = &testsuite_params;
4998 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4999 ts_params->op_mpool,
5000 ts_params->session_mpool,
5001 ts_params->valid_devs[0],
5002 rte_cryptodev_driver_id_get(
5003 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5004 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5006 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5008 return TEST_SUCCESS;
5012 test_3DES_chain_dpaa2_sec_all(void)
5014 struct crypto_testsuite_params *ts_params = &testsuite_params;
5017 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5018 ts_params->op_mpool,
5019 ts_params->session_mpool,
5020 ts_params->valid_devs[0],
5021 rte_cryptodev_driver_id_get(
5022 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5023 BLKCIPHER_3DES_CHAIN_TYPE);
5025 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5027 return TEST_SUCCESS;
5031 test_3DES_cipheronly_dpaa2_sec_all(void)
5033 struct crypto_testsuite_params *ts_params = &testsuite_params;
5036 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5037 ts_params->op_mpool,
5038 ts_params->session_mpool,
5039 ts_params->valid_devs[0],
5040 rte_cryptodev_driver_id_get(
5041 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5042 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5044 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5046 return TEST_SUCCESS;
5050 test_3DES_chain_ccp_all(void)
5052 struct crypto_testsuite_params *ts_params = &testsuite_params;
5055 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5056 ts_params->op_mpool,
5057 ts_params->session_mpool,
5058 ts_params->valid_devs[0],
5059 rte_cryptodev_driver_id_get(
5060 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5061 BLKCIPHER_3DES_CHAIN_TYPE);
5063 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5065 return TEST_SUCCESS;
5069 test_3DES_cipheronly_ccp_all(void)
5071 struct crypto_testsuite_params *ts_params = &testsuite_params;
5074 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5075 ts_params->op_mpool,
5076 ts_params->session_mpool,
5077 ts_params->valid_devs[0],
5078 rte_cryptodev_driver_id_get(
5079 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5080 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5082 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5084 return TEST_SUCCESS;
5088 test_3DES_cipheronly_qat_all(void)
5090 struct crypto_testsuite_params *ts_params = &testsuite_params;
5093 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5094 ts_params->op_mpool,
5095 ts_params->session_mpool,
5096 ts_params->valid_devs[0],
5097 rte_cryptodev_driver_id_get(
5098 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5099 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5101 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5103 return TEST_SUCCESS;
5107 test_3DES_chain_openssl_all(void)
5109 struct crypto_testsuite_params *ts_params = &testsuite_params;
5112 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5113 ts_params->op_mpool,
5114 ts_params->session_mpool,
5115 ts_params->valid_devs[0],
5116 rte_cryptodev_driver_id_get(
5117 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5118 BLKCIPHER_3DES_CHAIN_TYPE);
5120 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5122 return TEST_SUCCESS;
5126 test_3DES_cipheronly_openssl_all(void)
5128 struct crypto_testsuite_params *ts_params = &testsuite_params;
5131 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5132 ts_params->op_mpool,
5133 ts_params->session_mpool,
5134 ts_params->valid_devs[0],
5135 rte_cryptodev_driver_id_get(
5136 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5137 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5139 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5141 return TEST_SUCCESS;
5144 /* ***** AEAD algorithm Tests ***** */
5147 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5148 enum rte_crypto_aead_operation op,
5149 const uint8_t *key, const uint8_t key_len,
5150 const uint16_t aad_len, const uint8_t auth_len,
5153 uint8_t aead_key[key_len];
5155 struct crypto_testsuite_params *ts_params = &testsuite_params;
5156 struct crypto_unittest_params *ut_params = &unittest_params;
5158 memcpy(aead_key, key, key_len);
5160 /* Setup AEAD Parameters */
5161 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5162 ut_params->aead_xform.next = NULL;
5163 ut_params->aead_xform.aead.algo = algo;
5164 ut_params->aead_xform.aead.op = op;
5165 ut_params->aead_xform.aead.key.data = aead_key;
5166 ut_params->aead_xform.aead.key.length = key_len;
5167 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5168 ut_params->aead_xform.aead.iv.length = iv_len;
5169 ut_params->aead_xform.aead.digest_length = auth_len;
5170 ut_params->aead_xform.aead.aad_length = aad_len;
5172 debug_hexdump(stdout, "key:", key, key_len);
5174 /* Create Crypto session*/
5175 ut_params->sess = rte_cryptodev_sym_session_create(
5176 ts_params->session_mpool);
5178 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5179 &ut_params->aead_xform, ts_params->session_mpool);
5181 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5187 create_aead_xform(struct rte_crypto_op *op,
5188 enum rte_crypto_aead_algorithm algo,
5189 enum rte_crypto_aead_operation aead_op,
5190 uint8_t *key, const uint8_t key_len,
5191 const uint8_t aad_len, const uint8_t auth_len,
5194 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5195 "failed to allocate space for crypto transform");
5197 struct rte_crypto_sym_op *sym_op = op->sym;
5199 /* Setup AEAD Parameters */
5200 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5201 sym_op->xform->next = NULL;
5202 sym_op->xform->aead.algo = algo;
5203 sym_op->xform->aead.op = aead_op;
5204 sym_op->xform->aead.key.data = key;
5205 sym_op->xform->aead.key.length = key_len;
5206 sym_op->xform->aead.iv.offset = IV_OFFSET;
5207 sym_op->xform->aead.iv.length = iv_len;
5208 sym_op->xform->aead.digest_length = auth_len;
5209 sym_op->xform->aead.aad_length = aad_len;
5211 debug_hexdump(stdout, "key:", key, key_len);
5217 create_aead_operation(enum rte_crypto_aead_operation op,
5218 const struct aead_test_data *tdata)
5220 struct crypto_testsuite_params *ts_params = &testsuite_params;
5221 struct crypto_unittest_params *ut_params = &unittest_params;
5223 uint8_t *plaintext, *ciphertext;
5224 unsigned int aad_pad_len, plaintext_pad_len;
5226 /* Generate Crypto op data structure */
5227 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5228 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5229 TEST_ASSERT_NOT_NULL(ut_params->op,
5230 "Failed to allocate symmetric crypto operation struct");
5232 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5234 /* Append aad data */
5235 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5236 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5237 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5239 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5240 "no room to append aad");
5242 sym_op->aead.aad.phys_addr =
5243 rte_pktmbuf_iova(ut_params->ibuf);
5244 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5245 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5246 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5249 /* Append IV at the end of the crypto operation*/
5250 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5251 uint8_t *, IV_OFFSET);
5253 /* Copy IV 1 byte after the IV pointer, according to the API */
5254 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5255 debug_hexdump(stdout, "iv:", iv_ptr,
5258 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5259 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5261 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5262 "no room to append aad");
5264 sym_op->aead.aad.phys_addr =
5265 rte_pktmbuf_iova(ut_params->ibuf);
5266 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5267 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5270 /* Append IV at the end of the crypto operation*/
5271 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5272 uint8_t *, IV_OFFSET);
5274 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5275 debug_hexdump(stdout, "iv:", iv_ptr,
5279 /* Append plaintext/ciphertext */
5280 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5281 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5282 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5284 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5286 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5287 debug_hexdump(stdout, "plaintext:", plaintext,
5288 tdata->plaintext.len);
5290 if (ut_params->obuf) {
5291 ciphertext = (uint8_t *)rte_pktmbuf_append(
5293 plaintext_pad_len + aad_pad_len);
5294 TEST_ASSERT_NOT_NULL(ciphertext,
5295 "no room to append ciphertext");
5297 memset(ciphertext + aad_pad_len, 0,
5298 tdata->ciphertext.len);
5301 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5302 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5304 TEST_ASSERT_NOT_NULL(ciphertext,
5305 "no room to append ciphertext");
5307 memcpy(ciphertext, tdata->ciphertext.data,
5308 tdata->ciphertext.len);
5309 debug_hexdump(stdout, "ciphertext:", ciphertext,
5310 tdata->ciphertext.len);
5312 if (ut_params->obuf) {
5313 plaintext = (uint8_t *)rte_pktmbuf_append(
5315 plaintext_pad_len + aad_pad_len);
5316 TEST_ASSERT_NOT_NULL(plaintext,
5317 "no room to append plaintext");
5319 memset(plaintext + aad_pad_len, 0,
5320 tdata->plaintext.len);
5324 /* Append digest data */
5325 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5326 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5327 ut_params->obuf ? ut_params->obuf :
5329 tdata->auth_tag.len);
5330 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5331 "no room to append digest");
5332 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5333 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5334 ut_params->obuf ? ut_params->obuf :
5339 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5340 ut_params->ibuf, tdata->auth_tag.len);
5341 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5342 "no room to append digest");
5343 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5345 plaintext_pad_len + aad_pad_len);
5347 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5348 tdata->auth_tag.len);
5349 debug_hexdump(stdout, "digest:",
5350 sym_op->aead.digest.data,
5351 tdata->auth_tag.len);
5354 sym_op->aead.data.length = tdata->plaintext.len;
5355 sym_op->aead.data.offset = aad_pad_len;
5361 test_authenticated_encryption(const struct aead_test_data *tdata)
5363 struct crypto_testsuite_params *ts_params = &testsuite_params;
5364 struct crypto_unittest_params *ut_params = &unittest_params;
5367 uint8_t *ciphertext, *auth_tag;
5368 uint16_t plaintext_pad_len;
5371 /* Create AEAD session */
5372 retval = create_aead_session(ts_params->valid_devs[0],
5374 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5375 tdata->key.data, tdata->key.len,
5376 tdata->aad.len, tdata->auth_tag.len,
5381 if (tdata->aad.len > MBUF_SIZE) {
5382 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5383 /* Populate full size of add data */
5384 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5385 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5387 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5389 /* clear mbuf payload */
5390 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5391 rte_pktmbuf_tailroom(ut_params->ibuf));
5393 /* Create AEAD operation */
5394 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5398 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5400 ut_params->op->sym->m_src = ut_params->ibuf;
5402 /* Process crypto operation */
5403 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5404 ut_params->op), "failed to process sym crypto op");
5406 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5407 "crypto op processing failed");
5409 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5411 if (ut_params->op->sym->m_dst) {
5412 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5414 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5415 uint8_t *, plaintext_pad_len);
5417 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5419 ut_params->op->sym->cipher.data.offset);
5420 auth_tag = ciphertext + plaintext_pad_len;
5423 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5424 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5429 tdata->ciphertext.data,
5430 tdata->ciphertext.len,
5431 "Ciphertext data not as expected");
5433 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5435 tdata->auth_tag.data,
5436 tdata->auth_tag.len,
5437 "Generated auth tag not as expected");
5444 test_AES_GCM_authenticated_encryption_test_case_1(void)
5446 return test_authenticated_encryption(&gcm_test_case_1);
5450 test_AES_GCM_authenticated_encryption_test_case_2(void)
5452 return test_authenticated_encryption(&gcm_test_case_2);
5456 test_AES_GCM_authenticated_encryption_test_case_3(void)
5458 return test_authenticated_encryption(&gcm_test_case_3);
5462 test_AES_GCM_authenticated_encryption_test_case_4(void)
5464 return test_authenticated_encryption(&gcm_test_case_4);
5468 test_AES_GCM_authenticated_encryption_test_case_5(void)
5470 return test_authenticated_encryption(&gcm_test_case_5);
5474 test_AES_GCM_authenticated_encryption_test_case_6(void)
5476 return test_authenticated_encryption(&gcm_test_case_6);
5480 test_AES_GCM_authenticated_encryption_test_case_7(void)
5482 return test_authenticated_encryption(&gcm_test_case_7);
5486 test_AES_GCM_auth_encryption_test_case_192_1(void)
5488 return test_authenticated_encryption(&gcm_test_case_192_1);
5492 test_AES_GCM_auth_encryption_test_case_192_2(void)
5494 return test_authenticated_encryption(&gcm_test_case_192_2);
5498 test_AES_GCM_auth_encryption_test_case_192_3(void)
5500 return test_authenticated_encryption(&gcm_test_case_192_3);
5504 test_AES_GCM_auth_encryption_test_case_192_4(void)
5506 return test_authenticated_encryption(&gcm_test_case_192_4);
5510 test_AES_GCM_auth_encryption_test_case_192_5(void)
5512 return test_authenticated_encryption(&gcm_test_case_192_5);
5516 test_AES_GCM_auth_encryption_test_case_192_6(void)
5518 return test_authenticated_encryption(&gcm_test_case_192_6);
5522 test_AES_GCM_auth_encryption_test_case_192_7(void)
5524 return test_authenticated_encryption(&gcm_test_case_192_7);
5528 test_AES_GCM_auth_encryption_test_case_256_1(void)
5530 return test_authenticated_encryption(&gcm_test_case_256_1);
5534 test_AES_GCM_auth_encryption_test_case_256_2(void)
5536 return test_authenticated_encryption(&gcm_test_case_256_2);
5540 test_AES_GCM_auth_encryption_test_case_256_3(void)
5542 return test_authenticated_encryption(&gcm_test_case_256_3);
5546 test_AES_GCM_auth_encryption_test_case_256_4(void)
5548 return test_authenticated_encryption(&gcm_test_case_256_4);
5552 test_AES_GCM_auth_encryption_test_case_256_5(void)
5554 return test_authenticated_encryption(&gcm_test_case_256_5);
5558 test_AES_GCM_auth_encryption_test_case_256_6(void)
5560 return test_authenticated_encryption(&gcm_test_case_256_6);
5564 test_AES_GCM_auth_encryption_test_case_256_7(void)
5566 return test_authenticated_encryption(&gcm_test_case_256_7);
5570 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5572 return test_authenticated_encryption(&gcm_test_case_aad_1);
5576 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5578 return test_authenticated_encryption(&gcm_test_case_aad_2);
5582 test_authenticated_decryption(const struct aead_test_data *tdata)
5584 struct crypto_testsuite_params *ts_params = &testsuite_params;
5585 struct crypto_unittest_params *ut_params = &unittest_params;
5591 /* Create AEAD session */
5592 retval = create_aead_session(ts_params->valid_devs[0],
5594 RTE_CRYPTO_AEAD_OP_DECRYPT,
5595 tdata->key.data, tdata->key.len,
5596 tdata->aad.len, tdata->auth_tag.len,
5601 /* alloc mbuf and set payload */
5602 if (tdata->aad.len > MBUF_SIZE) {
5603 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5604 /* Populate full size of add data */
5605 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5606 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5608 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5610 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5611 rte_pktmbuf_tailroom(ut_params->ibuf));
5613 /* Create AEAD operation */
5614 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5618 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5620 ut_params->op->sym->m_src = ut_params->ibuf;
5622 /* Process crypto operation */
5623 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5624 ut_params->op), "failed to process sym crypto op");
5626 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5627 "crypto op processing failed");
5629 if (ut_params->op->sym->m_dst)
5630 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5633 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5635 ut_params->op->sym->cipher.data.offset);
5637 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5640 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5642 tdata->plaintext.data,
5643 tdata->plaintext.len,
5644 "Plaintext data not as expected");
5646 TEST_ASSERT_EQUAL(ut_params->op->status,
5647 RTE_CRYPTO_OP_STATUS_SUCCESS,
5648 "Authentication failed");
5653 test_AES_GCM_authenticated_decryption_test_case_1(void)
5655 return test_authenticated_decryption(&gcm_test_case_1);
5659 test_AES_GCM_authenticated_decryption_test_case_2(void)
5661 return test_authenticated_decryption(&gcm_test_case_2);
5665 test_AES_GCM_authenticated_decryption_test_case_3(void)
5667 return test_authenticated_decryption(&gcm_test_case_3);
5671 test_AES_GCM_authenticated_decryption_test_case_4(void)
5673 return test_authenticated_decryption(&gcm_test_case_4);
5677 test_AES_GCM_authenticated_decryption_test_case_5(void)
5679 return test_authenticated_decryption(&gcm_test_case_5);
5683 test_AES_GCM_authenticated_decryption_test_case_6(void)
5685 return test_authenticated_decryption(&gcm_test_case_6);
5689 test_AES_GCM_authenticated_decryption_test_case_7(void)
5691 return test_authenticated_decryption(&gcm_test_case_7);
5695 test_AES_GCM_auth_decryption_test_case_192_1(void)
5697 return test_authenticated_decryption(&gcm_test_case_192_1);
5701 test_AES_GCM_auth_decryption_test_case_192_2(void)
5703 return test_authenticated_decryption(&gcm_test_case_192_2);
5707 test_AES_GCM_auth_decryption_test_case_192_3(void)
5709 return test_authenticated_decryption(&gcm_test_case_192_3);
5713 test_AES_GCM_auth_decryption_test_case_192_4(void)
5715 return test_authenticated_decryption(&gcm_test_case_192_4);
5719 test_AES_GCM_auth_decryption_test_case_192_5(void)
5721 return test_authenticated_decryption(&gcm_test_case_192_5);
5725 test_AES_GCM_auth_decryption_test_case_192_6(void)
5727 return test_authenticated_decryption(&gcm_test_case_192_6);
5731 test_AES_GCM_auth_decryption_test_case_192_7(void)
5733 return test_authenticated_decryption(&gcm_test_case_192_7);
5737 test_AES_GCM_auth_decryption_test_case_256_1(void)
5739 return test_authenticated_decryption(&gcm_test_case_256_1);
5743 test_AES_GCM_auth_decryption_test_case_256_2(void)
5745 return test_authenticated_decryption(&gcm_test_case_256_2);
5749 test_AES_GCM_auth_decryption_test_case_256_3(void)
5751 return test_authenticated_decryption(&gcm_test_case_256_3);
5755 test_AES_GCM_auth_decryption_test_case_256_4(void)
5757 return test_authenticated_decryption(&gcm_test_case_256_4);
5761 test_AES_GCM_auth_decryption_test_case_256_5(void)
5763 return test_authenticated_decryption(&gcm_test_case_256_5);
5767 test_AES_GCM_auth_decryption_test_case_256_6(void)
5769 return test_authenticated_decryption(&gcm_test_case_256_6);
5773 test_AES_GCM_auth_decryption_test_case_256_7(void)
5775 return test_authenticated_decryption(&gcm_test_case_256_7);
5779 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5781 return test_authenticated_decryption(&gcm_test_case_aad_1);
5785 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5787 return test_authenticated_decryption(&gcm_test_case_aad_2);
5791 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5793 struct crypto_testsuite_params *ts_params = &testsuite_params;
5794 struct crypto_unittest_params *ut_params = &unittest_params;
5797 uint8_t *ciphertext, *auth_tag;
5798 uint16_t plaintext_pad_len;
5800 /* Create AEAD session */
5801 retval = create_aead_session(ts_params->valid_devs[0],
5803 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5804 tdata->key.data, tdata->key.len,
5805 tdata->aad.len, tdata->auth_tag.len,
5810 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5811 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5813 /* clear mbuf payload */
5814 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5815 rte_pktmbuf_tailroom(ut_params->ibuf));
5816 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5817 rte_pktmbuf_tailroom(ut_params->obuf));
5819 /* Create AEAD operation */
5820 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5824 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5826 ut_params->op->sym->m_src = ut_params->ibuf;
5827 ut_params->op->sym->m_dst = ut_params->obuf;
5829 /* Process crypto operation */
5830 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5831 ut_params->op), "failed to process sym crypto op");
5833 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5834 "crypto op processing failed");
5836 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5838 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5839 ut_params->op->sym->cipher.data.offset);
5840 auth_tag = ciphertext + plaintext_pad_len;
5842 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5843 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5846 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5848 tdata->ciphertext.data,
5849 tdata->ciphertext.len,
5850 "Ciphertext data not as expected");
5852 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5854 tdata->auth_tag.data,
5855 tdata->auth_tag.len,
5856 "Generated auth tag not as expected");
5863 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5865 return test_authenticated_encryption_oop(&gcm_test_case_5);
5869 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5871 struct crypto_testsuite_params *ts_params = &testsuite_params;
5872 struct crypto_unittest_params *ut_params = &unittest_params;
5877 /* Create AEAD session */
5878 retval = create_aead_session(ts_params->valid_devs[0],
5880 RTE_CRYPTO_AEAD_OP_DECRYPT,
5881 tdata->key.data, tdata->key.len,
5882 tdata->aad.len, tdata->auth_tag.len,
5887 /* alloc mbuf and set payload */
5888 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5889 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5891 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5892 rte_pktmbuf_tailroom(ut_params->ibuf));
5893 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5894 rte_pktmbuf_tailroom(ut_params->obuf));
5896 /* Create AEAD operation */
5897 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5901 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5903 ut_params->op->sym->m_src = ut_params->ibuf;
5904 ut_params->op->sym->m_dst = ut_params->obuf;
5906 /* Process crypto operation */
5907 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5908 ut_params->op), "failed to process sym crypto op");
5910 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5911 "crypto op processing failed");
5913 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5914 ut_params->op->sym->cipher.data.offset);
5916 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5919 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5921 tdata->plaintext.data,
5922 tdata->plaintext.len,
5923 "Plaintext data not as expected");
5925 TEST_ASSERT_EQUAL(ut_params->op->status,
5926 RTE_CRYPTO_OP_STATUS_SUCCESS,
5927 "Authentication failed");
5932 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5934 return test_authenticated_decryption_oop(&gcm_test_case_5);
5938 test_authenticated_encryption_sessionless(
5939 const struct aead_test_data *tdata)
5941 struct crypto_testsuite_params *ts_params = &testsuite_params;
5942 struct crypto_unittest_params *ut_params = &unittest_params;
5945 uint8_t *ciphertext, *auth_tag;
5946 uint16_t plaintext_pad_len;
5947 uint8_t key[tdata->key.len + 1];
5949 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5951 /* clear mbuf payload */
5952 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5953 rte_pktmbuf_tailroom(ut_params->ibuf));
5955 /* Create AEAD operation */
5956 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5960 /* Create GCM xform */
5961 memcpy(key, tdata->key.data, tdata->key.len);
5962 retval = create_aead_xform(ut_params->op,
5964 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5965 key, tdata->key.len,
5966 tdata->aad.len, tdata->auth_tag.len,
5971 ut_params->op->sym->m_src = ut_params->ibuf;
5973 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5974 RTE_CRYPTO_OP_SESSIONLESS,
5975 "crypto op session type not sessionless");
5977 /* Process crypto operation */
5978 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5979 ut_params->op), "failed to process sym crypto op");
5981 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5983 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5984 "crypto op status not success");
5986 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5988 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5989 ut_params->op->sym->cipher.data.offset);
5990 auth_tag = ciphertext + plaintext_pad_len;
5992 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5993 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5996 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5998 tdata->ciphertext.data,
5999 tdata->ciphertext.len,
6000 "Ciphertext data not as expected");
6002 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6004 tdata->auth_tag.data,
6005 tdata->auth_tag.len,
6006 "Generated auth tag not as expected");
6013 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6015 return test_authenticated_encryption_sessionless(
6020 test_authenticated_decryption_sessionless(
6021 const struct aead_test_data *tdata)
6023 struct crypto_testsuite_params *ts_params = &testsuite_params;
6024 struct crypto_unittest_params *ut_params = &unittest_params;
6028 uint8_t key[tdata->key.len + 1];
6030 /* alloc mbuf and set payload */
6031 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6033 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6034 rte_pktmbuf_tailroom(ut_params->ibuf));
6036 /* Create AEAD operation */
6037 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6041 /* Create AEAD xform */
6042 memcpy(key, tdata->key.data, tdata->key.len);
6043 retval = create_aead_xform(ut_params->op,
6045 RTE_CRYPTO_AEAD_OP_DECRYPT,
6046 key, tdata->key.len,
6047 tdata->aad.len, tdata->auth_tag.len,
6052 ut_params->op->sym->m_src = ut_params->ibuf;
6054 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6055 RTE_CRYPTO_OP_SESSIONLESS,
6056 "crypto op session type not sessionless");
6058 /* Process crypto operation */
6059 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6060 ut_params->op), "failed to process sym crypto op");
6062 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6064 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6065 "crypto op status not success");
6067 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6068 ut_params->op->sym->cipher.data.offset);
6070 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6073 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6075 tdata->plaintext.data,
6076 tdata->plaintext.len,
6077 "Plaintext data not as expected");
6079 TEST_ASSERT_EQUAL(ut_params->op->status,
6080 RTE_CRYPTO_OP_STATUS_SUCCESS,
6081 "Authentication failed");
6086 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6088 return test_authenticated_decryption_sessionless(
6093 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6095 return test_authenticated_encryption(&ccm_test_case_128_1);
6099 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6101 return test_authenticated_encryption(&ccm_test_case_128_2);
6105 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6107 return test_authenticated_encryption(&ccm_test_case_128_3);
6111 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6113 return test_authenticated_decryption(&ccm_test_case_128_1);
6117 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6119 return test_authenticated_decryption(&ccm_test_case_128_2);
6123 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6125 return test_authenticated_decryption(&ccm_test_case_128_3);
6129 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6131 return test_authenticated_encryption(&ccm_test_case_192_1);
6135 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6137 return test_authenticated_encryption(&ccm_test_case_192_2);
6141 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6143 return test_authenticated_encryption(&ccm_test_case_192_3);
6147 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6149 return test_authenticated_decryption(&ccm_test_case_192_1);
6153 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6155 return test_authenticated_decryption(&ccm_test_case_192_2);
6159 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6161 return test_authenticated_decryption(&ccm_test_case_192_3);
6165 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6167 return test_authenticated_encryption(&ccm_test_case_256_1);
6171 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6173 return test_authenticated_encryption(&ccm_test_case_256_2);
6177 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6179 return test_authenticated_encryption(&ccm_test_case_256_3);
6183 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6185 return test_authenticated_decryption(&ccm_test_case_256_1);
6189 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6191 return test_authenticated_decryption(&ccm_test_case_256_2);
6195 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6197 return test_authenticated_decryption(&ccm_test_case_256_3);
6203 struct crypto_testsuite_params *ts_params = &testsuite_params;
6204 struct rte_cryptodev_stats stats;
6205 struct rte_cryptodev *dev;
6206 cryptodev_stats_get_t temp_pfn;
6208 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6209 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6210 &stats) == -ENODEV),
6211 "rte_cryptodev_stats_get invalid dev failed");
6212 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6213 "rte_cryptodev_stats_get invalid Param failed");
6214 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6215 temp_pfn = dev->dev_ops->stats_get;
6216 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6217 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6219 "rte_cryptodev_stats_get invalid Param failed");
6220 dev->dev_ops->stats_get = temp_pfn;
6222 /* Test expected values */
6224 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6226 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6228 "rte_cryptodev_stats_get failed");
6229 TEST_ASSERT((stats.enqueued_count == 1),
6230 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6231 TEST_ASSERT((stats.dequeued_count == 1),
6232 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6233 TEST_ASSERT((stats.enqueue_err_count == 0),
6234 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6235 TEST_ASSERT((stats.dequeue_err_count == 0),
6236 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6238 /* invalid device but should ignore and not reset device stats*/
6239 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6240 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6242 "rte_cryptodev_stats_get failed");
6243 TEST_ASSERT((stats.enqueued_count == 1),
6244 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6246 /* check that a valid reset clears stats */
6247 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6248 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6250 "rte_cryptodev_stats_get failed");
6251 TEST_ASSERT((stats.enqueued_count == 0),
6252 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6253 TEST_ASSERT((stats.dequeued_count == 0),
6254 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6256 return TEST_SUCCESS;
6259 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6260 struct crypto_unittest_params *ut_params,
6261 enum rte_crypto_auth_operation op,
6262 const struct HMAC_MD5_vector *test_case)
6266 memcpy(key, test_case->key.data, test_case->key.len);
6268 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6269 ut_params->auth_xform.next = NULL;
6270 ut_params->auth_xform.auth.op = op;
6272 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6274 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6275 ut_params->auth_xform.auth.key.length = test_case->key.len;
6276 ut_params->auth_xform.auth.key.data = key;
6278 ut_params->sess = rte_cryptodev_sym_session_create(
6279 ts_params->session_mpool);
6281 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6282 ut_params->sess, &ut_params->auth_xform,
6283 ts_params->session_mpool);
6285 if (ut_params->sess == NULL)
6288 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6290 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6291 rte_pktmbuf_tailroom(ut_params->ibuf));
6296 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6297 const struct HMAC_MD5_vector *test_case,
6298 uint8_t **plaintext)
6300 uint16_t plaintext_pad_len;
6302 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6304 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6307 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6309 memcpy(*plaintext, test_case->plaintext.data,
6310 test_case->plaintext.len);
6312 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6313 ut_params->ibuf, MD5_DIGEST_LEN);
6314 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6315 "no room to append digest");
6316 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6317 ut_params->ibuf, plaintext_pad_len);
6319 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6320 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6321 test_case->auth_tag.len);
6324 sym_op->auth.data.offset = 0;
6325 sym_op->auth.data.length = test_case->plaintext.len;
6327 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6328 ut_params->op->sym->m_src = ut_params->ibuf;
6334 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6336 uint16_t plaintext_pad_len;
6337 uint8_t *plaintext, *auth_tag;
6339 struct crypto_testsuite_params *ts_params = &testsuite_params;
6340 struct crypto_unittest_params *ut_params = &unittest_params;
6342 if (MD5_HMAC_create_session(ts_params, ut_params,
6343 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6346 /* Generate Crypto op data structure */
6347 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6348 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6349 TEST_ASSERT_NOT_NULL(ut_params->op,
6350 "Failed to allocate symmetric crypto operation struct");
6352 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6355 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6358 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6359 ut_params->op), "failed to process sym crypto op");
6361 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6362 "crypto op processing failed");
6364 if (ut_params->op->sym->m_dst) {
6365 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6366 uint8_t *, plaintext_pad_len);
6368 auth_tag = plaintext + plaintext_pad_len;
6371 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6373 test_case->auth_tag.data,
6374 test_case->auth_tag.len,
6375 "HMAC_MD5 generated tag not as expected");
6377 return TEST_SUCCESS;
6381 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6385 struct crypto_testsuite_params *ts_params = &testsuite_params;
6386 struct crypto_unittest_params *ut_params = &unittest_params;
6388 if (MD5_HMAC_create_session(ts_params, ut_params,
6389 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6393 /* Generate Crypto op data structure */
6394 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6395 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6396 TEST_ASSERT_NOT_NULL(ut_params->op,
6397 "Failed to allocate symmetric crypto operation struct");
6399 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6402 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6403 ut_params->op), "failed to process sym crypto op");
6405 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6406 "HMAC_MD5 crypto op processing failed");
6408 return TEST_SUCCESS;
6412 test_MD5_HMAC_generate_case_1(void)
6414 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6418 test_MD5_HMAC_verify_case_1(void)
6420 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6424 test_MD5_HMAC_generate_case_2(void)
6426 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6430 test_MD5_HMAC_verify_case_2(void)
6432 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6436 test_multi_session(void)
6438 struct crypto_testsuite_params *ts_params = &testsuite_params;
6439 struct crypto_unittest_params *ut_params = &unittest_params;
6441 struct rte_cryptodev_info dev_info;
6442 struct rte_cryptodev_sym_session **sessions;
6446 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6447 aes_cbc_key, hmac_sha512_key);
6450 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6452 sessions = rte_malloc(NULL,
6453 (sizeof(struct rte_cryptodev_sym_session *) *
6454 dev_info.sym.max_nb_sessions) + 1, 0);
6456 /* Create multiple crypto sessions*/
6457 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6459 sessions[i] = rte_cryptodev_sym_session_create(
6460 ts_params->session_mpool);
6462 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6463 sessions[i], &ut_params->auth_xform,
6464 ts_params->session_mpool);
6465 TEST_ASSERT_NOT_NULL(sessions[i],
6466 "Session creation failed at session number %u",
6469 /* Attempt to send a request on each session */
6470 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6474 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6475 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6477 "Failed to perform decrypt on request number %u.", i);
6478 /* free crypto operation structure */
6480 rte_crypto_op_free(ut_params->op);
6483 * free mbuf - both obuf and ibuf are usually the same,
6484 * so check if they point at the same address is necessary,
6485 * to avoid freeing the mbuf twice.
6487 if (ut_params->obuf) {
6488 rte_pktmbuf_free(ut_params->obuf);
6489 if (ut_params->ibuf == ut_params->obuf)
6490 ut_params->ibuf = 0;
6491 ut_params->obuf = 0;
6493 if (ut_params->ibuf) {
6494 rte_pktmbuf_free(ut_params->ibuf);
6495 ut_params->ibuf = 0;
6499 /* Next session create should fail */
6500 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6501 sessions[i], &ut_params->auth_xform,
6502 ts_params->session_mpool);
6503 TEST_ASSERT_NULL(sessions[i],
6504 "Session creation succeeded unexpectedly!");
6506 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6507 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6509 rte_cryptodev_sym_session_free(sessions[i]);
6514 return TEST_SUCCESS;
6517 struct multi_session_params {
6518 struct crypto_unittest_params ut_params;
6519 uint8_t *cipher_key;
6521 const uint8_t *cipher;
6522 const uint8_t *digest;
6526 #define MB_SESSION_NUMBER 3
6529 test_multi_session_random_usage(void)
6531 struct crypto_testsuite_params *ts_params = &testsuite_params;
6532 struct rte_cryptodev_info dev_info;
6533 struct rte_cryptodev_sym_session **sessions;
6535 struct multi_session_params ut_paramz[] = {
6538 .cipher_key = ms_aes_cbc_key0,
6539 .hmac_key = ms_hmac_key0,
6540 .cipher = ms_aes_cbc_cipher0,
6541 .digest = ms_hmac_digest0,
6542 .iv = ms_aes_cbc_iv0
6545 .cipher_key = ms_aes_cbc_key1,
6546 .hmac_key = ms_hmac_key1,
6547 .cipher = ms_aes_cbc_cipher1,
6548 .digest = ms_hmac_digest1,
6549 .iv = ms_aes_cbc_iv1
6552 .cipher_key = ms_aes_cbc_key2,
6553 .hmac_key = ms_hmac_key2,
6554 .cipher = ms_aes_cbc_cipher2,
6555 .digest = ms_hmac_digest2,
6556 .iv = ms_aes_cbc_iv2
6561 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6563 sessions = rte_malloc(NULL,
6564 (sizeof(struct rte_cryptodev_sym_session *)
6565 * dev_info.sym.max_nb_sessions) + 1, 0);
6567 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6568 sessions[i] = rte_cryptodev_sym_session_create(
6569 ts_params->session_mpool);
6571 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6572 sizeof(struct crypto_unittest_params));
6574 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6575 &ut_paramz[i].ut_params,
6576 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6578 /* Create multiple crypto sessions*/
6579 rte_cryptodev_sym_session_init(
6580 ts_params->valid_devs[0],
6582 &ut_paramz[i].ut_params.auth_xform,
6583 ts_params->session_mpool);
6585 TEST_ASSERT_NOT_NULL(sessions[i],
6586 "Session creation failed at session number %u",
6592 for (i = 0; i < 40000; i++) {
6594 j = rand() % MB_SESSION_NUMBER;
6596 TEST_ASSERT_SUCCESS(
6597 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6599 &ut_paramz[j].ut_params,
6600 ts_params, ut_paramz[j].cipher,
6601 ut_paramz[j].digest,
6603 "Failed to perform decrypt on request number %u.", i);
6605 if (ut_paramz[j].ut_params.op)
6606 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6609 * free mbuf - both obuf and ibuf are usually the same,
6610 * so check if they point at the same address is necessary,
6611 * to avoid freeing the mbuf twice.
6613 if (ut_paramz[j].ut_params.obuf) {
6614 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6615 if (ut_paramz[j].ut_params.ibuf
6616 == ut_paramz[j].ut_params.obuf)
6617 ut_paramz[j].ut_params.ibuf = 0;
6618 ut_paramz[j].ut_params.obuf = 0;
6620 if (ut_paramz[j].ut_params.ibuf) {
6621 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6622 ut_paramz[j].ut_params.ibuf = 0;
6626 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6627 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6629 rte_cryptodev_sym_session_free(sessions[i]);
6634 return TEST_SUCCESS;
6638 test_null_cipher_only_operation(void)
6640 struct crypto_testsuite_params *ts_params = &testsuite_params;
6641 struct crypto_unittest_params *ut_params = &unittest_params;
6643 /* Generate test mbuf data and space for digest */
6644 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6645 catch_22_quote, QUOTE_512_BYTES, 0);
6647 /* Setup Cipher Parameters */
6648 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6649 ut_params->cipher_xform.next = NULL;
6651 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6652 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6654 ut_params->sess = rte_cryptodev_sym_session_create(
6655 ts_params->session_mpool);
6657 /* Create Crypto session*/
6658 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6660 &ut_params->cipher_xform,
6661 ts_params->session_mpool);
6662 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6664 /* Generate Crypto op data structure */
6665 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6666 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6667 TEST_ASSERT_NOT_NULL(ut_params->op,
6668 "Failed to allocate symmetric crypto operation struct");
6670 /* Set crypto operation data parameters */
6671 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6673 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6675 /* set crypto operation source mbuf */
6676 sym_op->m_src = ut_params->ibuf;
6678 sym_op->cipher.data.offset = 0;
6679 sym_op->cipher.data.length = QUOTE_512_BYTES;
6681 /* Process crypto operation */
6682 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6684 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6686 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6687 "crypto operation processing failed");
6690 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6691 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6694 "Ciphertext data not as expected");
6696 return TEST_SUCCESS;
6698 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6699 0xab, 0xab, 0xab, 0xab,
6700 0xab, 0xab, 0xab, 0xab,
6701 0xab, 0xab, 0xab, 0xab};
6703 test_null_auth_only_operation(void)
6705 struct crypto_testsuite_params *ts_params = &testsuite_params;
6706 struct crypto_unittest_params *ut_params = &unittest_params;
6709 /* Generate test mbuf data and space for digest */
6710 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6711 catch_22_quote, QUOTE_512_BYTES, 0);
6713 /* create a pointer for digest, but don't expect anything to be written
6714 * here in a NULL auth algo so no mbuf append done.
6716 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6718 /* prefill the memory pointed to by digest */
6719 memcpy(digest, orig_data, sizeof(orig_data));
6721 /* Setup HMAC Parameters */
6722 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6723 ut_params->auth_xform.next = NULL;
6725 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6726 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6728 ut_params->sess = rte_cryptodev_sym_session_create(
6729 ts_params->session_mpool);
6731 /* Create Crypto session*/
6732 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6733 ut_params->sess, &ut_params->auth_xform,
6734 ts_params->session_mpool);
6735 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6737 /* Generate Crypto op data structure */
6738 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6739 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6740 TEST_ASSERT_NOT_NULL(ut_params->op,
6741 "Failed to allocate symmetric crypto operation struct");
6743 /* Set crypto operation data parameters */
6744 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6746 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6748 sym_op->m_src = ut_params->ibuf;
6750 sym_op->auth.data.offset = 0;
6751 sym_op->auth.data.length = QUOTE_512_BYTES;
6752 sym_op->auth.digest.data = digest;
6753 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6756 /* Process crypto operation */
6757 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6759 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6761 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6762 "crypto operation processing failed");
6763 /* Make sure memory pointed to by digest hasn't been overwritten */
6764 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6768 "Memory at digest ptr overwritten unexpectedly");
6770 return TEST_SUCCESS;
6775 test_null_cipher_auth_operation(void)
6777 struct crypto_testsuite_params *ts_params = &testsuite_params;
6778 struct crypto_unittest_params *ut_params = &unittest_params;
6781 /* Generate test mbuf data and space for digest */
6782 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6783 catch_22_quote, QUOTE_512_BYTES, 0);
6785 /* create a pointer for digest, but don't expect anything to be written
6786 * here in a NULL auth algo so no mbuf append done.
6788 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6790 /* prefill the memory pointed to by digest */
6791 memcpy(digest, orig_data, sizeof(orig_data));
6793 /* Setup Cipher Parameters */
6794 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6795 ut_params->cipher_xform.next = &ut_params->auth_xform;
6797 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6798 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6800 /* Setup HMAC Parameters */
6801 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6802 ut_params->auth_xform.next = NULL;
6804 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6805 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6807 ut_params->sess = rte_cryptodev_sym_session_create(
6808 ts_params->session_mpool);
6810 /* Create Crypto session*/
6811 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6812 ut_params->sess, &ut_params->cipher_xform,
6813 ts_params->session_mpool);
6814 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6816 /* Generate Crypto op data structure */
6817 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6818 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6819 TEST_ASSERT_NOT_NULL(ut_params->op,
6820 "Failed to allocate symmetric crypto operation struct");
6822 /* Set crypto operation data parameters */
6823 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6825 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6827 sym_op->m_src = ut_params->ibuf;
6829 sym_op->cipher.data.offset = 0;
6830 sym_op->cipher.data.length = QUOTE_512_BYTES;
6832 sym_op->auth.data.offset = 0;
6833 sym_op->auth.data.length = QUOTE_512_BYTES;
6834 sym_op->auth.digest.data = digest;
6835 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6838 /* Process crypto operation */
6839 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6841 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6843 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6844 "crypto operation processing failed");
6847 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6848 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6851 "Ciphertext data not as expected");
6852 /* Make sure memory pointed to by digest hasn't been overwritten */
6853 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6857 "Memory at digest ptr overwritten unexpectedly");
6859 return TEST_SUCCESS;
6863 test_null_auth_cipher_operation(void)
6865 struct crypto_testsuite_params *ts_params = &testsuite_params;
6866 struct crypto_unittest_params *ut_params = &unittest_params;
6869 /* Generate test mbuf data */
6870 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6871 catch_22_quote, QUOTE_512_BYTES, 0);
6873 /* create a pointer for digest, but don't expect anything to be written
6874 * here in a NULL auth algo so no mbuf append done.
6876 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6878 /* prefill the memory pointed to by digest */
6879 memcpy(digest, orig_data, sizeof(orig_data));
6881 /* Setup Cipher Parameters */
6882 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6883 ut_params->cipher_xform.next = NULL;
6885 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6886 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6888 /* Setup HMAC Parameters */
6889 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6890 ut_params->auth_xform.next = &ut_params->cipher_xform;
6892 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6893 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6895 ut_params->sess = rte_cryptodev_sym_session_create(
6896 ts_params->session_mpool);
6898 /* Create Crypto session*/
6899 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6900 ut_params->sess, &ut_params->cipher_xform,
6901 ts_params->session_mpool);
6902 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6904 /* Generate Crypto op data structure */
6905 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6906 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6907 TEST_ASSERT_NOT_NULL(ut_params->op,
6908 "Failed to allocate symmetric crypto operation struct");
6910 /* Set crypto operation data parameters */
6911 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6913 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6915 sym_op->m_src = ut_params->ibuf;
6917 sym_op->cipher.data.offset = 0;
6918 sym_op->cipher.data.length = QUOTE_512_BYTES;
6920 sym_op->auth.data.offset = 0;
6921 sym_op->auth.data.length = QUOTE_512_BYTES;
6922 sym_op->auth.digest.data = digest;
6923 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6926 /* Process crypto operation */
6927 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6929 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6931 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6932 "crypto operation processing failed");
6935 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6936 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6939 "Ciphertext data not as expected");
6940 /* Make sure memory pointed to by digest hasn't been overwritten */
6941 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6945 "Memory at digest ptr overwritten unexpectedly");
6947 return TEST_SUCCESS;
6952 test_null_invalid_operation(void)
6954 struct crypto_testsuite_params *ts_params = &testsuite_params;
6955 struct crypto_unittest_params *ut_params = &unittest_params;
6958 /* Setup Cipher Parameters */
6959 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6960 ut_params->cipher_xform.next = NULL;
6962 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6963 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6965 ut_params->sess = rte_cryptodev_sym_session_create(
6966 ts_params->session_mpool);
6968 /* Create Crypto session*/
6969 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6970 ut_params->sess, &ut_params->cipher_xform,
6971 ts_params->session_mpool);
6972 TEST_ASSERT(ret < 0,
6973 "Session creation succeeded unexpectedly");
6976 /* Setup HMAC Parameters */
6977 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6978 ut_params->auth_xform.next = NULL;
6980 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6981 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6983 ut_params->sess = rte_cryptodev_sym_session_create(
6984 ts_params->session_mpool);
6986 /* Create Crypto session*/
6987 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6988 ut_params->sess, &ut_params->auth_xform,
6989 ts_params->session_mpool);
6990 TEST_ASSERT(ret < 0,
6991 "Session creation succeeded unexpectedly");
6993 return TEST_SUCCESS;
6997 #define NULL_BURST_LENGTH (32)
7000 test_null_burst_operation(void)
7002 struct crypto_testsuite_params *ts_params = &testsuite_params;
7003 struct crypto_unittest_params *ut_params = &unittest_params;
7005 unsigned i, burst_len = NULL_BURST_LENGTH;
7007 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7008 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7010 /* Setup Cipher Parameters */
7011 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7012 ut_params->cipher_xform.next = &ut_params->auth_xform;
7014 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7015 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7017 /* Setup HMAC Parameters */
7018 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7019 ut_params->auth_xform.next = NULL;
7021 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7022 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7024 ut_params->sess = rte_cryptodev_sym_session_create(
7025 ts_params->session_mpool);
7027 /* Create Crypto session*/
7028 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7029 ut_params->sess, &ut_params->cipher_xform,
7030 ts_params->session_mpool);
7031 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7033 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7034 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7035 burst_len, "failed to generate burst of crypto ops");
7037 /* Generate an operation for each mbuf in burst */
7038 for (i = 0; i < burst_len; i++) {
7039 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7041 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7043 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7047 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7049 burst[i]->sym->m_src = m;
7052 /* Process crypto operation */
7053 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7054 0, burst, burst_len),
7056 "Error enqueuing burst");
7058 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7059 0, burst_dequeued, burst_len),
7061 "Error dequeuing burst");
7064 for (i = 0; i < burst_len; i++) {
7066 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7067 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7069 "data not as expected");
7071 rte_pktmbuf_free(burst[i]->sym->m_src);
7072 rte_crypto_op_free(burst[i]);
7075 return TEST_SUCCESS;
7079 generate_gmac_large_plaintext(uint8_t *data)
7083 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7084 memcpy(&data[i], &data[0], 32);
7088 create_gmac_operation(enum rte_crypto_auth_operation op,
7089 const struct gmac_test_data *tdata)
7091 struct crypto_testsuite_params *ts_params = &testsuite_params;
7092 struct crypto_unittest_params *ut_params = &unittest_params;
7093 struct rte_crypto_sym_op *sym_op;
7095 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7097 /* Generate Crypto op data structure */
7098 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7099 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7100 TEST_ASSERT_NOT_NULL(ut_params->op,
7101 "Failed to allocate symmetric crypto operation struct");
7103 sym_op = ut_params->op->sym;
7105 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7106 ut_params->ibuf, tdata->gmac_tag.len);
7107 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7108 "no room to append digest");
7110 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7111 ut_params->ibuf, plaintext_pad_len);
7113 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7114 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7115 tdata->gmac_tag.len);
7116 debug_hexdump(stdout, "digest:",
7117 sym_op->auth.digest.data,
7118 tdata->gmac_tag.len);
7121 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7122 uint8_t *, IV_OFFSET);
7124 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7126 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7128 sym_op->cipher.data.length = 0;
7129 sym_op->cipher.data.offset = 0;
7131 sym_op->auth.data.offset = 0;
7132 sym_op->auth.data.length = tdata->plaintext.len;
7137 static int create_gmac_session(uint8_t dev_id,
7138 const struct gmac_test_data *tdata,
7139 enum rte_crypto_auth_operation auth_op)
7141 uint8_t auth_key[tdata->key.len];
7143 struct crypto_testsuite_params *ts_params = &testsuite_params;
7144 struct crypto_unittest_params *ut_params = &unittest_params;
7146 memcpy(auth_key, tdata->key.data, tdata->key.len);
7148 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7149 ut_params->auth_xform.next = NULL;
7151 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7152 ut_params->auth_xform.auth.op = auth_op;
7153 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7154 ut_params->auth_xform.auth.key.length = tdata->key.len;
7155 ut_params->auth_xform.auth.key.data = auth_key;
7156 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7157 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7160 ut_params->sess = rte_cryptodev_sym_session_create(
7161 ts_params->session_mpool);
7163 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7164 &ut_params->auth_xform,
7165 ts_params->session_mpool);
7167 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7173 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7175 struct crypto_testsuite_params *ts_params = &testsuite_params;
7176 struct crypto_unittest_params *ut_params = &unittest_params;
7180 uint8_t *auth_tag, *plaintext;
7181 uint16_t plaintext_pad_len;
7183 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7184 "No GMAC length in the source data");
7186 retval = create_gmac_session(ts_params->valid_devs[0],
7187 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7192 if (tdata->plaintext.len > MBUF_SIZE)
7193 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7195 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7196 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7197 "Failed to allocate input buffer in mempool");
7199 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7200 rte_pktmbuf_tailroom(ut_params->ibuf));
7202 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7204 * Runtime generate the large plain text instead of use hard code
7205 * plain text vector. It is done to avoid create huge source file
7206 * with the test vector.
7208 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7209 generate_gmac_large_plaintext(tdata->plaintext.data);
7211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7213 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7215 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7216 debug_hexdump(stdout, "plaintext:", plaintext,
7217 tdata->plaintext.len);
7219 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7225 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7227 ut_params->op->sym->m_src = ut_params->ibuf;
7229 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7230 ut_params->op), "failed to process sym crypto op");
7232 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7233 "crypto op processing failed");
7235 if (ut_params->op->sym->m_dst) {
7236 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7237 uint8_t *, plaintext_pad_len);
7239 auth_tag = plaintext + plaintext_pad_len;
7242 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7244 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7246 tdata->gmac_tag.data,
7247 tdata->gmac_tag.len,
7248 "GMAC Generated auth tag not as expected");
7254 test_AES_GMAC_authentication_test_case_1(void)
7256 return test_AES_GMAC_authentication(&gmac_test_case_1);
7260 test_AES_GMAC_authentication_test_case_2(void)
7262 return test_AES_GMAC_authentication(&gmac_test_case_2);
7266 test_AES_GMAC_authentication_test_case_3(void)
7268 return test_AES_GMAC_authentication(&gmac_test_case_3);
7272 test_AES_GMAC_authentication_test_case_4(void)
7274 return test_AES_GMAC_authentication(&gmac_test_case_4);
7278 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7280 struct crypto_testsuite_params *ts_params = &testsuite_params;
7281 struct crypto_unittest_params *ut_params = &unittest_params;
7283 uint32_t plaintext_pad_len;
7286 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7287 "No GMAC length in the source data");
7289 retval = create_gmac_session(ts_params->valid_devs[0],
7290 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7295 if (tdata->plaintext.len > MBUF_SIZE)
7296 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7298 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7299 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7300 "Failed to allocate input buffer in mempool");
7302 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7303 rte_pktmbuf_tailroom(ut_params->ibuf));
7305 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7308 * Runtime generate the large plain text instead of use hard code
7309 * plain text vector. It is done to avoid create huge source file
7310 * with the test vector.
7312 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7313 generate_gmac_large_plaintext(tdata->plaintext.data);
7315 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7317 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7319 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7320 debug_hexdump(stdout, "plaintext:", plaintext,
7321 tdata->plaintext.len);
7323 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7329 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7331 ut_params->op->sym->m_src = ut_params->ibuf;
7333 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7334 ut_params->op), "failed to process sym crypto op");
7336 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7337 "crypto op processing failed");
7344 test_AES_GMAC_authentication_verify_test_case_1(void)
7346 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7350 test_AES_GMAC_authentication_verify_test_case_2(void)
7352 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7356 test_AES_GMAC_authentication_verify_test_case_3(void)
7358 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7362 test_AES_GMAC_authentication_verify_test_case_4(void)
7364 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7367 struct test_crypto_vector {
7368 enum rte_crypto_cipher_algorithm crypto_algo;
7381 const uint8_t *data;
7386 const uint8_t *data;
7390 enum rte_crypto_auth_algorithm auth_algo;
7398 const uint8_t *data;
7408 static const struct test_crypto_vector
7409 hmac_sha1_test_crypto_vector = {
7410 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7412 .data = plaintext_hash,
7417 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7418 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7419 0xDE, 0xF4, 0xDE, 0xAD
7425 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7426 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7427 0x3F, 0x91, 0x64, 0x59
7433 static const struct test_crypto_vector
7434 aes128_gmac_test_vector = {
7435 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7437 .data = plaintext_hash,
7442 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7443 0x08, 0x09, 0x0A, 0x0B
7449 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7450 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7456 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7457 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7463 static const struct test_crypto_vector
7464 aes128cbc_hmac_sha1_test_vector = {
7465 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7468 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7469 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7475 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7476 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7481 .data = plaintext_hash,
7485 .data = ciphertext512_aes128cbc,
7488 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7491 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7492 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7493 0xDE, 0xF4, 0xDE, 0xAD
7499 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7500 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7501 0x18, 0x8C, 0x1D, 0x32
7508 data_corruption(uint8_t *data)
7514 tag_corruption(uint8_t *data, unsigned int tag_offset)
7516 data[tag_offset] += 1;
7520 create_auth_session(struct crypto_unittest_params *ut_params,
7522 const struct test_crypto_vector *reference,
7523 enum rte_crypto_auth_operation auth_op)
7525 struct crypto_testsuite_params *ts_params = &testsuite_params;
7526 uint8_t auth_key[reference->auth_key.len + 1];
7528 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7530 /* Setup Authentication Parameters */
7531 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7532 ut_params->auth_xform.auth.op = auth_op;
7533 ut_params->auth_xform.next = NULL;
7534 ut_params->auth_xform.auth.algo = reference->auth_algo;
7535 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7536 ut_params->auth_xform.auth.key.data = auth_key;
7537 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7539 /* Create Crypto session*/
7540 ut_params->sess = rte_cryptodev_sym_session_create(
7541 ts_params->session_mpool);
7543 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7544 &ut_params->auth_xform,
7545 ts_params->session_mpool);
7547 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7553 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7555 const struct test_crypto_vector *reference,
7556 enum rte_crypto_auth_operation auth_op,
7557 enum rte_crypto_cipher_operation cipher_op)
7559 struct crypto_testsuite_params *ts_params = &testsuite_params;
7560 uint8_t cipher_key[reference->cipher_key.len + 1];
7561 uint8_t auth_key[reference->auth_key.len + 1];
7563 memcpy(cipher_key, reference->cipher_key.data,
7564 reference->cipher_key.len);
7565 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7567 /* Setup Authentication Parameters */
7568 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7569 ut_params->auth_xform.auth.op = auth_op;
7570 ut_params->auth_xform.auth.algo = reference->auth_algo;
7571 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7572 ut_params->auth_xform.auth.key.data = auth_key;
7573 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7575 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7576 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7577 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7579 ut_params->auth_xform.next = &ut_params->cipher_xform;
7581 /* Setup Cipher Parameters */
7582 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7583 ut_params->cipher_xform.next = NULL;
7584 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7585 ut_params->cipher_xform.cipher.op = cipher_op;
7586 ut_params->cipher_xform.cipher.key.data = cipher_key;
7587 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7588 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7589 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7592 /* Create Crypto session*/
7593 ut_params->sess = rte_cryptodev_sym_session_create(
7594 ts_params->session_mpool);
7596 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7597 &ut_params->auth_xform,
7598 ts_params->session_mpool);
7600 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7606 create_auth_operation(struct crypto_testsuite_params *ts_params,
7607 struct crypto_unittest_params *ut_params,
7608 const struct test_crypto_vector *reference,
7609 unsigned int auth_generate)
7611 /* Generate Crypto op data structure */
7612 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7613 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7614 TEST_ASSERT_NOT_NULL(ut_params->op,
7615 "Failed to allocate pktmbuf offload");
7617 /* Set crypto operation data parameters */
7618 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7620 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7622 /* set crypto operation source mbuf */
7623 sym_op->m_src = ut_params->ibuf;
7626 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7627 ut_params->ibuf, reference->digest.len);
7629 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7630 "no room to append auth tag");
7632 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7633 ut_params->ibuf, reference->plaintext.len);
7636 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7638 memcpy(sym_op->auth.digest.data,
7639 reference->digest.data,
7640 reference->digest.len);
7642 debug_hexdump(stdout, "digest:",
7643 sym_op->auth.digest.data,
7644 reference->digest.len);
7646 sym_op->auth.data.length = reference->plaintext.len;
7647 sym_op->auth.data.offset = 0;
7653 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7654 struct crypto_unittest_params *ut_params,
7655 const struct test_crypto_vector *reference,
7656 unsigned int auth_generate)
7658 /* Generate Crypto op data structure */
7659 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7660 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7661 TEST_ASSERT_NOT_NULL(ut_params->op,
7662 "Failed to allocate pktmbuf offload");
7664 /* Set crypto operation data parameters */
7665 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7667 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7669 /* set crypto operation source mbuf */
7670 sym_op->m_src = ut_params->ibuf;
7673 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7674 ut_params->ibuf, reference->digest.len);
7676 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7677 "no room to append auth tag");
7679 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7680 ut_params->ibuf, reference->ciphertext.len);
7683 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7685 memcpy(sym_op->auth.digest.data,
7686 reference->digest.data,
7687 reference->digest.len);
7689 debug_hexdump(stdout, "digest:",
7690 sym_op->auth.digest.data,
7691 reference->digest.len);
7693 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7694 reference->iv.data, reference->iv.len);
7696 sym_op->cipher.data.length = 0;
7697 sym_op->cipher.data.offset = 0;
7699 sym_op->auth.data.length = reference->plaintext.len;
7700 sym_op->auth.data.offset = 0;
7706 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7707 struct crypto_unittest_params *ut_params,
7708 const struct test_crypto_vector *reference,
7709 unsigned int auth_generate)
7711 /* Generate Crypto op data structure */
7712 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7713 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7714 TEST_ASSERT_NOT_NULL(ut_params->op,
7715 "Failed to allocate pktmbuf offload");
7717 /* Set crypto operation data parameters */
7718 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7720 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7722 /* set crypto operation source mbuf */
7723 sym_op->m_src = ut_params->ibuf;
7726 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7727 ut_params->ibuf, reference->digest.len);
7729 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7730 "no room to append auth tag");
7732 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7733 ut_params->ibuf, reference->ciphertext.len);
7736 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7738 memcpy(sym_op->auth.digest.data,
7739 reference->digest.data,
7740 reference->digest.len);
7742 debug_hexdump(stdout, "digest:",
7743 sym_op->auth.digest.data,
7744 reference->digest.len);
7746 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7747 reference->iv.data, reference->iv.len);
7749 sym_op->cipher.data.length = reference->ciphertext.len;
7750 sym_op->cipher.data.offset = 0;
7752 sym_op->auth.data.length = reference->ciphertext.len;
7753 sym_op->auth.data.offset = 0;
7759 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7760 struct crypto_unittest_params *ut_params,
7761 const struct test_crypto_vector *reference)
7763 return create_auth_operation(ts_params, ut_params, reference, 0);
7767 create_auth_verify_GMAC_operation(
7768 struct crypto_testsuite_params *ts_params,
7769 struct crypto_unittest_params *ut_params,
7770 const struct test_crypto_vector *reference)
7772 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7776 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7777 struct crypto_unittest_params *ut_params,
7778 const struct test_crypto_vector *reference)
7780 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7784 test_authentication_verify_fail_when_data_corruption(
7785 struct crypto_testsuite_params *ts_params,
7786 struct crypto_unittest_params *ut_params,
7787 const struct test_crypto_vector *reference,
7788 unsigned int data_corrupted)
7794 /* Create session */
7795 retval = create_auth_session(ut_params,
7796 ts_params->valid_devs[0],
7798 RTE_CRYPTO_AUTH_OP_VERIFY);
7802 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7803 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7804 "Failed to allocate input buffer in mempool");
7806 /* clear mbuf payload */
7807 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7808 rte_pktmbuf_tailroom(ut_params->ibuf));
7810 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7811 reference->plaintext.len);
7812 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7813 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7815 debug_hexdump(stdout, "plaintext:", plaintext,
7816 reference->plaintext.len);
7818 /* Create operation */
7819 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7825 data_corruption(plaintext);
7827 tag_corruption(plaintext, reference->plaintext.len);
7829 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7831 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7832 TEST_ASSERT_EQUAL(ut_params->op->status,
7833 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7834 "authentication not failed");
7836 ut_params->obuf = ut_params->op->sym->m_src;
7837 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7843 test_authentication_verify_GMAC_fail_when_corruption(
7844 struct crypto_testsuite_params *ts_params,
7845 struct crypto_unittest_params *ut_params,
7846 const struct test_crypto_vector *reference,
7847 unsigned int data_corrupted)
7852 /* Create session */
7853 retval = create_auth_cipher_session(ut_params,
7854 ts_params->valid_devs[0],
7856 RTE_CRYPTO_AUTH_OP_VERIFY,
7857 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7861 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7862 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7863 "Failed to allocate input buffer in mempool");
7865 /* clear mbuf payload */
7866 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7867 rte_pktmbuf_tailroom(ut_params->ibuf));
7869 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7870 reference->plaintext.len);
7871 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7872 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7874 debug_hexdump(stdout, "plaintext:", plaintext,
7875 reference->plaintext.len);
7877 /* Create operation */
7878 retval = create_auth_verify_GMAC_operation(ts_params,
7886 data_corruption(plaintext);
7888 tag_corruption(plaintext, reference->aad.len);
7890 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7892 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7893 TEST_ASSERT_EQUAL(ut_params->op->status,
7894 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7895 "authentication not failed");
7897 ut_params->obuf = ut_params->op->sym->m_src;
7898 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7904 test_authenticated_decryption_fail_when_corruption(
7905 struct crypto_testsuite_params *ts_params,
7906 struct crypto_unittest_params *ut_params,
7907 const struct test_crypto_vector *reference,
7908 unsigned int data_corrupted)
7912 uint8_t *ciphertext;
7914 /* Create session */
7915 retval = create_auth_cipher_session(ut_params,
7916 ts_params->valid_devs[0],
7918 RTE_CRYPTO_AUTH_OP_VERIFY,
7919 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7923 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7924 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7925 "Failed to allocate input buffer in mempool");
7927 /* clear mbuf payload */
7928 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7929 rte_pktmbuf_tailroom(ut_params->ibuf));
7931 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7932 reference->ciphertext.len);
7933 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7934 memcpy(ciphertext, reference->ciphertext.data,
7935 reference->ciphertext.len);
7937 /* Create operation */
7938 retval = create_cipher_auth_verify_operation(ts_params,
7946 data_corruption(ciphertext);
7948 tag_corruption(ciphertext, reference->ciphertext.len);
7950 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7953 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7954 TEST_ASSERT_EQUAL(ut_params->op->status,
7955 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7956 "authentication not failed");
7958 ut_params->obuf = ut_params->op->sym->m_src;
7959 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7965 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7966 const struct aead_test_data *tdata,
7967 void *digest_mem, uint64_t digest_phys)
7969 struct crypto_testsuite_params *ts_params = &testsuite_params;
7970 struct crypto_unittest_params *ut_params = &unittest_params;
7972 const unsigned int auth_tag_len = tdata->auth_tag.len;
7973 const unsigned int iv_len = tdata->iv.len;
7974 unsigned int aad_len = tdata->aad.len;
7976 /* Generate Crypto op data structure */
7977 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7978 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7979 TEST_ASSERT_NOT_NULL(ut_params->op,
7980 "Failed to allocate symmetric crypto operation struct");
7982 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7984 sym_op->aead.digest.data = digest_mem;
7986 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7987 "no room to append digest");
7989 sym_op->aead.digest.phys_addr = digest_phys;
7991 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7992 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7994 debug_hexdump(stdout, "digest:",
7995 sym_op->aead.digest.data,
7999 /* Append aad data */
8000 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8001 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8002 uint8_t *, IV_OFFSET);
8004 /* Copy IV 1 byte after the IV pointer, according to the API */
8005 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8007 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8009 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8010 ut_params->ibuf, aad_len);
8011 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8012 "no room to prepend aad");
8013 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8016 memset(sym_op->aead.aad.data, 0, aad_len);
8017 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8018 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8020 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8021 debug_hexdump(stdout, "aad:",
8022 sym_op->aead.aad.data, aad_len);
8024 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8025 uint8_t *, IV_OFFSET);
8027 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8029 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8030 ut_params->ibuf, aad_len);
8031 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8032 "no room to prepend aad");
8033 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8036 memset(sym_op->aead.aad.data, 0, aad_len);
8037 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8039 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8040 debug_hexdump(stdout, "aad:",
8041 sym_op->aead.aad.data, aad_len);
8044 sym_op->aead.data.length = tdata->plaintext.len;
8045 sym_op->aead.data.offset = aad_len;
8050 #define SGL_MAX_NO 16
8053 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8054 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8056 struct crypto_testsuite_params *ts_params = &testsuite_params;
8057 struct crypto_unittest_params *ut_params = &unittest_params;
8058 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8061 int to_trn_tbl[SGL_MAX_NO];
8063 unsigned int trn_data = 0;
8064 uint8_t *plaintext, *ciphertext, *auth_tag;
8066 if (fragsz > tdata->plaintext.len)
8067 fragsz = tdata->plaintext.len;
8069 uint16_t plaintext_len = fragsz;
8070 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8072 if (fragsz_oop > tdata->plaintext.len)
8073 frag_size_oop = tdata->plaintext.len;
8076 void *digest_mem = NULL;
8078 uint32_t prepend_len = tdata->aad.len;
8080 if (tdata->plaintext.len % fragsz != 0) {
8081 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8084 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8089 * For out-op-place we need to alloc another mbuf
8092 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8093 rte_pktmbuf_append(ut_params->obuf,
8094 frag_size_oop + prepend_len);
8095 buf_oop = ut_params->obuf;
8098 /* Create AEAD session */
8099 retval = create_aead_session(ts_params->valid_devs[0],
8101 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8102 tdata->key.data, tdata->key.len,
8103 tdata->aad.len, tdata->auth_tag.len,
8108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8110 /* clear mbuf payload */
8111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8112 rte_pktmbuf_tailroom(ut_params->ibuf));
8114 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8117 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8119 trn_data += plaintext_len;
8121 buf = ut_params->ibuf;
8124 * Loop until no more fragments
8127 while (trn_data < tdata->plaintext.len) {
8129 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8130 (tdata->plaintext.len - trn_data) : fragsz;
8132 to_trn_tbl[ecx++] = to_trn;
8134 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8137 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8138 rte_pktmbuf_tailroom(buf));
8141 if (oop && !fragsz_oop) {
8142 buf_last_oop = buf_oop->next =
8143 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8144 buf_oop = buf_oop->next;
8145 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8146 0, rte_pktmbuf_tailroom(buf_oop));
8147 rte_pktmbuf_append(buf_oop, to_trn);
8150 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8153 memcpy(plaintext, tdata->plaintext.data + trn_data,
8156 if (trn_data == tdata->plaintext.len) {
8159 digest_mem = rte_pktmbuf_append(buf_oop,
8160 tdata->auth_tag.len);
8162 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8163 tdata->auth_tag.len);
8167 uint64_t digest_phys = 0;
8169 ut_params->ibuf->nb_segs = segs;
8172 if (fragsz_oop && oop) {
8176 if (frag_size_oop == tdata->plaintext.len) {
8177 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8178 tdata->auth_tag.len);
8180 digest_phys = rte_pktmbuf_iova_offset(
8182 tdata->plaintext.len + prepend_len);
8185 trn_data = frag_size_oop;
8186 while (trn_data < tdata->plaintext.len) {
8189 (tdata->plaintext.len - trn_data <
8191 (tdata->plaintext.len - trn_data) :
8194 to_trn_tbl[ecx++] = to_trn;
8196 buf_last_oop = buf_oop->next =
8197 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8198 buf_oop = buf_oop->next;
8199 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8200 0, rte_pktmbuf_tailroom(buf_oop));
8201 rte_pktmbuf_append(buf_oop, to_trn);
8205 if (trn_data == tdata->plaintext.len) {
8206 digest_mem = rte_pktmbuf_append(buf_oop,
8207 tdata->auth_tag.len);
8211 ut_params->obuf->nb_segs = segs;
8215 * Place digest at the end of the last buffer
8218 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8219 if (oop && buf_last_oop)
8220 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8222 if (!digest_mem && !oop) {
8223 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8224 + tdata->auth_tag.len);
8225 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8226 tdata->plaintext.len);
8229 /* Create AEAD operation */
8230 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8231 tdata, digest_mem, digest_phys);
8236 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8238 ut_params->op->sym->m_src = ut_params->ibuf;
8240 ut_params->op->sym->m_dst = ut_params->obuf;
8242 /* Process crypto operation */
8243 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8244 ut_params->op), "failed to process sym crypto op");
8246 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8247 "crypto op processing failed");
8250 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8251 uint8_t *, prepend_len);
8253 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8254 uint8_t *, prepend_len);
8258 fragsz = fragsz_oop;
8260 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8262 tdata->ciphertext.data,
8264 "Ciphertext data not as expected");
8266 buf = ut_params->op->sym->m_src->next;
8268 buf = ut_params->op->sym->m_dst->next;
8270 unsigned int off = fragsz;
8274 ciphertext = rte_pktmbuf_mtod(buf,
8277 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8279 tdata->ciphertext.data + off,
8281 "Ciphertext data not as expected");
8283 off += to_trn_tbl[ecx++];
8287 auth_tag = digest_mem;
8288 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8290 tdata->auth_tag.data,
8291 tdata->auth_tag.len,
8292 "Generated auth tag not as expected");
8298 #define OUT_OF_PLACE 1
8301 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8303 return test_authenticated_encryption_SGL(
8304 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8308 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8310 return test_authenticated_encryption_SGL(
8311 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8315 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8317 return test_authenticated_encryption_SGL(
8318 &gcm_test_case_8, OUT_OF_PLACE, 400,
8319 gcm_test_case_8.plaintext.len);
8323 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8326 return test_authenticated_encryption_SGL(
8327 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8331 test_authentication_verify_fail_when_data_corrupted(
8332 struct crypto_testsuite_params *ts_params,
8333 struct crypto_unittest_params *ut_params,
8334 const struct test_crypto_vector *reference)
8336 return test_authentication_verify_fail_when_data_corruption(
8337 ts_params, ut_params, reference, 1);
8341 test_authentication_verify_fail_when_tag_corrupted(
8342 struct crypto_testsuite_params *ts_params,
8343 struct crypto_unittest_params *ut_params,
8344 const struct test_crypto_vector *reference)
8346 return test_authentication_verify_fail_when_data_corruption(
8347 ts_params, ut_params, reference, 0);
8351 test_authentication_verify_GMAC_fail_when_data_corrupted(
8352 struct crypto_testsuite_params *ts_params,
8353 struct crypto_unittest_params *ut_params,
8354 const struct test_crypto_vector *reference)
8356 return test_authentication_verify_GMAC_fail_when_corruption(
8357 ts_params, ut_params, reference, 1);
8361 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8362 struct crypto_testsuite_params *ts_params,
8363 struct crypto_unittest_params *ut_params,
8364 const struct test_crypto_vector *reference)
8366 return test_authentication_verify_GMAC_fail_when_corruption(
8367 ts_params, ut_params, reference, 0);
8371 test_authenticated_decryption_fail_when_data_corrupted(
8372 struct crypto_testsuite_params *ts_params,
8373 struct crypto_unittest_params *ut_params,
8374 const struct test_crypto_vector *reference)
8376 return test_authenticated_decryption_fail_when_corruption(
8377 ts_params, ut_params, reference, 1);
8381 test_authenticated_decryption_fail_when_tag_corrupted(
8382 struct crypto_testsuite_params *ts_params,
8383 struct crypto_unittest_params *ut_params,
8384 const struct test_crypto_vector *reference)
8386 return test_authenticated_decryption_fail_when_corruption(
8387 ts_params, ut_params, reference, 0);
8391 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8393 return test_authentication_verify_fail_when_data_corrupted(
8394 &testsuite_params, &unittest_params,
8395 &hmac_sha1_test_crypto_vector);
8399 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8401 return test_authentication_verify_fail_when_tag_corrupted(
8402 &testsuite_params, &unittest_params,
8403 &hmac_sha1_test_crypto_vector);
8407 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8409 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8410 &testsuite_params, &unittest_params,
8411 &aes128_gmac_test_vector);
8415 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8417 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8418 &testsuite_params, &unittest_params,
8419 &aes128_gmac_test_vector);
8423 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8425 return test_authenticated_decryption_fail_when_data_corrupted(
8428 &aes128cbc_hmac_sha1_test_vector);
8432 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8434 return test_authenticated_decryption_fail_when_tag_corrupted(
8437 &aes128cbc_hmac_sha1_test_vector);
8440 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8442 /* global AESNI slave IDs for the scheduler test */
8443 uint8_t aesni_ids[2];
8446 test_scheduler_attach_slave_op(void)
8448 struct crypto_testsuite_params *ts_params = &testsuite_params;
8449 uint8_t sched_id = ts_params->valid_devs[0];
8450 uint32_t nb_devs, i, nb_devs_attached = 0;
8454 /* create 2 AESNI_MB if necessary */
8455 nb_devs = rte_cryptodev_device_count_by_driver(
8456 rte_cryptodev_driver_id_get(
8457 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8459 for (i = nb_devs; i < 2; i++) {
8460 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8461 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8463 ret = rte_vdev_init(vdev_name, NULL);
8465 TEST_ASSERT(ret == 0,
8466 "Failed to create instance %u of"
8468 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8472 /* attach 2 AESNI_MB cdevs */
8473 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8475 struct rte_cryptodev_info info;
8477 rte_cryptodev_info_get(i, &info);
8478 if (info.driver_id != rte_cryptodev_driver_id_get(
8479 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8483 * Create the session mempool again, since now there are new devices
8484 * to use the mempool.
8486 if (ts_params->session_mpool) {
8487 rte_mempool_free(ts_params->session_mpool);
8488 ts_params->session_mpool = NULL;
8490 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8493 * Create mempool with maximum number of sessions * 2,
8494 * to include the session headers
8496 if (ts_params->session_mpool == NULL) {
8497 ts_params->session_mpool = rte_mempool_create(
8499 info.sym.max_nb_sessions * 2,
8501 0, 0, NULL, NULL, NULL,
8502 NULL, SOCKET_ID_ANY,
8505 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8506 "session mempool allocation failed");
8509 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8512 TEST_ASSERT(ret == 0,
8513 "Failed to attach device %u of pmd : %s", i,
8514 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8516 aesni_ids[nb_devs_attached] = (uint8_t)i;
8525 test_scheduler_detach_slave_op(void)
8527 struct crypto_testsuite_params *ts_params = &testsuite_params;
8528 uint8_t sched_id = ts_params->valid_devs[0];
8532 for (i = 0; i < 2; i++) {
8533 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8535 TEST_ASSERT(ret == 0,
8536 "Failed to detach device %u", aesni_ids[i]);
8543 test_scheduler_mode_op(void)
8545 struct crypto_testsuite_params *ts_params = &testsuite_params;
8546 uint8_t sched_id = ts_params->valid_devs[0];
8547 struct rte_cryptodev_scheduler_ops op = {0};
8548 struct rte_cryptodev_scheduler dummy_scheduler = {
8549 .description = "dummy scheduler to test mode",
8550 .name = "dummy scheduler",
8551 .mode = CDEV_SCHED_MODE_USERDEFINED,
8556 /* set user defined mode */
8557 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8559 TEST_ASSERT(ret == 0,
8560 "Failed to set cdev %u to user defined mode", sched_id);
8562 /* set round robin mode */
8563 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8564 CDEV_SCHED_MODE_ROUNDROBIN);
8565 TEST_ASSERT(ret == 0,
8566 "Failed to set cdev %u to round-robin mode", sched_id);
8567 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8568 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8574 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8575 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8576 .setup = testsuite_setup,
8577 .teardown = testsuite_teardown,
8578 .unit_test_cases = {
8579 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8580 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8581 TEST_CASE_ST(ut_setup, ut_teardown,
8582 test_AES_chain_scheduler_all),
8583 TEST_CASE_ST(ut_setup, ut_teardown,
8584 test_AES_cipheronly_scheduler_all),
8585 TEST_CASE_ST(ut_setup, ut_teardown,
8586 test_authonly_scheduler_all),
8587 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8588 TEST_CASES_END() /**< NULL terminate unit test array */
8592 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8594 static struct unit_test_suite cryptodev_qat_testsuite = {
8595 .suite_name = "Crypto QAT Unit Test Suite",
8596 .setup = testsuite_setup,
8597 .teardown = testsuite_teardown,
8598 .unit_test_cases = {
8599 TEST_CASE_ST(ut_setup, ut_teardown,
8600 test_device_configure_invalid_dev_id),
8601 TEST_CASE_ST(ut_setup, ut_teardown,
8602 test_device_configure_invalid_queue_pair_ids),
8603 TEST_CASE_ST(ut_setup, ut_teardown,
8604 test_queue_pair_descriptor_setup),
8605 TEST_CASE_ST(ut_setup, ut_teardown,
8606 test_multi_session),
8608 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8609 TEST_CASE_ST(ut_setup, ut_teardown,
8610 test_AES_cipheronly_qat_all),
8611 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8612 TEST_CASE_ST(ut_setup, ut_teardown,
8613 test_3DES_cipheronly_qat_all),
8614 TEST_CASE_ST(ut_setup, ut_teardown,
8615 test_DES_cipheronly_qat_all),
8616 TEST_CASE_ST(ut_setup, ut_teardown,
8617 test_AES_docsis_qat_all),
8618 TEST_CASE_ST(ut_setup, ut_teardown,
8619 test_DES_docsis_qat_all),
8620 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8621 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8623 /** AES CCM Authenticated Encryption 128 bits key */
8624 TEST_CASE_ST(ut_setup, ut_teardown,
8625 test_AES_CCM_authenticated_encryption_test_case_128_1),
8626 TEST_CASE_ST(ut_setup, ut_teardown,
8627 test_AES_CCM_authenticated_encryption_test_case_128_2),
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_AES_CCM_authenticated_encryption_test_case_128_3),
8631 /** AES CCM Authenticated Decryption 128 bits key*/
8632 TEST_CASE_ST(ut_setup, ut_teardown,
8633 test_AES_CCM_authenticated_decryption_test_case_128_1),
8634 TEST_CASE_ST(ut_setup, ut_teardown,
8635 test_AES_CCM_authenticated_decryption_test_case_128_2),
8636 TEST_CASE_ST(ut_setup, ut_teardown,
8637 test_AES_CCM_authenticated_decryption_test_case_128_3),
8639 /** AES GCM Authenticated Encryption */
8640 TEST_CASE_ST(ut_setup, ut_teardown,
8641 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8642 TEST_CASE_ST(ut_setup, ut_teardown,
8643 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8644 TEST_CASE_ST(ut_setup, ut_teardown,
8645 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8646 TEST_CASE_ST(ut_setup, ut_teardown,
8647 test_AES_GCM_authenticated_encryption_test_case_1),
8648 TEST_CASE_ST(ut_setup, ut_teardown,
8649 test_AES_GCM_authenticated_encryption_test_case_2),
8650 TEST_CASE_ST(ut_setup, ut_teardown,
8651 test_AES_GCM_authenticated_encryption_test_case_3),
8652 TEST_CASE_ST(ut_setup, ut_teardown,
8653 test_AES_GCM_authenticated_encryption_test_case_4),
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_AES_GCM_authenticated_encryption_test_case_5),
8656 TEST_CASE_ST(ut_setup, ut_teardown,
8657 test_AES_GCM_authenticated_encryption_test_case_6),
8658 TEST_CASE_ST(ut_setup, ut_teardown,
8659 test_AES_GCM_authenticated_encryption_test_case_7),
8661 /** AES GCM Authenticated Decryption */
8662 TEST_CASE_ST(ut_setup, ut_teardown,
8663 test_AES_GCM_authenticated_decryption_test_case_1),
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_AES_GCM_authenticated_decryption_test_case_2),
8666 TEST_CASE_ST(ut_setup, ut_teardown,
8667 test_AES_GCM_authenticated_decryption_test_case_3),
8668 TEST_CASE_ST(ut_setup, ut_teardown,
8669 test_AES_GCM_authenticated_decryption_test_case_4),
8670 TEST_CASE_ST(ut_setup, ut_teardown,
8671 test_AES_GCM_authenticated_decryption_test_case_5),
8672 TEST_CASE_ST(ut_setup, ut_teardown,
8673 test_AES_GCM_authenticated_decryption_test_case_6),
8674 TEST_CASE_ST(ut_setup, ut_teardown,
8675 test_AES_GCM_authenticated_decryption_test_case_7),
8677 /** AES GCM Authenticated Encryption 192 bits key */
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_AES_GCM_auth_encryption_test_case_192_1),
8680 TEST_CASE_ST(ut_setup, ut_teardown,
8681 test_AES_GCM_auth_encryption_test_case_192_2),
8682 TEST_CASE_ST(ut_setup, ut_teardown,
8683 test_AES_GCM_auth_encryption_test_case_192_3),
8684 TEST_CASE_ST(ut_setup, ut_teardown,
8685 test_AES_GCM_auth_encryption_test_case_192_4),
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_AES_GCM_auth_encryption_test_case_192_5),
8688 TEST_CASE_ST(ut_setup, ut_teardown,
8689 test_AES_GCM_auth_encryption_test_case_192_6),
8690 TEST_CASE_ST(ut_setup, ut_teardown,
8691 test_AES_GCM_auth_encryption_test_case_192_7),
8693 /** AES GCM Authenticated Decryption 192 bits key */
8694 TEST_CASE_ST(ut_setup, ut_teardown,
8695 test_AES_GCM_auth_decryption_test_case_192_1),
8696 TEST_CASE_ST(ut_setup, ut_teardown,
8697 test_AES_GCM_auth_decryption_test_case_192_2),
8698 TEST_CASE_ST(ut_setup, ut_teardown,
8699 test_AES_GCM_auth_decryption_test_case_192_3),
8700 TEST_CASE_ST(ut_setup, ut_teardown,
8701 test_AES_GCM_auth_decryption_test_case_192_4),
8702 TEST_CASE_ST(ut_setup, ut_teardown,
8703 test_AES_GCM_auth_decryption_test_case_192_5),
8704 TEST_CASE_ST(ut_setup, ut_teardown,
8705 test_AES_GCM_auth_decryption_test_case_192_6),
8706 TEST_CASE_ST(ut_setup, ut_teardown,
8707 test_AES_GCM_auth_decryption_test_case_192_7),
8709 /** AES GCM Authenticated Encryption 256 bits key */
8710 TEST_CASE_ST(ut_setup, ut_teardown,
8711 test_AES_GCM_auth_encryption_test_case_256_1),
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_AES_GCM_auth_encryption_test_case_256_2),
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_AES_GCM_auth_encryption_test_case_256_3),
8716 TEST_CASE_ST(ut_setup, ut_teardown,
8717 test_AES_GCM_auth_encryption_test_case_256_4),
8718 TEST_CASE_ST(ut_setup, ut_teardown,
8719 test_AES_GCM_auth_encryption_test_case_256_5),
8720 TEST_CASE_ST(ut_setup, ut_teardown,
8721 test_AES_GCM_auth_encryption_test_case_256_6),
8722 TEST_CASE_ST(ut_setup, ut_teardown,
8723 test_AES_GCM_auth_encryption_test_case_256_7),
8725 /** AES GMAC Authentication */
8726 TEST_CASE_ST(ut_setup, ut_teardown,
8727 test_AES_GMAC_authentication_test_case_1),
8728 TEST_CASE_ST(ut_setup, ut_teardown,
8729 test_AES_GMAC_authentication_verify_test_case_1),
8730 TEST_CASE_ST(ut_setup, ut_teardown,
8731 test_AES_GMAC_authentication_test_case_2),
8732 TEST_CASE_ST(ut_setup, ut_teardown,
8733 test_AES_GMAC_authentication_verify_test_case_2),
8734 TEST_CASE_ST(ut_setup, ut_teardown,
8735 test_AES_GMAC_authentication_test_case_3),
8736 TEST_CASE_ST(ut_setup, ut_teardown,
8737 test_AES_GMAC_authentication_verify_test_case_3),
8739 /** SNOW 3G encrypt only (UEA2) */
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_snow3g_encryption_test_case_1),
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_snow3g_encryption_test_case_2),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_snow3g_encryption_test_case_3),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_snow3g_encryption_test_case_4),
8748 TEST_CASE_ST(ut_setup, ut_teardown,
8749 test_snow3g_encryption_test_case_5),
8751 TEST_CASE_ST(ut_setup, ut_teardown,
8752 test_snow3g_encryption_test_case_1_oop),
8753 TEST_CASE_ST(ut_setup, ut_teardown,
8754 test_snow3g_decryption_test_case_1_oop),
8756 /** SNOW 3G decrypt only (UEA2) */
8757 TEST_CASE_ST(ut_setup, ut_teardown,
8758 test_snow3g_decryption_test_case_1),
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 test_snow3g_decryption_test_case_2),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 test_snow3g_decryption_test_case_3),
8763 TEST_CASE_ST(ut_setup, ut_teardown,
8764 test_snow3g_decryption_test_case_4),
8765 TEST_CASE_ST(ut_setup, ut_teardown,
8766 test_snow3g_decryption_test_case_5),
8767 TEST_CASE_ST(ut_setup, ut_teardown,
8768 test_snow3g_hash_generate_test_case_1),
8769 TEST_CASE_ST(ut_setup, ut_teardown,
8770 test_snow3g_hash_generate_test_case_2),
8771 TEST_CASE_ST(ut_setup, ut_teardown,
8772 test_snow3g_hash_generate_test_case_3),
8773 TEST_CASE_ST(ut_setup, ut_teardown,
8774 test_snow3g_hash_verify_test_case_1),
8775 TEST_CASE_ST(ut_setup, ut_teardown,
8776 test_snow3g_hash_verify_test_case_2),
8777 TEST_CASE_ST(ut_setup, ut_teardown,
8778 test_snow3g_hash_verify_test_case_3),
8779 TEST_CASE_ST(ut_setup, ut_teardown,
8780 test_snow3g_cipher_auth_test_case_1),
8781 TEST_CASE_ST(ut_setup, ut_teardown,
8782 test_snow3g_auth_cipher_test_case_1),
8784 /** ZUC encrypt only (EEA3) */
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_zuc_encryption_test_case_1),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_zuc_encryption_test_case_2),
8789 TEST_CASE_ST(ut_setup, ut_teardown,
8790 test_zuc_encryption_test_case_3),
8791 TEST_CASE_ST(ut_setup, ut_teardown,
8792 test_zuc_encryption_test_case_4),
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_zuc_encryption_test_case_5),
8796 /** ZUC authenticate (EIA3) */
8797 TEST_CASE_ST(ut_setup, ut_teardown,
8798 test_zuc_hash_generate_test_case_6),
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_zuc_hash_generate_test_case_7),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_zuc_hash_generate_test_case_8),
8804 /** ZUC alg-chain (EEA3/EIA3) */
8805 TEST_CASE_ST(ut_setup, ut_teardown,
8806 test_zuc_cipher_auth_test_case_1),
8807 TEST_CASE_ST(ut_setup, ut_teardown,
8808 test_zuc_cipher_auth_test_case_2),
8810 /** HMAC_MD5 Authentication */
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_MD5_HMAC_generate_case_1),
8813 TEST_CASE_ST(ut_setup, ut_teardown,
8814 test_MD5_HMAC_verify_case_1),
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_MD5_HMAC_generate_case_2),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_MD5_HMAC_verify_case_2),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_null_auth_only_operation),
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_null_cipher_only_operation),
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_null_cipher_auth_operation),
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_null_auth_cipher_operation),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_kasumi_hash_generate_test_case_1),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_kasumi_hash_generate_test_case_2),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_kasumi_hash_generate_test_case_3),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_kasumi_hash_generate_test_case_4),
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_kasumi_hash_generate_test_case_5),
8841 TEST_CASE_ST(ut_setup, ut_teardown,
8842 test_kasumi_hash_generate_test_case_6),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_kasumi_hash_verify_test_case_1),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_kasumi_hash_verify_test_case_2),
8848 TEST_CASE_ST(ut_setup, ut_teardown,
8849 test_kasumi_hash_verify_test_case_3),
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_kasumi_hash_verify_test_case_4),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_kasumi_hash_verify_test_case_5),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_kasumi_encryption_test_case_1),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_kasumi_encryption_test_case_3),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_kasumi_auth_cipher_test_case_1),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_kasumi_cipher_auth_test_case_1),
8864 /** Negative tests */
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 authentication_verify_AES128_GMAC_fail_data_corrupt),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8878 TEST_CASES_END() /**< NULL terminate unit test array */
8882 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8883 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8884 .setup = testsuite_setup,
8885 .teardown = testsuite_teardown,
8886 .unit_test_cases = {
8887 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8888 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8889 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8890 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_DES_cipheronly_mb_all),
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_DES_docsis_mb_all),
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_AES_CCM_authenticated_encryption_test_case_128_1),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_AES_CCM_authenticated_decryption_test_case_128_1),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_AES_CCM_authenticated_encryption_test_case_128_2),
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_CCM_authenticated_decryption_test_case_128_2),
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_AES_CCM_authenticated_encryption_test_case_128_3),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_CCM_authenticated_decryption_test_case_128_3),
8908 TEST_CASES_END() /**< NULL terminate unit test array */
8912 static struct unit_test_suite cryptodev_openssl_testsuite = {
8913 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8914 .setup = testsuite_setup,
8915 .teardown = testsuite_teardown,
8916 .unit_test_cases = {
8917 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8918 TEST_CASE_ST(ut_setup, ut_teardown,
8919 test_multi_session_random_usage),
8920 TEST_CASE_ST(ut_setup, ut_teardown,
8921 test_AES_chain_openssl_all),
8922 TEST_CASE_ST(ut_setup, ut_teardown,
8923 test_AES_cipheronly_openssl_all),
8924 TEST_CASE_ST(ut_setup, ut_teardown,
8925 test_3DES_chain_openssl_all),
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_3DES_cipheronly_openssl_all),
8928 TEST_CASE_ST(ut_setup, ut_teardown,
8929 test_DES_cipheronly_openssl_all),
8930 TEST_CASE_ST(ut_setup, ut_teardown,
8931 test_DES_docsis_openssl_all),
8932 TEST_CASE_ST(ut_setup, ut_teardown,
8933 test_authonly_openssl_all),
8935 /** AES GCM Authenticated Encryption */
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_AES_GCM_authenticated_encryption_test_case_1),
8938 TEST_CASE_ST(ut_setup, ut_teardown,
8939 test_AES_GCM_authenticated_encryption_test_case_2),
8940 TEST_CASE_ST(ut_setup, ut_teardown,
8941 test_AES_GCM_authenticated_encryption_test_case_3),
8942 TEST_CASE_ST(ut_setup, ut_teardown,
8943 test_AES_GCM_authenticated_encryption_test_case_4),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_AES_GCM_authenticated_encryption_test_case_5),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_AES_GCM_authenticated_encryption_test_case_6),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_AES_GCM_authenticated_encryption_test_case_7),
8951 /** AES GCM Authenticated Decryption */
8952 TEST_CASE_ST(ut_setup, ut_teardown,
8953 test_AES_GCM_authenticated_decryption_test_case_1),
8954 TEST_CASE_ST(ut_setup, ut_teardown,
8955 test_AES_GCM_authenticated_decryption_test_case_2),
8956 TEST_CASE_ST(ut_setup, ut_teardown,
8957 test_AES_GCM_authenticated_decryption_test_case_3),
8958 TEST_CASE_ST(ut_setup, ut_teardown,
8959 test_AES_GCM_authenticated_decryption_test_case_4),
8960 TEST_CASE_ST(ut_setup, ut_teardown,
8961 test_AES_GCM_authenticated_decryption_test_case_5),
8962 TEST_CASE_ST(ut_setup, ut_teardown,
8963 test_AES_GCM_authenticated_decryption_test_case_6),
8964 TEST_CASE_ST(ut_setup, ut_teardown,
8965 test_AES_GCM_authenticated_decryption_test_case_7),
8968 /** AES GCM Authenticated Encryption 192 bits key */
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 test_AES_GCM_auth_encryption_test_case_192_1),
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 test_AES_GCM_auth_encryption_test_case_192_2),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_AES_GCM_auth_encryption_test_case_192_3),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_AES_GCM_auth_encryption_test_case_192_4),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_AES_GCM_auth_encryption_test_case_192_5),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_AES_GCM_auth_encryption_test_case_192_6),
8981 TEST_CASE_ST(ut_setup, ut_teardown,
8982 test_AES_GCM_auth_encryption_test_case_192_7),
8984 /** AES GCM Authenticated Decryption 192 bits key */
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_AES_GCM_auth_decryption_test_case_192_1),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_AES_GCM_auth_decryption_test_case_192_2),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_AES_GCM_auth_decryption_test_case_192_3),
8991 TEST_CASE_ST(ut_setup, ut_teardown,
8992 test_AES_GCM_auth_decryption_test_case_192_4),
8993 TEST_CASE_ST(ut_setup, ut_teardown,
8994 test_AES_GCM_auth_decryption_test_case_192_5),
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 test_AES_GCM_auth_decryption_test_case_192_6),
8997 TEST_CASE_ST(ut_setup, ut_teardown,
8998 test_AES_GCM_auth_decryption_test_case_192_7),
9000 /** AES GCM Authenticated Encryption 256 bits key */
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_AES_GCM_auth_encryption_test_case_256_1),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_AES_GCM_auth_encryption_test_case_256_2),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_GCM_auth_encryption_test_case_256_3),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_GCM_auth_encryption_test_case_256_4),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_AES_GCM_auth_encryption_test_case_256_5),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_GCM_auth_encryption_test_case_256_6),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 test_AES_GCM_auth_encryption_test_case_256_7),
9016 /** AES GCM Authenticated Decryption 256 bits key */
9017 TEST_CASE_ST(ut_setup, ut_teardown,
9018 test_AES_GCM_auth_decryption_test_case_256_1),
9019 TEST_CASE_ST(ut_setup, ut_teardown,
9020 test_AES_GCM_auth_decryption_test_case_256_2),
9021 TEST_CASE_ST(ut_setup, ut_teardown,
9022 test_AES_GCM_auth_decryption_test_case_256_3),
9023 TEST_CASE_ST(ut_setup, ut_teardown,
9024 test_AES_GCM_auth_decryption_test_case_256_4),
9025 TEST_CASE_ST(ut_setup, ut_teardown,
9026 test_AES_GCM_auth_decryption_test_case_256_5),
9027 TEST_CASE_ST(ut_setup, ut_teardown,
9028 test_AES_GCM_auth_decryption_test_case_256_6),
9029 TEST_CASE_ST(ut_setup, ut_teardown,
9030 test_AES_GCM_auth_decryption_test_case_256_7),
9032 /** AES GMAC Authentication */
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_AES_GMAC_authentication_test_case_1),
9035 TEST_CASE_ST(ut_setup, ut_teardown,
9036 test_AES_GMAC_authentication_verify_test_case_1),
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_AES_GMAC_authentication_test_case_2),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_AES_GMAC_authentication_verify_test_case_2),
9041 TEST_CASE_ST(ut_setup, ut_teardown,
9042 test_AES_GMAC_authentication_test_case_3),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_GMAC_authentication_verify_test_case_3),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_GMAC_authentication_test_case_4),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_GMAC_authentication_verify_test_case_4),
9050 /** AES CCM Authenticated Encryption 128 bits key */
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_AES_CCM_authenticated_encryption_test_case_128_1),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_AES_CCM_authenticated_encryption_test_case_128_2),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_AES_CCM_authenticated_encryption_test_case_128_3),
9058 /** AES CCM Authenticated Decryption 128 bits key*/
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_AES_CCM_authenticated_decryption_test_case_128_1),
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_AES_CCM_authenticated_decryption_test_case_128_2),
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_CCM_authenticated_decryption_test_case_128_3),
9066 /** AES CCM Authenticated Encryption 192 bits key */
9067 TEST_CASE_ST(ut_setup, ut_teardown,
9068 test_AES_CCM_authenticated_encryption_test_case_192_1),
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_AES_CCM_authenticated_encryption_test_case_192_2),
9071 TEST_CASE_ST(ut_setup, ut_teardown,
9072 test_AES_CCM_authenticated_encryption_test_case_192_3),
9074 /** AES CCM Authenticated Decryption 192 bits key*/
9075 TEST_CASE_ST(ut_setup, ut_teardown,
9076 test_AES_CCM_authenticated_decryption_test_case_192_1),
9077 TEST_CASE_ST(ut_setup, ut_teardown,
9078 test_AES_CCM_authenticated_decryption_test_case_192_2),
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_CCM_authenticated_decryption_test_case_192_3),
9082 /** AES CCM Authenticated Encryption 256 bits key */
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_AES_CCM_authenticated_encryption_test_case_256_1),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_CCM_authenticated_encryption_test_case_256_2),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_AES_CCM_authenticated_encryption_test_case_256_3),
9090 /** AES CCM Authenticated Decryption 256 bits key*/
9091 TEST_CASE_ST(ut_setup, ut_teardown,
9092 test_AES_CCM_authenticated_decryption_test_case_256_1),
9093 TEST_CASE_ST(ut_setup, ut_teardown,
9094 test_AES_CCM_authenticated_decryption_test_case_256_2),
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_AES_CCM_authenticated_decryption_test_case_256_3),
9098 /** Scatter-Gather */
9099 TEST_CASE_ST(ut_setup, ut_teardown,
9100 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9102 /** Negative tests */
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9105 TEST_CASE_ST(ut_setup, ut_teardown,
9106 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9107 TEST_CASE_ST(ut_setup, ut_teardown,
9108 authentication_verify_AES128_GMAC_fail_data_corrupt),
9109 TEST_CASE_ST(ut_setup, ut_teardown,
9110 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9116 TEST_CASES_END() /**< NULL terminate unit test array */
9120 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9121 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9122 .setup = testsuite_setup,
9123 .teardown = testsuite_teardown,
9124 .unit_test_cases = {
9125 /** AES GCM Authenticated Encryption */
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_AES_GCM_authenticated_encryption_test_case_1),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_AES_GCM_authenticated_encryption_test_case_2),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_AES_GCM_authenticated_encryption_test_case_3),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_AES_GCM_authenticated_encryption_test_case_4),
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_AES_GCM_authenticated_encryption_test_case_5),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_AES_GCM_authenticated_encryption_test_case_6),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_AES_GCM_authenticated_encryption_test_case_7),
9141 /** AES GCM Authenticated Decryption */
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_AES_GCM_authenticated_decryption_test_case_1),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_AES_GCM_authenticated_decryption_test_case_2),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_AES_GCM_authenticated_decryption_test_case_3),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_AES_GCM_authenticated_decryption_test_case_4),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_AES_GCM_authenticated_decryption_test_case_5),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_AES_GCM_authenticated_decryption_test_case_6),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_authenticated_decryption_test_case_7),
9157 /** AES GCM Authenticated Encryption 192 bits key */
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_AES_GCM_auth_encryption_test_case_192_1),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_AES_GCM_auth_encryption_test_case_192_2),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_AES_GCM_auth_encryption_test_case_192_3),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_AES_GCM_auth_encryption_test_case_192_4),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_AES_GCM_auth_encryption_test_case_192_5),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_AES_GCM_auth_encryption_test_case_192_6),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_AES_GCM_auth_encryption_test_case_192_7),
9173 /** AES GCM Authenticated Decryption 192 bits key */
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_AES_GCM_auth_decryption_test_case_192_1),
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_AES_GCM_auth_decryption_test_case_192_2),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_AES_GCM_auth_decryption_test_case_192_3),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_AES_GCM_auth_decryption_test_case_192_4),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_AES_GCM_auth_decryption_test_case_192_5),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_AES_GCM_auth_decryption_test_case_192_6),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_AES_GCM_auth_decryption_test_case_192_7),
9189 /** AES GCM Authenticated Encryption 256 bits key */
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_AES_GCM_auth_encryption_test_case_256_1),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_AES_GCM_auth_encryption_test_case_256_2),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_AES_GCM_auth_encryption_test_case_256_3),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_AES_GCM_auth_encryption_test_case_256_4),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_AES_GCM_auth_encryption_test_case_256_5),
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_AES_GCM_auth_encryption_test_case_256_6),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_AES_GCM_auth_encryption_test_case_256_7),
9205 /** AES GCM Authenticated Decryption 256 bits key */
9206 TEST_CASE_ST(ut_setup, ut_teardown,
9207 test_AES_GCM_auth_decryption_test_case_256_1),
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 test_AES_GCM_auth_decryption_test_case_256_2),
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_AES_GCM_auth_decryption_test_case_256_3),
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_AES_GCM_auth_decryption_test_case_256_4),
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_AES_GCM_auth_decryption_test_case_256_5),
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_AES_GCM_auth_decryption_test_case_256_6),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_AES_GCM_auth_decryption_test_case_256_7),
9221 /** AES GCM Authenticated Encryption big aad size */
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_AES_GCM_auth_encryption_test_case_aad_1),
9224 TEST_CASE_ST(ut_setup, ut_teardown,
9225 test_AES_GCM_auth_encryption_test_case_aad_2),
9227 /** AES GCM Authenticated Decryption big aad size */
9228 TEST_CASE_ST(ut_setup, ut_teardown,
9229 test_AES_GCM_auth_decryption_test_case_aad_1),
9230 TEST_CASE_ST(ut_setup, ut_teardown,
9231 test_AES_GCM_auth_decryption_test_case_aad_2),
9233 /** AES GMAC Authentication */
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 test_AES_GMAC_authentication_test_case_1),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_AES_GMAC_authentication_verify_test_case_1),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_AES_GMAC_authentication_test_case_3),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 test_AES_GMAC_authentication_verify_test_case_3),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_AES_GMAC_authentication_test_case_4),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_AES_GMAC_authentication_verify_test_case_4),
9247 /** Negative tests */
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 authentication_verify_AES128_GMAC_fail_data_corrupt),
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9253 /** Out of place tests */
9254 TEST_CASE_ST(ut_setup, ut_teardown,
9255 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9256 TEST_CASE_ST(ut_setup, ut_teardown,
9257 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9259 /** Session-less tests */
9260 TEST_CASE_ST(ut_setup, ut_teardown,
9261 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9262 TEST_CASE_ST(ut_setup, ut_teardown,
9263 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9265 /** Scatter-Gather */
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9269 TEST_CASES_END() /**< NULL terminate unit test array */
9273 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9274 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9275 .setup = testsuite_setup,
9276 .teardown = testsuite_teardown,
9277 .unit_test_cases = {
9278 /** KASUMI encrypt only (UEA1) */
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_kasumi_encryption_test_case_1),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_kasumi_encryption_test_case_1_sgl),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_kasumi_encryption_test_case_2),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_kasumi_encryption_test_case_3),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_kasumi_encryption_test_case_4),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_kasumi_encryption_test_case_5),
9291 /** KASUMI decrypt only (UEA1) */
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_kasumi_decryption_test_case_1),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_kasumi_decryption_test_case_2),
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_kasumi_decryption_test_case_3),
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_kasumi_decryption_test_case_4),
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_kasumi_decryption_test_case_5),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_kasumi_encryption_test_case_1_oop),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_kasumi_encryption_test_case_1_oop_sgl),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_kasumi_decryption_test_case_1_oop),
9312 /** KASUMI hash only (UIA1) */
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_kasumi_hash_generate_test_case_1),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_kasumi_hash_generate_test_case_2),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_kasumi_hash_generate_test_case_3),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_kasumi_hash_generate_test_case_4),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_kasumi_hash_generate_test_case_5),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_kasumi_hash_generate_test_case_6),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_kasumi_hash_verify_test_case_1),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_kasumi_hash_verify_test_case_2),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_kasumi_hash_verify_test_case_3),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_kasumi_hash_verify_test_case_4),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_kasumi_hash_verify_test_case_5),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_kasumi_auth_cipher_test_case_1),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_kasumi_cipher_auth_test_case_1),
9339 TEST_CASES_END() /**< NULL terminate unit test array */
9342 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9343 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9344 .setup = testsuite_setup,
9345 .teardown = testsuite_teardown,
9346 .unit_test_cases = {
9347 /** SNOW 3G encrypt only (UEA2) */
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_snow3g_encryption_test_case_1),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_snow3g_encryption_test_case_2),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_snow3g_encryption_test_case_3),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_snow3g_encryption_test_case_4),
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_snow3g_encryption_test_case_5),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_snow3g_encryption_test_case_1_oop),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_snow3g_encryption_test_case_1_oop_sgl),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_snow3g_decryption_test_case_1_oop),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_snow3g_encryption_test_case_1_offset_oop),
9369 /** SNOW 3G decrypt only (UEA2) */
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_snow3g_decryption_test_case_1),
9372 TEST_CASE_ST(ut_setup, ut_teardown,
9373 test_snow3g_decryption_test_case_2),
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_snow3g_decryption_test_case_3),
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_snow3g_decryption_test_case_4),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_snow3g_decryption_test_case_5),
9380 TEST_CASE_ST(ut_setup, ut_teardown,
9381 test_snow3g_hash_generate_test_case_1),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_snow3g_hash_generate_test_case_2),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_snow3g_hash_generate_test_case_3),
9386 /* Tests with buffers which length is not byte-aligned */
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_snow3g_hash_generate_test_case_4),
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_snow3g_hash_generate_test_case_5),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_snow3g_hash_generate_test_case_6),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_snow3g_hash_verify_test_case_1),
9395 TEST_CASE_ST(ut_setup, ut_teardown,
9396 test_snow3g_hash_verify_test_case_2),
9397 TEST_CASE_ST(ut_setup, ut_teardown,
9398 test_snow3g_hash_verify_test_case_3),
9399 /* Tests with buffers which length is not byte-aligned */
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_snow3g_hash_verify_test_case_4),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_snow3g_hash_verify_test_case_5),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_snow3g_hash_verify_test_case_6),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_snow3g_cipher_auth_test_case_1),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_snow3g_auth_cipher_test_case_1),
9411 TEST_CASES_END() /**< NULL terminate unit test array */
9415 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9416 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9417 .setup = testsuite_setup,
9418 .teardown = testsuite_teardown,
9419 .unit_test_cases = {
9420 /** ZUC encrypt only (EEA3) */
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_zuc_encryption_test_case_1),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_zuc_encryption_test_case_2),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_zuc_encryption_test_case_3),
9427 TEST_CASE_ST(ut_setup, ut_teardown,
9428 test_zuc_encryption_test_case_4),
9429 TEST_CASE_ST(ut_setup, ut_teardown,
9430 test_zuc_encryption_test_case_5),
9431 TEST_CASE_ST(ut_setup, ut_teardown,
9432 test_zuc_hash_generate_test_case_1),
9433 TEST_CASE_ST(ut_setup, ut_teardown,
9434 test_zuc_hash_generate_test_case_2),
9435 TEST_CASE_ST(ut_setup, ut_teardown,
9436 test_zuc_hash_generate_test_case_3),
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_zuc_hash_generate_test_case_4),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_zuc_hash_generate_test_case_5),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_zuc_encryption_test_case_6_sgl),
9443 TEST_CASES_END() /**< NULL terminate unit test array */
9447 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9448 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9449 .setup = testsuite_setup,
9450 .teardown = testsuite_teardown,
9451 .unit_test_cases = {
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_device_configure_invalid_dev_id),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_multi_session),
9457 TEST_CASE_ST(ut_setup, ut_teardown,
9458 test_AES_chain_dpaa_sec_all),
9459 TEST_CASE_ST(ut_setup, ut_teardown,
9460 test_3DES_chain_dpaa_sec_all),
9461 TEST_CASE_ST(ut_setup, ut_teardown,
9462 test_AES_cipheronly_dpaa_sec_all),
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_3DES_cipheronly_dpaa_sec_all),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_authonly_dpaa_sec_all),
9468 /** AES GCM Authenticated Encryption */
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_AES_GCM_authenticated_encryption_test_case_1),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_AES_GCM_authenticated_encryption_test_case_2),
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_AES_GCM_authenticated_encryption_test_case_3),
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_AES_GCM_authenticated_encryption_test_case_4),
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_AES_GCM_authenticated_encryption_test_case_5),
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_AES_GCM_authenticated_encryption_test_case_6),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_AES_GCM_authenticated_encryption_test_case_7),
9484 /** AES GCM Authenticated Decryption */
9485 TEST_CASE_ST(ut_setup, ut_teardown,
9486 test_AES_GCM_authenticated_decryption_test_case_1),
9487 TEST_CASE_ST(ut_setup, ut_teardown,
9488 test_AES_GCM_authenticated_decryption_test_case_2),
9489 TEST_CASE_ST(ut_setup, ut_teardown,
9490 test_AES_GCM_authenticated_decryption_test_case_3),
9491 TEST_CASE_ST(ut_setup, ut_teardown,
9492 test_AES_GCM_authenticated_decryption_test_case_4),
9493 TEST_CASE_ST(ut_setup, ut_teardown,
9494 test_AES_GCM_authenticated_decryption_test_case_5),
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_AES_GCM_authenticated_decryption_test_case_6),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_AES_GCM_authenticated_decryption_test_case_7),
9500 /** AES GCM Authenticated Encryption 256 bits key */
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_AES_GCM_auth_encryption_test_case_256_1),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_AES_GCM_auth_encryption_test_case_256_2),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_AES_GCM_auth_encryption_test_case_256_3),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_AES_GCM_auth_encryption_test_case_256_4),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_AES_GCM_auth_encryption_test_case_256_5),
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_AES_GCM_auth_encryption_test_case_256_6),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_AES_GCM_auth_encryption_test_case_256_7),
9516 /** AES GCM Authenticated Decryption 256 bits key */
9517 TEST_CASE_ST(ut_setup, ut_teardown,
9518 test_AES_GCM_auth_decryption_test_case_256_1),
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_AES_GCM_auth_decryption_test_case_256_2),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_GCM_auth_decryption_test_case_256_3),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_GCM_auth_decryption_test_case_256_4),
9525 TEST_CASE_ST(ut_setup, ut_teardown,
9526 test_AES_GCM_auth_decryption_test_case_256_5),
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_AES_GCM_auth_decryption_test_case_256_6),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_AES_GCM_auth_decryption_test_case_256_7),
9532 /** Out of place tests */
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9538 /** Scatter-Gather */
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9541 TEST_CASE_ST(ut_setup, ut_teardown,
9542 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9548 TEST_CASES_END() /**< NULL terminate unit test array */
9552 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9553 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9554 .setup = testsuite_setup,
9555 .teardown = testsuite_teardown,
9556 .unit_test_cases = {
9557 TEST_CASE_ST(ut_setup, ut_teardown,
9558 test_device_configure_invalid_dev_id),
9559 TEST_CASE_ST(ut_setup, ut_teardown,
9560 test_multi_session),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_AES_chain_dpaa2_sec_all),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_3DES_chain_dpaa2_sec_all),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_AES_cipheronly_dpaa2_sec_all),
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_3DES_cipheronly_dpaa2_sec_all),
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 test_authonly_dpaa2_sec_all),
9573 /** AES GCM Authenticated Encryption */
9574 TEST_CASE_ST(ut_setup, ut_teardown,
9575 test_AES_GCM_authenticated_encryption_test_case_1),
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 test_AES_GCM_authenticated_encryption_test_case_2),
9578 TEST_CASE_ST(ut_setup, ut_teardown,
9579 test_AES_GCM_authenticated_encryption_test_case_3),
9580 TEST_CASE_ST(ut_setup, ut_teardown,
9581 test_AES_GCM_authenticated_encryption_test_case_4),
9582 TEST_CASE_ST(ut_setup, ut_teardown,
9583 test_AES_GCM_authenticated_encryption_test_case_5),
9584 TEST_CASE_ST(ut_setup, ut_teardown,
9585 test_AES_GCM_authenticated_encryption_test_case_6),
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_AES_GCM_authenticated_encryption_test_case_7),
9589 /** AES GCM Authenticated Decryption */
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_AES_GCM_authenticated_decryption_test_case_1),
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_AES_GCM_authenticated_decryption_test_case_2),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_GCM_authenticated_decryption_test_case_3),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_authenticated_decryption_test_case_4),
9598 TEST_CASE_ST(ut_setup, ut_teardown,
9599 test_AES_GCM_authenticated_decryption_test_case_5),
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_GCM_authenticated_decryption_test_case_6),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_authenticated_decryption_test_case_7),
9605 /** AES GCM Authenticated Encryption 192 bits key */
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_auth_encryption_test_case_192_1),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_auth_encryption_test_case_192_2),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_auth_encryption_test_case_192_3),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_auth_encryption_test_case_192_4),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_auth_encryption_test_case_192_5),
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_auth_encryption_test_case_192_6),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_auth_encryption_test_case_192_7),
9621 /** AES GCM Authenticated Decryption 192 bits key */
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_auth_decryption_test_case_192_1),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GCM_auth_decryption_test_case_192_2),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GCM_auth_decryption_test_case_192_3),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GCM_auth_decryption_test_case_192_4),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GCM_auth_decryption_test_case_192_5),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GCM_auth_decryption_test_case_192_6),
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_decryption_test_case_192_7),
9637 /** AES GCM Authenticated Encryption 256 bits key */
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_encryption_test_case_256_1),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 test_AES_GCM_auth_encryption_test_case_256_2),
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_GCM_auth_encryption_test_case_256_3),
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_auth_encryption_test_case_256_4),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_auth_encryption_test_case_256_5),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_auth_encryption_test_case_256_6),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_encryption_test_case_256_7),
9653 /** AES GCM Authenticated Decryption 256 bits key */
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_decryption_test_case_256_1),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_GCM_auth_decryption_test_case_256_2),
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_GCM_auth_decryption_test_case_256_3),
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_auth_decryption_test_case_256_4),
9662 TEST_CASE_ST(ut_setup, ut_teardown,
9663 test_AES_GCM_auth_decryption_test_case_256_5),
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_GCM_auth_decryption_test_case_256_6),
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_decryption_test_case_256_7),
9669 /** Out of place tests */
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9675 /** Scatter-Gather */
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9685 TEST_CASES_END() /**< NULL terminate unit test array */
9689 static struct unit_test_suite cryptodev_null_testsuite = {
9690 .suite_name = "Crypto Device NULL Unit Test Suite",
9691 .setup = testsuite_setup,
9692 .teardown = testsuite_teardown,
9693 .unit_test_cases = {
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 test_null_auth_only_operation),
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_null_cipher_only_operation),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_null_cipher_auth_operation),
9700 TEST_CASE_ST(ut_setup, ut_teardown,
9701 test_null_auth_cipher_operation),
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_null_invalid_operation),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_null_burst_operation),
9707 TEST_CASES_END() /**< NULL terminate unit test array */
9711 static struct unit_test_suite cryptodev_armv8_testsuite = {
9712 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9713 .setup = testsuite_setup,
9714 .teardown = testsuite_teardown,
9715 .unit_test_cases = {
9716 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9718 /** Negative tests */
9719 TEST_CASE_ST(ut_setup, ut_teardown,
9720 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9721 TEST_CASE_ST(ut_setup, ut_teardown,
9722 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9724 TEST_CASES_END() /**< NULL terminate unit test array */
9728 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9729 .suite_name = "Crypto Device Marvell Component Test Suite",
9730 .setup = testsuite_setup,
9731 .teardown = testsuite_teardown,
9732 .unit_test_cases = {
9733 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_multi_session_random_usage),
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_AES_chain_mrvl_all),
9738 TEST_CASE_ST(ut_setup, ut_teardown,
9739 test_AES_cipheronly_mrvl_all),
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_authonly_mrvl_all),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_3DES_chain_mrvl_all),
9744 TEST_CASE_ST(ut_setup, ut_teardown,
9745 test_3DES_cipheronly_mrvl_all),
9747 /** Negative tests */
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9757 TEST_CASES_END() /**< NULL terminate unit test array */
9761 static struct unit_test_suite cryptodev_ccp_testsuite = {
9762 .suite_name = "Crypto Device CCP Unit Test Suite",
9763 .setup = testsuite_setup,
9764 .teardown = testsuite_teardown,
9765 .unit_test_cases = {
9766 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_multi_session_random_usage),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_AES_chain_ccp_all),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_AES_cipheronly_ccp_all),
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_3DES_chain_ccp_all),
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_3DES_cipheronly_ccp_all),
9777 TEST_CASE_ST(ut_setup, ut_teardown,
9778 test_authonly_ccp_all),
9780 /** Negative tests */
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9790 TEST_CASES_END() /**< NULL terminate unit test array */
9795 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9797 gbl_driver_id = rte_cryptodev_driver_id_get(
9798 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9800 if (gbl_driver_id == -1) {
9801 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9802 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9803 "in config file to run this testsuite.\n");
9804 return TEST_SKIPPED;
9807 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9811 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9813 gbl_driver_id = rte_cryptodev_driver_id_get(
9814 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9816 if (gbl_driver_id == -1) {
9817 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9818 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9819 "in config file to run this testsuite.\n");
9820 return TEST_SKIPPED;
9823 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9827 test_cryptodev_openssl(void)
9829 gbl_driver_id = rte_cryptodev_driver_id_get(
9830 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9832 if (gbl_driver_id == -1) {
9833 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9834 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9835 "in config file to run this testsuite.\n");
9836 return TEST_SKIPPED;
9839 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9843 test_cryptodev_aesni_gcm(void)
9845 gbl_driver_id = rte_cryptodev_driver_id_get(
9846 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9848 if (gbl_driver_id == -1) {
9849 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9850 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9851 "in config file to run this testsuite.\n");
9852 return TEST_SKIPPED;
9855 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9859 test_cryptodev_null(void)
9861 gbl_driver_id = rte_cryptodev_driver_id_get(
9862 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9864 if (gbl_driver_id == -1) {
9865 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9866 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9867 "in config file to run this testsuite.\n");
9868 return TEST_SKIPPED;
9871 return unit_test_suite_runner(&cryptodev_null_testsuite);
9875 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9877 gbl_driver_id = rte_cryptodev_driver_id_get(
9878 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9880 if (gbl_driver_id == -1) {
9881 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9882 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9883 "in config file to run this testsuite.\n");
9884 return TEST_SKIPPED;
9887 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9891 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9893 gbl_driver_id = rte_cryptodev_driver_id_get(
9894 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9896 if (gbl_driver_id == -1) {
9897 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9898 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9899 "in config file to run this testsuite.\n");
9900 return TEST_SKIPPED;
9903 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9907 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9909 gbl_driver_id = rte_cryptodev_driver_id_get(
9910 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9912 if (gbl_driver_id == -1) {
9913 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9914 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9915 "in config file to run this testsuite.\n");
9916 return TEST_SKIPPED;
9919 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9923 test_cryptodev_armv8(void)
9925 gbl_driver_id = rte_cryptodev_driver_id_get(
9926 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9928 if (gbl_driver_id == -1) {
9929 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9930 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9931 "in config file to run this testsuite.\n");
9932 return TEST_SKIPPED;
9935 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9939 test_cryptodev_mrvl(void)
9941 gbl_driver_id = rte_cryptodev_driver_id_get(
9942 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9944 if (gbl_driver_id == -1) {
9945 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9946 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9947 "in config file to run this testsuite.\n");
9948 return TEST_SKIPPED;
9951 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9954 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9957 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9959 gbl_driver_id = rte_cryptodev_driver_id_get(
9960 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9962 if (gbl_driver_id == -1) {
9963 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9964 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9965 "in config file to run this testsuite.\n");
9966 return TEST_SKIPPED;
9969 if (rte_cryptodev_driver_id_get(
9970 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9971 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9972 " enabled in config file to run this testsuite.\n");
9973 return TEST_SKIPPED;
9975 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9978 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9983 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9985 gbl_driver_id = rte_cryptodev_driver_id_get(
9986 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9988 if (gbl_driver_id == -1) {
9989 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9990 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9991 "in config file to run this testsuite.\n");
9992 return TEST_SKIPPED;
9995 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9999 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10001 gbl_driver_id = rte_cryptodev_driver_id_get(
10002 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10004 if (gbl_driver_id == -1) {
10005 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10006 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10007 "in config file to run this testsuite.\n");
10008 return TEST_SKIPPED;
10011 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10015 test_cryptodev_ccp(void)
10017 gbl_driver_id = rte_cryptodev_driver_id_get(
10018 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10020 if (gbl_driver_id == -1) {
10021 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10022 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10023 "in config file to run this testsuite.\n");
10024 return TEST_FAILED;
10027 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10030 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10031 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10032 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10033 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10034 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10035 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10036 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10037 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10038 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10039 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
10040 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10041 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10042 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);