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 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
342 if (gbl_driver_id == rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
345 nb_devs = rte_cryptodev_device_count_by_driver(
346 rte_cryptodev_driver_id_get(
347 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
350 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
353 TEST_ASSERT(ret == 0,
354 "Failed to create instance %u of"
356 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
359 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
361 nb_devs = rte_cryptodev_count();
363 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
367 /* Create list of valid crypto devs */
368 for (i = 0; i < nb_devs; i++) {
369 rte_cryptodev_info_get(i, &info);
370 if (info.driver_id == gbl_driver_id)
371 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
374 if (ts_params->valid_dev_count < 1)
377 /* Set up all the qps on the first of the valid devices found */
379 dev_id = ts_params->valid_devs[0];
381 rte_cryptodev_info_get(dev_id, &info);
383 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
384 ts_params->conf.socket_id = SOCKET_ID_ANY;
386 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
389 * Create mempool with maximum number of sessions * 2,
390 * to include the session headers
392 ts_params->session_mpool = rte_mempool_create(
394 info.sym.max_nb_sessions * 2,
396 0, 0, NULL, NULL, NULL,
400 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
401 "session mempool allocation failed");
403 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
405 "Failed to configure cryptodev %u with %u qps",
406 dev_id, ts_params->conf.nb_queue_pairs);
408 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
410 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
411 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
412 dev_id, qp_id, &ts_params->qp_conf,
413 rte_cryptodev_socket_id(dev_id),
414 ts_params->session_mpool),
415 "Failed to setup queue pair %u on cryptodev %u",
423 testsuite_teardown(void)
425 struct crypto_testsuite_params *ts_params = &testsuite_params;
427 if (ts_params->mbuf_pool != NULL) {
428 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
429 rte_mempool_avail_count(ts_params->mbuf_pool));
432 if (ts_params->op_mpool != NULL) {
433 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
434 rte_mempool_avail_count(ts_params->op_mpool));
437 /* Free session mempools */
438 if (ts_params->session_mpool != NULL) {
439 rte_mempool_free(ts_params->session_mpool);
440 ts_params->session_mpool = NULL;
447 struct crypto_testsuite_params *ts_params = &testsuite_params;
448 struct crypto_unittest_params *ut_params = &unittest_params;
452 /* Clear unit test parameters before running test */
453 memset(ut_params, 0, sizeof(*ut_params));
455 /* Reconfigure device to default parameters */
456 ts_params->conf.socket_id = SOCKET_ID_ANY;
458 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
460 "Failed to configure cryptodev %u",
461 ts_params->valid_devs[0]);
463 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
464 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
465 ts_params->valid_devs[0], qp_id,
467 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
468 ts_params->session_mpool),
469 "Failed to setup queue pair %u on cryptodev %u",
470 qp_id, ts_params->valid_devs[0]);
474 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
476 /* Start the device */
477 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
478 "Failed to start cryptodev %u",
479 ts_params->valid_devs[0]);
487 struct crypto_testsuite_params *ts_params = &testsuite_params;
488 struct crypto_unittest_params *ut_params = &unittest_params;
489 struct rte_cryptodev_stats stats;
491 /* free crypto session structure */
492 if (ut_params->sess) {
493 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
495 rte_cryptodev_sym_session_free(ut_params->sess);
496 ut_params->sess = NULL;
499 /* free crypto operation structure */
501 rte_crypto_op_free(ut_params->op);
504 * free mbuf - both obuf and ibuf are usually the same,
505 * so check if they point at the same address is necessary,
506 * to avoid freeing the mbuf twice.
508 if (ut_params->obuf) {
509 rte_pktmbuf_free(ut_params->obuf);
510 if (ut_params->ibuf == ut_params->obuf)
514 if (ut_params->ibuf) {
515 rte_pktmbuf_free(ut_params->ibuf);
519 if (ts_params->mbuf_pool != NULL)
520 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
521 rte_mempool_avail_count(ts_params->mbuf_pool));
523 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
525 /* Stop the device */
526 rte_cryptodev_stop(ts_params->valid_devs[0]);
530 test_device_configure_invalid_dev_id(void)
532 struct crypto_testsuite_params *ts_params = &testsuite_params;
533 uint16_t dev_id, num_devs = 0;
535 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
536 "Need at least %d devices for test", 1);
538 /* valid dev_id values */
539 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
541 /* Stop the device in case it's started so it can be configured */
542 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
544 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
545 "Failed test for rte_cryptodev_configure: "
546 "invalid dev_num %u", dev_id);
548 /* invalid dev_id values */
551 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
552 "Failed test for rte_cryptodev_configure: "
553 "invalid dev_num %u", dev_id);
557 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
558 "Failed test for rte_cryptodev_configure:"
559 "invalid dev_num %u", dev_id);
565 test_device_configure_invalid_queue_pair_ids(void)
567 struct crypto_testsuite_params *ts_params = &testsuite_params;
568 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
570 /* Stop the device in case it's started so it can be configured */
571 rte_cryptodev_stop(ts_params->valid_devs[0]);
573 /* valid - one queue pairs */
574 ts_params->conf.nb_queue_pairs = 1;
576 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
578 "Failed to configure cryptodev: dev_id %u, qp_id %u",
579 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
582 /* valid - max value queue pairs */
583 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
585 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
587 "Failed to configure cryptodev: dev_id %u, qp_id %u",
588 ts_params->valid_devs[0],
589 ts_params->conf.nb_queue_pairs);
592 /* invalid - zero queue pairs */
593 ts_params->conf.nb_queue_pairs = 0;
595 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
597 "Failed test for rte_cryptodev_configure, dev_id %u,"
599 ts_params->valid_devs[0],
600 ts_params->conf.nb_queue_pairs);
603 /* invalid - max value supported by field queue pairs */
604 ts_params->conf.nb_queue_pairs = UINT16_MAX;
606 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
608 "Failed test for rte_cryptodev_configure, dev_id %u,"
610 ts_params->valid_devs[0],
611 ts_params->conf.nb_queue_pairs);
614 /* invalid - max value + 1 queue pairs */
615 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
617 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
619 "Failed test for rte_cryptodev_configure, dev_id %u,"
621 ts_params->valid_devs[0],
622 ts_params->conf.nb_queue_pairs);
624 /* revert to original testsuite value */
625 ts_params->conf.nb_queue_pairs = orig_nb_qps;
631 test_queue_pair_descriptor_setup(void)
633 struct crypto_testsuite_params *ts_params = &testsuite_params;
634 struct rte_cryptodev_info dev_info;
635 struct rte_cryptodev_qp_conf qp_conf = {
636 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
641 /* Stop the device in case it's started so it can be configured */
642 rte_cryptodev_stop(ts_params->valid_devs[0]);
645 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
647 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
649 "Failed to configure cryptodev %u",
650 ts_params->valid_devs[0]);
653 * Test various ring sizes on this device. memzones can't be
654 * freed so are re-used if ring is released and re-created.
656 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
658 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
659 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
660 ts_params->valid_devs[0], qp_id, &qp_conf,
661 rte_cryptodev_socket_id(
662 ts_params->valid_devs[0]),
663 ts_params->session_mpool),
665 "rte_cryptodev_queue_pair_setup: num_inflights "
666 "%u on qp %u on cryptodev %u",
667 qp_conf.nb_descriptors, qp_id,
668 ts_params->valid_devs[0]);
671 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
673 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
674 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
675 ts_params->valid_devs[0], qp_id, &qp_conf,
676 rte_cryptodev_socket_id(
677 ts_params->valid_devs[0]),
678 ts_params->session_mpool),
680 " rte_cryptodev_queue_pair_setup: num_inflights"
681 " %u on qp %u on cryptodev %u",
682 qp_conf.nb_descriptors, qp_id,
683 ts_params->valid_devs[0]);
686 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
688 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
689 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
690 ts_params->valid_devs[0], qp_id, &qp_conf,
691 rte_cryptodev_socket_id(
692 ts_params->valid_devs[0]),
693 ts_params->session_mpool),
695 "rte_cryptodev_queue_pair_setup: num_inflights"
696 " %u on qp %u on cryptodev %u",
697 qp_conf.nb_descriptors, qp_id,
698 ts_params->valid_devs[0]);
701 /* invalid number of descriptors - max supported + 2 */
702 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
704 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
705 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
706 ts_params->valid_devs[0], qp_id, &qp_conf,
707 rte_cryptodev_socket_id(
708 ts_params->valid_devs[0]),
709 ts_params->session_mpool),
710 "Unexpectedly passed test for "
711 "rte_cryptodev_queue_pair_setup:"
712 "num_inflights %u on qp %u on cryptodev %u",
713 qp_conf.nb_descriptors, qp_id,
714 ts_params->valid_devs[0]);
717 /* invalid number of descriptors - max value of parameter */
718 qp_conf.nb_descriptors = UINT32_MAX-1;
720 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
721 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
722 ts_params->valid_devs[0], qp_id, &qp_conf,
723 rte_cryptodev_socket_id(
724 ts_params->valid_devs[0]),
725 ts_params->session_mpool),
726 "Unexpectedly passed test for "
727 "rte_cryptodev_queue_pair_setup:"
728 "num_inflights %u on qp %u on cryptodev %u",
729 qp_conf.nb_descriptors, qp_id,
730 ts_params->valid_devs[0]);
733 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
735 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
736 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
737 ts_params->valid_devs[0], qp_id, &qp_conf,
738 rte_cryptodev_socket_id(
739 ts_params->valid_devs[0]),
740 ts_params->session_mpool),
742 " rte_cryptodev_queue_pair_setup:"
743 "num_inflights %u on qp %u on cryptodev %u",
744 qp_conf.nb_descriptors, qp_id,
745 ts_params->valid_devs[0]);
748 /* invalid number of descriptors - max supported + 1 */
749 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
751 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
752 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
753 ts_params->valid_devs[0], qp_id, &qp_conf,
754 rte_cryptodev_socket_id(
755 ts_params->valid_devs[0]),
756 ts_params->session_mpool),
757 "Unexpectedly passed test for "
758 "rte_cryptodev_queue_pair_setup:"
759 "num_inflights %u on qp %u on cryptodev %u",
760 qp_conf.nb_descriptors, qp_id,
761 ts_params->valid_devs[0]);
764 /* test invalid queue pair id */
765 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
767 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
769 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
770 ts_params->valid_devs[0],
772 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
773 ts_params->session_mpool),
774 "Failed test for rte_cryptodev_queue_pair_setup:"
775 "invalid qp %u on cryptodev %u",
776 qp_id, ts_params->valid_devs[0]);
778 qp_id = 0xffff; /*invalid*/
780 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
781 ts_params->valid_devs[0],
783 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
784 ts_params->session_mpool),
785 "Failed test for rte_cryptodev_queue_pair_setup:"
786 "invalid qp %u on cryptodev %u",
787 qp_id, ts_params->valid_devs[0]);
792 /* ***** Plaintext data for tests ***** */
794 const char catch_22_quote_1[] =
795 "There was only one catch and that was Catch-22, which "
796 "specified that a concern for one's safety in the face of "
797 "dangers that were real and immediate was the process of a "
798 "rational mind. Orr was crazy and could be grounded. All he "
799 "had to do was ask; and as soon as he did, he would no longer "
800 "be crazy and would have to fly more missions. Orr would be "
801 "crazy to fly more missions and sane if he didn't, but if he "
802 "was sane he had to fly them. If he flew them he was crazy "
803 "and didn't have to; but if he didn't want to he was sane and "
804 "had to. Yossarian was moved very deeply by the absolute "
805 "simplicity of this clause of Catch-22 and let out a "
806 "respectful whistle. \"That's some catch, that Catch-22\", he "
807 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
809 const char catch_22_quote[] =
810 "What a lousy earth! He wondered how many people were "
811 "destitute that same night even in his own prosperous country, "
812 "how many homes were shanties, how many husbands were drunk "
813 "and wives socked, and how many children were bullied, abused, "
814 "or abandoned. How many families hungered for food they could "
815 "not afford to buy? How many hearts were broken? How many "
816 "suicides would take place that same night, how many people "
817 "would go insane? How many cockroaches and landlords would "
818 "triumph? How many winners were losers, successes failures, "
819 "and rich men poor men? How many wise guys were stupid? How "
820 "many happy endings were unhappy endings? How many honest men "
821 "were liars, brave men cowards, loyal men traitors, how many "
822 "sainted men were corrupt, how many people in positions of "
823 "trust had sold their souls to bodyguards, how many had never "
824 "had souls? How many straight-and-narrow paths were crooked "
825 "paths? How many best families were worst families and how "
826 "many good people were bad people? When you added them all up "
827 "and then subtracted, you might be left with only the children, "
828 "and perhaps with Albert Einstein and an old violinist or "
829 "sculptor somewhere.";
831 #define QUOTE_480_BYTES (480)
832 #define QUOTE_512_BYTES (512)
833 #define QUOTE_768_BYTES (768)
834 #define QUOTE_1024_BYTES (1024)
838 /* ***** SHA1 Hash Tests ***** */
840 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
842 static uint8_t hmac_sha1_key[] = {
843 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
844 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
845 0xDE, 0xF4, 0xDE, 0xAD };
847 /* ***** SHA224 Hash Tests ***** */
849 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
852 /* ***** AES-CBC Cipher Tests ***** */
854 #define CIPHER_KEY_LENGTH_AES_CBC (16)
855 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
857 static uint8_t aes_cbc_key[] = {
858 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
859 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
861 static uint8_t aes_cbc_iv[] = {
862 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
863 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
866 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
868 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
869 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
870 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
871 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
872 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
873 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
874 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
875 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
876 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
877 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
878 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
879 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
880 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
881 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
882 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
883 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
884 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
885 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
886 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
887 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
888 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
889 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
890 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
891 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
892 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
893 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
894 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
895 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
896 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
897 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
898 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
899 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
900 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
901 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
902 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
903 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
904 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
905 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
906 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
907 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
908 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
909 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
910 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
911 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
912 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
913 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
914 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
915 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
916 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
917 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
918 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
919 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
920 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
921 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
922 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
923 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
924 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
925 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
926 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
927 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
928 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
929 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
930 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
931 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
932 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
935 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
936 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
937 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
938 0x18, 0x8c, 0x1d, 0x32
942 /* Multisession Vector context Test */
944 static uint8_t ms_aes_cbc_key0[] = {
945 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
946 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
949 static uint8_t ms_aes_cbc_iv0[] = {
950 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
951 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
954 static const uint8_t ms_aes_cbc_cipher0[] = {
955 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
956 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
957 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
958 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
959 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
960 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
961 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
962 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
963 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
964 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
965 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
966 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
967 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
968 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
969 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
970 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
971 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
972 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
973 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
974 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
975 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
976 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
977 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
978 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
979 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
980 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
981 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
982 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
983 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
984 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
985 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
986 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
987 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
988 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
989 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
990 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
991 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
992 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
993 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
994 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
995 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
996 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
997 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
998 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
999 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1000 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1001 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1002 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1003 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1004 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1005 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1006 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1007 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1008 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1009 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1010 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1011 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1012 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1013 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1014 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1015 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1016 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1017 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1018 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1022 static uint8_t ms_hmac_key0[] = {
1023 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1024 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1025 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1026 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1027 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1028 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1029 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1030 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1033 static const uint8_t ms_hmac_digest0[] = {
1034 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1035 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1036 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1037 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1038 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1039 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1040 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1041 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1045 /* Begin session 1 */
1047 static uint8_t ms_aes_cbc_key1[] = {
1048 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1049 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1052 static uint8_t ms_aes_cbc_iv1[] = {
1053 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1054 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1057 static const uint8_t ms_aes_cbc_cipher1[] = {
1058 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1059 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1060 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1061 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1062 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1063 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1064 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1065 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1066 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1067 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1068 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1069 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1070 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1071 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1072 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1073 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1074 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1075 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1076 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1077 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1078 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1079 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1080 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1081 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1082 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1083 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1084 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1085 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1086 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1087 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1088 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1089 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1090 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1091 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1092 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1093 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1094 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1095 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1096 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1097 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1098 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1099 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1100 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1101 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1102 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1103 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1104 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1105 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1106 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1107 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1108 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1109 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1110 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1111 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1112 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1113 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1114 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1115 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1116 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1117 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1118 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1119 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1120 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1121 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1125 static uint8_t ms_hmac_key1[] = {
1126 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1127 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1128 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1129 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1130 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1131 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1132 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1133 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1136 static const uint8_t ms_hmac_digest1[] = {
1137 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1138 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1139 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1140 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1141 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1142 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1143 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1144 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1147 /* Begin Session 2 */
1148 static uint8_t ms_aes_cbc_key2[] = {
1149 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1150 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1153 static uint8_t ms_aes_cbc_iv2[] = {
1154 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1155 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1158 static const uint8_t ms_aes_cbc_cipher2[] = {
1159 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1160 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1161 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1162 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1163 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1164 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1165 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1166 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1167 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1168 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1169 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1170 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1171 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1172 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1173 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1174 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1175 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1176 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1177 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1178 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1179 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1180 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1181 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1182 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1183 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1184 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1185 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1186 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1187 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1188 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1189 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1190 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1191 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1192 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1193 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1194 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1195 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1196 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1197 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1198 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1199 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1200 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1201 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1202 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1203 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1204 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1205 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1206 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1207 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1208 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1209 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1210 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1211 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1212 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1213 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1214 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1215 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1216 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1217 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1218 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1219 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1220 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1221 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1222 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1225 static uint8_t ms_hmac_key2[] = {
1226 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1236 static const uint8_t ms_hmac_digest2[] = {
1237 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1238 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1239 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1240 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1241 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1242 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1243 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1244 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1251 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1253 struct crypto_testsuite_params *ts_params = &testsuite_params;
1254 struct crypto_unittest_params *ut_params = &unittest_params;
1256 /* Generate test mbuf data and space for digest */
1257 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1258 catch_22_quote, QUOTE_512_BYTES, 0);
1260 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1261 DIGEST_BYTE_LENGTH_SHA1);
1262 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1264 /* Setup Cipher Parameters */
1265 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1266 ut_params->cipher_xform.next = &ut_params->auth_xform;
1268 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1269 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1270 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1271 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1272 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1273 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1275 /* Setup HMAC Parameters */
1276 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1278 ut_params->auth_xform.next = NULL;
1280 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1281 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1282 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1283 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1284 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1286 ut_params->sess = rte_cryptodev_sym_session_create(
1287 ts_params->session_mpool);
1289 /* Create crypto session*/
1290 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1291 ut_params->sess, &ut_params->cipher_xform,
1292 ts_params->session_mpool);
1293 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1295 /* Generate crypto op data structure */
1296 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1297 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1298 TEST_ASSERT_NOT_NULL(ut_params->op,
1299 "Failed to allocate symmetric crypto operation struct");
1301 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1303 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1305 /* set crypto operation source mbuf */
1306 sym_op->m_src = ut_params->ibuf;
1308 /* Set crypto operation authentication parameters */
1309 sym_op->auth.digest.data = ut_params->digest;
1310 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1311 ut_params->ibuf, QUOTE_512_BYTES);
1313 sym_op->auth.data.offset = 0;
1314 sym_op->auth.data.length = QUOTE_512_BYTES;
1316 /* Copy IV at the end of the crypto operation */
1317 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1318 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1320 /* Set crypto operation cipher parameters */
1321 sym_op->cipher.data.offset = 0;
1322 sym_op->cipher.data.length = QUOTE_512_BYTES;
1324 /* Process crypto operation */
1325 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1326 ut_params->op), "failed to process sym crypto op");
1328 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1329 "crypto op processing failed");
1332 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1335 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1336 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1338 "ciphertext data not as expected");
1340 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1342 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1343 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1344 gbl_driver_id == rte_cryptodev_driver_id_get(
1345 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1346 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1347 DIGEST_BYTE_LENGTH_SHA1,
1348 "Generated digest data not as expected");
1350 return TEST_SUCCESS;
1353 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1355 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1357 static uint8_t hmac_sha512_key[] = {
1358 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1359 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1360 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1361 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1362 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1363 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1364 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1365 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1367 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1368 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1369 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1370 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1371 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1372 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1373 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1374 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1375 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1380 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1381 struct crypto_unittest_params *ut_params,
1382 uint8_t *cipher_key,
1386 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1387 struct crypto_unittest_params *ut_params,
1388 struct crypto_testsuite_params *ts_params,
1389 const uint8_t *cipher,
1390 const uint8_t *digest,
1395 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1396 struct crypto_unittest_params *ut_params,
1397 uint8_t *cipher_key,
1401 /* Setup Cipher Parameters */
1402 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1403 ut_params->cipher_xform.next = NULL;
1405 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1406 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1407 ut_params->cipher_xform.cipher.key.data = cipher_key;
1408 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1409 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1410 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1412 /* Setup HMAC Parameters */
1413 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1414 ut_params->auth_xform.next = &ut_params->cipher_xform;
1416 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1417 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1418 ut_params->auth_xform.auth.key.data = hmac_key;
1419 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1420 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1422 return TEST_SUCCESS;
1427 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1428 struct crypto_unittest_params *ut_params,
1429 struct crypto_testsuite_params *ts_params,
1430 const uint8_t *cipher,
1431 const uint8_t *digest,
1434 /* Generate test mbuf data and digest */
1435 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1438 QUOTE_512_BYTES, 0);
1440 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1441 DIGEST_BYTE_LENGTH_SHA512);
1442 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1444 rte_memcpy(ut_params->digest,
1446 DIGEST_BYTE_LENGTH_SHA512);
1448 /* Generate Crypto op data structure */
1449 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1450 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1451 TEST_ASSERT_NOT_NULL(ut_params->op,
1452 "Failed to allocate symmetric crypto operation struct");
1454 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1456 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1458 /* set crypto operation source mbuf */
1459 sym_op->m_src = ut_params->ibuf;
1461 sym_op->auth.digest.data = ut_params->digest;
1462 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1463 ut_params->ibuf, QUOTE_512_BYTES);
1465 sym_op->auth.data.offset = 0;
1466 sym_op->auth.data.length = QUOTE_512_BYTES;
1468 /* Copy IV at the end of the crypto operation */
1469 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1470 iv, CIPHER_IV_LENGTH_AES_CBC);
1472 sym_op->cipher.data.offset = 0;
1473 sym_op->cipher.data.length = QUOTE_512_BYTES;
1475 /* Process crypto operation */
1476 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1477 ut_params->op), "failed to process sym crypto op");
1479 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1480 "crypto op processing failed");
1482 ut_params->obuf = ut_params->op->sym->m_src;
1485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1486 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1489 "Plaintext data not as expected");
1492 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1493 "Digest verification failed");
1495 return TEST_SUCCESS;
1499 test_AES_cipheronly_mb_all(void)
1501 struct crypto_testsuite_params *ts_params = &testsuite_params;
1504 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1505 ts_params->op_mpool,
1506 ts_params->session_mpool,
1507 ts_params->valid_devs[0],
1508 rte_cryptodev_driver_id_get(
1509 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1510 BLKCIPHER_AES_CIPHERONLY_TYPE);
1512 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1514 return TEST_SUCCESS;
1518 test_AES_docsis_mb_all(void)
1520 struct crypto_testsuite_params *ts_params = &testsuite_params;
1523 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1524 ts_params->op_mpool,
1525 ts_params->session_mpool,
1526 ts_params->valid_devs[0],
1527 rte_cryptodev_driver_id_get(
1528 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1529 BLKCIPHER_AES_DOCSIS_TYPE);
1531 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1533 return TEST_SUCCESS;
1537 test_AES_docsis_qat_all(void)
1539 struct crypto_testsuite_params *ts_params = &testsuite_params;
1542 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1543 ts_params->op_mpool,
1544 ts_params->session_mpool,
1545 ts_params->valid_devs[0],
1546 rte_cryptodev_driver_id_get(
1547 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1548 BLKCIPHER_AES_DOCSIS_TYPE);
1550 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1552 return TEST_SUCCESS;
1556 test_DES_docsis_qat_all(void)
1558 struct crypto_testsuite_params *ts_params = &testsuite_params;
1561 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1562 ts_params->op_mpool,
1563 ts_params->session_mpool,
1564 ts_params->valid_devs[0],
1565 rte_cryptodev_driver_id_get(
1566 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1567 BLKCIPHER_DES_DOCSIS_TYPE);
1569 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1571 return TEST_SUCCESS;
1575 test_authonly_mb_all(void)
1577 struct crypto_testsuite_params *ts_params = &testsuite_params;
1580 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1581 ts_params->op_mpool,
1582 ts_params->session_mpool,
1583 ts_params->valid_devs[0],
1584 rte_cryptodev_driver_id_get(
1585 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1586 BLKCIPHER_AUTHONLY_TYPE);
1588 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1590 return TEST_SUCCESS;
1594 test_authonly_qat_all(void)
1596 struct crypto_testsuite_params *ts_params = &testsuite_params;
1599 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1600 ts_params->op_mpool,
1601 ts_params->session_mpool,
1602 ts_params->valid_devs[0],
1603 rte_cryptodev_driver_id_get(
1604 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1605 BLKCIPHER_AUTHONLY_TYPE);
1607 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1609 return TEST_SUCCESS;
1612 test_AES_chain_mb_all(void)
1614 struct crypto_testsuite_params *ts_params = &testsuite_params;
1617 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1618 ts_params->op_mpool,
1619 ts_params->session_mpool,
1620 ts_params->valid_devs[0],
1621 rte_cryptodev_driver_id_get(
1622 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1623 BLKCIPHER_AES_CHAIN_TYPE);
1625 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1627 return TEST_SUCCESS;
1630 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1633 test_AES_cipheronly_scheduler_all(void)
1635 struct crypto_testsuite_params *ts_params = &testsuite_params;
1638 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1639 ts_params->op_mpool,
1640 ts_params->session_mpool,
1641 ts_params->valid_devs[0],
1642 rte_cryptodev_driver_id_get(
1643 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1644 BLKCIPHER_AES_CIPHERONLY_TYPE);
1646 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1648 return TEST_SUCCESS;
1652 test_AES_chain_scheduler_all(void)
1654 struct crypto_testsuite_params *ts_params = &testsuite_params;
1657 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1658 ts_params->op_mpool,
1659 ts_params->session_mpool,
1660 ts_params->valid_devs[0],
1661 rte_cryptodev_driver_id_get(
1662 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1663 BLKCIPHER_AES_CHAIN_TYPE);
1665 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1667 return TEST_SUCCESS;
1671 test_authonly_scheduler_all(void)
1673 struct crypto_testsuite_params *ts_params = &testsuite_params;
1676 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1677 ts_params->op_mpool,
1678 ts_params->session_mpool,
1679 ts_params->valid_devs[0],
1680 rte_cryptodev_driver_id_get(
1681 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1682 BLKCIPHER_AUTHONLY_TYPE);
1684 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1686 return TEST_SUCCESS;
1689 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1692 test_AES_chain_openssl_all(void)
1694 struct crypto_testsuite_params *ts_params = &testsuite_params;
1697 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1698 ts_params->op_mpool,
1699 ts_params->session_mpool,
1700 ts_params->valid_devs[0],
1701 rte_cryptodev_driver_id_get(
1702 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1703 BLKCIPHER_AES_CHAIN_TYPE);
1705 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1707 return TEST_SUCCESS;
1711 test_AES_cipheronly_openssl_all(void)
1713 struct crypto_testsuite_params *ts_params = &testsuite_params;
1716 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1717 ts_params->op_mpool,
1718 ts_params->session_mpool,
1719 ts_params->valid_devs[0],
1720 rte_cryptodev_driver_id_get(
1721 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1722 BLKCIPHER_AES_CIPHERONLY_TYPE);
1724 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1726 return TEST_SUCCESS;
1730 test_AES_chain_qat_all(void)
1732 struct crypto_testsuite_params *ts_params = &testsuite_params;
1735 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1736 ts_params->op_mpool,
1737 ts_params->session_mpool,
1738 ts_params->valid_devs[0],
1739 rte_cryptodev_driver_id_get(
1740 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1741 BLKCIPHER_AES_CHAIN_TYPE);
1743 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1745 return TEST_SUCCESS;
1749 test_AES_cipheronly_qat_all(void)
1751 struct crypto_testsuite_params *ts_params = &testsuite_params;
1754 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1755 ts_params->op_mpool,
1756 ts_params->session_mpool,
1757 ts_params->valid_devs[0],
1758 rte_cryptodev_driver_id_get(
1759 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1760 BLKCIPHER_AES_CIPHERONLY_TYPE);
1762 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1764 return TEST_SUCCESS;
1768 test_AES_chain_dpaa_sec_all(void)
1770 struct crypto_testsuite_params *ts_params = &testsuite_params;
1773 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1774 ts_params->op_mpool,
1775 ts_params->session_mpool,
1776 ts_params->valid_devs[0],
1777 rte_cryptodev_driver_id_get(
1778 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1779 BLKCIPHER_AES_CHAIN_TYPE);
1781 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1783 return TEST_SUCCESS;
1787 test_AES_cipheronly_dpaa_sec_all(void)
1789 struct crypto_testsuite_params *ts_params = &testsuite_params;
1792 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1793 ts_params->op_mpool,
1794 ts_params->session_mpool,
1795 ts_params->valid_devs[0],
1796 rte_cryptodev_driver_id_get(
1797 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1798 BLKCIPHER_AES_CIPHERONLY_TYPE);
1800 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1802 return TEST_SUCCESS;
1806 test_authonly_dpaa_sec_all(void)
1808 struct crypto_testsuite_params *ts_params = &testsuite_params;
1811 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1812 ts_params->op_mpool,
1813 ts_params->session_mpool,
1814 ts_params->valid_devs[0],
1815 rte_cryptodev_driver_id_get(
1816 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1817 BLKCIPHER_AUTHONLY_TYPE);
1819 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1821 return TEST_SUCCESS;
1825 test_AES_chain_dpaa2_sec_all(void)
1827 struct crypto_testsuite_params *ts_params = &testsuite_params;
1830 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1831 ts_params->op_mpool,
1832 ts_params->session_mpool,
1833 ts_params->valid_devs[0],
1834 rte_cryptodev_driver_id_get(
1835 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1836 BLKCIPHER_AES_CHAIN_TYPE);
1838 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1840 return TEST_SUCCESS;
1844 test_AES_cipheronly_dpaa2_sec_all(void)
1846 struct crypto_testsuite_params *ts_params = &testsuite_params;
1849 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1850 ts_params->op_mpool,
1851 ts_params->session_mpool,
1852 ts_params->valid_devs[0],
1853 rte_cryptodev_driver_id_get(
1854 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1855 BLKCIPHER_AES_CIPHERONLY_TYPE);
1857 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1859 return TEST_SUCCESS;
1863 test_authonly_dpaa2_sec_all(void)
1865 struct crypto_testsuite_params *ts_params = &testsuite_params;
1868 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1869 ts_params->op_mpool,
1870 ts_params->session_mpool,
1871 ts_params->valid_devs[0],
1872 rte_cryptodev_driver_id_get(
1873 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1874 BLKCIPHER_AUTHONLY_TYPE);
1876 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1878 return TEST_SUCCESS;
1882 test_authonly_openssl_all(void)
1884 struct crypto_testsuite_params *ts_params = &testsuite_params;
1887 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1888 ts_params->op_mpool,
1889 ts_params->session_mpool,
1890 ts_params->valid_devs[0],
1891 rte_cryptodev_driver_id_get(
1892 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1893 BLKCIPHER_AUTHONLY_TYPE);
1895 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1897 return TEST_SUCCESS;
1901 test_AES_chain_armv8_all(void)
1903 struct crypto_testsuite_params *ts_params = &testsuite_params;
1906 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1907 ts_params->op_mpool,
1908 ts_params->session_mpool,
1909 ts_params->valid_devs[0],
1910 rte_cryptodev_driver_id_get(
1911 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1912 BLKCIPHER_AES_CHAIN_TYPE);
1914 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1916 return TEST_SUCCESS;
1920 test_AES_chain_mrvl_all(void)
1922 struct crypto_testsuite_params *ts_params = &testsuite_params;
1925 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1926 ts_params->op_mpool,
1927 ts_params->session_mpool,
1928 ts_params->valid_devs[0],
1929 rte_cryptodev_driver_id_get(
1930 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1931 BLKCIPHER_AES_CHAIN_TYPE);
1933 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1935 return TEST_SUCCESS;
1939 test_AES_cipheronly_mrvl_all(void)
1941 struct crypto_testsuite_params *ts_params = &testsuite_params;
1944 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1945 ts_params->op_mpool,
1946 ts_params->session_mpool,
1947 ts_params->valid_devs[0],
1948 rte_cryptodev_driver_id_get(
1949 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1950 BLKCIPHER_AES_CIPHERONLY_TYPE);
1952 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1954 return TEST_SUCCESS;
1958 test_authonly_mrvl_all(void)
1960 struct crypto_testsuite_params *ts_params = &testsuite_params;
1963 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1964 ts_params->op_mpool,
1965 ts_params->session_mpool,
1966 ts_params->valid_devs[0],
1967 rte_cryptodev_driver_id_get(
1968 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1969 BLKCIPHER_AUTHONLY_TYPE);
1971 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1973 return TEST_SUCCESS;
1977 test_3DES_chain_mrvl_all(void)
1979 struct crypto_testsuite_params *ts_params = &testsuite_params;
1982 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1983 ts_params->op_mpool,
1984 ts_params->session_mpool,
1985 ts_params->valid_devs[0],
1986 rte_cryptodev_driver_id_get(
1987 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1988 BLKCIPHER_3DES_CHAIN_TYPE);
1990 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1992 return TEST_SUCCESS;
1996 test_3DES_cipheronly_mrvl_all(void)
1998 struct crypto_testsuite_params *ts_params = &testsuite_params;
2001 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2002 ts_params->op_mpool,
2003 ts_params->session_mpool,
2004 ts_params->valid_devs[0],
2005 rte_cryptodev_driver_id_get(
2006 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2007 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2009 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2011 return TEST_SUCCESS;
2014 /* ***** SNOW 3G Tests ***** */
2016 create_wireless_algo_hash_session(uint8_t dev_id,
2017 const uint8_t *key, const uint8_t key_len,
2018 const uint8_t iv_len, const uint8_t auth_len,
2019 enum rte_crypto_auth_operation op,
2020 enum rte_crypto_auth_algorithm algo)
2022 uint8_t hash_key[key_len];
2024 struct crypto_testsuite_params *ts_params = &testsuite_params;
2025 struct crypto_unittest_params *ut_params = &unittest_params;
2027 memcpy(hash_key, key, key_len);
2029 debug_hexdump(stdout, "key:", key, key_len);
2031 /* Setup Authentication Parameters */
2032 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2033 ut_params->auth_xform.next = NULL;
2035 ut_params->auth_xform.auth.op = op;
2036 ut_params->auth_xform.auth.algo = algo;
2037 ut_params->auth_xform.auth.key.length = key_len;
2038 ut_params->auth_xform.auth.key.data = hash_key;
2039 ut_params->auth_xform.auth.digest_length = auth_len;
2040 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2041 ut_params->auth_xform.auth.iv.length = iv_len;
2042 ut_params->sess = rte_cryptodev_sym_session_create(
2043 ts_params->session_mpool);
2045 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2046 &ut_params->auth_xform, ts_params->session_mpool);
2047 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2052 create_wireless_algo_cipher_session(uint8_t dev_id,
2053 enum rte_crypto_cipher_operation op,
2054 enum rte_crypto_cipher_algorithm algo,
2055 const uint8_t *key, const uint8_t key_len,
2058 uint8_t cipher_key[key_len];
2060 struct crypto_testsuite_params *ts_params = &testsuite_params;
2061 struct crypto_unittest_params *ut_params = &unittest_params;
2063 memcpy(cipher_key, key, key_len);
2065 /* Setup Cipher Parameters */
2066 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2067 ut_params->cipher_xform.next = NULL;
2069 ut_params->cipher_xform.cipher.algo = algo;
2070 ut_params->cipher_xform.cipher.op = op;
2071 ut_params->cipher_xform.cipher.key.data = cipher_key;
2072 ut_params->cipher_xform.cipher.key.length = key_len;
2073 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2074 ut_params->cipher_xform.cipher.iv.length = iv_len;
2076 debug_hexdump(stdout, "key:", key, key_len);
2078 /* Create Crypto session */
2079 ut_params->sess = rte_cryptodev_sym_session_create(
2080 ts_params->session_mpool);
2082 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2083 &ut_params->cipher_xform, ts_params->session_mpool);
2084 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2089 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2090 unsigned int cipher_len,
2091 unsigned int cipher_offset)
2093 struct crypto_testsuite_params *ts_params = &testsuite_params;
2094 struct crypto_unittest_params *ut_params = &unittest_params;
2096 /* Generate Crypto op data structure */
2097 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2098 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2099 TEST_ASSERT_NOT_NULL(ut_params->op,
2100 "Failed to allocate pktmbuf offload");
2102 /* Set crypto operation data parameters */
2103 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2105 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2107 /* set crypto operation source mbuf */
2108 sym_op->m_src = ut_params->ibuf;
2111 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2113 sym_op->cipher.data.length = cipher_len;
2114 sym_op->cipher.data.offset = cipher_offset;
2119 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2120 unsigned int cipher_len,
2121 unsigned int cipher_offset)
2123 struct crypto_testsuite_params *ts_params = &testsuite_params;
2124 struct crypto_unittest_params *ut_params = &unittest_params;
2126 /* Generate Crypto op data structure */
2127 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2128 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2129 TEST_ASSERT_NOT_NULL(ut_params->op,
2130 "Failed to allocate pktmbuf offload");
2132 /* Set crypto operation data parameters */
2133 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2135 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2137 /* set crypto operation source mbuf */
2138 sym_op->m_src = ut_params->ibuf;
2139 sym_op->m_dst = ut_params->obuf;
2142 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2144 sym_op->cipher.data.length = cipher_len;
2145 sym_op->cipher.data.offset = cipher_offset;
2150 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2151 enum rte_crypto_cipher_operation cipher_op,
2152 enum rte_crypto_auth_operation auth_op,
2153 enum rte_crypto_auth_algorithm auth_algo,
2154 enum rte_crypto_cipher_algorithm cipher_algo,
2155 const uint8_t *key, uint8_t key_len,
2156 uint8_t auth_iv_len, uint8_t auth_len,
2157 uint8_t cipher_iv_len)
2160 uint8_t cipher_auth_key[key_len];
2162 struct crypto_testsuite_params *ts_params = &testsuite_params;
2163 struct crypto_unittest_params *ut_params = &unittest_params;
2165 memcpy(cipher_auth_key, key, key_len);
2167 /* Setup Authentication Parameters */
2168 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2169 ut_params->auth_xform.next = NULL;
2171 ut_params->auth_xform.auth.op = auth_op;
2172 ut_params->auth_xform.auth.algo = auth_algo;
2173 ut_params->auth_xform.auth.key.length = key_len;
2174 /* Hash key = cipher key */
2175 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2176 ut_params->auth_xform.auth.digest_length = auth_len;
2177 /* Auth IV will be after cipher IV */
2178 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2179 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2181 /* Setup Cipher Parameters */
2182 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2183 ut_params->cipher_xform.next = &ut_params->auth_xform;
2185 ut_params->cipher_xform.cipher.algo = cipher_algo;
2186 ut_params->cipher_xform.cipher.op = cipher_op;
2187 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2188 ut_params->cipher_xform.cipher.key.length = key_len;
2189 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2190 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2192 debug_hexdump(stdout, "key:", key, key_len);
2194 /* Create Crypto session*/
2195 ut_params->sess = rte_cryptodev_sym_session_create(
2196 ts_params->session_mpool);
2198 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2199 &ut_params->cipher_xform, ts_params->session_mpool);
2201 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2206 create_wireless_cipher_auth_session(uint8_t dev_id,
2207 enum rte_crypto_cipher_operation cipher_op,
2208 enum rte_crypto_auth_operation auth_op,
2209 enum rte_crypto_auth_algorithm auth_algo,
2210 enum rte_crypto_cipher_algorithm cipher_algo,
2211 const struct wireless_test_data *tdata)
2213 const uint8_t key_len = tdata->key.len;
2214 uint8_t cipher_auth_key[key_len];
2216 struct crypto_testsuite_params *ts_params = &testsuite_params;
2217 struct crypto_unittest_params *ut_params = &unittest_params;
2218 const uint8_t *key = tdata->key.data;
2219 const uint8_t auth_len = tdata->digest.len;
2220 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2221 uint8_t auth_iv_len = tdata->auth_iv.len;
2223 memcpy(cipher_auth_key, key, key_len);
2225 /* Setup Authentication Parameters */
2226 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2227 ut_params->auth_xform.next = NULL;
2229 ut_params->auth_xform.auth.op = auth_op;
2230 ut_params->auth_xform.auth.algo = auth_algo;
2231 ut_params->auth_xform.auth.key.length = key_len;
2232 /* Hash key = cipher key */
2233 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2234 ut_params->auth_xform.auth.digest_length = auth_len;
2235 /* Auth IV will be after cipher IV */
2236 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2237 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2239 /* Setup Cipher Parameters */
2240 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2241 ut_params->cipher_xform.next = &ut_params->auth_xform;
2243 ut_params->cipher_xform.cipher.algo = cipher_algo;
2244 ut_params->cipher_xform.cipher.op = cipher_op;
2245 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2246 ut_params->cipher_xform.cipher.key.length = key_len;
2247 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2248 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2251 debug_hexdump(stdout, "key:", key, key_len);
2253 /* Create Crypto session*/
2254 ut_params->sess = rte_cryptodev_sym_session_create(
2255 ts_params->session_mpool);
2257 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2258 &ut_params->cipher_xform, ts_params->session_mpool);
2260 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2265 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2266 const struct wireless_test_data *tdata)
2268 return create_wireless_cipher_auth_session(dev_id,
2269 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2270 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2271 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2275 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2276 enum rte_crypto_cipher_operation cipher_op,
2277 enum rte_crypto_auth_operation auth_op,
2278 enum rte_crypto_auth_algorithm auth_algo,
2279 enum rte_crypto_cipher_algorithm cipher_algo,
2280 const uint8_t *key, const uint8_t key_len,
2281 uint8_t auth_iv_len, uint8_t auth_len,
2282 uint8_t cipher_iv_len)
2284 uint8_t auth_cipher_key[key_len];
2286 struct crypto_testsuite_params *ts_params = &testsuite_params;
2287 struct crypto_unittest_params *ut_params = &unittest_params;
2289 memcpy(auth_cipher_key, key, key_len);
2291 /* Setup Authentication Parameters */
2292 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2293 ut_params->auth_xform.auth.op = auth_op;
2294 ut_params->auth_xform.next = &ut_params->cipher_xform;
2295 ut_params->auth_xform.auth.algo = auth_algo;
2296 ut_params->auth_xform.auth.key.length = key_len;
2297 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2298 ut_params->auth_xform.auth.digest_length = auth_len;
2299 /* Auth IV will be after cipher IV */
2300 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2301 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2303 /* Setup Cipher Parameters */
2304 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2305 ut_params->cipher_xform.next = NULL;
2306 ut_params->cipher_xform.cipher.algo = cipher_algo;
2307 ut_params->cipher_xform.cipher.op = cipher_op;
2308 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2309 ut_params->cipher_xform.cipher.key.length = key_len;
2310 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2311 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2313 debug_hexdump(stdout, "key:", key, key_len);
2315 /* Create Crypto session*/
2316 ut_params->sess = rte_cryptodev_sym_session_create(
2317 ts_params->session_mpool);
2319 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2320 &ut_params->auth_xform, ts_params->session_mpool);
2322 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2328 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2329 unsigned int auth_tag_len,
2330 const uint8_t *iv, unsigned int iv_len,
2331 unsigned int data_pad_len,
2332 enum rte_crypto_auth_operation op,
2333 unsigned int auth_len, unsigned int auth_offset)
2335 struct crypto_testsuite_params *ts_params = &testsuite_params;
2337 struct crypto_unittest_params *ut_params = &unittest_params;
2339 /* Generate Crypto op data structure */
2340 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2341 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2342 TEST_ASSERT_NOT_NULL(ut_params->op,
2343 "Failed to allocate pktmbuf offload");
2345 /* Set crypto operation data parameters */
2346 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2348 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2350 /* set crypto operation source mbuf */
2351 sym_op->m_src = ut_params->ibuf;
2354 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2357 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2358 ut_params->ibuf, auth_tag_len);
2360 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2361 "no room to append auth tag");
2362 ut_params->digest = sym_op->auth.digest.data;
2363 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2364 ut_params->ibuf, data_pad_len);
2365 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2366 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2368 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2370 debug_hexdump(stdout, "digest:",
2371 sym_op->auth.digest.data,
2374 sym_op->auth.data.length = auth_len;
2375 sym_op->auth.data.offset = auth_offset;
2381 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2382 enum rte_crypto_auth_operation op)
2384 struct crypto_testsuite_params *ts_params = &testsuite_params;
2385 struct crypto_unittest_params *ut_params = &unittest_params;
2387 const uint8_t *auth_tag = tdata->digest.data;
2388 const unsigned int auth_tag_len = tdata->digest.len;
2389 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2390 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2392 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2393 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2394 const uint8_t *auth_iv = tdata->auth_iv.data;
2395 const uint8_t auth_iv_len = tdata->auth_iv.len;
2396 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2397 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2399 /* Generate Crypto op data structure */
2400 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2401 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2402 TEST_ASSERT_NOT_NULL(ut_params->op,
2403 "Failed to allocate pktmbuf offload");
2404 /* Set crypto operation data parameters */
2405 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2407 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2409 /* set crypto operation source mbuf */
2410 sym_op->m_src = ut_params->ibuf;
2413 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2414 ut_params->ibuf, auth_tag_len);
2416 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2417 "no room to append auth tag");
2418 ut_params->digest = sym_op->auth.digest.data;
2419 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2420 ut_params->ibuf, data_pad_len);
2421 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2422 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2424 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2426 debug_hexdump(stdout, "digest:",
2427 sym_op->auth.digest.data,
2430 /* Copy cipher and auth IVs at the end of the crypto operation */
2431 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2433 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2434 iv_ptr += cipher_iv_len;
2435 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2437 sym_op->cipher.data.length = cipher_len;
2438 sym_op->cipher.data.offset = 0;
2439 sym_op->auth.data.length = auth_len;
2440 sym_op->auth.data.offset = 0;
2446 create_zuc_cipher_hash_generate_operation(
2447 const struct wireless_test_data *tdata)
2449 return create_wireless_cipher_hash_operation(tdata,
2450 RTE_CRYPTO_AUTH_OP_GENERATE);
2454 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2455 const unsigned auth_tag_len,
2456 const uint8_t *auth_iv, uint8_t auth_iv_len,
2457 unsigned data_pad_len,
2458 enum rte_crypto_auth_operation op,
2459 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2460 const unsigned cipher_len, const unsigned cipher_offset,
2461 const unsigned auth_len, const unsigned auth_offset)
2463 struct crypto_testsuite_params *ts_params = &testsuite_params;
2464 struct crypto_unittest_params *ut_params = &unittest_params;
2466 /* Generate Crypto op data structure */
2467 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2468 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2469 TEST_ASSERT_NOT_NULL(ut_params->op,
2470 "Failed to allocate pktmbuf offload");
2471 /* Set crypto operation data parameters */
2472 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2474 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2476 /* set crypto operation source mbuf */
2477 sym_op->m_src = ut_params->ibuf;
2480 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2481 ut_params->ibuf, auth_tag_len);
2483 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2484 "no room to append auth tag");
2485 ut_params->digest = sym_op->auth.digest.data;
2486 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2487 ut_params->ibuf, data_pad_len);
2488 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2489 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2491 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2493 debug_hexdump(stdout, "digest:",
2494 sym_op->auth.digest.data,
2497 /* Copy cipher and auth IVs at the end of the crypto operation */
2498 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2500 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2501 iv_ptr += cipher_iv_len;
2502 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2504 sym_op->cipher.data.length = cipher_len;
2505 sym_op->cipher.data.offset = cipher_offset;
2506 sym_op->auth.data.length = auth_len;
2507 sym_op->auth.data.offset = auth_offset;
2513 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2514 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2515 const uint8_t *auth_iv, uint8_t auth_iv_len,
2516 unsigned int data_pad_len,
2517 unsigned int cipher_len, unsigned int cipher_offset,
2518 unsigned int auth_len, unsigned int auth_offset)
2520 struct crypto_testsuite_params *ts_params = &testsuite_params;
2521 struct crypto_unittest_params *ut_params = &unittest_params;
2523 /* Generate Crypto op data structure */
2524 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2525 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2526 TEST_ASSERT_NOT_NULL(ut_params->op,
2527 "Failed to allocate pktmbuf offload");
2529 /* Set crypto operation data parameters */
2530 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2532 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2534 /* set crypto operation source mbuf */
2535 sym_op->m_src = ut_params->ibuf;
2538 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2539 ut_params->ibuf, auth_tag_len);
2541 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2542 "no room to append auth tag");
2544 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2545 ut_params->ibuf, data_pad_len);
2547 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2549 debug_hexdump(stdout, "digest:",
2550 sym_op->auth.digest.data,
2553 /* Copy cipher and auth IVs at the end of the crypto operation */
2554 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2556 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2557 iv_ptr += cipher_iv_len;
2558 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2560 sym_op->cipher.data.length = cipher_len;
2561 sym_op->cipher.data.offset = cipher_offset;
2563 sym_op->auth.data.length = auth_len;
2564 sym_op->auth.data.offset = auth_offset;
2570 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2572 struct crypto_testsuite_params *ts_params = &testsuite_params;
2573 struct crypto_unittest_params *ut_params = &unittest_params;
2576 unsigned plaintext_pad_len;
2577 unsigned plaintext_len;
2580 /* Create SNOW 3G session */
2581 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2582 tdata->key.data, tdata->key.len,
2583 tdata->auth_iv.len, tdata->digest.len,
2584 RTE_CRYPTO_AUTH_OP_GENERATE,
2585 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2589 /* alloc mbuf and set payload */
2590 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2592 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2593 rte_pktmbuf_tailroom(ut_params->ibuf));
2595 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2596 /* Append data which is padded to a multiple of */
2597 /* the algorithms block size */
2598 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2599 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2601 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2603 /* Create SNOW 3G operation */
2604 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2605 tdata->auth_iv.data, tdata->auth_iv.len,
2606 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2607 tdata->validAuthLenInBits.len,
2612 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2614 ut_params->obuf = ut_params->op->sym->m_src;
2615 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2616 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2617 + plaintext_pad_len;
2620 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2623 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2624 "SNOW 3G Generated auth tag not as expected");
2630 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2632 struct crypto_testsuite_params *ts_params = &testsuite_params;
2633 struct crypto_unittest_params *ut_params = &unittest_params;
2636 unsigned plaintext_pad_len;
2637 unsigned plaintext_len;
2640 /* Create SNOW 3G session */
2641 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2642 tdata->key.data, tdata->key.len,
2643 tdata->auth_iv.len, tdata->digest.len,
2644 RTE_CRYPTO_AUTH_OP_VERIFY,
2645 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2648 /* alloc mbuf and set payload */
2649 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2651 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2652 rte_pktmbuf_tailroom(ut_params->ibuf));
2654 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2655 /* Append data which is padded to a multiple of */
2656 /* the algorithms block size */
2657 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2658 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2660 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2662 /* Create SNOW 3G operation */
2663 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2665 tdata->auth_iv.data, tdata->auth_iv.len,
2667 RTE_CRYPTO_AUTH_OP_VERIFY,
2668 tdata->validAuthLenInBits.len,
2673 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2675 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2676 ut_params->obuf = ut_params->op->sym->m_src;
2677 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2678 + plaintext_pad_len;
2681 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2690 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2692 struct crypto_testsuite_params *ts_params = &testsuite_params;
2693 struct crypto_unittest_params *ut_params = &unittest_params;
2696 unsigned plaintext_pad_len;
2697 unsigned plaintext_len;
2700 /* Create KASUMI session */
2701 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2702 tdata->key.data, tdata->key.len,
2703 0, tdata->digest.len,
2704 RTE_CRYPTO_AUTH_OP_GENERATE,
2705 RTE_CRYPTO_AUTH_KASUMI_F9);
2709 /* alloc mbuf and set payload */
2710 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2712 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2713 rte_pktmbuf_tailroom(ut_params->ibuf));
2715 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2716 /* Append data which is padded to a multiple of */
2717 /* the algorithms block size */
2718 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2719 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2721 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2723 /* Create KASUMI operation */
2724 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2726 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2727 tdata->plaintext.len,
2732 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2734 ut_params->obuf = ut_params->op->sym->m_src;
2735 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2736 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2737 + plaintext_pad_len;
2740 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2743 DIGEST_BYTE_LENGTH_KASUMI_F9,
2744 "KASUMI Generated auth tag not as expected");
2750 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2752 struct crypto_testsuite_params *ts_params = &testsuite_params;
2753 struct crypto_unittest_params *ut_params = &unittest_params;
2756 unsigned plaintext_pad_len;
2757 unsigned plaintext_len;
2760 /* Create KASUMI session */
2761 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2762 tdata->key.data, tdata->key.len,
2763 0, tdata->digest.len,
2764 RTE_CRYPTO_AUTH_OP_VERIFY,
2765 RTE_CRYPTO_AUTH_KASUMI_F9);
2768 /* alloc mbuf and set payload */
2769 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2771 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2772 rte_pktmbuf_tailroom(ut_params->ibuf));
2774 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2775 /* Append data which is padded to a multiple */
2776 /* of the algorithms block size */
2777 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2778 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2780 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2782 /* Create KASUMI operation */
2783 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2787 RTE_CRYPTO_AUTH_OP_VERIFY,
2788 tdata->plaintext.len,
2793 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2795 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2796 ut_params->obuf = ut_params->op->sym->m_src;
2797 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2798 + plaintext_pad_len;
2801 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2810 test_snow3g_hash_generate_test_case_1(void)
2812 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2816 test_snow3g_hash_generate_test_case_2(void)
2818 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2822 test_snow3g_hash_generate_test_case_3(void)
2824 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2828 test_snow3g_hash_generate_test_case_4(void)
2830 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2834 test_snow3g_hash_generate_test_case_5(void)
2836 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2840 test_snow3g_hash_generate_test_case_6(void)
2842 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2846 test_snow3g_hash_verify_test_case_1(void)
2848 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2853 test_snow3g_hash_verify_test_case_2(void)
2855 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2859 test_snow3g_hash_verify_test_case_3(void)
2861 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2865 test_snow3g_hash_verify_test_case_4(void)
2867 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2871 test_snow3g_hash_verify_test_case_5(void)
2873 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2877 test_snow3g_hash_verify_test_case_6(void)
2879 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2883 test_kasumi_hash_generate_test_case_1(void)
2885 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2889 test_kasumi_hash_generate_test_case_2(void)
2891 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2895 test_kasumi_hash_generate_test_case_3(void)
2897 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2901 test_kasumi_hash_generate_test_case_4(void)
2903 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2907 test_kasumi_hash_generate_test_case_5(void)
2909 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2913 test_kasumi_hash_generate_test_case_6(void)
2915 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2919 test_kasumi_hash_verify_test_case_1(void)
2921 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2925 test_kasumi_hash_verify_test_case_2(void)
2927 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2931 test_kasumi_hash_verify_test_case_3(void)
2933 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2937 test_kasumi_hash_verify_test_case_4(void)
2939 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2943 test_kasumi_hash_verify_test_case_5(void)
2945 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2949 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2951 struct crypto_testsuite_params *ts_params = &testsuite_params;
2952 struct crypto_unittest_params *ut_params = &unittest_params;
2955 uint8_t *plaintext, *ciphertext;
2956 unsigned plaintext_pad_len;
2957 unsigned plaintext_len;
2959 /* Create KASUMI session */
2960 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2961 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2962 RTE_CRYPTO_CIPHER_KASUMI_F8,
2963 tdata->key.data, tdata->key.len,
2964 tdata->cipher_iv.len);
2968 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2970 /* Clear mbuf payload */
2971 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2972 rte_pktmbuf_tailroom(ut_params->ibuf));
2974 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2975 /* Append data which is padded to a multiple */
2976 /* of the algorithms block size */
2977 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2978 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2980 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2982 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
2984 /* Create KASUMI operation */
2985 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2986 tdata->cipher_iv.len,
2987 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2988 tdata->validCipherOffsetInBits.len);
2992 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2994 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2996 ut_params->obuf = ut_params->op->sym->m_dst;
2997 if (ut_params->obuf)
2998 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3000 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3002 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3004 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3005 (tdata->validCipherOffsetInBits.len >> 3);
3007 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3009 reference_ciphertext,
3010 tdata->validCipherLenInBits.len,
3011 "KASUMI Ciphertext data not as expected");
3016 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3018 struct crypto_testsuite_params *ts_params = &testsuite_params;
3019 struct crypto_unittest_params *ut_params = &unittest_params;
3023 unsigned int plaintext_pad_len;
3024 unsigned int plaintext_len;
3026 uint8_t buffer[10000];
3027 const uint8_t *ciphertext;
3029 struct rte_cryptodev_info dev_info;
3031 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3032 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3033 printf("Device doesn't support scatter-gather. "
3038 /* Create KASUMI session */
3039 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3040 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3041 RTE_CRYPTO_CIPHER_KASUMI_F8,
3042 tdata->key.data, tdata->key.len,
3043 tdata->cipher_iv.len);
3047 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3050 /* Append data which is padded to a multiple */
3051 /* of the algorithms block size */
3052 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3054 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3055 plaintext_pad_len, 10, 0);
3057 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3059 /* Create KASUMI operation */
3060 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3061 tdata->cipher_iv.len,
3062 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3063 tdata->validCipherOffsetInBits.len);
3067 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3069 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3071 ut_params->obuf = ut_params->op->sym->m_dst;
3073 if (ut_params->obuf)
3074 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3075 plaintext_len, buffer);
3077 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3078 tdata->validCipherOffsetInBits.len >> 3,
3079 plaintext_len, buffer);
3082 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3084 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3085 (tdata->validCipherOffsetInBits.len >> 3);
3087 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3089 reference_ciphertext,
3090 tdata->validCipherLenInBits.len,
3091 "KASUMI Ciphertext data not as expected");
3096 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3098 struct crypto_testsuite_params *ts_params = &testsuite_params;
3099 struct crypto_unittest_params *ut_params = &unittest_params;
3102 uint8_t *plaintext, *ciphertext;
3103 unsigned plaintext_pad_len;
3104 unsigned plaintext_len;
3106 /* Create KASUMI session */
3107 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3108 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3109 RTE_CRYPTO_CIPHER_KASUMI_F8,
3110 tdata->key.data, tdata->key.len,
3111 tdata->cipher_iv.len);
3115 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3116 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3118 /* Clear mbuf payload */
3119 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3120 rte_pktmbuf_tailroom(ut_params->ibuf));
3122 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3123 /* Append data which is padded to a multiple */
3124 /* of the algorithms block size */
3125 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3126 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3128 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3129 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3131 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3133 /* Create KASUMI operation */
3134 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3135 tdata->cipher_iv.len,
3136 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3137 tdata->validCipherOffsetInBits.len);
3141 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3143 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3145 ut_params->obuf = ut_params->op->sym->m_dst;
3146 if (ut_params->obuf)
3147 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3149 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3151 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3153 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3154 (tdata->validCipherOffsetInBits.len >> 3);
3156 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3158 reference_ciphertext,
3159 tdata->validCipherLenInBits.len,
3160 "KASUMI Ciphertext data not as expected");
3165 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3167 struct crypto_testsuite_params *ts_params = &testsuite_params;
3168 struct crypto_unittest_params *ut_params = &unittest_params;
3171 unsigned int plaintext_pad_len;
3172 unsigned int plaintext_len;
3174 const uint8_t *ciphertext;
3175 uint8_t buffer[2048];
3177 struct rte_cryptodev_info dev_info;
3179 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3180 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3181 printf("Device doesn't support scatter-gather. "
3186 /* Create KASUMI session */
3187 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3188 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3189 RTE_CRYPTO_CIPHER_KASUMI_F8,
3190 tdata->key.data, tdata->key.len,
3191 tdata->cipher_iv.len);
3195 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3196 /* Append data which is padded to a multiple */
3197 /* of the algorithms block size */
3198 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3200 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3201 plaintext_pad_len, 10, 0);
3202 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3203 plaintext_pad_len, 3, 0);
3205 /* Append data which is padded to a multiple */
3206 /* of the algorithms block size */
3207 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3209 /* Create KASUMI operation */
3210 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3211 tdata->cipher_iv.len,
3212 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3213 tdata->validCipherOffsetInBits.len);
3217 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3221 ut_params->obuf = ut_params->op->sym->m_dst;
3222 if (ut_params->obuf)
3223 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3224 plaintext_pad_len, buffer);
3226 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3227 tdata->validCipherOffsetInBits.len >> 3,
3228 plaintext_pad_len, buffer);
3230 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3231 (tdata->validCipherOffsetInBits.len >> 3);
3233 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3235 reference_ciphertext,
3236 tdata->validCipherLenInBits.len,
3237 "KASUMI Ciphertext data not as expected");
3243 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3245 struct crypto_testsuite_params *ts_params = &testsuite_params;
3246 struct crypto_unittest_params *ut_params = &unittest_params;
3249 uint8_t *ciphertext, *plaintext;
3250 unsigned ciphertext_pad_len;
3251 unsigned ciphertext_len;
3253 /* Create KASUMI session */
3254 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3255 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3256 RTE_CRYPTO_CIPHER_KASUMI_F8,
3257 tdata->key.data, tdata->key.len,
3258 tdata->cipher_iv.len);
3262 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3263 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3265 /* Clear mbuf payload */
3266 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3267 rte_pktmbuf_tailroom(ut_params->ibuf));
3269 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3270 /* Append data which is padded to a multiple */
3271 /* of the algorithms block size */
3272 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3273 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3274 ciphertext_pad_len);
3275 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3276 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3278 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3280 /* Create KASUMI operation */
3281 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3282 tdata->cipher_iv.len,
3283 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3284 tdata->validCipherOffsetInBits.len);
3288 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3290 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3292 ut_params->obuf = ut_params->op->sym->m_dst;
3293 if (ut_params->obuf)
3294 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3296 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3298 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3300 const uint8_t *reference_plaintext = tdata->plaintext.data +
3301 (tdata->validCipherOffsetInBits.len >> 3);
3303 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3305 reference_plaintext,
3306 tdata->validCipherLenInBits.len,
3307 "KASUMI Plaintext data not as expected");
3312 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3314 struct crypto_testsuite_params *ts_params = &testsuite_params;
3315 struct crypto_unittest_params *ut_params = &unittest_params;
3318 uint8_t *ciphertext, *plaintext;
3319 unsigned ciphertext_pad_len;
3320 unsigned ciphertext_len;
3322 /* Create KASUMI session */
3323 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3324 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3325 RTE_CRYPTO_CIPHER_KASUMI_F8,
3326 tdata->key.data, tdata->key.len,
3327 tdata->cipher_iv.len);
3331 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3333 /* Clear mbuf payload */
3334 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3335 rte_pktmbuf_tailroom(ut_params->ibuf));
3337 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3338 /* Append data which is padded to a multiple */
3339 /* of the algorithms block size */
3340 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3341 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3342 ciphertext_pad_len);
3343 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3345 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3347 /* Create KASUMI operation */
3348 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3349 tdata->cipher_iv.len,
3350 tdata->ciphertext.len,
3351 tdata->validCipherOffsetInBits.len);
3355 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3357 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3359 ut_params->obuf = ut_params->op->sym->m_dst;
3360 if (ut_params->obuf)
3361 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3363 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3365 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3367 const uint8_t *reference_plaintext = tdata->plaintext.data +
3368 (tdata->validCipherOffsetInBits.len >> 3);
3370 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3372 reference_plaintext,
3373 tdata->validCipherLenInBits.len,
3374 "KASUMI Plaintext data not as expected");
3379 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3381 struct crypto_testsuite_params *ts_params = &testsuite_params;
3382 struct crypto_unittest_params *ut_params = &unittest_params;
3385 uint8_t *plaintext, *ciphertext;
3386 unsigned plaintext_pad_len;
3387 unsigned plaintext_len;
3389 /* Create SNOW 3G session */
3390 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3391 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3392 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3393 tdata->key.data, tdata->key.len,
3394 tdata->cipher_iv.len);
3398 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3400 /* Clear mbuf payload */
3401 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3402 rte_pktmbuf_tailroom(ut_params->ibuf));
3404 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3405 /* Append data which is padded to a multiple of */
3406 /* the algorithms block size */
3407 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3408 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3410 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3412 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3414 /* Create SNOW 3G operation */
3415 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3416 tdata->cipher_iv.len,
3417 tdata->validCipherLenInBits.len,
3422 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3424 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3426 ut_params->obuf = ut_params->op->sym->m_dst;
3427 if (ut_params->obuf)
3428 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3430 ciphertext = plaintext;
3432 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3435 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3437 tdata->ciphertext.data,
3438 tdata->validDataLenInBits.len,
3439 "SNOW 3G Ciphertext data not as expected");
3445 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3447 struct crypto_testsuite_params *ts_params = &testsuite_params;
3448 struct crypto_unittest_params *ut_params = &unittest_params;
3449 uint8_t *plaintext, *ciphertext;
3452 unsigned plaintext_pad_len;
3453 unsigned plaintext_len;
3455 /* Create SNOW 3G session */
3456 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3457 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3458 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3459 tdata->key.data, tdata->key.len,
3460 tdata->cipher_iv.len);
3464 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3465 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3467 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3468 "Failed to allocate input buffer in mempool");
3469 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3470 "Failed to allocate output buffer in mempool");
3472 /* Clear mbuf payload */
3473 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3474 rte_pktmbuf_tailroom(ut_params->ibuf));
3476 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3477 /* Append data which is padded to a multiple of */
3478 /* the algorithms block size */
3479 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3480 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3482 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3483 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3485 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3487 /* Create SNOW 3G operation */
3488 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3489 tdata->cipher_iv.len,
3490 tdata->validCipherLenInBits.len,
3495 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3497 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3499 ut_params->obuf = ut_params->op->sym->m_dst;
3500 if (ut_params->obuf)
3501 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3503 ciphertext = plaintext;
3505 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3508 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3510 tdata->ciphertext.data,
3511 tdata->validDataLenInBits.len,
3512 "SNOW 3G Ciphertext data not as expected");
3517 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3519 struct crypto_testsuite_params *ts_params = &testsuite_params;
3520 struct crypto_unittest_params *ut_params = &unittest_params;
3523 unsigned int plaintext_pad_len;
3524 unsigned int plaintext_len;
3525 uint8_t buffer[10000];
3526 const uint8_t *ciphertext;
3528 struct rte_cryptodev_info dev_info;
3530 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3531 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3532 printf("Device doesn't support scatter-gather. "
3537 /* Create SNOW 3G session */
3538 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3539 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3540 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3541 tdata->key.data, tdata->key.len,
3542 tdata->cipher_iv.len);
3546 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3547 /* Append data which is padded to a multiple of */
3548 /* the algorithms block size */
3549 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3551 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3552 plaintext_pad_len, 10, 0);
3553 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3554 plaintext_pad_len, 3, 0);
3556 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3557 "Failed to allocate input buffer in mempool");
3558 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3559 "Failed to allocate output buffer in mempool");
3561 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3563 /* Create SNOW 3G operation */
3564 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3565 tdata->cipher_iv.len,
3566 tdata->validCipherLenInBits.len,
3571 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3573 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3575 ut_params->obuf = ut_params->op->sym->m_dst;
3576 if (ut_params->obuf)
3577 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3578 plaintext_len, buffer);
3580 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3581 plaintext_len, buffer);
3583 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3586 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3588 tdata->ciphertext.data,
3589 tdata->validDataLenInBits.len,
3590 "SNOW 3G Ciphertext data not as expected");
3595 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3597 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3599 uint8_t curr_byte, prev_byte;
3600 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3601 uint8_t lower_byte_mask = (1 << offset) - 1;
3604 prev_byte = buffer[0];
3605 buffer[0] >>= offset;
3607 for (i = 1; i < length_in_bytes; i++) {
3608 curr_byte = buffer[i];
3609 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3610 (curr_byte >> offset);
3611 prev_byte = curr_byte;
3616 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3618 struct crypto_testsuite_params *ts_params = &testsuite_params;
3619 struct crypto_unittest_params *ut_params = &unittest_params;
3620 uint8_t *plaintext, *ciphertext;
3622 uint32_t plaintext_len;
3623 uint32_t plaintext_pad_len;
3624 uint8_t extra_offset = 4;
3625 uint8_t *expected_ciphertext_shifted;
3627 /* Create SNOW 3G session */
3628 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3629 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3630 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3631 tdata->key.data, tdata->key.len,
3632 tdata->cipher_iv.len);
3636 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3639 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3640 "Failed to allocate input buffer in mempool");
3641 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3642 "Failed to allocate output buffer in mempool");
3644 /* Clear mbuf payload */
3645 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3646 rte_pktmbuf_tailroom(ut_params->ibuf));
3648 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3650 * Append data which is padded to a
3651 * multiple of the algorithms block size
3653 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3655 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3658 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3660 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3661 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3663 #ifdef RTE_APP_TEST_DEBUG
3664 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3666 /* Create SNOW 3G operation */
3667 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3668 tdata->cipher_iv.len,
3669 tdata->validCipherLenInBits.len,
3674 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3676 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3678 ut_params->obuf = ut_params->op->sym->m_dst;
3679 if (ut_params->obuf)
3680 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3682 ciphertext = plaintext;
3684 #ifdef RTE_APP_TEST_DEBUG
3685 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3688 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3690 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3691 "failed to reserve memory for ciphertext shifted\n");
3693 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3694 ceil_byte_length(tdata->ciphertext.len));
3695 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3698 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3700 expected_ciphertext_shifted,
3701 tdata->validDataLenInBits.len,
3703 "SNOW 3G Ciphertext data not as expected");
3707 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3709 struct crypto_testsuite_params *ts_params = &testsuite_params;
3710 struct crypto_unittest_params *ut_params = &unittest_params;
3714 uint8_t *plaintext, *ciphertext;
3715 unsigned ciphertext_pad_len;
3716 unsigned ciphertext_len;
3718 /* Create SNOW 3G session */
3719 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3720 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3721 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3722 tdata->key.data, tdata->key.len,
3723 tdata->cipher_iv.len);
3727 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3729 /* Clear mbuf payload */
3730 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3731 rte_pktmbuf_tailroom(ut_params->ibuf));
3733 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3734 /* Append data which is padded to a multiple of */
3735 /* the algorithms block size */
3736 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3737 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3738 ciphertext_pad_len);
3739 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3741 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3743 /* Create SNOW 3G operation */
3744 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3745 tdata->cipher_iv.len,
3746 tdata->validCipherLenInBits.len,
3751 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3753 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3754 ut_params->obuf = ut_params->op->sym->m_dst;
3755 if (ut_params->obuf)
3756 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3758 plaintext = ciphertext;
3760 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3763 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3764 tdata->plaintext.data,
3765 tdata->validDataLenInBits.len,
3766 "SNOW 3G Plaintext data not as expected");
3770 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3772 struct crypto_testsuite_params *ts_params = &testsuite_params;
3773 struct crypto_unittest_params *ut_params = &unittest_params;
3777 uint8_t *plaintext, *ciphertext;
3778 unsigned ciphertext_pad_len;
3779 unsigned ciphertext_len;
3781 /* Create SNOW 3G session */
3782 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3783 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3784 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3785 tdata->key.data, tdata->key.len,
3786 tdata->cipher_iv.len);
3790 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3791 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3793 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3794 "Failed to allocate input buffer");
3795 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3796 "Failed to allocate output buffer");
3798 /* Clear mbuf payload */
3799 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3800 rte_pktmbuf_tailroom(ut_params->ibuf));
3802 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3803 rte_pktmbuf_tailroom(ut_params->obuf));
3805 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3806 /* Append data which is padded to a multiple of */
3807 /* the algorithms block size */
3808 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3809 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3810 ciphertext_pad_len);
3811 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3812 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3814 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3816 /* Create SNOW 3G operation */
3817 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3818 tdata->cipher_iv.len,
3819 tdata->validCipherLenInBits.len,
3824 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3826 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3827 ut_params->obuf = ut_params->op->sym->m_dst;
3828 if (ut_params->obuf)
3829 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3831 plaintext = ciphertext;
3833 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3836 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3837 tdata->plaintext.data,
3838 tdata->validDataLenInBits.len,
3839 "SNOW 3G Plaintext data not as expected");
3844 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3846 struct crypto_testsuite_params *ts_params = &testsuite_params;
3847 struct crypto_unittest_params *ut_params = &unittest_params;
3851 uint8_t *plaintext, *ciphertext;
3852 unsigned int plaintext_pad_len;
3853 unsigned int plaintext_len;
3855 struct rte_cryptodev_sym_capability_idx cap_idx;
3857 /* Check if device supports ZUC EEA3 */
3858 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3859 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3861 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3865 /* Check if device supports ZUC EIA3 */
3866 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3867 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3869 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3873 /* Create ZUC session */
3874 retval = create_zuc_cipher_auth_encrypt_generate_session(
3875 ts_params->valid_devs[0],
3879 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3881 /* clear mbuf payload */
3882 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3883 rte_pktmbuf_tailroom(ut_params->ibuf));
3885 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3886 /* Append data which is padded to a multiple of */
3887 /* the algorithms block size */
3888 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3889 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3891 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3893 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3895 /* Create ZUC operation */
3896 retval = create_zuc_cipher_hash_generate_operation(tdata);
3900 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3902 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3903 ut_params->obuf = ut_params->op->sym->m_src;
3904 if (ut_params->obuf)
3905 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3907 ciphertext = plaintext;
3909 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3911 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3913 tdata->ciphertext.data,
3914 tdata->validDataLenInBits.len,
3915 "ZUC Ciphertext data not as expected");
3917 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3918 + plaintext_pad_len;
3921 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3925 "ZUC Generated auth tag not as expected");
3930 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3932 struct crypto_testsuite_params *ts_params = &testsuite_params;
3933 struct crypto_unittest_params *ut_params = &unittest_params;
3937 uint8_t *plaintext, *ciphertext;
3938 unsigned plaintext_pad_len;
3939 unsigned plaintext_len;
3941 /* Create SNOW 3G session */
3942 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3943 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3944 RTE_CRYPTO_AUTH_OP_GENERATE,
3945 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3946 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3947 tdata->key.data, tdata->key.len,
3948 tdata->auth_iv.len, tdata->digest.len,
3949 tdata->cipher_iv.len);
3952 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3954 /* clear mbuf payload */
3955 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3956 rte_pktmbuf_tailroom(ut_params->ibuf));
3958 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3959 /* Append data which is padded to a multiple of */
3960 /* the algorithms block size */
3961 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3962 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3964 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3966 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3968 /* Create SNOW 3G operation */
3969 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3970 tdata->digest.len, tdata->auth_iv.data,
3972 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3973 tdata->cipher_iv.data, tdata->cipher_iv.len,
3974 tdata->validCipherLenInBits.len,
3976 tdata->validAuthLenInBits.len,
3982 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3984 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3985 ut_params->obuf = ut_params->op->sym->m_src;
3986 if (ut_params->obuf)
3987 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3989 ciphertext = plaintext;
3991 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3993 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3995 tdata->ciphertext.data,
3996 tdata->validDataLenInBits.len,
3997 "SNOW 3G Ciphertext data not as expected");
3999 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4000 + plaintext_pad_len;
4003 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4006 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4007 "SNOW 3G Generated auth tag not as expected");
4011 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4013 struct crypto_testsuite_params *ts_params = &testsuite_params;
4014 struct crypto_unittest_params *ut_params = &unittest_params;
4018 uint8_t *plaintext, *ciphertext;
4019 unsigned plaintext_pad_len;
4020 unsigned plaintext_len;
4022 /* Create SNOW 3G session */
4023 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4024 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4025 RTE_CRYPTO_AUTH_OP_GENERATE,
4026 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4027 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4028 tdata->key.data, tdata->key.len,
4029 tdata->auth_iv.len, tdata->digest.len,
4030 tdata->cipher_iv.len);
4034 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 /* clear mbuf payload */
4037 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4038 rte_pktmbuf_tailroom(ut_params->ibuf));
4040 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4041 /* Append data which is padded to a multiple of */
4042 /* the algorithms block size */
4043 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4044 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4046 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4048 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4050 /* Create SNOW 3G operation */
4051 retval = create_wireless_algo_auth_cipher_operation(
4053 tdata->cipher_iv.data, tdata->cipher_iv.len,
4054 tdata->auth_iv.data, tdata->auth_iv.len,
4056 tdata->validCipherLenInBits.len,
4058 tdata->validAuthLenInBits.len,
4064 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4066 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4067 ut_params->obuf = ut_params->op->sym->m_src;
4068 if (ut_params->obuf)
4069 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4071 ciphertext = plaintext;
4073 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4074 + plaintext_pad_len;
4075 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4078 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4080 tdata->ciphertext.data,
4081 tdata->validDataLenInBits.len,
4082 "SNOW 3G Ciphertext data not as expected");
4085 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4088 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4089 "SNOW 3G Generated auth tag not as expected");
4094 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4096 struct crypto_testsuite_params *ts_params = &testsuite_params;
4097 struct crypto_unittest_params *ut_params = &unittest_params;
4101 uint8_t *plaintext, *ciphertext;
4102 unsigned plaintext_pad_len;
4103 unsigned plaintext_len;
4105 /* Create KASUMI session */
4106 retval = create_wireless_algo_auth_cipher_session(
4107 ts_params->valid_devs[0],
4108 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4109 RTE_CRYPTO_AUTH_OP_GENERATE,
4110 RTE_CRYPTO_AUTH_KASUMI_F9,
4111 RTE_CRYPTO_CIPHER_KASUMI_F8,
4112 tdata->key.data, tdata->key.len,
4113 0, tdata->digest.len,
4114 tdata->cipher_iv.len);
4117 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4119 /* clear mbuf payload */
4120 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4121 rte_pktmbuf_tailroom(ut_params->ibuf));
4123 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4124 /* Append data which is padded to a multiple of */
4125 /* the algorithms block size */
4126 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4127 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4129 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4131 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4133 /* Create KASUMI operation */
4134 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4135 tdata->cipher_iv.data, tdata->cipher_iv.len,
4138 tdata->validCipherLenInBits.len,
4139 tdata->validCipherOffsetInBits.len,
4140 tdata->validAuthLenInBits.len,
4147 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4149 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4150 if (ut_params->op->sym->m_dst)
4151 ut_params->obuf = ut_params->op->sym->m_dst;
4153 ut_params->obuf = ut_params->op->sym->m_src;
4155 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4156 tdata->validCipherOffsetInBits.len >> 3);
4158 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4159 (tdata->validCipherOffsetInBits.len >> 3);
4161 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4163 reference_ciphertext,
4164 tdata->validCipherLenInBits.len,
4165 "KASUMI Ciphertext data not as expected");
4166 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4167 + plaintext_pad_len;
4170 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4173 DIGEST_BYTE_LENGTH_KASUMI_F9,
4174 "KASUMI Generated auth tag not as expected");
4179 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4181 struct crypto_testsuite_params *ts_params = &testsuite_params;
4182 struct crypto_unittest_params *ut_params = &unittest_params;
4186 uint8_t *plaintext, *ciphertext;
4187 unsigned plaintext_pad_len;
4188 unsigned plaintext_len;
4190 /* Create KASUMI session */
4191 retval = create_wireless_algo_cipher_auth_session(
4192 ts_params->valid_devs[0],
4193 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4194 RTE_CRYPTO_AUTH_OP_GENERATE,
4195 RTE_CRYPTO_AUTH_KASUMI_F9,
4196 RTE_CRYPTO_CIPHER_KASUMI_F8,
4197 tdata->key.data, tdata->key.len,
4198 0, tdata->digest.len,
4199 tdata->cipher_iv.len);
4203 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4205 /* clear mbuf payload */
4206 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4207 rte_pktmbuf_tailroom(ut_params->ibuf));
4209 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4210 /* Append data which is padded to a multiple of */
4211 /* the algorithms block size */
4212 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4213 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4215 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4217 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4219 /* Create KASUMI operation */
4220 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4221 tdata->digest.len, NULL, 0,
4222 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4223 tdata->cipher_iv.data, tdata->cipher_iv.len,
4224 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4225 tdata->validCipherOffsetInBits.len,
4226 tdata->validAuthLenInBits.len,
4232 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4234 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4236 if (ut_params->op->sym->m_dst)
4237 ut_params->obuf = ut_params->op->sym->m_dst;
4239 ut_params->obuf = ut_params->op->sym->m_src;
4241 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4242 tdata->validCipherOffsetInBits.len >> 3);
4244 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4245 + plaintext_pad_len;
4247 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4248 (tdata->validCipherOffsetInBits.len >> 3);
4250 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4252 reference_ciphertext,
4253 tdata->validCipherLenInBits.len,
4254 "KASUMI Ciphertext data not as expected");
4257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4260 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4261 "KASUMI Generated auth tag not as expected");
4266 test_zuc_encryption(const struct wireless_test_data *tdata)
4268 struct crypto_testsuite_params *ts_params = &testsuite_params;
4269 struct crypto_unittest_params *ut_params = &unittest_params;
4272 uint8_t *plaintext, *ciphertext;
4273 unsigned plaintext_pad_len;
4274 unsigned plaintext_len;
4276 struct rte_cryptodev_sym_capability_idx cap_idx;
4278 /* Check if device supports ZUC EEA3 */
4279 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4280 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4282 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4286 /* Create ZUC session */
4287 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4288 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4289 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4290 tdata->key.data, tdata->key.len,
4291 tdata->cipher_iv.len);
4295 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4297 /* Clear mbuf payload */
4298 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4299 rte_pktmbuf_tailroom(ut_params->ibuf));
4301 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4302 /* Append data which is padded to a multiple */
4303 /* of the algorithms block size */
4304 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4305 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4307 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4309 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4311 /* Create ZUC operation */
4312 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4313 tdata->cipher_iv.len,
4314 tdata->plaintext.len,
4319 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4321 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4323 ut_params->obuf = ut_params->op->sym->m_dst;
4324 if (ut_params->obuf)
4325 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4327 ciphertext = plaintext;
4329 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4332 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4334 tdata->ciphertext.data,
4335 tdata->validCipherLenInBits.len,
4336 "ZUC Ciphertext data not as expected");
4341 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4343 struct crypto_testsuite_params *ts_params = &testsuite_params;
4344 struct crypto_unittest_params *ut_params = &unittest_params;
4348 unsigned int plaintext_pad_len;
4349 unsigned int plaintext_len;
4350 const uint8_t *ciphertext;
4351 uint8_t ciphertext_buffer[2048];
4352 struct rte_cryptodev_info dev_info;
4354 struct rte_cryptodev_sym_capability_idx cap_idx;
4356 /* Check if device supports ZUC EEA3 */
4357 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4358 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4360 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4364 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4365 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4366 printf("Device doesn't support scatter-gather. "
4371 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4373 /* Append data which is padded to a multiple */
4374 /* of the algorithms block size */
4375 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4377 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4378 plaintext_pad_len, 10, 0);
4380 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4381 tdata->plaintext.data);
4383 /* Create ZUC session */
4384 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4385 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4386 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4387 tdata->key.data, tdata->key.len,
4388 tdata->cipher_iv.len);
4392 /* Clear mbuf payload */
4394 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4396 /* Create ZUC operation */
4397 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4398 tdata->cipher_iv.len, tdata->plaintext.len,
4403 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4405 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4407 ut_params->obuf = ut_params->op->sym->m_dst;
4408 if (ut_params->obuf)
4409 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4410 0, plaintext_len, ciphertext_buffer);
4412 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4413 0, plaintext_len, ciphertext_buffer);
4416 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4419 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4421 tdata->ciphertext.data,
4422 tdata->validCipherLenInBits.len,
4423 "ZUC Ciphertext data not as expected");
4429 test_zuc_authentication(const struct wireless_test_data *tdata)
4431 struct crypto_testsuite_params *ts_params = &testsuite_params;
4432 struct crypto_unittest_params *ut_params = &unittest_params;
4435 unsigned plaintext_pad_len;
4436 unsigned plaintext_len;
4439 struct rte_cryptodev_sym_capability_idx cap_idx;
4441 /* Check if device supports ZUC EIA3 */
4442 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4443 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4445 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4449 /* Create ZUC session */
4450 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4451 tdata->key.data, tdata->key.len,
4452 tdata->auth_iv.len, tdata->digest.len,
4453 RTE_CRYPTO_AUTH_OP_GENERATE,
4454 RTE_CRYPTO_AUTH_ZUC_EIA3);
4458 /* alloc mbuf and set payload */
4459 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4461 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4462 rte_pktmbuf_tailroom(ut_params->ibuf));
4464 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4465 /* Append data which is padded to a multiple of */
4466 /* the algorithms block size */
4467 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4468 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4470 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4472 /* Create ZUC operation */
4473 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4474 tdata->auth_iv.data, tdata->auth_iv.len,
4475 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4476 tdata->validAuthLenInBits.len,
4481 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4483 ut_params->obuf = ut_params->op->sym->m_src;
4484 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4485 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4486 + plaintext_pad_len;
4489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4492 DIGEST_BYTE_LENGTH_KASUMI_F9,
4493 "ZUC Generated auth tag not as expected");
4499 test_kasumi_encryption_test_case_1(void)
4501 return test_kasumi_encryption(&kasumi_test_case_1);
4505 test_kasumi_encryption_test_case_1_sgl(void)
4507 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4511 test_kasumi_encryption_test_case_1_oop(void)
4513 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4517 test_kasumi_encryption_test_case_1_oop_sgl(void)
4519 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4523 test_kasumi_encryption_test_case_2(void)
4525 return test_kasumi_encryption(&kasumi_test_case_2);
4529 test_kasumi_encryption_test_case_3(void)
4531 return test_kasumi_encryption(&kasumi_test_case_3);
4535 test_kasumi_encryption_test_case_4(void)
4537 return test_kasumi_encryption(&kasumi_test_case_4);
4541 test_kasumi_encryption_test_case_5(void)
4543 return test_kasumi_encryption(&kasumi_test_case_5);
4547 test_kasumi_decryption_test_case_1(void)
4549 return test_kasumi_decryption(&kasumi_test_case_1);
4553 test_kasumi_decryption_test_case_1_oop(void)
4555 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4559 test_kasumi_decryption_test_case_2(void)
4561 return test_kasumi_decryption(&kasumi_test_case_2);
4565 test_kasumi_decryption_test_case_3(void)
4567 return test_kasumi_decryption(&kasumi_test_case_3);
4571 test_kasumi_decryption_test_case_4(void)
4573 return test_kasumi_decryption(&kasumi_test_case_4);
4577 test_kasumi_decryption_test_case_5(void)
4579 return test_kasumi_decryption(&kasumi_test_case_5);
4582 test_snow3g_encryption_test_case_1(void)
4584 return test_snow3g_encryption(&snow3g_test_case_1);
4588 test_snow3g_encryption_test_case_1_oop(void)
4590 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4594 test_snow3g_encryption_test_case_1_oop_sgl(void)
4596 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4601 test_snow3g_encryption_test_case_1_offset_oop(void)
4603 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4607 test_snow3g_encryption_test_case_2(void)
4609 return test_snow3g_encryption(&snow3g_test_case_2);
4613 test_snow3g_encryption_test_case_3(void)
4615 return test_snow3g_encryption(&snow3g_test_case_3);
4619 test_snow3g_encryption_test_case_4(void)
4621 return test_snow3g_encryption(&snow3g_test_case_4);
4625 test_snow3g_encryption_test_case_5(void)
4627 return test_snow3g_encryption(&snow3g_test_case_5);
4631 test_snow3g_decryption_test_case_1(void)
4633 return test_snow3g_decryption(&snow3g_test_case_1);
4637 test_snow3g_decryption_test_case_1_oop(void)
4639 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4643 test_snow3g_decryption_test_case_2(void)
4645 return test_snow3g_decryption(&snow3g_test_case_2);
4649 test_snow3g_decryption_test_case_3(void)
4651 return test_snow3g_decryption(&snow3g_test_case_3);
4655 test_snow3g_decryption_test_case_4(void)
4657 return test_snow3g_decryption(&snow3g_test_case_4);
4661 test_snow3g_decryption_test_case_5(void)
4663 return test_snow3g_decryption(&snow3g_test_case_5);
4666 test_snow3g_cipher_auth_test_case_1(void)
4668 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4672 test_snow3g_auth_cipher_test_case_1(void)
4674 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4678 test_kasumi_auth_cipher_test_case_1(void)
4680 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4684 test_kasumi_cipher_auth_test_case_1(void)
4686 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4690 test_zuc_encryption_test_case_1(void)
4692 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4696 test_zuc_encryption_test_case_2(void)
4698 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4702 test_zuc_encryption_test_case_3(void)
4704 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4708 test_zuc_encryption_test_case_4(void)
4710 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4714 test_zuc_encryption_test_case_5(void)
4716 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4720 test_zuc_encryption_test_case_6_sgl(void)
4722 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4726 test_zuc_hash_generate_test_case_1(void)
4728 return test_zuc_authentication(&zuc_test_case_auth_1b);
4732 test_zuc_hash_generate_test_case_2(void)
4734 return test_zuc_authentication(&zuc_test_case_auth_90b);
4738 test_zuc_hash_generate_test_case_3(void)
4740 return test_zuc_authentication(&zuc_test_case_auth_577b);
4744 test_zuc_hash_generate_test_case_4(void)
4746 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4750 test_zuc_hash_generate_test_case_5(void)
4752 return test_zuc_authentication(&zuc_test_auth_5670b);
4756 test_zuc_hash_generate_test_case_6(void)
4758 return test_zuc_authentication(&zuc_test_case_auth_128b);
4762 test_zuc_hash_generate_test_case_7(void)
4764 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4768 test_zuc_hash_generate_test_case_8(void)
4770 return test_zuc_authentication(&zuc_test_case_auth_584b);
4774 test_zuc_cipher_auth_test_case_1(void)
4776 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4780 test_zuc_cipher_auth_test_case_2(void)
4782 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4786 test_3DES_chain_qat_all(void)
4788 struct crypto_testsuite_params *ts_params = &testsuite_params;
4791 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4792 ts_params->op_mpool,
4793 ts_params->session_mpool,
4794 ts_params->valid_devs[0],
4795 rte_cryptodev_driver_id_get(
4796 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4797 BLKCIPHER_3DES_CHAIN_TYPE);
4799 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4801 return TEST_SUCCESS;
4805 test_DES_cipheronly_qat_all(void)
4807 struct crypto_testsuite_params *ts_params = &testsuite_params;
4810 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4811 ts_params->op_mpool,
4812 ts_params->session_mpool,
4813 ts_params->valid_devs[0],
4814 rte_cryptodev_driver_id_get(
4815 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4816 BLKCIPHER_DES_CIPHERONLY_TYPE);
4818 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4820 return TEST_SUCCESS;
4824 test_DES_cipheronly_openssl_all(void)
4826 struct crypto_testsuite_params *ts_params = &testsuite_params;
4829 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4830 ts_params->op_mpool,
4831 ts_params->session_mpool,
4832 ts_params->valid_devs[0],
4833 rte_cryptodev_driver_id_get(
4834 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4835 BLKCIPHER_DES_CIPHERONLY_TYPE);
4837 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4839 return TEST_SUCCESS;
4843 test_DES_docsis_openssl_all(void)
4845 struct crypto_testsuite_params *ts_params = &testsuite_params;
4848 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4849 ts_params->op_mpool,
4850 ts_params->session_mpool,
4851 ts_params->valid_devs[0],
4852 rte_cryptodev_driver_id_get(
4853 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4854 BLKCIPHER_DES_DOCSIS_TYPE);
4856 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4858 return TEST_SUCCESS;
4862 test_DES_cipheronly_mb_all(void)
4864 struct crypto_testsuite_params *ts_params = &testsuite_params;
4867 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4868 ts_params->op_mpool,
4869 ts_params->session_mpool,
4870 ts_params->valid_devs[0],
4871 rte_cryptodev_driver_id_get(
4872 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4873 BLKCIPHER_DES_CIPHERONLY_TYPE);
4875 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4877 return TEST_SUCCESS;
4881 test_DES_docsis_mb_all(void)
4883 struct crypto_testsuite_params *ts_params = &testsuite_params;
4886 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4887 ts_params->op_mpool,
4888 ts_params->session_mpool,
4889 ts_params->valid_devs[0],
4890 rte_cryptodev_driver_id_get(
4891 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4892 BLKCIPHER_DES_DOCSIS_TYPE);
4894 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4896 return TEST_SUCCESS;
4900 test_3DES_chain_dpaa_sec_all(void)
4902 struct crypto_testsuite_params *ts_params = &testsuite_params;
4905 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4906 ts_params->op_mpool,
4907 ts_params->session_mpool,
4908 ts_params->valid_devs[0],
4909 rte_cryptodev_driver_id_get(
4910 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4911 BLKCIPHER_3DES_CHAIN_TYPE);
4913 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4915 return TEST_SUCCESS;
4919 test_3DES_cipheronly_dpaa_sec_all(void)
4921 struct crypto_testsuite_params *ts_params = &testsuite_params;
4924 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4925 ts_params->op_mpool,
4926 ts_params->session_mpool,
4927 ts_params->valid_devs[0],
4928 rte_cryptodev_driver_id_get(
4929 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4930 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4932 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4934 return TEST_SUCCESS;
4938 test_3DES_chain_dpaa2_sec_all(void)
4940 struct crypto_testsuite_params *ts_params = &testsuite_params;
4943 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4944 ts_params->op_mpool,
4945 ts_params->session_mpool,
4946 ts_params->valid_devs[0],
4947 rte_cryptodev_driver_id_get(
4948 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4949 BLKCIPHER_3DES_CHAIN_TYPE);
4951 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4953 return TEST_SUCCESS;
4957 test_3DES_cipheronly_dpaa2_sec_all(void)
4959 struct crypto_testsuite_params *ts_params = &testsuite_params;
4962 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4963 ts_params->op_mpool,
4964 ts_params->session_mpool,
4965 ts_params->valid_devs[0],
4966 rte_cryptodev_driver_id_get(
4967 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4968 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4970 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4972 return TEST_SUCCESS;
4976 test_3DES_cipheronly_qat_all(void)
4978 struct crypto_testsuite_params *ts_params = &testsuite_params;
4981 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4982 ts_params->op_mpool,
4983 ts_params->session_mpool,
4984 ts_params->valid_devs[0],
4985 rte_cryptodev_driver_id_get(
4986 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4987 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4989 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4991 return TEST_SUCCESS;
4995 test_3DES_chain_openssl_all(void)
4997 struct crypto_testsuite_params *ts_params = &testsuite_params;
5000 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5001 ts_params->op_mpool,
5002 ts_params->session_mpool,
5003 ts_params->valid_devs[0],
5004 rte_cryptodev_driver_id_get(
5005 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5006 BLKCIPHER_3DES_CHAIN_TYPE);
5008 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5010 return TEST_SUCCESS;
5014 test_3DES_cipheronly_openssl_all(void)
5016 struct crypto_testsuite_params *ts_params = &testsuite_params;
5019 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5020 ts_params->op_mpool,
5021 ts_params->session_mpool,
5022 ts_params->valid_devs[0],
5023 rte_cryptodev_driver_id_get(
5024 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5025 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5027 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5029 return TEST_SUCCESS;
5032 /* ***** AEAD algorithm Tests ***** */
5035 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5036 enum rte_crypto_aead_operation op,
5037 const uint8_t *key, const uint8_t key_len,
5038 const uint16_t aad_len, const uint8_t auth_len,
5041 uint8_t aead_key[key_len];
5043 struct crypto_testsuite_params *ts_params = &testsuite_params;
5044 struct crypto_unittest_params *ut_params = &unittest_params;
5046 memcpy(aead_key, key, key_len);
5048 /* Setup AEAD Parameters */
5049 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5050 ut_params->aead_xform.next = NULL;
5051 ut_params->aead_xform.aead.algo = algo;
5052 ut_params->aead_xform.aead.op = op;
5053 ut_params->aead_xform.aead.key.data = aead_key;
5054 ut_params->aead_xform.aead.key.length = key_len;
5055 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5056 ut_params->aead_xform.aead.iv.length = iv_len;
5057 ut_params->aead_xform.aead.digest_length = auth_len;
5058 ut_params->aead_xform.aead.aad_length = aad_len;
5060 debug_hexdump(stdout, "key:", key, key_len);
5062 /* Create Crypto session*/
5063 ut_params->sess = rte_cryptodev_sym_session_create(
5064 ts_params->session_mpool);
5066 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5067 &ut_params->aead_xform, ts_params->session_mpool);
5069 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5075 create_aead_xform(struct rte_crypto_op *op,
5076 enum rte_crypto_aead_algorithm algo,
5077 enum rte_crypto_aead_operation aead_op,
5078 uint8_t *key, const uint8_t key_len,
5079 const uint8_t aad_len, const uint8_t auth_len,
5082 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5083 "failed to allocate space for crypto transform");
5085 struct rte_crypto_sym_op *sym_op = op->sym;
5087 /* Setup AEAD Parameters */
5088 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5089 sym_op->xform->next = NULL;
5090 sym_op->xform->aead.algo = algo;
5091 sym_op->xform->aead.op = aead_op;
5092 sym_op->xform->aead.key.data = key;
5093 sym_op->xform->aead.key.length = key_len;
5094 sym_op->xform->aead.iv.offset = IV_OFFSET;
5095 sym_op->xform->aead.iv.length = iv_len;
5096 sym_op->xform->aead.digest_length = auth_len;
5097 sym_op->xform->aead.aad_length = aad_len;
5099 debug_hexdump(stdout, "key:", key, key_len);
5105 create_aead_operation(enum rte_crypto_aead_operation op,
5106 const struct aead_test_data *tdata)
5108 struct crypto_testsuite_params *ts_params = &testsuite_params;
5109 struct crypto_unittest_params *ut_params = &unittest_params;
5111 uint8_t *plaintext, *ciphertext;
5112 unsigned int aad_pad_len, plaintext_pad_len;
5114 /* Generate Crypto op data structure */
5115 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5116 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5117 TEST_ASSERT_NOT_NULL(ut_params->op,
5118 "Failed to allocate symmetric crypto operation struct");
5120 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5122 /* Append aad data */
5123 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5124 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5125 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5127 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5128 "no room to append aad");
5130 sym_op->aead.aad.phys_addr =
5131 rte_pktmbuf_iova(ut_params->ibuf);
5132 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5133 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5134 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5137 /* Append IV at the end of the crypto operation*/
5138 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5139 uint8_t *, IV_OFFSET);
5141 /* Copy IV 1 byte after the IV pointer, according to the API */
5142 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5143 debug_hexdump(stdout, "iv:", iv_ptr,
5146 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5147 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5149 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5150 "no room to append aad");
5152 sym_op->aead.aad.phys_addr =
5153 rte_pktmbuf_iova(ut_params->ibuf);
5154 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5155 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5158 /* Append IV at the end of the crypto operation*/
5159 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5160 uint8_t *, IV_OFFSET);
5162 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5163 debug_hexdump(stdout, "iv:", iv_ptr,
5167 /* Append plaintext/ciphertext */
5168 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5169 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5170 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5172 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5174 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5175 debug_hexdump(stdout, "plaintext:", plaintext,
5176 tdata->plaintext.len);
5178 if (ut_params->obuf) {
5179 ciphertext = (uint8_t *)rte_pktmbuf_append(
5181 plaintext_pad_len + aad_pad_len);
5182 TEST_ASSERT_NOT_NULL(ciphertext,
5183 "no room to append ciphertext");
5185 memset(ciphertext + aad_pad_len, 0,
5186 tdata->ciphertext.len);
5189 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5190 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5192 TEST_ASSERT_NOT_NULL(ciphertext,
5193 "no room to append ciphertext");
5195 memcpy(ciphertext, tdata->ciphertext.data,
5196 tdata->ciphertext.len);
5197 debug_hexdump(stdout, "ciphertext:", ciphertext,
5198 tdata->ciphertext.len);
5200 if (ut_params->obuf) {
5201 plaintext = (uint8_t *)rte_pktmbuf_append(
5203 plaintext_pad_len + aad_pad_len);
5204 TEST_ASSERT_NOT_NULL(plaintext,
5205 "no room to append plaintext");
5207 memset(plaintext + aad_pad_len, 0,
5208 tdata->plaintext.len);
5212 /* Append digest data */
5213 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5214 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5215 ut_params->obuf ? ut_params->obuf :
5217 tdata->auth_tag.len);
5218 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5219 "no room to append digest");
5220 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5221 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5222 ut_params->obuf ? ut_params->obuf :
5227 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5228 ut_params->ibuf, tdata->auth_tag.len);
5229 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5230 "no room to append digest");
5231 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5233 plaintext_pad_len + aad_pad_len);
5235 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5236 tdata->auth_tag.len);
5237 debug_hexdump(stdout, "digest:",
5238 sym_op->aead.digest.data,
5239 tdata->auth_tag.len);
5242 sym_op->aead.data.length = tdata->plaintext.len;
5243 sym_op->aead.data.offset = aad_pad_len;
5249 test_authenticated_encryption(const struct aead_test_data *tdata)
5251 struct crypto_testsuite_params *ts_params = &testsuite_params;
5252 struct crypto_unittest_params *ut_params = &unittest_params;
5255 uint8_t *ciphertext, *auth_tag;
5256 uint16_t plaintext_pad_len;
5259 /* Create AEAD session */
5260 retval = create_aead_session(ts_params->valid_devs[0],
5262 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5263 tdata->key.data, tdata->key.len,
5264 tdata->aad.len, tdata->auth_tag.len,
5269 if (tdata->aad.len > MBUF_SIZE) {
5270 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5271 /* Populate full size of add data */
5272 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5273 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5277 /* clear mbuf payload */
5278 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5279 rte_pktmbuf_tailroom(ut_params->ibuf));
5281 /* Create AEAD operation */
5282 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5286 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5288 ut_params->op->sym->m_src = ut_params->ibuf;
5290 /* Process crypto operation */
5291 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5292 ut_params->op), "failed to process sym crypto op");
5294 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5295 "crypto op processing failed");
5297 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5299 if (ut_params->op->sym->m_dst) {
5300 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5302 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5303 uint8_t *, plaintext_pad_len);
5305 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5307 ut_params->op->sym->cipher.data.offset);
5308 auth_tag = ciphertext + plaintext_pad_len;
5311 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5312 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5315 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5317 tdata->ciphertext.data,
5318 tdata->ciphertext.len,
5319 "Ciphertext data not as expected");
5321 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5323 tdata->auth_tag.data,
5324 tdata->auth_tag.len,
5325 "Generated auth tag not as expected");
5332 test_AES_GCM_authenticated_encryption_test_case_1(void)
5334 return test_authenticated_encryption(&gcm_test_case_1);
5338 test_AES_GCM_authenticated_encryption_test_case_2(void)
5340 return test_authenticated_encryption(&gcm_test_case_2);
5344 test_AES_GCM_authenticated_encryption_test_case_3(void)
5346 return test_authenticated_encryption(&gcm_test_case_3);
5350 test_AES_GCM_authenticated_encryption_test_case_4(void)
5352 return test_authenticated_encryption(&gcm_test_case_4);
5356 test_AES_GCM_authenticated_encryption_test_case_5(void)
5358 return test_authenticated_encryption(&gcm_test_case_5);
5362 test_AES_GCM_authenticated_encryption_test_case_6(void)
5364 return test_authenticated_encryption(&gcm_test_case_6);
5368 test_AES_GCM_authenticated_encryption_test_case_7(void)
5370 return test_authenticated_encryption(&gcm_test_case_7);
5374 test_AES_GCM_auth_encryption_test_case_192_1(void)
5376 return test_authenticated_encryption(&gcm_test_case_192_1);
5380 test_AES_GCM_auth_encryption_test_case_192_2(void)
5382 return test_authenticated_encryption(&gcm_test_case_192_2);
5386 test_AES_GCM_auth_encryption_test_case_192_3(void)
5388 return test_authenticated_encryption(&gcm_test_case_192_3);
5392 test_AES_GCM_auth_encryption_test_case_192_4(void)
5394 return test_authenticated_encryption(&gcm_test_case_192_4);
5398 test_AES_GCM_auth_encryption_test_case_192_5(void)
5400 return test_authenticated_encryption(&gcm_test_case_192_5);
5404 test_AES_GCM_auth_encryption_test_case_192_6(void)
5406 return test_authenticated_encryption(&gcm_test_case_192_6);
5410 test_AES_GCM_auth_encryption_test_case_192_7(void)
5412 return test_authenticated_encryption(&gcm_test_case_192_7);
5416 test_AES_GCM_auth_encryption_test_case_256_1(void)
5418 return test_authenticated_encryption(&gcm_test_case_256_1);
5422 test_AES_GCM_auth_encryption_test_case_256_2(void)
5424 return test_authenticated_encryption(&gcm_test_case_256_2);
5428 test_AES_GCM_auth_encryption_test_case_256_3(void)
5430 return test_authenticated_encryption(&gcm_test_case_256_3);
5434 test_AES_GCM_auth_encryption_test_case_256_4(void)
5436 return test_authenticated_encryption(&gcm_test_case_256_4);
5440 test_AES_GCM_auth_encryption_test_case_256_5(void)
5442 return test_authenticated_encryption(&gcm_test_case_256_5);
5446 test_AES_GCM_auth_encryption_test_case_256_6(void)
5448 return test_authenticated_encryption(&gcm_test_case_256_6);
5452 test_AES_GCM_auth_encryption_test_case_256_7(void)
5454 return test_authenticated_encryption(&gcm_test_case_256_7);
5458 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5460 return test_authenticated_encryption(&gcm_test_case_aad_1);
5464 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5466 return test_authenticated_encryption(&gcm_test_case_aad_2);
5470 test_authenticated_decryption(const struct aead_test_data *tdata)
5472 struct crypto_testsuite_params *ts_params = &testsuite_params;
5473 struct crypto_unittest_params *ut_params = &unittest_params;
5479 /* Create AEAD session */
5480 retval = create_aead_session(ts_params->valid_devs[0],
5482 RTE_CRYPTO_AEAD_OP_DECRYPT,
5483 tdata->key.data, tdata->key.len,
5484 tdata->aad.len, tdata->auth_tag.len,
5489 /* alloc mbuf and set payload */
5490 if (tdata->aad.len > MBUF_SIZE) {
5491 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5492 /* Populate full size of add data */
5493 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5494 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5496 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5498 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5499 rte_pktmbuf_tailroom(ut_params->ibuf));
5501 /* Create AEAD operation */
5502 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5506 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5508 ut_params->op->sym->m_src = ut_params->ibuf;
5510 /* Process crypto operation */
5511 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5512 ut_params->op), "failed to process sym crypto op");
5514 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5515 "crypto op processing failed");
5517 if (ut_params->op->sym->m_dst)
5518 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5521 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5523 ut_params->op->sym->cipher.data.offset);
5525 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5528 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5530 tdata->plaintext.data,
5531 tdata->plaintext.len,
5532 "Plaintext data not as expected");
5534 TEST_ASSERT_EQUAL(ut_params->op->status,
5535 RTE_CRYPTO_OP_STATUS_SUCCESS,
5536 "Authentication failed");
5541 test_AES_GCM_authenticated_decryption_test_case_1(void)
5543 return test_authenticated_decryption(&gcm_test_case_1);
5547 test_AES_GCM_authenticated_decryption_test_case_2(void)
5549 return test_authenticated_decryption(&gcm_test_case_2);
5553 test_AES_GCM_authenticated_decryption_test_case_3(void)
5555 return test_authenticated_decryption(&gcm_test_case_3);
5559 test_AES_GCM_authenticated_decryption_test_case_4(void)
5561 return test_authenticated_decryption(&gcm_test_case_4);
5565 test_AES_GCM_authenticated_decryption_test_case_5(void)
5567 return test_authenticated_decryption(&gcm_test_case_5);
5571 test_AES_GCM_authenticated_decryption_test_case_6(void)
5573 return test_authenticated_decryption(&gcm_test_case_6);
5577 test_AES_GCM_authenticated_decryption_test_case_7(void)
5579 return test_authenticated_decryption(&gcm_test_case_7);
5583 test_AES_GCM_auth_decryption_test_case_192_1(void)
5585 return test_authenticated_decryption(&gcm_test_case_192_1);
5589 test_AES_GCM_auth_decryption_test_case_192_2(void)
5591 return test_authenticated_decryption(&gcm_test_case_192_2);
5595 test_AES_GCM_auth_decryption_test_case_192_3(void)
5597 return test_authenticated_decryption(&gcm_test_case_192_3);
5601 test_AES_GCM_auth_decryption_test_case_192_4(void)
5603 return test_authenticated_decryption(&gcm_test_case_192_4);
5607 test_AES_GCM_auth_decryption_test_case_192_5(void)
5609 return test_authenticated_decryption(&gcm_test_case_192_5);
5613 test_AES_GCM_auth_decryption_test_case_192_6(void)
5615 return test_authenticated_decryption(&gcm_test_case_192_6);
5619 test_AES_GCM_auth_decryption_test_case_192_7(void)
5621 return test_authenticated_decryption(&gcm_test_case_192_7);
5625 test_AES_GCM_auth_decryption_test_case_256_1(void)
5627 return test_authenticated_decryption(&gcm_test_case_256_1);
5631 test_AES_GCM_auth_decryption_test_case_256_2(void)
5633 return test_authenticated_decryption(&gcm_test_case_256_2);
5637 test_AES_GCM_auth_decryption_test_case_256_3(void)
5639 return test_authenticated_decryption(&gcm_test_case_256_3);
5643 test_AES_GCM_auth_decryption_test_case_256_4(void)
5645 return test_authenticated_decryption(&gcm_test_case_256_4);
5649 test_AES_GCM_auth_decryption_test_case_256_5(void)
5651 return test_authenticated_decryption(&gcm_test_case_256_5);
5655 test_AES_GCM_auth_decryption_test_case_256_6(void)
5657 return test_authenticated_decryption(&gcm_test_case_256_6);
5661 test_AES_GCM_auth_decryption_test_case_256_7(void)
5663 return test_authenticated_decryption(&gcm_test_case_256_7);
5667 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5669 return test_authenticated_decryption(&gcm_test_case_aad_1);
5673 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5675 return test_authenticated_decryption(&gcm_test_case_aad_2);
5679 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5681 struct crypto_testsuite_params *ts_params = &testsuite_params;
5682 struct crypto_unittest_params *ut_params = &unittest_params;
5685 uint8_t *ciphertext, *auth_tag;
5686 uint16_t plaintext_pad_len;
5688 /* Create AEAD session */
5689 retval = create_aead_session(ts_params->valid_devs[0],
5691 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5692 tdata->key.data, tdata->key.len,
5693 tdata->aad.len, tdata->auth_tag.len,
5698 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5699 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5701 /* clear mbuf payload */
5702 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5703 rte_pktmbuf_tailroom(ut_params->ibuf));
5704 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5705 rte_pktmbuf_tailroom(ut_params->obuf));
5707 /* Create AEAD operation */
5708 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5712 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5714 ut_params->op->sym->m_src = ut_params->ibuf;
5715 ut_params->op->sym->m_dst = ut_params->obuf;
5717 /* Process crypto operation */
5718 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5719 ut_params->op), "failed to process sym crypto op");
5721 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5722 "crypto op processing failed");
5724 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5726 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5727 ut_params->op->sym->cipher.data.offset);
5728 auth_tag = ciphertext + plaintext_pad_len;
5730 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5731 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5734 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5736 tdata->ciphertext.data,
5737 tdata->ciphertext.len,
5738 "Ciphertext data not as expected");
5740 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5742 tdata->auth_tag.data,
5743 tdata->auth_tag.len,
5744 "Generated auth tag not as expected");
5751 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5753 return test_authenticated_encryption_oop(&gcm_test_case_5);
5757 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5759 struct crypto_testsuite_params *ts_params = &testsuite_params;
5760 struct crypto_unittest_params *ut_params = &unittest_params;
5765 /* Create AEAD session */
5766 retval = create_aead_session(ts_params->valid_devs[0],
5768 RTE_CRYPTO_AEAD_OP_DECRYPT,
5769 tdata->key.data, tdata->key.len,
5770 tdata->aad.len, tdata->auth_tag.len,
5775 /* alloc mbuf and set payload */
5776 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5777 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5779 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5780 rte_pktmbuf_tailroom(ut_params->ibuf));
5781 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5782 rte_pktmbuf_tailroom(ut_params->obuf));
5784 /* Create AEAD operation */
5785 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5789 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5791 ut_params->op->sym->m_src = ut_params->ibuf;
5792 ut_params->op->sym->m_dst = ut_params->obuf;
5794 /* Process crypto operation */
5795 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5796 ut_params->op), "failed to process sym crypto op");
5798 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5799 "crypto op processing failed");
5801 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5802 ut_params->op->sym->cipher.data.offset);
5804 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5807 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5809 tdata->plaintext.data,
5810 tdata->plaintext.len,
5811 "Plaintext data not as expected");
5813 TEST_ASSERT_EQUAL(ut_params->op->status,
5814 RTE_CRYPTO_OP_STATUS_SUCCESS,
5815 "Authentication failed");
5820 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5822 return test_authenticated_decryption_oop(&gcm_test_case_5);
5826 test_authenticated_encryption_sessionless(
5827 const struct aead_test_data *tdata)
5829 struct crypto_testsuite_params *ts_params = &testsuite_params;
5830 struct crypto_unittest_params *ut_params = &unittest_params;
5833 uint8_t *ciphertext, *auth_tag;
5834 uint16_t plaintext_pad_len;
5835 uint8_t key[tdata->key.len + 1];
5837 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5839 /* clear mbuf payload */
5840 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5841 rte_pktmbuf_tailroom(ut_params->ibuf));
5843 /* Create AEAD operation */
5844 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5848 /* Create GCM xform */
5849 memcpy(key, tdata->key.data, tdata->key.len);
5850 retval = create_aead_xform(ut_params->op,
5852 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5853 key, tdata->key.len,
5854 tdata->aad.len, tdata->auth_tag.len,
5859 ut_params->op->sym->m_src = ut_params->ibuf;
5861 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5862 RTE_CRYPTO_OP_SESSIONLESS,
5863 "crypto op session type not sessionless");
5865 /* Process crypto operation */
5866 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5867 ut_params->op), "failed to process sym crypto op");
5869 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5871 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5872 "crypto op status not success");
5874 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5876 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5877 ut_params->op->sym->cipher.data.offset);
5878 auth_tag = ciphertext + plaintext_pad_len;
5880 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5881 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5884 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5886 tdata->ciphertext.data,
5887 tdata->ciphertext.len,
5888 "Ciphertext data not as expected");
5890 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5892 tdata->auth_tag.data,
5893 tdata->auth_tag.len,
5894 "Generated auth tag not as expected");
5901 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5903 return test_authenticated_encryption_sessionless(
5908 test_authenticated_decryption_sessionless(
5909 const struct aead_test_data *tdata)
5911 struct crypto_testsuite_params *ts_params = &testsuite_params;
5912 struct crypto_unittest_params *ut_params = &unittest_params;
5916 uint8_t key[tdata->key.len + 1];
5918 /* alloc mbuf and set payload */
5919 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5921 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5922 rte_pktmbuf_tailroom(ut_params->ibuf));
5924 /* Create AEAD operation */
5925 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5929 /* Create AEAD xform */
5930 memcpy(key, tdata->key.data, tdata->key.len);
5931 retval = create_aead_xform(ut_params->op,
5933 RTE_CRYPTO_AEAD_OP_DECRYPT,
5934 key, tdata->key.len,
5935 tdata->aad.len, tdata->auth_tag.len,
5940 ut_params->op->sym->m_src = ut_params->ibuf;
5942 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5943 RTE_CRYPTO_OP_SESSIONLESS,
5944 "crypto op session type not sessionless");
5946 /* Process crypto operation */
5947 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5948 ut_params->op), "failed to process sym crypto op");
5950 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5952 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5953 "crypto op status not success");
5955 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5956 ut_params->op->sym->cipher.data.offset);
5958 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5961 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5963 tdata->plaintext.data,
5964 tdata->plaintext.len,
5965 "Plaintext data not as expected");
5967 TEST_ASSERT_EQUAL(ut_params->op->status,
5968 RTE_CRYPTO_OP_STATUS_SUCCESS,
5969 "Authentication failed");
5974 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5976 return test_authenticated_decryption_sessionless(
5981 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
5983 return test_authenticated_encryption(&ccm_test_case_128_1);
5987 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
5989 return test_authenticated_encryption(&ccm_test_case_128_2);
5993 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
5995 return test_authenticated_encryption(&ccm_test_case_128_3);
5999 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6001 return test_authenticated_decryption(&ccm_test_case_128_1);
6005 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6007 return test_authenticated_decryption(&ccm_test_case_128_2);
6011 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6013 return test_authenticated_decryption(&ccm_test_case_128_3);
6017 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6019 return test_authenticated_encryption(&ccm_test_case_192_1);
6023 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6025 return test_authenticated_encryption(&ccm_test_case_192_2);
6029 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6031 return test_authenticated_encryption(&ccm_test_case_192_3);
6035 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6037 return test_authenticated_decryption(&ccm_test_case_192_1);
6041 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6043 return test_authenticated_decryption(&ccm_test_case_192_2);
6047 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6049 return test_authenticated_decryption(&ccm_test_case_192_3);
6053 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6055 return test_authenticated_encryption(&ccm_test_case_256_1);
6059 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6061 return test_authenticated_encryption(&ccm_test_case_256_2);
6065 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6067 return test_authenticated_encryption(&ccm_test_case_256_3);
6071 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6073 return test_authenticated_decryption(&ccm_test_case_256_1);
6077 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6079 return test_authenticated_decryption(&ccm_test_case_256_2);
6083 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6085 return test_authenticated_decryption(&ccm_test_case_256_3);
6091 struct crypto_testsuite_params *ts_params = &testsuite_params;
6092 struct rte_cryptodev_stats stats;
6093 struct rte_cryptodev *dev;
6094 cryptodev_stats_get_t temp_pfn;
6096 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6097 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6098 &stats) == -ENODEV),
6099 "rte_cryptodev_stats_get invalid dev failed");
6100 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6101 "rte_cryptodev_stats_get invalid Param failed");
6102 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6103 temp_pfn = dev->dev_ops->stats_get;
6104 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6105 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6107 "rte_cryptodev_stats_get invalid Param failed");
6108 dev->dev_ops->stats_get = temp_pfn;
6110 /* Test expected values */
6112 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6114 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6116 "rte_cryptodev_stats_get failed");
6117 TEST_ASSERT((stats.enqueued_count == 1),
6118 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6119 TEST_ASSERT((stats.dequeued_count == 1),
6120 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6121 TEST_ASSERT((stats.enqueue_err_count == 0),
6122 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6123 TEST_ASSERT((stats.dequeue_err_count == 0),
6124 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6126 /* invalid device but should ignore and not reset device stats*/
6127 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6128 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6130 "rte_cryptodev_stats_get failed");
6131 TEST_ASSERT((stats.enqueued_count == 1),
6132 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6134 /* check that a valid reset clears stats */
6135 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6136 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6138 "rte_cryptodev_stats_get failed");
6139 TEST_ASSERT((stats.enqueued_count == 0),
6140 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6141 TEST_ASSERT((stats.dequeued_count == 0),
6142 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6144 return TEST_SUCCESS;
6147 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6148 struct crypto_unittest_params *ut_params,
6149 enum rte_crypto_auth_operation op,
6150 const struct HMAC_MD5_vector *test_case)
6154 memcpy(key, test_case->key.data, test_case->key.len);
6156 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6157 ut_params->auth_xform.next = NULL;
6158 ut_params->auth_xform.auth.op = op;
6160 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6162 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6163 ut_params->auth_xform.auth.key.length = test_case->key.len;
6164 ut_params->auth_xform.auth.key.data = key;
6166 ut_params->sess = rte_cryptodev_sym_session_create(
6167 ts_params->session_mpool);
6169 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6170 ut_params->sess, &ut_params->auth_xform,
6171 ts_params->session_mpool);
6173 if (ut_params->sess == NULL)
6176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6178 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6179 rte_pktmbuf_tailroom(ut_params->ibuf));
6184 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6185 const struct HMAC_MD5_vector *test_case,
6186 uint8_t **plaintext)
6188 uint16_t plaintext_pad_len;
6190 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6192 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6195 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6197 memcpy(*plaintext, test_case->plaintext.data,
6198 test_case->plaintext.len);
6200 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6201 ut_params->ibuf, MD5_DIGEST_LEN);
6202 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6203 "no room to append digest");
6204 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6205 ut_params->ibuf, plaintext_pad_len);
6207 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6208 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6209 test_case->auth_tag.len);
6212 sym_op->auth.data.offset = 0;
6213 sym_op->auth.data.length = test_case->plaintext.len;
6215 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6216 ut_params->op->sym->m_src = ut_params->ibuf;
6222 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6224 uint16_t plaintext_pad_len;
6225 uint8_t *plaintext, *auth_tag;
6227 struct crypto_testsuite_params *ts_params = &testsuite_params;
6228 struct crypto_unittest_params *ut_params = &unittest_params;
6230 if (MD5_HMAC_create_session(ts_params, ut_params,
6231 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6234 /* Generate Crypto op data structure */
6235 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6236 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6237 TEST_ASSERT_NOT_NULL(ut_params->op,
6238 "Failed to allocate symmetric crypto operation struct");
6240 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6243 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6246 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6247 ut_params->op), "failed to process sym crypto op");
6249 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6250 "crypto op processing failed");
6252 if (ut_params->op->sym->m_dst) {
6253 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6254 uint8_t *, plaintext_pad_len);
6256 auth_tag = plaintext + plaintext_pad_len;
6259 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6261 test_case->auth_tag.data,
6262 test_case->auth_tag.len,
6263 "HMAC_MD5 generated tag not as expected");
6265 return TEST_SUCCESS;
6269 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6273 struct crypto_testsuite_params *ts_params = &testsuite_params;
6274 struct crypto_unittest_params *ut_params = &unittest_params;
6276 if (MD5_HMAC_create_session(ts_params, ut_params,
6277 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6281 /* Generate Crypto op data structure */
6282 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6283 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6284 TEST_ASSERT_NOT_NULL(ut_params->op,
6285 "Failed to allocate symmetric crypto operation struct");
6287 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6290 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6291 ut_params->op), "failed to process sym crypto op");
6293 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6294 "HMAC_MD5 crypto op processing failed");
6296 return TEST_SUCCESS;
6300 test_MD5_HMAC_generate_case_1(void)
6302 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6306 test_MD5_HMAC_verify_case_1(void)
6308 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6312 test_MD5_HMAC_generate_case_2(void)
6314 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6318 test_MD5_HMAC_verify_case_2(void)
6320 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6324 test_multi_session(void)
6326 struct crypto_testsuite_params *ts_params = &testsuite_params;
6327 struct crypto_unittest_params *ut_params = &unittest_params;
6329 struct rte_cryptodev_info dev_info;
6330 struct rte_cryptodev_sym_session **sessions;
6334 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6335 aes_cbc_key, hmac_sha512_key);
6338 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6340 sessions = rte_malloc(NULL,
6341 (sizeof(struct rte_cryptodev_sym_session *) *
6342 dev_info.sym.max_nb_sessions) + 1, 0);
6344 /* Create multiple crypto sessions*/
6345 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6347 sessions[i] = rte_cryptodev_sym_session_create(
6348 ts_params->session_mpool);
6350 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6351 sessions[i], &ut_params->auth_xform,
6352 ts_params->session_mpool);
6353 TEST_ASSERT_NOT_NULL(sessions[i],
6354 "Session creation failed at session number %u",
6357 /* Attempt to send a request on each session */
6358 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6362 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6363 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6365 "Failed to perform decrypt on request number %u.", i);
6366 /* free crypto operation structure */
6368 rte_crypto_op_free(ut_params->op);
6371 * free mbuf - both obuf and ibuf are usually the same,
6372 * so check if they point at the same address is necessary,
6373 * to avoid freeing the mbuf twice.
6375 if (ut_params->obuf) {
6376 rte_pktmbuf_free(ut_params->obuf);
6377 if (ut_params->ibuf == ut_params->obuf)
6378 ut_params->ibuf = 0;
6379 ut_params->obuf = 0;
6381 if (ut_params->ibuf) {
6382 rte_pktmbuf_free(ut_params->ibuf);
6383 ut_params->ibuf = 0;
6387 /* Next session create should fail */
6388 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6389 sessions[i], &ut_params->auth_xform,
6390 ts_params->session_mpool);
6391 TEST_ASSERT_NULL(sessions[i],
6392 "Session creation succeeded unexpectedly!");
6394 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6395 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6397 rte_cryptodev_sym_session_free(sessions[i]);
6402 return TEST_SUCCESS;
6405 struct multi_session_params {
6406 struct crypto_unittest_params ut_params;
6407 uint8_t *cipher_key;
6409 const uint8_t *cipher;
6410 const uint8_t *digest;
6414 #define MB_SESSION_NUMBER 3
6417 test_multi_session_random_usage(void)
6419 struct crypto_testsuite_params *ts_params = &testsuite_params;
6420 struct rte_cryptodev_info dev_info;
6421 struct rte_cryptodev_sym_session **sessions;
6423 struct multi_session_params ut_paramz[] = {
6426 .cipher_key = ms_aes_cbc_key0,
6427 .hmac_key = ms_hmac_key0,
6428 .cipher = ms_aes_cbc_cipher0,
6429 .digest = ms_hmac_digest0,
6430 .iv = ms_aes_cbc_iv0
6433 .cipher_key = ms_aes_cbc_key1,
6434 .hmac_key = ms_hmac_key1,
6435 .cipher = ms_aes_cbc_cipher1,
6436 .digest = ms_hmac_digest1,
6437 .iv = ms_aes_cbc_iv1
6440 .cipher_key = ms_aes_cbc_key2,
6441 .hmac_key = ms_hmac_key2,
6442 .cipher = ms_aes_cbc_cipher2,
6443 .digest = ms_hmac_digest2,
6444 .iv = ms_aes_cbc_iv2
6449 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6451 sessions = rte_malloc(NULL,
6452 (sizeof(struct rte_cryptodev_sym_session *)
6453 * dev_info.sym.max_nb_sessions) + 1, 0);
6455 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6456 sessions[i] = rte_cryptodev_sym_session_create(
6457 ts_params->session_mpool);
6459 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6460 sizeof(struct crypto_unittest_params));
6462 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6463 &ut_paramz[i].ut_params,
6464 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6466 /* Create multiple crypto sessions*/
6467 rte_cryptodev_sym_session_init(
6468 ts_params->valid_devs[0],
6470 &ut_paramz[i].ut_params.auth_xform,
6471 ts_params->session_mpool);
6473 TEST_ASSERT_NOT_NULL(sessions[i],
6474 "Session creation failed at session number %u",
6480 for (i = 0; i < 40000; i++) {
6482 j = rand() % MB_SESSION_NUMBER;
6484 TEST_ASSERT_SUCCESS(
6485 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6487 &ut_paramz[j].ut_params,
6488 ts_params, ut_paramz[j].cipher,
6489 ut_paramz[j].digest,
6491 "Failed to perform decrypt on request number %u.", i);
6493 if (ut_paramz[j].ut_params.op)
6494 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6497 * free mbuf - both obuf and ibuf are usually the same,
6498 * so check if they point at the same address is necessary,
6499 * to avoid freeing the mbuf twice.
6501 if (ut_paramz[j].ut_params.obuf) {
6502 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6503 if (ut_paramz[j].ut_params.ibuf
6504 == ut_paramz[j].ut_params.obuf)
6505 ut_paramz[j].ut_params.ibuf = 0;
6506 ut_paramz[j].ut_params.obuf = 0;
6508 if (ut_paramz[j].ut_params.ibuf) {
6509 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6510 ut_paramz[j].ut_params.ibuf = 0;
6514 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6515 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6517 rte_cryptodev_sym_session_free(sessions[i]);
6522 return TEST_SUCCESS;
6526 test_null_cipher_only_operation(void)
6528 struct crypto_testsuite_params *ts_params = &testsuite_params;
6529 struct crypto_unittest_params *ut_params = &unittest_params;
6531 /* Generate test mbuf data and space for digest */
6532 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6533 catch_22_quote, QUOTE_512_BYTES, 0);
6535 /* Setup Cipher Parameters */
6536 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6537 ut_params->cipher_xform.next = NULL;
6539 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6540 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6542 ut_params->sess = rte_cryptodev_sym_session_create(
6543 ts_params->session_mpool);
6545 /* Create Crypto session*/
6546 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6548 &ut_params->cipher_xform,
6549 ts_params->session_mpool);
6550 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6552 /* Generate Crypto op data structure */
6553 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6554 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6555 TEST_ASSERT_NOT_NULL(ut_params->op,
6556 "Failed to allocate symmetric crypto operation struct");
6558 /* Set crypto operation data parameters */
6559 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6561 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6563 /* set crypto operation source mbuf */
6564 sym_op->m_src = ut_params->ibuf;
6566 sym_op->cipher.data.offset = 0;
6567 sym_op->cipher.data.length = QUOTE_512_BYTES;
6569 /* Process crypto operation */
6570 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6572 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6574 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6575 "crypto operation processing failed");
6578 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6579 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6582 "Ciphertext data not as expected");
6584 return TEST_SUCCESS;
6586 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6587 0xab, 0xab, 0xab, 0xab,
6588 0xab, 0xab, 0xab, 0xab,
6589 0xab, 0xab, 0xab, 0xab};
6591 test_null_auth_only_operation(void)
6593 struct crypto_testsuite_params *ts_params = &testsuite_params;
6594 struct crypto_unittest_params *ut_params = &unittest_params;
6597 /* Generate test mbuf data and space for digest */
6598 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6599 catch_22_quote, QUOTE_512_BYTES, 0);
6601 /* create a pointer for digest, but don't expect anything to be written
6602 * here in a NULL auth algo so no mbuf append done.
6604 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6606 /* prefill the memory pointed to by digest */
6607 memcpy(digest, orig_data, sizeof(orig_data));
6609 /* Setup HMAC Parameters */
6610 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6611 ut_params->auth_xform.next = NULL;
6613 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6614 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6616 ut_params->sess = rte_cryptodev_sym_session_create(
6617 ts_params->session_mpool);
6619 /* Create Crypto session*/
6620 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6621 ut_params->sess, &ut_params->auth_xform,
6622 ts_params->session_mpool);
6623 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6625 /* Generate Crypto op data structure */
6626 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6627 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6628 TEST_ASSERT_NOT_NULL(ut_params->op,
6629 "Failed to allocate symmetric crypto operation struct");
6631 /* Set crypto operation data parameters */
6632 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6634 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6636 sym_op->m_src = ut_params->ibuf;
6638 sym_op->auth.data.offset = 0;
6639 sym_op->auth.data.length = QUOTE_512_BYTES;
6640 sym_op->auth.digest.data = digest;
6641 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6644 /* Process crypto operation */
6645 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6647 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6649 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6650 "crypto operation processing failed");
6651 /* Make sure memory pointed to by digest hasn't been overwritten */
6652 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6656 "Memory at digest ptr overwritten unexpectedly");
6658 return TEST_SUCCESS;
6663 test_null_cipher_auth_operation(void)
6665 struct crypto_testsuite_params *ts_params = &testsuite_params;
6666 struct crypto_unittest_params *ut_params = &unittest_params;
6669 /* Generate test mbuf data and space for digest */
6670 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6671 catch_22_quote, QUOTE_512_BYTES, 0);
6673 /* create a pointer for digest, but don't expect anything to be written
6674 * here in a NULL auth algo so no mbuf append done.
6676 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6678 /* prefill the memory pointed to by digest */
6679 memcpy(digest, orig_data, sizeof(orig_data));
6681 /* Setup Cipher Parameters */
6682 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6683 ut_params->cipher_xform.next = &ut_params->auth_xform;
6685 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6686 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6688 /* Setup HMAC Parameters */
6689 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6690 ut_params->auth_xform.next = NULL;
6692 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6693 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6695 ut_params->sess = rte_cryptodev_sym_session_create(
6696 ts_params->session_mpool);
6698 /* Create Crypto session*/
6699 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6700 ut_params->sess, &ut_params->cipher_xform,
6701 ts_params->session_mpool);
6702 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6704 /* Generate Crypto op data structure */
6705 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6706 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6707 TEST_ASSERT_NOT_NULL(ut_params->op,
6708 "Failed to allocate symmetric crypto operation struct");
6710 /* Set crypto operation data parameters */
6711 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6713 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6715 sym_op->m_src = ut_params->ibuf;
6717 sym_op->cipher.data.offset = 0;
6718 sym_op->cipher.data.length = QUOTE_512_BYTES;
6720 sym_op->auth.data.offset = 0;
6721 sym_op->auth.data.length = QUOTE_512_BYTES;
6722 sym_op->auth.digest.data = digest;
6723 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6726 /* Process crypto operation */
6727 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6729 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6731 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6732 "crypto operation processing failed");
6735 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6736 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6739 "Ciphertext data not as expected");
6740 /* Make sure memory pointed to by digest hasn't been overwritten */
6741 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6745 "Memory at digest ptr overwritten unexpectedly");
6747 return TEST_SUCCESS;
6751 test_null_auth_cipher_operation(void)
6753 struct crypto_testsuite_params *ts_params = &testsuite_params;
6754 struct crypto_unittest_params *ut_params = &unittest_params;
6757 /* Generate test mbuf data */
6758 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6759 catch_22_quote, QUOTE_512_BYTES, 0);
6761 /* create a pointer for digest, but don't expect anything to be written
6762 * here in a NULL auth algo so no mbuf append done.
6764 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6766 /* prefill the memory pointed to by digest */
6767 memcpy(digest, orig_data, sizeof(orig_data));
6769 /* Setup Cipher Parameters */
6770 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6771 ut_params->cipher_xform.next = NULL;
6773 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6774 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6776 /* Setup HMAC Parameters */
6777 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6778 ut_params->auth_xform.next = &ut_params->cipher_xform;
6780 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6781 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6783 ut_params->sess = rte_cryptodev_sym_session_create(
6784 ts_params->session_mpool);
6786 /* Create Crypto session*/
6787 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6788 ut_params->sess, &ut_params->cipher_xform,
6789 ts_params->session_mpool);
6790 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6792 /* Generate Crypto op data structure */
6793 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6794 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6795 TEST_ASSERT_NOT_NULL(ut_params->op,
6796 "Failed to allocate symmetric crypto operation struct");
6798 /* Set crypto operation data parameters */
6799 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6801 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6803 sym_op->m_src = ut_params->ibuf;
6805 sym_op->cipher.data.offset = 0;
6806 sym_op->cipher.data.length = QUOTE_512_BYTES;
6808 sym_op->auth.data.offset = 0;
6809 sym_op->auth.data.length = QUOTE_512_BYTES;
6810 sym_op->auth.digest.data = digest;
6811 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6814 /* Process crypto operation */
6815 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6817 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6819 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6820 "crypto operation processing failed");
6823 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6824 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6827 "Ciphertext data not as expected");
6828 /* Make sure memory pointed to by digest hasn't been overwritten */
6829 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6833 "Memory at digest ptr overwritten unexpectedly");
6835 return TEST_SUCCESS;
6840 test_null_invalid_operation(void)
6842 struct crypto_testsuite_params *ts_params = &testsuite_params;
6843 struct crypto_unittest_params *ut_params = &unittest_params;
6846 /* Setup Cipher Parameters */
6847 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6848 ut_params->cipher_xform.next = NULL;
6850 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6851 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6853 ut_params->sess = rte_cryptodev_sym_session_create(
6854 ts_params->session_mpool);
6856 /* Create Crypto session*/
6857 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6858 ut_params->sess, &ut_params->cipher_xform,
6859 ts_params->session_mpool);
6860 TEST_ASSERT(ret < 0,
6861 "Session creation succeeded unexpectedly");
6864 /* Setup HMAC Parameters */
6865 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6866 ut_params->auth_xform.next = NULL;
6868 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6869 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6871 ut_params->sess = rte_cryptodev_sym_session_create(
6872 ts_params->session_mpool);
6874 /* Create Crypto session*/
6875 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6876 ut_params->sess, &ut_params->auth_xform,
6877 ts_params->session_mpool);
6878 TEST_ASSERT(ret < 0,
6879 "Session creation succeeded unexpectedly");
6881 return TEST_SUCCESS;
6885 #define NULL_BURST_LENGTH (32)
6888 test_null_burst_operation(void)
6890 struct crypto_testsuite_params *ts_params = &testsuite_params;
6891 struct crypto_unittest_params *ut_params = &unittest_params;
6893 unsigned i, burst_len = NULL_BURST_LENGTH;
6895 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6896 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6898 /* Setup Cipher Parameters */
6899 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6900 ut_params->cipher_xform.next = &ut_params->auth_xform;
6902 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6903 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6905 /* Setup HMAC Parameters */
6906 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6907 ut_params->auth_xform.next = NULL;
6909 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6910 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6912 ut_params->sess = rte_cryptodev_sym_session_create(
6913 ts_params->session_mpool);
6915 /* Create Crypto session*/
6916 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6917 ut_params->sess, &ut_params->cipher_xform,
6918 ts_params->session_mpool);
6919 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6921 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6922 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6923 burst_len, "failed to generate burst of crypto ops");
6925 /* Generate an operation for each mbuf in burst */
6926 for (i = 0; i < burst_len; i++) {
6927 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6929 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6931 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6935 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6937 burst[i]->sym->m_src = m;
6940 /* Process crypto operation */
6941 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6942 0, burst, burst_len),
6944 "Error enqueuing burst");
6946 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6947 0, burst_dequeued, burst_len),
6949 "Error dequeuing burst");
6952 for (i = 0; i < burst_len; i++) {
6954 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6955 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6957 "data not as expected");
6959 rte_pktmbuf_free(burst[i]->sym->m_src);
6960 rte_crypto_op_free(burst[i]);
6963 return TEST_SUCCESS;
6967 generate_gmac_large_plaintext(uint8_t *data)
6971 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6972 memcpy(&data[i], &data[0], 32);
6976 create_gmac_operation(enum rte_crypto_auth_operation op,
6977 const struct gmac_test_data *tdata)
6979 struct crypto_testsuite_params *ts_params = &testsuite_params;
6980 struct crypto_unittest_params *ut_params = &unittest_params;
6981 struct rte_crypto_sym_op *sym_op;
6983 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6985 /* Generate Crypto op data structure */
6986 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6987 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6988 TEST_ASSERT_NOT_NULL(ut_params->op,
6989 "Failed to allocate symmetric crypto operation struct");
6991 sym_op = ut_params->op->sym;
6993 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6994 ut_params->ibuf, tdata->gmac_tag.len);
6995 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6996 "no room to append digest");
6998 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6999 ut_params->ibuf, plaintext_pad_len);
7001 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7002 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7003 tdata->gmac_tag.len);
7004 debug_hexdump(stdout, "digest:",
7005 sym_op->auth.digest.data,
7006 tdata->gmac_tag.len);
7009 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7010 uint8_t *, IV_OFFSET);
7012 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7014 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7016 sym_op->cipher.data.length = 0;
7017 sym_op->cipher.data.offset = 0;
7019 sym_op->auth.data.offset = 0;
7020 sym_op->auth.data.length = tdata->plaintext.len;
7025 static int create_gmac_session(uint8_t dev_id,
7026 const struct gmac_test_data *tdata,
7027 enum rte_crypto_auth_operation auth_op)
7029 uint8_t auth_key[tdata->key.len];
7031 struct crypto_testsuite_params *ts_params = &testsuite_params;
7032 struct crypto_unittest_params *ut_params = &unittest_params;
7034 memcpy(auth_key, tdata->key.data, tdata->key.len);
7036 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7037 ut_params->auth_xform.next = NULL;
7039 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7040 ut_params->auth_xform.auth.op = auth_op;
7041 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7042 ut_params->auth_xform.auth.key.length = tdata->key.len;
7043 ut_params->auth_xform.auth.key.data = auth_key;
7044 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7045 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7048 ut_params->sess = rte_cryptodev_sym_session_create(
7049 ts_params->session_mpool);
7051 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7052 &ut_params->auth_xform,
7053 ts_params->session_mpool);
7055 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7061 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7063 struct crypto_testsuite_params *ts_params = &testsuite_params;
7064 struct crypto_unittest_params *ut_params = &unittest_params;
7068 uint8_t *auth_tag, *plaintext;
7069 uint16_t plaintext_pad_len;
7071 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7072 "No GMAC length in the source data");
7074 retval = create_gmac_session(ts_params->valid_devs[0],
7075 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7080 if (tdata->plaintext.len > MBUF_SIZE)
7081 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7083 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7084 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7085 "Failed to allocate input buffer in mempool");
7087 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7088 rte_pktmbuf_tailroom(ut_params->ibuf));
7090 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7092 * Runtime generate the large plain text instead of use hard code
7093 * plain text vector. It is done to avoid create huge source file
7094 * with the test vector.
7096 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7097 generate_gmac_large_plaintext(tdata->plaintext.data);
7099 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7101 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7103 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7104 debug_hexdump(stdout, "plaintext:", plaintext,
7105 tdata->plaintext.len);
7107 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7113 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7115 ut_params->op->sym->m_src = ut_params->ibuf;
7117 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7118 ut_params->op), "failed to process sym crypto op");
7120 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7121 "crypto op processing failed");
7123 if (ut_params->op->sym->m_dst) {
7124 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7125 uint8_t *, plaintext_pad_len);
7127 auth_tag = plaintext + plaintext_pad_len;
7130 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7132 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7134 tdata->gmac_tag.data,
7135 tdata->gmac_tag.len,
7136 "GMAC Generated auth tag not as expected");
7142 test_AES_GMAC_authentication_test_case_1(void)
7144 return test_AES_GMAC_authentication(&gmac_test_case_1);
7148 test_AES_GMAC_authentication_test_case_2(void)
7150 return test_AES_GMAC_authentication(&gmac_test_case_2);
7154 test_AES_GMAC_authentication_test_case_3(void)
7156 return test_AES_GMAC_authentication(&gmac_test_case_3);
7160 test_AES_GMAC_authentication_test_case_4(void)
7162 return test_AES_GMAC_authentication(&gmac_test_case_4);
7166 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7168 struct crypto_testsuite_params *ts_params = &testsuite_params;
7169 struct crypto_unittest_params *ut_params = &unittest_params;
7171 uint32_t plaintext_pad_len;
7174 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7175 "No GMAC length in the source data");
7177 retval = create_gmac_session(ts_params->valid_devs[0],
7178 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7183 if (tdata->plaintext.len > MBUF_SIZE)
7184 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7186 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7187 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7188 "Failed to allocate input buffer in mempool");
7190 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7191 rte_pktmbuf_tailroom(ut_params->ibuf));
7193 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7196 * Runtime generate the large plain text instead of use hard code
7197 * plain text vector. It is done to avoid create huge source file
7198 * with the test vector.
7200 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7201 generate_gmac_large_plaintext(tdata->plaintext.data);
7203 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7205 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7207 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7208 debug_hexdump(stdout, "plaintext:", plaintext,
7209 tdata->plaintext.len);
7211 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7217 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7219 ut_params->op->sym->m_src = ut_params->ibuf;
7221 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7222 ut_params->op), "failed to process sym crypto op");
7224 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7225 "crypto op processing failed");
7232 test_AES_GMAC_authentication_verify_test_case_1(void)
7234 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7238 test_AES_GMAC_authentication_verify_test_case_2(void)
7240 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7244 test_AES_GMAC_authentication_verify_test_case_3(void)
7246 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7250 test_AES_GMAC_authentication_verify_test_case_4(void)
7252 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7255 struct test_crypto_vector {
7256 enum rte_crypto_cipher_algorithm crypto_algo;
7269 const uint8_t *data;
7274 const uint8_t *data;
7278 enum rte_crypto_auth_algorithm auth_algo;
7286 const uint8_t *data;
7296 static const struct test_crypto_vector
7297 hmac_sha1_test_crypto_vector = {
7298 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7300 .data = plaintext_hash,
7305 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7306 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7307 0xDE, 0xF4, 0xDE, 0xAD
7313 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7314 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7315 0x3F, 0x91, 0x64, 0x59
7321 static const struct test_crypto_vector
7322 aes128_gmac_test_vector = {
7323 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7325 .data = plaintext_hash,
7330 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7331 0x08, 0x09, 0x0A, 0x0B
7337 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7338 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7344 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7345 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7351 static const struct test_crypto_vector
7352 aes128cbc_hmac_sha1_test_vector = {
7353 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7356 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7357 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7363 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7364 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7369 .data = plaintext_hash,
7373 .data = ciphertext512_aes128cbc,
7376 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7379 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7380 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7381 0xDE, 0xF4, 0xDE, 0xAD
7387 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7388 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7389 0x18, 0x8C, 0x1D, 0x32
7396 data_corruption(uint8_t *data)
7402 tag_corruption(uint8_t *data, unsigned int tag_offset)
7404 data[tag_offset] += 1;
7408 create_auth_session(struct crypto_unittest_params *ut_params,
7410 const struct test_crypto_vector *reference,
7411 enum rte_crypto_auth_operation auth_op)
7413 struct crypto_testsuite_params *ts_params = &testsuite_params;
7414 uint8_t auth_key[reference->auth_key.len + 1];
7416 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7418 /* Setup Authentication Parameters */
7419 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7420 ut_params->auth_xform.auth.op = auth_op;
7421 ut_params->auth_xform.next = NULL;
7422 ut_params->auth_xform.auth.algo = reference->auth_algo;
7423 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7424 ut_params->auth_xform.auth.key.data = auth_key;
7425 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7427 /* Create Crypto session*/
7428 ut_params->sess = rte_cryptodev_sym_session_create(
7429 ts_params->session_mpool);
7431 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7432 &ut_params->auth_xform,
7433 ts_params->session_mpool);
7435 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7441 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7443 const struct test_crypto_vector *reference,
7444 enum rte_crypto_auth_operation auth_op,
7445 enum rte_crypto_cipher_operation cipher_op)
7447 struct crypto_testsuite_params *ts_params = &testsuite_params;
7448 uint8_t cipher_key[reference->cipher_key.len + 1];
7449 uint8_t auth_key[reference->auth_key.len + 1];
7451 memcpy(cipher_key, reference->cipher_key.data,
7452 reference->cipher_key.len);
7453 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7455 /* Setup Authentication Parameters */
7456 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7457 ut_params->auth_xform.auth.op = auth_op;
7458 ut_params->auth_xform.auth.algo = reference->auth_algo;
7459 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7460 ut_params->auth_xform.auth.key.data = auth_key;
7461 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7463 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7464 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7465 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7467 ut_params->auth_xform.next = &ut_params->cipher_xform;
7469 /* Setup Cipher Parameters */
7470 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7471 ut_params->cipher_xform.next = NULL;
7472 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7473 ut_params->cipher_xform.cipher.op = cipher_op;
7474 ut_params->cipher_xform.cipher.key.data = cipher_key;
7475 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7476 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7477 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7480 /* Create Crypto session*/
7481 ut_params->sess = rte_cryptodev_sym_session_create(
7482 ts_params->session_mpool);
7484 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7485 &ut_params->auth_xform,
7486 ts_params->session_mpool);
7488 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7494 create_auth_operation(struct crypto_testsuite_params *ts_params,
7495 struct crypto_unittest_params *ut_params,
7496 const struct test_crypto_vector *reference,
7497 unsigned int auth_generate)
7499 /* Generate Crypto op data structure */
7500 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7501 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7502 TEST_ASSERT_NOT_NULL(ut_params->op,
7503 "Failed to allocate pktmbuf offload");
7505 /* Set crypto operation data parameters */
7506 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7508 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7510 /* set crypto operation source mbuf */
7511 sym_op->m_src = ut_params->ibuf;
7514 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7515 ut_params->ibuf, reference->digest.len);
7517 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7518 "no room to append auth tag");
7520 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7521 ut_params->ibuf, reference->plaintext.len);
7524 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7526 memcpy(sym_op->auth.digest.data,
7527 reference->digest.data,
7528 reference->digest.len);
7530 debug_hexdump(stdout, "digest:",
7531 sym_op->auth.digest.data,
7532 reference->digest.len);
7534 sym_op->auth.data.length = reference->plaintext.len;
7535 sym_op->auth.data.offset = 0;
7541 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7542 struct crypto_unittest_params *ut_params,
7543 const struct test_crypto_vector *reference,
7544 unsigned int auth_generate)
7546 /* Generate Crypto op data structure */
7547 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7548 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7549 TEST_ASSERT_NOT_NULL(ut_params->op,
7550 "Failed to allocate pktmbuf offload");
7552 /* Set crypto operation data parameters */
7553 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7555 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7557 /* set crypto operation source mbuf */
7558 sym_op->m_src = ut_params->ibuf;
7561 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7562 ut_params->ibuf, reference->digest.len);
7564 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7565 "no room to append auth tag");
7567 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7568 ut_params->ibuf, reference->ciphertext.len);
7571 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7573 memcpy(sym_op->auth.digest.data,
7574 reference->digest.data,
7575 reference->digest.len);
7577 debug_hexdump(stdout, "digest:",
7578 sym_op->auth.digest.data,
7579 reference->digest.len);
7581 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7582 reference->iv.data, reference->iv.len);
7584 sym_op->cipher.data.length = 0;
7585 sym_op->cipher.data.offset = 0;
7587 sym_op->auth.data.length = reference->plaintext.len;
7588 sym_op->auth.data.offset = 0;
7594 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7595 struct crypto_unittest_params *ut_params,
7596 const struct test_crypto_vector *reference,
7597 unsigned int auth_generate)
7599 /* Generate Crypto op data structure */
7600 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7601 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7602 TEST_ASSERT_NOT_NULL(ut_params->op,
7603 "Failed to allocate pktmbuf offload");
7605 /* Set crypto operation data parameters */
7606 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7608 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7610 /* set crypto operation source mbuf */
7611 sym_op->m_src = ut_params->ibuf;
7614 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7615 ut_params->ibuf, reference->digest.len);
7617 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7618 "no room to append auth tag");
7620 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7621 ut_params->ibuf, reference->ciphertext.len);
7624 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7626 memcpy(sym_op->auth.digest.data,
7627 reference->digest.data,
7628 reference->digest.len);
7630 debug_hexdump(stdout, "digest:",
7631 sym_op->auth.digest.data,
7632 reference->digest.len);
7634 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7635 reference->iv.data, reference->iv.len);
7637 sym_op->cipher.data.length = reference->ciphertext.len;
7638 sym_op->cipher.data.offset = 0;
7640 sym_op->auth.data.length = reference->ciphertext.len;
7641 sym_op->auth.data.offset = 0;
7647 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7648 struct crypto_unittest_params *ut_params,
7649 const struct test_crypto_vector *reference)
7651 return create_auth_operation(ts_params, ut_params, reference, 0);
7655 create_auth_verify_GMAC_operation(
7656 struct crypto_testsuite_params *ts_params,
7657 struct crypto_unittest_params *ut_params,
7658 const struct test_crypto_vector *reference)
7660 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7664 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7665 struct crypto_unittest_params *ut_params,
7666 const struct test_crypto_vector *reference)
7668 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7672 test_authentication_verify_fail_when_data_corruption(
7673 struct crypto_testsuite_params *ts_params,
7674 struct crypto_unittest_params *ut_params,
7675 const struct test_crypto_vector *reference,
7676 unsigned int data_corrupted)
7682 /* Create session */
7683 retval = create_auth_session(ut_params,
7684 ts_params->valid_devs[0],
7686 RTE_CRYPTO_AUTH_OP_VERIFY);
7690 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7691 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7692 "Failed to allocate input buffer in mempool");
7694 /* clear mbuf payload */
7695 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7696 rte_pktmbuf_tailroom(ut_params->ibuf));
7698 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7699 reference->plaintext.len);
7700 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7701 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7703 debug_hexdump(stdout, "plaintext:", plaintext,
7704 reference->plaintext.len);
7706 /* Create operation */
7707 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7713 data_corruption(plaintext);
7715 tag_corruption(plaintext, reference->plaintext.len);
7717 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7719 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7720 TEST_ASSERT_EQUAL(ut_params->op->status,
7721 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7722 "authentication not failed");
7724 ut_params->obuf = ut_params->op->sym->m_src;
7725 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7731 test_authentication_verify_GMAC_fail_when_corruption(
7732 struct crypto_testsuite_params *ts_params,
7733 struct crypto_unittest_params *ut_params,
7734 const struct test_crypto_vector *reference,
7735 unsigned int data_corrupted)
7740 /* Create session */
7741 retval = create_auth_cipher_session(ut_params,
7742 ts_params->valid_devs[0],
7744 RTE_CRYPTO_AUTH_OP_VERIFY,
7745 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7749 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7750 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7751 "Failed to allocate input buffer in mempool");
7753 /* clear mbuf payload */
7754 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7755 rte_pktmbuf_tailroom(ut_params->ibuf));
7757 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7758 reference->plaintext.len);
7759 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7760 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7762 debug_hexdump(stdout, "plaintext:", plaintext,
7763 reference->plaintext.len);
7765 /* Create operation */
7766 retval = create_auth_verify_GMAC_operation(ts_params,
7774 data_corruption(plaintext);
7776 tag_corruption(plaintext, reference->aad.len);
7778 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7780 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7781 TEST_ASSERT_EQUAL(ut_params->op->status,
7782 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7783 "authentication not failed");
7785 ut_params->obuf = ut_params->op->sym->m_src;
7786 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7792 test_authenticated_decryption_fail_when_corruption(
7793 struct crypto_testsuite_params *ts_params,
7794 struct crypto_unittest_params *ut_params,
7795 const struct test_crypto_vector *reference,
7796 unsigned int data_corrupted)
7800 uint8_t *ciphertext;
7802 /* Create session */
7803 retval = create_auth_cipher_session(ut_params,
7804 ts_params->valid_devs[0],
7806 RTE_CRYPTO_AUTH_OP_VERIFY,
7807 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7812 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7813 "Failed to allocate input buffer in mempool");
7815 /* clear mbuf payload */
7816 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7817 rte_pktmbuf_tailroom(ut_params->ibuf));
7819 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7820 reference->ciphertext.len);
7821 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7822 memcpy(ciphertext, reference->ciphertext.data,
7823 reference->ciphertext.len);
7825 /* Create operation */
7826 retval = create_cipher_auth_verify_operation(ts_params,
7834 data_corruption(ciphertext);
7836 tag_corruption(ciphertext, reference->ciphertext.len);
7838 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7841 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7842 TEST_ASSERT_EQUAL(ut_params->op->status,
7843 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7844 "authentication not failed");
7846 ut_params->obuf = ut_params->op->sym->m_src;
7847 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7853 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7854 const struct aead_test_data *tdata,
7855 void *digest_mem, uint64_t digest_phys)
7857 struct crypto_testsuite_params *ts_params = &testsuite_params;
7858 struct crypto_unittest_params *ut_params = &unittest_params;
7860 const unsigned int auth_tag_len = tdata->auth_tag.len;
7861 const unsigned int iv_len = tdata->iv.len;
7862 unsigned int aad_len = tdata->aad.len;
7864 /* Generate Crypto op data structure */
7865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7867 TEST_ASSERT_NOT_NULL(ut_params->op,
7868 "Failed to allocate symmetric crypto operation struct");
7870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7872 sym_op->aead.digest.data = digest_mem;
7874 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7875 "no room to append digest");
7877 sym_op->aead.digest.phys_addr = digest_phys;
7879 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7880 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7882 debug_hexdump(stdout, "digest:",
7883 sym_op->aead.digest.data,
7887 /* Append aad data */
7888 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7889 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7890 uint8_t *, IV_OFFSET);
7892 /* Copy IV 1 byte after the IV pointer, according to the API */
7893 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
7895 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
7897 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7898 ut_params->ibuf, aad_len);
7899 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7900 "no room to prepend aad");
7901 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7904 memset(sym_op->aead.aad.data, 0, aad_len);
7905 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7906 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7908 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
7909 debug_hexdump(stdout, "aad:",
7910 sym_op->aead.aad.data, aad_len);
7912 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7913 uint8_t *, IV_OFFSET);
7915 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7917 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7918 ut_params->ibuf, aad_len);
7919 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7920 "no room to prepend aad");
7921 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7924 memset(sym_op->aead.aad.data, 0, aad_len);
7925 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7927 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
7928 debug_hexdump(stdout, "aad:",
7929 sym_op->aead.aad.data, aad_len);
7932 sym_op->aead.data.length = tdata->plaintext.len;
7933 sym_op->aead.data.offset = aad_len;
7938 #define SGL_MAX_NO 16
7941 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
7942 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7944 struct crypto_testsuite_params *ts_params = &testsuite_params;
7945 struct crypto_unittest_params *ut_params = &unittest_params;
7946 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7949 int to_trn_tbl[SGL_MAX_NO];
7951 unsigned int trn_data = 0;
7952 uint8_t *plaintext, *ciphertext, *auth_tag;
7954 if (fragsz > tdata->plaintext.len)
7955 fragsz = tdata->plaintext.len;
7957 uint16_t plaintext_len = fragsz;
7958 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7960 if (fragsz_oop > tdata->plaintext.len)
7961 frag_size_oop = tdata->plaintext.len;
7964 void *digest_mem = NULL;
7966 uint32_t prepend_len = tdata->aad.len;
7968 if (tdata->plaintext.len % fragsz != 0) {
7969 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7972 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7977 * For out-op-place we need to alloc another mbuf
7980 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7981 rte_pktmbuf_append(ut_params->obuf,
7982 frag_size_oop + prepend_len);
7983 buf_oop = ut_params->obuf;
7986 /* Create AEAD session */
7987 retval = create_aead_session(ts_params->valid_devs[0],
7989 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7990 tdata->key.data, tdata->key.len,
7991 tdata->aad.len, tdata->auth_tag.len,
7996 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7998 /* clear mbuf payload */
7999 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8000 rte_pktmbuf_tailroom(ut_params->ibuf));
8002 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8005 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8007 trn_data += plaintext_len;
8009 buf = ut_params->ibuf;
8012 * Loop until no more fragments
8015 while (trn_data < tdata->plaintext.len) {
8017 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8018 (tdata->plaintext.len - trn_data) : fragsz;
8020 to_trn_tbl[ecx++] = to_trn;
8022 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8025 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8026 rte_pktmbuf_tailroom(buf));
8029 if (oop && !fragsz_oop) {
8030 buf_last_oop = buf_oop->next =
8031 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8032 buf_oop = buf_oop->next;
8033 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8034 0, rte_pktmbuf_tailroom(buf_oop));
8035 rte_pktmbuf_append(buf_oop, to_trn);
8038 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8041 memcpy(plaintext, tdata->plaintext.data + trn_data,
8044 if (trn_data == tdata->plaintext.len) {
8047 digest_mem = rte_pktmbuf_append(buf_oop,
8048 tdata->auth_tag.len);
8050 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8051 tdata->auth_tag.len);
8055 uint64_t digest_phys = 0;
8057 ut_params->ibuf->nb_segs = segs;
8060 if (fragsz_oop && oop) {
8064 if (frag_size_oop == tdata->plaintext.len) {
8065 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8066 tdata->auth_tag.len);
8068 digest_phys = rte_pktmbuf_iova_offset(
8070 tdata->plaintext.len + prepend_len);
8073 trn_data = frag_size_oop;
8074 while (trn_data < tdata->plaintext.len) {
8077 (tdata->plaintext.len - trn_data <
8079 (tdata->plaintext.len - trn_data) :
8082 to_trn_tbl[ecx++] = to_trn;
8084 buf_last_oop = buf_oop->next =
8085 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8086 buf_oop = buf_oop->next;
8087 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8088 0, rte_pktmbuf_tailroom(buf_oop));
8089 rte_pktmbuf_append(buf_oop, to_trn);
8093 if (trn_data == tdata->plaintext.len) {
8094 digest_mem = rte_pktmbuf_append(buf_oop,
8095 tdata->auth_tag.len);
8099 ut_params->obuf->nb_segs = segs;
8103 * Place digest at the end of the last buffer
8106 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8107 if (oop && buf_last_oop)
8108 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8110 if (!digest_mem && !oop) {
8111 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8112 + tdata->auth_tag.len);
8113 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8114 tdata->plaintext.len);
8117 /* Create AEAD operation */
8118 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8119 tdata, digest_mem, digest_phys);
8124 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8126 ut_params->op->sym->m_src = ut_params->ibuf;
8128 ut_params->op->sym->m_dst = ut_params->obuf;
8130 /* Process crypto operation */
8131 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8132 ut_params->op), "failed to process sym crypto op");
8134 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8135 "crypto op processing failed");
8138 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8139 uint8_t *, prepend_len);
8141 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8142 uint8_t *, prepend_len);
8146 fragsz = fragsz_oop;
8148 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8150 tdata->ciphertext.data,
8152 "Ciphertext data not as expected");
8154 buf = ut_params->op->sym->m_src->next;
8156 buf = ut_params->op->sym->m_dst->next;
8158 unsigned int off = fragsz;
8162 ciphertext = rte_pktmbuf_mtod(buf,
8165 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8167 tdata->ciphertext.data + off,
8169 "Ciphertext data not as expected");
8171 off += to_trn_tbl[ecx++];
8175 auth_tag = digest_mem;
8176 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8178 tdata->auth_tag.data,
8179 tdata->auth_tag.len,
8180 "Generated auth tag not as expected");
8186 #define OUT_OF_PLACE 1
8189 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8191 return test_authenticated_encryption_SGL(
8192 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8196 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8198 return test_authenticated_encryption_SGL(
8199 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8203 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8205 return test_authenticated_encryption_SGL(
8206 &gcm_test_case_8, OUT_OF_PLACE, 400,
8207 gcm_test_case_8.plaintext.len);
8211 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8214 return test_authenticated_encryption_SGL(
8215 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8219 test_authentication_verify_fail_when_data_corrupted(
8220 struct crypto_testsuite_params *ts_params,
8221 struct crypto_unittest_params *ut_params,
8222 const struct test_crypto_vector *reference)
8224 return test_authentication_verify_fail_when_data_corruption(
8225 ts_params, ut_params, reference, 1);
8229 test_authentication_verify_fail_when_tag_corrupted(
8230 struct crypto_testsuite_params *ts_params,
8231 struct crypto_unittest_params *ut_params,
8232 const struct test_crypto_vector *reference)
8234 return test_authentication_verify_fail_when_data_corruption(
8235 ts_params, ut_params, reference, 0);
8239 test_authentication_verify_GMAC_fail_when_data_corrupted(
8240 struct crypto_testsuite_params *ts_params,
8241 struct crypto_unittest_params *ut_params,
8242 const struct test_crypto_vector *reference)
8244 return test_authentication_verify_GMAC_fail_when_corruption(
8245 ts_params, ut_params, reference, 1);
8249 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8250 struct crypto_testsuite_params *ts_params,
8251 struct crypto_unittest_params *ut_params,
8252 const struct test_crypto_vector *reference)
8254 return test_authentication_verify_GMAC_fail_when_corruption(
8255 ts_params, ut_params, reference, 0);
8259 test_authenticated_decryption_fail_when_data_corrupted(
8260 struct crypto_testsuite_params *ts_params,
8261 struct crypto_unittest_params *ut_params,
8262 const struct test_crypto_vector *reference)
8264 return test_authenticated_decryption_fail_when_corruption(
8265 ts_params, ut_params, reference, 1);
8269 test_authenticated_decryption_fail_when_tag_corrupted(
8270 struct crypto_testsuite_params *ts_params,
8271 struct crypto_unittest_params *ut_params,
8272 const struct test_crypto_vector *reference)
8274 return test_authenticated_decryption_fail_when_corruption(
8275 ts_params, ut_params, reference, 0);
8279 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8281 return test_authentication_verify_fail_when_data_corrupted(
8282 &testsuite_params, &unittest_params,
8283 &hmac_sha1_test_crypto_vector);
8287 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8289 return test_authentication_verify_fail_when_tag_corrupted(
8290 &testsuite_params, &unittest_params,
8291 &hmac_sha1_test_crypto_vector);
8295 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8297 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8298 &testsuite_params, &unittest_params,
8299 &aes128_gmac_test_vector);
8303 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8305 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8306 &testsuite_params, &unittest_params,
8307 &aes128_gmac_test_vector);
8311 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8313 return test_authenticated_decryption_fail_when_data_corrupted(
8316 &aes128cbc_hmac_sha1_test_vector);
8320 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8322 return test_authenticated_decryption_fail_when_tag_corrupted(
8325 &aes128cbc_hmac_sha1_test_vector);
8328 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8330 /* global AESNI slave IDs for the scheduler test */
8331 uint8_t aesni_ids[2];
8334 test_scheduler_attach_slave_op(void)
8336 struct crypto_testsuite_params *ts_params = &testsuite_params;
8337 uint8_t sched_id = ts_params->valid_devs[0];
8338 uint32_t nb_devs, i, nb_devs_attached = 0;
8342 /* create 2 AESNI_MB if necessary */
8343 nb_devs = rte_cryptodev_device_count_by_driver(
8344 rte_cryptodev_driver_id_get(
8345 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8347 for (i = nb_devs; i < 2; i++) {
8348 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8349 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8351 ret = rte_vdev_init(vdev_name, NULL);
8353 TEST_ASSERT(ret == 0,
8354 "Failed to create instance %u of"
8356 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8360 /* attach 2 AESNI_MB cdevs */
8361 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8363 struct rte_cryptodev_info info;
8365 rte_cryptodev_info_get(i, &info);
8366 if (info.driver_id != rte_cryptodev_driver_id_get(
8367 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8371 * Create the session mempool again, since now there are new devices
8372 * to use the mempool.
8374 if (ts_params->session_mpool) {
8375 rte_mempool_free(ts_params->session_mpool);
8376 ts_params->session_mpool = NULL;
8378 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8381 * Create mempool with maximum number of sessions * 2,
8382 * to include the session headers
8384 if (ts_params->session_mpool == NULL) {
8385 ts_params->session_mpool = rte_mempool_create(
8387 info.sym.max_nb_sessions * 2,
8389 0, 0, NULL, NULL, NULL,
8390 NULL, SOCKET_ID_ANY,
8393 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8394 "session mempool allocation failed");
8397 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8400 TEST_ASSERT(ret == 0,
8401 "Failed to attach device %u of pmd : %s", i,
8402 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8404 aesni_ids[nb_devs_attached] = (uint8_t)i;
8413 test_scheduler_detach_slave_op(void)
8415 struct crypto_testsuite_params *ts_params = &testsuite_params;
8416 uint8_t sched_id = ts_params->valid_devs[0];
8420 for (i = 0; i < 2; i++) {
8421 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8423 TEST_ASSERT(ret == 0,
8424 "Failed to detach device %u", aesni_ids[i]);
8431 test_scheduler_mode_op(void)
8433 struct crypto_testsuite_params *ts_params = &testsuite_params;
8434 uint8_t sched_id = ts_params->valid_devs[0];
8435 struct rte_cryptodev_scheduler_ops op = {0};
8436 struct rte_cryptodev_scheduler dummy_scheduler = {
8437 .description = "dummy scheduler to test mode",
8438 .name = "dummy scheduler",
8439 .mode = CDEV_SCHED_MODE_USERDEFINED,
8444 /* set user defined mode */
8445 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8447 TEST_ASSERT(ret == 0,
8448 "Failed to set cdev %u to user defined mode", sched_id);
8450 /* set round robin mode */
8451 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8452 CDEV_SCHED_MODE_ROUNDROBIN);
8453 TEST_ASSERT(ret == 0,
8454 "Failed to set cdev %u to round-robin mode", sched_id);
8455 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8456 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8462 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8463 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8464 .setup = testsuite_setup,
8465 .teardown = testsuite_teardown,
8466 .unit_test_cases = {
8467 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8468 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8469 TEST_CASE_ST(ut_setup, ut_teardown,
8470 test_AES_chain_scheduler_all),
8471 TEST_CASE_ST(ut_setup, ut_teardown,
8472 test_AES_cipheronly_scheduler_all),
8473 TEST_CASE_ST(ut_setup, ut_teardown,
8474 test_authonly_scheduler_all),
8475 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8476 TEST_CASES_END() /**< NULL terminate unit test array */
8480 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8482 static struct unit_test_suite cryptodev_qat_testsuite = {
8483 .suite_name = "Crypto QAT Unit Test Suite",
8484 .setup = testsuite_setup,
8485 .teardown = testsuite_teardown,
8486 .unit_test_cases = {
8487 TEST_CASE_ST(ut_setup, ut_teardown,
8488 test_device_configure_invalid_dev_id),
8489 TEST_CASE_ST(ut_setup, ut_teardown,
8490 test_device_configure_invalid_queue_pair_ids),
8491 TEST_CASE_ST(ut_setup, ut_teardown,
8492 test_queue_pair_descriptor_setup),
8493 TEST_CASE_ST(ut_setup, ut_teardown,
8494 test_multi_session),
8496 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8497 TEST_CASE_ST(ut_setup, ut_teardown,
8498 test_AES_cipheronly_qat_all),
8499 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 test_3DES_cipheronly_qat_all),
8502 TEST_CASE_ST(ut_setup, ut_teardown,
8503 test_DES_cipheronly_qat_all),
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_AES_docsis_qat_all),
8506 TEST_CASE_ST(ut_setup, ut_teardown,
8507 test_DES_docsis_qat_all),
8508 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8509 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8511 /** AES CCM Authenticated Encryption 128 bits key */
8512 TEST_CASE_ST(ut_setup, ut_teardown,
8513 test_AES_CCM_authenticated_encryption_test_case_128_1),
8514 TEST_CASE_ST(ut_setup, ut_teardown,
8515 test_AES_CCM_authenticated_encryption_test_case_128_2),
8516 TEST_CASE_ST(ut_setup, ut_teardown,
8517 test_AES_CCM_authenticated_encryption_test_case_128_3),
8519 /** AES CCM Authenticated Decryption 128 bits key*/
8520 TEST_CASE_ST(ut_setup, ut_teardown,
8521 test_AES_CCM_authenticated_decryption_test_case_128_1),
8522 TEST_CASE_ST(ut_setup, ut_teardown,
8523 test_AES_CCM_authenticated_decryption_test_case_128_2),
8524 TEST_CASE_ST(ut_setup, ut_teardown,
8525 test_AES_CCM_authenticated_decryption_test_case_128_3),
8527 /** AES GCM Authenticated Encryption */
8528 TEST_CASE_ST(ut_setup, ut_teardown,
8529 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8530 TEST_CASE_ST(ut_setup, ut_teardown,
8531 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8532 TEST_CASE_ST(ut_setup, ut_teardown,
8533 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8534 TEST_CASE_ST(ut_setup, ut_teardown,
8535 test_AES_GCM_authenticated_encryption_test_case_1),
8536 TEST_CASE_ST(ut_setup, ut_teardown,
8537 test_AES_GCM_authenticated_encryption_test_case_2),
8538 TEST_CASE_ST(ut_setup, ut_teardown,
8539 test_AES_GCM_authenticated_encryption_test_case_3),
8540 TEST_CASE_ST(ut_setup, ut_teardown,
8541 test_AES_GCM_authenticated_encryption_test_case_4),
8542 TEST_CASE_ST(ut_setup, ut_teardown,
8543 test_AES_GCM_authenticated_encryption_test_case_5),
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_AES_GCM_authenticated_encryption_test_case_6),
8546 TEST_CASE_ST(ut_setup, ut_teardown,
8547 test_AES_GCM_authenticated_encryption_test_case_7),
8549 /** AES GCM Authenticated Decryption */
8550 TEST_CASE_ST(ut_setup, ut_teardown,
8551 test_AES_GCM_authenticated_decryption_test_case_1),
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_AES_GCM_authenticated_decryption_test_case_2),
8554 TEST_CASE_ST(ut_setup, ut_teardown,
8555 test_AES_GCM_authenticated_decryption_test_case_3),
8556 TEST_CASE_ST(ut_setup, ut_teardown,
8557 test_AES_GCM_authenticated_decryption_test_case_4),
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_AES_GCM_authenticated_decryption_test_case_5),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_AES_GCM_authenticated_decryption_test_case_6),
8562 TEST_CASE_ST(ut_setup, ut_teardown,
8563 test_AES_GCM_authenticated_decryption_test_case_7),
8565 /** AES GCM Authenticated Encryption 192 bits key */
8566 TEST_CASE_ST(ut_setup, ut_teardown,
8567 test_AES_GCM_auth_encryption_test_case_192_1),
8568 TEST_CASE_ST(ut_setup, ut_teardown,
8569 test_AES_GCM_auth_encryption_test_case_192_2),
8570 TEST_CASE_ST(ut_setup, ut_teardown,
8571 test_AES_GCM_auth_encryption_test_case_192_3),
8572 TEST_CASE_ST(ut_setup, ut_teardown,
8573 test_AES_GCM_auth_encryption_test_case_192_4),
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_AES_GCM_auth_encryption_test_case_192_5),
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_AES_GCM_auth_encryption_test_case_192_6),
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_AES_GCM_auth_encryption_test_case_192_7),
8581 /** AES GCM Authenticated Decryption 192 bits key */
8582 TEST_CASE_ST(ut_setup, ut_teardown,
8583 test_AES_GCM_auth_decryption_test_case_192_1),
8584 TEST_CASE_ST(ut_setup, ut_teardown,
8585 test_AES_GCM_auth_decryption_test_case_192_2),
8586 TEST_CASE_ST(ut_setup, ut_teardown,
8587 test_AES_GCM_auth_decryption_test_case_192_3),
8588 TEST_CASE_ST(ut_setup, ut_teardown,
8589 test_AES_GCM_auth_decryption_test_case_192_4),
8590 TEST_CASE_ST(ut_setup, ut_teardown,
8591 test_AES_GCM_auth_decryption_test_case_192_5),
8592 TEST_CASE_ST(ut_setup, ut_teardown,
8593 test_AES_GCM_auth_decryption_test_case_192_6),
8594 TEST_CASE_ST(ut_setup, ut_teardown,
8595 test_AES_GCM_auth_decryption_test_case_192_7),
8597 /** AES GCM Authenticated Encryption 256 bits key */
8598 TEST_CASE_ST(ut_setup, ut_teardown,
8599 test_AES_GCM_auth_encryption_test_case_256_1),
8600 TEST_CASE_ST(ut_setup, ut_teardown,
8601 test_AES_GCM_auth_encryption_test_case_256_2),
8602 TEST_CASE_ST(ut_setup, ut_teardown,
8603 test_AES_GCM_auth_encryption_test_case_256_3),
8604 TEST_CASE_ST(ut_setup, ut_teardown,
8605 test_AES_GCM_auth_encryption_test_case_256_4),
8606 TEST_CASE_ST(ut_setup, ut_teardown,
8607 test_AES_GCM_auth_encryption_test_case_256_5),
8608 TEST_CASE_ST(ut_setup, ut_teardown,
8609 test_AES_GCM_auth_encryption_test_case_256_6),
8610 TEST_CASE_ST(ut_setup, ut_teardown,
8611 test_AES_GCM_auth_encryption_test_case_256_7),
8613 /** AES GMAC Authentication */
8614 TEST_CASE_ST(ut_setup, ut_teardown,
8615 test_AES_GMAC_authentication_test_case_1),
8616 TEST_CASE_ST(ut_setup, ut_teardown,
8617 test_AES_GMAC_authentication_verify_test_case_1),
8618 TEST_CASE_ST(ut_setup, ut_teardown,
8619 test_AES_GMAC_authentication_test_case_2),
8620 TEST_CASE_ST(ut_setup, ut_teardown,
8621 test_AES_GMAC_authentication_verify_test_case_2),
8622 TEST_CASE_ST(ut_setup, ut_teardown,
8623 test_AES_GMAC_authentication_test_case_3),
8624 TEST_CASE_ST(ut_setup, ut_teardown,
8625 test_AES_GMAC_authentication_verify_test_case_3),
8627 /** SNOW 3G encrypt only (UEA2) */
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_snow3g_encryption_test_case_1),
8630 TEST_CASE_ST(ut_setup, ut_teardown,
8631 test_snow3g_encryption_test_case_2),
8632 TEST_CASE_ST(ut_setup, ut_teardown,
8633 test_snow3g_encryption_test_case_3),
8634 TEST_CASE_ST(ut_setup, ut_teardown,
8635 test_snow3g_encryption_test_case_4),
8636 TEST_CASE_ST(ut_setup, ut_teardown,
8637 test_snow3g_encryption_test_case_5),
8639 TEST_CASE_ST(ut_setup, ut_teardown,
8640 test_snow3g_encryption_test_case_1_oop),
8641 TEST_CASE_ST(ut_setup, ut_teardown,
8642 test_snow3g_decryption_test_case_1_oop),
8644 /** SNOW 3G decrypt only (UEA2) */
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_snow3g_decryption_test_case_1),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_snow3g_decryption_test_case_2),
8649 TEST_CASE_ST(ut_setup, ut_teardown,
8650 test_snow3g_decryption_test_case_3),
8651 TEST_CASE_ST(ut_setup, ut_teardown,
8652 test_snow3g_decryption_test_case_4),
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_snow3g_decryption_test_case_5),
8655 TEST_CASE_ST(ut_setup, ut_teardown,
8656 test_snow3g_hash_generate_test_case_1),
8657 TEST_CASE_ST(ut_setup, ut_teardown,
8658 test_snow3g_hash_generate_test_case_2),
8659 TEST_CASE_ST(ut_setup, ut_teardown,
8660 test_snow3g_hash_generate_test_case_3),
8661 TEST_CASE_ST(ut_setup, ut_teardown,
8662 test_snow3g_hash_verify_test_case_1),
8663 TEST_CASE_ST(ut_setup, ut_teardown,
8664 test_snow3g_hash_verify_test_case_2),
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_snow3g_hash_verify_test_case_3),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_snow3g_cipher_auth_test_case_1),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_snow3g_auth_cipher_test_case_1),
8672 /** ZUC encrypt only (EEA3) */
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_zuc_encryption_test_case_1),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_zuc_encryption_test_case_2),
8677 TEST_CASE_ST(ut_setup, ut_teardown,
8678 test_zuc_encryption_test_case_3),
8679 TEST_CASE_ST(ut_setup, ut_teardown,
8680 test_zuc_encryption_test_case_4),
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_zuc_encryption_test_case_5),
8684 /** ZUC authenticate (EIA3) */
8685 TEST_CASE_ST(ut_setup, ut_teardown,
8686 test_zuc_hash_generate_test_case_6),
8687 TEST_CASE_ST(ut_setup, ut_teardown,
8688 test_zuc_hash_generate_test_case_7),
8689 TEST_CASE_ST(ut_setup, ut_teardown,
8690 test_zuc_hash_generate_test_case_8),
8692 /** ZUC alg-chain (EEA3/EIA3) */
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 test_zuc_cipher_auth_test_case_1),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_zuc_cipher_auth_test_case_2),
8698 /** HMAC_MD5 Authentication */
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_MD5_HMAC_generate_case_1),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_MD5_HMAC_verify_case_1),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 test_MD5_HMAC_generate_case_2),
8705 TEST_CASE_ST(ut_setup, ut_teardown,
8706 test_MD5_HMAC_verify_case_2),
8709 TEST_CASE_ST(ut_setup, ut_teardown,
8710 test_null_auth_only_operation),
8711 TEST_CASE_ST(ut_setup, ut_teardown,
8712 test_null_cipher_only_operation),
8713 TEST_CASE_ST(ut_setup, ut_teardown,
8714 test_null_cipher_auth_operation),
8715 TEST_CASE_ST(ut_setup, ut_teardown,
8716 test_null_auth_cipher_operation),
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 test_kasumi_hash_generate_test_case_1),
8721 TEST_CASE_ST(ut_setup, ut_teardown,
8722 test_kasumi_hash_generate_test_case_2),
8723 TEST_CASE_ST(ut_setup, ut_teardown,
8724 test_kasumi_hash_generate_test_case_3),
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 test_kasumi_hash_generate_test_case_4),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_kasumi_hash_generate_test_case_5),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_kasumi_hash_generate_test_case_6),
8732 TEST_CASE_ST(ut_setup, ut_teardown,
8733 test_kasumi_hash_verify_test_case_1),
8734 TEST_CASE_ST(ut_setup, ut_teardown,
8735 test_kasumi_hash_verify_test_case_2),
8736 TEST_CASE_ST(ut_setup, ut_teardown,
8737 test_kasumi_hash_verify_test_case_3),
8738 TEST_CASE_ST(ut_setup, ut_teardown,
8739 test_kasumi_hash_verify_test_case_4),
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_kasumi_hash_verify_test_case_5),
8743 TEST_CASE_ST(ut_setup, ut_teardown,
8744 test_kasumi_encryption_test_case_1),
8745 TEST_CASE_ST(ut_setup, ut_teardown,
8746 test_kasumi_encryption_test_case_3),
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_kasumi_auth_cipher_test_case_1),
8749 TEST_CASE_ST(ut_setup, ut_teardown,
8750 test_kasumi_cipher_auth_test_case_1),
8752 /** Negative tests */
8753 TEST_CASE_ST(ut_setup, ut_teardown,
8754 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8755 TEST_CASE_ST(ut_setup, ut_teardown,
8756 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8757 TEST_CASE_ST(ut_setup, ut_teardown,
8758 authentication_verify_AES128_GMAC_fail_data_corrupt),
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8763 TEST_CASE_ST(ut_setup, ut_teardown,
8764 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8766 TEST_CASES_END() /**< NULL terminate unit test array */
8770 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8771 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8772 .setup = testsuite_setup,
8773 .teardown = testsuite_teardown,
8774 .unit_test_cases = {
8775 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8776 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8777 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8778 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8779 TEST_CASE_ST(ut_setup, ut_teardown,
8780 test_DES_cipheronly_mb_all),
8781 TEST_CASE_ST(ut_setup, ut_teardown,
8782 test_DES_docsis_mb_all),
8783 TEST_CASE_ST(ut_setup, ut_teardown,
8784 test_AES_CCM_authenticated_encryption_test_case_128_1),
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_AES_CCM_authenticated_decryption_test_case_128_1),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_AES_CCM_authenticated_encryption_test_case_128_2),
8789 TEST_CASE_ST(ut_setup, ut_teardown,
8790 test_AES_CCM_authenticated_decryption_test_case_128_2),
8791 TEST_CASE_ST(ut_setup, ut_teardown,
8792 test_AES_CCM_authenticated_encryption_test_case_128_3),
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_AES_CCM_authenticated_decryption_test_case_128_3),
8796 TEST_CASES_END() /**< NULL terminate unit test array */
8800 static struct unit_test_suite cryptodev_openssl_testsuite = {
8801 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8802 .setup = testsuite_setup,
8803 .teardown = testsuite_teardown,
8804 .unit_test_cases = {
8805 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_multi_session_random_usage),
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_chain_openssl_all),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_cipheronly_openssl_all),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_3DES_chain_openssl_all),
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_3DES_cipheronly_openssl_all),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_DES_cipheronly_openssl_all),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_DES_docsis_openssl_all),
8820 TEST_CASE_ST(ut_setup, ut_teardown,
8821 test_authonly_openssl_all),
8823 /** AES GCM Authenticated Encryption */
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_AES_GCM_authenticated_encryption_test_case_1),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GCM_authenticated_encryption_test_case_2),
8828 TEST_CASE_ST(ut_setup, ut_teardown,
8829 test_AES_GCM_authenticated_encryption_test_case_3),
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_AES_GCM_authenticated_encryption_test_case_4),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_AES_GCM_authenticated_encryption_test_case_5),
8834 TEST_CASE_ST(ut_setup, ut_teardown,
8835 test_AES_GCM_authenticated_encryption_test_case_6),
8836 TEST_CASE_ST(ut_setup, ut_teardown,
8837 test_AES_GCM_authenticated_encryption_test_case_7),
8839 /** AES GCM Authenticated Decryption */
8840 TEST_CASE_ST(ut_setup, ut_teardown,
8841 test_AES_GCM_authenticated_decryption_test_case_1),
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_AES_GCM_authenticated_decryption_test_case_2),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_AES_GCM_authenticated_decryption_test_case_3),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_AES_GCM_authenticated_decryption_test_case_4),
8848 TEST_CASE_ST(ut_setup, ut_teardown,
8849 test_AES_GCM_authenticated_decryption_test_case_5),
8850 TEST_CASE_ST(ut_setup, ut_teardown,
8851 test_AES_GCM_authenticated_decryption_test_case_6),
8852 TEST_CASE_ST(ut_setup, ut_teardown,
8853 test_AES_GCM_authenticated_decryption_test_case_7),
8856 /** AES GCM Authenticated Encryption 192 bits key */
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_AES_GCM_auth_encryption_test_case_192_1),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_AES_GCM_auth_encryption_test_case_192_2),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_AES_GCM_auth_encryption_test_case_192_3),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_AES_GCM_auth_encryption_test_case_192_4),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_AES_GCM_auth_encryption_test_case_192_5),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_AES_GCM_auth_encryption_test_case_192_6),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_AES_GCM_auth_encryption_test_case_192_7),
8872 /** AES GCM Authenticated Decryption 192 bits key */
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_AES_GCM_auth_decryption_test_case_192_1),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_AES_GCM_auth_decryption_test_case_192_2),
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_AES_GCM_auth_decryption_test_case_192_3),
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 test_AES_GCM_auth_decryption_test_case_192_4),
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_AES_GCM_auth_decryption_test_case_192_5),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_AES_GCM_auth_decryption_test_case_192_6),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_AES_GCM_auth_decryption_test_case_192_7),
8888 /** AES GCM Authenticated Encryption 256 bits key */
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_AES_GCM_auth_encryption_test_case_256_1),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_AES_GCM_auth_encryption_test_case_256_2),
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_AES_GCM_auth_encryption_test_case_256_3),
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_AES_GCM_auth_encryption_test_case_256_4),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_AES_GCM_auth_encryption_test_case_256_5),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_AES_GCM_auth_encryption_test_case_256_6),
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_GCM_auth_encryption_test_case_256_7),
8904 /** AES GCM Authenticated Decryption 256 bits key */
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_GCM_auth_decryption_test_case_256_1),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_AES_GCM_auth_decryption_test_case_256_2),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_AES_GCM_auth_decryption_test_case_256_3),
8911 TEST_CASE_ST(ut_setup, ut_teardown,
8912 test_AES_GCM_auth_decryption_test_case_256_4),
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_AES_GCM_auth_decryption_test_case_256_5),
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_AES_GCM_auth_decryption_test_case_256_6),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_AES_GCM_auth_decryption_test_case_256_7),
8920 /** AES GMAC Authentication */
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_AES_GMAC_authentication_test_case_1),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_AES_GMAC_authentication_verify_test_case_1),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_AES_GMAC_authentication_test_case_2),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_AES_GMAC_authentication_verify_test_case_2),
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_AES_GMAC_authentication_test_case_3),
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_AES_GMAC_authentication_verify_test_case_3),
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_AES_GMAC_authentication_test_case_4),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_AES_GMAC_authentication_verify_test_case_4),
8938 /** AES CCM Authenticated Encryption 128 bits key */
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 test_AES_CCM_authenticated_encryption_test_case_128_1),
8941 TEST_CASE_ST(ut_setup, ut_teardown,
8942 test_AES_CCM_authenticated_encryption_test_case_128_2),
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 test_AES_CCM_authenticated_encryption_test_case_128_3),
8946 /** AES CCM Authenticated Decryption 128 bits key*/
8947 TEST_CASE_ST(ut_setup, ut_teardown,
8948 test_AES_CCM_authenticated_decryption_test_case_128_1),
8949 TEST_CASE_ST(ut_setup, ut_teardown,
8950 test_AES_CCM_authenticated_decryption_test_case_128_2),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_AES_CCM_authenticated_decryption_test_case_128_3),
8954 /** AES CCM Authenticated Encryption 192 bits key */
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 test_AES_CCM_authenticated_encryption_test_case_192_1),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_AES_CCM_authenticated_encryption_test_case_192_2),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_AES_CCM_authenticated_encryption_test_case_192_3),
8962 /** AES CCM Authenticated Decryption 192 bits key*/
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 test_AES_CCM_authenticated_decryption_test_case_192_1),
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 test_AES_CCM_authenticated_decryption_test_case_192_2),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 test_AES_CCM_authenticated_decryption_test_case_192_3),
8970 /** AES CCM Authenticated Encryption 256 bits key */
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 test_AES_CCM_authenticated_encryption_test_case_256_1),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 test_AES_CCM_authenticated_encryption_test_case_256_2),
8975 TEST_CASE_ST(ut_setup, ut_teardown,
8976 test_AES_CCM_authenticated_encryption_test_case_256_3),
8978 /** AES CCM Authenticated Decryption 256 bits key*/
8979 TEST_CASE_ST(ut_setup, ut_teardown,
8980 test_AES_CCM_authenticated_decryption_test_case_256_1),
8981 TEST_CASE_ST(ut_setup, ut_teardown,
8982 test_AES_CCM_authenticated_decryption_test_case_256_2),
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_CCM_authenticated_decryption_test_case_256_3),
8986 /** Scatter-Gather */
8987 TEST_CASE_ST(ut_setup, ut_teardown,
8988 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8990 /** Negative tests */
8991 TEST_CASE_ST(ut_setup, ut_teardown,
8992 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8993 TEST_CASE_ST(ut_setup, ut_teardown,
8994 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 authentication_verify_AES128_GMAC_fail_data_corrupt),
8997 TEST_CASE_ST(ut_setup, ut_teardown,
8998 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9004 TEST_CASES_END() /**< NULL terminate unit test array */
9008 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9009 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9010 .setup = testsuite_setup,
9011 .teardown = testsuite_teardown,
9012 .unit_test_cases = {
9013 /** AES GCM Authenticated Encryption */
9014 TEST_CASE_ST(ut_setup, ut_teardown,
9015 test_AES_GCM_authenticated_encryption_test_case_1),
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_GCM_authenticated_encryption_test_case_2),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_AES_GCM_authenticated_encryption_test_case_3),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_authenticated_encryption_test_case_4),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_authenticated_encryption_test_case_5),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_GCM_authenticated_encryption_test_case_6),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_authenticated_encryption_test_case_7),
9029 /** AES GCM Authenticated Decryption */
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_GCM_authenticated_decryption_test_case_1),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_GCM_authenticated_decryption_test_case_2),
9034 TEST_CASE_ST(ut_setup, ut_teardown,
9035 test_AES_GCM_authenticated_decryption_test_case_3),
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_authenticated_decryption_test_case_4),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_authenticated_decryption_test_case_5),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_AES_GCM_authenticated_decryption_test_case_6),
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_authenticated_decryption_test_case_7),
9045 /** AES GCM Authenticated Encryption 192 bits key */
9046 TEST_CASE_ST(ut_setup, ut_teardown,
9047 test_AES_GCM_auth_encryption_test_case_192_1),
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_auth_encryption_test_case_192_2),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GCM_auth_encryption_test_case_192_3),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_auth_encryption_test_case_192_4),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_auth_encryption_test_case_192_5),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GCM_auth_encryption_test_case_192_6),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GCM_auth_encryption_test_case_192_7),
9061 /** AES GCM Authenticated Decryption 192 bits key */
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_GCM_auth_decryption_test_case_192_1),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GCM_auth_decryption_test_case_192_2),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GCM_auth_decryption_test_case_192_3),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GCM_auth_decryption_test_case_192_4),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GCM_auth_decryption_test_case_192_5),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GCM_auth_decryption_test_case_192_6),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_GCM_auth_decryption_test_case_192_7),
9077 /** AES GCM Authenticated Encryption 256 bits key */
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 test_AES_GCM_auth_encryption_test_case_256_1),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GCM_auth_encryption_test_case_256_2),
9082 TEST_CASE_ST(ut_setup, ut_teardown,
9083 test_AES_GCM_auth_encryption_test_case_256_3),
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GCM_auth_encryption_test_case_256_4),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GCM_auth_encryption_test_case_256_5),
9088 TEST_CASE_ST(ut_setup, ut_teardown,
9089 test_AES_GCM_auth_encryption_test_case_256_6),
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_AES_GCM_auth_encryption_test_case_256_7),
9093 /** AES GCM Authenticated Decryption 256 bits key */
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_AES_GCM_auth_decryption_test_case_256_1),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_auth_decryption_test_case_256_2),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_auth_decryption_test_case_256_3),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_auth_decryption_test_case_256_4),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_auth_decryption_test_case_256_5),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_auth_decryption_test_case_256_6),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GCM_auth_decryption_test_case_256_7),
9109 /** AES GCM Authenticated Encryption big aad size */
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_AES_GCM_auth_encryption_test_case_aad_1),
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_AES_GCM_auth_encryption_test_case_aad_2),
9115 /** AES GCM Authenticated Decryption big aad size */
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_AES_GCM_auth_decryption_test_case_aad_1),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_AES_GCM_auth_decryption_test_case_aad_2),
9121 /** AES GMAC Authentication */
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_GMAC_authentication_test_case_1),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_AES_GMAC_authentication_verify_test_case_1),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_AES_GMAC_authentication_test_case_3),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_AES_GMAC_authentication_verify_test_case_3),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_AES_GMAC_authentication_test_case_4),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_AES_GMAC_authentication_verify_test_case_4),
9135 /** Negative tests */
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 authentication_verify_AES128_GMAC_fail_data_corrupt),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9141 /** Out of place tests */
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9147 /** Session-less tests */
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9153 /** Scatter-Gather */
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9157 TEST_CASES_END() /**< NULL terminate unit test array */
9161 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9162 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9163 .setup = testsuite_setup,
9164 .teardown = testsuite_teardown,
9165 .unit_test_cases = {
9166 /** KASUMI encrypt only (UEA1) */
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_kasumi_encryption_test_case_1),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_kasumi_encryption_test_case_1_sgl),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_kasumi_encryption_test_case_2),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_kasumi_encryption_test_case_3),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_kasumi_encryption_test_case_4),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_kasumi_encryption_test_case_5),
9179 /** KASUMI decrypt only (UEA1) */
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_kasumi_decryption_test_case_1),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_kasumi_decryption_test_case_2),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_kasumi_decryption_test_case_3),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_kasumi_decryption_test_case_4),
9188 TEST_CASE_ST(ut_setup, ut_teardown,
9189 test_kasumi_decryption_test_case_5),
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_kasumi_encryption_test_case_1_oop),
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_kasumi_encryption_test_case_1_oop_sgl),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_kasumi_decryption_test_case_1_oop),
9200 /** KASUMI hash only (UIA1) */
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_kasumi_hash_generate_test_case_1),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_kasumi_hash_generate_test_case_2),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_kasumi_hash_generate_test_case_3),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_kasumi_hash_generate_test_case_4),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_kasumi_hash_generate_test_case_5),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_kasumi_hash_generate_test_case_6),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 test_kasumi_hash_verify_test_case_1),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 test_kasumi_hash_verify_test_case_2),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_kasumi_hash_verify_test_case_3),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_kasumi_hash_verify_test_case_4),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_kasumi_hash_verify_test_case_5),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_kasumi_auth_cipher_test_case_1),
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_kasumi_cipher_auth_test_case_1),
9227 TEST_CASES_END() /**< NULL terminate unit test array */
9230 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9231 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9232 .setup = testsuite_setup,
9233 .teardown = testsuite_teardown,
9234 .unit_test_cases = {
9235 /** SNOW 3G encrypt only (UEA2) */
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_snow3g_encryption_test_case_1),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_snow3g_encryption_test_case_2),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 test_snow3g_encryption_test_case_3),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_snow3g_encryption_test_case_4),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_snow3g_encryption_test_case_5),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_snow3g_encryption_test_case_1_oop),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_snow3g_encryption_test_case_1_oop_sgl),
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_snow3g_decryption_test_case_1_oop),
9254 TEST_CASE_ST(ut_setup, ut_teardown,
9255 test_snow3g_encryption_test_case_1_offset_oop),
9257 /** SNOW 3G decrypt only (UEA2) */
9258 TEST_CASE_ST(ut_setup, ut_teardown,
9259 test_snow3g_decryption_test_case_1),
9260 TEST_CASE_ST(ut_setup, ut_teardown,
9261 test_snow3g_decryption_test_case_2),
9262 TEST_CASE_ST(ut_setup, ut_teardown,
9263 test_snow3g_decryption_test_case_3),
9264 TEST_CASE_ST(ut_setup, ut_teardown,
9265 test_snow3g_decryption_test_case_4),
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_snow3g_decryption_test_case_5),
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_snow3g_hash_generate_test_case_1),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_snow3g_hash_generate_test_case_2),
9272 TEST_CASE_ST(ut_setup, ut_teardown,
9273 test_snow3g_hash_generate_test_case_3),
9274 /* Tests with buffers which length is not byte-aligned */
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_snow3g_hash_generate_test_case_4),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_snow3g_hash_generate_test_case_5),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_snow3g_hash_generate_test_case_6),
9281 TEST_CASE_ST(ut_setup, ut_teardown,
9282 test_snow3g_hash_verify_test_case_1),
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_snow3g_hash_verify_test_case_2),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_snow3g_hash_verify_test_case_3),
9287 /* Tests with buffers which length is not byte-aligned */
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_snow3g_hash_verify_test_case_4),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_snow3g_hash_verify_test_case_5),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_snow3g_hash_verify_test_case_6),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_snow3g_cipher_auth_test_case_1),
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_snow3g_auth_cipher_test_case_1),
9299 TEST_CASES_END() /**< NULL terminate unit test array */
9303 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9304 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9305 .setup = testsuite_setup,
9306 .teardown = testsuite_teardown,
9307 .unit_test_cases = {
9308 /** ZUC encrypt only (EEA3) */
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_zuc_encryption_test_case_1),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_zuc_encryption_test_case_2),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_zuc_encryption_test_case_3),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_zuc_encryption_test_case_4),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_zuc_encryption_test_case_5),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_zuc_hash_generate_test_case_1),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_zuc_hash_generate_test_case_2),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_zuc_hash_generate_test_case_3),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_zuc_hash_generate_test_case_4),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_zuc_hash_generate_test_case_5),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_zuc_encryption_test_case_6_sgl),
9331 TEST_CASES_END() /**< NULL terminate unit test array */
9335 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9336 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9337 .setup = testsuite_setup,
9338 .teardown = testsuite_teardown,
9339 .unit_test_cases = {
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_device_configure_invalid_dev_id),
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_multi_session),
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_AES_chain_dpaa_sec_all),
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_3DES_chain_dpaa_sec_all),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_cipheronly_dpaa_sec_all),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_3DES_cipheronly_dpaa_sec_all),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_authonly_dpaa_sec_all),
9356 /** AES GCM Authenticated Encryption */
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_AES_GCM_authenticated_encryption_test_case_1),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_AES_GCM_authenticated_encryption_test_case_2),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_GCM_authenticated_encryption_test_case_3),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GCM_authenticated_encryption_test_case_4),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GCM_authenticated_encryption_test_case_5),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_GCM_authenticated_encryption_test_case_6),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 test_AES_GCM_authenticated_encryption_test_case_7),
9372 /** AES GCM Authenticated Decryption */
9373 TEST_CASE_ST(ut_setup, ut_teardown,
9374 test_AES_GCM_authenticated_decryption_test_case_1),
9375 TEST_CASE_ST(ut_setup, ut_teardown,
9376 test_AES_GCM_authenticated_decryption_test_case_2),
9377 TEST_CASE_ST(ut_setup, ut_teardown,
9378 test_AES_GCM_authenticated_decryption_test_case_3),
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_AES_GCM_authenticated_decryption_test_case_4),
9381 TEST_CASE_ST(ut_setup, ut_teardown,
9382 test_AES_GCM_authenticated_decryption_test_case_5),
9383 TEST_CASE_ST(ut_setup, ut_teardown,
9384 test_AES_GCM_authenticated_decryption_test_case_6),
9385 TEST_CASE_ST(ut_setup, ut_teardown,
9386 test_AES_GCM_authenticated_decryption_test_case_7),
9388 /** AES GCM Authenticated Encryption 256 bits key */
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_AES_GCM_auth_encryption_test_case_256_1),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_AES_GCM_auth_encryption_test_case_256_2),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_AES_GCM_auth_encryption_test_case_256_3),
9395 TEST_CASE_ST(ut_setup, ut_teardown,
9396 test_AES_GCM_auth_encryption_test_case_256_4),
9397 TEST_CASE_ST(ut_setup, ut_teardown,
9398 test_AES_GCM_auth_encryption_test_case_256_5),
9399 TEST_CASE_ST(ut_setup, ut_teardown,
9400 test_AES_GCM_auth_encryption_test_case_256_6),
9401 TEST_CASE_ST(ut_setup, ut_teardown,
9402 test_AES_GCM_auth_encryption_test_case_256_7),
9404 /** AES GCM Authenticated Decryption 256 bits key */
9405 TEST_CASE_ST(ut_setup, ut_teardown,
9406 test_AES_GCM_auth_decryption_test_case_256_1),
9407 TEST_CASE_ST(ut_setup, ut_teardown,
9408 test_AES_GCM_auth_decryption_test_case_256_2),
9409 TEST_CASE_ST(ut_setup, ut_teardown,
9410 test_AES_GCM_auth_decryption_test_case_256_3),
9411 TEST_CASE_ST(ut_setup, ut_teardown,
9412 test_AES_GCM_auth_decryption_test_case_256_4),
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 test_AES_GCM_auth_decryption_test_case_256_5),
9415 TEST_CASE_ST(ut_setup, ut_teardown,
9416 test_AES_GCM_auth_decryption_test_case_256_6),
9417 TEST_CASE_ST(ut_setup, ut_teardown,
9418 test_AES_GCM_auth_decryption_test_case_256_7),
9420 /** Out of place tests */
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9426 /** Scatter-Gather */
9427 TEST_CASE_ST(ut_setup, ut_teardown,
9428 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9429 TEST_CASE_ST(ut_setup, ut_teardown,
9430 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9431 TEST_CASE_ST(ut_setup, ut_teardown,
9432 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9433 TEST_CASE_ST(ut_setup, ut_teardown,
9434 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9436 TEST_CASES_END() /**< NULL terminate unit test array */
9440 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9441 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9442 .setup = testsuite_setup,
9443 .teardown = testsuite_teardown,
9444 .unit_test_cases = {
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_device_configure_invalid_dev_id),
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_multi_session),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_chain_dpaa2_sec_all),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_3DES_chain_dpaa2_sec_all),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_cipheronly_dpaa2_sec_all),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_3DES_cipheronly_dpaa2_sec_all),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_authonly_dpaa2_sec_all),
9461 /** AES GCM Authenticated Encryption */
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_authenticated_encryption_test_case_1),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_authenticated_encryption_test_case_2),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_authenticated_encryption_test_case_3),
9468 TEST_CASE_ST(ut_setup, ut_teardown,
9469 test_AES_GCM_authenticated_encryption_test_case_4),
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_AES_GCM_authenticated_encryption_test_case_5),
9472 TEST_CASE_ST(ut_setup, ut_teardown,
9473 test_AES_GCM_authenticated_encryption_test_case_6),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_authenticated_encryption_test_case_7),
9477 /** AES GCM Authenticated Decryption */
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_GCM_authenticated_decryption_test_case_1),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_GCM_authenticated_decryption_test_case_2),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_GCM_authenticated_decryption_test_case_3),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_AES_GCM_authenticated_decryption_test_case_4),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_GCM_authenticated_decryption_test_case_5),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_AES_GCM_authenticated_decryption_test_case_6),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_GCM_authenticated_decryption_test_case_7),
9493 /** AES GCM Authenticated Encryption 192 bits key */
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_AES_GCM_auth_encryption_test_case_192_1),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_AES_GCM_auth_encryption_test_case_192_2),
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_AES_GCM_auth_encryption_test_case_192_3),
9500 TEST_CASE_ST(ut_setup, ut_teardown,
9501 test_AES_GCM_auth_encryption_test_case_192_4),
9502 TEST_CASE_ST(ut_setup, ut_teardown,
9503 test_AES_GCM_auth_encryption_test_case_192_5),
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_AES_GCM_auth_encryption_test_case_192_6),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_AES_GCM_auth_encryption_test_case_192_7),
9509 /** AES GCM Authenticated Decryption 192 bits key */
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_AES_GCM_auth_decryption_test_case_192_1),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_AES_GCM_auth_decryption_test_case_192_2),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_AES_GCM_auth_decryption_test_case_192_3),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_AES_GCM_auth_decryption_test_case_192_4),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_AES_GCM_auth_decryption_test_case_192_5),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_AES_GCM_auth_decryption_test_case_192_6),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_AES_GCM_auth_decryption_test_case_192_7),
9525 /** AES GCM Authenticated Encryption 256 bits key */
9526 TEST_CASE_ST(ut_setup, ut_teardown,
9527 test_AES_GCM_auth_encryption_test_case_256_1),
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_AES_GCM_auth_encryption_test_case_256_2),
9530 TEST_CASE_ST(ut_setup, ut_teardown,
9531 test_AES_GCM_auth_encryption_test_case_256_3),
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 test_AES_GCM_auth_encryption_test_case_256_4),
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 test_AES_GCM_auth_encryption_test_case_256_5),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_AES_GCM_auth_encryption_test_case_256_6),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 test_AES_GCM_auth_encryption_test_case_256_7),
9541 /** AES GCM Authenticated Decryption 256 bits key */
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 test_AES_GCM_auth_decryption_test_case_256_1),
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 test_AES_GCM_auth_decryption_test_case_256_2),
9546 TEST_CASE_ST(ut_setup, ut_teardown,
9547 test_AES_GCM_auth_decryption_test_case_256_3),
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 test_AES_GCM_auth_decryption_test_case_256_4),
9550 TEST_CASE_ST(ut_setup, ut_teardown,
9551 test_AES_GCM_auth_decryption_test_case_256_5),
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_AES_GCM_auth_decryption_test_case_256_6),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_AES_GCM_auth_decryption_test_case_256_7),
9557 /** Out of place tests */
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9563 /** Scatter-Gather */
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9568 TEST_CASE_ST(ut_setup, ut_teardown,
9569 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9570 TEST_CASE_ST(ut_setup, ut_teardown,
9571 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9573 TEST_CASES_END() /**< NULL terminate unit test array */
9577 static struct unit_test_suite cryptodev_null_testsuite = {
9578 .suite_name = "Crypto Device NULL Unit Test Suite",
9579 .setup = testsuite_setup,
9580 .teardown = testsuite_teardown,
9581 .unit_test_cases = {
9582 TEST_CASE_ST(ut_setup, ut_teardown,
9583 test_null_auth_only_operation),
9584 TEST_CASE_ST(ut_setup, ut_teardown,
9585 test_null_cipher_only_operation),
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_null_cipher_auth_operation),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_null_auth_cipher_operation),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_null_invalid_operation),
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_null_burst_operation),
9595 TEST_CASES_END() /**< NULL terminate unit test array */
9599 static struct unit_test_suite cryptodev_armv8_testsuite = {
9600 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9601 .setup = testsuite_setup,
9602 .teardown = testsuite_teardown,
9603 .unit_test_cases = {
9604 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9606 /** Negative tests */
9607 TEST_CASE_ST(ut_setup, ut_teardown,
9608 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9609 TEST_CASE_ST(ut_setup, ut_teardown,
9610 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9612 TEST_CASES_END() /**< NULL terminate unit test array */
9616 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9617 .suite_name = "Crypto Device Marvell Component Test Suite",
9618 .setup = testsuite_setup,
9619 .teardown = testsuite_teardown,
9620 .unit_test_cases = {
9621 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_multi_session_random_usage),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_chain_mrvl_all),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_cipheronly_mrvl_all),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_authonly_mrvl_all),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_3DES_chain_mrvl_all),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_3DES_cipheronly_mrvl_all),
9635 /** Negative tests */
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9645 TEST_CASES_END() /**< NULL terminate unit test array */
9651 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9653 gbl_driver_id = rte_cryptodev_driver_id_get(
9654 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9656 if (gbl_driver_id == -1) {
9657 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9658 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9659 "in config file to run this testsuite.\n");
9660 return TEST_SKIPPED;
9663 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9667 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9669 gbl_driver_id = rte_cryptodev_driver_id_get(
9670 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9672 if (gbl_driver_id == -1) {
9673 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9674 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9675 "in config file to run this testsuite.\n");
9676 return TEST_SKIPPED;
9679 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9683 test_cryptodev_openssl(void)
9685 gbl_driver_id = rte_cryptodev_driver_id_get(
9686 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9688 if (gbl_driver_id == -1) {
9689 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9690 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9691 "in config file to run this testsuite.\n");
9692 return TEST_SKIPPED;
9695 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9699 test_cryptodev_aesni_gcm(void)
9701 gbl_driver_id = rte_cryptodev_driver_id_get(
9702 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9704 if (gbl_driver_id == -1) {
9705 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9706 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9707 "in config file to run this testsuite.\n");
9708 return TEST_SKIPPED;
9711 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9715 test_cryptodev_null(void)
9717 gbl_driver_id = rte_cryptodev_driver_id_get(
9718 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9720 if (gbl_driver_id == -1) {
9721 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9722 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9723 "in config file to run this testsuite.\n");
9724 return TEST_SKIPPED;
9727 return unit_test_suite_runner(&cryptodev_null_testsuite);
9731 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9733 gbl_driver_id = rte_cryptodev_driver_id_get(
9734 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9736 if (gbl_driver_id == -1) {
9737 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9738 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9739 "in config file to run this testsuite.\n");
9740 return TEST_SKIPPED;
9743 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9747 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9749 gbl_driver_id = rte_cryptodev_driver_id_get(
9750 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9752 if (gbl_driver_id == -1) {
9753 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9754 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9755 "in config file to run this testsuite.\n");
9756 return TEST_SKIPPED;
9759 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9763 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9765 gbl_driver_id = rte_cryptodev_driver_id_get(
9766 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9768 if (gbl_driver_id == -1) {
9769 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9770 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9771 "in config file to run this testsuite.\n");
9772 return TEST_SKIPPED;
9775 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9779 test_cryptodev_armv8(void)
9781 gbl_driver_id = rte_cryptodev_driver_id_get(
9782 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9784 if (gbl_driver_id == -1) {
9785 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9786 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9787 "in config file to run this testsuite.\n");
9788 return TEST_SKIPPED;
9791 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9795 test_cryptodev_mrvl(void)
9797 gbl_driver_id = rte_cryptodev_driver_id_get(
9798 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9800 if (gbl_driver_id == -1) {
9801 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9802 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9803 "in config file to run this testsuite.\n");
9804 return TEST_SKIPPED;
9807 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9810 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9813 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9815 gbl_driver_id = rte_cryptodev_driver_id_get(
9816 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9818 if (gbl_driver_id == -1) {
9819 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9820 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9821 "in config file to run this testsuite.\n");
9822 return TEST_SKIPPED;
9825 if (rte_cryptodev_driver_id_get(
9826 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9827 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9828 " enabled in config file to run this testsuite.\n");
9829 return TEST_SKIPPED;
9831 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9834 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9839 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9841 gbl_driver_id = rte_cryptodev_driver_id_get(
9842 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9844 if (gbl_driver_id == -1) {
9845 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9846 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9847 "in config file to run this testsuite.\n");
9848 return TEST_SKIPPED;
9851 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9855 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9857 gbl_driver_id = rte_cryptodev_driver_id_get(
9858 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
9860 if (gbl_driver_id == -1) {
9861 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
9862 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
9863 "in config file to run this testsuite.\n");
9864 return TEST_SKIPPED;
9867 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
9870 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9871 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9872 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9873 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9874 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9875 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9876 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9877 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9878 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9879 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
9880 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
9881 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);