1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 Intel Corporation
5 #include <rte_common.h>
6 #include <rte_hexdump.h>
8 #include <rte_malloc.h>
9 #include <rte_memcpy.h>
10 #include <rte_pause.h>
11 #include <rte_bus_vdev.h>
13 #include <rte_crypto.h>
14 #include <rte_cryptodev.h>
15 #include <rte_cryptodev_pmd.h>
17 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
18 #include <rte_cryptodev_scheduler.h>
19 #include <rte_cryptodev_scheduler_operations.h>
23 #include "test_cryptodev.h"
25 #include "test_cryptodev_blockcipher.h"
26 #include "test_cryptodev_aes_test_vectors.h"
27 #include "test_cryptodev_des_test_vectors.h"
28 #include "test_cryptodev_hash_test_vectors.h"
29 #include "test_cryptodev_kasumi_test_vectors.h"
30 #include "test_cryptodev_kasumi_hash_test_vectors.h"
31 #include "test_cryptodev_snow3g_test_vectors.h"
32 #include "test_cryptodev_snow3g_hash_test_vectors.h"
33 #include "test_cryptodev_zuc_test_vectors.h"
34 #include "test_cryptodev_aead_test_vectors.h"
35 #include "test_cryptodev_hmac_test_vectors.h"
37 static int gbl_driver_id;
39 struct crypto_testsuite_params {
40 struct rte_mempool *mbuf_pool;
41 struct rte_mempool *large_mbuf_pool;
42 struct rte_mempool *op_mpool;
43 struct rte_mempool *session_mpool;
44 struct rte_cryptodev_config conf;
45 struct rte_cryptodev_qp_conf qp_conf;
47 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
48 uint8_t valid_dev_count;
51 struct crypto_unittest_params {
52 struct rte_crypto_sym_xform cipher_xform;
53 struct rte_crypto_sym_xform auth_xform;
54 struct rte_crypto_sym_xform aead_xform;
56 struct rte_cryptodev_sym_session *sess;
58 struct rte_crypto_op *op;
60 struct rte_mbuf *obuf, *ibuf;
65 #define ALIGN_POW2_ROUNDUP(num, align) \
66 (((num) + (align) - 1) & ~((align) - 1))
69 * Forward declarations.
72 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
73 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
77 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
78 struct crypto_unittest_params *ut_params,
79 struct crypto_testsuite_params *ts_param,
80 const uint8_t *cipher,
81 const uint8_t *digest,
84 static struct rte_mbuf *
85 setup_test_string(struct rte_mempool *mpool,
86 const char *string, size_t len, uint8_t blocksize)
88 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
89 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
91 memset(m->buf_addr, 0, m->buf_len);
93 char *dst = rte_pktmbuf_append(m, t_len);
100 rte_memcpy(dst, string, t_len);
102 memset(dst, 0, t_len);
108 /* Get number of bytes in X bits (rounding up) */
110 ceil_byte_length(uint32_t num_bits)
113 return ((num_bits >> 3) + 1);
115 return (num_bits >> 3);
118 static struct rte_crypto_op *
119 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
121 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
122 printf("Error sending packet for encryption");
128 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
134 static struct crypto_testsuite_params testsuite_params = { NULL };
135 static struct crypto_unittest_params unittest_params;
138 testsuite_setup(void)
140 struct crypto_testsuite_params *ts_params = &testsuite_params;
141 struct rte_cryptodev_info info;
142 uint32_t i = 0, nb_devs, dev_id;
146 memset(ts_params, 0, sizeof(*ts_params));
148 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
149 if (ts_params->mbuf_pool == NULL) {
150 /* Not already created so create */
151 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
153 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
155 if (ts_params->mbuf_pool == NULL) {
156 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
161 ts_params->large_mbuf_pool = rte_mempool_lookup(
162 "CRYPTO_LARGE_MBUFPOOL");
163 if (ts_params->large_mbuf_pool == NULL) {
164 /* Not already created so create */
165 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
166 "CRYPTO_LARGE_MBUFPOOL",
169 if (ts_params->large_mbuf_pool == NULL) {
171 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
176 ts_params->op_mpool = rte_crypto_op_pool_create(
177 "MBUF_CRYPTO_SYM_OP_POOL",
178 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
179 NUM_MBUFS, MBUF_CACHE_SIZE,
181 sizeof(struct rte_crypto_sym_xform) +
184 if (ts_params->op_mpool == NULL) {
185 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
189 /* Create an AESNI MB device if required */
190 if (gbl_driver_id == rte_cryptodev_driver_id_get(
191 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
192 nb_devs = rte_cryptodev_device_count_by_driver(
193 rte_cryptodev_driver_id_get(
194 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
197 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
199 TEST_ASSERT(ret == 0,
200 "Failed to create instance of"
202 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
206 /* Create an AESNI GCM device if required */
207 if (gbl_driver_id == rte_cryptodev_driver_id_get(
208 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
209 nb_devs = rte_cryptodev_device_count_by_driver(
210 rte_cryptodev_driver_id_get(
211 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
213 TEST_ASSERT_SUCCESS(rte_vdev_init(
214 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
215 "Failed to create instance of"
217 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
221 /* Create a SNOW 3G device if required */
222 if (gbl_driver_id == rte_cryptodev_driver_id_get(
223 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
224 nb_devs = rte_cryptodev_device_count_by_driver(
225 rte_cryptodev_driver_id_get(
226 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
228 TEST_ASSERT_SUCCESS(rte_vdev_init(
229 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
230 "Failed to create instance of"
232 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
236 /* Create a KASUMI device if required */
237 if (gbl_driver_id == rte_cryptodev_driver_id_get(
238 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
239 nb_devs = rte_cryptodev_device_count_by_driver(
240 rte_cryptodev_driver_id_get(
241 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
243 TEST_ASSERT_SUCCESS(rte_vdev_init(
244 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
245 "Failed to create instance of"
247 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
251 /* Create a ZUC device if required */
252 if (gbl_driver_id == rte_cryptodev_driver_id_get(
253 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
254 nb_devs = rte_cryptodev_device_count_by_driver(
255 rte_cryptodev_driver_id_get(
256 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
258 TEST_ASSERT_SUCCESS(rte_vdev_init(
259 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
260 "Failed to create instance of"
262 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
266 /* Create a NULL device if required */
267 if (gbl_driver_id == rte_cryptodev_driver_id_get(
268 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
269 nb_devs = rte_cryptodev_device_count_by_driver(
270 rte_cryptodev_driver_id_get(
271 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
274 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
276 TEST_ASSERT(ret == 0,
277 "Failed to create instance of"
279 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
283 /* Create an OPENSSL device if required */
284 if (gbl_driver_id == rte_cryptodev_driver_id_get(
285 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
286 nb_devs = rte_cryptodev_device_count_by_driver(
287 rte_cryptodev_driver_id_get(
288 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
291 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
294 TEST_ASSERT(ret == 0, "Failed to create "
295 "instance of pmd : %s",
296 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
300 /* Create a ARMv8 device if required */
301 if (gbl_driver_id == rte_cryptodev_driver_id_get(
302 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
303 nb_devs = rte_cryptodev_device_count_by_driver(
304 rte_cryptodev_driver_id_get(
305 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
308 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
311 TEST_ASSERT(ret == 0, "Failed to create "
312 "instance of pmd : %s",
313 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
317 /* Create a MRVL device if required */
318 if (gbl_driver_id == rte_cryptodev_driver_id_get(
319 RTE_STR(CRYPTODEV_MRVL_PMD))) {
320 #ifndef RTE_LIBRTE_PMD_MRVL_CRYPTO
321 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO must be"
322 " enabled in config file to run this testsuite.\n");
325 nb_devs = rte_cryptodev_device_count_by_driver(
326 rte_cryptodev_driver_id_get(
327 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)));
330 RTE_STR(CRYPTODEV_NAME_MRVL_PMD),
333 TEST_ASSERT(ret == 0, "Failed to create "
334 "instance of pmd : %s",
335 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
339 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
340 if (gbl_driver_id == rte_cryptodev_driver_id_get(
341 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
343 nb_devs = rte_cryptodev_device_count_by_driver(
344 rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
348 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
351 TEST_ASSERT(ret == 0,
352 "Failed to create instance %u of"
354 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
357 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
359 nb_devs = rte_cryptodev_count();
361 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
365 /* Create list of valid crypto devs */
366 for (i = 0; i < nb_devs; i++) {
367 rte_cryptodev_info_get(i, &info);
368 if (info.driver_id == gbl_driver_id)
369 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
372 if (ts_params->valid_dev_count < 1)
375 /* Set up all the qps on the first of the valid devices found */
377 dev_id = ts_params->valid_devs[0];
379 rte_cryptodev_info_get(dev_id, &info);
381 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
382 ts_params->conf.socket_id = SOCKET_ID_ANY;
384 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
387 * Create mempool with maximum number of sessions * 2,
388 * to include the session headers
390 ts_params->session_mpool = rte_mempool_create(
392 info.sym.max_nb_sessions * 2,
394 0, 0, NULL, NULL, NULL,
398 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
399 "session mempool allocation failed");
401 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
403 "Failed to configure cryptodev %u with %u qps",
404 dev_id, ts_params->conf.nb_queue_pairs);
406 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
408 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
409 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
410 dev_id, qp_id, &ts_params->qp_conf,
411 rte_cryptodev_socket_id(dev_id),
412 ts_params->session_mpool),
413 "Failed to setup queue pair %u on cryptodev %u",
421 testsuite_teardown(void)
423 struct crypto_testsuite_params *ts_params = &testsuite_params;
425 if (ts_params->mbuf_pool != NULL) {
426 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
427 rte_mempool_avail_count(ts_params->mbuf_pool));
430 if (ts_params->op_mpool != NULL) {
431 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
432 rte_mempool_avail_count(ts_params->op_mpool));
435 /* Free session mempools */
436 if (ts_params->session_mpool != NULL) {
437 rte_mempool_free(ts_params->session_mpool);
438 ts_params->session_mpool = NULL;
445 struct crypto_testsuite_params *ts_params = &testsuite_params;
446 struct crypto_unittest_params *ut_params = &unittest_params;
450 /* Clear unit test parameters before running test */
451 memset(ut_params, 0, sizeof(*ut_params));
453 /* Reconfigure device to default parameters */
454 ts_params->conf.socket_id = SOCKET_ID_ANY;
456 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
458 "Failed to configure cryptodev %u",
459 ts_params->valid_devs[0]);
461 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
462 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
463 ts_params->valid_devs[0], qp_id,
465 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
466 ts_params->session_mpool),
467 "Failed to setup queue pair %u on cryptodev %u",
468 qp_id, ts_params->valid_devs[0]);
472 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
474 /* Start the device */
475 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
476 "Failed to start cryptodev %u",
477 ts_params->valid_devs[0]);
485 struct crypto_testsuite_params *ts_params = &testsuite_params;
486 struct crypto_unittest_params *ut_params = &unittest_params;
487 struct rte_cryptodev_stats stats;
489 /* free crypto session structure */
490 if (ut_params->sess) {
491 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
493 rte_cryptodev_sym_session_free(ut_params->sess);
494 ut_params->sess = NULL;
497 /* free crypto operation structure */
499 rte_crypto_op_free(ut_params->op);
502 * free mbuf - both obuf and ibuf are usually the same,
503 * so check if they point at the same address is necessary,
504 * to avoid freeing the mbuf twice.
506 if (ut_params->obuf) {
507 rte_pktmbuf_free(ut_params->obuf);
508 if (ut_params->ibuf == ut_params->obuf)
512 if (ut_params->ibuf) {
513 rte_pktmbuf_free(ut_params->ibuf);
517 if (ts_params->mbuf_pool != NULL)
518 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
519 rte_mempool_avail_count(ts_params->mbuf_pool));
521 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
523 /* Stop the device */
524 rte_cryptodev_stop(ts_params->valid_devs[0]);
528 test_device_configure_invalid_dev_id(void)
530 struct crypto_testsuite_params *ts_params = &testsuite_params;
531 uint16_t dev_id, num_devs = 0;
533 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
534 "Need at least %d devices for test", 1);
536 /* valid dev_id values */
537 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
539 /* Stop the device in case it's started so it can be configured */
540 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
542 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
543 "Failed test for rte_cryptodev_configure: "
544 "invalid dev_num %u", dev_id);
546 /* invalid dev_id values */
549 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
550 "Failed test for rte_cryptodev_configure: "
551 "invalid dev_num %u", dev_id);
555 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
556 "Failed test for rte_cryptodev_configure:"
557 "invalid dev_num %u", dev_id);
563 test_device_configure_invalid_queue_pair_ids(void)
565 struct crypto_testsuite_params *ts_params = &testsuite_params;
566 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
568 /* Stop the device in case it's started so it can be configured */
569 rte_cryptodev_stop(ts_params->valid_devs[0]);
571 /* valid - one queue pairs */
572 ts_params->conf.nb_queue_pairs = 1;
574 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
576 "Failed to configure cryptodev: dev_id %u, qp_id %u",
577 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
580 /* valid - max value queue pairs */
581 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
583 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
585 "Failed to configure cryptodev: dev_id %u, qp_id %u",
586 ts_params->valid_devs[0],
587 ts_params->conf.nb_queue_pairs);
590 /* invalid - zero queue pairs */
591 ts_params->conf.nb_queue_pairs = 0;
593 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
595 "Failed test for rte_cryptodev_configure, dev_id %u,"
597 ts_params->valid_devs[0],
598 ts_params->conf.nb_queue_pairs);
601 /* invalid - max value supported by field queue pairs */
602 ts_params->conf.nb_queue_pairs = UINT16_MAX;
604 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
606 "Failed test for rte_cryptodev_configure, dev_id %u,"
608 ts_params->valid_devs[0],
609 ts_params->conf.nb_queue_pairs);
612 /* invalid - max value + 1 queue pairs */
613 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
615 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
617 "Failed test for rte_cryptodev_configure, dev_id %u,"
619 ts_params->valid_devs[0],
620 ts_params->conf.nb_queue_pairs);
622 /* revert to original testsuite value */
623 ts_params->conf.nb_queue_pairs = orig_nb_qps;
629 test_queue_pair_descriptor_setup(void)
631 struct crypto_testsuite_params *ts_params = &testsuite_params;
632 struct rte_cryptodev_info dev_info;
633 struct rte_cryptodev_qp_conf qp_conf = {
634 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
639 /* Stop the device in case it's started so it can be configured */
640 rte_cryptodev_stop(ts_params->valid_devs[0]);
643 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
645 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
647 "Failed to configure cryptodev %u",
648 ts_params->valid_devs[0]);
651 * Test various ring sizes on this device. memzones can't be
652 * freed so are re-used if ring is released and re-created.
654 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
656 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
657 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
658 ts_params->valid_devs[0], qp_id, &qp_conf,
659 rte_cryptodev_socket_id(
660 ts_params->valid_devs[0]),
661 ts_params->session_mpool),
663 "rte_cryptodev_queue_pair_setup: num_inflights "
664 "%u on qp %u on cryptodev %u",
665 qp_conf.nb_descriptors, qp_id,
666 ts_params->valid_devs[0]);
669 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
671 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
672 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
673 ts_params->valid_devs[0], qp_id, &qp_conf,
674 rte_cryptodev_socket_id(
675 ts_params->valid_devs[0]),
676 ts_params->session_mpool),
678 " rte_cryptodev_queue_pair_setup: num_inflights"
679 " %u on qp %u on cryptodev %u",
680 qp_conf.nb_descriptors, qp_id,
681 ts_params->valid_devs[0]);
684 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
686 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
687 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
688 ts_params->valid_devs[0], qp_id, &qp_conf,
689 rte_cryptodev_socket_id(
690 ts_params->valid_devs[0]),
691 ts_params->session_mpool),
693 "rte_cryptodev_queue_pair_setup: num_inflights"
694 " %u on qp %u on cryptodev %u",
695 qp_conf.nb_descriptors, qp_id,
696 ts_params->valid_devs[0]);
699 /* invalid number of descriptors - max supported + 2 */
700 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
702 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
703 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
704 ts_params->valid_devs[0], qp_id, &qp_conf,
705 rte_cryptodev_socket_id(
706 ts_params->valid_devs[0]),
707 ts_params->session_mpool),
708 "Unexpectedly passed test for "
709 "rte_cryptodev_queue_pair_setup:"
710 "num_inflights %u on qp %u on cryptodev %u",
711 qp_conf.nb_descriptors, qp_id,
712 ts_params->valid_devs[0]);
715 /* invalid number of descriptors - max value of parameter */
716 qp_conf.nb_descriptors = UINT32_MAX-1;
718 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
719 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
720 ts_params->valid_devs[0], qp_id, &qp_conf,
721 rte_cryptodev_socket_id(
722 ts_params->valid_devs[0]),
723 ts_params->session_mpool),
724 "Unexpectedly passed test for "
725 "rte_cryptodev_queue_pair_setup:"
726 "num_inflights %u on qp %u on cryptodev %u",
727 qp_conf.nb_descriptors, qp_id,
728 ts_params->valid_devs[0]);
731 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
733 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
734 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
735 ts_params->valid_devs[0], qp_id, &qp_conf,
736 rte_cryptodev_socket_id(
737 ts_params->valid_devs[0]),
738 ts_params->session_mpool),
740 " rte_cryptodev_queue_pair_setup:"
741 "num_inflights %u on qp %u on cryptodev %u",
742 qp_conf.nb_descriptors, qp_id,
743 ts_params->valid_devs[0]);
746 /* invalid number of descriptors - max supported + 1 */
747 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
749 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
750 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
751 ts_params->valid_devs[0], qp_id, &qp_conf,
752 rte_cryptodev_socket_id(
753 ts_params->valid_devs[0]),
754 ts_params->session_mpool),
755 "Unexpectedly passed test for "
756 "rte_cryptodev_queue_pair_setup:"
757 "num_inflights %u on qp %u on cryptodev %u",
758 qp_conf.nb_descriptors, qp_id,
759 ts_params->valid_devs[0]);
762 /* test invalid queue pair id */
763 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
765 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
767 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
768 ts_params->valid_devs[0],
770 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
771 ts_params->session_mpool),
772 "Failed test for rte_cryptodev_queue_pair_setup:"
773 "invalid qp %u on cryptodev %u",
774 qp_id, ts_params->valid_devs[0]);
776 qp_id = 0xffff; /*invalid*/
778 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
779 ts_params->valid_devs[0],
781 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
782 ts_params->session_mpool),
783 "Failed test for rte_cryptodev_queue_pair_setup:"
784 "invalid qp %u on cryptodev %u",
785 qp_id, ts_params->valid_devs[0]);
790 /* ***** Plaintext data for tests ***** */
792 const char catch_22_quote_1[] =
793 "There was only one catch and that was Catch-22, which "
794 "specified that a concern for one's safety in the face of "
795 "dangers that were real and immediate was the process of a "
796 "rational mind. Orr was crazy and could be grounded. All he "
797 "had to do was ask; and as soon as he did, he would no longer "
798 "be crazy and would have to fly more missions. Orr would be "
799 "crazy to fly more missions and sane if he didn't, but if he "
800 "was sane he had to fly them. If he flew them he was crazy "
801 "and didn't have to; but if he didn't want to he was sane and "
802 "had to. Yossarian was moved very deeply by the absolute "
803 "simplicity of this clause of Catch-22 and let out a "
804 "respectful whistle. \"That's some catch, that Catch-22\", he "
805 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
807 const char catch_22_quote[] =
808 "What a lousy earth! He wondered how many people were "
809 "destitute that same night even in his own prosperous country, "
810 "how many homes were shanties, how many husbands were drunk "
811 "and wives socked, and how many children were bullied, abused, "
812 "or abandoned. How many families hungered for food they could "
813 "not afford to buy? How many hearts were broken? How many "
814 "suicides would take place that same night, how many people "
815 "would go insane? How many cockroaches and landlords would "
816 "triumph? How many winners were losers, successes failures, "
817 "and rich men poor men? How many wise guys were stupid? How "
818 "many happy endings were unhappy endings? How many honest men "
819 "were liars, brave men cowards, loyal men traitors, how many "
820 "sainted men were corrupt, how many people in positions of "
821 "trust had sold their souls to bodyguards, how many had never "
822 "had souls? How many straight-and-narrow paths were crooked "
823 "paths? How many best families were worst families and how "
824 "many good people were bad people? When you added them all up "
825 "and then subtracted, you might be left with only the children, "
826 "and perhaps with Albert Einstein and an old violinist or "
827 "sculptor somewhere.";
829 #define QUOTE_480_BYTES (480)
830 #define QUOTE_512_BYTES (512)
831 #define QUOTE_768_BYTES (768)
832 #define QUOTE_1024_BYTES (1024)
836 /* ***** SHA1 Hash Tests ***** */
838 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
840 static uint8_t hmac_sha1_key[] = {
841 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
842 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
843 0xDE, 0xF4, 0xDE, 0xAD };
845 /* ***** SHA224 Hash Tests ***** */
847 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
850 /* ***** AES-CBC Cipher Tests ***** */
852 #define CIPHER_KEY_LENGTH_AES_CBC (16)
853 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
855 static uint8_t aes_cbc_key[] = {
856 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
857 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
859 static uint8_t aes_cbc_iv[] = {
860 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
861 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
864 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
866 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
867 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
868 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
869 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
870 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
871 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
872 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
873 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
874 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
875 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
876 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
877 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
878 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
879 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
880 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
881 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
882 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
883 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
884 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
885 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
886 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
887 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
888 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
889 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
890 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
891 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
892 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
893 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
894 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
895 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
896 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
897 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
898 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
899 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
900 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
901 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
902 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
903 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
904 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
905 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
906 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
907 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
908 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
909 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
910 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
911 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
912 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
913 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
914 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
915 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
916 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
917 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
918 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
919 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
920 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
921 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
922 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
923 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
924 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
925 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
926 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
927 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
928 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
929 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
930 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
933 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
934 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
935 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
936 0x18, 0x8c, 0x1d, 0x32
940 /* Multisession Vector context Test */
942 static uint8_t ms_aes_cbc_key0[] = {
943 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
944 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
947 static uint8_t ms_aes_cbc_iv0[] = {
948 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
949 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
952 static const uint8_t ms_aes_cbc_cipher0[] = {
953 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
954 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
955 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
956 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
957 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
958 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
959 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
960 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
961 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
962 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
963 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
964 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
965 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
966 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
967 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
968 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
969 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
970 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
971 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
972 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
973 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
974 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
975 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
976 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
977 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
978 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
979 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
980 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
981 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
982 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
983 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
984 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
985 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
986 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
987 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
988 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
989 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
990 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
991 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
992 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
993 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
994 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
995 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
996 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
997 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
998 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
999 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1000 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1001 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1002 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1003 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1004 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1005 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1006 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1007 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1008 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1009 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1010 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1011 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1012 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1013 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1014 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1015 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1016 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1020 static uint8_t ms_hmac_key0[] = {
1021 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1022 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1023 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1024 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1025 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1026 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1027 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1028 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1031 static const uint8_t ms_hmac_digest0[] = {
1032 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1033 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1034 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1035 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1036 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1037 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1038 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1039 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1043 /* Begin session 1 */
1045 static uint8_t ms_aes_cbc_key1[] = {
1046 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1047 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1050 static uint8_t ms_aes_cbc_iv1[] = {
1051 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1052 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1055 static const uint8_t ms_aes_cbc_cipher1[] = {
1056 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1057 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1058 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1059 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1060 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1061 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1062 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1063 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1064 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1065 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1066 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1067 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1068 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1069 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1070 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1071 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1072 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1073 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1074 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1075 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1076 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1077 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1078 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1079 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1080 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1081 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1082 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1083 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1084 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1085 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1086 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1087 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1088 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1089 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1090 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1091 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1092 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1093 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1094 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1095 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1096 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1097 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1098 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1099 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1100 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1101 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1102 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1103 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1104 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1105 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1106 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1107 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1108 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1109 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1110 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1111 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1112 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1113 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1114 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1115 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1116 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1117 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1118 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1119 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1123 static uint8_t ms_hmac_key1[] = {
1124 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1125 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1126 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1127 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1128 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1129 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1130 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1131 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1134 static const uint8_t ms_hmac_digest1[] = {
1135 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1136 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1137 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1138 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1139 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1140 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1141 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1142 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1145 /* Begin Session 2 */
1146 static uint8_t ms_aes_cbc_key2[] = {
1147 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1148 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1151 static uint8_t ms_aes_cbc_iv2[] = {
1152 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1153 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1156 static const uint8_t ms_aes_cbc_cipher2[] = {
1157 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1158 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1159 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1160 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1161 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1162 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1163 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1164 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1165 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1166 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1167 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1168 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1169 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1170 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1171 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1172 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1173 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1174 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1175 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1176 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1177 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1178 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1179 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1180 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1181 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1182 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1183 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1184 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1185 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1186 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1187 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1188 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1189 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1190 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1191 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1192 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1193 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1194 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1195 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1196 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1197 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1198 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1199 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1200 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1201 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1202 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1203 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1204 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1205 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1206 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1207 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1208 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1209 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1210 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1211 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1212 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1213 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1214 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1215 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1216 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1217 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1218 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1219 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1220 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1223 static uint8_t ms_hmac_key2[] = {
1224 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1225 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1226 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1227 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1228 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1229 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1230 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1231 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1234 static const uint8_t ms_hmac_digest2[] = {
1235 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1236 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1237 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1238 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1239 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1240 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1241 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1242 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1249 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1251 struct crypto_testsuite_params *ts_params = &testsuite_params;
1252 struct crypto_unittest_params *ut_params = &unittest_params;
1254 /* Generate test mbuf data and space for digest */
1255 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1256 catch_22_quote, QUOTE_512_BYTES, 0);
1258 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1259 DIGEST_BYTE_LENGTH_SHA1);
1260 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1262 /* Setup Cipher Parameters */
1263 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1264 ut_params->cipher_xform.next = &ut_params->auth_xform;
1266 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1267 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1268 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1269 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1270 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1271 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1273 /* Setup HMAC Parameters */
1274 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1276 ut_params->auth_xform.next = NULL;
1278 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1279 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1280 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1281 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1282 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1284 ut_params->sess = rte_cryptodev_sym_session_create(
1285 ts_params->session_mpool);
1287 /* Create crypto session*/
1288 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1289 ut_params->sess, &ut_params->cipher_xform,
1290 ts_params->session_mpool);
1291 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1293 /* Generate crypto op data structure */
1294 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1295 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1296 TEST_ASSERT_NOT_NULL(ut_params->op,
1297 "Failed to allocate symmetric crypto operation struct");
1299 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1301 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1303 /* set crypto operation source mbuf */
1304 sym_op->m_src = ut_params->ibuf;
1306 /* Set crypto operation authentication parameters */
1307 sym_op->auth.digest.data = ut_params->digest;
1308 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1309 ut_params->ibuf, QUOTE_512_BYTES);
1311 sym_op->auth.data.offset = 0;
1312 sym_op->auth.data.length = QUOTE_512_BYTES;
1314 /* Copy IV at the end of the crypto operation */
1315 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1316 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1318 /* Set crypto operation cipher parameters */
1319 sym_op->cipher.data.offset = 0;
1320 sym_op->cipher.data.length = QUOTE_512_BYTES;
1322 /* Process crypto operation */
1323 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1324 ut_params->op), "failed to process sym crypto op");
1326 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1327 "crypto op processing failed");
1330 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1333 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1334 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1336 "ciphertext data not as expected");
1338 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1340 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1341 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1342 gbl_driver_id == rte_cryptodev_driver_id_get(
1343 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1344 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1345 DIGEST_BYTE_LENGTH_SHA1,
1346 "Generated digest data not as expected");
1348 return TEST_SUCCESS;
1351 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1353 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1355 static uint8_t hmac_sha512_key[] = {
1356 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1357 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1358 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1359 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1360 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1361 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1362 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1363 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1365 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1366 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1367 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1368 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1369 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1370 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1371 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1372 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1373 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1378 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1379 struct crypto_unittest_params *ut_params,
1380 uint8_t *cipher_key,
1384 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1385 struct crypto_unittest_params *ut_params,
1386 struct crypto_testsuite_params *ts_params,
1387 const uint8_t *cipher,
1388 const uint8_t *digest,
1393 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1394 struct crypto_unittest_params *ut_params,
1395 uint8_t *cipher_key,
1399 /* Setup Cipher Parameters */
1400 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1401 ut_params->cipher_xform.next = NULL;
1403 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1404 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1405 ut_params->cipher_xform.cipher.key.data = cipher_key;
1406 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1407 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1408 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1410 /* Setup HMAC Parameters */
1411 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1412 ut_params->auth_xform.next = &ut_params->cipher_xform;
1414 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1415 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1416 ut_params->auth_xform.auth.key.data = hmac_key;
1417 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1418 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1420 return TEST_SUCCESS;
1425 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1426 struct crypto_unittest_params *ut_params,
1427 struct crypto_testsuite_params *ts_params,
1428 const uint8_t *cipher,
1429 const uint8_t *digest,
1432 /* Generate test mbuf data and digest */
1433 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1436 QUOTE_512_BYTES, 0);
1438 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1439 DIGEST_BYTE_LENGTH_SHA512);
1440 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1442 rte_memcpy(ut_params->digest,
1444 DIGEST_BYTE_LENGTH_SHA512);
1446 /* Generate Crypto op data structure */
1447 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1448 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1449 TEST_ASSERT_NOT_NULL(ut_params->op,
1450 "Failed to allocate symmetric crypto operation struct");
1452 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1454 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1456 /* set crypto operation source mbuf */
1457 sym_op->m_src = ut_params->ibuf;
1459 sym_op->auth.digest.data = ut_params->digest;
1460 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1461 ut_params->ibuf, QUOTE_512_BYTES);
1463 sym_op->auth.data.offset = 0;
1464 sym_op->auth.data.length = QUOTE_512_BYTES;
1466 /* Copy IV at the end of the crypto operation */
1467 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1468 iv, CIPHER_IV_LENGTH_AES_CBC);
1470 sym_op->cipher.data.offset = 0;
1471 sym_op->cipher.data.length = QUOTE_512_BYTES;
1473 /* Process crypto operation */
1474 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1475 ut_params->op), "failed to process sym crypto op");
1477 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1478 "crypto op processing failed");
1480 ut_params->obuf = ut_params->op->sym->m_src;
1483 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1484 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1487 "Plaintext data not as expected");
1490 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1491 "Digest verification failed");
1493 return TEST_SUCCESS;
1497 test_AES_cipheronly_mb_all(void)
1499 struct crypto_testsuite_params *ts_params = &testsuite_params;
1502 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1503 ts_params->op_mpool,
1504 ts_params->session_mpool,
1505 ts_params->valid_devs[0],
1506 rte_cryptodev_driver_id_get(
1507 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1508 BLKCIPHER_AES_CIPHERONLY_TYPE);
1510 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1512 return TEST_SUCCESS;
1516 test_AES_docsis_mb_all(void)
1518 struct crypto_testsuite_params *ts_params = &testsuite_params;
1521 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1522 ts_params->op_mpool,
1523 ts_params->session_mpool,
1524 ts_params->valid_devs[0],
1525 rte_cryptodev_driver_id_get(
1526 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1527 BLKCIPHER_AES_DOCSIS_TYPE);
1529 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1531 return TEST_SUCCESS;
1535 test_AES_docsis_qat_all(void)
1537 struct crypto_testsuite_params *ts_params = &testsuite_params;
1540 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1541 ts_params->op_mpool,
1542 ts_params->session_mpool,
1543 ts_params->valid_devs[0],
1544 rte_cryptodev_driver_id_get(
1545 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1546 BLKCIPHER_AES_DOCSIS_TYPE);
1548 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1550 return TEST_SUCCESS;
1554 test_DES_docsis_qat_all(void)
1556 struct crypto_testsuite_params *ts_params = &testsuite_params;
1559 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1560 ts_params->op_mpool,
1561 ts_params->session_mpool,
1562 ts_params->valid_devs[0],
1563 rte_cryptodev_driver_id_get(
1564 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1565 BLKCIPHER_DES_DOCSIS_TYPE);
1567 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1569 return TEST_SUCCESS;
1573 test_authonly_mb_all(void)
1575 struct crypto_testsuite_params *ts_params = &testsuite_params;
1578 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1579 ts_params->op_mpool,
1580 ts_params->session_mpool,
1581 ts_params->valid_devs[0],
1582 rte_cryptodev_driver_id_get(
1583 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1584 BLKCIPHER_AUTHONLY_TYPE);
1586 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1588 return TEST_SUCCESS;
1592 test_authonly_qat_all(void)
1594 struct crypto_testsuite_params *ts_params = &testsuite_params;
1597 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1598 ts_params->op_mpool,
1599 ts_params->session_mpool,
1600 ts_params->valid_devs[0],
1601 rte_cryptodev_driver_id_get(
1602 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1603 BLKCIPHER_AUTHONLY_TYPE);
1605 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1607 return TEST_SUCCESS;
1610 test_AES_chain_mb_all(void)
1612 struct crypto_testsuite_params *ts_params = &testsuite_params;
1615 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1616 ts_params->op_mpool,
1617 ts_params->session_mpool,
1618 ts_params->valid_devs[0],
1619 rte_cryptodev_driver_id_get(
1620 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1621 BLKCIPHER_AES_CHAIN_TYPE);
1623 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1625 return TEST_SUCCESS;
1628 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1631 test_AES_cipheronly_scheduler_all(void)
1633 struct crypto_testsuite_params *ts_params = &testsuite_params;
1636 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1637 ts_params->op_mpool,
1638 ts_params->session_mpool,
1639 ts_params->valid_devs[0],
1640 rte_cryptodev_driver_id_get(
1641 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1642 BLKCIPHER_AES_CIPHERONLY_TYPE);
1644 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1646 return TEST_SUCCESS;
1650 test_AES_chain_scheduler_all(void)
1652 struct crypto_testsuite_params *ts_params = &testsuite_params;
1655 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1656 ts_params->op_mpool,
1657 ts_params->session_mpool,
1658 ts_params->valid_devs[0],
1659 rte_cryptodev_driver_id_get(
1660 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1661 BLKCIPHER_AES_CHAIN_TYPE);
1663 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1665 return TEST_SUCCESS;
1669 test_authonly_scheduler_all(void)
1671 struct crypto_testsuite_params *ts_params = &testsuite_params;
1674 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1675 ts_params->op_mpool,
1676 ts_params->session_mpool,
1677 ts_params->valid_devs[0],
1678 rte_cryptodev_driver_id_get(
1679 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1680 BLKCIPHER_AUTHONLY_TYPE);
1682 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1684 return TEST_SUCCESS;
1687 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1690 test_AES_chain_openssl_all(void)
1692 struct crypto_testsuite_params *ts_params = &testsuite_params;
1695 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1696 ts_params->op_mpool,
1697 ts_params->session_mpool,
1698 ts_params->valid_devs[0],
1699 rte_cryptodev_driver_id_get(
1700 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1701 BLKCIPHER_AES_CHAIN_TYPE);
1703 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1705 return TEST_SUCCESS;
1709 test_AES_cipheronly_openssl_all(void)
1711 struct crypto_testsuite_params *ts_params = &testsuite_params;
1714 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1715 ts_params->op_mpool,
1716 ts_params->session_mpool,
1717 ts_params->valid_devs[0],
1718 rte_cryptodev_driver_id_get(
1719 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1720 BLKCIPHER_AES_CIPHERONLY_TYPE);
1722 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1724 return TEST_SUCCESS;
1728 test_AES_chain_qat_all(void)
1730 struct crypto_testsuite_params *ts_params = &testsuite_params;
1733 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1734 ts_params->op_mpool,
1735 ts_params->session_mpool,
1736 ts_params->valid_devs[0],
1737 rte_cryptodev_driver_id_get(
1738 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1739 BLKCIPHER_AES_CHAIN_TYPE);
1741 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1743 return TEST_SUCCESS;
1747 test_AES_cipheronly_qat_all(void)
1749 struct crypto_testsuite_params *ts_params = &testsuite_params;
1752 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1753 ts_params->op_mpool,
1754 ts_params->session_mpool,
1755 ts_params->valid_devs[0],
1756 rte_cryptodev_driver_id_get(
1757 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1758 BLKCIPHER_AES_CIPHERONLY_TYPE);
1760 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1762 return TEST_SUCCESS;
1766 test_AES_chain_dpaa_sec_all(void)
1768 struct crypto_testsuite_params *ts_params = &testsuite_params;
1771 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1772 ts_params->op_mpool,
1773 ts_params->session_mpool,
1774 ts_params->valid_devs[0],
1775 rte_cryptodev_driver_id_get(
1776 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1777 BLKCIPHER_AES_CHAIN_TYPE);
1779 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1781 return TEST_SUCCESS;
1785 test_AES_cipheronly_dpaa_sec_all(void)
1787 struct crypto_testsuite_params *ts_params = &testsuite_params;
1790 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1791 ts_params->op_mpool,
1792 ts_params->session_mpool,
1793 ts_params->valid_devs[0],
1794 rte_cryptodev_driver_id_get(
1795 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1796 BLKCIPHER_AES_CIPHERONLY_TYPE);
1798 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1800 return TEST_SUCCESS;
1804 test_authonly_dpaa_sec_all(void)
1806 struct crypto_testsuite_params *ts_params = &testsuite_params;
1809 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1810 ts_params->op_mpool,
1811 ts_params->session_mpool,
1812 ts_params->valid_devs[0],
1813 rte_cryptodev_driver_id_get(
1814 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1815 BLKCIPHER_AUTHONLY_TYPE);
1817 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1819 return TEST_SUCCESS;
1823 test_AES_chain_dpaa2_sec_all(void)
1825 struct crypto_testsuite_params *ts_params = &testsuite_params;
1828 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1829 ts_params->op_mpool,
1830 ts_params->session_mpool,
1831 ts_params->valid_devs[0],
1832 rte_cryptodev_driver_id_get(
1833 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1834 BLKCIPHER_AES_CHAIN_TYPE);
1836 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1838 return TEST_SUCCESS;
1842 test_AES_cipheronly_dpaa2_sec_all(void)
1844 struct crypto_testsuite_params *ts_params = &testsuite_params;
1847 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1848 ts_params->op_mpool,
1849 ts_params->session_mpool,
1850 ts_params->valid_devs[0],
1851 rte_cryptodev_driver_id_get(
1852 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1853 BLKCIPHER_AES_CIPHERONLY_TYPE);
1855 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1857 return TEST_SUCCESS;
1861 test_authonly_dpaa2_sec_all(void)
1863 struct crypto_testsuite_params *ts_params = &testsuite_params;
1866 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1867 ts_params->op_mpool,
1868 ts_params->session_mpool,
1869 ts_params->valid_devs[0],
1870 rte_cryptodev_driver_id_get(
1871 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1872 BLKCIPHER_AUTHONLY_TYPE);
1874 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1876 return TEST_SUCCESS;
1880 test_authonly_openssl_all(void)
1882 struct crypto_testsuite_params *ts_params = &testsuite_params;
1885 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1886 ts_params->op_mpool,
1887 ts_params->session_mpool,
1888 ts_params->valid_devs[0],
1889 rte_cryptodev_driver_id_get(
1890 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1891 BLKCIPHER_AUTHONLY_TYPE);
1893 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1895 return TEST_SUCCESS;
1899 test_AES_chain_armv8_all(void)
1901 struct crypto_testsuite_params *ts_params = &testsuite_params;
1904 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1905 ts_params->op_mpool,
1906 ts_params->session_mpool,
1907 ts_params->valid_devs[0],
1908 rte_cryptodev_driver_id_get(
1909 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
1910 BLKCIPHER_AES_CHAIN_TYPE);
1912 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1914 return TEST_SUCCESS;
1918 test_AES_chain_mrvl_all(void)
1920 struct crypto_testsuite_params *ts_params = &testsuite_params;
1923 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1924 ts_params->op_mpool,
1925 ts_params->session_mpool,
1926 ts_params->valid_devs[0],
1927 rte_cryptodev_driver_id_get(
1928 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1929 BLKCIPHER_AES_CHAIN_TYPE);
1931 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1933 return TEST_SUCCESS;
1937 test_AES_cipheronly_mrvl_all(void)
1939 struct crypto_testsuite_params *ts_params = &testsuite_params;
1942 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1943 ts_params->op_mpool,
1944 ts_params->session_mpool,
1945 ts_params->valid_devs[0],
1946 rte_cryptodev_driver_id_get(
1947 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1948 BLKCIPHER_AES_CIPHERONLY_TYPE);
1950 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1952 return TEST_SUCCESS;
1956 test_authonly_mrvl_all(void)
1958 struct crypto_testsuite_params *ts_params = &testsuite_params;
1961 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1962 ts_params->op_mpool,
1963 ts_params->session_mpool,
1964 ts_params->valid_devs[0],
1965 rte_cryptodev_driver_id_get(
1966 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1967 BLKCIPHER_AUTHONLY_TYPE);
1969 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1971 return TEST_SUCCESS;
1975 test_3DES_chain_mrvl_all(void)
1977 struct crypto_testsuite_params *ts_params = &testsuite_params;
1980 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1981 ts_params->op_mpool,
1982 ts_params->session_mpool,
1983 ts_params->valid_devs[0],
1984 rte_cryptodev_driver_id_get(
1985 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
1986 BLKCIPHER_3DES_CHAIN_TYPE);
1988 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1990 return TEST_SUCCESS;
1994 test_3DES_cipheronly_mrvl_all(void)
1996 struct crypto_testsuite_params *ts_params = &testsuite_params;
1999 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2000 ts_params->op_mpool,
2001 ts_params->session_mpool,
2002 ts_params->valid_devs[0],
2003 rte_cryptodev_driver_id_get(
2004 RTE_STR(CRYPTODEV_NAME_MRVL_PMD)),
2005 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2007 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2009 return TEST_SUCCESS;
2012 /* ***** SNOW 3G Tests ***** */
2014 create_wireless_algo_hash_session(uint8_t dev_id,
2015 const uint8_t *key, const uint8_t key_len,
2016 const uint8_t iv_len, const uint8_t auth_len,
2017 enum rte_crypto_auth_operation op,
2018 enum rte_crypto_auth_algorithm algo)
2020 uint8_t hash_key[key_len];
2022 struct crypto_testsuite_params *ts_params = &testsuite_params;
2023 struct crypto_unittest_params *ut_params = &unittest_params;
2025 memcpy(hash_key, key, key_len);
2027 TEST_HEXDUMP(stdout, "key:", key, key_len);
2029 /* Setup Authentication Parameters */
2030 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2031 ut_params->auth_xform.next = NULL;
2033 ut_params->auth_xform.auth.op = op;
2034 ut_params->auth_xform.auth.algo = algo;
2035 ut_params->auth_xform.auth.key.length = key_len;
2036 ut_params->auth_xform.auth.key.data = hash_key;
2037 ut_params->auth_xform.auth.digest_length = auth_len;
2038 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2039 ut_params->auth_xform.auth.iv.length = iv_len;
2040 ut_params->sess = rte_cryptodev_sym_session_create(
2041 ts_params->session_mpool);
2043 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2044 &ut_params->auth_xform, ts_params->session_mpool);
2045 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2050 create_wireless_algo_cipher_session(uint8_t dev_id,
2051 enum rte_crypto_cipher_operation op,
2052 enum rte_crypto_cipher_algorithm algo,
2053 const uint8_t *key, const uint8_t key_len,
2056 uint8_t cipher_key[key_len];
2058 struct crypto_testsuite_params *ts_params = &testsuite_params;
2059 struct crypto_unittest_params *ut_params = &unittest_params;
2061 memcpy(cipher_key, key, key_len);
2063 /* Setup Cipher Parameters */
2064 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2065 ut_params->cipher_xform.next = NULL;
2067 ut_params->cipher_xform.cipher.algo = algo;
2068 ut_params->cipher_xform.cipher.op = op;
2069 ut_params->cipher_xform.cipher.key.data = cipher_key;
2070 ut_params->cipher_xform.cipher.key.length = key_len;
2071 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2072 ut_params->cipher_xform.cipher.iv.length = iv_len;
2074 TEST_HEXDUMP(stdout, "key:", key, key_len);
2076 /* Create Crypto session */
2077 ut_params->sess = rte_cryptodev_sym_session_create(
2078 ts_params->session_mpool);
2080 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2081 &ut_params->cipher_xform, ts_params->session_mpool);
2082 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2087 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2088 unsigned int cipher_len,
2089 unsigned int cipher_offset)
2091 struct crypto_testsuite_params *ts_params = &testsuite_params;
2092 struct crypto_unittest_params *ut_params = &unittest_params;
2094 /* Generate Crypto op data structure */
2095 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2096 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2097 TEST_ASSERT_NOT_NULL(ut_params->op,
2098 "Failed to allocate pktmbuf offload");
2100 /* Set crypto operation data parameters */
2101 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2103 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2105 /* set crypto operation source mbuf */
2106 sym_op->m_src = ut_params->ibuf;
2109 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2111 sym_op->cipher.data.length = cipher_len;
2112 sym_op->cipher.data.offset = cipher_offset;
2117 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2118 unsigned int cipher_len,
2119 unsigned int cipher_offset)
2121 struct crypto_testsuite_params *ts_params = &testsuite_params;
2122 struct crypto_unittest_params *ut_params = &unittest_params;
2124 /* Generate Crypto op data structure */
2125 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2126 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2127 TEST_ASSERT_NOT_NULL(ut_params->op,
2128 "Failed to allocate pktmbuf offload");
2130 /* Set crypto operation data parameters */
2131 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2133 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2135 /* set crypto operation source mbuf */
2136 sym_op->m_src = ut_params->ibuf;
2137 sym_op->m_dst = ut_params->obuf;
2140 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2142 sym_op->cipher.data.length = cipher_len;
2143 sym_op->cipher.data.offset = cipher_offset;
2148 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2149 enum rte_crypto_cipher_operation cipher_op,
2150 enum rte_crypto_auth_operation auth_op,
2151 enum rte_crypto_auth_algorithm auth_algo,
2152 enum rte_crypto_cipher_algorithm cipher_algo,
2153 const uint8_t *key, uint8_t key_len,
2154 uint8_t auth_iv_len, uint8_t auth_len,
2155 uint8_t cipher_iv_len)
2158 uint8_t cipher_auth_key[key_len];
2160 struct crypto_testsuite_params *ts_params = &testsuite_params;
2161 struct crypto_unittest_params *ut_params = &unittest_params;
2163 memcpy(cipher_auth_key, key, key_len);
2165 /* Setup Authentication Parameters */
2166 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2167 ut_params->auth_xform.next = NULL;
2169 ut_params->auth_xform.auth.op = auth_op;
2170 ut_params->auth_xform.auth.algo = auth_algo;
2171 ut_params->auth_xform.auth.key.length = key_len;
2172 /* Hash key = cipher key */
2173 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2174 ut_params->auth_xform.auth.digest_length = auth_len;
2175 /* Auth IV will be after cipher IV */
2176 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2177 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2179 /* Setup Cipher Parameters */
2180 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2181 ut_params->cipher_xform.next = &ut_params->auth_xform;
2183 ut_params->cipher_xform.cipher.algo = cipher_algo;
2184 ut_params->cipher_xform.cipher.op = cipher_op;
2185 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2186 ut_params->cipher_xform.cipher.key.length = key_len;
2187 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2188 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2190 TEST_HEXDUMP(stdout, "key:", key, key_len);
2192 /* Create Crypto session*/
2193 ut_params->sess = rte_cryptodev_sym_session_create(
2194 ts_params->session_mpool);
2196 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2197 &ut_params->cipher_xform, ts_params->session_mpool);
2199 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2204 create_wireless_cipher_auth_session(uint8_t dev_id,
2205 enum rte_crypto_cipher_operation cipher_op,
2206 enum rte_crypto_auth_operation auth_op,
2207 enum rte_crypto_auth_algorithm auth_algo,
2208 enum rte_crypto_cipher_algorithm cipher_algo,
2209 const struct wireless_test_data *tdata)
2211 const uint8_t key_len = tdata->key.len;
2212 uint8_t cipher_auth_key[key_len];
2214 struct crypto_testsuite_params *ts_params = &testsuite_params;
2215 struct crypto_unittest_params *ut_params = &unittest_params;
2216 const uint8_t *key = tdata->key.data;
2217 const uint8_t auth_len = tdata->digest.len;
2218 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2219 uint8_t auth_iv_len = tdata->auth_iv.len;
2221 memcpy(cipher_auth_key, key, key_len);
2223 /* Setup Authentication Parameters */
2224 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2225 ut_params->auth_xform.next = NULL;
2227 ut_params->auth_xform.auth.op = auth_op;
2228 ut_params->auth_xform.auth.algo = auth_algo;
2229 ut_params->auth_xform.auth.key.length = key_len;
2230 /* Hash key = cipher key */
2231 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2232 ut_params->auth_xform.auth.digest_length = auth_len;
2233 /* Auth IV will be after cipher IV */
2234 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2235 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2237 /* Setup Cipher Parameters */
2238 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2239 ut_params->cipher_xform.next = &ut_params->auth_xform;
2241 ut_params->cipher_xform.cipher.algo = cipher_algo;
2242 ut_params->cipher_xform.cipher.op = cipher_op;
2243 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2244 ut_params->cipher_xform.cipher.key.length = key_len;
2245 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2246 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2249 TEST_HEXDUMP(stdout, "key:", key, key_len);
2251 /* Create Crypto session*/
2252 ut_params->sess = rte_cryptodev_sym_session_create(
2253 ts_params->session_mpool);
2255 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2256 &ut_params->cipher_xform, ts_params->session_mpool);
2258 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2263 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2264 const struct wireless_test_data *tdata)
2266 return create_wireless_cipher_auth_session(dev_id,
2267 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2268 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2269 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2273 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2274 enum rte_crypto_cipher_operation cipher_op,
2275 enum rte_crypto_auth_operation auth_op,
2276 enum rte_crypto_auth_algorithm auth_algo,
2277 enum rte_crypto_cipher_algorithm cipher_algo,
2278 const uint8_t *key, const uint8_t key_len,
2279 uint8_t auth_iv_len, uint8_t auth_len,
2280 uint8_t cipher_iv_len)
2282 uint8_t auth_cipher_key[key_len];
2284 struct crypto_testsuite_params *ts_params = &testsuite_params;
2285 struct crypto_unittest_params *ut_params = &unittest_params;
2287 memcpy(auth_cipher_key, key, key_len);
2289 /* Setup Authentication Parameters */
2290 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2291 ut_params->auth_xform.auth.op = auth_op;
2292 ut_params->auth_xform.next = &ut_params->cipher_xform;
2293 ut_params->auth_xform.auth.algo = auth_algo;
2294 ut_params->auth_xform.auth.key.length = key_len;
2295 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2296 ut_params->auth_xform.auth.digest_length = auth_len;
2297 /* Auth IV will be after cipher IV */
2298 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2299 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2301 /* Setup Cipher Parameters */
2302 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2303 ut_params->cipher_xform.next = NULL;
2304 ut_params->cipher_xform.cipher.algo = cipher_algo;
2305 ut_params->cipher_xform.cipher.op = cipher_op;
2306 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2307 ut_params->cipher_xform.cipher.key.length = key_len;
2308 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2309 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2311 TEST_HEXDUMP(stdout, "key:", key, key_len);
2313 /* Create Crypto session*/
2314 ut_params->sess = rte_cryptodev_sym_session_create(
2315 ts_params->session_mpool);
2317 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2318 &ut_params->auth_xform, ts_params->session_mpool);
2320 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2326 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2327 unsigned int auth_tag_len,
2328 const uint8_t *iv, unsigned int iv_len,
2329 unsigned int data_pad_len,
2330 enum rte_crypto_auth_operation op,
2331 unsigned int auth_len, unsigned int auth_offset)
2333 struct crypto_testsuite_params *ts_params = &testsuite_params;
2335 struct crypto_unittest_params *ut_params = &unittest_params;
2337 /* Generate Crypto op data structure */
2338 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2339 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2340 TEST_ASSERT_NOT_NULL(ut_params->op,
2341 "Failed to allocate pktmbuf offload");
2343 /* Set crypto operation data parameters */
2344 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2346 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2348 /* set crypto operation source mbuf */
2349 sym_op->m_src = ut_params->ibuf;
2352 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2355 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2356 ut_params->ibuf, auth_tag_len);
2358 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2359 "no room to append auth tag");
2360 ut_params->digest = sym_op->auth.digest.data;
2361 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2362 ut_params->ibuf, data_pad_len);
2363 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2364 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2366 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2368 TEST_HEXDUMP(stdout, "digest:",
2369 sym_op->auth.digest.data,
2372 sym_op->auth.data.length = auth_len;
2373 sym_op->auth.data.offset = auth_offset;
2379 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2380 enum rte_crypto_auth_operation op)
2382 struct crypto_testsuite_params *ts_params = &testsuite_params;
2383 struct crypto_unittest_params *ut_params = &unittest_params;
2385 const uint8_t *auth_tag = tdata->digest.data;
2386 const unsigned int auth_tag_len = tdata->digest.len;
2387 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2388 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2390 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2391 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2392 const uint8_t *auth_iv = tdata->auth_iv.data;
2393 const uint8_t auth_iv_len = tdata->auth_iv.len;
2394 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2395 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2397 /* Generate Crypto op data structure */
2398 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2399 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2400 TEST_ASSERT_NOT_NULL(ut_params->op,
2401 "Failed to allocate pktmbuf offload");
2402 /* Set crypto operation data parameters */
2403 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2405 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2407 /* set crypto operation source mbuf */
2408 sym_op->m_src = ut_params->ibuf;
2411 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2412 ut_params->ibuf, auth_tag_len);
2414 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2415 "no room to append auth tag");
2416 ut_params->digest = sym_op->auth.digest.data;
2417 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2418 ut_params->ibuf, data_pad_len);
2419 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2420 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2422 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2424 TEST_HEXDUMP(stdout, "digest:",
2425 sym_op->auth.digest.data,
2428 /* Copy cipher and auth IVs at the end of the crypto operation */
2429 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2431 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2432 iv_ptr += cipher_iv_len;
2433 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2435 sym_op->cipher.data.length = cipher_len;
2436 sym_op->cipher.data.offset = 0;
2437 sym_op->auth.data.length = auth_len;
2438 sym_op->auth.data.offset = 0;
2444 create_zuc_cipher_hash_generate_operation(
2445 const struct wireless_test_data *tdata)
2447 return create_wireless_cipher_hash_operation(tdata,
2448 RTE_CRYPTO_AUTH_OP_GENERATE);
2452 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2453 const unsigned auth_tag_len,
2454 const uint8_t *auth_iv, uint8_t auth_iv_len,
2455 unsigned data_pad_len,
2456 enum rte_crypto_auth_operation op,
2457 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2458 const unsigned cipher_len, const unsigned cipher_offset,
2459 const unsigned auth_len, const unsigned auth_offset)
2461 struct crypto_testsuite_params *ts_params = &testsuite_params;
2462 struct crypto_unittest_params *ut_params = &unittest_params;
2464 /* Generate Crypto op data structure */
2465 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2466 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2467 TEST_ASSERT_NOT_NULL(ut_params->op,
2468 "Failed to allocate pktmbuf offload");
2469 /* Set crypto operation data parameters */
2470 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2472 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2474 /* set crypto operation source mbuf */
2475 sym_op->m_src = ut_params->ibuf;
2478 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2479 ut_params->ibuf, auth_tag_len);
2481 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2482 "no room to append auth tag");
2483 ut_params->digest = sym_op->auth.digest.data;
2484 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2485 ut_params->ibuf, data_pad_len);
2486 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2487 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2489 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2491 TEST_HEXDUMP(stdout, "digest:",
2492 sym_op->auth.digest.data,
2495 /* Copy cipher and auth IVs at the end of the crypto operation */
2496 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2498 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2499 iv_ptr += cipher_iv_len;
2500 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2502 sym_op->cipher.data.length = cipher_len;
2503 sym_op->cipher.data.offset = cipher_offset;
2504 sym_op->auth.data.length = auth_len;
2505 sym_op->auth.data.offset = auth_offset;
2511 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2512 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2513 const uint8_t *auth_iv, uint8_t auth_iv_len,
2514 unsigned int data_pad_len,
2515 unsigned int cipher_len, unsigned int cipher_offset,
2516 unsigned int auth_len, unsigned int auth_offset)
2518 struct crypto_testsuite_params *ts_params = &testsuite_params;
2519 struct crypto_unittest_params *ut_params = &unittest_params;
2521 /* Generate Crypto op data structure */
2522 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2523 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2524 TEST_ASSERT_NOT_NULL(ut_params->op,
2525 "Failed to allocate pktmbuf offload");
2527 /* Set crypto operation data parameters */
2528 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2530 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2532 /* set crypto operation source mbuf */
2533 sym_op->m_src = ut_params->ibuf;
2536 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2537 ut_params->ibuf, auth_tag_len);
2539 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2540 "no room to append auth tag");
2542 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2543 ut_params->ibuf, data_pad_len);
2545 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2547 TEST_HEXDUMP(stdout, "digest:",
2548 sym_op->auth.digest.data,
2551 /* Copy cipher and auth IVs at the end of the crypto operation */
2552 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2554 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2555 iv_ptr += cipher_iv_len;
2556 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2558 sym_op->cipher.data.length = cipher_len;
2559 sym_op->cipher.data.offset = cipher_offset;
2561 sym_op->auth.data.length = auth_len;
2562 sym_op->auth.data.offset = auth_offset;
2568 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2570 struct crypto_testsuite_params *ts_params = &testsuite_params;
2571 struct crypto_unittest_params *ut_params = &unittest_params;
2574 unsigned plaintext_pad_len;
2575 unsigned plaintext_len;
2578 /* Create SNOW 3G session */
2579 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2580 tdata->key.data, tdata->key.len,
2581 tdata->auth_iv.len, tdata->digest.len,
2582 RTE_CRYPTO_AUTH_OP_GENERATE,
2583 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2587 /* alloc mbuf and set payload */
2588 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2590 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2591 rte_pktmbuf_tailroom(ut_params->ibuf));
2593 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2594 /* Append data which is padded to a multiple of */
2595 /* the algorithms block size */
2596 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2597 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2599 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2601 /* Create SNOW 3G operation */
2602 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2603 tdata->auth_iv.data, tdata->auth_iv.len,
2604 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2605 tdata->validAuthLenInBits.len,
2610 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2612 ut_params->obuf = ut_params->op->sym->m_src;
2613 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2614 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2615 + plaintext_pad_len;
2618 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2621 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2622 "SNOW 3G Generated auth tag not as expected");
2628 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2630 struct crypto_testsuite_params *ts_params = &testsuite_params;
2631 struct crypto_unittest_params *ut_params = &unittest_params;
2634 unsigned plaintext_pad_len;
2635 unsigned plaintext_len;
2638 /* Create SNOW 3G session */
2639 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2640 tdata->key.data, tdata->key.len,
2641 tdata->auth_iv.len, tdata->digest.len,
2642 RTE_CRYPTO_AUTH_OP_VERIFY,
2643 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2646 /* alloc mbuf and set payload */
2647 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2649 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2650 rte_pktmbuf_tailroom(ut_params->ibuf));
2652 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2653 /* Append data which is padded to a multiple of */
2654 /* the algorithms block size */
2655 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2656 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2658 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2660 /* Create SNOW 3G operation */
2661 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2663 tdata->auth_iv.data, tdata->auth_iv.len,
2665 RTE_CRYPTO_AUTH_OP_VERIFY,
2666 tdata->validAuthLenInBits.len,
2671 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2673 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2674 ut_params->obuf = ut_params->op->sym->m_src;
2675 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2676 + plaintext_pad_len;
2679 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2688 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2690 struct crypto_testsuite_params *ts_params = &testsuite_params;
2691 struct crypto_unittest_params *ut_params = &unittest_params;
2694 unsigned plaintext_pad_len;
2695 unsigned plaintext_len;
2698 /* Create KASUMI session */
2699 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2700 tdata->key.data, tdata->key.len,
2701 0, tdata->digest.len,
2702 RTE_CRYPTO_AUTH_OP_GENERATE,
2703 RTE_CRYPTO_AUTH_KASUMI_F9);
2707 /* alloc mbuf and set payload */
2708 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2710 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2711 rte_pktmbuf_tailroom(ut_params->ibuf));
2713 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2714 /* Append data which is padded to a multiple of */
2715 /* the algorithms block size */
2716 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2717 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2719 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2721 /* Create KASUMI operation */
2722 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2724 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2725 tdata->plaintext.len,
2730 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2732 ut_params->obuf = ut_params->op->sym->m_src;
2733 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2734 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2735 + plaintext_pad_len;
2738 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2741 DIGEST_BYTE_LENGTH_KASUMI_F9,
2742 "KASUMI Generated auth tag not as expected");
2748 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2750 struct crypto_testsuite_params *ts_params = &testsuite_params;
2751 struct crypto_unittest_params *ut_params = &unittest_params;
2754 unsigned plaintext_pad_len;
2755 unsigned plaintext_len;
2758 /* Create KASUMI session */
2759 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2760 tdata->key.data, tdata->key.len,
2761 0, tdata->digest.len,
2762 RTE_CRYPTO_AUTH_OP_VERIFY,
2763 RTE_CRYPTO_AUTH_KASUMI_F9);
2766 /* alloc mbuf and set payload */
2767 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2769 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2770 rte_pktmbuf_tailroom(ut_params->ibuf));
2772 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2773 /* Append data which is padded to a multiple */
2774 /* of the algorithms block size */
2775 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2776 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2778 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2780 /* Create KASUMI operation */
2781 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2785 RTE_CRYPTO_AUTH_OP_VERIFY,
2786 tdata->plaintext.len,
2791 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2793 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2794 ut_params->obuf = ut_params->op->sym->m_src;
2795 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2796 + plaintext_pad_len;
2799 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2808 test_snow3g_hash_generate_test_case_1(void)
2810 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2814 test_snow3g_hash_generate_test_case_2(void)
2816 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2820 test_snow3g_hash_generate_test_case_3(void)
2822 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2826 test_snow3g_hash_generate_test_case_4(void)
2828 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2832 test_snow3g_hash_generate_test_case_5(void)
2834 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2838 test_snow3g_hash_generate_test_case_6(void)
2840 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2844 test_snow3g_hash_verify_test_case_1(void)
2846 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2851 test_snow3g_hash_verify_test_case_2(void)
2853 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2857 test_snow3g_hash_verify_test_case_3(void)
2859 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2863 test_snow3g_hash_verify_test_case_4(void)
2865 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2869 test_snow3g_hash_verify_test_case_5(void)
2871 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2875 test_snow3g_hash_verify_test_case_6(void)
2877 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2881 test_kasumi_hash_generate_test_case_1(void)
2883 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2887 test_kasumi_hash_generate_test_case_2(void)
2889 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2893 test_kasumi_hash_generate_test_case_3(void)
2895 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2899 test_kasumi_hash_generate_test_case_4(void)
2901 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2905 test_kasumi_hash_generate_test_case_5(void)
2907 return test_kasumi_authentication(&kasumi_hash_test_case_5);
2911 test_kasumi_hash_generate_test_case_6(void)
2913 return test_kasumi_authentication(&kasumi_hash_test_case_6);
2917 test_kasumi_hash_verify_test_case_1(void)
2919 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
2923 test_kasumi_hash_verify_test_case_2(void)
2925 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
2929 test_kasumi_hash_verify_test_case_3(void)
2931 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
2935 test_kasumi_hash_verify_test_case_4(void)
2937 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
2941 test_kasumi_hash_verify_test_case_5(void)
2943 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
2947 test_kasumi_encryption(const struct kasumi_test_data *tdata)
2949 struct crypto_testsuite_params *ts_params = &testsuite_params;
2950 struct crypto_unittest_params *ut_params = &unittest_params;
2953 uint8_t *plaintext, *ciphertext;
2954 unsigned plaintext_pad_len;
2955 unsigned plaintext_len;
2957 /* Create KASUMI session */
2958 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
2959 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2960 RTE_CRYPTO_CIPHER_KASUMI_F8,
2961 tdata->key.data, tdata->key.len,
2962 tdata->cipher_iv.len);
2966 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2968 /* Clear mbuf payload */
2969 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2970 rte_pktmbuf_tailroom(ut_params->ibuf));
2972 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2973 /* Append data which is padded to a multiple */
2974 /* of the algorithms block size */
2975 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2976 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2978 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2980 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
2982 /* Create KASUMI operation */
2983 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
2984 tdata->cipher_iv.len,
2985 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
2986 tdata->validCipherOffsetInBits.len);
2990 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2992 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2994 ut_params->obuf = ut_params->op->sym->m_dst;
2995 if (ut_params->obuf)
2996 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
2998 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3000 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3002 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3003 (tdata->validCipherOffsetInBits.len >> 3);
3005 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3007 reference_ciphertext,
3008 tdata->validCipherLenInBits.len,
3009 "KASUMI Ciphertext data not as expected");
3014 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3016 struct crypto_testsuite_params *ts_params = &testsuite_params;
3017 struct crypto_unittest_params *ut_params = &unittest_params;
3021 unsigned int plaintext_pad_len;
3022 unsigned int plaintext_len;
3024 uint8_t buffer[10000];
3025 const uint8_t *ciphertext;
3027 struct rte_cryptodev_info dev_info;
3029 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3030 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3031 printf("Device doesn't support scatter-gather. "
3036 /* Create KASUMI session */
3037 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3038 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3039 RTE_CRYPTO_CIPHER_KASUMI_F8,
3040 tdata->key.data, tdata->key.len,
3041 tdata->cipher_iv.len);
3045 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3048 /* Append data which is padded to a multiple */
3049 /* of the algorithms block size */
3050 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3052 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3053 plaintext_pad_len, 10, 0);
3055 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3057 /* Create KASUMI operation */
3058 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3059 tdata->cipher_iv.len,
3060 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3061 tdata->validCipherOffsetInBits.len);
3065 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3067 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3069 ut_params->obuf = ut_params->op->sym->m_dst;
3071 if (ut_params->obuf)
3072 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3073 plaintext_len, buffer);
3075 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3076 tdata->validCipherOffsetInBits.len >> 3,
3077 plaintext_len, buffer);
3080 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3082 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3083 (tdata->validCipherOffsetInBits.len >> 3);
3085 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3087 reference_ciphertext,
3088 tdata->validCipherLenInBits.len,
3089 "KASUMI Ciphertext data not as expected");
3094 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3096 struct crypto_testsuite_params *ts_params = &testsuite_params;
3097 struct crypto_unittest_params *ut_params = &unittest_params;
3100 uint8_t *plaintext, *ciphertext;
3101 unsigned plaintext_pad_len;
3102 unsigned plaintext_len;
3104 /* Create KASUMI session */
3105 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3106 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3107 RTE_CRYPTO_CIPHER_KASUMI_F8,
3108 tdata->key.data, tdata->key.len,
3109 tdata->cipher_iv.len);
3113 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3114 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3116 /* Clear mbuf payload */
3117 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3118 rte_pktmbuf_tailroom(ut_params->ibuf));
3120 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3121 /* Append data which is padded to a multiple */
3122 /* of the algorithms block size */
3123 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3124 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3126 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3127 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3129 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3131 /* Create KASUMI operation */
3132 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3133 tdata->cipher_iv.len,
3134 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3135 tdata->validCipherOffsetInBits.len);
3139 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3141 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3143 ut_params->obuf = ut_params->op->sym->m_dst;
3144 if (ut_params->obuf)
3145 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3147 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3149 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3151 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3152 (tdata->validCipherOffsetInBits.len >> 3);
3154 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3156 reference_ciphertext,
3157 tdata->validCipherLenInBits.len,
3158 "KASUMI Ciphertext data not as expected");
3163 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3165 struct crypto_testsuite_params *ts_params = &testsuite_params;
3166 struct crypto_unittest_params *ut_params = &unittest_params;
3169 unsigned int plaintext_pad_len;
3170 unsigned int plaintext_len;
3172 const uint8_t *ciphertext;
3173 uint8_t buffer[2048];
3175 struct rte_cryptodev_info dev_info;
3177 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3178 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3179 printf("Device doesn't support scatter-gather. "
3184 /* Create KASUMI session */
3185 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3186 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3187 RTE_CRYPTO_CIPHER_KASUMI_F8,
3188 tdata->key.data, tdata->key.len,
3189 tdata->cipher_iv.len);
3193 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3194 /* Append data which is padded to a multiple */
3195 /* of the algorithms block size */
3196 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3198 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3199 plaintext_pad_len, 10, 0);
3200 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3201 plaintext_pad_len, 3, 0);
3203 /* Append data which is padded to a multiple */
3204 /* of the algorithms block size */
3205 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3207 /* Create KASUMI operation */
3208 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3209 tdata->cipher_iv.len,
3210 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3211 tdata->validCipherOffsetInBits.len);
3215 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3217 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3219 ut_params->obuf = ut_params->op->sym->m_dst;
3220 if (ut_params->obuf)
3221 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3222 plaintext_pad_len, buffer);
3224 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3225 tdata->validCipherOffsetInBits.len >> 3,
3226 plaintext_pad_len, buffer);
3228 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3229 (tdata->validCipherOffsetInBits.len >> 3);
3231 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3233 reference_ciphertext,
3234 tdata->validCipherLenInBits.len,
3235 "KASUMI Ciphertext data not as expected");
3241 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3243 struct crypto_testsuite_params *ts_params = &testsuite_params;
3244 struct crypto_unittest_params *ut_params = &unittest_params;
3247 uint8_t *ciphertext, *plaintext;
3248 unsigned ciphertext_pad_len;
3249 unsigned ciphertext_len;
3251 /* Create KASUMI session */
3252 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3253 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3254 RTE_CRYPTO_CIPHER_KASUMI_F8,
3255 tdata->key.data, tdata->key.len,
3256 tdata->cipher_iv.len);
3260 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3261 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3263 /* Clear mbuf payload */
3264 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3265 rte_pktmbuf_tailroom(ut_params->ibuf));
3267 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3268 /* Append data which is padded to a multiple */
3269 /* of the algorithms block size */
3270 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3271 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3272 ciphertext_pad_len);
3273 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3274 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3276 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3278 /* Create KASUMI operation */
3279 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3280 tdata->cipher_iv.len,
3281 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3282 tdata->validCipherOffsetInBits.len);
3286 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3288 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3290 ut_params->obuf = ut_params->op->sym->m_dst;
3291 if (ut_params->obuf)
3292 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3294 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3296 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3298 const uint8_t *reference_plaintext = tdata->plaintext.data +
3299 (tdata->validCipherOffsetInBits.len >> 3);
3301 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3303 reference_plaintext,
3304 tdata->validCipherLenInBits.len,
3305 "KASUMI Plaintext data not as expected");
3310 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3312 struct crypto_testsuite_params *ts_params = &testsuite_params;
3313 struct crypto_unittest_params *ut_params = &unittest_params;
3316 uint8_t *ciphertext, *plaintext;
3317 unsigned ciphertext_pad_len;
3318 unsigned ciphertext_len;
3320 /* Create KASUMI session */
3321 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3322 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3323 RTE_CRYPTO_CIPHER_KASUMI_F8,
3324 tdata->key.data, tdata->key.len,
3325 tdata->cipher_iv.len);
3329 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3331 /* Clear mbuf payload */
3332 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3333 rte_pktmbuf_tailroom(ut_params->ibuf));
3335 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3336 /* Append data which is padded to a multiple */
3337 /* of the algorithms block size */
3338 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3339 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3340 ciphertext_pad_len);
3341 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3343 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3345 /* Create KASUMI operation */
3346 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3347 tdata->cipher_iv.len,
3348 tdata->ciphertext.len,
3349 tdata->validCipherOffsetInBits.len);
3353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3357 ut_params->obuf = ut_params->op->sym->m_dst;
3358 if (ut_params->obuf)
3359 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3361 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3363 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3365 const uint8_t *reference_plaintext = tdata->plaintext.data +
3366 (tdata->validCipherOffsetInBits.len >> 3);
3368 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3370 reference_plaintext,
3371 tdata->validCipherLenInBits.len,
3372 "KASUMI Plaintext data not as expected");
3377 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3379 struct crypto_testsuite_params *ts_params = &testsuite_params;
3380 struct crypto_unittest_params *ut_params = &unittest_params;
3383 uint8_t *plaintext, *ciphertext;
3384 unsigned plaintext_pad_len;
3385 unsigned plaintext_len;
3387 /* Create SNOW 3G session */
3388 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3389 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3390 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3391 tdata->key.data, tdata->key.len,
3392 tdata->cipher_iv.len);
3396 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3398 /* Clear mbuf payload */
3399 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3400 rte_pktmbuf_tailroom(ut_params->ibuf));
3402 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3403 /* Append data which is padded to a multiple of */
3404 /* the algorithms block size */
3405 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3406 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3408 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3410 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3412 /* Create SNOW 3G operation */
3413 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3414 tdata->cipher_iv.len,
3415 tdata->validCipherLenInBits.len,
3420 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3422 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3424 ut_params->obuf = ut_params->op->sym->m_dst;
3425 if (ut_params->obuf)
3426 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3428 ciphertext = plaintext;
3430 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3433 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3435 tdata->ciphertext.data,
3436 tdata->validDataLenInBits.len,
3437 "SNOW 3G Ciphertext data not as expected");
3443 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3445 struct crypto_testsuite_params *ts_params = &testsuite_params;
3446 struct crypto_unittest_params *ut_params = &unittest_params;
3447 uint8_t *plaintext, *ciphertext;
3450 unsigned plaintext_pad_len;
3451 unsigned plaintext_len;
3453 /* Create SNOW 3G session */
3454 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3455 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3456 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3457 tdata->key.data, tdata->key.len,
3458 tdata->cipher_iv.len);
3462 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3463 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3465 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3466 "Failed to allocate input buffer in mempool");
3467 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3468 "Failed to allocate output buffer in mempool");
3470 /* Clear mbuf payload */
3471 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3472 rte_pktmbuf_tailroom(ut_params->ibuf));
3474 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3475 /* Append data which is padded to a multiple of */
3476 /* the algorithms block size */
3477 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3478 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3480 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3481 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3483 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3485 /* Create SNOW 3G operation */
3486 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3487 tdata->cipher_iv.len,
3488 tdata->validCipherLenInBits.len,
3493 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3495 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3497 ut_params->obuf = ut_params->op->sym->m_dst;
3498 if (ut_params->obuf)
3499 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3501 ciphertext = plaintext;
3503 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3506 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3508 tdata->ciphertext.data,
3509 tdata->validDataLenInBits.len,
3510 "SNOW 3G Ciphertext data not as expected");
3515 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3517 struct crypto_testsuite_params *ts_params = &testsuite_params;
3518 struct crypto_unittest_params *ut_params = &unittest_params;
3521 unsigned int plaintext_pad_len;
3522 unsigned int plaintext_len;
3523 uint8_t buffer[10000];
3524 const uint8_t *ciphertext;
3526 struct rte_cryptodev_info dev_info;
3528 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3529 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3530 printf("Device doesn't support scatter-gather. "
3535 /* Create SNOW 3G session */
3536 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3537 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3538 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3539 tdata->key.data, tdata->key.len,
3540 tdata->cipher_iv.len);
3544 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3545 /* Append data which is padded to a multiple of */
3546 /* the algorithms block size */
3547 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3549 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3550 plaintext_pad_len, 10, 0);
3551 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3552 plaintext_pad_len, 3, 0);
3554 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3555 "Failed to allocate input buffer in mempool");
3556 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3557 "Failed to allocate output buffer in mempool");
3559 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3561 /* Create SNOW 3G operation */
3562 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3563 tdata->cipher_iv.len,
3564 tdata->validCipherLenInBits.len,
3569 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3571 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3573 ut_params->obuf = ut_params->op->sym->m_dst;
3574 if (ut_params->obuf)
3575 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3576 plaintext_len, buffer);
3578 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3579 plaintext_len, buffer);
3581 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3584 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3586 tdata->ciphertext.data,
3587 tdata->validDataLenInBits.len,
3588 "SNOW 3G Ciphertext data not as expected");
3593 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3595 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3597 uint8_t curr_byte, prev_byte;
3598 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3599 uint8_t lower_byte_mask = (1 << offset) - 1;
3602 prev_byte = buffer[0];
3603 buffer[0] >>= offset;
3605 for (i = 1; i < length_in_bytes; i++) {
3606 curr_byte = buffer[i];
3607 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3608 (curr_byte >> offset);
3609 prev_byte = curr_byte;
3614 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3616 struct crypto_testsuite_params *ts_params = &testsuite_params;
3617 struct crypto_unittest_params *ut_params = &unittest_params;
3618 uint8_t *plaintext, *ciphertext;
3620 uint32_t plaintext_len;
3621 uint32_t plaintext_pad_len;
3622 uint8_t extra_offset = 4;
3623 uint8_t *expected_ciphertext_shifted;
3625 /* Create SNOW 3G session */
3626 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3627 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3628 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3629 tdata->key.data, tdata->key.len,
3630 tdata->cipher_iv.len);
3634 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3635 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3637 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3638 "Failed to allocate input buffer in mempool");
3639 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3640 "Failed to allocate output buffer in mempool");
3642 /* Clear mbuf payload */
3643 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3644 rte_pktmbuf_tailroom(ut_params->ibuf));
3646 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3648 * Append data which is padded to a
3649 * multiple of the algorithms block size
3651 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3653 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3656 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3658 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3659 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3661 #ifdef RTE_APP_TEST_DEBUG
3662 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3664 /* Create SNOW 3G operation */
3665 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3666 tdata->cipher_iv.len,
3667 tdata->validCipherLenInBits.len,
3672 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3674 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3676 ut_params->obuf = ut_params->op->sym->m_dst;
3677 if (ut_params->obuf)
3678 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3680 ciphertext = plaintext;
3682 #ifdef RTE_APP_TEST_DEBUG
3683 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3686 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3688 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3689 "failed to reserve memory for ciphertext shifted\n");
3691 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3692 ceil_byte_length(tdata->ciphertext.len));
3693 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3696 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3698 expected_ciphertext_shifted,
3699 tdata->validDataLenInBits.len,
3701 "SNOW 3G Ciphertext data not as expected");
3705 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3707 struct crypto_testsuite_params *ts_params = &testsuite_params;
3708 struct crypto_unittest_params *ut_params = &unittest_params;
3712 uint8_t *plaintext, *ciphertext;
3713 unsigned ciphertext_pad_len;
3714 unsigned ciphertext_len;
3716 /* Create SNOW 3G session */
3717 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3718 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3719 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3720 tdata->key.data, tdata->key.len,
3721 tdata->cipher_iv.len);
3725 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3727 /* Clear mbuf payload */
3728 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3729 rte_pktmbuf_tailroom(ut_params->ibuf));
3731 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3732 /* Append data which is padded to a multiple of */
3733 /* the algorithms block size */
3734 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3735 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3736 ciphertext_pad_len);
3737 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3739 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3741 /* Create SNOW 3G operation */
3742 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3743 tdata->cipher_iv.len,
3744 tdata->validCipherLenInBits.len,
3749 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3751 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3752 ut_params->obuf = ut_params->op->sym->m_dst;
3753 if (ut_params->obuf)
3754 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3756 plaintext = ciphertext;
3758 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3761 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3762 tdata->plaintext.data,
3763 tdata->validDataLenInBits.len,
3764 "SNOW 3G Plaintext data not as expected");
3768 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3770 struct crypto_testsuite_params *ts_params = &testsuite_params;
3771 struct crypto_unittest_params *ut_params = &unittest_params;
3775 uint8_t *plaintext, *ciphertext;
3776 unsigned ciphertext_pad_len;
3777 unsigned ciphertext_len;
3779 /* Create SNOW 3G session */
3780 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3781 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3782 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3783 tdata->key.data, tdata->key.len,
3784 tdata->cipher_iv.len);
3788 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3789 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3791 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3792 "Failed to allocate input buffer");
3793 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3794 "Failed to allocate output buffer");
3796 /* Clear mbuf payload */
3797 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3798 rte_pktmbuf_tailroom(ut_params->ibuf));
3800 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3801 rte_pktmbuf_tailroom(ut_params->obuf));
3803 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3804 /* Append data which is padded to a multiple of */
3805 /* the algorithms block size */
3806 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3807 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3808 ciphertext_pad_len);
3809 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3810 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3812 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, ciphertext_len);
3814 /* Create SNOW 3G operation */
3815 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3816 tdata->cipher_iv.len,
3817 tdata->validCipherLenInBits.len,
3822 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3824 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3825 ut_params->obuf = ut_params->op->sym->m_dst;
3826 if (ut_params->obuf)
3827 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3829 plaintext = ciphertext;
3831 TEST_HEXDUMP(stdout, "plaintext:", plaintext, ciphertext_len);
3834 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3835 tdata->plaintext.data,
3836 tdata->validDataLenInBits.len,
3837 "SNOW 3G Plaintext data not as expected");
3842 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3844 struct crypto_testsuite_params *ts_params = &testsuite_params;
3845 struct crypto_unittest_params *ut_params = &unittest_params;
3849 uint8_t *plaintext, *ciphertext;
3850 unsigned int plaintext_pad_len;
3851 unsigned int plaintext_len;
3853 struct rte_cryptodev_sym_capability_idx cap_idx;
3855 /* Check if device supports ZUC EEA3 */
3856 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3857 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3859 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3863 /* Check if device supports ZUC EIA3 */
3864 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3865 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3867 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3871 /* Create ZUC session */
3872 retval = create_zuc_cipher_auth_encrypt_generate_session(
3873 ts_params->valid_devs[0],
3877 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3879 /* clear mbuf payload */
3880 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3881 rte_pktmbuf_tailroom(ut_params->ibuf));
3883 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3884 /* Append data which is padded to a multiple of */
3885 /* the algorithms block size */
3886 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3887 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3889 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3891 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3893 /* Create ZUC operation */
3894 retval = create_zuc_cipher_hash_generate_operation(tdata);
3898 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3900 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3901 ut_params->obuf = ut_params->op->sym->m_src;
3902 if (ut_params->obuf)
3903 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3905 ciphertext = plaintext;
3907 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3909 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3911 tdata->ciphertext.data,
3912 tdata->validDataLenInBits.len,
3913 "ZUC Ciphertext data not as expected");
3915 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3916 + plaintext_pad_len;
3919 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3923 "ZUC Generated auth tag not as expected");
3928 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
3930 struct crypto_testsuite_params *ts_params = &testsuite_params;
3931 struct crypto_unittest_params *ut_params = &unittest_params;
3935 uint8_t *plaintext, *ciphertext;
3936 unsigned plaintext_pad_len;
3937 unsigned plaintext_len;
3939 /* Create SNOW 3G session */
3940 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
3941 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3942 RTE_CRYPTO_AUTH_OP_GENERATE,
3943 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
3944 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3945 tdata->key.data, tdata->key.len,
3946 tdata->auth_iv.len, tdata->digest.len,
3947 tdata->cipher_iv.len);
3950 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3952 /* clear mbuf payload */
3953 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3954 rte_pktmbuf_tailroom(ut_params->ibuf));
3956 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3957 /* Append data which is padded to a multiple of */
3958 /* the algorithms block size */
3959 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3960 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3962 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3964 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
3966 /* Create SNOW 3G operation */
3967 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
3968 tdata->digest.len, tdata->auth_iv.data,
3970 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3971 tdata->cipher_iv.data, tdata->cipher_iv.len,
3972 tdata->validCipherLenInBits.len,
3974 tdata->validAuthLenInBits.len,
3980 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3982 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3983 ut_params->obuf = ut_params->op->sym->m_src;
3984 if (ut_params->obuf)
3985 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3987 ciphertext = plaintext;
3989 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
3991 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3993 tdata->ciphertext.data,
3994 tdata->validDataLenInBits.len,
3995 "SNOW 3G Ciphertext data not as expected");
3997 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3998 + plaintext_pad_len;
4001 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4004 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4005 "SNOW 3G Generated auth tag not as expected");
4009 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4011 struct crypto_testsuite_params *ts_params = &testsuite_params;
4012 struct crypto_unittest_params *ut_params = &unittest_params;
4016 uint8_t *plaintext, *ciphertext;
4017 unsigned plaintext_pad_len;
4018 unsigned plaintext_len;
4020 /* Create SNOW 3G session */
4021 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4022 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4023 RTE_CRYPTO_AUTH_OP_GENERATE,
4024 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4025 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4026 tdata->key.data, tdata->key.len,
4027 tdata->auth_iv.len, tdata->digest.len,
4028 tdata->cipher_iv.len);
4032 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4034 /* clear mbuf payload */
4035 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4036 rte_pktmbuf_tailroom(ut_params->ibuf));
4038 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4039 /* Append data which is padded to a multiple of */
4040 /* the algorithms block size */
4041 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4042 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4044 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4046 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4048 /* Create SNOW 3G operation */
4049 retval = create_wireless_algo_auth_cipher_operation(
4051 tdata->cipher_iv.data, tdata->cipher_iv.len,
4052 tdata->auth_iv.data, tdata->auth_iv.len,
4054 tdata->validCipherLenInBits.len,
4056 tdata->validAuthLenInBits.len,
4062 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4064 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4065 ut_params->obuf = ut_params->op->sym->m_src;
4066 if (ut_params->obuf)
4067 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4069 ciphertext = plaintext;
4071 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4072 + plaintext_pad_len;
4073 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4076 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4078 tdata->ciphertext.data,
4079 tdata->validDataLenInBits.len,
4080 "SNOW 3G Ciphertext data not as expected");
4083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4086 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4087 "SNOW 3G Generated auth tag not as expected");
4092 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4094 struct crypto_testsuite_params *ts_params = &testsuite_params;
4095 struct crypto_unittest_params *ut_params = &unittest_params;
4099 uint8_t *plaintext, *ciphertext;
4100 unsigned plaintext_pad_len;
4101 unsigned plaintext_len;
4103 /* Create KASUMI session */
4104 retval = create_wireless_algo_auth_cipher_session(
4105 ts_params->valid_devs[0],
4106 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4107 RTE_CRYPTO_AUTH_OP_GENERATE,
4108 RTE_CRYPTO_AUTH_KASUMI_F9,
4109 RTE_CRYPTO_CIPHER_KASUMI_F8,
4110 tdata->key.data, tdata->key.len,
4111 0, tdata->digest.len,
4112 tdata->cipher_iv.len);
4115 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4117 /* clear mbuf payload */
4118 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4119 rte_pktmbuf_tailroom(ut_params->ibuf));
4121 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4122 /* Append data which is padded to a multiple of */
4123 /* the algorithms block size */
4124 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4125 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4127 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4129 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4131 /* Create KASUMI operation */
4132 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4133 tdata->cipher_iv.data, tdata->cipher_iv.len,
4136 tdata->validCipherLenInBits.len,
4137 tdata->validCipherOffsetInBits.len,
4138 tdata->validAuthLenInBits.len,
4145 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4147 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4148 if (ut_params->op->sym->m_dst)
4149 ut_params->obuf = ut_params->op->sym->m_dst;
4151 ut_params->obuf = ut_params->op->sym->m_src;
4153 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4154 tdata->validCipherOffsetInBits.len >> 3);
4156 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4157 (tdata->validCipherOffsetInBits.len >> 3);
4159 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4161 reference_ciphertext,
4162 tdata->validCipherLenInBits.len,
4163 "KASUMI Ciphertext data not as expected");
4164 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4165 + plaintext_pad_len;
4168 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4171 DIGEST_BYTE_LENGTH_KASUMI_F9,
4172 "KASUMI Generated auth tag not as expected");
4177 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4179 struct crypto_testsuite_params *ts_params = &testsuite_params;
4180 struct crypto_unittest_params *ut_params = &unittest_params;
4184 uint8_t *plaintext, *ciphertext;
4185 unsigned plaintext_pad_len;
4186 unsigned plaintext_len;
4188 /* Create KASUMI session */
4189 retval = create_wireless_algo_cipher_auth_session(
4190 ts_params->valid_devs[0],
4191 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4192 RTE_CRYPTO_AUTH_OP_GENERATE,
4193 RTE_CRYPTO_AUTH_KASUMI_F9,
4194 RTE_CRYPTO_CIPHER_KASUMI_F8,
4195 tdata->key.data, tdata->key.len,
4196 0, tdata->digest.len,
4197 tdata->cipher_iv.len);
4201 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4203 /* clear mbuf payload */
4204 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4205 rte_pktmbuf_tailroom(ut_params->ibuf));
4207 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4208 /* Append data which is padded to a multiple of */
4209 /* the algorithms block size */
4210 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4211 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4213 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4215 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4217 /* Create KASUMI operation */
4218 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4219 tdata->digest.len, NULL, 0,
4220 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4221 tdata->cipher_iv.data, tdata->cipher_iv.len,
4222 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4223 tdata->validCipherOffsetInBits.len,
4224 tdata->validAuthLenInBits.len,
4230 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4232 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4234 if (ut_params->op->sym->m_dst)
4235 ut_params->obuf = ut_params->op->sym->m_dst;
4237 ut_params->obuf = ut_params->op->sym->m_src;
4239 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4240 tdata->validCipherOffsetInBits.len >> 3);
4242 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4243 + plaintext_pad_len;
4245 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4246 (tdata->validCipherOffsetInBits.len >> 3);
4248 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4250 reference_ciphertext,
4251 tdata->validCipherLenInBits.len,
4252 "KASUMI Ciphertext data not as expected");
4255 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4258 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4259 "KASUMI Generated auth tag not as expected");
4264 test_zuc_encryption(const struct wireless_test_data *tdata)
4266 struct crypto_testsuite_params *ts_params = &testsuite_params;
4267 struct crypto_unittest_params *ut_params = &unittest_params;
4270 uint8_t *plaintext, *ciphertext;
4271 unsigned plaintext_pad_len;
4272 unsigned plaintext_len;
4274 struct rte_cryptodev_sym_capability_idx cap_idx;
4276 /* Check if device supports ZUC EEA3 */
4277 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4278 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4280 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4284 /* Create ZUC session */
4285 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4286 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4287 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4288 tdata->key.data, tdata->key.len,
4289 tdata->cipher_iv.len);
4293 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4295 /* Clear mbuf payload */
4296 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4297 rte_pktmbuf_tailroom(ut_params->ibuf));
4299 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4300 /* Append data which is padded to a multiple */
4301 /* of the algorithms block size */
4302 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4303 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4305 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4307 TEST_HEXDUMP(stdout, "plaintext:", plaintext, plaintext_len);
4309 /* Create ZUC operation */
4310 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4311 tdata->cipher_iv.len,
4312 tdata->plaintext.len,
4317 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4319 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4321 ut_params->obuf = ut_params->op->sym->m_dst;
4322 if (ut_params->obuf)
4323 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4325 ciphertext = plaintext;
4327 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4330 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4332 tdata->ciphertext.data,
4333 tdata->validCipherLenInBits.len,
4334 "ZUC Ciphertext data not as expected");
4339 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4341 struct crypto_testsuite_params *ts_params = &testsuite_params;
4342 struct crypto_unittest_params *ut_params = &unittest_params;
4346 unsigned int plaintext_pad_len;
4347 unsigned int plaintext_len;
4348 const uint8_t *ciphertext;
4349 uint8_t ciphertext_buffer[2048];
4350 struct rte_cryptodev_info dev_info;
4352 struct rte_cryptodev_sym_capability_idx cap_idx;
4354 /* Check if device supports ZUC EEA3 */
4355 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4356 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4358 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4362 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4363 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4364 printf("Device doesn't support scatter-gather. "
4369 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4371 /* Append data which is padded to a multiple */
4372 /* of the algorithms block size */
4373 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4375 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4376 plaintext_pad_len, 10, 0);
4378 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4379 tdata->plaintext.data);
4381 /* Create ZUC session */
4382 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4383 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4384 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4385 tdata->key.data, tdata->key.len,
4386 tdata->cipher_iv.len);
4390 /* Clear mbuf payload */
4392 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4394 /* Create ZUC operation */
4395 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4396 tdata->cipher_iv.len, tdata->plaintext.len,
4401 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4403 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4405 ut_params->obuf = ut_params->op->sym->m_dst;
4406 if (ut_params->obuf)
4407 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4408 0, plaintext_len, ciphertext_buffer);
4410 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4411 0, plaintext_len, ciphertext_buffer);
4414 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, plaintext_len);
4417 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4419 tdata->ciphertext.data,
4420 tdata->validCipherLenInBits.len,
4421 "ZUC Ciphertext data not as expected");
4427 test_zuc_authentication(const struct wireless_test_data *tdata)
4429 struct crypto_testsuite_params *ts_params = &testsuite_params;
4430 struct crypto_unittest_params *ut_params = &unittest_params;
4433 unsigned plaintext_pad_len;
4434 unsigned plaintext_len;
4437 struct rte_cryptodev_sym_capability_idx cap_idx;
4439 /* Check if device supports ZUC EIA3 */
4440 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4441 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4443 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4447 /* Create ZUC session */
4448 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4449 tdata->key.data, tdata->key.len,
4450 tdata->auth_iv.len, tdata->digest.len,
4451 RTE_CRYPTO_AUTH_OP_GENERATE,
4452 RTE_CRYPTO_AUTH_ZUC_EIA3);
4456 /* alloc mbuf and set payload */
4457 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4459 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4460 rte_pktmbuf_tailroom(ut_params->ibuf));
4462 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4463 /* Append data which is padded to a multiple of */
4464 /* the algorithms block size */
4465 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4466 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4468 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4470 /* Create ZUC operation */
4471 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4472 tdata->auth_iv.data, tdata->auth_iv.len,
4473 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4474 tdata->validAuthLenInBits.len,
4479 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4481 ut_params->obuf = ut_params->op->sym->m_src;
4482 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4483 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4484 + plaintext_pad_len;
4487 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4490 DIGEST_BYTE_LENGTH_KASUMI_F9,
4491 "ZUC Generated auth tag not as expected");
4497 test_kasumi_encryption_test_case_1(void)
4499 return test_kasumi_encryption(&kasumi_test_case_1);
4503 test_kasumi_encryption_test_case_1_sgl(void)
4505 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4509 test_kasumi_encryption_test_case_1_oop(void)
4511 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4515 test_kasumi_encryption_test_case_1_oop_sgl(void)
4517 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4521 test_kasumi_encryption_test_case_2(void)
4523 return test_kasumi_encryption(&kasumi_test_case_2);
4527 test_kasumi_encryption_test_case_3(void)
4529 return test_kasumi_encryption(&kasumi_test_case_3);
4533 test_kasumi_encryption_test_case_4(void)
4535 return test_kasumi_encryption(&kasumi_test_case_4);
4539 test_kasumi_encryption_test_case_5(void)
4541 return test_kasumi_encryption(&kasumi_test_case_5);
4545 test_kasumi_decryption_test_case_1(void)
4547 return test_kasumi_decryption(&kasumi_test_case_1);
4551 test_kasumi_decryption_test_case_1_oop(void)
4553 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4557 test_kasumi_decryption_test_case_2(void)
4559 return test_kasumi_decryption(&kasumi_test_case_2);
4563 test_kasumi_decryption_test_case_3(void)
4565 return test_kasumi_decryption(&kasumi_test_case_3);
4569 test_kasumi_decryption_test_case_4(void)
4571 return test_kasumi_decryption(&kasumi_test_case_4);
4575 test_kasumi_decryption_test_case_5(void)
4577 return test_kasumi_decryption(&kasumi_test_case_5);
4580 test_snow3g_encryption_test_case_1(void)
4582 return test_snow3g_encryption(&snow3g_test_case_1);
4586 test_snow3g_encryption_test_case_1_oop(void)
4588 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4592 test_snow3g_encryption_test_case_1_oop_sgl(void)
4594 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4599 test_snow3g_encryption_test_case_1_offset_oop(void)
4601 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4605 test_snow3g_encryption_test_case_2(void)
4607 return test_snow3g_encryption(&snow3g_test_case_2);
4611 test_snow3g_encryption_test_case_3(void)
4613 return test_snow3g_encryption(&snow3g_test_case_3);
4617 test_snow3g_encryption_test_case_4(void)
4619 return test_snow3g_encryption(&snow3g_test_case_4);
4623 test_snow3g_encryption_test_case_5(void)
4625 return test_snow3g_encryption(&snow3g_test_case_5);
4629 test_snow3g_decryption_test_case_1(void)
4631 return test_snow3g_decryption(&snow3g_test_case_1);
4635 test_snow3g_decryption_test_case_1_oop(void)
4637 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4641 test_snow3g_decryption_test_case_2(void)
4643 return test_snow3g_decryption(&snow3g_test_case_2);
4647 test_snow3g_decryption_test_case_3(void)
4649 return test_snow3g_decryption(&snow3g_test_case_3);
4653 test_snow3g_decryption_test_case_4(void)
4655 return test_snow3g_decryption(&snow3g_test_case_4);
4659 test_snow3g_decryption_test_case_5(void)
4661 return test_snow3g_decryption(&snow3g_test_case_5);
4664 test_snow3g_cipher_auth_test_case_1(void)
4666 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4670 test_snow3g_auth_cipher_test_case_1(void)
4672 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4676 test_kasumi_auth_cipher_test_case_1(void)
4678 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4682 test_kasumi_cipher_auth_test_case_1(void)
4684 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4688 test_zuc_encryption_test_case_1(void)
4690 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4694 test_zuc_encryption_test_case_2(void)
4696 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4700 test_zuc_encryption_test_case_3(void)
4702 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4706 test_zuc_encryption_test_case_4(void)
4708 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4712 test_zuc_encryption_test_case_5(void)
4714 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4718 test_zuc_encryption_test_case_6_sgl(void)
4720 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4724 test_zuc_hash_generate_test_case_1(void)
4726 return test_zuc_authentication(&zuc_test_case_auth_1b);
4730 test_zuc_hash_generate_test_case_2(void)
4732 return test_zuc_authentication(&zuc_test_case_auth_90b);
4736 test_zuc_hash_generate_test_case_3(void)
4738 return test_zuc_authentication(&zuc_test_case_auth_577b);
4742 test_zuc_hash_generate_test_case_4(void)
4744 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4748 test_zuc_hash_generate_test_case_5(void)
4750 return test_zuc_authentication(&zuc_test_auth_5670b);
4754 test_zuc_hash_generate_test_case_6(void)
4756 return test_zuc_authentication(&zuc_test_case_auth_128b);
4760 test_zuc_hash_generate_test_case_7(void)
4762 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4766 test_zuc_hash_generate_test_case_8(void)
4768 return test_zuc_authentication(&zuc_test_case_auth_584b);
4772 test_zuc_cipher_auth_test_case_1(void)
4774 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4778 test_zuc_cipher_auth_test_case_2(void)
4780 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4784 test_3DES_chain_qat_all(void)
4786 struct crypto_testsuite_params *ts_params = &testsuite_params;
4789 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4790 ts_params->op_mpool,
4791 ts_params->session_mpool,
4792 ts_params->valid_devs[0],
4793 rte_cryptodev_driver_id_get(
4794 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4795 BLKCIPHER_3DES_CHAIN_TYPE);
4797 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4799 return TEST_SUCCESS;
4803 test_DES_cipheronly_qat_all(void)
4805 struct crypto_testsuite_params *ts_params = &testsuite_params;
4808 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4809 ts_params->op_mpool,
4810 ts_params->session_mpool,
4811 ts_params->valid_devs[0],
4812 rte_cryptodev_driver_id_get(
4813 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4814 BLKCIPHER_DES_CIPHERONLY_TYPE);
4816 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4818 return TEST_SUCCESS;
4822 test_DES_cipheronly_openssl_all(void)
4824 struct crypto_testsuite_params *ts_params = &testsuite_params;
4827 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4828 ts_params->op_mpool,
4829 ts_params->session_mpool,
4830 ts_params->valid_devs[0],
4831 rte_cryptodev_driver_id_get(
4832 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4833 BLKCIPHER_DES_CIPHERONLY_TYPE);
4835 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4837 return TEST_SUCCESS;
4841 test_DES_docsis_openssl_all(void)
4843 struct crypto_testsuite_params *ts_params = &testsuite_params;
4846 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4847 ts_params->op_mpool,
4848 ts_params->session_mpool,
4849 ts_params->valid_devs[0],
4850 rte_cryptodev_driver_id_get(
4851 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4852 BLKCIPHER_DES_DOCSIS_TYPE);
4854 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4856 return TEST_SUCCESS;
4860 test_DES_cipheronly_mb_all(void)
4862 struct crypto_testsuite_params *ts_params = &testsuite_params;
4865 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4866 ts_params->op_mpool,
4867 ts_params->session_mpool,
4868 ts_params->valid_devs[0],
4869 rte_cryptodev_driver_id_get(
4870 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4871 BLKCIPHER_DES_CIPHERONLY_TYPE);
4873 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4875 return TEST_SUCCESS;
4879 test_DES_docsis_mb_all(void)
4881 struct crypto_testsuite_params *ts_params = &testsuite_params;
4884 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4885 ts_params->op_mpool,
4886 ts_params->session_mpool,
4887 ts_params->valid_devs[0],
4888 rte_cryptodev_driver_id_get(
4889 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4890 BLKCIPHER_DES_DOCSIS_TYPE);
4892 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4894 return TEST_SUCCESS;
4898 test_3DES_chain_dpaa_sec_all(void)
4900 struct crypto_testsuite_params *ts_params = &testsuite_params;
4903 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4904 ts_params->op_mpool,
4905 ts_params->session_mpool,
4906 ts_params->valid_devs[0],
4907 rte_cryptodev_driver_id_get(
4908 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4909 BLKCIPHER_3DES_CHAIN_TYPE);
4911 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4913 return TEST_SUCCESS;
4917 test_3DES_cipheronly_dpaa_sec_all(void)
4919 struct crypto_testsuite_params *ts_params = &testsuite_params;
4922 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4923 ts_params->op_mpool,
4924 ts_params->session_mpool,
4925 ts_params->valid_devs[0],
4926 rte_cryptodev_driver_id_get(
4927 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4928 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4930 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4932 return TEST_SUCCESS;
4936 test_3DES_chain_dpaa2_sec_all(void)
4938 struct crypto_testsuite_params *ts_params = &testsuite_params;
4941 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4942 ts_params->op_mpool,
4943 ts_params->session_mpool,
4944 ts_params->valid_devs[0],
4945 rte_cryptodev_driver_id_get(
4946 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4947 BLKCIPHER_3DES_CHAIN_TYPE);
4949 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4951 return TEST_SUCCESS;
4955 test_3DES_cipheronly_dpaa2_sec_all(void)
4957 struct crypto_testsuite_params *ts_params = &testsuite_params;
4960 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4961 ts_params->op_mpool,
4962 ts_params->session_mpool,
4963 ts_params->valid_devs[0],
4964 rte_cryptodev_driver_id_get(
4965 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
4966 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4968 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4970 return TEST_SUCCESS;
4974 test_3DES_cipheronly_qat_all(void)
4976 struct crypto_testsuite_params *ts_params = &testsuite_params;
4979 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4980 ts_params->op_mpool,
4981 ts_params->session_mpool,
4982 ts_params->valid_devs[0],
4983 rte_cryptodev_driver_id_get(
4984 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4985 BLKCIPHER_3DES_CIPHERONLY_TYPE);
4987 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4989 return TEST_SUCCESS;
4993 test_3DES_chain_openssl_all(void)
4995 struct crypto_testsuite_params *ts_params = &testsuite_params;
4998 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4999 ts_params->op_mpool,
5000 ts_params->session_mpool,
5001 ts_params->valid_devs[0],
5002 rte_cryptodev_driver_id_get(
5003 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5004 BLKCIPHER_3DES_CHAIN_TYPE);
5006 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5008 return TEST_SUCCESS;
5012 test_3DES_cipheronly_openssl_all(void)
5014 struct crypto_testsuite_params *ts_params = &testsuite_params;
5017 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5018 ts_params->op_mpool,
5019 ts_params->session_mpool,
5020 ts_params->valid_devs[0],
5021 rte_cryptodev_driver_id_get(
5022 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5023 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5025 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5027 return TEST_SUCCESS;
5030 /* ***** AEAD algorithm Tests ***** */
5033 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5034 enum rte_crypto_aead_operation op,
5035 const uint8_t *key, const uint8_t key_len,
5036 const uint16_t aad_len, const uint8_t auth_len,
5039 uint8_t aead_key[key_len];
5041 struct crypto_testsuite_params *ts_params = &testsuite_params;
5042 struct crypto_unittest_params *ut_params = &unittest_params;
5044 memcpy(aead_key, key, key_len);
5046 /* Setup AEAD Parameters */
5047 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5048 ut_params->aead_xform.next = NULL;
5049 ut_params->aead_xform.aead.algo = algo;
5050 ut_params->aead_xform.aead.op = op;
5051 ut_params->aead_xform.aead.key.data = aead_key;
5052 ut_params->aead_xform.aead.key.length = key_len;
5053 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5054 ut_params->aead_xform.aead.iv.length = iv_len;
5055 ut_params->aead_xform.aead.digest_length = auth_len;
5056 ut_params->aead_xform.aead.aad_length = aad_len;
5058 TEST_HEXDUMP(stdout, "key:", key, key_len);
5060 /* Create Crypto session*/
5061 ut_params->sess = rte_cryptodev_sym_session_create(
5062 ts_params->session_mpool);
5064 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5065 &ut_params->aead_xform, ts_params->session_mpool);
5067 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5073 create_aead_xform(struct rte_crypto_op *op,
5074 enum rte_crypto_aead_algorithm algo,
5075 enum rte_crypto_aead_operation aead_op,
5076 uint8_t *key, const uint8_t key_len,
5077 const uint8_t aad_len, const uint8_t auth_len,
5080 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5081 "failed to allocate space for crypto transform");
5083 struct rte_crypto_sym_op *sym_op = op->sym;
5085 /* Setup AEAD Parameters */
5086 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5087 sym_op->xform->next = NULL;
5088 sym_op->xform->aead.algo = algo;
5089 sym_op->xform->aead.op = aead_op;
5090 sym_op->xform->aead.key.data = key;
5091 sym_op->xform->aead.key.length = key_len;
5092 sym_op->xform->aead.iv.offset = IV_OFFSET;
5093 sym_op->xform->aead.iv.length = iv_len;
5094 sym_op->xform->aead.digest_length = auth_len;
5095 sym_op->xform->aead.aad_length = aad_len;
5097 TEST_HEXDUMP(stdout, "key:", key, key_len);
5103 create_aead_operation(enum rte_crypto_aead_operation op,
5104 const struct aead_test_data *tdata)
5106 struct crypto_testsuite_params *ts_params = &testsuite_params;
5107 struct crypto_unittest_params *ut_params = &unittest_params;
5109 uint8_t *plaintext, *ciphertext;
5110 unsigned int aad_pad_len, plaintext_pad_len;
5112 /* Generate Crypto op data structure */
5113 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5114 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5115 TEST_ASSERT_NOT_NULL(ut_params->op,
5116 "Failed to allocate symmetric crypto operation struct");
5118 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5120 /* Append aad data */
5121 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5122 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5123 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5125 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5126 "no room to append aad");
5128 sym_op->aead.aad.phys_addr =
5129 rte_pktmbuf_iova(ut_params->ibuf);
5130 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5131 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5132 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5135 /* Append IV at the end of the crypto operation*/
5136 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5137 uint8_t *, IV_OFFSET);
5139 /* Copy IV 1 byte after the IV pointer, according to the API */
5140 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5141 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5144 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5145 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5147 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5148 "no room to append aad");
5150 sym_op->aead.aad.phys_addr =
5151 rte_pktmbuf_iova(ut_params->ibuf);
5152 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5153 TEST_HEXDUMP(stdout, "aad:", sym_op->aead.aad.data,
5156 /* Append IV at the end of the crypto operation*/
5157 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5158 uint8_t *, IV_OFFSET);
5160 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5161 TEST_HEXDUMP(stdout, "iv:", iv_ptr,
5165 /* Append plaintext/ciphertext */
5166 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5167 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5168 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5170 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5172 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5173 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
5174 tdata->plaintext.len);
5176 if (ut_params->obuf) {
5177 ciphertext = (uint8_t *)rte_pktmbuf_append(
5179 plaintext_pad_len + aad_pad_len);
5180 TEST_ASSERT_NOT_NULL(ciphertext,
5181 "no room to append ciphertext");
5183 memset(ciphertext + aad_pad_len, 0,
5184 tdata->ciphertext.len);
5187 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5188 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5190 TEST_ASSERT_NOT_NULL(ciphertext,
5191 "no room to append ciphertext");
5193 memcpy(ciphertext, tdata->ciphertext.data,
5194 tdata->ciphertext.len);
5195 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext,
5196 tdata->ciphertext.len);
5198 if (ut_params->obuf) {
5199 plaintext = (uint8_t *)rte_pktmbuf_append(
5201 plaintext_pad_len + aad_pad_len);
5202 TEST_ASSERT_NOT_NULL(plaintext,
5203 "no room to append plaintext");
5205 memset(plaintext + aad_pad_len, 0,
5206 tdata->plaintext.len);
5210 /* Append digest data */
5211 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5212 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5213 ut_params->obuf ? ut_params->obuf :
5215 tdata->auth_tag.len);
5216 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5217 "no room to append digest");
5218 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5219 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5220 ut_params->obuf ? ut_params->obuf :
5225 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5226 ut_params->ibuf, tdata->auth_tag.len);
5227 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5228 "no room to append digest");
5229 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5231 plaintext_pad_len + aad_pad_len);
5233 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5234 tdata->auth_tag.len);
5235 TEST_HEXDUMP(stdout, "digest:",
5236 sym_op->aead.digest.data,
5237 tdata->auth_tag.len);
5240 sym_op->aead.data.length = tdata->plaintext.len;
5241 sym_op->aead.data.offset = aad_pad_len;
5247 test_authenticated_encryption(const struct aead_test_data *tdata)
5249 struct crypto_testsuite_params *ts_params = &testsuite_params;
5250 struct crypto_unittest_params *ut_params = &unittest_params;
5253 uint8_t *ciphertext, *auth_tag;
5254 uint16_t plaintext_pad_len;
5257 /* Create AEAD session */
5258 retval = create_aead_session(ts_params->valid_devs[0],
5260 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5261 tdata->key.data, tdata->key.len,
5262 tdata->aad.len, tdata->auth_tag.len,
5267 if (tdata->aad.len > MBUF_SIZE) {
5268 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5269 /* Populate full size of add data */
5270 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5271 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5273 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5275 /* clear mbuf payload */
5276 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5277 rte_pktmbuf_tailroom(ut_params->ibuf));
5279 /* Create AEAD operation */
5280 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5284 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5286 ut_params->op->sym->m_src = ut_params->ibuf;
5288 /* Process crypto operation */
5289 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5290 ut_params->op), "failed to process sym crypto op");
5292 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5293 "crypto op processing failed");
5295 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5297 if (ut_params->op->sym->m_dst) {
5298 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5300 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5301 uint8_t *, plaintext_pad_len);
5303 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5305 ut_params->op->sym->cipher.data.offset);
5306 auth_tag = ciphertext + plaintext_pad_len;
5309 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5310 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5313 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5315 tdata->ciphertext.data,
5316 tdata->ciphertext.len,
5317 "Ciphertext data not as expected");
5319 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5321 tdata->auth_tag.data,
5322 tdata->auth_tag.len,
5323 "Generated auth tag not as expected");
5330 test_AES_GCM_authenticated_encryption_test_case_1(void)
5332 return test_authenticated_encryption(&gcm_test_case_1);
5336 test_AES_GCM_authenticated_encryption_test_case_2(void)
5338 return test_authenticated_encryption(&gcm_test_case_2);
5342 test_AES_GCM_authenticated_encryption_test_case_3(void)
5344 return test_authenticated_encryption(&gcm_test_case_3);
5348 test_AES_GCM_authenticated_encryption_test_case_4(void)
5350 return test_authenticated_encryption(&gcm_test_case_4);
5354 test_AES_GCM_authenticated_encryption_test_case_5(void)
5356 return test_authenticated_encryption(&gcm_test_case_5);
5360 test_AES_GCM_authenticated_encryption_test_case_6(void)
5362 return test_authenticated_encryption(&gcm_test_case_6);
5366 test_AES_GCM_authenticated_encryption_test_case_7(void)
5368 return test_authenticated_encryption(&gcm_test_case_7);
5372 test_AES_GCM_auth_encryption_test_case_192_1(void)
5374 return test_authenticated_encryption(&gcm_test_case_192_1);
5378 test_AES_GCM_auth_encryption_test_case_192_2(void)
5380 return test_authenticated_encryption(&gcm_test_case_192_2);
5384 test_AES_GCM_auth_encryption_test_case_192_3(void)
5386 return test_authenticated_encryption(&gcm_test_case_192_3);
5390 test_AES_GCM_auth_encryption_test_case_192_4(void)
5392 return test_authenticated_encryption(&gcm_test_case_192_4);
5396 test_AES_GCM_auth_encryption_test_case_192_5(void)
5398 return test_authenticated_encryption(&gcm_test_case_192_5);
5402 test_AES_GCM_auth_encryption_test_case_192_6(void)
5404 return test_authenticated_encryption(&gcm_test_case_192_6);
5408 test_AES_GCM_auth_encryption_test_case_192_7(void)
5410 return test_authenticated_encryption(&gcm_test_case_192_7);
5414 test_AES_GCM_auth_encryption_test_case_256_1(void)
5416 return test_authenticated_encryption(&gcm_test_case_256_1);
5420 test_AES_GCM_auth_encryption_test_case_256_2(void)
5422 return test_authenticated_encryption(&gcm_test_case_256_2);
5426 test_AES_GCM_auth_encryption_test_case_256_3(void)
5428 return test_authenticated_encryption(&gcm_test_case_256_3);
5432 test_AES_GCM_auth_encryption_test_case_256_4(void)
5434 return test_authenticated_encryption(&gcm_test_case_256_4);
5438 test_AES_GCM_auth_encryption_test_case_256_5(void)
5440 return test_authenticated_encryption(&gcm_test_case_256_5);
5444 test_AES_GCM_auth_encryption_test_case_256_6(void)
5446 return test_authenticated_encryption(&gcm_test_case_256_6);
5450 test_AES_GCM_auth_encryption_test_case_256_7(void)
5452 return test_authenticated_encryption(&gcm_test_case_256_7);
5456 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5458 return test_authenticated_encryption(&gcm_test_case_aad_1);
5462 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5464 return test_authenticated_encryption(&gcm_test_case_aad_2);
5468 test_authenticated_decryption(const struct aead_test_data *tdata)
5470 struct crypto_testsuite_params *ts_params = &testsuite_params;
5471 struct crypto_unittest_params *ut_params = &unittest_params;
5477 /* Create AEAD session */
5478 retval = create_aead_session(ts_params->valid_devs[0],
5480 RTE_CRYPTO_AEAD_OP_DECRYPT,
5481 tdata->key.data, tdata->key.len,
5482 tdata->aad.len, tdata->auth_tag.len,
5487 /* alloc mbuf and set payload */
5488 if (tdata->aad.len > MBUF_SIZE) {
5489 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5490 /* Populate full size of add data */
5491 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5492 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5494 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5497 rte_pktmbuf_tailroom(ut_params->ibuf));
5499 /* Create AEAD operation */
5500 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5504 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5506 ut_params->op->sym->m_src = ut_params->ibuf;
5508 /* Process crypto operation */
5509 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5510 ut_params->op), "failed to process sym crypto op");
5512 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5513 "crypto op processing failed");
5515 if (ut_params->op->sym->m_dst)
5516 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5519 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5521 ut_params->op->sym->cipher.data.offset);
5523 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5526 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5528 tdata->plaintext.data,
5529 tdata->plaintext.len,
5530 "Plaintext data not as expected");
5532 TEST_ASSERT_EQUAL(ut_params->op->status,
5533 RTE_CRYPTO_OP_STATUS_SUCCESS,
5534 "Authentication failed");
5539 test_AES_GCM_authenticated_decryption_test_case_1(void)
5541 return test_authenticated_decryption(&gcm_test_case_1);
5545 test_AES_GCM_authenticated_decryption_test_case_2(void)
5547 return test_authenticated_decryption(&gcm_test_case_2);
5551 test_AES_GCM_authenticated_decryption_test_case_3(void)
5553 return test_authenticated_decryption(&gcm_test_case_3);
5557 test_AES_GCM_authenticated_decryption_test_case_4(void)
5559 return test_authenticated_decryption(&gcm_test_case_4);
5563 test_AES_GCM_authenticated_decryption_test_case_5(void)
5565 return test_authenticated_decryption(&gcm_test_case_5);
5569 test_AES_GCM_authenticated_decryption_test_case_6(void)
5571 return test_authenticated_decryption(&gcm_test_case_6);
5575 test_AES_GCM_authenticated_decryption_test_case_7(void)
5577 return test_authenticated_decryption(&gcm_test_case_7);
5581 test_AES_GCM_auth_decryption_test_case_192_1(void)
5583 return test_authenticated_decryption(&gcm_test_case_192_1);
5587 test_AES_GCM_auth_decryption_test_case_192_2(void)
5589 return test_authenticated_decryption(&gcm_test_case_192_2);
5593 test_AES_GCM_auth_decryption_test_case_192_3(void)
5595 return test_authenticated_decryption(&gcm_test_case_192_3);
5599 test_AES_GCM_auth_decryption_test_case_192_4(void)
5601 return test_authenticated_decryption(&gcm_test_case_192_4);
5605 test_AES_GCM_auth_decryption_test_case_192_5(void)
5607 return test_authenticated_decryption(&gcm_test_case_192_5);
5611 test_AES_GCM_auth_decryption_test_case_192_6(void)
5613 return test_authenticated_decryption(&gcm_test_case_192_6);
5617 test_AES_GCM_auth_decryption_test_case_192_7(void)
5619 return test_authenticated_decryption(&gcm_test_case_192_7);
5623 test_AES_GCM_auth_decryption_test_case_256_1(void)
5625 return test_authenticated_decryption(&gcm_test_case_256_1);
5629 test_AES_GCM_auth_decryption_test_case_256_2(void)
5631 return test_authenticated_decryption(&gcm_test_case_256_2);
5635 test_AES_GCM_auth_decryption_test_case_256_3(void)
5637 return test_authenticated_decryption(&gcm_test_case_256_3);
5641 test_AES_GCM_auth_decryption_test_case_256_4(void)
5643 return test_authenticated_decryption(&gcm_test_case_256_4);
5647 test_AES_GCM_auth_decryption_test_case_256_5(void)
5649 return test_authenticated_decryption(&gcm_test_case_256_5);
5653 test_AES_GCM_auth_decryption_test_case_256_6(void)
5655 return test_authenticated_decryption(&gcm_test_case_256_6);
5659 test_AES_GCM_auth_decryption_test_case_256_7(void)
5661 return test_authenticated_decryption(&gcm_test_case_256_7);
5665 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5667 return test_authenticated_decryption(&gcm_test_case_aad_1);
5671 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5673 return test_authenticated_decryption(&gcm_test_case_aad_2);
5677 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5679 struct crypto_testsuite_params *ts_params = &testsuite_params;
5680 struct crypto_unittest_params *ut_params = &unittest_params;
5683 uint8_t *ciphertext, *auth_tag;
5684 uint16_t plaintext_pad_len;
5686 /* Create AEAD session */
5687 retval = create_aead_session(ts_params->valid_devs[0],
5689 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5690 tdata->key.data, tdata->key.len,
5691 tdata->aad.len, tdata->auth_tag.len,
5696 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5697 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5699 /* clear mbuf payload */
5700 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5701 rte_pktmbuf_tailroom(ut_params->ibuf));
5702 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5703 rte_pktmbuf_tailroom(ut_params->obuf));
5705 /* Create AEAD operation */
5706 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5710 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5712 ut_params->op->sym->m_src = ut_params->ibuf;
5713 ut_params->op->sym->m_dst = ut_params->obuf;
5715 /* Process crypto operation */
5716 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5717 ut_params->op), "failed to process sym crypto op");
5719 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5720 "crypto op processing failed");
5722 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5724 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5725 ut_params->op->sym->cipher.data.offset);
5726 auth_tag = ciphertext + plaintext_pad_len;
5728 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5729 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5732 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5734 tdata->ciphertext.data,
5735 tdata->ciphertext.len,
5736 "Ciphertext data not as expected");
5738 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5740 tdata->auth_tag.data,
5741 tdata->auth_tag.len,
5742 "Generated auth tag not as expected");
5749 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5751 return test_authenticated_encryption_oop(&gcm_test_case_5);
5755 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5757 struct crypto_testsuite_params *ts_params = &testsuite_params;
5758 struct crypto_unittest_params *ut_params = &unittest_params;
5763 /* Create AEAD session */
5764 retval = create_aead_session(ts_params->valid_devs[0],
5766 RTE_CRYPTO_AEAD_OP_DECRYPT,
5767 tdata->key.data, tdata->key.len,
5768 tdata->aad.len, tdata->auth_tag.len,
5773 /* alloc mbuf and set payload */
5774 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5775 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5777 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5778 rte_pktmbuf_tailroom(ut_params->ibuf));
5779 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5780 rte_pktmbuf_tailroom(ut_params->obuf));
5782 /* Create AEAD operation */
5783 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5787 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5789 ut_params->op->sym->m_src = ut_params->ibuf;
5790 ut_params->op->sym->m_dst = ut_params->obuf;
5792 /* Process crypto operation */
5793 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5794 ut_params->op), "failed to process sym crypto op");
5796 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5797 "crypto op processing failed");
5799 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5800 ut_params->op->sym->cipher.data.offset);
5802 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5805 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5807 tdata->plaintext.data,
5808 tdata->plaintext.len,
5809 "Plaintext data not as expected");
5811 TEST_ASSERT_EQUAL(ut_params->op->status,
5812 RTE_CRYPTO_OP_STATUS_SUCCESS,
5813 "Authentication failed");
5818 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5820 return test_authenticated_decryption_oop(&gcm_test_case_5);
5824 test_authenticated_encryption_sessionless(
5825 const struct aead_test_data *tdata)
5827 struct crypto_testsuite_params *ts_params = &testsuite_params;
5828 struct crypto_unittest_params *ut_params = &unittest_params;
5831 uint8_t *ciphertext, *auth_tag;
5832 uint16_t plaintext_pad_len;
5833 uint8_t key[tdata->key.len + 1];
5835 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5837 /* clear mbuf payload */
5838 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5839 rte_pktmbuf_tailroom(ut_params->ibuf));
5841 /* Create AEAD operation */
5842 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5846 /* Create GCM xform */
5847 memcpy(key, tdata->key.data, tdata->key.len);
5848 retval = create_aead_xform(ut_params->op,
5850 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5851 key, tdata->key.len,
5852 tdata->aad.len, tdata->auth_tag.len,
5857 ut_params->op->sym->m_src = ut_params->ibuf;
5859 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5860 RTE_CRYPTO_OP_SESSIONLESS,
5861 "crypto op session type not sessionless");
5863 /* Process crypto operation */
5864 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5865 ut_params->op), "failed to process sym crypto op");
5867 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5869 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5870 "crypto op status not success");
5872 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5874 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5875 ut_params->op->sym->cipher.data.offset);
5876 auth_tag = ciphertext + plaintext_pad_len;
5878 TEST_HEXDUMP(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5879 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5882 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5884 tdata->ciphertext.data,
5885 tdata->ciphertext.len,
5886 "Ciphertext data not as expected");
5888 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5890 tdata->auth_tag.data,
5891 tdata->auth_tag.len,
5892 "Generated auth tag not as expected");
5899 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
5901 return test_authenticated_encryption_sessionless(
5906 test_authenticated_decryption_sessionless(
5907 const struct aead_test_data *tdata)
5909 struct crypto_testsuite_params *ts_params = &testsuite_params;
5910 struct crypto_unittest_params *ut_params = &unittest_params;
5914 uint8_t key[tdata->key.len + 1];
5916 /* alloc mbuf and set payload */
5917 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5919 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5920 rte_pktmbuf_tailroom(ut_params->ibuf));
5922 /* Create AEAD operation */
5923 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5927 /* Create AEAD xform */
5928 memcpy(key, tdata->key.data, tdata->key.len);
5929 retval = create_aead_xform(ut_params->op,
5931 RTE_CRYPTO_AEAD_OP_DECRYPT,
5932 key, tdata->key.len,
5933 tdata->aad.len, tdata->auth_tag.len,
5938 ut_params->op->sym->m_src = ut_params->ibuf;
5940 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5941 RTE_CRYPTO_OP_SESSIONLESS,
5942 "crypto op session type not sessionless");
5944 /* Process crypto operation */
5945 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5946 ut_params->op), "failed to process sym crypto op");
5948 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5950 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5951 "crypto op status not success");
5953 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
5954 ut_params->op->sym->cipher.data.offset);
5956 TEST_HEXDUMP(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5959 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5961 tdata->plaintext.data,
5962 tdata->plaintext.len,
5963 "Plaintext data not as expected");
5965 TEST_ASSERT_EQUAL(ut_params->op->status,
5966 RTE_CRYPTO_OP_STATUS_SUCCESS,
5967 "Authentication failed");
5972 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
5974 return test_authenticated_decryption_sessionless(
5979 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
5981 return test_authenticated_encryption(&ccm_test_case_128_1);
5985 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
5987 return test_authenticated_encryption(&ccm_test_case_128_2);
5991 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
5993 return test_authenticated_encryption(&ccm_test_case_128_3);
5997 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
5999 return test_authenticated_decryption(&ccm_test_case_128_1);
6003 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6005 return test_authenticated_decryption(&ccm_test_case_128_2);
6009 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6011 return test_authenticated_decryption(&ccm_test_case_128_3);
6015 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6017 return test_authenticated_encryption(&ccm_test_case_192_1);
6021 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6023 return test_authenticated_encryption(&ccm_test_case_192_2);
6027 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6029 return test_authenticated_encryption(&ccm_test_case_192_3);
6033 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6035 return test_authenticated_decryption(&ccm_test_case_192_1);
6039 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6041 return test_authenticated_decryption(&ccm_test_case_192_2);
6045 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6047 return test_authenticated_decryption(&ccm_test_case_192_3);
6051 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6053 return test_authenticated_encryption(&ccm_test_case_256_1);
6057 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6059 return test_authenticated_encryption(&ccm_test_case_256_2);
6063 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6065 return test_authenticated_encryption(&ccm_test_case_256_3);
6069 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6071 return test_authenticated_decryption(&ccm_test_case_256_1);
6075 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6077 return test_authenticated_decryption(&ccm_test_case_256_2);
6081 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6083 return test_authenticated_decryption(&ccm_test_case_256_3);
6089 struct crypto_testsuite_params *ts_params = &testsuite_params;
6090 struct rte_cryptodev_stats stats;
6091 struct rte_cryptodev *dev;
6092 cryptodev_stats_get_t temp_pfn;
6094 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6095 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6096 &stats) == -ENODEV),
6097 "rte_cryptodev_stats_get invalid dev failed");
6098 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6099 "rte_cryptodev_stats_get invalid Param failed");
6100 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6101 temp_pfn = dev->dev_ops->stats_get;
6102 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6103 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6105 "rte_cryptodev_stats_get invalid Param failed");
6106 dev->dev_ops->stats_get = temp_pfn;
6108 /* Test expected values */
6110 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6112 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6114 "rte_cryptodev_stats_get failed");
6115 TEST_ASSERT((stats.enqueued_count == 1),
6116 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6117 TEST_ASSERT((stats.dequeued_count == 1),
6118 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6119 TEST_ASSERT((stats.enqueue_err_count == 0),
6120 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6121 TEST_ASSERT((stats.dequeue_err_count == 0),
6122 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6124 /* invalid device but should ignore and not reset device stats*/
6125 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6126 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6128 "rte_cryptodev_stats_get failed");
6129 TEST_ASSERT((stats.enqueued_count == 1),
6130 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6132 /* check that a valid reset clears stats */
6133 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6134 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6136 "rte_cryptodev_stats_get failed");
6137 TEST_ASSERT((stats.enqueued_count == 0),
6138 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6139 TEST_ASSERT((stats.dequeued_count == 0),
6140 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6142 return TEST_SUCCESS;
6145 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6146 struct crypto_unittest_params *ut_params,
6147 enum rte_crypto_auth_operation op,
6148 const struct HMAC_MD5_vector *test_case)
6152 memcpy(key, test_case->key.data, test_case->key.len);
6154 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6155 ut_params->auth_xform.next = NULL;
6156 ut_params->auth_xform.auth.op = op;
6158 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6160 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6161 ut_params->auth_xform.auth.key.length = test_case->key.len;
6162 ut_params->auth_xform.auth.key.data = key;
6164 ut_params->sess = rte_cryptodev_sym_session_create(
6165 ts_params->session_mpool);
6167 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6168 ut_params->sess, &ut_params->auth_xform,
6169 ts_params->session_mpool);
6171 if (ut_params->sess == NULL)
6174 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6176 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6177 rte_pktmbuf_tailroom(ut_params->ibuf));
6182 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6183 const struct HMAC_MD5_vector *test_case,
6184 uint8_t **plaintext)
6186 uint16_t plaintext_pad_len;
6188 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6190 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6193 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6195 memcpy(*plaintext, test_case->plaintext.data,
6196 test_case->plaintext.len);
6198 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6199 ut_params->ibuf, MD5_DIGEST_LEN);
6200 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6201 "no room to append digest");
6202 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6203 ut_params->ibuf, plaintext_pad_len);
6205 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6206 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6207 test_case->auth_tag.len);
6210 sym_op->auth.data.offset = 0;
6211 sym_op->auth.data.length = test_case->plaintext.len;
6213 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6214 ut_params->op->sym->m_src = ut_params->ibuf;
6220 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6222 uint16_t plaintext_pad_len;
6223 uint8_t *plaintext, *auth_tag;
6225 struct crypto_testsuite_params *ts_params = &testsuite_params;
6226 struct crypto_unittest_params *ut_params = &unittest_params;
6228 if (MD5_HMAC_create_session(ts_params, ut_params,
6229 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6232 /* Generate Crypto op data structure */
6233 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6234 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6235 TEST_ASSERT_NOT_NULL(ut_params->op,
6236 "Failed to allocate symmetric crypto operation struct");
6238 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6241 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6244 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6245 ut_params->op), "failed to process sym crypto op");
6247 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6248 "crypto op processing failed");
6250 if (ut_params->op->sym->m_dst) {
6251 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6252 uint8_t *, plaintext_pad_len);
6254 auth_tag = plaintext + plaintext_pad_len;
6257 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6259 test_case->auth_tag.data,
6260 test_case->auth_tag.len,
6261 "HMAC_MD5 generated tag not as expected");
6263 return TEST_SUCCESS;
6267 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6271 struct crypto_testsuite_params *ts_params = &testsuite_params;
6272 struct crypto_unittest_params *ut_params = &unittest_params;
6274 if (MD5_HMAC_create_session(ts_params, ut_params,
6275 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6279 /* Generate Crypto op data structure */
6280 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6281 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6282 TEST_ASSERT_NOT_NULL(ut_params->op,
6283 "Failed to allocate symmetric crypto operation struct");
6285 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6288 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6289 ut_params->op), "failed to process sym crypto op");
6291 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6292 "HMAC_MD5 crypto op processing failed");
6294 return TEST_SUCCESS;
6298 test_MD5_HMAC_generate_case_1(void)
6300 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6304 test_MD5_HMAC_verify_case_1(void)
6306 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6310 test_MD5_HMAC_generate_case_2(void)
6312 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6316 test_MD5_HMAC_verify_case_2(void)
6318 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6322 test_multi_session(void)
6324 struct crypto_testsuite_params *ts_params = &testsuite_params;
6325 struct crypto_unittest_params *ut_params = &unittest_params;
6327 struct rte_cryptodev_info dev_info;
6328 struct rte_cryptodev_sym_session **sessions;
6332 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6333 aes_cbc_key, hmac_sha512_key);
6336 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6338 sessions = rte_malloc(NULL,
6339 (sizeof(struct rte_cryptodev_sym_session *) *
6340 dev_info.sym.max_nb_sessions) + 1, 0);
6342 /* Create multiple crypto sessions*/
6343 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6345 sessions[i] = rte_cryptodev_sym_session_create(
6346 ts_params->session_mpool);
6348 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6349 sessions[i], &ut_params->auth_xform,
6350 ts_params->session_mpool);
6351 TEST_ASSERT_NOT_NULL(sessions[i],
6352 "Session creation failed at session number %u",
6355 /* Attempt to send a request on each session */
6356 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6360 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6361 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6363 "Failed to perform decrypt on request number %u.", i);
6364 /* free crypto operation structure */
6366 rte_crypto_op_free(ut_params->op);
6369 * free mbuf - both obuf and ibuf are usually the same,
6370 * so check if they point at the same address is necessary,
6371 * to avoid freeing the mbuf twice.
6373 if (ut_params->obuf) {
6374 rte_pktmbuf_free(ut_params->obuf);
6375 if (ut_params->ibuf == ut_params->obuf)
6376 ut_params->ibuf = 0;
6377 ut_params->obuf = 0;
6379 if (ut_params->ibuf) {
6380 rte_pktmbuf_free(ut_params->ibuf);
6381 ut_params->ibuf = 0;
6385 /* Next session create should fail */
6386 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6387 sessions[i], &ut_params->auth_xform,
6388 ts_params->session_mpool);
6389 TEST_ASSERT_NULL(sessions[i],
6390 "Session creation succeeded unexpectedly!");
6392 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6393 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6395 rte_cryptodev_sym_session_free(sessions[i]);
6400 return TEST_SUCCESS;
6403 struct multi_session_params {
6404 struct crypto_unittest_params ut_params;
6405 uint8_t *cipher_key;
6407 const uint8_t *cipher;
6408 const uint8_t *digest;
6412 #define MB_SESSION_NUMBER 3
6415 test_multi_session_random_usage(void)
6417 struct crypto_testsuite_params *ts_params = &testsuite_params;
6418 struct rte_cryptodev_info dev_info;
6419 struct rte_cryptodev_sym_session **sessions;
6421 struct multi_session_params ut_paramz[] = {
6424 .cipher_key = ms_aes_cbc_key0,
6425 .hmac_key = ms_hmac_key0,
6426 .cipher = ms_aes_cbc_cipher0,
6427 .digest = ms_hmac_digest0,
6428 .iv = ms_aes_cbc_iv0
6431 .cipher_key = ms_aes_cbc_key1,
6432 .hmac_key = ms_hmac_key1,
6433 .cipher = ms_aes_cbc_cipher1,
6434 .digest = ms_hmac_digest1,
6435 .iv = ms_aes_cbc_iv1
6438 .cipher_key = ms_aes_cbc_key2,
6439 .hmac_key = ms_hmac_key2,
6440 .cipher = ms_aes_cbc_cipher2,
6441 .digest = ms_hmac_digest2,
6442 .iv = ms_aes_cbc_iv2
6447 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6449 sessions = rte_malloc(NULL,
6450 (sizeof(struct rte_cryptodev_sym_session *)
6451 * dev_info.sym.max_nb_sessions) + 1, 0);
6453 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6454 sessions[i] = rte_cryptodev_sym_session_create(
6455 ts_params->session_mpool);
6457 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6458 sizeof(struct crypto_unittest_params));
6460 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6461 &ut_paramz[i].ut_params,
6462 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6464 /* Create multiple crypto sessions*/
6465 rte_cryptodev_sym_session_init(
6466 ts_params->valid_devs[0],
6468 &ut_paramz[i].ut_params.auth_xform,
6469 ts_params->session_mpool);
6471 TEST_ASSERT_NOT_NULL(sessions[i],
6472 "Session creation failed at session number %u",
6478 for (i = 0; i < 40000; i++) {
6480 j = rand() % MB_SESSION_NUMBER;
6482 TEST_ASSERT_SUCCESS(
6483 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6485 &ut_paramz[j].ut_params,
6486 ts_params, ut_paramz[j].cipher,
6487 ut_paramz[j].digest,
6489 "Failed to perform decrypt on request number %u.", i);
6491 if (ut_paramz[j].ut_params.op)
6492 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6495 * free mbuf - both obuf and ibuf are usually the same,
6496 * so check if they point at the same address is necessary,
6497 * to avoid freeing the mbuf twice.
6499 if (ut_paramz[j].ut_params.obuf) {
6500 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6501 if (ut_paramz[j].ut_params.ibuf
6502 == ut_paramz[j].ut_params.obuf)
6503 ut_paramz[j].ut_params.ibuf = 0;
6504 ut_paramz[j].ut_params.obuf = 0;
6506 if (ut_paramz[j].ut_params.ibuf) {
6507 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6508 ut_paramz[j].ut_params.ibuf = 0;
6512 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6513 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6515 rte_cryptodev_sym_session_free(sessions[i]);
6520 return TEST_SUCCESS;
6524 test_null_cipher_only_operation(void)
6526 struct crypto_testsuite_params *ts_params = &testsuite_params;
6527 struct crypto_unittest_params *ut_params = &unittest_params;
6529 /* Generate test mbuf data and space for digest */
6530 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6531 catch_22_quote, QUOTE_512_BYTES, 0);
6533 /* Setup Cipher Parameters */
6534 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6535 ut_params->cipher_xform.next = NULL;
6537 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6538 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6540 ut_params->sess = rte_cryptodev_sym_session_create(
6541 ts_params->session_mpool);
6543 /* Create Crypto session*/
6544 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6546 &ut_params->cipher_xform,
6547 ts_params->session_mpool);
6548 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6550 /* Generate Crypto op data structure */
6551 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6552 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6553 TEST_ASSERT_NOT_NULL(ut_params->op,
6554 "Failed to allocate symmetric crypto operation struct");
6556 /* Set crypto operation data parameters */
6557 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6559 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6561 /* set crypto operation source mbuf */
6562 sym_op->m_src = ut_params->ibuf;
6564 sym_op->cipher.data.offset = 0;
6565 sym_op->cipher.data.length = QUOTE_512_BYTES;
6567 /* Process crypto operation */
6568 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6570 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6572 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6573 "crypto operation processing failed");
6576 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6577 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6580 "Ciphertext data not as expected");
6582 return TEST_SUCCESS;
6586 test_null_auth_only_operation(void)
6588 struct crypto_testsuite_params *ts_params = &testsuite_params;
6589 struct crypto_unittest_params *ut_params = &unittest_params;
6591 /* Generate test mbuf data and space for digest */
6592 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6593 catch_22_quote, QUOTE_512_BYTES, 0);
6595 /* Setup HMAC Parameters */
6596 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6597 ut_params->auth_xform.next = NULL;
6599 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6600 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6602 ut_params->sess = rte_cryptodev_sym_session_create(
6603 ts_params->session_mpool);
6605 /* Create Crypto session*/
6606 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6607 ut_params->sess, &ut_params->auth_xform,
6608 ts_params->session_mpool);
6609 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6611 /* Generate Crypto op data structure */
6612 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6613 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6614 TEST_ASSERT_NOT_NULL(ut_params->op,
6615 "Failed to allocate symmetric crypto operation struct");
6617 /* Set crypto operation data parameters */
6618 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6620 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6622 sym_op->m_src = ut_params->ibuf;
6624 sym_op->auth.data.offset = 0;
6625 sym_op->auth.data.length = QUOTE_512_BYTES;
6627 /* Process crypto operation */
6628 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6630 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6632 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6633 "crypto operation processing failed");
6635 return TEST_SUCCESS;
6639 test_null_cipher_auth_operation(void)
6641 struct crypto_testsuite_params *ts_params = &testsuite_params;
6642 struct crypto_unittest_params *ut_params = &unittest_params;
6644 /* Generate test mbuf data and space for digest */
6645 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6646 catch_22_quote, QUOTE_512_BYTES, 0);
6648 /* Setup Cipher Parameters */
6649 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6650 ut_params->cipher_xform.next = &ut_params->auth_xform;
6652 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6653 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6655 /* Setup HMAC Parameters */
6656 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6657 ut_params->auth_xform.next = NULL;
6659 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6660 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6662 ut_params->sess = rte_cryptodev_sym_session_create(
6663 ts_params->session_mpool);
6665 /* Create Crypto session*/
6666 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6667 ut_params->sess, &ut_params->cipher_xform,
6668 ts_params->session_mpool);
6669 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6671 /* Generate Crypto op data structure */
6672 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6673 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6674 TEST_ASSERT_NOT_NULL(ut_params->op,
6675 "Failed to allocate symmetric crypto operation struct");
6677 /* Set crypto operation data parameters */
6678 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6680 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6682 sym_op->m_src = ut_params->ibuf;
6684 sym_op->cipher.data.offset = 0;
6685 sym_op->cipher.data.length = QUOTE_512_BYTES;
6687 sym_op->auth.data.offset = 0;
6688 sym_op->auth.data.length = QUOTE_512_BYTES;
6690 /* Process crypto operation */
6691 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6693 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6695 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6696 "crypto operation processing failed");
6699 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6700 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6703 "Ciphertext data not as expected");
6705 return TEST_SUCCESS;
6709 test_null_auth_cipher_operation(void)
6711 struct crypto_testsuite_params *ts_params = &testsuite_params;
6712 struct crypto_unittest_params *ut_params = &unittest_params;
6714 /* Generate test mbuf data and space for digest */
6715 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6716 catch_22_quote, QUOTE_512_BYTES, 0);
6718 /* Setup Cipher Parameters */
6719 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6720 ut_params->cipher_xform.next = NULL;
6722 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6723 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6725 /* Setup HMAC Parameters */
6726 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6727 ut_params->auth_xform.next = &ut_params->cipher_xform;
6729 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6730 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6732 ut_params->sess = rte_cryptodev_sym_session_create(
6733 ts_params->session_mpool);
6735 /* Create Crypto session*/
6736 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6737 ut_params->sess, &ut_params->cipher_xform,
6738 ts_params->session_mpool);
6739 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6741 /* Generate Crypto op data structure */
6742 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6743 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6744 TEST_ASSERT_NOT_NULL(ut_params->op,
6745 "Failed to allocate symmetric crypto operation struct");
6747 /* Set crypto operation data parameters */
6748 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6750 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6752 sym_op->m_src = ut_params->ibuf;
6754 sym_op->cipher.data.offset = 0;
6755 sym_op->cipher.data.length = QUOTE_512_BYTES;
6757 sym_op->auth.data.offset = 0;
6758 sym_op->auth.data.length = QUOTE_512_BYTES;
6760 /* Process crypto operation */
6761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6763 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6765 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6766 "crypto operation processing failed");
6769 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6770 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6773 "Ciphertext data not as expected");
6775 return TEST_SUCCESS;
6780 test_null_invalid_operation(void)
6782 struct crypto_testsuite_params *ts_params = &testsuite_params;
6783 struct crypto_unittest_params *ut_params = &unittest_params;
6786 /* Setup Cipher Parameters */
6787 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6788 ut_params->cipher_xform.next = NULL;
6790 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6791 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6793 ut_params->sess = rte_cryptodev_sym_session_create(
6794 ts_params->session_mpool);
6796 /* Create Crypto session*/
6797 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6798 ut_params->sess, &ut_params->cipher_xform,
6799 ts_params->session_mpool);
6800 TEST_ASSERT(ret < 0,
6801 "Session creation succeeded unexpectedly");
6804 /* Setup HMAC Parameters */
6805 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6806 ut_params->auth_xform.next = NULL;
6808 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6809 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6811 ut_params->sess = rte_cryptodev_sym_session_create(
6812 ts_params->session_mpool);
6814 /* Create Crypto session*/
6815 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6816 ut_params->sess, &ut_params->auth_xform,
6817 ts_params->session_mpool);
6818 TEST_ASSERT(ret < 0,
6819 "Session creation succeeded unexpectedly");
6821 return TEST_SUCCESS;
6825 #define NULL_BURST_LENGTH (32)
6828 test_null_burst_operation(void)
6830 struct crypto_testsuite_params *ts_params = &testsuite_params;
6831 struct crypto_unittest_params *ut_params = &unittest_params;
6833 unsigned i, burst_len = NULL_BURST_LENGTH;
6835 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
6836 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
6838 /* Setup Cipher Parameters */
6839 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6840 ut_params->cipher_xform.next = &ut_params->auth_xform;
6842 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6843 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6845 /* Setup HMAC Parameters */
6846 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6847 ut_params->auth_xform.next = NULL;
6849 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6850 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6852 ut_params->sess = rte_cryptodev_sym_session_create(
6853 ts_params->session_mpool);
6855 /* Create Crypto session*/
6856 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6857 ut_params->sess, &ut_params->cipher_xform,
6858 ts_params->session_mpool);
6859 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6861 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
6862 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
6863 burst_len, "failed to generate burst of crypto ops");
6865 /* Generate an operation for each mbuf in burst */
6866 for (i = 0; i < burst_len; i++) {
6867 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6869 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
6871 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
6875 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
6877 burst[i]->sym->m_src = m;
6880 /* Process crypto operation */
6881 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
6882 0, burst, burst_len),
6884 "Error enqueuing burst");
6886 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
6887 0, burst_dequeued, burst_len),
6889 "Error dequeuing burst");
6892 for (i = 0; i < burst_len; i++) {
6894 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
6895 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
6897 "data not as expected");
6899 rte_pktmbuf_free(burst[i]->sym->m_src);
6900 rte_crypto_op_free(burst[i]);
6903 return TEST_SUCCESS;
6907 generate_gmac_large_plaintext(uint8_t *data)
6911 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
6912 memcpy(&data[i], &data[0], 32);
6916 create_gmac_operation(enum rte_crypto_auth_operation op,
6917 const struct gmac_test_data *tdata)
6919 struct crypto_testsuite_params *ts_params = &testsuite_params;
6920 struct crypto_unittest_params *ut_params = &unittest_params;
6921 struct rte_crypto_sym_op *sym_op;
6923 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6925 /* Generate Crypto op data structure */
6926 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6927 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6928 TEST_ASSERT_NOT_NULL(ut_params->op,
6929 "Failed to allocate symmetric crypto operation struct");
6931 sym_op = ut_params->op->sym;
6933 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6934 ut_params->ibuf, tdata->gmac_tag.len);
6935 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6936 "no room to append digest");
6938 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6939 ut_params->ibuf, plaintext_pad_len);
6941 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6942 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
6943 tdata->gmac_tag.len);
6944 TEST_HEXDUMP(stdout, "digest:",
6945 sym_op->auth.digest.data,
6946 tdata->gmac_tag.len);
6949 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
6950 uint8_t *, IV_OFFSET);
6952 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
6954 TEST_HEXDUMP(stdout, "iv:", iv_ptr, tdata->iv.len);
6956 sym_op->cipher.data.length = 0;
6957 sym_op->cipher.data.offset = 0;
6959 sym_op->auth.data.offset = 0;
6960 sym_op->auth.data.length = tdata->plaintext.len;
6965 static int create_gmac_session(uint8_t dev_id,
6966 const struct gmac_test_data *tdata,
6967 enum rte_crypto_auth_operation auth_op)
6969 uint8_t auth_key[tdata->key.len];
6971 struct crypto_testsuite_params *ts_params = &testsuite_params;
6972 struct crypto_unittest_params *ut_params = &unittest_params;
6974 memcpy(auth_key, tdata->key.data, tdata->key.len);
6976 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6977 ut_params->auth_xform.next = NULL;
6979 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
6980 ut_params->auth_xform.auth.op = auth_op;
6981 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
6982 ut_params->auth_xform.auth.key.length = tdata->key.len;
6983 ut_params->auth_xform.auth.key.data = auth_key;
6984 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
6985 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
6988 ut_params->sess = rte_cryptodev_sym_session_create(
6989 ts_params->session_mpool);
6991 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
6992 &ut_params->auth_xform,
6993 ts_params->session_mpool);
6995 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7001 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7003 struct crypto_testsuite_params *ts_params = &testsuite_params;
7004 struct crypto_unittest_params *ut_params = &unittest_params;
7008 uint8_t *auth_tag, *plaintext;
7009 uint16_t plaintext_pad_len;
7011 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7012 "No GMAC length in the source data");
7014 retval = create_gmac_session(ts_params->valid_devs[0],
7015 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7020 if (tdata->plaintext.len > MBUF_SIZE)
7021 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7023 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7024 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7025 "Failed to allocate input buffer in mempool");
7027 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7028 rte_pktmbuf_tailroom(ut_params->ibuf));
7030 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7032 * Runtime generate the large plain text instead of use hard code
7033 * plain text vector. It is done to avoid create huge source file
7034 * with the test vector.
7036 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7037 generate_gmac_large_plaintext(tdata->plaintext.data);
7039 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7041 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7043 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7044 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7045 tdata->plaintext.len);
7047 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7053 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7055 ut_params->op->sym->m_src = ut_params->ibuf;
7057 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7058 ut_params->op), "failed to process sym crypto op");
7060 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7061 "crypto op processing failed");
7063 if (ut_params->op->sym->m_dst) {
7064 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7065 uint8_t *, plaintext_pad_len);
7067 auth_tag = plaintext + plaintext_pad_len;
7070 TEST_HEXDUMP(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7072 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7074 tdata->gmac_tag.data,
7075 tdata->gmac_tag.len,
7076 "GMAC Generated auth tag not as expected");
7082 test_AES_GMAC_authentication_test_case_1(void)
7084 return test_AES_GMAC_authentication(&gmac_test_case_1);
7088 test_AES_GMAC_authentication_test_case_2(void)
7090 return test_AES_GMAC_authentication(&gmac_test_case_2);
7094 test_AES_GMAC_authentication_test_case_3(void)
7096 return test_AES_GMAC_authentication(&gmac_test_case_3);
7100 test_AES_GMAC_authentication_test_case_4(void)
7102 return test_AES_GMAC_authentication(&gmac_test_case_4);
7106 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7108 struct crypto_testsuite_params *ts_params = &testsuite_params;
7109 struct crypto_unittest_params *ut_params = &unittest_params;
7111 uint32_t plaintext_pad_len;
7114 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7115 "No GMAC length in the source data");
7117 retval = create_gmac_session(ts_params->valid_devs[0],
7118 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7123 if (tdata->plaintext.len > MBUF_SIZE)
7124 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7126 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7127 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7128 "Failed to allocate input buffer in mempool");
7130 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7131 rte_pktmbuf_tailroom(ut_params->ibuf));
7133 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7136 * Runtime generate the large plain text instead of use hard code
7137 * plain text vector. It is done to avoid create huge source file
7138 * with the test vector.
7140 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7141 generate_gmac_large_plaintext(tdata->plaintext.data);
7143 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7145 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7147 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7148 TEST_HEXDUMP(stdout, "plaintext:", plaintext,
7149 tdata->plaintext.len);
7151 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7157 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7159 ut_params->op->sym->m_src = ut_params->ibuf;
7161 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7162 ut_params->op), "failed to process sym crypto op");
7164 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7165 "crypto op processing failed");
7172 test_AES_GMAC_authentication_verify_test_case_1(void)
7174 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7178 test_AES_GMAC_authentication_verify_test_case_2(void)
7180 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7184 test_AES_GMAC_authentication_verify_test_case_3(void)
7186 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7190 test_AES_GMAC_authentication_verify_test_case_4(void)
7192 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7195 struct test_crypto_vector {
7196 enum rte_crypto_cipher_algorithm crypto_algo;
7209 const uint8_t *data;
7214 const uint8_t *data;
7218 enum rte_crypto_auth_algorithm auth_algo;
7226 const uint8_t *data;
7236 static const struct test_crypto_vector
7237 hmac_sha1_test_crypto_vector = {
7238 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7240 .data = plaintext_hash,
7245 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7246 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7247 0xDE, 0xF4, 0xDE, 0xAD
7253 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7254 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7255 0x3F, 0x91, 0x64, 0x59
7261 static const struct test_crypto_vector
7262 aes128_gmac_test_vector = {
7263 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7265 .data = plaintext_hash,
7270 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7271 0x08, 0x09, 0x0A, 0x0B
7277 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7278 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7284 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7285 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7291 static const struct test_crypto_vector
7292 aes128cbc_hmac_sha1_test_vector = {
7293 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7296 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7297 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7303 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7304 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7309 .data = plaintext_hash,
7313 .data = ciphertext512_aes128cbc,
7316 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7319 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7320 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7321 0xDE, 0xF4, 0xDE, 0xAD
7327 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7328 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7329 0x18, 0x8C, 0x1D, 0x32
7336 data_corruption(uint8_t *data)
7342 tag_corruption(uint8_t *data, unsigned int tag_offset)
7344 data[tag_offset] += 1;
7348 create_auth_session(struct crypto_unittest_params *ut_params,
7350 const struct test_crypto_vector *reference,
7351 enum rte_crypto_auth_operation auth_op)
7353 struct crypto_testsuite_params *ts_params = &testsuite_params;
7354 uint8_t auth_key[reference->auth_key.len + 1];
7356 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7358 /* Setup Authentication Parameters */
7359 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7360 ut_params->auth_xform.auth.op = auth_op;
7361 ut_params->auth_xform.next = NULL;
7362 ut_params->auth_xform.auth.algo = reference->auth_algo;
7363 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7364 ut_params->auth_xform.auth.key.data = auth_key;
7365 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7367 /* Create Crypto session*/
7368 ut_params->sess = rte_cryptodev_sym_session_create(
7369 ts_params->session_mpool);
7371 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7372 &ut_params->auth_xform,
7373 ts_params->session_mpool);
7375 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7381 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7383 const struct test_crypto_vector *reference,
7384 enum rte_crypto_auth_operation auth_op,
7385 enum rte_crypto_cipher_operation cipher_op)
7387 struct crypto_testsuite_params *ts_params = &testsuite_params;
7388 uint8_t cipher_key[reference->cipher_key.len + 1];
7389 uint8_t auth_key[reference->auth_key.len + 1];
7391 memcpy(cipher_key, reference->cipher_key.data,
7392 reference->cipher_key.len);
7393 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7395 /* Setup Authentication Parameters */
7396 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7397 ut_params->auth_xform.auth.op = auth_op;
7398 ut_params->auth_xform.auth.algo = reference->auth_algo;
7399 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7400 ut_params->auth_xform.auth.key.data = auth_key;
7401 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7403 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7404 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7405 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7407 ut_params->auth_xform.next = &ut_params->cipher_xform;
7409 /* Setup Cipher Parameters */
7410 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7411 ut_params->cipher_xform.next = NULL;
7412 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7413 ut_params->cipher_xform.cipher.op = cipher_op;
7414 ut_params->cipher_xform.cipher.key.data = cipher_key;
7415 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7416 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7417 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7420 /* Create Crypto session*/
7421 ut_params->sess = rte_cryptodev_sym_session_create(
7422 ts_params->session_mpool);
7424 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7425 &ut_params->auth_xform,
7426 ts_params->session_mpool);
7428 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7434 create_auth_operation(struct crypto_testsuite_params *ts_params,
7435 struct crypto_unittest_params *ut_params,
7436 const struct test_crypto_vector *reference,
7437 unsigned int auth_generate)
7439 /* Generate Crypto op data structure */
7440 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7441 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7442 TEST_ASSERT_NOT_NULL(ut_params->op,
7443 "Failed to allocate pktmbuf offload");
7445 /* Set crypto operation data parameters */
7446 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7448 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7450 /* set crypto operation source mbuf */
7451 sym_op->m_src = ut_params->ibuf;
7454 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7455 ut_params->ibuf, reference->digest.len);
7457 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7458 "no room to append auth tag");
7460 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7461 ut_params->ibuf, reference->plaintext.len);
7464 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7466 memcpy(sym_op->auth.digest.data,
7467 reference->digest.data,
7468 reference->digest.len);
7470 TEST_HEXDUMP(stdout, "digest:",
7471 sym_op->auth.digest.data,
7472 reference->digest.len);
7474 sym_op->auth.data.length = reference->plaintext.len;
7475 sym_op->auth.data.offset = 0;
7481 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7482 struct crypto_unittest_params *ut_params,
7483 const struct test_crypto_vector *reference,
7484 unsigned int auth_generate)
7486 /* Generate Crypto op data structure */
7487 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7488 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7489 TEST_ASSERT_NOT_NULL(ut_params->op,
7490 "Failed to allocate pktmbuf offload");
7492 /* Set crypto operation data parameters */
7493 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7495 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7497 /* set crypto operation source mbuf */
7498 sym_op->m_src = ut_params->ibuf;
7501 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7502 ut_params->ibuf, reference->digest.len);
7504 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7505 "no room to append auth tag");
7507 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7508 ut_params->ibuf, reference->ciphertext.len);
7511 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7513 memcpy(sym_op->auth.digest.data,
7514 reference->digest.data,
7515 reference->digest.len);
7517 TEST_HEXDUMP(stdout, "digest:",
7518 sym_op->auth.digest.data,
7519 reference->digest.len);
7521 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7522 reference->iv.data, reference->iv.len);
7524 sym_op->cipher.data.length = 0;
7525 sym_op->cipher.data.offset = 0;
7527 sym_op->auth.data.length = reference->plaintext.len;
7528 sym_op->auth.data.offset = 0;
7534 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7535 struct crypto_unittest_params *ut_params,
7536 const struct test_crypto_vector *reference,
7537 unsigned int auth_generate)
7539 /* Generate Crypto op data structure */
7540 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7541 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7542 TEST_ASSERT_NOT_NULL(ut_params->op,
7543 "Failed to allocate pktmbuf offload");
7545 /* Set crypto operation data parameters */
7546 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7548 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7550 /* set crypto operation source mbuf */
7551 sym_op->m_src = ut_params->ibuf;
7554 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7555 ut_params->ibuf, reference->digest.len);
7557 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7558 "no room to append auth tag");
7560 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7561 ut_params->ibuf, reference->ciphertext.len);
7564 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7566 memcpy(sym_op->auth.digest.data,
7567 reference->digest.data,
7568 reference->digest.len);
7570 TEST_HEXDUMP(stdout, "digest:",
7571 sym_op->auth.digest.data,
7572 reference->digest.len);
7574 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7575 reference->iv.data, reference->iv.len);
7577 sym_op->cipher.data.length = reference->ciphertext.len;
7578 sym_op->cipher.data.offset = 0;
7580 sym_op->auth.data.length = reference->ciphertext.len;
7581 sym_op->auth.data.offset = 0;
7587 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7588 struct crypto_unittest_params *ut_params,
7589 const struct test_crypto_vector *reference)
7591 return create_auth_operation(ts_params, ut_params, reference, 0);
7595 create_auth_verify_GMAC_operation(
7596 struct crypto_testsuite_params *ts_params,
7597 struct crypto_unittest_params *ut_params,
7598 const struct test_crypto_vector *reference)
7600 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7604 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7605 struct crypto_unittest_params *ut_params,
7606 const struct test_crypto_vector *reference)
7608 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7612 test_authentication_verify_fail_when_data_corruption(
7613 struct crypto_testsuite_params *ts_params,
7614 struct crypto_unittest_params *ut_params,
7615 const struct test_crypto_vector *reference,
7616 unsigned int data_corrupted)
7622 /* Create session */
7623 retval = create_auth_session(ut_params,
7624 ts_params->valid_devs[0],
7626 RTE_CRYPTO_AUTH_OP_VERIFY);
7630 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7631 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7632 "Failed to allocate input buffer in mempool");
7634 /* clear mbuf payload */
7635 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7636 rte_pktmbuf_tailroom(ut_params->ibuf));
7638 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7639 reference->plaintext.len);
7640 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7641 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7643 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7645 /* Create operation */
7646 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7652 data_corruption(plaintext);
7654 tag_corruption(plaintext, reference->plaintext.len);
7656 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7658 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7659 TEST_ASSERT_EQUAL(ut_params->op->status,
7660 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7661 "authentication not failed");
7663 ut_params->obuf = ut_params->op->sym->m_src;
7664 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7670 test_authentication_verify_GMAC_fail_when_corruption(
7671 struct crypto_testsuite_params *ts_params,
7672 struct crypto_unittest_params *ut_params,
7673 const struct test_crypto_vector *reference,
7674 unsigned int data_corrupted)
7679 /* Create session */
7680 retval = create_auth_cipher_session(ut_params,
7681 ts_params->valid_devs[0],
7683 RTE_CRYPTO_AUTH_OP_VERIFY,
7684 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7688 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7689 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7690 "Failed to allocate input buffer in mempool");
7692 /* clear mbuf payload */
7693 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7694 rte_pktmbuf_tailroom(ut_params->ibuf));
7696 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7697 reference->plaintext.len);
7698 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7699 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7701 TEST_HEXDUMP(stdout, "plaintext:", plaintext, reference->plaintext.len);
7703 /* Create operation */
7704 retval = create_auth_verify_GMAC_operation(ts_params,
7712 data_corruption(plaintext);
7714 tag_corruption(plaintext, reference->aad.len);
7716 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7718 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7719 TEST_ASSERT_EQUAL(ut_params->op->status,
7720 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7721 "authentication not failed");
7723 ut_params->obuf = ut_params->op->sym->m_src;
7724 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7730 test_authenticated_decryption_fail_when_corruption(
7731 struct crypto_testsuite_params *ts_params,
7732 struct crypto_unittest_params *ut_params,
7733 const struct test_crypto_vector *reference,
7734 unsigned int data_corrupted)
7738 uint8_t *ciphertext;
7740 /* Create session */
7741 retval = create_auth_cipher_session(ut_params,
7742 ts_params->valid_devs[0],
7744 RTE_CRYPTO_AUTH_OP_VERIFY,
7745 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7749 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7750 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7751 "Failed to allocate input buffer in mempool");
7753 /* clear mbuf payload */
7754 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7755 rte_pktmbuf_tailroom(ut_params->ibuf));
7757 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7758 reference->ciphertext.len);
7759 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7760 memcpy(ciphertext, reference->ciphertext.data,
7761 reference->ciphertext.len);
7763 /* Create operation */
7764 retval = create_cipher_auth_verify_operation(ts_params,
7772 data_corruption(ciphertext);
7774 tag_corruption(ciphertext, reference->ciphertext.len);
7776 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7779 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7780 TEST_ASSERT_EQUAL(ut_params->op->status,
7781 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7782 "authentication not failed");
7784 ut_params->obuf = ut_params->op->sym->m_src;
7785 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7791 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7792 const struct aead_test_data *tdata,
7793 void *digest_mem, uint64_t digest_phys)
7795 struct crypto_testsuite_params *ts_params = &testsuite_params;
7796 struct crypto_unittest_params *ut_params = &unittest_params;
7798 const unsigned int auth_tag_len = tdata->auth_tag.len;
7799 const unsigned int iv_len = tdata->iv.len;
7800 unsigned int aad_len = tdata->aad.len;
7802 /* Generate Crypto op data structure */
7803 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7804 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7805 TEST_ASSERT_NOT_NULL(ut_params->op,
7806 "Failed to allocate symmetric crypto operation struct");
7808 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7810 sym_op->aead.digest.data = digest_mem;
7812 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7813 "no room to append digest");
7815 sym_op->aead.digest.phys_addr = digest_phys;
7817 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
7818 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7820 TEST_HEXDUMP(stdout, "digest:",
7821 sym_op->aead.digest.data,
7825 /* Append aad data */
7826 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7827 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7828 uint8_t *, IV_OFFSET);
7830 /* Copy IV 1 byte after the IV pointer, according to the API */
7831 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
7833 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
7835 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7836 ut_params->ibuf, aad_len);
7837 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7838 "no room to prepend aad");
7839 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7842 memset(sym_op->aead.aad.data, 0, aad_len);
7843 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7844 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7846 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7847 TEST_HEXDUMP(stdout, "aad:",
7848 sym_op->aead.aad.data, aad_len);
7850 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7851 uint8_t *, IV_OFFSET);
7853 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
7855 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
7856 ut_params->ibuf, aad_len);
7857 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7858 "no room to prepend aad");
7859 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
7862 memset(sym_op->aead.aad.data, 0, aad_len);
7863 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
7865 TEST_HEXDUMP(stdout, "iv:", iv_ptr, iv_len);
7866 TEST_HEXDUMP(stdout, "aad:",
7867 sym_op->aead.aad.data, aad_len);
7870 sym_op->aead.data.length = tdata->plaintext.len;
7871 sym_op->aead.data.offset = aad_len;
7876 #define SGL_MAX_NO 16
7879 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
7880 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
7882 struct crypto_testsuite_params *ts_params = &testsuite_params;
7883 struct crypto_unittest_params *ut_params = &unittest_params;
7884 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
7887 int to_trn_tbl[SGL_MAX_NO];
7889 unsigned int trn_data = 0;
7890 uint8_t *plaintext, *ciphertext, *auth_tag;
7892 if (fragsz > tdata->plaintext.len)
7893 fragsz = tdata->plaintext.len;
7895 uint16_t plaintext_len = fragsz;
7896 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7898 if (fragsz_oop > tdata->plaintext.len)
7899 frag_size_oop = tdata->plaintext.len;
7902 void *digest_mem = NULL;
7904 uint32_t prepend_len = tdata->aad.len;
7906 if (tdata->plaintext.len % fragsz != 0) {
7907 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
7910 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
7915 * For out-op-place we need to alloc another mbuf
7918 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7919 rte_pktmbuf_append(ut_params->obuf,
7920 frag_size_oop + prepend_len);
7921 buf_oop = ut_params->obuf;
7924 /* Create AEAD session */
7925 retval = create_aead_session(ts_params->valid_devs[0],
7927 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7928 tdata->key.data, tdata->key.len,
7929 tdata->aad.len, tdata->auth_tag.len,
7934 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7936 /* clear mbuf payload */
7937 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7938 rte_pktmbuf_tailroom(ut_params->ibuf));
7940 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7943 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
7945 trn_data += plaintext_len;
7947 buf = ut_params->ibuf;
7950 * Loop until no more fragments
7953 while (trn_data < tdata->plaintext.len) {
7955 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
7956 (tdata->plaintext.len - trn_data) : fragsz;
7958 to_trn_tbl[ecx++] = to_trn;
7960 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7963 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7964 rte_pktmbuf_tailroom(buf));
7967 if (oop && !fragsz_oop) {
7968 buf_last_oop = buf_oop->next =
7969 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7970 buf_oop = buf_oop->next;
7971 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7972 0, rte_pktmbuf_tailroom(buf_oop));
7973 rte_pktmbuf_append(buf_oop, to_trn);
7976 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7979 memcpy(plaintext, tdata->plaintext.data + trn_data,
7982 if (trn_data == tdata->plaintext.len) {
7985 digest_mem = rte_pktmbuf_append(buf_oop,
7986 tdata->auth_tag.len);
7988 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
7989 tdata->auth_tag.len);
7993 uint64_t digest_phys = 0;
7995 ut_params->ibuf->nb_segs = segs;
7998 if (fragsz_oop && oop) {
8002 if (frag_size_oop == tdata->plaintext.len) {
8003 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8004 tdata->auth_tag.len);
8006 digest_phys = rte_pktmbuf_iova_offset(
8008 tdata->plaintext.len + prepend_len);
8011 trn_data = frag_size_oop;
8012 while (trn_data < tdata->plaintext.len) {
8015 (tdata->plaintext.len - trn_data <
8017 (tdata->plaintext.len - trn_data) :
8020 to_trn_tbl[ecx++] = to_trn;
8022 buf_last_oop = buf_oop->next =
8023 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8024 buf_oop = buf_oop->next;
8025 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8026 0, rte_pktmbuf_tailroom(buf_oop));
8027 rte_pktmbuf_append(buf_oop, to_trn);
8031 if (trn_data == tdata->plaintext.len) {
8032 digest_mem = rte_pktmbuf_append(buf_oop,
8033 tdata->auth_tag.len);
8037 ut_params->obuf->nb_segs = segs;
8041 * Place digest at the end of the last buffer
8044 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8045 if (oop && buf_last_oop)
8046 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8048 if (!digest_mem && !oop) {
8049 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8050 + tdata->auth_tag.len);
8051 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8052 tdata->plaintext.len);
8055 /* Create AEAD operation */
8056 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8057 tdata, digest_mem, digest_phys);
8062 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8064 ut_params->op->sym->m_src = ut_params->ibuf;
8066 ut_params->op->sym->m_dst = ut_params->obuf;
8068 /* Process crypto operation */
8069 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8070 ut_params->op), "failed to process sym crypto op");
8072 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8073 "crypto op processing failed");
8076 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8077 uint8_t *, prepend_len);
8079 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8080 uint8_t *, prepend_len);
8084 fragsz = fragsz_oop;
8086 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8088 tdata->ciphertext.data,
8090 "Ciphertext data not as expected");
8092 buf = ut_params->op->sym->m_src->next;
8094 buf = ut_params->op->sym->m_dst->next;
8096 unsigned int off = fragsz;
8100 ciphertext = rte_pktmbuf_mtod(buf,
8103 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8105 tdata->ciphertext.data + off,
8107 "Ciphertext data not as expected");
8109 off += to_trn_tbl[ecx++];
8113 auth_tag = digest_mem;
8114 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8116 tdata->auth_tag.data,
8117 tdata->auth_tag.len,
8118 "Generated auth tag not as expected");
8124 #define OUT_OF_PLACE 1
8127 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8129 return test_authenticated_encryption_SGL(
8130 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8134 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8136 return test_authenticated_encryption_SGL(
8137 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8141 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8143 return test_authenticated_encryption_SGL(
8144 &gcm_test_case_8, OUT_OF_PLACE, 400,
8145 gcm_test_case_8.plaintext.len);
8149 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8152 return test_authenticated_encryption_SGL(
8153 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8157 test_authentication_verify_fail_when_data_corrupted(
8158 struct crypto_testsuite_params *ts_params,
8159 struct crypto_unittest_params *ut_params,
8160 const struct test_crypto_vector *reference)
8162 return test_authentication_verify_fail_when_data_corruption(
8163 ts_params, ut_params, reference, 1);
8167 test_authentication_verify_fail_when_tag_corrupted(
8168 struct crypto_testsuite_params *ts_params,
8169 struct crypto_unittest_params *ut_params,
8170 const struct test_crypto_vector *reference)
8172 return test_authentication_verify_fail_when_data_corruption(
8173 ts_params, ut_params, reference, 0);
8177 test_authentication_verify_GMAC_fail_when_data_corrupted(
8178 struct crypto_testsuite_params *ts_params,
8179 struct crypto_unittest_params *ut_params,
8180 const struct test_crypto_vector *reference)
8182 return test_authentication_verify_GMAC_fail_when_corruption(
8183 ts_params, ut_params, reference, 1);
8187 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8188 struct crypto_testsuite_params *ts_params,
8189 struct crypto_unittest_params *ut_params,
8190 const struct test_crypto_vector *reference)
8192 return test_authentication_verify_GMAC_fail_when_corruption(
8193 ts_params, ut_params, reference, 0);
8197 test_authenticated_decryption_fail_when_data_corrupted(
8198 struct crypto_testsuite_params *ts_params,
8199 struct crypto_unittest_params *ut_params,
8200 const struct test_crypto_vector *reference)
8202 return test_authenticated_decryption_fail_when_corruption(
8203 ts_params, ut_params, reference, 1);
8207 test_authenticated_decryption_fail_when_tag_corrupted(
8208 struct crypto_testsuite_params *ts_params,
8209 struct crypto_unittest_params *ut_params,
8210 const struct test_crypto_vector *reference)
8212 return test_authenticated_decryption_fail_when_corruption(
8213 ts_params, ut_params, reference, 0);
8217 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8219 return test_authentication_verify_fail_when_data_corrupted(
8220 &testsuite_params, &unittest_params,
8221 &hmac_sha1_test_crypto_vector);
8225 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8227 return test_authentication_verify_fail_when_tag_corrupted(
8228 &testsuite_params, &unittest_params,
8229 &hmac_sha1_test_crypto_vector);
8233 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8235 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8236 &testsuite_params, &unittest_params,
8237 &aes128_gmac_test_vector);
8241 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8243 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8244 &testsuite_params, &unittest_params,
8245 &aes128_gmac_test_vector);
8249 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8251 return test_authenticated_decryption_fail_when_data_corrupted(
8254 &aes128cbc_hmac_sha1_test_vector);
8258 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8260 return test_authenticated_decryption_fail_when_tag_corrupted(
8263 &aes128cbc_hmac_sha1_test_vector);
8266 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8268 /* global AESNI slave IDs for the scheduler test */
8269 uint8_t aesni_ids[2];
8272 test_scheduler_attach_slave_op(void)
8274 struct crypto_testsuite_params *ts_params = &testsuite_params;
8275 uint8_t sched_id = ts_params->valid_devs[0];
8276 uint32_t nb_devs, i, nb_devs_attached = 0;
8280 /* create 2 AESNI_MB if necessary */
8281 nb_devs = rte_cryptodev_device_count_by_driver(
8282 rte_cryptodev_driver_id_get(
8283 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8285 for (i = nb_devs; i < 2; i++) {
8286 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8287 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8289 ret = rte_vdev_init(vdev_name, NULL);
8291 TEST_ASSERT(ret == 0,
8292 "Failed to create instance %u of"
8294 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8298 /* attach 2 AESNI_MB cdevs */
8299 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8301 struct rte_cryptodev_info info;
8303 rte_cryptodev_info_get(i, &info);
8304 if (info.driver_id != rte_cryptodev_driver_id_get(
8305 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8309 * Create the session mempool again, since now there are new devices
8310 * to use the mempool.
8312 if (ts_params->session_mpool) {
8313 rte_mempool_free(ts_params->session_mpool);
8314 ts_params->session_mpool = NULL;
8316 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8319 * Create mempool with maximum number of sessions * 2,
8320 * to include the session headers
8322 if (ts_params->session_mpool == NULL) {
8323 ts_params->session_mpool = rte_mempool_create(
8325 info.sym.max_nb_sessions * 2,
8327 0, 0, NULL, NULL, NULL,
8328 NULL, SOCKET_ID_ANY,
8331 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8332 "session mempool allocation failed");
8335 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8338 TEST_ASSERT(ret == 0,
8339 "Failed to attach device %u of pmd : %s", i,
8340 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8342 aesni_ids[nb_devs_attached] = (uint8_t)i;
8351 test_scheduler_detach_slave_op(void)
8353 struct crypto_testsuite_params *ts_params = &testsuite_params;
8354 uint8_t sched_id = ts_params->valid_devs[0];
8358 for (i = 0; i < 2; i++) {
8359 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8361 TEST_ASSERT(ret == 0,
8362 "Failed to detach device %u", aesni_ids[i]);
8369 test_scheduler_mode_op(void)
8371 struct crypto_testsuite_params *ts_params = &testsuite_params;
8372 uint8_t sched_id = ts_params->valid_devs[0];
8373 struct rte_cryptodev_scheduler_ops op = {0};
8374 struct rte_cryptodev_scheduler dummy_scheduler = {
8375 .description = "dummy scheduler to test mode",
8376 .name = "dummy scheduler",
8377 .mode = CDEV_SCHED_MODE_USERDEFINED,
8382 /* set user defined mode */
8383 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8385 TEST_ASSERT(ret == 0,
8386 "Failed to set cdev %u to user defined mode", sched_id);
8388 /* set round robin mode */
8389 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8390 CDEV_SCHED_MODE_ROUNDROBIN);
8391 TEST_ASSERT(ret == 0,
8392 "Failed to set cdev %u to round-robin mode", sched_id);
8393 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8394 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8400 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8401 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8402 .setup = testsuite_setup,
8403 .teardown = testsuite_teardown,
8404 .unit_test_cases = {
8405 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8406 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8407 TEST_CASE_ST(ut_setup, ut_teardown,
8408 test_AES_chain_scheduler_all),
8409 TEST_CASE_ST(ut_setup, ut_teardown,
8410 test_AES_cipheronly_scheduler_all),
8411 TEST_CASE_ST(ut_setup, ut_teardown,
8412 test_authonly_scheduler_all),
8413 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8414 TEST_CASES_END() /**< NULL terminate unit test array */
8418 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8420 static struct unit_test_suite cryptodev_qat_testsuite = {
8421 .suite_name = "Crypto QAT Unit Test Suite",
8422 .setup = testsuite_setup,
8423 .teardown = testsuite_teardown,
8424 .unit_test_cases = {
8425 TEST_CASE_ST(ut_setup, ut_teardown,
8426 test_device_configure_invalid_dev_id),
8427 TEST_CASE_ST(ut_setup, ut_teardown,
8428 test_device_configure_invalid_queue_pair_ids),
8429 TEST_CASE_ST(ut_setup, ut_teardown,
8430 test_queue_pair_descriptor_setup),
8431 TEST_CASE_ST(ut_setup, ut_teardown,
8432 test_multi_session),
8434 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8435 TEST_CASE_ST(ut_setup, ut_teardown,
8436 test_AES_cipheronly_qat_all),
8437 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8438 TEST_CASE_ST(ut_setup, ut_teardown,
8439 test_3DES_cipheronly_qat_all),
8440 TEST_CASE_ST(ut_setup, ut_teardown,
8441 test_DES_cipheronly_qat_all),
8442 TEST_CASE_ST(ut_setup, ut_teardown,
8443 test_AES_docsis_qat_all),
8444 TEST_CASE_ST(ut_setup, ut_teardown,
8445 test_DES_docsis_qat_all),
8446 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8447 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8449 /** AES CCM Authenticated Encryption 128 bits key */
8450 TEST_CASE_ST(ut_setup, ut_teardown,
8451 test_AES_CCM_authenticated_encryption_test_case_128_1),
8452 TEST_CASE_ST(ut_setup, ut_teardown,
8453 test_AES_CCM_authenticated_encryption_test_case_128_2),
8454 TEST_CASE_ST(ut_setup, ut_teardown,
8455 test_AES_CCM_authenticated_encryption_test_case_128_3),
8457 /** AES CCM Authenticated Decryption 128 bits key*/
8458 TEST_CASE_ST(ut_setup, ut_teardown,
8459 test_AES_CCM_authenticated_decryption_test_case_128_1),
8460 TEST_CASE_ST(ut_setup, ut_teardown,
8461 test_AES_CCM_authenticated_decryption_test_case_128_2),
8462 TEST_CASE_ST(ut_setup, ut_teardown,
8463 test_AES_CCM_authenticated_decryption_test_case_128_3),
8465 /** AES GCM Authenticated Encryption */
8466 TEST_CASE_ST(ut_setup, ut_teardown,
8467 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8468 TEST_CASE_ST(ut_setup, ut_teardown,
8469 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8470 TEST_CASE_ST(ut_setup, ut_teardown,
8471 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8472 TEST_CASE_ST(ut_setup, ut_teardown,
8473 test_AES_GCM_authenticated_encryption_test_case_1),
8474 TEST_CASE_ST(ut_setup, ut_teardown,
8475 test_AES_GCM_authenticated_encryption_test_case_2),
8476 TEST_CASE_ST(ut_setup, ut_teardown,
8477 test_AES_GCM_authenticated_encryption_test_case_3),
8478 TEST_CASE_ST(ut_setup, ut_teardown,
8479 test_AES_GCM_authenticated_encryption_test_case_4),
8480 TEST_CASE_ST(ut_setup, ut_teardown,
8481 test_AES_GCM_authenticated_encryption_test_case_5),
8482 TEST_CASE_ST(ut_setup, ut_teardown,
8483 test_AES_GCM_authenticated_encryption_test_case_6),
8484 TEST_CASE_ST(ut_setup, ut_teardown,
8485 test_AES_GCM_authenticated_encryption_test_case_7),
8487 /** AES GCM Authenticated Decryption */
8488 TEST_CASE_ST(ut_setup, ut_teardown,
8489 test_AES_GCM_authenticated_decryption_test_case_1),
8490 TEST_CASE_ST(ut_setup, ut_teardown,
8491 test_AES_GCM_authenticated_decryption_test_case_2),
8492 TEST_CASE_ST(ut_setup, ut_teardown,
8493 test_AES_GCM_authenticated_decryption_test_case_3),
8494 TEST_CASE_ST(ut_setup, ut_teardown,
8495 test_AES_GCM_authenticated_decryption_test_case_4),
8496 TEST_CASE_ST(ut_setup, ut_teardown,
8497 test_AES_GCM_authenticated_decryption_test_case_5),
8498 TEST_CASE_ST(ut_setup, ut_teardown,
8499 test_AES_GCM_authenticated_decryption_test_case_6),
8500 TEST_CASE_ST(ut_setup, ut_teardown,
8501 test_AES_GCM_authenticated_decryption_test_case_7),
8503 /** AES GCM Authenticated Encryption 192 bits key */
8504 TEST_CASE_ST(ut_setup, ut_teardown,
8505 test_AES_GCM_auth_encryption_test_case_192_1),
8506 TEST_CASE_ST(ut_setup, ut_teardown,
8507 test_AES_GCM_auth_encryption_test_case_192_2),
8508 TEST_CASE_ST(ut_setup, ut_teardown,
8509 test_AES_GCM_auth_encryption_test_case_192_3),
8510 TEST_CASE_ST(ut_setup, ut_teardown,
8511 test_AES_GCM_auth_encryption_test_case_192_4),
8512 TEST_CASE_ST(ut_setup, ut_teardown,
8513 test_AES_GCM_auth_encryption_test_case_192_5),
8514 TEST_CASE_ST(ut_setup, ut_teardown,
8515 test_AES_GCM_auth_encryption_test_case_192_6),
8516 TEST_CASE_ST(ut_setup, ut_teardown,
8517 test_AES_GCM_auth_encryption_test_case_192_7),
8519 /** AES GCM Authenticated Decryption 192 bits key */
8520 TEST_CASE_ST(ut_setup, ut_teardown,
8521 test_AES_GCM_auth_decryption_test_case_192_1),
8522 TEST_CASE_ST(ut_setup, ut_teardown,
8523 test_AES_GCM_auth_decryption_test_case_192_2),
8524 TEST_CASE_ST(ut_setup, ut_teardown,
8525 test_AES_GCM_auth_decryption_test_case_192_3),
8526 TEST_CASE_ST(ut_setup, ut_teardown,
8527 test_AES_GCM_auth_decryption_test_case_192_4),
8528 TEST_CASE_ST(ut_setup, ut_teardown,
8529 test_AES_GCM_auth_decryption_test_case_192_5),
8530 TEST_CASE_ST(ut_setup, ut_teardown,
8531 test_AES_GCM_auth_decryption_test_case_192_6),
8532 TEST_CASE_ST(ut_setup, ut_teardown,
8533 test_AES_GCM_auth_decryption_test_case_192_7),
8535 /** AES GCM Authenticated Encryption 256 bits key */
8536 TEST_CASE_ST(ut_setup, ut_teardown,
8537 test_AES_GCM_auth_encryption_test_case_256_1),
8538 TEST_CASE_ST(ut_setup, ut_teardown,
8539 test_AES_GCM_auth_encryption_test_case_256_2),
8540 TEST_CASE_ST(ut_setup, ut_teardown,
8541 test_AES_GCM_auth_encryption_test_case_256_3),
8542 TEST_CASE_ST(ut_setup, ut_teardown,
8543 test_AES_GCM_auth_encryption_test_case_256_4),
8544 TEST_CASE_ST(ut_setup, ut_teardown,
8545 test_AES_GCM_auth_encryption_test_case_256_5),
8546 TEST_CASE_ST(ut_setup, ut_teardown,
8547 test_AES_GCM_auth_encryption_test_case_256_6),
8548 TEST_CASE_ST(ut_setup, ut_teardown,
8549 test_AES_GCM_auth_encryption_test_case_256_7),
8551 /** AES GMAC Authentication */
8552 TEST_CASE_ST(ut_setup, ut_teardown,
8553 test_AES_GMAC_authentication_test_case_1),
8554 TEST_CASE_ST(ut_setup, ut_teardown,
8555 test_AES_GMAC_authentication_verify_test_case_1),
8556 TEST_CASE_ST(ut_setup, ut_teardown,
8557 test_AES_GMAC_authentication_test_case_2),
8558 TEST_CASE_ST(ut_setup, ut_teardown,
8559 test_AES_GMAC_authentication_verify_test_case_2),
8560 TEST_CASE_ST(ut_setup, ut_teardown,
8561 test_AES_GMAC_authentication_test_case_3),
8562 TEST_CASE_ST(ut_setup, ut_teardown,
8563 test_AES_GMAC_authentication_verify_test_case_3),
8565 /** SNOW 3G encrypt only (UEA2) */
8566 TEST_CASE_ST(ut_setup, ut_teardown,
8567 test_snow3g_encryption_test_case_1),
8568 TEST_CASE_ST(ut_setup, ut_teardown,
8569 test_snow3g_encryption_test_case_2),
8570 TEST_CASE_ST(ut_setup, ut_teardown,
8571 test_snow3g_encryption_test_case_3),
8572 TEST_CASE_ST(ut_setup, ut_teardown,
8573 test_snow3g_encryption_test_case_4),
8574 TEST_CASE_ST(ut_setup, ut_teardown,
8575 test_snow3g_encryption_test_case_5),
8577 TEST_CASE_ST(ut_setup, ut_teardown,
8578 test_snow3g_encryption_test_case_1_oop),
8579 TEST_CASE_ST(ut_setup, ut_teardown,
8580 test_snow3g_decryption_test_case_1_oop),
8582 /** SNOW 3G decrypt only (UEA2) */
8583 TEST_CASE_ST(ut_setup, ut_teardown,
8584 test_snow3g_decryption_test_case_1),
8585 TEST_CASE_ST(ut_setup, ut_teardown,
8586 test_snow3g_decryption_test_case_2),
8587 TEST_CASE_ST(ut_setup, ut_teardown,
8588 test_snow3g_decryption_test_case_3),
8589 TEST_CASE_ST(ut_setup, ut_teardown,
8590 test_snow3g_decryption_test_case_4),
8591 TEST_CASE_ST(ut_setup, ut_teardown,
8592 test_snow3g_decryption_test_case_5),
8593 TEST_CASE_ST(ut_setup, ut_teardown,
8594 test_snow3g_hash_generate_test_case_1),
8595 TEST_CASE_ST(ut_setup, ut_teardown,
8596 test_snow3g_hash_generate_test_case_2),
8597 TEST_CASE_ST(ut_setup, ut_teardown,
8598 test_snow3g_hash_generate_test_case_3),
8599 TEST_CASE_ST(ut_setup, ut_teardown,
8600 test_snow3g_hash_verify_test_case_1),
8601 TEST_CASE_ST(ut_setup, ut_teardown,
8602 test_snow3g_hash_verify_test_case_2),
8603 TEST_CASE_ST(ut_setup, ut_teardown,
8604 test_snow3g_hash_verify_test_case_3),
8605 TEST_CASE_ST(ut_setup, ut_teardown,
8606 test_snow3g_cipher_auth_test_case_1),
8607 TEST_CASE_ST(ut_setup, ut_teardown,
8608 test_snow3g_auth_cipher_test_case_1),
8610 /** ZUC encrypt only (EEA3) */
8611 TEST_CASE_ST(ut_setup, ut_teardown,
8612 test_zuc_encryption_test_case_1),
8613 TEST_CASE_ST(ut_setup, ut_teardown,
8614 test_zuc_encryption_test_case_2),
8615 TEST_CASE_ST(ut_setup, ut_teardown,
8616 test_zuc_encryption_test_case_3),
8617 TEST_CASE_ST(ut_setup, ut_teardown,
8618 test_zuc_encryption_test_case_4),
8619 TEST_CASE_ST(ut_setup, ut_teardown,
8620 test_zuc_encryption_test_case_5),
8622 /** ZUC authenticate (EIA3) */
8623 TEST_CASE_ST(ut_setup, ut_teardown,
8624 test_zuc_hash_generate_test_case_6),
8625 TEST_CASE_ST(ut_setup, ut_teardown,
8626 test_zuc_hash_generate_test_case_7),
8627 TEST_CASE_ST(ut_setup, ut_teardown,
8628 test_zuc_hash_generate_test_case_8),
8630 /** ZUC alg-chain (EEA3/EIA3) */
8631 TEST_CASE_ST(ut_setup, ut_teardown,
8632 test_zuc_cipher_auth_test_case_1),
8633 TEST_CASE_ST(ut_setup, ut_teardown,
8634 test_zuc_cipher_auth_test_case_2),
8636 /** HMAC_MD5 Authentication */
8637 TEST_CASE_ST(ut_setup, ut_teardown,
8638 test_MD5_HMAC_generate_case_1),
8639 TEST_CASE_ST(ut_setup, ut_teardown,
8640 test_MD5_HMAC_verify_case_1),
8641 TEST_CASE_ST(ut_setup, ut_teardown,
8642 test_MD5_HMAC_generate_case_2),
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_MD5_HMAC_verify_case_2),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_null_auth_only_operation),
8649 TEST_CASE_ST(ut_setup, ut_teardown,
8650 test_null_cipher_only_operation),
8651 TEST_CASE_ST(ut_setup, ut_teardown,
8652 test_null_cipher_auth_operation),
8653 TEST_CASE_ST(ut_setup, ut_teardown,
8654 test_null_auth_cipher_operation),
8657 TEST_CASE_ST(ut_setup, ut_teardown,
8658 test_kasumi_hash_generate_test_case_1),
8659 TEST_CASE_ST(ut_setup, ut_teardown,
8660 test_kasumi_hash_generate_test_case_2),
8661 TEST_CASE_ST(ut_setup, ut_teardown,
8662 test_kasumi_hash_generate_test_case_3),
8663 TEST_CASE_ST(ut_setup, ut_teardown,
8664 test_kasumi_hash_generate_test_case_4),
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_kasumi_hash_generate_test_case_5),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_kasumi_hash_generate_test_case_6),
8670 TEST_CASE_ST(ut_setup, ut_teardown,
8671 test_kasumi_hash_verify_test_case_1),
8672 TEST_CASE_ST(ut_setup, ut_teardown,
8673 test_kasumi_hash_verify_test_case_2),
8674 TEST_CASE_ST(ut_setup, ut_teardown,
8675 test_kasumi_hash_verify_test_case_3),
8676 TEST_CASE_ST(ut_setup, ut_teardown,
8677 test_kasumi_hash_verify_test_case_4),
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_kasumi_hash_verify_test_case_5),
8681 TEST_CASE_ST(ut_setup, ut_teardown,
8682 test_kasumi_encryption_test_case_1),
8683 TEST_CASE_ST(ut_setup, ut_teardown,
8684 test_kasumi_encryption_test_case_3),
8685 TEST_CASE_ST(ut_setup, ut_teardown,
8686 test_kasumi_auth_cipher_test_case_1),
8687 TEST_CASE_ST(ut_setup, ut_teardown,
8688 test_kasumi_cipher_auth_test_case_1),
8690 /** Negative tests */
8691 TEST_CASE_ST(ut_setup, ut_teardown,
8692 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 authentication_verify_AES128_GMAC_fail_data_corrupt),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8704 TEST_CASES_END() /**< NULL terminate unit test array */
8708 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8709 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8710 .setup = testsuite_setup,
8711 .teardown = testsuite_teardown,
8712 .unit_test_cases = {
8713 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8714 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8715 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8716 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8717 TEST_CASE_ST(ut_setup, ut_teardown,
8718 test_DES_cipheronly_mb_all),
8719 TEST_CASE_ST(ut_setup, ut_teardown,
8720 test_DES_docsis_mb_all),
8722 TEST_CASES_END() /**< NULL terminate unit test array */
8726 static struct unit_test_suite cryptodev_openssl_testsuite = {
8727 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8728 .setup = testsuite_setup,
8729 .teardown = testsuite_teardown,
8730 .unit_test_cases = {
8731 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8732 TEST_CASE_ST(ut_setup, ut_teardown,
8733 test_multi_session_random_usage),
8734 TEST_CASE_ST(ut_setup, ut_teardown,
8735 test_AES_chain_openssl_all),
8736 TEST_CASE_ST(ut_setup, ut_teardown,
8737 test_AES_cipheronly_openssl_all),
8738 TEST_CASE_ST(ut_setup, ut_teardown,
8739 test_3DES_chain_openssl_all),
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_3DES_cipheronly_openssl_all),
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_DES_cipheronly_openssl_all),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_DES_docsis_openssl_all),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_authonly_openssl_all),
8749 /** AES GCM Authenticated Encryption */
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_AES_GCM_authenticated_encryption_test_case_1),
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_AES_GCM_authenticated_encryption_test_case_2),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_AES_GCM_authenticated_encryption_test_case_3),
8756 TEST_CASE_ST(ut_setup, ut_teardown,
8757 test_AES_GCM_authenticated_encryption_test_case_4),
8758 TEST_CASE_ST(ut_setup, ut_teardown,
8759 test_AES_GCM_authenticated_encryption_test_case_5),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_AES_GCM_authenticated_encryption_test_case_6),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_GCM_authenticated_encryption_test_case_7),
8765 /** AES GCM Authenticated Decryption */
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_AES_GCM_authenticated_decryption_test_case_1),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_AES_GCM_authenticated_decryption_test_case_2),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_GCM_authenticated_decryption_test_case_3),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_AES_GCM_authenticated_decryption_test_case_4),
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_AES_GCM_authenticated_decryption_test_case_5),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_AES_GCM_authenticated_decryption_test_case_6),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_authenticated_decryption_test_case_7),
8782 /** AES GCM Authenticated Encryption 192 bits key */
8783 TEST_CASE_ST(ut_setup, ut_teardown,
8784 test_AES_GCM_auth_encryption_test_case_192_1),
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_AES_GCM_auth_encryption_test_case_192_2),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_AES_GCM_auth_encryption_test_case_192_3),
8789 TEST_CASE_ST(ut_setup, ut_teardown,
8790 test_AES_GCM_auth_encryption_test_case_192_4),
8791 TEST_CASE_ST(ut_setup, ut_teardown,
8792 test_AES_GCM_auth_encryption_test_case_192_5),
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_AES_GCM_auth_encryption_test_case_192_6),
8795 TEST_CASE_ST(ut_setup, ut_teardown,
8796 test_AES_GCM_auth_encryption_test_case_192_7),
8798 /** AES GCM Authenticated Decryption 192 bits key */
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_AES_GCM_auth_decryption_test_case_192_1),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_AES_GCM_auth_decryption_test_case_192_2),
8803 TEST_CASE_ST(ut_setup, ut_teardown,
8804 test_AES_GCM_auth_decryption_test_case_192_3),
8805 TEST_CASE_ST(ut_setup, ut_teardown,
8806 test_AES_GCM_auth_decryption_test_case_192_4),
8807 TEST_CASE_ST(ut_setup, ut_teardown,
8808 test_AES_GCM_auth_decryption_test_case_192_5),
8809 TEST_CASE_ST(ut_setup, ut_teardown,
8810 test_AES_GCM_auth_decryption_test_case_192_6),
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_AES_GCM_auth_decryption_test_case_192_7),
8814 /** AES GCM Authenticated Encryption 256 bits key */
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_AES_GCM_auth_encryption_test_case_256_1),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_AES_GCM_auth_encryption_test_case_256_2),
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_AES_GCM_auth_encryption_test_case_256_3),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_AES_GCM_auth_encryption_test_case_256_4),
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_AES_GCM_auth_encryption_test_case_256_5),
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_AES_GCM_auth_encryption_test_case_256_6),
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_AES_GCM_auth_encryption_test_case_256_7),
8830 /** AES GCM Authenticated Decryption 256 bits key */
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_AES_GCM_auth_decryption_test_case_256_1),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_AES_GCM_auth_decryption_test_case_256_2),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_AES_GCM_auth_decryption_test_case_256_3),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_AES_GCM_auth_decryption_test_case_256_4),
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_AES_GCM_auth_decryption_test_case_256_5),
8841 TEST_CASE_ST(ut_setup, ut_teardown,
8842 test_AES_GCM_auth_decryption_test_case_256_6),
8843 TEST_CASE_ST(ut_setup, ut_teardown,
8844 test_AES_GCM_auth_decryption_test_case_256_7),
8846 /** AES GMAC Authentication */
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_AES_GMAC_authentication_test_case_1),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_AES_GMAC_authentication_verify_test_case_1),
8851 TEST_CASE_ST(ut_setup, ut_teardown,
8852 test_AES_GMAC_authentication_test_case_2),
8853 TEST_CASE_ST(ut_setup, ut_teardown,
8854 test_AES_GMAC_authentication_verify_test_case_2),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_AES_GMAC_authentication_test_case_3),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_AES_GMAC_authentication_verify_test_case_3),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_AES_GMAC_authentication_test_case_4),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_AES_GMAC_authentication_verify_test_case_4),
8864 /** AES CCM Authenticated Encryption 128 bits key */
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_AES_CCM_authenticated_encryption_test_case_128_1),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_AES_CCM_authenticated_encryption_test_case_128_2),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_AES_CCM_authenticated_encryption_test_case_128_3),
8872 /** AES CCM Authenticated Decryption 128 bits key*/
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_AES_CCM_authenticated_decryption_test_case_128_1),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_AES_CCM_authenticated_decryption_test_case_128_2),
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_AES_CCM_authenticated_decryption_test_case_128_3),
8880 /** AES CCM Authenticated Encryption 192 bits key */
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_AES_CCM_authenticated_encryption_test_case_192_1),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_AES_CCM_authenticated_encryption_test_case_192_2),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_AES_CCM_authenticated_encryption_test_case_192_3),
8888 /** AES CCM Authenticated Decryption 192 bits key*/
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_AES_CCM_authenticated_decryption_test_case_192_1),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_AES_CCM_authenticated_decryption_test_case_192_2),
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_AES_CCM_authenticated_decryption_test_case_192_3),
8896 /** AES CCM Authenticated Encryption 256 bits key */
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_AES_CCM_authenticated_encryption_test_case_256_1),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_AES_CCM_authenticated_encryption_test_case_256_2),
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_CCM_authenticated_encryption_test_case_256_3),
8904 /** AES CCM Authenticated Decryption 256 bits key*/
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_AES_CCM_authenticated_decryption_test_case_256_1),
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_AES_CCM_authenticated_decryption_test_case_256_2),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_AES_CCM_authenticated_decryption_test_case_256_3),
8912 /** Scatter-Gather */
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
8916 /** Negative tests */
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 authentication_verify_AES128_GMAC_fail_data_corrupt),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8930 TEST_CASES_END() /**< NULL terminate unit test array */
8934 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
8935 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
8936 .setup = testsuite_setup,
8937 .teardown = testsuite_teardown,
8938 .unit_test_cases = {
8939 /** AES GCM Authenticated Encryption */
8940 TEST_CASE_ST(ut_setup, ut_teardown,
8941 test_AES_GCM_authenticated_encryption_test_case_1),
8942 TEST_CASE_ST(ut_setup, ut_teardown,
8943 test_AES_GCM_authenticated_encryption_test_case_2),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_AES_GCM_authenticated_encryption_test_case_3),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_AES_GCM_authenticated_encryption_test_case_4),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_AES_GCM_authenticated_encryption_test_case_5),
8950 TEST_CASE_ST(ut_setup, ut_teardown,
8951 test_AES_GCM_authenticated_encryption_test_case_6),
8952 TEST_CASE_ST(ut_setup, ut_teardown,
8953 test_AES_GCM_authenticated_encryption_test_case_7),
8955 /** AES GCM Authenticated Decryption */
8956 TEST_CASE_ST(ut_setup, ut_teardown,
8957 test_AES_GCM_authenticated_decryption_test_case_1),
8958 TEST_CASE_ST(ut_setup, ut_teardown,
8959 test_AES_GCM_authenticated_decryption_test_case_2),
8960 TEST_CASE_ST(ut_setup, ut_teardown,
8961 test_AES_GCM_authenticated_decryption_test_case_3),
8962 TEST_CASE_ST(ut_setup, ut_teardown,
8963 test_AES_GCM_authenticated_decryption_test_case_4),
8964 TEST_CASE_ST(ut_setup, ut_teardown,
8965 test_AES_GCM_authenticated_decryption_test_case_5),
8966 TEST_CASE_ST(ut_setup, ut_teardown,
8967 test_AES_GCM_authenticated_decryption_test_case_6),
8968 TEST_CASE_ST(ut_setup, ut_teardown,
8969 test_AES_GCM_authenticated_decryption_test_case_7),
8971 /** AES GCM Authenticated Encryption 192 bits key */
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_AES_GCM_auth_encryption_test_case_192_1),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_AES_GCM_auth_encryption_test_case_192_2),
8976 TEST_CASE_ST(ut_setup, ut_teardown,
8977 test_AES_GCM_auth_encryption_test_case_192_3),
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_AES_GCM_auth_encryption_test_case_192_4),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_AES_GCM_auth_encryption_test_case_192_5),
8982 TEST_CASE_ST(ut_setup, ut_teardown,
8983 test_AES_GCM_auth_encryption_test_case_192_6),
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 test_AES_GCM_auth_encryption_test_case_192_7),
8987 /** AES GCM Authenticated Decryption 192 bits key */
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 test_AES_GCM_auth_decryption_test_case_192_1),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_GCM_auth_decryption_test_case_192_2),
8992 TEST_CASE_ST(ut_setup, ut_teardown,
8993 test_AES_GCM_auth_decryption_test_case_192_3),
8994 TEST_CASE_ST(ut_setup, ut_teardown,
8995 test_AES_GCM_auth_decryption_test_case_192_4),
8996 TEST_CASE_ST(ut_setup, ut_teardown,
8997 test_AES_GCM_auth_decryption_test_case_192_5),
8998 TEST_CASE_ST(ut_setup, ut_teardown,
8999 test_AES_GCM_auth_decryption_test_case_192_6),
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_AES_GCM_auth_decryption_test_case_192_7),
9003 /** AES GCM Authenticated Encryption 256 bits key */
9004 TEST_CASE_ST(ut_setup, ut_teardown,
9005 test_AES_GCM_auth_encryption_test_case_256_1),
9006 TEST_CASE_ST(ut_setup, ut_teardown,
9007 test_AES_GCM_auth_encryption_test_case_256_2),
9008 TEST_CASE_ST(ut_setup, ut_teardown,
9009 test_AES_GCM_auth_encryption_test_case_256_3),
9010 TEST_CASE_ST(ut_setup, ut_teardown,
9011 test_AES_GCM_auth_encryption_test_case_256_4),
9012 TEST_CASE_ST(ut_setup, ut_teardown,
9013 test_AES_GCM_auth_encryption_test_case_256_5),
9014 TEST_CASE_ST(ut_setup, ut_teardown,
9015 test_AES_GCM_auth_encryption_test_case_256_6),
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_AES_GCM_auth_encryption_test_case_256_7),
9019 /** AES GCM Authenticated Decryption 256 bits key */
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_GCM_auth_decryption_test_case_256_1),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_GCM_auth_decryption_test_case_256_2),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_GCM_auth_decryption_test_case_256_3),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_GCM_auth_decryption_test_case_256_4),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_GCM_auth_decryption_test_case_256_5),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_GCM_auth_decryption_test_case_256_6),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_GCM_auth_decryption_test_case_256_7),
9035 /** AES GCM Authenticated Encryption big aad size */
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_AES_GCM_auth_encryption_test_case_aad_1),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_AES_GCM_auth_encryption_test_case_aad_2),
9041 /** AES GCM Authenticated Decryption big aad size */
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_AES_GCM_auth_decryption_test_case_aad_1),
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_auth_decryption_test_case_aad_2),
9047 /** AES GMAC Authentication */
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GMAC_authentication_test_case_1),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GMAC_authentication_verify_test_case_1),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GMAC_authentication_test_case_3),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GMAC_authentication_verify_test_case_3),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GMAC_authentication_test_case_4),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GMAC_authentication_verify_test_case_4),
9061 /** Negative tests */
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 authentication_verify_AES128_GMAC_fail_data_corrupt),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9067 /** Out of place tests */
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9073 /** Session-less tests */
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9076 TEST_CASE_ST(ut_setup, ut_teardown,
9077 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9079 /** Scatter-Gather */
9080 TEST_CASE_ST(ut_setup, ut_teardown,
9081 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9083 TEST_CASES_END() /**< NULL terminate unit test array */
9087 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9088 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9089 .setup = testsuite_setup,
9090 .teardown = testsuite_teardown,
9091 .unit_test_cases = {
9092 /** KASUMI encrypt only (UEA1) */
9093 TEST_CASE_ST(ut_setup, ut_teardown,
9094 test_kasumi_encryption_test_case_1),
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_kasumi_encryption_test_case_1_sgl),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_kasumi_encryption_test_case_2),
9099 TEST_CASE_ST(ut_setup, ut_teardown,
9100 test_kasumi_encryption_test_case_3),
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_kasumi_encryption_test_case_4),
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 test_kasumi_encryption_test_case_5),
9105 /** KASUMI decrypt only (UEA1) */
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_kasumi_decryption_test_case_1),
9108 TEST_CASE_ST(ut_setup, ut_teardown,
9109 test_kasumi_decryption_test_case_2),
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_kasumi_decryption_test_case_3),
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_kasumi_decryption_test_case_4),
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_kasumi_decryption_test_case_5),
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_kasumi_encryption_test_case_1_oop),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_kasumi_encryption_test_case_1_oop_sgl),
9123 TEST_CASE_ST(ut_setup, ut_teardown,
9124 test_kasumi_decryption_test_case_1_oop),
9126 /** KASUMI hash only (UIA1) */
9127 TEST_CASE_ST(ut_setup, ut_teardown,
9128 test_kasumi_hash_generate_test_case_1),
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_kasumi_hash_generate_test_case_2),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_kasumi_hash_generate_test_case_3),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_kasumi_hash_generate_test_case_4),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_kasumi_hash_generate_test_case_5),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_kasumi_hash_generate_test_case_6),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 test_kasumi_hash_verify_test_case_1),
9141 TEST_CASE_ST(ut_setup, ut_teardown,
9142 test_kasumi_hash_verify_test_case_2),
9143 TEST_CASE_ST(ut_setup, ut_teardown,
9144 test_kasumi_hash_verify_test_case_3),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_kasumi_hash_verify_test_case_4),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_kasumi_hash_verify_test_case_5),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_kasumi_auth_cipher_test_case_1),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_kasumi_cipher_auth_test_case_1),
9153 TEST_CASES_END() /**< NULL terminate unit test array */
9156 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9157 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9158 .setup = testsuite_setup,
9159 .teardown = testsuite_teardown,
9160 .unit_test_cases = {
9161 /** SNOW 3G encrypt only (UEA2) */
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_snow3g_encryption_test_case_1),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_snow3g_encryption_test_case_2),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_snow3g_encryption_test_case_3),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_snow3g_encryption_test_case_4),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_snow3g_encryption_test_case_5),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_snow3g_encryption_test_case_1_oop),
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_snow3g_encryption_test_case_1_oop_sgl),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_snow3g_decryption_test_case_1_oop),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_snow3g_encryption_test_case_1_offset_oop),
9183 /** SNOW 3G decrypt only (UEA2) */
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_snow3g_decryption_test_case_1),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_snow3g_decryption_test_case_2),
9188 TEST_CASE_ST(ut_setup, ut_teardown,
9189 test_snow3g_decryption_test_case_3),
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_snow3g_decryption_test_case_4),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_snow3g_decryption_test_case_5),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_snow3g_hash_generate_test_case_1),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_snow3g_hash_generate_test_case_2),
9198 TEST_CASE_ST(ut_setup, ut_teardown,
9199 test_snow3g_hash_generate_test_case_3),
9200 /* Tests with buffers which length is not byte-aligned */
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_snow3g_hash_generate_test_case_4),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_snow3g_hash_generate_test_case_5),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_snow3g_hash_generate_test_case_6),
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_snow3g_hash_verify_test_case_1),
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_snow3g_hash_verify_test_case_2),
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 test_snow3g_hash_verify_test_case_3),
9213 /* Tests with buffers which length is not byte-aligned */
9214 TEST_CASE_ST(ut_setup, ut_teardown,
9215 test_snow3g_hash_verify_test_case_4),
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_snow3g_hash_verify_test_case_5),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_snow3g_hash_verify_test_case_6),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_snow3g_cipher_auth_test_case_1),
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_snow3g_auth_cipher_test_case_1),
9225 TEST_CASES_END() /**< NULL terminate unit test array */
9229 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9230 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9231 .setup = testsuite_setup,
9232 .teardown = testsuite_teardown,
9233 .unit_test_cases = {
9234 /** ZUC encrypt only (EEA3) */
9235 TEST_CASE_ST(ut_setup, ut_teardown,
9236 test_zuc_encryption_test_case_1),
9237 TEST_CASE_ST(ut_setup, ut_teardown,
9238 test_zuc_encryption_test_case_2),
9239 TEST_CASE_ST(ut_setup, ut_teardown,
9240 test_zuc_encryption_test_case_3),
9241 TEST_CASE_ST(ut_setup, ut_teardown,
9242 test_zuc_encryption_test_case_4),
9243 TEST_CASE_ST(ut_setup, ut_teardown,
9244 test_zuc_encryption_test_case_5),
9245 TEST_CASE_ST(ut_setup, ut_teardown,
9246 test_zuc_hash_generate_test_case_1),
9247 TEST_CASE_ST(ut_setup, ut_teardown,
9248 test_zuc_hash_generate_test_case_2),
9249 TEST_CASE_ST(ut_setup, ut_teardown,
9250 test_zuc_hash_generate_test_case_3),
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_zuc_hash_generate_test_case_4),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_zuc_hash_generate_test_case_5),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_zuc_encryption_test_case_6_sgl),
9257 TEST_CASES_END() /**< NULL terminate unit test array */
9261 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9262 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9263 .setup = testsuite_setup,
9264 .teardown = testsuite_teardown,
9265 .unit_test_cases = {
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_device_configure_invalid_dev_id),
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_multi_session),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_AES_chain_dpaa_sec_all),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_3DES_chain_dpaa_sec_all),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_cipheronly_dpaa_sec_all),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_3DES_cipheronly_dpaa_sec_all),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_authonly_dpaa_sec_all),
9282 /** AES GCM Authenticated Encryption */
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_AES_GCM_authenticated_encryption_test_case_1),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_AES_GCM_authenticated_encryption_test_case_2),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_GCM_authenticated_encryption_test_case_3),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_AES_GCM_authenticated_encryption_test_case_4),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_authenticated_encryption_test_case_5),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_AES_GCM_authenticated_encryption_test_case_6),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_AES_GCM_authenticated_encryption_test_case_7),
9298 /** AES GCM Authenticated Decryption */
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_GCM_authenticated_decryption_test_case_1),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_authenticated_decryption_test_case_2),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_GCM_authenticated_decryption_test_case_3),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_GCM_authenticated_decryption_test_case_4),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_AES_GCM_authenticated_decryption_test_case_5),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_AES_GCM_authenticated_decryption_test_case_6),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_authenticated_decryption_test_case_7),
9314 /** AES GCM Authenticated Encryption 256 bits key */
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_auth_encryption_test_case_256_1),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_auth_encryption_test_case_256_2),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_auth_encryption_test_case_256_3),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_auth_encryption_test_case_256_4),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_auth_encryption_test_case_256_5),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_AES_GCM_auth_encryption_test_case_256_6),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_auth_encryption_test_case_256_7),
9330 /** AES GCM Authenticated Decryption 256 bits key */
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_AES_GCM_auth_decryption_test_case_256_1),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_auth_decryption_test_case_256_2),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_auth_decryption_test_case_256_3),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_AES_GCM_auth_decryption_test_case_256_4),
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_auth_decryption_test_case_256_5),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_auth_decryption_test_case_256_6),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GCM_auth_decryption_test_case_256_7),
9346 /** Out of place tests */
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9352 TEST_CASES_END() /**< NULL terminate unit test array */
9356 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9357 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9358 .setup = testsuite_setup,
9359 .teardown = testsuite_teardown,
9360 .unit_test_cases = {
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_device_configure_invalid_dev_id),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_multi_session),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_chain_dpaa2_sec_all),
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_3DES_chain_dpaa2_sec_all),
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_cipheronly_dpaa2_sec_all),
9372 TEST_CASE_ST(ut_setup, ut_teardown,
9373 test_3DES_cipheronly_dpaa2_sec_all),
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_authonly_dpaa2_sec_all),
9377 /** AES GCM Authenticated Encryption */
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_AES_GCM_authenticated_encryption_test_case_1),
9380 TEST_CASE_ST(ut_setup, ut_teardown,
9381 test_AES_GCM_authenticated_encryption_test_case_2),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_AES_GCM_authenticated_encryption_test_case_3),
9384 TEST_CASE_ST(ut_setup, ut_teardown,
9385 test_AES_GCM_authenticated_encryption_test_case_4),
9386 TEST_CASE_ST(ut_setup, ut_teardown,
9387 test_AES_GCM_authenticated_encryption_test_case_5),
9388 TEST_CASE_ST(ut_setup, ut_teardown,
9389 test_AES_GCM_authenticated_encryption_test_case_6),
9390 TEST_CASE_ST(ut_setup, ut_teardown,
9391 test_AES_GCM_authenticated_encryption_test_case_7),
9393 /** AES GCM Authenticated Decryption */
9394 TEST_CASE_ST(ut_setup, ut_teardown,
9395 test_AES_GCM_authenticated_decryption_test_case_1),
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_AES_GCM_authenticated_decryption_test_case_2),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_AES_GCM_authenticated_decryption_test_case_3),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_AES_GCM_authenticated_decryption_test_case_4),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_AES_GCM_authenticated_decryption_test_case_5),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_AES_GCM_authenticated_decryption_test_case_6),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_AES_GCM_authenticated_decryption_test_case_7),
9409 /** AES GCM Authenticated Encryption 192 bits key */
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_AES_GCM_auth_encryption_test_case_192_1),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_AES_GCM_auth_encryption_test_case_192_2),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_AES_GCM_auth_encryption_test_case_192_3),
9416 TEST_CASE_ST(ut_setup, ut_teardown,
9417 test_AES_GCM_auth_encryption_test_case_192_4),
9418 TEST_CASE_ST(ut_setup, ut_teardown,
9419 test_AES_GCM_auth_encryption_test_case_192_5),
9420 TEST_CASE_ST(ut_setup, ut_teardown,
9421 test_AES_GCM_auth_encryption_test_case_192_6),
9422 TEST_CASE_ST(ut_setup, ut_teardown,
9423 test_AES_GCM_auth_encryption_test_case_192_7),
9425 /** AES GCM Authenticated Decryption 192 bits key */
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_AES_GCM_auth_decryption_test_case_192_1),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_AES_GCM_auth_decryption_test_case_192_2),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_AES_GCM_auth_decryption_test_case_192_3),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_AES_GCM_auth_decryption_test_case_192_4),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_AES_GCM_auth_decryption_test_case_192_5),
9436 TEST_CASE_ST(ut_setup, ut_teardown,
9437 test_AES_GCM_auth_decryption_test_case_192_6),
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_AES_GCM_auth_decryption_test_case_192_7),
9441 /** AES GCM Authenticated Encryption 256 bits key */
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_AES_GCM_auth_encryption_test_case_256_1),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_AES_GCM_auth_encryption_test_case_256_2),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_AES_GCM_auth_encryption_test_case_256_3),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_AES_GCM_auth_encryption_test_case_256_4),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_AES_GCM_auth_encryption_test_case_256_5),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_AES_GCM_auth_encryption_test_case_256_6),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_AES_GCM_auth_encryption_test_case_256_7),
9457 /** AES GCM Authenticated Decryption 256 bits key */
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_AES_GCM_auth_decryption_test_case_256_1),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_AES_GCM_auth_decryption_test_case_256_2),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_AES_GCM_auth_decryption_test_case_256_3),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_AES_GCM_auth_decryption_test_case_256_4),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_AES_GCM_auth_decryption_test_case_256_5),
9468 TEST_CASE_ST(ut_setup, ut_teardown,
9469 test_AES_GCM_auth_decryption_test_case_256_6),
9470 TEST_CASE_ST(ut_setup, ut_teardown,
9471 test_AES_GCM_auth_decryption_test_case_256_7),
9473 /** Out of place tests */
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9479 TEST_CASES_END() /**< NULL terminate unit test array */
9483 static struct unit_test_suite cryptodev_null_testsuite = {
9484 .suite_name = "Crypto Device NULL Unit Test Suite",
9485 .setup = testsuite_setup,
9486 .teardown = testsuite_teardown,
9487 .unit_test_cases = {
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_null_auth_only_operation),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_null_cipher_only_operation),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_null_cipher_auth_operation),
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_null_auth_cipher_operation),
9496 TEST_CASE_ST(ut_setup, ut_teardown,
9497 test_null_invalid_operation),
9498 TEST_CASE_ST(ut_setup, ut_teardown,
9499 test_null_burst_operation),
9501 TEST_CASES_END() /**< NULL terminate unit test array */
9505 static struct unit_test_suite cryptodev_armv8_testsuite = {
9506 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9507 .setup = testsuite_setup,
9508 .teardown = testsuite_teardown,
9509 .unit_test_cases = {
9510 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9512 /** Negative tests */
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9518 TEST_CASES_END() /**< NULL terminate unit test array */
9522 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9523 .suite_name = "Crypto Device Marvell Component Test Suite",
9524 .setup = testsuite_setup,
9525 .teardown = testsuite_teardown,
9526 .unit_test_cases = {
9527 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9528 TEST_CASE_ST(ut_setup, ut_teardown,
9529 test_multi_session_random_usage),
9530 TEST_CASE_ST(ut_setup, ut_teardown,
9531 test_AES_chain_mrvl_all),
9532 TEST_CASE_ST(ut_setup, ut_teardown,
9533 test_AES_cipheronly_mrvl_all),
9534 TEST_CASE_ST(ut_setup, ut_teardown,
9535 test_authonly_mrvl_all),
9536 TEST_CASE_ST(ut_setup, ut_teardown,
9537 test_3DES_chain_mrvl_all),
9538 TEST_CASE_ST(ut_setup, ut_teardown,
9539 test_3DES_cipheronly_mrvl_all),
9541 /** Negative tests */
9542 TEST_CASE_ST(ut_setup, ut_teardown,
9543 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9544 TEST_CASE_ST(ut_setup, ut_teardown,
9545 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9546 TEST_CASE_ST(ut_setup, ut_teardown,
9547 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9551 TEST_CASES_END() /**< NULL terminate unit test array */
9557 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9559 gbl_driver_id = rte_cryptodev_driver_id_get(
9560 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9562 if (gbl_driver_id == -1) {
9563 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9564 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9565 "in config file to run this testsuite.\n");
9569 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9573 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9575 gbl_driver_id = rte_cryptodev_driver_id_get(
9576 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9578 if (gbl_driver_id == -1) {
9579 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9580 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9581 "in config file to run this testsuite.\n");
9585 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9589 test_cryptodev_openssl(void)
9591 gbl_driver_id = rte_cryptodev_driver_id_get(
9592 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9594 if (gbl_driver_id == -1) {
9595 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9596 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9597 "in config file to run this testsuite.\n");
9601 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9605 test_cryptodev_aesni_gcm(void)
9607 gbl_driver_id = rte_cryptodev_driver_id_get(
9608 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9610 if (gbl_driver_id == -1) {
9611 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9612 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9613 "in config file to run this testsuite.\n");
9617 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9621 test_cryptodev_null(void)
9623 gbl_driver_id = rte_cryptodev_driver_id_get(
9624 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9626 if (gbl_driver_id == -1) {
9627 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9628 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9629 "in config file to run this testsuite.\n");
9633 return unit_test_suite_runner(&cryptodev_null_testsuite);
9637 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9639 gbl_driver_id = rte_cryptodev_driver_id_get(
9640 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9642 if (gbl_driver_id == -1) {
9643 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9644 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9645 "in config file to run this testsuite.\n");
9649 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9653 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9655 gbl_driver_id = rte_cryptodev_driver_id_get(
9656 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9658 if (gbl_driver_id == -1) {
9659 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9660 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9661 "in config file to run this testsuite.\n");
9665 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9669 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9671 gbl_driver_id = rte_cryptodev_driver_id_get(
9672 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9674 if (gbl_driver_id == -1) {
9675 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9676 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9677 "in config file to run this testsuite.\n");
9681 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9685 test_cryptodev_armv8(void)
9687 gbl_driver_id = rte_cryptodev_driver_id_get(
9688 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9690 if (gbl_driver_id == -1) {
9691 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9692 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9693 "in config file to run this testsuite.\n");
9697 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9701 test_cryptodev_mrvl(void)
9703 gbl_driver_id = rte_cryptodev_driver_id_get(
9704 RTE_STR(CRYPTODEV_NAME_MRVL_PMD));
9706 if (gbl_driver_id == -1) {
9707 RTE_LOG(ERR, USER1, "MRVL PMD must be loaded. Check if "
9708 "CONFIG_RTE_LIBRTE_PMD_MRVL_CRYPTO is enabled "
9709 "in config file to run this testsuite.\n");
9713 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9716 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9719 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
9721 gbl_driver_id = rte_cryptodev_driver_id_get(
9722 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
9724 if (gbl_driver_id == -1) {
9725 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
9726 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
9727 "in config file to run this testsuite.\n");
9731 if (rte_cryptodev_driver_id_get(
9732 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
9733 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
9734 " enabled in config file to run this testsuite.\n");
9737 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
9740 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
9745 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9747 gbl_driver_id = rte_cryptodev_driver_id_get(
9748 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
9750 if (gbl_driver_id == -1) {
9751 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
9752 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
9753 "in config file to run this testsuite.\n");
9757 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
9761 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
9763 gbl_driver_id = rte_cryptodev_driver_id_get(
9764 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
9766 if (gbl_driver_id == -1) {
9767 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
9768 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
9769 "in config file to run this testsuite.\n");
9773 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
9776 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
9777 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
9778 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
9779 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
9780 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
9781 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
9782 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
9783 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
9784 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
9785 REGISTER_TEST_COMMAND(cryptodev_sw_mrvl_autotest, test_cryptodev_mrvl);
9786 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
9787 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);