1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2017 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
19 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
20 #include <rte_cryptodev_scheduler.h>
21 #include <rte_cryptodev_scheduler_operations.h>
25 #include "test_cryptodev.h"
27 #include "test_cryptodev_blockcipher.h"
28 #include "test_cryptodev_aes_test_vectors.h"
29 #include "test_cryptodev_des_test_vectors.h"
30 #include "test_cryptodev_hash_test_vectors.h"
31 #include "test_cryptodev_kasumi_test_vectors.h"
32 #include "test_cryptodev_kasumi_hash_test_vectors.h"
33 #include "test_cryptodev_snow3g_test_vectors.h"
34 #include "test_cryptodev_snow3g_hash_test_vectors.h"
35 #include "test_cryptodev_zuc_test_vectors.h"
36 #include "test_cryptodev_aead_test_vectors.h"
37 #include "test_cryptodev_hmac_test_vectors.h"
39 static int gbl_driver_id;
41 struct crypto_testsuite_params {
42 struct rte_mempool *mbuf_pool;
43 struct rte_mempool *large_mbuf_pool;
44 struct rte_mempool *op_mpool;
45 struct rte_mempool *session_mpool;
46 struct rte_cryptodev_config conf;
47 struct rte_cryptodev_qp_conf qp_conf;
49 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
50 uint8_t valid_dev_count;
53 struct crypto_unittest_params {
54 struct rte_crypto_sym_xform cipher_xform;
55 struct rte_crypto_sym_xform auth_xform;
56 struct rte_crypto_sym_xform aead_xform;
58 struct rte_cryptodev_sym_session *sess;
60 struct rte_crypto_op *op;
62 struct rte_mbuf *obuf, *ibuf;
67 #define ALIGN_POW2_ROUNDUP(num, align) \
68 (((num) + (align) - 1) & ~((align) - 1))
71 * Forward declarations.
74 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
75 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
79 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
80 struct crypto_unittest_params *ut_params,
81 struct crypto_testsuite_params *ts_param,
82 const uint8_t *cipher,
83 const uint8_t *digest,
86 static struct rte_mbuf *
87 setup_test_string(struct rte_mempool *mpool,
88 const char *string, size_t len, uint8_t blocksize)
90 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
91 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
93 memset(m->buf_addr, 0, m->buf_len);
95 char *dst = rte_pktmbuf_append(m, t_len);
102 rte_memcpy(dst, string, t_len);
104 memset(dst, 0, t_len);
110 /* Get number of bytes in X bits (rounding up) */
112 ceil_byte_length(uint32_t num_bits)
115 return ((num_bits >> 3) + 1);
117 return (num_bits >> 3);
120 static struct rte_crypto_op *
121 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
123 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
124 printf("Error sending packet for encryption");
130 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
136 static struct crypto_testsuite_params testsuite_params = { NULL };
137 static struct crypto_unittest_params unittest_params;
140 testsuite_setup(void)
142 struct crypto_testsuite_params *ts_params = &testsuite_params;
143 struct rte_cryptodev_info info;
144 uint32_t i = 0, nb_devs, dev_id;
148 memset(ts_params, 0, sizeof(*ts_params));
150 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
151 if (ts_params->mbuf_pool == NULL) {
152 /* Not already created so create */
153 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
155 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
157 if (ts_params->mbuf_pool == NULL) {
158 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
163 ts_params->large_mbuf_pool = rte_mempool_lookup(
164 "CRYPTO_LARGE_MBUFPOOL");
165 if (ts_params->large_mbuf_pool == NULL) {
166 /* Not already created so create */
167 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
168 "CRYPTO_LARGE_MBUFPOOL",
171 if (ts_params->large_mbuf_pool == NULL) {
173 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
178 ts_params->op_mpool = rte_crypto_op_pool_create(
179 "MBUF_CRYPTO_SYM_OP_POOL",
180 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
181 NUM_MBUFS, MBUF_CACHE_SIZE,
183 sizeof(struct rte_crypto_sym_xform) +
186 if (ts_params->op_mpool == NULL) {
187 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
191 /* Create an AESNI MB device if required */
192 if (gbl_driver_id == rte_cryptodev_driver_id_get(
193 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
194 nb_devs = rte_cryptodev_device_count_by_driver(
195 rte_cryptodev_driver_id_get(
196 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
199 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
201 TEST_ASSERT(ret == 0,
202 "Failed to create instance of"
204 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
208 /* Create an AESNI GCM device if required */
209 if (gbl_driver_id == rte_cryptodev_driver_id_get(
210 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
211 nb_devs = rte_cryptodev_device_count_by_driver(
212 rte_cryptodev_driver_id_get(
213 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
215 TEST_ASSERT_SUCCESS(rte_vdev_init(
216 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
217 "Failed to create instance of"
219 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
223 /* Create a SNOW 3G device if required */
224 if (gbl_driver_id == rte_cryptodev_driver_id_get(
225 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
226 nb_devs = rte_cryptodev_device_count_by_driver(
227 rte_cryptodev_driver_id_get(
228 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
230 TEST_ASSERT_SUCCESS(rte_vdev_init(
231 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
232 "Failed to create instance of"
234 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
238 /* Create a KASUMI device if required */
239 if (gbl_driver_id == rte_cryptodev_driver_id_get(
240 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
241 nb_devs = rte_cryptodev_device_count_by_driver(
242 rte_cryptodev_driver_id_get(
243 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
245 TEST_ASSERT_SUCCESS(rte_vdev_init(
246 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
247 "Failed to create instance of"
249 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
253 /* Create a ZUC device if required */
254 if (gbl_driver_id == rte_cryptodev_driver_id_get(
255 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
256 nb_devs = rte_cryptodev_device_count_by_driver(
257 rte_cryptodev_driver_id_get(
258 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
260 TEST_ASSERT_SUCCESS(rte_vdev_init(
261 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
262 "Failed to create instance of"
264 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
268 /* Create a NULL device if required */
269 if (gbl_driver_id == rte_cryptodev_driver_id_get(
270 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
271 nb_devs = rte_cryptodev_device_count_by_driver(
272 rte_cryptodev_driver_id_get(
273 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
276 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
278 TEST_ASSERT(ret == 0,
279 "Failed to create instance of"
281 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
285 /* Create an OPENSSL device if required */
286 if (gbl_driver_id == rte_cryptodev_driver_id_get(
287 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
288 nb_devs = rte_cryptodev_device_count_by_driver(
289 rte_cryptodev_driver_id_get(
290 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
293 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
296 TEST_ASSERT(ret == 0, "Failed to create "
297 "instance of pmd : %s",
298 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
302 /* Create a ARMv8 device if required */
303 if (gbl_driver_id == rte_cryptodev_driver_id_get(
304 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
305 nb_devs = rte_cryptodev_device_count_by_driver(
306 rte_cryptodev_driver_id_get(
307 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
310 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
313 TEST_ASSERT(ret == 0, "Failed to create "
314 "instance of pmd : %s",
315 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
319 /* Create a MVSAM device if required */
320 if (gbl_driver_id == rte_cryptodev_driver_id_get(
321 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
322 nb_devs = rte_cryptodev_device_count_by_driver(
323 rte_cryptodev_driver_id_get(
324 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
327 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
330 TEST_ASSERT(ret == 0, "Failed to create "
331 "instance of pmd : %s",
332 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
336 /* Create an CCP device if required */
337 if (gbl_driver_id == rte_cryptodev_driver_id_get(
338 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
339 nb_devs = rte_cryptodev_device_count_by_driver(
340 rte_cryptodev_driver_id_get(
341 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
344 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
347 TEST_ASSERT(ret == 0, "Failed to create "
348 "instance of pmd : %s",
349 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
353 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
354 if (gbl_driver_id == rte_cryptodev_driver_id_get(
355 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
357 nb_devs = rte_cryptodev_device_count_by_driver(
358 rte_cryptodev_driver_id_get(
359 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
362 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
365 TEST_ASSERT(ret == 0,
366 "Failed to create instance %u of"
368 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
371 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
373 nb_devs = rte_cryptodev_count();
375 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
379 /* Create list of valid crypto devs */
380 for (i = 0; i < nb_devs; i++) {
381 rte_cryptodev_info_get(i, &info);
382 if (info.driver_id == gbl_driver_id)
383 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
386 if (ts_params->valid_dev_count < 1)
389 /* Set up all the qps on the first of the valid devices found */
391 dev_id = ts_params->valid_devs[0];
393 rte_cryptodev_info_get(dev_id, &info);
395 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
396 ts_params->conf.socket_id = SOCKET_ID_ANY;
398 unsigned int session_size = rte_cryptodev_get_private_session_size(dev_id);
401 * Create mempool with maximum number of sessions * 2,
402 * to include the session headers
404 ts_params->session_mpool = rte_mempool_create(
406 info.sym.max_nb_sessions * 2,
408 0, 0, NULL, NULL, NULL,
412 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
413 "session mempool allocation failed");
415 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
417 "Failed to configure cryptodev %u with %u qps",
418 dev_id, ts_params->conf.nb_queue_pairs);
420 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
422 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
423 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
424 dev_id, qp_id, &ts_params->qp_conf,
425 rte_cryptodev_socket_id(dev_id),
426 ts_params->session_mpool),
427 "Failed to setup queue pair %u on cryptodev %u",
435 testsuite_teardown(void)
437 struct crypto_testsuite_params *ts_params = &testsuite_params;
439 if (ts_params->mbuf_pool != NULL) {
440 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
441 rte_mempool_avail_count(ts_params->mbuf_pool));
444 if (ts_params->op_mpool != NULL) {
445 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
446 rte_mempool_avail_count(ts_params->op_mpool));
449 /* Free session mempools */
450 if (ts_params->session_mpool != NULL) {
451 rte_mempool_free(ts_params->session_mpool);
452 ts_params->session_mpool = NULL;
459 struct crypto_testsuite_params *ts_params = &testsuite_params;
460 struct crypto_unittest_params *ut_params = &unittest_params;
464 /* Clear unit test parameters before running test */
465 memset(ut_params, 0, sizeof(*ut_params));
467 /* Reconfigure device to default parameters */
468 ts_params->conf.socket_id = SOCKET_ID_ANY;
470 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
472 "Failed to configure cryptodev %u",
473 ts_params->valid_devs[0]);
475 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
476 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
477 ts_params->valid_devs[0], qp_id,
479 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
480 ts_params->session_mpool),
481 "Failed to setup queue pair %u on cryptodev %u",
482 qp_id, ts_params->valid_devs[0]);
486 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
488 /* Start the device */
489 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
490 "Failed to start cryptodev %u",
491 ts_params->valid_devs[0]);
499 struct crypto_testsuite_params *ts_params = &testsuite_params;
500 struct crypto_unittest_params *ut_params = &unittest_params;
501 struct rte_cryptodev_stats stats;
503 /* free crypto session structure */
504 if (ut_params->sess) {
505 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
507 rte_cryptodev_sym_session_free(ut_params->sess);
508 ut_params->sess = NULL;
511 /* free crypto operation structure */
513 rte_crypto_op_free(ut_params->op);
516 * free mbuf - both obuf and ibuf are usually the same,
517 * so check if they point at the same address is necessary,
518 * to avoid freeing the mbuf twice.
520 if (ut_params->obuf) {
521 rte_pktmbuf_free(ut_params->obuf);
522 if (ut_params->ibuf == ut_params->obuf)
526 if (ut_params->ibuf) {
527 rte_pktmbuf_free(ut_params->ibuf);
531 if (ts_params->mbuf_pool != NULL)
532 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
533 rte_mempool_avail_count(ts_params->mbuf_pool));
535 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
537 /* Stop the device */
538 rte_cryptodev_stop(ts_params->valid_devs[0]);
542 test_device_configure_invalid_dev_id(void)
544 struct crypto_testsuite_params *ts_params = &testsuite_params;
545 uint16_t dev_id, num_devs = 0;
547 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
548 "Need at least %d devices for test", 1);
550 /* valid dev_id values */
551 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
553 /* Stop the device in case it's started so it can be configured */
554 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
556 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
557 "Failed test for rte_cryptodev_configure: "
558 "invalid dev_num %u", dev_id);
560 /* invalid dev_id values */
563 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
564 "Failed test for rte_cryptodev_configure: "
565 "invalid dev_num %u", dev_id);
569 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
570 "Failed test for rte_cryptodev_configure:"
571 "invalid dev_num %u", dev_id);
577 test_device_configure_invalid_queue_pair_ids(void)
579 struct crypto_testsuite_params *ts_params = &testsuite_params;
580 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
582 /* Stop the device in case it's started so it can be configured */
583 rte_cryptodev_stop(ts_params->valid_devs[0]);
585 /* valid - one queue pairs */
586 ts_params->conf.nb_queue_pairs = 1;
588 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
590 "Failed to configure cryptodev: dev_id %u, qp_id %u",
591 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
594 /* valid - max value queue pairs */
595 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
597 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
599 "Failed to configure cryptodev: dev_id %u, qp_id %u",
600 ts_params->valid_devs[0],
601 ts_params->conf.nb_queue_pairs);
604 /* invalid - zero queue pairs */
605 ts_params->conf.nb_queue_pairs = 0;
607 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
609 "Failed test for rte_cryptodev_configure, dev_id %u,"
611 ts_params->valid_devs[0],
612 ts_params->conf.nb_queue_pairs);
615 /* invalid - max value supported by field queue pairs */
616 ts_params->conf.nb_queue_pairs = UINT16_MAX;
618 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
620 "Failed test for rte_cryptodev_configure, dev_id %u,"
622 ts_params->valid_devs[0],
623 ts_params->conf.nb_queue_pairs);
626 /* invalid - max value + 1 queue pairs */
627 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
629 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
631 "Failed test for rte_cryptodev_configure, dev_id %u,"
633 ts_params->valid_devs[0],
634 ts_params->conf.nb_queue_pairs);
636 /* revert to original testsuite value */
637 ts_params->conf.nb_queue_pairs = orig_nb_qps;
643 test_queue_pair_descriptor_setup(void)
645 struct crypto_testsuite_params *ts_params = &testsuite_params;
646 struct rte_cryptodev_info dev_info;
647 struct rte_cryptodev_qp_conf qp_conf = {
648 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
653 /* Stop the device in case it's started so it can be configured */
654 rte_cryptodev_stop(ts_params->valid_devs[0]);
657 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
659 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
661 "Failed to configure cryptodev %u",
662 ts_params->valid_devs[0]);
665 * Test various ring sizes on this device. memzones can't be
666 * freed so are re-used if ring is released and re-created.
668 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
670 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
671 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
672 ts_params->valid_devs[0], qp_id, &qp_conf,
673 rte_cryptodev_socket_id(
674 ts_params->valid_devs[0]),
675 ts_params->session_mpool),
677 "rte_cryptodev_queue_pair_setup: num_inflights "
678 "%u on qp %u on cryptodev %u",
679 qp_conf.nb_descriptors, qp_id,
680 ts_params->valid_devs[0]);
683 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
685 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
686 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
687 ts_params->valid_devs[0], qp_id, &qp_conf,
688 rte_cryptodev_socket_id(
689 ts_params->valid_devs[0]),
690 ts_params->session_mpool),
692 " rte_cryptodev_queue_pair_setup: num_inflights"
693 " %u on qp %u on cryptodev %u",
694 qp_conf.nb_descriptors, qp_id,
695 ts_params->valid_devs[0]);
698 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
700 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
701 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
702 ts_params->valid_devs[0], qp_id, &qp_conf,
703 rte_cryptodev_socket_id(
704 ts_params->valid_devs[0]),
705 ts_params->session_mpool),
707 "rte_cryptodev_queue_pair_setup: num_inflights"
708 " %u on qp %u on cryptodev %u",
709 qp_conf.nb_descriptors, qp_id,
710 ts_params->valid_devs[0]);
713 /* invalid number of descriptors - max supported + 2 */
714 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
716 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
717 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
718 ts_params->valid_devs[0], qp_id, &qp_conf,
719 rte_cryptodev_socket_id(
720 ts_params->valid_devs[0]),
721 ts_params->session_mpool),
722 "Unexpectedly passed test for "
723 "rte_cryptodev_queue_pair_setup:"
724 "num_inflights %u on qp %u on cryptodev %u",
725 qp_conf.nb_descriptors, qp_id,
726 ts_params->valid_devs[0]);
729 /* invalid number of descriptors - max value of parameter */
730 qp_conf.nb_descriptors = UINT32_MAX-1;
732 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
733 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
734 ts_params->valid_devs[0], qp_id, &qp_conf,
735 rte_cryptodev_socket_id(
736 ts_params->valid_devs[0]),
737 ts_params->session_mpool),
738 "Unexpectedly passed test for "
739 "rte_cryptodev_queue_pair_setup:"
740 "num_inflights %u on qp %u on cryptodev %u",
741 qp_conf.nb_descriptors, qp_id,
742 ts_params->valid_devs[0]);
745 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
747 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
748 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
749 ts_params->valid_devs[0], qp_id, &qp_conf,
750 rte_cryptodev_socket_id(
751 ts_params->valid_devs[0]),
752 ts_params->session_mpool),
754 " rte_cryptodev_queue_pair_setup:"
755 "num_inflights %u on qp %u on cryptodev %u",
756 qp_conf.nb_descriptors, qp_id,
757 ts_params->valid_devs[0]);
760 /* invalid number of descriptors - max supported + 1 */
761 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
763 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
764 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
765 ts_params->valid_devs[0], qp_id, &qp_conf,
766 rte_cryptodev_socket_id(
767 ts_params->valid_devs[0]),
768 ts_params->session_mpool),
769 "Unexpectedly passed test for "
770 "rte_cryptodev_queue_pair_setup:"
771 "num_inflights %u on qp %u on cryptodev %u",
772 qp_conf.nb_descriptors, qp_id,
773 ts_params->valid_devs[0]);
776 /* test invalid queue pair id */
777 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
779 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
781 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
782 ts_params->valid_devs[0],
784 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
785 ts_params->session_mpool),
786 "Failed test for rte_cryptodev_queue_pair_setup:"
787 "invalid qp %u on cryptodev %u",
788 qp_id, ts_params->valid_devs[0]);
790 qp_id = 0xffff; /*invalid*/
792 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
793 ts_params->valid_devs[0],
795 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
796 ts_params->session_mpool),
797 "Failed test for rte_cryptodev_queue_pair_setup:"
798 "invalid qp %u on cryptodev %u",
799 qp_id, ts_params->valid_devs[0]);
804 /* ***** Plaintext data for tests ***** */
806 const char catch_22_quote_1[] =
807 "There was only one catch and that was Catch-22, which "
808 "specified that a concern for one's safety in the face of "
809 "dangers that were real and immediate was the process of a "
810 "rational mind. Orr was crazy and could be grounded. All he "
811 "had to do was ask; and as soon as he did, he would no longer "
812 "be crazy and would have to fly more missions. Orr would be "
813 "crazy to fly more missions and sane if he didn't, but if he "
814 "was sane he had to fly them. If he flew them he was crazy "
815 "and didn't have to; but if he didn't want to he was sane and "
816 "had to. Yossarian was moved very deeply by the absolute "
817 "simplicity of this clause of Catch-22 and let out a "
818 "respectful whistle. \"That's some catch, that Catch-22\", he "
819 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
821 const char catch_22_quote[] =
822 "What a lousy earth! He wondered how many people were "
823 "destitute that same night even in his own prosperous country, "
824 "how many homes were shanties, how many husbands were drunk "
825 "and wives socked, and how many children were bullied, abused, "
826 "or abandoned. How many families hungered for food they could "
827 "not afford to buy? How many hearts were broken? How many "
828 "suicides would take place that same night, how many people "
829 "would go insane? How many cockroaches and landlords would "
830 "triumph? How many winners were losers, successes failures, "
831 "and rich men poor men? How many wise guys were stupid? How "
832 "many happy endings were unhappy endings? How many honest men "
833 "were liars, brave men cowards, loyal men traitors, how many "
834 "sainted men were corrupt, how many people in positions of "
835 "trust had sold their souls to bodyguards, how many had never "
836 "had souls? How many straight-and-narrow paths were crooked "
837 "paths? How many best families were worst families and how "
838 "many good people were bad people? When you added them all up "
839 "and then subtracted, you might be left with only the children, "
840 "and perhaps with Albert Einstein and an old violinist or "
841 "sculptor somewhere.";
843 #define QUOTE_480_BYTES (480)
844 #define QUOTE_512_BYTES (512)
845 #define QUOTE_768_BYTES (768)
846 #define QUOTE_1024_BYTES (1024)
850 /* ***** SHA1 Hash Tests ***** */
852 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
854 static uint8_t hmac_sha1_key[] = {
855 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
856 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
857 0xDE, 0xF4, 0xDE, 0xAD };
859 /* ***** SHA224 Hash Tests ***** */
861 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
864 /* ***** AES-CBC Cipher Tests ***** */
866 #define CIPHER_KEY_LENGTH_AES_CBC (16)
867 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
869 static uint8_t aes_cbc_key[] = {
870 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
871 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
873 static uint8_t aes_cbc_iv[] = {
874 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
875 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
878 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
880 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
881 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
882 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
883 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
884 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
885 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
886 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
887 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
888 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
889 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
890 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
891 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
892 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
893 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
894 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
895 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
896 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
897 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
898 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
899 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
900 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
901 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
902 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
903 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
904 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
905 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
906 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
907 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
908 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
909 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
910 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
911 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
912 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
913 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
914 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
915 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
916 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
917 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
918 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
919 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
920 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
921 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
922 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
923 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
924 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
925 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
926 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
927 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
928 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
929 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
930 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
931 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
932 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
933 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
934 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
935 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
936 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
937 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
938 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
939 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
940 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
941 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
942 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
943 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
944 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
947 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
948 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
949 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
950 0x18, 0x8c, 0x1d, 0x32
954 /* Multisession Vector context Test */
956 static uint8_t ms_aes_cbc_key0[] = {
957 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
958 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
961 static uint8_t ms_aes_cbc_iv0[] = {
962 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
963 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
966 static const uint8_t ms_aes_cbc_cipher0[] = {
967 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
968 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
969 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
970 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
971 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
972 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
973 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
974 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
975 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
976 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
977 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
978 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
979 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
980 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
981 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
982 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
983 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
984 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
985 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
986 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
987 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
988 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
989 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
990 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
991 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
992 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
993 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
994 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
995 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
996 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
997 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
998 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
999 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1000 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1001 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1002 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1003 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1004 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1005 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1006 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1007 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1008 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1009 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1010 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1011 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1012 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1013 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1014 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1015 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1016 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1017 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1018 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1019 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1020 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1021 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1022 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1023 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1024 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1025 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1026 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1027 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1028 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1029 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1030 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1034 static uint8_t ms_hmac_key0[] = {
1035 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1036 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1037 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1038 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1039 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1040 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1041 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1042 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1045 static const uint8_t ms_hmac_digest0[] = {
1046 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1047 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1048 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1049 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1050 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1051 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1052 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1053 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1057 /* Begin session 1 */
1059 static uint8_t ms_aes_cbc_key1[] = {
1060 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1061 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1064 static uint8_t ms_aes_cbc_iv1[] = {
1065 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1066 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1069 static const uint8_t ms_aes_cbc_cipher1[] = {
1070 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1071 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1072 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1073 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1074 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1075 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1076 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1077 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1078 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1079 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1080 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1081 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1082 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1083 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1084 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1085 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1086 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1087 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1088 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1089 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1090 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1091 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1092 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1093 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1094 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1095 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1096 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1097 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1098 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1099 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1100 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1101 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1102 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1103 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1104 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1105 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1106 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1107 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1108 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1109 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1110 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1111 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1112 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1113 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1114 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1115 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1116 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1117 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1118 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1119 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1120 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1121 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1122 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1123 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1124 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1125 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1126 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1127 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1128 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1129 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1130 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1131 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1132 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1133 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1137 static uint8_t ms_hmac_key1[] = {
1138 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1139 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1140 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1141 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1142 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1143 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1144 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1145 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1148 static const uint8_t ms_hmac_digest1[] = {
1149 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1150 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1151 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1152 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1153 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1154 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1155 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1156 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1159 /* Begin Session 2 */
1160 static uint8_t ms_aes_cbc_key2[] = {
1161 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1162 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1165 static uint8_t ms_aes_cbc_iv2[] = {
1166 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1167 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1170 static const uint8_t ms_aes_cbc_cipher2[] = {
1171 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1172 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1173 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1174 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1175 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1176 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1177 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1178 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1179 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1180 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1181 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1182 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1183 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1184 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1185 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1186 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1187 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1188 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1189 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1190 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1191 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1192 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1193 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1194 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1195 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1196 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1197 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1198 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1199 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1200 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1201 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1202 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1203 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1204 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1205 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1206 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1207 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1208 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1209 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1210 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1211 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1212 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1213 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1214 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1215 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1216 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1217 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1218 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1219 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1220 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1221 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1222 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1223 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1224 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1225 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1226 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1227 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1228 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1229 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1230 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1231 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1232 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1233 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1234 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1237 static uint8_t ms_hmac_key2[] = {
1238 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1239 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1240 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1241 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1242 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1243 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1244 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1245 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1248 static const uint8_t ms_hmac_digest2[] = {
1249 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1250 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1251 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1252 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1253 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1254 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1255 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1256 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1263 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1265 struct crypto_testsuite_params *ts_params = &testsuite_params;
1266 struct crypto_unittest_params *ut_params = &unittest_params;
1268 /* Generate test mbuf data and space for digest */
1269 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1270 catch_22_quote, QUOTE_512_BYTES, 0);
1272 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1273 DIGEST_BYTE_LENGTH_SHA1);
1274 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1276 /* Setup Cipher Parameters */
1277 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1278 ut_params->cipher_xform.next = &ut_params->auth_xform;
1280 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1281 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1282 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1283 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1284 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1285 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1287 /* Setup HMAC Parameters */
1288 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1290 ut_params->auth_xform.next = NULL;
1292 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1293 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1294 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1295 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1296 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1298 ut_params->sess = rte_cryptodev_sym_session_create(
1299 ts_params->session_mpool);
1301 /* Create crypto session*/
1302 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1303 ut_params->sess, &ut_params->cipher_xform,
1304 ts_params->session_mpool);
1305 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1307 /* Generate crypto op data structure */
1308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1309 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1310 TEST_ASSERT_NOT_NULL(ut_params->op,
1311 "Failed to allocate symmetric crypto operation struct");
1313 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1315 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1317 /* set crypto operation source mbuf */
1318 sym_op->m_src = ut_params->ibuf;
1320 /* Set crypto operation authentication parameters */
1321 sym_op->auth.digest.data = ut_params->digest;
1322 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1323 ut_params->ibuf, QUOTE_512_BYTES);
1325 sym_op->auth.data.offset = 0;
1326 sym_op->auth.data.length = QUOTE_512_BYTES;
1328 /* Copy IV at the end of the crypto operation */
1329 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1330 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1332 /* Set crypto operation cipher parameters */
1333 sym_op->cipher.data.offset = 0;
1334 sym_op->cipher.data.length = QUOTE_512_BYTES;
1336 /* Process crypto operation */
1337 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1338 ut_params->op), "failed to process sym crypto op");
1340 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1341 "crypto op processing failed");
1344 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1347 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1348 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1350 "ciphertext data not as expected");
1352 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1354 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1355 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1356 gbl_driver_id == rte_cryptodev_driver_id_get(
1357 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1358 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1359 DIGEST_BYTE_LENGTH_SHA1,
1360 "Generated digest data not as expected");
1362 return TEST_SUCCESS;
1365 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1367 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1369 static uint8_t hmac_sha512_key[] = {
1370 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1371 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1372 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1373 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1374 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1375 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1376 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1377 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1379 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1380 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1381 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1382 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1383 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1384 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1385 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1386 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1387 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1392 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1393 struct crypto_unittest_params *ut_params,
1394 uint8_t *cipher_key,
1398 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1399 struct crypto_unittest_params *ut_params,
1400 struct crypto_testsuite_params *ts_params,
1401 const uint8_t *cipher,
1402 const uint8_t *digest,
1407 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1408 struct crypto_unittest_params *ut_params,
1409 uint8_t *cipher_key,
1413 /* Setup Cipher Parameters */
1414 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1415 ut_params->cipher_xform.next = NULL;
1417 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1418 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1419 ut_params->cipher_xform.cipher.key.data = cipher_key;
1420 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1421 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1422 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1424 /* Setup HMAC Parameters */
1425 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1426 ut_params->auth_xform.next = &ut_params->cipher_xform;
1428 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1429 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1430 ut_params->auth_xform.auth.key.data = hmac_key;
1431 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1432 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1434 return TEST_SUCCESS;
1439 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1440 struct crypto_unittest_params *ut_params,
1441 struct crypto_testsuite_params *ts_params,
1442 const uint8_t *cipher,
1443 const uint8_t *digest,
1446 /* Generate test mbuf data and digest */
1447 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1450 QUOTE_512_BYTES, 0);
1452 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1453 DIGEST_BYTE_LENGTH_SHA512);
1454 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1456 rte_memcpy(ut_params->digest,
1458 DIGEST_BYTE_LENGTH_SHA512);
1460 /* Generate Crypto op data structure */
1461 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1462 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1463 TEST_ASSERT_NOT_NULL(ut_params->op,
1464 "Failed to allocate symmetric crypto operation struct");
1466 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1468 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1470 /* set crypto operation source mbuf */
1471 sym_op->m_src = ut_params->ibuf;
1473 sym_op->auth.digest.data = ut_params->digest;
1474 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1475 ut_params->ibuf, QUOTE_512_BYTES);
1477 sym_op->auth.data.offset = 0;
1478 sym_op->auth.data.length = QUOTE_512_BYTES;
1480 /* Copy IV at the end of the crypto operation */
1481 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1482 iv, CIPHER_IV_LENGTH_AES_CBC);
1484 sym_op->cipher.data.offset = 0;
1485 sym_op->cipher.data.length = QUOTE_512_BYTES;
1487 /* Process crypto operation */
1488 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1489 ut_params->op), "failed to process sym crypto op");
1491 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1492 "crypto op processing failed");
1494 ut_params->obuf = ut_params->op->sym->m_src;
1497 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1498 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1501 "Plaintext data not as expected");
1504 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1505 "Digest verification failed");
1507 return TEST_SUCCESS;
1511 test_AES_cipheronly_mb_all(void)
1513 struct crypto_testsuite_params *ts_params = &testsuite_params;
1516 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1517 ts_params->op_mpool,
1518 ts_params->session_mpool,
1519 ts_params->valid_devs[0],
1520 rte_cryptodev_driver_id_get(
1521 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1522 BLKCIPHER_AES_CIPHERONLY_TYPE);
1524 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1526 return TEST_SUCCESS;
1530 test_AES_docsis_mb_all(void)
1532 struct crypto_testsuite_params *ts_params = &testsuite_params;
1535 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1536 ts_params->op_mpool,
1537 ts_params->session_mpool,
1538 ts_params->valid_devs[0],
1539 rte_cryptodev_driver_id_get(
1540 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1541 BLKCIPHER_AES_DOCSIS_TYPE);
1543 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1545 return TEST_SUCCESS;
1549 test_AES_docsis_qat_all(void)
1551 struct crypto_testsuite_params *ts_params = &testsuite_params;
1554 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1555 ts_params->op_mpool,
1556 ts_params->session_mpool,
1557 ts_params->valid_devs[0],
1558 rte_cryptodev_driver_id_get(
1559 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1560 BLKCIPHER_AES_DOCSIS_TYPE);
1562 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1564 return TEST_SUCCESS;
1568 test_DES_docsis_qat_all(void)
1570 struct crypto_testsuite_params *ts_params = &testsuite_params;
1573 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1574 ts_params->op_mpool,
1575 ts_params->session_mpool,
1576 ts_params->valid_devs[0],
1577 rte_cryptodev_driver_id_get(
1578 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1579 BLKCIPHER_DES_DOCSIS_TYPE);
1581 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1583 return TEST_SUCCESS;
1587 test_authonly_mb_all(void)
1589 struct crypto_testsuite_params *ts_params = &testsuite_params;
1592 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1593 ts_params->op_mpool,
1594 ts_params->session_mpool,
1595 ts_params->valid_devs[0],
1596 rte_cryptodev_driver_id_get(
1597 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1598 BLKCIPHER_AUTHONLY_TYPE);
1600 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1602 return TEST_SUCCESS;
1606 test_authonly_qat_all(void)
1608 struct crypto_testsuite_params *ts_params = &testsuite_params;
1611 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1612 ts_params->op_mpool,
1613 ts_params->session_mpool,
1614 ts_params->valid_devs[0],
1615 rte_cryptodev_driver_id_get(
1616 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1617 BLKCIPHER_AUTHONLY_TYPE);
1619 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1621 return TEST_SUCCESS;
1624 test_AES_chain_mb_all(void)
1626 struct crypto_testsuite_params *ts_params = &testsuite_params;
1629 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1630 ts_params->op_mpool,
1631 ts_params->session_mpool,
1632 ts_params->valid_devs[0],
1633 rte_cryptodev_driver_id_get(
1634 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1635 BLKCIPHER_AES_CHAIN_TYPE);
1637 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1639 return TEST_SUCCESS;
1642 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1645 test_AES_cipheronly_scheduler_all(void)
1647 struct crypto_testsuite_params *ts_params = &testsuite_params;
1650 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1651 ts_params->op_mpool,
1652 ts_params->session_mpool,
1653 ts_params->valid_devs[0],
1654 rte_cryptodev_driver_id_get(
1655 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1656 BLKCIPHER_AES_CIPHERONLY_TYPE);
1658 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1660 return TEST_SUCCESS;
1664 test_AES_chain_scheduler_all(void)
1666 struct crypto_testsuite_params *ts_params = &testsuite_params;
1669 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1670 ts_params->op_mpool,
1671 ts_params->session_mpool,
1672 ts_params->valid_devs[0],
1673 rte_cryptodev_driver_id_get(
1674 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1675 BLKCIPHER_AES_CHAIN_TYPE);
1677 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1679 return TEST_SUCCESS;
1683 test_authonly_scheduler_all(void)
1685 struct crypto_testsuite_params *ts_params = &testsuite_params;
1688 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1689 ts_params->op_mpool,
1690 ts_params->session_mpool,
1691 ts_params->valid_devs[0],
1692 rte_cryptodev_driver_id_get(
1693 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1694 BLKCIPHER_AUTHONLY_TYPE);
1696 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1698 return TEST_SUCCESS;
1701 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1704 test_AES_chain_openssl_all(void)
1706 struct crypto_testsuite_params *ts_params = &testsuite_params;
1709 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1710 ts_params->op_mpool,
1711 ts_params->session_mpool,
1712 ts_params->valid_devs[0],
1713 rte_cryptodev_driver_id_get(
1714 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1715 BLKCIPHER_AES_CHAIN_TYPE);
1717 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1719 return TEST_SUCCESS;
1723 test_AES_cipheronly_openssl_all(void)
1725 struct crypto_testsuite_params *ts_params = &testsuite_params;
1728 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1729 ts_params->op_mpool,
1730 ts_params->session_mpool,
1731 ts_params->valid_devs[0],
1732 rte_cryptodev_driver_id_get(
1733 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1734 BLKCIPHER_AES_CIPHERONLY_TYPE);
1736 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1738 return TEST_SUCCESS;
1742 test_AES_chain_ccp_all(void)
1744 struct crypto_testsuite_params *ts_params = &testsuite_params;
1747 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1748 ts_params->op_mpool,
1749 ts_params->session_mpool,
1750 ts_params->valid_devs[0],
1751 rte_cryptodev_driver_id_get(
1752 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1753 BLKCIPHER_AES_CHAIN_TYPE);
1755 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1757 return TEST_SUCCESS;
1761 test_AES_cipheronly_ccp_all(void)
1763 struct crypto_testsuite_params *ts_params = &testsuite_params;
1766 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1767 ts_params->op_mpool,
1768 ts_params->session_mpool,
1769 ts_params->valid_devs[0],
1770 rte_cryptodev_driver_id_get(
1771 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1772 BLKCIPHER_AES_CIPHERONLY_TYPE);
1774 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1776 return TEST_SUCCESS;
1780 test_AES_chain_qat_all(void)
1782 struct crypto_testsuite_params *ts_params = &testsuite_params;
1785 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1786 ts_params->op_mpool,
1787 ts_params->session_mpool,
1788 ts_params->valid_devs[0],
1789 rte_cryptodev_driver_id_get(
1790 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1791 BLKCIPHER_AES_CHAIN_TYPE);
1793 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1795 return TEST_SUCCESS;
1799 test_AES_cipheronly_qat_all(void)
1801 struct crypto_testsuite_params *ts_params = &testsuite_params;
1804 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1805 ts_params->op_mpool,
1806 ts_params->session_mpool,
1807 ts_params->valid_devs[0],
1808 rte_cryptodev_driver_id_get(
1809 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1810 BLKCIPHER_AES_CIPHERONLY_TYPE);
1812 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1814 return TEST_SUCCESS;
1818 test_AES_cipheronly_virtio_all(void)
1820 struct crypto_testsuite_params *ts_params = &testsuite_params;
1823 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1824 ts_params->op_mpool,
1825 ts_params->session_mpool,
1826 ts_params->valid_devs[0],
1827 rte_cryptodev_driver_id_get(
1828 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1829 BLKCIPHER_AES_CIPHERONLY_TYPE);
1831 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1833 return TEST_SUCCESS;
1837 test_AES_chain_dpaa_sec_all(void)
1839 struct crypto_testsuite_params *ts_params = &testsuite_params;
1842 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1843 ts_params->op_mpool,
1844 ts_params->session_mpool,
1845 ts_params->valid_devs[0],
1846 rte_cryptodev_driver_id_get(
1847 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1848 BLKCIPHER_AES_CHAIN_TYPE);
1850 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1852 return TEST_SUCCESS;
1856 test_AES_cipheronly_dpaa_sec_all(void)
1858 struct crypto_testsuite_params *ts_params = &testsuite_params;
1861 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1862 ts_params->op_mpool,
1863 ts_params->session_mpool,
1864 ts_params->valid_devs[0],
1865 rte_cryptodev_driver_id_get(
1866 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1867 BLKCIPHER_AES_CIPHERONLY_TYPE);
1869 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1871 return TEST_SUCCESS;
1875 test_authonly_dpaa_sec_all(void)
1877 struct crypto_testsuite_params *ts_params = &testsuite_params;
1880 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1881 ts_params->op_mpool,
1882 ts_params->session_mpool,
1883 ts_params->valid_devs[0],
1884 rte_cryptodev_driver_id_get(
1885 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1886 BLKCIPHER_AUTHONLY_TYPE);
1888 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1890 return TEST_SUCCESS;
1894 test_AES_chain_dpaa2_sec_all(void)
1896 struct crypto_testsuite_params *ts_params = &testsuite_params;
1899 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1900 ts_params->op_mpool,
1901 ts_params->session_mpool,
1902 ts_params->valid_devs[0],
1903 rte_cryptodev_driver_id_get(
1904 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1905 BLKCIPHER_AES_CHAIN_TYPE);
1907 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1909 return TEST_SUCCESS;
1913 test_AES_cipheronly_dpaa2_sec_all(void)
1915 struct crypto_testsuite_params *ts_params = &testsuite_params;
1918 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1919 ts_params->op_mpool,
1920 ts_params->session_mpool,
1921 ts_params->valid_devs[0],
1922 rte_cryptodev_driver_id_get(
1923 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1924 BLKCIPHER_AES_CIPHERONLY_TYPE);
1926 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1928 return TEST_SUCCESS;
1932 test_authonly_dpaa2_sec_all(void)
1934 struct crypto_testsuite_params *ts_params = &testsuite_params;
1937 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1938 ts_params->op_mpool,
1939 ts_params->session_mpool,
1940 ts_params->valid_devs[0],
1941 rte_cryptodev_driver_id_get(
1942 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1943 BLKCIPHER_AUTHONLY_TYPE);
1945 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1947 return TEST_SUCCESS;
1951 test_authonly_openssl_all(void)
1953 struct crypto_testsuite_params *ts_params = &testsuite_params;
1956 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1957 ts_params->op_mpool,
1958 ts_params->session_mpool,
1959 ts_params->valid_devs[0],
1960 rte_cryptodev_driver_id_get(
1961 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1962 BLKCIPHER_AUTHONLY_TYPE);
1964 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1966 return TEST_SUCCESS;
1970 test_authonly_ccp_all(void)
1972 struct crypto_testsuite_params *ts_params = &testsuite_params;
1975 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1976 ts_params->op_mpool,
1977 ts_params->session_mpool,
1978 ts_params->valid_devs[0],
1979 rte_cryptodev_driver_id_get(
1980 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1981 BLKCIPHER_AUTHONLY_TYPE);
1983 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1985 return TEST_SUCCESS;
1989 test_AES_chain_armv8_all(void)
1991 struct crypto_testsuite_params *ts_params = &testsuite_params;
1994 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1995 ts_params->op_mpool,
1996 ts_params->session_mpool,
1997 ts_params->valid_devs[0],
1998 rte_cryptodev_driver_id_get(
1999 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2000 BLKCIPHER_AES_CHAIN_TYPE);
2002 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2004 return TEST_SUCCESS;
2008 test_AES_chain_mrvl_all(void)
2010 struct crypto_testsuite_params *ts_params = &testsuite_params;
2013 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2014 ts_params->op_mpool,
2015 ts_params->session_mpool,
2016 ts_params->valid_devs[0],
2017 rte_cryptodev_driver_id_get(
2018 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2019 BLKCIPHER_AES_CHAIN_TYPE);
2021 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2023 return TEST_SUCCESS;
2027 test_AES_cipheronly_mrvl_all(void)
2029 struct crypto_testsuite_params *ts_params = &testsuite_params;
2032 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2033 ts_params->op_mpool,
2034 ts_params->session_mpool,
2035 ts_params->valid_devs[0],
2036 rte_cryptodev_driver_id_get(
2037 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2038 BLKCIPHER_AES_CIPHERONLY_TYPE);
2040 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2042 return TEST_SUCCESS;
2046 test_authonly_mrvl_all(void)
2048 struct crypto_testsuite_params *ts_params = &testsuite_params;
2051 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2052 ts_params->op_mpool,
2053 ts_params->session_mpool,
2054 ts_params->valid_devs[0],
2055 rte_cryptodev_driver_id_get(
2056 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2057 BLKCIPHER_AUTHONLY_TYPE);
2059 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2061 return TEST_SUCCESS;
2065 test_3DES_chain_mrvl_all(void)
2067 struct crypto_testsuite_params *ts_params = &testsuite_params;
2070 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2071 ts_params->op_mpool,
2072 ts_params->session_mpool,
2073 ts_params->valid_devs[0],
2074 rte_cryptodev_driver_id_get(
2075 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2076 BLKCIPHER_3DES_CHAIN_TYPE);
2078 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2080 return TEST_SUCCESS;
2084 test_3DES_cipheronly_mrvl_all(void)
2086 struct crypto_testsuite_params *ts_params = &testsuite_params;
2089 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2090 ts_params->op_mpool,
2091 ts_params->session_mpool,
2092 ts_params->valid_devs[0],
2093 rte_cryptodev_driver_id_get(
2094 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2095 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2097 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2099 return TEST_SUCCESS;
2102 /* ***** SNOW 3G Tests ***** */
2104 create_wireless_algo_hash_session(uint8_t dev_id,
2105 const uint8_t *key, const uint8_t key_len,
2106 const uint8_t iv_len, const uint8_t auth_len,
2107 enum rte_crypto_auth_operation op,
2108 enum rte_crypto_auth_algorithm algo)
2110 uint8_t hash_key[key_len];
2112 struct crypto_testsuite_params *ts_params = &testsuite_params;
2113 struct crypto_unittest_params *ut_params = &unittest_params;
2115 memcpy(hash_key, key, key_len);
2117 debug_hexdump(stdout, "key:", key, key_len);
2119 /* Setup Authentication Parameters */
2120 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2121 ut_params->auth_xform.next = NULL;
2123 ut_params->auth_xform.auth.op = op;
2124 ut_params->auth_xform.auth.algo = algo;
2125 ut_params->auth_xform.auth.key.length = key_len;
2126 ut_params->auth_xform.auth.key.data = hash_key;
2127 ut_params->auth_xform.auth.digest_length = auth_len;
2128 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2129 ut_params->auth_xform.auth.iv.length = iv_len;
2130 ut_params->sess = rte_cryptodev_sym_session_create(
2131 ts_params->session_mpool);
2133 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2134 &ut_params->auth_xform, ts_params->session_mpool);
2135 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2140 create_wireless_algo_cipher_session(uint8_t dev_id,
2141 enum rte_crypto_cipher_operation op,
2142 enum rte_crypto_cipher_algorithm algo,
2143 const uint8_t *key, const uint8_t key_len,
2146 uint8_t cipher_key[key_len];
2148 struct crypto_testsuite_params *ts_params = &testsuite_params;
2149 struct crypto_unittest_params *ut_params = &unittest_params;
2151 memcpy(cipher_key, key, key_len);
2153 /* Setup Cipher Parameters */
2154 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2155 ut_params->cipher_xform.next = NULL;
2157 ut_params->cipher_xform.cipher.algo = algo;
2158 ut_params->cipher_xform.cipher.op = op;
2159 ut_params->cipher_xform.cipher.key.data = cipher_key;
2160 ut_params->cipher_xform.cipher.key.length = key_len;
2161 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2162 ut_params->cipher_xform.cipher.iv.length = iv_len;
2164 debug_hexdump(stdout, "key:", key, key_len);
2166 /* Create Crypto session */
2167 ut_params->sess = rte_cryptodev_sym_session_create(
2168 ts_params->session_mpool);
2170 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2171 &ut_params->cipher_xform, ts_params->session_mpool);
2172 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2177 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2178 unsigned int cipher_len,
2179 unsigned int cipher_offset)
2181 struct crypto_testsuite_params *ts_params = &testsuite_params;
2182 struct crypto_unittest_params *ut_params = &unittest_params;
2184 /* Generate Crypto op data structure */
2185 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2186 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2187 TEST_ASSERT_NOT_NULL(ut_params->op,
2188 "Failed to allocate pktmbuf offload");
2190 /* Set crypto operation data parameters */
2191 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2193 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2195 /* set crypto operation source mbuf */
2196 sym_op->m_src = ut_params->ibuf;
2199 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2201 sym_op->cipher.data.length = cipher_len;
2202 sym_op->cipher.data.offset = cipher_offset;
2207 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2208 unsigned int cipher_len,
2209 unsigned int cipher_offset)
2211 struct crypto_testsuite_params *ts_params = &testsuite_params;
2212 struct crypto_unittest_params *ut_params = &unittest_params;
2214 /* Generate Crypto op data structure */
2215 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2216 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2217 TEST_ASSERT_NOT_NULL(ut_params->op,
2218 "Failed to allocate pktmbuf offload");
2220 /* Set crypto operation data parameters */
2221 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2223 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2225 /* set crypto operation source mbuf */
2226 sym_op->m_src = ut_params->ibuf;
2227 sym_op->m_dst = ut_params->obuf;
2230 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2232 sym_op->cipher.data.length = cipher_len;
2233 sym_op->cipher.data.offset = cipher_offset;
2238 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2239 enum rte_crypto_cipher_operation cipher_op,
2240 enum rte_crypto_auth_operation auth_op,
2241 enum rte_crypto_auth_algorithm auth_algo,
2242 enum rte_crypto_cipher_algorithm cipher_algo,
2243 const uint8_t *key, uint8_t key_len,
2244 uint8_t auth_iv_len, uint8_t auth_len,
2245 uint8_t cipher_iv_len)
2248 uint8_t cipher_auth_key[key_len];
2250 struct crypto_testsuite_params *ts_params = &testsuite_params;
2251 struct crypto_unittest_params *ut_params = &unittest_params;
2253 memcpy(cipher_auth_key, key, key_len);
2255 /* Setup Authentication Parameters */
2256 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2257 ut_params->auth_xform.next = NULL;
2259 ut_params->auth_xform.auth.op = auth_op;
2260 ut_params->auth_xform.auth.algo = auth_algo;
2261 ut_params->auth_xform.auth.key.length = key_len;
2262 /* Hash key = cipher key */
2263 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2264 ut_params->auth_xform.auth.digest_length = auth_len;
2265 /* Auth IV will be after cipher IV */
2266 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2267 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2269 /* Setup Cipher Parameters */
2270 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2271 ut_params->cipher_xform.next = &ut_params->auth_xform;
2273 ut_params->cipher_xform.cipher.algo = cipher_algo;
2274 ut_params->cipher_xform.cipher.op = cipher_op;
2275 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2276 ut_params->cipher_xform.cipher.key.length = key_len;
2277 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2278 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2280 debug_hexdump(stdout, "key:", key, key_len);
2282 /* Create Crypto session*/
2283 ut_params->sess = rte_cryptodev_sym_session_create(
2284 ts_params->session_mpool);
2286 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2287 &ut_params->cipher_xform, ts_params->session_mpool);
2289 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2294 create_wireless_cipher_auth_session(uint8_t dev_id,
2295 enum rte_crypto_cipher_operation cipher_op,
2296 enum rte_crypto_auth_operation auth_op,
2297 enum rte_crypto_auth_algorithm auth_algo,
2298 enum rte_crypto_cipher_algorithm cipher_algo,
2299 const struct wireless_test_data *tdata)
2301 const uint8_t key_len = tdata->key.len;
2302 uint8_t cipher_auth_key[key_len];
2304 struct crypto_testsuite_params *ts_params = &testsuite_params;
2305 struct crypto_unittest_params *ut_params = &unittest_params;
2306 const uint8_t *key = tdata->key.data;
2307 const uint8_t auth_len = tdata->digest.len;
2308 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2309 uint8_t auth_iv_len = tdata->auth_iv.len;
2311 memcpy(cipher_auth_key, key, key_len);
2313 /* Setup Authentication Parameters */
2314 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2315 ut_params->auth_xform.next = NULL;
2317 ut_params->auth_xform.auth.op = auth_op;
2318 ut_params->auth_xform.auth.algo = auth_algo;
2319 ut_params->auth_xform.auth.key.length = key_len;
2320 /* Hash key = cipher key */
2321 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2322 ut_params->auth_xform.auth.digest_length = auth_len;
2323 /* Auth IV will be after cipher IV */
2324 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2325 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2327 /* Setup Cipher Parameters */
2328 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2329 ut_params->cipher_xform.next = &ut_params->auth_xform;
2331 ut_params->cipher_xform.cipher.algo = cipher_algo;
2332 ut_params->cipher_xform.cipher.op = cipher_op;
2333 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2334 ut_params->cipher_xform.cipher.key.length = key_len;
2335 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2336 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2339 debug_hexdump(stdout, "key:", key, key_len);
2341 /* Create Crypto session*/
2342 ut_params->sess = rte_cryptodev_sym_session_create(
2343 ts_params->session_mpool);
2345 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2346 &ut_params->cipher_xform, ts_params->session_mpool);
2348 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2353 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2354 const struct wireless_test_data *tdata)
2356 return create_wireless_cipher_auth_session(dev_id,
2357 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2358 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2359 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2363 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2364 enum rte_crypto_cipher_operation cipher_op,
2365 enum rte_crypto_auth_operation auth_op,
2366 enum rte_crypto_auth_algorithm auth_algo,
2367 enum rte_crypto_cipher_algorithm cipher_algo,
2368 const uint8_t *key, const uint8_t key_len,
2369 uint8_t auth_iv_len, uint8_t auth_len,
2370 uint8_t cipher_iv_len)
2372 uint8_t auth_cipher_key[key_len];
2374 struct crypto_testsuite_params *ts_params = &testsuite_params;
2375 struct crypto_unittest_params *ut_params = &unittest_params;
2377 memcpy(auth_cipher_key, key, key_len);
2379 /* Setup Authentication Parameters */
2380 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2381 ut_params->auth_xform.auth.op = auth_op;
2382 ut_params->auth_xform.next = &ut_params->cipher_xform;
2383 ut_params->auth_xform.auth.algo = auth_algo;
2384 ut_params->auth_xform.auth.key.length = key_len;
2385 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2386 ut_params->auth_xform.auth.digest_length = auth_len;
2387 /* Auth IV will be after cipher IV */
2388 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2389 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2391 /* Setup Cipher Parameters */
2392 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2393 ut_params->cipher_xform.next = NULL;
2394 ut_params->cipher_xform.cipher.algo = cipher_algo;
2395 ut_params->cipher_xform.cipher.op = cipher_op;
2396 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2397 ut_params->cipher_xform.cipher.key.length = key_len;
2398 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2399 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2401 debug_hexdump(stdout, "key:", key, key_len);
2403 /* Create Crypto session*/
2404 ut_params->sess = rte_cryptodev_sym_session_create(
2405 ts_params->session_mpool);
2407 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2408 &ut_params->auth_xform, ts_params->session_mpool);
2410 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2416 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2417 unsigned int auth_tag_len,
2418 const uint8_t *iv, unsigned int iv_len,
2419 unsigned int data_pad_len,
2420 enum rte_crypto_auth_operation op,
2421 unsigned int auth_len, unsigned int auth_offset)
2423 struct crypto_testsuite_params *ts_params = &testsuite_params;
2425 struct crypto_unittest_params *ut_params = &unittest_params;
2427 /* Generate Crypto op data structure */
2428 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2429 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2430 TEST_ASSERT_NOT_NULL(ut_params->op,
2431 "Failed to allocate pktmbuf offload");
2433 /* Set crypto operation data parameters */
2434 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2436 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2438 /* set crypto operation source mbuf */
2439 sym_op->m_src = ut_params->ibuf;
2442 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2445 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2446 ut_params->ibuf, auth_tag_len);
2448 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2449 "no room to append auth tag");
2450 ut_params->digest = sym_op->auth.digest.data;
2451 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2452 ut_params->ibuf, data_pad_len);
2453 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2454 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2456 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2458 debug_hexdump(stdout, "digest:",
2459 sym_op->auth.digest.data,
2462 sym_op->auth.data.length = auth_len;
2463 sym_op->auth.data.offset = auth_offset;
2469 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2470 enum rte_crypto_auth_operation op)
2472 struct crypto_testsuite_params *ts_params = &testsuite_params;
2473 struct crypto_unittest_params *ut_params = &unittest_params;
2475 const uint8_t *auth_tag = tdata->digest.data;
2476 const unsigned int auth_tag_len = tdata->digest.len;
2477 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2478 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2480 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2481 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2482 const uint8_t *auth_iv = tdata->auth_iv.data;
2483 const uint8_t auth_iv_len = tdata->auth_iv.len;
2484 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2485 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2487 /* Generate Crypto op data structure */
2488 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2489 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2490 TEST_ASSERT_NOT_NULL(ut_params->op,
2491 "Failed to allocate pktmbuf offload");
2492 /* Set crypto operation data parameters */
2493 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2495 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2497 /* set crypto operation source mbuf */
2498 sym_op->m_src = ut_params->ibuf;
2501 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2502 ut_params->ibuf, auth_tag_len);
2504 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2505 "no room to append auth tag");
2506 ut_params->digest = sym_op->auth.digest.data;
2507 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2508 ut_params->ibuf, data_pad_len);
2509 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2510 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2512 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2514 debug_hexdump(stdout, "digest:",
2515 sym_op->auth.digest.data,
2518 /* Copy cipher and auth IVs at the end of the crypto operation */
2519 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2521 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2522 iv_ptr += cipher_iv_len;
2523 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2525 sym_op->cipher.data.length = cipher_len;
2526 sym_op->cipher.data.offset = 0;
2527 sym_op->auth.data.length = auth_len;
2528 sym_op->auth.data.offset = 0;
2534 create_zuc_cipher_hash_generate_operation(
2535 const struct wireless_test_data *tdata)
2537 return create_wireless_cipher_hash_operation(tdata,
2538 RTE_CRYPTO_AUTH_OP_GENERATE);
2542 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2543 const unsigned auth_tag_len,
2544 const uint8_t *auth_iv, uint8_t auth_iv_len,
2545 unsigned data_pad_len,
2546 enum rte_crypto_auth_operation op,
2547 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2548 const unsigned cipher_len, const unsigned cipher_offset,
2549 const unsigned auth_len, const unsigned auth_offset)
2551 struct crypto_testsuite_params *ts_params = &testsuite_params;
2552 struct crypto_unittest_params *ut_params = &unittest_params;
2554 /* Generate Crypto op data structure */
2555 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2556 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2557 TEST_ASSERT_NOT_NULL(ut_params->op,
2558 "Failed to allocate pktmbuf offload");
2559 /* Set crypto operation data parameters */
2560 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2562 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2564 /* set crypto operation source mbuf */
2565 sym_op->m_src = ut_params->ibuf;
2568 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2569 ut_params->ibuf, auth_tag_len);
2571 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2572 "no room to append auth tag");
2573 ut_params->digest = sym_op->auth.digest.data;
2574 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2575 ut_params->ibuf, data_pad_len);
2576 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2577 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2579 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2581 debug_hexdump(stdout, "digest:",
2582 sym_op->auth.digest.data,
2585 /* Copy cipher and auth IVs at the end of the crypto operation */
2586 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2588 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2589 iv_ptr += cipher_iv_len;
2590 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2592 sym_op->cipher.data.length = cipher_len;
2593 sym_op->cipher.data.offset = cipher_offset;
2594 sym_op->auth.data.length = auth_len;
2595 sym_op->auth.data.offset = auth_offset;
2601 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2602 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2603 const uint8_t *auth_iv, uint8_t auth_iv_len,
2604 unsigned int data_pad_len,
2605 unsigned int cipher_len, unsigned int cipher_offset,
2606 unsigned int auth_len, unsigned int auth_offset)
2608 struct crypto_testsuite_params *ts_params = &testsuite_params;
2609 struct crypto_unittest_params *ut_params = &unittest_params;
2611 /* Generate Crypto op data structure */
2612 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2613 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2614 TEST_ASSERT_NOT_NULL(ut_params->op,
2615 "Failed to allocate pktmbuf offload");
2617 /* Set crypto operation data parameters */
2618 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2620 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2622 /* set crypto operation source mbuf */
2623 sym_op->m_src = ut_params->ibuf;
2626 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2627 ut_params->ibuf, auth_tag_len);
2629 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2630 "no room to append auth tag");
2632 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2633 ut_params->ibuf, data_pad_len);
2635 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2637 debug_hexdump(stdout, "digest:",
2638 sym_op->auth.digest.data,
2641 /* Copy cipher and auth IVs at the end of the crypto operation */
2642 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2644 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2645 iv_ptr += cipher_iv_len;
2646 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2648 sym_op->cipher.data.length = cipher_len;
2649 sym_op->cipher.data.offset = cipher_offset;
2651 sym_op->auth.data.length = auth_len;
2652 sym_op->auth.data.offset = auth_offset;
2658 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2660 struct crypto_testsuite_params *ts_params = &testsuite_params;
2661 struct crypto_unittest_params *ut_params = &unittest_params;
2664 unsigned plaintext_pad_len;
2665 unsigned plaintext_len;
2668 /* Create SNOW 3G session */
2669 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2670 tdata->key.data, tdata->key.len,
2671 tdata->auth_iv.len, tdata->digest.len,
2672 RTE_CRYPTO_AUTH_OP_GENERATE,
2673 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2677 /* alloc mbuf and set payload */
2678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2680 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2681 rte_pktmbuf_tailroom(ut_params->ibuf));
2683 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2684 /* Append data which is padded to a multiple of */
2685 /* the algorithms block size */
2686 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2687 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2689 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2691 /* Create SNOW 3G operation */
2692 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2693 tdata->auth_iv.data, tdata->auth_iv.len,
2694 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2695 tdata->validAuthLenInBits.len,
2700 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2702 ut_params->obuf = ut_params->op->sym->m_src;
2703 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2704 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2705 + plaintext_pad_len;
2708 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2711 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2712 "SNOW 3G Generated auth tag not as expected");
2718 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2720 struct crypto_testsuite_params *ts_params = &testsuite_params;
2721 struct crypto_unittest_params *ut_params = &unittest_params;
2724 unsigned plaintext_pad_len;
2725 unsigned plaintext_len;
2728 /* Create SNOW 3G session */
2729 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2730 tdata->key.data, tdata->key.len,
2731 tdata->auth_iv.len, tdata->digest.len,
2732 RTE_CRYPTO_AUTH_OP_VERIFY,
2733 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2736 /* alloc mbuf and set payload */
2737 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2739 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2740 rte_pktmbuf_tailroom(ut_params->ibuf));
2742 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2743 /* Append data which is padded to a multiple of */
2744 /* the algorithms block size */
2745 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2746 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2748 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2750 /* Create SNOW 3G operation */
2751 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2753 tdata->auth_iv.data, tdata->auth_iv.len,
2755 RTE_CRYPTO_AUTH_OP_VERIFY,
2756 tdata->validAuthLenInBits.len,
2761 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2763 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2764 ut_params->obuf = ut_params->op->sym->m_src;
2765 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2766 + plaintext_pad_len;
2769 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2778 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2780 struct crypto_testsuite_params *ts_params = &testsuite_params;
2781 struct crypto_unittest_params *ut_params = &unittest_params;
2784 unsigned plaintext_pad_len;
2785 unsigned plaintext_len;
2788 /* Create KASUMI session */
2789 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2790 tdata->key.data, tdata->key.len,
2791 0, tdata->digest.len,
2792 RTE_CRYPTO_AUTH_OP_GENERATE,
2793 RTE_CRYPTO_AUTH_KASUMI_F9);
2797 /* alloc mbuf and set payload */
2798 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2800 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2801 rte_pktmbuf_tailroom(ut_params->ibuf));
2803 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2804 /* Append data which is padded to a multiple of */
2805 /* the algorithms block size */
2806 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2807 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2809 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2811 /* Create KASUMI operation */
2812 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2814 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2815 tdata->plaintext.len,
2820 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2822 ut_params->obuf = ut_params->op->sym->m_src;
2823 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2824 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2825 + plaintext_pad_len;
2828 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2831 DIGEST_BYTE_LENGTH_KASUMI_F9,
2832 "KASUMI Generated auth tag not as expected");
2838 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2840 struct crypto_testsuite_params *ts_params = &testsuite_params;
2841 struct crypto_unittest_params *ut_params = &unittest_params;
2844 unsigned plaintext_pad_len;
2845 unsigned plaintext_len;
2848 /* Create KASUMI session */
2849 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2850 tdata->key.data, tdata->key.len,
2851 0, tdata->digest.len,
2852 RTE_CRYPTO_AUTH_OP_VERIFY,
2853 RTE_CRYPTO_AUTH_KASUMI_F9);
2856 /* alloc mbuf and set payload */
2857 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2859 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2860 rte_pktmbuf_tailroom(ut_params->ibuf));
2862 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2863 /* Append data which is padded to a multiple */
2864 /* of the algorithms block size */
2865 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2866 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2868 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2870 /* Create KASUMI operation */
2871 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2875 RTE_CRYPTO_AUTH_OP_VERIFY,
2876 tdata->plaintext.len,
2881 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2883 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2884 ut_params->obuf = ut_params->op->sym->m_src;
2885 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2886 + plaintext_pad_len;
2889 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2898 test_snow3g_hash_generate_test_case_1(void)
2900 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2904 test_snow3g_hash_generate_test_case_2(void)
2906 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2910 test_snow3g_hash_generate_test_case_3(void)
2912 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2916 test_snow3g_hash_generate_test_case_4(void)
2918 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2922 test_snow3g_hash_generate_test_case_5(void)
2924 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2928 test_snow3g_hash_generate_test_case_6(void)
2930 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2934 test_snow3g_hash_verify_test_case_1(void)
2936 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2941 test_snow3g_hash_verify_test_case_2(void)
2943 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2947 test_snow3g_hash_verify_test_case_3(void)
2949 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2953 test_snow3g_hash_verify_test_case_4(void)
2955 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2959 test_snow3g_hash_verify_test_case_5(void)
2961 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2965 test_snow3g_hash_verify_test_case_6(void)
2967 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
2971 test_kasumi_hash_generate_test_case_1(void)
2973 return test_kasumi_authentication(&kasumi_hash_test_case_1);
2977 test_kasumi_hash_generate_test_case_2(void)
2979 return test_kasumi_authentication(&kasumi_hash_test_case_2);
2983 test_kasumi_hash_generate_test_case_3(void)
2985 return test_kasumi_authentication(&kasumi_hash_test_case_3);
2989 test_kasumi_hash_generate_test_case_4(void)
2991 return test_kasumi_authentication(&kasumi_hash_test_case_4);
2995 test_kasumi_hash_generate_test_case_5(void)
2997 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3001 test_kasumi_hash_generate_test_case_6(void)
3003 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3007 test_kasumi_hash_verify_test_case_1(void)
3009 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3013 test_kasumi_hash_verify_test_case_2(void)
3015 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3019 test_kasumi_hash_verify_test_case_3(void)
3021 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3025 test_kasumi_hash_verify_test_case_4(void)
3027 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3031 test_kasumi_hash_verify_test_case_5(void)
3033 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3037 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3039 struct crypto_testsuite_params *ts_params = &testsuite_params;
3040 struct crypto_unittest_params *ut_params = &unittest_params;
3043 uint8_t *plaintext, *ciphertext;
3044 unsigned plaintext_pad_len;
3045 unsigned plaintext_len;
3047 /* Create KASUMI session */
3048 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3049 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3050 RTE_CRYPTO_CIPHER_KASUMI_F8,
3051 tdata->key.data, tdata->key.len,
3052 tdata->cipher_iv.len);
3056 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3058 /* Clear mbuf payload */
3059 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3060 rte_pktmbuf_tailroom(ut_params->ibuf));
3062 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3063 /* Append data which is padded to a multiple */
3064 /* of the algorithms block size */
3065 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3066 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3068 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3070 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3072 /* Create KASUMI operation */
3073 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3074 tdata->cipher_iv.len,
3075 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3076 tdata->validCipherOffsetInBits.len);
3080 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3082 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3084 ut_params->obuf = ut_params->op->sym->m_dst;
3085 if (ut_params->obuf)
3086 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3088 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3090 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3092 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3093 (tdata->validCipherOffsetInBits.len >> 3);
3095 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3097 reference_ciphertext,
3098 tdata->validCipherLenInBits.len,
3099 "KASUMI Ciphertext data not as expected");
3104 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3106 struct crypto_testsuite_params *ts_params = &testsuite_params;
3107 struct crypto_unittest_params *ut_params = &unittest_params;
3111 unsigned int plaintext_pad_len;
3112 unsigned int plaintext_len;
3114 uint8_t buffer[10000];
3115 const uint8_t *ciphertext;
3117 struct rte_cryptodev_info dev_info;
3119 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3120 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3121 printf("Device doesn't support scatter-gather. "
3126 /* Create KASUMI session */
3127 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3128 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3129 RTE_CRYPTO_CIPHER_KASUMI_F8,
3130 tdata->key.data, tdata->key.len,
3131 tdata->cipher_iv.len);
3135 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3138 /* Append data which is padded to a multiple */
3139 /* of the algorithms block size */
3140 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3142 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3143 plaintext_pad_len, 10, 0);
3145 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3147 /* Create KASUMI operation */
3148 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3149 tdata->cipher_iv.len,
3150 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3151 tdata->validCipherOffsetInBits.len);
3155 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3157 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3159 ut_params->obuf = ut_params->op->sym->m_dst;
3161 if (ut_params->obuf)
3162 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3163 plaintext_len, buffer);
3165 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3166 tdata->validCipherOffsetInBits.len >> 3,
3167 plaintext_len, buffer);
3170 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3172 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3173 (tdata->validCipherOffsetInBits.len >> 3);
3175 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3177 reference_ciphertext,
3178 tdata->validCipherLenInBits.len,
3179 "KASUMI Ciphertext data not as expected");
3184 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3186 struct crypto_testsuite_params *ts_params = &testsuite_params;
3187 struct crypto_unittest_params *ut_params = &unittest_params;
3190 uint8_t *plaintext, *ciphertext;
3191 unsigned plaintext_pad_len;
3192 unsigned plaintext_len;
3194 /* Create KASUMI session */
3195 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3196 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3197 RTE_CRYPTO_CIPHER_KASUMI_F8,
3198 tdata->key.data, tdata->key.len,
3199 tdata->cipher_iv.len);
3203 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3204 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3206 /* Clear mbuf payload */
3207 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3208 rte_pktmbuf_tailroom(ut_params->ibuf));
3210 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3211 /* Append data which is padded to a multiple */
3212 /* of the algorithms block size */
3213 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3214 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3216 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3217 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3219 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3221 /* Create KASUMI operation */
3222 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3223 tdata->cipher_iv.len,
3224 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3225 tdata->validCipherOffsetInBits.len);
3229 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3231 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3233 ut_params->obuf = ut_params->op->sym->m_dst;
3234 if (ut_params->obuf)
3235 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3237 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3239 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3241 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3242 (tdata->validCipherOffsetInBits.len >> 3);
3244 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3246 reference_ciphertext,
3247 tdata->validCipherLenInBits.len,
3248 "KASUMI Ciphertext data not as expected");
3253 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3255 struct crypto_testsuite_params *ts_params = &testsuite_params;
3256 struct crypto_unittest_params *ut_params = &unittest_params;
3259 unsigned int plaintext_pad_len;
3260 unsigned int plaintext_len;
3262 const uint8_t *ciphertext;
3263 uint8_t buffer[2048];
3265 struct rte_cryptodev_info dev_info;
3267 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3268 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3269 printf("Device doesn't support scatter-gather. "
3274 /* Create KASUMI session */
3275 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3276 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3277 RTE_CRYPTO_CIPHER_KASUMI_F8,
3278 tdata->key.data, tdata->key.len,
3279 tdata->cipher_iv.len);
3283 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3284 /* Append data which is padded to a multiple */
3285 /* of the algorithms block size */
3286 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3288 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3289 plaintext_pad_len, 10, 0);
3290 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3291 plaintext_pad_len, 3, 0);
3293 /* Append data which is padded to a multiple */
3294 /* of the algorithms block size */
3295 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3297 /* Create KASUMI operation */
3298 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3299 tdata->cipher_iv.len,
3300 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3301 tdata->validCipherOffsetInBits.len);
3305 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3307 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3309 ut_params->obuf = ut_params->op->sym->m_dst;
3310 if (ut_params->obuf)
3311 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3312 plaintext_pad_len, buffer);
3314 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3315 tdata->validCipherOffsetInBits.len >> 3,
3316 plaintext_pad_len, buffer);
3318 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3319 (tdata->validCipherOffsetInBits.len >> 3);
3321 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3323 reference_ciphertext,
3324 tdata->validCipherLenInBits.len,
3325 "KASUMI Ciphertext data not as expected");
3331 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3333 struct crypto_testsuite_params *ts_params = &testsuite_params;
3334 struct crypto_unittest_params *ut_params = &unittest_params;
3337 uint8_t *ciphertext, *plaintext;
3338 unsigned ciphertext_pad_len;
3339 unsigned ciphertext_len;
3341 /* Create KASUMI session */
3342 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3343 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3344 RTE_CRYPTO_CIPHER_KASUMI_F8,
3345 tdata->key.data, tdata->key.len,
3346 tdata->cipher_iv.len);
3350 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3351 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3353 /* Clear mbuf payload */
3354 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3355 rte_pktmbuf_tailroom(ut_params->ibuf));
3357 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3358 /* Append data which is padded to a multiple */
3359 /* of the algorithms block size */
3360 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3361 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3362 ciphertext_pad_len);
3363 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3364 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3366 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3368 /* Create KASUMI operation */
3369 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3370 tdata->cipher_iv.len,
3371 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3372 tdata->validCipherOffsetInBits.len);
3376 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3378 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3380 ut_params->obuf = ut_params->op->sym->m_dst;
3381 if (ut_params->obuf)
3382 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3384 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3386 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3388 const uint8_t *reference_plaintext = tdata->plaintext.data +
3389 (tdata->validCipherOffsetInBits.len >> 3);
3391 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3393 reference_plaintext,
3394 tdata->validCipherLenInBits.len,
3395 "KASUMI Plaintext data not as expected");
3400 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3402 struct crypto_testsuite_params *ts_params = &testsuite_params;
3403 struct crypto_unittest_params *ut_params = &unittest_params;
3406 uint8_t *ciphertext, *plaintext;
3407 unsigned ciphertext_pad_len;
3408 unsigned ciphertext_len;
3410 /* Create KASUMI session */
3411 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3412 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3413 RTE_CRYPTO_CIPHER_KASUMI_F8,
3414 tdata->key.data, tdata->key.len,
3415 tdata->cipher_iv.len);
3419 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3421 /* Clear mbuf payload */
3422 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3423 rte_pktmbuf_tailroom(ut_params->ibuf));
3425 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3426 /* Append data which is padded to a multiple */
3427 /* of the algorithms block size */
3428 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3429 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3430 ciphertext_pad_len);
3431 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3433 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3435 /* Create KASUMI operation */
3436 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3437 tdata->cipher_iv.len,
3438 tdata->ciphertext.len,
3439 tdata->validCipherOffsetInBits.len);
3443 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3445 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3447 ut_params->obuf = ut_params->op->sym->m_dst;
3448 if (ut_params->obuf)
3449 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3451 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3453 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3455 const uint8_t *reference_plaintext = tdata->plaintext.data +
3456 (tdata->validCipherOffsetInBits.len >> 3);
3458 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3460 reference_plaintext,
3461 tdata->validCipherLenInBits.len,
3462 "KASUMI Plaintext data not as expected");
3467 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3469 struct crypto_testsuite_params *ts_params = &testsuite_params;
3470 struct crypto_unittest_params *ut_params = &unittest_params;
3473 uint8_t *plaintext, *ciphertext;
3474 unsigned plaintext_pad_len;
3475 unsigned plaintext_len;
3477 /* Create SNOW 3G session */
3478 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3479 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3480 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3481 tdata->key.data, tdata->key.len,
3482 tdata->cipher_iv.len);
3486 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3488 /* Clear mbuf payload */
3489 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3490 rte_pktmbuf_tailroom(ut_params->ibuf));
3492 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3493 /* Append data which is padded to a multiple of */
3494 /* the algorithms block size */
3495 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3496 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3498 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3500 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3502 /* Create SNOW 3G operation */
3503 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3504 tdata->cipher_iv.len,
3505 tdata->validCipherLenInBits.len,
3510 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3512 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3514 ut_params->obuf = ut_params->op->sym->m_dst;
3515 if (ut_params->obuf)
3516 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3518 ciphertext = plaintext;
3520 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3523 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3525 tdata->ciphertext.data,
3526 tdata->validDataLenInBits.len,
3527 "SNOW 3G Ciphertext data not as expected");
3533 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3535 struct crypto_testsuite_params *ts_params = &testsuite_params;
3536 struct crypto_unittest_params *ut_params = &unittest_params;
3537 uint8_t *plaintext, *ciphertext;
3540 unsigned plaintext_pad_len;
3541 unsigned plaintext_len;
3543 /* Create SNOW 3G session */
3544 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3545 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3546 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3547 tdata->key.data, tdata->key.len,
3548 tdata->cipher_iv.len);
3552 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3553 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3555 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3556 "Failed to allocate input buffer in mempool");
3557 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3558 "Failed to allocate output buffer in mempool");
3560 /* Clear mbuf payload */
3561 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3562 rte_pktmbuf_tailroom(ut_params->ibuf));
3564 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3565 /* Append data which is padded to a multiple of */
3566 /* the algorithms block size */
3567 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3568 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3570 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3571 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3573 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3575 /* Create SNOW 3G operation */
3576 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3577 tdata->cipher_iv.len,
3578 tdata->validCipherLenInBits.len,
3583 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3585 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3587 ut_params->obuf = ut_params->op->sym->m_dst;
3588 if (ut_params->obuf)
3589 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3591 ciphertext = plaintext;
3593 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3596 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3598 tdata->ciphertext.data,
3599 tdata->validDataLenInBits.len,
3600 "SNOW 3G Ciphertext data not as expected");
3605 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3607 struct crypto_testsuite_params *ts_params = &testsuite_params;
3608 struct crypto_unittest_params *ut_params = &unittest_params;
3611 unsigned int plaintext_pad_len;
3612 unsigned int plaintext_len;
3613 uint8_t buffer[10000];
3614 const uint8_t *ciphertext;
3616 struct rte_cryptodev_info dev_info;
3618 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3619 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3620 printf("Device doesn't support scatter-gather. "
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 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3635 /* Append data which is padded to a multiple of */
3636 /* the algorithms block size */
3637 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3639 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3640 plaintext_pad_len, 10, 0);
3641 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3642 plaintext_pad_len, 3, 0);
3644 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3645 "Failed to allocate input buffer in mempool");
3646 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3647 "Failed to allocate output buffer in mempool");
3649 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3651 /* Create SNOW 3G operation */
3652 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3653 tdata->cipher_iv.len,
3654 tdata->validCipherLenInBits.len,
3659 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3661 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3663 ut_params->obuf = ut_params->op->sym->m_dst;
3664 if (ut_params->obuf)
3665 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3666 plaintext_len, buffer);
3668 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3669 plaintext_len, buffer);
3671 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3674 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3676 tdata->ciphertext.data,
3677 tdata->validDataLenInBits.len,
3678 "SNOW 3G Ciphertext data not as expected");
3683 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3685 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3687 uint8_t curr_byte, prev_byte;
3688 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3689 uint8_t lower_byte_mask = (1 << offset) - 1;
3692 prev_byte = buffer[0];
3693 buffer[0] >>= offset;
3695 for (i = 1; i < length_in_bytes; i++) {
3696 curr_byte = buffer[i];
3697 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3698 (curr_byte >> offset);
3699 prev_byte = curr_byte;
3704 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3706 struct crypto_testsuite_params *ts_params = &testsuite_params;
3707 struct crypto_unittest_params *ut_params = &unittest_params;
3708 uint8_t *plaintext, *ciphertext;
3710 uint32_t plaintext_len;
3711 uint32_t plaintext_pad_len;
3712 uint8_t extra_offset = 4;
3713 uint8_t *expected_ciphertext_shifted;
3715 /* Create SNOW 3G session */
3716 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3717 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3718 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3719 tdata->key.data, tdata->key.len,
3720 tdata->cipher_iv.len);
3724 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3725 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3727 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3728 "Failed to allocate input buffer in mempool");
3729 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3730 "Failed to allocate output buffer in mempool");
3732 /* Clear mbuf payload */
3733 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3734 rte_pktmbuf_tailroom(ut_params->ibuf));
3736 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3738 * Append data which is padded to a
3739 * multiple of the algorithms block size
3741 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3743 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3746 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3748 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3749 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3751 #ifdef RTE_APP_TEST_DEBUG
3752 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3754 /* Create SNOW 3G operation */
3755 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3756 tdata->cipher_iv.len,
3757 tdata->validCipherLenInBits.len,
3762 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3764 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3766 ut_params->obuf = ut_params->op->sym->m_dst;
3767 if (ut_params->obuf)
3768 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3770 ciphertext = plaintext;
3772 #ifdef RTE_APP_TEST_DEBUG
3773 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3776 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3778 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3779 "failed to reserve memory for ciphertext shifted\n");
3781 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3782 ceil_byte_length(tdata->ciphertext.len));
3783 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3786 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3788 expected_ciphertext_shifted,
3789 tdata->validDataLenInBits.len,
3791 "SNOW 3G Ciphertext data not as expected");
3795 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3797 struct crypto_testsuite_params *ts_params = &testsuite_params;
3798 struct crypto_unittest_params *ut_params = &unittest_params;
3802 uint8_t *plaintext, *ciphertext;
3803 unsigned ciphertext_pad_len;
3804 unsigned ciphertext_len;
3806 /* Create SNOW 3G session */
3807 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3808 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3809 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3810 tdata->key.data, tdata->key.len,
3811 tdata->cipher_iv.len);
3815 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3817 /* Clear mbuf payload */
3818 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3819 rte_pktmbuf_tailroom(ut_params->ibuf));
3821 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3822 /* Append data which is padded to a multiple of */
3823 /* the algorithms block size */
3824 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3825 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3826 ciphertext_pad_len);
3827 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3829 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3831 /* Create SNOW 3G operation */
3832 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3833 tdata->cipher_iv.len,
3834 tdata->validCipherLenInBits.len,
3839 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3841 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3842 ut_params->obuf = ut_params->op->sym->m_dst;
3843 if (ut_params->obuf)
3844 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3846 plaintext = ciphertext;
3848 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3851 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3852 tdata->plaintext.data,
3853 tdata->validDataLenInBits.len,
3854 "SNOW 3G Plaintext data not as expected");
3858 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3860 struct crypto_testsuite_params *ts_params = &testsuite_params;
3861 struct crypto_unittest_params *ut_params = &unittest_params;
3865 uint8_t *plaintext, *ciphertext;
3866 unsigned ciphertext_pad_len;
3867 unsigned ciphertext_len;
3869 /* Create SNOW 3G session */
3870 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3871 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3872 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3873 tdata->key.data, tdata->key.len,
3874 tdata->cipher_iv.len);
3878 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3879 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3881 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3882 "Failed to allocate input buffer");
3883 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3884 "Failed to allocate output buffer");
3886 /* Clear mbuf payload */
3887 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3888 rte_pktmbuf_tailroom(ut_params->ibuf));
3890 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3891 rte_pktmbuf_tailroom(ut_params->obuf));
3893 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3894 /* Append data which is padded to a multiple of */
3895 /* the algorithms block size */
3896 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3897 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3898 ciphertext_pad_len);
3899 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3900 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3902 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3904 /* Create SNOW 3G operation */
3905 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3906 tdata->cipher_iv.len,
3907 tdata->validCipherLenInBits.len,
3912 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3914 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3915 ut_params->obuf = ut_params->op->sym->m_dst;
3916 if (ut_params->obuf)
3917 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3919 plaintext = ciphertext;
3921 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3924 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3925 tdata->plaintext.data,
3926 tdata->validDataLenInBits.len,
3927 "SNOW 3G Plaintext data not as expected");
3932 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3934 struct crypto_testsuite_params *ts_params = &testsuite_params;
3935 struct crypto_unittest_params *ut_params = &unittest_params;
3939 uint8_t *plaintext, *ciphertext;
3940 unsigned int plaintext_pad_len;
3941 unsigned int plaintext_len;
3943 struct rte_cryptodev_sym_capability_idx cap_idx;
3945 /* Check if device supports ZUC EEA3 */
3946 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3947 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3949 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3953 /* Check if device supports ZUC EIA3 */
3954 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3955 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3957 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3961 /* Create ZUC session */
3962 retval = create_zuc_cipher_auth_encrypt_generate_session(
3963 ts_params->valid_devs[0],
3967 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3969 /* clear mbuf payload */
3970 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3971 rte_pktmbuf_tailroom(ut_params->ibuf));
3973 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3974 /* Append data which is padded to a multiple of */
3975 /* the algorithms block size */
3976 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3977 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3979 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3981 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3983 /* Create ZUC operation */
3984 retval = create_zuc_cipher_hash_generate_operation(tdata);
3988 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3990 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3991 ut_params->obuf = ut_params->op->sym->m_src;
3992 if (ut_params->obuf)
3993 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3995 ciphertext = plaintext;
3997 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3999 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4001 tdata->ciphertext.data,
4002 tdata->validDataLenInBits.len,
4003 "ZUC Ciphertext data not as expected");
4005 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4006 + plaintext_pad_len;
4009 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4013 "ZUC Generated auth tag not as expected");
4018 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4020 struct crypto_testsuite_params *ts_params = &testsuite_params;
4021 struct crypto_unittest_params *ut_params = &unittest_params;
4025 uint8_t *plaintext, *ciphertext;
4026 unsigned plaintext_pad_len;
4027 unsigned plaintext_len;
4029 /* Create SNOW 3G session */
4030 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4031 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4032 RTE_CRYPTO_AUTH_OP_GENERATE,
4033 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4034 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4035 tdata->key.data, tdata->key.len,
4036 tdata->auth_iv.len, tdata->digest.len,
4037 tdata->cipher_iv.len);
4040 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4042 /* clear mbuf payload */
4043 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4044 rte_pktmbuf_tailroom(ut_params->ibuf));
4046 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4047 /* Append data which is padded to a multiple of */
4048 /* the algorithms block size */
4049 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4050 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4052 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4054 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4056 /* Create SNOW 3G operation */
4057 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4058 tdata->digest.len, tdata->auth_iv.data,
4060 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4061 tdata->cipher_iv.data, tdata->cipher_iv.len,
4062 tdata->validCipherLenInBits.len,
4064 tdata->validAuthLenInBits.len,
4070 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4072 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4073 ut_params->obuf = ut_params->op->sym->m_src;
4074 if (ut_params->obuf)
4075 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4077 ciphertext = plaintext;
4079 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4081 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4083 tdata->ciphertext.data,
4084 tdata->validDataLenInBits.len,
4085 "SNOW 3G Ciphertext data not as expected");
4087 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4088 + plaintext_pad_len;
4091 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4094 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4095 "SNOW 3G Generated auth tag not as expected");
4099 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4101 struct crypto_testsuite_params *ts_params = &testsuite_params;
4102 struct crypto_unittest_params *ut_params = &unittest_params;
4106 uint8_t *plaintext, *ciphertext;
4107 unsigned plaintext_pad_len;
4108 unsigned plaintext_len;
4110 /* Create SNOW 3G session */
4111 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4112 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4113 RTE_CRYPTO_AUTH_OP_GENERATE,
4114 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4115 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4116 tdata->key.data, tdata->key.len,
4117 tdata->auth_iv.len, tdata->digest.len,
4118 tdata->cipher_iv.len);
4122 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4124 /* clear mbuf payload */
4125 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4126 rte_pktmbuf_tailroom(ut_params->ibuf));
4128 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4129 /* Append data which is padded to a multiple of */
4130 /* the algorithms block size */
4131 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4132 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4134 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4136 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4138 /* Create SNOW 3G operation */
4139 retval = create_wireless_algo_auth_cipher_operation(
4141 tdata->cipher_iv.data, tdata->cipher_iv.len,
4142 tdata->auth_iv.data, tdata->auth_iv.len,
4144 tdata->validCipherLenInBits.len,
4146 tdata->validAuthLenInBits.len,
4152 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4154 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4155 ut_params->obuf = ut_params->op->sym->m_src;
4156 if (ut_params->obuf)
4157 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4159 ciphertext = plaintext;
4161 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4162 + plaintext_pad_len;
4163 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4166 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4168 tdata->ciphertext.data,
4169 tdata->validDataLenInBits.len,
4170 "SNOW 3G Ciphertext data not as expected");
4173 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4176 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4177 "SNOW 3G Generated auth tag not as expected");
4182 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4184 struct crypto_testsuite_params *ts_params = &testsuite_params;
4185 struct crypto_unittest_params *ut_params = &unittest_params;
4189 uint8_t *plaintext, *ciphertext;
4190 unsigned plaintext_pad_len;
4191 unsigned plaintext_len;
4193 /* Create KASUMI session */
4194 retval = create_wireless_algo_auth_cipher_session(
4195 ts_params->valid_devs[0],
4196 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4197 RTE_CRYPTO_AUTH_OP_GENERATE,
4198 RTE_CRYPTO_AUTH_KASUMI_F9,
4199 RTE_CRYPTO_CIPHER_KASUMI_F8,
4200 tdata->key.data, tdata->key.len,
4201 0, tdata->digest.len,
4202 tdata->cipher_iv.len);
4205 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4207 /* clear mbuf payload */
4208 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4209 rte_pktmbuf_tailroom(ut_params->ibuf));
4211 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4212 /* Append data which is padded to a multiple of */
4213 /* the algorithms block size */
4214 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4215 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4217 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4219 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4221 /* Create KASUMI operation */
4222 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4223 tdata->cipher_iv.data, tdata->cipher_iv.len,
4226 tdata->validCipherLenInBits.len,
4227 tdata->validCipherOffsetInBits.len,
4228 tdata->validAuthLenInBits.len,
4235 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4237 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4238 if (ut_params->op->sym->m_dst)
4239 ut_params->obuf = ut_params->op->sym->m_dst;
4241 ut_params->obuf = ut_params->op->sym->m_src;
4243 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4244 tdata->validCipherOffsetInBits.len >> 3);
4246 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4247 (tdata->validCipherOffsetInBits.len >> 3);
4249 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4251 reference_ciphertext,
4252 tdata->validCipherLenInBits.len,
4253 "KASUMI Ciphertext data not as expected");
4254 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4255 + plaintext_pad_len;
4258 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4261 DIGEST_BYTE_LENGTH_KASUMI_F9,
4262 "KASUMI Generated auth tag not as expected");
4267 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4269 struct crypto_testsuite_params *ts_params = &testsuite_params;
4270 struct crypto_unittest_params *ut_params = &unittest_params;
4274 uint8_t *plaintext, *ciphertext;
4275 unsigned plaintext_pad_len;
4276 unsigned plaintext_len;
4278 /* Create KASUMI session */
4279 retval = create_wireless_algo_cipher_auth_session(
4280 ts_params->valid_devs[0],
4281 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4282 RTE_CRYPTO_AUTH_OP_GENERATE,
4283 RTE_CRYPTO_AUTH_KASUMI_F9,
4284 RTE_CRYPTO_CIPHER_KASUMI_F8,
4285 tdata->key.data, tdata->key.len,
4286 0, tdata->digest.len,
4287 tdata->cipher_iv.len);
4291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4293 /* clear mbuf payload */
4294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4295 rte_pktmbuf_tailroom(ut_params->ibuf));
4297 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4298 /* Append data which is padded to a multiple of */
4299 /* the algorithms block size */
4300 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4301 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4303 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4305 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4307 /* Create KASUMI operation */
4308 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4309 tdata->digest.len, NULL, 0,
4310 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4311 tdata->cipher_iv.data, tdata->cipher_iv.len,
4312 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4313 tdata->validCipherOffsetInBits.len,
4314 tdata->validAuthLenInBits.len,
4320 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4322 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4324 if (ut_params->op->sym->m_dst)
4325 ut_params->obuf = ut_params->op->sym->m_dst;
4327 ut_params->obuf = ut_params->op->sym->m_src;
4329 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4330 tdata->validCipherOffsetInBits.len >> 3);
4332 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4333 + plaintext_pad_len;
4335 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4336 (tdata->validCipherOffsetInBits.len >> 3);
4338 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4340 reference_ciphertext,
4341 tdata->validCipherLenInBits.len,
4342 "KASUMI Ciphertext data not as expected");
4345 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4348 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4349 "KASUMI Generated auth tag not as expected");
4354 test_zuc_encryption(const struct wireless_test_data *tdata)
4356 struct crypto_testsuite_params *ts_params = &testsuite_params;
4357 struct crypto_unittest_params *ut_params = &unittest_params;
4360 uint8_t *plaintext, *ciphertext;
4361 unsigned plaintext_pad_len;
4362 unsigned plaintext_len;
4364 struct rte_cryptodev_sym_capability_idx cap_idx;
4366 /* Check if device supports ZUC EEA3 */
4367 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4368 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4370 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4374 /* Create ZUC session */
4375 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4376 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4377 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4378 tdata->key.data, tdata->key.len,
4379 tdata->cipher_iv.len);
4383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4385 /* Clear mbuf payload */
4386 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4387 rte_pktmbuf_tailroom(ut_params->ibuf));
4389 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4390 /* Append data which is padded to a multiple */
4391 /* of the algorithms block size */
4392 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4393 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4395 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4397 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4399 /* Create ZUC operation */
4400 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4401 tdata->cipher_iv.len,
4402 tdata->plaintext.len,
4407 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4409 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4411 ut_params->obuf = ut_params->op->sym->m_dst;
4412 if (ut_params->obuf)
4413 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4415 ciphertext = plaintext;
4417 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4420 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4422 tdata->ciphertext.data,
4423 tdata->validCipherLenInBits.len,
4424 "ZUC Ciphertext data not as expected");
4429 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4431 struct crypto_testsuite_params *ts_params = &testsuite_params;
4432 struct crypto_unittest_params *ut_params = &unittest_params;
4436 unsigned int plaintext_pad_len;
4437 unsigned int plaintext_len;
4438 const uint8_t *ciphertext;
4439 uint8_t ciphertext_buffer[2048];
4440 struct rte_cryptodev_info dev_info;
4442 struct rte_cryptodev_sym_capability_idx cap_idx;
4444 /* Check if device supports ZUC EEA3 */
4445 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4446 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4448 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4452 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4453 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4454 printf("Device doesn't support scatter-gather. "
4459 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4461 /* Append data which is padded to a multiple */
4462 /* of the algorithms block size */
4463 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4465 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4466 plaintext_pad_len, 10, 0);
4468 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4469 tdata->plaintext.data);
4471 /* Create ZUC session */
4472 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4473 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4474 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4475 tdata->key.data, tdata->key.len,
4476 tdata->cipher_iv.len);
4480 /* Clear mbuf payload */
4482 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4484 /* Create ZUC operation */
4485 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4486 tdata->cipher_iv.len, tdata->plaintext.len,
4491 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4493 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4495 ut_params->obuf = ut_params->op->sym->m_dst;
4496 if (ut_params->obuf)
4497 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4498 0, plaintext_len, ciphertext_buffer);
4500 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4501 0, plaintext_len, ciphertext_buffer);
4504 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4507 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4509 tdata->ciphertext.data,
4510 tdata->validCipherLenInBits.len,
4511 "ZUC Ciphertext data not as expected");
4517 test_zuc_authentication(const struct wireless_test_data *tdata)
4519 struct crypto_testsuite_params *ts_params = &testsuite_params;
4520 struct crypto_unittest_params *ut_params = &unittest_params;
4523 unsigned plaintext_pad_len;
4524 unsigned plaintext_len;
4527 struct rte_cryptodev_sym_capability_idx cap_idx;
4529 /* Check if device supports ZUC EIA3 */
4530 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4531 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4533 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4537 /* Create ZUC session */
4538 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4539 tdata->key.data, tdata->key.len,
4540 tdata->auth_iv.len, tdata->digest.len,
4541 RTE_CRYPTO_AUTH_OP_GENERATE,
4542 RTE_CRYPTO_AUTH_ZUC_EIA3);
4546 /* alloc mbuf and set payload */
4547 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4549 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4550 rte_pktmbuf_tailroom(ut_params->ibuf));
4552 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4553 /* Append data which is padded to a multiple of */
4554 /* the algorithms block size */
4555 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4556 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4558 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4560 /* Create ZUC operation */
4561 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4562 tdata->auth_iv.data, tdata->auth_iv.len,
4563 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4564 tdata->validAuthLenInBits.len,
4569 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4571 ut_params->obuf = ut_params->op->sym->m_src;
4572 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4573 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4574 + plaintext_pad_len;
4577 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4580 DIGEST_BYTE_LENGTH_KASUMI_F9,
4581 "ZUC Generated auth tag not as expected");
4587 test_kasumi_encryption_test_case_1(void)
4589 return test_kasumi_encryption(&kasumi_test_case_1);
4593 test_kasumi_encryption_test_case_1_sgl(void)
4595 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4599 test_kasumi_encryption_test_case_1_oop(void)
4601 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4605 test_kasumi_encryption_test_case_1_oop_sgl(void)
4607 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4611 test_kasumi_encryption_test_case_2(void)
4613 return test_kasumi_encryption(&kasumi_test_case_2);
4617 test_kasumi_encryption_test_case_3(void)
4619 return test_kasumi_encryption(&kasumi_test_case_3);
4623 test_kasumi_encryption_test_case_4(void)
4625 return test_kasumi_encryption(&kasumi_test_case_4);
4629 test_kasumi_encryption_test_case_5(void)
4631 return test_kasumi_encryption(&kasumi_test_case_5);
4635 test_kasumi_decryption_test_case_1(void)
4637 return test_kasumi_decryption(&kasumi_test_case_1);
4641 test_kasumi_decryption_test_case_1_oop(void)
4643 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4647 test_kasumi_decryption_test_case_2(void)
4649 return test_kasumi_decryption(&kasumi_test_case_2);
4653 test_kasumi_decryption_test_case_3(void)
4655 return test_kasumi_decryption(&kasumi_test_case_3);
4659 test_kasumi_decryption_test_case_4(void)
4661 return test_kasumi_decryption(&kasumi_test_case_4);
4665 test_kasumi_decryption_test_case_5(void)
4667 return test_kasumi_decryption(&kasumi_test_case_5);
4670 test_snow3g_encryption_test_case_1(void)
4672 return test_snow3g_encryption(&snow3g_test_case_1);
4676 test_snow3g_encryption_test_case_1_oop(void)
4678 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4682 test_snow3g_encryption_test_case_1_oop_sgl(void)
4684 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4689 test_snow3g_encryption_test_case_1_offset_oop(void)
4691 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4695 test_snow3g_encryption_test_case_2(void)
4697 return test_snow3g_encryption(&snow3g_test_case_2);
4701 test_snow3g_encryption_test_case_3(void)
4703 return test_snow3g_encryption(&snow3g_test_case_3);
4707 test_snow3g_encryption_test_case_4(void)
4709 return test_snow3g_encryption(&snow3g_test_case_4);
4713 test_snow3g_encryption_test_case_5(void)
4715 return test_snow3g_encryption(&snow3g_test_case_5);
4719 test_snow3g_decryption_test_case_1(void)
4721 return test_snow3g_decryption(&snow3g_test_case_1);
4725 test_snow3g_decryption_test_case_1_oop(void)
4727 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4731 test_snow3g_decryption_test_case_2(void)
4733 return test_snow3g_decryption(&snow3g_test_case_2);
4737 test_snow3g_decryption_test_case_3(void)
4739 return test_snow3g_decryption(&snow3g_test_case_3);
4743 test_snow3g_decryption_test_case_4(void)
4745 return test_snow3g_decryption(&snow3g_test_case_4);
4749 test_snow3g_decryption_test_case_5(void)
4751 return test_snow3g_decryption(&snow3g_test_case_5);
4754 test_snow3g_cipher_auth_test_case_1(void)
4756 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4760 test_snow3g_auth_cipher_test_case_1(void)
4762 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4766 test_kasumi_auth_cipher_test_case_1(void)
4768 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4772 test_kasumi_cipher_auth_test_case_1(void)
4774 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4778 test_zuc_encryption_test_case_1(void)
4780 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4784 test_zuc_encryption_test_case_2(void)
4786 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4790 test_zuc_encryption_test_case_3(void)
4792 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4796 test_zuc_encryption_test_case_4(void)
4798 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4802 test_zuc_encryption_test_case_5(void)
4804 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4808 test_zuc_encryption_test_case_6_sgl(void)
4810 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4814 test_zuc_hash_generate_test_case_1(void)
4816 return test_zuc_authentication(&zuc_test_case_auth_1b);
4820 test_zuc_hash_generate_test_case_2(void)
4822 return test_zuc_authentication(&zuc_test_case_auth_90b);
4826 test_zuc_hash_generate_test_case_3(void)
4828 return test_zuc_authentication(&zuc_test_case_auth_577b);
4832 test_zuc_hash_generate_test_case_4(void)
4834 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4838 test_zuc_hash_generate_test_case_5(void)
4840 return test_zuc_authentication(&zuc_test_auth_5670b);
4844 test_zuc_hash_generate_test_case_6(void)
4846 return test_zuc_authentication(&zuc_test_case_auth_128b);
4850 test_zuc_hash_generate_test_case_7(void)
4852 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4856 test_zuc_hash_generate_test_case_8(void)
4858 return test_zuc_authentication(&zuc_test_case_auth_584b);
4862 test_zuc_cipher_auth_test_case_1(void)
4864 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4868 test_zuc_cipher_auth_test_case_2(void)
4870 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4874 test_3DES_chain_qat_all(void)
4876 struct crypto_testsuite_params *ts_params = &testsuite_params;
4879 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4880 ts_params->op_mpool,
4881 ts_params->session_mpool,
4882 ts_params->valid_devs[0],
4883 rte_cryptodev_driver_id_get(
4884 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4885 BLKCIPHER_3DES_CHAIN_TYPE);
4887 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4889 return TEST_SUCCESS;
4893 test_DES_cipheronly_qat_all(void)
4895 struct crypto_testsuite_params *ts_params = &testsuite_params;
4898 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4899 ts_params->op_mpool,
4900 ts_params->session_mpool,
4901 ts_params->valid_devs[0],
4902 rte_cryptodev_driver_id_get(
4903 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4904 BLKCIPHER_DES_CIPHERONLY_TYPE);
4906 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4908 return TEST_SUCCESS;
4912 test_DES_cipheronly_openssl_all(void)
4914 struct crypto_testsuite_params *ts_params = &testsuite_params;
4917 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4918 ts_params->op_mpool,
4919 ts_params->session_mpool,
4920 ts_params->valid_devs[0],
4921 rte_cryptodev_driver_id_get(
4922 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4923 BLKCIPHER_DES_CIPHERONLY_TYPE);
4925 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4927 return TEST_SUCCESS;
4931 test_DES_docsis_openssl_all(void)
4933 struct crypto_testsuite_params *ts_params = &testsuite_params;
4936 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4937 ts_params->op_mpool,
4938 ts_params->session_mpool,
4939 ts_params->valid_devs[0],
4940 rte_cryptodev_driver_id_get(
4941 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4942 BLKCIPHER_DES_DOCSIS_TYPE);
4944 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4946 return TEST_SUCCESS;
4950 test_DES_cipheronly_mb_all(void)
4952 struct crypto_testsuite_params *ts_params = &testsuite_params;
4955 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4956 ts_params->op_mpool,
4957 ts_params->session_mpool,
4958 ts_params->valid_devs[0],
4959 rte_cryptodev_driver_id_get(
4960 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4961 BLKCIPHER_DES_CIPHERONLY_TYPE);
4963 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4965 return TEST_SUCCESS;
4969 test_DES_docsis_mb_all(void)
4971 struct crypto_testsuite_params *ts_params = &testsuite_params;
4974 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4975 ts_params->op_mpool,
4976 ts_params->session_mpool,
4977 ts_params->valid_devs[0],
4978 rte_cryptodev_driver_id_get(
4979 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4980 BLKCIPHER_DES_DOCSIS_TYPE);
4982 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4984 return TEST_SUCCESS;
4988 test_3DES_chain_dpaa_sec_all(void)
4990 struct crypto_testsuite_params *ts_params = &testsuite_params;
4993 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4994 ts_params->op_mpool,
4995 ts_params->session_mpool,
4996 ts_params->valid_devs[0],
4997 rte_cryptodev_driver_id_get(
4998 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
4999 BLKCIPHER_3DES_CHAIN_TYPE);
5001 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5003 return TEST_SUCCESS;
5007 test_3DES_cipheronly_dpaa_sec_all(void)
5009 struct crypto_testsuite_params *ts_params = &testsuite_params;
5012 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5013 ts_params->op_mpool,
5014 ts_params->session_mpool,
5015 ts_params->valid_devs[0],
5016 rte_cryptodev_driver_id_get(
5017 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5018 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5020 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5022 return TEST_SUCCESS;
5026 test_3DES_chain_dpaa2_sec_all(void)
5028 struct crypto_testsuite_params *ts_params = &testsuite_params;
5031 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5032 ts_params->op_mpool,
5033 ts_params->session_mpool,
5034 ts_params->valid_devs[0],
5035 rte_cryptodev_driver_id_get(
5036 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5037 BLKCIPHER_3DES_CHAIN_TYPE);
5039 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5041 return TEST_SUCCESS;
5045 test_3DES_cipheronly_dpaa2_sec_all(void)
5047 struct crypto_testsuite_params *ts_params = &testsuite_params;
5050 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5051 ts_params->op_mpool,
5052 ts_params->session_mpool,
5053 ts_params->valid_devs[0],
5054 rte_cryptodev_driver_id_get(
5055 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5056 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5058 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5060 return TEST_SUCCESS;
5064 test_3DES_chain_ccp_all(void)
5066 struct crypto_testsuite_params *ts_params = &testsuite_params;
5069 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5070 ts_params->op_mpool,
5071 ts_params->session_mpool,
5072 ts_params->valid_devs[0],
5073 rte_cryptodev_driver_id_get(
5074 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5075 BLKCIPHER_3DES_CHAIN_TYPE);
5077 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5079 return TEST_SUCCESS;
5083 test_3DES_cipheronly_ccp_all(void)
5085 struct crypto_testsuite_params *ts_params = &testsuite_params;
5088 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5089 ts_params->op_mpool,
5090 ts_params->session_mpool,
5091 ts_params->valid_devs[0],
5092 rte_cryptodev_driver_id_get(
5093 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5094 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5096 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5098 return TEST_SUCCESS;
5102 test_3DES_cipheronly_qat_all(void)
5104 struct crypto_testsuite_params *ts_params = &testsuite_params;
5107 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5108 ts_params->op_mpool,
5109 ts_params->session_mpool,
5110 ts_params->valid_devs[0],
5111 rte_cryptodev_driver_id_get(
5112 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5113 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5115 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5117 return TEST_SUCCESS;
5121 test_3DES_chain_openssl_all(void)
5123 struct crypto_testsuite_params *ts_params = &testsuite_params;
5126 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5127 ts_params->op_mpool,
5128 ts_params->session_mpool,
5129 ts_params->valid_devs[0],
5130 rte_cryptodev_driver_id_get(
5131 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5132 BLKCIPHER_3DES_CHAIN_TYPE);
5134 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5136 return TEST_SUCCESS;
5140 test_3DES_cipheronly_openssl_all(void)
5142 struct crypto_testsuite_params *ts_params = &testsuite_params;
5145 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5146 ts_params->op_mpool,
5147 ts_params->session_mpool,
5148 ts_params->valid_devs[0],
5149 rte_cryptodev_driver_id_get(
5150 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5151 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5153 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5155 return TEST_SUCCESS;
5158 /* ***** AEAD algorithm Tests ***** */
5161 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5162 enum rte_crypto_aead_operation op,
5163 const uint8_t *key, const uint8_t key_len,
5164 const uint16_t aad_len, const uint8_t auth_len,
5167 uint8_t aead_key[key_len];
5169 struct crypto_testsuite_params *ts_params = &testsuite_params;
5170 struct crypto_unittest_params *ut_params = &unittest_params;
5172 memcpy(aead_key, key, key_len);
5174 /* Setup AEAD Parameters */
5175 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5176 ut_params->aead_xform.next = NULL;
5177 ut_params->aead_xform.aead.algo = algo;
5178 ut_params->aead_xform.aead.op = op;
5179 ut_params->aead_xform.aead.key.data = aead_key;
5180 ut_params->aead_xform.aead.key.length = key_len;
5181 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5182 ut_params->aead_xform.aead.iv.length = iv_len;
5183 ut_params->aead_xform.aead.digest_length = auth_len;
5184 ut_params->aead_xform.aead.aad_length = aad_len;
5186 debug_hexdump(stdout, "key:", key, key_len);
5188 /* Create Crypto session*/
5189 ut_params->sess = rte_cryptodev_sym_session_create(
5190 ts_params->session_mpool);
5192 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5193 &ut_params->aead_xform, ts_params->session_mpool);
5195 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5201 create_aead_xform(struct rte_crypto_op *op,
5202 enum rte_crypto_aead_algorithm algo,
5203 enum rte_crypto_aead_operation aead_op,
5204 uint8_t *key, const uint8_t key_len,
5205 const uint8_t aad_len, const uint8_t auth_len,
5208 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5209 "failed to allocate space for crypto transform");
5211 struct rte_crypto_sym_op *sym_op = op->sym;
5213 /* Setup AEAD Parameters */
5214 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5215 sym_op->xform->next = NULL;
5216 sym_op->xform->aead.algo = algo;
5217 sym_op->xform->aead.op = aead_op;
5218 sym_op->xform->aead.key.data = key;
5219 sym_op->xform->aead.key.length = key_len;
5220 sym_op->xform->aead.iv.offset = IV_OFFSET;
5221 sym_op->xform->aead.iv.length = iv_len;
5222 sym_op->xform->aead.digest_length = auth_len;
5223 sym_op->xform->aead.aad_length = aad_len;
5225 debug_hexdump(stdout, "key:", key, key_len);
5231 create_aead_operation(enum rte_crypto_aead_operation op,
5232 const struct aead_test_data *tdata)
5234 struct crypto_testsuite_params *ts_params = &testsuite_params;
5235 struct crypto_unittest_params *ut_params = &unittest_params;
5237 uint8_t *plaintext, *ciphertext;
5238 unsigned int aad_pad_len, plaintext_pad_len;
5240 /* Generate Crypto op data structure */
5241 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5242 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5243 TEST_ASSERT_NOT_NULL(ut_params->op,
5244 "Failed to allocate symmetric crypto operation struct");
5246 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5248 /* Append aad data */
5249 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5250 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5251 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5253 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5254 "no room to append aad");
5256 sym_op->aead.aad.phys_addr =
5257 rte_pktmbuf_iova(ut_params->ibuf);
5258 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5259 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5260 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5263 /* Append IV at the end of the crypto operation*/
5264 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5265 uint8_t *, IV_OFFSET);
5267 /* Copy IV 1 byte after the IV pointer, according to the API */
5268 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5269 debug_hexdump(stdout, "iv:", iv_ptr,
5272 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5273 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5275 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5276 "no room to append aad");
5278 sym_op->aead.aad.phys_addr =
5279 rte_pktmbuf_iova(ut_params->ibuf);
5280 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5281 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5284 /* Append IV at the end of the crypto operation*/
5285 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5286 uint8_t *, IV_OFFSET);
5288 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5289 debug_hexdump(stdout, "iv:", iv_ptr,
5293 /* Append plaintext/ciphertext */
5294 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5295 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5296 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5298 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5300 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5301 debug_hexdump(stdout, "plaintext:", plaintext,
5302 tdata->plaintext.len);
5304 if (ut_params->obuf) {
5305 ciphertext = (uint8_t *)rte_pktmbuf_append(
5307 plaintext_pad_len + aad_pad_len);
5308 TEST_ASSERT_NOT_NULL(ciphertext,
5309 "no room to append ciphertext");
5311 memset(ciphertext + aad_pad_len, 0,
5312 tdata->ciphertext.len);
5315 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5316 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5318 TEST_ASSERT_NOT_NULL(ciphertext,
5319 "no room to append ciphertext");
5321 memcpy(ciphertext, tdata->ciphertext.data,
5322 tdata->ciphertext.len);
5323 debug_hexdump(stdout, "ciphertext:", ciphertext,
5324 tdata->ciphertext.len);
5326 if (ut_params->obuf) {
5327 plaintext = (uint8_t *)rte_pktmbuf_append(
5329 plaintext_pad_len + aad_pad_len);
5330 TEST_ASSERT_NOT_NULL(plaintext,
5331 "no room to append plaintext");
5333 memset(plaintext + aad_pad_len, 0,
5334 tdata->plaintext.len);
5338 /* Append digest data */
5339 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5340 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5341 ut_params->obuf ? ut_params->obuf :
5343 tdata->auth_tag.len);
5344 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5345 "no room to append digest");
5346 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5347 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5348 ut_params->obuf ? ut_params->obuf :
5353 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5354 ut_params->ibuf, tdata->auth_tag.len);
5355 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5356 "no room to append digest");
5357 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5359 plaintext_pad_len + aad_pad_len);
5361 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5362 tdata->auth_tag.len);
5363 debug_hexdump(stdout, "digest:",
5364 sym_op->aead.digest.data,
5365 tdata->auth_tag.len);
5368 sym_op->aead.data.length = tdata->plaintext.len;
5369 sym_op->aead.data.offset = aad_pad_len;
5375 test_authenticated_encryption(const struct aead_test_data *tdata)
5377 struct crypto_testsuite_params *ts_params = &testsuite_params;
5378 struct crypto_unittest_params *ut_params = &unittest_params;
5381 uint8_t *ciphertext, *auth_tag;
5382 uint16_t plaintext_pad_len;
5385 /* Create AEAD session */
5386 retval = create_aead_session(ts_params->valid_devs[0],
5388 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5389 tdata->key.data, tdata->key.len,
5390 tdata->aad.len, tdata->auth_tag.len,
5395 if (tdata->aad.len > MBUF_SIZE) {
5396 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5397 /* Populate full size of add data */
5398 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5399 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5401 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5403 /* clear mbuf payload */
5404 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5405 rte_pktmbuf_tailroom(ut_params->ibuf));
5407 /* Create AEAD operation */
5408 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5412 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5414 ut_params->op->sym->m_src = ut_params->ibuf;
5416 /* Process crypto operation */
5417 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5418 ut_params->op), "failed to process sym crypto op");
5420 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5421 "crypto op processing failed");
5423 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5425 if (ut_params->op->sym->m_dst) {
5426 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5428 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5429 uint8_t *, plaintext_pad_len);
5431 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5433 ut_params->op->sym->cipher.data.offset);
5434 auth_tag = ciphertext + plaintext_pad_len;
5437 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5438 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5441 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5443 tdata->ciphertext.data,
5444 tdata->ciphertext.len,
5445 "Ciphertext data not as expected");
5447 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5449 tdata->auth_tag.data,
5450 tdata->auth_tag.len,
5451 "Generated auth tag not as expected");
5458 test_AES_GCM_authenticated_encryption_test_case_1(void)
5460 return test_authenticated_encryption(&gcm_test_case_1);
5464 test_AES_GCM_authenticated_encryption_test_case_2(void)
5466 return test_authenticated_encryption(&gcm_test_case_2);
5470 test_AES_GCM_authenticated_encryption_test_case_3(void)
5472 return test_authenticated_encryption(&gcm_test_case_3);
5476 test_AES_GCM_authenticated_encryption_test_case_4(void)
5478 return test_authenticated_encryption(&gcm_test_case_4);
5482 test_AES_GCM_authenticated_encryption_test_case_5(void)
5484 return test_authenticated_encryption(&gcm_test_case_5);
5488 test_AES_GCM_authenticated_encryption_test_case_6(void)
5490 return test_authenticated_encryption(&gcm_test_case_6);
5494 test_AES_GCM_authenticated_encryption_test_case_7(void)
5496 return test_authenticated_encryption(&gcm_test_case_7);
5500 test_AES_GCM_auth_encryption_test_case_192_1(void)
5502 return test_authenticated_encryption(&gcm_test_case_192_1);
5506 test_AES_GCM_auth_encryption_test_case_192_2(void)
5508 return test_authenticated_encryption(&gcm_test_case_192_2);
5512 test_AES_GCM_auth_encryption_test_case_192_3(void)
5514 return test_authenticated_encryption(&gcm_test_case_192_3);
5518 test_AES_GCM_auth_encryption_test_case_192_4(void)
5520 return test_authenticated_encryption(&gcm_test_case_192_4);
5524 test_AES_GCM_auth_encryption_test_case_192_5(void)
5526 return test_authenticated_encryption(&gcm_test_case_192_5);
5530 test_AES_GCM_auth_encryption_test_case_192_6(void)
5532 return test_authenticated_encryption(&gcm_test_case_192_6);
5536 test_AES_GCM_auth_encryption_test_case_192_7(void)
5538 return test_authenticated_encryption(&gcm_test_case_192_7);
5542 test_AES_GCM_auth_encryption_test_case_256_1(void)
5544 return test_authenticated_encryption(&gcm_test_case_256_1);
5548 test_AES_GCM_auth_encryption_test_case_256_2(void)
5550 return test_authenticated_encryption(&gcm_test_case_256_2);
5554 test_AES_GCM_auth_encryption_test_case_256_3(void)
5556 return test_authenticated_encryption(&gcm_test_case_256_3);
5560 test_AES_GCM_auth_encryption_test_case_256_4(void)
5562 return test_authenticated_encryption(&gcm_test_case_256_4);
5566 test_AES_GCM_auth_encryption_test_case_256_5(void)
5568 return test_authenticated_encryption(&gcm_test_case_256_5);
5572 test_AES_GCM_auth_encryption_test_case_256_6(void)
5574 return test_authenticated_encryption(&gcm_test_case_256_6);
5578 test_AES_GCM_auth_encryption_test_case_256_7(void)
5580 return test_authenticated_encryption(&gcm_test_case_256_7);
5584 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5586 return test_authenticated_encryption(&gcm_test_case_aad_1);
5590 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5592 return test_authenticated_encryption(&gcm_test_case_aad_2);
5596 test_authenticated_decryption(const struct aead_test_data *tdata)
5598 struct crypto_testsuite_params *ts_params = &testsuite_params;
5599 struct crypto_unittest_params *ut_params = &unittest_params;
5605 /* Create AEAD session */
5606 retval = create_aead_session(ts_params->valid_devs[0],
5608 RTE_CRYPTO_AEAD_OP_DECRYPT,
5609 tdata->key.data, tdata->key.len,
5610 tdata->aad.len, tdata->auth_tag.len,
5615 /* alloc mbuf and set payload */
5616 if (tdata->aad.len > MBUF_SIZE) {
5617 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5618 /* Populate full size of add data */
5619 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5620 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5622 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5624 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5625 rte_pktmbuf_tailroom(ut_params->ibuf));
5627 /* Create AEAD operation */
5628 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5632 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5634 ut_params->op->sym->m_src = ut_params->ibuf;
5636 /* Process crypto operation */
5637 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5638 ut_params->op), "failed to process sym crypto op");
5640 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5641 "crypto op processing failed");
5643 if (ut_params->op->sym->m_dst)
5644 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5647 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5649 ut_params->op->sym->cipher.data.offset);
5651 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5654 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5656 tdata->plaintext.data,
5657 tdata->plaintext.len,
5658 "Plaintext data not as expected");
5660 TEST_ASSERT_EQUAL(ut_params->op->status,
5661 RTE_CRYPTO_OP_STATUS_SUCCESS,
5662 "Authentication failed");
5667 test_AES_GCM_authenticated_decryption_test_case_1(void)
5669 return test_authenticated_decryption(&gcm_test_case_1);
5673 test_AES_GCM_authenticated_decryption_test_case_2(void)
5675 return test_authenticated_decryption(&gcm_test_case_2);
5679 test_AES_GCM_authenticated_decryption_test_case_3(void)
5681 return test_authenticated_decryption(&gcm_test_case_3);
5685 test_AES_GCM_authenticated_decryption_test_case_4(void)
5687 return test_authenticated_decryption(&gcm_test_case_4);
5691 test_AES_GCM_authenticated_decryption_test_case_5(void)
5693 return test_authenticated_decryption(&gcm_test_case_5);
5697 test_AES_GCM_authenticated_decryption_test_case_6(void)
5699 return test_authenticated_decryption(&gcm_test_case_6);
5703 test_AES_GCM_authenticated_decryption_test_case_7(void)
5705 return test_authenticated_decryption(&gcm_test_case_7);
5709 test_AES_GCM_auth_decryption_test_case_192_1(void)
5711 return test_authenticated_decryption(&gcm_test_case_192_1);
5715 test_AES_GCM_auth_decryption_test_case_192_2(void)
5717 return test_authenticated_decryption(&gcm_test_case_192_2);
5721 test_AES_GCM_auth_decryption_test_case_192_3(void)
5723 return test_authenticated_decryption(&gcm_test_case_192_3);
5727 test_AES_GCM_auth_decryption_test_case_192_4(void)
5729 return test_authenticated_decryption(&gcm_test_case_192_4);
5733 test_AES_GCM_auth_decryption_test_case_192_5(void)
5735 return test_authenticated_decryption(&gcm_test_case_192_5);
5739 test_AES_GCM_auth_decryption_test_case_192_6(void)
5741 return test_authenticated_decryption(&gcm_test_case_192_6);
5745 test_AES_GCM_auth_decryption_test_case_192_7(void)
5747 return test_authenticated_decryption(&gcm_test_case_192_7);
5751 test_AES_GCM_auth_decryption_test_case_256_1(void)
5753 return test_authenticated_decryption(&gcm_test_case_256_1);
5757 test_AES_GCM_auth_decryption_test_case_256_2(void)
5759 return test_authenticated_decryption(&gcm_test_case_256_2);
5763 test_AES_GCM_auth_decryption_test_case_256_3(void)
5765 return test_authenticated_decryption(&gcm_test_case_256_3);
5769 test_AES_GCM_auth_decryption_test_case_256_4(void)
5771 return test_authenticated_decryption(&gcm_test_case_256_4);
5775 test_AES_GCM_auth_decryption_test_case_256_5(void)
5777 return test_authenticated_decryption(&gcm_test_case_256_5);
5781 test_AES_GCM_auth_decryption_test_case_256_6(void)
5783 return test_authenticated_decryption(&gcm_test_case_256_6);
5787 test_AES_GCM_auth_decryption_test_case_256_7(void)
5789 return test_authenticated_decryption(&gcm_test_case_256_7);
5793 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5795 return test_authenticated_decryption(&gcm_test_case_aad_1);
5799 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5801 return test_authenticated_decryption(&gcm_test_case_aad_2);
5805 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5807 struct crypto_testsuite_params *ts_params = &testsuite_params;
5808 struct crypto_unittest_params *ut_params = &unittest_params;
5811 uint8_t *ciphertext, *auth_tag;
5812 uint16_t plaintext_pad_len;
5814 /* Create AEAD session */
5815 retval = create_aead_session(ts_params->valid_devs[0],
5817 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5818 tdata->key.data, tdata->key.len,
5819 tdata->aad.len, tdata->auth_tag.len,
5824 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5825 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5827 /* clear mbuf payload */
5828 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5829 rte_pktmbuf_tailroom(ut_params->ibuf));
5830 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5831 rte_pktmbuf_tailroom(ut_params->obuf));
5833 /* Create AEAD operation */
5834 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5838 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5840 ut_params->op->sym->m_src = ut_params->ibuf;
5841 ut_params->op->sym->m_dst = ut_params->obuf;
5843 /* Process crypto operation */
5844 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5845 ut_params->op), "failed to process sym crypto op");
5847 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5848 "crypto op processing failed");
5850 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5852 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5853 ut_params->op->sym->cipher.data.offset);
5854 auth_tag = ciphertext + plaintext_pad_len;
5856 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5857 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5860 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5862 tdata->ciphertext.data,
5863 tdata->ciphertext.len,
5864 "Ciphertext data not as expected");
5866 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5868 tdata->auth_tag.data,
5869 tdata->auth_tag.len,
5870 "Generated auth tag not as expected");
5877 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5879 return test_authenticated_encryption_oop(&gcm_test_case_5);
5883 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5885 struct crypto_testsuite_params *ts_params = &testsuite_params;
5886 struct crypto_unittest_params *ut_params = &unittest_params;
5891 /* Create AEAD session */
5892 retval = create_aead_session(ts_params->valid_devs[0],
5894 RTE_CRYPTO_AEAD_OP_DECRYPT,
5895 tdata->key.data, tdata->key.len,
5896 tdata->aad.len, tdata->auth_tag.len,
5901 /* alloc mbuf and set payload */
5902 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5903 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5905 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5906 rte_pktmbuf_tailroom(ut_params->ibuf));
5907 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5908 rte_pktmbuf_tailroom(ut_params->obuf));
5910 /* Create AEAD operation */
5911 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5915 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5917 ut_params->op->sym->m_src = ut_params->ibuf;
5918 ut_params->op->sym->m_dst = ut_params->obuf;
5920 /* Process crypto operation */
5921 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5922 ut_params->op), "failed to process sym crypto op");
5924 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5925 "crypto op processing failed");
5927 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5928 ut_params->op->sym->cipher.data.offset);
5930 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5933 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5935 tdata->plaintext.data,
5936 tdata->plaintext.len,
5937 "Plaintext data not as expected");
5939 TEST_ASSERT_EQUAL(ut_params->op->status,
5940 RTE_CRYPTO_OP_STATUS_SUCCESS,
5941 "Authentication failed");
5946 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5948 return test_authenticated_decryption_oop(&gcm_test_case_5);
5952 test_authenticated_encryption_sessionless(
5953 const struct aead_test_data *tdata)
5955 struct crypto_testsuite_params *ts_params = &testsuite_params;
5956 struct crypto_unittest_params *ut_params = &unittest_params;
5959 uint8_t *ciphertext, *auth_tag;
5960 uint16_t plaintext_pad_len;
5961 uint8_t key[tdata->key.len + 1];
5963 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5965 /* clear mbuf payload */
5966 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5967 rte_pktmbuf_tailroom(ut_params->ibuf));
5969 /* Create AEAD operation */
5970 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5974 /* Create GCM xform */
5975 memcpy(key, tdata->key.data, tdata->key.len);
5976 retval = create_aead_xform(ut_params->op,
5978 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5979 key, tdata->key.len,
5980 tdata->aad.len, tdata->auth_tag.len,
5985 ut_params->op->sym->m_src = ut_params->ibuf;
5987 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
5988 RTE_CRYPTO_OP_SESSIONLESS,
5989 "crypto op session type not sessionless");
5991 /* Process crypto operation */
5992 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5993 ut_params->op), "failed to process sym crypto op");
5995 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
5997 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5998 "crypto op status not success");
6000 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6002 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6003 ut_params->op->sym->cipher.data.offset);
6004 auth_tag = ciphertext + plaintext_pad_len;
6006 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6007 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6010 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6012 tdata->ciphertext.data,
6013 tdata->ciphertext.len,
6014 "Ciphertext data not as expected");
6016 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6018 tdata->auth_tag.data,
6019 tdata->auth_tag.len,
6020 "Generated auth tag not as expected");
6027 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6029 return test_authenticated_encryption_sessionless(
6034 test_authenticated_decryption_sessionless(
6035 const struct aead_test_data *tdata)
6037 struct crypto_testsuite_params *ts_params = &testsuite_params;
6038 struct crypto_unittest_params *ut_params = &unittest_params;
6042 uint8_t key[tdata->key.len + 1];
6044 /* alloc mbuf and set payload */
6045 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6047 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6048 rte_pktmbuf_tailroom(ut_params->ibuf));
6050 /* Create AEAD operation */
6051 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6055 /* Create AEAD xform */
6056 memcpy(key, tdata->key.data, tdata->key.len);
6057 retval = create_aead_xform(ut_params->op,
6059 RTE_CRYPTO_AEAD_OP_DECRYPT,
6060 key, tdata->key.len,
6061 tdata->aad.len, tdata->auth_tag.len,
6066 ut_params->op->sym->m_src = ut_params->ibuf;
6068 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6069 RTE_CRYPTO_OP_SESSIONLESS,
6070 "crypto op session type not sessionless");
6072 /* Process crypto operation */
6073 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6074 ut_params->op), "failed to process sym crypto op");
6076 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6078 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6079 "crypto op status not success");
6081 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6082 ut_params->op->sym->cipher.data.offset);
6084 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6087 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6089 tdata->plaintext.data,
6090 tdata->plaintext.len,
6091 "Plaintext data not as expected");
6093 TEST_ASSERT_EQUAL(ut_params->op->status,
6094 RTE_CRYPTO_OP_STATUS_SUCCESS,
6095 "Authentication failed");
6100 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6102 return test_authenticated_decryption_sessionless(
6107 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6109 return test_authenticated_encryption(&ccm_test_case_128_1);
6113 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6115 return test_authenticated_encryption(&ccm_test_case_128_2);
6119 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6121 return test_authenticated_encryption(&ccm_test_case_128_3);
6125 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6127 return test_authenticated_decryption(&ccm_test_case_128_1);
6131 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6133 return test_authenticated_decryption(&ccm_test_case_128_2);
6137 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6139 return test_authenticated_decryption(&ccm_test_case_128_3);
6143 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6145 return test_authenticated_encryption(&ccm_test_case_192_1);
6149 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6151 return test_authenticated_encryption(&ccm_test_case_192_2);
6155 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6157 return test_authenticated_encryption(&ccm_test_case_192_3);
6161 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6163 return test_authenticated_decryption(&ccm_test_case_192_1);
6167 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6169 return test_authenticated_decryption(&ccm_test_case_192_2);
6173 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6175 return test_authenticated_decryption(&ccm_test_case_192_3);
6179 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6181 return test_authenticated_encryption(&ccm_test_case_256_1);
6185 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6187 return test_authenticated_encryption(&ccm_test_case_256_2);
6191 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6193 return test_authenticated_encryption(&ccm_test_case_256_3);
6197 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6199 return test_authenticated_decryption(&ccm_test_case_256_1);
6203 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6205 return test_authenticated_decryption(&ccm_test_case_256_2);
6209 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6211 return test_authenticated_decryption(&ccm_test_case_256_3);
6217 struct crypto_testsuite_params *ts_params = &testsuite_params;
6218 struct rte_cryptodev_stats stats;
6219 struct rte_cryptodev *dev;
6220 cryptodev_stats_get_t temp_pfn;
6222 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6223 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6224 &stats) == -ENODEV),
6225 "rte_cryptodev_stats_get invalid dev failed");
6226 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6227 "rte_cryptodev_stats_get invalid Param failed");
6228 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6229 temp_pfn = dev->dev_ops->stats_get;
6230 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6231 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6233 "rte_cryptodev_stats_get invalid Param failed");
6234 dev->dev_ops->stats_get = temp_pfn;
6236 /* Test expected values */
6238 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6240 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6242 "rte_cryptodev_stats_get failed");
6243 TEST_ASSERT((stats.enqueued_count == 1),
6244 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6245 TEST_ASSERT((stats.dequeued_count == 1),
6246 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6247 TEST_ASSERT((stats.enqueue_err_count == 0),
6248 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6249 TEST_ASSERT((stats.dequeue_err_count == 0),
6250 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6252 /* invalid device but should ignore and not reset device stats*/
6253 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6254 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6256 "rte_cryptodev_stats_get failed");
6257 TEST_ASSERT((stats.enqueued_count == 1),
6258 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6260 /* check that a valid reset clears stats */
6261 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6262 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6264 "rte_cryptodev_stats_get failed");
6265 TEST_ASSERT((stats.enqueued_count == 0),
6266 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6267 TEST_ASSERT((stats.dequeued_count == 0),
6268 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6270 return TEST_SUCCESS;
6273 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6274 struct crypto_unittest_params *ut_params,
6275 enum rte_crypto_auth_operation op,
6276 const struct HMAC_MD5_vector *test_case)
6280 memcpy(key, test_case->key.data, test_case->key.len);
6282 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6283 ut_params->auth_xform.next = NULL;
6284 ut_params->auth_xform.auth.op = op;
6286 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6288 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6289 ut_params->auth_xform.auth.key.length = test_case->key.len;
6290 ut_params->auth_xform.auth.key.data = key;
6292 ut_params->sess = rte_cryptodev_sym_session_create(
6293 ts_params->session_mpool);
6295 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6296 ut_params->sess, &ut_params->auth_xform,
6297 ts_params->session_mpool);
6299 if (ut_params->sess == NULL)
6302 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6304 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6305 rte_pktmbuf_tailroom(ut_params->ibuf));
6310 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6311 const struct HMAC_MD5_vector *test_case,
6312 uint8_t **plaintext)
6314 uint16_t plaintext_pad_len;
6316 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6318 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6321 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6323 memcpy(*plaintext, test_case->plaintext.data,
6324 test_case->plaintext.len);
6326 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6327 ut_params->ibuf, MD5_DIGEST_LEN);
6328 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6329 "no room to append digest");
6330 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6331 ut_params->ibuf, plaintext_pad_len);
6333 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6334 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6335 test_case->auth_tag.len);
6338 sym_op->auth.data.offset = 0;
6339 sym_op->auth.data.length = test_case->plaintext.len;
6341 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6342 ut_params->op->sym->m_src = ut_params->ibuf;
6348 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6350 uint16_t plaintext_pad_len;
6351 uint8_t *plaintext, *auth_tag;
6353 struct crypto_testsuite_params *ts_params = &testsuite_params;
6354 struct crypto_unittest_params *ut_params = &unittest_params;
6356 if (MD5_HMAC_create_session(ts_params, ut_params,
6357 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6360 /* Generate Crypto op data structure */
6361 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6362 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6363 TEST_ASSERT_NOT_NULL(ut_params->op,
6364 "Failed to allocate symmetric crypto operation struct");
6366 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6369 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6372 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6373 ut_params->op), "failed to process sym crypto op");
6375 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6376 "crypto op processing failed");
6378 if (ut_params->op->sym->m_dst) {
6379 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6380 uint8_t *, plaintext_pad_len);
6382 auth_tag = plaintext + plaintext_pad_len;
6385 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6387 test_case->auth_tag.data,
6388 test_case->auth_tag.len,
6389 "HMAC_MD5 generated tag not as expected");
6391 return TEST_SUCCESS;
6395 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6399 struct crypto_testsuite_params *ts_params = &testsuite_params;
6400 struct crypto_unittest_params *ut_params = &unittest_params;
6402 if (MD5_HMAC_create_session(ts_params, ut_params,
6403 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6407 /* Generate Crypto op data structure */
6408 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6409 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6410 TEST_ASSERT_NOT_NULL(ut_params->op,
6411 "Failed to allocate symmetric crypto operation struct");
6413 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6416 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6417 ut_params->op), "failed to process sym crypto op");
6419 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6420 "HMAC_MD5 crypto op processing failed");
6422 return TEST_SUCCESS;
6426 test_MD5_HMAC_generate_case_1(void)
6428 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6432 test_MD5_HMAC_verify_case_1(void)
6434 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6438 test_MD5_HMAC_generate_case_2(void)
6440 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6444 test_MD5_HMAC_verify_case_2(void)
6446 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6450 test_multi_session(void)
6452 struct crypto_testsuite_params *ts_params = &testsuite_params;
6453 struct crypto_unittest_params *ut_params = &unittest_params;
6455 struct rte_cryptodev_info dev_info;
6456 struct rte_cryptodev_sym_session **sessions;
6460 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6461 aes_cbc_key, hmac_sha512_key);
6464 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6466 sessions = rte_malloc(NULL,
6467 (sizeof(struct rte_cryptodev_sym_session *) *
6468 dev_info.sym.max_nb_sessions) + 1, 0);
6470 /* Create multiple crypto sessions*/
6471 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6473 sessions[i] = rte_cryptodev_sym_session_create(
6474 ts_params->session_mpool);
6476 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6477 sessions[i], &ut_params->auth_xform,
6478 ts_params->session_mpool);
6479 TEST_ASSERT_NOT_NULL(sessions[i],
6480 "Session creation failed at session number %u",
6483 /* Attempt to send a request on each session */
6484 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6488 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6489 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6491 "Failed to perform decrypt on request number %u.", i);
6492 /* free crypto operation structure */
6494 rte_crypto_op_free(ut_params->op);
6497 * free mbuf - both obuf and ibuf are usually the same,
6498 * so check if they point at the same address is necessary,
6499 * to avoid freeing the mbuf twice.
6501 if (ut_params->obuf) {
6502 rte_pktmbuf_free(ut_params->obuf);
6503 if (ut_params->ibuf == ut_params->obuf)
6504 ut_params->ibuf = 0;
6505 ut_params->obuf = 0;
6507 if (ut_params->ibuf) {
6508 rte_pktmbuf_free(ut_params->ibuf);
6509 ut_params->ibuf = 0;
6513 /* Next session create should fail */
6514 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6515 sessions[i], &ut_params->auth_xform,
6516 ts_params->session_mpool);
6517 TEST_ASSERT_NULL(sessions[i],
6518 "Session creation succeeded unexpectedly!");
6520 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6521 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6523 rte_cryptodev_sym_session_free(sessions[i]);
6528 return TEST_SUCCESS;
6531 struct multi_session_params {
6532 struct crypto_unittest_params ut_params;
6533 uint8_t *cipher_key;
6535 const uint8_t *cipher;
6536 const uint8_t *digest;
6540 #define MB_SESSION_NUMBER 3
6543 test_multi_session_random_usage(void)
6545 struct crypto_testsuite_params *ts_params = &testsuite_params;
6546 struct rte_cryptodev_info dev_info;
6547 struct rte_cryptodev_sym_session **sessions;
6549 struct multi_session_params ut_paramz[] = {
6552 .cipher_key = ms_aes_cbc_key0,
6553 .hmac_key = ms_hmac_key0,
6554 .cipher = ms_aes_cbc_cipher0,
6555 .digest = ms_hmac_digest0,
6556 .iv = ms_aes_cbc_iv0
6559 .cipher_key = ms_aes_cbc_key1,
6560 .hmac_key = ms_hmac_key1,
6561 .cipher = ms_aes_cbc_cipher1,
6562 .digest = ms_hmac_digest1,
6563 .iv = ms_aes_cbc_iv1
6566 .cipher_key = ms_aes_cbc_key2,
6567 .hmac_key = ms_hmac_key2,
6568 .cipher = ms_aes_cbc_cipher2,
6569 .digest = ms_hmac_digest2,
6570 .iv = ms_aes_cbc_iv2
6575 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6577 sessions = rte_malloc(NULL,
6578 (sizeof(struct rte_cryptodev_sym_session *)
6579 * dev_info.sym.max_nb_sessions) + 1, 0);
6581 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6582 sessions[i] = rte_cryptodev_sym_session_create(
6583 ts_params->session_mpool);
6585 rte_memcpy(&ut_paramz[i].ut_params, &testsuite_params,
6586 sizeof(struct crypto_unittest_params));
6588 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6589 &ut_paramz[i].ut_params,
6590 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6592 /* Create multiple crypto sessions*/
6593 rte_cryptodev_sym_session_init(
6594 ts_params->valid_devs[0],
6596 &ut_paramz[i].ut_params.auth_xform,
6597 ts_params->session_mpool);
6599 TEST_ASSERT_NOT_NULL(sessions[i],
6600 "Session creation failed at session number %u",
6606 for (i = 0; i < 40000; i++) {
6608 j = rand() % MB_SESSION_NUMBER;
6610 TEST_ASSERT_SUCCESS(
6611 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6613 &ut_paramz[j].ut_params,
6614 ts_params, ut_paramz[j].cipher,
6615 ut_paramz[j].digest,
6617 "Failed to perform decrypt on request number %u.", i);
6619 if (ut_paramz[j].ut_params.op)
6620 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6623 * free mbuf - both obuf and ibuf are usually the same,
6624 * so check if they point at the same address is necessary,
6625 * to avoid freeing the mbuf twice.
6627 if (ut_paramz[j].ut_params.obuf) {
6628 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6629 if (ut_paramz[j].ut_params.ibuf
6630 == ut_paramz[j].ut_params.obuf)
6631 ut_paramz[j].ut_params.ibuf = 0;
6632 ut_paramz[j].ut_params.obuf = 0;
6634 if (ut_paramz[j].ut_params.ibuf) {
6635 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6636 ut_paramz[j].ut_params.ibuf = 0;
6640 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6641 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6643 rte_cryptodev_sym_session_free(sessions[i]);
6648 return TEST_SUCCESS;
6652 test_null_cipher_only_operation(void)
6654 struct crypto_testsuite_params *ts_params = &testsuite_params;
6655 struct crypto_unittest_params *ut_params = &unittest_params;
6657 /* Generate test mbuf data and space for digest */
6658 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6659 catch_22_quote, QUOTE_512_BYTES, 0);
6661 /* Setup Cipher Parameters */
6662 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6663 ut_params->cipher_xform.next = NULL;
6665 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6666 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6668 ut_params->sess = rte_cryptodev_sym_session_create(
6669 ts_params->session_mpool);
6671 /* Create Crypto session*/
6672 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6674 &ut_params->cipher_xform,
6675 ts_params->session_mpool);
6676 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6678 /* Generate Crypto op data structure */
6679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6680 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6681 TEST_ASSERT_NOT_NULL(ut_params->op,
6682 "Failed to allocate symmetric crypto operation struct");
6684 /* Set crypto operation data parameters */
6685 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6687 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6689 /* set crypto operation source mbuf */
6690 sym_op->m_src = ut_params->ibuf;
6692 sym_op->cipher.data.offset = 0;
6693 sym_op->cipher.data.length = QUOTE_512_BYTES;
6695 /* Process crypto operation */
6696 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6698 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6700 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6701 "crypto operation processing failed");
6704 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6705 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6708 "Ciphertext data not as expected");
6710 return TEST_SUCCESS;
6712 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6713 0xab, 0xab, 0xab, 0xab,
6714 0xab, 0xab, 0xab, 0xab,
6715 0xab, 0xab, 0xab, 0xab};
6717 test_null_auth_only_operation(void)
6719 struct crypto_testsuite_params *ts_params = &testsuite_params;
6720 struct crypto_unittest_params *ut_params = &unittest_params;
6723 /* Generate test mbuf data and space for digest */
6724 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6725 catch_22_quote, QUOTE_512_BYTES, 0);
6727 /* create a pointer for digest, but don't expect anything to be written
6728 * here in a NULL auth algo so no mbuf append done.
6730 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6732 /* prefill the memory pointed to by digest */
6733 memcpy(digest, orig_data, sizeof(orig_data));
6735 /* Setup HMAC Parameters */
6736 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6737 ut_params->auth_xform.next = NULL;
6739 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6740 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6742 ut_params->sess = rte_cryptodev_sym_session_create(
6743 ts_params->session_mpool);
6745 /* Create Crypto session*/
6746 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6747 ut_params->sess, &ut_params->auth_xform,
6748 ts_params->session_mpool);
6749 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6751 /* Generate Crypto op data structure */
6752 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6753 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6754 TEST_ASSERT_NOT_NULL(ut_params->op,
6755 "Failed to allocate symmetric crypto operation struct");
6757 /* Set crypto operation data parameters */
6758 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6760 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6762 sym_op->m_src = ut_params->ibuf;
6764 sym_op->auth.data.offset = 0;
6765 sym_op->auth.data.length = QUOTE_512_BYTES;
6766 sym_op->auth.digest.data = digest;
6767 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6770 /* Process crypto operation */
6771 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6773 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6775 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6776 "crypto operation processing failed");
6777 /* Make sure memory pointed to by digest hasn't been overwritten */
6778 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6782 "Memory at digest ptr overwritten unexpectedly");
6784 return TEST_SUCCESS;
6789 test_null_cipher_auth_operation(void)
6791 struct crypto_testsuite_params *ts_params = &testsuite_params;
6792 struct crypto_unittest_params *ut_params = &unittest_params;
6795 /* Generate test mbuf data and space for digest */
6796 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6797 catch_22_quote, QUOTE_512_BYTES, 0);
6799 /* create a pointer for digest, but don't expect anything to be written
6800 * here in a NULL auth algo so no mbuf append done.
6802 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6804 /* prefill the memory pointed to by digest */
6805 memcpy(digest, orig_data, sizeof(orig_data));
6807 /* Setup Cipher Parameters */
6808 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6809 ut_params->cipher_xform.next = &ut_params->auth_xform;
6811 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6812 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6814 /* Setup HMAC Parameters */
6815 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6816 ut_params->auth_xform.next = NULL;
6818 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6819 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6821 ut_params->sess = rte_cryptodev_sym_session_create(
6822 ts_params->session_mpool);
6824 /* Create Crypto session*/
6825 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6826 ut_params->sess, &ut_params->cipher_xform,
6827 ts_params->session_mpool);
6828 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6830 /* Generate Crypto op data structure */
6831 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6832 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6833 TEST_ASSERT_NOT_NULL(ut_params->op,
6834 "Failed to allocate symmetric crypto operation struct");
6836 /* Set crypto operation data parameters */
6837 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6839 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6841 sym_op->m_src = ut_params->ibuf;
6843 sym_op->cipher.data.offset = 0;
6844 sym_op->cipher.data.length = QUOTE_512_BYTES;
6846 sym_op->auth.data.offset = 0;
6847 sym_op->auth.data.length = QUOTE_512_BYTES;
6848 sym_op->auth.digest.data = digest;
6849 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6852 /* Process crypto operation */
6853 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6855 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6857 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6858 "crypto operation processing failed");
6861 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6862 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6865 "Ciphertext data not as expected");
6866 /* Make sure memory pointed to by digest hasn't been overwritten */
6867 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6871 "Memory at digest ptr overwritten unexpectedly");
6873 return TEST_SUCCESS;
6877 test_null_auth_cipher_operation(void)
6879 struct crypto_testsuite_params *ts_params = &testsuite_params;
6880 struct crypto_unittest_params *ut_params = &unittest_params;
6883 /* Generate test mbuf data */
6884 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6885 catch_22_quote, QUOTE_512_BYTES, 0);
6887 /* create a pointer for digest, but don't expect anything to be written
6888 * here in a NULL auth algo so no mbuf append done.
6890 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6892 /* prefill the memory pointed to by digest */
6893 memcpy(digest, orig_data, sizeof(orig_data));
6895 /* Setup Cipher Parameters */
6896 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6897 ut_params->cipher_xform.next = NULL;
6899 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6900 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6902 /* Setup HMAC Parameters */
6903 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6904 ut_params->auth_xform.next = &ut_params->cipher_xform;
6906 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6907 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6909 ut_params->sess = rte_cryptodev_sym_session_create(
6910 ts_params->session_mpool);
6912 /* Create Crypto session*/
6913 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6914 ut_params->sess, &ut_params->cipher_xform,
6915 ts_params->session_mpool);
6916 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6918 /* Generate Crypto op data structure */
6919 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6920 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6921 TEST_ASSERT_NOT_NULL(ut_params->op,
6922 "Failed to allocate symmetric crypto operation struct");
6924 /* Set crypto operation data parameters */
6925 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6927 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6929 sym_op->m_src = ut_params->ibuf;
6931 sym_op->cipher.data.offset = 0;
6932 sym_op->cipher.data.length = QUOTE_512_BYTES;
6934 sym_op->auth.data.offset = 0;
6935 sym_op->auth.data.length = QUOTE_512_BYTES;
6936 sym_op->auth.digest.data = digest;
6937 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6940 /* Process crypto operation */
6941 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6943 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6945 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6946 "crypto operation processing failed");
6949 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6950 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6953 "Ciphertext data not as expected");
6954 /* Make sure memory pointed to by digest hasn't been overwritten */
6955 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6959 "Memory at digest ptr overwritten unexpectedly");
6961 return TEST_SUCCESS;
6966 test_null_invalid_operation(void)
6968 struct crypto_testsuite_params *ts_params = &testsuite_params;
6969 struct crypto_unittest_params *ut_params = &unittest_params;
6972 /* Setup Cipher Parameters */
6973 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6974 ut_params->cipher_xform.next = NULL;
6976 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
6977 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6979 ut_params->sess = rte_cryptodev_sym_session_create(
6980 ts_params->session_mpool);
6982 /* Create Crypto session*/
6983 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6984 ut_params->sess, &ut_params->cipher_xform,
6985 ts_params->session_mpool);
6986 TEST_ASSERT(ret < 0,
6987 "Session creation succeeded unexpectedly");
6990 /* Setup HMAC Parameters */
6991 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6992 ut_params->auth_xform.next = NULL;
6994 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
6995 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6997 ut_params->sess = rte_cryptodev_sym_session_create(
6998 ts_params->session_mpool);
7000 /* Create Crypto session*/
7001 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7002 ut_params->sess, &ut_params->auth_xform,
7003 ts_params->session_mpool);
7004 TEST_ASSERT(ret < 0,
7005 "Session creation succeeded unexpectedly");
7007 return TEST_SUCCESS;
7011 #define NULL_BURST_LENGTH (32)
7014 test_null_burst_operation(void)
7016 struct crypto_testsuite_params *ts_params = &testsuite_params;
7017 struct crypto_unittest_params *ut_params = &unittest_params;
7019 unsigned i, burst_len = NULL_BURST_LENGTH;
7021 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7022 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7024 /* Setup Cipher Parameters */
7025 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7026 ut_params->cipher_xform.next = &ut_params->auth_xform;
7028 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7029 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7031 /* Setup HMAC Parameters */
7032 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7033 ut_params->auth_xform.next = NULL;
7035 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7036 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7038 ut_params->sess = rte_cryptodev_sym_session_create(
7039 ts_params->session_mpool);
7041 /* Create Crypto session*/
7042 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7043 ut_params->sess, &ut_params->cipher_xform,
7044 ts_params->session_mpool);
7045 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7047 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7048 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7049 burst_len, "failed to generate burst of crypto ops");
7051 /* Generate an operation for each mbuf in burst */
7052 for (i = 0; i < burst_len; i++) {
7053 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7055 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7057 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7061 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7063 burst[i]->sym->m_src = m;
7066 /* Process crypto operation */
7067 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7068 0, burst, burst_len),
7070 "Error enqueuing burst");
7072 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7073 0, burst_dequeued, burst_len),
7075 "Error dequeuing burst");
7078 for (i = 0; i < burst_len; i++) {
7080 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7081 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7083 "data not as expected");
7085 rte_pktmbuf_free(burst[i]->sym->m_src);
7086 rte_crypto_op_free(burst[i]);
7089 return TEST_SUCCESS;
7093 generate_gmac_large_plaintext(uint8_t *data)
7097 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7098 memcpy(&data[i], &data[0], 32);
7102 create_gmac_operation(enum rte_crypto_auth_operation op,
7103 const struct gmac_test_data *tdata)
7105 struct crypto_testsuite_params *ts_params = &testsuite_params;
7106 struct crypto_unittest_params *ut_params = &unittest_params;
7107 struct rte_crypto_sym_op *sym_op;
7109 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7111 /* Generate Crypto op data structure */
7112 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7113 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7114 TEST_ASSERT_NOT_NULL(ut_params->op,
7115 "Failed to allocate symmetric crypto operation struct");
7117 sym_op = ut_params->op->sym;
7119 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7120 ut_params->ibuf, tdata->gmac_tag.len);
7121 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7122 "no room to append digest");
7124 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7125 ut_params->ibuf, plaintext_pad_len);
7127 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7128 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7129 tdata->gmac_tag.len);
7130 debug_hexdump(stdout, "digest:",
7131 sym_op->auth.digest.data,
7132 tdata->gmac_tag.len);
7135 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7136 uint8_t *, IV_OFFSET);
7138 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7140 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7142 sym_op->cipher.data.length = 0;
7143 sym_op->cipher.data.offset = 0;
7145 sym_op->auth.data.offset = 0;
7146 sym_op->auth.data.length = tdata->plaintext.len;
7151 static int create_gmac_session(uint8_t dev_id,
7152 const struct gmac_test_data *tdata,
7153 enum rte_crypto_auth_operation auth_op)
7155 uint8_t auth_key[tdata->key.len];
7157 struct crypto_testsuite_params *ts_params = &testsuite_params;
7158 struct crypto_unittest_params *ut_params = &unittest_params;
7160 memcpy(auth_key, tdata->key.data, tdata->key.len);
7162 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7163 ut_params->auth_xform.next = NULL;
7165 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7166 ut_params->auth_xform.auth.op = auth_op;
7167 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7168 ut_params->auth_xform.auth.key.length = tdata->key.len;
7169 ut_params->auth_xform.auth.key.data = auth_key;
7170 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7171 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7174 ut_params->sess = rte_cryptodev_sym_session_create(
7175 ts_params->session_mpool);
7177 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7178 &ut_params->auth_xform,
7179 ts_params->session_mpool);
7181 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7187 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7189 struct crypto_testsuite_params *ts_params = &testsuite_params;
7190 struct crypto_unittest_params *ut_params = &unittest_params;
7194 uint8_t *auth_tag, *plaintext;
7195 uint16_t plaintext_pad_len;
7197 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7198 "No GMAC length in the source data");
7200 retval = create_gmac_session(ts_params->valid_devs[0],
7201 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7206 if (tdata->plaintext.len > MBUF_SIZE)
7207 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7209 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7210 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7211 "Failed to allocate input buffer in mempool");
7213 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7214 rte_pktmbuf_tailroom(ut_params->ibuf));
7216 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7218 * Runtime generate the large plain text instead of use hard code
7219 * plain text vector. It is done to avoid create huge source file
7220 * with the test vector.
7222 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7223 generate_gmac_large_plaintext(tdata->plaintext.data);
7225 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7227 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7229 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7230 debug_hexdump(stdout, "plaintext:", plaintext,
7231 tdata->plaintext.len);
7233 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7239 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7241 ut_params->op->sym->m_src = ut_params->ibuf;
7243 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7244 ut_params->op), "failed to process sym crypto op");
7246 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7247 "crypto op processing failed");
7249 if (ut_params->op->sym->m_dst) {
7250 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7251 uint8_t *, plaintext_pad_len);
7253 auth_tag = plaintext + plaintext_pad_len;
7256 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7258 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7260 tdata->gmac_tag.data,
7261 tdata->gmac_tag.len,
7262 "GMAC Generated auth tag not as expected");
7268 test_AES_GMAC_authentication_test_case_1(void)
7270 return test_AES_GMAC_authentication(&gmac_test_case_1);
7274 test_AES_GMAC_authentication_test_case_2(void)
7276 return test_AES_GMAC_authentication(&gmac_test_case_2);
7280 test_AES_GMAC_authentication_test_case_3(void)
7282 return test_AES_GMAC_authentication(&gmac_test_case_3);
7286 test_AES_GMAC_authentication_test_case_4(void)
7288 return test_AES_GMAC_authentication(&gmac_test_case_4);
7292 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7294 struct crypto_testsuite_params *ts_params = &testsuite_params;
7295 struct crypto_unittest_params *ut_params = &unittest_params;
7297 uint32_t plaintext_pad_len;
7300 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7301 "No GMAC length in the source data");
7303 retval = create_gmac_session(ts_params->valid_devs[0],
7304 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7309 if (tdata->plaintext.len > MBUF_SIZE)
7310 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7312 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7313 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7314 "Failed to allocate input buffer in mempool");
7316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7317 rte_pktmbuf_tailroom(ut_params->ibuf));
7319 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7322 * Runtime generate the large plain text instead of use hard code
7323 * plain text vector. It is done to avoid create huge source file
7324 * with the test vector.
7326 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7327 generate_gmac_large_plaintext(tdata->plaintext.data);
7329 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7331 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7333 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7334 debug_hexdump(stdout, "plaintext:", plaintext,
7335 tdata->plaintext.len);
7337 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7343 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7345 ut_params->op->sym->m_src = ut_params->ibuf;
7347 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7348 ut_params->op), "failed to process sym crypto op");
7350 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7351 "crypto op processing failed");
7358 test_AES_GMAC_authentication_verify_test_case_1(void)
7360 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7364 test_AES_GMAC_authentication_verify_test_case_2(void)
7366 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7370 test_AES_GMAC_authentication_verify_test_case_3(void)
7372 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7376 test_AES_GMAC_authentication_verify_test_case_4(void)
7378 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7381 struct test_crypto_vector {
7382 enum rte_crypto_cipher_algorithm crypto_algo;
7395 const uint8_t *data;
7400 const uint8_t *data;
7404 enum rte_crypto_auth_algorithm auth_algo;
7412 const uint8_t *data;
7422 static const struct test_crypto_vector
7423 hmac_sha1_test_crypto_vector = {
7424 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7426 .data = plaintext_hash,
7431 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7432 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7433 0xDE, 0xF4, 0xDE, 0xAD
7439 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7440 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7441 0x3F, 0x91, 0x64, 0x59
7447 static const struct test_crypto_vector
7448 aes128_gmac_test_vector = {
7449 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7451 .data = plaintext_hash,
7456 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7457 0x08, 0x09, 0x0A, 0x0B
7463 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7464 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7470 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7471 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7477 static const struct test_crypto_vector
7478 aes128cbc_hmac_sha1_test_vector = {
7479 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7482 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7483 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7489 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7490 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7495 .data = plaintext_hash,
7499 .data = ciphertext512_aes128cbc,
7502 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7505 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7506 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7507 0xDE, 0xF4, 0xDE, 0xAD
7513 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7514 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7515 0x18, 0x8C, 0x1D, 0x32
7522 data_corruption(uint8_t *data)
7528 tag_corruption(uint8_t *data, unsigned int tag_offset)
7530 data[tag_offset] += 1;
7534 create_auth_session(struct crypto_unittest_params *ut_params,
7536 const struct test_crypto_vector *reference,
7537 enum rte_crypto_auth_operation auth_op)
7539 struct crypto_testsuite_params *ts_params = &testsuite_params;
7540 uint8_t auth_key[reference->auth_key.len + 1];
7542 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7544 /* Setup Authentication Parameters */
7545 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7546 ut_params->auth_xform.auth.op = auth_op;
7547 ut_params->auth_xform.next = NULL;
7548 ut_params->auth_xform.auth.algo = reference->auth_algo;
7549 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7550 ut_params->auth_xform.auth.key.data = auth_key;
7551 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7553 /* Create Crypto session*/
7554 ut_params->sess = rte_cryptodev_sym_session_create(
7555 ts_params->session_mpool);
7557 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7558 &ut_params->auth_xform,
7559 ts_params->session_mpool);
7561 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7567 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7569 const struct test_crypto_vector *reference,
7570 enum rte_crypto_auth_operation auth_op,
7571 enum rte_crypto_cipher_operation cipher_op)
7573 struct crypto_testsuite_params *ts_params = &testsuite_params;
7574 uint8_t cipher_key[reference->cipher_key.len + 1];
7575 uint8_t auth_key[reference->auth_key.len + 1];
7577 memcpy(cipher_key, reference->cipher_key.data,
7578 reference->cipher_key.len);
7579 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7581 /* Setup Authentication Parameters */
7582 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7583 ut_params->auth_xform.auth.op = auth_op;
7584 ut_params->auth_xform.auth.algo = reference->auth_algo;
7585 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7586 ut_params->auth_xform.auth.key.data = auth_key;
7587 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7589 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7590 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7591 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7593 ut_params->auth_xform.next = &ut_params->cipher_xform;
7595 /* Setup Cipher Parameters */
7596 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7597 ut_params->cipher_xform.next = NULL;
7598 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7599 ut_params->cipher_xform.cipher.op = cipher_op;
7600 ut_params->cipher_xform.cipher.key.data = cipher_key;
7601 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7602 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7603 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7606 /* Create Crypto session*/
7607 ut_params->sess = rte_cryptodev_sym_session_create(
7608 ts_params->session_mpool);
7610 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7611 &ut_params->auth_xform,
7612 ts_params->session_mpool);
7614 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7620 create_auth_operation(struct crypto_testsuite_params *ts_params,
7621 struct crypto_unittest_params *ut_params,
7622 const struct test_crypto_vector *reference,
7623 unsigned int auth_generate)
7625 /* Generate Crypto op data structure */
7626 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7627 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7628 TEST_ASSERT_NOT_NULL(ut_params->op,
7629 "Failed to allocate pktmbuf offload");
7631 /* Set crypto operation data parameters */
7632 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7634 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7636 /* set crypto operation source mbuf */
7637 sym_op->m_src = ut_params->ibuf;
7640 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7641 ut_params->ibuf, reference->digest.len);
7643 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7644 "no room to append auth tag");
7646 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7647 ut_params->ibuf, reference->plaintext.len);
7650 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7652 memcpy(sym_op->auth.digest.data,
7653 reference->digest.data,
7654 reference->digest.len);
7656 debug_hexdump(stdout, "digest:",
7657 sym_op->auth.digest.data,
7658 reference->digest.len);
7660 sym_op->auth.data.length = reference->plaintext.len;
7661 sym_op->auth.data.offset = 0;
7667 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7668 struct crypto_unittest_params *ut_params,
7669 const struct test_crypto_vector *reference,
7670 unsigned int auth_generate)
7672 /* Generate Crypto op data structure */
7673 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7674 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7675 TEST_ASSERT_NOT_NULL(ut_params->op,
7676 "Failed to allocate pktmbuf offload");
7678 /* Set crypto operation data parameters */
7679 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7681 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7683 /* set crypto operation source mbuf */
7684 sym_op->m_src = ut_params->ibuf;
7687 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7688 ut_params->ibuf, reference->digest.len);
7690 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7691 "no room to append auth tag");
7693 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7694 ut_params->ibuf, reference->ciphertext.len);
7697 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7699 memcpy(sym_op->auth.digest.data,
7700 reference->digest.data,
7701 reference->digest.len);
7703 debug_hexdump(stdout, "digest:",
7704 sym_op->auth.digest.data,
7705 reference->digest.len);
7707 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7708 reference->iv.data, reference->iv.len);
7710 sym_op->cipher.data.length = 0;
7711 sym_op->cipher.data.offset = 0;
7713 sym_op->auth.data.length = reference->plaintext.len;
7714 sym_op->auth.data.offset = 0;
7720 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7721 struct crypto_unittest_params *ut_params,
7722 const struct test_crypto_vector *reference,
7723 unsigned int auth_generate)
7725 /* Generate Crypto op data structure */
7726 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7727 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7728 TEST_ASSERT_NOT_NULL(ut_params->op,
7729 "Failed to allocate pktmbuf offload");
7731 /* Set crypto operation data parameters */
7732 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7734 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7736 /* set crypto operation source mbuf */
7737 sym_op->m_src = ut_params->ibuf;
7740 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7741 ut_params->ibuf, reference->digest.len);
7743 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7744 "no room to append auth tag");
7746 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7747 ut_params->ibuf, reference->ciphertext.len);
7750 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7752 memcpy(sym_op->auth.digest.data,
7753 reference->digest.data,
7754 reference->digest.len);
7756 debug_hexdump(stdout, "digest:",
7757 sym_op->auth.digest.data,
7758 reference->digest.len);
7760 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7761 reference->iv.data, reference->iv.len);
7763 sym_op->cipher.data.length = reference->ciphertext.len;
7764 sym_op->cipher.data.offset = 0;
7766 sym_op->auth.data.length = reference->ciphertext.len;
7767 sym_op->auth.data.offset = 0;
7773 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7774 struct crypto_unittest_params *ut_params,
7775 const struct test_crypto_vector *reference)
7777 return create_auth_operation(ts_params, ut_params, reference, 0);
7781 create_auth_verify_GMAC_operation(
7782 struct crypto_testsuite_params *ts_params,
7783 struct crypto_unittest_params *ut_params,
7784 const struct test_crypto_vector *reference)
7786 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7790 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7791 struct crypto_unittest_params *ut_params,
7792 const struct test_crypto_vector *reference)
7794 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7798 test_authentication_verify_fail_when_data_corruption(
7799 struct crypto_testsuite_params *ts_params,
7800 struct crypto_unittest_params *ut_params,
7801 const struct test_crypto_vector *reference,
7802 unsigned int data_corrupted)
7808 /* Create session */
7809 retval = create_auth_session(ut_params,
7810 ts_params->valid_devs[0],
7812 RTE_CRYPTO_AUTH_OP_VERIFY);
7816 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7817 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7818 "Failed to allocate input buffer in mempool");
7820 /* clear mbuf payload */
7821 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7822 rte_pktmbuf_tailroom(ut_params->ibuf));
7824 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7825 reference->plaintext.len);
7826 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7827 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7829 debug_hexdump(stdout, "plaintext:", plaintext,
7830 reference->plaintext.len);
7832 /* Create operation */
7833 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7839 data_corruption(plaintext);
7841 tag_corruption(plaintext, reference->plaintext.len);
7843 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7845 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7846 TEST_ASSERT_EQUAL(ut_params->op->status,
7847 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7848 "authentication not failed");
7850 ut_params->obuf = ut_params->op->sym->m_src;
7851 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7857 test_authentication_verify_GMAC_fail_when_corruption(
7858 struct crypto_testsuite_params *ts_params,
7859 struct crypto_unittest_params *ut_params,
7860 const struct test_crypto_vector *reference,
7861 unsigned int data_corrupted)
7866 /* Create session */
7867 retval = create_auth_cipher_session(ut_params,
7868 ts_params->valid_devs[0],
7870 RTE_CRYPTO_AUTH_OP_VERIFY,
7871 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7875 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7876 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7877 "Failed to allocate input buffer in mempool");
7879 /* clear mbuf payload */
7880 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7881 rte_pktmbuf_tailroom(ut_params->ibuf));
7883 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7884 reference->plaintext.len);
7885 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7886 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7888 debug_hexdump(stdout, "plaintext:", plaintext,
7889 reference->plaintext.len);
7891 /* Create operation */
7892 retval = create_auth_verify_GMAC_operation(ts_params,
7900 data_corruption(plaintext);
7902 tag_corruption(plaintext, reference->aad.len);
7904 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7906 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7907 TEST_ASSERT_EQUAL(ut_params->op->status,
7908 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7909 "authentication not failed");
7911 ut_params->obuf = ut_params->op->sym->m_src;
7912 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7918 test_authenticated_decryption_fail_when_corruption(
7919 struct crypto_testsuite_params *ts_params,
7920 struct crypto_unittest_params *ut_params,
7921 const struct test_crypto_vector *reference,
7922 unsigned int data_corrupted)
7926 uint8_t *ciphertext;
7928 /* Create session */
7929 retval = create_auth_cipher_session(ut_params,
7930 ts_params->valid_devs[0],
7932 RTE_CRYPTO_AUTH_OP_VERIFY,
7933 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7937 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7938 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7939 "Failed to allocate input buffer in mempool");
7941 /* clear mbuf payload */
7942 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7943 rte_pktmbuf_tailroom(ut_params->ibuf));
7945 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7946 reference->ciphertext.len);
7947 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7948 memcpy(ciphertext, reference->ciphertext.data,
7949 reference->ciphertext.len);
7951 /* Create operation */
7952 retval = create_cipher_auth_verify_operation(ts_params,
7960 data_corruption(ciphertext);
7962 tag_corruption(ciphertext, reference->ciphertext.len);
7964 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7968 TEST_ASSERT_EQUAL(ut_params->op->status,
7969 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7970 "authentication not failed");
7972 ut_params->obuf = ut_params->op->sym->m_src;
7973 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7979 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
7980 const struct aead_test_data *tdata,
7981 void *digest_mem, uint64_t digest_phys)
7983 struct crypto_testsuite_params *ts_params = &testsuite_params;
7984 struct crypto_unittest_params *ut_params = &unittest_params;
7986 const unsigned int auth_tag_len = tdata->auth_tag.len;
7987 const unsigned int iv_len = tdata->iv.len;
7988 unsigned int aad_len = tdata->aad.len;
7990 /* Generate Crypto op data structure */
7991 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7992 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7993 TEST_ASSERT_NOT_NULL(ut_params->op,
7994 "Failed to allocate symmetric crypto operation struct");
7996 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7998 sym_op->aead.digest.data = digest_mem;
8000 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8001 "no room to append digest");
8003 sym_op->aead.digest.phys_addr = digest_phys;
8005 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8006 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8008 debug_hexdump(stdout, "digest:",
8009 sym_op->aead.digest.data,
8013 /* Append aad data */
8014 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8015 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8016 uint8_t *, IV_OFFSET);
8018 /* Copy IV 1 byte after the IV pointer, according to the API */
8019 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8021 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8023 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8024 ut_params->ibuf, aad_len);
8025 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8026 "no room to prepend aad");
8027 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8030 memset(sym_op->aead.aad.data, 0, aad_len);
8031 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8032 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8034 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8035 debug_hexdump(stdout, "aad:",
8036 sym_op->aead.aad.data, aad_len);
8038 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8039 uint8_t *, IV_OFFSET);
8041 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8043 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8044 ut_params->ibuf, aad_len);
8045 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8046 "no room to prepend aad");
8047 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8050 memset(sym_op->aead.aad.data, 0, aad_len);
8051 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8053 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8054 debug_hexdump(stdout, "aad:",
8055 sym_op->aead.aad.data, aad_len);
8058 sym_op->aead.data.length = tdata->plaintext.len;
8059 sym_op->aead.data.offset = aad_len;
8064 #define SGL_MAX_NO 16
8067 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8068 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8070 struct crypto_testsuite_params *ts_params = &testsuite_params;
8071 struct crypto_unittest_params *ut_params = &unittest_params;
8072 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8075 int to_trn_tbl[SGL_MAX_NO];
8077 unsigned int trn_data = 0;
8078 uint8_t *plaintext, *ciphertext, *auth_tag;
8080 if (fragsz > tdata->plaintext.len)
8081 fragsz = tdata->plaintext.len;
8083 uint16_t plaintext_len = fragsz;
8084 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8086 if (fragsz_oop > tdata->plaintext.len)
8087 frag_size_oop = tdata->plaintext.len;
8090 void *digest_mem = NULL;
8092 uint32_t prepend_len = tdata->aad.len;
8094 if (tdata->plaintext.len % fragsz != 0) {
8095 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8098 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8103 * For out-op-place we need to alloc another mbuf
8106 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8107 rte_pktmbuf_append(ut_params->obuf,
8108 frag_size_oop + prepend_len);
8109 buf_oop = ut_params->obuf;
8112 /* Create AEAD session */
8113 retval = create_aead_session(ts_params->valid_devs[0],
8115 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8116 tdata->key.data, tdata->key.len,
8117 tdata->aad.len, tdata->auth_tag.len,
8122 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8124 /* clear mbuf payload */
8125 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8126 rte_pktmbuf_tailroom(ut_params->ibuf));
8128 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8131 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8133 trn_data += plaintext_len;
8135 buf = ut_params->ibuf;
8138 * Loop until no more fragments
8141 while (trn_data < tdata->plaintext.len) {
8143 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8144 (tdata->plaintext.len - trn_data) : fragsz;
8146 to_trn_tbl[ecx++] = to_trn;
8148 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8151 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8152 rte_pktmbuf_tailroom(buf));
8155 if (oop && !fragsz_oop) {
8156 buf_last_oop = buf_oop->next =
8157 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8158 buf_oop = buf_oop->next;
8159 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8160 0, rte_pktmbuf_tailroom(buf_oop));
8161 rte_pktmbuf_append(buf_oop, to_trn);
8164 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8167 memcpy(plaintext, tdata->plaintext.data + trn_data,
8170 if (trn_data == tdata->plaintext.len) {
8173 digest_mem = rte_pktmbuf_append(buf_oop,
8174 tdata->auth_tag.len);
8176 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8177 tdata->auth_tag.len);
8181 uint64_t digest_phys = 0;
8183 ut_params->ibuf->nb_segs = segs;
8186 if (fragsz_oop && oop) {
8190 if (frag_size_oop == tdata->plaintext.len) {
8191 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8192 tdata->auth_tag.len);
8194 digest_phys = rte_pktmbuf_iova_offset(
8196 tdata->plaintext.len + prepend_len);
8199 trn_data = frag_size_oop;
8200 while (trn_data < tdata->plaintext.len) {
8203 (tdata->plaintext.len - trn_data <
8205 (tdata->plaintext.len - trn_data) :
8208 to_trn_tbl[ecx++] = to_trn;
8210 buf_last_oop = buf_oop->next =
8211 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8212 buf_oop = buf_oop->next;
8213 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8214 0, rte_pktmbuf_tailroom(buf_oop));
8215 rte_pktmbuf_append(buf_oop, to_trn);
8219 if (trn_data == tdata->plaintext.len) {
8220 digest_mem = rte_pktmbuf_append(buf_oop,
8221 tdata->auth_tag.len);
8225 ut_params->obuf->nb_segs = segs;
8229 * Place digest at the end of the last buffer
8232 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8233 if (oop && buf_last_oop)
8234 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8236 if (!digest_mem && !oop) {
8237 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8238 + tdata->auth_tag.len);
8239 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8240 tdata->plaintext.len);
8243 /* Create AEAD operation */
8244 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8245 tdata, digest_mem, digest_phys);
8250 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8252 ut_params->op->sym->m_src = ut_params->ibuf;
8254 ut_params->op->sym->m_dst = ut_params->obuf;
8256 /* Process crypto operation */
8257 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8258 ut_params->op), "failed to process sym crypto op");
8260 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8261 "crypto op processing failed");
8264 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8265 uint8_t *, prepend_len);
8267 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8268 uint8_t *, prepend_len);
8272 fragsz = fragsz_oop;
8274 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8276 tdata->ciphertext.data,
8278 "Ciphertext data not as expected");
8280 buf = ut_params->op->sym->m_src->next;
8282 buf = ut_params->op->sym->m_dst->next;
8284 unsigned int off = fragsz;
8288 ciphertext = rte_pktmbuf_mtod(buf,
8291 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8293 tdata->ciphertext.data + off,
8295 "Ciphertext data not as expected");
8297 off += to_trn_tbl[ecx++];
8301 auth_tag = digest_mem;
8302 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8304 tdata->auth_tag.data,
8305 tdata->auth_tag.len,
8306 "Generated auth tag not as expected");
8312 #define OUT_OF_PLACE 1
8315 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8317 return test_authenticated_encryption_SGL(
8318 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8322 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8324 return test_authenticated_encryption_SGL(
8325 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8329 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8331 return test_authenticated_encryption_SGL(
8332 &gcm_test_case_8, OUT_OF_PLACE, 400,
8333 gcm_test_case_8.plaintext.len);
8337 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8340 return test_authenticated_encryption_SGL(
8341 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8345 test_authentication_verify_fail_when_data_corrupted(
8346 struct crypto_testsuite_params *ts_params,
8347 struct crypto_unittest_params *ut_params,
8348 const struct test_crypto_vector *reference)
8350 return test_authentication_verify_fail_when_data_corruption(
8351 ts_params, ut_params, reference, 1);
8355 test_authentication_verify_fail_when_tag_corrupted(
8356 struct crypto_testsuite_params *ts_params,
8357 struct crypto_unittest_params *ut_params,
8358 const struct test_crypto_vector *reference)
8360 return test_authentication_verify_fail_when_data_corruption(
8361 ts_params, ut_params, reference, 0);
8365 test_authentication_verify_GMAC_fail_when_data_corrupted(
8366 struct crypto_testsuite_params *ts_params,
8367 struct crypto_unittest_params *ut_params,
8368 const struct test_crypto_vector *reference)
8370 return test_authentication_verify_GMAC_fail_when_corruption(
8371 ts_params, ut_params, reference, 1);
8375 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8376 struct crypto_testsuite_params *ts_params,
8377 struct crypto_unittest_params *ut_params,
8378 const struct test_crypto_vector *reference)
8380 return test_authentication_verify_GMAC_fail_when_corruption(
8381 ts_params, ut_params, reference, 0);
8385 test_authenticated_decryption_fail_when_data_corrupted(
8386 struct crypto_testsuite_params *ts_params,
8387 struct crypto_unittest_params *ut_params,
8388 const struct test_crypto_vector *reference)
8390 return test_authenticated_decryption_fail_when_corruption(
8391 ts_params, ut_params, reference, 1);
8395 test_authenticated_decryption_fail_when_tag_corrupted(
8396 struct crypto_testsuite_params *ts_params,
8397 struct crypto_unittest_params *ut_params,
8398 const struct test_crypto_vector *reference)
8400 return test_authenticated_decryption_fail_when_corruption(
8401 ts_params, ut_params, reference, 0);
8405 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8407 return test_authentication_verify_fail_when_data_corrupted(
8408 &testsuite_params, &unittest_params,
8409 &hmac_sha1_test_crypto_vector);
8413 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8415 return test_authentication_verify_fail_when_tag_corrupted(
8416 &testsuite_params, &unittest_params,
8417 &hmac_sha1_test_crypto_vector);
8421 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8423 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8424 &testsuite_params, &unittest_params,
8425 &aes128_gmac_test_vector);
8429 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8431 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8432 &testsuite_params, &unittest_params,
8433 &aes128_gmac_test_vector);
8437 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8439 return test_authenticated_decryption_fail_when_data_corrupted(
8442 &aes128cbc_hmac_sha1_test_vector);
8446 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8448 return test_authenticated_decryption_fail_when_tag_corrupted(
8451 &aes128cbc_hmac_sha1_test_vector);
8454 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8456 /* global AESNI slave IDs for the scheduler test */
8457 uint8_t aesni_ids[2];
8460 test_scheduler_attach_slave_op(void)
8462 struct crypto_testsuite_params *ts_params = &testsuite_params;
8463 uint8_t sched_id = ts_params->valid_devs[0];
8464 uint32_t nb_devs, i, nb_devs_attached = 0;
8468 /* create 2 AESNI_MB if necessary */
8469 nb_devs = rte_cryptodev_device_count_by_driver(
8470 rte_cryptodev_driver_id_get(
8471 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8473 for (i = nb_devs; i < 2; i++) {
8474 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8475 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8477 ret = rte_vdev_init(vdev_name, NULL);
8479 TEST_ASSERT(ret == 0,
8480 "Failed to create instance %u of"
8482 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8486 /* attach 2 AESNI_MB cdevs */
8487 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8489 struct rte_cryptodev_info info;
8491 rte_cryptodev_info_get(i, &info);
8492 if (info.driver_id != rte_cryptodev_driver_id_get(
8493 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8497 * Create the session mempool again, since now there are new devices
8498 * to use the mempool.
8500 if (ts_params->session_mpool) {
8501 rte_mempool_free(ts_params->session_mpool);
8502 ts_params->session_mpool = NULL;
8504 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8507 * Create mempool with maximum number of sessions * 2,
8508 * to include the session headers
8510 if (ts_params->session_mpool == NULL) {
8511 ts_params->session_mpool = rte_mempool_create(
8513 info.sym.max_nb_sessions * 2,
8515 0, 0, NULL, NULL, NULL,
8516 NULL, SOCKET_ID_ANY,
8519 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8520 "session mempool allocation failed");
8523 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8526 TEST_ASSERT(ret == 0,
8527 "Failed to attach device %u of pmd : %s", i,
8528 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8530 aesni_ids[nb_devs_attached] = (uint8_t)i;
8539 test_scheduler_detach_slave_op(void)
8541 struct crypto_testsuite_params *ts_params = &testsuite_params;
8542 uint8_t sched_id = ts_params->valid_devs[0];
8546 for (i = 0; i < 2; i++) {
8547 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8549 TEST_ASSERT(ret == 0,
8550 "Failed to detach device %u", aesni_ids[i]);
8557 test_scheduler_mode_op(void)
8559 struct crypto_testsuite_params *ts_params = &testsuite_params;
8560 uint8_t sched_id = ts_params->valid_devs[0];
8561 struct rte_cryptodev_scheduler_ops op = {0};
8562 struct rte_cryptodev_scheduler dummy_scheduler = {
8563 .description = "dummy scheduler to test mode",
8564 .name = "dummy scheduler",
8565 .mode = CDEV_SCHED_MODE_USERDEFINED,
8570 /* set user defined mode */
8571 ret = rte_cryptodev_scheduler_load_user_scheduler(sched_id,
8573 TEST_ASSERT(ret == 0,
8574 "Failed to set cdev %u to user defined mode", sched_id);
8576 /* set round robin mode */
8577 ret = rte_cryptodev_scheduler_mode_set(sched_id,
8578 CDEV_SCHED_MODE_ROUNDROBIN);
8579 TEST_ASSERT(ret == 0,
8580 "Failed to set cdev %u to round-robin mode", sched_id);
8581 TEST_ASSERT(rte_cryptodev_scheduler_mode_get(sched_id) ==
8582 CDEV_SCHED_MODE_ROUNDROBIN, "Scheduling Mode "
8588 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8589 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8590 .setup = testsuite_setup,
8591 .teardown = testsuite_teardown,
8592 .unit_test_cases = {
8593 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8594 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_op),
8595 TEST_CASE_ST(ut_setup, ut_teardown,
8596 test_AES_chain_scheduler_all),
8597 TEST_CASE_ST(ut_setup, ut_teardown,
8598 test_AES_cipheronly_scheduler_all),
8599 TEST_CASE_ST(ut_setup, ut_teardown,
8600 test_authonly_scheduler_all),
8601 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8602 TEST_CASES_END() /**< NULL terminate unit test array */
8606 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8608 static struct unit_test_suite cryptodev_qat_testsuite = {
8609 .suite_name = "Crypto QAT Unit Test Suite",
8610 .setup = testsuite_setup,
8611 .teardown = testsuite_teardown,
8612 .unit_test_cases = {
8613 TEST_CASE_ST(ut_setup, ut_teardown,
8614 test_device_configure_invalid_dev_id),
8615 TEST_CASE_ST(ut_setup, ut_teardown,
8616 test_device_configure_invalid_queue_pair_ids),
8617 TEST_CASE_ST(ut_setup, ut_teardown,
8618 test_queue_pair_descriptor_setup),
8619 TEST_CASE_ST(ut_setup, ut_teardown,
8620 test_multi_session),
8622 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8623 TEST_CASE_ST(ut_setup, ut_teardown,
8624 test_AES_cipheronly_qat_all),
8625 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8626 TEST_CASE_ST(ut_setup, ut_teardown,
8627 test_3DES_cipheronly_qat_all),
8628 TEST_CASE_ST(ut_setup, ut_teardown,
8629 test_DES_cipheronly_qat_all),
8630 TEST_CASE_ST(ut_setup, ut_teardown,
8631 test_AES_docsis_qat_all),
8632 TEST_CASE_ST(ut_setup, ut_teardown,
8633 test_DES_docsis_qat_all),
8634 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8635 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8637 /** AES CCM Authenticated Encryption 128 bits key */
8638 TEST_CASE_ST(ut_setup, ut_teardown,
8639 test_AES_CCM_authenticated_encryption_test_case_128_1),
8640 TEST_CASE_ST(ut_setup, ut_teardown,
8641 test_AES_CCM_authenticated_encryption_test_case_128_2),
8642 TEST_CASE_ST(ut_setup, ut_teardown,
8643 test_AES_CCM_authenticated_encryption_test_case_128_3),
8645 /** AES CCM Authenticated Decryption 128 bits key*/
8646 TEST_CASE_ST(ut_setup, ut_teardown,
8647 test_AES_CCM_authenticated_decryption_test_case_128_1),
8648 TEST_CASE_ST(ut_setup, ut_teardown,
8649 test_AES_CCM_authenticated_decryption_test_case_128_2),
8650 TEST_CASE_ST(ut_setup, ut_teardown,
8651 test_AES_CCM_authenticated_decryption_test_case_128_3),
8653 /** AES GCM Authenticated Encryption */
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8656 TEST_CASE_ST(ut_setup, ut_teardown,
8657 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8658 TEST_CASE_ST(ut_setup, ut_teardown,
8659 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_AES_GCM_authenticated_encryption_test_case_1),
8662 TEST_CASE_ST(ut_setup, ut_teardown,
8663 test_AES_GCM_authenticated_encryption_test_case_2),
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_AES_GCM_authenticated_encryption_test_case_3),
8666 TEST_CASE_ST(ut_setup, ut_teardown,
8667 test_AES_GCM_authenticated_encryption_test_case_4),
8668 TEST_CASE_ST(ut_setup, ut_teardown,
8669 test_AES_GCM_authenticated_encryption_test_case_5),
8670 TEST_CASE_ST(ut_setup, ut_teardown,
8671 test_AES_GCM_authenticated_encryption_test_case_6),
8672 TEST_CASE_ST(ut_setup, ut_teardown,
8673 test_AES_GCM_authenticated_encryption_test_case_7),
8675 /** AES GCM Authenticated Decryption */
8676 TEST_CASE_ST(ut_setup, ut_teardown,
8677 test_AES_GCM_authenticated_decryption_test_case_1),
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_AES_GCM_authenticated_decryption_test_case_2),
8680 TEST_CASE_ST(ut_setup, ut_teardown,
8681 test_AES_GCM_authenticated_decryption_test_case_3),
8682 TEST_CASE_ST(ut_setup, ut_teardown,
8683 test_AES_GCM_authenticated_decryption_test_case_4),
8684 TEST_CASE_ST(ut_setup, ut_teardown,
8685 test_AES_GCM_authenticated_decryption_test_case_5),
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_AES_GCM_authenticated_decryption_test_case_6),
8688 TEST_CASE_ST(ut_setup, ut_teardown,
8689 test_AES_GCM_authenticated_decryption_test_case_7),
8691 /** AES GCM Authenticated Encryption 192 bits key */
8692 TEST_CASE_ST(ut_setup, ut_teardown,
8693 test_AES_GCM_auth_encryption_test_case_192_1),
8694 TEST_CASE_ST(ut_setup, ut_teardown,
8695 test_AES_GCM_auth_encryption_test_case_192_2),
8696 TEST_CASE_ST(ut_setup, ut_teardown,
8697 test_AES_GCM_auth_encryption_test_case_192_3),
8698 TEST_CASE_ST(ut_setup, ut_teardown,
8699 test_AES_GCM_auth_encryption_test_case_192_4),
8700 TEST_CASE_ST(ut_setup, ut_teardown,
8701 test_AES_GCM_auth_encryption_test_case_192_5),
8702 TEST_CASE_ST(ut_setup, ut_teardown,
8703 test_AES_GCM_auth_encryption_test_case_192_6),
8704 TEST_CASE_ST(ut_setup, ut_teardown,
8705 test_AES_GCM_auth_encryption_test_case_192_7),
8707 /** AES GCM Authenticated Decryption 192 bits key */
8708 TEST_CASE_ST(ut_setup, ut_teardown,
8709 test_AES_GCM_auth_decryption_test_case_192_1),
8710 TEST_CASE_ST(ut_setup, ut_teardown,
8711 test_AES_GCM_auth_decryption_test_case_192_2),
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_AES_GCM_auth_decryption_test_case_192_3),
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_AES_GCM_auth_decryption_test_case_192_4),
8716 TEST_CASE_ST(ut_setup, ut_teardown,
8717 test_AES_GCM_auth_decryption_test_case_192_5),
8718 TEST_CASE_ST(ut_setup, ut_teardown,
8719 test_AES_GCM_auth_decryption_test_case_192_6),
8720 TEST_CASE_ST(ut_setup, ut_teardown,
8721 test_AES_GCM_auth_decryption_test_case_192_7),
8723 /** AES GCM Authenticated Encryption 256 bits key */
8724 TEST_CASE_ST(ut_setup, ut_teardown,
8725 test_AES_GCM_auth_encryption_test_case_256_1),
8726 TEST_CASE_ST(ut_setup, ut_teardown,
8727 test_AES_GCM_auth_encryption_test_case_256_2),
8728 TEST_CASE_ST(ut_setup, ut_teardown,
8729 test_AES_GCM_auth_encryption_test_case_256_3),
8730 TEST_CASE_ST(ut_setup, ut_teardown,
8731 test_AES_GCM_auth_encryption_test_case_256_4),
8732 TEST_CASE_ST(ut_setup, ut_teardown,
8733 test_AES_GCM_auth_encryption_test_case_256_5),
8734 TEST_CASE_ST(ut_setup, ut_teardown,
8735 test_AES_GCM_auth_encryption_test_case_256_6),
8736 TEST_CASE_ST(ut_setup, ut_teardown,
8737 test_AES_GCM_auth_encryption_test_case_256_7),
8739 /** AES GMAC Authentication */
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_AES_GMAC_authentication_test_case_1),
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_AES_GMAC_authentication_verify_test_case_1),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_AES_GMAC_authentication_test_case_2),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_AES_GMAC_authentication_verify_test_case_2),
8748 TEST_CASE_ST(ut_setup, ut_teardown,
8749 test_AES_GMAC_authentication_test_case_3),
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_AES_GMAC_authentication_verify_test_case_3),
8753 /** SNOW 3G encrypt only (UEA2) */
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_snow3g_encryption_test_case_1),
8756 TEST_CASE_ST(ut_setup, ut_teardown,
8757 test_snow3g_encryption_test_case_2),
8758 TEST_CASE_ST(ut_setup, ut_teardown,
8759 test_snow3g_encryption_test_case_3),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_snow3g_encryption_test_case_4),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_snow3g_encryption_test_case_5),
8765 TEST_CASE_ST(ut_setup, ut_teardown,
8766 test_snow3g_encryption_test_case_1_oop),
8767 TEST_CASE_ST(ut_setup, ut_teardown,
8768 test_snow3g_decryption_test_case_1_oop),
8770 /** SNOW 3G decrypt only (UEA2) */
8771 TEST_CASE_ST(ut_setup, ut_teardown,
8772 test_snow3g_decryption_test_case_1),
8773 TEST_CASE_ST(ut_setup, ut_teardown,
8774 test_snow3g_decryption_test_case_2),
8775 TEST_CASE_ST(ut_setup, ut_teardown,
8776 test_snow3g_decryption_test_case_3),
8777 TEST_CASE_ST(ut_setup, ut_teardown,
8778 test_snow3g_decryption_test_case_4),
8779 TEST_CASE_ST(ut_setup, ut_teardown,
8780 test_snow3g_decryption_test_case_5),
8781 TEST_CASE_ST(ut_setup, ut_teardown,
8782 test_snow3g_hash_generate_test_case_1),
8783 TEST_CASE_ST(ut_setup, ut_teardown,
8784 test_snow3g_hash_generate_test_case_2),
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_snow3g_hash_generate_test_case_3),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_snow3g_hash_verify_test_case_1),
8789 TEST_CASE_ST(ut_setup, ut_teardown,
8790 test_snow3g_hash_verify_test_case_2),
8791 TEST_CASE_ST(ut_setup, ut_teardown,
8792 test_snow3g_hash_verify_test_case_3),
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_snow3g_cipher_auth_test_case_1),
8795 TEST_CASE_ST(ut_setup, ut_teardown,
8796 test_snow3g_auth_cipher_test_case_1),
8798 /** ZUC encrypt only (EEA3) */
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_zuc_encryption_test_case_1),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_zuc_encryption_test_case_2),
8803 TEST_CASE_ST(ut_setup, ut_teardown,
8804 test_zuc_encryption_test_case_3),
8805 TEST_CASE_ST(ut_setup, ut_teardown,
8806 test_zuc_encryption_test_case_4),
8807 TEST_CASE_ST(ut_setup, ut_teardown,
8808 test_zuc_encryption_test_case_5),
8810 /** ZUC authenticate (EIA3) */
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_zuc_hash_generate_test_case_6),
8813 TEST_CASE_ST(ut_setup, ut_teardown,
8814 test_zuc_hash_generate_test_case_7),
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_zuc_hash_generate_test_case_8),
8818 /** ZUC alg-chain (EEA3/EIA3) */
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_zuc_cipher_auth_test_case_1),
8821 TEST_CASE_ST(ut_setup, ut_teardown,
8822 test_zuc_cipher_auth_test_case_2),
8824 /** HMAC_MD5 Authentication */
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_MD5_HMAC_generate_case_1),
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_MD5_HMAC_verify_case_1),
8829 TEST_CASE_ST(ut_setup, ut_teardown,
8830 test_MD5_HMAC_generate_case_2),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_MD5_HMAC_verify_case_2),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_null_auth_only_operation),
8837 TEST_CASE_ST(ut_setup, ut_teardown,
8838 test_null_cipher_only_operation),
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_null_cipher_auth_operation),
8841 TEST_CASE_ST(ut_setup, ut_teardown,
8842 test_null_auth_cipher_operation),
8845 TEST_CASE_ST(ut_setup, ut_teardown,
8846 test_kasumi_hash_generate_test_case_1),
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_kasumi_hash_generate_test_case_2),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_kasumi_hash_generate_test_case_3),
8851 TEST_CASE_ST(ut_setup, ut_teardown,
8852 test_kasumi_hash_generate_test_case_4),
8853 TEST_CASE_ST(ut_setup, ut_teardown,
8854 test_kasumi_hash_generate_test_case_5),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_kasumi_hash_generate_test_case_6),
8858 TEST_CASE_ST(ut_setup, ut_teardown,
8859 test_kasumi_hash_verify_test_case_1),
8860 TEST_CASE_ST(ut_setup, ut_teardown,
8861 test_kasumi_hash_verify_test_case_2),
8862 TEST_CASE_ST(ut_setup, ut_teardown,
8863 test_kasumi_hash_verify_test_case_3),
8864 TEST_CASE_ST(ut_setup, ut_teardown,
8865 test_kasumi_hash_verify_test_case_4),
8866 TEST_CASE_ST(ut_setup, ut_teardown,
8867 test_kasumi_hash_verify_test_case_5),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_kasumi_encryption_test_case_1),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_kasumi_encryption_test_case_3),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_kasumi_auth_cipher_test_case_1),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_kasumi_cipher_auth_test_case_1),
8878 /** Negative tests */
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 authentication_verify_AES128_GMAC_fail_data_corrupt),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8892 TEST_CASES_END() /**< NULL terminate unit test array */
8896 static struct unit_test_suite cryptodev_virtio_testsuite = {
8897 .suite_name = "Crypto VIRTIO Unit Test Suite",
8898 .setup = testsuite_setup,
8899 .teardown = testsuite_teardown,
8900 .unit_test_cases = {
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_AES_cipheronly_virtio_all),
8904 TEST_CASES_END() /**< NULL terminate unit test array */
8908 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8909 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8910 .setup = testsuite_setup,
8911 .teardown = testsuite_teardown,
8912 .unit_test_cases = {
8913 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8914 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8915 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8916 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_DES_cipheronly_mb_all),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_DES_docsis_mb_all),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_AES_CCM_authenticated_encryption_test_case_128_1),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_AES_CCM_authenticated_decryption_test_case_128_1),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_AES_CCM_authenticated_encryption_test_case_128_2),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_AES_CCM_authenticated_decryption_test_case_128_2),
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_AES_CCM_authenticated_encryption_test_case_128_3),
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_AES_CCM_authenticated_decryption_test_case_128_3),
8934 TEST_CASES_END() /**< NULL terminate unit test array */
8938 static struct unit_test_suite cryptodev_openssl_testsuite = {
8939 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
8940 .setup = testsuite_setup,
8941 .teardown = testsuite_teardown,
8942 .unit_test_cases = {
8943 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_multi_session_random_usage),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_AES_chain_openssl_all),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_AES_cipheronly_openssl_all),
8950 TEST_CASE_ST(ut_setup, ut_teardown,
8951 test_3DES_chain_openssl_all),
8952 TEST_CASE_ST(ut_setup, ut_teardown,
8953 test_3DES_cipheronly_openssl_all),
8954 TEST_CASE_ST(ut_setup, ut_teardown,
8955 test_DES_cipheronly_openssl_all),
8956 TEST_CASE_ST(ut_setup, ut_teardown,
8957 test_DES_docsis_openssl_all),
8958 TEST_CASE_ST(ut_setup, ut_teardown,
8959 test_authonly_openssl_all),
8961 /** AES GCM Authenticated Encryption */
8962 TEST_CASE_ST(ut_setup, ut_teardown,
8963 test_AES_GCM_authenticated_encryption_test_case_1),
8964 TEST_CASE_ST(ut_setup, ut_teardown,
8965 test_AES_GCM_authenticated_encryption_test_case_2),
8966 TEST_CASE_ST(ut_setup, ut_teardown,
8967 test_AES_GCM_authenticated_encryption_test_case_3),
8968 TEST_CASE_ST(ut_setup, ut_teardown,
8969 test_AES_GCM_authenticated_encryption_test_case_4),
8970 TEST_CASE_ST(ut_setup, ut_teardown,
8971 test_AES_GCM_authenticated_encryption_test_case_5),
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_AES_GCM_authenticated_encryption_test_case_6),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_AES_GCM_authenticated_encryption_test_case_7),
8977 /** AES GCM Authenticated Decryption */
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 test_AES_GCM_authenticated_decryption_test_case_1),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 test_AES_GCM_authenticated_decryption_test_case_2),
8982 TEST_CASE_ST(ut_setup, ut_teardown,
8983 test_AES_GCM_authenticated_decryption_test_case_3),
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 test_AES_GCM_authenticated_decryption_test_case_4),
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 test_AES_GCM_authenticated_decryption_test_case_5),
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 test_AES_GCM_authenticated_decryption_test_case_6),
8990 TEST_CASE_ST(ut_setup, ut_teardown,
8991 test_AES_GCM_authenticated_decryption_test_case_7),
8994 /** AES GCM Authenticated Encryption 192 bits key */
8995 TEST_CASE_ST(ut_setup, ut_teardown,
8996 test_AES_GCM_auth_encryption_test_case_192_1),
8997 TEST_CASE_ST(ut_setup, ut_teardown,
8998 test_AES_GCM_auth_encryption_test_case_192_2),
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 test_AES_GCM_auth_encryption_test_case_192_3),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_AES_GCM_auth_encryption_test_case_192_4),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_AES_GCM_auth_encryption_test_case_192_5),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_GCM_auth_encryption_test_case_192_6),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_GCM_auth_encryption_test_case_192_7),
9010 /** AES GCM Authenticated Decryption 192 bits key */
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_GCM_auth_decryption_test_case_192_1),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 test_AES_GCM_auth_decryption_test_case_192_2),
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 test_AES_GCM_auth_decryption_test_case_192_3),
9017 TEST_CASE_ST(ut_setup, ut_teardown,
9018 test_AES_GCM_auth_decryption_test_case_192_4),
9019 TEST_CASE_ST(ut_setup, ut_teardown,
9020 test_AES_GCM_auth_decryption_test_case_192_5),
9021 TEST_CASE_ST(ut_setup, ut_teardown,
9022 test_AES_GCM_auth_decryption_test_case_192_6),
9023 TEST_CASE_ST(ut_setup, ut_teardown,
9024 test_AES_GCM_auth_decryption_test_case_192_7),
9026 /** AES GCM Authenticated Encryption 256 bits key */
9027 TEST_CASE_ST(ut_setup, ut_teardown,
9028 test_AES_GCM_auth_encryption_test_case_256_1),
9029 TEST_CASE_ST(ut_setup, ut_teardown,
9030 test_AES_GCM_auth_encryption_test_case_256_2),
9031 TEST_CASE_ST(ut_setup, ut_teardown,
9032 test_AES_GCM_auth_encryption_test_case_256_3),
9033 TEST_CASE_ST(ut_setup, ut_teardown,
9034 test_AES_GCM_auth_encryption_test_case_256_4),
9035 TEST_CASE_ST(ut_setup, ut_teardown,
9036 test_AES_GCM_auth_encryption_test_case_256_5),
9037 TEST_CASE_ST(ut_setup, ut_teardown,
9038 test_AES_GCM_auth_encryption_test_case_256_6),
9039 TEST_CASE_ST(ut_setup, ut_teardown,
9040 test_AES_GCM_auth_encryption_test_case_256_7),
9042 /** AES GCM Authenticated Decryption 256 bits key */
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_AES_GCM_auth_decryption_test_case_256_1),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_GCM_auth_decryption_test_case_256_2),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_GCM_auth_decryption_test_case_256_3),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_AES_GCM_auth_decryption_test_case_256_4),
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_AES_GCM_auth_decryption_test_case_256_5),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_AES_GCM_auth_decryption_test_case_256_6),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_AES_GCM_auth_decryption_test_case_256_7),
9058 /** AES GMAC Authentication */
9059 TEST_CASE_ST(ut_setup, ut_teardown,
9060 test_AES_GMAC_authentication_test_case_1),
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_AES_GMAC_authentication_verify_test_case_1),
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_GMAC_authentication_test_case_2),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_GMAC_authentication_verify_test_case_2),
9067 TEST_CASE_ST(ut_setup, ut_teardown,
9068 test_AES_GMAC_authentication_test_case_3),
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_AES_GMAC_authentication_verify_test_case_3),
9071 TEST_CASE_ST(ut_setup, ut_teardown,
9072 test_AES_GMAC_authentication_test_case_4),
9073 TEST_CASE_ST(ut_setup, ut_teardown,
9074 test_AES_GMAC_authentication_verify_test_case_4),
9076 /** AES CCM Authenticated Encryption 128 bits key */
9077 TEST_CASE_ST(ut_setup, ut_teardown,
9078 test_AES_CCM_authenticated_encryption_test_case_128_1),
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_CCM_authenticated_encryption_test_case_128_2),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_AES_CCM_authenticated_encryption_test_case_128_3),
9084 /** AES CCM Authenticated Decryption 128 bits key*/
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_CCM_authenticated_decryption_test_case_128_1),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_AES_CCM_authenticated_decryption_test_case_128_2),
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 test_AES_CCM_authenticated_decryption_test_case_128_3),
9092 /** AES CCM Authenticated Encryption 192 bits key */
9093 TEST_CASE_ST(ut_setup, ut_teardown,
9094 test_AES_CCM_authenticated_encryption_test_case_192_1),
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_AES_CCM_authenticated_encryption_test_case_192_2),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_AES_CCM_authenticated_encryption_test_case_192_3),
9100 /** AES CCM Authenticated Decryption 192 bits key*/
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_AES_CCM_authenticated_decryption_test_case_192_1),
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 test_AES_CCM_authenticated_decryption_test_case_192_2),
9105 TEST_CASE_ST(ut_setup, ut_teardown,
9106 test_AES_CCM_authenticated_decryption_test_case_192_3),
9108 /** AES CCM Authenticated Encryption 256 bits key */
9109 TEST_CASE_ST(ut_setup, ut_teardown,
9110 test_AES_CCM_authenticated_encryption_test_case_256_1),
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_AES_CCM_authenticated_encryption_test_case_256_2),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 test_AES_CCM_authenticated_encryption_test_case_256_3),
9116 /** AES CCM Authenticated Decryption 256 bits key*/
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_AES_CCM_authenticated_decryption_test_case_256_1),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_AES_CCM_authenticated_decryption_test_case_256_2),
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_AES_CCM_authenticated_decryption_test_case_256_3),
9124 /** Scatter-Gather */
9125 TEST_CASE_ST(ut_setup, ut_teardown,
9126 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9128 /** Negative tests */
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 authentication_verify_AES128_GMAC_fail_data_corrupt),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9142 TEST_CASES_END() /**< NULL terminate unit test array */
9146 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9147 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9148 .setup = testsuite_setup,
9149 .teardown = testsuite_teardown,
9150 .unit_test_cases = {
9151 /** AES GCM Authenticated Encryption */
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_AES_GCM_authenticated_encryption_test_case_1),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_authenticated_encryption_test_case_2),
9156 TEST_CASE_ST(ut_setup, ut_teardown,
9157 test_AES_GCM_authenticated_encryption_test_case_3),
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_AES_GCM_authenticated_encryption_test_case_4),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_AES_GCM_authenticated_encryption_test_case_5),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_AES_GCM_authenticated_encryption_test_case_6),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_AES_GCM_authenticated_encryption_test_case_7),
9167 /** AES GCM Authenticated Decryption */
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_AES_GCM_authenticated_decryption_test_case_1),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_AES_GCM_authenticated_decryption_test_case_2),
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_AES_GCM_authenticated_decryption_test_case_3),
9174 TEST_CASE_ST(ut_setup, ut_teardown,
9175 test_AES_GCM_authenticated_decryption_test_case_4),
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_AES_GCM_authenticated_decryption_test_case_5),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_AES_GCM_authenticated_decryption_test_case_6),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_AES_GCM_authenticated_decryption_test_case_7),
9183 /** AES GCM Authenticated Encryption 192 bits key */
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_AES_GCM_auth_encryption_test_case_192_1),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_AES_GCM_auth_encryption_test_case_192_2),
9188 TEST_CASE_ST(ut_setup, ut_teardown,
9189 test_AES_GCM_auth_encryption_test_case_192_3),
9190 TEST_CASE_ST(ut_setup, ut_teardown,
9191 test_AES_GCM_auth_encryption_test_case_192_4),
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_AES_GCM_auth_encryption_test_case_192_5),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_AES_GCM_auth_encryption_test_case_192_6),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_AES_GCM_auth_encryption_test_case_192_7),
9199 /** AES GCM Authenticated Decryption 192 bits key */
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_AES_GCM_auth_decryption_test_case_192_1),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_AES_GCM_auth_decryption_test_case_192_2),
9204 TEST_CASE_ST(ut_setup, ut_teardown,
9205 test_AES_GCM_auth_decryption_test_case_192_3),
9206 TEST_CASE_ST(ut_setup, ut_teardown,
9207 test_AES_GCM_auth_decryption_test_case_192_4),
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 test_AES_GCM_auth_decryption_test_case_192_5),
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_AES_GCM_auth_decryption_test_case_192_6),
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_AES_GCM_auth_decryption_test_case_192_7),
9215 /** AES GCM Authenticated Encryption 256 bits key */
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_AES_GCM_auth_encryption_test_case_256_1),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_AES_GCM_auth_encryption_test_case_256_2),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_AES_GCM_auth_encryption_test_case_256_3),
9222 TEST_CASE_ST(ut_setup, ut_teardown,
9223 test_AES_GCM_auth_encryption_test_case_256_4),
9224 TEST_CASE_ST(ut_setup, ut_teardown,
9225 test_AES_GCM_auth_encryption_test_case_256_5),
9226 TEST_CASE_ST(ut_setup, ut_teardown,
9227 test_AES_GCM_auth_encryption_test_case_256_6),
9228 TEST_CASE_ST(ut_setup, ut_teardown,
9229 test_AES_GCM_auth_encryption_test_case_256_7),
9231 /** AES GCM Authenticated Decryption 256 bits key */
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 test_AES_GCM_auth_decryption_test_case_256_1),
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 test_AES_GCM_auth_decryption_test_case_256_2),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_AES_GCM_auth_decryption_test_case_256_3),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_AES_GCM_auth_decryption_test_case_256_4),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 test_AES_GCM_auth_decryption_test_case_256_5),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_AES_GCM_auth_decryption_test_case_256_6),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_AES_GCM_auth_decryption_test_case_256_7),
9247 /** AES GCM Authenticated Encryption big aad size */
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 test_AES_GCM_auth_encryption_test_case_aad_1),
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 test_AES_GCM_auth_encryption_test_case_aad_2),
9253 /** AES GCM Authenticated Decryption big aad size */
9254 TEST_CASE_ST(ut_setup, ut_teardown,
9255 test_AES_GCM_auth_decryption_test_case_aad_1),
9256 TEST_CASE_ST(ut_setup, ut_teardown,
9257 test_AES_GCM_auth_decryption_test_case_aad_2),
9259 /** AES GMAC Authentication */
9260 TEST_CASE_ST(ut_setup, ut_teardown,
9261 test_AES_GMAC_authentication_test_case_1),
9262 TEST_CASE_ST(ut_setup, ut_teardown,
9263 test_AES_GMAC_authentication_verify_test_case_1),
9264 TEST_CASE_ST(ut_setup, ut_teardown,
9265 test_AES_GMAC_authentication_test_case_3),
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_AES_GMAC_authentication_verify_test_case_3),
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_AES_GMAC_authentication_test_case_4),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_AES_GMAC_authentication_verify_test_case_4),
9273 /** Negative tests */
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 authentication_verify_AES128_GMAC_fail_data_corrupt),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9279 /** Out of place tests */
9280 TEST_CASE_ST(ut_setup, ut_teardown,
9281 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9285 /** Session-less tests */
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9291 /** Scatter-Gather */
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9295 TEST_CASES_END() /**< NULL terminate unit test array */
9299 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9300 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9301 .setup = testsuite_setup,
9302 .teardown = testsuite_teardown,
9303 .unit_test_cases = {
9304 /** KASUMI encrypt only (UEA1) */
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_kasumi_encryption_test_case_1),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_kasumi_encryption_test_case_1_sgl),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_kasumi_encryption_test_case_2),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_kasumi_encryption_test_case_3),
9313 TEST_CASE_ST(ut_setup, ut_teardown,
9314 test_kasumi_encryption_test_case_4),
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_kasumi_encryption_test_case_5),
9317 /** KASUMI decrypt only (UEA1) */
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_kasumi_decryption_test_case_1),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_kasumi_decryption_test_case_2),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_kasumi_decryption_test_case_3),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_kasumi_decryption_test_case_4),
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_kasumi_decryption_test_case_5),
9329 TEST_CASE_ST(ut_setup, ut_teardown,
9330 test_kasumi_encryption_test_case_1_oop),
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_kasumi_encryption_test_case_1_oop_sgl),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_kasumi_decryption_test_case_1_oop),
9338 /** KASUMI hash only (UIA1) */
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_kasumi_hash_generate_test_case_1),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_kasumi_hash_generate_test_case_2),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_kasumi_hash_generate_test_case_3),
9345 TEST_CASE_ST(ut_setup, ut_teardown,
9346 test_kasumi_hash_generate_test_case_4),
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_kasumi_hash_generate_test_case_5),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_kasumi_hash_generate_test_case_6),
9351 TEST_CASE_ST(ut_setup, ut_teardown,
9352 test_kasumi_hash_verify_test_case_1),
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_kasumi_hash_verify_test_case_2),
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_kasumi_hash_verify_test_case_3),
9357 TEST_CASE_ST(ut_setup, ut_teardown,
9358 test_kasumi_hash_verify_test_case_4),
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_kasumi_hash_verify_test_case_5),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_kasumi_auth_cipher_test_case_1),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_kasumi_cipher_auth_test_case_1),
9365 TEST_CASES_END() /**< NULL terminate unit test array */
9368 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9369 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9370 .setup = testsuite_setup,
9371 .teardown = testsuite_teardown,
9372 .unit_test_cases = {
9373 /** SNOW 3G encrypt only (UEA2) */
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_snow3g_encryption_test_case_1),
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_snow3g_encryption_test_case_2),
9378 TEST_CASE_ST(ut_setup, ut_teardown,
9379 test_snow3g_encryption_test_case_3),
9380 TEST_CASE_ST(ut_setup, ut_teardown,
9381 test_snow3g_encryption_test_case_4),
9382 TEST_CASE_ST(ut_setup, ut_teardown,
9383 test_snow3g_encryption_test_case_5),
9385 TEST_CASE_ST(ut_setup, ut_teardown,
9386 test_snow3g_encryption_test_case_1_oop),
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_snow3g_encryption_test_case_1_oop_sgl),
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_snow3g_decryption_test_case_1_oop),
9392 TEST_CASE_ST(ut_setup, ut_teardown,
9393 test_snow3g_encryption_test_case_1_offset_oop),
9395 /** SNOW 3G decrypt only (UEA2) */
9396 TEST_CASE_ST(ut_setup, ut_teardown,
9397 test_snow3g_decryption_test_case_1),
9398 TEST_CASE_ST(ut_setup, ut_teardown,
9399 test_snow3g_decryption_test_case_2),
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_snow3g_decryption_test_case_3),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_snow3g_decryption_test_case_4),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_snow3g_decryption_test_case_5),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_snow3g_hash_generate_test_case_1),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_snow3g_hash_generate_test_case_2),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_snow3g_hash_generate_test_case_3),
9412 /* Tests with buffers which length is not byte-aligned */
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 test_snow3g_hash_generate_test_case_4),
9415 TEST_CASE_ST(ut_setup, ut_teardown,
9416 test_snow3g_hash_generate_test_case_5),
9417 TEST_CASE_ST(ut_setup, ut_teardown,
9418 test_snow3g_hash_generate_test_case_6),
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_snow3g_hash_verify_test_case_1),
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_snow3g_hash_verify_test_case_2),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_snow3g_hash_verify_test_case_3),
9425 /* Tests with buffers which length is not byte-aligned */
9426 TEST_CASE_ST(ut_setup, ut_teardown,
9427 test_snow3g_hash_verify_test_case_4),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_snow3g_hash_verify_test_case_5),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_snow3g_hash_verify_test_case_6),
9432 TEST_CASE_ST(ut_setup, ut_teardown,
9433 test_snow3g_cipher_auth_test_case_1),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_snow3g_auth_cipher_test_case_1),
9437 TEST_CASES_END() /**< NULL terminate unit test array */
9441 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9442 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9443 .setup = testsuite_setup,
9444 .teardown = testsuite_teardown,
9445 .unit_test_cases = {
9446 /** ZUC encrypt only (EEA3) */
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_zuc_encryption_test_case_1),
9449 TEST_CASE_ST(ut_setup, ut_teardown,
9450 test_zuc_encryption_test_case_2),
9451 TEST_CASE_ST(ut_setup, ut_teardown,
9452 test_zuc_encryption_test_case_3),
9453 TEST_CASE_ST(ut_setup, ut_teardown,
9454 test_zuc_encryption_test_case_4),
9455 TEST_CASE_ST(ut_setup, ut_teardown,
9456 test_zuc_encryption_test_case_5),
9457 TEST_CASE_ST(ut_setup, ut_teardown,
9458 test_zuc_hash_generate_test_case_1),
9459 TEST_CASE_ST(ut_setup, ut_teardown,
9460 test_zuc_hash_generate_test_case_2),
9461 TEST_CASE_ST(ut_setup, ut_teardown,
9462 test_zuc_hash_generate_test_case_3),
9463 TEST_CASE_ST(ut_setup, ut_teardown,
9464 test_zuc_hash_generate_test_case_4),
9465 TEST_CASE_ST(ut_setup, ut_teardown,
9466 test_zuc_hash_generate_test_case_5),
9467 TEST_CASE_ST(ut_setup, ut_teardown,
9468 test_zuc_encryption_test_case_6_sgl),
9469 TEST_CASES_END() /**< NULL terminate unit test array */
9473 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9474 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9475 .setup = testsuite_setup,
9476 .teardown = testsuite_teardown,
9477 .unit_test_cases = {
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_device_configure_invalid_dev_id),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_multi_session),
9483 TEST_CASE_ST(ut_setup, ut_teardown,
9484 test_AES_chain_dpaa_sec_all),
9485 TEST_CASE_ST(ut_setup, ut_teardown,
9486 test_3DES_chain_dpaa_sec_all),
9487 TEST_CASE_ST(ut_setup, ut_teardown,
9488 test_AES_cipheronly_dpaa_sec_all),
9489 TEST_CASE_ST(ut_setup, ut_teardown,
9490 test_3DES_cipheronly_dpaa_sec_all),
9491 TEST_CASE_ST(ut_setup, ut_teardown,
9492 test_authonly_dpaa_sec_all),
9494 /** AES GCM Authenticated Encryption */
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_AES_GCM_authenticated_encryption_test_case_1),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_AES_GCM_authenticated_encryption_test_case_2),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_AES_GCM_authenticated_encryption_test_case_3),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_AES_GCM_authenticated_encryption_test_case_4),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_AES_GCM_authenticated_encryption_test_case_5),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_AES_GCM_authenticated_encryption_test_case_6),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_AES_GCM_authenticated_encryption_test_case_7),
9510 /** AES GCM Authenticated Decryption */
9511 TEST_CASE_ST(ut_setup, ut_teardown,
9512 test_AES_GCM_authenticated_decryption_test_case_1),
9513 TEST_CASE_ST(ut_setup, ut_teardown,
9514 test_AES_GCM_authenticated_decryption_test_case_2),
9515 TEST_CASE_ST(ut_setup, ut_teardown,
9516 test_AES_GCM_authenticated_decryption_test_case_3),
9517 TEST_CASE_ST(ut_setup, ut_teardown,
9518 test_AES_GCM_authenticated_decryption_test_case_4),
9519 TEST_CASE_ST(ut_setup, ut_teardown,
9520 test_AES_GCM_authenticated_decryption_test_case_5),
9521 TEST_CASE_ST(ut_setup, ut_teardown,
9522 test_AES_GCM_authenticated_decryption_test_case_6),
9523 TEST_CASE_ST(ut_setup, ut_teardown,
9524 test_AES_GCM_authenticated_decryption_test_case_7),
9526 /** AES GCM Authenticated Encryption 256 bits key */
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_AES_GCM_auth_encryption_test_case_256_1),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_AES_GCM_auth_encryption_test_case_256_2),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_AES_GCM_auth_encryption_test_case_256_3),
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_AES_GCM_auth_encryption_test_case_256_4),
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_AES_GCM_auth_encryption_test_case_256_5),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_AES_GCM_auth_encryption_test_case_256_6),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_AES_GCM_auth_encryption_test_case_256_7),
9542 /** AES GCM Authenticated Decryption 256 bits key */
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_AES_GCM_auth_decryption_test_case_256_1),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_AES_GCM_auth_decryption_test_case_256_2),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_AES_GCM_auth_decryption_test_case_256_3),
9549 TEST_CASE_ST(ut_setup, ut_teardown,
9550 test_AES_GCM_auth_decryption_test_case_256_4),
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_AES_GCM_auth_decryption_test_case_256_5),
9553 TEST_CASE_ST(ut_setup, ut_teardown,
9554 test_AES_GCM_auth_decryption_test_case_256_6),
9555 TEST_CASE_ST(ut_setup, ut_teardown,
9556 test_AES_GCM_auth_decryption_test_case_256_7),
9558 /** Out of place tests */
9559 TEST_CASE_ST(ut_setup, ut_teardown,
9560 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9561 TEST_CASE_ST(ut_setup, ut_teardown,
9562 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9564 /** Scatter-Gather */
9565 TEST_CASE_ST(ut_setup, ut_teardown,
9566 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9574 TEST_CASES_END() /**< NULL terminate unit test array */
9578 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9579 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9580 .setup = testsuite_setup,
9581 .teardown = testsuite_teardown,
9582 .unit_test_cases = {
9583 TEST_CASE_ST(ut_setup, ut_teardown,
9584 test_device_configure_invalid_dev_id),
9585 TEST_CASE_ST(ut_setup, ut_teardown,
9586 test_multi_session),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_AES_chain_dpaa2_sec_all),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_3DES_chain_dpaa2_sec_all),
9592 TEST_CASE_ST(ut_setup, ut_teardown,
9593 test_AES_cipheronly_dpaa2_sec_all),
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_3DES_cipheronly_dpaa2_sec_all),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_authonly_dpaa2_sec_all),
9599 /** AES GCM Authenticated Encryption */
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_GCM_authenticated_encryption_test_case_1),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_authenticated_encryption_test_case_2),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_authenticated_encryption_test_case_3),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_authenticated_encryption_test_case_4),
9608 TEST_CASE_ST(ut_setup, ut_teardown,
9609 test_AES_GCM_authenticated_encryption_test_case_5),
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_authenticated_encryption_test_case_6),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_authenticated_encryption_test_case_7),
9615 /** AES GCM Authenticated Decryption */
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_authenticated_decryption_test_case_1),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_authenticated_decryption_test_case_2),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GCM_authenticated_decryption_test_case_3),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_authenticated_decryption_test_case_4),
9624 TEST_CASE_ST(ut_setup, ut_teardown,
9625 test_AES_GCM_authenticated_decryption_test_case_5),
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GCM_authenticated_decryption_test_case_6),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GCM_authenticated_decryption_test_case_7),
9631 /** AES GCM Authenticated Encryption 192 bits key */
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GCM_auth_encryption_test_case_192_1),
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_encryption_test_case_192_2),
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_GCM_auth_encryption_test_case_192_3),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_encryption_test_case_192_4),
9640 TEST_CASE_ST(ut_setup, ut_teardown,
9641 test_AES_GCM_auth_encryption_test_case_192_5),
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_GCM_auth_encryption_test_case_192_6),
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_auth_encryption_test_case_192_7),
9647 /** AES GCM Authenticated Decryption 192 bits key */
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_auth_decryption_test_case_192_1),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_decryption_test_case_192_2),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_GCM_auth_decryption_test_case_192_3),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_decryption_test_case_192_4),
9656 TEST_CASE_ST(ut_setup, ut_teardown,
9657 test_AES_GCM_auth_decryption_test_case_192_5),
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_GCM_auth_decryption_test_case_192_6),
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_auth_decryption_test_case_192_7),
9663 /** AES GCM Authenticated Encryption 256 bits key */
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_GCM_auth_encryption_test_case_256_1),
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_encryption_test_case_256_2),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_GCM_auth_encryption_test_case_256_3),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_auth_encryption_test_case_256_4),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_GCM_auth_encryption_test_case_256_5),
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_AES_GCM_auth_encryption_test_case_256_6),
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_GCM_auth_encryption_test_case_256_7),
9679 /** AES GCM Authenticated Decryption 256 bits key */
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_AES_GCM_auth_decryption_test_case_256_1),
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GCM_auth_decryption_test_case_256_2),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GCM_auth_decryption_test_case_256_3),
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 test_AES_GCM_auth_decryption_test_case_256_4),
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 test_AES_GCM_auth_decryption_test_case_256_5),
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 test_AES_GCM_auth_decryption_test_case_256_6),
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 test_AES_GCM_auth_decryption_test_case_256_7),
9695 /** Out of place tests */
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9701 /** Scatter-Gather */
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9706 TEST_CASE_ST(ut_setup, ut_teardown,
9707 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9711 TEST_CASES_END() /**< NULL terminate unit test array */
9715 static struct unit_test_suite cryptodev_null_testsuite = {
9716 .suite_name = "Crypto Device NULL Unit Test Suite",
9717 .setup = testsuite_setup,
9718 .teardown = testsuite_teardown,
9719 .unit_test_cases = {
9720 TEST_CASE_ST(ut_setup, ut_teardown,
9721 test_null_auth_only_operation),
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_null_cipher_only_operation),
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_null_cipher_auth_operation),
9726 TEST_CASE_ST(ut_setup, ut_teardown,
9727 test_null_auth_cipher_operation),
9728 TEST_CASE_ST(ut_setup, ut_teardown,
9729 test_null_invalid_operation),
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_null_burst_operation),
9733 TEST_CASES_END() /**< NULL terminate unit test array */
9737 static struct unit_test_suite cryptodev_armv8_testsuite = {
9738 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9739 .setup = testsuite_setup,
9740 .teardown = testsuite_teardown,
9741 .unit_test_cases = {
9742 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9744 /** Negative tests */
9745 TEST_CASE_ST(ut_setup, ut_teardown,
9746 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9750 TEST_CASES_END() /**< NULL terminate unit test array */
9754 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9755 .suite_name = "Crypto Device Marvell Component Test Suite",
9756 .setup = testsuite_setup,
9757 .teardown = testsuite_teardown,
9758 .unit_test_cases = {
9759 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9760 TEST_CASE_ST(ut_setup, ut_teardown,
9761 test_multi_session_random_usage),
9762 TEST_CASE_ST(ut_setup, ut_teardown,
9763 test_AES_chain_mrvl_all),
9764 TEST_CASE_ST(ut_setup, ut_teardown,
9765 test_AES_cipheronly_mrvl_all),
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_authonly_mrvl_all),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 test_3DES_chain_mrvl_all),
9770 TEST_CASE_ST(ut_setup, ut_teardown,
9771 test_3DES_cipheronly_mrvl_all),
9773 /** Negative tests */
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9776 TEST_CASE_ST(ut_setup, ut_teardown,
9777 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9778 TEST_CASE_ST(ut_setup, ut_teardown,
9779 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9780 TEST_CASE_ST(ut_setup, ut_teardown,
9781 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9783 TEST_CASES_END() /**< NULL terminate unit test array */
9787 static struct unit_test_suite cryptodev_ccp_testsuite = {
9788 .suite_name = "Crypto Device CCP Unit Test Suite",
9789 .setup = testsuite_setup,
9790 .teardown = testsuite_teardown,
9791 .unit_test_cases = {
9792 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9793 TEST_CASE_ST(ut_setup, ut_teardown,
9794 test_multi_session_random_usage),
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_AES_chain_ccp_all),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_AES_cipheronly_ccp_all),
9799 TEST_CASE_ST(ut_setup, ut_teardown,
9800 test_3DES_chain_ccp_all),
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_3DES_cipheronly_ccp_all),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_authonly_ccp_all),
9806 /** Negative tests */
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9809 TEST_CASE_ST(ut_setup, ut_teardown,
9810 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9811 TEST_CASE_ST(ut_setup, ut_teardown,
9812 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9813 TEST_CASE_ST(ut_setup, ut_teardown,
9814 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9816 TEST_CASES_END() /**< NULL terminate unit test array */
9821 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9823 gbl_driver_id = rte_cryptodev_driver_id_get(
9824 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9826 if (gbl_driver_id == -1) {
9827 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9828 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9829 "in config file to run this testsuite.\n");
9830 return TEST_SKIPPED;
9833 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9837 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9839 gbl_driver_id = rte_cryptodev_driver_id_get(
9840 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9842 if (gbl_driver_id == -1) {
9843 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9844 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9845 "in config file to run this testsuite.\n");
9849 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9853 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9855 gbl_driver_id = rte_cryptodev_driver_id_get(
9856 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9858 if (gbl_driver_id == -1) {
9859 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9860 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9861 "in config file to run this testsuite.\n");
9862 return TEST_SKIPPED;
9865 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9869 test_cryptodev_openssl(void)
9871 gbl_driver_id = rte_cryptodev_driver_id_get(
9872 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9874 if (gbl_driver_id == -1) {
9875 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9876 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9877 "in config file to run this testsuite.\n");
9878 return TEST_SKIPPED;
9881 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9885 test_cryptodev_aesni_gcm(void)
9887 gbl_driver_id = rte_cryptodev_driver_id_get(
9888 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9890 if (gbl_driver_id == -1) {
9891 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9892 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9893 "in config file to run this testsuite.\n");
9894 return TEST_SKIPPED;
9897 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9901 test_cryptodev_null(void)
9903 gbl_driver_id = rte_cryptodev_driver_id_get(
9904 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9906 if (gbl_driver_id == -1) {
9907 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9908 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9909 "in config file to run this testsuite.\n");
9910 return TEST_SKIPPED;
9913 return unit_test_suite_runner(&cryptodev_null_testsuite);
9917 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
9919 gbl_driver_id = rte_cryptodev_driver_id_get(
9920 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
9922 if (gbl_driver_id == -1) {
9923 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
9924 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
9925 "in config file to run this testsuite.\n");
9926 return TEST_SKIPPED;
9929 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
9933 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
9935 gbl_driver_id = rte_cryptodev_driver_id_get(
9936 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
9938 if (gbl_driver_id == -1) {
9939 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9940 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
9941 "in config file to run this testsuite.\n");
9942 return TEST_SKIPPED;
9945 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
9949 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
9951 gbl_driver_id = rte_cryptodev_driver_id_get(
9952 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
9954 if (gbl_driver_id == -1) {
9955 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
9956 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
9957 "in config file to run this testsuite.\n");
9958 return TEST_SKIPPED;
9961 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
9965 test_cryptodev_armv8(void)
9967 gbl_driver_id = rte_cryptodev_driver_id_get(
9968 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
9970 if (gbl_driver_id == -1) {
9971 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
9972 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
9973 "in config file to run this testsuite.\n");
9974 return TEST_SKIPPED;
9977 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
9981 test_cryptodev_mrvl(void)
9983 gbl_driver_id = rte_cryptodev_driver_id_get(
9984 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
9986 if (gbl_driver_id == -1) {
9987 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
9988 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
9989 "in config file to run this testsuite.\n");
9990 return TEST_SKIPPED;
9993 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
9996 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
9999 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10001 gbl_driver_id = rte_cryptodev_driver_id_get(
10002 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10004 if (gbl_driver_id == -1) {
10005 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10006 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10007 "in config file to run this testsuite.\n");
10008 return TEST_SKIPPED;
10011 if (rte_cryptodev_driver_id_get(
10012 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10013 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10014 " enabled in config file to run this testsuite.\n");
10015 return TEST_SKIPPED;
10017 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10020 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10025 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10027 gbl_driver_id = rte_cryptodev_driver_id_get(
10028 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10030 if (gbl_driver_id == -1) {
10031 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10032 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10033 "in config file to run this testsuite.\n");
10034 return TEST_SKIPPED;
10037 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10041 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10043 gbl_driver_id = rte_cryptodev_driver_id_get(
10044 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10046 if (gbl_driver_id == -1) {
10047 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10048 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10049 "in config file to run this testsuite.\n");
10050 return TEST_SKIPPED;
10053 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10057 test_cryptodev_ccp(void)
10059 gbl_driver_id = rte_cryptodev_driver_id_get(
10060 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10062 if (gbl_driver_id == -1) {
10063 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10064 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10065 "in config file to run this testsuite.\n");
10066 return TEST_FAILED;
10069 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10072 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10073 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10074 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10075 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10076 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10077 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10078 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10079 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10080 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10081 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10082 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10083 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10084 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10085 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);