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>
24 #include <rte_lcore.h>
27 #include "test_cryptodev.h"
29 #include "test_cryptodev_blockcipher.h"
30 #include "test_cryptodev_aes_test_vectors.h"
31 #include "test_cryptodev_des_test_vectors.h"
32 #include "test_cryptodev_hash_test_vectors.h"
33 #include "test_cryptodev_kasumi_test_vectors.h"
34 #include "test_cryptodev_kasumi_hash_test_vectors.h"
35 #include "test_cryptodev_snow3g_test_vectors.h"
36 #include "test_cryptodev_snow3g_hash_test_vectors.h"
37 #include "test_cryptodev_zuc_test_vectors.h"
38 #include "test_cryptodev_aead_test_vectors.h"
39 #include "test_cryptodev_hmac_test_vectors.h"
41 #define VDEV_ARGS_SIZE 100
42 #define MAX_NB_SESSIONS 4
44 static int gbl_driver_id;
46 struct crypto_testsuite_params {
47 struct rte_mempool *mbuf_pool;
48 struct rte_mempool *large_mbuf_pool;
49 struct rte_mempool *op_mpool;
50 struct rte_mempool *session_mpool;
51 struct rte_cryptodev_config conf;
52 struct rte_cryptodev_qp_conf qp_conf;
54 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
55 uint8_t valid_dev_count;
58 struct crypto_unittest_params {
59 struct rte_crypto_sym_xform cipher_xform;
60 struct rte_crypto_sym_xform auth_xform;
61 struct rte_crypto_sym_xform aead_xform;
63 struct rte_cryptodev_sym_session *sess;
65 struct rte_crypto_op *op;
67 struct rte_mbuf *obuf, *ibuf;
72 #define ALIGN_POW2_ROUNDUP(num, align) \
73 (((num) + (align) - 1) & ~((align) - 1))
76 * Forward declarations.
79 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
80 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
84 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
85 struct crypto_unittest_params *ut_params,
86 struct crypto_testsuite_params *ts_param,
87 const uint8_t *cipher,
88 const uint8_t *digest,
91 static struct rte_mbuf *
92 setup_test_string(struct rte_mempool *mpool,
93 const char *string, size_t len, uint8_t blocksize)
95 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
96 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
98 memset(m->buf_addr, 0, m->buf_len);
100 char *dst = rte_pktmbuf_append(m, t_len);
107 rte_memcpy(dst, string, t_len);
109 memset(dst, 0, t_len);
115 /* Get number of bytes in X bits (rounding up) */
117 ceil_byte_length(uint32_t num_bits)
120 return ((num_bits >> 3) + 1);
122 return (num_bits >> 3);
125 static struct rte_crypto_op *
126 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
128 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
129 printf("Error sending packet for encryption");
135 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
141 static struct crypto_testsuite_params testsuite_params = { NULL };
142 static struct crypto_unittest_params unittest_params;
145 testsuite_setup(void)
147 struct crypto_testsuite_params *ts_params = &testsuite_params;
148 struct rte_cryptodev_info info;
149 uint32_t i = 0, nb_devs, dev_id;
153 memset(ts_params, 0, sizeof(*ts_params));
155 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
156 if (ts_params->mbuf_pool == NULL) {
157 /* Not already created so create */
158 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
160 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
162 if (ts_params->mbuf_pool == NULL) {
163 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
168 ts_params->large_mbuf_pool = rte_mempool_lookup(
169 "CRYPTO_LARGE_MBUFPOOL");
170 if (ts_params->large_mbuf_pool == NULL) {
171 /* Not already created so create */
172 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
173 "CRYPTO_LARGE_MBUFPOOL",
176 if (ts_params->large_mbuf_pool == NULL) {
178 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
183 ts_params->op_mpool = rte_crypto_op_pool_create(
184 "MBUF_CRYPTO_SYM_OP_POOL",
185 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
186 NUM_MBUFS, MBUF_CACHE_SIZE,
188 sizeof(struct rte_crypto_sym_xform) +
191 if (ts_params->op_mpool == NULL) {
192 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
196 /* Create an AESNI MB device if required */
197 if (gbl_driver_id == rte_cryptodev_driver_id_get(
198 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
199 nb_devs = rte_cryptodev_device_count_by_driver(
200 rte_cryptodev_driver_id_get(
201 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
204 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
206 TEST_ASSERT(ret == 0,
207 "Failed to create instance of"
209 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
213 /* Create an AESNI GCM device if required */
214 if (gbl_driver_id == rte_cryptodev_driver_id_get(
215 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
216 nb_devs = rte_cryptodev_device_count_by_driver(
217 rte_cryptodev_driver_id_get(
218 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
220 TEST_ASSERT_SUCCESS(rte_vdev_init(
221 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
222 "Failed to create instance of"
224 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
228 /* Create a SNOW 3G device if required */
229 if (gbl_driver_id == rte_cryptodev_driver_id_get(
230 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
231 nb_devs = rte_cryptodev_device_count_by_driver(
232 rte_cryptodev_driver_id_get(
233 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
235 TEST_ASSERT_SUCCESS(rte_vdev_init(
236 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
237 "Failed to create instance of"
239 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
243 /* Create a KASUMI device if required */
244 if (gbl_driver_id == rte_cryptodev_driver_id_get(
245 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
246 nb_devs = rte_cryptodev_device_count_by_driver(
247 rte_cryptodev_driver_id_get(
248 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
250 TEST_ASSERT_SUCCESS(rte_vdev_init(
251 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
252 "Failed to create instance of"
254 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
258 /* Create a ZUC device if required */
259 if (gbl_driver_id == rte_cryptodev_driver_id_get(
260 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
261 nb_devs = rte_cryptodev_device_count_by_driver(
262 rte_cryptodev_driver_id_get(
263 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
265 TEST_ASSERT_SUCCESS(rte_vdev_init(
266 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
267 "Failed to create instance of"
269 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
273 /* Create a NULL device if required */
274 if (gbl_driver_id == rte_cryptodev_driver_id_get(
275 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
276 nb_devs = rte_cryptodev_device_count_by_driver(
277 rte_cryptodev_driver_id_get(
278 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
281 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
283 TEST_ASSERT(ret == 0,
284 "Failed to create instance of"
286 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
290 /* Create an OPENSSL device if required */
291 if (gbl_driver_id == rte_cryptodev_driver_id_get(
292 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
293 nb_devs = rte_cryptodev_device_count_by_driver(
294 rte_cryptodev_driver_id_get(
295 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
298 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
301 TEST_ASSERT(ret == 0, "Failed to create "
302 "instance of pmd : %s",
303 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
307 /* Create a ARMv8 device if required */
308 if (gbl_driver_id == rte_cryptodev_driver_id_get(
309 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
310 nb_devs = rte_cryptodev_device_count_by_driver(
311 rte_cryptodev_driver_id_get(
312 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
315 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
318 TEST_ASSERT(ret == 0, "Failed to create "
319 "instance of pmd : %s",
320 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
324 /* Create a MVSAM device if required */
325 if (gbl_driver_id == rte_cryptodev_driver_id_get(
326 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
327 nb_devs = rte_cryptodev_device_count_by_driver(
328 rte_cryptodev_driver_id_get(
329 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
332 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
335 TEST_ASSERT(ret == 0, "Failed to create "
336 "instance of pmd : %s",
337 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
341 /* Create an CCP device if required */
342 if (gbl_driver_id == rte_cryptodev_driver_id_get(
343 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
344 nb_devs = rte_cryptodev_device_count_by_driver(
345 rte_cryptodev_driver_id_get(
346 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
349 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
352 TEST_ASSERT(ret == 0, "Failed to create "
353 "instance of pmd : %s",
354 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
358 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
359 char vdev_args[VDEV_ARGS_SIZE] = {""};
360 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
361 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
362 uint16_t slave_core_count = 0;
363 uint16_t socket_id = 0;
365 if (gbl_driver_id == rte_cryptodev_driver_id_get(
366 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
368 /* Identify the Slave Cores
369 * Use 2 slave cores for the device args
371 RTE_LCORE_FOREACH_SLAVE(i) {
372 if (slave_core_count > 1)
374 snprintf(vdev_args, sizeof(vdev_args),
375 "%s%d", temp_str, i);
376 strcpy(temp_str, vdev_args);
377 strcat(temp_str, ";");
379 socket_id = lcore_config[i].socket_id;
381 if (slave_core_count != 2) {
383 "Cryptodev scheduler test require at least "
384 "two slave cores to run. "
385 "Please use the correct coremask.\n");
388 strcpy(temp_str, vdev_args);
389 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
390 temp_str, socket_id);
391 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
392 nb_devs = rte_cryptodev_device_count_by_driver(
393 rte_cryptodev_driver_id_get(
394 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
397 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
399 TEST_ASSERT(ret == 0,
400 "Failed to create instance %u of"
402 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
405 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
407 nb_devs = rte_cryptodev_count();
409 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
413 /* Create list of valid crypto devs */
414 for (i = 0; i < nb_devs; i++) {
415 rte_cryptodev_info_get(i, &info);
416 if (info.driver_id == gbl_driver_id)
417 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
420 if (ts_params->valid_dev_count < 1)
423 /* Set up all the qps on the first of the valid devices found */
425 dev_id = ts_params->valid_devs[0];
427 rte_cryptodev_info_get(dev_id, &info);
429 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
430 ts_params->conf.socket_id = SOCKET_ID_ANY;
432 unsigned int session_size =
433 rte_cryptodev_sym_get_private_session_size(dev_id);
436 * Create mempool with maximum number of sessions * 2,
437 * to include the session headers
439 if (info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
440 RTE_LOG(ERR, USER1, "Device does not support "
441 "at least %u sessions\n",
446 ts_params->session_mpool = rte_mempool_create(
450 0, 0, NULL, NULL, NULL,
454 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
455 "session mempool allocation failed");
457 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
459 "Failed to configure cryptodev %u with %u qps",
460 dev_id, ts_params->conf.nb_queue_pairs);
462 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
464 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
465 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
466 dev_id, qp_id, &ts_params->qp_conf,
467 rte_cryptodev_socket_id(dev_id),
468 ts_params->session_mpool),
469 "Failed to setup queue pair %u on cryptodev %u",
477 testsuite_teardown(void)
479 struct crypto_testsuite_params *ts_params = &testsuite_params;
481 if (ts_params->mbuf_pool != NULL) {
482 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
483 rte_mempool_avail_count(ts_params->mbuf_pool));
486 if (ts_params->op_mpool != NULL) {
487 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
488 rte_mempool_avail_count(ts_params->op_mpool));
491 /* Free session mempools */
492 if (ts_params->session_mpool != NULL) {
493 rte_mempool_free(ts_params->session_mpool);
494 ts_params->session_mpool = NULL;
501 struct crypto_testsuite_params *ts_params = &testsuite_params;
502 struct crypto_unittest_params *ut_params = &unittest_params;
506 /* Clear unit test parameters before running test */
507 memset(ut_params, 0, sizeof(*ut_params));
509 /* Reconfigure device to default parameters */
510 ts_params->conf.socket_id = SOCKET_ID_ANY;
512 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
514 "Failed to configure cryptodev %u",
515 ts_params->valid_devs[0]);
517 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
518 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
519 ts_params->valid_devs[0], qp_id,
521 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
522 ts_params->session_mpool),
523 "Failed to setup queue pair %u on cryptodev %u",
524 qp_id, ts_params->valid_devs[0]);
528 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
530 /* Start the device */
531 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
532 "Failed to start cryptodev %u",
533 ts_params->valid_devs[0]);
541 struct crypto_testsuite_params *ts_params = &testsuite_params;
542 struct crypto_unittest_params *ut_params = &unittest_params;
543 struct rte_cryptodev_stats stats;
545 /* free crypto session structure */
546 if (ut_params->sess) {
547 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
549 rte_cryptodev_sym_session_free(ut_params->sess);
550 ut_params->sess = NULL;
553 /* free crypto operation structure */
555 rte_crypto_op_free(ut_params->op);
558 * free mbuf - both obuf and ibuf are usually the same,
559 * so check if they point at the same address is necessary,
560 * to avoid freeing the mbuf twice.
562 if (ut_params->obuf) {
563 rte_pktmbuf_free(ut_params->obuf);
564 if (ut_params->ibuf == ut_params->obuf)
568 if (ut_params->ibuf) {
569 rte_pktmbuf_free(ut_params->ibuf);
573 if (ts_params->mbuf_pool != NULL)
574 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
575 rte_mempool_avail_count(ts_params->mbuf_pool));
577 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
579 /* Stop the device */
580 rte_cryptodev_stop(ts_params->valid_devs[0]);
584 test_device_configure_invalid_dev_id(void)
586 struct crypto_testsuite_params *ts_params = &testsuite_params;
587 uint16_t dev_id, num_devs = 0;
589 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
590 "Need at least %d devices for test", 1);
592 /* valid dev_id values */
593 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
595 /* Stop the device in case it's started so it can be configured */
596 rte_cryptodev_stop(dev_id);
598 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
599 "Failed test for rte_cryptodev_configure: "
600 "invalid dev_num %u", dev_id);
602 /* invalid dev_id values */
605 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
606 "Failed test for rte_cryptodev_configure: "
607 "invalid dev_num %u", dev_id);
611 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
612 "Failed test for rte_cryptodev_configure:"
613 "invalid dev_num %u", dev_id);
619 test_device_configure_invalid_queue_pair_ids(void)
621 struct crypto_testsuite_params *ts_params = &testsuite_params;
622 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
624 /* Stop the device in case it's started so it can be configured */
625 rte_cryptodev_stop(ts_params->valid_devs[0]);
627 /* valid - one queue pairs */
628 ts_params->conf.nb_queue_pairs = 1;
630 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
632 "Failed to configure cryptodev: dev_id %u, qp_id %u",
633 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
636 /* valid - max value queue pairs */
637 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
639 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
641 "Failed to configure cryptodev: dev_id %u, qp_id %u",
642 ts_params->valid_devs[0],
643 ts_params->conf.nb_queue_pairs);
646 /* invalid - zero queue pairs */
647 ts_params->conf.nb_queue_pairs = 0;
649 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
651 "Failed test for rte_cryptodev_configure, dev_id %u,"
653 ts_params->valid_devs[0],
654 ts_params->conf.nb_queue_pairs);
657 /* invalid - max value supported by field queue pairs */
658 ts_params->conf.nb_queue_pairs = UINT16_MAX;
660 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
662 "Failed test for rte_cryptodev_configure, dev_id %u,"
664 ts_params->valid_devs[0],
665 ts_params->conf.nb_queue_pairs);
668 /* invalid - max value + 1 queue pairs */
669 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
671 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
673 "Failed test for rte_cryptodev_configure, dev_id %u,"
675 ts_params->valid_devs[0],
676 ts_params->conf.nb_queue_pairs);
678 /* revert to original testsuite value */
679 ts_params->conf.nb_queue_pairs = orig_nb_qps;
685 test_queue_pair_descriptor_setup(void)
687 struct crypto_testsuite_params *ts_params = &testsuite_params;
688 struct rte_cryptodev_info dev_info;
689 struct rte_cryptodev_qp_conf qp_conf = {
690 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
695 /* Stop the device in case it's started so it can be configured */
696 rte_cryptodev_stop(ts_params->valid_devs[0]);
699 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
701 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
703 "Failed to configure cryptodev %u",
704 ts_params->valid_devs[0]);
707 * Test various ring sizes on this device. memzones can't be
708 * freed so are re-used if ring is released and re-created.
710 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
712 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
713 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
714 ts_params->valid_devs[0], qp_id, &qp_conf,
715 rte_cryptodev_socket_id(
716 ts_params->valid_devs[0]),
717 ts_params->session_mpool),
719 "rte_cryptodev_queue_pair_setup: num_inflights "
720 "%u on qp %u on cryptodev %u",
721 qp_conf.nb_descriptors, qp_id,
722 ts_params->valid_devs[0]);
725 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
727 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
728 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
729 ts_params->valid_devs[0], qp_id, &qp_conf,
730 rte_cryptodev_socket_id(
731 ts_params->valid_devs[0]),
732 ts_params->session_mpool),
734 " rte_cryptodev_queue_pair_setup: num_inflights"
735 " %u on qp %u on cryptodev %u",
736 qp_conf.nb_descriptors, qp_id,
737 ts_params->valid_devs[0]);
740 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
742 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
743 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
744 ts_params->valid_devs[0], qp_id, &qp_conf,
745 rte_cryptodev_socket_id(
746 ts_params->valid_devs[0]),
747 ts_params->session_mpool),
749 "rte_cryptodev_queue_pair_setup: num_inflights"
750 " %u on qp %u on cryptodev %u",
751 qp_conf.nb_descriptors, qp_id,
752 ts_params->valid_devs[0]);
755 /* invalid number of descriptors - max supported + 2 */
756 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
758 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
759 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
760 ts_params->valid_devs[0], qp_id, &qp_conf,
761 rte_cryptodev_socket_id(
762 ts_params->valid_devs[0]),
763 ts_params->session_mpool),
764 "Unexpectedly passed test for "
765 "rte_cryptodev_queue_pair_setup:"
766 "num_inflights %u on qp %u on cryptodev %u",
767 qp_conf.nb_descriptors, qp_id,
768 ts_params->valid_devs[0]);
771 /* invalid number of descriptors - max value of parameter */
772 qp_conf.nb_descriptors = UINT32_MAX-1;
774 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
775 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
776 ts_params->valid_devs[0], qp_id, &qp_conf,
777 rte_cryptodev_socket_id(
778 ts_params->valid_devs[0]),
779 ts_params->session_mpool),
780 "Unexpectedly passed test for "
781 "rte_cryptodev_queue_pair_setup:"
782 "num_inflights %u on qp %u on cryptodev %u",
783 qp_conf.nb_descriptors, qp_id,
784 ts_params->valid_devs[0]);
787 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
789 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
790 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
791 ts_params->valid_devs[0], qp_id, &qp_conf,
792 rte_cryptodev_socket_id(
793 ts_params->valid_devs[0]),
794 ts_params->session_mpool),
796 " rte_cryptodev_queue_pair_setup:"
797 "num_inflights %u on qp %u on cryptodev %u",
798 qp_conf.nb_descriptors, qp_id,
799 ts_params->valid_devs[0]);
802 /* invalid number of descriptors - max supported + 1 */
803 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
805 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
806 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
807 ts_params->valid_devs[0], qp_id, &qp_conf,
808 rte_cryptodev_socket_id(
809 ts_params->valid_devs[0]),
810 ts_params->session_mpool),
811 "Unexpectedly passed test for "
812 "rte_cryptodev_queue_pair_setup:"
813 "num_inflights %u on qp %u on cryptodev %u",
814 qp_conf.nb_descriptors, qp_id,
815 ts_params->valid_devs[0]);
818 /* test invalid queue pair id */
819 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
821 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
823 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
824 ts_params->valid_devs[0],
826 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
827 ts_params->session_mpool),
828 "Failed test for rte_cryptodev_queue_pair_setup:"
829 "invalid qp %u on cryptodev %u",
830 qp_id, ts_params->valid_devs[0]);
832 qp_id = 0xffff; /*invalid*/
834 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
835 ts_params->valid_devs[0],
837 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
838 ts_params->session_mpool),
839 "Failed test for rte_cryptodev_queue_pair_setup:"
840 "invalid qp %u on cryptodev %u",
841 qp_id, ts_params->valid_devs[0]);
846 /* ***** Plaintext data for tests ***** */
848 const char catch_22_quote_1[] =
849 "There was only one catch and that was Catch-22, which "
850 "specified that a concern for one's safety in the face of "
851 "dangers that were real and immediate was the process of a "
852 "rational mind. Orr was crazy and could be grounded. All he "
853 "had to do was ask; and as soon as he did, he would no longer "
854 "be crazy and would have to fly more missions. Orr would be "
855 "crazy to fly more missions and sane if he didn't, but if he "
856 "was sane he had to fly them. If he flew them he was crazy "
857 "and didn't have to; but if he didn't want to he was sane and "
858 "had to. Yossarian was moved very deeply by the absolute "
859 "simplicity of this clause of Catch-22 and let out a "
860 "respectful whistle. \"That's some catch, that Catch-22\", he "
861 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
863 const char catch_22_quote[] =
864 "What a lousy earth! He wondered how many people were "
865 "destitute that same night even in his own prosperous country, "
866 "how many homes were shanties, how many husbands were drunk "
867 "and wives socked, and how many children were bullied, abused, "
868 "or abandoned. How many families hungered for food they could "
869 "not afford to buy? How many hearts were broken? How many "
870 "suicides would take place that same night, how many people "
871 "would go insane? How many cockroaches and landlords would "
872 "triumph? How many winners were losers, successes failures, "
873 "and rich men poor men? How many wise guys were stupid? How "
874 "many happy endings were unhappy endings? How many honest men "
875 "were liars, brave men cowards, loyal men traitors, how many "
876 "sainted men were corrupt, how many people in positions of "
877 "trust had sold their souls to bodyguards, how many had never "
878 "had souls? How many straight-and-narrow paths were crooked "
879 "paths? How many best families were worst families and how "
880 "many good people were bad people? When you added them all up "
881 "and then subtracted, you might be left with only the children, "
882 "and perhaps with Albert Einstein and an old violinist or "
883 "sculptor somewhere.";
885 #define QUOTE_480_BYTES (480)
886 #define QUOTE_512_BYTES (512)
887 #define QUOTE_768_BYTES (768)
888 #define QUOTE_1024_BYTES (1024)
892 /* ***** SHA1 Hash Tests ***** */
894 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
896 static uint8_t hmac_sha1_key[] = {
897 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
898 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
899 0xDE, 0xF4, 0xDE, 0xAD };
901 /* ***** SHA224 Hash Tests ***** */
903 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
906 /* ***** AES-CBC Cipher Tests ***** */
908 #define CIPHER_KEY_LENGTH_AES_CBC (16)
909 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
911 static uint8_t aes_cbc_key[] = {
912 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
913 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
915 static uint8_t aes_cbc_iv[] = {
916 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
917 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
920 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
922 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
923 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
924 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
925 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
926 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
927 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
928 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
929 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
930 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
931 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
932 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
933 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
934 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
935 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
936 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
937 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
938 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
939 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
940 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
941 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
942 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
943 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
944 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
945 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
946 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
947 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
948 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
949 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
950 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
951 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
952 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
953 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
954 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
955 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
956 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
957 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
958 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
959 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
960 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
961 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
962 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
963 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
964 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
965 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
966 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
967 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
968 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
969 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
970 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
971 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
972 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
973 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
974 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
975 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
976 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
977 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
978 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
979 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
980 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
981 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
982 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
983 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
984 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
985 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
986 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
989 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
990 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
991 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
992 0x18, 0x8c, 0x1d, 0x32
996 /* Multisession Vector context Test */
998 static uint8_t ms_aes_cbc_key0[] = {
999 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1000 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1003 static uint8_t ms_aes_cbc_iv0[] = {
1004 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1005 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1008 static const uint8_t ms_aes_cbc_cipher0[] = {
1009 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1010 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1011 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1012 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1013 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1014 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1015 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1016 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1017 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1018 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1019 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1020 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1021 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1022 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1023 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1024 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1025 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1026 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1027 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1028 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1029 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1030 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1031 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1032 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1033 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1034 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1035 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1036 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1037 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1038 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1039 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1040 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1041 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1042 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1043 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1044 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1045 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1046 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1047 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1048 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1049 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1050 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1051 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1052 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1053 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1054 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1055 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1056 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1057 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1058 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1059 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1060 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1061 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1062 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1063 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1064 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1065 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1066 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1067 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1068 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1069 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1070 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1071 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1072 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1076 static uint8_t ms_hmac_key0[] = {
1077 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1078 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1079 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1080 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1081 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1082 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1083 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1084 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1087 static const uint8_t ms_hmac_digest0[] = {
1088 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1089 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1090 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1091 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1092 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1093 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1094 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1095 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1099 /* Begin session 1 */
1101 static uint8_t ms_aes_cbc_key1[] = {
1102 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1103 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1106 static uint8_t ms_aes_cbc_iv1[] = {
1107 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1108 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1111 static const uint8_t ms_aes_cbc_cipher1[] = {
1112 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1113 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1114 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1115 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1116 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1117 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1118 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1119 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1120 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1121 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1122 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1123 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1124 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1125 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1126 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1127 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1128 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1129 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1130 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1131 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1132 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1133 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1134 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1135 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1136 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1137 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1138 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1139 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1140 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1141 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1142 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1143 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1144 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1145 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1146 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1147 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1148 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1149 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1150 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1151 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1152 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1153 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1154 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1155 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1156 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1157 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1158 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1159 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1160 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1161 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1162 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1163 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1164 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1165 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1166 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1167 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1168 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1169 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1170 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1171 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1172 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1173 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1174 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1175 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1179 static uint8_t ms_hmac_key1[] = {
1180 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1181 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1182 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1183 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1184 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1185 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1186 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1187 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1190 static const uint8_t ms_hmac_digest1[] = {
1191 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1192 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1193 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1194 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1195 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1196 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1197 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1198 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1201 /* Begin Session 2 */
1202 static uint8_t ms_aes_cbc_key2[] = {
1203 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1204 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1207 static uint8_t ms_aes_cbc_iv2[] = {
1208 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1209 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1212 static const uint8_t ms_aes_cbc_cipher2[] = {
1213 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1214 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1215 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1216 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1217 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1218 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1219 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1220 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1221 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1222 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1223 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1224 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1225 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1226 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1227 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1228 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1229 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1230 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1231 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1232 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1233 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1234 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1235 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1236 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1237 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1238 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1239 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1240 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1241 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1242 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1243 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1244 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1245 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1246 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1247 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1248 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1249 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1250 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1251 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1252 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1253 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1254 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1255 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1256 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1257 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1258 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1259 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1260 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1261 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1262 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1263 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1264 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1265 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1266 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1267 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1268 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1269 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1270 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1271 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1272 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1273 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1274 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1275 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1276 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1279 static uint8_t ms_hmac_key2[] = {
1280 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1281 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1282 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1283 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1284 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1285 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1286 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1287 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1290 static const uint8_t ms_hmac_digest2[] = {
1291 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1292 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1293 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1294 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1295 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1296 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1297 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1298 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1305 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1307 struct crypto_testsuite_params *ts_params = &testsuite_params;
1308 struct crypto_unittest_params *ut_params = &unittest_params;
1310 /* Generate test mbuf data and space for digest */
1311 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1312 catch_22_quote, QUOTE_512_BYTES, 0);
1314 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1315 DIGEST_BYTE_LENGTH_SHA1);
1316 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1318 /* Setup Cipher Parameters */
1319 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1320 ut_params->cipher_xform.next = &ut_params->auth_xform;
1322 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1323 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1324 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1325 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1326 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1327 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1329 /* Setup HMAC Parameters */
1330 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1332 ut_params->auth_xform.next = NULL;
1334 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1335 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1336 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1337 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1338 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1340 ut_params->sess = rte_cryptodev_sym_session_create(
1341 ts_params->session_mpool);
1343 /* Create crypto session*/
1344 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1345 ut_params->sess, &ut_params->cipher_xform,
1346 ts_params->session_mpool);
1347 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1349 /* Generate crypto op data structure */
1350 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1351 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1352 TEST_ASSERT_NOT_NULL(ut_params->op,
1353 "Failed to allocate symmetric crypto operation struct");
1355 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1357 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1359 /* set crypto operation source mbuf */
1360 sym_op->m_src = ut_params->ibuf;
1362 /* Set crypto operation authentication parameters */
1363 sym_op->auth.digest.data = ut_params->digest;
1364 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1365 ut_params->ibuf, QUOTE_512_BYTES);
1367 sym_op->auth.data.offset = 0;
1368 sym_op->auth.data.length = QUOTE_512_BYTES;
1370 /* Copy IV at the end of the crypto operation */
1371 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1372 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1374 /* Set crypto operation cipher parameters */
1375 sym_op->cipher.data.offset = 0;
1376 sym_op->cipher.data.length = QUOTE_512_BYTES;
1378 /* Process crypto operation */
1379 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1380 ut_params->op), "failed to process sym crypto op");
1382 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1383 "crypto op processing failed");
1386 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1389 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1390 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1392 "ciphertext data not as expected");
1394 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1396 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1397 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1398 gbl_driver_id == rte_cryptodev_driver_id_get(
1399 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1400 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1401 DIGEST_BYTE_LENGTH_SHA1,
1402 "Generated digest data not as expected");
1404 return TEST_SUCCESS;
1407 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1409 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1411 static uint8_t hmac_sha512_key[] = {
1412 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1413 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1414 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1415 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1416 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1417 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1418 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1419 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1421 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1422 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1423 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1424 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1425 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1426 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1427 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1428 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1429 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1434 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1435 struct crypto_unittest_params *ut_params,
1436 uint8_t *cipher_key,
1440 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1441 struct crypto_unittest_params *ut_params,
1442 struct crypto_testsuite_params *ts_params,
1443 const uint8_t *cipher,
1444 const uint8_t *digest,
1449 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1450 struct crypto_unittest_params *ut_params,
1451 uint8_t *cipher_key,
1455 /* Setup Cipher Parameters */
1456 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1457 ut_params->cipher_xform.next = NULL;
1459 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1460 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1461 ut_params->cipher_xform.cipher.key.data = cipher_key;
1462 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1463 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1464 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1466 /* Setup HMAC Parameters */
1467 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1468 ut_params->auth_xform.next = &ut_params->cipher_xform;
1470 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1471 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1472 ut_params->auth_xform.auth.key.data = hmac_key;
1473 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1474 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1476 return TEST_SUCCESS;
1481 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1482 struct crypto_unittest_params *ut_params,
1483 struct crypto_testsuite_params *ts_params,
1484 const uint8_t *cipher,
1485 const uint8_t *digest,
1488 /* Generate test mbuf data and digest */
1489 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1492 QUOTE_512_BYTES, 0);
1494 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1495 DIGEST_BYTE_LENGTH_SHA512);
1496 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1498 rte_memcpy(ut_params->digest,
1500 DIGEST_BYTE_LENGTH_SHA512);
1502 /* Generate Crypto op data structure */
1503 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1504 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1505 TEST_ASSERT_NOT_NULL(ut_params->op,
1506 "Failed to allocate symmetric crypto operation struct");
1508 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1510 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1512 /* set crypto operation source mbuf */
1513 sym_op->m_src = ut_params->ibuf;
1515 sym_op->auth.digest.data = ut_params->digest;
1516 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1517 ut_params->ibuf, QUOTE_512_BYTES);
1519 sym_op->auth.data.offset = 0;
1520 sym_op->auth.data.length = QUOTE_512_BYTES;
1522 /* Copy IV at the end of the crypto operation */
1523 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1524 iv, CIPHER_IV_LENGTH_AES_CBC);
1526 sym_op->cipher.data.offset = 0;
1527 sym_op->cipher.data.length = QUOTE_512_BYTES;
1529 /* Process crypto operation */
1530 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1531 ut_params->op), "failed to process sym crypto op");
1533 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1534 "crypto op processing failed");
1536 ut_params->obuf = ut_params->op->sym->m_src;
1539 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1540 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1543 "Plaintext data not as expected");
1546 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1547 "Digest verification failed");
1549 return TEST_SUCCESS;
1553 test_AES_cipheronly_mb_all(void)
1555 struct crypto_testsuite_params *ts_params = &testsuite_params;
1558 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1559 ts_params->op_mpool,
1560 ts_params->session_mpool,
1561 ts_params->valid_devs[0],
1562 rte_cryptodev_driver_id_get(
1563 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1564 BLKCIPHER_AES_CIPHERONLY_TYPE);
1566 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1568 return TEST_SUCCESS;
1572 test_AES_docsis_mb_all(void)
1574 struct crypto_testsuite_params *ts_params = &testsuite_params;
1577 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1578 ts_params->op_mpool,
1579 ts_params->session_mpool,
1580 ts_params->valid_devs[0],
1581 rte_cryptodev_driver_id_get(
1582 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1583 BLKCIPHER_AES_DOCSIS_TYPE);
1585 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1587 return TEST_SUCCESS;
1591 test_AES_docsis_qat_all(void)
1593 struct crypto_testsuite_params *ts_params = &testsuite_params;
1596 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1597 ts_params->op_mpool,
1598 ts_params->session_mpool,
1599 ts_params->valid_devs[0],
1600 rte_cryptodev_driver_id_get(
1601 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1602 BLKCIPHER_AES_DOCSIS_TYPE);
1604 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1606 return TEST_SUCCESS;
1610 test_DES_docsis_qat_all(void)
1612 struct crypto_testsuite_params *ts_params = &testsuite_params;
1615 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1616 ts_params->op_mpool,
1617 ts_params->session_mpool,
1618 ts_params->valid_devs[0],
1619 rte_cryptodev_driver_id_get(
1620 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1621 BLKCIPHER_DES_DOCSIS_TYPE);
1623 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1625 return TEST_SUCCESS;
1629 test_authonly_mb_all(void)
1631 struct crypto_testsuite_params *ts_params = &testsuite_params;
1634 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1635 ts_params->op_mpool,
1636 ts_params->session_mpool,
1637 ts_params->valid_devs[0],
1638 rte_cryptodev_driver_id_get(
1639 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1640 BLKCIPHER_AUTHONLY_TYPE);
1642 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1644 return TEST_SUCCESS;
1648 test_authonly_qat_all(void)
1650 struct crypto_testsuite_params *ts_params = &testsuite_params;
1653 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1654 ts_params->op_mpool,
1655 ts_params->session_mpool,
1656 ts_params->valid_devs[0],
1657 rte_cryptodev_driver_id_get(
1658 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1659 BLKCIPHER_AUTHONLY_TYPE);
1661 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1663 return TEST_SUCCESS;
1666 test_AES_chain_mb_all(void)
1668 struct crypto_testsuite_params *ts_params = &testsuite_params;
1671 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1672 ts_params->op_mpool,
1673 ts_params->session_mpool,
1674 ts_params->valid_devs[0],
1675 rte_cryptodev_driver_id_get(
1676 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1677 BLKCIPHER_AES_CHAIN_TYPE);
1679 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1681 return TEST_SUCCESS;
1684 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1687 test_AES_cipheronly_scheduler_all(void)
1689 struct crypto_testsuite_params *ts_params = &testsuite_params;
1692 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1693 ts_params->op_mpool,
1694 ts_params->session_mpool,
1695 ts_params->valid_devs[0],
1696 rte_cryptodev_driver_id_get(
1697 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1698 BLKCIPHER_AES_CIPHERONLY_TYPE);
1700 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1702 return TEST_SUCCESS;
1706 test_AES_chain_scheduler_all(void)
1708 struct crypto_testsuite_params *ts_params = &testsuite_params;
1711 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1712 ts_params->op_mpool,
1713 ts_params->session_mpool,
1714 ts_params->valid_devs[0],
1715 rte_cryptodev_driver_id_get(
1716 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1717 BLKCIPHER_AES_CHAIN_TYPE);
1719 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1721 return TEST_SUCCESS;
1725 test_authonly_scheduler_all(void)
1727 struct crypto_testsuite_params *ts_params = &testsuite_params;
1730 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1731 ts_params->op_mpool,
1732 ts_params->session_mpool,
1733 ts_params->valid_devs[0],
1734 rte_cryptodev_driver_id_get(
1735 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1736 BLKCIPHER_AUTHONLY_TYPE);
1738 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1740 return TEST_SUCCESS;
1743 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1746 test_AES_chain_openssl_all(void)
1748 struct crypto_testsuite_params *ts_params = &testsuite_params;
1751 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1752 ts_params->op_mpool,
1753 ts_params->session_mpool,
1754 ts_params->valid_devs[0],
1755 rte_cryptodev_driver_id_get(
1756 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1757 BLKCIPHER_AES_CHAIN_TYPE);
1759 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1761 return TEST_SUCCESS;
1765 test_AES_cipheronly_openssl_all(void)
1767 struct crypto_testsuite_params *ts_params = &testsuite_params;
1770 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1771 ts_params->op_mpool,
1772 ts_params->session_mpool,
1773 ts_params->valid_devs[0],
1774 rte_cryptodev_driver_id_get(
1775 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1776 BLKCIPHER_AES_CIPHERONLY_TYPE);
1778 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1780 return TEST_SUCCESS;
1784 test_AES_chain_ccp_all(void)
1786 struct crypto_testsuite_params *ts_params = &testsuite_params;
1789 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1790 ts_params->op_mpool,
1791 ts_params->session_mpool,
1792 ts_params->valid_devs[0],
1793 rte_cryptodev_driver_id_get(
1794 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1795 BLKCIPHER_AES_CHAIN_TYPE);
1797 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1799 return TEST_SUCCESS;
1803 test_AES_cipheronly_ccp_all(void)
1805 struct crypto_testsuite_params *ts_params = &testsuite_params;
1808 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1809 ts_params->op_mpool,
1810 ts_params->session_mpool,
1811 ts_params->valid_devs[0],
1812 rte_cryptodev_driver_id_get(
1813 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1814 BLKCIPHER_AES_CIPHERONLY_TYPE);
1816 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1818 return TEST_SUCCESS;
1822 test_AES_chain_qat_all(void)
1824 struct crypto_testsuite_params *ts_params = &testsuite_params;
1827 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1828 ts_params->op_mpool,
1829 ts_params->session_mpool,
1830 ts_params->valid_devs[0],
1831 rte_cryptodev_driver_id_get(
1832 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1833 BLKCIPHER_AES_CHAIN_TYPE);
1835 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1837 return TEST_SUCCESS;
1841 test_AES_cipheronly_qat_all(void)
1843 struct crypto_testsuite_params *ts_params = &testsuite_params;
1846 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1847 ts_params->op_mpool,
1848 ts_params->session_mpool,
1849 ts_params->valid_devs[0],
1850 rte_cryptodev_driver_id_get(
1851 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1852 BLKCIPHER_AES_CIPHERONLY_TYPE);
1854 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1856 return TEST_SUCCESS;
1860 test_AES_cipheronly_virtio_all(void)
1862 struct crypto_testsuite_params *ts_params = &testsuite_params;
1865 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1866 ts_params->op_mpool,
1867 ts_params->session_mpool,
1868 ts_params->valid_devs[0],
1869 rte_cryptodev_driver_id_get(
1870 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1871 BLKCIPHER_AES_CIPHERONLY_TYPE);
1873 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1875 return TEST_SUCCESS;
1879 test_AES_chain_dpaa_sec_all(void)
1881 struct crypto_testsuite_params *ts_params = &testsuite_params;
1884 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1885 ts_params->op_mpool,
1886 ts_params->session_mpool,
1887 ts_params->valid_devs[0],
1888 rte_cryptodev_driver_id_get(
1889 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1890 BLKCIPHER_AES_CHAIN_TYPE);
1892 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1894 return TEST_SUCCESS;
1898 test_AES_cipheronly_dpaa_sec_all(void)
1900 struct crypto_testsuite_params *ts_params = &testsuite_params;
1903 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1904 ts_params->op_mpool,
1905 ts_params->session_mpool,
1906 ts_params->valid_devs[0],
1907 rte_cryptodev_driver_id_get(
1908 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1909 BLKCIPHER_AES_CIPHERONLY_TYPE);
1911 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1913 return TEST_SUCCESS;
1917 test_authonly_dpaa_sec_all(void)
1919 struct crypto_testsuite_params *ts_params = &testsuite_params;
1922 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1923 ts_params->op_mpool,
1924 ts_params->session_mpool,
1925 ts_params->valid_devs[0],
1926 rte_cryptodev_driver_id_get(
1927 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1928 BLKCIPHER_AUTHONLY_TYPE);
1930 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1932 return TEST_SUCCESS;
1936 test_AES_chain_dpaa2_sec_all(void)
1938 struct crypto_testsuite_params *ts_params = &testsuite_params;
1941 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1942 ts_params->op_mpool,
1943 ts_params->session_mpool,
1944 ts_params->valid_devs[0],
1945 rte_cryptodev_driver_id_get(
1946 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1947 BLKCIPHER_AES_CHAIN_TYPE);
1949 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1951 return TEST_SUCCESS;
1955 test_AES_cipheronly_dpaa2_sec_all(void)
1957 struct crypto_testsuite_params *ts_params = &testsuite_params;
1960 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1961 ts_params->op_mpool,
1962 ts_params->session_mpool,
1963 ts_params->valid_devs[0],
1964 rte_cryptodev_driver_id_get(
1965 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1966 BLKCIPHER_AES_CIPHERONLY_TYPE);
1968 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1970 return TEST_SUCCESS;
1974 test_authonly_dpaa2_sec_all(void)
1976 struct crypto_testsuite_params *ts_params = &testsuite_params;
1979 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1980 ts_params->op_mpool,
1981 ts_params->session_mpool,
1982 ts_params->valid_devs[0],
1983 rte_cryptodev_driver_id_get(
1984 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1985 BLKCIPHER_AUTHONLY_TYPE);
1987 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1989 return TEST_SUCCESS;
1993 test_authonly_openssl_all(void)
1995 struct crypto_testsuite_params *ts_params = &testsuite_params;
1998 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1999 ts_params->op_mpool,
2000 ts_params->session_mpool,
2001 ts_params->valid_devs[0],
2002 rte_cryptodev_driver_id_get(
2003 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2004 BLKCIPHER_AUTHONLY_TYPE);
2006 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2008 return TEST_SUCCESS;
2012 test_authonly_ccp_all(void)
2014 struct crypto_testsuite_params *ts_params = &testsuite_params;
2017 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2018 ts_params->op_mpool,
2019 ts_params->session_mpool,
2020 ts_params->valid_devs[0],
2021 rte_cryptodev_driver_id_get(
2022 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2023 BLKCIPHER_AUTHONLY_TYPE);
2025 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2027 return TEST_SUCCESS;
2031 test_AES_chain_armv8_all(void)
2033 struct crypto_testsuite_params *ts_params = &testsuite_params;
2036 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2037 ts_params->op_mpool,
2038 ts_params->session_mpool,
2039 ts_params->valid_devs[0],
2040 rte_cryptodev_driver_id_get(
2041 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2042 BLKCIPHER_AES_CHAIN_TYPE);
2044 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2046 return TEST_SUCCESS;
2050 test_AES_chain_mrvl_all(void)
2052 struct crypto_testsuite_params *ts_params = &testsuite_params;
2055 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2056 ts_params->op_mpool,
2057 ts_params->session_mpool,
2058 ts_params->valid_devs[0],
2059 rte_cryptodev_driver_id_get(
2060 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2061 BLKCIPHER_AES_CHAIN_TYPE);
2063 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2065 return TEST_SUCCESS;
2069 test_AES_cipheronly_mrvl_all(void)
2071 struct crypto_testsuite_params *ts_params = &testsuite_params;
2074 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2075 ts_params->op_mpool,
2076 ts_params->session_mpool,
2077 ts_params->valid_devs[0],
2078 rte_cryptodev_driver_id_get(
2079 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2080 BLKCIPHER_AES_CIPHERONLY_TYPE);
2082 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2084 return TEST_SUCCESS;
2088 test_authonly_mrvl_all(void)
2090 struct crypto_testsuite_params *ts_params = &testsuite_params;
2093 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2094 ts_params->op_mpool,
2095 ts_params->session_mpool,
2096 ts_params->valid_devs[0],
2097 rte_cryptodev_driver_id_get(
2098 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2099 BLKCIPHER_AUTHONLY_TYPE);
2101 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2103 return TEST_SUCCESS;
2107 test_3DES_chain_mrvl_all(void)
2109 struct crypto_testsuite_params *ts_params = &testsuite_params;
2112 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2113 ts_params->op_mpool,
2114 ts_params->session_mpool,
2115 ts_params->valid_devs[0],
2116 rte_cryptodev_driver_id_get(
2117 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2118 BLKCIPHER_3DES_CHAIN_TYPE);
2120 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2122 return TEST_SUCCESS;
2126 test_3DES_cipheronly_mrvl_all(void)
2128 struct crypto_testsuite_params *ts_params = &testsuite_params;
2131 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2132 ts_params->op_mpool,
2133 ts_params->session_mpool,
2134 ts_params->valid_devs[0],
2135 rte_cryptodev_driver_id_get(
2136 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2137 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2139 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2141 return TEST_SUCCESS;
2144 /* ***** SNOW 3G Tests ***** */
2146 create_wireless_algo_hash_session(uint8_t dev_id,
2147 const uint8_t *key, const uint8_t key_len,
2148 const uint8_t iv_len, const uint8_t auth_len,
2149 enum rte_crypto_auth_operation op,
2150 enum rte_crypto_auth_algorithm algo)
2152 uint8_t hash_key[key_len];
2154 struct crypto_testsuite_params *ts_params = &testsuite_params;
2155 struct crypto_unittest_params *ut_params = &unittest_params;
2157 memcpy(hash_key, key, key_len);
2159 debug_hexdump(stdout, "key:", key, key_len);
2161 /* Setup Authentication Parameters */
2162 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2163 ut_params->auth_xform.next = NULL;
2165 ut_params->auth_xform.auth.op = op;
2166 ut_params->auth_xform.auth.algo = algo;
2167 ut_params->auth_xform.auth.key.length = key_len;
2168 ut_params->auth_xform.auth.key.data = hash_key;
2169 ut_params->auth_xform.auth.digest_length = auth_len;
2170 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2171 ut_params->auth_xform.auth.iv.length = iv_len;
2172 ut_params->sess = rte_cryptodev_sym_session_create(
2173 ts_params->session_mpool);
2175 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2176 &ut_params->auth_xform, ts_params->session_mpool);
2177 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2182 create_wireless_algo_cipher_session(uint8_t dev_id,
2183 enum rte_crypto_cipher_operation op,
2184 enum rte_crypto_cipher_algorithm algo,
2185 const uint8_t *key, const uint8_t key_len,
2188 uint8_t cipher_key[key_len];
2190 struct crypto_testsuite_params *ts_params = &testsuite_params;
2191 struct crypto_unittest_params *ut_params = &unittest_params;
2193 memcpy(cipher_key, key, key_len);
2195 /* Setup Cipher Parameters */
2196 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2197 ut_params->cipher_xform.next = NULL;
2199 ut_params->cipher_xform.cipher.algo = algo;
2200 ut_params->cipher_xform.cipher.op = op;
2201 ut_params->cipher_xform.cipher.key.data = cipher_key;
2202 ut_params->cipher_xform.cipher.key.length = key_len;
2203 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2204 ut_params->cipher_xform.cipher.iv.length = iv_len;
2206 debug_hexdump(stdout, "key:", key, key_len);
2208 /* Create Crypto session */
2209 ut_params->sess = rte_cryptodev_sym_session_create(
2210 ts_params->session_mpool);
2212 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2213 &ut_params->cipher_xform, ts_params->session_mpool);
2214 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2219 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2220 unsigned int cipher_len,
2221 unsigned int cipher_offset)
2223 struct crypto_testsuite_params *ts_params = &testsuite_params;
2224 struct crypto_unittest_params *ut_params = &unittest_params;
2226 /* Generate Crypto op data structure */
2227 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2228 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2229 TEST_ASSERT_NOT_NULL(ut_params->op,
2230 "Failed to allocate pktmbuf offload");
2232 /* Set crypto operation data parameters */
2233 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2235 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2237 /* set crypto operation source mbuf */
2238 sym_op->m_src = ut_params->ibuf;
2241 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2243 sym_op->cipher.data.length = cipher_len;
2244 sym_op->cipher.data.offset = cipher_offset;
2249 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2250 unsigned int cipher_len,
2251 unsigned int cipher_offset)
2253 struct crypto_testsuite_params *ts_params = &testsuite_params;
2254 struct crypto_unittest_params *ut_params = &unittest_params;
2256 /* Generate Crypto op data structure */
2257 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2258 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2259 TEST_ASSERT_NOT_NULL(ut_params->op,
2260 "Failed to allocate pktmbuf offload");
2262 /* Set crypto operation data parameters */
2263 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2265 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2267 /* set crypto operation source mbuf */
2268 sym_op->m_src = ut_params->ibuf;
2269 sym_op->m_dst = ut_params->obuf;
2272 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2274 sym_op->cipher.data.length = cipher_len;
2275 sym_op->cipher.data.offset = cipher_offset;
2280 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2281 enum rte_crypto_cipher_operation cipher_op,
2282 enum rte_crypto_auth_operation auth_op,
2283 enum rte_crypto_auth_algorithm auth_algo,
2284 enum rte_crypto_cipher_algorithm cipher_algo,
2285 const uint8_t *key, uint8_t key_len,
2286 uint8_t auth_iv_len, uint8_t auth_len,
2287 uint8_t cipher_iv_len)
2290 uint8_t cipher_auth_key[key_len];
2292 struct crypto_testsuite_params *ts_params = &testsuite_params;
2293 struct crypto_unittest_params *ut_params = &unittest_params;
2295 memcpy(cipher_auth_key, key, key_len);
2297 /* Setup Authentication Parameters */
2298 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2299 ut_params->auth_xform.next = NULL;
2301 ut_params->auth_xform.auth.op = auth_op;
2302 ut_params->auth_xform.auth.algo = auth_algo;
2303 ut_params->auth_xform.auth.key.length = key_len;
2304 /* Hash key = cipher key */
2305 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2306 ut_params->auth_xform.auth.digest_length = auth_len;
2307 /* Auth IV will be after cipher IV */
2308 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2309 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2311 /* Setup Cipher Parameters */
2312 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2313 ut_params->cipher_xform.next = &ut_params->auth_xform;
2315 ut_params->cipher_xform.cipher.algo = cipher_algo;
2316 ut_params->cipher_xform.cipher.op = cipher_op;
2317 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2318 ut_params->cipher_xform.cipher.key.length = key_len;
2319 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2320 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2322 debug_hexdump(stdout, "key:", key, key_len);
2324 /* Create Crypto session*/
2325 ut_params->sess = rte_cryptodev_sym_session_create(
2326 ts_params->session_mpool);
2328 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2329 &ut_params->cipher_xform, ts_params->session_mpool);
2331 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2336 create_wireless_cipher_auth_session(uint8_t dev_id,
2337 enum rte_crypto_cipher_operation cipher_op,
2338 enum rte_crypto_auth_operation auth_op,
2339 enum rte_crypto_auth_algorithm auth_algo,
2340 enum rte_crypto_cipher_algorithm cipher_algo,
2341 const struct wireless_test_data *tdata)
2343 const uint8_t key_len = tdata->key.len;
2344 uint8_t cipher_auth_key[key_len];
2346 struct crypto_testsuite_params *ts_params = &testsuite_params;
2347 struct crypto_unittest_params *ut_params = &unittest_params;
2348 const uint8_t *key = tdata->key.data;
2349 const uint8_t auth_len = tdata->digest.len;
2350 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2351 uint8_t auth_iv_len = tdata->auth_iv.len;
2353 memcpy(cipher_auth_key, key, key_len);
2355 /* Setup Authentication Parameters */
2356 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2357 ut_params->auth_xform.next = NULL;
2359 ut_params->auth_xform.auth.op = auth_op;
2360 ut_params->auth_xform.auth.algo = auth_algo;
2361 ut_params->auth_xform.auth.key.length = key_len;
2362 /* Hash key = cipher key */
2363 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2364 ut_params->auth_xform.auth.digest_length = auth_len;
2365 /* Auth IV will be after cipher IV */
2366 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2367 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2369 /* Setup Cipher Parameters */
2370 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2371 ut_params->cipher_xform.next = &ut_params->auth_xform;
2373 ut_params->cipher_xform.cipher.algo = cipher_algo;
2374 ut_params->cipher_xform.cipher.op = cipher_op;
2375 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2376 ut_params->cipher_xform.cipher.key.length = key_len;
2377 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2378 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2381 debug_hexdump(stdout, "key:", key, key_len);
2383 /* Create Crypto session*/
2384 ut_params->sess = rte_cryptodev_sym_session_create(
2385 ts_params->session_mpool);
2387 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2388 &ut_params->cipher_xform, ts_params->session_mpool);
2390 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2395 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2396 const struct wireless_test_data *tdata)
2398 return create_wireless_cipher_auth_session(dev_id,
2399 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2400 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2401 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2405 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2406 enum rte_crypto_cipher_operation cipher_op,
2407 enum rte_crypto_auth_operation auth_op,
2408 enum rte_crypto_auth_algorithm auth_algo,
2409 enum rte_crypto_cipher_algorithm cipher_algo,
2410 const uint8_t *key, const uint8_t key_len,
2411 uint8_t auth_iv_len, uint8_t auth_len,
2412 uint8_t cipher_iv_len)
2414 uint8_t auth_cipher_key[key_len];
2416 struct crypto_testsuite_params *ts_params = &testsuite_params;
2417 struct crypto_unittest_params *ut_params = &unittest_params;
2419 memcpy(auth_cipher_key, key, key_len);
2421 /* Setup Authentication Parameters */
2422 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2423 ut_params->auth_xform.auth.op = auth_op;
2424 ut_params->auth_xform.next = &ut_params->cipher_xform;
2425 ut_params->auth_xform.auth.algo = auth_algo;
2426 ut_params->auth_xform.auth.key.length = key_len;
2427 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2428 ut_params->auth_xform.auth.digest_length = auth_len;
2429 /* Auth IV will be after cipher IV */
2430 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2431 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2433 /* Setup Cipher Parameters */
2434 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2435 ut_params->cipher_xform.next = NULL;
2436 ut_params->cipher_xform.cipher.algo = cipher_algo;
2437 ut_params->cipher_xform.cipher.op = cipher_op;
2438 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2439 ut_params->cipher_xform.cipher.key.length = key_len;
2440 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2441 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2443 debug_hexdump(stdout, "key:", key, key_len);
2445 /* Create Crypto session*/
2446 ut_params->sess = rte_cryptodev_sym_session_create(
2447 ts_params->session_mpool);
2449 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2450 &ut_params->auth_xform, ts_params->session_mpool);
2452 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2458 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2459 unsigned int auth_tag_len,
2460 const uint8_t *iv, unsigned int iv_len,
2461 unsigned int data_pad_len,
2462 enum rte_crypto_auth_operation op,
2463 unsigned int auth_len, unsigned int auth_offset)
2465 struct crypto_testsuite_params *ts_params = &testsuite_params;
2467 struct crypto_unittest_params *ut_params = &unittest_params;
2469 /* Generate Crypto op data structure */
2470 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2471 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2472 TEST_ASSERT_NOT_NULL(ut_params->op,
2473 "Failed to allocate pktmbuf offload");
2475 /* Set crypto operation data parameters */
2476 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2478 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2480 /* set crypto operation source mbuf */
2481 sym_op->m_src = ut_params->ibuf;
2484 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2487 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2488 ut_params->ibuf, auth_tag_len);
2490 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2491 "no room to append auth tag");
2492 ut_params->digest = sym_op->auth.digest.data;
2493 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2494 ut_params->ibuf, data_pad_len);
2495 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2496 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2498 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2500 debug_hexdump(stdout, "digest:",
2501 sym_op->auth.digest.data,
2504 sym_op->auth.data.length = auth_len;
2505 sym_op->auth.data.offset = auth_offset;
2511 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2512 enum rte_crypto_auth_operation op)
2514 struct crypto_testsuite_params *ts_params = &testsuite_params;
2515 struct crypto_unittest_params *ut_params = &unittest_params;
2517 const uint8_t *auth_tag = tdata->digest.data;
2518 const unsigned int auth_tag_len = tdata->digest.len;
2519 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2520 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2522 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2523 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2524 const uint8_t *auth_iv = tdata->auth_iv.data;
2525 const uint8_t auth_iv_len = tdata->auth_iv.len;
2526 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2527 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2529 /* Generate Crypto op data structure */
2530 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2531 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2532 TEST_ASSERT_NOT_NULL(ut_params->op,
2533 "Failed to allocate pktmbuf offload");
2534 /* Set crypto operation data parameters */
2535 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2537 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2539 /* set crypto operation source mbuf */
2540 sym_op->m_src = ut_params->ibuf;
2543 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2544 ut_params->ibuf, auth_tag_len);
2546 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2547 "no room to append auth tag");
2548 ut_params->digest = sym_op->auth.digest.data;
2549 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2550 ut_params->ibuf, data_pad_len);
2551 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2552 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2554 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2556 debug_hexdump(stdout, "digest:",
2557 sym_op->auth.digest.data,
2560 /* Copy cipher and auth IVs at the end of the crypto operation */
2561 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2563 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2564 iv_ptr += cipher_iv_len;
2565 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2567 sym_op->cipher.data.length = cipher_len;
2568 sym_op->cipher.data.offset = 0;
2569 sym_op->auth.data.length = auth_len;
2570 sym_op->auth.data.offset = 0;
2576 create_zuc_cipher_hash_generate_operation(
2577 const struct wireless_test_data *tdata)
2579 return create_wireless_cipher_hash_operation(tdata,
2580 RTE_CRYPTO_AUTH_OP_GENERATE);
2584 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2585 const unsigned auth_tag_len,
2586 const uint8_t *auth_iv, uint8_t auth_iv_len,
2587 unsigned data_pad_len,
2588 enum rte_crypto_auth_operation op,
2589 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2590 const unsigned cipher_len, const unsigned cipher_offset,
2591 const unsigned auth_len, const unsigned auth_offset)
2593 struct crypto_testsuite_params *ts_params = &testsuite_params;
2594 struct crypto_unittest_params *ut_params = &unittest_params;
2596 /* Generate Crypto op data structure */
2597 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2598 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2599 TEST_ASSERT_NOT_NULL(ut_params->op,
2600 "Failed to allocate pktmbuf offload");
2601 /* Set crypto operation data parameters */
2602 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2604 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2606 /* set crypto operation source mbuf */
2607 sym_op->m_src = ut_params->ibuf;
2610 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2611 ut_params->ibuf, auth_tag_len);
2613 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2614 "no room to append auth tag");
2615 ut_params->digest = sym_op->auth.digest.data;
2616 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2617 ut_params->ibuf, data_pad_len);
2618 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2619 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2621 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2623 debug_hexdump(stdout, "digest:",
2624 sym_op->auth.digest.data,
2627 /* Copy cipher and auth IVs at the end of the crypto operation */
2628 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2630 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2631 iv_ptr += cipher_iv_len;
2632 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2634 sym_op->cipher.data.length = cipher_len;
2635 sym_op->cipher.data.offset = cipher_offset;
2636 sym_op->auth.data.length = auth_len;
2637 sym_op->auth.data.offset = auth_offset;
2643 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2644 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2645 const uint8_t *auth_iv, uint8_t auth_iv_len,
2646 unsigned int data_pad_len,
2647 unsigned int cipher_len, unsigned int cipher_offset,
2648 unsigned int auth_len, unsigned int auth_offset)
2650 struct crypto_testsuite_params *ts_params = &testsuite_params;
2651 struct crypto_unittest_params *ut_params = &unittest_params;
2653 /* Generate Crypto op data structure */
2654 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2655 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2656 TEST_ASSERT_NOT_NULL(ut_params->op,
2657 "Failed to allocate pktmbuf offload");
2659 /* Set crypto operation data parameters */
2660 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2662 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2664 /* set crypto operation source mbuf */
2665 sym_op->m_src = ut_params->ibuf;
2668 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2669 ut_params->ibuf, auth_tag_len);
2671 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2672 "no room to append auth tag");
2674 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2675 ut_params->ibuf, data_pad_len);
2677 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2679 debug_hexdump(stdout, "digest:",
2680 sym_op->auth.digest.data,
2683 /* Copy cipher and auth IVs at the end of the crypto operation */
2684 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2686 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2687 iv_ptr += cipher_iv_len;
2688 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2690 sym_op->cipher.data.length = cipher_len;
2691 sym_op->cipher.data.offset = cipher_offset;
2693 sym_op->auth.data.length = auth_len;
2694 sym_op->auth.data.offset = auth_offset;
2700 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2702 struct crypto_testsuite_params *ts_params = &testsuite_params;
2703 struct crypto_unittest_params *ut_params = &unittest_params;
2706 unsigned plaintext_pad_len;
2707 unsigned plaintext_len;
2710 /* Create SNOW 3G session */
2711 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2712 tdata->key.data, tdata->key.len,
2713 tdata->auth_iv.len, tdata->digest.len,
2714 RTE_CRYPTO_AUTH_OP_GENERATE,
2715 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2719 /* alloc mbuf and set payload */
2720 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2722 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2723 rte_pktmbuf_tailroom(ut_params->ibuf));
2725 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2726 /* Append data which is padded to a multiple of */
2727 /* the algorithms block size */
2728 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2729 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2731 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2733 /* Create SNOW 3G operation */
2734 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2735 tdata->auth_iv.data, tdata->auth_iv.len,
2736 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2737 tdata->validAuthLenInBits.len,
2742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2744 ut_params->obuf = ut_params->op->sym->m_src;
2745 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2746 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2747 + plaintext_pad_len;
2750 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2753 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2754 "SNOW 3G Generated auth tag not as expected");
2760 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2762 struct crypto_testsuite_params *ts_params = &testsuite_params;
2763 struct crypto_unittest_params *ut_params = &unittest_params;
2766 unsigned plaintext_pad_len;
2767 unsigned plaintext_len;
2770 /* Create SNOW 3G session */
2771 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2772 tdata->key.data, tdata->key.len,
2773 tdata->auth_iv.len, tdata->digest.len,
2774 RTE_CRYPTO_AUTH_OP_VERIFY,
2775 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2778 /* alloc mbuf and set payload */
2779 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2781 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2782 rte_pktmbuf_tailroom(ut_params->ibuf));
2784 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2785 /* Append data which is padded to a multiple of */
2786 /* the algorithms block size */
2787 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2788 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2790 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2792 /* Create SNOW 3G operation */
2793 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2795 tdata->auth_iv.data, tdata->auth_iv.len,
2797 RTE_CRYPTO_AUTH_OP_VERIFY,
2798 tdata->validAuthLenInBits.len,
2803 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2805 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2806 ut_params->obuf = ut_params->op->sym->m_src;
2807 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2808 + plaintext_pad_len;
2811 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2820 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2822 struct crypto_testsuite_params *ts_params = &testsuite_params;
2823 struct crypto_unittest_params *ut_params = &unittest_params;
2826 unsigned plaintext_pad_len;
2827 unsigned plaintext_len;
2830 /* Create KASUMI session */
2831 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2832 tdata->key.data, tdata->key.len,
2833 0, tdata->digest.len,
2834 RTE_CRYPTO_AUTH_OP_GENERATE,
2835 RTE_CRYPTO_AUTH_KASUMI_F9);
2839 /* alloc mbuf and set payload */
2840 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2842 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2843 rte_pktmbuf_tailroom(ut_params->ibuf));
2845 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2846 /* Append data which is padded to a multiple of */
2847 /* the algorithms block size */
2848 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2849 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2851 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2853 /* Create KASUMI operation */
2854 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2856 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2857 tdata->plaintext.len,
2862 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2864 ut_params->obuf = ut_params->op->sym->m_src;
2865 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2866 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2867 + plaintext_pad_len;
2870 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2873 DIGEST_BYTE_LENGTH_KASUMI_F9,
2874 "KASUMI Generated auth tag not as expected");
2880 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2882 struct crypto_testsuite_params *ts_params = &testsuite_params;
2883 struct crypto_unittest_params *ut_params = &unittest_params;
2886 unsigned plaintext_pad_len;
2887 unsigned plaintext_len;
2890 /* Create KASUMI session */
2891 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2892 tdata->key.data, tdata->key.len,
2893 0, tdata->digest.len,
2894 RTE_CRYPTO_AUTH_OP_VERIFY,
2895 RTE_CRYPTO_AUTH_KASUMI_F9);
2898 /* alloc mbuf and set payload */
2899 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2901 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2902 rte_pktmbuf_tailroom(ut_params->ibuf));
2904 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2905 /* Append data which is padded to a multiple */
2906 /* of the algorithms block size */
2907 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2908 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2910 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2912 /* Create KASUMI operation */
2913 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2917 RTE_CRYPTO_AUTH_OP_VERIFY,
2918 tdata->plaintext.len,
2923 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2925 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2926 ut_params->obuf = ut_params->op->sym->m_src;
2927 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2928 + plaintext_pad_len;
2931 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2940 test_snow3g_hash_generate_test_case_1(void)
2942 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2946 test_snow3g_hash_generate_test_case_2(void)
2948 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2952 test_snow3g_hash_generate_test_case_3(void)
2954 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2958 test_snow3g_hash_generate_test_case_4(void)
2960 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2964 test_snow3g_hash_generate_test_case_5(void)
2966 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2970 test_snow3g_hash_generate_test_case_6(void)
2972 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2976 test_snow3g_hash_verify_test_case_1(void)
2978 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2983 test_snow3g_hash_verify_test_case_2(void)
2985 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2989 test_snow3g_hash_verify_test_case_3(void)
2991 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2995 test_snow3g_hash_verify_test_case_4(void)
2997 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3001 test_snow3g_hash_verify_test_case_5(void)
3003 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3007 test_snow3g_hash_verify_test_case_6(void)
3009 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3013 test_kasumi_hash_generate_test_case_1(void)
3015 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3019 test_kasumi_hash_generate_test_case_2(void)
3021 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3025 test_kasumi_hash_generate_test_case_3(void)
3027 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3031 test_kasumi_hash_generate_test_case_4(void)
3033 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3037 test_kasumi_hash_generate_test_case_5(void)
3039 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3043 test_kasumi_hash_generate_test_case_6(void)
3045 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3049 test_kasumi_hash_verify_test_case_1(void)
3051 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3055 test_kasumi_hash_verify_test_case_2(void)
3057 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3061 test_kasumi_hash_verify_test_case_3(void)
3063 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3067 test_kasumi_hash_verify_test_case_4(void)
3069 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3073 test_kasumi_hash_verify_test_case_5(void)
3075 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3079 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3081 struct crypto_testsuite_params *ts_params = &testsuite_params;
3082 struct crypto_unittest_params *ut_params = &unittest_params;
3085 uint8_t *plaintext, *ciphertext;
3086 unsigned plaintext_pad_len;
3087 unsigned plaintext_len;
3089 /* Create KASUMI session */
3090 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3091 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3092 RTE_CRYPTO_CIPHER_KASUMI_F8,
3093 tdata->key.data, tdata->key.len,
3094 tdata->cipher_iv.len);
3098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3100 /* Clear mbuf payload */
3101 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3102 rte_pktmbuf_tailroom(ut_params->ibuf));
3104 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3105 /* Append data which is padded to a multiple */
3106 /* of the algorithms block size */
3107 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3108 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3110 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3112 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3114 /* Create KASUMI operation */
3115 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3116 tdata->cipher_iv.len,
3117 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3118 tdata->validCipherOffsetInBits.len);
3122 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3124 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3126 ut_params->obuf = ut_params->op->sym->m_dst;
3127 if (ut_params->obuf)
3128 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3130 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3132 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3134 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3135 (tdata->validCipherOffsetInBits.len >> 3);
3137 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3139 reference_ciphertext,
3140 tdata->validCipherLenInBits.len,
3141 "KASUMI Ciphertext data not as expected");
3146 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3148 struct crypto_testsuite_params *ts_params = &testsuite_params;
3149 struct crypto_unittest_params *ut_params = &unittest_params;
3153 unsigned int plaintext_pad_len;
3154 unsigned int plaintext_len;
3156 uint8_t buffer[10000];
3157 const uint8_t *ciphertext;
3159 struct rte_cryptodev_info dev_info;
3161 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3162 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3163 printf("Device doesn't support scatter-gather. "
3168 /* Create KASUMI session */
3169 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3170 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3171 RTE_CRYPTO_CIPHER_KASUMI_F8,
3172 tdata->key.data, tdata->key.len,
3173 tdata->cipher_iv.len);
3177 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3180 /* Append data which is padded to a multiple */
3181 /* of the algorithms block size */
3182 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3184 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3185 plaintext_pad_len, 10, 0);
3187 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3189 /* Create KASUMI operation */
3190 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3191 tdata->cipher_iv.len,
3192 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3193 tdata->validCipherOffsetInBits.len);
3197 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3199 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3201 ut_params->obuf = ut_params->op->sym->m_dst;
3203 if (ut_params->obuf)
3204 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3205 plaintext_len, buffer);
3207 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3208 tdata->validCipherOffsetInBits.len >> 3,
3209 plaintext_len, buffer);
3212 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3214 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3215 (tdata->validCipherOffsetInBits.len >> 3);
3217 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3219 reference_ciphertext,
3220 tdata->validCipherLenInBits.len,
3221 "KASUMI Ciphertext data not as expected");
3226 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3228 struct crypto_testsuite_params *ts_params = &testsuite_params;
3229 struct crypto_unittest_params *ut_params = &unittest_params;
3232 uint8_t *plaintext, *ciphertext;
3233 unsigned plaintext_pad_len;
3234 unsigned plaintext_len;
3236 /* Create KASUMI session */
3237 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3238 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3239 RTE_CRYPTO_CIPHER_KASUMI_F8,
3240 tdata->key.data, tdata->key.len,
3241 tdata->cipher_iv.len);
3245 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3246 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3248 /* Clear mbuf payload */
3249 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3250 rte_pktmbuf_tailroom(ut_params->ibuf));
3252 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3253 /* Append data which is padded to a multiple */
3254 /* of the algorithms block size */
3255 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3256 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3258 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3259 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3261 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3263 /* Create KASUMI operation */
3264 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3265 tdata->cipher_iv.len,
3266 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3267 tdata->validCipherOffsetInBits.len);
3271 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3273 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3275 ut_params->obuf = ut_params->op->sym->m_dst;
3276 if (ut_params->obuf)
3277 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3279 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3281 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3283 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3284 (tdata->validCipherOffsetInBits.len >> 3);
3286 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3288 reference_ciphertext,
3289 tdata->validCipherLenInBits.len,
3290 "KASUMI Ciphertext data not as expected");
3295 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3297 struct crypto_testsuite_params *ts_params = &testsuite_params;
3298 struct crypto_unittest_params *ut_params = &unittest_params;
3301 unsigned int plaintext_pad_len;
3302 unsigned int plaintext_len;
3304 const uint8_t *ciphertext;
3305 uint8_t buffer[2048];
3307 struct rte_cryptodev_info dev_info;
3309 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3310 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3311 printf("Device doesn't support scatter-gather. "
3316 /* Create KASUMI session */
3317 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3318 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3319 RTE_CRYPTO_CIPHER_KASUMI_F8,
3320 tdata->key.data, tdata->key.len,
3321 tdata->cipher_iv.len);
3325 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3326 /* Append data which is padded to a multiple */
3327 /* of the algorithms block size */
3328 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3330 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3331 plaintext_pad_len, 10, 0);
3332 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3333 plaintext_pad_len, 3, 0);
3335 /* Append data which is padded to a multiple */
3336 /* of the algorithms block size */
3337 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3339 /* Create KASUMI operation */
3340 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3341 tdata->cipher_iv.len,
3342 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3343 tdata->validCipherOffsetInBits.len);
3347 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3349 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3351 ut_params->obuf = ut_params->op->sym->m_dst;
3352 if (ut_params->obuf)
3353 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3354 plaintext_pad_len, buffer);
3356 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3357 tdata->validCipherOffsetInBits.len >> 3,
3358 plaintext_pad_len, buffer);
3360 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3361 (tdata->validCipherOffsetInBits.len >> 3);
3363 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3365 reference_ciphertext,
3366 tdata->validCipherLenInBits.len,
3367 "KASUMI Ciphertext data not as expected");
3373 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3375 struct crypto_testsuite_params *ts_params = &testsuite_params;
3376 struct crypto_unittest_params *ut_params = &unittest_params;
3379 uint8_t *ciphertext, *plaintext;
3380 unsigned ciphertext_pad_len;
3381 unsigned ciphertext_len;
3383 /* Create KASUMI session */
3384 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3385 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3386 RTE_CRYPTO_CIPHER_KASUMI_F8,
3387 tdata->key.data, tdata->key.len,
3388 tdata->cipher_iv.len);
3392 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3393 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3395 /* Clear mbuf payload */
3396 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3397 rte_pktmbuf_tailroom(ut_params->ibuf));
3399 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3400 /* Append data which is padded to a multiple */
3401 /* of the algorithms block size */
3402 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3403 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3404 ciphertext_pad_len);
3405 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3406 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3408 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3410 /* Create KASUMI operation */
3411 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3412 tdata->cipher_iv.len,
3413 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3414 tdata->validCipherOffsetInBits.len);
3418 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3420 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3422 ut_params->obuf = ut_params->op->sym->m_dst;
3423 if (ut_params->obuf)
3424 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3426 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3428 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3430 const uint8_t *reference_plaintext = tdata->plaintext.data +
3431 (tdata->validCipherOffsetInBits.len >> 3);
3433 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3435 reference_plaintext,
3436 tdata->validCipherLenInBits.len,
3437 "KASUMI Plaintext data not as expected");
3442 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3444 struct crypto_testsuite_params *ts_params = &testsuite_params;
3445 struct crypto_unittest_params *ut_params = &unittest_params;
3448 uint8_t *ciphertext, *plaintext;
3449 unsigned ciphertext_pad_len;
3450 unsigned ciphertext_len;
3452 /* Create KASUMI session */
3453 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3454 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3455 RTE_CRYPTO_CIPHER_KASUMI_F8,
3456 tdata->key.data, tdata->key.len,
3457 tdata->cipher_iv.len);
3461 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3463 /* Clear mbuf payload */
3464 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3465 rte_pktmbuf_tailroom(ut_params->ibuf));
3467 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3468 /* Append data which is padded to a multiple */
3469 /* of the algorithms block size */
3470 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3471 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3472 ciphertext_pad_len);
3473 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3475 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3477 /* Create KASUMI operation */
3478 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3479 tdata->cipher_iv.len,
3480 tdata->ciphertext.len,
3481 tdata->validCipherOffsetInBits.len);
3485 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3487 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3489 ut_params->obuf = ut_params->op->sym->m_dst;
3490 if (ut_params->obuf)
3491 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3493 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3495 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3497 const uint8_t *reference_plaintext = tdata->plaintext.data +
3498 (tdata->validCipherOffsetInBits.len >> 3);
3500 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3502 reference_plaintext,
3503 tdata->validCipherLenInBits.len,
3504 "KASUMI Plaintext data not as expected");
3509 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3511 struct crypto_testsuite_params *ts_params = &testsuite_params;
3512 struct crypto_unittest_params *ut_params = &unittest_params;
3515 uint8_t *plaintext, *ciphertext;
3516 unsigned plaintext_pad_len;
3517 unsigned plaintext_len;
3519 /* Create SNOW 3G session */
3520 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3521 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3522 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3523 tdata->key.data, tdata->key.len,
3524 tdata->cipher_iv.len);
3528 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3530 /* Clear mbuf payload */
3531 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3532 rte_pktmbuf_tailroom(ut_params->ibuf));
3534 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3535 /* Append data which is padded to a multiple of */
3536 /* the algorithms block size */
3537 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3538 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3540 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3542 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3544 /* Create SNOW 3G operation */
3545 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3546 tdata->cipher_iv.len,
3547 tdata->validCipherLenInBits.len,
3552 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3554 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3556 ut_params->obuf = ut_params->op->sym->m_dst;
3557 if (ut_params->obuf)
3558 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3560 ciphertext = plaintext;
3562 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3565 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3567 tdata->ciphertext.data,
3568 tdata->validDataLenInBits.len,
3569 "SNOW 3G Ciphertext data not as expected");
3575 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3577 struct crypto_testsuite_params *ts_params = &testsuite_params;
3578 struct crypto_unittest_params *ut_params = &unittest_params;
3579 uint8_t *plaintext, *ciphertext;
3582 unsigned plaintext_pad_len;
3583 unsigned plaintext_len;
3585 /* Create SNOW 3G session */
3586 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3587 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3588 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3589 tdata->key.data, tdata->key.len,
3590 tdata->cipher_iv.len);
3594 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3595 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3597 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3598 "Failed to allocate input buffer in mempool");
3599 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3600 "Failed to allocate output buffer in mempool");
3602 /* Clear mbuf payload */
3603 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3604 rte_pktmbuf_tailroom(ut_params->ibuf));
3606 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3607 /* Append data which is padded to a multiple of */
3608 /* the algorithms block size */
3609 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3610 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3612 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3613 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3615 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3617 /* Create SNOW 3G operation */
3618 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3619 tdata->cipher_iv.len,
3620 tdata->validCipherLenInBits.len,
3625 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3627 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3629 ut_params->obuf = ut_params->op->sym->m_dst;
3630 if (ut_params->obuf)
3631 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3633 ciphertext = plaintext;
3635 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3638 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3640 tdata->ciphertext.data,
3641 tdata->validDataLenInBits.len,
3642 "SNOW 3G Ciphertext data not as expected");
3647 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3649 struct crypto_testsuite_params *ts_params = &testsuite_params;
3650 struct crypto_unittest_params *ut_params = &unittest_params;
3653 unsigned int plaintext_pad_len;
3654 unsigned int plaintext_len;
3655 uint8_t buffer[10000];
3656 const uint8_t *ciphertext;
3658 struct rte_cryptodev_info dev_info;
3660 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3661 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3662 printf("Device doesn't support scatter-gather. "
3667 /* Create SNOW 3G session */
3668 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3669 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3670 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3671 tdata->key.data, tdata->key.len,
3672 tdata->cipher_iv.len);
3676 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3677 /* Append data which is padded to a multiple of */
3678 /* the algorithms block size */
3679 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3681 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3682 plaintext_pad_len, 10, 0);
3683 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3684 plaintext_pad_len, 3, 0);
3686 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3687 "Failed to allocate input buffer in mempool");
3688 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3689 "Failed to allocate output buffer in mempool");
3691 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3693 /* Create SNOW 3G operation */
3694 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3695 tdata->cipher_iv.len,
3696 tdata->validCipherLenInBits.len,
3701 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3703 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3705 ut_params->obuf = ut_params->op->sym->m_dst;
3706 if (ut_params->obuf)
3707 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3708 plaintext_len, buffer);
3710 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3711 plaintext_len, buffer);
3713 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3716 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3718 tdata->ciphertext.data,
3719 tdata->validDataLenInBits.len,
3720 "SNOW 3G Ciphertext data not as expected");
3725 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3727 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3729 uint8_t curr_byte, prev_byte;
3730 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3731 uint8_t lower_byte_mask = (1 << offset) - 1;
3734 prev_byte = buffer[0];
3735 buffer[0] >>= offset;
3737 for (i = 1; i < length_in_bytes; i++) {
3738 curr_byte = buffer[i];
3739 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3740 (curr_byte >> offset);
3741 prev_byte = curr_byte;
3746 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3748 struct crypto_testsuite_params *ts_params = &testsuite_params;
3749 struct crypto_unittest_params *ut_params = &unittest_params;
3750 uint8_t *plaintext, *ciphertext;
3752 uint32_t plaintext_len;
3753 uint32_t plaintext_pad_len;
3754 uint8_t extra_offset = 4;
3755 uint8_t *expected_ciphertext_shifted;
3757 /* Create SNOW 3G session */
3758 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3759 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3760 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3761 tdata->key.data, tdata->key.len,
3762 tdata->cipher_iv.len);
3766 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3767 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3769 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3770 "Failed to allocate input buffer in mempool");
3771 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3772 "Failed to allocate output buffer in mempool");
3774 /* Clear mbuf payload */
3775 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3776 rte_pktmbuf_tailroom(ut_params->ibuf));
3778 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3780 * Append data which is padded to a
3781 * multiple of the algorithms block size
3783 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3785 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3788 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3790 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3791 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3793 #ifdef RTE_APP_TEST_DEBUG
3794 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3796 /* Create SNOW 3G operation */
3797 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3798 tdata->cipher_iv.len,
3799 tdata->validCipherLenInBits.len,
3804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3806 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3808 ut_params->obuf = ut_params->op->sym->m_dst;
3809 if (ut_params->obuf)
3810 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3812 ciphertext = plaintext;
3814 #ifdef RTE_APP_TEST_DEBUG
3815 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3818 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3820 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3821 "failed to reserve memory for ciphertext shifted\n");
3823 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3824 ceil_byte_length(tdata->ciphertext.len));
3825 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3828 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3830 expected_ciphertext_shifted,
3831 tdata->validDataLenInBits.len,
3833 "SNOW 3G Ciphertext data not as expected");
3837 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3839 struct crypto_testsuite_params *ts_params = &testsuite_params;
3840 struct crypto_unittest_params *ut_params = &unittest_params;
3844 uint8_t *plaintext, *ciphertext;
3845 unsigned ciphertext_pad_len;
3846 unsigned ciphertext_len;
3848 /* Create SNOW 3G session */
3849 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3850 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3851 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3852 tdata->key.data, tdata->key.len,
3853 tdata->cipher_iv.len);
3857 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3859 /* Clear mbuf payload */
3860 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3861 rte_pktmbuf_tailroom(ut_params->ibuf));
3863 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3864 /* Append data which is padded to a multiple of */
3865 /* the algorithms block size */
3866 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3867 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3868 ciphertext_pad_len);
3869 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3871 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3873 /* Create SNOW 3G operation */
3874 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3875 tdata->cipher_iv.len,
3876 tdata->validCipherLenInBits.len,
3881 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3883 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3884 ut_params->obuf = ut_params->op->sym->m_dst;
3885 if (ut_params->obuf)
3886 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3888 plaintext = ciphertext;
3890 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3893 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3894 tdata->plaintext.data,
3895 tdata->validDataLenInBits.len,
3896 "SNOW 3G Plaintext data not as expected");
3900 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3902 struct crypto_testsuite_params *ts_params = &testsuite_params;
3903 struct crypto_unittest_params *ut_params = &unittest_params;
3907 uint8_t *plaintext, *ciphertext;
3908 unsigned ciphertext_pad_len;
3909 unsigned ciphertext_len;
3911 /* Create SNOW 3G session */
3912 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3913 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3914 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3915 tdata->key.data, tdata->key.len,
3916 tdata->cipher_iv.len);
3920 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3921 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3923 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3924 "Failed to allocate input buffer");
3925 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3926 "Failed to allocate output buffer");
3928 /* Clear mbuf payload */
3929 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3930 rte_pktmbuf_tailroom(ut_params->ibuf));
3932 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3933 rte_pktmbuf_tailroom(ut_params->obuf));
3935 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3936 /* Append data which is padded to a multiple of */
3937 /* the algorithms block size */
3938 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3939 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3940 ciphertext_pad_len);
3941 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3942 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3944 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3946 /* Create SNOW 3G operation */
3947 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3948 tdata->cipher_iv.len,
3949 tdata->validCipherLenInBits.len,
3954 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3956 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3957 ut_params->obuf = ut_params->op->sym->m_dst;
3958 if (ut_params->obuf)
3959 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3961 plaintext = ciphertext;
3963 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3966 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3967 tdata->plaintext.data,
3968 tdata->validDataLenInBits.len,
3969 "SNOW 3G Plaintext data not as expected");
3974 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3976 struct crypto_testsuite_params *ts_params = &testsuite_params;
3977 struct crypto_unittest_params *ut_params = &unittest_params;
3981 uint8_t *plaintext, *ciphertext;
3982 unsigned int plaintext_pad_len;
3983 unsigned int plaintext_len;
3985 struct rte_cryptodev_sym_capability_idx cap_idx;
3987 /* Check if device supports ZUC EEA3 */
3988 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3989 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3991 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3995 /* Check if device supports ZUC EIA3 */
3996 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3997 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3999 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4003 /* Create ZUC session */
4004 retval = create_zuc_cipher_auth_encrypt_generate_session(
4005 ts_params->valid_devs[0],
4009 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4011 /* clear mbuf payload */
4012 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4013 rte_pktmbuf_tailroom(ut_params->ibuf));
4015 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4016 /* Append data which is padded to a multiple of */
4017 /* the algorithms block size */
4018 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4019 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4021 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4023 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4025 /* Create ZUC operation */
4026 retval = create_zuc_cipher_hash_generate_operation(tdata);
4030 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4032 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4033 ut_params->obuf = ut_params->op->sym->m_src;
4034 if (ut_params->obuf)
4035 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4037 ciphertext = plaintext;
4039 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4041 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4043 tdata->ciphertext.data,
4044 tdata->validDataLenInBits.len,
4045 "ZUC Ciphertext data not as expected");
4047 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4048 + plaintext_pad_len;
4051 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4055 "ZUC Generated auth tag not as expected");
4060 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4062 struct crypto_testsuite_params *ts_params = &testsuite_params;
4063 struct crypto_unittest_params *ut_params = &unittest_params;
4067 uint8_t *plaintext, *ciphertext;
4068 unsigned plaintext_pad_len;
4069 unsigned plaintext_len;
4071 /* Create SNOW 3G session */
4072 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4073 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4074 RTE_CRYPTO_AUTH_OP_GENERATE,
4075 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4076 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4077 tdata->key.data, tdata->key.len,
4078 tdata->auth_iv.len, tdata->digest.len,
4079 tdata->cipher_iv.len);
4082 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4084 /* clear mbuf payload */
4085 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4086 rte_pktmbuf_tailroom(ut_params->ibuf));
4088 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4089 /* Append data which is padded to a multiple of */
4090 /* the algorithms block size */
4091 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4092 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4094 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4096 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4098 /* Create SNOW 3G operation */
4099 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4100 tdata->digest.len, tdata->auth_iv.data,
4102 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4103 tdata->cipher_iv.data, tdata->cipher_iv.len,
4104 tdata->validCipherLenInBits.len,
4106 tdata->validAuthLenInBits.len,
4112 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4114 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4115 ut_params->obuf = ut_params->op->sym->m_src;
4116 if (ut_params->obuf)
4117 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4119 ciphertext = plaintext;
4121 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4123 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4125 tdata->ciphertext.data,
4126 tdata->validDataLenInBits.len,
4127 "SNOW 3G Ciphertext data not as expected");
4129 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4130 + plaintext_pad_len;
4133 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4136 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4137 "SNOW 3G Generated auth tag not as expected");
4141 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4143 struct crypto_testsuite_params *ts_params = &testsuite_params;
4144 struct crypto_unittest_params *ut_params = &unittest_params;
4148 uint8_t *plaintext, *ciphertext;
4149 unsigned plaintext_pad_len;
4150 unsigned plaintext_len;
4152 /* Create SNOW 3G session */
4153 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4154 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4155 RTE_CRYPTO_AUTH_OP_GENERATE,
4156 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4157 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4158 tdata->key.data, tdata->key.len,
4159 tdata->auth_iv.len, tdata->digest.len,
4160 tdata->cipher_iv.len);
4164 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4166 /* clear mbuf payload */
4167 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4168 rte_pktmbuf_tailroom(ut_params->ibuf));
4170 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4171 /* Append data which is padded to a multiple of */
4172 /* the algorithms block size */
4173 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4174 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4176 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4178 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4180 /* Create SNOW 3G operation */
4181 retval = create_wireless_algo_auth_cipher_operation(
4183 tdata->cipher_iv.data, tdata->cipher_iv.len,
4184 tdata->auth_iv.data, tdata->auth_iv.len,
4186 tdata->validCipherLenInBits.len,
4188 tdata->validAuthLenInBits.len,
4194 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4196 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4197 ut_params->obuf = ut_params->op->sym->m_src;
4198 if (ut_params->obuf)
4199 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4201 ciphertext = plaintext;
4203 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4204 + plaintext_pad_len;
4205 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4208 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4210 tdata->ciphertext.data,
4211 tdata->validDataLenInBits.len,
4212 "SNOW 3G Ciphertext data not as expected");
4215 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4218 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4219 "SNOW 3G Generated auth tag not as expected");
4224 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4226 struct crypto_testsuite_params *ts_params = &testsuite_params;
4227 struct crypto_unittest_params *ut_params = &unittest_params;
4231 uint8_t *plaintext, *ciphertext;
4232 unsigned plaintext_pad_len;
4233 unsigned plaintext_len;
4235 /* Create KASUMI session */
4236 retval = create_wireless_algo_auth_cipher_session(
4237 ts_params->valid_devs[0],
4238 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4239 RTE_CRYPTO_AUTH_OP_GENERATE,
4240 RTE_CRYPTO_AUTH_KASUMI_F9,
4241 RTE_CRYPTO_CIPHER_KASUMI_F8,
4242 tdata->key.data, tdata->key.len,
4243 0, tdata->digest.len,
4244 tdata->cipher_iv.len);
4247 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4249 /* clear mbuf payload */
4250 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4251 rte_pktmbuf_tailroom(ut_params->ibuf));
4253 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4254 /* Append data which is padded to a multiple of */
4255 /* the algorithms block size */
4256 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4257 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4259 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4261 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4263 /* Create KASUMI operation */
4264 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4265 tdata->cipher_iv.data, tdata->cipher_iv.len,
4268 tdata->validCipherLenInBits.len,
4269 tdata->validCipherOffsetInBits.len,
4270 tdata->validAuthLenInBits.len,
4277 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4279 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4280 if (ut_params->op->sym->m_dst)
4281 ut_params->obuf = ut_params->op->sym->m_dst;
4283 ut_params->obuf = ut_params->op->sym->m_src;
4285 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4286 tdata->validCipherOffsetInBits.len >> 3);
4288 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4289 (tdata->validCipherOffsetInBits.len >> 3);
4291 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4293 reference_ciphertext,
4294 tdata->validCipherLenInBits.len,
4295 "KASUMI Ciphertext data not as expected");
4296 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4297 + plaintext_pad_len;
4300 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4303 DIGEST_BYTE_LENGTH_KASUMI_F9,
4304 "KASUMI Generated auth tag not as expected");
4309 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4311 struct crypto_testsuite_params *ts_params = &testsuite_params;
4312 struct crypto_unittest_params *ut_params = &unittest_params;
4316 uint8_t *plaintext, *ciphertext;
4317 unsigned plaintext_pad_len;
4318 unsigned plaintext_len;
4320 /* Create KASUMI session */
4321 retval = create_wireless_algo_cipher_auth_session(
4322 ts_params->valid_devs[0],
4323 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4324 RTE_CRYPTO_AUTH_OP_GENERATE,
4325 RTE_CRYPTO_AUTH_KASUMI_F9,
4326 RTE_CRYPTO_CIPHER_KASUMI_F8,
4327 tdata->key.data, tdata->key.len,
4328 0, tdata->digest.len,
4329 tdata->cipher_iv.len);
4333 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4335 /* clear mbuf payload */
4336 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4337 rte_pktmbuf_tailroom(ut_params->ibuf));
4339 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4340 /* Append data which is padded to a multiple of */
4341 /* the algorithms block size */
4342 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4343 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4345 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4347 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4349 /* Create KASUMI operation */
4350 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4351 tdata->digest.len, NULL, 0,
4352 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4353 tdata->cipher_iv.data, tdata->cipher_iv.len,
4354 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4355 tdata->validCipherOffsetInBits.len,
4356 tdata->validAuthLenInBits.len,
4362 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4364 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4366 if (ut_params->op->sym->m_dst)
4367 ut_params->obuf = ut_params->op->sym->m_dst;
4369 ut_params->obuf = ut_params->op->sym->m_src;
4371 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4372 tdata->validCipherOffsetInBits.len >> 3);
4374 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4375 + plaintext_pad_len;
4377 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4378 (tdata->validCipherOffsetInBits.len >> 3);
4380 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4382 reference_ciphertext,
4383 tdata->validCipherLenInBits.len,
4384 "KASUMI Ciphertext data not as expected");
4387 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4390 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4391 "KASUMI Generated auth tag not as expected");
4396 test_zuc_encryption(const struct wireless_test_data *tdata)
4398 struct crypto_testsuite_params *ts_params = &testsuite_params;
4399 struct crypto_unittest_params *ut_params = &unittest_params;
4402 uint8_t *plaintext, *ciphertext;
4403 unsigned plaintext_pad_len;
4404 unsigned plaintext_len;
4406 struct rte_cryptodev_sym_capability_idx cap_idx;
4408 /* Check if device supports ZUC EEA3 */
4409 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4410 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4412 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4416 /* Create ZUC session */
4417 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4418 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4419 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4420 tdata->key.data, tdata->key.len,
4421 tdata->cipher_iv.len);
4425 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4427 /* Clear mbuf payload */
4428 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4429 rte_pktmbuf_tailroom(ut_params->ibuf));
4431 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4432 /* Append data which is padded to a multiple */
4433 /* of the algorithms block size */
4434 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4435 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4437 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4439 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4441 /* Create ZUC operation */
4442 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4443 tdata->cipher_iv.len,
4444 tdata->plaintext.len,
4449 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4451 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4453 ut_params->obuf = ut_params->op->sym->m_dst;
4454 if (ut_params->obuf)
4455 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4457 ciphertext = plaintext;
4459 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4462 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4464 tdata->ciphertext.data,
4465 tdata->validCipherLenInBits.len,
4466 "ZUC Ciphertext data not as expected");
4471 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4473 struct crypto_testsuite_params *ts_params = &testsuite_params;
4474 struct crypto_unittest_params *ut_params = &unittest_params;
4478 unsigned int plaintext_pad_len;
4479 unsigned int plaintext_len;
4480 const uint8_t *ciphertext;
4481 uint8_t ciphertext_buffer[2048];
4482 struct rte_cryptodev_info dev_info;
4484 struct rte_cryptodev_sym_capability_idx cap_idx;
4486 /* Check if device supports ZUC EEA3 */
4487 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4488 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4490 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4494 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4495 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4496 printf("Device doesn't support scatter-gather. "
4501 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4503 /* Append data which is padded to a multiple */
4504 /* of the algorithms block size */
4505 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4507 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4508 plaintext_pad_len, 10, 0);
4510 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4511 tdata->plaintext.data);
4513 /* Create ZUC session */
4514 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4515 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4516 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4517 tdata->key.data, tdata->key.len,
4518 tdata->cipher_iv.len);
4522 /* Clear mbuf payload */
4524 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4526 /* Create ZUC operation */
4527 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4528 tdata->cipher_iv.len, tdata->plaintext.len,
4533 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4535 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4537 ut_params->obuf = ut_params->op->sym->m_dst;
4538 if (ut_params->obuf)
4539 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4540 0, plaintext_len, ciphertext_buffer);
4542 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4543 0, plaintext_len, ciphertext_buffer);
4546 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4549 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4551 tdata->ciphertext.data,
4552 tdata->validCipherLenInBits.len,
4553 "ZUC Ciphertext data not as expected");
4559 test_zuc_authentication(const struct wireless_test_data *tdata)
4561 struct crypto_testsuite_params *ts_params = &testsuite_params;
4562 struct crypto_unittest_params *ut_params = &unittest_params;
4565 unsigned plaintext_pad_len;
4566 unsigned plaintext_len;
4569 struct rte_cryptodev_sym_capability_idx cap_idx;
4571 /* Check if device supports ZUC EIA3 */
4572 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4573 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4575 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4579 /* Create ZUC session */
4580 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4581 tdata->key.data, tdata->key.len,
4582 tdata->auth_iv.len, tdata->digest.len,
4583 RTE_CRYPTO_AUTH_OP_GENERATE,
4584 RTE_CRYPTO_AUTH_ZUC_EIA3);
4588 /* alloc mbuf and set payload */
4589 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4591 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4592 rte_pktmbuf_tailroom(ut_params->ibuf));
4594 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4595 /* Append data which is padded to a multiple of */
4596 /* the algorithms block size */
4597 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4598 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4600 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4602 /* Create ZUC operation */
4603 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4604 tdata->auth_iv.data, tdata->auth_iv.len,
4605 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4606 tdata->validAuthLenInBits.len,
4611 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4613 ut_params->obuf = ut_params->op->sym->m_src;
4614 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4615 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4616 + plaintext_pad_len;
4619 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4622 DIGEST_BYTE_LENGTH_KASUMI_F9,
4623 "ZUC Generated auth tag not as expected");
4629 test_kasumi_encryption_test_case_1(void)
4631 return test_kasumi_encryption(&kasumi_test_case_1);
4635 test_kasumi_encryption_test_case_1_sgl(void)
4637 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4641 test_kasumi_encryption_test_case_1_oop(void)
4643 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4647 test_kasumi_encryption_test_case_1_oop_sgl(void)
4649 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4653 test_kasumi_encryption_test_case_2(void)
4655 return test_kasumi_encryption(&kasumi_test_case_2);
4659 test_kasumi_encryption_test_case_3(void)
4661 return test_kasumi_encryption(&kasumi_test_case_3);
4665 test_kasumi_encryption_test_case_4(void)
4667 return test_kasumi_encryption(&kasumi_test_case_4);
4671 test_kasumi_encryption_test_case_5(void)
4673 return test_kasumi_encryption(&kasumi_test_case_5);
4677 test_kasumi_decryption_test_case_1(void)
4679 return test_kasumi_decryption(&kasumi_test_case_1);
4683 test_kasumi_decryption_test_case_1_oop(void)
4685 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4689 test_kasumi_decryption_test_case_2(void)
4691 return test_kasumi_decryption(&kasumi_test_case_2);
4695 test_kasumi_decryption_test_case_3(void)
4697 return test_kasumi_decryption(&kasumi_test_case_3);
4701 test_kasumi_decryption_test_case_4(void)
4703 return test_kasumi_decryption(&kasumi_test_case_4);
4707 test_kasumi_decryption_test_case_5(void)
4709 return test_kasumi_decryption(&kasumi_test_case_5);
4712 test_snow3g_encryption_test_case_1(void)
4714 return test_snow3g_encryption(&snow3g_test_case_1);
4718 test_snow3g_encryption_test_case_1_oop(void)
4720 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4724 test_snow3g_encryption_test_case_1_oop_sgl(void)
4726 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4731 test_snow3g_encryption_test_case_1_offset_oop(void)
4733 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4737 test_snow3g_encryption_test_case_2(void)
4739 return test_snow3g_encryption(&snow3g_test_case_2);
4743 test_snow3g_encryption_test_case_3(void)
4745 return test_snow3g_encryption(&snow3g_test_case_3);
4749 test_snow3g_encryption_test_case_4(void)
4751 return test_snow3g_encryption(&snow3g_test_case_4);
4755 test_snow3g_encryption_test_case_5(void)
4757 return test_snow3g_encryption(&snow3g_test_case_5);
4761 test_snow3g_decryption_test_case_1(void)
4763 return test_snow3g_decryption(&snow3g_test_case_1);
4767 test_snow3g_decryption_test_case_1_oop(void)
4769 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4773 test_snow3g_decryption_test_case_2(void)
4775 return test_snow3g_decryption(&snow3g_test_case_2);
4779 test_snow3g_decryption_test_case_3(void)
4781 return test_snow3g_decryption(&snow3g_test_case_3);
4785 test_snow3g_decryption_test_case_4(void)
4787 return test_snow3g_decryption(&snow3g_test_case_4);
4791 test_snow3g_decryption_test_case_5(void)
4793 return test_snow3g_decryption(&snow3g_test_case_5);
4796 test_snow3g_cipher_auth_test_case_1(void)
4798 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4802 test_snow3g_auth_cipher_test_case_1(void)
4804 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4808 test_kasumi_auth_cipher_test_case_1(void)
4810 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4814 test_kasumi_cipher_auth_test_case_1(void)
4816 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4820 test_zuc_encryption_test_case_1(void)
4822 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4826 test_zuc_encryption_test_case_2(void)
4828 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4832 test_zuc_encryption_test_case_3(void)
4834 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4838 test_zuc_encryption_test_case_4(void)
4840 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4844 test_zuc_encryption_test_case_5(void)
4846 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4850 test_zuc_encryption_test_case_6_sgl(void)
4852 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4856 test_zuc_hash_generate_test_case_1(void)
4858 return test_zuc_authentication(&zuc_test_case_auth_1b);
4862 test_zuc_hash_generate_test_case_2(void)
4864 return test_zuc_authentication(&zuc_test_case_auth_90b);
4868 test_zuc_hash_generate_test_case_3(void)
4870 return test_zuc_authentication(&zuc_test_case_auth_577b);
4874 test_zuc_hash_generate_test_case_4(void)
4876 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4880 test_zuc_hash_generate_test_case_5(void)
4882 return test_zuc_authentication(&zuc_test_auth_5670b);
4886 test_zuc_hash_generate_test_case_6(void)
4888 return test_zuc_authentication(&zuc_test_case_auth_128b);
4892 test_zuc_hash_generate_test_case_7(void)
4894 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4898 test_zuc_hash_generate_test_case_8(void)
4900 return test_zuc_authentication(&zuc_test_case_auth_584b);
4904 test_zuc_cipher_auth_test_case_1(void)
4906 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4910 test_zuc_cipher_auth_test_case_2(void)
4912 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4916 test_3DES_chain_qat_all(void)
4918 struct crypto_testsuite_params *ts_params = &testsuite_params;
4921 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4922 ts_params->op_mpool,
4923 ts_params->session_mpool,
4924 ts_params->valid_devs[0],
4925 rte_cryptodev_driver_id_get(
4926 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4927 BLKCIPHER_3DES_CHAIN_TYPE);
4929 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4931 return TEST_SUCCESS;
4935 test_DES_cipheronly_qat_all(void)
4937 struct crypto_testsuite_params *ts_params = &testsuite_params;
4940 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4941 ts_params->op_mpool,
4942 ts_params->session_mpool,
4943 ts_params->valid_devs[0],
4944 rte_cryptodev_driver_id_get(
4945 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4946 BLKCIPHER_DES_CIPHERONLY_TYPE);
4948 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4950 return TEST_SUCCESS;
4954 test_DES_cipheronly_openssl_all(void)
4956 struct crypto_testsuite_params *ts_params = &testsuite_params;
4959 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4960 ts_params->op_mpool,
4961 ts_params->session_mpool,
4962 ts_params->valid_devs[0],
4963 rte_cryptodev_driver_id_get(
4964 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4965 BLKCIPHER_DES_CIPHERONLY_TYPE);
4967 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4969 return TEST_SUCCESS;
4973 test_DES_docsis_openssl_all(void)
4975 struct crypto_testsuite_params *ts_params = &testsuite_params;
4978 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4979 ts_params->op_mpool,
4980 ts_params->session_mpool,
4981 ts_params->valid_devs[0],
4982 rte_cryptodev_driver_id_get(
4983 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4984 BLKCIPHER_DES_DOCSIS_TYPE);
4986 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4988 return TEST_SUCCESS;
4992 test_DES_cipheronly_mb_all(void)
4994 struct crypto_testsuite_params *ts_params = &testsuite_params;
4997 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4998 ts_params->op_mpool,
4999 ts_params->session_mpool,
5000 ts_params->valid_devs[0],
5001 rte_cryptodev_driver_id_get(
5002 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5003 BLKCIPHER_DES_CIPHERONLY_TYPE);
5005 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5007 return TEST_SUCCESS;
5011 test_DES_docsis_mb_all(void)
5013 struct crypto_testsuite_params *ts_params = &testsuite_params;
5016 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5017 ts_params->op_mpool,
5018 ts_params->session_mpool,
5019 ts_params->valid_devs[0],
5020 rte_cryptodev_driver_id_get(
5021 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5022 BLKCIPHER_DES_DOCSIS_TYPE);
5024 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5026 return TEST_SUCCESS;
5030 test_3DES_chain_dpaa_sec_all(void)
5032 struct crypto_testsuite_params *ts_params = &testsuite_params;
5035 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5036 ts_params->op_mpool,
5037 ts_params->session_mpool,
5038 ts_params->valid_devs[0],
5039 rte_cryptodev_driver_id_get(
5040 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5041 BLKCIPHER_3DES_CHAIN_TYPE);
5043 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5045 return TEST_SUCCESS;
5049 test_3DES_cipheronly_dpaa_sec_all(void)
5051 struct crypto_testsuite_params *ts_params = &testsuite_params;
5054 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5055 ts_params->op_mpool,
5056 ts_params->session_mpool,
5057 ts_params->valid_devs[0],
5058 rte_cryptodev_driver_id_get(
5059 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5060 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5062 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5064 return TEST_SUCCESS;
5068 test_3DES_chain_dpaa2_sec_all(void)
5070 struct crypto_testsuite_params *ts_params = &testsuite_params;
5073 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5074 ts_params->op_mpool,
5075 ts_params->session_mpool,
5076 ts_params->valid_devs[0],
5077 rte_cryptodev_driver_id_get(
5078 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5079 BLKCIPHER_3DES_CHAIN_TYPE);
5081 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5083 return TEST_SUCCESS;
5087 test_3DES_cipheronly_dpaa2_sec_all(void)
5089 struct crypto_testsuite_params *ts_params = &testsuite_params;
5092 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5093 ts_params->op_mpool,
5094 ts_params->session_mpool,
5095 ts_params->valid_devs[0],
5096 rte_cryptodev_driver_id_get(
5097 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5098 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5100 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5102 return TEST_SUCCESS;
5106 test_3DES_chain_ccp_all(void)
5108 struct crypto_testsuite_params *ts_params = &testsuite_params;
5111 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5112 ts_params->op_mpool,
5113 ts_params->session_mpool,
5114 ts_params->valid_devs[0],
5115 rte_cryptodev_driver_id_get(
5116 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5117 BLKCIPHER_3DES_CHAIN_TYPE);
5119 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5121 return TEST_SUCCESS;
5125 test_3DES_cipheronly_ccp_all(void)
5127 struct crypto_testsuite_params *ts_params = &testsuite_params;
5130 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5131 ts_params->op_mpool,
5132 ts_params->session_mpool,
5133 ts_params->valid_devs[0],
5134 rte_cryptodev_driver_id_get(
5135 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5136 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5138 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5140 return TEST_SUCCESS;
5144 test_3DES_cipheronly_qat_all(void)
5146 struct crypto_testsuite_params *ts_params = &testsuite_params;
5149 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5150 ts_params->op_mpool,
5151 ts_params->session_mpool,
5152 ts_params->valid_devs[0],
5153 rte_cryptodev_driver_id_get(
5154 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5155 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5157 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5159 return TEST_SUCCESS;
5163 test_3DES_chain_openssl_all(void)
5165 struct crypto_testsuite_params *ts_params = &testsuite_params;
5168 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5169 ts_params->op_mpool,
5170 ts_params->session_mpool,
5171 ts_params->valid_devs[0],
5172 rte_cryptodev_driver_id_get(
5173 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5174 BLKCIPHER_3DES_CHAIN_TYPE);
5176 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5178 return TEST_SUCCESS;
5182 test_3DES_cipheronly_openssl_all(void)
5184 struct crypto_testsuite_params *ts_params = &testsuite_params;
5187 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5188 ts_params->op_mpool,
5189 ts_params->session_mpool,
5190 ts_params->valid_devs[0],
5191 rte_cryptodev_driver_id_get(
5192 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5193 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5195 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5197 return TEST_SUCCESS;
5200 /* ***** AEAD algorithm Tests ***** */
5203 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5204 enum rte_crypto_aead_operation op,
5205 const uint8_t *key, const uint8_t key_len,
5206 const uint16_t aad_len, const uint8_t auth_len,
5209 uint8_t aead_key[key_len];
5211 struct crypto_testsuite_params *ts_params = &testsuite_params;
5212 struct crypto_unittest_params *ut_params = &unittest_params;
5214 memcpy(aead_key, key, key_len);
5216 /* Setup AEAD Parameters */
5217 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5218 ut_params->aead_xform.next = NULL;
5219 ut_params->aead_xform.aead.algo = algo;
5220 ut_params->aead_xform.aead.op = op;
5221 ut_params->aead_xform.aead.key.data = aead_key;
5222 ut_params->aead_xform.aead.key.length = key_len;
5223 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5224 ut_params->aead_xform.aead.iv.length = iv_len;
5225 ut_params->aead_xform.aead.digest_length = auth_len;
5226 ut_params->aead_xform.aead.aad_length = aad_len;
5228 debug_hexdump(stdout, "key:", key, key_len);
5230 /* Create Crypto session*/
5231 ut_params->sess = rte_cryptodev_sym_session_create(
5232 ts_params->session_mpool);
5234 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5235 &ut_params->aead_xform, ts_params->session_mpool);
5237 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5243 create_aead_xform(struct rte_crypto_op *op,
5244 enum rte_crypto_aead_algorithm algo,
5245 enum rte_crypto_aead_operation aead_op,
5246 uint8_t *key, const uint8_t key_len,
5247 const uint8_t aad_len, const uint8_t auth_len,
5250 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5251 "failed to allocate space for crypto transform");
5253 struct rte_crypto_sym_op *sym_op = op->sym;
5255 /* Setup AEAD Parameters */
5256 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5257 sym_op->xform->next = NULL;
5258 sym_op->xform->aead.algo = algo;
5259 sym_op->xform->aead.op = aead_op;
5260 sym_op->xform->aead.key.data = key;
5261 sym_op->xform->aead.key.length = key_len;
5262 sym_op->xform->aead.iv.offset = IV_OFFSET;
5263 sym_op->xform->aead.iv.length = iv_len;
5264 sym_op->xform->aead.digest_length = auth_len;
5265 sym_op->xform->aead.aad_length = aad_len;
5267 debug_hexdump(stdout, "key:", key, key_len);
5273 create_aead_operation(enum rte_crypto_aead_operation op,
5274 const struct aead_test_data *tdata)
5276 struct crypto_testsuite_params *ts_params = &testsuite_params;
5277 struct crypto_unittest_params *ut_params = &unittest_params;
5279 uint8_t *plaintext, *ciphertext;
5280 unsigned int aad_pad_len, plaintext_pad_len;
5282 /* Generate Crypto op data structure */
5283 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5284 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5285 TEST_ASSERT_NOT_NULL(ut_params->op,
5286 "Failed to allocate symmetric crypto operation struct");
5288 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5290 /* Append aad data */
5291 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5292 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5293 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5295 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5296 "no room to append aad");
5298 sym_op->aead.aad.phys_addr =
5299 rte_pktmbuf_iova(ut_params->ibuf);
5300 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5301 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5302 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5305 /* Append IV at the end of the crypto operation*/
5306 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5307 uint8_t *, IV_OFFSET);
5309 /* Copy IV 1 byte after the IV pointer, according to the API */
5310 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5311 debug_hexdump(stdout, "iv:", iv_ptr,
5314 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5315 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5317 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5318 "no room to append aad");
5320 sym_op->aead.aad.phys_addr =
5321 rte_pktmbuf_iova(ut_params->ibuf);
5322 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5323 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5326 /* Append IV at the end of the crypto operation*/
5327 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5328 uint8_t *, IV_OFFSET);
5330 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5331 debug_hexdump(stdout, "iv:", iv_ptr,
5335 /* Append plaintext/ciphertext */
5336 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5337 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5338 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5340 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5342 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5343 debug_hexdump(stdout, "plaintext:", plaintext,
5344 tdata->plaintext.len);
5346 if (ut_params->obuf) {
5347 ciphertext = (uint8_t *)rte_pktmbuf_append(
5349 plaintext_pad_len + aad_pad_len);
5350 TEST_ASSERT_NOT_NULL(ciphertext,
5351 "no room to append ciphertext");
5353 memset(ciphertext + aad_pad_len, 0,
5354 tdata->ciphertext.len);
5357 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5358 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5360 TEST_ASSERT_NOT_NULL(ciphertext,
5361 "no room to append ciphertext");
5363 memcpy(ciphertext, tdata->ciphertext.data,
5364 tdata->ciphertext.len);
5365 debug_hexdump(stdout, "ciphertext:", ciphertext,
5366 tdata->ciphertext.len);
5368 if (ut_params->obuf) {
5369 plaintext = (uint8_t *)rte_pktmbuf_append(
5371 plaintext_pad_len + aad_pad_len);
5372 TEST_ASSERT_NOT_NULL(plaintext,
5373 "no room to append plaintext");
5375 memset(plaintext + aad_pad_len, 0,
5376 tdata->plaintext.len);
5380 /* Append digest data */
5381 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5382 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5383 ut_params->obuf ? ut_params->obuf :
5385 tdata->auth_tag.len);
5386 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5387 "no room to append digest");
5388 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5389 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5390 ut_params->obuf ? ut_params->obuf :
5395 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5396 ut_params->ibuf, tdata->auth_tag.len);
5397 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5398 "no room to append digest");
5399 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5401 plaintext_pad_len + aad_pad_len);
5403 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5404 tdata->auth_tag.len);
5405 debug_hexdump(stdout, "digest:",
5406 sym_op->aead.digest.data,
5407 tdata->auth_tag.len);
5410 sym_op->aead.data.length = tdata->plaintext.len;
5411 sym_op->aead.data.offset = aad_pad_len;
5417 test_authenticated_encryption(const struct aead_test_data *tdata)
5419 struct crypto_testsuite_params *ts_params = &testsuite_params;
5420 struct crypto_unittest_params *ut_params = &unittest_params;
5423 uint8_t *ciphertext, *auth_tag;
5424 uint16_t plaintext_pad_len;
5427 /* Create AEAD session */
5428 retval = create_aead_session(ts_params->valid_devs[0],
5430 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5431 tdata->key.data, tdata->key.len,
5432 tdata->aad.len, tdata->auth_tag.len,
5437 if (tdata->aad.len > MBUF_SIZE) {
5438 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5439 /* Populate full size of add data */
5440 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5441 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5443 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5445 /* clear mbuf payload */
5446 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5447 rte_pktmbuf_tailroom(ut_params->ibuf));
5449 /* Create AEAD operation */
5450 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5454 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5456 ut_params->op->sym->m_src = ut_params->ibuf;
5458 /* Process crypto operation */
5459 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5460 ut_params->op), "failed to process sym crypto op");
5462 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5463 "crypto op processing failed");
5465 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5467 if (ut_params->op->sym->m_dst) {
5468 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5470 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5471 uint8_t *, plaintext_pad_len);
5473 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5475 ut_params->op->sym->cipher.data.offset);
5476 auth_tag = ciphertext + plaintext_pad_len;
5479 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5480 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5483 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5485 tdata->ciphertext.data,
5486 tdata->ciphertext.len,
5487 "Ciphertext data not as expected");
5489 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5491 tdata->auth_tag.data,
5492 tdata->auth_tag.len,
5493 "Generated auth tag not as expected");
5500 test_AES_GCM_authenticated_encryption_test_case_1(void)
5502 return test_authenticated_encryption(&gcm_test_case_1);
5506 test_AES_GCM_authenticated_encryption_test_case_2(void)
5508 return test_authenticated_encryption(&gcm_test_case_2);
5512 test_AES_GCM_authenticated_encryption_test_case_3(void)
5514 return test_authenticated_encryption(&gcm_test_case_3);
5518 test_AES_GCM_authenticated_encryption_test_case_4(void)
5520 return test_authenticated_encryption(&gcm_test_case_4);
5524 test_AES_GCM_authenticated_encryption_test_case_5(void)
5526 return test_authenticated_encryption(&gcm_test_case_5);
5530 test_AES_GCM_authenticated_encryption_test_case_6(void)
5532 return test_authenticated_encryption(&gcm_test_case_6);
5536 test_AES_GCM_authenticated_encryption_test_case_7(void)
5538 return test_authenticated_encryption(&gcm_test_case_7);
5542 test_AES_GCM_auth_encryption_test_case_192_1(void)
5544 return test_authenticated_encryption(&gcm_test_case_192_1);
5548 test_AES_GCM_auth_encryption_test_case_192_2(void)
5550 return test_authenticated_encryption(&gcm_test_case_192_2);
5554 test_AES_GCM_auth_encryption_test_case_192_3(void)
5556 return test_authenticated_encryption(&gcm_test_case_192_3);
5560 test_AES_GCM_auth_encryption_test_case_192_4(void)
5562 return test_authenticated_encryption(&gcm_test_case_192_4);
5566 test_AES_GCM_auth_encryption_test_case_192_5(void)
5568 return test_authenticated_encryption(&gcm_test_case_192_5);
5572 test_AES_GCM_auth_encryption_test_case_192_6(void)
5574 return test_authenticated_encryption(&gcm_test_case_192_6);
5578 test_AES_GCM_auth_encryption_test_case_192_7(void)
5580 return test_authenticated_encryption(&gcm_test_case_192_7);
5584 test_AES_GCM_auth_encryption_test_case_256_1(void)
5586 return test_authenticated_encryption(&gcm_test_case_256_1);
5590 test_AES_GCM_auth_encryption_test_case_256_2(void)
5592 return test_authenticated_encryption(&gcm_test_case_256_2);
5596 test_AES_GCM_auth_encryption_test_case_256_3(void)
5598 return test_authenticated_encryption(&gcm_test_case_256_3);
5602 test_AES_GCM_auth_encryption_test_case_256_4(void)
5604 return test_authenticated_encryption(&gcm_test_case_256_4);
5608 test_AES_GCM_auth_encryption_test_case_256_5(void)
5610 return test_authenticated_encryption(&gcm_test_case_256_5);
5614 test_AES_GCM_auth_encryption_test_case_256_6(void)
5616 return test_authenticated_encryption(&gcm_test_case_256_6);
5620 test_AES_GCM_auth_encryption_test_case_256_7(void)
5622 return test_authenticated_encryption(&gcm_test_case_256_7);
5626 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5628 return test_authenticated_encryption(&gcm_test_case_aad_1);
5632 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5634 return test_authenticated_encryption(&gcm_test_case_aad_2);
5638 test_authenticated_decryption(const struct aead_test_data *tdata)
5640 struct crypto_testsuite_params *ts_params = &testsuite_params;
5641 struct crypto_unittest_params *ut_params = &unittest_params;
5647 /* Create AEAD session */
5648 retval = create_aead_session(ts_params->valid_devs[0],
5650 RTE_CRYPTO_AEAD_OP_DECRYPT,
5651 tdata->key.data, tdata->key.len,
5652 tdata->aad.len, tdata->auth_tag.len,
5657 /* alloc mbuf and set payload */
5658 if (tdata->aad.len > MBUF_SIZE) {
5659 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5660 /* Populate full size of add data */
5661 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5662 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5664 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5666 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5667 rte_pktmbuf_tailroom(ut_params->ibuf));
5669 /* Create AEAD operation */
5670 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5674 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5676 ut_params->op->sym->m_src = ut_params->ibuf;
5678 /* Process crypto operation */
5679 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5680 ut_params->op), "failed to process sym crypto op");
5682 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5683 "crypto op processing failed");
5685 if (ut_params->op->sym->m_dst)
5686 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5689 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5691 ut_params->op->sym->cipher.data.offset);
5693 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5696 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5698 tdata->plaintext.data,
5699 tdata->plaintext.len,
5700 "Plaintext data not as expected");
5702 TEST_ASSERT_EQUAL(ut_params->op->status,
5703 RTE_CRYPTO_OP_STATUS_SUCCESS,
5704 "Authentication failed");
5709 test_AES_GCM_authenticated_decryption_test_case_1(void)
5711 return test_authenticated_decryption(&gcm_test_case_1);
5715 test_AES_GCM_authenticated_decryption_test_case_2(void)
5717 return test_authenticated_decryption(&gcm_test_case_2);
5721 test_AES_GCM_authenticated_decryption_test_case_3(void)
5723 return test_authenticated_decryption(&gcm_test_case_3);
5727 test_AES_GCM_authenticated_decryption_test_case_4(void)
5729 return test_authenticated_decryption(&gcm_test_case_4);
5733 test_AES_GCM_authenticated_decryption_test_case_5(void)
5735 return test_authenticated_decryption(&gcm_test_case_5);
5739 test_AES_GCM_authenticated_decryption_test_case_6(void)
5741 return test_authenticated_decryption(&gcm_test_case_6);
5745 test_AES_GCM_authenticated_decryption_test_case_7(void)
5747 return test_authenticated_decryption(&gcm_test_case_7);
5751 test_AES_GCM_auth_decryption_test_case_192_1(void)
5753 return test_authenticated_decryption(&gcm_test_case_192_1);
5757 test_AES_GCM_auth_decryption_test_case_192_2(void)
5759 return test_authenticated_decryption(&gcm_test_case_192_2);
5763 test_AES_GCM_auth_decryption_test_case_192_3(void)
5765 return test_authenticated_decryption(&gcm_test_case_192_3);
5769 test_AES_GCM_auth_decryption_test_case_192_4(void)
5771 return test_authenticated_decryption(&gcm_test_case_192_4);
5775 test_AES_GCM_auth_decryption_test_case_192_5(void)
5777 return test_authenticated_decryption(&gcm_test_case_192_5);
5781 test_AES_GCM_auth_decryption_test_case_192_6(void)
5783 return test_authenticated_decryption(&gcm_test_case_192_6);
5787 test_AES_GCM_auth_decryption_test_case_192_7(void)
5789 return test_authenticated_decryption(&gcm_test_case_192_7);
5793 test_AES_GCM_auth_decryption_test_case_256_1(void)
5795 return test_authenticated_decryption(&gcm_test_case_256_1);
5799 test_AES_GCM_auth_decryption_test_case_256_2(void)
5801 return test_authenticated_decryption(&gcm_test_case_256_2);
5805 test_AES_GCM_auth_decryption_test_case_256_3(void)
5807 return test_authenticated_decryption(&gcm_test_case_256_3);
5811 test_AES_GCM_auth_decryption_test_case_256_4(void)
5813 return test_authenticated_decryption(&gcm_test_case_256_4);
5817 test_AES_GCM_auth_decryption_test_case_256_5(void)
5819 return test_authenticated_decryption(&gcm_test_case_256_5);
5823 test_AES_GCM_auth_decryption_test_case_256_6(void)
5825 return test_authenticated_decryption(&gcm_test_case_256_6);
5829 test_AES_GCM_auth_decryption_test_case_256_7(void)
5831 return test_authenticated_decryption(&gcm_test_case_256_7);
5835 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5837 return test_authenticated_decryption(&gcm_test_case_aad_1);
5841 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5843 return test_authenticated_decryption(&gcm_test_case_aad_2);
5847 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5849 struct crypto_testsuite_params *ts_params = &testsuite_params;
5850 struct crypto_unittest_params *ut_params = &unittest_params;
5853 uint8_t *ciphertext, *auth_tag;
5854 uint16_t plaintext_pad_len;
5856 /* Create AEAD session */
5857 retval = create_aead_session(ts_params->valid_devs[0],
5859 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5860 tdata->key.data, tdata->key.len,
5861 tdata->aad.len, tdata->auth_tag.len,
5866 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5867 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5869 /* clear mbuf payload */
5870 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5871 rte_pktmbuf_tailroom(ut_params->ibuf));
5872 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5873 rte_pktmbuf_tailroom(ut_params->obuf));
5875 /* Create AEAD operation */
5876 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5880 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5882 ut_params->op->sym->m_src = ut_params->ibuf;
5883 ut_params->op->sym->m_dst = ut_params->obuf;
5885 /* Process crypto operation */
5886 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5887 ut_params->op), "failed to process sym crypto op");
5889 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5890 "crypto op processing failed");
5892 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5894 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5895 ut_params->op->sym->cipher.data.offset);
5896 auth_tag = ciphertext + plaintext_pad_len;
5898 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5899 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5902 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5904 tdata->ciphertext.data,
5905 tdata->ciphertext.len,
5906 "Ciphertext data not as expected");
5908 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5910 tdata->auth_tag.data,
5911 tdata->auth_tag.len,
5912 "Generated auth tag not as expected");
5919 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5921 return test_authenticated_encryption_oop(&gcm_test_case_5);
5925 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5927 struct crypto_testsuite_params *ts_params = &testsuite_params;
5928 struct crypto_unittest_params *ut_params = &unittest_params;
5933 /* Create AEAD session */
5934 retval = create_aead_session(ts_params->valid_devs[0],
5936 RTE_CRYPTO_AEAD_OP_DECRYPT,
5937 tdata->key.data, tdata->key.len,
5938 tdata->aad.len, tdata->auth_tag.len,
5943 /* alloc mbuf and set payload */
5944 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5945 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5947 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5948 rte_pktmbuf_tailroom(ut_params->ibuf));
5949 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5950 rte_pktmbuf_tailroom(ut_params->obuf));
5952 /* Create AEAD operation */
5953 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5957 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5959 ut_params->op->sym->m_src = ut_params->ibuf;
5960 ut_params->op->sym->m_dst = ut_params->obuf;
5962 /* Process crypto operation */
5963 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5964 ut_params->op), "failed to process sym crypto op");
5966 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5967 "crypto op processing failed");
5969 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5970 ut_params->op->sym->cipher.data.offset);
5972 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5975 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5977 tdata->plaintext.data,
5978 tdata->plaintext.len,
5979 "Plaintext data not as expected");
5981 TEST_ASSERT_EQUAL(ut_params->op->status,
5982 RTE_CRYPTO_OP_STATUS_SUCCESS,
5983 "Authentication failed");
5988 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5990 return test_authenticated_decryption_oop(&gcm_test_case_5);
5994 test_authenticated_encryption_sessionless(
5995 const struct aead_test_data *tdata)
5997 struct crypto_testsuite_params *ts_params = &testsuite_params;
5998 struct crypto_unittest_params *ut_params = &unittest_params;
6001 uint8_t *ciphertext, *auth_tag;
6002 uint16_t plaintext_pad_len;
6003 uint8_t key[tdata->key.len + 1];
6005 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6007 /* clear mbuf payload */
6008 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6009 rte_pktmbuf_tailroom(ut_params->ibuf));
6011 /* Create AEAD operation */
6012 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6016 /* Create GCM xform */
6017 memcpy(key, tdata->key.data, tdata->key.len);
6018 retval = create_aead_xform(ut_params->op,
6020 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6021 key, tdata->key.len,
6022 tdata->aad.len, tdata->auth_tag.len,
6027 ut_params->op->sym->m_src = ut_params->ibuf;
6029 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6030 RTE_CRYPTO_OP_SESSIONLESS,
6031 "crypto op session type not sessionless");
6033 /* Process crypto operation */
6034 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6035 ut_params->op), "failed to process sym crypto op");
6037 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6039 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6040 "crypto op status not success");
6042 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6044 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6045 ut_params->op->sym->cipher.data.offset);
6046 auth_tag = ciphertext + plaintext_pad_len;
6048 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6049 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6052 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6054 tdata->ciphertext.data,
6055 tdata->ciphertext.len,
6056 "Ciphertext data not as expected");
6058 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6060 tdata->auth_tag.data,
6061 tdata->auth_tag.len,
6062 "Generated auth tag not as expected");
6069 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6071 return test_authenticated_encryption_sessionless(
6076 test_authenticated_decryption_sessionless(
6077 const struct aead_test_data *tdata)
6079 struct crypto_testsuite_params *ts_params = &testsuite_params;
6080 struct crypto_unittest_params *ut_params = &unittest_params;
6084 uint8_t key[tdata->key.len + 1];
6086 /* alloc mbuf and set payload */
6087 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6089 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6090 rte_pktmbuf_tailroom(ut_params->ibuf));
6092 /* Create AEAD operation */
6093 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6097 /* Create AEAD xform */
6098 memcpy(key, tdata->key.data, tdata->key.len);
6099 retval = create_aead_xform(ut_params->op,
6101 RTE_CRYPTO_AEAD_OP_DECRYPT,
6102 key, tdata->key.len,
6103 tdata->aad.len, tdata->auth_tag.len,
6108 ut_params->op->sym->m_src = ut_params->ibuf;
6110 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6111 RTE_CRYPTO_OP_SESSIONLESS,
6112 "crypto op session type not sessionless");
6114 /* Process crypto operation */
6115 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6116 ut_params->op), "failed to process sym crypto op");
6118 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6120 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6121 "crypto op status not success");
6123 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6124 ut_params->op->sym->cipher.data.offset);
6126 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6129 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6131 tdata->plaintext.data,
6132 tdata->plaintext.len,
6133 "Plaintext data not as expected");
6135 TEST_ASSERT_EQUAL(ut_params->op->status,
6136 RTE_CRYPTO_OP_STATUS_SUCCESS,
6137 "Authentication failed");
6142 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6144 return test_authenticated_decryption_sessionless(
6149 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6151 return test_authenticated_encryption(&ccm_test_case_128_1);
6155 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6157 return test_authenticated_encryption(&ccm_test_case_128_2);
6161 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6163 return test_authenticated_encryption(&ccm_test_case_128_3);
6167 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6169 return test_authenticated_decryption(&ccm_test_case_128_1);
6173 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6175 return test_authenticated_decryption(&ccm_test_case_128_2);
6179 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6181 return test_authenticated_decryption(&ccm_test_case_128_3);
6185 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6187 return test_authenticated_encryption(&ccm_test_case_192_1);
6191 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6193 return test_authenticated_encryption(&ccm_test_case_192_2);
6197 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6199 return test_authenticated_encryption(&ccm_test_case_192_3);
6203 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6205 return test_authenticated_decryption(&ccm_test_case_192_1);
6209 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6211 return test_authenticated_decryption(&ccm_test_case_192_2);
6215 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6217 return test_authenticated_decryption(&ccm_test_case_192_3);
6221 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6223 return test_authenticated_encryption(&ccm_test_case_256_1);
6227 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6229 return test_authenticated_encryption(&ccm_test_case_256_2);
6233 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6235 return test_authenticated_encryption(&ccm_test_case_256_3);
6239 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6241 return test_authenticated_decryption(&ccm_test_case_256_1);
6245 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6247 return test_authenticated_decryption(&ccm_test_case_256_2);
6251 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6253 return test_authenticated_decryption(&ccm_test_case_256_3);
6259 struct crypto_testsuite_params *ts_params = &testsuite_params;
6260 struct rte_cryptodev_stats stats;
6261 struct rte_cryptodev *dev;
6262 cryptodev_stats_get_t temp_pfn;
6264 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6265 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6266 &stats) == -ENODEV),
6267 "rte_cryptodev_stats_get invalid dev failed");
6268 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6269 "rte_cryptodev_stats_get invalid Param failed");
6270 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6271 temp_pfn = dev->dev_ops->stats_get;
6272 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6273 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6275 "rte_cryptodev_stats_get invalid Param failed");
6276 dev->dev_ops->stats_get = temp_pfn;
6278 /* Test expected values */
6280 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6282 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6284 "rte_cryptodev_stats_get failed");
6285 TEST_ASSERT((stats.enqueued_count == 1),
6286 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6287 TEST_ASSERT((stats.dequeued_count == 1),
6288 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6289 TEST_ASSERT((stats.enqueue_err_count == 0),
6290 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6291 TEST_ASSERT((stats.dequeue_err_count == 0),
6292 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6294 /* invalid device but should ignore and not reset device stats*/
6295 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6296 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6298 "rte_cryptodev_stats_get failed");
6299 TEST_ASSERT((stats.enqueued_count == 1),
6300 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6302 /* check that a valid reset clears stats */
6303 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6304 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6306 "rte_cryptodev_stats_get failed");
6307 TEST_ASSERT((stats.enqueued_count == 0),
6308 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6309 TEST_ASSERT((stats.dequeued_count == 0),
6310 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6312 return TEST_SUCCESS;
6315 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6316 struct crypto_unittest_params *ut_params,
6317 enum rte_crypto_auth_operation op,
6318 const struct HMAC_MD5_vector *test_case)
6322 memcpy(key, test_case->key.data, test_case->key.len);
6324 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6325 ut_params->auth_xform.next = NULL;
6326 ut_params->auth_xform.auth.op = op;
6328 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6330 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6331 ut_params->auth_xform.auth.key.length = test_case->key.len;
6332 ut_params->auth_xform.auth.key.data = key;
6334 ut_params->sess = rte_cryptodev_sym_session_create(
6335 ts_params->session_mpool);
6337 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6338 ut_params->sess, &ut_params->auth_xform,
6339 ts_params->session_mpool);
6341 if (ut_params->sess == NULL)
6344 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6346 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6347 rte_pktmbuf_tailroom(ut_params->ibuf));
6352 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6353 const struct HMAC_MD5_vector *test_case,
6354 uint8_t **plaintext)
6356 uint16_t plaintext_pad_len;
6358 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6360 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6363 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6365 memcpy(*plaintext, test_case->plaintext.data,
6366 test_case->plaintext.len);
6368 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6369 ut_params->ibuf, MD5_DIGEST_LEN);
6370 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6371 "no room to append digest");
6372 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6373 ut_params->ibuf, plaintext_pad_len);
6375 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6376 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6377 test_case->auth_tag.len);
6380 sym_op->auth.data.offset = 0;
6381 sym_op->auth.data.length = test_case->plaintext.len;
6383 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6384 ut_params->op->sym->m_src = ut_params->ibuf;
6390 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6392 uint16_t plaintext_pad_len;
6393 uint8_t *plaintext, *auth_tag;
6395 struct crypto_testsuite_params *ts_params = &testsuite_params;
6396 struct crypto_unittest_params *ut_params = &unittest_params;
6398 if (MD5_HMAC_create_session(ts_params, ut_params,
6399 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6402 /* Generate Crypto op data structure */
6403 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6404 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6405 TEST_ASSERT_NOT_NULL(ut_params->op,
6406 "Failed to allocate symmetric crypto operation struct");
6408 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6411 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6414 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6415 ut_params->op), "failed to process sym crypto op");
6417 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6418 "crypto op processing failed");
6420 if (ut_params->op->sym->m_dst) {
6421 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6422 uint8_t *, plaintext_pad_len);
6424 auth_tag = plaintext + plaintext_pad_len;
6427 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6429 test_case->auth_tag.data,
6430 test_case->auth_tag.len,
6431 "HMAC_MD5 generated tag not as expected");
6433 return TEST_SUCCESS;
6437 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6441 struct crypto_testsuite_params *ts_params = &testsuite_params;
6442 struct crypto_unittest_params *ut_params = &unittest_params;
6444 if (MD5_HMAC_create_session(ts_params, ut_params,
6445 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6449 /* Generate Crypto op data structure */
6450 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6451 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6452 TEST_ASSERT_NOT_NULL(ut_params->op,
6453 "Failed to allocate symmetric crypto operation struct");
6455 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6458 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6459 ut_params->op), "failed to process sym crypto op");
6461 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6462 "HMAC_MD5 crypto op processing failed");
6464 return TEST_SUCCESS;
6468 test_MD5_HMAC_generate_case_1(void)
6470 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6474 test_MD5_HMAC_verify_case_1(void)
6476 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6480 test_MD5_HMAC_generate_case_2(void)
6482 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6486 test_MD5_HMAC_verify_case_2(void)
6488 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6492 test_multi_session(void)
6494 struct crypto_testsuite_params *ts_params = &testsuite_params;
6495 struct crypto_unittest_params *ut_params = &unittest_params;
6497 struct rte_cryptodev_info dev_info;
6498 struct rte_cryptodev_sym_session **sessions;
6502 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6503 aes_cbc_key, hmac_sha512_key);
6506 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6508 sessions = rte_malloc(NULL,
6509 (sizeof(struct rte_cryptodev_sym_session *) *
6510 MAX_NB_SESSIONS) + 1, 0);
6512 /* Create multiple crypto sessions*/
6513 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6515 sessions[i] = rte_cryptodev_sym_session_create(
6516 ts_params->session_mpool);
6518 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6519 sessions[i], &ut_params->auth_xform,
6520 ts_params->session_mpool);
6521 TEST_ASSERT_NOT_NULL(sessions[i],
6522 "Session creation failed at session number %u",
6525 /* Attempt to send a request on each session */
6526 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6530 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6531 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6533 "Failed to perform decrypt on request number %u.", i);
6534 /* free crypto operation structure */
6536 rte_crypto_op_free(ut_params->op);
6539 * free mbuf - both obuf and ibuf are usually the same,
6540 * so check if they point at the same address is necessary,
6541 * to avoid freeing the mbuf twice.
6543 if (ut_params->obuf) {
6544 rte_pktmbuf_free(ut_params->obuf);
6545 if (ut_params->ibuf == ut_params->obuf)
6546 ut_params->ibuf = 0;
6547 ut_params->obuf = 0;
6549 if (ut_params->ibuf) {
6550 rte_pktmbuf_free(ut_params->ibuf);
6551 ut_params->ibuf = 0;
6555 /* Next session create should fail */
6556 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6557 sessions[i], &ut_params->auth_xform,
6558 ts_params->session_mpool);
6559 TEST_ASSERT_NULL(sessions[i],
6560 "Session creation succeeded unexpectedly!");
6562 for (i = 0; i < MAX_NB_SESSIONS; i++) {
6563 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6565 rte_cryptodev_sym_session_free(sessions[i]);
6570 return TEST_SUCCESS;
6573 struct multi_session_params {
6574 struct crypto_unittest_params ut_params;
6575 uint8_t *cipher_key;
6577 const uint8_t *cipher;
6578 const uint8_t *digest;
6582 #define MB_SESSION_NUMBER 3
6585 test_multi_session_random_usage(void)
6587 struct crypto_testsuite_params *ts_params = &testsuite_params;
6588 struct rte_cryptodev_info dev_info;
6589 struct rte_cryptodev_sym_session **sessions;
6591 struct multi_session_params ut_paramz[] = {
6594 .cipher_key = ms_aes_cbc_key0,
6595 .hmac_key = ms_hmac_key0,
6596 .cipher = ms_aes_cbc_cipher0,
6597 .digest = ms_hmac_digest0,
6598 .iv = ms_aes_cbc_iv0
6601 .cipher_key = ms_aes_cbc_key1,
6602 .hmac_key = ms_hmac_key1,
6603 .cipher = ms_aes_cbc_cipher1,
6604 .digest = ms_hmac_digest1,
6605 .iv = ms_aes_cbc_iv1
6608 .cipher_key = ms_aes_cbc_key2,
6609 .hmac_key = ms_hmac_key2,
6610 .cipher = ms_aes_cbc_cipher2,
6611 .digest = ms_hmac_digest2,
6612 .iv = ms_aes_cbc_iv2
6617 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6619 sessions = rte_malloc(NULL,
6620 (sizeof(struct rte_cryptodev_sym_session *)
6621 * MAX_NB_SESSIONS) + 1, 0);
6623 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6624 sessions[i] = rte_cryptodev_sym_session_create(
6625 ts_params->session_mpool);
6627 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6628 sizeof(struct crypto_unittest_params));
6630 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6631 &ut_paramz[i].ut_params,
6632 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6634 /* Create multiple crypto sessions*/
6635 rte_cryptodev_sym_session_init(
6636 ts_params->valid_devs[0],
6638 &ut_paramz[i].ut_params.auth_xform,
6639 ts_params->session_mpool);
6641 TEST_ASSERT_NOT_NULL(sessions[i],
6642 "Session creation failed at session number %u",
6648 for (i = 0; i < 40000; i++) {
6650 j = rand() % MB_SESSION_NUMBER;
6652 TEST_ASSERT_SUCCESS(
6653 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6655 &ut_paramz[j].ut_params,
6656 ts_params, ut_paramz[j].cipher,
6657 ut_paramz[j].digest,
6659 "Failed to perform decrypt on request number %u.", i);
6661 if (ut_paramz[j].ut_params.op)
6662 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6665 * free mbuf - both obuf and ibuf are usually the same,
6666 * so check if they point at the same address is necessary,
6667 * to avoid freeing the mbuf twice.
6669 if (ut_paramz[j].ut_params.obuf) {
6670 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6671 if (ut_paramz[j].ut_params.ibuf
6672 == ut_paramz[j].ut_params.obuf)
6673 ut_paramz[j].ut_params.ibuf = 0;
6674 ut_paramz[j].ut_params.obuf = 0;
6676 if (ut_paramz[j].ut_params.ibuf) {
6677 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6678 ut_paramz[j].ut_params.ibuf = 0;
6682 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6683 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6685 rte_cryptodev_sym_session_free(sessions[i]);
6690 return TEST_SUCCESS;
6694 test_null_cipher_only_operation(void)
6696 struct crypto_testsuite_params *ts_params = &testsuite_params;
6697 struct crypto_unittest_params *ut_params = &unittest_params;
6699 /* Generate test mbuf data and space for digest */
6700 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6701 catch_22_quote, QUOTE_512_BYTES, 0);
6703 /* Setup Cipher Parameters */
6704 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6705 ut_params->cipher_xform.next = NULL;
6707 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6708 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6710 ut_params->sess = rte_cryptodev_sym_session_create(
6711 ts_params->session_mpool);
6713 /* Create Crypto session*/
6714 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6716 &ut_params->cipher_xform,
6717 ts_params->session_mpool);
6718 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6720 /* Generate Crypto op data structure */
6721 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6722 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6723 TEST_ASSERT_NOT_NULL(ut_params->op,
6724 "Failed to allocate symmetric crypto operation struct");
6726 /* Set crypto operation data parameters */
6727 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6729 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6731 /* set crypto operation source mbuf */
6732 sym_op->m_src = ut_params->ibuf;
6734 sym_op->cipher.data.offset = 0;
6735 sym_op->cipher.data.length = QUOTE_512_BYTES;
6737 /* Process crypto operation */
6738 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6740 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6742 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6743 "crypto operation processing failed");
6746 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6747 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6750 "Ciphertext data not as expected");
6752 return TEST_SUCCESS;
6754 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6755 0xab, 0xab, 0xab, 0xab,
6756 0xab, 0xab, 0xab, 0xab,
6757 0xab, 0xab, 0xab, 0xab};
6759 test_null_auth_only_operation(void)
6761 struct crypto_testsuite_params *ts_params = &testsuite_params;
6762 struct crypto_unittest_params *ut_params = &unittest_params;
6765 /* Generate test mbuf data and space for digest */
6766 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6767 catch_22_quote, QUOTE_512_BYTES, 0);
6769 /* create a pointer for digest, but don't expect anything to be written
6770 * here in a NULL auth algo so no mbuf append done.
6772 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6774 /* prefill the memory pointed to by digest */
6775 memcpy(digest, orig_data, sizeof(orig_data));
6777 /* Setup HMAC Parameters */
6778 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6779 ut_params->auth_xform.next = NULL;
6781 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6782 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6784 ut_params->sess = rte_cryptodev_sym_session_create(
6785 ts_params->session_mpool);
6787 /* Create Crypto session*/
6788 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6789 ut_params->sess, &ut_params->auth_xform,
6790 ts_params->session_mpool);
6791 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6793 /* Generate Crypto op data structure */
6794 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6795 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6796 TEST_ASSERT_NOT_NULL(ut_params->op,
6797 "Failed to allocate symmetric crypto operation struct");
6799 /* Set crypto operation data parameters */
6800 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6802 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6804 sym_op->m_src = ut_params->ibuf;
6806 sym_op->auth.data.offset = 0;
6807 sym_op->auth.data.length = QUOTE_512_BYTES;
6808 sym_op->auth.digest.data = digest;
6809 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6812 /* Process crypto operation */
6813 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6815 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6817 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6818 "crypto operation processing failed");
6819 /* Make sure memory pointed to by digest hasn't been overwritten */
6820 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6824 "Memory at digest ptr overwritten unexpectedly");
6826 return TEST_SUCCESS;
6831 test_null_cipher_auth_operation(void)
6833 struct crypto_testsuite_params *ts_params = &testsuite_params;
6834 struct crypto_unittest_params *ut_params = &unittest_params;
6837 /* Generate test mbuf data and space for digest */
6838 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6839 catch_22_quote, QUOTE_512_BYTES, 0);
6841 /* create a pointer for digest, but don't expect anything to be written
6842 * here in a NULL auth algo so no mbuf append done.
6844 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6846 /* prefill the memory pointed to by digest */
6847 memcpy(digest, orig_data, sizeof(orig_data));
6849 /* Setup Cipher Parameters */
6850 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6851 ut_params->cipher_xform.next = &ut_params->auth_xform;
6853 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6854 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6856 /* Setup HMAC Parameters */
6857 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6858 ut_params->auth_xform.next = NULL;
6860 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6861 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6863 ut_params->sess = rte_cryptodev_sym_session_create(
6864 ts_params->session_mpool);
6866 /* Create Crypto session*/
6867 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6868 ut_params->sess, &ut_params->cipher_xform,
6869 ts_params->session_mpool);
6870 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6872 /* Generate Crypto op data structure */
6873 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6874 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6875 TEST_ASSERT_NOT_NULL(ut_params->op,
6876 "Failed to allocate symmetric crypto operation struct");
6878 /* Set crypto operation data parameters */
6879 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6881 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6883 sym_op->m_src = ut_params->ibuf;
6885 sym_op->cipher.data.offset = 0;
6886 sym_op->cipher.data.length = QUOTE_512_BYTES;
6888 sym_op->auth.data.offset = 0;
6889 sym_op->auth.data.length = QUOTE_512_BYTES;
6890 sym_op->auth.digest.data = digest;
6891 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6894 /* Process crypto operation */
6895 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6897 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6899 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6900 "crypto operation processing failed");
6903 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6904 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6907 "Ciphertext data not as expected");
6908 /* Make sure memory pointed to by digest hasn't been overwritten */
6909 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6913 "Memory at digest ptr overwritten unexpectedly");
6915 return TEST_SUCCESS;
6919 test_null_auth_cipher_operation(void)
6921 struct crypto_testsuite_params *ts_params = &testsuite_params;
6922 struct crypto_unittest_params *ut_params = &unittest_params;
6925 /* Generate test mbuf data */
6926 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6927 catch_22_quote, QUOTE_512_BYTES, 0);
6929 /* create a pointer for digest, but don't expect anything to be written
6930 * here in a NULL auth algo so no mbuf append done.
6932 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6934 /* prefill the memory pointed to by digest */
6935 memcpy(digest, orig_data, sizeof(orig_data));
6937 /* Setup Cipher Parameters */
6938 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6939 ut_params->cipher_xform.next = NULL;
6941 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6942 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6944 /* Setup HMAC Parameters */
6945 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6946 ut_params->auth_xform.next = &ut_params->cipher_xform;
6948 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6949 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6951 ut_params->sess = rte_cryptodev_sym_session_create(
6952 ts_params->session_mpool);
6954 /* Create Crypto session*/
6955 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6956 ut_params->sess, &ut_params->cipher_xform,
6957 ts_params->session_mpool);
6958 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6960 /* Generate Crypto op data structure */
6961 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6962 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6963 TEST_ASSERT_NOT_NULL(ut_params->op,
6964 "Failed to allocate symmetric crypto operation struct");
6966 /* Set crypto operation data parameters */
6967 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6969 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6971 sym_op->m_src = ut_params->ibuf;
6973 sym_op->cipher.data.offset = 0;
6974 sym_op->cipher.data.length = QUOTE_512_BYTES;
6976 sym_op->auth.data.offset = 0;
6977 sym_op->auth.data.length = QUOTE_512_BYTES;
6978 sym_op->auth.digest.data = digest;
6979 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6982 /* Process crypto operation */
6983 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6985 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6987 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6988 "crypto operation processing failed");
6991 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6992 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6995 "Ciphertext data not as expected");
6996 /* Make sure memory pointed to by digest hasn't been overwritten */
6997 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7001 "Memory at digest ptr overwritten unexpectedly");
7003 return TEST_SUCCESS;
7008 test_null_invalid_operation(void)
7010 struct crypto_testsuite_params *ts_params = &testsuite_params;
7011 struct crypto_unittest_params *ut_params = &unittest_params;
7014 /* Setup Cipher Parameters */
7015 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7016 ut_params->cipher_xform.next = NULL;
7018 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7019 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7021 ut_params->sess = rte_cryptodev_sym_session_create(
7022 ts_params->session_mpool);
7024 /* Create Crypto session*/
7025 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7026 ut_params->sess, &ut_params->cipher_xform,
7027 ts_params->session_mpool);
7028 TEST_ASSERT(ret < 0,
7029 "Session creation succeeded unexpectedly");
7032 /* Setup HMAC Parameters */
7033 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7034 ut_params->auth_xform.next = NULL;
7036 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7037 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7039 ut_params->sess = rte_cryptodev_sym_session_create(
7040 ts_params->session_mpool);
7042 /* Create Crypto session*/
7043 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7044 ut_params->sess, &ut_params->auth_xform,
7045 ts_params->session_mpool);
7046 TEST_ASSERT(ret < 0,
7047 "Session creation succeeded unexpectedly");
7049 return TEST_SUCCESS;
7053 #define NULL_BURST_LENGTH (32)
7056 test_null_burst_operation(void)
7058 struct crypto_testsuite_params *ts_params = &testsuite_params;
7059 struct crypto_unittest_params *ut_params = &unittest_params;
7061 unsigned i, burst_len = NULL_BURST_LENGTH;
7063 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7064 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7066 /* Setup Cipher Parameters */
7067 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7068 ut_params->cipher_xform.next = &ut_params->auth_xform;
7070 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7071 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7073 /* Setup HMAC Parameters */
7074 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7075 ut_params->auth_xform.next = NULL;
7077 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7078 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7080 ut_params->sess = rte_cryptodev_sym_session_create(
7081 ts_params->session_mpool);
7083 /* Create Crypto session*/
7084 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7085 ut_params->sess, &ut_params->cipher_xform,
7086 ts_params->session_mpool);
7087 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7089 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7090 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7091 burst_len, "failed to generate burst of crypto ops");
7093 /* Generate an operation for each mbuf in burst */
7094 for (i = 0; i < burst_len; i++) {
7095 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7097 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7099 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7103 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7105 burst[i]->sym->m_src = m;
7108 /* Process crypto operation */
7109 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7110 0, burst, burst_len),
7112 "Error enqueuing burst");
7114 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7115 0, burst_dequeued, burst_len),
7117 "Error dequeuing burst");
7120 for (i = 0; i < burst_len; i++) {
7122 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7123 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7125 "data not as expected");
7127 rte_pktmbuf_free(burst[i]->sym->m_src);
7128 rte_crypto_op_free(burst[i]);
7131 return TEST_SUCCESS;
7135 generate_gmac_large_plaintext(uint8_t *data)
7139 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7140 memcpy(&data[i], &data[0], 32);
7144 create_gmac_operation(enum rte_crypto_auth_operation op,
7145 const struct gmac_test_data *tdata)
7147 struct crypto_testsuite_params *ts_params = &testsuite_params;
7148 struct crypto_unittest_params *ut_params = &unittest_params;
7149 struct rte_crypto_sym_op *sym_op;
7151 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7153 /* Generate Crypto op data structure */
7154 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7155 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7156 TEST_ASSERT_NOT_NULL(ut_params->op,
7157 "Failed to allocate symmetric crypto operation struct");
7159 sym_op = ut_params->op->sym;
7161 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7162 ut_params->ibuf, tdata->gmac_tag.len);
7163 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7164 "no room to append digest");
7166 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7167 ut_params->ibuf, plaintext_pad_len);
7169 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7170 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7171 tdata->gmac_tag.len);
7172 debug_hexdump(stdout, "digest:",
7173 sym_op->auth.digest.data,
7174 tdata->gmac_tag.len);
7177 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7178 uint8_t *, IV_OFFSET);
7180 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7182 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7184 sym_op->cipher.data.length = 0;
7185 sym_op->cipher.data.offset = 0;
7187 sym_op->auth.data.offset = 0;
7188 sym_op->auth.data.length = tdata->plaintext.len;
7193 static int create_gmac_session(uint8_t dev_id,
7194 const struct gmac_test_data *tdata,
7195 enum rte_crypto_auth_operation auth_op)
7197 uint8_t auth_key[tdata->key.len];
7199 struct crypto_testsuite_params *ts_params = &testsuite_params;
7200 struct crypto_unittest_params *ut_params = &unittest_params;
7202 memcpy(auth_key, tdata->key.data, tdata->key.len);
7204 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7205 ut_params->auth_xform.next = NULL;
7207 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7208 ut_params->auth_xform.auth.op = auth_op;
7209 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7210 ut_params->auth_xform.auth.key.length = tdata->key.len;
7211 ut_params->auth_xform.auth.key.data = auth_key;
7212 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7213 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7216 ut_params->sess = rte_cryptodev_sym_session_create(
7217 ts_params->session_mpool);
7219 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7220 &ut_params->auth_xform,
7221 ts_params->session_mpool);
7223 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7229 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7231 struct crypto_testsuite_params *ts_params = &testsuite_params;
7232 struct crypto_unittest_params *ut_params = &unittest_params;
7236 uint8_t *auth_tag, *plaintext;
7237 uint16_t plaintext_pad_len;
7239 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7240 "No GMAC length in the source data");
7242 retval = create_gmac_session(ts_params->valid_devs[0],
7243 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7248 if (tdata->plaintext.len > MBUF_SIZE)
7249 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7251 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7252 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7253 "Failed to allocate input buffer in mempool");
7255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7256 rte_pktmbuf_tailroom(ut_params->ibuf));
7258 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7260 * Runtime generate the large plain text instead of use hard code
7261 * plain text vector. It is done to avoid create huge source file
7262 * with the test vector.
7264 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7265 generate_gmac_large_plaintext(tdata->plaintext.data);
7267 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7269 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7271 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7272 debug_hexdump(stdout, "plaintext:", plaintext,
7273 tdata->plaintext.len);
7275 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7281 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7283 ut_params->op->sym->m_src = ut_params->ibuf;
7285 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7286 ut_params->op), "failed to process sym crypto op");
7288 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7289 "crypto op processing failed");
7291 if (ut_params->op->sym->m_dst) {
7292 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7293 uint8_t *, plaintext_pad_len);
7295 auth_tag = plaintext + plaintext_pad_len;
7298 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7300 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7302 tdata->gmac_tag.data,
7303 tdata->gmac_tag.len,
7304 "GMAC Generated auth tag not as expected");
7310 test_AES_GMAC_authentication_test_case_1(void)
7312 return test_AES_GMAC_authentication(&gmac_test_case_1);
7316 test_AES_GMAC_authentication_test_case_2(void)
7318 return test_AES_GMAC_authentication(&gmac_test_case_2);
7322 test_AES_GMAC_authentication_test_case_3(void)
7324 return test_AES_GMAC_authentication(&gmac_test_case_3);
7328 test_AES_GMAC_authentication_test_case_4(void)
7330 return test_AES_GMAC_authentication(&gmac_test_case_4);
7334 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7336 struct crypto_testsuite_params *ts_params = &testsuite_params;
7337 struct crypto_unittest_params *ut_params = &unittest_params;
7339 uint32_t plaintext_pad_len;
7342 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7343 "No GMAC length in the source data");
7345 retval = create_gmac_session(ts_params->valid_devs[0],
7346 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7351 if (tdata->plaintext.len > MBUF_SIZE)
7352 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7354 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7355 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7356 "Failed to allocate input buffer in mempool");
7358 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7359 rte_pktmbuf_tailroom(ut_params->ibuf));
7361 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7364 * Runtime generate the large plain text instead of use hard code
7365 * plain text vector. It is done to avoid create huge source file
7366 * with the test vector.
7368 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7369 generate_gmac_large_plaintext(tdata->plaintext.data);
7371 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7373 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7375 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7376 debug_hexdump(stdout, "plaintext:", plaintext,
7377 tdata->plaintext.len);
7379 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7385 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7387 ut_params->op->sym->m_src = ut_params->ibuf;
7389 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7390 ut_params->op), "failed to process sym crypto op");
7392 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7393 "crypto op processing failed");
7400 test_AES_GMAC_authentication_verify_test_case_1(void)
7402 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7406 test_AES_GMAC_authentication_verify_test_case_2(void)
7408 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7412 test_AES_GMAC_authentication_verify_test_case_3(void)
7414 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7418 test_AES_GMAC_authentication_verify_test_case_4(void)
7420 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7423 struct test_crypto_vector {
7424 enum rte_crypto_cipher_algorithm crypto_algo;
7437 const uint8_t *data;
7442 const uint8_t *data;
7446 enum rte_crypto_auth_algorithm auth_algo;
7454 const uint8_t *data;
7464 static const struct test_crypto_vector
7465 hmac_sha1_test_crypto_vector = {
7466 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7468 .data = plaintext_hash,
7473 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7474 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7475 0xDE, 0xF4, 0xDE, 0xAD
7481 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7482 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7483 0x3F, 0x91, 0x64, 0x59
7489 static const struct test_crypto_vector
7490 aes128_gmac_test_vector = {
7491 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7493 .data = plaintext_hash,
7498 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7499 0x08, 0x09, 0x0A, 0x0B
7505 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7506 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7512 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7513 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7519 static const struct test_crypto_vector
7520 aes128cbc_hmac_sha1_test_vector = {
7521 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7524 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7525 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7531 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7532 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7537 .data = plaintext_hash,
7541 .data = ciphertext512_aes128cbc,
7544 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7547 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7548 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7549 0xDE, 0xF4, 0xDE, 0xAD
7555 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7556 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7557 0x18, 0x8C, 0x1D, 0x32
7564 data_corruption(uint8_t *data)
7570 tag_corruption(uint8_t *data, unsigned int tag_offset)
7572 data[tag_offset] += 1;
7576 create_auth_session(struct crypto_unittest_params *ut_params,
7578 const struct test_crypto_vector *reference,
7579 enum rte_crypto_auth_operation auth_op)
7581 struct crypto_testsuite_params *ts_params = &testsuite_params;
7582 uint8_t auth_key[reference->auth_key.len + 1];
7584 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7586 /* Setup Authentication Parameters */
7587 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7588 ut_params->auth_xform.auth.op = auth_op;
7589 ut_params->auth_xform.next = NULL;
7590 ut_params->auth_xform.auth.algo = reference->auth_algo;
7591 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7592 ut_params->auth_xform.auth.key.data = auth_key;
7593 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7595 /* Create Crypto session*/
7596 ut_params->sess = rte_cryptodev_sym_session_create(
7597 ts_params->session_mpool);
7599 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7600 &ut_params->auth_xform,
7601 ts_params->session_mpool);
7603 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7609 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7611 const struct test_crypto_vector *reference,
7612 enum rte_crypto_auth_operation auth_op,
7613 enum rte_crypto_cipher_operation cipher_op)
7615 struct crypto_testsuite_params *ts_params = &testsuite_params;
7616 uint8_t cipher_key[reference->cipher_key.len + 1];
7617 uint8_t auth_key[reference->auth_key.len + 1];
7619 memcpy(cipher_key, reference->cipher_key.data,
7620 reference->cipher_key.len);
7621 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7623 /* Setup Authentication Parameters */
7624 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7625 ut_params->auth_xform.auth.op = auth_op;
7626 ut_params->auth_xform.auth.algo = reference->auth_algo;
7627 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7628 ut_params->auth_xform.auth.key.data = auth_key;
7629 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7631 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7632 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7633 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7635 ut_params->auth_xform.next = &ut_params->cipher_xform;
7637 /* Setup Cipher Parameters */
7638 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7639 ut_params->cipher_xform.next = NULL;
7640 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7641 ut_params->cipher_xform.cipher.op = cipher_op;
7642 ut_params->cipher_xform.cipher.key.data = cipher_key;
7643 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7644 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7645 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7648 /* Create Crypto session*/
7649 ut_params->sess = rte_cryptodev_sym_session_create(
7650 ts_params->session_mpool);
7652 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7653 &ut_params->auth_xform,
7654 ts_params->session_mpool);
7656 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7662 create_auth_operation(struct crypto_testsuite_params *ts_params,
7663 struct crypto_unittest_params *ut_params,
7664 const struct test_crypto_vector *reference,
7665 unsigned int auth_generate)
7667 /* Generate Crypto op data structure */
7668 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7669 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7670 TEST_ASSERT_NOT_NULL(ut_params->op,
7671 "Failed to allocate pktmbuf offload");
7673 /* Set crypto operation data parameters */
7674 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7676 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7678 /* set crypto operation source mbuf */
7679 sym_op->m_src = ut_params->ibuf;
7682 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7683 ut_params->ibuf, reference->digest.len);
7685 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7686 "no room to append auth tag");
7688 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7689 ut_params->ibuf, reference->plaintext.len);
7692 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7694 memcpy(sym_op->auth.digest.data,
7695 reference->digest.data,
7696 reference->digest.len);
7698 debug_hexdump(stdout, "digest:",
7699 sym_op->auth.digest.data,
7700 reference->digest.len);
7702 sym_op->auth.data.length = reference->plaintext.len;
7703 sym_op->auth.data.offset = 0;
7709 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7710 struct crypto_unittest_params *ut_params,
7711 const struct test_crypto_vector *reference,
7712 unsigned int auth_generate)
7714 /* Generate Crypto op data structure */
7715 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7716 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7717 TEST_ASSERT_NOT_NULL(ut_params->op,
7718 "Failed to allocate pktmbuf offload");
7720 /* Set crypto operation data parameters */
7721 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7723 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7725 /* set crypto operation source mbuf */
7726 sym_op->m_src = ut_params->ibuf;
7729 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7730 ut_params->ibuf, reference->digest.len);
7732 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7733 "no room to append auth tag");
7735 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7736 ut_params->ibuf, reference->ciphertext.len);
7739 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7741 memcpy(sym_op->auth.digest.data,
7742 reference->digest.data,
7743 reference->digest.len);
7745 debug_hexdump(stdout, "digest:",
7746 sym_op->auth.digest.data,
7747 reference->digest.len);
7749 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7750 reference->iv.data, reference->iv.len);
7752 sym_op->cipher.data.length = 0;
7753 sym_op->cipher.data.offset = 0;
7755 sym_op->auth.data.length = reference->plaintext.len;
7756 sym_op->auth.data.offset = 0;
7762 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7763 struct crypto_unittest_params *ut_params,
7764 const struct test_crypto_vector *reference,
7765 unsigned int auth_generate)
7767 /* Generate Crypto op data structure */
7768 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7769 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7770 TEST_ASSERT_NOT_NULL(ut_params->op,
7771 "Failed to allocate pktmbuf offload");
7773 /* Set crypto operation data parameters */
7774 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7776 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7778 /* set crypto operation source mbuf */
7779 sym_op->m_src = ut_params->ibuf;
7782 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7783 ut_params->ibuf, reference->digest.len);
7785 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7786 "no room to append auth tag");
7788 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7789 ut_params->ibuf, reference->ciphertext.len);
7792 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7794 memcpy(sym_op->auth.digest.data,
7795 reference->digest.data,
7796 reference->digest.len);
7798 debug_hexdump(stdout, "digest:",
7799 sym_op->auth.digest.data,
7800 reference->digest.len);
7802 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7803 reference->iv.data, reference->iv.len);
7805 sym_op->cipher.data.length = reference->ciphertext.len;
7806 sym_op->cipher.data.offset = 0;
7808 sym_op->auth.data.length = reference->ciphertext.len;
7809 sym_op->auth.data.offset = 0;
7815 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7816 struct crypto_unittest_params *ut_params,
7817 const struct test_crypto_vector *reference)
7819 return create_auth_operation(ts_params, ut_params, reference, 0);
7823 create_auth_verify_GMAC_operation(
7824 struct crypto_testsuite_params *ts_params,
7825 struct crypto_unittest_params *ut_params,
7826 const struct test_crypto_vector *reference)
7828 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7832 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7833 struct crypto_unittest_params *ut_params,
7834 const struct test_crypto_vector *reference)
7836 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7840 test_authentication_verify_fail_when_data_corruption(
7841 struct crypto_testsuite_params *ts_params,
7842 struct crypto_unittest_params *ut_params,
7843 const struct test_crypto_vector *reference,
7844 unsigned int data_corrupted)
7850 /* Create session */
7851 retval = create_auth_session(ut_params,
7852 ts_params->valid_devs[0],
7854 RTE_CRYPTO_AUTH_OP_VERIFY);
7858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7859 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7860 "Failed to allocate input buffer in mempool");
7862 /* clear mbuf payload */
7863 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7864 rte_pktmbuf_tailroom(ut_params->ibuf));
7866 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7867 reference->plaintext.len);
7868 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7869 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7871 debug_hexdump(stdout, "plaintext:", plaintext,
7872 reference->plaintext.len);
7874 /* Create operation */
7875 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7881 data_corruption(plaintext);
7883 tag_corruption(plaintext, reference->plaintext.len);
7885 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7887 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7888 TEST_ASSERT_EQUAL(ut_params->op->status,
7889 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7890 "authentication not failed");
7892 ut_params->obuf = ut_params->op->sym->m_src;
7893 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7899 test_authentication_verify_GMAC_fail_when_corruption(
7900 struct crypto_testsuite_params *ts_params,
7901 struct crypto_unittest_params *ut_params,
7902 const struct test_crypto_vector *reference,
7903 unsigned int data_corrupted)
7908 /* Create session */
7909 retval = create_auth_cipher_session(ut_params,
7910 ts_params->valid_devs[0],
7912 RTE_CRYPTO_AUTH_OP_VERIFY,
7913 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7917 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7918 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7919 "Failed to allocate input buffer in mempool");
7921 /* clear mbuf payload */
7922 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7923 rte_pktmbuf_tailroom(ut_params->ibuf));
7925 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7926 reference->plaintext.len);
7927 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7928 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7930 debug_hexdump(stdout, "plaintext:", plaintext,
7931 reference->plaintext.len);
7933 /* Create operation */
7934 retval = create_auth_verify_GMAC_operation(ts_params,
7942 data_corruption(plaintext);
7944 tag_corruption(plaintext, reference->aad.len);
7946 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7948 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7949 TEST_ASSERT_EQUAL(ut_params->op->status,
7950 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7951 "authentication not failed");
7953 ut_params->obuf = ut_params->op->sym->m_src;
7954 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7960 test_authenticated_decryption_fail_when_corruption(
7961 struct crypto_testsuite_params *ts_params,
7962 struct crypto_unittest_params *ut_params,
7963 const struct test_crypto_vector *reference,
7964 unsigned int data_corrupted)
7968 uint8_t *ciphertext;
7970 /* Create session */
7971 retval = create_auth_cipher_session(ut_params,
7972 ts_params->valid_devs[0],
7974 RTE_CRYPTO_AUTH_OP_VERIFY,
7975 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7979 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7980 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7981 "Failed to allocate input buffer in mempool");
7983 /* clear mbuf payload */
7984 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7985 rte_pktmbuf_tailroom(ut_params->ibuf));
7987 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7988 reference->ciphertext.len);
7989 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7990 memcpy(ciphertext, reference->ciphertext.data,
7991 reference->ciphertext.len);
7993 /* Create operation */
7994 retval = create_cipher_auth_verify_operation(ts_params,
8002 data_corruption(ciphertext);
8004 tag_corruption(ciphertext, reference->ciphertext.len);
8006 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8009 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8010 TEST_ASSERT_EQUAL(ut_params->op->status,
8011 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8012 "authentication not failed");
8014 ut_params->obuf = ut_params->op->sym->m_src;
8015 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8021 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8022 const struct aead_test_data *tdata,
8023 void *digest_mem, uint64_t digest_phys)
8025 struct crypto_testsuite_params *ts_params = &testsuite_params;
8026 struct crypto_unittest_params *ut_params = &unittest_params;
8028 const unsigned int auth_tag_len = tdata->auth_tag.len;
8029 const unsigned int iv_len = tdata->iv.len;
8030 unsigned int aad_len = tdata->aad.len;
8032 /* Generate Crypto op data structure */
8033 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8034 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8035 TEST_ASSERT_NOT_NULL(ut_params->op,
8036 "Failed to allocate symmetric crypto operation struct");
8038 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8040 sym_op->aead.digest.data = digest_mem;
8042 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8043 "no room to append digest");
8045 sym_op->aead.digest.phys_addr = digest_phys;
8047 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8048 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8050 debug_hexdump(stdout, "digest:",
8051 sym_op->aead.digest.data,
8055 /* Append aad data */
8056 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8057 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8058 uint8_t *, IV_OFFSET);
8060 /* Copy IV 1 byte after the IV pointer, according to the API */
8061 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8063 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8065 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8066 ut_params->ibuf, aad_len);
8067 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8068 "no room to prepend aad");
8069 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8072 memset(sym_op->aead.aad.data, 0, aad_len);
8073 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8074 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8076 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8077 debug_hexdump(stdout, "aad:",
8078 sym_op->aead.aad.data, aad_len);
8080 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8081 uint8_t *, IV_OFFSET);
8083 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8085 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8086 ut_params->ibuf, aad_len);
8087 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8088 "no room to prepend aad");
8089 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8092 memset(sym_op->aead.aad.data, 0, aad_len);
8093 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8095 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8096 debug_hexdump(stdout, "aad:",
8097 sym_op->aead.aad.data, aad_len);
8100 sym_op->aead.data.length = tdata->plaintext.len;
8101 sym_op->aead.data.offset = aad_len;
8106 #define SGL_MAX_NO 16
8109 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8110 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8112 struct crypto_testsuite_params *ts_params = &testsuite_params;
8113 struct crypto_unittest_params *ut_params = &unittest_params;
8114 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8117 int to_trn_tbl[SGL_MAX_NO];
8119 unsigned int trn_data = 0;
8120 uint8_t *plaintext, *ciphertext, *auth_tag;
8122 if (fragsz > tdata->plaintext.len)
8123 fragsz = tdata->plaintext.len;
8125 uint16_t plaintext_len = fragsz;
8126 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8128 if (fragsz_oop > tdata->plaintext.len)
8129 frag_size_oop = tdata->plaintext.len;
8132 void *digest_mem = NULL;
8134 uint32_t prepend_len = tdata->aad.len;
8136 if (tdata->plaintext.len % fragsz != 0) {
8137 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8140 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8145 * For out-op-place we need to alloc another mbuf
8148 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8149 rte_pktmbuf_append(ut_params->obuf,
8150 frag_size_oop + prepend_len);
8151 buf_oop = ut_params->obuf;
8154 /* Create AEAD session */
8155 retval = create_aead_session(ts_params->valid_devs[0],
8157 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8158 tdata->key.data, tdata->key.len,
8159 tdata->aad.len, tdata->auth_tag.len,
8164 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8166 /* clear mbuf payload */
8167 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8168 rte_pktmbuf_tailroom(ut_params->ibuf));
8170 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8173 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8175 trn_data += plaintext_len;
8177 buf = ut_params->ibuf;
8180 * Loop until no more fragments
8183 while (trn_data < tdata->plaintext.len) {
8185 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8186 (tdata->plaintext.len - trn_data) : fragsz;
8188 to_trn_tbl[ecx++] = to_trn;
8190 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8193 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8194 rte_pktmbuf_tailroom(buf));
8197 if (oop && !fragsz_oop) {
8198 buf_last_oop = buf_oop->next =
8199 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8200 buf_oop = buf_oop->next;
8201 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8202 0, rte_pktmbuf_tailroom(buf_oop));
8203 rte_pktmbuf_append(buf_oop, to_trn);
8206 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8209 memcpy(plaintext, tdata->plaintext.data + trn_data,
8212 if (trn_data == tdata->plaintext.len) {
8215 digest_mem = rte_pktmbuf_append(buf_oop,
8216 tdata->auth_tag.len);
8218 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8219 tdata->auth_tag.len);
8223 uint64_t digest_phys = 0;
8225 ut_params->ibuf->nb_segs = segs;
8228 if (fragsz_oop && oop) {
8232 if (frag_size_oop == tdata->plaintext.len) {
8233 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8234 tdata->auth_tag.len);
8236 digest_phys = rte_pktmbuf_iova_offset(
8238 tdata->plaintext.len + prepend_len);
8241 trn_data = frag_size_oop;
8242 while (trn_data < tdata->plaintext.len) {
8245 (tdata->plaintext.len - trn_data <
8247 (tdata->plaintext.len - trn_data) :
8250 to_trn_tbl[ecx++] = to_trn;
8252 buf_last_oop = buf_oop->next =
8253 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8254 buf_oop = buf_oop->next;
8255 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8256 0, rte_pktmbuf_tailroom(buf_oop));
8257 rte_pktmbuf_append(buf_oop, to_trn);
8261 if (trn_data == tdata->plaintext.len) {
8262 digest_mem = rte_pktmbuf_append(buf_oop,
8263 tdata->auth_tag.len);
8267 ut_params->obuf->nb_segs = segs;
8271 * Place digest at the end of the last buffer
8274 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8275 if (oop && buf_last_oop)
8276 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8278 if (!digest_mem && !oop) {
8279 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8280 + tdata->auth_tag.len);
8281 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8282 tdata->plaintext.len);
8285 /* Create AEAD operation */
8286 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8287 tdata, digest_mem, digest_phys);
8292 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8294 ut_params->op->sym->m_src = ut_params->ibuf;
8296 ut_params->op->sym->m_dst = ut_params->obuf;
8298 /* Process crypto operation */
8299 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8300 ut_params->op), "failed to process sym crypto op");
8302 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8303 "crypto op processing failed");
8306 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8307 uint8_t *, prepend_len);
8309 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8310 uint8_t *, prepend_len);
8314 fragsz = fragsz_oop;
8316 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8318 tdata->ciphertext.data,
8320 "Ciphertext data not as expected");
8322 buf = ut_params->op->sym->m_src->next;
8324 buf = ut_params->op->sym->m_dst->next;
8326 unsigned int off = fragsz;
8330 ciphertext = rte_pktmbuf_mtod(buf,
8333 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8335 tdata->ciphertext.data + off,
8337 "Ciphertext data not as expected");
8339 off += to_trn_tbl[ecx++];
8343 auth_tag = digest_mem;
8344 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8346 tdata->auth_tag.data,
8347 tdata->auth_tag.len,
8348 "Generated auth tag not as expected");
8354 #define OUT_OF_PLACE 1
8357 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8359 return test_authenticated_encryption_SGL(
8360 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8364 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8366 return test_authenticated_encryption_SGL(
8367 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8371 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8373 return test_authenticated_encryption_SGL(
8374 &gcm_test_case_8, OUT_OF_PLACE, 400,
8375 gcm_test_case_8.plaintext.len);
8379 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8382 return test_authenticated_encryption_SGL(
8383 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8387 test_authentication_verify_fail_when_data_corrupted(
8388 struct crypto_testsuite_params *ts_params,
8389 struct crypto_unittest_params *ut_params,
8390 const struct test_crypto_vector *reference)
8392 return test_authentication_verify_fail_when_data_corruption(
8393 ts_params, ut_params, reference, 1);
8397 test_authentication_verify_fail_when_tag_corrupted(
8398 struct crypto_testsuite_params *ts_params,
8399 struct crypto_unittest_params *ut_params,
8400 const struct test_crypto_vector *reference)
8402 return test_authentication_verify_fail_when_data_corruption(
8403 ts_params, ut_params, reference, 0);
8407 test_authentication_verify_GMAC_fail_when_data_corrupted(
8408 struct crypto_testsuite_params *ts_params,
8409 struct crypto_unittest_params *ut_params,
8410 const struct test_crypto_vector *reference)
8412 return test_authentication_verify_GMAC_fail_when_corruption(
8413 ts_params, ut_params, reference, 1);
8417 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8418 struct crypto_testsuite_params *ts_params,
8419 struct crypto_unittest_params *ut_params,
8420 const struct test_crypto_vector *reference)
8422 return test_authentication_verify_GMAC_fail_when_corruption(
8423 ts_params, ut_params, reference, 0);
8427 test_authenticated_decryption_fail_when_data_corrupted(
8428 struct crypto_testsuite_params *ts_params,
8429 struct crypto_unittest_params *ut_params,
8430 const struct test_crypto_vector *reference)
8432 return test_authenticated_decryption_fail_when_corruption(
8433 ts_params, ut_params, reference, 1);
8437 test_authenticated_decryption_fail_when_tag_corrupted(
8438 struct crypto_testsuite_params *ts_params,
8439 struct crypto_unittest_params *ut_params,
8440 const struct test_crypto_vector *reference)
8442 return test_authenticated_decryption_fail_when_corruption(
8443 ts_params, ut_params, reference, 0);
8447 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8449 return test_authentication_verify_fail_when_data_corrupted(
8450 &testsuite_params, &unittest_params,
8451 &hmac_sha1_test_crypto_vector);
8455 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8457 return test_authentication_verify_fail_when_tag_corrupted(
8458 &testsuite_params, &unittest_params,
8459 &hmac_sha1_test_crypto_vector);
8463 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8465 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8466 &testsuite_params, &unittest_params,
8467 &aes128_gmac_test_vector);
8471 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8473 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8474 &testsuite_params, &unittest_params,
8475 &aes128_gmac_test_vector);
8479 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8481 return test_authenticated_decryption_fail_when_data_corrupted(
8484 &aes128cbc_hmac_sha1_test_vector);
8488 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8490 return test_authenticated_decryption_fail_when_tag_corrupted(
8493 &aes128cbc_hmac_sha1_test_vector);
8496 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8498 /* global AESNI slave IDs for the scheduler test */
8499 uint8_t aesni_ids[2];
8502 test_scheduler_attach_slave_op(void)
8504 struct crypto_testsuite_params *ts_params = &testsuite_params;
8505 uint8_t sched_id = ts_params->valid_devs[0];
8506 uint32_t nb_devs, i, nb_devs_attached = 0;
8510 /* create 2 AESNI_MB if necessary */
8511 nb_devs = rte_cryptodev_device_count_by_driver(
8512 rte_cryptodev_driver_id_get(
8513 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8515 for (i = nb_devs; i < 2; i++) {
8516 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8517 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8519 ret = rte_vdev_init(vdev_name, NULL);
8521 TEST_ASSERT(ret == 0,
8522 "Failed to create instance %u of"
8524 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8528 /* attach 2 AESNI_MB cdevs */
8529 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8531 struct rte_cryptodev_info info;
8533 rte_cryptodev_info_get(i, &info);
8534 if (info.driver_id != rte_cryptodev_driver_id_get(
8535 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8539 * Create the session mempool again, since now there are new devices
8540 * to use the mempool.
8542 if (ts_params->session_mpool) {
8543 rte_mempool_free(ts_params->session_mpool);
8544 ts_params->session_mpool = NULL;
8546 unsigned int session_size =
8547 rte_cryptodev_sym_get_private_session_size(i);
8549 if (info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
8551 "Device does not support "
8552 "at least %u sessions\n",
8557 * Create mempool with maximum number of sessions * 2,
8558 * to include the session headers
8560 if (ts_params->session_mpool == NULL) {
8561 ts_params->session_mpool = rte_mempool_create(
8563 MAX_NB_SESSIONS * 2,
8565 0, 0, NULL, NULL, NULL,
8566 NULL, SOCKET_ID_ANY,
8569 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8570 "session mempool allocation failed");
8573 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8576 TEST_ASSERT(ret == 0,
8577 "Failed to attach device %u of pmd : %s", i,
8578 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8580 aesni_ids[nb_devs_attached] = (uint8_t)i;
8589 test_scheduler_detach_slave_op(void)
8591 struct crypto_testsuite_params *ts_params = &testsuite_params;
8592 uint8_t sched_id = ts_params->valid_devs[0];
8596 for (i = 0; i < 2; i++) {
8597 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8599 TEST_ASSERT(ret == 0,
8600 "Failed to detach device %u", aesni_ids[i]);
8607 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8609 struct crypto_testsuite_params *ts_params = &testsuite_params;
8610 uint8_t sched_id = ts_params->valid_devs[0];
8612 return rte_cryptodev_scheduler_mode_set(sched_id,
8617 test_scheduler_mode_roundrobin_op(void)
8619 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8620 0, "Failed to set roundrobin mode");
8626 test_scheduler_mode_multicore_op(void)
8628 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8629 0, "Failed to set multicore mode");
8635 test_scheduler_mode_failover_op(void)
8637 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8638 0, "Failed to set failover mode");
8644 test_scheduler_mode_pkt_size_distr_op(void)
8646 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8647 0, "Failed to set pktsize mode");
8652 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8653 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8654 .setup = testsuite_setup,
8655 .teardown = testsuite_teardown,
8656 .unit_test_cases = {
8658 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8659 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_AES_chain_scheduler_all),
8662 TEST_CASE_ST(ut_setup, ut_teardown,
8663 test_AES_cipheronly_scheduler_all),
8664 TEST_CASE_ST(ut_setup, ut_teardown,
8665 test_authonly_scheduler_all),
8666 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8669 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8670 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 test_AES_chain_scheduler_all),
8673 TEST_CASE_ST(ut_setup, ut_teardown,
8674 test_AES_cipheronly_scheduler_all),
8675 TEST_CASE_ST(ut_setup, ut_teardown,
8676 test_authonly_scheduler_all),
8677 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8680 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8681 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8682 TEST_CASE_ST(ut_setup, ut_teardown,
8683 test_AES_chain_scheduler_all),
8684 TEST_CASE_ST(ut_setup, ut_teardown,
8685 test_AES_cipheronly_scheduler_all),
8686 TEST_CASE_ST(ut_setup, ut_teardown,
8687 test_authonly_scheduler_all),
8688 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8691 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8692 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8693 TEST_CASE_ST(ut_setup, ut_teardown,
8694 test_AES_chain_scheduler_all),
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_AES_cipheronly_scheduler_all),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_authonly_scheduler_all),
8699 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8701 TEST_CASES_END() /**< NULL terminate unit test array */
8705 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8707 static struct unit_test_suite cryptodev_qat_testsuite = {
8708 .suite_name = "Crypto QAT Unit Test Suite",
8709 .setup = testsuite_setup,
8710 .teardown = testsuite_teardown,
8711 .unit_test_cases = {
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_device_configure_invalid_dev_id),
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_device_configure_invalid_queue_pair_ids),
8716 TEST_CASE_ST(ut_setup, ut_teardown,
8717 test_queue_pair_descriptor_setup),
8718 TEST_CASE_ST(ut_setup, ut_teardown,
8719 test_multi_session),
8721 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8722 TEST_CASE_ST(ut_setup, ut_teardown,
8723 test_AES_cipheronly_qat_all),
8724 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8725 TEST_CASE_ST(ut_setup, ut_teardown,
8726 test_3DES_cipheronly_qat_all),
8727 TEST_CASE_ST(ut_setup, ut_teardown,
8728 test_DES_cipheronly_qat_all),
8729 TEST_CASE_ST(ut_setup, ut_teardown,
8730 test_AES_docsis_qat_all),
8731 TEST_CASE_ST(ut_setup, ut_teardown,
8732 test_DES_docsis_qat_all),
8733 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8734 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8736 /** AES CCM Authenticated Encryption 128 bits key */
8737 TEST_CASE_ST(ut_setup, ut_teardown,
8738 test_AES_CCM_authenticated_encryption_test_case_128_1),
8739 TEST_CASE_ST(ut_setup, ut_teardown,
8740 test_AES_CCM_authenticated_encryption_test_case_128_2),
8741 TEST_CASE_ST(ut_setup, ut_teardown,
8742 test_AES_CCM_authenticated_encryption_test_case_128_3),
8744 /** AES CCM Authenticated Decryption 128 bits key*/
8745 TEST_CASE_ST(ut_setup, ut_teardown,
8746 test_AES_CCM_authenticated_decryption_test_case_128_1),
8747 TEST_CASE_ST(ut_setup, ut_teardown,
8748 test_AES_CCM_authenticated_decryption_test_case_128_2),
8749 TEST_CASE_ST(ut_setup, ut_teardown,
8750 test_AES_CCM_authenticated_decryption_test_case_128_3),
8752 /** AES GCM Authenticated Encryption */
8753 TEST_CASE_ST(ut_setup, ut_teardown,
8754 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8755 TEST_CASE_ST(ut_setup, ut_teardown,
8756 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8757 TEST_CASE_ST(ut_setup, ut_teardown,
8758 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8759 TEST_CASE_ST(ut_setup, ut_teardown,
8760 test_AES_GCM_authenticated_encryption_test_case_1),
8761 TEST_CASE_ST(ut_setup, ut_teardown,
8762 test_AES_GCM_authenticated_encryption_test_case_2),
8763 TEST_CASE_ST(ut_setup, ut_teardown,
8764 test_AES_GCM_authenticated_encryption_test_case_3),
8765 TEST_CASE_ST(ut_setup, ut_teardown,
8766 test_AES_GCM_authenticated_encryption_test_case_4),
8767 TEST_CASE_ST(ut_setup, ut_teardown,
8768 test_AES_GCM_authenticated_encryption_test_case_5),
8769 TEST_CASE_ST(ut_setup, ut_teardown,
8770 test_AES_GCM_authenticated_encryption_test_case_6),
8771 TEST_CASE_ST(ut_setup, ut_teardown,
8772 test_AES_GCM_authenticated_encryption_test_case_7),
8774 /** AES GCM Authenticated Decryption */
8775 TEST_CASE_ST(ut_setup, ut_teardown,
8776 test_AES_GCM_authenticated_decryption_test_case_1),
8777 TEST_CASE_ST(ut_setup, ut_teardown,
8778 test_AES_GCM_authenticated_decryption_test_case_2),
8779 TEST_CASE_ST(ut_setup, ut_teardown,
8780 test_AES_GCM_authenticated_decryption_test_case_3),
8781 TEST_CASE_ST(ut_setup, ut_teardown,
8782 test_AES_GCM_authenticated_decryption_test_case_4),
8783 TEST_CASE_ST(ut_setup, ut_teardown,
8784 test_AES_GCM_authenticated_decryption_test_case_5),
8785 TEST_CASE_ST(ut_setup, ut_teardown,
8786 test_AES_GCM_authenticated_decryption_test_case_6),
8787 TEST_CASE_ST(ut_setup, ut_teardown,
8788 test_AES_GCM_authenticated_decryption_test_case_7),
8790 /** AES GCM Authenticated Encryption 192 bits key */
8791 TEST_CASE_ST(ut_setup, ut_teardown,
8792 test_AES_GCM_auth_encryption_test_case_192_1),
8793 TEST_CASE_ST(ut_setup, ut_teardown,
8794 test_AES_GCM_auth_encryption_test_case_192_2),
8795 TEST_CASE_ST(ut_setup, ut_teardown,
8796 test_AES_GCM_auth_encryption_test_case_192_3),
8797 TEST_CASE_ST(ut_setup, ut_teardown,
8798 test_AES_GCM_auth_encryption_test_case_192_4),
8799 TEST_CASE_ST(ut_setup, ut_teardown,
8800 test_AES_GCM_auth_encryption_test_case_192_5),
8801 TEST_CASE_ST(ut_setup, ut_teardown,
8802 test_AES_GCM_auth_encryption_test_case_192_6),
8803 TEST_CASE_ST(ut_setup, ut_teardown,
8804 test_AES_GCM_auth_encryption_test_case_192_7),
8806 /** AES GCM Authenticated Decryption 192 bits key */
8807 TEST_CASE_ST(ut_setup, ut_teardown,
8808 test_AES_GCM_auth_decryption_test_case_192_1),
8809 TEST_CASE_ST(ut_setup, ut_teardown,
8810 test_AES_GCM_auth_decryption_test_case_192_2),
8811 TEST_CASE_ST(ut_setup, ut_teardown,
8812 test_AES_GCM_auth_decryption_test_case_192_3),
8813 TEST_CASE_ST(ut_setup, ut_teardown,
8814 test_AES_GCM_auth_decryption_test_case_192_4),
8815 TEST_CASE_ST(ut_setup, ut_teardown,
8816 test_AES_GCM_auth_decryption_test_case_192_5),
8817 TEST_CASE_ST(ut_setup, ut_teardown,
8818 test_AES_GCM_auth_decryption_test_case_192_6),
8819 TEST_CASE_ST(ut_setup, ut_teardown,
8820 test_AES_GCM_auth_decryption_test_case_192_7),
8822 /** AES GCM Authenticated Encryption 256 bits key */
8823 TEST_CASE_ST(ut_setup, ut_teardown,
8824 test_AES_GCM_auth_encryption_test_case_256_1),
8825 TEST_CASE_ST(ut_setup, ut_teardown,
8826 test_AES_GCM_auth_encryption_test_case_256_2),
8827 TEST_CASE_ST(ut_setup, ut_teardown,
8828 test_AES_GCM_auth_encryption_test_case_256_3),
8829 TEST_CASE_ST(ut_setup, ut_teardown,
8830 test_AES_GCM_auth_encryption_test_case_256_4),
8831 TEST_CASE_ST(ut_setup, ut_teardown,
8832 test_AES_GCM_auth_encryption_test_case_256_5),
8833 TEST_CASE_ST(ut_setup, ut_teardown,
8834 test_AES_GCM_auth_encryption_test_case_256_6),
8835 TEST_CASE_ST(ut_setup, ut_teardown,
8836 test_AES_GCM_auth_encryption_test_case_256_7),
8838 /** AES GMAC Authentication */
8839 TEST_CASE_ST(ut_setup, ut_teardown,
8840 test_AES_GMAC_authentication_test_case_1),
8841 TEST_CASE_ST(ut_setup, ut_teardown,
8842 test_AES_GMAC_authentication_verify_test_case_1),
8843 TEST_CASE_ST(ut_setup, ut_teardown,
8844 test_AES_GMAC_authentication_test_case_2),
8845 TEST_CASE_ST(ut_setup, ut_teardown,
8846 test_AES_GMAC_authentication_verify_test_case_2),
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_AES_GMAC_authentication_test_case_3),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_AES_GMAC_authentication_verify_test_case_3),
8852 /** SNOW 3G encrypt only (UEA2) */
8853 TEST_CASE_ST(ut_setup, ut_teardown,
8854 test_snow3g_encryption_test_case_1),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_snow3g_encryption_test_case_2),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_snow3g_encryption_test_case_3),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_snow3g_encryption_test_case_4),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_snow3g_encryption_test_case_5),
8864 TEST_CASE_ST(ut_setup, ut_teardown,
8865 test_snow3g_encryption_test_case_1_oop),
8866 TEST_CASE_ST(ut_setup, ut_teardown,
8867 test_snow3g_decryption_test_case_1_oop),
8869 /** SNOW 3G decrypt only (UEA2) */
8870 TEST_CASE_ST(ut_setup, ut_teardown,
8871 test_snow3g_decryption_test_case_1),
8872 TEST_CASE_ST(ut_setup, ut_teardown,
8873 test_snow3g_decryption_test_case_2),
8874 TEST_CASE_ST(ut_setup, ut_teardown,
8875 test_snow3g_decryption_test_case_3),
8876 TEST_CASE_ST(ut_setup, ut_teardown,
8877 test_snow3g_decryption_test_case_4),
8878 TEST_CASE_ST(ut_setup, ut_teardown,
8879 test_snow3g_decryption_test_case_5),
8880 TEST_CASE_ST(ut_setup, ut_teardown,
8881 test_snow3g_hash_generate_test_case_1),
8882 TEST_CASE_ST(ut_setup, ut_teardown,
8883 test_snow3g_hash_generate_test_case_2),
8884 TEST_CASE_ST(ut_setup, ut_teardown,
8885 test_snow3g_hash_generate_test_case_3),
8886 TEST_CASE_ST(ut_setup, ut_teardown,
8887 test_snow3g_hash_verify_test_case_1),
8888 TEST_CASE_ST(ut_setup, ut_teardown,
8889 test_snow3g_hash_verify_test_case_2),
8890 TEST_CASE_ST(ut_setup, ut_teardown,
8891 test_snow3g_hash_verify_test_case_3),
8892 TEST_CASE_ST(ut_setup, ut_teardown,
8893 test_snow3g_cipher_auth_test_case_1),
8894 TEST_CASE_ST(ut_setup, ut_teardown,
8895 test_snow3g_auth_cipher_test_case_1),
8897 /** ZUC encrypt only (EEA3) */
8898 TEST_CASE_ST(ut_setup, ut_teardown,
8899 test_zuc_encryption_test_case_1),
8900 TEST_CASE_ST(ut_setup, ut_teardown,
8901 test_zuc_encryption_test_case_2),
8902 TEST_CASE_ST(ut_setup, ut_teardown,
8903 test_zuc_encryption_test_case_3),
8904 TEST_CASE_ST(ut_setup, ut_teardown,
8905 test_zuc_encryption_test_case_4),
8906 TEST_CASE_ST(ut_setup, ut_teardown,
8907 test_zuc_encryption_test_case_5),
8909 /** ZUC authenticate (EIA3) */
8910 TEST_CASE_ST(ut_setup, ut_teardown,
8911 test_zuc_hash_generate_test_case_6),
8912 TEST_CASE_ST(ut_setup, ut_teardown,
8913 test_zuc_hash_generate_test_case_7),
8914 TEST_CASE_ST(ut_setup, ut_teardown,
8915 test_zuc_hash_generate_test_case_8),
8917 /** ZUC alg-chain (EEA3/EIA3) */
8918 TEST_CASE_ST(ut_setup, ut_teardown,
8919 test_zuc_cipher_auth_test_case_1),
8920 TEST_CASE_ST(ut_setup, ut_teardown,
8921 test_zuc_cipher_auth_test_case_2),
8923 /** HMAC_MD5 Authentication */
8924 TEST_CASE_ST(ut_setup, ut_teardown,
8925 test_MD5_HMAC_generate_case_1),
8926 TEST_CASE_ST(ut_setup, ut_teardown,
8927 test_MD5_HMAC_verify_case_1),
8928 TEST_CASE_ST(ut_setup, ut_teardown,
8929 test_MD5_HMAC_generate_case_2),
8930 TEST_CASE_ST(ut_setup, ut_teardown,
8931 test_MD5_HMAC_verify_case_2),
8934 TEST_CASE_ST(ut_setup, ut_teardown,
8935 test_null_auth_only_operation),
8936 TEST_CASE_ST(ut_setup, ut_teardown,
8937 test_null_cipher_only_operation),
8938 TEST_CASE_ST(ut_setup, ut_teardown,
8939 test_null_cipher_auth_operation),
8940 TEST_CASE_ST(ut_setup, ut_teardown,
8941 test_null_auth_cipher_operation),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_kasumi_hash_generate_test_case_1),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_kasumi_hash_generate_test_case_2),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_kasumi_hash_generate_test_case_3),
8950 TEST_CASE_ST(ut_setup, ut_teardown,
8951 test_kasumi_hash_generate_test_case_4),
8952 TEST_CASE_ST(ut_setup, ut_teardown,
8953 test_kasumi_hash_generate_test_case_5),
8954 TEST_CASE_ST(ut_setup, ut_teardown,
8955 test_kasumi_hash_generate_test_case_6),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_kasumi_hash_verify_test_case_1),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_kasumi_hash_verify_test_case_2),
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 test_kasumi_hash_verify_test_case_3),
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 test_kasumi_hash_verify_test_case_4),
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 test_kasumi_hash_verify_test_case_5),
8968 TEST_CASE_ST(ut_setup, ut_teardown,
8969 test_kasumi_encryption_test_case_1),
8970 TEST_CASE_ST(ut_setup, ut_teardown,
8971 test_kasumi_encryption_test_case_3),
8972 TEST_CASE_ST(ut_setup, ut_teardown,
8973 test_kasumi_auth_cipher_test_case_1),
8974 TEST_CASE_ST(ut_setup, ut_teardown,
8975 test_kasumi_cipher_auth_test_case_1),
8977 /** Negative tests */
8978 TEST_CASE_ST(ut_setup, ut_teardown,
8979 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8980 TEST_CASE_ST(ut_setup, ut_teardown,
8981 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8982 TEST_CASE_ST(ut_setup, ut_teardown,
8983 authentication_verify_AES128_GMAC_fail_data_corrupt),
8984 TEST_CASE_ST(ut_setup, ut_teardown,
8985 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8986 TEST_CASE_ST(ut_setup, ut_teardown,
8987 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8988 TEST_CASE_ST(ut_setup, ut_teardown,
8989 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8991 TEST_CASES_END() /**< NULL terminate unit test array */
8995 static struct unit_test_suite cryptodev_virtio_testsuite = {
8996 .suite_name = "Crypto VIRTIO Unit Test Suite",
8997 .setup = testsuite_setup,
8998 .teardown = testsuite_teardown,
8999 .unit_test_cases = {
9000 TEST_CASE_ST(ut_setup, ut_teardown,
9001 test_AES_cipheronly_virtio_all),
9003 TEST_CASES_END() /**< NULL terminate unit test array */
9007 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
9008 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
9009 .setup = testsuite_setup,
9010 .teardown = testsuite_teardown,
9011 .unit_test_cases = {
9012 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
9013 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
9014 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9015 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9016 TEST_CASE_ST(ut_setup, ut_teardown,
9017 test_DES_cipheronly_mb_all),
9018 TEST_CASE_ST(ut_setup, ut_teardown,
9019 test_DES_docsis_mb_all),
9020 TEST_CASE_ST(ut_setup, ut_teardown,
9021 test_AES_CCM_authenticated_encryption_test_case_128_1),
9022 TEST_CASE_ST(ut_setup, ut_teardown,
9023 test_AES_CCM_authenticated_decryption_test_case_128_1),
9024 TEST_CASE_ST(ut_setup, ut_teardown,
9025 test_AES_CCM_authenticated_encryption_test_case_128_2),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_AES_CCM_authenticated_decryption_test_case_128_2),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_CCM_authenticated_encryption_test_case_128_3),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_CCM_authenticated_decryption_test_case_128_3),
9033 TEST_CASES_END() /**< NULL terminate unit test array */
9037 static struct unit_test_suite cryptodev_openssl_testsuite = {
9038 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9039 .setup = testsuite_setup,
9040 .teardown = testsuite_teardown,
9041 .unit_test_cases = {
9042 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9043 TEST_CASE_ST(ut_setup, ut_teardown,
9044 test_multi_session_random_usage),
9045 TEST_CASE_ST(ut_setup, ut_teardown,
9046 test_AES_chain_openssl_all),
9047 TEST_CASE_ST(ut_setup, ut_teardown,
9048 test_AES_cipheronly_openssl_all),
9049 TEST_CASE_ST(ut_setup, ut_teardown,
9050 test_3DES_chain_openssl_all),
9051 TEST_CASE_ST(ut_setup, ut_teardown,
9052 test_3DES_cipheronly_openssl_all),
9053 TEST_CASE_ST(ut_setup, ut_teardown,
9054 test_DES_cipheronly_openssl_all),
9055 TEST_CASE_ST(ut_setup, ut_teardown,
9056 test_DES_docsis_openssl_all),
9057 TEST_CASE_ST(ut_setup, ut_teardown,
9058 test_authonly_openssl_all),
9060 /** AES GCM Authenticated Encryption */
9061 TEST_CASE_ST(ut_setup, ut_teardown,
9062 test_AES_GCM_authenticated_encryption_test_case_1),
9063 TEST_CASE_ST(ut_setup, ut_teardown,
9064 test_AES_GCM_authenticated_encryption_test_case_2),
9065 TEST_CASE_ST(ut_setup, ut_teardown,
9066 test_AES_GCM_authenticated_encryption_test_case_3),
9067 TEST_CASE_ST(ut_setup, ut_teardown,
9068 test_AES_GCM_authenticated_encryption_test_case_4),
9069 TEST_CASE_ST(ut_setup, ut_teardown,
9070 test_AES_GCM_authenticated_encryption_test_case_5),
9071 TEST_CASE_ST(ut_setup, ut_teardown,
9072 test_AES_GCM_authenticated_encryption_test_case_6),
9073 TEST_CASE_ST(ut_setup, ut_teardown,
9074 test_AES_GCM_authenticated_encryption_test_case_7),
9076 /** AES GCM Authenticated Decryption */
9077 TEST_CASE_ST(ut_setup, ut_teardown,
9078 test_AES_GCM_authenticated_decryption_test_case_1),
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_GCM_authenticated_decryption_test_case_2),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_AES_GCM_authenticated_decryption_test_case_3),
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_AES_GCM_authenticated_decryption_test_case_4),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_GCM_authenticated_decryption_test_case_5),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_AES_GCM_authenticated_decryption_test_case_6),
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 test_AES_GCM_authenticated_decryption_test_case_7),
9093 /** AES GCM Authenticated Encryption 192 bits key */
9094 TEST_CASE_ST(ut_setup, ut_teardown,
9095 test_AES_GCM_auth_encryption_test_case_192_1),
9096 TEST_CASE_ST(ut_setup, ut_teardown,
9097 test_AES_GCM_auth_encryption_test_case_192_2),
9098 TEST_CASE_ST(ut_setup, ut_teardown,
9099 test_AES_GCM_auth_encryption_test_case_192_3),
9100 TEST_CASE_ST(ut_setup, ut_teardown,
9101 test_AES_GCM_auth_encryption_test_case_192_4),
9102 TEST_CASE_ST(ut_setup, ut_teardown,
9103 test_AES_GCM_auth_encryption_test_case_192_5),
9104 TEST_CASE_ST(ut_setup, ut_teardown,
9105 test_AES_GCM_auth_encryption_test_case_192_6),
9106 TEST_CASE_ST(ut_setup, ut_teardown,
9107 test_AES_GCM_auth_encryption_test_case_192_7),
9109 /** AES GCM Authenticated Decryption 192 bits key */
9110 TEST_CASE_ST(ut_setup, ut_teardown,
9111 test_AES_GCM_auth_decryption_test_case_192_1),
9112 TEST_CASE_ST(ut_setup, ut_teardown,
9113 test_AES_GCM_auth_decryption_test_case_192_2),
9114 TEST_CASE_ST(ut_setup, ut_teardown,
9115 test_AES_GCM_auth_decryption_test_case_192_3),
9116 TEST_CASE_ST(ut_setup, ut_teardown,
9117 test_AES_GCM_auth_decryption_test_case_192_4),
9118 TEST_CASE_ST(ut_setup, ut_teardown,
9119 test_AES_GCM_auth_decryption_test_case_192_5),
9120 TEST_CASE_ST(ut_setup, ut_teardown,
9121 test_AES_GCM_auth_decryption_test_case_192_6),
9122 TEST_CASE_ST(ut_setup, ut_teardown,
9123 test_AES_GCM_auth_decryption_test_case_192_7),
9125 /** AES GCM Authenticated Encryption 256 bits key */
9126 TEST_CASE_ST(ut_setup, ut_teardown,
9127 test_AES_GCM_auth_encryption_test_case_256_1),
9128 TEST_CASE_ST(ut_setup, ut_teardown,
9129 test_AES_GCM_auth_encryption_test_case_256_2),
9130 TEST_CASE_ST(ut_setup, ut_teardown,
9131 test_AES_GCM_auth_encryption_test_case_256_3),
9132 TEST_CASE_ST(ut_setup, ut_teardown,
9133 test_AES_GCM_auth_encryption_test_case_256_4),
9134 TEST_CASE_ST(ut_setup, ut_teardown,
9135 test_AES_GCM_auth_encryption_test_case_256_5),
9136 TEST_CASE_ST(ut_setup, ut_teardown,
9137 test_AES_GCM_auth_encryption_test_case_256_6),
9138 TEST_CASE_ST(ut_setup, ut_teardown,
9139 test_AES_GCM_auth_encryption_test_case_256_7),
9141 /** AES GCM Authenticated Decryption 256 bits key */
9142 TEST_CASE_ST(ut_setup, ut_teardown,
9143 test_AES_GCM_auth_decryption_test_case_256_1),
9144 TEST_CASE_ST(ut_setup, ut_teardown,
9145 test_AES_GCM_auth_decryption_test_case_256_2),
9146 TEST_CASE_ST(ut_setup, ut_teardown,
9147 test_AES_GCM_auth_decryption_test_case_256_3),
9148 TEST_CASE_ST(ut_setup, ut_teardown,
9149 test_AES_GCM_auth_decryption_test_case_256_4),
9150 TEST_CASE_ST(ut_setup, ut_teardown,
9151 test_AES_GCM_auth_decryption_test_case_256_5),
9152 TEST_CASE_ST(ut_setup, ut_teardown,
9153 test_AES_GCM_auth_decryption_test_case_256_6),
9154 TEST_CASE_ST(ut_setup, ut_teardown,
9155 test_AES_GCM_auth_decryption_test_case_256_7),
9157 /** AES GMAC Authentication */
9158 TEST_CASE_ST(ut_setup, ut_teardown,
9159 test_AES_GMAC_authentication_test_case_1),
9160 TEST_CASE_ST(ut_setup, ut_teardown,
9161 test_AES_GMAC_authentication_verify_test_case_1),
9162 TEST_CASE_ST(ut_setup, ut_teardown,
9163 test_AES_GMAC_authentication_test_case_2),
9164 TEST_CASE_ST(ut_setup, ut_teardown,
9165 test_AES_GMAC_authentication_verify_test_case_2),
9166 TEST_CASE_ST(ut_setup, ut_teardown,
9167 test_AES_GMAC_authentication_test_case_3),
9168 TEST_CASE_ST(ut_setup, ut_teardown,
9169 test_AES_GMAC_authentication_verify_test_case_3),
9170 TEST_CASE_ST(ut_setup, ut_teardown,
9171 test_AES_GMAC_authentication_test_case_4),
9172 TEST_CASE_ST(ut_setup, ut_teardown,
9173 test_AES_GMAC_authentication_verify_test_case_4),
9175 /** AES CCM Authenticated Encryption 128 bits key */
9176 TEST_CASE_ST(ut_setup, ut_teardown,
9177 test_AES_CCM_authenticated_encryption_test_case_128_1),
9178 TEST_CASE_ST(ut_setup, ut_teardown,
9179 test_AES_CCM_authenticated_encryption_test_case_128_2),
9180 TEST_CASE_ST(ut_setup, ut_teardown,
9181 test_AES_CCM_authenticated_encryption_test_case_128_3),
9183 /** AES CCM Authenticated Decryption 128 bits key*/
9184 TEST_CASE_ST(ut_setup, ut_teardown,
9185 test_AES_CCM_authenticated_decryption_test_case_128_1),
9186 TEST_CASE_ST(ut_setup, ut_teardown,
9187 test_AES_CCM_authenticated_decryption_test_case_128_2),
9188 TEST_CASE_ST(ut_setup, ut_teardown,
9189 test_AES_CCM_authenticated_decryption_test_case_128_3),
9191 /** AES CCM Authenticated Encryption 192 bits key */
9192 TEST_CASE_ST(ut_setup, ut_teardown,
9193 test_AES_CCM_authenticated_encryption_test_case_192_1),
9194 TEST_CASE_ST(ut_setup, ut_teardown,
9195 test_AES_CCM_authenticated_encryption_test_case_192_2),
9196 TEST_CASE_ST(ut_setup, ut_teardown,
9197 test_AES_CCM_authenticated_encryption_test_case_192_3),
9199 /** AES CCM Authenticated Decryption 192 bits key*/
9200 TEST_CASE_ST(ut_setup, ut_teardown,
9201 test_AES_CCM_authenticated_decryption_test_case_192_1),
9202 TEST_CASE_ST(ut_setup, ut_teardown,
9203 test_AES_CCM_authenticated_decryption_test_case_192_2),
9204 TEST_CASE_ST(ut_setup, ut_teardown,
9205 test_AES_CCM_authenticated_decryption_test_case_192_3),
9207 /** AES CCM Authenticated Encryption 256 bits key */
9208 TEST_CASE_ST(ut_setup, ut_teardown,
9209 test_AES_CCM_authenticated_encryption_test_case_256_1),
9210 TEST_CASE_ST(ut_setup, ut_teardown,
9211 test_AES_CCM_authenticated_encryption_test_case_256_2),
9212 TEST_CASE_ST(ut_setup, ut_teardown,
9213 test_AES_CCM_authenticated_encryption_test_case_256_3),
9215 /** AES CCM Authenticated Decryption 256 bits key*/
9216 TEST_CASE_ST(ut_setup, ut_teardown,
9217 test_AES_CCM_authenticated_decryption_test_case_256_1),
9218 TEST_CASE_ST(ut_setup, ut_teardown,
9219 test_AES_CCM_authenticated_decryption_test_case_256_2),
9220 TEST_CASE_ST(ut_setup, ut_teardown,
9221 test_AES_CCM_authenticated_decryption_test_case_256_3),
9223 /** Scatter-Gather */
9224 TEST_CASE_ST(ut_setup, ut_teardown,
9225 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9227 /** Negative tests */
9228 TEST_CASE_ST(ut_setup, ut_teardown,
9229 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9230 TEST_CASE_ST(ut_setup, ut_teardown,
9231 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9232 TEST_CASE_ST(ut_setup, ut_teardown,
9233 authentication_verify_AES128_GMAC_fail_data_corrupt),
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9241 TEST_CASES_END() /**< NULL terminate unit test array */
9245 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9246 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9247 .setup = testsuite_setup,
9248 .teardown = testsuite_teardown,
9249 .unit_test_cases = {
9250 /** AES GCM Authenticated Encryption */
9251 TEST_CASE_ST(ut_setup, ut_teardown,
9252 test_AES_GCM_authenticated_encryption_test_case_1),
9253 TEST_CASE_ST(ut_setup, ut_teardown,
9254 test_AES_GCM_authenticated_encryption_test_case_2),
9255 TEST_CASE_ST(ut_setup, ut_teardown,
9256 test_AES_GCM_authenticated_encryption_test_case_3),
9257 TEST_CASE_ST(ut_setup, ut_teardown,
9258 test_AES_GCM_authenticated_encryption_test_case_4),
9259 TEST_CASE_ST(ut_setup, ut_teardown,
9260 test_AES_GCM_authenticated_encryption_test_case_5),
9261 TEST_CASE_ST(ut_setup, ut_teardown,
9262 test_AES_GCM_authenticated_encryption_test_case_6),
9263 TEST_CASE_ST(ut_setup, ut_teardown,
9264 test_AES_GCM_authenticated_encryption_test_case_7),
9266 /** AES GCM Authenticated Decryption */
9267 TEST_CASE_ST(ut_setup, ut_teardown,
9268 test_AES_GCM_authenticated_decryption_test_case_1),
9269 TEST_CASE_ST(ut_setup, ut_teardown,
9270 test_AES_GCM_authenticated_decryption_test_case_2),
9271 TEST_CASE_ST(ut_setup, ut_teardown,
9272 test_AES_GCM_authenticated_decryption_test_case_3),
9273 TEST_CASE_ST(ut_setup, ut_teardown,
9274 test_AES_GCM_authenticated_decryption_test_case_4),
9275 TEST_CASE_ST(ut_setup, ut_teardown,
9276 test_AES_GCM_authenticated_decryption_test_case_5),
9277 TEST_CASE_ST(ut_setup, ut_teardown,
9278 test_AES_GCM_authenticated_decryption_test_case_6),
9279 TEST_CASE_ST(ut_setup, ut_teardown,
9280 test_AES_GCM_authenticated_decryption_test_case_7),
9282 /** AES GCM Authenticated Encryption 192 bits key */
9283 TEST_CASE_ST(ut_setup, ut_teardown,
9284 test_AES_GCM_auth_encryption_test_case_192_1),
9285 TEST_CASE_ST(ut_setup, ut_teardown,
9286 test_AES_GCM_auth_encryption_test_case_192_2),
9287 TEST_CASE_ST(ut_setup, ut_teardown,
9288 test_AES_GCM_auth_encryption_test_case_192_3),
9289 TEST_CASE_ST(ut_setup, ut_teardown,
9290 test_AES_GCM_auth_encryption_test_case_192_4),
9291 TEST_CASE_ST(ut_setup, ut_teardown,
9292 test_AES_GCM_auth_encryption_test_case_192_5),
9293 TEST_CASE_ST(ut_setup, ut_teardown,
9294 test_AES_GCM_auth_encryption_test_case_192_6),
9295 TEST_CASE_ST(ut_setup, ut_teardown,
9296 test_AES_GCM_auth_encryption_test_case_192_7),
9298 /** AES GCM Authenticated Decryption 192 bits key */
9299 TEST_CASE_ST(ut_setup, ut_teardown,
9300 test_AES_GCM_auth_decryption_test_case_192_1),
9301 TEST_CASE_ST(ut_setup, ut_teardown,
9302 test_AES_GCM_auth_decryption_test_case_192_2),
9303 TEST_CASE_ST(ut_setup, ut_teardown,
9304 test_AES_GCM_auth_decryption_test_case_192_3),
9305 TEST_CASE_ST(ut_setup, ut_teardown,
9306 test_AES_GCM_auth_decryption_test_case_192_4),
9307 TEST_CASE_ST(ut_setup, ut_teardown,
9308 test_AES_GCM_auth_decryption_test_case_192_5),
9309 TEST_CASE_ST(ut_setup, ut_teardown,
9310 test_AES_GCM_auth_decryption_test_case_192_6),
9311 TEST_CASE_ST(ut_setup, ut_teardown,
9312 test_AES_GCM_auth_decryption_test_case_192_7),
9314 /** AES GCM Authenticated Encryption 256 bits key */
9315 TEST_CASE_ST(ut_setup, ut_teardown,
9316 test_AES_GCM_auth_encryption_test_case_256_1),
9317 TEST_CASE_ST(ut_setup, ut_teardown,
9318 test_AES_GCM_auth_encryption_test_case_256_2),
9319 TEST_CASE_ST(ut_setup, ut_teardown,
9320 test_AES_GCM_auth_encryption_test_case_256_3),
9321 TEST_CASE_ST(ut_setup, ut_teardown,
9322 test_AES_GCM_auth_encryption_test_case_256_4),
9323 TEST_CASE_ST(ut_setup, ut_teardown,
9324 test_AES_GCM_auth_encryption_test_case_256_5),
9325 TEST_CASE_ST(ut_setup, ut_teardown,
9326 test_AES_GCM_auth_encryption_test_case_256_6),
9327 TEST_CASE_ST(ut_setup, ut_teardown,
9328 test_AES_GCM_auth_encryption_test_case_256_7),
9330 /** AES GCM Authenticated Decryption 256 bits key */
9331 TEST_CASE_ST(ut_setup, ut_teardown,
9332 test_AES_GCM_auth_decryption_test_case_256_1),
9333 TEST_CASE_ST(ut_setup, ut_teardown,
9334 test_AES_GCM_auth_decryption_test_case_256_2),
9335 TEST_CASE_ST(ut_setup, ut_teardown,
9336 test_AES_GCM_auth_decryption_test_case_256_3),
9337 TEST_CASE_ST(ut_setup, ut_teardown,
9338 test_AES_GCM_auth_decryption_test_case_256_4),
9339 TEST_CASE_ST(ut_setup, ut_teardown,
9340 test_AES_GCM_auth_decryption_test_case_256_5),
9341 TEST_CASE_ST(ut_setup, ut_teardown,
9342 test_AES_GCM_auth_decryption_test_case_256_6),
9343 TEST_CASE_ST(ut_setup, ut_teardown,
9344 test_AES_GCM_auth_decryption_test_case_256_7),
9346 /** AES GCM Authenticated Encryption big aad size */
9347 TEST_CASE_ST(ut_setup, ut_teardown,
9348 test_AES_GCM_auth_encryption_test_case_aad_1),
9349 TEST_CASE_ST(ut_setup, ut_teardown,
9350 test_AES_GCM_auth_encryption_test_case_aad_2),
9352 /** AES GCM Authenticated Decryption big aad size */
9353 TEST_CASE_ST(ut_setup, ut_teardown,
9354 test_AES_GCM_auth_decryption_test_case_aad_1),
9355 TEST_CASE_ST(ut_setup, ut_teardown,
9356 test_AES_GCM_auth_decryption_test_case_aad_2),
9358 /** AES GMAC Authentication */
9359 TEST_CASE_ST(ut_setup, ut_teardown,
9360 test_AES_GMAC_authentication_test_case_1),
9361 TEST_CASE_ST(ut_setup, ut_teardown,
9362 test_AES_GMAC_authentication_verify_test_case_1),
9363 TEST_CASE_ST(ut_setup, ut_teardown,
9364 test_AES_GMAC_authentication_test_case_3),
9365 TEST_CASE_ST(ut_setup, ut_teardown,
9366 test_AES_GMAC_authentication_verify_test_case_3),
9367 TEST_CASE_ST(ut_setup, ut_teardown,
9368 test_AES_GMAC_authentication_test_case_4),
9369 TEST_CASE_ST(ut_setup, ut_teardown,
9370 test_AES_GMAC_authentication_verify_test_case_4),
9372 /** Negative tests */
9373 TEST_CASE_ST(ut_setup, ut_teardown,
9374 authentication_verify_AES128_GMAC_fail_data_corrupt),
9375 TEST_CASE_ST(ut_setup, ut_teardown,
9376 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9378 /** Out of place tests */
9379 TEST_CASE_ST(ut_setup, ut_teardown,
9380 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9381 TEST_CASE_ST(ut_setup, ut_teardown,
9382 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9384 /** Session-less tests */
9385 TEST_CASE_ST(ut_setup, ut_teardown,
9386 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9390 /** Scatter-Gather */
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9394 TEST_CASES_END() /**< NULL terminate unit test array */
9398 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9399 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9400 .setup = testsuite_setup,
9401 .teardown = testsuite_teardown,
9402 .unit_test_cases = {
9403 /** KASUMI encrypt only (UEA1) */
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_kasumi_encryption_test_case_1),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_kasumi_encryption_test_case_1_sgl),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_kasumi_encryption_test_case_2),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_kasumi_encryption_test_case_3),
9412 TEST_CASE_ST(ut_setup, ut_teardown,
9413 test_kasumi_encryption_test_case_4),
9414 TEST_CASE_ST(ut_setup, ut_teardown,
9415 test_kasumi_encryption_test_case_5),
9416 /** KASUMI decrypt only (UEA1) */
9417 TEST_CASE_ST(ut_setup, ut_teardown,
9418 test_kasumi_decryption_test_case_1),
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_kasumi_decryption_test_case_2),
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_kasumi_decryption_test_case_3),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_kasumi_decryption_test_case_4),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_kasumi_decryption_test_case_5),
9428 TEST_CASE_ST(ut_setup, ut_teardown,
9429 test_kasumi_encryption_test_case_1_oop),
9430 TEST_CASE_ST(ut_setup, ut_teardown,
9431 test_kasumi_encryption_test_case_1_oop_sgl),
9434 TEST_CASE_ST(ut_setup, ut_teardown,
9435 test_kasumi_decryption_test_case_1_oop),
9437 /** KASUMI hash only (UIA1) */
9438 TEST_CASE_ST(ut_setup, ut_teardown,
9439 test_kasumi_hash_generate_test_case_1),
9440 TEST_CASE_ST(ut_setup, ut_teardown,
9441 test_kasumi_hash_generate_test_case_2),
9442 TEST_CASE_ST(ut_setup, ut_teardown,
9443 test_kasumi_hash_generate_test_case_3),
9444 TEST_CASE_ST(ut_setup, ut_teardown,
9445 test_kasumi_hash_generate_test_case_4),
9446 TEST_CASE_ST(ut_setup, ut_teardown,
9447 test_kasumi_hash_generate_test_case_5),
9448 TEST_CASE_ST(ut_setup, ut_teardown,
9449 test_kasumi_hash_generate_test_case_6),
9450 TEST_CASE_ST(ut_setup, ut_teardown,
9451 test_kasumi_hash_verify_test_case_1),
9452 TEST_CASE_ST(ut_setup, ut_teardown,
9453 test_kasumi_hash_verify_test_case_2),
9454 TEST_CASE_ST(ut_setup, ut_teardown,
9455 test_kasumi_hash_verify_test_case_3),
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_kasumi_hash_verify_test_case_4),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_kasumi_hash_verify_test_case_5),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_kasumi_auth_cipher_test_case_1),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_kasumi_cipher_auth_test_case_1),
9464 TEST_CASES_END() /**< NULL terminate unit test array */
9467 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9468 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9469 .setup = testsuite_setup,
9470 .teardown = testsuite_teardown,
9471 .unit_test_cases = {
9472 /** SNOW 3G encrypt only (UEA2) */
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_snow3g_encryption_test_case_1),
9475 TEST_CASE_ST(ut_setup, ut_teardown,
9476 test_snow3g_encryption_test_case_2),
9477 TEST_CASE_ST(ut_setup, ut_teardown,
9478 test_snow3g_encryption_test_case_3),
9479 TEST_CASE_ST(ut_setup, ut_teardown,
9480 test_snow3g_encryption_test_case_4),
9481 TEST_CASE_ST(ut_setup, ut_teardown,
9482 test_snow3g_encryption_test_case_5),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_snow3g_encryption_test_case_1_oop),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_snow3g_encryption_test_case_1_oop_sgl),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_snow3g_decryption_test_case_1_oop),
9491 TEST_CASE_ST(ut_setup, ut_teardown,
9492 test_snow3g_encryption_test_case_1_offset_oop),
9494 /** SNOW 3G decrypt only (UEA2) */
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_snow3g_decryption_test_case_1),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_snow3g_decryption_test_case_2),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_snow3g_decryption_test_case_3),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_snow3g_decryption_test_case_4),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_snow3g_decryption_test_case_5),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_snow3g_hash_generate_test_case_1),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_snow3g_hash_generate_test_case_2),
9509 TEST_CASE_ST(ut_setup, ut_teardown,
9510 test_snow3g_hash_generate_test_case_3),
9511 /* Tests with buffers which length is not byte-aligned */
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_snow3g_hash_generate_test_case_4),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_snow3g_hash_generate_test_case_5),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_snow3g_hash_generate_test_case_6),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_snow3g_hash_verify_test_case_1),
9520 TEST_CASE_ST(ut_setup, ut_teardown,
9521 test_snow3g_hash_verify_test_case_2),
9522 TEST_CASE_ST(ut_setup, ut_teardown,
9523 test_snow3g_hash_verify_test_case_3),
9524 /* Tests with buffers which length is not byte-aligned */
9525 TEST_CASE_ST(ut_setup, ut_teardown,
9526 test_snow3g_hash_verify_test_case_4),
9527 TEST_CASE_ST(ut_setup, ut_teardown,
9528 test_snow3g_hash_verify_test_case_5),
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_snow3g_hash_verify_test_case_6),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_snow3g_cipher_auth_test_case_1),
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_snow3g_auth_cipher_test_case_1),
9536 TEST_CASES_END() /**< NULL terminate unit test array */
9540 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9541 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9542 .setup = testsuite_setup,
9543 .teardown = testsuite_teardown,
9544 .unit_test_cases = {
9545 /** ZUC encrypt only (EEA3) */
9546 TEST_CASE_ST(ut_setup, ut_teardown,
9547 test_zuc_encryption_test_case_1),
9548 TEST_CASE_ST(ut_setup, ut_teardown,
9549 test_zuc_encryption_test_case_2),
9550 TEST_CASE_ST(ut_setup, ut_teardown,
9551 test_zuc_encryption_test_case_3),
9552 TEST_CASE_ST(ut_setup, ut_teardown,
9553 test_zuc_encryption_test_case_4),
9554 TEST_CASE_ST(ut_setup, ut_teardown,
9555 test_zuc_encryption_test_case_5),
9556 TEST_CASE_ST(ut_setup, ut_teardown,
9557 test_zuc_hash_generate_test_case_1),
9558 TEST_CASE_ST(ut_setup, ut_teardown,
9559 test_zuc_hash_generate_test_case_2),
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_zuc_hash_generate_test_case_3),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_zuc_hash_generate_test_case_4),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_zuc_hash_generate_test_case_5),
9566 TEST_CASE_ST(ut_setup, ut_teardown,
9567 test_zuc_encryption_test_case_6_sgl),
9568 TEST_CASES_END() /**< NULL terminate unit test array */
9572 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9573 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9574 .setup = testsuite_setup,
9575 .teardown = testsuite_teardown,
9576 .unit_test_cases = {
9577 TEST_CASE_ST(ut_setup, ut_teardown,
9578 test_device_configure_invalid_dev_id),
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_multi_session),
9582 TEST_CASE_ST(ut_setup, ut_teardown,
9583 test_AES_chain_dpaa_sec_all),
9584 TEST_CASE_ST(ut_setup, ut_teardown,
9585 test_3DES_chain_dpaa_sec_all),
9586 TEST_CASE_ST(ut_setup, ut_teardown,
9587 test_AES_cipheronly_dpaa_sec_all),
9588 TEST_CASE_ST(ut_setup, ut_teardown,
9589 test_3DES_cipheronly_dpaa_sec_all),
9590 TEST_CASE_ST(ut_setup, ut_teardown,
9591 test_authonly_dpaa_sec_all),
9593 /** AES GCM Authenticated Encryption */
9594 TEST_CASE_ST(ut_setup, ut_teardown,
9595 test_AES_GCM_authenticated_encryption_test_case_1),
9596 TEST_CASE_ST(ut_setup, ut_teardown,
9597 test_AES_GCM_authenticated_encryption_test_case_2),
9598 TEST_CASE_ST(ut_setup, ut_teardown,
9599 test_AES_GCM_authenticated_encryption_test_case_3),
9600 TEST_CASE_ST(ut_setup, ut_teardown,
9601 test_AES_GCM_authenticated_encryption_test_case_4),
9602 TEST_CASE_ST(ut_setup, ut_teardown,
9603 test_AES_GCM_authenticated_encryption_test_case_5),
9604 TEST_CASE_ST(ut_setup, ut_teardown,
9605 test_AES_GCM_authenticated_encryption_test_case_6),
9606 TEST_CASE_ST(ut_setup, ut_teardown,
9607 test_AES_GCM_authenticated_encryption_test_case_7),
9609 /** AES GCM Authenticated Decryption */
9610 TEST_CASE_ST(ut_setup, ut_teardown,
9611 test_AES_GCM_authenticated_decryption_test_case_1),
9612 TEST_CASE_ST(ut_setup, ut_teardown,
9613 test_AES_GCM_authenticated_decryption_test_case_2),
9614 TEST_CASE_ST(ut_setup, ut_teardown,
9615 test_AES_GCM_authenticated_decryption_test_case_3),
9616 TEST_CASE_ST(ut_setup, ut_teardown,
9617 test_AES_GCM_authenticated_decryption_test_case_4),
9618 TEST_CASE_ST(ut_setup, ut_teardown,
9619 test_AES_GCM_authenticated_decryption_test_case_5),
9620 TEST_CASE_ST(ut_setup, ut_teardown,
9621 test_AES_GCM_authenticated_decryption_test_case_6),
9622 TEST_CASE_ST(ut_setup, ut_teardown,
9623 test_AES_GCM_authenticated_decryption_test_case_7),
9625 /** AES GCM Authenticated Encryption 256 bits key */
9626 TEST_CASE_ST(ut_setup, ut_teardown,
9627 test_AES_GCM_auth_encryption_test_case_256_1),
9628 TEST_CASE_ST(ut_setup, ut_teardown,
9629 test_AES_GCM_auth_encryption_test_case_256_2),
9630 TEST_CASE_ST(ut_setup, ut_teardown,
9631 test_AES_GCM_auth_encryption_test_case_256_3),
9632 TEST_CASE_ST(ut_setup, ut_teardown,
9633 test_AES_GCM_auth_encryption_test_case_256_4),
9634 TEST_CASE_ST(ut_setup, ut_teardown,
9635 test_AES_GCM_auth_encryption_test_case_256_5),
9636 TEST_CASE_ST(ut_setup, ut_teardown,
9637 test_AES_GCM_auth_encryption_test_case_256_6),
9638 TEST_CASE_ST(ut_setup, ut_teardown,
9639 test_AES_GCM_auth_encryption_test_case_256_7),
9641 /** AES GCM Authenticated Decryption 256 bits key */
9642 TEST_CASE_ST(ut_setup, ut_teardown,
9643 test_AES_GCM_auth_decryption_test_case_256_1),
9644 TEST_CASE_ST(ut_setup, ut_teardown,
9645 test_AES_GCM_auth_decryption_test_case_256_2),
9646 TEST_CASE_ST(ut_setup, ut_teardown,
9647 test_AES_GCM_auth_decryption_test_case_256_3),
9648 TEST_CASE_ST(ut_setup, ut_teardown,
9649 test_AES_GCM_auth_decryption_test_case_256_4),
9650 TEST_CASE_ST(ut_setup, ut_teardown,
9651 test_AES_GCM_auth_decryption_test_case_256_5),
9652 TEST_CASE_ST(ut_setup, ut_teardown,
9653 test_AES_GCM_auth_decryption_test_case_256_6),
9654 TEST_CASE_ST(ut_setup, ut_teardown,
9655 test_AES_GCM_auth_decryption_test_case_256_7),
9657 /** Out of place tests */
9658 TEST_CASE_ST(ut_setup, ut_teardown,
9659 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9660 TEST_CASE_ST(ut_setup, ut_teardown,
9661 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9663 /** Scatter-Gather */
9664 TEST_CASE_ST(ut_setup, ut_teardown,
9665 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9666 TEST_CASE_ST(ut_setup, ut_teardown,
9667 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9668 TEST_CASE_ST(ut_setup, ut_teardown,
9669 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9673 TEST_CASES_END() /**< NULL terminate unit test array */
9677 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9678 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9679 .setup = testsuite_setup,
9680 .teardown = testsuite_teardown,
9681 .unit_test_cases = {
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_device_configure_invalid_dev_id),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_multi_session),
9687 TEST_CASE_ST(ut_setup, ut_teardown,
9688 test_AES_chain_dpaa2_sec_all),
9689 TEST_CASE_ST(ut_setup, ut_teardown,
9690 test_3DES_chain_dpaa2_sec_all),
9691 TEST_CASE_ST(ut_setup, ut_teardown,
9692 test_AES_cipheronly_dpaa2_sec_all),
9693 TEST_CASE_ST(ut_setup, ut_teardown,
9694 test_3DES_cipheronly_dpaa2_sec_all),
9695 TEST_CASE_ST(ut_setup, ut_teardown,
9696 test_authonly_dpaa2_sec_all),
9698 /** AES GCM Authenticated Encryption */
9699 TEST_CASE_ST(ut_setup, ut_teardown,
9700 test_AES_GCM_authenticated_encryption_test_case_1),
9701 TEST_CASE_ST(ut_setup, ut_teardown,
9702 test_AES_GCM_authenticated_encryption_test_case_2),
9703 TEST_CASE_ST(ut_setup, ut_teardown,
9704 test_AES_GCM_authenticated_encryption_test_case_3),
9705 TEST_CASE_ST(ut_setup, ut_teardown,
9706 test_AES_GCM_authenticated_encryption_test_case_4),
9707 TEST_CASE_ST(ut_setup, ut_teardown,
9708 test_AES_GCM_authenticated_encryption_test_case_5),
9709 TEST_CASE_ST(ut_setup, ut_teardown,
9710 test_AES_GCM_authenticated_encryption_test_case_6),
9711 TEST_CASE_ST(ut_setup, ut_teardown,
9712 test_AES_GCM_authenticated_encryption_test_case_7),
9714 /** AES GCM Authenticated Decryption */
9715 TEST_CASE_ST(ut_setup, ut_teardown,
9716 test_AES_GCM_authenticated_decryption_test_case_1),
9717 TEST_CASE_ST(ut_setup, ut_teardown,
9718 test_AES_GCM_authenticated_decryption_test_case_2),
9719 TEST_CASE_ST(ut_setup, ut_teardown,
9720 test_AES_GCM_authenticated_decryption_test_case_3),
9721 TEST_CASE_ST(ut_setup, ut_teardown,
9722 test_AES_GCM_authenticated_decryption_test_case_4),
9723 TEST_CASE_ST(ut_setup, ut_teardown,
9724 test_AES_GCM_authenticated_decryption_test_case_5),
9725 TEST_CASE_ST(ut_setup, ut_teardown,
9726 test_AES_GCM_authenticated_decryption_test_case_6),
9727 TEST_CASE_ST(ut_setup, ut_teardown,
9728 test_AES_GCM_authenticated_decryption_test_case_7),
9730 /** AES GCM Authenticated Encryption 192 bits key */
9731 TEST_CASE_ST(ut_setup, ut_teardown,
9732 test_AES_GCM_auth_encryption_test_case_192_1),
9733 TEST_CASE_ST(ut_setup, ut_teardown,
9734 test_AES_GCM_auth_encryption_test_case_192_2),
9735 TEST_CASE_ST(ut_setup, ut_teardown,
9736 test_AES_GCM_auth_encryption_test_case_192_3),
9737 TEST_CASE_ST(ut_setup, ut_teardown,
9738 test_AES_GCM_auth_encryption_test_case_192_4),
9739 TEST_CASE_ST(ut_setup, ut_teardown,
9740 test_AES_GCM_auth_encryption_test_case_192_5),
9741 TEST_CASE_ST(ut_setup, ut_teardown,
9742 test_AES_GCM_auth_encryption_test_case_192_6),
9743 TEST_CASE_ST(ut_setup, ut_teardown,
9744 test_AES_GCM_auth_encryption_test_case_192_7),
9746 /** AES GCM Authenticated Decryption 192 bits key */
9747 TEST_CASE_ST(ut_setup, ut_teardown,
9748 test_AES_GCM_auth_decryption_test_case_192_1),
9749 TEST_CASE_ST(ut_setup, ut_teardown,
9750 test_AES_GCM_auth_decryption_test_case_192_2),
9751 TEST_CASE_ST(ut_setup, ut_teardown,
9752 test_AES_GCM_auth_decryption_test_case_192_3),
9753 TEST_CASE_ST(ut_setup, ut_teardown,
9754 test_AES_GCM_auth_decryption_test_case_192_4),
9755 TEST_CASE_ST(ut_setup, ut_teardown,
9756 test_AES_GCM_auth_decryption_test_case_192_5),
9757 TEST_CASE_ST(ut_setup, ut_teardown,
9758 test_AES_GCM_auth_decryption_test_case_192_6),
9759 TEST_CASE_ST(ut_setup, ut_teardown,
9760 test_AES_GCM_auth_decryption_test_case_192_7),
9762 /** AES GCM Authenticated Encryption 256 bits key */
9763 TEST_CASE_ST(ut_setup, ut_teardown,
9764 test_AES_GCM_auth_encryption_test_case_256_1),
9765 TEST_CASE_ST(ut_setup, ut_teardown,
9766 test_AES_GCM_auth_encryption_test_case_256_2),
9767 TEST_CASE_ST(ut_setup, ut_teardown,
9768 test_AES_GCM_auth_encryption_test_case_256_3),
9769 TEST_CASE_ST(ut_setup, ut_teardown,
9770 test_AES_GCM_auth_encryption_test_case_256_4),
9771 TEST_CASE_ST(ut_setup, ut_teardown,
9772 test_AES_GCM_auth_encryption_test_case_256_5),
9773 TEST_CASE_ST(ut_setup, ut_teardown,
9774 test_AES_GCM_auth_encryption_test_case_256_6),
9775 TEST_CASE_ST(ut_setup, ut_teardown,
9776 test_AES_GCM_auth_encryption_test_case_256_7),
9778 /** AES GCM Authenticated Decryption 256 bits key */
9779 TEST_CASE_ST(ut_setup, ut_teardown,
9780 test_AES_GCM_auth_decryption_test_case_256_1),
9781 TEST_CASE_ST(ut_setup, ut_teardown,
9782 test_AES_GCM_auth_decryption_test_case_256_2),
9783 TEST_CASE_ST(ut_setup, ut_teardown,
9784 test_AES_GCM_auth_decryption_test_case_256_3),
9785 TEST_CASE_ST(ut_setup, ut_teardown,
9786 test_AES_GCM_auth_decryption_test_case_256_4),
9787 TEST_CASE_ST(ut_setup, ut_teardown,
9788 test_AES_GCM_auth_decryption_test_case_256_5),
9789 TEST_CASE_ST(ut_setup, ut_teardown,
9790 test_AES_GCM_auth_decryption_test_case_256_6),
9791 TEST_CASE_ST(ut_setup, ut_teardown,
9792 test_AES_GCM_auth_decryption_test_case_256_7),
9794 /** Out of place tests */
9795 TEST_CASE_ST(ut_setup, ut_teardown,
9796 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9797 TEST_CASE_ST(ut_setup, ut_teardown,
9798 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9800 /** Scatter-Gather */
9801 TEST_CASE_ST(ut_setup, ut_teardown,
9802 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9803 TEST_CASE_ST(ut_setup, ut_teardown,
9804 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9805 TEST_CASE_ST(ut_setup, ut_teardown,
9806 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9807 TEST_CASE_ST(ut_setup, ut_teardown,
9808 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9810 TEST_CASES_END() /**< NULL terminate unit test array */
9814 static struct unit_test_suite cryptodev_null_testsuite = {
9815 .suite_name = "Crypto Device NULL Unit Test Suite",
9816 .setup = testsuite_setup,
9817 .teardown = testsuite_teardown,
9818 .unit_test_cases = {
9819 TEST_CASE_ST(ut_setup, ut_teardown,
9820 test_null_auth_only_operation),
9821 TEST_CASE_ST(ut_setup, ut_teardown,
9822 test_null_cipher_only_operation),
9823 TEST_CASE_ST(ut_setup, ut_teardown,
9824 test_null_cipher_auth_operation),
9825 TEST_CASE_ST(ut_setup, ut_teardown,
9826 test_null_auth_cipher_operation),
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 test_null_invalid_operation),
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 test_null_burst_operation),
9832 TEST_CASES_END() /**< NULL terminate unit test array */
9836 static struct unit_test_suite cryptodev_armv8_testsuite = {
9837 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9838 .setup = testsuite_setup,
9839 .teardown = testsuite_teardown,
9840 .unit_test_cases = {
9841 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9843 /** Negative tests */
9844 TEST_CASE_ST(ut_setup, ut_teardown,
9845 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9846 TEST_CASE_ST(ut_setup, ut_teardown,
9847 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9849 TEST_CASES_END() /**< NULL terminate unit test array */
9853 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9854 .suite_name = "Crypto Device Marvell Component Test Suite",
9855 .setup = testsuite_setup,
9856 .teardown = testsuite_teardown,
9857 .unit_test_cases = {
9858 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9859 TEST_CASE_ST(ut_setup, ut_teardown,
9860 test_multi_session_random_usage),
9861 TEST_CASE_ST(ut_setup, ut_teardown,
9862 test_AES_chain_mrvl_all),
9863 TEST_CASE_ST(ut_setup, ut_teardown,
9864 test_AES_cipheronly_mrvl_all),
9865 TEST_CASE_ST(ut_setup, ut_teardown,
9866 test_authonly_mrvl_all),
9867 TEST_CASE_ST(ut_setup, ut_teardown,
9868 test_3DES_chain_mrvl_all),
9869 TEST_CASE_ST(ut_setup, ut_teardown,
9870 test_3DES_cipheronly_mrvl_all),
9872 /** Negative tests */
9873 TEST_CASE_ST(ut_setup, ut_teardown,
9874 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9875 TEST_CASE_ST(ut_setup, ut_teardown,
9876 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9882 TEST_CASES_END() /**< NULL terminate unit test array */
9886 static struct unit_test_suite cryptodev_ccp_testsuite = {
9887 .suite_name = "Crypto Device CCP Unit Test Suite",
9888 .setup = testsuite_setup,
9889 .teardown = testsuite_teardown,
9890 .unit_test_cases = {
9891 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9892 TEST_CASE_ST(ut_setup, ut_teardown,
9893 test_multi_session_random_usage),
9894 TEST_CASE_ST(ut_setup, ut_teardown,
9895 test_AES_chain_ccp_all),
9896 TEST_CASE_ST(ut_setup, ut_teardown,
9897 test_AES_cipheronly_ccp_all),
9898 TEST_CASE_ST(ut_setup, ut_teardown,
9899 test_3DES_chain_ccp_all),
9900 TEST_CASE_ST(ut_setup, ut_teardown,
9901 test_3DES_cipheronly_ccp_all),
9902 TEST_CASE_ST(ut_setup, ut_teardown,
9903 test_authonly_ccp_all),
9905 /** Negative tests */
9906 TEST_CASE_ST(ut_setup, ut_teardown,
9907 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9908 TEST_CASE_ST(ut_setup, ut_teardown,
9909 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9910 TEST_CASE_ST(ut_setup, ut_teardown,
9911 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9912 TEST_CASE_ST(ut_setup, ut_teardown,
9913 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9915 TEST_CASES_END() /**< NULL terminate unit test array */
9920 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9922 gbl_driver_id = rte_cryptodev_driver_id_get(
9923 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9925 if (gbl_driver_id == -1) {
9926 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9927 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9928 "in config file to run this testsuite.\n");
9929 return TEST_SKIPPED;
9932 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9936 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9938 gbl_driver_id = rte_cryptodev_driver_id_get(
9939 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9941 if (gbl_driver_id == -1) {
9942 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9943 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9944 "in config file to run this testsuite.\n");
9948 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9952 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9954 gbl_driver_id = rte_cryptodev_driver_id_get(
9955 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9957 if (gbl_driver_id == -1) {
9958 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9959 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9960 "in config file to run this testsuite.\n");
9961 return TEST_SKIPPED;
9964 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9968 test_cryptodev_openssl(void)
9970 gbl_driver_id = rte_cryptodev_driver_id_get(
9971 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9973 if (gbl_driver_id == -1) {
9974 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9975 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9976 "in config file to run this testsuite.\n");
9977 return TEST_SKIPPED;
9980 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9984 test_cryptodev_aesni_gcm(void)
9986 gbl_driver_id = rte_cryptodev_driver_id_get(
9987 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9989 if (gbl_driver_id == -1) {
9990 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9991 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9992 "in config file to run this testsuite.\n");
9993 return TEST_SKIPPED;
9996 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
10000 test_cryptodev_null(void)
10002 gbl_driver_id = rte_cryptodev_driver_id_get(
10003 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
10005 if (gbl_driver_id == -1) {
10006 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
10007 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
10008 "in config file to run this testsuite.\n");
10009 return TEST_SKIPPED;
10012 return unit_test_suite_runner(&cryptodev_null_testsuite);
10016 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10018 gbl_driver_id = rte_cryptodev_driver_id_get(
10019 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10021 if (gbl_driver_id == -1) {
10022 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10023 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10024 "in config file to run this testsuite.\n");
10025 return TEST_SKIPPED;
10028 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10032 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10034 gbl_driver_id = rte_cryptodev_driver_id_get(
10035 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10037 if (gbl_driver_id == -1) {
10038 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10039 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10040 "in config file to run this testsuite.\n");
10041 return TEST_SKIPPED;
10044 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10048 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10050 gbl_driver_id = rte_cryptodev_driver_id_get(
10051 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10053 if (gbl_driver_id == -1) {
10054 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10055 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10056 "in config file to run this testsuite.\n");
10057 return TEST_SKIPPED;
10060 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10064 test_cryptodev_armv8(void)
10066 gbl_driver_id = rte_cryptodev_driver_id_get(
10067 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10069 if (gbl_driver_id == -1) {
10070 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10071 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10072 "in config file to run this testsuite.\n");
10073 return TEST_SKIPPED;
10076 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10080 test_cryptodev_mrvl(void)
10082 gbl_driver_id = rte_cryptodev_driver_id_get(
10083 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10085 if (gbl_driver_id == -1) {
10086 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10087 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10088 "in config file to run this testsuite.\n");
10089 return TEST_SKIPPED;
10092 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10095 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10098 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10100 gbl_driver_id = rte_cryptodev_driver_id_get(
10101 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10103 if (gbl_driver_id == -1) {
10104 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10105 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10106 "in config file to run this testsuite.\n");
10107 return TEST_SKIPPED;
10110 if (rte_cryptodev_driver_id_get(
10111 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10112 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10113 " enabled in config file to run this testsuite.\n");
10114 return TEST_SKIPPED;
10116 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10119 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10124 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10126 gbl_driver_id = rte_cryptodev_driver_id_get(
10127 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10129 if (gbl_driver_id == -1) {
10130 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10131 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10132 "in config file to run this testsuite.\n");
10133 return TEST_SKIPPED;
10136 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10140 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10142 gbl_driver_id = rte_cryptodev_driver_id_get(
10143 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10145 if (gbl_driver_id == -1) {
10146 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10147 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10148 "in config file to run this testsuite.\n");
10149 return TEST_SKIPPED;
10152 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10156 test_cryptodev_ccp(void)
10158 gbl_driver_id = rte_cryptodev_driver_id_get(
10159 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10161 if (gbl_driver_id == -1) {
10162 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10163 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10164 "in config file to run this testsuite.\n");
10165 return TEST_FAILED;
10168 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10171 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10172 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10173 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10174 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10175 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10176 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10177 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10178 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10179 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10180 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10181 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10182 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10183 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10184 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);