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;
6588 test_null_auth_only_operation(void)
6590 struct crypto_testsuite_params *ts_params = &testsuite_params;
6591 struct crypto_unittest_params *ut_params = &unittest_params;
6593 /* Generate test mbuf data and space for digest */
6594 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6595 catch_22_quote, QUOTE_512_BYTES, 0);
6597 /* Setup HMAC Parameters */
6598 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6599 ut_params->auth_xform.next = NULL;
6601 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6602 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6604 ut_params->sess = rte_cryptodev_sym_session_create(
6605 ts_params->session_mpool);
6607 /* Create Crypto session*/
6608 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6609 ut_params->sess, &ut_params->auth_xform,
6610 ts_params->session_mpool);
6611 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6613 /* Generate Crypto op data structure */
6614 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6615 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6616 TEST_ASSERT_NOT_NULL(ut_params->op,
6617 "Failed to allocate symmetric crypto operation struct");
6619 /* Set crypto operation data parameters */
6620 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6622 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6624 sym_op->m_src = ut_params->ibuf;
6626 sym_op->auth.data.offset = 0;
6627 sym_op->auth.data.length = QUOTE_512_BYTES;
6629 /* Process crypto operation */
6630 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6632 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6634 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6635 "crypto operation processing failed");
6637 return TEST_SUCCESS;
6641 test_null_cipher_auth_operation(void)
6643 struct crypto_testsuite_params *ts_params = &testsuite_params;
6644 struct crypto_unittest_params *ut_params = &unittest_params;
6646 /* Generate test mbuf data and space for digest */
6647 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6648 catch_22_quote, QUOTE_512_BYTES, 0);
6650 /* Setup Cipher Parameters */
6651 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6652 ut_params->cipher_xform.next = &ut_params->auth_xform;
6654 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6655 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6657 /* Setup HMAC Parameters */
6658 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6659 ut_params->auth_xform.next = NULL;
6661 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6662 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6664 ut_params->sess = rte_cryptodev_sym_session_create(
6665 ts_params->session_mpool);
6667 /* Create Crypto session*/
6668 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6669 ut_params->sess, &ut_params->cipher_xform,
6670 ts_params->session_mpool);
6671 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6673 /* Generate Crypto op data structure */
6674 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6675 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6676 TEST_ASSERT_NOT_NULL(ut_params->op,
6677 "Failed to allocate symmetric crypto operation struct");
6679 /* Set crypto operation data parameters */
6680 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6682 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6684 sym_op->m_src = ut_params->ibuf;
6686 sym_op->cipher.data.offset = 0;
6687 sym_op->cipher.data.length = QUOTE_512_BYTES;
6689 sym_op->auth.data.offset = 0;
6690 sym_op->auth.data.length = QUOTE_512_BYTES;
6692 /* Process crypto operation */
6693 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6695 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6697 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6698 "crypto operation processing failed");
6701 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6702 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6705 "Ciphertext data not as expected");
6707 return TEST_SUCCESS;
6711 test_null_auth_cipher_operation(void)
6713 struct crypto_testsuite_params *ts_params = &testsuite_params;
6714 struct crypto_unittest_params *ut_params = &unittest_params;
6716 /* Generate test mbuf data and space for digest */
6717 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6718 catch_22_quote, QUOTE_512_BYTES, 0);
6720 /* Setup Cipher Parameters */
6721 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6722 ut_params->cipher_xform.next = NULL;
6724 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6725 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6727 /* Setup HMAC Parameters */
6728 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6729 ut_params->auth_xform.next = &ut_params->cipher_xform;
6731 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6732 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6734 ut_params->sess = rte_cryptodev_sym_session_create(
6735 ts_params->session_mpool);
6737 /* Create Crypto session*/
6738 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6739 ut_params->sess, &ut_params->cipher_xform,
6740 ts_params->session_mpool);
6741 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6743 /* Generate Crypto op data structure */
6744 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6745 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6746 TEST_ASSERT_NOT_NULL(ut_params->op,
6747 "Failed to allocate symmetric crypto operation struct");
6749 /* Set crypto operation data parameters */
6750 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6752 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6754 sym_op->m_src = ut_params->ibuf;
6756 sym_op->cipher.data.offset = 0;
6757 sym_op->cipher.data.length = QUOTE_512_BYTES;
6759 sym_op->auth.data.offset = 0;
6760 sym_op->auth.data.length = QUOTE_512_BYTES;
6762 /* Process crypto operation */
6763 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6765 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6767 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6768 "crypto operation processing failed");
6771 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6772 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6775 "Ciphertext data not as expected");
6777 return TEST_SUCCESS;
6782 test_null_invalid_operation(void)
6784 struct crypto_testsuite_params *ts_params = &testsuite_params;
6785 struct crypto_unittest_params *ut_params = &unittest_params;
6788 /* Setup Cipher Parameters */
6789 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6790 ut_params->cipher_xform.next = NULL;
6792 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6793 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6795 ut_params->sess = rte_cryptodev_sym_session_create(
6796 ts_params->session_mpool);
6798 /* Create Crypto session*/
6799 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6800 ut_params->sess, &ut_params->cipher_xform,
6801 ts_params->session_mpool);
6802 TEST_ASSERT(ret < 0,
6803 "Session creation succeeded unexpectedly");
6806 /* Setup HMAC Parameters */
6807 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6808 ut_params->auth_xform.next = NULL;
6810 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6811 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6813 ut_params->sess = rte_cryptodev_sym_session_create(
6814 ts_params->session_mpool);
6816 /* Create Crypto session*/
6817 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6818 ut_params->sess, &ut_params->auth_xform,
6819 ts_params->session_mpool);
6820 TEST_ASSERT(ret < 0,
6821 "Session creation succeeded unexpectedly");
6823 return TEST_SUCCESS;
6827 #define NULL_BURST_LENGTH (32)
6830 test_null_burst_operation(void)
6832 struct crypto_testsuite_params *ts_params = &testsuite_params;
6833 struct crypto_unittest_params *ut_params = &unittest_params;
6835 unsigned i, burst_len = NULL_BURST_LENGTH;
6837 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6838 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6840 /* Setup Cipher Parameters */
6841 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6842 ut_params->cipher_xform.next = &ut_params->auth_xform;
6844 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6845 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6847 /* Setup HMAC Parameters */
6848 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6849 ut_params->auth_xform.next = NULL;
6851 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6852 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6854 ut_params->sess = rte_cryptodev_sym_session_create(
6855 ts_params->session_mpool);
6857 /* Create Crypto session*/
6858 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6859 ut_params->sess, &ut_params->cipher_xform,
6860 ts_params->session_mpool);
6861 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6863 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6864 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6865 burst_len, "failed to generate burst of crypto ops");
6867 /* Generate an operation for each mbuf in burst */
6868 for (i = 0; i < burst_len; i++) {
6869 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6871 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6873 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6877 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6879 burst[i]->sym->m_src = m;
6882 /* Process crypto operation */
6883 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6884 0, burst, burst_len),
6886 "Error enqueuing burst");
6888 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6889 0, burst_dequeued, burst_len),
6891 "Error dequeuing burst");
6894 for (i = 0; i < burst_len; i++) {
6896 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6897 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6899 "data not as expected");
6901 rte_pktmbuf_free(burst[i]->sym->m_src);
6902 rte_crypto_op_free(burst[i]);
6905 return TEST_SUCCESS;
6909 generate_gmac_large_plaintext(uint8_t *data)
6913 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6914 memcpy(&data[i], &data[0], 32);
6918 create_gmac_operation(enum rte_crypto_auth_operation op,
6919 const struct gmac_test_data *tdata)
6921 struct crypto_testsuite_params *ts_params = &testsuite_params;
6922 struct crypto_unittest_params *ut_params = &unittest_params;
6923 struct rte_crypto_sym_op *sym_op;
6925 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6927 /* Generate Crypto op data structure */
6928 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6929 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6930 TEST_ASSERT_NOT_NULL(ut_params->op,
6931 "Failed to allocate symmetric crypto operation struct");
6933 sym_op = ut_params->op->sym;
6935 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6936 ut_params->ibuf, tdata->gmac_tag.len);
6937 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6938 "no room to append digest");
6940 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6941 ut_params->ibuf, plaintext_pad_len);
6943 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6944 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6945 tdata->gmac_tag.len);
6946 debug_hexdump(stdout, "digest:",
6947 sym_op->auth.digest.data,
6948 tdata->gmac_tag.len);
6951 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6952 uint8_t *, IV_OFFSET);
6954 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6956 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
6958 sym_op->cipher.data.length = 0;
6959 sym_op->cipher.data.offset = 0;
6961 sym_op->auth.data.offset = 0;
6962 sym_op->auth.data.length = tdata->plaintext.len;
6967 static int create_gmac_session(uint8_t dev_id,
6968 const struct gmac_test_data *tdata,
6969 enum rte_crypto_auth_operation auth_op)
6971 uint8_t auth_key[tdata->key.len];
6973 struct crypto_testsuite_params *ts_params = &testsuite_params;
6974 struct crypto_unittest_params *ut_params = &unittest_params;
6976 memcpy(auth_key, tdata->key.data, tdata->key.len);
6978 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6979 ut_params->auth_xform.next = NULL;
6981 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6982 ut_params->auth_xform.auth.op = auth_op;
6983 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6984 ut_params->auth_xform.auth.key.length = tdata->key.len;
6985 ut_params->auth_xform.auth.key.data = auth_key;
6986 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6987 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6990 ut_params->sess = rte_cryptodev_sym_session_create(
6991 ts_params->session_mpool);
6993 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6994 &ut_params->auth_xform,
6995 ts_params->session_mpool);
6997 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7003 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7005 struct crypto_testsuite_params *ts_params = &testsuite_params;
7006 struct crypto_unittest_params *ut_params = &unittest_params;
7010 uint8_t *auth_tag, *plaintext;
7011 uint16_t plaintext_pad_len;
7013 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7014 "No GMAC length in the source data");
7016 retval = create_gmac_session(ts_params->valid_devs[0],
7017 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7022 if (tdata->plaintext.len > MBUF_SIZE)
7023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7025 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7026 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7027 "Failed to allocate input buffer in mempool");
7029 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7030 rte_pktmbuf_tailroom(ut_params->ibuf));
7032 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7034 * Runtime generate the large plain text instead of use hard code
7035 * plain text vector. It is done to avoid create huge source file
7036 * with the test vector.
7038 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7039 generate_gmac_large_plaintext(tdata->plaintext.data);
7041 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7043 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7045 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7046 debug_hexdump(stdout, "plaintext:", plaintext,
7047 tdata->plaintext.len);
7049 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7055 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7057 ut_params->op->sym->m_src = ut_params->ibuf;
7059 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7060 ut_params->op), "failed to process sym crypto op");
7062 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7063 "crypto op processing failed");
7065 if (ut_params->op->sym->m_dst) {
7066 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7067 uint8_t *, plaintext_pad_len);
7069 auth_tag = plaintext + plaintext_pad_len;
7072 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7074 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7076 tdata->gmac_tag.data,
7077 tdata->gmac_tag.len,
7078 "GMAC Generated auth tag not as expected");
7084 test_AES_GMAC_authentication_test_case_1(void)
7086 return test_AES_GMAC_authentication(&gmac_test_case_1);
7090 test_AES_GMAC_authentication_test_case_2(void)
7092 return test_AES_GMAC_authentication(&gmac_test_case_2);
7096 test_AES_GMAC_authentication_test_case_3(void)
7098 return test_AES_GMAC_authentication(&gmac_test_case_3);
7102 test_AES_GMAC_authentication_test_case_4(void)
7104 return test_AES_GMAC_authentication(&gmac_test_case_4);
7108 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7110 struct crypto_testsuite_params *ts_params = &testsuite_params;
7111 struct crypto_unittest_params *ut_params = &unittest_params;
7113 uint32_t plaintext_pad_len;
7116 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7117 "No GMAC length in the source data");
7119 retval = create_gmac_session(ts_params->valid_devs[0],
7120 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7125 if (tdata->plaintext.len > MBUF_SIZE)
7126 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7128 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7129 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7130 "Failed to allocate input buffer in mempool");
7132 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7133 rte_pktmbuf_tailroom(ut_params->ibuf));
7135 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7138 * Runtime generate the large plain text instead of use hard code
7139 * plain text vector. It is done to avoid create huge source file
7140 * with the test vector.
7142 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7143 generate_gmac_large_plaintext(tdata->plaintext.data);
7145 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7147 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7149 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7150 debug_hexdump(stdout, "plaintext:", plaintext,
7151 tdata->plaintext.len);
7153 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7159 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7161 ut_params->op->sym->m_src = ut_params->ibuf;
7163 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7164 ut_params->op), "failed to process sym crypto op");
7166 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7167 "crypto op processing failed");
7174 test_AES_GMAC_authentication_verify_test_case_1(void)
7176 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7180 test_AES_GMAC_authentication_verify_test_case_2(void)
7182 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7186 test_AES_GMAC_authentication_verify_test_case_3(void)
7188 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7192 test_AES_GMAC_authentication_verify_test_case_4(void)
7194 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7197 struct test_crypto_vector {
7198 enum rte_crypto_cipher_algorithm crypto_algo;
7211 const uint8_t *data;
7216 const uint8_t *data;
7220 enum rte_crypto_auth_algorithm auth_algo;
7228 const uint8_t *data;
7238 static const struct test_crypto_vector
7239 hmac_sha1_test_crypto_vector = {
7240 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7242 .data = plaintext_hash,
7247 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7248 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7249 0xDE, 0xF4, 0xDE, 0xAD
7255 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7256 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7257 0x3F, 0x91, 0x64, 0x59
7263 static const struct test_crypto_vector
7264 aes128_gmac_test_vector = {
7265 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7267 .data = plaintext_hash,
7272 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7273 0x08, 0x09, 0x0A, 0x0B
7279 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7280 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7286 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7287 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7293 static const struct test_crypto_vector
7294 aes128cbc_hmac_sha1_test_vector = {
7295 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7298 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7299 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7305 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7306 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7311 .data = plaintext_hash,
7315 .data = ciphertext512_aes128cbc,
7318 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7321 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7322 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7323 0xDE, 0xF4, 0xDE, 0xAD
7329 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7330 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7331 0x18, 0x8C, 0x1D, 0x32
7338 data_corruption(uint8_t *data)
7344 tag_corruption(uint8_t *data, unsigned int tag_offset)
7346 data[tag_offset] += 1;
7350 create_auth_session(struct crypto_unittest_params *ut_params,
7352 const struct test_crypto_vector *reference,
7353 enum rte_crypto_auth_operation auth_op)
7355 struct crypto_testsuite_params *ts_params = &testsuite_params;
7356 uint8_t auth_key[reference->auth_key.len + 1];
7358 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7360 /* Setup Authentication Parameters */
7361 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7362 ut_params->auth_xform.auth.op = auth_op;
7363 ut_params->auth_xform.next = NULL;
7364 ut_params->auth_xform.auth.algo = reference->auth_algo;
7365 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7366 ut_params->auth_xform.auth.key.data = auth_key;
7367 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7369 /* Create Crypto session*/
7370 ut_params->sess = rte_cryptodev_sym_session_create(
7371 ts_params->session_mpool);
7373 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7374 &ut_params->auth_xform,
7375 ts_params->session_mpool);
7377 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7383 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7385 const struct test_crypto_vector *reference,
7386 enum rte_crypto_auth_operation auth_op,
7387 enum rte_crypto_cipher_operation cipher_op)
7389 struct crypto_testsuite_params *ts_params = &testsuite_params;
7390 uint8_t cipher_key[reference->cipher_key.len + 1];
7391 uint8_t auth_key[reference->auth_key.len + 1];
7393 memcpy(cipher_key, reference->cipher_key.data,
7394 reference->cipher_key.len);
7395 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7397 /* Setup Authentication Parameters */
7398 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7399 ut_params->auth_xform.auth.op = auth_op;
7400 ut_params->auth_xform.auth.algo = reference->auth_algo;
7401 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7402 ut_params->auth_xform.auth.key.data = auth_key;
7403 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7405 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7406 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7407 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7409 ut_params->auth_xform.next = &ut_params->cipher_xform;
7411 /* Setup Cipher Parameters */
7412 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7413 ut_params->cipher_xform.next = NULL;
7414 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7415 ut_params->cipher_xform.cipher.op = cipher_op;
7416 ut_params->cipher_xform.cipher.key.data = cipher_key;
7417 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7418 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7419 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7422 /* Create Crypto session*/
7423 ut_params->sess = rte_cryptodev_sym_session_create(
7424 ts_params->session_mpool);
7426 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7427 &ut_params->auth_xform,
7428 ts_params->session_mpool);
7430 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7436 create_auth_operation(struct crypto_testsuite_params *ts_params,
7437 struct crypto_unittest_params *ut_params,
7438 const struct test_crypto_vector *reference,
7439 unsigned int auth_generate)
7441 /* Generate Crypto op data structure */
7442 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7443 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7444 TEST_ASSERT_NOT_NULL(ut_params->op,
7445 "Failed to allocate pktmbuf offload");
7447 /* Set crypto operation data parameters */
7448 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7450 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7452 /* set crypto operation source mbuf */
7453 sym_op->m_src = ut_params->ibuf;
7456 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7457 ut_params->ibuf, reference->digest.len);
7459 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7460 "no room to append auth tag");
7462 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7463 ut_params->ibuf, reference->plaintext.len);
7466 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7468 memcpy(sym_op->auth.digest.data,
7469 reference->digest.data,
7470 reference->digest.len);
7472 debug_hexdump(stdout, "digest:",
7473 sym_op->auth.digest.data,
7474 reference->digest.len);
7476 sym_op->auth.data.length = reference->plaintext.len;
7477 sym_op->auth.data.offset = 0;
7483 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7484 struct crypto_unittest_params *ut_params,
7485 const struct test_crypto_vector *reference,
7486 unsigned int auth_generate)
7488 /* Generate Crypto op data structure */
7489 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7490 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7491 TEST_ASSERT_NOT_NULL(ut_params->op,
7492 "Failed to allocate pktmbuf offload");
7494 /* Set crypto operation data parameters */
7495 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7497 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7499 /* set crypto operation source mbuf */
7500 sym_op->m_src = ut_params->ibuf;
7503 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7504 ut_params->ibuf, reference->digest.len);
7506 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7507 "no room to append auth tag");
7509 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7510 ut_params->ibuf, reference->ciphertext.len);
7513 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7515 memcpy(sym_op->auth.digest.data,
7516 reference->digest.data,
7517 reference->digest.len);
7519 debug_hexdump(stdout, "digest:",
7520 sym_op->auth.digest.data,
7521 reference->digest.len);
7523 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7524 reference->iv.data, reference->iv.len);
7526 sym_op->cipher.data.length = 0;
7527 sym_op->cipher.data.offset = 0;
7529 sym_op->auth.data.length = reference->plaintext.len;
7530 sym_op->auth.data.offset = 0;
7536 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7537 struct crypto_unittest_params *ut_params,
7538 const struct test_crypto_vector *reference,
7539 unsigned int auth_generate)
7541 /* Generate Crypto op data structure */
7542 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7543 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7544 TEST_ASSERT_NOT_NULL(ut_params->op,
7545 "Failed to allocate pktmbuf offload");
7547 /* Set crypto operation data parameters */
7548 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7550 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7552 /* set crypto operation source mbuf */
7553 sym_op->m_src = ut_params->ibuf;
7556 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7557 ut_params->ibuf, reference->digest.len);
7559 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7560 "no room to append auth tag");
7562 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7563 ut_params->ibuf, reference->ciphertext.len);
7566 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7568 memcpy(sym_op->auth.digest.data,
7569 reference->digest.data,
7570 reference->digest.len);
7572 debug_hexdump(stdout, "digest:",
7573 sym_op->auth.digest.data,
7574 reference->digest.len);
7576 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7577 reference->iv.data, reference->iv.len);
7579 sym_op->cipher.data.length = reference->ciphertext.len;
7580 sym_op->cipher.data.offset = 0;
7582 sym_op->auth.data.length = reference->ciphertext.len;
7583 sym_op->auth.data.offset = 0;
7589 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7590 struct crypto_unittest_params *ut_params,
7591 const struct test_crypto_vector *reference)
7593 return create_auth_operation(ts_params, ut_params, reference, 0);
7597 create_auth_verify_GMAC_operation(
7598 struct crypto_testsuite_params *ts_params,
7599 struct crypto_unittest_params *ut_params,
7600 const struct test_crypto_vector *reference)
7602 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7606 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7607 struct crypto_unittest_params *ut_params,
7608 const struct test_crypto_vector *reference)
7610 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7614 test_authentication_verify_fail_when_data_corruption(
7615 struct crypto_testsuite_params *ts_params,
7616 struct crypto_unittest_params *ut_params,
7617 const struct test_crypto_vector *reference,
7618 unsigned int data_corrupted)
7624 /* Create session */
7625 retval = create_auth_session(ut_params,
7626 ts_params->valid_devs[0],
7628 RTE_CRYPTO_AUTH_OP_VERIFY);
7632 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7633 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7634 "Failed to allocate input buffer in mempool");
7636 /* clear mbuf payload */
7637 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7638 rte_pktmbuf_tailroom(ut_params->ibuf));
7640 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7641 reference->plaintext.len);
7642 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7643 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7645 debug_hexdump(stdout, "plaintext:", plaintext,
7646 reference->plaintext.len);
7648 /* Create operation */
7649 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7655 data_corruption(plaintext);
7657 tag_corruption(plaintext, reference->plaintext.len);
7659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7662 TEST_ASSERT_EQUAL(ut_params->op->status,
7663 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7664 "authentication not failed");
7666 ut_params->obuf = ut_params->op->sym->m_src;
7667 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7673 test_authentication_verify_GMAC_fail_when_corruption(
7674 struct crypto_testsuite_params *ts_params,
7675 struct crypto_unittest_params *ut_params,
7676 const struct test_crypto_vector *reference,
7677 unsigned int data_corrupted)
7682 /* Create session */
7683 retval = create_auth_cipher_session(ut_params,
7684 ts_params->valid_devs[0],
7686 RTE_CRYPTO_AUTH_OP_VERIFY,
7687 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7692 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7693 "Failed to allocate input buffer in mempool");
7695 /* clear mbuf payload */
7696 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7697 rte_pktmbuf_tailroom(ut_params->ibuf));
7699 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7700 reference->plaintext.len);
7701 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7702 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7704 debug_hexdump(stdout, "plaintext:", plaintext,
7705 reference->plaintext.len);
7707 /* Create operation */
7708 retval = create_auth_verify_GMAC_operation(ts_params,
7716 data_corruption(plaintext);
7718 tag_corruption(plaintext, reference->aad.len);
7720 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7723 TEST_ASSERT_EQUAL(ut_params->op->status,
7724 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7725 "authentication not failed");
7727 ut_params->obuf = ut_params->op->sym->m_src;
7728 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7734 test_authenticated_decryption_fail_when_corruption(
7735 struct crypto_testsuite_params *ts_params,
7736 struct crypto_unittest_params *ut_params,
7737 const struct test_crypto_vector *reference,
7738 unsigned int data_corrupted)
7742 uint8_t *ciphertext;
7744 /* Create session */
7745 retval = create_auth_cipher_session(ut_params,
7746 ts_params->valid_devs[0],
7748 RTE_CRYPTO_AUTH_OP_VERIFY,
7749 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7753 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7754 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7755 "Failed to allocate input buffer in mempool");
7757 /* clear mbuf payload */
7758 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7759 rte_pktmbuf_tailroom(ut_params->ibuf));
7761 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7762 reference->ciphertext.len);
7763 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7764 memcpy(ciphertext, reference->ciphertext.data,
7765 reference->ciphertext.len);
7767 /* Create operation */
7768 retval = create_cipher_auth_verify_operation(ts_params,
7776 data_corruption(ciphertext);
7778 tag_corruption(ciphertext, reference->ciphertext.len);
7780 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7783 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7784 TEST_ASSERT_EQUAL(ut_params->op->status,
7785 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7786 "authentication not failed");
7788 ut_params->obuf = ut_params->op->sym->m_src;
7789 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7795 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7796 const struct aead_test_data *tdata,
7797 void *digest_mem, uint64_t digest_phys)
7799 struct crypto_testsuite_params *ts_params = &testsuite_params;
7800 struct crypto_unittest_params *ut_params = &unittest_params;
7802 const unsigned int auth_tag_len = tdata->auth_tag.len;
7803 const unsigned int iv_len = tdata->iv.len;
7804 unsigned int aad_len = tdata->aad.len;
7806 /* Generate Crypto op data structure */
7807 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7808 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7809 TEST_ASSERT_NOT_NULL(ut_params->op,
7810 "Failed to allocate symmetric crypto operation struct");
7812 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7814 sym_op->aead.digest.data = digest_mem;
7816 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7817 "no room to append digest");
7819 sym_op->aead.digest.phys_addr = digest_phys;
7821 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7822 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7824 debug_hexdump(stdout, "digest:",
7825 sym_op->aead.digest.data,
7829 /* Append aad data */
7830 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7831 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7832 uint8_t *, IV_OFFSET);
7834 /* Copy IV 1 byte after the IV pointer, according to the API */
7835 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
7837 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
7839 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7840 ut_params->ibuf, aad_len);
7841 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7842 "no room to prepend aad");
7843 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7846 memset(sym_op->aead.aad.data, 0, aad_len);
7847 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7848 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7850 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
7851 debug_hexdump(stdout, "aad:",
7852 sym_op->aead.aad.data, aad_len);
7854 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7855 uint8_t *, IV_OFFSET);
7857 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7859 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7860 ut_params->ibuf, aad_len);
7861 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7862 "no room to prepend aad");
7863 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7866 memset(sym_op->aead.aad.data, 0, aad_len);
7867 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7869 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
7870 debug_hexdump(stdout, "aad:",
7871 sym_op->aead.aad.data, aad_len);
7874 sym_op->aead.data.length = tdata->plaintext.len;
7875 sym_op->aead.data.offset = aad_len;
7880 #define SGL_MAX_NO 16
7883 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
7884 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7886 struct crypto_testsuite_params *ts_params = &testsuite_params;
7887 struct crypto_unittest_params *ut_params = &unittest_params;
7888 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7891 int to_trn_tbl[SGL_MAX_NO];
7893 unsigned int trn_data = 0;
7894 uint8_t *plaintext, *ciphertext, *auth_tag;
7896 if (fragsz > tdata->plaintext.len)
7897 fragsz = tdata->plaintext.len;
7899 uint16_t plaintext_len = fragsz;
7900 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7902 if (fragsz_oop > tdata->plaintext.len)
7903 frag_size_oop = tdata->plaintext.len;
7906 void *digest_mem = NULL;
7908 uint32_t prepend_len = tdata->aad.len;
7910 if (tdata->plaintext.len % fragsz != 0) {
7911 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7914 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7919 * For out-op-place we need to alloc another mbuf
7922 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7923 rte_pktmbuf_append(ut_params->obuf,
7924 frag_size_oop + prepend_len);
7925 buf_oop = ut_params->obuf;
7928 /* Create AEAD session */
7929 retval = create_aead_session(ts_params->valid_devs[0],
7931 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7932 tdata->key.data, tdata->key.len,
7933 tdata->aad.len, tdata->auth_tag.len,
7938 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7940 /* clear mbuf payload */
7941 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7942 rte_pktmbuf_tailroom(ut_params->ibuf));
7944 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7947 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7949 trn_data += plaintext_len;
7951 buf = ut_params->ibuf;
7954 * Loop until no more fragments
7957 while (trn_data < tdata->plaintext.len) {
7959 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7960 (tdata->plaintext.len - trn_data) : fragsz;
7962 to_trn_tbl[ecx++] = to_trn;
7964 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7967 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7968 rte_pktmbuf_tailroom(buf));
7971 if (oop && !fragsz_oop) {
7972 buf_last_oop = buf_oop->next =
7973 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7974 buf_oop = buf_oop->next;
7975 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7976 0, rte_pktmbuf_tailroom(buf_oop));
7977 rte_pktmbuf_append(buf_oop, to_trn);
7980 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7983 memcpy(plaintext, tdata->plaintext.data + trn_data,
7986 if (trn_data == tdata->plaintext.len) {
7989 digest_mem = rte_pktmbuf_append(buf_oop,
7990 tdata->auth_tag.len);
7992 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7993 tdata->auth_tag.len);
7997 uint64_t digest_phys = 0;
7999 ut_params->ibuf->nb_segs = segs;
8002 if (fragsz_oop && oop) {
8006 if (frag_size_oop == tdata->plaintext.len) {
8007 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8008 tdata->auth_tag.len);
8010 digest_phys = rte_pktmbuf_iova_offset(
8012 tdata->plaintext.len + prepend_len);
8015 trn_data = frag_size_oop;
8016 while (trn_data < tdata->plaintext.len) {
8019 (tdata->plaintext.len - trn_data <
8021 (tdata->plaintext.len - trn_data) :
8024 to_trn_tbl[ecx++] = to_trn;
8026 buf_last_oop = buf_oop->next =
8027 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8028 buf_oop = buf_oop->next;
8029 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8030 0, rte_pktmbuf_tailroom(buf_oop));
8031 rte_pktmbuf_append(buf_oop, to_trn);
8035 if (trn_data == tdata->plaintext.len) {
8036 digest_mem = rte_pktmbuf_append(buf_oop,
8037 tdata->auth_tag.len);
8041 ut_params->obuf->nb_segs = segs;
8045 * Place digest at the end of the last buffer
8048 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8049 if (oop && buf_last_oop)
8050 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8052 if (!digest_mem && !oop) {
8053 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8054 + tdata->auth_tag.len);
8055 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8056 tdata->plaintext.len);
8059 /* Create AEAD operation */
8060 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8061 tdata, digest_mem, digest_phys);
8066 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8068 ut_params->op->sym->m_src = ut_params->ibuf;
8070 ut_params->op->sym->m_dst = ut_params->obuf;
8072 /* Process crypto operation */
8073 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8074 ut_params->op), "failed to process sym crypto op");
8076 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8077 "crypto op processing failed");
8080 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8081 uint8_t *, prepend_len);
8083 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8084 uint8_t *, prepend_len);
8088 fragsz = fragsz_oop;
8090 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8092 tdata->ciphertext.data,
8094 "Ciphertext data not as expected");
8096 buf = ut_params->op->sym->m_src->next;
8098 buf = ut_params->op->sym->m_dst->next;
8100 unsigned int off = fragsz;
8104 ciphertext = rte_pktmbuf_mtod(buf,
8107 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8109 tdata->ciphertext.data + off,
8111 "Ciphertext data not as expected");
8113 off += to_trn_tbl[ecx++];
8117 auth_tag = digest_mem;
8118 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8120 tdata->auth_tag.data,
8121 tdata->auth_tag.len,
8122 "Generated auth tag not as expected");
8128 #define OUT_OF_PLACE 1
8131 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8133 return test_authenticated_encryption_SGL(
8134 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8138 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8140 return test_authenticated_encryption_SGL(
8141 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8145 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8147 return test_authenticated_encryption_SGL(
8148 &gcm_test_case_8, OUT_OF_PLACE, 400,
8149 gcm_test_case_8.plaintext.len);
8153 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8156 return test_authenticated_encryption_SGL(
8157 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8161 test_authentication_verify_fail_when_data_corrupted(
8162 struct crypto_testsuite_params *ts_params,
8163 struct crypto_unittest_params *ut_params,
8164 const struct test_crypto_vector *reference)
8166 return test_authentication_verify_fail_when_data_corruption(
8167 ts_params, ut_params, reference, 1);
8171 test_authentication_verify_fail_when_tag_corrupted(
8172 struct crypto_testsuite_params *ts_params,
8173 struct crypto_unittest_params *ut_params,
8174 const struct test_crypto_vector *reference)
8176 return test_authentication_verify_fail_when_data_corruption(
8177 ts_params, ut_params, reference, 0);
8181 test_authentication_verify_GMAC_fail_when_data_corrupted(
8182 struct crypto_testsuite_params *ts_params,
8183 struct crypto_unittest_params *ut_params,
8184 const struct test_crypto_vector *reference)
8186 return test_authentication_verify_GMAC_fail_when_corruption(
8187 ts_params, ut_params, reference, 1);
8191 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8192 struct crypto_testsuite_params *ts_params,
8193 struct crypto_unittest_params *ut_params,
8194 const struct test_crypto_vector *reference)
8196 return test_authentication_verify_GMAC_fail_when_corruption(
8197 ts_params, ut_params, reference, 0);
8201 test_authenticated_decryption_fail_when_data_corrupted(
8202 struct crypto_testsuite_params *ts_params,
8203 struct crypto_unittest_params *ut_params,
8204 const struct test_crypto_vector *reference)
8206 return test_authenticated_decryption_fail_when_corruption(
8207 ts_params, ut_params, reference, 1);
8211 test_authenticated_decryption_fail_when_tag_corrupted(
8212 struct crypto_testsuite_params *ts_params,
8213 struct crypto_unittest_params *ut_params,
8214 const struct test_crypto_vector *reference)
8216 return test_authenticated_decryption_fail_when_corruption(
8217 ts_params, ut_params, reference, 0);
8221 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8223 return test_authentication_verify_fail_when_data_corrupted(
8224 &testsuite_params, &unittest_params,
8225 &hmac_sha1_test_crypto_vector);
8229 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8231 return test_authentication_verify_fail_when_tag_corrupted(
8232 &testsuite_params, &unittest_params,
8233 &hmac_sha1_test_crypto_vector);
8237 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8239 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8240 &testsuite_params, &unittest_params,
8241 &aes128_gmac_test_vector);
8245 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8247 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8248 &testsuite_params, &unittest_params,
8249 &aes128_gmac_test_vector);
8253 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8255 return test_authenticated_decryption_fail_when_data_corrupted(
8258 &aes128cbc_hmac_sha1_test_vector);
8262 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8264 return test_authenticated_decryption_fail_when_tag_corrupted(
8267 &aes128cbc_hmac_sha1_test_vector);
8270 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8272 /* global AESNI slave IDs for the scheduler test */
8273 uint8_t aesni_ids[2];
8276 test_scheduler_attach_slave_op(void)
8278 struct crypto_testsuite_params *ts_params = &testsuite_params;
8279 uint8_t sched_id = ts_params->valid_devs[0];
8280 uint32_t nb_devs, i, nb_devs_attached = 0;
8284 /* create 2 AESNI_MB if necessary */
8285 nb_devs = rte_cryptodev_device_count_by_driver(
8286 rte_cryptodev_driver_id_get(
8287 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8289 for (i = nb_devs; i < 2; i++) {
8290 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8291 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8293 ret = rte_vdev_init(vdev_name, NULL);
8295 TEST_ASSERT(ret == 0,
8296 "Failed to create instance %u of"
8298 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8302 /* attach 2 AESNI_MB cdevs */
8303 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8305 struct rte_cryptodev_info info;
8307 rte_cryptodev_info_get(i, &info);
8308 if (info.driver_id != rte_cryptodev_driver_id_get(
8309 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8313 * Create the session mempool again, since now there are new devices
8314 * to use the mempool.
8316 if (ts_params->session_mpool) {
8317 rte_mempool_free(ts_params->session_mpool);
8318 ts_params->session_mpool = NULL;
8320 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8323 * Create mempool with maximum number of sessions * 2,
8324 * to include the session headers
8326 if (ts_params->session_mpool == NULL) {
8327 ts_params->session_mpool = rte_mempool_create(
8329 info.sym.max_nb_sessions * 2,
8331 0, 0, NULL, NULL, NULL,
8332 NULL, SOCKET_ID_ANY,
8335 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8336 "session mempool allocation failed");
8339 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8342 TEST_ASSERT(ret == 0,
8343 "Failed to attach device %u of pmd : %s", i,
8344 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8346 aesni_ids[nb_devs_attached] = (uint8_t)i;
8355 test_scheduler_detach_slave_op(void)
8357 struct crypto_testsuite_params *ts_params = &testsuite_params;
8358 uint8_t sched_id = ts_params->valid_devs[0];
8362 for (i = 0; i < 2; i++) {
8363 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8365 TEST_ASSERT(ret == 0,
8366 "Failed to detach device %u", aesni_ids[i]);
8373 test_scheduler_mode_op(void)
8375 struct crypto_testsuite_params *ts_params = &testsuite_params;
8376 uint8_t sched_id = ts_params->valid_devs[0];
8377 struct rte_cryptodev_scheduler_ops op = {0};
8378 struct rte_cryptodev_scheduler dummy_scheduler = {
8379 .description = "dummy scheduler to test mode",
8380 .name = "dummy scheduler",
8381 .mode = CDEV_SCHED_MODE_USERDEFINED,
8386 /* set user defined mode */
8387 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8389 TEST_ASSERT(ret == 0,
8390 "Failed to set cdev %u to user defined mode", sched_id);
8392 /* set round robin mode */
8393 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8394 CDEV_SCHED_MODE_ROUNDROBIN);
8395 TEST_ASSERT(ret == 0,
8396 "Failed to set cdev %u to round-robin mode", sched_id);
8397 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8398 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8404 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8405 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8406 .setup = testsuite_setup,
8407 .teardown = testsuite_teardown,
8408 .unit_test_cases = {
8409 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8410 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_AES_chain_scheduler_all),
8413 TEST_CASE_ST(ut_setup, ut_teardown,
8414 test_AES_cipheronly_scheduler_all),
8415 TEST_CASE_ST(ut_setup, ut_teardown,
8416 test_authonly_scheduler_all),
8417 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8418 TEST_CASES_END() /**< NULL terminate unit test array */
8422 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8424 static struct unit_test_suite cryptodev_qat_testsuite = {
8425 .suite_name = "Crypto QAT Unit Test Suite",
8426 .setup = testsuite_setup,
8427 .teardown = testsuite_teardown,
8428 .unit_test_cases = {
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_device_configure_invalid_dev_id),
8431 TEST_CASE_ST(ut_setup, ut_teardown,
8432 test_device_configure_invalid_queue_pair_ids),
8433 TEST_CASE_ST(ut_setup, ut_teardown,
8434 test_queue_pair_descriptor_setup),
8435 TEST_CASE_ST(ut_setup, ut_teardown,
8436 test_multi_session),
8438 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8439 TEST_CASE_ST(ut_setup, ut_teardown,
8440 test_AES_cipheronly_qat_all),
8441 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8442 TEST_CASE_ST(ut_setup, ut_teardown,
8443 test_3DES_cipheronly_qat_all),
8444 TEST_CASE_ST(ut_setup, ut_teardown,
8445 test_DES_cipheronly_qat_all),
8446 TEST_CASE_ST(ut_setup, ut_teardown,
8447 test_AES_docsis_qat_all),
8448 TEST_CASE_ST(ut_setup, ut_teardown,
8449 test_DES_docsis_qat_all),
8450 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8451 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8453 /** AES CCM Authenticated Encryption 128 bits key */
8454 TEST_CASE_ST(ut_setup, ut_teardown,
8455 test_AES_CCM_authenticated_encryption_test_case_128_1),
8456 TEST_CASE_ST(ut_setup, ut_teardown,
8457 test_AES_CCM_authenticated_encryption_test_case_128_2),
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_AES_CCM_authenticated_encryption_test_case_128_3),
8461 /** AES CCM Authenticated Decryption 128 bits key*/
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_AES_CCM_authenticated_decryption_test_case_128_1),
8464 TEST_CASE_ST(ut_setup, ut_teardown,
8465 test_AES_CCM_authenticated_decryption_test_case_128_2),
8466 TEST_CASE_ST(ut_setup, ut_teardown,
8467 test_AES_CCM_authenticated_decryption_test_case_128_3),
8469 /** AES GCM Authenticated Encryption */
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8474 TEST_CASE_ST(ut_setup, ut_teardown,
8475 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8476 TEST_CASE_ST(ut_setup, ut_teardown,
8477 test_AES_GCM_authenticated_encryption_test_case_1),
8478 TEST_CASE_ST(ut_setup, ut_teardown,
8479 test_AES_GCM_authenticated_encryption_test_case_2),
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_AES_GCM_authenticated_encryption_test_case_3),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 test_AES_GCM_authenticated_encryption_test_case_4),
8484 TEST_CASE_ST(ut_setup, ut_teardown,
8485 test_AES_GCM_authenticated_encryption_test_case_5),
8486 TEST_CASE_ST(ut_setup, ut_teardown,
8487 test_AES_GCM_authenticated_encryption_test_case_6),
8488 TEST_CASE_ST(ut_setup, ut_teardown,
8489 test_AES_GCM_authenticated_encryption_test_case_7),
8491 /** AES GCM Authenticated Decryption */
8492 TEST_CASE_ST(ut_setup, ut_teardown,
8493 test_AES_GCM_authenticated_decryption_test_case_1),
8494 TEST_CASE_ST(ut_setup, ut_teardown,
8495 test_AES_GCM_authenticated_decryption_test_case_2),
8496 TEST_CASE_ST(ut_setup, ut_teardown,
8497 test_AES_GCM_authenticated_decryption_test_case_3),
8498 TEST_CASE_ST(ut_setup, ut_teardown,
8499 test_AES_GCM_authenticated_decryption_test_case_4),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 test_AES_GCM_authenticated_decryption_test_case_5),
8502 TEST_CASE_ST(ut_setup, ut_teardown,
8503 test_AES_GCM_authenticated_decryption_test_case_6),
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_AES_GCM_authenticated_decryption_test_case_7),
8507 /** AES GCM Authenticated Encryption 192 bits key */
8508 TEST_CASE_ST(ut_setup, ut_teardown,
8509 test_AES_GCM_auth_encryption_test_case_192_1),
8510 TEST_CASE_ST(ut_setup, ut_teardown,
8511 test_AES_GCM_auth_encryption_test_case_192_2),
8512 TEST_CASE_ST(ut_setup, ut_teardown,
8513 test_AES_GCM_auth_encryption_test_case_192_3),
8514 TEST_CASE_ST(ut_setup, ut_teardown,
8515 test_AES_GCM_auth_encryption_test_case_192_4),
8516 TEST_CASE_ST(ut_setup, ut_teardown,
8517 test_AES_GCM_auth_encryption_test_case_192_5),
8518 TEST_CASE_ST(ut_setup, ut_teardown,
8519 test_AES_GCM_auth_encryption_test_case_192_6),
8520 TEST_CASE_ST(ut_setup, ut_teardown,
8521 test_AES_GCM_auth_encryption_test_case_192_7),
8523 /** AES GCM Authenticated Decryption 192 bits key */
8524 TEST_CASE_ST(ut_setup, ut_teardown,
8525 test_AES_GCM_auth_decryption_test_case_192_1),
8526 TEST_CASE_ST(ut_setup, ut_teardown,
8527 test_AES_GCM_auth_decryption_test_case_192_2),
8528 TEST_CASE_ST(ut_setup, ut_teardown,
8529 test_AES_GCM_auth_decryption_test_case_192_3),
8530 TEST_CASE_ST(ut_setup, ut_teardown,
8531 test_AES_GCM_auth_decryption_test_case_192_4),
8532 TEST_CASE_ST(ut_setup, ut_teardown,
8533 test_AES_GCM_auth_decryption_test_case_192_5),
8534 TEST_CASE_ST(ut_setup, ut_teardown,
8535 test_AES_GCM_auth_decryption_test_case_192_6),
8536 TEST_CASE_ST(ut_setup, ut_teardown,
8537 test_AES_GCM_auth_decryption_test_case_192_7),
8539 /** AES GCM Authenticated Encryption 256 bits key */
8540 TEST_CASE_ST(ut_setup, ut_teardown,
8541 test_AES_GCM_auth_encryption_test_case_256_1),
8542 TEST_CASE_ST(ut_setup, ut_teardown,
8543 test_AES_GCM_auth_encryption_test_case_256_2),
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_AES_GCM_auth_encryption_test_case_256_3),
8546 TEST_CASE_ST(ut_setup, ut_teardown,
8547 test_AES_GCM_auth_encryption_test_case_256_4),
8548 TEST_CASE_ST(ut_setup, ut_teardown,
8549 test_AES_GCM_auth_encryption_test_case_256_5),
8550 TEST_CASE_ST(ut_setup, ut_teardown,
8551 test_AES_GCM_auth_encryption_test_case_256_6),
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_AES_GCM_auth_encryption_test_case_256_7),
8555 /** AES GMAC Authentication */
8556 TEST_CASE_ST(ut_setup, ut_teardown,
8557 test_AES_GMAC_authentication_test_case_1),
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_AES_GMAC_authentication_verify_test_case_1),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_AES_GMAC_authentication_test_case_2),
8562 TEST_CASE_ST(ut_setup, ut_teardown,
8563 test_AES_GMAC_authentication_verify_test_case_2),
8564 TEST_CASE_ST(ut_setup, ut_teardown,
8565 test_AES_GMAC_authentication_test_case_3),
8566 TEST_CASE_ST(ut_setup, ut_teardown,
8567 test_AES_GMAC_authentication_verify_test_case_3),
8569 /** SNOW 3G encrypt only (UEA2) */
8570 TEST_CASE_ST(ut_setup, ut_teardown,
8571 test_snow3g_encryption_test_case_1),
8572 TEST_CASE_ST(ut_setup, ut_teardown,
8573 test_snow3g_encryption_test_case_2),
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_snow3g_encryption_test_case_3),
8576 TEST_CASE_ST(ut_setup, ut_teardown,
8577 test_snow3g_encryption_test_case_4),
8578 TEST_CASE_ST(ut_setup, ut_teardown,
8579 test_snow3g_encryption_test_case_5),
8581 TEST_CASE_ST(ut_setup, ut_teardown,
8582 test_snow3g_encryption_test_case_1_oop),
8583 TEST_CASE_ST(ut_setup, ut_teardown,
8584 test_snow3g_decryption_test_case_1_oop),
8586 /** SNOW 3G decrypt only (UEA2) */
8587 TEST_CASE_ST(ut_setup, ut_teardown,
8588 test_snow3g_decryption_test_case_1),
8589 TEST_CASE_ST(ut_setup, ut_teardown,
8590 test_snow3g_decryption_test_case_2),
8591 TEST_CASE_ST(ut_setup, ut_teardown,
8592 test_snow3g_decryption_test_case_3),
8593 TEST_CASE_ST(ut_setup, ut_teardown,
8594 test_snow3g_decryption_test_case_4),
8595 TEST_CASE_ST(ut_setup, ut_teardown,
8596 test_snow3g_decryption_test_case_5),
8597 TEST_CASE_ST(ut_setup, ut_teardown,
8598 test_snow3g_hash_generate_test_case_1),
8599 TEST_CASE_ST(ut_setup, ut_teardown,
8600 test_snow3g_hash_generate_test_case_2),
8601 TEST_CASE_ST(ut_setup, ut_teardown,
8602 test_snow3g_hash_generate_test_case_3),
8603 TEST_CASE_ST(ut_setup, ut_teardown,
8604 test_snow3g_hash_verify_test_case_1),
8605 TEST_CASE_ST(ut_setup, ut_teardown,
8606 test_snow3g_hash_verify_test_case_2),
8607 TEST_CASE_ST(ut_setup, ut_teardown,
8608 test_snow3g_hash_verify_test_case_3),
8609 TEST_CASE_ST(ut_setup, ut_teardown,
8610 test_snow3g_cipher_auth_test_case_1),
8611 TEST_CASE_ST(ut_setup, ut_teardown,
8612 test_snow3g_auth_cipher_test_case_1),
8614 /** ZUC encrypt only (EEA3) */
8615 TEST_CASE_ST(ut_setup, ut_teardown,
8616 test_zuc_encryption_test_case_1),
8617 TEST_CASE_ST(ut_setup, ut_teardown,
8618 test_zuc_encryption_test_case_2),
8619 TEST_CASE_ST(ut_setup, ut_teardown,
8620 test_zuc_encryption_test_case_3),
8621 TEST_CASE_ST(ut_setup, ut_teardown,
8622 test_zuc_encryption_test_case_4),
8623 TEST_CASE_ST(ut_setup, ut_teardown,
8624 test_zuc_encryption_test_case_5),
8626 /** ZUC authenticate (EIA3) */
8627 TEST_CASE_ST(ut_setup, ut_teardown,
8628 test_zuc_hash_generate_test_case_6),
8629 TEST_CASE_ST(ut_setup, ut_teardown,
8630 test_zuc_hash_generate_test_case_7),
8631 TEST_CASE_ST(ut_setup, ut_teardown,
8632 test_zuc_hash_generate_test_case_8),
8634 /** ZUC alg-chain (EEA3/EIA3) */
8635 TEST_CASE_ST(ut_setup, ut_teardown,
8636 test_zuc_cipher_auth_test_case_1),
8637 TEST_CASE_ST(ut_setup, ut_teardown,
8638 test_zuc_cipher_auth_test_case_2),
8640 /** HMAC_MD5 Authentication */
8641 TEST_CASE_ST(ut_setup, ut_teardown,
8642 test_MD5_HMAC_generate_case_1),
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_MD5_HMAC_verify_case_1),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_MD5_HMAC_generate_case_2),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_MD5_HMAC_verify_case_2),
8651 TEST_CASE_ST(ut_setup, ut_teardown,
8652 test_null_auth_only_operation),
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_null_cipher_only_operation),
8655 TEST_CASE_ST(ut_setup, ut_teardown,
8656 test_null_cipher_auth_operation),
8657 TEST_CASE_ST(ut_setup, ut_teardown,
8658 test_null_auth_cipher_operation),
8661 TEST_CASE_ST(ut_setup, ut_teardown,
8662 test_kasumi_hash_generate_test_case_1),
8663 TEST_CASE_ST(ut_setup, ut_teardown,
8664 test_kasumi_hash_generate_test_case_2),
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_kasumi_hash_generate_test_case_3),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_kasumi_hash_generate_test_case_4),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_kasumi_hash_generate_test_case_5),
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 test_kasumi_hash_generate_test_case_6),
8674 TEST_CASE_ST(ut_setup, ut_teardown,
8675 test_kasumi_hash_verify_test_case_1),
8676 TEST_CASE_ST(ut_setup, ut_teardown,
8677 test_kasumi_hash_verify_test_case_2),
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_kasumi_hash_verify_test_case_3),
8680 TEST_CASE_ST(ut_setup, ut_teardown,
8681 test_kasumi_hash_verify_test_case_4),
8682 TEST_CASE_ST(ut_setup, ut_teardown,
8683 test_kasumi_hash_verify_test_case_5),
8685 TEST_CASE_ST(ut_setup, ut_teardown,
8686 test_kasumi_encryption_test_case_1),
8687 TEST_CASE_ST(ut_setup, ut_teardown,
8688 test_kasumi_encryption_test_case_3),
8689 TEST_CASE_ST(ut_setup, ut_teardown,
8690 test_kasumi_auth_cipher_test_case_1),
8691 TEST_CASE_ST(ut_setup, ut_teardown,
8692 test_kasumi_cipher_auth_test_case_1),
8694 /** Negative tests */
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 authentication_verify_AES128_GMAC_fail_data_corrupt),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8705 TEST_CASE_ST(ut_setup, ut_teardown,
8706 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8708 TEST_CASES_END() /**< NULL terminate unit test array */
8712 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8713 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8714 .setup = testsuite_setup,
8715 .teardown = testsuite_teardown,
8716 .unit_test_cases = {
8717 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8718 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8719 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8720 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8721 TEST_CASE_ST(ut_setup, ut_teardown,
8722 test_DES_cipheronly_mb_all),
8723 TEST_CASE_ST(ut_setup, ut_teardown,
8724 test_DES_docsis_mb_all),
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 test_AES_CCM_authenticated_encryption_test_case_128_1),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_AES_CCM_authenticated_decryption_test_case_128_1),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_AES_CCM_authenticated_encryption_test_case_128_2),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 test_AES_CCM_authenticated_decryption_test_case_128_2),
8733 TEST_CASE_ST(ut_setup, ut_teardown,
8734 test_AES_CCM_authenticated_encryption_test_case_128_3),
8735 TEST_CASE_ST(ut_setup, ut_teardown,
8736 test_AES_CCM_authenticated_decryption_test_case_128_3),
8738 TEST_CASES_END() /**< NULL terminate unit test array */
8742 static struct unit_test_suite cryptodev_openssl_testsuite = {
8743 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8744 .setup = testsuite_setup,
8745 .teardown = testsuite_teardown,
8746 .unit_test_cases = {
8747 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8748 TEST_CASE_ST(ut_setup, ut_teardown,
8749 test_multi_session_random_usage),
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_AES_chain_openssl_all),
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_AES_cipheronly_openssl_all),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_3DES_chain_openssl_all),
8756 TEST_CASE_ST(ut_setup, ut_teardown,
8757 test_3DES_cipheronly_openssl_all),
8758 TEST_CASE_ST(ut_setup, ut_teardown,
8759 test_DES_cipheronly_openssl_all),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_DES_docsis_openssl_all),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_authonly_openssl_all),
8765 /** AES GCM Authenticated Encryption */
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_AES_GCM_authenticated_encryption_test_case_1),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_AES_GCM_authenticated_encryption_test_case_2),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_GCM_authenticated_encryption_test_case_3),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_AES_GCM_authenticated_encryption_test_case_4),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_AES_GCM_authenticated_encryption_test_case_5),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_AES_GCM_authenticated_encryption_test_case_6),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_authenticated_encryption_test_case_7),
8781 /** AES GCM Authenticated Decryption */
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_authenticated_decryption_test_case_1),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_authenticated_decryption_test_case_2),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_authenticated_decryption_test_case_3),
8788 TEST_CASE_ST(ut_setup, ut_teardown,
8789 test_AES_GCM_authenticated_decryption_test_case_4),
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_authenticated_decryption_test_case_5),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_authenticated_decryption_test_case_6),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_authenticated_decryption_test_case_7),
8798 /** AES GCM Authenticated Encryption 192 bits key */
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_AES_GCM_auth_encryption_test_case_192_1),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_AES_GCM_auth_encryption_test_case_192_2),
8803 TEST_CASE_ST(ut_setup, ut_teardown,
8804 test_AES_GCM_auth_encryption_test_case_192_3),
8805 TEST_CASE_ST(ut_setup, ut_teardown,
8806 test_AES_GCM_auth_encryption_test_case_192_4),
8807 TEST_CASE_ST(ut_setup, ut_teardown,
8808 test_AES_GCM_auth_encryption_test_case_192_5),
8809 TEST_CASE_ST(ut_setup, ut_teardown,
8810 test_AES_GCM_auth_encryption_test_case_192_6),
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_AES_GCM_auth_encryption_test_case_192_7),
8814 /** AES GCM Authenticated Decryption 192 bits key */
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_AES_GCM_auth_decryption_test_case_192_1),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_AES_GCM_auth_decryption_test_case_192_2),
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_AES_GCM_auth_decryption_test_case_192_3),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_AES_GCM_auth_decryption_test_case_192_4),
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_AES_GCM_auth_decryption_test_case_192_5),
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_AES_GCM_auth_decryption_test_case_192_6),
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_AES_GCM_auth_decryption_test_case_192_7),
8830 /** AES GCM Authenticated Encryption 256 bits key */
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_AES_GCM_auth_encryption_test_case_256_1),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_AES_GCM_auth_encryption_test_case_256_2),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_AES_GCM_auth_encryption_test_case_256_3),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_AES_GCM_auth_encryption_test_case_256_4),
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_AES_GCM_auth_encryption_test_case_256_5),
8841 TEST_CASE_ST(ut_setup, ut_teardown,
8842 test_AES_GCM_auth_encryption_test_case_256_6),
8843 TEST_CASE_ST(ut_setup, ut_teardown,
8844 test_AES_GCM_auth_encryption_test_case_256_7),
8846 /** AES GCM Authenticated Decryption 256 bits key */
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_AES_GCM_auth_decryption_test_case_256_1),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_AES_GCM_auth_decryption_test_case_256_2),
8851 TEST_CASE_ST(ut_setup, ut_teardown,
8852 test_AES_GCM_auth_decryption_test_case_256_3),
8853 TEST_CASE_ST(ut_setup, ut_teardown,
8854 test_AES_GCM_auth_decryption_test_case_256_4),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_AES_GCM_auth_decryption_test_case_256_5),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_AES_GCM_auth_decryption_test_case_256_6),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_AES_GCM_auth_decryption_test_case_256_7),
8862 /** AES GMAC Authentication */
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_AES_GMAC_authentication_test_case_1),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_AES_GMAC_authentication_verify_test_case_1),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_AES_GMAC_authentication_test_case_2),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_AES_GMAC_authentication_verify_test_case_2),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_AES_GMAC_authentication_test_case_3),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_AES_GMAC_authentication_verify_test_case_3),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_AES_GMAC_authentication_test_case_4),
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_AES_GMAC_authentication_verify_test_case_4),
8880 /** AES CCM Authenticated Encryption 128 bits key */
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_AES_CCM_authenticated_encryption_test_case_128_1),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_AES_CCM_authenticated_encryption_test_case_128_2),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_AES_CCM_authenticated_encryption_test_case_128_3),
8888 /** AES CCM Authenticated Decryption 128 bits key*/
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_AES_CCM_authenticated_decryption_test_case_128_1),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_AES_CCM_authenticated_decryption_test_case_128_2),
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_AES_CCM_authenticated_decryption_test_case_128_3),
8896 /** AES CCM Authenticated Encryption 192 bits key */
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_AES_CCM_authenticated_encryption_test_case_192_1),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_AES_CCM_authenticated_encryption_test_case_192_2),
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_CCM_authenticated_encryption_test_case_192_3),
8904 /** AES CCM Authenticated Decryption 192 bits key*/
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_CCM_authenticated_decryption_test_case_192_1),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_AES_CCM_authenticated_decryption_test_case_192_2),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_AES_CCM_authenticated_decryption_test_case_192_3),
8912 /** AES CCM Authenticated Encryption 256 bits key */
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_AES_CCM_authenticated_encryption_test_case_256_1),
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_AES_CCM_authenticated_encryption_test_case_256_2),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_AES_CCM_authenticated_encryption_test_case_256_3),
8920 /** AES CCM Authenticated Decryption 256 bits key*/
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_AES_CCM_authenticated_decryption_test_case_256_1),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_AES_CCM_authenticated_decryption_test_case_256_2),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_AES_CCM_authenticated_decryption_test_case_256_3),
8928 /** Scatter-Gather */
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8932 /** Negative tests */
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 authentication_verify_AES128_GMAC_fail_data_corrupt),
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8941 TEST_CASE_ST(ut_setup, ut_teardown,
8942 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8943 TEST_CASE_ST(ut_setup, ut_teardown,
8944 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8946 TEST_CASES_END() /**< NULL terminate unit test array */
8950 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8951 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8952 .setup = testsuite_setup,
8953 .teardown = testsuite_teardown,
8954 .unit_test_cases = {
8955 /** AES GCM Authenticated Encryption */
8956 TEST_CASE_ST(ut_setup, ut_teardown,
8957 test_AES_GCM_authenticated_encryption_test_case_1),
8958 TEST_CASE_ST(ut_setup, ut_teardown,
8959 test_AES_GCM_authenticated_encryption_test_case_2),
8960 TEST_CASE_ST(ut_setup, ut_teardown,
8961 test_AES_GCM_authenticated_encryption_test_case_3),
8962 TEST_CASE_ST(ut_setup, ut_teardown,
8963 test_AES_GCM_authenticated_encryption_test_case_4),
8964 TEST_CASE_ST(ut_setup, ut_teardown,
8965 test_AES_GCM_authenticated_encryption_test_case_5),
8966 TEST_CASE_ST(ut_setup, ut_teardown,
8967 test_AES_GCM_authenticated_encryption_test_case_6),
8968 TEST_CASE_ST(ut_setup, ut_teardown,
8969 test_AES_GCM_authenticated_encryption_test_case_7),
8971 /** AES GCM Authenticated Decryption */
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_AES_GCM_authenticated_decryption_test_case_1),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_AES_GCM_authenticated_decryption_test_case_2),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_AES_GCM_authenticated_decryption_test_case_3),
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_AES_GCM_authenticated_decryption_test_case_4),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_AES_GCM_authenticated_decryption_test_case_5),
8982 TEST_CASE_ST(ut_setup, ut_teardown,
8983 test_AES_GCM_authenticated_decryption_test_case_6),
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 test_AES_GCM_authenticated_decryption_test_case_7),
8987 /** AES GCM Authenticated Encryption 192 bits key */
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 test_AES_GCM_auth_encryption_test_case_192_1),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_GCM_auth_encryption_test_case_192_2),
8992 TEST_CASE_ST(ut_setup, ut_teardown,
8993 test_AES_GCM_auth_encryption_test_case_192_3),
8994 TEST_CASE_ST(ut_setup, ut_teardown,
8995 test_AES_GCM_auth_encryption_test_case_192_4),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_AES_GCM_auth_encryption_test_case_192_5),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_AES_GCM_auth_encryption_test_case_192_6),
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_AES_GCM_auth_encryption_test_case_192_7),
9003 /** AES GCM Authenticated Decryption 192 bits key */
9004 TEST_CASE_ST(ut_setup, ut_teardown,
9005 test_AES_GCM_auth_decryption_test_case_192_1),
9006 TEST_CASE_ST(ut_setup, ut_teardown,
9007 test_AES_GCM_auth_decryption_test_case_192_2),
9008 TEST_CASE_ST(ut_setup, ut_teardown,
9009 test_AES_GCM_auth_decryption_test_case_192_3),
9010 TEST_CASE_ST(ut_setup, ut_teardown,
9011 test_AES_GCM_auth_decryption_test_case_192_4),
9012 TEST_CASE_ST(ut_setup, ut_teardown,
9013 test_AES_GCM_auth_decryption_test_case_192_5),
9014 TEST_CASE_ST(ut_setup, ut_teardown,
9015 test_AES_GCM_auth_decryption_test_case_192_6),
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_GCM_auth_decryption_test_case_192_7),
9019 /** AES GCM Authenticated Encryption 256 bits key */
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_auth_encryption_test_case_256_1),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_auth_encryption_test_case_256_2),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_GCM_auth_encryption_test_case_256_3),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_auth_encryption_test_case_256_4),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_GCM_auth_encryption_test_case_256_5),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_GCM_auth_encryption_test_case_256_6),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_GCM_auth_encryption_test_case_256_7),
9035 /** AES GCM Authenticated Decryption 256 bits key */
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_auth_decryption_test_case_256_1),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_auth_decryption_test_case_256_2),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_AES_GCM_auth_decryption_test_case_256_3),
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_auth_decryption_test_case_256_4),
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_auth_decryption_test_case_256_5),
9046 TEST_CASE_ST(ut_setup, ut_teardown,
9047 test_AES_GCM_auth_decryption_test_case_256_6),
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_auth_decryption_test_case_256_7),
9051 /** AES GCM Authenticated Encryption big aad size */
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_auth_encryption_test_case_aad_1),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_auth_encryption_test_case_aad_2),
9057 /** AES GCM Authenticated Decryption big aad size */
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GCM_auth_decryption_test_case_aad_1),
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_GCM_auth_decryption_test_case_aad_2),
9063 /** AES GMAC Authentication */
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GMAC_authentication_test_case_1),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GMAC_authentication_verify_test_case_1),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GMAC_authentication_test_case_3),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GMAC_authentication_verify_test_case_3),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GMAC_authentication_test_case_4),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_GMAC_authentication_verify_test_case_4),
9077 /** Negative tests */
9078 TEST_CASE_ST(ut_setup, ut_teardown,
9079 authentication_verify_AES128_GMAC_fail_data_corrupt),
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9083 /** Out of place tests */
9084 TEST_CASE_ST(ut_setup, ut_teardown,
9085 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9086 TEST_CASE_ST(ut_setup, ut_teardown,
9087 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9089 /** Session-less tests */
9090 TEST_CASE_ST(ut_setup, ut_teardown,
9091 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9092 TEST_CASE_ST(ut_setup, ut_teardown,
9093 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9095 /** Scatter-Gather */
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9099 TEST_CASES_END() /**< NULL terminate unit test array */
9103 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9104 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9105 .setup = testsuite_setup,
9106 .teardown = testsuite_teardown,
9107 .unit_test_cases = {
9108 /** KASUMI encrypt only (UEA1) */
9109 TEST_CASE_ST(ut_setup, ut_teardown,
9110 test_kasumi_encryption_test_case_1),
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_kasumi_encryption_test_case_1_sgl),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 test_kasumi_encryption_test_case_2),
9115 TEST_CASE_ST(ut_setup, ut_teardown,
9116 test_kasumi_encryption_test_case_3),
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_kasumi_encryption_test_case_4),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_kasumi_encryption_test_case_5),
9121 /** KASUMI decrypt only (UEA1) */
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_kasumi_decryption_test_case_1),
9124 TEST_CASE_ST(ut_setup, ut_teardown,
9125 test_kasumi_decryption_test_case_2),
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_kasumi_decryption_test_case_3),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_kasumi_decryption_test_case_4),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_kasumi_decryption_test_case_5),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_kasumi_encryption_test_case_1_oop),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_kasumi_encryption_test_case_1_oop_sgl),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 test_kasumi_decryption_test_case_1_oop),
9142 /** KASUMI hash only (UIA1) */
9143 TEST_CASE_ST(ut_setup, ut_teardown,
9144 test_kasumi_hash_generate_test_case_1),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_kasumi_hash_generate_test_case_2),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_kasumi_hash_generate_test_case_3),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_kasumi_hash_generate_test_case_4),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_kasumi_hash_generate_test_case_5),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_kasumi_hash_generate_test_case_6),
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_kasumi_hash_verify_test_case_1),
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_kasumi_hash_verify_test_case_2),
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_kasumi_hash_verify_test_case_3),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_kasumi_hash_verify_test_case_4),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_kasumi_hash_verify_test_case_5),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_kasumi_auth_cipher_test_case_1),
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_kasumi_cipher_auth_test_case_1),
9169 TEST_CASES_END() /**< NULL terminate unit test array */
9172 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9173 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9174 .setup = testsuite_setup,
9175 .teardown = testsuite_teardown,
9176 .unit_test_cases = {
9177 /** SNOW 3G encrypt only (UEA2) */
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_snow3g_encryption_test_case_1),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_snow3g_encryption_test_case_2),
9182 TEST_CASE_ST(ut_setup, ut_teardown,
9183 test_snow3g_encryption_test_case_3),
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_snow3g_encryption_test_case_4),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_snow3g_encryption_test_case_5),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_snow3g_encryption_test_case_1_oop),
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_snow3g_encryption_test_case_1_oop_sgl),
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_snow3g_decryption_test_case_1_oop),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_snow3g_encryption_test_case_1_offset_oop),
9199 /** SNOW 3G decrypt only (UEA2) */
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_snow3g_decryption_test_case_1),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_snow3g_decryption_test_case_2),
9204 TEST_CASE_ST(ut_setup, ut_teardown,
9205 test_snow3g_decryption_test_case_3),
9206 TEST_CASE_ST(ut_setup, ut_teardown,
9207 test_snow3g_decryption_test_case_4),
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 test_snow3g_decryption_test_case_5),
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_snow3g_hash_generate_test_case_1),
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_snow3g_hash_generate_test_case_2),
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_snow3g_hash_generate_test_case_3),
9216 /* Tests with buffers which length is not byte-aligned */
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 test_snow3g_hash_generate_test_case_4),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 test_snow3g_hash_generate_test_case_5),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 test_snow3g_hash_generate_test_case_6),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 test_snow3g_hash_verify_test_case_1),
9225 TEST_CASE_ST(ut_setup, ut_teardown,
9226 test_snow3g_hash_verify_test_case_2),
9227 TEST_CASE_ST(ut_setup, ut_teardown,
9228 test_snow3g_hash_verify_test_case_3),
9229 /* Tests with buffers which length is not byte-aligned */
9230 TEST_CASE_ST(ut_setup, ut_teardown,
9231 test_snow3g_hash_verify_test_case_4),
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 test_snow3g_hash_verify_test_case_5),
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 test_snow3g_hash_verify_test_case_6),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_snow3g_cipher_auth_test_case_1),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_snow3g_auth_cipher_test_case_1),
9241 TEST_CASES_END() /**< NULL terminate unit test array */
9245 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9246 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9247 .setup = testsuite_setup,
9248 .teardown = testsuite_teardown,
9249 .unit_test_cases = {
9250 /** ZUC encrypt only (EEA3) */
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_zuc_encryption_test_case_1),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_zuc_encryption_test_case_2),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_zuc_encryption_test_case_3),
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_zuc_encryption_test_case_4),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_zuc_encryption_test_case_5),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_zuc_hash_generate_test_case_1),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_zuc_hash_generate_test_case_2),
9265 TEST_CASE_ST(ut_setup, ut_teardown,
9266 test_zuc_hash_generate_test_case_3),
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_zuc_hash_generate_test_case_4),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_zuc_hash_generate_test_case_5),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_zuc_encryption_test_case_6_sgl),
9273 TEST_CASES_END() /**< NULL terminate unit test array */
9277 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9278 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9279 .setup = testsuite_setup,
9280 .teardown = testsuite_teardown,
9281 .unit_test_cases = {
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_device_configure_invalid_dev_id),
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_multi_session),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_chain_dpaa_sec_all),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_3DES_chain_dpaa_sec_all),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_cipheronly_dpaa_sec_all),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_3DES_cipheronly_dpaa_sec_all),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_authonly_dpaa_sec_all),
9298 /** AES GCM Authenticated Encryption */
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_GCM_authenticated_encryption_test_case_1),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_authenticated_encryption_test_case_2),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_GCM_authenticated_encryption_test_case_3),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_GCM_authenticated_encryption_test_case_4),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_AES_GCM_authenticated_encryption_test_case_5),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_AES_GCM_authenticated_encryption_test_case_6),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_authenticated_encryption_test_case_7),
9314 /** AES GCM Authenticated Decryption */
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_authenticated_decryption_test_case_1),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_authenticated_decryption_test_case_2),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_authenticated_decryption_test_case_3),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_authenticated_decryption_test_case_4),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_authenticated_decryption_test_case_5),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_AES_GCM_authenticated_decryption_test_case_6),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_authenticated_decryption_test_case_7),
9330 /** AES GCM Authenticated Encryption 256 bits key */
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_AES_GCM_auth_encryption_test_case_256_1),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_auth_encryption_test_case_256_2),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_auth_encryption_test_case_256_3),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_AES_GCM_auth_encryption_test_case_256_4),
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_auth_encryption_test_case_256_5),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_auth_encryption_test_case_256_6),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GCM_auth_encryption_test_case_256_7),
9346 /** AES GCM Authenticated Decryption 256 bits key */
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GCM_auth_decryption_test_case_256_1),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_auth_decryption_test_case_256_2),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_AES_GCM_auth_decryption_test_case_256_3),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_AES_GCM_auth_decryption_test_case_256_4),
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_AES_GCM_auth_decryption_test_case_256_5),
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_AES_GCM_auth_decryption_test_case_256_6),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_AES_GCM_auth_decryption_test_case_256_7),
9362 /** Out of place tests */
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9368 TEST_CASES_END() /**< NULL terminate unit test array */
9372 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9373 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9374 .setup = testsuite_setup,
9375 .teardown = testsuite_teardown,
9376 .unit_test_cases = {
9377 TEST_CASE_ST(ut_setup, ut_teardown,
9378 test_device_configure_invalid_dev_id),
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_multi_session),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_chain_dpaa2_sec_all),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_3DES_chain_dpaa2_sec_all),
9386 TEST_CASE_ST(ut_setup, ut_teardown,
9387 test_AES_cipheronly_dpaa2_sec_all),
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_3DES_cipheronly_dpaa2_sec_all),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_authonly_dpaa2_sec_all),
9393 /** AES GCM Authenticated Encryption */
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GCM_authenticated_encryption_test_case_1),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GCM_authenticated_encryption_test_case_2),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GCM_authenticated_encryption_test_case_3),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GCM_authenticated_encryption_test_case_4),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_AES_GCM_authenticated_encryption_test_case_5),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_AES_GCM_authenticated_encryption_test_case_6),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_authenticated_encryption_test_case_7),
9409 /** AES GCM Authenticated Decryption */
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_authenticated_decryption_test_case_1),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_authenticated_decryption_test_case_2),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_authenticated_decryption_test_case_3),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_authenticated_decryption_test_case_4),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_GCM_authenticated_decryption_test_case_5),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_authenticated_decryption_test_case_6),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_authenticated_decryption_test_case_7),
9425 /** AES GCM Authenticated Encryption 192 bits key */
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_auth_encryption_test_case_192_1),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_auth_encryption_test_case_192_2),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_auth_encryption_test_case_192_3),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_auth_encryption_test_case_192_4),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_AES_GCM_auth_encryption_test_case_192_5),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_AES_GCM_auth_encryption_test_case_192_6),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_GCM_auth_encryption_test_case_192_7),
9441 /** AES GCM Authenticated Decryption 192 bits key */
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_AES_GCM_auth_decryption_test_case_192_1),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_AES_GCM_auth_decryption_test_case_192_2),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_AES_GCM_auth_decryption_test_case_192_3),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_AES_GCM_auth_decryption_test_case_192_4),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_auth_decryption_test_case_192_5),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_AES_GCM_auth_decryption_test_case_192_6),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_GCM_auth_decryption_test_case_192_7),
9457 /** AES GCM Authenticated Encryption 256 bits key */
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GCM_auth_encryption_test_case_256_1),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GCM_auth_encryption_test_case_256_2),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_auth_encryption_test_case_256_3),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_auth_encryption_test_case_256_4),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_auth_encryption_test_case_256_5),
9468 TEST_CASE_ST(ut_setup, ut_teardown,
9469 test_AES_GCM_auth_encryption_test_case_256_6),
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_AES_GCM_auth_encryption_test_case_256_7),
9473 /** AES GCM Authenticated Decryption 256 bits key */
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_auth_decryption_test_case_256_1),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_AES_GCM_auth_decryption_test_case_256_2),
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_AES_GCM_auth_decryption_test_case_256_3),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_AES_GCM_auth_decryption_test_case_256_4),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_AES_GCM_auth_decryption_test_case_256_5),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_AES_GCM_auth_decryption_test_case_256_6),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_AES_GCM_auth_decryption_test_case_256_7),
9489 /** Out of place tests */
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9495 TEST_CASES_END() /**< NULL terminate unit test array */
9499 static struct unit_test_suite cryptodev_null_testsuite = {
9500 .suite_name = "Crypto Device NULL Unit Test Suite",
9501 .setup = testsuite_setup,
9502 .teardown = testsuite_teardown,
9503 .unit_test_cases = {
9504 TEST_CASE_ST(ut_setup, ut_teardown,
9505 test_null_auth_only_operation),
9506 TEST_CASE_ST(ut_setup, ut_teardown,
9507 test_null_cipher_only_operation),
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_null_cipher_auth_operation),
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_null_auth_cipher_operation),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_null_invalid_operation),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_null_burst_operation),
9517 TEST_CASES_END() /**< NULL terminate unit test array */
9521 static struct unit_test_suite cryptodev_armv8_testsuite = {
9522 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9523 .setup = testsuite_setup,
9524 .teardown = testsuite_teardown,
9525 .unit_test_cases = {
9526 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9528 /** Negative tests */
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9534 TEST_CASES_END() /**< NULL terminate unit test array */
9538 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9539 .suite_name = "Crypto Device Marvell Component Test Suite",
9540 .setup = testsuite_setup,
9541 .teardown = testsuite_teardown,
9542 .unit_test_cases = {
9543 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 test_multi_session_random_usage),
9546 TEST_CASE_ST(ut_setup, ut_teardown,
9547 test_AES_chain_mrvl_all),
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 test_AES_cipheronly_mrvl_all),
9550 TEST_CASE_ST(ut_setup, ut_teardown,
9551 test_authonly_mrvl_all),
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_3DES_chain_mrvl_all),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_3DES_cipheronly_mrvl_all),
9557 /** Negative tests */
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9567 TEST_CASES_END() /**< NULL terminate unit test array */
9573 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9575 gbl_driver_id = rte_cryptodev_driver_id_get(
9576 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9578 if (gbl_driver_id == -1) {
9579 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9580 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9581 "in config file to run this testsuite.\n");
9582 return TEST_SKIPPED;
9585 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9589 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9591 gbl_driver_id = rte_cryptodev_driver_id_get(
9592 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9594 if (gbl_driver_id == -1) {
9595 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9596 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9597 "in config file to run this testsuite.\n");
9598 return TEST_SKIPPED;
9601 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9605 test_cryptodev_openssl(void)
9607 gbl_driver_id = rte_cryptodev_driver_id_get(
9608 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9610 if (gbl_driver_id == -1) {
9611 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9612 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9613 "in config file to run this testsuite.\n");
9614 return TEST_SKIPPED;
9617 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9621 test_cryptodev_aesni_gcm(void)
9623 gbl_driver_id = rte_cryptodev_driver_id_get(
9624 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9626 if (gbl_driver_id == -1) {
9627 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9628 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9629 "in config file to run this testsuite.\n");
9630 return TEST_SKIPPED;
9633 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9637 test_cryptodev_null(void)
9639 gbl_driver_id = rte_cryptodev_driver_id_get(
9640 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9642 if (gbl_driver_id == -1) {
9643 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9644 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9645 "in config file to run this testsuite.\n");
9646 return TEST_SKIPPED;
9649 return unit_test_suite_runner(&cryptodev_null_testsuite);
9653 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9655 gbl_driver_id = rte_cryptodev_driver_id_get(
9656 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9658 if (gbl_driver_id == -1) {
9659 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9660 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9661 "in config file to run this testsuite.\n");
9662 return TEST_SKIPPED;
9665 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9669 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9671 gbl_driver_id = rte_cryptodev_driver_id_get(
9672 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9674 if (gbl_driver_id == -1) {
9675 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9676 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9677 "in config file to run this testsuite.\n");
9678 return TEST_SKIPPED;
9681 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9685 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9687 gbl_driver_id = rte_cryptodev_driver_id_get(
9688 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9690 if (gbl_driver_id == -1) {
9691 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9692 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9693 "in config file to run this testsuite.\n");
9694 return TEST_SKIPPED;
9697 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9701 test_cryptodev_armv8(void)
9703 gbl_driver_id = rte_cryptodev_driver_id_get(
9704 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9706 if (gbl_driver_id == -1) {
9707 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9708 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9709 "in config file to run this testsuite.\n");
9710 return TEST_SKIPPED;
9713 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9717 test_cryptodev_mrvl(void)
9719 gbl_driver_id = rte_cryptodev_driver_id_get(
9720 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9722 if (gbl_driver_id == -1) {
9723 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9724 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9725 "in config file to run this testsuite.\n");
9726 return TEST_SKIPPED;
9729 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9732 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9735 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9737 gbl_driver_id = rte_cryptodev_driver_id_get(
9738 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9740 if (gbl_driver_id == -1) {
9741 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9742 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9743 "in config file to run this testsuite.\n");
9744 return TEST_SKIPPED;
9747 if (rte_cryptodev_driver_id_get(
9748 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9749 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9750 " enabled in config file to run this testsuite.\n");
9751 return TEST_SKIPPED;
9753 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9756 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9761 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9763 gbl_driver_id = rte_cryptodev_driver_id_get(
9764 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9766 if (gbl_driver_id == -1) {
9767 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9768 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9769 "in config file to run this testsuite.\n");
9770 return TEST_SKIPPED;
9773 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9777 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9779 gbl_driver_id = rte_cryptodev_driver_id_get(
9780 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
9782 if (gbl_driver_id == -1) {
9783 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
9784 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
9785 "in config file to run this testsuite.\n");
9786 return TEST_SKIPPED;
9789 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
9792 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9793 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9794 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9795 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9796 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9797 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9798 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9799 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9800 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9801 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
9802 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
9803 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);