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_cipheronly_virtio_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_VIRTIO_PMD)),
1834 BLKCIPHER_AES_CIPHERONLY_TYPE);
1836 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1838 return TEST_SUCCESS;
1842 test_AES_chain_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_CHAIN_TYPE);
1855 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1857 return TEST_SUCCESS;
1861 test_AES_cipheronly_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_AES_CIPHERONLY_TYPE);
1874 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1876 return TEST_SUCCESS;
1880 test_authonly_dpaa_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_DPAA_SEC_PMD)),
1891 BLKCIPHER_AUTHONLY_TYPE);
1893 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1895 return TEST_SUCCESS;
1899 test_AES_chain_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_CHAIN_TYPE);
1912 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1914 return TEST_SUCCESS;
1918 test_AES_cipheronly_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_AES_CIPHERONLY_TYPE);
1931 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1933 return TEST_SUCCESS;
1937 test_authonly_dpaa2_sec_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_DPAA2_SEC_PMD)),
1948 BLKCIPHER_AUTHONLY_TYPE);
1950 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1952 return TEST_SUCCESS;
1956 test_authonly_openssl_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_OPENSSL_PMD)),
1967 BLKCIPHER_AUTHONLY_TYPE);
1969 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1971 return TEST_SUCCESS;
1975 test_authonly_ccp_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_CCP_PMD)),
1986 BLKCIPHER_AUTHONLY_TYPE);
1988 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1990 return TEST_SUCCESS;
1994 test_AES_chain_armv8_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_ARMV8_PMD)),
2005 BLKCIPHER_AES_CHAIN_TYPE);
2007 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2009 return TEST_SUCCESS;
2013 test_AES_chain_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_CHAIN_TYPE);
2026 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2028 return TEST_SUCCESS;
2032 test_AES_cipheronly_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_AES_CIPHERONLY_TYPE);
2045 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2047 return TEST_SUCCESS;
2051 test_authonly_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_AUTHONLY_TYPE);
2064 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2066 return TEST_SUCCESS;
2070 test_3DES_chain_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_CHAIN_TYPE);
2083 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2085 return TEST_SUCCESS;
2089 test_3DES_cipheronly_mrvl_all(void)
2091 struct crypto_testsuite_params *ts_params = &testsuite_params;
2094 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2095 ts_params->op_mpool,
2096 ts_params->session_mpool,
2097 ts_params->valid_devs[0],
2098 rte_cryptodev_driver_id_get(
2099 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2100 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2102 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2104 return TEST_SUCCESS;
2107 /* ***** SNOW 3G Tests ***** */
2109 create_wireless_algo_hash_session(uint8_t dev_id,
2110 const uint8_t *key, const uint8_t key_len,
2111 const uint8_t iv_len, const uint8_t auth_len,
2112 enum rte_crypto_auth_operation op,
2113 enum rte_crypto_auth_algorithm algo)
2115 uint8_t hash_key[key_len];
2117 struct crypto_testsuite_params *ts_params = &testsuite_params;
2118 struct crypto_unittest_params *ut_params = &unittest_params;
2120 memcpy(hash_key, key, key_len);
2122 debug_hexdump(stdout, "key:", key, key_len);
2124 /* Setup Authentication Parameters */
2125 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2126 ut_params->auth_xform.next = NULL;
2128 ut_params->auth_xform.auth.op = op;
2129 ut_params->auth_xform.auth.algo = algo;
2130 ut_params->auth_xform.auth.key.length = key_len;
2131 ut_params->auth_xform.auth.key.data = hash_key;
2132 ut_params->auth_xform.auth.digest_length = auth_len;
2133 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2134 ut_params->auth_xform.auth.iv.length = iv_len;
2135 ut_params->sess = rte_cryptodev_sym_session_create(
2136 ts_params->session_mpool);
2138 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2139 &ut_params->auth_xform, ts_params->session_mpool);
2140 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2145 create_wireless_algo_cipher_session(uint8_t dev_id,
2146 enum rte_crypto_cipher_operation op,
2147 enum rte_crypto_cipher_algorithm algo,
2148 const uint8_t *key, const uint8_t key_len,
2151 uint8_t cipher_key[key_len];
2153 struct crypto_testsuite_params *ts_params = &testsuite_params;
2154 struct crypto_unittest_params *ut_params = &unittest_params;
2156 memcpy(cipher_key, key, key_len);
2158 /* Setup Cipher Parameters */
2159 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2160 ut_params->cipher_xform.next = NULL;
2162 ut_params->cipher_xform.cipher.algo = algo;
2163 ut_params->cipher_xform.cipher.op = op;
2164 ut_params->cipher_xform.cipher.key.data = cipher_key;
2165 ut_params->cipher_xform.cipher.key.length = key_len;
2166 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2167 ut_params->cipher_xform.cipher.iv.length = iv_len;
2169 debug_hexdump(stdout, "key:", key, key_len);
2171 /* Create Crypto session */
2172 ut_params->sess = rte_cryptodev_sym_session_create(
2173 ts_params->session_mpool);
2175 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2176 &ut_params->cipher_xform, ts_params->session_mpool);
2177 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2182 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2183 unsigned int cipher_len,
2184 unsigned int cipher_offset)
2186 struct crypto_testsuite_params *ts_params = &testsuite_params;
2187 struct crypto_unittest_params *ut_params = &unittest_params;
2189 /* Generate Crypto op data structure */
2190 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2191 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2192 TEST_ASSERT_NOT_NULL(ut_params->op,
2193 "Failed to allocate pktmbuf offload");
2195 /* Set crypto operation data parameters */
2196 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2198 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2200 /* set crypto operation source mbuf */
2201 sym_op->m_src = ut_params->ibuf;
2204 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2206 sym_op->cipher.data.length = cipher_len;
2207 sym_op->cipher.data.offset = cipher_offset;
2212 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2213 unsigned int cipher_len,
2214 unsigned int cipher_offset)
2216 struct crypto_testsuite_params *ts_params = &testsuite_params;
2217 struct crypto_unittest_params *ut_params = &unittest_params;
2219 /* Generate Crypto op data structure */
2220 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2221 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2222 TEST_ASSERT_NOT_NULL(ut_params->op,
2223 "Failed to allocate pktmbuf offload");
2225 /* Set crypto operation data parameters */
2226 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2228 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2230 /* set crypto operation source mbuf */
2231 sym_op->m_src = ut_params->ibuf;
2232 sym_op->m_dst = ut_params->obuf;
2235 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2237 sym_op->cipher.data.length = cipher_len;
2238 sym_op->cipher.data.offset = cipher_offset;
2243 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2244 enum rte_crypto_cipher_operation cipher_op,
2245 enum rte_crypto_auth_operation auth_op,
2246 enum rte_crypto_auth_algorithm auth_algo,
2247 enum rte_crypto_cipher_algorithm cipher_algo,
2248 const uint8_t *key, uint8_t key_len,
2249 uint8_t auth_iv_len, uint8_t auth_len,
2250 uint8_t cipher_iv_len)
2253 uint8_t cipher_auth_key[key_len];
2255 struct crypto_testsuite_params *ts_params = &testsuite_params;
2256 struct crypto_unittest_params *ut_params = &unittest_params;
2258 memcpy(cipher_auth_key, key, key_len);
2260 /* Setup Authentication Parameters */
2261 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2262 ut_params->auth_xform.next = NULL;
2264 ut_params->auth_xform.auth.op = auth_op;
2265 ut_params->auth_xform.auth.algo = auth_algo;
2266 ut_params->auth_xform.auth.key.length = key_len;
2267 /* Hash key = cipher key */
2268 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2269 ut_params->auth_xform.auth.digest_length = auth_len;
2270 /* Auth IV will be after cipher IV */
2271 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2272 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2274 /* Setup Cipher Parameters */
2275 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2276 ut_params->cipher_xform.next = &ut_params->auth_xform;
2278 ut_params->cipher_xform.cipher.algo = cipher_algo;
2279 ut_params->cipher_xform.cipher.op = cipher_op;
2280 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2281 ut_params->cipher_xform.cipher.key.length = key_len;
2282 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2283 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2285 debug_hexdump(stdout, "key:", key, key_len);
2287 /* Create Crypto session*/
2288 ut_params->sess = rte_cryptodev_sym_session_create(
2289 ts_params->session_mpool);
2291 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2292 &ut_params->cipher_xform, ts_params->session_mpool);
2294 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2299 create_wireless_cipher_auth_session(uint8_t dev_id,
2300 enum rte_crypto_cipher_operation cipher_op,
2301 enum rte_crypto_auth_operation auth_op,
2302 enum rte_crypto_auth_algorithm auth_algo,
2303 enum rte_crypto_cipher_algorithm cipher_algo,
2304 const struct wireless_test_data *tdata)
2306 const uint8_t key_len = tdata->key.len;
2307 uint8_t cipher_auth_key[key_len];
2309 struct crypto_testsuite_params *ts_params = &testsuite_params;
2310 struct crypto_unittest_params *ut_params = &unittest_params;
2311 const uint8_t *key = tdata->key.data;
2312 const uint8_t auth_len = tdata->digest.len;
2313 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2314 uint8_t auth_iv_len = tdata->auth_iv.len;
2316 memcpy(cipher_auth_key, key, key_len);
2318 /* Setup Authentication Parameters */
2319 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2320 ut_params->auth_xform.next = NULL;
2322 ut_params->auth_xform.auth.op = auth_op;
2323 ut_params->auth_xform.auth.algo = auth_algo;
2324 ut_params->auth_xform.auth.key.length = key_len;
2325 /* Hash key = cipher key */
2326 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2327 ut_params->auth_xform.auth.digest_length = auth_len;
2328 /* Auth IV will be after cipher IV */
2329 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2330 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2332 /* Setup Cipher Parameters */
2333 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2334 ut_params->cipher_xform.next = &ut_params->auth_xform;
2336 ut_params->cipher_xform.cipher.algo = cipher_algo;
2337 ut_params->cipher_xform.cipher.op = cipher_op;
2338 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2339 ut_params->cipher_xform.cipher.key.length = key_len;
2340 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2341 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2344 debug_hexdump(stdout, "key:", key, key_len);
2346 /* Create Crypto session*/
2347 ut_params->sess = rte_cryptodev_sym_session_create(
2348 ts_params->session_mpool);
2350 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2351 &ut_params->cipher_xform, ts_params->session_mpool);
2353 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2358 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2359 const struct wireless_test_data *tdata)
2361 return create_wireless_cipher_auth_session(dev_id,
2362 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2363 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2364 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2368 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2369 enum rte_crypto_cipher_operation cipher_op,
2370 enum rte_crypto_auth_operation auth_op,
2371 enum rte_crypto_auth_algorithm auth_algo,
2372 enum rte_crypto_cipher_algorithm cipher_algo,
2373 const uint8_t *key, const uint8_t key_len,
2374 uint8_t auth_iv_len, uint8_t auth_len,
2375 uint8_t cipher_iv_len)
2377 uint8_t auth_cipher_key[key_len];
2379 struct crypto_testsuite_params *ts_params = &testsuite_params;
2380 struct crypto_unittest_params *ut_params = &unittest_params;
2382 memcpy(auth_cipher_key, key, key_len);
2384 /* Setup Authentication Parameters */
2385 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2386 ut_params->auth_xform.auth.op = auth_op;
2387 ut_params->auth_xform.next = &ut_params->cipher_xform;
2388 ut_params->auth_xform.auth.algo = auth_algo;
2389 ut_params->auth_xform.auth.key.length = key_len;
2390 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2391 ut_params->auth_xform.auth.digest_length = auth_len;
2392 /* Auth IV will be after cipher IV */
2393 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2394 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2396 /* Setup Cipher Parameters */
2397 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2398 ut_params->cipher_xform.next = NULL;
2399 ut_params->cipher_xform.cipher.algo = cipher_algo;
2400 ut_params->cipher_xform.cipher.op = cipher_op;
2401 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2402 ut_params->cipher_xform.cipher.key.length = key_len;
2403 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2404 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2406 debug_hexdump(stdout, "key:", key, key_len);
2408 /* Create Crypto session*/
2409 ut_params->sess = rte_cryptodev_sym_session_create(
2410 ts_params->session_mpool);
2412 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2413 &ut_params->auth_xform, ts_params->session_mpool);
2415 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2421 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2422 unsigned int auth_tag_len,
2423 const uint8_t *iv, unsigned int iv_len,
2424 unsigned int data_pad_len,
2425 enum rte_crypto_auth_operation op,
2426 unsigned int auth_len, unsigned int auth_offset)
2428 struct crypto_testsuite_params *ts_params = &testsuite_params;
2430 struct crypto_unittest_params *ut_params = &unittest_params;
2432 /* Generate Crypto op data structure */
2433 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2434 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2435 TEST_ASSERT_NOT_NULL(ut_params->op,
2436 "Failed to allocate pktmbuf offload");
2438 /* Set crypto operation data parameters */
2439 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2441 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2443 /* set crypto operation source mbuf */
2444 sym_op->m_src = ut_params->ibuf;
2447 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2450 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2451 ut_params->ibuf, auth_tag_len);
2453 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2454 "no room to append auth tag");
2455 ut_params->digest = sym_op->auth.digest.data;
2456 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2457 ut_params->ibuf, data_pad_len);
2458 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2459 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2461 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2463 debug_hexdump(stdout, "digest:",
2464 sym_op->auth.digest.data,
2467 sym_op->auth.data.length = auth_len;
2468 sym_op->auth.data.offset = auth_offset;
2474 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2475 enum rte_crypto_auth_operation op)
2477 struct crypto_testsuite_params *ts_params = &testsuite_params;
2478 struct crypto_unittest_params *ut_params = &unittest_params;
2480 const uint8_t *auth_tag = tdata->digest.data;
2481 const unsigned int auth_tag_len = tdata->digest.len;
2482 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2483 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2485 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2486 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2487 const uint8_t *auth_iv = tdata->auth_iv.data;
2488 const uint8_t auth_iv_len = tdata->auth_iv.len;
2489 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2490 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2492 /* Generate Crypto op data structure */
2493 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2494 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2495 TEST_ASSERT_NOT_NULL(ut_params->op,
2496 "Failed to allocate pktmbuf offload");
2497 /* Set crypto operation data parameters */
2498 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2500 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2502 /* set crypto operation source mbuf */
2503 sym_op->m_src = ut_params->ibuf;
2506 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2507 ut_params->ibuf, auth_tag_len);
2509 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2510 "no room to append auth tag");
2511 ut_params->digest = sym_op->auth.digest.data;
2512 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2513 ut_params->ibuf, data_pad_len);
2514 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2515 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2517 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2519 debug_hexdump(stdout, "digest:",
2520 sym_op->auth.digest.data,
2523 /* Copy cipher and auth IVs at the end of the crypto operation */
2524 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2526 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2527 iv_ptr += cipher_iv_len;
2528 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2530 sym_op->cipher.data.length = cipher_len;
2531 sym_op->cipher.data.offset = 0;
2532 sym_op->auth.data.length = auth_len;
2533 sym_op->auth.data.offset = 0;
2539 create_zuc_cipher_hash_generate_operation(
2540 const struct wireless_test_data *tdata)
2542 return create_wireless_cipher_hash_operation(tdata,
2543 RTE_CRYPTO_AUTH_OP_GENERATE);
2547 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2548 const unsigned auth_tag_len,
2549 const uint8_t *auth_iv, uint8_t auth_iv_len,
2550 unsigned data_pad_len,
2551 enum rte_crypto_auth_operation op,
2552 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2553 const unsigned cipher_len, const unsigned cipher_offset,
2554 const unsigned auth_len, const unsigned auth_offset)
2556 struct crypto_testsuite_params *ts_params = &testsuite_params;
2557 struct crypto_unittest_params *ut_params = &unittest_params;
2559 /* Generate Crypto op data structure */
2560 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2561 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2562 TEST_ASSERT_NOT_NULL(ut_params->op,
2563 "Failed to allocate pktmbuf offload");
2564 /* Set crypto operation data parameters */
2565 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2567 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2569 /* set crypto operation source mbuf */
2570 sym_op->m_src = ut_params->ibuf;
2573 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2574 ut_params->ibuf, auth_tag_len);
2576 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2577 "no room to append auth tag");
2578 ut_params->digest = sym_op->auth.digest.data;
2579 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2580 ut_params->ibuf, data_pad_len);
2581 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2582 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2584 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2586 debug_hexdump(stdout, "digest:",
2587 sym_op->auth.digest.data,
2590 /* Copy cipher and auth IVs at the end of the crypto operation */
2591 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2593 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2594 iv_ptr += cipher_iv_len;
2595 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2597 sym_op->cipher.data.length = cipher_len;
2598 sym_op->cipher.data.offset = cipher_offset;
2599 sym_op->auth.data.length = auth_len;
2600 sym_op->auth.data.offset = auth_offset;
2606 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2607 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2608 const uint8_t *auth_iv, uint8_t auth_iv_len,
2609 unsigned int data_pad_len,
2610 unsigned int cipher_len, unsigned int cipher_offset,
2611 unsigned int auth_len, unsigned int auth_offset)
2613 struct crypto_testsuite_params *ts_params = &testsuite_params;
2614 struct crypto_unittest_params *ut_params = &unittest_params;
2616 /* Generate Crypto op data structure */
2617 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2618 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2619 TEST_ASSERT_NOT_NULL(ut_params->op,
2620 "Failed to allocate pktmbuf offload");
2622 /* Set crypto operation data parameters */
2623 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2625 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2627 /* set crypto operation source mbuf */
2628 sym_op->m_src = ut_params->ibuf;
2631 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2632 ut_params->ibuf, auth_tag_len);
2634 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2635 "no room to append auth tag");
2637 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2638 ut_params->ibuf, data_pad_len);
2640 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2642 debug_hexdump(stdout, "digest:",
2643 sym_op->auth.digest.data,
2646 /* Copy cipher and auth IVs at the end of the crypto operation */
2647 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2649 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2650 iv_ptr += cipher_iv_len;
2651 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2653 sym_op->cipher.data.length = cipher_len;
2654 sym_op->cipher.data.offset = cipher_offset;
2656 sym_op->auth.data.length = auth_len;
2657 sym_op->auth.data.offset = auth_offset;
2663 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2665 struct crypto_testsuite_params *ts_params = &testsuite_params;
2666 struct crypto_unittest_params *ut_params = &unittest_params;
2669 unsigned plaintext_pad_len;
2670 unsigned plaintext_len;
2673 /* Create SNOW 3G session */
2674 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2675 tdata->key.data, tdata->key.len,
2676 tdata->auth_iv.len, tdata->digest.len,
2677 RTE_CRYPTO_AUTH_OP_GENERATE,
2678 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2682 /* alloc mbuf and set payload */
2683 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2685 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2686 rte_pktmbuf_tailroom(ut_params->ibuf));
2688 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2689 /* Append data which is padded to a multiple of */
2690 /* the algorithms block size */
2691 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2692 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2694 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2696 /* Create SNOW 3G operation */
2697 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2698 tdata->auth_iv.data, tdata->auth_iv.len,
2699 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2700 tdata->validAuthLenInBits.len,
2705 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2707 ut_params->obuf = ut_params->op->sym->m_src;
2708 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2709 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2710 + plaintext_pad_len;
2713 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2716 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2717 "SNOW 3G Generated auth tag not as expected");
2723 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2725 struct crypto_testsuite_params *ts_params = &testsuite_params;
2726 struct crypto_unittest_params *ut_params = &unittest_params;
2729 unsigned plaintext_pad_len;
2730 unsigned plaintext_len;
2733 /* Create SNOW 3G session */
2734 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2735 tdata->key.data, tdata->key.len,
2736 tdata->auth_iv.len, tdata->digest.len,
2737 RTE_CRYPTO_AUTH_OP_VERIFY,
2738 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2741 /* alloc mbuf and set payload */
2742 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2744 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2745 rte_pktmbuf_tailroom(ut_params->ibuf));
2747 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2748 /* Append data which is padded to a multiple of */
2749 /* the algorithms block size */
2750 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2751 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2753 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2755 /* Create SNOW 3G operation */
2756 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2758 tdata->auth_iv.data, tdata->auth_iv.len,
2760 RTE_CRYPTO_AUTH_OP_VERIFY,
2761 tdata->validAuthLenInBits.len,
2766 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2768 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2769 ut_params->obuf = ut_params->op->sym->m_src;
2770 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2771 + plaintext_pad_len;
2774 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2783 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2785 struct crypto_testsuite_params *ts_params = &testsuite_params;
2786 struct crypto_unittest_params *ut_params = &unittest_params;
2789 unsigned plaintext_pad_len;
2790 unsigned plaintext_len;
2793 /* Create KASUMI session */
2794 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2795 tdata->key.data, tdata->key.len,
2796 0, tdata->digest.len,
2797 RTE_CRYPTO_AUTH_OP_GENERATE,
2798 RTE_CRYPTO_AUTH_KASUMI_F9);
2802 /* alloc mbuf and set payload */
2803 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2805 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2806 rte_pktmbuf_tailroom(ut_params->ibuf));
2808 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2809 /* Append data which is padded to a multiple of */
2810 /* the algorithms block size */
2811 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2812 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2814 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2816 /* Create KASUMI operation */
2817 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2819 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2820 tdata->plaintext.len,
2825 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2827 ut_params->obuf = ut_params->op->sym->m_src;
2828 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2829 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2830 + plaintext_pad_len;
2833 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2836 DIGEST_BYTE_LENGTH_KASUMI_F9,
2837 "KASUMI Generated auth tag not as expected");
2843 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2845 struct crypto_testsuite_params *ts_params = &testsuite_params;
2846 struct crypto_unittest_params *ut_params = &unittest_params;
2849 unsigned plaintext_pad_len;
2850 unsigned plaintext_len;
2853 /* Create KASUMI session */
2854 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2855 tdata->key.data, tdata->key.len,
2856 0, tdata->digest.len,
2857 RTE_CRYPTO_AUTH_OP_VERIFY,
2858 RTE_CRYPTO_AUTH_KASUMI_F9);
2861 /* alloc mbuf and set payload */
2862 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2864 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2865 rte_pktmbuf_tailroom(ut_params->ibuf));
2867 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2868 /* Append data which is padded to a multiple */
2869 /* of the algorithms block size */
2870 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2871 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2873 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2875 /* Create KASUMI operation */
2876 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2880 RTE_CRYPTO_AUTH_OP_VERIFY,
2881 tdata->plaintext.len,
2886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2888 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2889 ut_params->obuf = ut_params->op->sym->m_src;
2890 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2891 + plaintext_pad_len;
2894 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2903 test_snow3g_hash_generate_test_case_1(void)
2905 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2909 test_snow3g_hash_generate_test_case_2(void)
2911 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2915 test_snow3g_hash_generate_test_case_3(void)
2917 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2921 test_snow3g_hash_generate_test_case_4(void)
2923 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2927 test_snow3g_hash_generate_test_case_5(void)
2929 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2933 test_snow3g_hash_generate_test_case_6(void)
2935 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2939 test_snow3g_hash_verify_test_case_1(void)
2941 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2946 test_snow3g_hash_verify_test_case_2(void)
2948 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2952 test_snow3g_hash_verify_test_case_3(void)
2954 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2958 test_snow3g_hash_verify_test_case_4(void)
2960 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2964 test_snow3g_hash_verify_test_case_5(void)
2966 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2970 test_snow3g_hash_verify_test_case_6(void)
2972 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2976 test_kasumi_hash_generate_test_case_1(void)
2978 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2982 test_kasumi_hash_generate_test_case_2(void)
2984 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2988 test_kasumi_hash_generate_test_case_3(void)
2990 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2994 test_kasumi_hash_generate_test_case_4(void)
2996 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3000 test_kasumi_hash_generate_test_case_5(void)
3002 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3006 test_kasumi_hash_generate_test_case_6(void)
3008 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3012 test_kasumi_hash_verify_test_case_1(void)
3014 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3018 test_kasumi_hash_verify_test_case_2(void)
3020 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3024 test_kasumi_hash_verify_test_case_3(void)
3026 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3030 test_kasumi_hash_verify_test_case_4(void)
3032 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3036 test_kasumi_hash_verify_test_case_5(void)
3038 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3042 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3044 struct crypto_testsuite_params *ts_params = &testsuite_params;
3045 struct crypto_unittest_params *ut_params = &unittest_params;
3048 uint8_t *plaintext, *ciphertext;
3049 unsigned plaintext_pad_len;
3050 unsigned plaintext_len;
3052 /* Create KASUMI session */
3053 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3054 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3055 RTE_CRYPTO_CIPHER_KASUMI_F8,
3056 tdata->key.data, tdata->key.len,
3057 tdata->cipher_iv.len);
3061 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3063 /* Clear mbuf payload */
3064 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3065 rte_pktmbuf_tailroom(ut_params->ibuf));
3067 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3068 /* Append data which is padded to a multiple */
3069 /* of the algorithms block size */
3070 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3071 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3073 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3075 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3077 /* Create KASUMI operation */
3078 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3079 tdata->cipher_iv.len,
3080 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3081 tdata->validCipherOffsetInBits.len);
3085 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3087 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3089 ut_params->obuf = ut_params->op->sym->m_dst;
3090 if (ut_params->obuf)
3091 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3093 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3095 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3097 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3098 (tdata->validCipherOffsetInBits.len >> 3);
3100 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3102 reference_ciphertext,
3103 tdata->validCipherLenInBits.len,
3104 "KASUMI Ciphertext data not as expected");
3109 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3111 struct crypto_testsuite_params *ts_params = &testsuite_params;
3112 struct crypto_unittest_params *ut_params = &unittest_params;
3116 unsigned int plaintext_pad_len;
3117 unsigned int plaintext_len;
3119 uint8_t buffer[10000];
3120 const uint8_t *ciphertext;
3122 struct rte_cryptodev_info dev_info;
3124 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3125 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3126 printf("Device doesn't support scatter-gather. "
3131 /* Create KASUMI session */
3132 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3133 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3134 RTE_CRYPTO_CIPHER_KASUMI_F8,
3135 tdata->key.data, tdata->key.len,
3136 tdata->cipher_iv.len);
3140 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3143 /* Append data which is padded to a multiple */
3144 /* of the algorithms block size */
3145 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3147 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3148 plaintext_pad_len, 10, 0);
3150 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3152 /* Create KASUMI operation */
3153 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3154 tdata->cipher_iv.len,
3155 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3156 tdata->validCipherOffsetInBits.len);
3160 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3162 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3164 ut_params->obuf = ut_params->op->sym->m_dst;
3166 if (ut_params->obuf)
3167 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3168 plaintext_len, buffer);
3170 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3171 tdata->validCipherOffsetInBits.len >> 3,
3172 plaintext_len, buffer);
3175 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3177 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3178 (tdata->validCipherOffsetInBits.len >> 3);
3180 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3182 reference_ciphertext,
3183 tdata->validCipherLenInBits.len,
3184 "KASUMI Ciphertext data not as expected");
3189 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3191 struct crypto_testsuite_params *ts_params = &testsuite_params;
3192 struct crypto_unittest_params *ut_params = &unittest_params;
3195 uint8_t *plaintext, *ciphertext;
3196 unsigned plaintext_pad_len;
3197 unsigned plaintext_len;
3199 /* Create KASUMI session */
3200 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3201 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3202 RTE_CRYPTO_CIPHER_KASUMI_F8,
3203 tdata->key.data, tdata->key.len,
3204 tdata->cipher_iv.len);
3208 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3209 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3211 /* Clear mbuf payload */
3212 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3213 rte_pktmbuf_tailroom(ut_params->ibuf));
3215 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3216 /* Append data which is padded to a multiple */
3217 /* of the algorithms block size */
3218 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3219 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3221 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3222 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3224 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3226 /* Create KASUMI operation */
3227 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3228 tdata->cipher_iv.len,
3229 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3230 tdata->validCipherOffsetInBits.len);
3234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3236 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3238 ut_params->obuf = ut_params->op->sym->m_dst;
3239 if (ut_params->obuf)
3240 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3242 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3244 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3246 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3247 (tdata->validCipherOffsetInBits.len >> 3);
3249 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3251 reference_ciphertext,
3252 tdata->validCipherLenInBits.len,
3253 "KASUMI Ciphertext data not as expected");
3258 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3260 struct crypto_testsuite_params *ts_params = &testsuite_params;
3261 struct crypto_unittest_params *ut_params = &unittest_params;
3264 unsigned int plaintext_pad_len;
3265 unsigned int plaintext_len;
3267 const uint8_t *ciphertext;
3268 uint8_t buffer[2048];
3270 struct rte_cryptodev_info dev_info;
3272 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3273 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3274 printf("Device doesn't support scatter-gather. "
3279 /* Create KASUMI session */
3280 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3281 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3282 RTE_CRYPTO_CIPHER_KASUMI_F8,
3283 tdata->key.data, tdata->key.len,
3284 tdata->cipher_iv.len);
3288 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3289 /* Append data which is padded to a multiple */
3290 /* of the algorithms block size */
3291 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3293 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3294 plaintext_pad_len, 10, 0);
3295 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3296 plaintext_pad_len, 3, 0);
3298 /* Append data which is padded to a multiple */
3299 /* of the algorithms block size */
3300 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3302 /* Create KASUMI operation */
3303 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3304 tdata->cipher_iv.len,
3305 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3306 tdata->validCipherOffsetInBits.len);
3310 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3312 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3314 ut_params->obuf = ut_params->op->sym->m_dst;
3315 if (ut_params->obuf)
3316 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3317 plaintext_pad_len, buffer);
3319 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3320 tdata->validCipherOffsetInBits.len >> 3,
3321 plaintext_pad_len, buffer);
3323 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3324 (tdata->validCipherOffsetInBits.len >> 3);
3326 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3328 reference_ciphertext,
3329 tdata->validCipherLenInBits.len,
3330 "KASUMI Ciphertext data not as expected");
3336 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3338 struct crypto_testsuite_params *ts_params = &testsuite_params;
3339 struct crypto_unittest_params *ut_params = &unittest_params;
3342 uint8_t *ciphertext, *plaintext;
3343 unsigned ciphertext_pad_len;
3344 unsigned ciphertext_len;
3346 /* Create KASUMI session */
3347 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3348 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3349 RTE_CRYPTO_CIPHER_KASUMI_F8,
3350 tdata->key.data, tdata->key.len,
3351 tdata->cipher_iv.len);
3355 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3356 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3358 /* Clear mbuf payload */
3359 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3360 rte_pktmbuf_tailroom(ut_params->ibuf));
3362 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3363 /* Append data which is padded to a multiple */
3364 /* of the algorithms block size */
3365 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3366 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3367 ciphertext_pad_len);
3368 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3369 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3371 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3373 /* Create KASUMI operation */
3374 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3375 tdata->cipher_iv.len,
3376 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3377 tdata->validCipherOffsetInBits.len);
3381 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3383 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3385 ut_params->obuf = ut_params->op->sym->m_dst;
3386 if (ut_params->obuf)
3387 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3389 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3391 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3393 const uint8_t *reference_plaintext = tdata->plaintext.data +
3394 (tdata->validCipherOffsetInBits.len >> 3);
3396 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3398 reference_plaintext,
3399 tdata->validCipherLenInBits.len,
3400 "KASUMI Plaintext data not as expected");
3405 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3407 struct crypto_testsuite_params *ts_params = &testsuite_params;
3408 struct crypto_unittest_params *ut_params = &unittest_params;
3411 uint8_t *ciphertext, *plaintext;
3412 unsigned ciphertext_pad_len;
3413 unsigned ciphertext_len;
3415 /* Create KASUMI session */
3416 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3417 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3418 RTE_CRYPTO_CIPHER_KASUMI_F8,
3419 tdata->key.data, tdata->key.len,
3420 tdata->cipher_iv.len);
3424 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3426 /* Clear mbuf payload */
3427 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3428 rte_pktmbuf_tailroom(ut_params->ibuf));
3430 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3431 /* Append data which is padded to a multiple */
3432 /* of the algorithms block size */
3433 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3434 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3435 ciphertext_pad_len);
3436 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3438 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3440 /* Create KASUMI operation */
3441 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3442 tdata->cipher_iv.len,
3443 tdata->ciphertext.len,
3444 tdata->validCipherOffsetInBits.len);
3448 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3450 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3452 ut_params->obuf = ut_params->op->sym->m_dst;
3453 if (ut_params->obuf)
3454 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3456 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3458 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3460 const uint8_t *reference_plaintext = tdata->plaintext.data +
3461 (tdata->validCipherOffsetInBits.len >> 3);
3463 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3465 reference_plaintext,
3466 tdata->validCipherLenInBits.len,
3467 "KASUMI Plaintext data not as expected");
3472 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3474 struct crypto_testsuite_params *ts_params = &testsuite_params;
3475 struct crypto_unittest_params *ut_params = &unittest_params;
3478 uint8_t *plaintext, *ciphertext;
3479 unsigned plaintext_pad_len;
3480 unsigned plaintext_len;
3482 /* Create SNOW 3G session */
3483 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3484 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3485 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3486 tdata->key.data, tdata->key.len,
3487 tdata->cipher_iv.len);
3491 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3493 /* Clear mbuf payload */
3494 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3495 rte_pktmbuf_tailroom(ut_params->ibuf));
3497 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3498 /* Append data which is padded to a multiple of */
3499 /* the algorithms block size */
3500 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3501 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3503 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3505 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3507 /* Create SNOW 3G operation */
3508 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3509 tdata->cipher_iv.len,
3510 tdata->validCipherLenInBits.len,
3515 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3517 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3519 ut_params->obuf = ut_params->op->sym->m_dst;
3520 if (ut_params->obuf)
3521 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3523 ciphertext = plaintext;
3525 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3528 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3530 tdata->ciphertext.data,
3531 tdata->validDataLenInBits.len,
3532 "SNOW 3G Ciphertext data not as expected");
3538 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3540 struct crypto_testsuite_params *ts_params = &testsuite_params;
3541 struct crypto_unittest_params *ut_params = &unittest_params;
3542 uint8_t *plaintext, *ciphertext;
3545 unsigned plaintext_pad_len;
3546 unsigned plaintext_len;
3548 /* Create SNOW 3G session */
3549 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3550 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3551 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3552 tdata->key.data, tdata->key.len,
3553 tdata->cipher_iv.len);
3557 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3558 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3560 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3561 "Failed to allocate input buffer in mempool");
3562 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3563 "Failed to allocate output buffer in mempool");
3565 /* Clear mbuf payload */
3566 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3567 rte_pktmbuf_tailroom(ut_params->ibuf));
3569 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3570 /* Append data which is padded to a multiple of */
3571 /* the algorithms block size */
3572 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3573 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3575 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3576 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3578 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3580 /* Create SNOW 3G operation */
3581 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3582 tdata->cipher_iv.len,
3583 tdata->validCipherLenInBits.len,
3588 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3590 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3592 ut_params->obuf = ut_params->op->sym->m_dst;
3593 if (ut_params->obuf)
3594 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3596 ciphertext = plaintext;
3598 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3601 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3603 tdata->ciphertext.data,
3604 tdata->validDataLenInBits.len,
3605 "SNOW 3G Ciphertext data not as expected");
3610 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3612 struct crypto_testsuite_params *ts_params = &testsuite_params;
3613 struct crypto_unittest_params *ut_params = &unittest_params;
3616 unsigned int plaintext_pad_len;
3617 unsigned int plaintext_len;
3618 uint8_t buffer[10000];
3619 const uint8_t *ciphertext;
3621 struct rte_cryptodev_info dev_info;
3623 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3624 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3625 printf("Device doesn't support scatter-gather. "
3630 /* Create SNOW 3G session */
3631 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3632 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3633 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3634 tdata->key.data, tdata->key.len,
3635 tdata->cipher_iv.len);
3639 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3640 /* Append data which is padded to a multiple of */
3641 /* the algorithms block size */
3642 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3644 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3645 plaintext_pad_len, 10, 0);
3646 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3647 plaintext_pad_len, 3, 0);
3649 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3650 "Failed to allocate input buffer in mempool");
3651 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3652 "Failed to allocate output buffer in mempool");
3654 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3656 /* Create SNOW 3G operation */
3657 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3658 tdata->cipher_iv.len,
3659 tdata->validCipherLenInBits.len,
3664 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3666 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3668 ut_params->obuf = ut_params->op->sym->m_dst;
3669 if (ut_params->obuf)
3670 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3671 plaintext_len, buffer);
3673 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3674 plaintext_len, buffer);
3676 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3679 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3681 tdata->ciphertext.data,
3682 tdata->validDataLenInBits.len,
3683 "SNOW 3G Ciphertext data not as expected");
3688 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3690 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3692 uint8_t curr_byte, prev_byte;
3693 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3694 uint8_t lower_byte_mask = (1 << offset) - 1;
3697 prev_byte = buffer[0];
3698 buffer[0] >>= offset;
3700 for (i = 1; i < length_in_bytes; i++) {
3701 curr_byte = buffer[i];
3702 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3703 (curr_byte >> offset);
3704 prev_byte = curr_byte;
3709 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3711 struct crypto_testsuite_params *ts_params = &testsuite_params;
3712 struct crypto_unittest_params *ut_params = &unittest_params;
3713 uint8_t *plaintext, *ciphertext;
3715 uint32_t plaintext_len;
3716 uint32_t plaintext_pad_len;
3717 uint8_t extra_offset = 4;
3718 uint8_t *expected_ciphertext_shifted;
3720 /* Create SNOW 3G session */
3721 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3722 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3723 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3724 tdata->key.data, tdata->key.len,
3725 tdata->cipher_iv.len);
3729 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3730 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3732 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3733 "Failed to allocate input buffer in mempool");
3734 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3735 "Failed to allocate output buffer in mempool");
3737 /* Clear mbuf payload */
3738 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3739 rte_pktmbuf_tailroom(ut_params->ibuf));
3741 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3743 * Append data which is padded to a
3744 * multiple of the algorithms block size
3746 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3748 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3751 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3753 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3754 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3756 #ifdef RTE_APP_TEST_DEBUG
3757 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3759 /* Create SNOW 3G operation */
3760 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3761 tdata->cipher_iv.len,
3762 tdata->validCipherLenInBits.len,
3767 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3769 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3771 ut_params->obuf = ut_params->op->sym->m_dst;
3772 if (ut_params->obuf)
3773 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3775 ciphertext = plaintext;
3777 #ifdef RTE_APP_TEST_DEBUG
3778 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3781 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3783 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3784 "failed to reserve memory for ciphertext shifted\n");
3786 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3787 ceil_byte_length(tdata->ciphertext.len));
3788 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3793 expected_ciphertext_shifted,
3794 tdata->validDataLenInBits.len,
3796 "SNOW 3G Ciphertext data not as expected");
3800 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3802 struct crypto_testsuite_params *ts_params = &testsuite_params;
3803 struct crypto_unittest_params *ut_params = &unittest_params;
3807 uint8_t *plaintext, *ciphertext;
3808 unsigned ciphertext_pad_len;
3809 unsigned ciphertext_len;
3811 /* Create SNOW 3G session */
3812 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3813 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3814 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3815 tdata->key.data, tdata->key.len,
3816 tdata->cipher_iv.len);
3820 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3822 /* Clear mbuf payload */
3823 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3824 rte_pktmbuf_tailroom(ut_params->ibuf));
3826 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3827 /* Append data which is padded to a multiple of */
3828 /* the algorithms block size */
3829 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3830 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3831 ciphertext_pad_len);
3832 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3834 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3836 /* Create SNOW 3G operation */
3837 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3838 tdata->cipher_iv.len,
3839 tdata->validCipherLenInBits.len,
3844 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3846 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3847 ut_params->obuf = ut_params->op->sym->m_dst;
3848 if (ut_params->obuf)
3849 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3851 plaintext = ciphertext;
3853 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3856 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3857 tdata->plaintext.data,
3858 tdata->validDataLenInBits.len,
3859 "SNOW 3G Plaintext data not as expected");
3863 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3865 struct crypto_testsuite_params *ts_params = &testsuite_params;
3866 struct crypto_unittest_params *ut_params = &unittest_params;
3870 uint8_t *plaintext, *ciphertext;
3871 unsigned ciphertext_pad_len;
3872 unsigned ciphertext_len;
3874 /* Create SNOW 3G session */
3875 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3876 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3877 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3878 tdata->key.data, tdata->key.len,
3879 tdata->cipher_iv.len);
3883 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3884 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3886 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3887 "Failed to allocate input buffer");
3888 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3889 "Failed to allocate output buffer");
3891 /* Clear mbuf payload */
3892 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3893 rte_pktmbuf_tailroom(ut_params->ibuf));
3895 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3896 rte_pktmbuf_tailroom(ut_params->obuf));
3898 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3899 /* Append data which is padded to a multiple of */
3900 /* the algorithms block size */
3901 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3902 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3903 ciphertext_pad_len);
3904 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3905 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3907 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3909 /* Create SNOW 3G operation */
3910 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3911 tdata->cipher_iv.len,
3912 tdata->validCipherLenInBits.len,
3917 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3919 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3920 ut_params->obuf = ut_params->op->sym->m_dst;
3921 if (ut_params->obuf)
3922 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3924 plaintext = ciphertext;
3926 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3929 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3930 tdata->plaintext.data,
3931 tdata->validDataLenInBits.len,
3932 "SNOW 3G Plaintext data not as expected");
3937 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3939 struct crypto_testsuite_params *ts_params = &testsuite_params;
3940 struct crypto_unittest_params *ut_params = &unittest_params;
3944 uint8_t *plaintext, *ciphertext;
3945 unsigned int plaintext_pad_len;
3946 unsigned int plaintext_len;
3948 struct rte_cryptodev_sym_capability_idx cap_idx;
3950 /* Check if device supports ZUC EEA3 */
3951 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3952 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3954 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3958 /* Check if device supports ZUC EIA3 */
3959 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3960 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3962 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3966 /* Create ZUC session */
3967 retval = create_zuc_cipher_auth_encrypt_generate_session(
3968 ts_params->valid_devs[0],
3972 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3974 /* clear mbuf payload */
3975 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3976 rte_pktmbuf_tailroom(ut_params->ibuf));
3978 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3979 /* Append data which is padded to a multiple of */
3980 /* the algorithms block size */
3981 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3982 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3984 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3986 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3988 /* Create ZUC operation */
3989 retval = create_zuc_cipher_hash_generate_operation(tdata);
3993 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3995 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3996 ut_params->obuf = ut_params->op->sym->m_src;
3997 if (ut_params->obuf)
3998 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4000 ciphertext = plaintext;
4002 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4004 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4006 tdata->ciphertext.data,
4007 tdata->validDataLenInBits.len,
4008 "ZUC Ciphertext data not as expected");
4010 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4011 + plaintext_pad_len;
4014 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4018 "ZUC Generated auth tag not as expected");
4023 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4025 struct crypto_testsuite_params *ts_params = &testsuite_params;
4026 struct crypto_unittest_params *ut_params = &unittest_params;
4030 uint8_t *plaintext, *ciphertext;
4031 unsigned plaintext_pad_len;
4032 unsigned plaintext_len;
4034 /* Create SNOW 3G session */
4035 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4036 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4037 RTE_CRYPTO_AUTH_OP_GENERATE,
4038 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4039 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4040 tdata->key.data, tdata->key.len,
4041 tdata->auth_iv.len, tdata->digest.len,
4042 tdata->cipher_iv.len);
4045 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4047 /* clear mbuf payload */
4048 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4049 rte_pktmbuf_tailroom(ut_params->ibuf));
4051 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4052 /* Append data which is padded to a multiple of */
4053 /* the algorithms block size */
4054 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4055 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4057 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4059 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4061 /* Create SNOW 3G operation */
4062 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4063 tdata->digest.len, tdata->auth_iv.data,
4065 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4066 tdata->cipher_iv.data, tdata->cipher_iv.len,
4067 tdata->validCipherLenInBits.len,
4069 tdata->validAuthLenInBits.len,
4075 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4077 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4078 ut_params->obuf = ut_params->op->sym->m_src;
4079 if (ut_params->obuf)
4080 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4082 ciphertext = plaintext;
4084 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4086 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4088 tdata->ciphertext.data,
4089 tdata->validDataLenInBits.len,
4090 "SNOW 3G Ciphertext data not as expected");
4092 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4093 + plaintext_pad_len;
4096 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4099 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4100 "SNOW 3G Generated auth tag not as expected");
4104 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4106 struct crypto_testsuite_params *ts_params = &testsuite_params;
4107 struct crypto_unittest_params *ut_params = &unittest_params;
4111 uint8_t *plaintext, *ciphertext;
4112 unsigned plaintext_pad_len;
4113 unsigned plaintext_len;
4115 /* Create SNOW 3G session */
4116 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4117 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4118 RTE_CRYPTO_AUTH_OP_GENERATE,
4119 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4120 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4121 tdata->key.data, tdata->key.len,
4122 tdata->auth_iv.len, tdata->digest.len,
4123 tdata->cipher_iv.len);
4127 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4129 /* clear mbuf payload */
4130 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4131 rte_pktmbuf_tailroom(ut_params->ibuf));
4133 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4134 /* Append data which is padded to a multiple of */
4135 /* the algorithms block size */
4136 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4137 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4139 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4141 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4143 /* Create SNOW 3G operation */
4144 retval = create_wireless_algo_auth_cipher_operation(
4146 tdata->cipher_iv.data, tdata->cipher_iv.len,
4147 tdata->auth_iv.data, tdata->auth_iv.len,
4149 tdata->validCipherLenInBits.len,
4151 tdata->validAuthLenInBits.len,
4157 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4159 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4160 ut_params->obuf = ut_params->op->sym->m_src;
4161 if (ut_params->obuf)
4162 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4164 ciphertext = plaintext;
4166 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4167 + plaintext_pad_len;
4168 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4171 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4173 tdata->ciphertext.data,
4174 tdata->validDataLenInBits.len,
4175 "SNOW 3G Ciphertext data not as expected");
4178 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4181 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4182 "SNOW 3G Generated auth tag not as expected");
4187 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4189 struct crypto_testsuite_params *ts_params = &testsuite_params;
4190 struct crypto_unittest_params *ut_params = &unittest_params;
4194 uint8_t *plaintext, *ciphertext;
4195 unsigned plaintext_pad_len;
4196 unsigned plaintext_len;
4198 /* Create KASUMI session */
4199 retval = create_wireless_algo_auth_cipher_session(
4200 ts_params->valid_devs[0],
4201 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4202 RTE_CRYPTO_AUTH_OP_GENERATE,
4203 RTE_CRYPTO_AUTH_KASUMI_F9,
4204 RTE_CRYPTO_CIPHER_KASUMI_F8,
4205 tdata->key.data, tdata->key.len,
4206 0, tdata->digest.len,
4207 tdata->cipher_iv.len);
4210 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4212 /* clear mbuf payload */
4213 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4214 rte_pktmbuf_tailroom(ut_params->ibuf));
4216 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4217 /* Append data which is padded to a multiple of */
4218 /* the algorithms block size */
4219 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4220 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4222 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4224 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4226 /* Create KASUMI operation */
4227 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4228 tdata->cipher_iv.data, tdata->cipher_iv.len,
4231 tdata->validCipherLenInBits.len,
4232 tdata->validCipherOffsetInBits.len,
4233 tdata->validAuthLenInBits.len,
4240 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4242 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4243 if (ut_params->op->sym->m_dst)
4244 ut_params->obuf = ut_params->op->sym->m_dst;
4246 ut_params->obuf = ut_params->op->sym->m_src;
4248 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4249 tdata->validCipherOffsetInBits.len >> 3);
4251 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4252 (tdata->validCipherOffsetInBits.len >> 3);
4254 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4256 reference_ciphertext,
4257 tdata->validCipherLenInBits.len,
4258 "KASUMI Ciphertext data not as expected");
4259 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4260 + plaintext_pad_len;
4263 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4266 DIGEST_BYTE_LENGTH_KASUMI_F9,
4267 "KASUMI Generated auth tag not as expected");
4272 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4274 struct crypto_testsuite_params *ts_params = &testsuite_params;
4275 struct crypto_unittest_params *ut_params = &unittest_params;
4279 uint8_t *plaintext, *ciphertext;
4280 unsigned plaintext_pad_len;
4281 unsigned plaintext_len;
4283 /* Create KASUMI session */
4284 retval = create_wireless_algo_cipher_auth_session(
4285 ts_params->valid_devs[0],
4286 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4287 RTE_CRYPTO_AUTH_OP_GENERATE,
4288 RTE_CRYPTO_AUTH_KASUMI_F9,
4289 RTE_CRYPTO_CIPHER_KASUMI_F8,
4290 tdata->key.data, tdata->key.len,
4291 0, tdata->digest.len,
4292 tdata->cipher_iv.len);
4296 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4298 /* clear mbuf payload */
4299 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4300 rte_pktmbuf_tailroom(ut_params->ibuf));
4302 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4303 /* Append data which is padded to a multiple of */
4304 /* the algorithms block size */
4305 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4306 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4308 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4310 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4312 /* Create KASUMI operation */
4313 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4314 tdata->digest.len, NULL, 0,
4315 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4316 tdata->cipher_iv.data, tdata->cipher_iv.len,
4317 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4318 tdata->validCipherOffsetInBits.len,
4319 tdata->validAuthLenInBits.len,
4325 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4327 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4329 if (ut_params->op->sym->m_dst)
4330 ut_params->obuf = ut_params->op->sym->m_dst;
4332 ut_params->obuf = ut_params->op->sym->m_src;
4334 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4335 tdata->validCipherOffsetInBits.len >> 3);
4337 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4338 + plaintext_pad_len;
4340 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4341 (tdata->validCipherOffsetInBits.len >> 3);
4343 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4345 reference_ciphertext,
4346 tdata->validCipherLenInBits.len,
4347 "KASUMI Ciphertext data not as expected");
4350 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4353 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4354 "KASUMI Generated auth tag not as expected");
4359 test_zuc_encryption(const struct wireless_test_data *tdata)
4361 struct crypto_testsuite_params *ts_params = &testsuite_params;
4362 struct crypto_unittest_params *ut_params = &unittest_params;
4365 uint8_t *plaintext, *ciphertext;
4366 unsigned plaintext_pad_len;
4367 unsigned plaintext_len;
4369 struct rte_cryptodev_sym_capability_idx cap_idx;
4371 /* Check if device supports ZUC EEA3 */
4372 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4373 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4375 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4379 /* Create ZUC session */
4380 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4381 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4382 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4383 tdata->key.data, tdata->key.len,
4384 tdata->cipher_iv.len);
4388 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4390 /* Clear mbuf payload */
4391 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4392 rte_pktmbuf_tailroom(ut_params->ibuf));
4394 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4395 /* Append data which is padded to a multiple */
4396 /* of the algorithms block size */
4397 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4398 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4400 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4402 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4404 /* Create ZUC operation */
4405 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4406 tdata->cipher_iv.len,
4407 tdata->plaintext.len,
4412 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4414 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4416 ut_params->obuf = ut_params->op->sym->m_dst;
4417 if (ut_params->obuf)
4418 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4420 ciphertext = plaintext;
4422 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4425 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4427 tdata->ciphertext.data,
4428 tdata->validCipherLenInBits.len,
4429 "ZUC Ciphertext data not as expected");
4434 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4436 struct crypto_testsuite_params *ts_params = &testsuite_params;
4437 struct crypto_unittest_params *ut_params = &unittest_params;
4441 unsigned int plaintext_pad_len;
4442 unsigned int plaintext_len;
4443 const uint8_t *ciphertext;
4444 uint8_t ciphertext_buffer[2048];
4445 struct rte_cryptodev_info dev_info;
4447 struct rte_cryptodev_sym_capability_idx cap_idx;
4449 /* Check if device supports ZUC EEA3 */
4450 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4451 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4453 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4457 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4458 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4459 printf("Device doesn't support scatter-gather. "
4464 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4466 /* Append data which is padded to a multiple */
4467 /* of the algorithms block size */
4468 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4470 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4471 plaintext_pad_len, 10, 0);
4473 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4474 tdata->plaintext.data);
4476 /* Create ZUC session */
4477 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4478 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4479 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4480 tdata->key.data, tdata->key.len,
4481 tdata->cipher_iv.len);
4485 /* Clear mbuf payload */
4487 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4489 /* Create ZUC operation */
4490 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4491 tdata->cipher_iv.len, tdata->plaintext.len,
4496 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4498 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4500 ut_params->obuf = ut_params->op->sym->m_dst;
4501 if (ut_params->obuf)
4502 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4503 0, plaintext_len, ciphertext_buffer);
4505 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4506 0, plaintext_len, ciphertext_buffer);
4509 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4512 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4514 tdata->ciphertext.data,
4515 tdata->validCipherLenInBits.len,
4516 "ZUC Ciphertext data not as expected");
4522 test_zuc_authentication(const struct wireless_test_data *tdata)
4524 struct crypto_testsuite_params *ts_params = &testsuite_params;
4525 struct crypto_unittest_params *ut_params = &unittest_params;
4528 unsigned plaintext_pad_len;
4529 unsigned plaintext_len;
4532 struct rte_cryptodev_sym_capability_idx cap_idx;
4534 /* Check if device supports ZUC EIA3 */
4535 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4536 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4538 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4542 /* Create ZUC session */
4543 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4544 tdata->key.data, tdata->key.len,
4545 tdata->auth_iv.len, tdata->digest.len,
4546 RTE_CRYPTO_AUTH_OP_GENERATE,
4547 RTE_CRYPTO_AUTH_ZUC_EIA3);
4551 /* alloc mbuf and set payload */
4552 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4554 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4555 rte_pktmbuf_tailroom(ut_params->ibuf));
4557 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4558 /* Append data which is padded to a multiple of */
4559 /* the algorithms block size */
4560 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4561 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4563 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4565 /* Create ZUC operation */
4566 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4567 tdata->auth_iv.data, tdata->auth_iv.len,
4568 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4569 tdata->validAuthLenInBits.len,
4574 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4576 ut_params->obuf = ut_params->op->sym->m_src;
4577 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4578 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4579 + plaintext_pad_len;
4582 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4585 DIGEST_BYTE_LENGTH_KASUMI_F9,
4586 "ZUC Generated auth tag not as expected");
4592 test_kasumi_encryption_test_case_1(void)
4594 return test_kasumi_encryption(&kasumi_test_case_1);
4598 test_kasumi_encryption_test_case_1_sgl(void)
4600 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4604 test_kasumi_encryption_test_case_1_oop(void)
4606 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4610 test_kasumi_encryption_test_case_1_oop_sgl(void)
4612 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4616 test_kasumi_encryption_test_case_2(void)
4618 return test_kasumi_encryption(&kasumi_test_case_2);
4622 test_kasumi_encryption_test_case_3(void)
4624 return test_kasumi_encryption(&kasumi_test_case_3);
4628 test_kasumi_encryption_test_case_4(void)
4630 return test_kasumi_encryption(&kasumi_test_case_4);
4634 test_kasumi_encryption_test_case_5(void)
4636 return test_kasumi_encryption(&kasumi_test_case_5);
4640 test_kasumi_decryption_test_case_1(void)
4642 return test_kasumi_decryption(&kasumi_test_case_1);
4646 test_kasumi_decryption_test_case_1_oop(void)
4648 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4652 test_kasumi_decryption_test_case_2(void)
4654 return test_kasumi_decryption(&kasumi_test_case_2);
4658 test_kasumi_decryption_test_case_3(void)
4660 return test_kasumi_decryption(&kasumi_test_case_3);
4664 test_kasumi_decryption_test_case_4(void)
4666 return test_kasumi_decryption(&kasumi_test_case_4);
4670 test_kasumi_decryption_test_case_5(void)
4672 return test_kasumi_decryption(&kasumi_test_case_5);
4675 test_snow3g_encryption_test_case_1(void)
4677 return test_snow3g_encryption(&snow3g_test_case_1);
4681 test_snow3g_encryption_test_case_1_oop(void)
4683 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4687 test_snow3g_encryption_test_case_1_oop_sgl(void)
4689 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4694 test_snow3g_encryption_test_case_1_offset_oop(void)
4696 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4700 test_snow3g_encryption_test_case_2(void)
4702 return test_snow3g_encryption(&snow3g_test_case_2);
4706 test_snow3g_encryption_test_case_3(void)
4708 return test_snow3g_encryption(&snow3g_test_case_3);
4712 test_snow3g_encryption_test_case_4(void)
4714 return test_snow3g_encryption(&snow3g_test_case_4);
4718 test_snow3g_encryption_test_case_5(void)
4720 return test_snow3g_encryption(&snow3g_test_case_5);
4724 test_snow3g_decryption_test_case_1(void)
4726 return test_snow3g_decryption(&snow3g_test_case_1);
4730 test_snow3g_decryption_test_case_1_oop(void)
4732 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4736 test_snow3g_decryption_test_case_2(void)
4738 return test_snow3g_decryption(&snow3g_test_case_2);
4742 test_snow3g_decryption_test_case_3(void)
4744 return test_snow3g_decryption(&snow3g_test_case_3);
4748 test_snow3g_decryption_test_case_4(void)
4750 return test_snow3g_decryption(&snow3g_test_case_4);
4754 test_snow3g_decryption_test_case_5(void)
4756 return test_snow3g_decryption(&snow3g_test_case_5);
4759 test_snow3g_cipher_auth_test_case_1(void)
4761 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4765 test_snow3g_auth_cipher_test_case_1(void)
4767 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4771 test_kasumi_auth_cipher_test_case_1(void)
4773 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4777 test_kasumi_cipher_auth_test_case_1(void)
4779 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4783 test_zuc_encryption_test_case_1(void)
4785 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4789 test_zuc_encryption_test_case_2(void)
4791 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4795 test_zuc_encryption_test_case_3(void)
4797 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4801 test_zuc_encryption_test_case_4(void)
4803 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4807 test_zuc_encryption_test_case_5(void)
4809 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4813 test_zuc_encryption_test_case_6_sgl(void)
4815 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4819 test_zuc_hash_generate_test_case_1(void)
4821 return test_zuc_authentication(&zuc_test_case_auth_1b);
4825 test_zuc_hash_generate_test_case_2(void)
4827 return test_zuc_authentication(&zuc_test_case_auth_90b);
4831 test_zuc_hash_generate_test_case_3(void)
4833 return test_zuc_authentication(&zuc_test_case_auth_577b);
4837 test_zuc_hash_generate_test_case_4(void)
4839 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4843 test_zuc_hash_generate_test_case_5(void)
4845 return test_zuc_authentication(&zuc_test_auth_5670b);
4849 test_zuc_hash_generate_test_case_6(void)
4851 return test_zuc_authentication(&zuc_test_case_auth_128b);
4855 test_zuc_hash_generate_test_case_7(void)
4857 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4861 test_zuc_hash_generate_test_case_8(void)
4863 return test_zuc_authentication(&zuc_test_case_auth_584b);
4867 test_zuc_cipher_auth_test_case_1(void)
4869 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4873 test_zuc_cipher_auth_test_case_2(void)
4875 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4879 test_3DES_chain_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_3DES_CHAIN_TYPE);
4892 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4894 return TEST_SUCCESS;
4898 test_DES_cipheronly_qat_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_QAT_SYM_PMD)),
4909 BLKCIPHER_DES_CIPHERONLY_TYPE);
4911 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4913 return TEST_SUCCESS;
4917 test_DES_cipheronly_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_CIPHERONLY_TYPE);
4930 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4932 return TEST_SUCCESS;
4936 test_DES_docsis_openssl_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_OPENSSL_PMD)),
4947 BLKCIPHER_DES_DOCSIS_TYPE);
4949 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4951 return TEST_SUCCESS;
4955 test_DES_cipheronly_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_CIPHERONLY_TYPE);
4968 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4970 return TEST_SUCCESS;
4974 test_DES_docsis_mb_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_AESNI_MB_PMD)),
4985 BLKCIPHER_DES_DOCSIS_TYPE);
4987 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4989 return TEST_SUCCESS;
4993 test_3DES_chain_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_CHAIN_TYPE);
5006 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5008 return TEST_SUCCESS;
5012 test_3DES_cipheronly_dpaa_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_DPAA_SEC_PMD)),
5023 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5025 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5027 return TEST_SUCCESS;
5031 test_3DES_chain_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_CHAIN_TYPE);
5044 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5046 return TEST_SUCCESS;
5050 test_3DES_cipheronly_dpaa2_sec_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_DPAA2_SEC_PMD)),
5061 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5063 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5065 return TEST_SUCCESS;
5069 test_3DES_chain_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_CHAIN_TYPE);
5082 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5084 return TEST_SUCCESS;
5088 test_3DES_cipheronly_ccp_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_CCP_PMD)),
5099 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5101 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5103 return TEST_SUCCESS;
5107 test_3DES_cipheronly_qat_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_QAT_SYM_PMD)),
5118 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5120 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5122 return TEST_SUCCESS;
5126 test_3DES_chain_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_CHAIN_TYPE);
5139 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5141 return TEST_SUCCESS;
5145 test_3DES_cipheronly_openssl_all(void)
5147 struct crypto_testsuite_params *ts_params = &testsuite_params;
5150 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5151 ts_params->op_mpool,
5152 ts_params->session_mpool,
5153 ts_params->valid_devs[0],
5154 rte_cryptodev_driver_id_get(
5155 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5156 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5158 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5160 return TEST_SUCCESS;
5163 /* ***** AEAD algorithm Tests ***** */
5166 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5167 enum rte_crypto_aead_operation op,
5168 const uint8_t *key, const uint8_t key_len,
5169 const uint16_t aad_len, const uint8_t auth_len,
5172 uint8_t aead_key[key_len];
5174 struct crypto_testsuite_params *ts_params = &testsuite_params;
5175 struct crypto_unittest_params *ut_params = &unittest_params;
5177 memcpy(aead_key, key, key_len);
5179 /* Setup AEAD Parameters */
5180 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5181 ut_params->aead_xform.next = NULL;
5182 ut_params->aead_xform.aead.algo = algo;
5183 ut_params->aead_xform.aead.op = op;
5184 ut_params->aead_xform.aead.key.data = aead_key;
5185 ut_params->aead_xform.aead.key.length = key_len;
5186 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5187 ut_params->aead_xform.aead.iv.length = iv_len;
5188 ut_params->aead_xform.aead.digest_length = auth_len;
5189 ut_params->aead_xform.aead.aad_length = aad_len;
5191 debug_hexdump(stdout, "key:", key, key_len);
5193 /* Create Crypto session*/
5194 ut_params->sess = rte_cryptodev_sym_session_create(
5195 ts_params->session_mpool);
5197 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5198 &ut_params->aead_xform, ts_params->session_mpool);
5200 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5206 create_aead_xform(struct rte_crypto_op *op,
5207 enum rte_crypto_aead_algorithm algo,
5208 enum rte_crypto_aead_operation aead_op,
5209 uint8_t *key, const uint8_t key_len,
5210 const uint8_t aad_len, const uint8_t auth_len,
5213 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5214 "failed to allocate space for crypto transform");
5216 struct rte_crypto_sym_op *sym_op = op->sym;
5218 /* Setup AEAD Parameters */
5219 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5220 sym_op->xform->next = NULL;
5221 sym_op->xform->aead.algo = algo;
5222 sym_op->xform->aead.op = aead_op;
5223 sym_op->xform->aead.key.data = key;
5224 sym_op->xform->aead.key.length = key_len;
5225 sym_op->xform->aead.iv.offset = IV_OFFSET;
5226 sym_op->xform->aead.iv.length = iv_len;
5227 sym_op->xform->aead.digest_length = auth_len;
5228 sym_op->xform->aead.aad_length = aad_len;
5230 debug_hexdump(stdout, "key:", key, key_len);
5236 create_aead_operation(enum rte_crypto_aead_operation op,
5237 const struct aead_test_data *tdata)
5239 struct crypto_testsuite_params *ts_params = &testsuite_params;
5240 struct crypto_unittest_params *ut_params = &unittest_params;
5242 uint8_t *plaintext, *ciphertext;
5243 unsigned int aad_pad_len, plaintext_pad_len;
5245 /* Generate Crypto op data structure */
5246 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5247 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5248 TEST_ASSERT_NOT_NULL(ut_params->op,
5249 "Failed to allocate symmetric crypto operation struct");
5251 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5253 /* Append aad data */
5254 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5255 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5256 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5258 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5259 "no room to append aad");
5261 sym_op->aead.aad.phys_addr =
5262 rte_pktmbuf_iova(ut_params->ibuf);
5263 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5264 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5265 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5268 /* Append IV at the end of the crypto operation*/
5269 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5270 uint8_t *, IV_OFFSET);
5272 /* Copy IV 1 byte after the IV pointer, according to the API */
5273 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5274 debug_hexdump(stdout, "iv:", iv_ptr,
5277 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5278 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5280 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5281 "no room to append aad");
5283 sym_op->aead.aad.phys_addr =
5284 rte_pktmbuf_iova(ut_params->ibuf);
5285 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5286 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5289 /* Append IV at the end of the crypto operation*/
5290 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5291 uint8_t *, IV_OFFSET);
5293 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5294 debug_hexdump(stdout, "iv:", iv_ptr,
5298 /* Append plaintext/ciphertext */
5299 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5300 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5301 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5303 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5305 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5306 debug_hexdump(stdout, "plaintext:", plaintext,
5307 tdata->plaintext.len);
5309 if (ut_params->obuf) {
5310 ciphertext = (uint8_t *)rte_pktmbuf_append(
5312 plaintext_pad_len + aad_pad_len);
5313 TEST_ASSERT_NOT_NULL(ciphertext,
5314 "no room to append ciphertext");
5316 memset(ciphertext + aad_pad_len, 0,
5317 tdata->ciphertext.len);
5320 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5321 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5323 TEST_ASSERT_NOT_NULL(ciphertext,
5324 "no room to append ciphertext");
5326 memcpy(ciphertext, tdata->ciphertext.data,
5327 tdata->ciphertext.len);
5328 debug_hexdump(stdout, "ciphertext:", ciphertext,
5329 tdata->ciphertext.len);
5331 if (ut_params->obuf) {
5332 plaintext = (uint8_t *)rte_pktmbuf_append(
5334 plaintext_pad_len + aad_pad_len);
5335 TEST_ASSERT_NOT_NULL(plaintext,
5336 "no room to append plaintext");
5338 memset(plaintext + aad_pad_len, 0,
5339 tdata->plaintext.len);
5343 /* Append digest data */
5344 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5345 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5346 ut_params->obuf ? ut_params->obuf :
5348 tdata->auth_tag.len);
5349 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5350 "no room to append digest");
5351 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5352 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5353 ut_params->obuf ? ut_params->obuf :
5358 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5359 ut_params->ibuf, tdata->auth_tag.len);
5360 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5361 "no room to append digest");
5362 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5364 plaintext_pad_len + aad_pad_len);
5366 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5367 tdata->auth_tag.len);
5368 debug_hexdump(stdout, "digest:",
5369 sym_op->aead.digest.data,
5370 tdata->auth_tag.len);
5373 sym_op->aead.data.length = tdata->plaintext.len;
5374 sym_op->aead.data.offset = aad_pad_len;
5380 test_authenticated_encryption(const struct aead_test_data *tdata)
5382 struct crypto_testsuite_params *ts_params = &testsuite_params;
5383 struct crypto_unittest_params *ut_params = &unittest_params;
5386 uint8_t *ciphertext, *auth_tag;
5387 uint16_t plaintext_pad_len;
5390 /* Create AEAD session */
5391 retval = create_aead_session(ts_params->valid_devs[0],
5393 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5394 tdata->key.data, tdata->key.len,
5395 tdata->aad.len, tdata->auth_tag.len,
5400 if (tdata->aad.len > MBUF_SIZE) {
5401 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5402 /* Populate full size of add data */
5403 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5404 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5406 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5408 /* clear mbuf payload */
5409 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5410 rte_pktmbuf_tailroom(ut_params->ibuf));
5412 /* Create AEAD operation */
5413 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5417 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5419 ut_params->op->sym->m_src = ut_params->ibuf;
5421 /* Process crypto operation */
5422 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5423 ut_params->op), "failed to process sym crypto op");
5425 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5426 "crypto op processing failed");
5428 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5430 if (ut_params->op->sym->m_dst) {
5431 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5433 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5434 uint8_t *, plaintext_pad_len);
5436 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5438 ut_params->op->sym->cipher.data.offset);
5439 auth_tag = ciphertext + plaintext_pad_len;
5442 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5443 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5446 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5448 tdata->ciphertext.data,
5449 tdata->ciphertext.len,
5450 "Ciphertext data not as expected");
5452 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5454 tdata->auth_tag.data,
5455 tdata->auth_tag.len,
5456 "Generated auth tag not as expected");
5463 test_AES_GCM_authenticated_encryption_test_case_1(void)
5465 return test_authenticated_encryption(&gcm_test_case_1);
5469 test_AES_GCM_authenticated_encryption_test_case_2(void)
5471 return test_authenticated_encryption(&gcm_test_case_2);
5475 test_AES_GCM_authenticated_encryption_test_case_3(void)
5477 return test_authenticated_encryption(&gcm_test_case_3);
5481 test_AES_GCM_authenticated_encryption_test_case_4(void)
5483 return test_authenticated_encryption(&gcm_test_case_4);
5487 test_AES_GCM_authenticated_encryption_test_case_5(void)
5489 return test_authenticated_encryption(&gcm_test_case_5);
5493 test_AES_GCM_authenticated_encryption_test_case_6(void)
5495 return test_authenticated_encryption(&gcm_test_case_6);
5499 test_AES_GCM_authenticated_encryption_test_case_7(void)
5501 return test_authenticated_encryption(&gcm_test_case_7);
5505 test_AES_GCM_auth_encryption_test_case_192_1(void)
5507 return test_authenticated_encryption(&gcm_test_case_192_1);
5511 test_AES_GCM_auth_encryption_test_case_192_2(void)
5513 return test_authenticated_encryption(&gcm_test_case_192_2);
5517 test_AES_GCM_auth_encryption_test_case_192_3(void)
5519 return test_authenticated_encryption(&gcm_test_case_192_3);
5523 test_AES_GCM_auth_encryption_test_case_192_4(void)
5525 return test_authenticated_encryption(&gcm_test_case_192_4);
5529 test_AES_GCM_auth_encryption_test_case_192_5(void)
5531 return test_authenticated_encryption(&gcm_test_case_192_5);
5535 test_AES_GCM_auth_encryption_test_case_192_6(void)
5537 return test_authenticated_encryption(&gcm_test_case_192_6);
5541 test_AES_GCM_auth_encryption_test_case_192_7(void)
5543 return test_authenticated_encryption(&gcm_test_case_192_7);
5547 test_AES_GCM_auth_encryption_test_case_256_1(void)
5549 return test_authenticated_encryption(&gcm_test_case_256_1);
5553 test_AES_GCM_auth_encryption_test_case_256_2(void)
5555 return test_authenticated_encryption(&gcm_test_case_256_2);
5559 test_AES_GCM_auth_encryption_test_case_256_3(void)
5561 return test_authenticated_encryption(&gcm_test_case_256_3);
5565 test_AES_GCM_auth_encryption_test_case_256_4(void)
5567 return test_authenticated_encryption(&gcm_test_case_256_4);
5571 test_AES_GCM_auth_encryption_test_case_256_5(void)
5573 return test_authenticated_encryption(&gcm_test_case_256_5);
5577 test_AES_GCM_auth_encryption_test_case_256_6(void)
5579 return test_authenticated_encryption(&gcm_test_case_256_6);
5583 test_AES_GCM_auth_encryption_test_case_256_7(void)
5585 return test_authenticated_encryption(&gcm_test_case_256_7);
5589 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5591 return test_authenticated_encryption(&gcm_test_case_aad_1);
5595 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5597 return test_authenticated_encryption(&gcm_test_case_aad_2);
5601 test_authenticated_decryption(const struct aead_test_data *tdata)
5603 struct crypto_testsuite_params *ts_params = &testsuite_params;
5604 struct crypto_unittest_params *ut_params = &unittest_params;
5610 /* Create AEAD session */
5611 retval = create_aead_session(ts_params->valid_devs[0],
5613 RTE_CRYPTO_AEAD_OP_DECRYPT,
5614 tdata->key.data, tdata->key.len,
5615 tdata->aad.len, tdata->auth_tag.len,
5620 /* alloc mbuf and set payload */
5621 if (tdata->aad.len > MBUF_SIZE) {
5622 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5623 /* Populate full size of add data */
5624 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5625 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5627 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5629 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5630 rte_pktmbuf_tailroom(ut_params->ibuf));
5632 /* Create AEAD operation */
5633 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5637 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5639 ut_params->op->sym->m_src = ut_params->ibuf;
5641 /* Process crypto operation */
5642 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5643 ut_params->op), "failed to process sym crypto op");
5645 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5646 "crypto op processing failed");
5648 if (ut_params->op->sym->m_dst)
5649 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5652 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5654 ut_params->op->sym->cipher.data.offset);
5656 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5659 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5661 tdata->plaintext.data,
5662 tdata->plaintext.len,
5663 "Plaintext data not as expected");
5665 TEST_ASSERT_EQUAL(ut_params->op->status,
5666 RTE_CRYPTO_OP_STATUS_SUCCESS,
5667 "Authentication failed");
5672 test_AES_GCM_authenticated_decryption_test_case_1(void)
5674 return test_authenticated_decryption(&gcm_test_case_1);
5678 test_AES_GCM_authenticated_decryption_test_case_2(void)
5680 return test_authenticated_decryption(&gcm_test_case_2);
5684 test_AES_GCM_authenticated_decryption_test_case_3(void)
5686 return test_authenticated_decryption(&gcm_test_case_3);
5690 test_AES_GCM_authenticated_decryption_test_case_4(void)
5692 return test_authenticated_decryption(&gcm_test_case_4);
5696 test_AES_GCM_authenticated_decryption_test_case_5(void)
5698 return test_authenticated_decryption(&gcm_test_case_5);
5702 test_AES_GCM_authenticated_decryption_test_case_6(void)
5704 return test_authenticated_decryption(&gcm_test_case_6);
5708 test_AES_GCM_authenticated_decryption_test_case_7(void)
5710 return test_authenticated_decryption(&gcm_test_case_7);
5714 test_AES_GCM_auth_decryption_test_case_192_1(void)
5716 return test_authenticated_decryption(&gcm_test_case_192_1);
5720 test_AES_GCM_auth_decryption_test_case_192_2(void)
5722 return test_authenticated_decryption(&gcm_test_case_192_2);
5726 test_AES_GCM_auth_decryption_test_case_192_3(void)
5728 return test_authenticated_decryption(&gcm_test_case_192_3);
5732 test_AES_GCM_auth_decryption_test_case_192_4(void)
5734 return test_authenticated_decryption(&gcm_test_case_192_4);
5738 test_AES_GCM_auth_decryption_test_case_192_5(void)
5740 return test_authenticated_decryption(&gcm_test_case_192_5);
5744 test_AES_GCM_auth_decryption_test_case_192_6(void)
5746 return test_authenticated_decryption(&gcm_test_case_192_6);
5750 test_AES_GCM_auth_decryption_test_case_192_7(void)
5752 return test_authenticated_decryption(&gcm_test_case_192_7);
5756 test_AES_GCM_auth_decryption_test_case_256_1(void)
5758 return test_authenticated_decryption(&gcm_test_case_256_1);
5762 test_AES_GCM_auth_decryption_test_case_256_2(void)
5764 return test_authenticated_decryption(&gcm_test_case_256_2);
5768 test_AES_GCM_auth_decryption_test_case_256_3(void)
5770 return test_authenticated_decryption(&gcm_test_case_256_3);
5774 test_AES_GCM_auth_decryption_test_case_256_4(void)
5776 return test_authenticated_decryption(&gcm_test_case_256_4);
5780 test_AES_GCM_auth_decryption_test_case_256_5(void)
5782 return test_authenticated_decryption(&gcm_test_case_256_5);
5786 test_AES_GCM_auth_decryption_test_case_256_6(void)
5788 return test_authenticated_decryption(&gcm_test_case_256_6);
5792 test_AES_GCM_auth_decryption_test_case_256_7(void)
5794 return test_authenticated_decryption(&gcm_test_case_256_7);
5798 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5800 return test_authenticated_decryption(&gcm_test_case_aad_1);
5804 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5806 return test_authenticated_decryption(&gcm_test_case_aad_2);
5810 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5812 struct crypto_testsuite_params *ts_params = &testsuite_params;
5813 struct crypto_unittest_params *ut_params = &unittest_params;
5816 uint8_t *ciphertext, *auth_tag;
5817 uint16_t plaintext_pad_len;
5819 /* Create AEAD session */
5820 retval = create_aead_session(ts_params->valid_devs[0],
5822 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5823 tdata->key.data, tdata->key.len,
5824 tdata->aad.len, tdata->auth_tag.len,
5829 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5830 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5832 /* clear mbuf payload */
5833 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5834 rte_pktmbuf_tailroom(ut_params->ibuf));
5835 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5836 rte_pktmbuf_tailroom(ut_params->obuf));
5838 /* Create AEAD operation */
5839 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5843 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5845 ut_params->op->sym->m_src = ut_params->ibuf;
5846 ut_params->op->sym->m_dst = ut_params->obuf;
5848 /* Process crypto operation */
5849 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5850 ut_params->op), "failed to process sym crypto op");
5852 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5853 "crypto op processing failed");
5855 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5857 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5858 ut_params->op->sym->cipher.data.offset);
5859 auth_tag = ciphertext + plaintext_pad_len;
5861 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5862 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5865 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5867 tdata->ciphertext.data,
5868 tdata->ciphertext.len,
5869 "Ciphertext data not as expected");
5871 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5873 tdata->auth_tag.data,
5874 tdata->auth_tag.len,
5875 "Generated auth tag not as expected");
5882 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5884 return test_authenticated_encryption_oop(&gcm_test_case_5);
5888 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5890 struct crypto_testsuite_params *ts_params = &testsuite_params;
5891 struct crypto_unittest_params *ut_params = &unittest_params;
5896 /* Create AEAD session */
5897 retval = create_aead_session(ts_params->valid_devs[0],
5899 RTE_CRYPTO_AEAD_OP_DECRYPT,
5900 tdata->key.data, tdata->key.len,
5901 tdata->aad.len, tdata->auth_tag.len,
5906 /* alloc mbuf and set payload */
5907 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5908 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5910 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5911 rte_pktmbuf_tailroom(ut_params->ibuf));
5912 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5913 rte_pktmbuf_tailroom(ut_params->obuf));
5915 /* Create AEAD operation */
5916 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5920 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5922 ut_params->op->sym->m_src = ut_params->ibuf;
5923 ut_params->op->sym->m_dst = ut_params->obuf;
5925 /* Process crypto operation */
5926 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5927 ut_params->op), "failed to process sym crypto op");
5929 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5930 "crypto op processing failed");
5932 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5933 ut_params->op->sym->cipher.data.offset);
5935 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5938 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5940 tdata->plaintext.data,
5941 tdata->plaintext.len,
5942 "Plaintext data not as expected");
5944 TEST_ASSERT_EQUAL(ut_params->op->status,
5945 RTE_CRYPTO_OP_STATUS_SUCCESS,
5946 "Authentication failed");
5951 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5953 return test_authenticated_decryption_oop(&gcm_test_case_5);
5957 test_authenticated_encryption_sessionless(
5958 const struct aead_test_data *tdata)
5960 struct crypto_testsuite_params *ts_params = &testsuite_params;
5961 struct crypto_unittest_params *ut_params = &unittest_params;
5964 uint8_t *ciphertext, *auth_tag;
5965 uint16_t plaintext_pad_len;
5966 uint8_t key[tdata->key.len + 1];
5968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5970 /* clear mbuf payload */
5971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5972 rte_pktmbuf_tailroom(ut_params->ibuf));
5974 /* Create AEAD operation */
5975 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5979 /* Create GCM xform */
5980 memcpy(key, tdata->key.data, tdata->key.len);
5981 retval = create_aead_xform(ut_params->op,
5983 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5984 key, tdata->key.len,
5985 tdata->aad.len, tdata->auth_tag.len,
5990 ut_params->op->sym->m_src = ut_params->ibuf;
5992 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5993 RTE_CRYPTO_OP_SESSIONLESS,
5994 "crypto op session type not sessionless");
5996 /* Process crypto operation */
5997 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5998 ut_params->op), "failed to process sym crypto op");
6000 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6002 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6003 "crypto op status not success");
6005 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6007 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6008 ut_params->op->sym->cipher.data.offset);
6009 auth_tag = ciphertext + plaintext_pad_len;
6011 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6012 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6015 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6017 tdata->ciphertext.data,
6018 tdata->ciphertext.len,
6019 "Ciphertext data not as expected");
6021 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6023 tdata->auth_tag.data,
6024 tdata->auth_tag.len,
6025 "Generated auth tag not as expected");
6032 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6034 return test_authenticated_encryption_sessionless(
6039 test_authenticated_decryption_sessionless(
6040 const struct aead_test_data *tdata)
6042 struct crypto_testsuite_params *ts_params = &testsuite_params;
6043 struct crypto_unittest_params *ut_params = &unittest_params;
6047 uint8_t key[tdata->key.len + 1];
6049 /* alloc mbuf and set payload */
6050 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6052 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6053 rte_pktmbuf_tailroom(ut_params->ibuf));
6055 /* Create AEAD operation */
6056 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6060 /* Create AEAD xform */
6061 memcpy(key, tdata->key.data, tdata->key.len);
6062 retval = create_aead_xform(ut_params->op,
6064 RTE_CRYPTO_AEAD_OP_DECRYPT,
6065 key, tdata->key.len,
6066 tdata->aad.len, tdata->auth_tag.len,
6071 ut_params->op->sym->m_src = ut_params->ibuf;
6073 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6074 RTE_CRYPTO_OP_SESSIONLESS,
6075 "crypto op session type not sessionless");
6077 /* Process crypto operation */
6078 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6079 ut_params->op), "failed to process sym crypto op");
6081 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6083 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6084 "crypto op status not success");
6086 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6087 ut_params->op->sym->cipher.data.offset);
6089 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6092 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6094 tdata->plaintext.data,
6095 tdata->plaintext.len,
6096 "Plaintext data not as expected");
6098 TEST_ASSERT_EQUAL(ut_params->op->status,
6099 RTE_CRYPTO_OP_STATUS_SUCCESS,
6100 "Authentication failed");
6105 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6107 return test_authenticated_decryption_sessionless(
6112 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6114 return test_authenticated_encryption(&ccm_test_case_128_1);
6118 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6120 return test_authenticated_encryption(&ccm_test_case_128_2);
6124 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6126 return test_authenticated_encryption(&ccm_test_case_128_3);
6130 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6132 return test_authenticated_decryption(&ccm_test_case_128_1);
6136 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6138 return test_authenticated_decryption(&ccm_test_case_128_2);
6142 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6144 return test_authenticated_decryption(&ccm_test_case_128_3);
6148 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6150 return test_authenticated_encryption(&ccm_test_case_192_1);
6154 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6156 return test_authenticated_encryption(&ccm_test_case_192_2);
6160 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6162 return test_authenticated_encryption(&ccm_test_case_192_3);
6166 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6168 return test_authenticated_decryption(&ccm_test_case_192_1);
6172 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6174 return test_authenticated_decryption(&ccm_test_case_192_2);
6178 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6180 return test_authenticated_decryption(&ccm_test_case_192_3);
6184 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6186 return test_authenticated_encryption(&ccm_test_case_256_1);
6190 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6192 return test_authenticated_encryption(&ccm_test_case_256_2);
6196 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6198 return test_authenticated_encryption(&ccm_test_case_256_3);
6202 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6204 return test_authenticated_decryption(&ccm_test_case_256_1);
6208 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6210 return test_authenticated_decryption(&ccm_test_case_256_2);
6214 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6216 return test_authenticated_decryption(&ccm_test_case_256_3);
6222 struct crypto_testsuite_params *ts_params = &testsuite_params;
6223 struct rte_cryptodev_stats stats;
6224 struct rte_cryptodev *dev;
6225 cryptodev_stats_get_t temp_pfn;
6227 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6228 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6229 &stats) == -ENODEV),
6230 "rte_cryptodev_stats_get invalid dev failed");
6231 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6232 "rte_cryptodev_stats_get invalid Param failed");
6233 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6234 temp_pfn = dev->dev_ops->stats_get;
6235 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6236 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6238 "rte_cryptodev_stats_get invalid Param failed");
6239 dev->dev_ops->stats_get = temp_pfn;
6241 /* Test expected values */
6243 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6245 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6247 "rte_cryptodev_stats_get failed");
6248 TEST_ASSERT((stats.enqueued_count == 1),
6249 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6250 TEST_ASSERT((stats.dequeued_count == 1),
6251 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6252 TEST_ASSERT((stats.enqueue_err_count == 0),
6253 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6254 TEST_ASSERT((stats.dequeue_err_count == 0),
6255 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6257 /* invalid device but should ignore and not reset device stats*/
6258 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6259 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6261 "rte_cryptodev_stats_get failed");
6262 TEST_ASSERT((stats.enqueued_count == 1),
6263 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6265 /* check that a valid reset clears stats */
6266 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6267 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6269 "rte_cryptodev_stats_get failed");
6270 TEST_ASSERT((stats.enqueued_count == 0),
6271 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6272 TEST_ASSERT((stats.dequeued_count == 0),
6273 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6275 return TEST_SUCCESS;
6278 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6279 struct crypto_unittest_params *ut_params,
6280 enum rte_crypto_auth_operation op,
6281 const struct HMAC_MD5_vector *test_case)
6285 memcpy(key, test_case->key.data, test_case->key.len);
6287 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6288 ut_params->auth_xform.next = NULL;
6289 ut_params->auth_xform.auth.op = op;
6291 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6293 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6294 ut_params->auth_xform.auth.key.length = test_case->key.len;
6295 ut_params->auth_xform.auth.key.data = key;
6297 ut_params->sess = rte_cryptodev_sym_session_create(
6298 ts_params->session_mpool);
6300 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6301 ut_params->sess, &ut_params->auth_xform,
6302 ts_params->session_mpool);
6304 if (ut_params->sess == NULL)
6307 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6309 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6310 rte_pktmbuf_tailroom(ut_params->ibuf));
6315 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6316 const struct HMAC_MD5_vector *test_case,
6317 uint8_t **plaintext)
6319 uint16_t plaintext_pad_len;
6321 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6323 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6326 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6328 memcpy(*plaintext, test_case->plaintext.data,
6329 test_case->plaintext.len);
6331 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6332 ut_params->ibuf, MD5_DIGEST_LEN);
6333 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6334 "no room to append digest");
6335 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6336 ut_params->ibuf, plaintext_pad_len);
6338 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6339 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6340 test_case->auth_tag.len);
6343 sym_op->auth.data.offset = 0;
6344 sym_op->auth.data.length = test_case->plaintext.len;
6346 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6347 ut_params->op->sym->m_src = ut_params->ibuf;
6353 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6355 uint16_t plaintext_pad_len;
6356 uint8_t *plaintext, *auth_tag;
6358 struct crypto_testsuite_params *ts_params = &testsuite_params;
6359 struct crypto_unittest_params *ut_params = &unittest_params;
6361 if (MD5_HMAC_create_session(ts_params, ut_params,
6362 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6365 /* Generate Crypto op data structure */
6366 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6367 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6368 TEST_ASSERT_NOT_NULL(ut_params->op,
6369 "Failed to allocate symmetric crypto operation struct");
6371 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6374 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6377 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6378 ut_params->op), "failed to process sym crypto op");
6380 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6381 "crypto op processing failed");
6383 if (ut_params->op->sym->m_dst) {
6384 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6385 uint8_t *, plaintext_pad_len);
6387 auth_tag = plaintext + plaintext_pad_len;
6390 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6392 test_case->auth_tag.data,
6393 test_case->auth_tag.len,
6394 "HMAC_MD5 generated tag not as expected");
6396 return TEST_SUCCESS;
6400 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6404 struct crypto_testsuite_params *ts_params = &testsuite_params;
6405 struct crypto_unittest_params *ut_params = &unittest_params;
6407 if (MD5_HMAC_create_session(ts_params, ut_params,
6408 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6412 /* Generate Crypto op data structure */
6413 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6414 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6415 TEST_ASSERT_NOT_NULL(ut_params->op,
6416 "Failed to allocate symmetric crypto operation struct");
6418 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6421 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6422 ut_params->op), "failed to process sym crypto op");
6424 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6425 "HMAC_MD5 crypto op processing failed");
6427 return TEST_SUCCESS;
6431 test_MD5_HMAC_generate_case_1(void)
6433 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6437 test_MD5_HMAC_verify_case_1(void)
6439 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6443 test_MD5_HMAC_generate_case_2(void)
6445 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6449 test_MD5_HMAC_verify_case_2(void)
6451 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6455 test_multi_session(void)
6457 struct crypto_testsuite_params *ts_params = &testsuite_params;
6458 struct crypto_unittest_params *ut_params = &unittest_params;
6460 struct rte_cryptodev_info dev_info;
6461 struct rte_cryptodev_sym_session **sessions;
6465 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6466 aes_cbc_key, hmac_sha512_key);
6469 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6471 sessions = rte_malloc(NULL,
6472 (sizeof(struct rte_cryptodev_sym_session *) *
6473 dev_info.sym.max_nb_sessions) + 1, 0);
6475 /* Create multiple crypto sessions*/
6476 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6478 sessions[i] = rte_cryptodev_sym_session_create(
6479 ts_params->session_mpool);
6481 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6482 sessions[i], &ut_params->auth_xform,
6483 ts_params->session_mpool);
6484 TEST_ASSERT_NOT_NULL(sessions[i],
6485 "Session creation failed at session number %u",
6488 /* Attempt to send a request on each session */
6489 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6493 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6494 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6496 "Failed to perform decrypt on request number %u.", i);
6497 /* free crypto operation structure */
6499 rte_crypto_op_free(ut_params->op);
6502 * free mbuf - both obuf and ibuf are usually the same,
6503 * so check if they point at the same address is necessary,
6504 * to avoid freeing the mbuf twice.
6506 if (ut_params->obuf) {
6507 rte_pktmbuf_free(ut_params->obuf);
6508 if (ut_params->ibuf == ut_params->obuf)
6509 ut_params->ibuf = 0;
6510 ut_params->obuf = 0;
6512 if (ut_params->ibuf) {
6513 rte_pktmbuf_free(ut_params->ibuf);
6514 ut_params->ibuf = 0;
6518 /* Next session create should fail */
6519 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6520 sessions[i], &ut_params->auth_xform,
6521 ts_params->session_mpool);
6522 TEST_ASSERT_NULL(sessions[i],
6523 "Session creation succeeded unexpectedly!");
6525 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6526 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6528 rte_cryptodev_sym_session_free(sessions[i]);
6533 return TEST_SUCCESS;
6536 struct multi_session_params {
6537 struct crypto_unittest_params ut_params;
6538 uint8_t *cipher_key;
6540 const uint8_t *cipher;
6541 const uint8_t *digest;
6545 #define MB_SESSION_NUMBER 3
6548 test_multi_session_random_usage(void)
6550 struct crypto_testsuite_params *ts_params = &testsuite_params;
6551 struct rte_cryptodev_info dev_info;
6552 struct rte_cryptodev_sym_session **sessions;
6554 struct multi_session_params ut_paramz[] = {
6557 .cipher_key = ms_aes_cbc_key0,
6558 .hmac_key = ms_hmac_key0,
6559 .cipher = ms_aes_cbc_cipher0,
6560 .digest = ms_hmac_digest0,
6561 .iv = ms_aes_cbc_iv0
6564 .cipher_key = ms_aes_cbc_key1,
6565 .hmac_key = ms_hmac_key1,
6566 .cipher = ms_aes_cbc_cipher1,
6567 .digest = ms_hmac_digest1,
6568 .iv = ms_aes_cbc_iv1
6571 .cipher_key = ms_aes_cbc_key2,
6572 .hmac_key = ms_hmac_key2,
6573 .cipher = ms_aes_cbc_cipher2,
6574 .digest = ms_hmac_digest2,
6575 .iv = ms_aes_cbc_iv2
6580 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6582 sessions = rte_malloc(NULL,
6583 (sizeof(struct rte_cryptodev_sym_session *)
6584 * dev_info.sym.max_nb_sessions) + 1, 0);
6586 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6587 sessions[i] = rte_cryptodev_sym_session_create(
6588 ts_params->session_mpool);
6590 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6591 sizeof(struct crypto_unittest_params));
6593 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6594 &ut_paramz[i].ut_params,
6595 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6597 /* Create multiple crypto sessions*/
6598 rte_cryptodev_sym_session_init(
6599 ts_params->valid_devs[0],
6601 &ut_paramz[i].ut_params.auth_xform,
6602 ts_params->session_mpool);
6604 TEST_ASSERT_NOT_NULL(sessions[i],
6605 "Session creation failed at session number %u",
6611 for (i = 0; i < 40000; i++) {
6613 j = rand() % MB_SESSION_NUMBER;
6615 TEST_ASSERT_SUCCESS(
6616 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6618 &ut_paramz[j].ut_params,
6619 ts_params, ut_paramz[j].cipher,
6620 ut_paramz[j].digest,
6622 "Failed to perform decrypt on request number %u.", i);
6624 if (ut_paramz[j].ut_params.op)
6625 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6628 * free mbuf - both obuf and ibuf are usually the same,
6629 * so check if they point at the same address is necessary,
6630 * to avoid freeing the mbuf twice.
6632 if (ut_paramz[j].ut_params.obuf) {
6633 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6634 if (ut_paramz[j].ut_params.ibuf
6635 == ut_paramz[j].ut_params.obuf)
6636 ut_paramz[j].ut_params.ibuf = 0;
6637 ut_paramz[j].ut_params.obuf = 0;
6639 if (ut_paramz[j].ut_params.ibuf) {
6640 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6641 ut_paramz[j].ut_params.ibuf = 0;
6645 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6646 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6648 rte_cryptodev_sym_session_free(sessions[i]);
6653 return TEST_SUCCESS;
6657 test_null_cipher_only_operation(void)
6659 struct crypto_testsuite_params *ts_params = &testsuite_params;
6660 struct crypto_unittest_params *ut_params = &unittest_params;
6662 /* Generate test mbuf data and space for digest */
6663 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6664 catch_22_quote, QUOTE_512_BYTES, 0);
6666 /* Setup Cipher Parameters */
6667 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6668 ut_params->cipher_xform.next = NULL;
6670 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6671 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6673 ut_params->sess = rte_cryptodev_sym_session_create(
6674 ts_params->session_mpool);
6676 /* Create Crypto session*/
6677 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6679 &ut_params->cipher_xform,
6680 ts_params->session_mpool);
6681 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6683 /* Generate Crypto op data structure */
6684 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6685 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6686 TEST_ASSERT_NOT_NULL(ut_params->op,
6687 "Failed to allocate symmetric crypto operation struct");
6689 /* Set crypto operation data parameters */
6690 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6692 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6694 /* set crypto operation source mbuf */
6695 sym_op->m_src = ut_params->ibuf;
6697 sym_op->cipher.data.offset = 0;
6698 sym_op->cipher.data.length = QUOTE_512_BYTES;
6700 /* Process crypto operation */
6701 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6703 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6705 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6706 "crypto operation processing failed");
6709 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6710 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6713 "Ciphertext data not as expected");
6715 return TEST_SUCCESS;
6717 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6718 0xab, 0xab, 0xab, 0xab,
6719 0xab, 0xab, 0xab, 0xab,
6720 0xab, 0xab, 0xab, 0xab};
6722 test_null_auth_only_operation(void)
6724 struct crypto_testsuite_params *ts_params = &testsuite_params;
6725 struct crypto_unittest_params *ut_params = &unittest_params;
6728 /* Generate test mbuf data and space for digest */
6729 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6730 catch_22_quote, QUOTE_512_BYTES, 0);
6732 /* create a pointer for digest, but don't expect anything to be written
6733 * here in a NULL auth algo so no mbuf append done.
6735 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6737 /* prefill the memory pointed to by digest */
6738 memcpy(digest, orig_data, sizeof(orig_data));
6740 /* Setup HMAC Parameters */
6741 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6742 ut_params->auth_xform.next = NULL;
6744 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6745 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6747 ut_params->sess = rte_cryptodev_sym_session_create(
6748 ts_params->session_mpool);
6750 /* Create Crypto session*/
6751 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6752 ut_params->sess, &ut_params->auth_xform,
6753 ts_params->session_mpool);
6754 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6756 /* Generate Crypto op data structure */
6757 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6758 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6759 TEST_ASSERT_NOT_NULL(ut_params->op,
6760 "Failed to allocate symmetric crypto operation struct");
6762 /* Set crypto operation data parameters */
6763 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6765 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6767 sym_op->m_src = ut_params->ibuf;
6769 sym_op->auth.data.offset = 0;
6770 sym_op->auth.data.length = QUOTE_512_BYTES;
6771 sym_op->auth.digest.data = digest;
6772 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6775 /* Process crypto operation */
6776 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6778 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6780 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6781 "crypto operation processing failed");
6782 /* Make sure memory pointed to by digest hasn't been overwritten */
6783 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6787 "Memory at digest ptr overwritten unexpectedly");
6789 return TEST_SUCCESS;
6794 test_null_cipher_auth_operation(void)
6796 struct crypto_testsuite_params *ts_params = &testsuite_params;
6797 struct crypto_unittest_params *ut_params = &unittest_params;
6800 /* Generate test mbuf data and space for digest */
6801 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6802 catch_22_quote, QUOTE_512_BYTES, 0);
6804 /* create a pointer for digest, but don't expect anything to be written
6805 * here in a NULL auth algo so no mbuf append done.
6807 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6809 /* prefill the memory pointed to by digest */
6810 memcpy(digest, orig_data, sizeof(orig_data));
6812 /* Setup Cipher Parameters */
6813 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6814 ut_params->cipher_xform.next = &ut_params->auth_xform;
6816 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6817 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6819 /* Setup HMAC Parameters */
6820 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6821 ut_params->auth_xform.next = NULL;
6823 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6824 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6826 ut_params->sess = rte_cryptodev_sym_session_create(
6827 ts_params->session_mpool);
6829 /* Create Crypto session*/
6830 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6831 ut_params->sess, &ut_params->cipher_xform,
6832 ts_params->session_mpool);
6833 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6835 /* Generate Crypto op data structure */
6836 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6837 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6838 TEST_ASSERT_NOT_NULL(ut_params->op,
6839 "Failed to allocate symmetric crypto operation struct");
6841 /* Set crypto operation data parameters */
6842 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6844 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6846 sym_op->m_src = ut_params->ibuf;
6848 sym_op->cipher.data.offset = 0;
6849 sym_op->cipher.data.length = QUOTE_512_BYTES;
6851 sym_op->auth.data.offset = 0;
6852 sym_op->auth.data.length = QUOTE_512_BYTES;
6853 sym_op->auth.digest.data = digest;
6854 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6857 /* Process crypto operation */
6858 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6860 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6862 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6863 "crypto operation processing failed");
6866 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6867 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6870 "Ciphertext data not as expected");
6871 /* Make sure memory pointed to by digest hasn't been overwritten */
6872 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6876 "Memory at digest ptr overwritten unexpectedly");
6878 return TEST_SUCCESS;
6882 test_null_auth_cipher_operation(void)
6884 struct crypto_testsuite_params *ts_params = &testsuite_params;
6885 struct crypto_unittest_params *ut_params = &unittest_params;
6888 /* Generate test mbuf data */
6889 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6890 catch_22_quote, QUOTE_512_BYTES, 0);
6892 /* create a pointer for digest, but don't expect anything to be written
6893 * here in a NULL auth algo so no mbuf append done.
6895 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6897 /* prefill the memory pointed to by digest */
6898 memcpy(digest, orig_data, sizeof(orig_data));
6900 /* Setup Cipher Parameters */
6901 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6902 ut_params->cipher_xform.next = NULL;
6904 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6905 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6907 /* Setup HMAC Parameters */
6908 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6909 ut_params->auth_xform.next = &ut_params->cipher_xform;
6911 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6912 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6914 ut_params->sess = rte_cryptodev_sym_session_create(
6915 ts_params->session_mpool);
6917 /* Create Crypto session*/
6918 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6919 ut_params->sess, &ut_params->cipher_xform,
6920 ts_params->session_mpool);
6921 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6923 /* Generate Crypto op data structure */
6924 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6925 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6926 TEST_ASSERT_NOT_NULL(ut_params->op,
6927 "Failed to allocate symmetric crypto operation struct");
6929 /* Set crypto operation data parameters */
6930 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6932 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6934 sym_op->m_src = ut_params->ibuf;
6936 sym_op->cipher.data.offset = 0;
6937 sym_op->cipher.data.length = QUOTE_512_BYTES;
6939 sym_op->auth.data.offset = 0;
6940 sym_op->auth.data.length = QUOTE_512_BYTES;
6941 sym_op->auth.digest.data = digest;
6942 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6945 /* Process crypto operation */
6946 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6948 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6950 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6951 "crypto operation processing failed");
6954 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6955 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6958 "Ciphertext data not as expected");
6959 /* Make sure memory pointed to by digest hasn't been overwritten */
6960 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6964 "Memory at digest ptr overwritten unexpectedly");
6966 return TEST_SUCCESS;
6971 test_null_invalid_operation(void)
6973 struct crypto_testsuite_params *ts_params = &testsuite_params;
6974 struct crypto_unittest_params *ut_params = &unittest_params;
6977 /* Setup Cipher Parameters */
6978 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6979 ut_params->cipher_xform.next = NULL;
6981 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6982 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6984 ut_params->sess = rte_cryptodev_sym_session_create(
6985 ts_params->session_mpool);
6987 /* Create Crypto session*/
6988 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6989 ut_params->sess, &ut_params->cipher_xform,
6990 ts_params->session_mpool);
6991 TEST_ASSERT(ret < 0,
6992 "Session creation succeeded unexpectedly");
6995 /* Setup HMAC Parameters */
6996 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6997 ut_params->auth_xform.next = NULL;
6999 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7000 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7002 ut_params->sess = rte_cryptodev_sym_session_create(
7003 ts_params->session_mpool);
7005 /* Create Crypto session*/
7006 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7007 ut_params->sess, &ut_params->auth_xform,
7008 ts_params->session_mpool);
7009 TEST_ASSERT(ret < 0,
7010 "Session creation succeeded unexpectedly");
7012 return TEST_SUCCESS;
7016 #define NULL_BURST_LENGTH (32)
7019 test_null_burst_operation(void)
7021 struct crypto_testsuite_params *ts_params = &testsuite_params;
7022 struct crypto_unittest_params *ut_params = &unittest_params;
7024 unsigned i, burst_len = NULL_BURST_LENGTH;
7026 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7027 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7029 /* Setup Cipher Parameters */
7030 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7031 ut_params->cipher_xform.next = &ut_params->auth_xform;
7033 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7034 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7036 /* Setup HMAC Parameters */
7037 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7038 ut_params->auth_xform.next = NULL;
7040 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7041 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7043 ut_params->sess = rte_cryptodev_sym_session_create(
7044 ts_params->session_mpool);
7046 /* Create Crypto session*/
7047 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7048 ut_params->sess, &ut_params->cipher_xform,
7049 ts_params->session_mpool);
7050 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7052 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7053 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7054 burst_len, "failed to generate burst of crypto ops");
7056 /* Generate an operation for each mbuf in burst */
7057 for (i = 0; i < burst_len; i++) {
7058 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7060 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7062 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7066 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7068 burst[i]->sym->m_src = m;
7071 /* Process crypto operation */
7072 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7073 0, burst, burst_len),
7075 "Error enqueuing burst");
7077 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7078 0, burst_dequeued, burst_len),
7080 "Error dequeuing burst");
7083 for (i = 0; i < burst_len; i++) {
7085 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7086 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7088 "data not as expected");
7090 rte_pktmbuf_free(burst[i]->sym->m_src);
7091 rte_crypto_op_free(burst[i]);
7094 return TEST_SUCCESS;
7098 generate_gmac_large_plaintext(uint8_t *data)
7102 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7103 memcpy(&data[i], &data[0], 32);
7107 create_gmac_operation(enum rte_crypto_auth_operation op,
7108 const struct gmac_test_data *tdata)
7110 struct crypto_testsuite_params *ts_params = &testsuite_params;
7111 struct crypto_unittest_params *ut_params = &unittest_params;
7112 struct rte_crypto_sym_op *sym_op;
7114 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7116 /* Generate Crypto op data structure */
7117 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7118 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7119 TEST_ASSERT_NOT_NULL(ut_params->op,
7120 "Failed to allocate symmetric crypto operation struct");
7122 sym_op = ut_params->op->sym;
7124 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7125 ut_params->ibuf, tdata->gmac_tag.len);
7126 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7127 "no room to append digest");
7129 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7130 ut_params->ibuf, plaintext_pad_len);
7132 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7133 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7134 tdata->gmac_tag.len);
7135 debug_hexdump(stdout, "digest:",
7136 sym_op->auth.digest.data,
7137 tdata->gmac_tag.len);
7140 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7141 uint8_t *, IV_OFFSET);
7143 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7145 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7147 sym_op->cipher.data.length = 0;
7148 sym_op->cipher.data.offset = 0;
7150 sym_op->auth.data.offset = 0;
7151 sym_op->auth.data.length = tdata->plaintext.len;
7156 static int create_gmac_session(uint8_t dev_id,
7157 const struct gmac_test_data *tdata,
7158 enum rte_crypto_auth_operation auth_op)
7160 uint8_t auth_key[tdata->key.len];
7162 struct crypto_testsuite_params *ts_params = &testsuite_params;
7163 struct crypto_unittest_params *ut_params = &unittest_params;
7165 memcpy(auth_key, tdata->key.data, tdata->key.len);
7167 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7168 ut_params->auth_xform.next = NULL;
7170 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7171 ut_params->auth_xform.auth.op = auth_op;
7172 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7173 ut_params->auth_xform.auth.key.length = tdata->key.len;
7174 ut_params->auth_xform.auth.key.data = auth_key;
7175 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7176 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7179 ut_params->sess = rte_cryptodev_sym_session_create(
7180 ts_params->session_mpool);
7182 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7183 &ut_params->auth_xform,
7184 ts_params->session_mpool);
7186 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7192 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7194 struct crypto_testsuite_params *ts_params = &testsuite_params;
7195 struct crypto_unittest_params *ut_params = &unittest_params;
7199 uint8_t *auth_tag, *plaintext;
7200 uint16_t plaintext_pad_len;
7202 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7203 "No GMAC length in the source data");
7205 retval = create_gmac_session(ts_params->valid_devs[0],
7206 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7211 if (tdata->plaintext.len > MBUF_SIZE)
7212 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7214 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7215 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7216 "Failed to allocate input buffer in mempool");
7218 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7219 rte_pktmbuf_tailroom(ut_params->ibuf));
7221 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7223 * Runtime generate the large plain text instead of use hard code
7224 * plain text vector. It is done to avoid create huge source file
7225 * with the test vector.
7227 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7228 generate_gmac_large_plaintext(tdata->plaintext.data);
7230 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7232 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7234 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7235 debug_hexdump(stdout, "plaintext:", plaintext,
7236 tdata->plaintext.len);
7238 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7244 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7246 ut_params->op->sym->m_src = ut_params->ibuf;
7248 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7249 ut_params->op), "failed to process sym crypto op");
7251 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7252 "crypto op processing failed");
7254 if (ut_params->op->sym->m_dst) {
7255 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7256 uint8_t *, plaintext_pad_len);
7258 auth_tag = plaintext + plaintext_pad_len;
7261 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7263 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7265 tdata->gmac_tag.data,
7266 tdata->gmac_tag.len,
7267 "GMAC Generated auth tag not as expected");
7273 test_AES_GMAC_authentication_test_case_1(void)
7275 return test_AES_GMAC_authentication(&gmac_test_case_1);
7279 test_AES_GMAC_authentication_test_case_2(void)
7281 return test_AES_GMAC_authentication(&gmac_test_case_2);
7285 test_AES_GMAC_authentication_test_case_3(void)
7287 return test_AES_GMAC_authentication(&gmac_test_case_3);
7291 test_AES_GMAC_authentication_test_case_4(void)
7293 return test_AES_GMAC_authentication(&gmac_test_case_4);
7297 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7299 struct crypto_testsuite_params *ts_params = &testsuite_params;
7300 struct crypto_unittest_params *ut_params = &unittest_params;
7302 uint32_t plaintext_pad_len;
7305 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7306 "No GMAC length in the source data");
7308 retval = create_gmac_session(ts_params->valid_devs[0],
7309 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7314 if (tdata->plaintext.len > MBUF_SIZE)
7315 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7317 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7318 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7319 "Failed to allocate input buffer in mempool");
7321 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7322 rte_pktmbuf_tailroom(ut_params->ibuf));
7324 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7327 * Runtime generate the large plain text instead of use hard code
7328 * plain text vector. It is done to avoid create huge source file
7329 * with the test vector.
7331 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7332 generate_gmac_large_plaintext(tdata->plaintext.data);
7334 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7336 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7338 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7339 debug_hexdump(stdout, "plaintext:", plaintext,
7340 tdata->plaintext.len);
7342 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7348 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7350 ut_params->op->sym->m_src = ut_params->ibuf;
7352 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7353 ut_params->op), "failed to process sym crypto op");
7355 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7356 "crypto op processing failed");
7363 test_AES_GMAC_authentication_verify_test_case_1(void)
7365 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7369 test_AES_GMAC_authentication_verify_test_case_2(void)
7371 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7375 test_AES_GMAC_authentication_verify_test_case_3(void)
7377 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7381 test_AES_GMAC_authentication_verify_test_case_4(void)
7383 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7386 struct test_crypto_vector {
7387 enum rte_crypto_cipher_algorithm crypto_algo;
7400 const uint8_t *data;
7405 const uint8_t *data;
7409 enum rte_crypto_auth_algorithm auth_algo;
7417 const uint8_t *data;
7427 static const struct test_crypto_vector
7428 hmac_sha1_test_crypto_vector = {
7429 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7431 .data = plaintext_hash,
7436 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7437 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7438 0xDE, 0xF4, 0xDE, 0xAD
7444 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7445 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7446 0x3F, 0x91, 0x64, 0x59
7452 static const struct test_crypto_vector
7453 aes128_gmac_test_vector = {
7454 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7456 .data = plaintext_hash,
7461 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7462 0x08, 0x09, 0x0A, 0x0B
7468 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7469 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7475 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7476 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7482 static const struct test_crypto_vector
7483 aes128cbc_hmac_sha1_test_vector = {
7484 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7487 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7488 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7494 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7495 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7500 .data = plaintext_hash,
7504 .data = ciphertext512_aes128cbc,
7507 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7510 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7511 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7512 0xDE, 0xF4, 0xDE, 0xAD
7518 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7519 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7520 0x18, 0x8C, 0x1D, 0x32
7527 data_corruption(uint8_t *data)
7533 tag_corruption(uint8_t *data, unsigned int tag_offset)
7535 data[tag_offset] += 1;
7539 create_auth_session(struct crypto_unittest_params *ut_params,
7541 const struct test_crypto_vector *reference,
7542 enum rte_crypto_auth_operation auth_op)
7544 struct crypto_testsuite_params *ts_params = &testsuite_params;
7545 uint8_t auth_key[reference->auth_key.len + 1];
7547 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7549 /* Setup Authentication Parameters */
7550 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7551 ut_params->auth_xform.auth.op = auth_op;
7552 ut_params->auth_xform.next = NULL;
7553 ut_params->auth_xform.auth.algo = reference->auth_algo;
7554 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7555 ut_params->auth_xform.auth.key.data = auth_key;
7556 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7558 /* Create Crypto session*/
7559 ut_params->sess = rte_cryptodev_sym_session_create(
7560 ts_params->session_mpool);
7562 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7563 &ut_params->auth_xform,
7564 ts_params->session_mpool);
7566 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7572 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7574 const struct test_crypto_vector *reference,
7575 enum rte_crypto_auth_operation auth_op,
7576 enum rte_crypto_cipher_operation cipher_op)
7578 struct crypto_testsuite_params *ts_params = &testsuite_params;
7579 uint8_t cipher_key[reference->cipher_key.len + 1];
7580 uint8_t auth_key[reference->auth_key.len + 1];
7582 memcpy(cipher_key, reference->cipher_key.data,
7583 reference->cipher_key.len);
7584 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7586 /* Setup Authentication Parameters */
7587 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7588 ut_params->auth_xform.auth.op = auth_op;
7589 ut_params->auth_xform.auth.algo = reference->auth_algo;
7590 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7591 ut_params->auth_xform.auth.key.data = auth_key;
7592 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7594 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7595 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7596 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7598 ut_params->auth_xform.next = &ut_params->cipher_xform;
7600 /* Setup Cipher Parameters */
7601 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7602 ut_params->cipher_xform.next = NULL;
7603 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7604 ut_params->cipher_xform.cipher.op = cipher_op;
7605 ut_params->cipher_xform.cipher.key.data = cipher_key;
7606 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7607 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7608 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7611 /* Create Crypto session*/
7612 ut_params->sess = rte_cryptodev_sym_session_create(
7613 ts_params->session_mpool);
7615 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7616 &ut_params->auth_xform,
7617 ts_params->session_mpool);
7619 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7625 create_auth_operation(struct crypto_testsuite_params *ts_params,
7626 struct crypto_unittest_params *ut_params,
7627 const struct test_crypto_vector *reference,
7628 unsigned int auth_generate)
7630 /* Generate Crypto op data structure */
7631 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7632 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7633 TEST_ASSERT_NOT_NULL(ut_params->op,
7634 "Failed to allocate pktmbuf offload");
7636 /* Set crypto operation data parameters */
7637 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7639 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7641 /* set crypto operation source mbuf */
7642 sym_op->m_src = ut_params->ibuf;
7645 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7646 ut_params->ibuf, reference->digest.len);
7648 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7649 "no room to append auth tag");
7651 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7652 ut_params->ibuf, reference->plaintext.len);
7655 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7657 memcpy(sym_op->auth.digest.data,
7658 reference->digest.data,
7659 reference->digest.len);
7661 debug_hexdump(stdout, "digest:",
7662 sym_op->auth.digest.data,
7663 reference->digest.len);
7665 sym_op->auth.data.length = reference->plaintext.len;
7666 sym_op->auth.data.offset = 0;
7672 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7673 struct crypto_unittest_params *ut_params,
7674 const struct test_crypto_vector *reference,
7675 unsigned int auth_generate)
7677 /* Generate Crypto op data structure */
7678 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7679 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7680 TEST_ASSERT_NOT_NULL(ut_params->op,
7681 "Failed to allocate pktmbuf offload");
7683 /* Set crypto operation data parameters */
7684 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7686 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7688 /* set crypto operation source mbuf */
7689 sym_op->m_src = ut_params->ibuf;
7692 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7693 ut_params->ibuf, reference->digest.len);
7695 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7696 "no room to append auth tag");
7698 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7699 ut_params->ibuf, reference->ciphertext.len);
7702 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7704 memcpy(sym_op->auth.digest.data,
7705 reference->digest.data,
7706 reference->digest.len);
7708 debug_hexdump(stdout, "digest:",
7709 sym_op->auth.digest.data,
7710 reference->digest.len);
7712 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7713 reference->iv.data, reference->iv.len);
7715 sym_op->cipher.data.length = 0;
7716 sym_op->cipher.data.offset = 0;
7718 sym_op->auth.data.length = reference->plaintext.len;
7719 sym_op->auth.data.offset = 0;
7725 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7726 struct crypto_unittest_params *ut_params,
7727 const struct test_crypto_vector *reference,
7728 unsigned int auth_generate)
7730 /* Generate Crypto op data structure */
7731 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7732 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7733 TEST_ASSERT_NOT_NULL(ut_params->op,
7734 "Failed to allocate pktmbuf offload");
7736 /* Set crypto operation data parameters */
7737 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7739 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7741 /* set crypto operation source mbuf */
7742 sym_op->m_src = ut_params->ibuf;
7745 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7746 ut_params->ibuf, reference->digest.len);
7748 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7749 "no room to append auth tag");
7751 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7752 ut_params->ibuf, reference->ciphertext.len);
7755 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7757 memcpy(sym_op->auth.digest.data,
7758 reference->digest.data,
7759 reference->digest.len);
7761 debug_hexdump(stdout, "digest:",
7762 sym_op->auth.digest.data,
7763 reference->digest.len);
7765 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7766 reference->iv.data, reference->iv.len);
7768 sym_op->cipher.data.length = reference->ciphertext.len;
7769 sym_op->cipher.data.offset = 0;
7771 sym_op->auth.data.length = reference->ciphertext.len;
7772 sym_op->auth.data.offset = 0;
7778 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7779 struct crypto_unittest_params *ut_params,
7780 const struct test_crypto_vector *reference)
7782 return create_auth_operation(ts_params, ut_params, reference, 0);
7786 create_auth_verify_GMAC_operation(
7787 struct crypto_testsuite_params *ts_params,
7788 struct crypto_unittest_params *ut_params,
7789 const struct test_crypto_vector *reference)
7791 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7795 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7796 struct crypto_unittest_params *ut_params,
7797 const struct test_crypto_vector *reference)
7799 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7803 test_authentication_verify_fail_when_data_corruption(
7804 struct crypto_testsuite_params *ts_params,
7805 struct crypto_unittest_params *ut_params,
7806 const struct test_crypto_vector *reference,
7807 unsigned int data_corrupted)
7813 /* Create session */
7814 retval = create_auth_session(ut_params,
7815 ts_params->valid_devs[0],
7817 RTE_CRYPTO_AUTH_OP_VERIFY);
7821 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7822 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7823 "Failed to allocate input buffer in mempool");
7825 /* clear mbuf payload */
7826 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7827 rte_pktmbuf_tailroom(ut_params->ibuf));
7829 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7830 reference->plaintext.len);
7831 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7832 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7834 debug_hexdump(stdout, "plaintext:", plaintext,
7835 reference->plaintext.len);
7837 /* Create operation */
7838 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7844 data_corruption(plaintext);
7846 tag_corruption(plaintext, reference->plaintext.len);
7848 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7850 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7851 TEST_ASSERT_EQUAL(ut_params->op->status,
7852 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7853 "authentication not failed");
7855 ut_params->obuf = ut_params->op->sym->m_src;
7856 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7862 test_authentication_verify_GMAC_fail_when_corruption(
7863 struct crypto_testsuite_params *ts_params,
7864 struct crypto_unittest_params *ut_params,
7865 const struct test_crypto_vector *reference,
7866 unsigned int data_corrupted)
7871 /* Create session */
7872 retval = create_auth_cipher_session(ut_params,
7873 ts_params->valid_devs[0],
7875 RTE_CRYPTO_AUTH_OP_VERIFY,
7876 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7880 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7881 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7882 "Failed to allocate input buffer in mempool");
7884 /* clear mbuf payload */
7885 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7886 rte_pktmbuf_tailroom(ut_params->ibuf));
7888 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7889 reference->plaintext.len);
7890 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7891 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7893 debug_hexdump(stdout, "plaintext:", plaintext,
7894 reference->plaintext.len);
7896 /* Create operation */
7897 retval = create_auth_verify_GMAC_operation(ts_params,
7905 data_corruption(plaintext);
7907 tag_corruption(plaintext, reference->aad.len);
7909 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7911 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7912 TEST_ASSERT_EQUAL(ut_params->op->status,
7913 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7914 "authentication not failed");
7916 ut_params->obuf = ut_params->op->sym->m_src;
7917 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7923 test_authenticated_decryption_fail_when_corruption(
7924 struct crypto_testsuite_params *ts_params,
7925 struct crypto_unittest_params *ut_params,
7926 const struct test_crypto_vector *reference,
7927 unsigned int data_corrupted)
7931 uint8_t *ciphertext;
7933 /* Create session */
7934 retval = create_auth_cipher_session(ut_params,
7935 ts_params->valid_devs[0],
7937 RTE_CRYPTO_AUTH_OP_VERIFY,
7938 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7942 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7943 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7944 "Failed to allocate input buffer in mempool");
7946 /* clear mbuf payload */
7947 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7948 rte_pktmbuf_tailroom(ut_params->ibuf));
7950 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7951 reference->ciphertext.len);
7952 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7953 memcpy(ciphertext, reference->ciphertext.data,
7954 reference->ciphertext.len);
7956 /* Create operation */
7957 retval = create_cipher_auth_verify_operation(ts_params,
7965 data_corruption(ciphertext);
7967 tag_corruption(ciphertext, reference->ciphertext.len);
7969 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7972 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7973 TEST_ASSERT_EQUAL(ut_params->op->status,
7974 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7975 "authentication not failed");
7977 ut_params->obuf = ut_params->op->sym->m_src;
7978 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7984 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7985 const struct aead_test_data *tdata,
7986 void *digest_mem, uint64_t digest_phys)
7988 struct crypto_testsuite_params *ts_params = &testsuite_params;
7989 struct crypto_unittest_params *ut_params = &unittest_params;
7991 const unsigned int auth_tag_len = tdata->auth_tag.len;
7992 const unsigned int iv_len = tdata->iv.len;
7993 unsigned int aad_len = tdata->aad.len;
7995 /* Generate Crypto op data structure */
7996 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7997 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7998 TEST_ASSERT_NOT_NULL(ut_params->op,
7999 "Failed to allocate symmetric crypto operation struct");
8001 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8003 sym_op->aead.digest.data = digest_mem;
8005 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8006 "no room to append digest");
8008 sym_op->aead.digest.phys_addr = digest_phys;
8010 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8011 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8013 debug_hexdump(stdout, "digest:",
8014 sym_op->aead.digest.data,
8018 /* Append aad data */
8019 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8020 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8021 uint8_t *, IV_OFFSET);
8023 /* Copy IV 1 byte after the IV pointer, according to the API */
8024 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8026 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8028 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8029 ut_params->ibuf, aad_len);
8030 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8031 "no room to prepend aad");
8032 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8035 memset(sym_op->aead.aad.data, 0, aad_len);
8036 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
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);
8043 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8044 uint8_t *, IV_OFFSET);
8046 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8048 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8049 ut_params->ibuf, aad_len);
8050 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8051 "no room to prepend aad");
8052 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8055 memset(sym_op->aead.aad.data, 0, aad_len);
8056 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8058 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8059 debug_hexdump(stdout, "aad:",
8060 sym_op->aead.aad.data, aad_len);
8063 sym_op->aead.data.length = tdata->plaintext.len;
8064 sym_op->aead.data.offset = aad_len;
8069 #define SGL_MAX_NO 16
8072 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8073 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8075 struct crypto_testsuite_params *ts_params = &testsuite_params;
8076 struct crypto_unittest_params *ut_params = &unittest_params;
8077 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8080 int to_trn_tbl[SGL_MAX_NO];
8082 unsigned int trn_data = 0;
8083 uint8_t *plaintext, *ciphertext, *auth_tag;
8085 if (fragsz > tdata->plaintext.len)
8086 fragsz = tdata->plaintext.len;
8088 uint16_t plaintext_len = fragsz;
8089 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8091 if (fragsz_oop > tdata->plaintext.len)
8092 frag_size_oop = tdata->plaintext.len;
8095 void *digest_mem = NULL;
8097 uint32_t prepend_len = tdata->aad.len;
8099 if (tdata->plaintext.len % fragsz != 0) {
8100 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8103 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8108 * For out-op-place we need to alloc another mbuf
8111 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8112 rte_pktmbuf_append(ut_params->obuf,
8113 frag_size_oop + prepend_len);
8114 buf_oop = ut_params->obuf;
8117 /* Create AEAD session */
8118 retval = create_aead_session(ts_params->valid_devs[0],
8120 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8121 tdata->key.data, tdata->key.len,
8122 tdata->aad.len, tdata->auth_tag.len,
8127 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8129 /* clear mbuf payload */
8130 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8131 rte_pktmbuf_tailroom(ut_params->ibuf));
8133 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8136 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8138 trn_data += plaintext_len;
8140 buf = ut_params->ibuf;
8143 * Loop until no more fragments
8146 while (trn_data < tdata->plaintext.len) {
8148 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8149 (tdata->plaintext.len - trn_data) : fragsz;
8151 to_trn_tbl[ecx++] = to_trn;
8153 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8156 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8157 rte_pktmbuf_tailroom(buf));
8160 if (oop && !fragsz_oop) {
8161 buf_last_oop = buf_oop->next =
8162 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8163 buf_oop = buf_oop->next;
8164 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8165 0, rte_pktmbuf_tailroom(buf_oop));
8166 rte_pktmbuf_append(buf_oop, to_trn);
8169 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8172 memcpy(plaintext, tdata->plaintext.data + trn_data,
8175 if (trn_data == tdata->plaintext.len) {
8178 digest_mem = rte_pktmbuf_append(buf_oop,
8179 tdata->auth_tag.len);
8181 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8182 tdata->auth_tag.len);
8186 uint64_t digest_phys = 0;
8188 ut_params->ibuf->nb_segs = segs;
8191 if (fragsz_oop && oop) {
8195 if (frag_size_oop == tdata->plaintext.len) {
8196 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8197 tdata->auth_tag.len);
8199 digest_phys = rte_pktmbuf_iova_offset(
8201 tdata->plaintext.len + prepend_len);
8204 trn_data = frag_size_oop;
8205 while (trn_data < tdata->plaintext.len) {
8208 (tdata->plaintext.len - trn_data <
8210 (tdata->plaintext.len - trn_data) :
8213 to_trn_tbl[ecx++] = to_trn;
8215 buf_last_oop = buf_oop->next =
8216 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8217 buf_oop = buf_oop->next;
8218 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8219 0, rte_pktmbuf_tailroom(buf_oop));
8220 rte_pktmbuf_append(buf_oop, to_trn);
8224 if (trn_data == tdata->plaintext.len) {
8225 digest_mem = rte_pktmbuf_append(buf_oop,
8226 tdata->auth_tag.len);
8230 ut_params->obuf->nb_segs = segs;
8234 * Place digest at the end of the last buffer
8237 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8238 if (oop && buf_last_oop)
8239 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8241 if (!digest_mem && !oop) {
8242 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8243 + tdata->auth_tag.len);
8244 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8245 tdata->plaintext.len);
8248 /* Create AEAD operation */
8249 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8250 tdata, digest_mem, digest_phys);
8255 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8257 ut_params->op->sym->m_src = ut_params->ibuf;
8259 ut_params->op->sym->m_dst = ut_params->obuf;
8261 /* Process crypto operation */
8262 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8263 ut_params->op), "failed to process sym crypto op");
8265 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8266 "crypto op processing failed");
8269 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8270 uint8_t *, prepend_len);
8272 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8273 uint8_t *, prepend_len);
8277 fragsz = fragsz_oop;
8279 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8281 tdata->ciphertext.data,
8283 "Ciphertext data not as expected");
8285 buf = ut_params->op->sym->m_src->next;
8287 buf = ut_params->op->sym->m_dst->next;
8289 unsigned int off = fragsz;
8293 ciphertext = rte_pktmbuf_mtod(buf,
8296 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8298 tdata->ciphertext.data + off,
8300 "Ciphertext data not as expected");
8302 off += to_trn_tbl[ecx++];
8306 auth_tag = digest_mem;
8307 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8309 tdata->auth_tag.data,
8310 tdata->auth_tag.len,
8311 "Generated auth tag not as expected");
8317 #define OUT_OF_PLACE 1
8320 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8322 return test_authenticated_encryption_SGL(
8323 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8327 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8329 return test_authenticated_encryption_SGL(
8330 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8334 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8336 return test_authenticated_encryption_SGL(
8337 &gcm_test_case_8, OUT_OF_PLACE, 400,
8338 gcm_test_case_8.plaintext.len);
8342 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8345 return test_authenticated_encryption_SGL(
8346 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8350 test_authentication_verify_fail_when_data_corrupted(
8351 struct crypto_testsuite_params *ts_params,
8352 struct crypto_unittest_params *ut_params,
8353 const struct test_crypto_vector *reference)
8355 return test_authentication_verify_fail_when_data_corruption(
8356 ts_params, ut_params, reference, 1);
8360 test_authentication_verify_fail_when_tag_corrupted(
8361 struct crypto_testsuite_params *ts_params,
8362 struct crypto_unittest_params *ut_params,
8363 const struct test_crypto_vector *reference)
8365 return test_authentication_verify_fail_when_data_corruption(
8366 ts_params, ut_params, reference, 0);
8370 test_authentication_verify_GMAC_fail_when_data_corrupted(
8371 struct crypto_testsuite_params *ts_params,
8372 struct crypto_unittest_params *ut_params,
8373 const struct test_crypto_vector *reference)
8375 return test_authentication_verify_GMAC_fail_when_corruption(
8376 ts_params, ut_params, reference, 1);
8380 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8381 struct crypto_testsuite_params *ts_params,
8382 struct crypto_unittest_params *ut_params,
8383 const struct test_crypto_vector *reference)
8385 return test_authentication_verify_GMAC_fail_when_corruption(
8386 ts_params, ut_params, reference, 0);
8390 test_authenticated_decryption_fail_when_data_corrupted(
8391 struct crypto_testsuite_params *ts_params,
8392 struct crypto_unittest_params *ut_params,
8393 const struct test_crypto_vector *reference)
8395 return test_authenticated_decryption_fail_when_corruption(
8396 ts_params, ut_params, reference, 1);
8400 test_authenticated_decryption_fail_when_tag_corrupted(
8401 struct crypto_testsuite_params *ts_params,
8402 struct crypto_unittest_params *ut_params,
8403 const struct test_crypto_vector *reference)
8405 return test_authenticated_decryption_fail_when_corruption(
8406 ts_params, ut_params, reference, 0);
8410 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8412 return test_authentication_verify_fail_when_data_corrupted(
8413 &testsuite_params, &unittest_params,
8414 &hmac_sha1_test_crypto_vector);
8418 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8420 return test_authentication_verify_fail_when_tag_corrupted(
8421 &testsuite_params, &unittest_params,
8422 &hmac_sha1_test_crypto_vector);
8426 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8428 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8429 &testsuite_params, &unittest_params,
8430 &aes128_gmac_test_vector);
8434 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8436 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8437 &testsuite_params, &unittest_params,
8438 &aes128_gmac_test_vector);
8442 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8444 return test_authenticated_decryption_fail_when_data_corrupted(
8447 &aes128cbc_hmac_sha1_test_vector);
8451 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8453 return test_authenticated_decryption_fail_when_tag_corrupted(
8456 &aes128cbc_hmac_sha1_test_vector);
8459 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8461 /* global AESNI slave IDs for the scheduler test */
8462 uint8_t aesni_ids[2];
8465 test_scheduler_attach_slave_op(void)
8467 struct crypto_testsuite_params *ts_params = &testsuite_params;
8468 uint8_t sched_id = ts_params->valid_devs[0];
8469 uint32_t nb_devs, i, nb_devs_attached = 0;
8473 /* create 2 AESNI_MB if necessary */
8474 nb_devs = rte_cryptodev_device_count_by_driver(
8475 rte_cryptodev_driver_id_get(
8476 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8478 for (i = nb_devs; i < 2; i++) {
8479 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8480 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8482 ret = rte_vdev_init(vdev_name, NULL);
8484 TEST_ASSERT(ret == 0,
8485 "Failed to create instance %u of"
8487 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8491 /* attach 2 AESNI_MB cdevs */
8492 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8494 struct rte_cryptodev_info info;
8496 rte_cryptodev_info_get(i, &info);
8497 if (info.driver_id != rte_cryptodev_driver_id_get(
8498 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8502 * Create the session mempool again, since now there are new devices
8503 * to use the mempool.
8505 if (ts_params->session_mpool) {
8506 rte_mempool_free(ts_params->session_mpool);
8507 ts_params->session_mpool = NULL;
8509 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8512 * Create mempool with maximum number of sessions * 2,
8513 * to include the session headers
8515 if (ts_params->session_mpool == NULL) {
8516 ts_params->session_mpool = rte_mempool_create(
8518 info.sym.max_nb_sessions * 2,
8520 0, 0, NULL, NULL, NULL,
8521 NULL, SOCKET_ID_ANY,
8524 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8525 "session mempool allocation failed");
8528 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8531 TEST_ASSERT(ret == 0,
8532 "Failed to attach device %u of pmd : %s", i,
8533 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8535 aesni_ids[nb_devs_attached] = (uint8_t)i;
8544 test_scheduler_detach_slave_op(void)
8546 struct crypto_testsuite_params *ts_params = &testsuite_params;
8547 uint8_t sched_id = ts_params->valid_devs[0];
8551 for (i = 0; i < 2; i++) {
8552 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8554 TEST_ASSERT(ret == 0,
8555 "Failed to detach device %u", aesni_ids[i]);
8562 test_scheduler_mode_op(void)
8564 struct crypto_testsuite_params *ts_params = &testsuite_params;
8565 uint8_t sched_id = ts_params->valid_devs[0];
8566 struct rte_cryptodev_scheduler_ops op = {0};
8567 struct rte_cryptodev_scheduler dummy_scheduler = {
8568 .description = "dummy scheduler to test mode",
8569 .name = "dummy scheduler",
8570 .mode = CDEV_SCHED_MODE_USERDEFINED,
8575 /* set user defined mode */
8576 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8578 TEST_ASSERT(ret == 0,
8579 "Failed to set cdev %u to user defined mode", sched_id);
8581 /* set round robin mode */
8582 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8583 CDEV_SCHED_MODE_ROUNDROBIN);
8584 TEST_ASSERT(ret == 0,
8585 "Failed to set cdev %u to round-robin mode", sched_id);
8586 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8587 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8593 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8594 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8595 .setup = testsuite_setup,
8596 .teardown = testsuite_teardown,
8597 .unit_test_cases = {
8598 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8599 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_AES_chain_scheduler_all),
8602 TEST_CASE_ST(ut_setup, ut_teardown,
8603 test_AES_cipheronly_scheduler_all),
8604 TEST_CASE_ST(ut_setup, ut_teardown,
8605 test_authonly_scheduler_all),
8606 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8607 TEST_CASES_END() /**< NULL terminate unit test array */
8611 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8613 static struct unit_test_suite cryptodev_qat_testsuite = {
8614 .suite_name = "Crypto QAT Unit Test Suite",
8615 .setup = testsuite_setup,
8616 .teardown = testsuite_teardown,
8617 .unit_test_cases = {
8618 TEST_CASE_ST(ut_setup, ut_teardown,
8619 test_device_configure_invalid_dev_id),
8620 TEST_CASE_ST(ut_setup, ut_teardown,
8621 test_device_configure_invalid_queue_pair_ids),
8622 TEST_CASE_ST(ut_setup, ut_teardown,
8623 test_queue_pair_descriptor_setup),
8624 TEST_CASE_ST(ut_setup, ut_teardown,
8625 test_multi_session),
8627 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_AES_cipheronly_qat_all),
8630 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8631 TEST_CASE_ST(ut_setup, ut_teardown,
8632 test_3DES_cipheronly_qat_all),
8633 TEST_CASE_ST(ut_setup, ut_teardown,
8634 test_DES_cipheronly_qat_all),
8635 TEST_CASE_ST(ut_setup, ut_teardown,
8636 test_AES_docsis_qat_all),
8637 TEST_CASE_ST(ut_setup, ut_teardown,
8638 test_DES_docsis_qat_all),
8639 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8640 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8642 /** AES CCM Authenticated Encryption 128 bits key */
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_AES_CCM_authenticated_encryption_test_case_128_1),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_AES_CCM_authenticated_encryption_test_case_128_2),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_AES_CCM_authenticated_encryption_test_case_128_3),
8650 /** AES CCM Authenticated Decryption 128 bits key*/
8651 TEST_CASE_ST(ut_setup, ut_teardown,
8652 test_AES_CCM_authenticated_decryption_test_case_128_1),
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_AES_CCM_authenticated_decryption_test_case_128_2),
8655 TEST_CASE_ST(ut_setup, ut_teardown,
8656 test_AES_CCM_authenticated_decryption_test_case_128_3),
8658 /** AES GCM Authenticated Encryption */
8659 TEST_CASE_ST(ut_setup, ut_teardown,
8660 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8661 TEST_CASE_ST(ut_setup, ut_teardown,
8662 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8663 TEST_CASE_ST(ut_setup, ut_teardown,
8664 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_AES_GCM_authenticated_encryption_test_case_1),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_AES_GCM_authenticated_encryption_test_case_2),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_AES_GCM_authenticated_encryption_test_case_3),
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 test_AES_GCM_authenticated_encryption_test_case_4),
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_AES_GCM_authenticated_encryption_test_case_5),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_AES_GCM_authenticated_encryption_test_case_6),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_AES_GCM_authenticated_encryption_test_case_7),
8680 /** AES GCM Authenticated Decryption */
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_AES_GCM_authenticated_decryption_test_case_1),
8683 TEST_CASE_ST(ut_setup, ut_teardown,
8684 test_AES_GCM_authenticated_decryption_test_case_2),
8685 TEST_CASE_ST(ut_setup, ut_teardown,
8686 test_AES_GCM_authenticated_decryption_test_case_3),
8687 TEST_CASE_ST(ut_setup, ut_teardown,
8688 test_AES_GCM_authenticated_decryption_test_case_4),
8689 TEST_CASE_ST(ut_setup, ut_teardown,
8690 test_AES_GCM_authenticated_decryption_test_case_5),
8691 TEST_CASE_ST(ut_setup, ut_teardown,
8692 test_AES_GCM_authenticated_decryption_test_case_6),
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 test_AES_GCM_authenticated_decryption_test_case_7),
8696 /** AES GCM Authenticated Encryption 192 bits key */
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_AES_GCM_auth_encryption_test_case_192_1),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_AES_GCM_auth_encryption_test_case_192_2),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_AES_GCM_auth_encryption_test_case_192_3),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 test_AES_GCM_auth_encryption_test_case_192_4),
8705 TEST_CASE_ST(ut_setup, ut_teardown,
8706 test_AES_GCM_auth_encryption_test_case_192_5),
8707 TEST_CASE_ST(ut_setup, ut_teardown,
8708 test_AES_GCM_auth_encryption_test_case_192_6),
8709 TEST_CASE_ST(ut_setup, ut_teardown,
8710 test_AES_GCM_auth_encryption_test_case_192_7),
8712 /** AES GCM Authenticated Decryption 192 bits key */
8713 TEST_CASE_ST(ut_setup, ut_teardown,
8714 test_AES_GCM_auth_decryption_test_case_192_1),
8715 TEST_CASE_ST(ut_setup, ut_teardown,
8716 test_AES_GCM_auth_decryption_test_case_192_2),
8717 TEST_CASE_ST(ut_setup, ut_teardown,
8718 test_AES_GCM_auth_decryption_test_case_192_3),
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 test_AES_GCM_auth_decryption_test_case_192_4),
8721 TEST_CASE_ST(ut_setup, ut_teardown,
8722 test_AES_GCM_auth_decryption_test_case_192_5),
8723 TEST_CASE_ST(ut_setup, ut_teardown,
8724 test_AES_GCM_auth_decryption_test_case_192_6),
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 test_AES_GCM_auth_decryption_test_case_192_7),
8728 /** AES GCM Authenticated Encryption 256 bits key */
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_AES_GCM_auth_encryption_test_case_256_1),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 test_AES_GCM_auth_encryption_test_case_256_2),
8733 TEST_CASE_ST(ut_setup, ut_teardown,
8734 test_AES_GCM_auth_encryption_test_case_256_3),
8735 TEST_CASE_ST(ut_setup, ut_teardown,
8736 test_AES_GCM_auth_encryption_test_case_256_4),
8737 TEST_CASE_ST(ut_setup, ut_teardown,
8738 test_AES_GCM_auth_encryption_test_case_256_5),
8739 TEST_CASE_ST(ut_setup, ut_teardown,
8740 test_AES_GCM_auth_encryption_test_case_256_6),
8741 TEST_CASE_ST(ut_setup, ut_teardown,
8742 test_AES_GCM_auth_encryption_test_case_256_7),
8744 /** AES GMAC Authentication */
8745 TEST_CASE_ST(ut_setup, ut_teardown,
8746 test_AES_GMAC_authentication_test_case_1),
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_AES_GMAC_authentication_verify_test_case_1),
8749 TEST_CASE_ST(ut_setup, ut_teardown,
8750 test_AES_GMAC_authentication_test_case_2),
8751 TEST_CASE_ST(ut_setup, ut_teardown,
8752 test_AES_GMAC_authentication_verify_test_case_2),
8753 TEST_CASE_ST(ut_setup, ut_teardown,
8754 test_AES_GMAC_authentication_test_case_3),
8755 TEST_CASE_ST(ut_setup, ut_teardown,
8756 test_AES_GMAC_authentication_verify_test_case_3),
8758 /** SNOW 3G encrypt only (UEA2) */
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 test_snow3g_encryption_test_case_1),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 test_snow3g_encryption_test_case_2),
8763 TEST_CASE_ST(ut_setup, ut_teardown,
8764 test_snow3g_encryption_test_case_3),
8765 TEST_CASE_ST(ut_setup, ut_teardown,
8766 test_snow3g_encryption_test_case_4),
8767 TEST_CASE_ST(ut_setup, ut_teardown,
8768 test_snow3g_encryption_test_case_5),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_snow3g_encryption_test_case_1_oop),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_snow3g_decryption_test_case_1_oop),
8775 /** SNOW 3G decrypt only (UEA2) */
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_snow3g_decryption_test_case_1),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_snow3g_decryption_test_case_2),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_snow3g_decryption_test_case_3),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_snow3g_decryption_test_case_4),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_snow3g_decryption_test_case_5),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_snow3g_hash_generate_test_case_1),
8788 TEST_CASE_ST(ut_setup, ut_teardown,
8789 test_snow3g_hash_generate_test_case_2),
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_snow3g_hash_generate_test_case_3),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_snow3g_hash_verify_test_case_1),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_snow3g_hash_verify_test_case_2),
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_snow3g_hash_verify_test_case_3),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_snow3g_cipher_auth_test_case_1),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_snow3g_auth_cipher_test_case_1),
8803 /** ZUC encrypt only (EEA3) */
8804 TEST_CASE_ST(ut_setup, ut_teardown,
8805 test_zuc_encryption_test_case_1),
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_zuc_encryption_test_case_2),
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_zuc_encryption_test_case_3),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_zuc_encryption_test_case_4),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_zuc_encryption_test_case_5),
8815 /** ZUC authenticate (EIA3) */
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_zuc_hash_generate_test_case_6),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_zuc_hash_generate_test_case_7),
8820 TEST_CASE_ST(ut_setup, ut_teardown,
8821 test_zuc_hash_generate_test_case_8),
8823 /** ZUC alg-chain (EEA3/EIA3) */
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_zuc_cipher_auth_test_case_1),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_zuc_cipher_auth_test_case_2),
8829 /** HMAC_MD5 Authentication */
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_MD5_HMAC_generate_case_1),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_MD5_HMAC_verify_case_1),
8834 TEST_CASE_ST(ut_setup, ut_teardown,
8835 test_MD5_HMAC_generate_case_2),
8836 TEST_CASE_ST(ut_setup, ut_teardown,
8837 test_MD5_HMAC_verify_case_2),
8840 TEST_CASE_ST(ut_setup, ut_teardown,
8841 test_null_auth_only_operation),
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_null_cipher_only_operation),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_null_cipher_auth_operation),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_null_auth_cipher_operation),
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_kasumi_hash_generate_test_case_1),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_kasumi_hash_generate_test_case_2),
8854 TEST_CASE_ST(ut_setup, ut_teardown,
8855 test_kasumi_hash_generate_test_case_3),
8856 TEST_CASE_ST(ut_setup, ut_teardown,
8857 test_kasumi_hash_generate_test_case_4),
8858 TEST_CASE_ST(ut_setup, ut_teardown,
8859 test_kasumi_hash_generate_test_case_5),
8860 TEST_CASE_ST(ut_setup, ut_teardown,
8861 test_kasumi_hash_generate_test_case_6),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_kasumi_hash_verify_test_case_1),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_kasumi_hash_verify_test_case_2),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_kasumi_hash_verify_test_case_3),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_kasumi_hash_verify_test_case_4),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_kasumi_hash_verify_test_case_5),
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_kasumi_encryption_test_case_1),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_kasumi_encryption_test_case_3),
8878 TEST_CASE_ST(ut_setup, ut_teardown,
8879 test_kasumi_auth_cipher_test_case_1),
8880 TEST_CASE_ST(ut_setup, ut_teardown,
8881 test_kasumi_cipher_auth_test_case_1),
8883 /** Negative tests */
8884 TEST_CASE_ST(ut_setup, ut_teardown,
8885 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8886 TEST_CASE_ST(ut_setup, ut_teardown,
8887 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8888 TEST_CASE_ST(ut_setup, ut_teardown,
8889 authentication_verify_AES128_GMAC_fail_data_corrupt),
8890 TEST_CASE_ST(ut_setup, ut_teardown,
8891 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8892 TEST_CASE_ST(ut_setup, ut_teardown,
8893 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8897 TEST_CASES_END() /**< NULL terminate unit test array */
8901 static struct unit_test_suite cryptodev_virtio_testsuite = {
8902 .suite_name = "Crypto VIRTIO Unit Test Suite",
8903 .setup = testsuite_setup,
8904 .teardown = testsuite_teardown,
8905 .unit_test_cases = {
8906 TEST_CASE_ST(ut_setup, ut_teardown,
8907 test_AES_cipheronly_virtio_all),
8909 TEST_CASES_END() /**< NULL terminate unit test array */
8913 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8914 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8915 .setup = testsuite_setup,
8916 .teardown = testsuite_teardown,
8917 .unit_test_cases = {
8918 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8919 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8920 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8921 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8922 TEST_CASE_ST(ut_setup, ut_teardown,
8923 test_DES_cipheronly_mb_all),
8924 TEST_CASE_ST(ut_setup, ut_teardown,
8925 test_DES_docsis_mb_all),
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_AES_CCM_authenticated_encryption_test_case_128_1),
8928 TEST_CASE_ST(ut_setup, ut_teardown,
8929 test_AES_CCM_authenticated_decryption_test_case_128_1),
8930 TEST_CASE_ST(ut_setup, ut_teardown,
8931 test_AES_CCM_authenticated_encryption_test_case_128_2),
8932 TEST_CASE_ST(ut_setup, ut_teardown,
8933 test_AES_CCM_authenticated_decryption_test_case_128_2),
8934 TEST_CASE_ST(ut_setup, ut_teardown,
8935 test_AES_CCM_authenticated_encryption_test_case_128_3),
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_AES_CCM_authenticated_decryption_test_case_128_3),
8939 TEST_CASES_END() /**< NULL terminate unit test array */
8943 static struct unit_test_suite cryptodev_openssl_testsuite = {
8944 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8945 .setup = testsuite_setup,
8946 .teardown = testsuite_teardown,
8947 .unit_test_cases = {
8948 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 test_multi_session_random_usage),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_AES_chain_openssl_all),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 test_AES_cipheronly_openssl_all),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 test_3DES_chain_openssl_all),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_3DES_cipheronly_openssl_all),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_DES_cipheronly_openssl_all),
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 test_DES_docsis_openssl_all),
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 test_authonly_openssl_all),
8966 /** AES GCM Authenticated Encryption */
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_AES_GCM_authenticated_encryption_test_case_1),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 test_AES_GCM_authenticated_encryption_test_case_2),
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 test_AES_GCM_authenticated_encryption_test_case_3),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_AES_GCM_authenticated_encryption_test_case_4),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_AES_GCM_authenticated_encryption_test_case_5),
8977 TEST_CASE_ST(ut_setup, ut_teardown,
8978 test_AES_GCM_authenticated_encryption_test_case_6),
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_AES_GCM_authenticated_encryption_test_case_7),
8982 /** AES GCM Authenticated Decryption */
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_GCM_authenticated_decryption_test_case_1),
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_AES_GCM_authenticated_decryption_test_case_2),
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_AES_GCM_authenticated_decryption_test_case_3),
8989 TEST_CASE_ST(ut_setup, ut_teardown,
8990 test_AES_GCM_authenticated_decryption_test_case_4),
8991 TEST_CASE_ST(ut_setup, ut_teardown,
8992 test_AES_GCM_authenticated_decryption_test_case_5),
8993 TEST_CASE_ST(ut_setup, ut_teardown,
8994 test_AES_GCM_authenticated_decryption_test_case_6),
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 test_AES_GCM_authenticated_decryption_test_case_7),
8999 /** AES GCM Authenticated Encryption 192 bits key */
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_AES_GCM_auth_encryption_test_case_192_1),
9002 TEST_CASE_ST(ut_setup, ut_teardown,
9003 test_AES_GCM_auth_encryption_test_case_192_2),
9004 TEST_CASE_ST(ut_setup, ut_teardown,
9005 test_AES_GCM_auth_encryption_test_case_192_3),
9006 TEST_CASE_ST(ut_setup, ut_teardown,
9007 test_AES_GCM_auth_encryption_test_case_192_4),
9008 TEST_CASE_ST(ut_setup, ut_teardown,
9009 test_AES_GCM_auth_encryption_test_case_192_5),
9010 TEST_CASE_ST(ut_setup, ut_teardown,
9011 test_AES_GCM_auth_encryption_test_case_192_6),
9012 TEST_CASE_ST(ut_setup, ut_teardown,
9013 test_AES_GCM_auth_encryption_test_case_192_7),
9015 /** AES GCM Authenticated Decryption 192 bits key */
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_GCM_auth_decryption_test_case_192_1),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_GCM_auth_decryption_test_case_192_2),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_auth_decryption_test_case_192_3),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_auth_decryption_test_case_192_4),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_GCM_auth_decryption_test_case_192_5),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_auth_decryption_test_case_192_6),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_GCM_auth_decryption_test_case_192_7),
9031 /** AES GCM Authenticated Encryption 256 bits key */
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_GCM_auth_encryption_test_case_256_1),
9034 TEST_CASE_ST(ut_setup, ut_teardown,
9035 test_AES_GCM_auth_encryption_test_case_256_2),
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_auth_encryption_test_case_256_3),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_auth_encryption_test_case_256_4),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_AES_GCM_auth_encryption_test_case_256_5),
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_auth_encryption_test_case_256_6),
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_auth_encryption_test_case_256_7),
9047 /** AES GCM Authenticated Decryption 256 bits key */
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_auth_decryption_test_case_256_1),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GCM_auth_decryption_test_case_256_2),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_auth_decryption_test_case_256_3),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_auth_decryption_test_case_256_4),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GCM_auth_decryption_test_case_256_5),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GCM_auth_decryption_test_case_256_6),
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_GCM_auth_decryption_test_case_256_7),
9063 /** AES GMAC Authentication */
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GMAC_authentication_test_case_1),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GMAC_authentication_verify_test_case_1),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GMAC_authentication_test_case_2),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GMAC_authentication_verify_test_case_2),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GMAC_authentication_test_case_3),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_GMAC_authentication_verify_test_case_3),
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_AES_GMAC_authentication_test_case_4),
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GMAC_authentication_verify_test_case_4),
9081 /** AES CCM Authenticated Encryption 128 bits key */
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_CCM_authenticated_encryption_test_case_128_1),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_CCM_authenticated_encryption_test_case_128_2),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_CCM_authenticated_encryption_test_case_128_3),
9089 /** AES CCM Authenticated Decryption 128 bits key*/
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_AES_CCM_authenticated_decryption_test_case_128_1),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_AES_CCM_authenticated_decryption_test_case_128_2),
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_AES_CCM_authenticated_decryption_test_case_128_3),
9097 /** AES CCM Authenticated Encryption 192 bits key */
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_CCM_authenticated_encryption_test_case_192_1),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_CCM_authenticated_encryption_test_case_192_2),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_CCM_authenticated_encryption_test_case_192_3),
9105 /** AES CCM Authenticated Decryption 192 bits key*/
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_CCM_authenticated_decryption_test_case_192_1),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_AES_CCM_authenticated_decryption_test_case_192_2),
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_AES_CCM_authenticated_decryption_test_case_192_3),
9113 /** AES CCM Authenticated Encryption 256 bits key */
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_AES_CCM_authenticated_encryption_test_case_256_1),
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_AES_CCM_authenticated_encryption_test_case_256_2),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_AES_CCM_authenticated_encryption_test_case_256_3),
9121 /** AES CCM Authenticated Decryption 256 bits key*/
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_CCM_authenticated_decryption_test_case_256_1),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_AES_CCM_authenticated_decryption_test_case_256_2),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_AES_CCM_authenticated_decryption_test_case_256_3),
9129 /** Scatter-Gather */
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9133 /** Negative tests */
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 authentication_verify_AES128_GMAC_fail_data_corrupt),
9140 TEST_CASE_ST(ut_setup, ut_teardown,
9141 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9147 TEST_CASES_END() /**< NULL terminate unit test array */
9151 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9152 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9153 .setup = testsuite_setup,
9154 .teardown = testsuite_teardown,
9155 .unit_test_cases = {
9156 /** AES GCM Authenticated Encryption */
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_AES_GCM_authenticated_encryption_test_case_1),
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_AES_GCM_authenticated_encryption_test_case_2),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_AES_GCM_authenticated_encryption_test_case_3),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_AES_GCM_authenticated_encryption_test_case_4),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_AES_GCM_authenticated_encryption_test_case_5),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_AES_GCM_authenticated_encryption_test_case_6),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_AES_GCM_authenticated_encryption_test_case_7),
9172 /** AES GCM Authenticated Decryption */
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_AES_GCM_authenticated_decryption_test_case_1),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_AES_GCM_authenticated_decryption_test_case_2),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_AES_GCM_authenticated_decryption_test_case_3),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_AES_GCM_authenticated_decryption_test_case_4),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_AES_GCM_authenticated_decryption_test_case_5),
9183 TEST_CASE_ST(ut_setup, ut_teardown,
9184 test_AES_GCM_authenticated_decryption_test_case_6),
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_AES_GCM_authenticated_decryption_test_case_7),
9188 /** AES GCM Authenticated Encryption 192 bits key */
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_AES_GCM_auth_encryption_test_case_192_1),
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_AES_GCM_auth_encryption_test_case_192_2),
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_AES_GCM_auth_encryption_test_case_192_3),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_AES_GCM_auth_encryption_test_case_192_4),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_AES_GCM_auth_encryption_test_case_192_5),
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_AES_GCM_auth_encryption_test_case_192_6),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_AES_GCM_auth_encryption_test_case_192_7),
9204 /** AES GCM Authenticated Decryption 192 bits key */
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_AES_GCM_auth_decryption_test_case_192_1),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_AES_GCM_auth_decryption_test_case_192_2),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_AES_GCM_auth_decryption_test_case_192_3),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_AES_GCM_auth_decryption_test_case_192_4),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_AES_GCM_auth_decryption_test_case_192_5),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_AES_GCM_auth_decryption_test_case_192_6),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_AES_GCM_auth_decryption_test_case_192_7),
9220 /** AES GCM Authenticated Encryption 256 bits key */
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_AES_GCM_auth_encryption_test_case_256_1),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_AES_GCM_auth_encryption_test_case_256_2),
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_AES_GCM_auth_encryption_test_case_256_3),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_AES_GCM_auth_encryption_test_case_256_4),
9229 TEST_CASE_ST(ut_setup, ut_teardown,
9230 test_AES_GCM_auth_encryption_test_case_256_5),
9231 TEST_CASE_ST(ut_setup, ut_teardown,
9232 test_AES_GCM_auth_encryption_test_case_256_6),
9233 TEST_CASE_ST(ut_setup, ut_teardown,
9234 test_AES_GCM_auth_encryption_test_case_256_7),
9236 /** AES GCM Authenticated Decryption 256 bits key */
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_AES_GCM_auth_decryption_test_case_256_1),
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_AES_GCM_auth_decryption_test_case_256_2),
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_AES_GCM_auth_decryption_test_case_256_3),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_AES_GCM_auth_decryption_test_case_256_4),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 test_AES_GCM_auth_decryption_test_case_256_5),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_AES_GCM_auth_decryption_test_case_256_6),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_AES_GCM_auth_decryption_test_case_256_7),
9252 /** AES GCM Authenticated Encryption big aad size */
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_AES_GCM_auth_encryption_test_case_aad_1),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_AES_GCM_auth_encryption_test_case_aad_2),
9258 /** AES GCM Authenticated Decryption big aad size */
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_AES_GCM_auth_decryption_test_case_aad_1),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_AES_GCM_auth_decryption_test_case_aad_2),
9264 /** AES GMAC Authentication */
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_AES_GMAC_authentication_test_case_1),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_AES_GMAC_authentication_verify_test_case_1),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_AES_GMAC_authentication_test_case_3),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_AES_GMAC_authentication_verify_test_case_3),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_AES_GMAC_authentication_test_case_4),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_GMAC_authentication_verify_test_case_4),
9278 /** Negative tests */
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 authentication_verify_AES128_GMAC_fail_data_corrupt),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9284 /** Out of place tests */
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9290 /** Session-less tests */
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9296 /** Scatter-Gather */
9297 TEST_CASE_ST(ut_setup, ut_teardown,
9298 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9300 TEST_CASES_END() /**< NULL terminate unit test array */
9304 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9305 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9306 .setup = testsuite_setup,
9307 .teardown = testsuite_teardown,
9308 .unit_test_cases = {
9309 /** KASUMI encrypt only (UEA1) */
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_kasumi_encryption_test_case_1),
9312 TEST_CASE_ST(ut_setup, ut_teardown,
9313 test_kasumi_encryption_test_case_1_sgl),
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_kasumi_encryption_test_case_2),
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_kasumi_encryption_test_case_3),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_kasumi_encryption_test_case_4),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_kasumi_encryption_test_case_5),
9322 /** KASUMI decrypt only (UEA1) */
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_kasumi_decryption_test_case_1),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_kasumi_decryption_test_case_2),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_kasumi_decryption_test_case_3),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_kasumi_decryption_test_case_4),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_kasumi_decryption_test_case_5),
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_kasumi_encryption_test_case_1_oop),
9336 TEST_CASE_ST(ut_setup, ut_teardown,
9337 test_kasumi_encryption_test_case_1_oop_sgl),
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_kasumi_decryption_test_case_1_oop),
9343 /** KASUMI hash only (UIA1) */
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_kasumi_hash_generate_test_case_1),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_kasumi_hash_generate_test_case_2),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_kasumi_hash_generate_test_case_3),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_kasumi_hash_generate_test_case_4),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_kasumi_hash_generate_test_case_5),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_kasumi_hash_generate_test_case_6),
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 test_kasumi_hash_verify_test_case_1),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 test_kasumi_hash_verify_test_case_2),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 test_kasumi_hash_verify_test_case_3),
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_kasumi_hash_verify_test_case_4),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_kasumi_hash_verify_test_case_5),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_kasumi_auth_cipher_test_case_1),
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_kasumi_cipher_auth_test_case_1),
9370 TEST_CASES_END() /**< NULL terminate unit test array */
9373 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9374 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9375 .setup = testsuite_setup,
9376 .teardown = testsuite_teardown,
9377 .unit_test_cases = {
9378 /** SNOW 3G encrypt only (UEA2) */
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_snow3g_encryption_test_case_1),
9381 TEST_CASE_ST(ut_setup, ut_teardown,
9382 test_snow3g_encryption_test_case_2),
9383 TEST_CASE_ST(ut_setup, ut_teardown,
9384 test_snow3g_encryption_test_case_3),
9385 TEST_CASE_ST(ut_setup, ut_teardown,
9386 test_snow3g_encryption_test_case_4),
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_snow3g_encryption_test_case_5),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_snow3g_encryption_test_case_1_oop),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_snow3g_encryption_test_case_1_oop_sgl),
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_snow3g_decryption_test_case_1_oop),
9397 TEST_CASE_ST(ut_setup, ut_teardown,
9398 test_snow3g_encryption_test_case_1_offset_oop),
9400 /** SNOW 3G decrypt only (UEA2) */
9401 TEST_CASE_ST(ut_setup, ut_teardown,
9402 test_snow3g_decryption_test_case_1),
9403 TEST_CASE_ST(ut_setup, ut_teardown,
9404 test_snow3g_decryption_test_case_2),
9405 TEST_CASE_ST(ut_setup, ut_teardown,
9406 test_snow3g_decryption_test_case_3),
9407 TEST_CASE_ST(ut_setup, ut_teardown,
9408 test_snow3g_decryption_test_case_4),
9409 TEST_CASE_ST(ut_setup, ut_teardown,
9410 test_snow3g_decryption_test_case_5),
9411 TEST_CASE_ST(ut_setup, ut_teardown,
9412 test_snow3g_hash_generate_test_case_1),
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 test_snow3g_hash_generate_test_case_2),
9415 TEST_CASE_ST(ut_setup, ut_teardown,
9416 test_snow3g_hash_generate_test_case_3),
9417 /* Tests with buffers which length is not byte-aligned */
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_snow3g_hash_generate_test_case_4),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_snow3g_hash_generate_test_case_5),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_snow3g_hash_generate_test_case_6),
9424 TEST_CASE_ST(ut_setup, ut_teardown,
9425 test_snow3g_hash_verify_test_case_1),
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_snow3g_hash_verify_test_case_2),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_snow3g_hash_verify_test_case_3),
9430 /* Tests with buffers which length is not byte-aligned */
9431 TEST_CASE_ST(ut_setup, ut_teardown,
9432 test_snow3g_hash_verify_test_case_4),
9433 TEST_CASE_ST(ut_setup, ut_teardown,
9434 test_snow3g_hash_verify_test_case_5),
9435 TEST_CASE_ST(ut_setup, ut_teardown,
9436 test_snow3g_hash_verify_test_case_6),
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_snow3g_cipher_auth_test_case_1),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_snow3g_auth_cipher_test_case_1),
9442 TEST_CASES_END() /**< NULL terminate unit test array */
9446 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9447 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9448 .setup = testsuite_setup,
9449 .teardown = testsuite_teardown,
9450 .unit_test_cases = {
9451 /** ZUC encrypt only (EEA3) */
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_zuc_encryption_test_case_1),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_zuc_encryption_test_case_2),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_zuc_encryption_test_case_3),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_zuc_encryption_test_case_4),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_zuc_encryption_test_case_5),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_zuc_hash_generate_test_case_1),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_zuc_hash_generate_test_case_2),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_zuc_hash_generate_test_case_3),
9468 TEST_CASE_ST(ut_setup, ut_teardown,
9469 test_zuc_hash_generate_test_case_4),
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_zuc_hash_generate_test_case_5),
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_zuc_encryption_test_case_6_sgl),
9474 TEST_CASES_END() /**< NULL terminate unit test array */
9478 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9479 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9480 .setup = testsuite_setup,
9481 .teardown = testsuite_teardown,
9482 .unit_test_cases = {
9483 TEST_CASE_ST(ut_setup, ut_teardown,
9484 test_device_configure_invalid_dev_id),
9485 TEST_CASE_ST(ut_setup, ut_teardown,
9486 test_multi_session),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_chain_dpaa_sec_all),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_3DES_chain_dpaa_sec_all),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_AES_cipheronly_dpaa_sec_all),
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_3DES_cipheronly_dpaa_sec_all),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_authonly_dpaa_sec_all),
9499 /** AES GCM Authenticated Encryption */
9500 TEST_CASE_ST(ut_setup, ut_teardown,
9501 test_AES_GCM_authenticated_encryption_test_case_1),
9502 TEST_CASE_ST(ut_setup, ut_teardown,
9503 test_AES_GCM_authenticated_encryption_test_case_2),
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_AES_GCM_authenticated_encryption_test_case_3),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_AES_GCM_authenticated_encryption_test_case_4),
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_AES_GCM_authenticated_encryption_test_case_5),
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_AES_GCM_authenticated_encryption_test_case_6),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_AES_GCM_authenticated_encryption_test_case_7),
9515 /** AES GCM Authenticated Decryption */
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_AES_GCM_authenticated_decryption_test_case_1),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_AES_GCM_authenticated_decryption_test_case_2),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_AES_GCM_authenticated_decryption_test_case_3),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_AES_GCM_authenticated_decryption_test_case_4),
9524 TEST_CASE_ST(ut_setup, ut_teardown,
9525 test_AES_GCM_authenticated_decryption_test_case_5),
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_AES_GCM_authenticated_decryption_test_case_6),
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_AES_GCM_authenticated_decryption_test_case_7),
9531 /** AES GCM Authenticated Encryption 256 bits key */
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 test_AES_GCM_auth_encryption_test_case_256_1),
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 test_AES_GCM_auth_encryption_test_case_256_2),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_AES_GCM_auth_encryption_test_case_256_3),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 test_AES_GCM_auth_encryption_test_case_256_4),
9540 TEST_CASE_ST(ut_setup, ut_teardown,
9541 test_AES_GCM_auth_encryption_test_case_256_5),
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 test_AES_GCM_auth_encryption_test_case_256_6),
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 test_AES_GCM_auth_encryption_test_case_256_7),
9547 /** AES GCM Authenticated Decryption 256 bits key */
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 test_AES_GCM_auth_decryption_test_case_256_1),
9550 TEST_CASE_ST(ut_setup, ut_teardown,
9551 test_AES_GCM_auth_decryption_test_case_256_2),
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_AES_GCM_auth_decryption_test_case_256_3),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_AES_GCM_auth_decryption_test_case_256_4),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_AES_GCM_auth_decryption_test_case_256_5),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_AES_GCM_auth_decryption_test_case_256_6),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_GCM_auth_decryption_test_case_256_7),
9563 /** Out of place tests */
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9569 /** Scatter-Gather */
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9572 TEST_CASE_ST(ut_setup, ut_teardown,
9573 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9574 TEST_CASE_ST(ut_setup, ut_teardown,
9575 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9576 TEST_CASE_ST(ut_setup, ut_teardown,
9577 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9579 TEST_CASES_END() /**< NULL terminate unit test array */
9583 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9584 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9585 .setup = testsuite_setup,
9586 .teardown = testsuite_teardown,
9587 .unit_test_cases = {
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_device_configure_invalid_dev_id),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_multi_session),
9593 TEST_CASE_ST(ut_setup, ut_teardown,
9594 test_AES_chain_dpaa2_sec_all),
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_3DES_chain_dpaa2_sec_all),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_AES_cipheronly_dpaa2_sec_all),
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_3DES_cipheronly_dpaa2_sec_all),
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_authonly_dpaa2_sec_all),
9604 /** AES GCM Authenticated Encryption */
9605 TEST_CASE_ST(ut_setup, ut_teardown,
9606 test_AES_GCM_authenticated_encryption_test_case_1),
9607 TEST_CASE_ST(ut_setup, ut_teardown,
9608 test_AES_GCM_authenticated_encryption_test_case_2),
9609 TEST_CASE_ST(ut_setup, ut_teardown,
9610 test_AES_GCM_authenticated_encryption_test_case_3),
9611 TEST_CASE_ST(ut_setup, ut_teardown,
9612 test_AES_GCM_authenticated_encryption_test_case_4),
9613 TEST_CASE_ST(ut_setup, ut_teardown,
9614 test_AES_GCM_authenticated_encryption_test_case_5),
9615 TEST_CASE_ST(ut_setup, ut_teardown,
9616 test_AES_GCM_authenticated_encryption_test_case_6),
9617 TEST_CASE_ST(ut_setup, ut_teardown,
9618 test_AES_GCM_authenticated_encryption_test_case_7),
9620 /** AES GCM Authenticated Decryption */
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 test_AES_GCM_authenticated_decryption_test_case_1),
9623 TEST_CASE_ST(ut_setup, ut_teardown,
9624 test_AES_GCM_authenticated_decryption_test_case_2),
9625 TEST_CASE_ST(ut_setup, ut_teardown,
9626 test_AES_GCM_authenticated_decryption_test_case_3),
9627 TEST_CASE_ST(ut_setup, ut_teardown,
9628 test_AES_GCM_authenticated_decryption_test_case_4),
9629 TEST_CASE_ST(ut_setup, ut_teardown,
9630 test_AES_GCM_authenticated_decryption_test_case_5),
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 test_AES_GCM_authenticated_decryption_test_case_6),
9633 TEST_CASE_ST(ut_setup, ut_teardown,
9634 test_AES_GCM_authenticated_decryption_test_case_7),
9636 /** AES GCM Authenticated Encryption 192 bits key */
9637 TEST_CASE_ST(ut_setup, ut_teardown,
9638 test_AES_GCM_auth_encryption_test_case_192_1),
9639 TEST_CASE_ST(ut_setup, ut_teardown,
9640 test_AES_GCM_auth_encryption_test_case_192_2),
9641 TEST_CASE_ST(ut_setup, ut_teardown,
9642 test_AES_GCM_auth_encryption_test_case_192_3),
9643 TEST_CASE_ST(ut_setup, ut_teardown,
9644 test_AES_GCM_auth_encryption_test_case_192_4),
9645 TEST_CASE_ST(ut_setup, ut_teardown,
9646 test_AES_GCM_auth_encryption_test_case_192_5),
9647 TEST_CASE_ST(ut_setup, ut_teardown,
9648 test_AES_GCM_auth_encryption_test_case_192_6),
9649 TEST_CASE_ST(ut_setup, ut_teardown,
9650 test_AES_GCM_auth_encryption_test_case_192_7),
9652 /** AES GCM Authenticated Decryption 192 bits key */
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_auth_decryption_test_case_192_1),
9655 TEST_CASE_ST(ut_setup, ut_teardown,
9656 test_AES_GCM_auth_decryption_test_case_192_2),
9657 TEST_CASE_ST(ut_setup, ut_teardown,
9658 test_AES_GCM_auth_decryption_test_case_192_3),
9659 TEST_CASE_ST(ut_setup, ut_teardown,
9660 test_AES_GCM_auth_decryption_test_case_192_4),
9661 TEST_CASE_ST(ut_setup, ut_teardown,
9662 test_AES_GCM_auth_decryption_test_case_192_5),
9663 TEST_CASE_ST(ut_setup, ut_teardown,
9664 test_AES_GCM_auth_decryption_test_case_192_6),
9665 TEST_CASE_ST(ut_setup, ut_teardown,
9666 test_AES_GCM_auth_decryption_test_case_192_7),
9668 /** AES GCM Authenticated Encryption 256 bits key */
9669 TEST_CASE_ST(ut_setup, ut_teardown,
9670 test_AES_GCM_auth_encryption_test_case_256_1),
9671 TEST_CASE_ST(ut_setup, ut_teardown,
9672 test_AES_GCM_auth_encryption_test_case_256_2),
9673 TEST_CASE_ST(ut_setup, ut_teardown,
9674 test_AES_GCM_auth_encryption_test_case_256_3),
9675 TEST_CASE_ST(ut_setup, ut_teardown,
9676 test_AES_GCM_auth_encryption_test_case_256_4),
9677 TEST_CASE_ST(ut_setup, ut_teardown,
9678 test_AES_GCM_auth_encryption_test_case_256_5),
9679 TEST_CASE_ST(ut_setup, ut_teardown,
9680 test_AES_GCM_auth_encryption_test_case_256_6),
9681 TEST_CASE_ST(ut_setup, ut_teardown,
9682 test_AES_GCM_auth_encryption_test_case_256_7),
9684 /** AES GCM Authenticated Decryption 256 bits key */
9685 TEST_CASE_ST(ut_setup, ut_teardown,
9686 test_AES_GCM_auth_decryption_test_case_256_1),
9687 TEST_CASE_ST(ut_setup, ut_teardown,
9688 test_AES_GCM_auth_decryption_test_case_256_2),
9689 TEST_CASE_ST(ut_setup, ut_teardown,
9690 test_AES_GCM_auth_decryption_test_case_256_3),
9691 TEST_CASE_ST(ut_setup, ut_teardown,
9692 test_AES_GCM_auth_decryption_test_case_256_4),
9693 TEST_CASE_ST(ut_setup, ut_teardown,
9694 test_AES_GCM_auth_decryption_test_case_256_5),
9695 TEST_CASE_ST(ut_setup, ut_teardown,
9696 test_AES_GCM_auth_decryption_test_case_256_6),
9697 TEST_CASE_ST(ut_setup, ut_teardown,
9698 test_AES_GCM_auth_decryption_test_case_256_7),
9700 /** Out of place tests */
9701 TEST_CASE_ST(ut_setup, ut_teardown,
9702 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9706 /** Scatter-Gather */
9707 TEST_CASE_ST(ut_setup, ut_teardown,
9708 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9713 TEST_CASE_ST(ut_setup, ut_teardown,
9714 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9716 TEST_CASES_END() /**< NULL terminate unit test array */
9720 static struct unit_test_suite cryptodev_null_testsuite = {
9721 .suite_name = "Crypto Device NULL Unit Test Suite",
9722 .setup = testsuite_setup,
9723 .teardown = testsuite_teardown,
9724 .unit_test_cases = {
9725 TEST_CASE_ST(ut_setup, ut_teardown,
9726 test_null_auth_only_operation),
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_null_cipher_only_operation),
9729 TEST_CASE_ST(ut_setup, ut_teardown,
9730 test_null_cipher_auth_operation),
9731 TEST_CASE_ST(ut_setup, ut_teardown,
9732 test_null_auth_cipher_operation),
9733 TEST_CASE_ST(ut_setup, ut_teardown,
9734 test_null_invalid_operation),
9735 TEST_CASE_ST(ut_setup, ut_teardown,
9736 test_null_burst_operation),
9738 TEST_CASES_END() /**< NULL terminate unit test array */
9742 static struct unit_test_suite cryptodev_armv8_testsuite = {
9743 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9744 .setup = testsuite_setup,
9745 .teardown = testsuite_teardown,
9746 .unit_test_cases = {
9747 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9749 /** Negative tests */
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9755 TEST_CASES_END() /**< NULL terminate unit test array */
9759 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9760 .suite_name = "Crypto Device Marvell Component Test Suite",
9761 .setup = testsuite_setup,
9762 .teardown = testsuite_teardown,
9763 .unit_test_cases = {
9764 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_multi_session_random_usage),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_AES_chain_mrvl_all),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_AES_cipheronly_mrvl_all),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_authonly_mrvl_all),
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_3DES_chain_mrvl_all),
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_3DES_cipheronly_mrvl_all),
9778 /** Negative tests */
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9788 TEST_CASES_END() /**< NULL terminate unit test array */
9792 static struct unit_test_suite cryptodev_ccp_testsuite = {
9793 .suite_name = "Crypto Device CCP Unit Test Suite",
9794 .setup = testsuite_setup,
9795 .teardown = testsuite_teardown,
9796 .unit_test_cases = {
9797 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9798 TEST_CASE_ST(ut_setup, ut_teardown,
9799 test_multi_session_random_usage),
9800 TEST_CASE_ST(ut_setup, ut_teardown,
9801 test_AES_chain_ccp_all),
9802 TEST_CASE_ST(ut_setup, ut_teardown,
9803 test_AES_cipheronly_ccp_all),
9804 TEST_CASE_ST(ut_setup, ut_teardown,
9805 test_3DES_chain_ccp_all),
9806 TEST_CASE_ST(ut_setup, ut_teardown,
9807 test_3DES_cipheronly_ccp_all),
9808 TEST_CASE_ST(ut_setup, ut_teardown,
9809 test_authonly_ccp_all),
9811 /** Negative tests */
9812 TEST_CASE_ST(ut_setup, ut_teardown,
9813 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9814 TEST_CASE_ST(ut_setup, ut_teardown,
9815 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9816 TEST_CASE_ST(ut_setup, ut_teardown,
9817 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9818 TEST_CASE_ST(ut_setup, ut_teardown,
9819 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9821 TEST_CASES_END() /**< NULL terminate unit test array */
9826 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9828 gbl_driver_id = rte_cryptodev_driver_id_get(
9829 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9831 if (gbl_driver_id == -1) {
9832 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9833 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9834 "in config file to run this testsuite.\n");
9835 return TEST_SKIPPED;
9838 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9842 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9844 gbl_driver_id = rte_cryptodev_driver_id_get(
9845 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9847 if (gbl_driver_id == -1) {
9848 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9849 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9850 "in config file to run this testsuite.\n");
9854 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9858 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9860 gbl_driver_id = rte_cryptodev_driver_id_get(
9861 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9863 if (gbl_driver_id == -1) {
9864 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9865 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9866 "in config file to run this testsuite.\n");
9867 return TEST_SKIPPED;
9870 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9874 test_cryptodev_openssl(void)
9876 gbl_driver_id = rte_cryptodev_driver_id_get(
9877 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9879 if (gbl_driver_id == -1) {
9880 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9881 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9882 "in config file to run this testsuite.\n");
9883 return TEST_SKIPPED;
9886 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9890 test_cryptodev_aesni_gcm(void)
9892 gbl_driver_id = rte_cryptodev_driver_id_get(
9893 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9895 if (gbl_driver_id == -1) {
9896 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9897 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9898 "in config file to run this testsuite.\n");
9899 return TEST_SKIPPED;
9902 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9906 test_cryptodev_null(void)
9908 gbl_driver_id = rte_cryptodev_driver_id_get(
9909 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9911 if (gbl_driver_id == -1) {
9912 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9913 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9914 "in config file to run this testsuite.\n");
9915 return TEST_SKIPPED;
9918 return unit_test_suite_runner(&cryptodev_null_testsuite);
9922 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9924 gbl_driver_id = rte_cryptodev_driver_id_get(
9925 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9927 if (gbl_driver_id == -1) {
9928 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9929 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9930 "in config file to run this testsuite.\n");
9931 return TEST_SKIPPED;
9934 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9938 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9940 gbl_driver_id = rte_cryptodev_driver_id_get(
9941 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9943 if (gbl_driver_id == -1) {
9944 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9945 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9946 "in config file to run this testsuite.\n");
9947 return TEST_SKIPPED;
9950 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9954 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9956 gbl_driver_id = rte_cryptodev_driver_id_get(
9957 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9959 if (gbl_driver_id == -1) {
9960 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9961 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9962 "in config file to run this testsuite.\n");
9963 return TEST_SKIPPED;
9966 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9970 test_cryptodev_armv8(void)
9972 gbl_driver_id = rte_cryptodev_driver_id_get(
9973 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9975 if (gbl_driver_id == -1) {
9976 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9977 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9978 "in config file to run this testsuite.\n");
9979 return TEST_SKIPPED;
9982 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9986 test_cryptodev_mrvl(void)
9988 gbl_driver_id = rte_cryptodev_driver_id_get(
9989 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9991 if (gbl_driver_id == -1) {
9992 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9993 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9994 "in config file to run this testsuite.\n");
9995 return TEST_SKIPPED;
9998 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10001 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10004 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10006 gbl_driver_id = rte_cryptodev_driver_id_get(
10007 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10009 if (gbl_driver_id == -1) {
10010 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10011 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10012 "in config file to run this testsuite.\n");
10013 return TEST_SKIPPED;
10016 if (rte_cryptodev_driver_id_get(
10017 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10018 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10019 " enabled in config file to run this testsuite.\n");
10020 return TEST_SKIPPED;
10022 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10025 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10030 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10032 gbl_driver_id = rte_cryptodev_driver_id_get(
10033 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10035 if (gbl_driver_id == -1) {
10036 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10037 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10038 "in config file to run this testsuite.\n");
10039 return TEST_SKIPPED;
10042 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10046 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10048 gbl_driver_id = rte_cryptodev_driver_id_get(
10049 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10051 if (gbl_driver_id == -1) {
10052 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10053 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10054 "in config file to run this testsuite.\n");
10055 return TEST_SKIPPED;
10058 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10062 test_cryptodev_ccp(void)
10064 gbl_driver_id = rte_cryptodev_driver_id_get(
10065 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10067 if (gbl_driver_id == -1) {
10068 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10069 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10070 "in config file to run this testsuite.\n");
10071 return TEST_FAILED;
10074 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10077 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10078 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10079 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10080 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10081 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10082 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10083 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10084 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10085 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10086 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
10087 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10088 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10089 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10090 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);