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
43 static int gbl_driver_id;
45 struct crypto_testsuite_params {
46 struct rte_mempool *mbuf_pool;
47 struct rte_mempool *large_mbuf_pool;
48 struct rte_mempool *op_mpool;
49 struct rte_mempool *session_mpool;
50 struct rte_cryptodev_config conf;
51 struct rte_cryptodev_qp_conf qp_conf;
53 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
54 uint8_t valid_dev_count;
57 struct crypto_unittest_params {
58 struct rte_crypto_sym_xform cipher_xform;
59 struct rte_crypto_sym_xform auth_xform;
60 struct rte_crypto_sym_xform aead_xform;
62 struct rte_cryptodev_sym_session *sess;
64 struct rte_crypto_op *op;
66 struct rte_mbuf *obuf, *ibuf;
71 #define ALIGN_POW2_ROUNDUP(num, align) \
72 (((num) + (align) - 1) & ~((align) - 1))
75 * Forward declarations.
78 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
79 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
83 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
84 struct crypto_unittest_params *ut_params,
85 struct crypto_testsuite_params *ts_param,
86 const uint8_t *cipher,
87 const uint8_t *digest,
90 static struct rte_mbuf *
91 setup_test_string(struct rte_mempool *mpool,
92 const char *string, size_t len, uint8_t blocksize)
94 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
95 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
97 memset(m->buf_addr, 0, m->buf_len);
99 char *dst = rte_pktmbuf_append(m, t_len);
106 rte_memcpy(dst, string, t_len);
108 memset(dst, 0, t_len);
114 /* Get number of bytes in X bits (rounding up) */
116 ceil_byte_length(uint32_t num_bits)
119 return ((num_bits >> 3) + 1);
121 return (num_bits >> 3);
124 static struct rte_crypto_op *
125 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
127 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
128 printf("Error sending packet for encryption");
134 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
140 static struct crypto_testsuite_params testsuite_params = { NULL };
141 static struct crypto_unittest_params unittest_params;
144 testsuite_setup(void)
146 struct crypto_testsuite_params *ts_params = &testsuite_params;
147 struct rte_cryptodev_info info;
148 uint32_t i = 0, nb_devs, dev_id;
152 memset(ts_params, 0, sizeof(*ts_params));
154 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
155 if (ts_params->mbuf_pool == NULL) {
156 /* Not already created so create */
157 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
159 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
161 if (ts_params->mbuf_pool == NULL) {
162 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
167 ts_params->large_mbuf_pool = rte_mempool_lookup(
168 "CRYPTO_LARGE_MBUFPOOL");
169 if (ts_params->large_mbuf_pool == NULL) {
170 /* Not already created so create */
171 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
172 "CRYPTO_LARGE_MBUFPOOL",
175 if (ts_params->large_mbuf_pool == NULL) {
177 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
182 ts_params->op_mpool = rte_crypto_op_pool_create(
183 "MBUF_CRYPTO_SYM_OP_POOL",
184 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
185 NUM_MBUFS, MBUF_CACHE_SIZE,
187 sizeof(struct rte_crypto_sym_xform) +
190 if (ts_params->op_mpool == NULL) {
191 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
195 /* Create an AESNI MB device if required */
196 if (gbl_driver_id == rte_cryptodev_driver_id_get(
197 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
198 nb_devs = rte_cryptodev_device_count_by_driver(
199 rte_cryptodev_driver_id_get(
200 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
203 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
205 TEST_ASSERT(ret == 0,
206 "Failed to create instance of"
208 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
212 /* Create an AESNI GCM device if required */
213 if (gbl_driver_id == rte_cryptodev_driver_id_get(
214 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
215 nb_devs = rte_cryptodev_device_count_by_driver(
216 rte_cryptodev_driver_id_get(
217 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
219 TEST_ASSERT_SUCCESS(rte_vdev_init(
220 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
221 "Failed to create instance of"
223 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
227 /* Create a SNOW 3G device if required */
228 if (gbl_driver_id == rte_cryptodev_driver_id_get(
229 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
230 nb_devs = rte_cryptodev_device_count_by_driver(
231 rte_cryptodev_driver_id_get(
232 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
234 TEST_ASSERT_SUCCESS(rte_vdev_init(
235 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
236 "Failed to create instance of"
238 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
242 /* Create a KASUMI device if required */
243 if (gbl_driver_id == rte_cryptodev_driver_id_get(
244 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
245 nb_devs = rte_cryptodev_device_count_by_driver(
246 rte_cryptodev_driver_id_get(
247 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
249 TEST_ASSERT_SUCCESS(rte_vdev_init(
250 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
251 "Failed to create instance of"
253 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
257 /* Create a ZUC device if required */
258 if (gbl_driver_id == rte_cryptodev_driver_id_get(
259 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
260 nb_devs = rte_cryptodev_device_count_by_driver(
261 rte_cryptodev_driver_id_get(
262 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
264 TEST_ASSERT_SUCCESS(rte_vdev_init(
265 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
266 "Failed to create instance of"
268 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
272 /* Create a NULL device if required */
273 if (gbl_driver_id == rte_cryptodev_driver_id_get(
274 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
275 nb_devs = rte_cryptodev_device_count_by_driver(
276 rte_cryptodev_driver_id_get(
277 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
280 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
282 TEST_ASSERT(ret == 0,
283 "Failed to create instance of"
285 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
289 /* Create an OPENSSL device if required */
290 if (gbl_driver_id == rte_cryptodev_driver_id_get(
291 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
292 nb_devs = rte_cryptodev_device_count_by_driver(
293 rte_cryptodev_driver_id_get(
294 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
297 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
300 TEST_ASSERT(ret == 0, "Failed to create "
301 "instance of pmd : %s",
302 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
306 /* Create a ARMv8 device if required */
307 if (gbl_driver_id == rte_cryptodev_driver_id_get(
308 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
309 nb_devs = rte_cryptodev_device_count_by_driver(
310 rte_cryptodev_driver_id_get(
311 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
314 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
317 TEST_ASSERT(ret == 0, "Failed to create "
318 "instance of pmd : %s",
319 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
323 /* Create a MVSAM device if required */
324 if (gbl_driver_id == rte_cryptodev_driver_id_get(
325 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
326 nb_devs = rte_cryptodev_device_count_by_driver(
327 rte_cryptodev_driver_id_get(
328 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
331 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
334 TEST_ASSERT(ret == 0, "Failed to create "
335 "instance of pmd : %s",
336 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
340 /* Create an CCP device if required */
341 if (gbl_driver_id == rte_cryptodev_driver_id_get(
342 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
343 nb_devs = rte_cryptodev_device_count_by_driver(
344 rte_cryptodev_driver_id_get(
345 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
348 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
351 TEST_ASSERT(ret == 0, "Failed to create "
352 "instance of pmd : %s",
353 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
357 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
358 char vdev_args[VDEV_ARGS_SIZE] = {""};
359 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
360 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
361 uint16_t slave_core_count = 0;
362 uint16_t socket_id = 0;
364 if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
367 /* Identify the Slave Cores
368 * Use 2 slave cores for the device args
370 RTE_LCORE_FOREACH_SLAVE(i) {
371 if (slave_core_count > 1)
373 snprintf(vdev_args, sizeof(vdev_args),
374 "%s%d", temp_str, i);
375 strcpy(temp_str, vdev_args);
376 strcat(temp_str, ";");
378 socket_id = lcore_config[i].socket_id;
380 if (slave_core_count != 2) {
382 "Cryptodev scheduler test require at least "
383 "two slave cores to run. "
384 "Please use the correct coremask.\n");
387 strcpy(temp_str, vdev_args);
388 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
389 temp_str, socket_id);
390 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
391 nb_devs = rte_cryptodev_device_count_by_driver(
392 rte_cryptodev_driver_id_get(
393 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
396 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
398 TEST_ASSERT(ret == 0,
399 "Failed to create instance %u of"
401 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
404 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
406 nb_devs = rte_cryptodev_count();
408 RTE_LOG(ERR, USER1, "No crypto devices found?\n");
412 /* Create list of valid crypto devs */
413 for (i = 0; i < nb_devs; i++) {
414 rte_cryptodev_info_get(i, &info);
415 if (info.driver_id == gbl_driver_id)
416 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
419 if (ts_params->valid_dev_count < 1)
422 /* Set up all the qps on the first of the valid devices found */
424 dev_id = ts_params->valid_devs[0];
426 rte_cryptodev_info_get(dev_id, &info);
428 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
429 ts_params->conf.socket_id = SOCKET_ID_ANY;
431 unsigned int session_size =
432 rte_cryptodev_sym_get_private_session_size(dev_id);
435 * Create mempool with maximum number of sessions * 2,
436 * to include the session headers
438 ts_params->session_mpool = rte_mempool_create(
440 info.sym.max_nb_sessions * 2,
442 0, 0, NULL, NULL, NULL,
446 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
447 "session mempool allocation failed");
449 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
451 "Failed to configure cryptodev %u with %u qps",
452 dev_id, ts_params->conf.nb_queue_pairs);
454 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
456 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
457 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
458 dev_id, qp_id, &ts_params->qp_conf,
459 rte_cryptodev_socket_id(dev_id),
460 ts_params->session_mpool),
461 "Failed to setup queue pair %u on cryptodev %u",
469 testsuite_teardown(void)
471 struct crypto_testsuite_params *ts_params = &testsuite_params;
473 if (ts_params->mbuf_pool != NULL) {
474 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
475 rte_mempool_avail_count(ts_params->mbuf_pool));
478 if (ts_params->op_mpool != NULL) {
479 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
480 rte_mempool_avail_count(ts_params->op_mpool));
483 /* Free session mempools */
484 if (ts_params->session_mpool != NULL) {
485 rte_mempool_free(ts_params->session_mpool);
486 ts_params->session_mpool = NULL;
493 struct crypto_testsuite_params *ts_params = &testsuite_params;
494 struct crypto_unittest_params *ut_params = &unittest_params;
498 /* Clear unit test parameters before running test */
499 memset(ut_params, 0, sizeof(*ut_params));
501 /* Reconfigure device to default parameters */
502 ts_params->conf.socket_id = SOCKET_ID_ANY;
504 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
506 "Failed to configure cryptodev %u",
507 ts_params->valid_devs[0]);
509 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
510 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
511 ts_params->valid_devs[0], qp_id,
513 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
514 ts_params->session_mpool),
515 "Failed to setup queue pair %u on cryptodev %u",
516 qp_id, ts_params->valid_devs[0]);
520 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
522 /* Start the device */
523 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
524 "Failed to start cryptodev %u",
525 ts_params->valid_devs[0]);
533 struct crypto_testsuite_params *ts_params = &testsuite_params;
534 struct crypto_unittest_params *ut_params = &unittest_params;
535 struct rte_cryptodev_stats stats;
537 /* free crypto session structure */
538 if (ut_params->sess) {
539 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
541 rte_cryptodev_sym_session_free(ut_params->sess);
542 ut_params->sess = NULL;
545 /* free crypto operation structure */
547 rte_crypto_op_free(ut_params->op);
550 * free mbuf - both obuf and ibuf are usually the same,
551 * so check if they point at the same address is necessary,
552 * to avoid freeing the mbuf twice.
554 if (ut_params->obuf) {
555 rte_pktmbuf_free(ut_params->obuf);
556 if (ut_params->ibuf == ut_params->obuf)
560 if (ut_params->ibuf) {
561 rte_pktmbuf_free(ut_params->ibuf);
565 if (ts_params->mbuf_pool != NULL)
566 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
567 rte_mempool_avail_count(ts_params->mbuf_pool));
569 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
571 /* Stop the device */
572 rte_cryptodev_stop(ts_params->valid_devs[0]);
576 test_device_configure_invalid_dev_id(void)
578 struct crypto_testsuite_params *ts_params = &testsuite_params;
579 uint16_t dev_id, num_devs = 0;
581 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
582 "Need at least %d devices for test", 1);
584 /* valid dev_id values */
585 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
587 /* Stop the device in case it's started so it can be configured */
588 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
590 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
591 "Failed test for rte_cryptodev_configure: "
592 "invalid dev_num %u", dev_id);
594 /* invalid dev_id values */
597 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
598 "Failed test for rte_cryptodev_configure: "
599 "invalid dev_num %u", dev_id);
603 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
604 "Failed test for rte_cryptodev_configure:"
605 "invalid dev_num %u", dev_id);
611 test_device_configure_invalid_queue_pair_ids(void)
613 struct crypto_testsuite_params *ts_params = &testsuite_params;
614 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
616 /* Stop the device in case it's started so it can be configured */
617 rte_cryptodev_stop(ts_params->valid_devs[0]);
619 /* valid - one queue pairs */
620 ts_params->conf.nb_queue_pairs = 1;
622 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
624 "Failed to configure cryptodev: dev_id %u, qp_id %u",
625 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
628 /* valid - max value queue pairs */
629 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
631 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
633 "Failed to configure cryptodev: dev_id %u, qp_id %u",
634 ts_params->valid_devs[0],
635 ts_params->conf.nb_queue_pairs);
638 /* invalid - zero queue pairs */
639 ts_params->conf.nb_queue_pairs = 0;
641 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
643 "Failed test for rte_cryptodev_configure, dev_id %u,"
645 ts_params->valid_devs[0],
646 ts_params->conf.nb_queue_pairs);
649 /* invalid - max value supported by field queue pairs */
650 ts_params->conf.nb_queue_pairs = UINT16_MAX;
652 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
654 "Failed test for rte_cryptodev_configure, dev_id %u,"
656 ts_params->valid_devs[0],
657 ts_params->conf.nb_queue_pairs);
660 /* invalid - max value + 1 queue pairs */
661 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
663 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
665 "Failed test for rte_cryptodev_configure, dev_id %u,"
667 ts_params->valid_devs[0],
668 ts_params->conf.nb_queue_pairs);
670 /* revert to original testsuite value */
671 ts_params->conf.nb_queue_pairs = orig_nb_qps;
677 test_queue_pair_descriptor_setup(void)
679 struct crypto_testsuite_params *ts_params = &testsuite_params;
680 struct rte_cryptodev_info dev_info;
681 struct rte_cryptodev_qp_conf qp_conf = {
682 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
687 /* Stop the device in case it's started so it can be configured */
688 rte_cryptodev_stop(ts_params->valid_devs[0]);
691 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
693 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
695 "Failed to configure cryptodev %u",
696 ts_params->valid_devs[0]);
699 * Test various ring sizes on this device. memzones can't be
700 * freed so are re-used if ring is released and re-created.
702 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
704 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
705 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
706 ts_params->valid_devs[0], qp_id, &qp_conf,
707 rte_cryptodev_socket_id(
708 ts_params->valid_devs[0]),
709 ts_params->session_mpool),
711 "rte_cryptodev_queue_pair_setup: num_inflights "
712 "%u on qp %u on cryptodev %u",
713 qp_conf.nb_descriptors, qp_id,
714 ts_params->valid_devs[0]);
717 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
719 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
720 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
721 ts_params->valid_devs[0], qp_id, &qp_conf,
722 rte_cryptodev_socket_id(
723 ts_params->valid_devs[0]),
724 ts_params->session_mpool),
726 " rte_cryptodev_queue_pair_setup: num_inflights"
727 " %u on qp %u on cryptodev %u",
728 qp_conf.nb_descriptors, qp_id,
729 ts_params->valid_devs[0]);
732 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
734 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
735 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
736 ts_params->valid_devs[0], qp_id, &qp_conf,
737 rte_cryptodev_socket_id(
738 ts_params->valid_devs[0]),
739 ts_params->session_mpool),
741 "rte_cryptodev_queue_pair_setup: num_inflights"
742 " %u on qp %u on cryptodev %u",
743 qp_conf.nb_descriptors, qp_id,
744 ts_params->valid_devs[0]);
747 /* invalid number of descriptors - max supported + 2 */
748 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
750 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
751 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
752 ts_params->valid_devs[0], qp_id, &qp_conf,
753 rte_cryptodev_socket_id(
754 ts_params->valid_devs[0]),
755 ts_params->session_mpool),
756 "Unexpectedly passed test for "
757 "rte_cryptodev_queue_pair_setup:"
758 "num_inflights %u on qp %u on cryptodev %u",
759 qp_conf.nb_descriptors, qp_id,
760 ts_params->valid_devs[0]);
763 /* invalid number of descriptors - max value of parameter */
764 qp_conf.nb_descriptors = UINT32_MAX-1;
766 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
767 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
768 ts_params->valid_devs[0], qp_id, &qp_conf,
769 rte_cryptodev_socket_id(
770 ts_params->valid_devs[0]),
771 ts_params->session_mpool),
772 "Unexpectedly passed test for "
773 "rte_cryptodev_queue_pair_setup:"
774 "num_inflights %u on qp %u on cryptodev %u",
775 qp_conf.nb_descriptors, qp_id,
776 ts_params->valid_devs[0]);
779 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
781 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
782 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
783 ts_params->valid_devs[0], qp_id, &qp_conf,
784 rte_cryptodev_socket_id(
785 ts_params->valid_devs[0]),
786 ts_params->session_mpool),
788 " rte_cryptodev_queue_pair_setup:"
789 "num_inflights %u on qp %u on cryptodev %u",
790 qp_conf.nb_descriptors, qp_id,
791 ts_params->valid_devs[0]);
794 /* invalid number of descriptors - max supported + 1 */
795 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
797 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
798 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
799 ts_params->valid_devs[0], qp_id, &qp_conf,
800 rte_cryptodev_socket_id(
801 ts_params->valid_devs[0]),
802 ts_params->session_mpool),
803 "Unexpectedly passed test for "
804 "rte_cryptodev_queue_pair_setup:"
805 "num_inflights %u on qp %u on cryptodev %u",
806 qp_conf.nb_descriptors, qp_id,
807 ts_params->valid_devs[0]);
810 /* test invalid queue pair id */
811 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
813 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
815 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
816 ts_params->valid_devs[0],
818 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
819 ts_params->session_mpool),
820 "Failed test for rte_cryptodev_queue_pair_setup:"
821 "invalid qp %u on cryptodev %u",
822 qp_id, ts_params->valid_devs[0]);
824 qp_id = 0xffff; /*invalid*/
826 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
827 ts_params->valid_devs[0],
829 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
830 ts_params->session_mpool),
831 "Failed test for rte_cryptodev_queue_pair_setup:"
832 "invalid qp %u on cryptodev %u",
833 qp_id, ts_params->valid_devs[0]);
838 /* ***** Plaintext data for tests ***** */
840 const char catch_22_quote_1[] =
841 "There was only one catch and that was Catch-22, which "
842 "specified that a concern for one's safety in the face of "
843 "dangers that were real and immediate was the process of a "
844 "rational mind. Orr was crazy and could be grounded. All he "
845 "had to do was ask; and as soon as he did, he would no longer "
846 "be crazy and would have to fly more missions. Orr would be "
847 "crazy to fly more missions and sane if he didn't, but if he "
848 "was sane he had to fly them. If he flew them he was crazy "
849 "and didn't have to; but if he didn't want to he was sane and "
850 "had to. Yossarian was moved very deeply by the absolute "
851 "simplicity of this clause of Catch-22 and let out a "
852 "respectful whistle. \"That's some catch, that Catch-22\", he "
853 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
855 const char catch_22_quote[] =
856 "What a lousy earth! He wondered how many people were "
857 "destitute that same night even in his own prosperous country, "
858 "how many homes were shanties, how many husbands were drunk "
859 "and wives socked, and how many children were bullied, abused, "
860 "or abandoned. How many families hungered for food they could "
861 "not afford to buy? How many hearts were broken? How many "
862 "suicides would take place that same night, how many people "
863 "would go insane? How many cockroaches and landlords would "
864 "triumph? How many winners were losers, successes failures, "
865 "and rich men poor men? How many wise guys were stupid? How "
866 "many happy endings were unhappy endings? How many honest men "
867 "were liars, brave men cowards, loyal men traitors, how many "
868 "sainted men were corrupt, how many people in positions of "
869 "trust had sold their souls to bodyguards, how many had never "
870 "had souls? How many straight-and-narrow paths were crooked "
871 "paths? How many best families were worst families and how "
872 "many good people were bad people? When you added them all up "
873 "and then subtracted, you might be left with only the children, "
874 "and perhaps with Albert Einstein and an old violinist or "
875 "sculptor somewhere.";
877 #define QUOTE_480_BYTES (480)
878 #define QUOTE_512_BYTES (512)
879 #define QUOTE_768_BYTES (768)
880 #define QUOTE_1024_BYTES (1024)
884 /* ***** SHA1 Hash Tests ***** */
886 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
888 static uint8_t hmac_sha1_key[] = {
889 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
890 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
891 0xDE, 0xF4, 0xDE, 0xAD };
893 /* ***** SHA224 Hash Tests ***** */
895 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
898 /* ***** AES-CBC Cipher Tests ***** */
900 #define CIPHER_KEY_LENGTH_AES_CBC (16)
901 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
903 static uint8_t aes_cbc_key[] = {
904 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
905 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
907 static uint8_t aes_cbc_iv[] = {
908 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
909 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
912 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
914 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
915 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
916 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
917 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
918 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
919 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
920 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
921 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
922 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
923 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
924 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
925 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
926 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
927 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
928 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
929 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
930 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
931 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
932 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
933 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
934 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
935 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
936 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
937 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
938 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
939 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
940 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
941 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
942 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
943 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
944 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
945 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
946 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
947 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
948 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
949 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
950 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
951 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
952 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
953 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
954 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
955 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
956 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
957 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
958 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
959 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
960 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
961 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
962 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
963 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
964 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
965 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
966 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
967 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
968 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
969 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
970 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
971 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
972 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
973 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
974 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
975 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
976 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
977 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
978 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
981 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
982 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
983 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
984 0x18, 0x8c, 0x1d, 0x32
988 /* Multisession Vector context Test */
990 static uint8_t ms_aes_cbc_key0[] = {
991 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
992 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
995 static uint8_t ms_aes_cbc_iv0[] = {
996 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
997 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1000 static const uint8_t ms_aes_cbc_cipher0[] = {
1001 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1002 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1003 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1004 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1005 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1006 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1007 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1008 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1009 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1010 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1011 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1012 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1013 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1014 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1015 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1016 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1017 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1018 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1019 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1020 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1021 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1022 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1023 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1024 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1025 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1026 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1027 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1028 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1029 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1030 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1031 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1032 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1033 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1034 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1035 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1036 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1037 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1038 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1039 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1040 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1041 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1042 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1043 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1044 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1045 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1046 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1047 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1048 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1049 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1050 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1051 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1052 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1053 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1054 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1055 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1056 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1057 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1058 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1059 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1060 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1061 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1062 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1063 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1064 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1068 static uint8_t ms_hmac_key0[] = {
1069 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1070 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1071 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1072 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1073 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1074 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1075 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1076 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1079 static const uint8_t ms_hmac_digest0[] = {
1080 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1081 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1082 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1083 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1084 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1085 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1086 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1087 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1091 /* Begin session 1 */
1093 static uint8_t ms_aes_cbc_key1[] = {
1094 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1095 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1098 static uint8_t ms_aes_cbc_iv1[] = {
1099 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1100 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1103 static const uint8_t ms_aes_cbc_cipher1[] = {
1104 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1105 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1106 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1107 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1108 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1109 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1110 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1111 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1112 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1113 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1114 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1115 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1116 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1117 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1118 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1119 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1120 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1121 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1122 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1123 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1124 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1125 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1126 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1127 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1128 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1129 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1130 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1131 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1132 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1133 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1134 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1135 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1136 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1137 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1138 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1139 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1140 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1141 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1142 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1143 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1144 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1145 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1146 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1147 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1148 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1149 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1150 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1151 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1152 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1153 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1154 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1155 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1156 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1157 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1158 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1159 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1160 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1161 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1162 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1163 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1164 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1165 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1166 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1167 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1171 static uint8_t ms_hmac_key1[] = {
1172 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1173 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1174 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1175 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1176 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1177 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1178 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1179 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1182 static const uint8_t ms_hmac_digest1[] = {
1183 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1184 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1185 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1186 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1187 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1188 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1189 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1190 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1193 /* Begin Session 2 */
1194 static uint8_t ms_aes_cbc_key2[] = {
1195 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1196 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1199 static uint8_t ms_aes_cbc_iv2[] = {
1200 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1201 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1204 static const uint8_t ms_aes_cbc_cipher2[] = {
1205 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1206 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1207 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1208 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1209 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1210 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1211 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1212 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1213 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1214 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1215 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1216 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1217 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1218 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1219 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1220 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1221 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1222 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1223 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1224 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1225 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1226 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1227 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1228 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1229 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1230 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1231 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1232 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1233 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1234 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1235 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1236 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1237 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1238 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1239 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1240 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1241 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1242 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1243 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1244 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1245 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1246 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1247 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1248 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1249 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1250 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1251 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1252 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1253 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1254 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1255 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1256 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1257 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1258 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1259 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1260 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1261 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1262 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1263 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1264 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1265 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1266 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1267 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1268 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1271 static uint8_t ms_hmac_key2[] = {
1272 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1273 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1274 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1275 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1276 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1277 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1278 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1279 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1282 static const uint8_t ms_hmac_digest2[] = {
1283 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1284 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1285 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1286 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1287 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1288 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1289 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1290 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1297 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1299 struct crypto_testsuite_params *ts_params = &testsuite_params;
1300 struct crypto_unittest_params *ut_params = &unittest_params;
1302 /* Generate test mbuf data and space for digest */
1303 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1304 catch_22_quote, QUOTE_512_BYTES, 0);
1306 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1307 DIGEST_BYTE_LENGTH_SHA1);
1308 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1310 /* Setup Cipher Parameters */
1311 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1312 ut_params->cipher_xform.next = &ut_params->auth_xform;
1314 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1315 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1316 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1317 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1318 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1319 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1321 /* Setup HMAC Parameters */
1322 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1324 ut_params->auth_xform.next = NULL;
1326 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1327 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1328 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1329 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1330 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1332 ut_params->sess = rte_cryptodev_sym_session_create(
1333 ts_params->session_mpool);
1335 /* Create crypto session*/
1336 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1337 ut_params->sess, &ut_params->cipher_xform,
1338 ts_params->session_mpool);
1339 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1341 /* Generate crypto op data structure */
1342 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1343 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1344 TEST_ASSERT_NOT_NULL(ut_params->op,
1345 "Failed to allocate symmetric crypto operation struct");
1347 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1349 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1351 /* set crypto operation source mbuf */
1352 sym_op->m_src = ut_params->ibuf;
1354 /* Set crypto operation authentication parameters */
1355 sym_op->auth.digest.data = ut_params->digest;
1356 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1357 ut_params->ibuf, QUOTE_512_BYTES);
1359 sym_op->auth.data.offset = 0;
1360 sym_op->auth.data.length = QUOTE_512_BYTES;
1362 /* Copy IV at the end of the crypto operation */
1363 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1364 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1366 /* Set crypto operation cipher parameters */
1367 sym_op->cipher.data.offset = 0;
1368 sym_op->cipher.data.length = QUOTE_512_BYTES;
1370 /* Process crypto operation */
1371 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1372 ut_params->op), "failed to process sym crypto op");
1374 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1375 "crypto op processing failed");
1378 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1381 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1382 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1384 "ciphertext data not as expected");
1386 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1388 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1389 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1390 gbl_driver_id == rte_cryptodev_driver_id_get(
1391 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1392 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1393 DIGEST_BYTE_LENGTH_SHA1,
1394 "Generated digest data not as expected");
1396 return TEST_SUCCESS;
1399 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1401 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1403 static uint8_t hmac_sha512_key[] = {
1404 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1405 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1406 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1407 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1408 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1409 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1410 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1411 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1413 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1414 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1415 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1416 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1417 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1418 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1419 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1420 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1421 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1426 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1427 struct crypto_unittest_params *ut_params,
1428 uint8_t *cipher_key,
1432 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1433 struct crypto_unittest_params *ut_params,
1434 struct crypto_testsuite_params *ts_params,
1435 const uint8_t *cipher,
1436 const uint8_t *digest,
1441 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1442 struct crypto_unittest_params *ut_params,
1443 uint8_t *cipher_key,
1447 /* Setup Cipher Parameters */
1448 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1449 ut_params->cipher_xform.next = NULL;
1451 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1452 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1453 ut_params->cipher_xform.cipher.key.data = cipher_key;
1454 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1455 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1456 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1458 /* Setup HMAC Parameters */
1459 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1460 ut_params->auth_xform.next = &ut_params->cipher_xform;
1462 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1463 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1464 ut_params->auth_xform.auth.key.data = hmac_key;
1465 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1466 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1468 return TEST_SUCCESS;
1473 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1474 struct crypto_unittest_params *ut_params,
1475 struct crypto_testsuite_params *ts_params,
1476 const uint8_t *cipher,
1477 const uint8_t *digest,
1480 /* Generate test mbuf data and digest */
1481 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1484 QUOTE_512_BYTES, 0);
1486 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1487 DIGEST_BYTE_LENGTH_SHA512);
1488 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1490 rte_memcpy(ut_params->digest,
1492 DIGEST_BYTE_LENGTH_SHA512);
1494 /* Generate Crypto op data structure */
1495 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1496 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1497 TEST_ASSERT_NOT_NULL(ut_params->op,
1498 "Failed to allocate symmetric crypto operation struct");
1500 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1502 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1504 /* set crypto operation source mbuf */
1505 sym_op->m_src = ut_params->ibuf;
1507 sym_op->auth.digest.data = ut_params->digest;
1508 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1509 ut_params->ibuf, QUOTE_512_BYTES);
1511 sym_op->auth.data.offset = 0;
1512 sym_op->auth.data.length = QUOTE_512_BYTES;
1514 /* Copy IV at the end of the crypto operation */
1515 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1516 iv, CIPHER_IV_LENGTH_AES_CBC);
1518 sym_op->cipher.data.offset = 0;
1519 sym_op->cipher.data.length = QUOTE_512_BYTES;
1521 /* Process crypto operation */
1522 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1523 ut_params->op), "failed to process sym crypto op");
1525 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1526 "crypto op processing failed");
1528 ut_params->obuf = ut_params->op->sym->m_src;
1531 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1532 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1535 "Plaintext data not as expected");
1538 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1539 "Digest verification failed");
1541 return TEST_SUCCESS;
1545 test_AES_cipheronly_mb_all(void)
1547 struct crypto_testsuite_params *ts_params = &testsuite_params;
1550 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1551 ts_params->op_mpool,
1552 ts_params->session_mpool,
1553 ts_params->valid_devs[0],
1554 rte_cryptodev_driver_id_get(
1555 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1556 BLKCIPHER_AES_CIPHERONLY_TYPE);
1558 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1560 return TEST_SUCCESS;
1564 test_AES_docsis_mb_all(void)
1566 struct crypto_testsuite_params *ts_params = &testsuite_params;
1569 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1570 ts_params->op_mpool,
1571 ts_params->session_mpool,
1572 ts_params->valid_devs[0],
1573 rte_cryptodev_driver_id_get(
1574 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1575 BLKCIPHER_AES_DOCSIS_TYPE);
1577 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1579 return TEST_SUCCESS;
1583 test_AES_docsis_qat_all(void)
1585 struct crypto_testsuite_params *ts_params = &testsuite_params;
1588 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1589 ts_params->op_mpool,
1590 ts_params->session_mpool,
1591 ts_params->valid_devs[0],
1592 rte_cryptodev_driver_id_get(
1593 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1594 BLKCIPHER_AES_DOCSIS_TYPE);
1596 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1598 return TEST_SUCCESS;
1602 test_DES_docsis_qat_all(void)
1604 struct crypto_testsuite_params *ts_params = &testsuite_params;
1607 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1608 ts_params->op_mpool,
1609 ts_params->session_mpool,
1610 ts_params->valid_devs[0],
1611 rte_cryptodev_driver_id_get(
1612 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1613 BLKCIPHER_DES_DOCSIS_TYPE);
1615 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1617 return TEST_SUCCESS;
1621 test_authonly_mb_all(void)
1623 struct crypto_testsuite_params *ts_params = &testsuite_params;
1626 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1627 ts_params->op_mpool,
1628 ts_params->session_mpool,
1629 ts_params->valid_devs[0],
1630 rte_cryptodev_driver_id_get(
1631 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1632 BLKCIPHER_AUTHONLY_TYPE);
1634 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1636 return TEST_SUCCESS;
1640 test_authonly_qat_all(void)
1642 struct crypto_testsuite_params *ts_params = &testsuite_params;
1645 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1646 ts_params->op_mpool,
1647 ts_params->session_mpool,
1648 ts_params->valid_devs[0],
1649 rte_cryptodev_driver_id_get(
1650 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1651 BLKCIPHER_AUTHONLY_TYPE);
1653 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1655 return TEST_SUCCESS;
1658 test_AES_chain_mb_all(void)
1660 struct crypto_testsuite_params *ts_params = &testsuite_params;
1663 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1664 ts_params->op_mpool,
1665 ts_params->session_mpool,
1666 ts_params->valid_devs[0],
1667 rte_cryptodev_driver_id_get(
1668 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1669 BLKCIPHER_AES_CHAIN_TYPE);
1671 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1673 return TEST_SUCCESS;
1676 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1679 test_AES_cipheronly_scheduler_all(void)
1681 struct crypto_testsuite_params *ts_params = &testsuite_params;
1684 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1685 ts_params->op_mpool,
1686 ts_params->session_mpool,
1687 ts_params->valid_devs[0],
1688 rte_cryptodev_driver_id_get(
1689 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1690 BLKCIPHER_AES_CIPHERONLY_TYPE);
1692 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1694 return TEST_SUCCESS;
1698 test_AES_chain_scheduler_all(void)
1700 struct crypto_testsuite_params *ts_params = &testsuite_params;
1703 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1704 ts_params->op_mpool,
1705 ts_params->session_mpool,
1706 ts_params->valid_devs[0],
1707 rte_cryptodev_driver_id_get(
1708 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1709 BLKCIPHER_AES_CHAIN_TYPE);
1711 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1713 return TEST_SUCCESS;
1717 test_authonly_scheduler_all(void)
1719 struct crypto_testsuite_params *ts_params = &testsuite_params;
1722 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1723 ts_params->op_mpool,
1724 ts_params->session_mpool,
1725 ts_params->valid_devs[0],
1726 rte_cryptodev_driver_id_get(
1727 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1728 BLKCIPHER_AUTHONLY_TYPE);
1730 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1732 return TEST_SUCCESS;
1735 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1738 test_AES_chain_openssl_all(void)
1740 struct crypto_testsuite_params *ts_params = &testsuite_params;
1743 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1744 ts_params->op_mpool,
1745 ts_params->session_mpool,
1746 ts_params->valid_devs[0],
1747 rte_cryptodev_driver_id_get(
1748 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1749 BLKCIPHER_AES_CHAIN_TYPE);
1751 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1753 return TEST_SUCCESS;
1757 test_AES_cipheronly_openssl_all(void)
1759 struct crypto_testsuite_params *ts_params = &testsuite_params;
1762 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1763 ts_params->op_mpool,
1764 ts_params->session_mpool,
1765 ts_params->valid_devs[0],
1766 rte_cryptodev_driver_id_get(
1767 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1768 BLKCIPHER_AES_CIPHERONLY_TYPE);
1770 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1772 return TEST_SUCCESS;
1776 test_AES_chain_ccp_all(void)
1778 struct crypto_testsuite_params *ts_params = &testsuite_params;
1781 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1782 ts_params->op_mpool,
1783 ts_params->session_mpool,
1784 ts_params->valid_devs[0],
1785 rte_cryptodev_driver_id_get(
1786 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1787 BLKCIPHER_AES_CHAIN_TYPE);
1789 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1791 return TEST_SUCCESS;
1795 test_AES_cipheronly_ccp_all(void)
1797 struct crypto_testsuite_params *ts_params = &testsuite_params;
1800 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1801 ts_params->op_mpool,
1802 ts_params->session_mpool,
1803 ts_params->valid_devs[0],
1804 rte_cryptodev_driver_id_get(
1805 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1806 BLKCIPHER_AES_CIPHERONLY_TYPE);
1808 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1810 return TEST_SUCCESS;
1814 test_AES_chain_qat_all(void)
1816 struct crypto_testsuite_params *ts_params = &testsuite_params;
1819 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1820 ts_params->op_mpool,
1821 ts_params->session_mpool,
1822 ts_params->valid_devs[0],
1823 rte_cryptodev_driver_id_get(
1824 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1825 BLKCIPHER_AES_CHAIN_TYPE);
1827 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1829 return TEST_SUCCESS;
1833 test_AES_cipheronly_qat_all(void)
1835 struct crypto_testsuite_params *ts_params = &testsuite_params;
1838 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1839 ts_params->op_mpool,
1840 ts_params->session_mpool,
1841 ts_params->valid_devs[0],
1842 rte_cryptodev_driver_id_get(
1843 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1844 BLKCIPHER_AES_CIPHERONLY_TYPE);
1846 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1848 return TEST_SUCCESS;
1852 test_AES_cipheronly_virtio_all(void)
1854 struct crypto_testsuite_params *ts_params = &testsuite_params;
1857 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1858 ts_params->op_mpool,
1859 ts_params->session_mpool,
1860 ts_params->valid_devs[0],
1861 rte_cryptodev_driver_id_get(
1862 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1863 BLKCIPHER_AES_CIPHERONLY_TYPE);
1865 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1867 return TEST_SUCCESS;
1871 test_AES_chain_dpaa_sec_all(void)
1873 struct crypto_testsuite_params *ts_params = &testsuite_params;
1876 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1877 ts_params->op_mpool,
1878 ts_params->session_mpool,
1879 ts_params->valid_devs[0],
1880 rte_cryptodev_driver_id_get(
1881 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1882 BLKCIPHER_AES_CHAIN_TYPE);
1884 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1886 return TEST_SUCCESS;
1890 test_AES_cipheronly_dpaa_sec_all(void)
1892 struct crypto_testsuite_params *ts_params = &testsuite_params;
1895 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1896 ts_params->op_mpool,
1897 ts_params->session_mpool,
1898 ts_params->valid_devs[0],
1899 rte_cryptodev_driver_id_get(
1900 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1901 BLKCIPHER_AES_CIPHERONLY_TYPE);
1903 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1905 return TEST_SUCCESS;
1909 test_authonly_dpaa_sec_all(void)
1911 struct crypto_testsuite_params *ts_params = &testsuite_params;
1914 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1915 ts_params->op_mpool,
1916 ts_params->session_mpool,
1917 ts_params->valid_devs[0],
1918 rte_cryptodev_driver_id_get(
1919 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1920 BLKCIPHER_AUTHONLY_TYPE);
1922 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1924 return TEST_SUCCESS;
1928 test_AES_chain_dpaa2_sec_all(void)
1930 struct crypto_testsuite_params *ts_params = &testsuite_params;
1933 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1934 ts_params->op_mpool,
1935 ts_params->session_mpool,
1936 ts_params->valid_devs[0],
1937 rte_cryptodev_driver_id_get(
1938 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1939 BLKCIPHER_AES_CHAIN_TYPE);
1941 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1943 return TEST_SUCCESS;
1947 test_AES_cipheronly_dpaa2_sec_all(void)
1949 struct crypto_testsuite_params *ts_params = &testsuite_params;
1952 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1953 ts_params->op_mpool,
1954 ts_params->session_mpool,
1955 ts_params->valid_devs[0],
1956 rte_cryptodev_driver_id_get(
1957 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1958 BLKCIPHER_AES_CIPHERONLY_TYPE);
1960 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1962 return TEST_SUCCESS;
1966 test_authonly_dpaa2_sec_all(void)
1968 struct crypto_testsuite_params *ts_params = &testsuite_params;
1971 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1972 ts_params->op_mpool,
1973 ts_params->session_mpool,
1974 ts_params->valid_devs[0],
1975 rte_cryptodev_driver_id_get(
1976 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1977 BLKCIPHER_AUTHONLY_TYPE);
1979 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1981 return TEST_SUCCESS;
1985 test_authonly_openssl_all(void)
1987 struct crypto_testsuite_params *ts_params = &testsuite_params;
1990 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1991 ts_params->op_mpool,
1992 ts_params->session_mpool,
1993 ts_params->valid_devs[0],
1994 rte_cryptodev_driver_id_get(
1995 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1996 BLKCIPHER_AUTHONLY_TYPE);
1998 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2000 return TEST_SUCCESS;
2004 test_authonly_ccp_all(void)
2006 struct crypto_testsuite_params *ts_params = &testsuite_params;
2009 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2010 ts_params->op_mpool,
2011 ts_params->session_mpool,
2012 ts_params->valid_devs[0],
2013 rte_cryptodev_driver_id_get(
2014 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2015 BLKCIPHER_AUTHONLY_TYPE);
2017 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2019 return TEST_SUCCESS;
2023 test_AES_chain_armv8_all(void)
2025 struct crypto_testsuite_params *ts_params = &testsuite_params;
2028 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2029 ts_params->op_mpool,
2030 ts_params->session_mpool,
2031 ts_params->valid_devs[0],
2032 rte_cryptodev_driver_id_get(
2033 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2034 BLKCIPHER_AES_CHAIN_TYPE);
2036 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2038 return TEST_SUCCESS;
2042 test_AES_chain_mrvl_all(void)
2044 struct crypto_testsuite_params *ts_params = &testsuite_params;
2047 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2048 ts_params->op_mpool,
2049 ts_params->session_mpool,
2050 ts_params->valid_devs[0],
2051 rte_cryptodev_driver_id_get(
2052 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2053 BLKCIPHER_AES_CHAIN_TYPE);
2055 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2057 return TEST_SUCCESS;
2061 test_AES_cipheronly_mrvl_all(void)
2063 struct crypto_testsuite_params *ts_params = &testsuite_params;
2066 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2067 ts_params->op_mpool,
2068 ts_params->session_mpool,
2069 ts_params->valid_devs[0],
2070 rte_cryptodev_driver_id_get(
2071 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2072 BLKCIPHER_AES_CIPHERONLY_TYPE);
2074 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2076 return TEST_SUCCESS;
2080 test_authonly_mrvl_all(void)
2082 struct crypto_testsuite_params *ts_params = &testsuite_params;
2085 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2086 ts_params->op_mpool,
2087 ts_params->session_mpool,
2088 ts_params->valid_devs[0],
2089 rte_cryptodev_driver_id_get(
2090 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2091 BLKCIPHER_AUTHONLY_TYPE);
2093 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2095 return TEST_SUCCESS;
2099 test_3DES_chain_mrvl_all(void)
2101 struct crypto_testsuite_params *ts_params = &testsuite_params;
2104 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2105 ts_params->op_mpool,
2106 ts_params->session_mpool,
2107 ts_params->valid_devs[0],
2108 rte_cryptodev_driver_id_get(
2109 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2110 BLKCIPHER_3DES_CHAIN_TYPE);
2112 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2114 return TEST_SUCCESS;
2118 test_3DES_cipheronly_mrvl_all(void)
2120 struct crypto_testsuite_params *ts_params = &testsuite_params;
2123 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2124 ts_params->op_mpool,
2125 ts_params->session_mpool,
2126 ts_params->valid_devs[0],
2127 rte_cryptodev_driver_id_get(
2128 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2129 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2131 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2133 return TEST_SUCCESS;
2136 /* ***** SNOW 3G Tests ***** */
2138 create_wireless_algo_hash_session(uint8_t dev_id,
2139 const uint8_t *key, const uint8_t key_len,
2140 const uint8_t iv_len, const uint8_t auth_len,
2141 enum rte_crypto_auth_operation op,
2142 enum rte_crypto_auth_algorithm algo)
2144 uint8_t hash_key[key_len];
2146 struct crypto_testsuite_params *ts_params = &testsuite_params;
2147 struct crypto_unittest_params *ut_params = &unittest_params;
2149 memcpy(hash_key, key, key_len);
2151 debug_hexdump(stdout, "key:", key, key_len);
2153 /* Setup Authentication Parameters */
2154 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2155 ut_params->auth_xform.next = NULL;
2157 ut_params->auth_xform.auth.op = op;
2158 ut_params->auth_xform.auth.algo = algo;
2159 ut_params->auth_xform.auth.key.length = key_len;
2160 ut_params->auth_xform.auth.key.data = hash_key;
2161 ut_params->auth_xform.auth.digest_length = auth_len;
2162 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2163 ut_params->auth_xform.auth.iv.length = iv_len;
2164 ut_params->sess = rte_cryptodev_sym_session_create(
2165 ts_params->session_mpool);
2167 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2168 &ut_params->auth_xform, ts_params->session_mpool);
2169 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2174 create_wireless_algo_cipher_session(uint8_t dev_id,
2175 enum rte_crypto_cipher_operation op,
2176 enum rte_crypto_cipher_algorithm algo,
2177 const uint8_t *key, const uint8_t key_len,
2180 uint8_t cipher_key[key_len];
2182 struct crypto_testsuite_params *ts_params = &testsuite_params;
2183 struct crypto_unittest_params *ut_params = &unittest_params;
2185 memcpy(cipher_key, key, key_len);
2187 /* Setup Cipher Parameters */
2188 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2189 ut_params->cipher_xform.next = NULL;
2191 ut_params->cipher_xform.cipher.algo = algo;
2192 ut_params->cipher_xform.cipher.op = op;
2193 ut_params->cipher_xform.cipher.key.data = cipher_key;
2194 ut_params->cipher_xform.cipher.key.length = key_len;
2195 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2196 ut_params->cipher_xform.cipher.iv.length = iv_len;
2198 debug_hexdump(stdout, "key:", key, key_len);
2200 /* Create Crypto session */
2201 ut_params->sess = rte_cryptodev_sym_session_create(
2202 ts_params->session_mpool);
2204 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2205 &ut_params->cipher_xform, ts_params->session_mpool);
2206 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2211 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2212 unsigned int cipher_len,
2213 unsigned int cipher_offset)
2215 struct crypto_testsuite_params *ts_params = &testsuite_params;
2216 struct crypto_unittest_params *ut_params = &unittest_params;
2218 /* Generate Crypto op data structure */
2219 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2220 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2221 TEST_ASSERT_NOT_NULL(ut_params->op,
2222 "Failed to allocate pktmbuf offload");
2224 /* Set crypto operation data parameters */
2225 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2227 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2229 /* set crypto operation source mbuf */
2230 sym_op->m_src = ut_params->ibuf;
2233 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2235 sym_op->cipher.data.length = cipher_len;
2236 sym_op->cipher.data.offset = cipher_offset;
2241 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2242 unsigned int cipher_len,
2243 unsigned int cipher_offset)
2245 struct crypto_testsuite_params *ts_params = &testsuite_params;
2246 struct crypto_unittest_params *ut_params = &unittest_params;
2248 /* Generate Crypto op data structure */
2249 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2250 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2251 TEST_ASSERT_NOT_NULL(ut_params->op,
2252 "Failed to allocate pktmbuf offload");
2254 /* Set crypto operation data parameters */
2255 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2257 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2259 /* set crypto operation source mbuf */
2260 sym_op->m_src = ut_params->ibuf;
2261 sym_op->m_dst = ut_params->obuf;
2264 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2266 sym_op->cipher.data.length = cipher_len;
2267 sym_op->cipher.data.offset = cipher_offset;
2272 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2273 enum rte_crypto_cipher_operation cipher_op,
2274 enum rte_crypto_auth_operation auth_op,
2275 enum rte_crypto_auth_algorithm auth_algo,
2276 enum rte_crypto_cipher_algorithm cipher_algo,
2277 const uint8_t *key, uint8_t key_len,
2278 uint8_t auth_iv_len, uint8_t auth_len,
2279 uint8_t cipher_iv_len)
2282 uint8_t cipher_auth_key[key_len];
2284 struct crypto_testsuite_params *ts_params = &testsuite_params;
2285 struct crypto_unittest_params *ut_params = &unittest_params;
2287 memcpy(cipher_auth_key, key, key_len);
2289 /* Setup Authentication Parameters */
2290 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2291 ut_params->auth_xform.next = NULL;
2293 ut_params->auth_xform.auth.op = auth_op;
2294 ut_params->auth_xform.auth.algo = auth_algo;
2295 ut_params->auth_xform.auth.key.length = key_len;
2296 /* Hash key = cipher key */
2297 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2298 ut_params->auth_xform.auth.digest_length = auth_len;
2299 /* Auth IV will be after cipher IV */
2300 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2301 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2303 /* Setup Cipher Parameters */
2304 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2305 ut_params->cipher_xform.next = &ut_params->auth_xform;
2307 ut_params->cipher_xform.cipher.algo = cipher_algo;
2308 ut_params->cipher_xform.cipher.op = cipher_op;
2309 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2310 ut_params->cipher_xform.cipher.key.length = key_len;
2311 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2312 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2314 debug_hexdump(stdout, "key:", key, key_len);
2316 /* Create Crypto session*/
2317 ut_params->sess = rte_cryptodev_sym_session_create(
2318 ts_params->session_mpool);
2320 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2321 &ut_params->cipher_xform, ts_params->session_mpool);
2323 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2328 create_wireless_cipher_auth_session(uint8_t dev_id,
2329 enum rte_crypto_cipher_operation cipher_op,
2330 enum rte_crypto_auth_operation auth_op,
2331 enum rte_crypto_auth_algorithm auth_algo,
2332 enum rte_crypto_cipher_algorithm cipher_algo,
2333 const struct wireless_test_data *tdata)
2335 const uint8_t key_len = tdata->key.len;
2336 uint8_t cipher_auth_key[key_len];
2338 struct crypto_testsuite_params *ts_params = &testsuite_params;
2339 struct crypto_unittest_params *ut_params = &unittest_params;
2340 const uint8_t *key = tdata->key.data;
2341 const uint8_t auth_len = tdata->digest.len;
2342 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2343 uint8_t auth_iv_len = tdata->auth_iv.len;
2345 memcpy(cipher_auth_key, key, key_len);
2347 /* Setup Authentication Parameters */
2348 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2349 ut_params->auth_xform.next = NULL;
2351 ut_params->auth_xform.auth.op = auth_op;
2352 ut_params->auth_xform.auth.algo = auth_algo;
2353 ut_params->auth_xform.auth.key.length = key_len;
2354 /* Hash key = cipher key */
2355 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2356 ut_params->auth_xform.auth.digest_length = auth_len;
2357 /* Auth IV will be after cipher IV */
2358 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2359 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2361 /* Setup Cipher Parameters */
2362 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2363 ut_params->cipher_xform.next = &ut_params->auth_xform;
2365 ut_params->cipher_xform.cipher.algo = cipher_algo;
2366 ut_params->cipher_xform.cipher.op = cipher_op;
2367 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2368 ut_params->cipher_xform.cipher.key.length = key_len;
2369 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2370 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2373 debug_hexdump(stdout, "key:", key, key_len);
2375 /* Create Crypto session*/
2376 ut_params->sess = rte_cryptodev_sym_session_create(
2377 ts_params->session_mpool);
2379 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2380 &ut_params->cipher_xform, ts_params->session_mpool);
2382 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2387 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2388 const struct wireless_test_data *tdata)
2390 return create_wireless_cipher_auth_session(dev_id,
2391 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2392 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2393 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2397 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2398 enum rte_crypto_cipher_operation cipher_op,
2399 enum rte_crypto_auth_operation auth_op,
2400 enum rte_crypto_auth_algorithm auth_algo,
2401 enum rte_crypto_cipher_algorithm cipher_algo,
2402 const uint8_t *key, const uint8_t key_len,
2403 uint8_t auth_iv_len, uint8_t auth_len,
2404 uint8_t cipher_iv_len)
2406 uint8_t auth_cipher_key[key_len];
2408 struct crypto_testsuite_params *ts_params = &testsuite_params;
2409 struct crypto_unittest_params *ut_params = &unittest_params;
2411 memcpy(auth_cipher_key, key, key_len);
2413 /* Setup Authentication Parameters */
2414 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2415 ut_params->auth_xform.auth.op = auth_op;
2416 ut_params->auth_xform.next = &ut_params->cipher_xform;
2417 ut_params->auth_xform.auth.algo = auth_algo;
2418 ut_params->auth_xform.auth.key.length = key_len;
2419 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2420 ut_params->auth_xform.auth.digest_length = auth_len;
2421 /* Auth IV will be after cipher IV */
2422 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2423 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2425 /* Setup Cipher Parameters */
2426 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2427 ut_params->cipher_xform.next = NULL;
2428 ut_params->cipher_xform.cipher.algo = cipher_algo;
2429 ut_params->cipher_xform.cipher.op = cipher_op;
2430 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2431 ut_params->cipher_xform.cipher.key.length = key_len;
2432 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2433 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2435 debug_hexdump(stdout, "key:", key, key_len);
2437 /* Create Crypto session*/
2438 ut_params->sess = rte_cryptodev_sym_session_create(
2439 ts_params->session_mpool);
2441 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2442 &ut_params->auth_xform, ts_params->session_mpool);
2444 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2450 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2451 unsigned int auth_tag_len,
2452 const uint8_t *iv, unsigned int iv_len,
2453 unsigned int data_pad_len,
2454 enum rte_crypto_auth_operation op,
2455 unsigned int auth_len, unsigned int auth_offset)
2457 struct crypto_testsuite_params *ts_params = &testsuite_params;
2459 struct crypto_unittest_params *ut_params = &unittest_params;
2461 /* Generate Crypto op data structure */
2462 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2463 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2464 TEST_ASSERT_NOT_NULL(ut_params->op,
2465 "Failed to allocate pktmbuf offload");
2467 /* Set crypto operation data parameters */
2468 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2470 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2472 /* set crypto operation source mbuf */
2473 sym_op->m_src = ut_params->ibuf;
2476 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2479 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2480 ut_params->ibuf, auth_tag_len);
2482 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2483 "no room to append auth tag");
2484 ut_params->digest = sym_op->auth.digest.data;
2485 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2486 ut_params->ibuf, data_pad_len);
2487 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2488 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2490 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2492 debug_hexdump(stdout, "digest:",
2493 sym_op->auth.digest.data,
2496 sym_op->auth.data.length = auth_len;
2497 sym_op->auth.data.offset = auth_offset;
2503 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2504 enum rte_crypto_auth_operation op)
2506 struct crypto_testsuite_params *ts_params = &testsuite_params;
2507 struct crypto_unittest_params *ut_params = &unittest_params;
2509 const uint8_t *auth_tag = tdata->digest.data;
2510 const unsigned int auth_tag_len = tdata->digest.len;
2511 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2512 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2514 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2515 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2516 const uint8_t *auth_iv = tdata->auth_iv.data;
2517 const uint8_t auth_iv_len = tdata->auth_iv.len;
2518 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2519 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2521 /* Generate Crypto op data structure */
2522 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2523 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2524 TEST_ASSERT_NOT_NULL(ut_params->op,
2525 "Failed to allocate pktmbuf offload");
2526 /* Set crypto operation data parameters */
2527 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2529 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2531 /* set crypto operation source mbuf */
2532 sym_op->m_src = ut_params->ibuf;
2535 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2536 ut_params->ibuf, auth_tag_len);
2538 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2539 "no room to append auth tag");
2540 ut_params->digest = sym_op->auth.digest.data;
2541 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2542 ut_params->ibuf, data_pad_len);
2543 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2544 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2546 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2548 debug_hexdump(stdout, "digest:",
2549 sym_op->auth.digest.data,
2552 /* Copy cipher and auth IVs at the end of the crypto operation */
2553 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2555 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2556 iv_ptr += cipher_iv_len;
2557 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2559 sym_op->cipher.data.length = cipher_len;
2560 sym_op->cipher.data.offset = 0;
2561 sym_op->auth.data.length = auth_len;
2562 sym_op->auth.data.offset = 0;
2568 create_zuc_cipher_hash_generate_operation(
2569 const struct wireless_test_data *tdata)
2571 return create_wireless_cipher_hash_operation(tdata,
2572 RTE_CRYPTO_AUTH_OP_GENERATE);
2576 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2577 const unsigned auth_tag_len,
2578 const uint8_t *auth_iv, uint8_t auth_iv_len,
2579 unsigned data_pad_len,
2580 enum rte_crypto_auth_operation op,
2581 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2582 const unsigned cipher_len, const unsigned cipher_offset,
2583 const unsigned auth_len, const unsigned auth_offset)
2585 struct crypto_testsuite_params *ts_params = &testsuite_params;
2586 struct crypto_unittest_params *ut_params = &unittest_params;
2588 /* Generate Crypto op data structure */
2589 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2590 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2591 TEST_ASSERT_NOT_NULL(ut_params->op,
2592 "Failed to allocate pktmbuf offload");
2593 /* Set crypto operation data parameters */
2594 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2596 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2598 /* set crypto operation source mbuf */
2599 sym_op->m_src = ut_params->ibuf;
2602 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2603 ut_params->ibuf, auth_tag_len);
2605 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2606 "no room to append auth tag");
2607 ut_params->digest = sym_op->auth.digest.data;
2608 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2609 ut_params->ibuf, data_pad_len);
2610 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2611 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2613 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2615 debug_hexdump(stdout, "digest:",
2616 sym_op->auth.digest.data,
2619 /* Copy cipher and auth IVs at the end of the crypto operation */
2620 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2622 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2623 iv_ptr += cipher_iv_len;
2624 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2626 sym_op->cipher.data.length = cipher_len;
2627 sym_op->cipher.data.offset = cipher_offset;
2628 sym_op->auth.data.length = auth_len;
2629 sym_op->auth.data.offset = auth_offset;
2635 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2636 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2637 const uint8_t *auth_iv, uint8_t auth_iv_len,
2638 unsigned int data_pad_len,
2639 unsigned int cipher_len, unsigned int cipher_offset,
2640 unsigned int auth_len, unsigned int auth_offset)
2642 struct crypto_testsuite_params *ts_params = &testsuite_params;
2643 struct crypto_unittest_params *ut_params = &unittest_params;
2645 /* Generate Crypto op data structure */
2646 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2647 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2648 TEST_ASSERT_NOT_NULL(ut_params->op,
2649 "Failed to allocate pktmbuf offload");
2651 /* Set crypto operation data parameters */
2652 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2654 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2656 /* set crypto operation source mbuf */
2657 sym_op->m_src = ut_params->ibuf;
2660 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2661 ut_params->ibuf, auth_tag_len);
2663 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2664 "no room to append auth tag");
2666 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2667 ut_params->ibuf, data_pad_len);
2669 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2671 debug_hexdump(stdout, "digest:",
2672 sym_op->auth.digest.data,
2675 /* Copy cipher and auth IVs at the end of the crypto operation */
2676 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2678 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2679 iv_ptr += cipher_iv_len;
2680 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2682 sym_op->cipher.data.length = cipher_len;
2683 sym_op->cipher.data.offset = cipher_offset;
2685 sym_op->auth.data.length = auth_len;
2686 sym_op->auth.data.offset = auth_offset;
2692 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2694 struct crypto_testsuite_params *ts_params = &testsuite_params;
2695 struct crypto_unittest_params *ut_params = &unittest_params;
2698 unsigned plaintext_pad_len;
2699 unsigned plaintext_len;
2702 /* Create SNOW 3G session */
2703 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2704 tdata->key.data, tdata->key.len,
2705 tdata->auth_iv.len, tdata->digest.len,
2706 RTE_CRYPTO_AUTH_OP_GENERATE,
2707 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2711 /* alloc mbuf and set payload */
2712 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2714 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2715 rte_pktmbuf_tailroom(ut_params->ibuf));
2717 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2718 /* Append data which is padded to a multiple of */
2719 /* the algorithms block size */
2720 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2721 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2723 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2725 /* Create SNOW 3G operation */
2726 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2727 tdata->auth_iv.data, tdata->auth_iv.len,
2728 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2729 tdata->validAuthLenInBits.len,
2734 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2736 ut_params->obuf = ut_params->op->sym->m_src;
2737 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2738 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2739 + plaintext_pad_len;
2742 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2745 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2746 "SNOW 3G Generated auth tag not as expected");
2752 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2754 struct crypto_testsuite_params *ts_params = &testsuite_params;
2755 struct crypto_unittest_params *ut_params = &unittest_params;
2758 unsigned plaintext_pad_len;
2759 unsigned plaintext_len;
2762 /* Create SNOW 3G session */
2763 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2764 tdata->key.data, tdata->key.len,
2765 tdata->auth_iv.len, tdata->digest.len,
2766 RTE_CRYPTO_AUTH_OP_VERIFY,
2767 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2770 /* alloc mbuf and set payload */
2771 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2773 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2774 rte_pktmbuf_tailroom(ut_params->ibuf));
2776 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2777 /* Append data which is padded to a multiple of */
2778 /* the algorithms block size */
2779 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2780 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2782 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2784 /* Create SNOW 3G operation */
2785 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2787 tdata->auth_iv.data, tdata->auth_iv.len,
2789 RTE_CRYPTO_AUTH_OP_VERIFY,
2790 tdata->validAuthLenInBits.len,
2795 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2797 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2798 ut_params->obuf = ut_params->op->sym->m_src;
2799 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2800 + plaintext_pad_len;
2803 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2812 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2814 struct crypto_testsuite_params *ts_params = &testsuite_params;
2815 struct crypto_unittest_params *ut_params = &unittest_params;
2818 unsigned plaintext_pad_len;
2819 unsigned plaintext_len;
2822 /* Create KASUMI session */
2823 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2824 tdata->key.data, tdata->key.len,
2825 0, tdata->digest.len,
2826 RTE_CRYPTO_AUTH_OP_GENERATE,
2827 RTE_CRYPTO_AUTH_KASUMI_F9);
2831 /* alloc mbuf and set payload */
2832 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2834 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2835 rte_pktmbuf_tailroom(ut_params->ibuf));
2837 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2838 /* Append data which is padded to a multiple of */
2839 /* the algorithms block size */
2840 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2841 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2843 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2845 /* Create KASUMI operation */
2846 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2848 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2849 tdata->plaintext.len,
2854 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2856 ut_params->obuf = ut_params->op->sym->m_src;
2857 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2858 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2859 + plaintext_pad_len;
2862 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2865 DIGEST_BYTE_LENGTH_KASUMI_F9,
2866 "KASUMI Generated auth tag not as expected");
2872 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2874 struct crypto_testsuite_params *ts_params = &testsuite_params;
2875 struct crypto_unittest_params *ut_params = &unittest_params;
2878 unsigned plaintext_pad_len;
2879 unsigned plaintext_len;
2882 /* Create KASUMI session */
2883 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2884 tdata->key.data, tdata->key.len,
2885 0, tdata->digest.len,
2886 RTE_CRYPTO_AUTH_OP_VERIFY,
2887 RTE_CRYPTO_AUTH_KASUMI_F9);
2890 /* alloc mbuf and set payload */
2891 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2893 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2894 rte_pktmbuf_tailroom(ut_params->ibuf));
2896 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2897 /* Append data which is padded to a multiple */
2898 /* of the algorithms block size */
2899 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2900 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2902 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2904 /* Create KASUMI operation */
2905 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2909 RTE_CRYPTO_AUTH_OP_VERIFY,
2910 tdata->plaintext.len,
2915 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2917 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2918 ut_params->obuf = ut_params->op->sym->m_src;
2919 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2920 + plaintext_pad_len;
2923 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2932 test_snow3g_hash_generate_test_case_1(void)
2934 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2938 test_snow3g_hash_generate_test_case_2(void)
2940 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2944 test_snow3g_hash_generate_test_case_3(void)
2946 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2950 test_snow3g_hash_generate_test_case_4(void)
2952 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2956 test_snow3g_hash_generate_test_case_5(void)
2958 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2962 test_snow3g_hash_generate_test_case_6(void)
2964 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2968 test_snow3g_hash_verify_test_case_1(void)
2970 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2975 test_snow3g_hash_verify_test_case_2(void)
2977 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2981 test_snow3g_hash_verify_test_case_3(void)
2983 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2987 test_snow3g_hash_verify_test_case_4(void)
2989 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2993 test_snow3g_hash_verify_test_case_5(void)
2995 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2999 test_snow3g_hash_verify_test_case_6(void)
3001 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3005 test_kasumi_hash_generate_test_case_1(void)
3007 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3011 test_kasumi_hash_generate_test_case_2(void)
3013 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3017 test_kasumi_hash_generate_test_case_3(void)
3019 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3023 test_kasumi_hash_generate_test_case_4(void)
3025 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3029 test_kasumi_hash_generate_test_case_5(void)
3031 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3035 test_kasumi_hash_generate_test_case_6(void)
3037 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3041 test_kasumi_hash_verify_test_case_1(void)
3043 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3047 test_kasumi_hash_verify_test_case_2(void)
3049 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3053 test_kasumi_hash_verify_test_case_3(void)
3055 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3059 test_kasumi_hash_verify_test_case_4(void)
3061 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3065 test_kasumi_hash_verify_test_case_5(void)
3067 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3071 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3073 struct crypto_testsuite_params *ts_params = &testsuite_params;
3074 struct crypto_unittest_params *ut_params = &unittest_params;
3077 uint8_t *plaintext, *ciphertext;
3078 unsigned plaintext_pad_len;
3079 unsigned plaintext_len;
3081 /* Create KASUMI session */
3082 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3083 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3084 RTE_CRYPTO_CIPHER_KASUMI_F8,
3085 tdata->key.data, tdata->key.len,
3086 tdata->cipher_iv.len);
3090 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3092 /* Clear mbuf payload */
3093 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3094 rte_pktmbuf_tailroom(ut_params->ibuf));
3096 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3097 /* Append data which is padded to a multiple */
3098 /* of the algorithms block size */
3099 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3100 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3102 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3104 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3106 /* Create KASUMI operation */
3107 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3108 tdata->cipher_iv.len,
3109 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3110 tdata->validCipherOffsetInBits.len);
3114 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3116 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3118 ut_params->obuf = ut_params->op->sym->m_dst;
3119 if (ut_params->obuf)
3120 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3122 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3124 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3126 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3127 (tdata->validCipherOffsetInBits.len >> 3);
3129 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3131 reference_ciphertext,
3132 tdata->validCipherLenInBits.len,
3133 "KASUMI Ciphertext data not as expected");
3138 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3140 struct crypto_testsuite_params *ts_params = &testsuite_params;
3141 struct crypto_unittest_params *ut_params = &unittest_params;
3145 unsigned int plaintext_pad_len;
3146 unsigned int plaintext_len;
3148 uint8_t buffer[10000];
3149 const uint8_t *ciphertext;
3151 struct rte_cryptodev_info dev_info;
3153 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3154 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3155 printf("Device doesn't support scatter-gather. "
3160 /* Create KASUMI session */
3161 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3162 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3163 RTE_CRYPTO_CIPHER_KASUMI_F8,
3164 tdata->key.data, tdata->key.len,
3165 tdata->cipher_iv.len);
3169 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3172 /* Append data which is padded to a multiple */
3173 /* of the algorithms block size */
3174 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3176 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3177 plaintext_pad_len, 10, 0);
3179 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3181 /* Create KASUMI operation */
3182 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3183 tdata->cipher_iv.len,
3184 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3185 tdata->validCipherOffsetInBits.len);
3189 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3193 ut_params->obuf = ut_params->op->sym->m_dst;
3195 if (ut_params->obuf)
3196 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3197 plaintext_len, buffer);
3199 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3200 tdata->validCipherOffsetInBits.len >> 3,
3201 plaintext_len, buffer);
3204 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3206 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3207 (tdata->validCipherOffsetInBits.len >> 3);
3209 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3211 reference_ciphertext,
3212 tdata->validCipherLenInBits.len,
3213 "KASUMI Ciphertext data not as expected");
3218 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3220 struct crypto_testsuite_params *ts_params = &testsuite_params;
3221 struct crypto_unittest_params *ut_params = &unittest_params;
3224 uint8_t *plaintext, *ciphertext;
3225 unsigned plaintext_pad_len;
3226 unsigned plaintext_len;
3228 /* Create KASUMI session */
3229 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3230 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3231 RTE_CRYPTO_CIPHER_KASUMI_F8,
3232 tdata->key.data, tdata->key.len,
3233 tdata->cipher_iv.len);
3237 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3238 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3240 /* Clear mbuf payload */
3241 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3242 rte_pktmbuf_tailroom(ut_params->ibuf));
3244 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3245 /* Append data which is padded to a multiple */
3246 /* of the algorithms block size */
3247 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3248 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3250 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3251 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3253 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3255 /* Create KASUMI operation */
3256 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3257 tdata->cipher_iv.len,
3258 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3259 tdata->validCipherOffsetInBits.len);
3263 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3265 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3267 ut_params->obuf = ut_params->op->sym->m_dst;
3268 if (ut_params->obuf)
3269 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3271 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3273 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3275 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3276 (tdata->validCipherOffsetInBits.len >> 3);
3278 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3280 reference_ciphertext,
3281 tdata->validCipherLenInBits.len,
3282 "KASUMI Ciphertext data not as expected");
3287 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3289 struct crypto_testsuite_params *ts_params = &testsuite_params;
3290 struct crypto_unittest_params *ut_params = &unittest_params;
3293 unsigned int plaintext_pad_len;
3294 unsigned int plaintext_len;
3296 const uint8_t *ciphertext;
3297 uint8_t buffer[2048];
3299 struct rte_cryptodev_info dev_info;
3301 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3302 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3303 printf("Device doesn't support scatter-gather. "
3308 /* Create KASUMI session */
3309 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3310 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3311 RTE_CRYPTO_CIPHER_KASUMI_F8,
3312 tdata->key.data, tdata->key.len,
3313 tdata->cipher_iv.len);
3317 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3318 /* Append data which is padded to a multiple */
3319 /* of the algorithms block size */
3320 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3322 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3323 plaintext_pad_len, 10, 0);
3324 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3325 plaintext_pad_len, 3, 0);
3327 /* Append data which is padded to a multiple */
3328 /* of the algorithms block size */
3329 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3331 /* Create KASUMI operation */
3332 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3333 tdata->cipher_iv.len,
3334 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3335 tdata->validCipherOffsetInBits.len);
3339 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3341 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3343 ut_params->obuf = ut_params->op->sym->m_dst;
3344 if (ut_params->obuf)
3345 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3346 plaintext_pad_len, buffer);
3348 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3349 tdata->validCipherOffsetInBits.len >> 3,
3350 plaintext_pad_len, buffer);
3352 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3353 (tdata->validCipherOffsetInBits.len >> 3);
3355 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3357 reference_ciphertext,
3358 tdata->validCipherLenInBits.len,
3359 "KASUMI Ciphertext data not as expected");
3365 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3367 struct crypto_testsuite_params *ts_params = &testsuite_params;
3368 struct crypto_unittest_params *ut_params = &unittest_params;
3371 uint8_t *ciphertext, *plaintext;
3372 unsigned ciphertext_pad_len;
3373 unsigned ciphertext_len;
3375 /* Create KASUMI session */
3376 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3377 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3378 RTE_CRYPTO_CIPHER_KASUMI_F8,
3379 tdata->key.data, tdata->key.len,
3380 tdata->cipher_iv.len);
3384 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3385 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3387 /* Clear mbuf payload */
3388 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3389 rte_pktmbuf_tailroom(ut_params->ibuf));
3391 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3392 /* Append data which is padded to a multiple */
3393 /* of the algorithms block size */
3394 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3395 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3396 ciphertext_pad_len);
3397 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3398 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3400 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3402 /* Create KASUMI operation */
3403 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3404 tdata->cipher_iv.len,
3405 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3406 tdata->validCipherOffsetInBits.len);
3410 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3412 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3414 ut_params->obuf = ut_params->op->sym->m_dst;
3415 if (ut_params->obuf)
3416 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3418 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3420 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3422 const uint8_t *reference_plaintext = tdata->plaintext.data +
3423 (tdata->validCipherOffsetInBits.len >> 3);
3425 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3427 reference_plaintext,
3428 tdata->validCipherLenInBits.len,
3429 "KASUMI Plaintext data not as expected");
3434 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3436 struct crypto_testsuite_params *ts_params = &testsuite_params;
3437 struct crypto_unittest_params *ut_params = &unittest_params;
3440 uint8_t *ciphertext, *plaintext;
3441 unsigned ciphertext_pad_len;
3442 unsigned ciphertext_len;
3444 /* Create KASUMI session */
3445 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3446 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3447 RTE_CRYPTO_CIPHER_KASUMI_F8,
3448 tdata->key.data, tdata->key.len,
3449 tdata->cipher_iv.len);
3453 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3455 /* Clear mbuf payload */
3456 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3457 rte_pktmbuf_tailroom(ut_params->ibuf));
3459 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3460 /* Append data which is padded to a multiple */
3461 /* of the algorithms block size */
3462 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3463 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3464 ciphertext_pad_len);
3465 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3467 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3469 /* Create KASUMI operation */
3470 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3471 tdata->cipher_iv.len,
3472 tdata->ciphertext.len,
3473 tdata->validCipherOffsetInBits.len);
3477 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3479 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3481 ut_params->obuf = ut_params->op->sym->m_dst;
3482 if (ut_params->obuf)
3483 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3485 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3487 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3489 const uint8_t *reference_plaintext = tdata->plaintext.data +
3490 (tdata->validCipherOffsetInBits.len >> 3);
3492 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3494 reference_plaintext,
3495 tdata->validCipherLenInBits.len,
3496 "KASUMI Plaintext data not as expected");
3501 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3503 struct crypto_testsuite_params *ts_params = &testsuite_params;
3504 struct crypto_unittest_params *ut_params = &unittest_params;
3507 uint8_t *plaintext, *ciphertext;
3508 unsigned plaintext_pad_len;
3509 unsigned plaintext_len;
3511 /* Create SNOW 3G session */
3512 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3513 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3514 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3515 tdata->key.data, tdata->key.len,
3516 tdata->cipher_iv.len);
3520 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3522 /* Clear mbuf payload */
3523 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3524 rte_pktmbuf_tailroom(ut_params->ibuf));
3526 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3527 /* Append data which is padded to a multiple of */
3528 /* the algorithms block size */
3529 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3530 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3532 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3534 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3536 /* Create SNOW 3G operation */
3537 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3538 tdata->cipher_iv.len,
3539 tdata->validCipherLenInBits.len,
3544 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3546 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3548 ut_params->obuf = ut_params->op->sym->m_dst;
3549 if (ut_params->obuf)
3550 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3552 ciphertext = plaintext;
3554 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3557 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3559 tdata->ciphertext.data,
3560 tdata->validDataLenInBits.len,
3561 "SNOW 3G Ciphertext data not as expected");
3567 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3569 struct crypto_testsuite_params *ts_params = &testsuite_params;
3570 struct crypto_unittest_params *ut_params = &unittest_params;
3571 uint8_t *plaintext, *ciphertext;
3574 unsigned plaintext_pad_len;
3575 unsigned plaintext_len;
3577 /* Create SNOW 3G session */
3578 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3579 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3580 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3581 tdata->key.data, tdata->key.len,
3582 tdata->cipher_iv.len);
3586 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3587 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3589 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3590 "Failed to allocate input buffer in mempool");
3591 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3592 "Failed to allocate output buffer in mempool");
3594 /* Clear mbuf payload */
3595 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3596 rte_pktmbuf_tailroom(ut_params->ibuf));
3598 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3599 /* Append data which is padded to a multiple of */
3600 /* the algorithms block size */
3601 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3602 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3604 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3605 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3607 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3609 /* Create SNOW 3G operation */
3610 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3611 tdata->cipher_iv.len,
3612 tdata->validCipherLenInBits.len,
3617 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3619 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3621 ut_params->obuf = ut_params->op->sym->m_dst;
3622 if (ut_params->obuf)
3623 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3625 ciphertext = plaintext;
3627 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3630 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3632 tdata->ciphertext.data,
3633 tdata->validDataLenInBits.len,
3634 "SNOW 3G Ciphertext data not as expected");
3639 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3641 struct crypto_testsuite_params *ts_params = &testsuite_params;
3642 struct crypto_unittest_params *ut_params = &unittest_params;
3645 unsigned int plaintext_pad_len;
3646 unsigned int plaintext_len;
3647 uint8_t buffer[10000];
3648 const uint8_t *ciphertext;
3650 struct rte_cryptodev_info dev_info;
3652 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3653 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3654 printf("Device doesn't support scatter-gather. "
3659 /* Create SNOW 3G session */
3660 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3661 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3662 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3663 tdata->key.data, tdata->key.len,
3664 tdata->cipher_iv.len);
3668 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3669 /* Append data which is padded to a multiple of */
3670 /* the algorithms block size */
3671 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3673 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3674 plaintext_pad_len, 10, 0);
3675 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3676 plaintext_pad_len, 3, 0);
3678 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3679 "Failed to allocate input buffer in mempool");
3680 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3681 "Failed to allocate output buffer in mempool");
3683 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3685 /* Create SNOW 3G operation */
3686 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3687 tdata->cipher_iv.len,
3688 tdata->validCipherLenInBits.len,
3693 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3695 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3697 ut_params->obuf = ut_params->op->sym->m_dst;
3698 if (ut_params->obuf)
3699 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3700 plaintext_len, buffer);
3702 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3703 plaintext_len, buffer);
3705 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3708 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3710 tdata->ciphertext.data,
3711 tdata->validDataLenInBits.len,
3712 "SNOW 3G Ciphertext data not as expected");
3717 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3719 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3721 uint8_t curr_byte, prev_byte;
3722 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3723 uint8_t lower_byte_mask = (1 << offset) - 1;
3726 prev_byte = buffer[0];
3727 buffer[0] >>= offset;
3729 for (i = 1; i < length_in_bytes; i++) {
3730 curr_byte = buffer[i];
3731 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3732 (curr_byte >> offset);
3733 prev_byte = curr_byte;
3738 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3740 struct crypto_testsuite_params *ts_params = &testsuite_params;
3741 struct crypto_unittest_params *ut_params = &unittest_params;
3742 uint8_t *plaintext, *ciphertext;
3744 uint32_t plaintext_len;
3745 uint32_t plaintext_pad_len;
3746 uint8_t extra_offset = 4;
3747 uint8_t *expected_ciphertext_shifted;
3749 /* Create SNOW 3G session */
3750 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3751 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3752 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3753 tdata->key.data, tdata->key.len,
3754 tdata->cipher_iv.len);
3758 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3759 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3761 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3762 "Failed to allocate input buffer in mempool");
3763 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3764 "Failed to allocate output buffer in mempool");
3766 /* Clear mbuf payload */
3767 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3768 rte_pktmbuf_tailroom(ut_params->ibuf));
3770 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3772 * Append data which is padded to a
3773 * multiple of the algorithms block size
3775 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3777 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3780 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3782 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3783 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3785 #ifdef RTE_APP_TEST_DEBUG
3786 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3788 /* Create SNOW 3G operation */
3789 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3790 tdata->cipher_iv.len,
3791 tdata->validCipherLenInBits.len,
3796 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3798 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3800 ut_params->obuf = ut_params->op->sym->m_dst;
3801 if (ut_params->obuf)
3802 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3804 ciphertext = plaintext;
3806 #ifdef RTE_APP_TEST_DEBUG
3807 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3810 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3812 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3813 "failed to reserve memory for ciphertext shifted\n");
3815 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3816 ceil_byte_length(tdata->ciphertext.len));
3817 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3820 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3822 expected_ciphertext_shifted,
3823 tdata->validDataLenInBits.len,
3825 "SNOW 3G Ciphertext data not as expected");
3829 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3831 struct crypto_testsuite_params *ts_params = &testsuite_params;
3832 struct crypto_unittest_params *ut_params = &unittest_params;
3836 uint8_t *plaintext, *ciphertext;
3837 unsigned ciphertext_pad_len;
3838 unsigned ciphertext_len;
3840 /* Create SNOW 3G session */
3841 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3842 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3843 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3844 tdata->key.data, tdata->key.len,
3845 tdata->cipher_iv.len);
3849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3851 /* Clear mbuf payload */
3852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3853 rte_pktmbuf_tailroom(ut_params->ibuf));
3855 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3856 /* Append data which is padded to a multiple of */
3857 /* the algorithms block size */
3858 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3859 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3860 ciphertext_pad_len);
3861 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3863 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3865 /* Create SNOW 3G operation */
3866 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3867 tdata->cipher_iv.len,
3868 tdata->validCipherLenInBits.len,
3873 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3875 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3876 ut_params->obuf = ut_params->op->sym->m_dst;
3877 if (ut_params->obuf)
3878 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3880 plaintext = ciphertext;
3882 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3885 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3886 tdata->plaintext.data,
3887 tdata->validDataLenInBits.len,
3888 "SNOW 3G Plaintext data not as expected");
3892 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3894 struct crypto_testsuite_params *ts_params = &testsuite_params;
3895 struct crypto_unittest_params *ut_params = &unittest_params;
3899 uint8_t *plaintext, *ciphertext;
3900 unsigned ciphertext_pad_len;
3901 unsigned ciphertext_len;
3903 /* Create SNOW 3G session */
3904 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3905 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3906 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3907 tdata->key.data, tdata->key.len,
3908 tdata->cipher_iv.len);
3912 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3913 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3915 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3916 "Failed to allocate input buffer");
3917 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3918 "Failed to allocate output buffer");
3920 /* Clear mbuf payload */
3921 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3922 rte_pktmbuf_tailroom(ut_params->ibuf));
3924 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3925 rte_pktmbuf_tailroom(ut_params->obuf));
3927 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3928 /* Append data which is padded to a multiple of */
3929 /* the algorithms block size */
3930 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3931 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3932 ciphertext_pad_len);
3933 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3934 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3936 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3938 /* Create SNOW 3G operation */
3939 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3940 tdata->cipher_iv.len,
3941 tdata->validCipherLenInBits.len,
3946 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3948 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3949 ut_params->obuf = ut_params->op->sym->m_dst;
3950 if (ut_params->obuf)
3951 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3953 plaintext = ciphertext;
3955 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3958 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3959 tdata->plaintext.data,
3960 tdata->validDataLenInBits.len,
3961 "SNOW 3G Plaintext data not as expected");
3966 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3968 struct crypto_testsuite_params *ts_params = &testsuite_params;
3969 struct crypto_unittest_params *ut_params = &unittest_params;
3973 uint8_t *plaintext, *ciphertext;
3974 unsigned int plaintext_pad_len;
3975 unsigned int plaintext_len;
3977 struct rte_cryptodev_sym_capability_idx cap_idx;
3979 /* Check if device supports ZUC EEA3 */
3980 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3981 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3983 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3987 /* Check if device supports ZUC EIA3 */
3988 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3989 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3991 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3995 /* Create ZUC session */
3996 retval = create_zuc_cipher_auth_encrypt_generate_session(
3997 ts_params->valid_devs[0],
4001 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4003 /* clear mbuf payload */
4004 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4005 rte_pktmbuf_tailroom(ut_params->ibuf));
4007 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4008 /* Append data which is padded to a multiple of */
4009 /* the algorithms block size */
4010 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4011 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4013 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4015 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4017 /* Create ZUC operation */
4018 retval = create_zuc_cipher_hash_generate_operation(tdata);
4022 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4024 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4025 ut_params->obuf = ut_params->op->sym->m_src;
4026 if (ut_params->obuf)
4027 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4029 ciphertext = plaintext;
4031 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4033 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4035 tdata->ciphertext.data,
4036 tdata->validDataLenInBits.len,
4037 "ZUC Ciphertext data not as expected");
4039 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4040 + plaintext_pad_len;
4043 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4047 "ZUC Generated auth tag not as expected");
4052 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4054 struct crypto_testsuite_params *ts_params = &testsuite_params;
4055 struct crypto_unittest_params *ut_params = &unittest_params;
4059 uint8_t *plaintext, *ciphertext;
4060 unsigned plaintext_pad_len;
4061 unsigned plaintext_len;
4063 /* Create SNOW 3G session */
4064 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4065 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4066 RTE_CRYPTO_AUTH_OP_GENERATE,
4067 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4068 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4069 tdata->key.data, tdata->key.len,
4070 tdata->auth_iv.len, tdata->digest.len,
4071 tdata->cipher_iv.len);
4074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4076 /* clear mbuf payload */
4077 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4078 rte_pktmbuf_tailroom(ut_params->ibuf));
4080 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4081 /* Append data which is padded to a multiple of */
4082 /* the algorithms block size */
4083 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4084 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4086 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4088 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4090 /* Create SNOW 3G operation */
4091 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4092 tdata->digest.len, tdata->auth_iv.data,
4094 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4095 tdata->cipher_iv.data, tdata->cipher_iv.len,
4096 tdata->validCipherLenInBits.len,
4098 tdata->validAuthLenInBits.len,
4104 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4106 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4107 ut_params->obuf = ut_params->op->sym->m_src;
4108 if (ut_params->obuf)
4109 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4111 ciphertext = plaintext;
4113 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4115 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4117 tdata->ciphertext.data,
4118 tdata->validDataLenInBits.len,
4119 "SNOW 3G Ciphertext data not as expected");
4121 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4122 + plaintext_pad_len;
4125 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4128 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4129 "SNOW 3G Generated auth tag not as expected");
4133 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4135 struct crypto_testsuite_params *ts_params = &testsuite_params;
4136 struct crypto_unittest_params *ut_params = &unittest_params;
4140 uint8_t *plaintext, *ciphertext;
4141 unsigned plaintext_pad_len;
4142 unsigned plaintext_len;
4144 /* Create SNOW 3G session */
4145 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4146 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4147 RTE_CRYPTO_AUTH_OP_GENERATE,
4148 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4149 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4150 tdata->key.data, tdata->key.len,
4151 tdata->auth_iv.len, tdata->digest.len,
4152 tdata->cipher_iv.len);
4156 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4158 /* clear mbuf payload */
4159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4160 rte_pktmbuf_tailroom(ut_params->ibuf));
4162 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4163 /* Append data which is padded to a multiple of */
4164 /* the algorithms block size */
4165 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4166 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4168 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4170 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4172 /* Create SNOW 3G operation */
4173 retval = create_wireless_algo_auth_cipher_operation(
4175 tdata->cipher_iv.data, tdata->cipher_iv.len,
4176 tdata->auth_iv.data, tdata->auth_iv.len,
4178 tdata->validCipherLenInBits.len,
4180 tdata->validAuthLenInBits.len,
4186 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4188 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4189 ut_params->obuf = ut_params->op->sym->m_src;
4190 if (ut_params->obuf)
4191 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4193 ciphertext = plaintext;
4195 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4196 + plaintext_pad_len;
4197 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4200 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4202 tdata->ciphertext.data,
4203 tdata->validDataLenInBits.len,
4204 "SNOW 3G Ciphertext data not as expected");
4207 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4210 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4211 "SNOW 3G Generated auth tag not as expected");
4216 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4218 struct crypto_testsuite_params *ts_params = &testsuite_params;
4219 struct crypto_unittest_params *ut_params = &unittest_params;
4223 uint8_t *plaintext, *ciphertext;
4224 unsigned plaintext_pad_len;
4225 unsigned plaintext_len;
4227 /* Create KASUMI session */
4228 retval = create_wireless_algo_auth_cipher_session(
4229 ts_params->valid_devs[0],
4230 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4231 RTE_CRYPTO_AUTH_OP_GENERATE,
4232 RTE_CRYPTO_AUTH_KASUMI_F9,
4233 RTE_CRYPTO_CIPHER_KASUMI_F8,
4234 tdata->key.data, tdata->key.len,
4235 0, tdata->digest.len,
4236 tdata->cipher_iv.len);
4239 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4241 /* clear mbuf payload */
4242 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4243 rte_pktmbuf_tailroom(ut_params->ibuf));
4245 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4246 /* Append data which is padded to a multiple of */
4247 /* the algorithms block size */
4248 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4249 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4251 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4253 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4255 /* Create KASUMI operation */
4256 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4257 tdata->cipher_iv.data, tdata->cipher_iv.len,
4260 tdata->validCipherLenInBits.len,
4261 tdata->validCipherOffsetInBits.len,
4262 tdata->validAuthLenInBits.len,
4269 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4271 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4272 if (ut_params->op->sym->m_dst)
4273 ut_params->obuf = ut_params->op->sym->m_dst;
4275 ut_params->obuf = ut_params->op->sym->m_src;
4277 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4278 tdata->validCipherOffsetInBits.len >> 3);
4280 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4281 (tdata->validCipherOffsetInBits.len >> 3);
4283 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4285 reference_ciphertext,
4286 tdata->validCipherLenInBits.len,
4287 "KASUMI Ciphertext data not as expected");
4288 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4289 + plaintext_pad_len;
4292 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4295 DIGEST_BYTE_LENGTH_KASUMI_F9,
4296 "KASUMI Generated auth tag not as expected");
4301 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4303 struct crypto_testsuite_params *ts_params = &testsuite_params;
4304 struct crypto_unittest_params *ut_params = &unittest_params;
4308 uint8_t *plaintext, *ciphertext;
4309 unsigned plaintext_pad_len;
4310 unsigned plaintext_len;
4312 /* Create KASUMI session */
4313 retval = create_wireless_algo_cipher_auth_session(
4314 ts_params->valid_devs[0],
4315 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4316 RTE_CRYPTO_AUTH_OP_GENERATE,
4317 RTE_CRYPTO_AUTH_KASUMI_F9,
4318 RTE_CRYPTO_CIPHER_KASUMI_F8,
4319 tdata->key.data, tdata->key.len,
4320 0, tdata->digest.len,
4321 tdata->cipher_iv.len);
4325 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4327 /* clear mbuf payload */
4328 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4329 rte_pktmbuf_tailroom(ut_params->ibuf));
4331 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4332 /* Append data which is padded to a multiple of */
4333 /* the algorithms block size */
4334 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4335 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4337 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4339 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4341 /* Create KASUMI operation */
4342 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4343 tdata->digest.len, NULL, 0,
4344 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4345 tdata->cipher_iv.data, tdata->cipher_iv.len,
4346 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4347 tdata->validCipherOffsetInBits.len,
4348 tdata->validAuthLenInBits.len,
4354 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4356 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4358 if (ut_params->op->sym->m_dst)
4359 ut_params->obuf = ut_params->op->sym->m_dst;
4361 ut_params->obuf = ut_params->op->sym->m_src;
4363 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4364 tdata->validCipherOffsetInBits.len >> 3);
4366 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4367 + plaintext_pad_len;
4369 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4370 (tdata->validCipherOffsetInBits.len >> 3);
4372 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4374 reference_ciphertext,
4375 tdata->validCipherLenInBits.len,
4376 "KASUMI Ciphertext data not as expected");
4379 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4382 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4383 "KASUMI Generated auth tag not as expected");
4388 test_zuc_encryption(const struct wireless_test_data *tdata)
4390 struct crypto_testsuite_params *ts_params = &testsuite_params;
4391 struct crypto_unittest_params *ut_params = &unittest_params;
4394 uint8_t *plaintext, *ciphertext;
4395 unsigned plaintext_pad_len;
4396 unsigned plaintext_len;
4398 struct rte_cryptodev_sym_capability_idx cap_idx;
4400 /* Check if device supports ZUC EEA3 */
4401 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4402 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4404 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4408 /* Create ZUC session */
4409 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4410 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4411 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4412 tdata->key.data, tdata->key.len,
4413 tdata->cipher_iv.len);
4417 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4419 /* Clear mbuf payload */
4420 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4421 rte_pktmbuf_tailroom(ut_params->ibuf));
4423 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4424 /* Append data which is padded to a multiple */
4425 /* of the algorithms block size */
4426 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4427 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4429 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4431 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4433 /* Create ZUC operation */
4434 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4435 tdata->cipher_iv.len,
4436 tdata->plaintext.len,
4441 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4443 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4445 ut_params->obuf = ut_params->op->sym->m_dst;
4446 if (ut_params->obuf)
4447 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4449 ciphertext = plaintext;
4451 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4454 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4456 tdata->ciphertext.data,
4457 tdata->validCipherLenInBits.len,
4458 "ZUC Ciphertext data not as expected");
4463 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4465 struct crypto_testsuite_params *ts_params = &testsuite_params;
4466 struct crypto_unittest_params *ut_params = &unittest_params;
4470 unsigned int plaintext_pad_len;
4471 unsigned int plaintext_len;
4472 const uint8_t *ciphertext;
4473 uint8_t ciphertext_buffer[2048];
4474 struct rte_cryptodev_info dev_info;
4476 struct rte_cryptodev_sym_capability_idx cap_idx;
4478 /* Check if device supports ZUC EEA3 */
4479 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4480 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4482 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4486 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4487 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4488 printf("Device doesn't support scatter-gather. "
4493 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4495 /* Append data which is padded to a multiple */
4496 /* of the algorithms block size */
4497 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4499 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4500 plaintext_pad_len, 10, 0);
4502 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4503 tdata->plaintext.data);
4505 /* Create ZUC session */
4506 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4507 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4508 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4509 tdata->key.data, tdata->key.len,
4510 tdata->cipher_iv.len);
4514 /* Clear mbuf payload */
4516 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4518 /* Create ZUC operation */
4519 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4520 tdata->cipher_iv.len, tdata->plaintext.len,
4525 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4527 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4529 ut_params->obuf = ut_params->op->sym->m_dst;
4530 if (ut_params->obuf)
4531 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4532 0, plaintext_len, ciphertext_buffer);
4534 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4535 0, plaintext_len, ciphertext_buffer);
4538 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4541 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4543 tdata->ciphertext.data,
4544 tdata->validCipherLenInBits.len,
4545 "ZUC Ciphertext data not as expected");
4551 test_zuc_authentication(const struct wireless_test_data *tdata)
4553 struct crypto_testsuite_params *ts_params = &testsuite_params;
4554 struct crypto_unittest_params *ut_params = &unittest_params;
4557 unsigned plaintext_pad_len;
4558 unsigned plaintext_len;
4561 struct rte_cryptodev_sym_capability_idx cap_idx;
4563 /* Check if device supports ZUC EIA3 */
4564 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4565 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4567 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4571 /* Create ZUC session */
4572 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4573 tdata->key.data, tdata->key.len,
4574 tdata->auth_iv.len, tdata->digest.len,
4575 RTE_CRYPTO_AUTH_OP_GENERATE,
4576 RTE_CRYPTO_AUTH_ZUC_EIA3);
4580 /* alloc mbuf and set payload */
4581 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4583 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4584 rte_pktmbuf_tailroom(ut_params->ibuf));
4586 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4587 /* Append data which is padded to a multiple of */
4588 /* the algorithms block size */
4589 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4590 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4592 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4594 /* Create ZUC operation */
4595 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4596 tdata->auth_iv.data, tdata->auth_iv.len,
4597 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4598 tdata->validAuthLenInBits.len,
4603 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4605 ut_params->obuf = ut_params->op->sym->m_src;
4606 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4607 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4608 + plaintext_pad_len;
4611 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4614 DIGEST_BYTE_LENGTH_KASUMI_F9,
4615 "ZUC Generated auth tag not as expected");
4621 test_kasumi_encryption_test_case_1(void)
4623 return test_kasumi_encryption(&kasumi_test_case_1);
4627 test_kasumi_encryption_test_case_1_sgl(void)
4629 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4633 test_kasumi_encryption_test_case_1_oop(void)
4635 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4639 test_kasumi_encryption_test_case_1_oop_sgl(void)
4641 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4645 test_kasumi_encryption_test_case_2(void)
4647 return test_kasumi_encryption(&kasumi_test_case_2);
4651 test_kasumi_encryption_test_case_3(void)
4653 return test_kasumi_encryption(&kasumi_test_case_3);
4657 test_kasumi_encryption_test_case_4(void)
4659 return test_kasumi_encryption(&kasumi_test_case_4);
4663 test_kasumi_encryption_test_case_5(void)
4665 return test_kasumi_encryption(&kasumi_test_case_5);
4669 test_kasumi_decryption_test_case_1(void)
4671 return test_kasumi_decryption(&kasumi_test_case_1);
4675 test_kasumi_decryption_test_case_1_oop(void)
4677 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4681 test_kasumi_decryption_test_case_2(void)
4683 return test_kasumi_decryption(&kasumi_test_case_2);
4687 test_kasumi_decryption_test_case_3(void)
4689 return test_kasumi_decryption(&kasumi_test_case_3);
4693 test_kasumi_decryption_test_case_4(void)
4695 return test_kasumi_decryption(&kasumi_test_case_4);
4699 test_kasumi_decryption_test_case_5(void)
4701 return test_kasumi_decryption(&kasumi_test_case_5);
4704 test_snow3g_encryption_test_case_1(void)
4706 return test_snow3g_encryption(&snow3g_test_case_1);
4710 test_snow3g_encryption_test_case_1_oop(void)
4712 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4716 test_snow3g_encryption_test_case_1_oop_sgl(void)
4718 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4723 test_snow3g_encryption_test_case_1_offset_oop(void)
4725 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4729 test_snow3g_encryption_test_case_2(void)
4731 return test_snow3g_encryption(&snow3g_test_case_2);
4735 test_snow3g_encryption_test_case_3(void)
4737 return test_snow3g_encryption(&snow3g_test_case_3);
4741 test_snow3g_encryption_test_case_4(void)
4743 return test_snow3g_encryption(&snow3g_test_case_4);
4747 test_snow3g_encryption_test_case_5(void)
4749 return test_snow3g_encryption(&snow3g_test_case_5);
4753 test_snow3g_decryption_test_case_1(void)
4755 return test_snow3g_decryption(&snow3g_test_case_1);
4759 test_snow3g_decryption_test_case_1_oop(void)
4761 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4765 test_snow3g_decryption_test_case_2(void)
4767 return test_snow3g_decryption(&snow3g_test_case_2);
4771 test_snow3g_decryption_test_case_3(void)
4773 return test_snow3g_decryption(&snow3g_test_case_3);
4777 test_snow3g_decryption_test_case_4(void)
4779 return test_snow3g_decryption(&snow3g_test_case_4);
4783 test_snow3g_decryption_test_case_5(void)
4785 return test_snow3g_decryption(&snow3g_test_case_5);
4788 test_snow3g_cipher_auth_test_case_1(void)
4790 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4794 test_snow3g_auth_cipher_test_case_1(void)
4796 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4800 test_kasumi_auth_cipher_test_case_1(void)
4802 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4806 test_kasumi_cipher_auth_test_case_1(void)
4808 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4812 test_zuc_encryption_test_case_1(void)
4814 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4818 test_zuc_encryption_test_case_2(void)
4820 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4824 test_zuc_encryption_test_case_3(void)
4826 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4830 test_zuc_encryption_test_case_4(void)
4832 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4836 test_zuc_encryption_test_case_5(void)
4838 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4842 test_zuc_encryption_test_case_6_sgl(void)
4844 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4848 test_zuc_hash_generate_test_case_1(void)
4850 return test_zuc_authentication(&zuc_test_case_auth_1b);
4854 test_zuc_hash_generate_test_case_2(void)
4856 return test_zuc_authentication(&zuc_test_case_auth_90b);
4860 test_zuc_hash_generate_test_case_3(void)
4862 return test_zuc_authentication(&zuc_test_case_auth_577b);
4866 test_zuc_hash_generate_test_case_4(void)
4868 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4872 test_zuc_hash_generate_test_case_5(void)
4874 return test_zuc_authentication(&zuc_test_auth_5670b);
4878 test_zuc_hash_generate_test_case_6(void)
4880 return test_zuc_authentication(&zuc_test_case_auth_128b);
4884 test_zuc_hash_generate_test_case_7(void)
4886 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4890 test_zuc_hash_generate_test_case_8(void)
4892 return test_zuc_authentication(&zuc_test_case_auth_584b);
4896 test_zuc_cipher_auth_test_case_1(void)
4898 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4902 test_zuc_cipher_auth_test_case_2(void)
4904 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4908 test_3DES_chain_qat_all(void)
4910 struct crypto_testsuite_params *ts_params = &testsuite_params;
4913 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4914 ts_params->op_mpool,
4915 ts_params->session_mpool,
4916 ts_params->valid_devs[0],
4917 rte_cryptodev_driver_id_get(
4918 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4919 BLKCIPHER_3DES_CHAIN_TYPE);
4921 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4923 return TEST_SUCCESS;
4927 test_DES_cipheronly_qat_all(void)
4929 struct crypto_testsuite_params *ts_params = &testsuite_params;
4932 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4933 ts_params->op_mpool,
4934 ts_params->session_mpool,
4935 ts_params->valid_devs[0],
4936 rte_cryptodev_driver_id_get(
4937 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4938 BLKCIPHER_DES_CIPHERONLY_TYPE);
4940 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4942 return TEST_SUCCESS;
4946 test_DES_cipheronly_openssl_all(void)
4948 struct crypto_testsuite_params *ts_params = &testsuite_params;
4951 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4952 ts_params->op_mpool,
4953 ts_params->session_mpool,
4954 ts_params->valid_devs[0],
4955 rte_cryptodev_driver_id_get(
4956 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4957 BLKCIPHER_DES_CIPHERONLY_TYPE);
4959 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4961 return TEST_SUCCESS;
4965 test_DES_docsis_openssl_all(void)
4967 struct crypto_testsuite_params *ts_params = &testsuite_params;
4970 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4971 ts_params->op_mpool,
4972 ts_params->session_mpool,
4973 ts_params->valid_devs[0],
4974 rte_cryptodev_driver_id_get(
4975 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4976 BLKCIPHER_DES_DOCSIS_TYPE);
4978 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4980 return TEST_SUCCESS;
4984 test_DES_cipheronly_mb_all(void)
4986 struct crypto_testsuite_params *ts_params = &testsuite_params;
4989 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4990 ts_params->op_mpool,
4991 ts_params->session_mpool,
4992 ts_params->valid_devs[0],
4993 rte_cryptodev_driver_id_get(
4994 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4995 BLKCIPHER_DES_CIPHERONLY_TYPE);
4997 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4999 return TEST_SUCCESS;
5003 test_DES_docsis_mb_all(void)
5005 struct crypto_testsuite_params *ts_params = &testsuite_params;
5008 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5009 ts_params->op_mpool,
5010 ts_params->session_mpool,
5011 ts_params->valid_devs[0],
5012 rte_cryptodev_driver_id_get(
5013 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5014 BLKCIPHER_DES_DOCSIS_TYPE);
5016 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5018 return TEST_SUCCESS;
5022 test_3DES_chain_dpaa_sec_all(void)
5024 struct crypto_testsuite_params *ts_params = &testsuite_params;
5027 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5028 ts_params->op_mpool,
5029 ts_params->session_mpool,
5030 ts_params->valid_devs[0],
5031 rte_cryptodev_driver_id_get(
5032 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5033 BLKCIPHER_3DES_CHAIN_TYPE);
5035 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5037 return TEST_SUCCESS;
5041 test_3DES_cipheronly_dpaa_sec_all(void)
5043 struct crypto_testsuite_params *ts_params = &testsuite_params;
5046 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5047 ts_params->op_mpool,
5048 ts_params->session_mpool,
5049 ts_params->valid_devs[0],
5050 rte_cryptodev_driver_id_get(
5051 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5052 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5054 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5056 return TEST_SUCCESS;
5060 test_3DES_chain_dpaa2_sec_all(void)
5062 struct crypto_testsuite_params *ts_params = &testsuite_params;
5065 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5066 ts_params->op_mpool,
5067 ts_params->session_mpool,
5068 ts_params->valid_devs[0],
5069 rte_cryptodev_driver_id_get(
5070 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5071 BLKCIPHER_3DES_CHAIN_TYPE);
5073 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5075 return TEST_SUCCESS;
5079 test_3DES_cipheronly_dpaa2_sec_all(void)
5081 struct crypto_testsuite_params *ts_params = &testsuite_params;
5084 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5085 ts_params->op_mpool,
5086 ts_params->session_mpool,
5087 ts_params->valid_devs[0],
5088 rte_cryptodev_driver_id_get(
5089 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5090 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5092 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5094 return TEST_SUCCESS;
5098 test_3DES_chain_ccp_all(void)
5100 struct crypto_testsuite_params *ts_params = &testsuite_params;
5103 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5104 ts_params->op_mpool,
5105 ts_params->session_mpool,
5106 ts_params->valid_devs[0],
5107 rte_cryptodev_driver_id_get(
5108 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5109 BLKCIPHER_3DES_CHAIN_TYPE);
5111 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5113 return TEST_SUCCESS;
5117 test_3DES_cipheronly_ccp_all(void)
5119 struct crypto_testsuite_params *ts_params = &testsuite_params;
5122 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5123 ts_params->op_mpool,
5124 ts_params->session_mpool,
5125 ts_params->valid_devs[0],
5126 rte_cryptodev_driver_id_get(
5127 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5128 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5130 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5132 return TEST_SUCCESS;
5136 test_3DES_cipheronly_qat_all(void)
5138 struct crypto_testsuite_params *ts_params = &testsuite_params;
5141 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5142 ts_params->op_mpool,
5143 ts_params->session_mpool,
5144 ts_params->valid_devs[0],
5145 rte_cryptodev_driver_id_get(
5146 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5147 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5149 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5151 return TEST_SUCCESS;
5155 test_3DES_chain_openssl_all(void)
5157 struct crypto_testsuite_params *ts_params = &testsuite_params;
5160 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5161 ts_params->op_mpool,
5162 ts_params->session_mpool,
5163 ts_params->valid_devs[0],
5164 rte_cryptodev_driver_id_get(
5165 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5166 BLKCIPHER_3DES_CHAIN_TYPE);
5168 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5170 return TEST_SUCCESS;
5174 test_3DES_cipheronly_openssl_all(void)
5176 struct crypto_testsuite_params *ts_params = &testsuite_params;
5179 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5180 ts_params->op_mpool,
5181 ts_params->session_mpool,
5182 ts_params->valid_devs[0],
5183 rte_cryptodev_driver_id_get(
5184 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5185 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5187 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5189 return TEST_SUCCESS;
5192 /* ***** AEAD algorithm Tests ***** */
5195 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5196 enum rte_crypto_aead_operation op,
5197 const uint8_t *key, const uint8_t key_len,
5198 const uint16_t aad_len, const uint8_t auth_len,
5201 uint8_t aead_key[key_len];
5203 struct crypto_testsuite_params *ts_params = &testsuite_params;
5204 struct crypto_unittest_params *ut_params = &unittest_params;
5206 memcpy(aead_key, key, key_len);
5208 /* Setup AEAD Parameters */
5209 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5210 ut_params->aead_xform.next = NULL;
5211 ut_params->aead_xform.aead.algo = algo;
5212 ut_params->aead_xform.aead.op = op;
5213 ut_params->aead_xform.aead.key.data = aead_key;
5214 ut_params->aead_xform.aead.key.length = key_len;
5215 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5216 ut_params->aead_xform.aead.iv.length = iv_len;
5217 ut_params->aead_xform.aead.digest_length = auth_len;
5218 ut_params->aead_xform.aead.aad_length = aad_len;
5220 debug_hexdump(stdout, "key:", key, key_len);
5222 /* Create Crypto session*/
5223 ut_params->sess = rte_cryptodev_sym_session_create(
5224 ts_params->session_mpool);
5226 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5227 &ut_params->aead_xform, ts_params->session_mpool);
5229 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5235 create_aead_xform(struct rte_crypto_op *op,
5236 enum rte_crypto_aead_algorithm algo,
5237 enum rte_crypto_aead_operation aead_op,
5238 uint8_t *key, const uint8_t key_len,
5239 const uint8_t aad_len, const uint8_t auth_len,
5242 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5243 "failed to allocate space for crypto transform");
5245 struct rte_crypto_sym_op *sym_op = op->sym;
5247 /* Setup AEAD Parameters */
5248 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5249 sym_op->xform->next = NULL;
5250 sym_op->xform->aead.algo = algo;
5251 sym_op->xform->aead.op = aead_op;
5252 sym_op->xform->aead.key.data = key;
5253 sym_op->xform->aead.key.length = key_len;
5254 sym_op->xform->aead.iv.offset = IV_OFFSET;
5255 sym_op->xform->aead.iv.length = iv_len;
5256 sym_op->xform->aead.digest_length = auth_len;
5257 sym_op->xform->aead.aad_length = aad_len;
5259 debug_hexdump(stdout, "key:", key, key_len);
5265 create_aead_operation(enum rte_crypto_aead_operation op,
5266 const struct aead_test_data *tdata)
5268 struct crypto_testsuite_params *ts_params = &testsuite_params;
5269 struct crypto_unittest_params *ut_params = &unittest_params;
5271 uint8_t *plaintext, *ciphertext;
5272 unsigned int aad_pad_len, plaintext_pad_len;
5274 /* Generate Crypto op data structure */
5275 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5276 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5277 TEST_ASSERT_NOT_NULL(ut_params->op,
5278 "Failed to allocate symmetric crypto operation struct");
5280 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5282 /* Append aad data */
5283 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5284 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5285 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5287 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5288 "no room to append aad");
5290 sym_op->aead.aad.phys_addr =
5291 rte_pktmbuf_iova(ut_params->ibuf);
5292 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5293 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5294 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5297 /* Append IV at the end of the crypto operation*/
5298 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5299 uint8_t *, IV_OFFSET);
5301 /* Copy IV 1 byte after the IV pointer, according to the API */
5302 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5303 debug_hexdump(stdout, "iv:", iv_ptr,
5306 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5307 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5309 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5310 "no room to append aad");
5312 sym_op->aead.aad.phys_addr =
5313 rte_pktmbuf_iova(ut_params->ibuf);
5314 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5315 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5318 /* Append IV at the end of the crypto operation*/
5319 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5320 uint8_t *, IV_OFFSET);
5322 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5323 debug_hexdump(stdout, "iv:", iv_ptr,
5327 /* Append plaintext/ciphertext */
5328 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5329 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5330 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5332 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5334 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5335 debug_hexdump(stdout, "plaintext:", plaintext,
5336 tdata->plaintext.len);
5338 if (ut_params->obuf) {
5339 ciphertext = (uint8_t *)rte_pktmbuf_append(
5341 plaintext_pad_len + aad_pad_len);
5342 TEST_ASSERT_NOT_NULL(ciphertext,
5343 "no room to append ciphertext");
5345 memset(ciphertext + aad_pad_len, 0,
5346 tdata->ciphertext.len);
5349 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5350 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5352 TEST_ASSERT_NOT_NULL(ciphertext,
5353 "no room to append ciphertext");
5355 memcpy(ciphertext, tdata->ciphertext.data,
5356 tdata->ciphertext.len);
5357 debug_hexdump(stdout, "ciphertext:", ciphertext,
5358 tdata->ciphertext.len);
5360 if (ut_params->obuf) {
5361 plaintext = (uint8_t *)rte_pktmbuf_append(
5363 plaintext_pad_len + aad_pad_len);
5364 TEST_ASSERT_NOT_NULL(plaintext,
5365 "no room to append plaintext");
5367 memset(plaintext + aad_pad_len, 0,
5368 tdata->plaintext.len);
5372 /* Append digest data */
5373 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5374 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5375 ut_params->obuf ? ut_params->obuf :
5377 tdata->auth_tag.len);
5378 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5379 "no room to append digest");
5380 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5381 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5382 ut_params->obuf ? ut_params->obuf :
5387 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5388 ut_params->ibuf, tdata->auth_tag.len);
5389 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5390 "no room to append digest");
5391 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5393 plaintext_pad_len + aad_pad_len);
5395 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5396 tdata->auth_tag.len);
5397 debug_hexdump(stdout, "digest:",
5398 sym_op->aead.digest.data,
5399 tdata->auth_tag.len);
5402 sym_op->aead.data.length = tdata->plaintext.len;
5403 sym_op->aead.data.offset = aad_pad_len;
5409 test_authenticated_encryption(const struct aead_test_data *tdata)
5411 struct crypto_testsuite_params *ts_params = &testsuite_params;
5412 struct crypto_unittest_params *ut_params = &unittest_params;
5415 uint8_t *ciphertext, *auth_tag;
5416 uint16_t plaintext_pad_len;
5419 /* Create AEAD session */
5420 retval = create_aead_session(ts_params->valid_devs[0],
5422 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5423 tdata->key.data, tdata->key.len,
5424 tdata->aad.len, tdata->auth_tag.len,
5429 if (tdata->aad.len > MBUF_SIZE) {
5430 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5431 /* Populate full size of add data */
5432 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5433 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5435 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5437 /* clear mbuf payload */
5438 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5439 rte_pktmbuf_tailroom(ut_params->ibuf));
5441 /* Create AEAD operation */
5442 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5446 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5448 ut_params->op->sym->m_src = ut_params->ibuf;
5450 /* Process crypto operation */
5451 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5452 ut_params->op), "failed to process sym crypto op");
5454 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5455 "crypto op processing failed");
5457 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5459 if (ut_params->op->sym->m_dst) {
5460 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5462 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5463 uint8_t *, plaintext_pad_len);
5465 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5467 ut_params->op->sym->cipher.data.offset);
5468 auth_tag = ciphertext + plaintext_pad_len;
5471 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5472 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5475 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5477 tdata->ciphertext.data,
5478 tdata->ciphertext.len,
5479 "Ciphertext data not as expected");
5481 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5483 tdata->auth_tag.data,
5484 tdata->auth_tag.len,
5485 "Generated auth tag not as expected");
5492 test_AES_GCM_authenticated_encryption_test_case_1(void)
5494 return test_authenticated_encryption(&gcm_test_case_1);
5498 test_AES_GCM_authenticated_encryption_test_case_2(void)
5500 return test_authenticated_encryption(&gcm_test_case_2);
5504 test_AES_GCM_authenticated_encryption_test_case_3(void)
5506 return test_authenticated_encryption(&gcm_test_case_3);
5510 test_AES_GCM_authenticated_encryption_test_case_4(void)
5512 return test_authenticated_encryption(&gcm_test_case_4);
5516 test_AES_GCM_authenticated_encryption_test_case_5(void)
5518 return test_authenticated_encryption(&gcm_test_case_5);
5522 test_AES_GCM_authenticated_encryption_test_case_6(void)
5524 return test_authenticated_encryption(&gcm_test_case_6);
5528 test_AES_GCM_authenticated_encryption_test_case_7(void)
5530 return test_authenticated_encryption(&gcm_test_case_7);
5534 test_AES_GCM_auth_encryption_test_case_192_1(void)
5536 return test_authenticated_encryption(&gcm_test_case_192_1);
5540 test_AES_GCM_auth_encryption_test_case_192_2(void)
5542 return test_authenticated_encryption(&gcm_test_case_192_2);
5546 test_AES_GCM_auth_encryption_test_case_192_3(void)
5548 return test_authenticated_encryption(&gcm_test_case_192_3);
5552 test_AES_GCM_auth_encryption_test_case_192_4(void)
5554 return test_authenticated_encryption(&gcm_test_case_192_4);
5558 test_AES_GCM_auth_encryption_test_case_192_5(void)
5560 return test_authenticated_encryption(&gcm_test_case_192_5);
5564 test_AES_GCM_auth_encryption_test_case_192_6(void)
5566 return test_authenticated_encryption(&gcm_test_case_192_6);
5570 test_AES_GCM_auth_encryption_test_case_192_7(void)
5572 return test_authenticated_encryption(&gcm_test_case_192_7);
5576 test_AES_GCM_auth_encryption_test_case_256_1(void)
5578 return test_authenticated_encryption(&gcm_test_case_256_1);
5582 test_AES_GCM_auth_encryption_test_case_256_2(void)
5584 return test_authenticated_encryption(&gcm_test_case_256_2);
5588 test_AES_GCM_auth_encryption_test_case_256_3(void)
5590 return test_authenticated_encryption(&gcm_test_case_256_3);
5594 test_AES_GCM_auth_encryption_test_case_256_4(void)
5596 return test_authenticated_encryption(&gcm_test_case_256_4);
5600 test_AES_GCM_auth_encryption_test_case_256_5(void)
5602 return test_authenticated_encryption(&gcm_test_case_256_5);
5606 test_AES_GCM_auth_encryption_test_case_256_6(void)
5608 return test_authenticated_encryption(&gcm_test_case_256_6);
5612 test_AES_GCM_auth_encryption_test_case_256_7(void)
5614 return test_authenticated_encryption(&gcm_test_case_256_7);
5618 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5620 return test_authenticated_encryption(&gcm_test_case_aad_1);
5624 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5626 return test_authenticated_encryption(&gcm_test_case_aad_2);
5630 test_authenticated_decryption(const struct aead_test_data *tdata)
5632 struct crypto_testsuite_params *ts_params = &testsuite_params;
5633 struct crypto_unittest_params *ut_params = &unittest_params;
5639 /* Create AEAD session */
5640 retval = create_aead_session(ts_params->valid_devs[0],
5642 RTE_CRYPTO_AEAD_OP_DECRYPT,
5643 tdata->key.data, tdata->key.len,
5644 tdata->aad.len, tdata->auth_tag.len,
5649 /* alloc mbuf and set payload */
5650 if (tdata->aad.len > MBUF_SIZE) {
5651 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5652 /* Populate full size of add data */
5653 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5654 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5656 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5658 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5659 rte_pktmbuf_tailroom(ut_params->ibuf));
5661 /* Create AEAD operation */
5662 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5666 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5668 ut_params->op->sym->m_src = ut_params->ibuf;
5670 /* Process crypto operation */
5671 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5672 ut_params->op), "failed to process sym crypto op");
5674 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5675 "crypto op processing failed");
5677 if (ut_params->op->sym->m_dst)
5678 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5681 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5683 ut_params->op->sym->cipher.data.offset);
5685 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5688 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5690 tdata->plaintext.data,
5691 tdata->plaintext.len,
5692 "Plaintext data not as expected");
5694 TEST_ASSERT_EQUAL(ut_params->op->status,
5695 RTE_CRYPTO_OP_STATUS_SUCCESS,
5696 "Authentication failed");
5701 test_AES_GCM_authenticated_decryption_test_case_1(void)
5703 return test_authenticated_decryption(&gcm_test_case_1);
5707 test_AES_GCM_authenticated_decryption_test_case_2(void)
5709 return test_authenticated_decryption(&gcm_test_case_2);
5713 test_AES_GCM_authenticated_decryption_test_case_3(void)
5715 return test_authenticated_decryption(&gcm_test_case_3);
5719 test_AES_GCM_authenticated_decryption_test_case_4(void)
5721 return test_authenticated_decryption(&gcm_test_case_4);
5725 test_AES_GCM_authenticated_decryption_test_case_5(void)
5727 return test_authenticated_decryption(&gcm_test_case_5);
5731 test_AES_GCM_authenticated_decryption_test_case_6(void)
5733 return test_authenticated_decryption(&gcm_test_case_6);
5737 test_AES_GCM_authenticated_decryption_test_case_7(void)
5739 return test_authenticated_decryption(&gcm_test_case_7);
5743 test_AES_GCM_auth_decryption_test_case_192_1(void)
5745 return test_authenticated_decryption(&gcm_test_case_192_1);
5749 test_AES_GCM_auth_decryption_test_case_192_2(void)
5751 return test_authenticated_decryption(&gcm_test_case_192_2);
5755 test_AES_GCM_auth_decryption_test_case_192_3(void)
5757 return test_authenticated_decryption(&gcm_test_case_192_3);
5761 test_AES_GCM_auth_decryption_test_case_192_4(void)
5763 return test_authenticated_decryption(&gcm_test_case_192_4);
5767 test_AES_GCM_auth_decryption_test_case_192_5(void)
5769 return test_authenticated_decryption(&gcm_test_case_192_5);
5773 test_AES_GCM_auth_decryption_test_case_192_6(void)
5775 return test_authenticated_decryption(&gcm_test_case_192_6);
5779 test_AES_GCM_auth_decryption_test_case_192_7(void)
5781 return test_authenticated_decryption(&gcm_test_case_192_7);
5785 test_AES_GCM_auth_decryption_test_case_256_1(void)
5787 return test_authenticated_decryption(&gcm_test_case_256_1);
5791 test_AES_GCM_auth_decryption_test_case_256_2(void)
5793 return test_authenticated_decryption(&gcm_test_case_256_2);
5797 test_AES_GCM_auth_decryption_test_case_256_3(void)
5799 return test_authenticated_decryption(&gcm_test_case_256_3);
5803 test_AES_GCM_auth_decryption_test_case_256_4(void)
5805 return test_authenticated_decryption(&gcm_test_case_256_4);
5809 test_AES_GCM_auth_decryption_test_case_256_5(void)
5811 return test_authenticated_decryption(&gcm_test_case_256_5);
5815 test_AES_GCM_auth_decryption_test_case_256_6(void)
5817 return test_authenticated_decryption(&gcm_test_case_256_6);
5821 test_AES_GCM_auth_decryption_test_case_256_7(void)
5823 return test_authenticated_decryption(&gcm_test_case_256_7);
5827 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5829 return test_authenticated_decryption(&gcm_test_case_aad_1);
5833 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5835 return test_authenticated_decryption(&gcm_test_case_aad_2);
5839 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5841 struct crypto_testsuite_params *ts_params = &testsuite_params;
5842 struct crypto_unittest_params *ut_params = &unittest_params;
5845 uint8_t *ciphertext, *auth_tag;
5846 uint16_t plaintext_pad_len;
5848 /* Create AEAD session */
5849 retval = create_aead_session(ts_params->valid_devs[0],
5851 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5852 tdata->key.data, tdata->key.len,
5853 tdata->aad.len, tdata->auth_tag.len,
5858 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5859 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5861 /* clear mbuf payload */
5862 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5863 rte_pktmbuf_tailroom(ut_params->ibuf));
5864 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5865 rte_pktmbuf_tailroom(ut_params->obuf));
5867 /* Create AEAD operation */
5868 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5872 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5874 ut_params->op->sym->m_src = ut_params->ibuf;
5875 ut_params->op->sym->m_dst = ut_params->obuf;
5877 /* Process crypto operation */
5878 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5879 ut_params->op), "failed to process sym crypto op");
5881 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5882 "crypto op processing failed");
5884 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5886 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5887 ut_params->op->sym->cipher.data.offset);
5888 auth_tag = ciphertext + plaintext_pad_len;
5890 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5891 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5894 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5896 tdata->ciphertext.data,
5897 tdata->ciphertext.len,
5898 "Ciphertext data not as expected");
5900 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5902 tdata->auth_tag.data,
5903 tdata->auth_tag.len,
5904 "Generated auth tag not as expected");
5911 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5913 return test_authenticated_encryption_oop(&gcm_test_case_5);
5917 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5919 struct crypto_testsuite_params *ts_params = &testsuite_params;
5920 struct crypto_unittest_params *ut_params = &unittest_params;
5925 /* Create AEAD session */
5926 retval = create_aead_session(ts_params->valid_devs[0],
5928 RTE_CRYPTO_AEAD_OP_DECRYPT,
5929 tdata->key.data, tdata->key.len,
5930 tdata->aad.len, tdata->auth_tag.len,
5935 /* alloc mbuf and set payload */
5936 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5937 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5939 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5940 rte_pktmbuf_tailroom(ut_params->ibuf));
5941 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5942 rte_pktmbuf_tailroom(ut_params->obuf));
5944 /* Create AEAD operation */
5945 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5949 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5951 ut_params->op->sym->m_src = ut_params->ibuf;
5952 ut_params->op->sym->m_dst = ut_params->obuf;
5954 /* Process crypto operation */
5955 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5956 ut_params->op), "failed to process sym crypto op");
5958 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5959 "crypto op processing failed");
5961 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5962 ut_params->op->sym->cipher.data.offset);
5964 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5967 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5969 tdata->plaintext.data,
5970 tdata->plaintext.len,
5971 "Plaintext data not as expected");
5973 TEST_ASSERT_EQUAL(ut_params->op->status,
5974 RTE_CRYPTO_OP_STATUS_SUCCESS,
5975 "Authentication failed");
5980 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5982 return test_authenticated_decryption_oop(&gcm_test_case_5);
5986 test_authenticated_encryption_sessionless(
5987 const struct aead_test_data *tdata)
5989 struct crypto_testsuite_params *ts_params = &testsuite_params;
5990 struct crypto_unittest_params *ut_params = &unittest_params;
5993 uint8_t *ciphertext, *auth_tag;
5994 uint16_t plaintext_pad_len;
5995 uint8_t key[tdata->key.len + 1];
5997 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5999 /* clear mbuf payload */
6000 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6001 rte_pktmbuf_tailroom(ut_params->ibuf));
6003 /* Create AEAD operation */
6004 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6008 /* Create GCM xform */
6009 memcpy(key, tdata->key.data, tdata->key.len);
6010 retval = create_aead_xform(ut_params->op,
6012 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6013 key, tdata->key.len,
6014 tdata->aad.len, tdata->auth_tag.len,
6019 ut_params->op->sym->m_src = ut_params->ibuf;
6021 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6022 RTE_CRYPTO_OP_SESSIONLESS,
6023 "crypto op session type not sessionless");
6025 /* Process crypto operation */
6026 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6027 ut_params->op), "failed to process sym crypto op");
6029 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6031 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6032 "crypto op status not success");
6034 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6036 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6037 ut_params->op->sym->cipher.data.offset);
6038 auth_tag = ciphertext + plaintext_pad_len;
6040 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6041 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6044 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6046 tdata->ciphertext.data,
6047 tdata->ciphertext.len,
6048 "Ciphertext data not as expected");
6050 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6052 tdata->auth_tag.data,
6053 tdata->auth_tag.len,
6054 "Generated auth tag not as expected");
6061 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6063 return test_authenticated_encryption_sessionless(
6068 test_authenticated_decryption_sessionless(
6069 const struct aead_test_data *tdata)
6071 struct crypto_testsuite_params *ts_params = &testsuite_params;
6072 struct crypto_unittest_params *ut_params = &unittest_params;
6076 uint8_t key[tdata->key.len + 1];
6078 /* alloc mbuf and set payload */
6079 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6081 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6082 rte_pktmbuf_tailroom(ut_params->ibuf));
6084 /* Create AEAD operation */
6085 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6089 /* Create AEAD xform */
6090 memcpy(key, tdata->key.data, tdata->key.len);
6091 retval = create_aead_xform(ut_params->op,
6093 RTE_CRYPTO_AEAD_OP_DECRYPT,
6094 key, tdata->key.len,
6095 tdata->aad.len, tdata->auth_tag.len,
6100 ut_params->op->sym->m_src = ut_params->ibuf;
6102 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6103 RTE_CRYPTO_OP_SESSIONLESS,
6104 "crypto op session type not sessionless");
6106 /* Process crypto operation */
6107 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6108 ut_params->op), "failed to process sym crypto op");
6110 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6112 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6113 "crypto op status not success");
6115 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6116 ut_params->op->sym->cipher.data.offset);
6118 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6121 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6123 tdata->plaintext.data,
6124 tdata->plaintext.len,
6125 "Plaintext data not as expected");
6127 TEST_ASSERT_EQUAL(ut_params->op->status,
6128 RTE_CRYPTO_OP_STATUS_SUCCESS,
6129 "Authentication failed");
6134 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6136 return test_authenticated_decryption_sessionless(
6141 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6143 return test_authenticated_encryption(&ccm_test_case_128_1);
6147 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6149 return test_authenticated_encryption(&ccm_test_case_128_2);
6153 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6155 return test_authenticated_encryption(&ccm_test_case_128_3);
6159 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6161 return test_authenticated_decryption(&ccm_test_case_128_1);
6165 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6167 return test_authenticated_decryption(&ccm_test_case_128_2);
6171 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6173 return test_authenticated_decryption(&ccm_test_case_128_3);
6177 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6179 return test_authenticated_encryption(&ccm_test_case_192_1);
6183 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6185 return test_authenticated_encryption(&ccm_test_case_192_2);
6189 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6191 return test_authenticated_encryption(&ccm_test_case_192_3);
6195 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6197 return test_authenticated_decryption(&ccm_test_case_192_1);
6201 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6203 return test_authenticated_decryption(&ccm_test_case_192_2);
6207 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6209 return test_authenticated_decryption(&ccm_test_case_192_3);
6213 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6215 return test_authenticated_encryption(&ccm_test_case_256_1);
6219 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6221 return test_authenticated_encryption(&ccm_test_case_256_2);
6225 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6227 return test_authenticated_encryption(&ccm_test_case_256_3);
6231 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6233 return test_authenticated_decryption(&ccm_test_case_256_1);
6237 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6239 return test_authenticated_decryption(&ccm_test_case_256_2);
6243 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6245 return test_authenticated_decryption(&ccm_test_case_256_3);
6251 struct crypto_testsuite_params *ts_params = &testsuite_params;
6252 struct rte_cryptodev_stats stats;
6253 struct rte_cryptodev *dev;
6254 cryptodev_stats_get_t temp_pfn;
6256 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6257 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6258 &stats) == -ENODEV),
6259 "rte_cryptodev_stats_get invalid dev failed");
6260 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6261 "rte_cryptodev_stats_get invalid Param failed");
6262 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6263 temp_pfn = dev->dev_ops->stats_get;
6264 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6265 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6267 "rte_cryptodev_stats_get invalid Param failed");
6268 dev->dev_ops->stats_get = temp_pfn;
6270 /* Test expected values */
6272 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6274 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6276 "rte_cryptodev_stats_get failed");
6277 TEST_ASSERT((stats.enqueued_count == 1),
6278 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6279 TEST_ASSERT((stats.dequeued_count == 1),
6280 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6281 TEST_ASSERT((stats.enqueue_err_count == 0),
6282 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6283 TEST_ASSERT((stats.dequeue_err_count == 0),
6284 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6286 /* invalid device but should ignore and not reset device stats*/
6287 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6288 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6290 "rte_cryptodev_stats_get failed");
6291 TEST_ASSERT((stats.enqueued_count == 1),
6292 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6294 /* check that a valid reset clears stats */
6295 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
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 == 0),
6300 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6301 TEST_ASSERT((stats.dequeued_count == 0),
6302 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6304 return TEST_SUCCESS;
6307 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6308 struct crypto_unittest_params *ut_params,
6309 enum rte_crypto_auth_operation op,
6310 const struct HMAC_MD5_vector *test_case)
6314 memcpy(key, test_case->key.data, test_case->key.len);
6316 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6317 ut_params->auth_xform.next = NULL;
6318 ut_params->auth_xform.auth.op = op;
6320 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6322 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6323 ut_params->auth_xform.auth.key.length = test_case->key.len;
6324 ut_params->auth_xform.auth.key.data = key;
6326 ut_params->sess = rte_cryptodev_sym_session_create(
6327 ts_params->session_mpool);
6329 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6330 ut_params->sess, &ut_params->auth_xform,
6331 ts_params->session_mpool);
6333 if (ut_params->sess == NULL)
6336 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6338 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6339 rte_pktmbuf_tailroom(ut_params->ibuf));
6344 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6345 const struct HMAC_MD5_vector *test_case,
6346 uint8_t **plaintext)
6348 uint16_t plaintext_pad_len;
6350 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6352 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6355 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6357 memcpy(*plaintext, test_case->plaintext.data,
6358 test_case->plaintext.len);
6360 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6361 ut_params->ibuf, MD5_DIGEST_LEN);
6362 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6363 "no room to append digest");
6364 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6365 ut_params->ibuf, plaintext_pad_len);
6367 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6368 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6369 test_case->auth_tag.len);
6372 sym_op->auth.data.offset = 0;
6373 sym_op->auth.data.length = test_case->plaintext.len;
6375 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6376 ut_params->op->sym->m_src = ut_params->ibuf;
6382 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6384 uint16_t plaintext_pad_len;
6385 uint8_t *plaintext, *auth_tag;
6387 struct crypto_testsuite_params *ts_params = &testsuite_params;
6388 struct crypto_unittest_params *ut_params = &unittest_params;
6390 if (MD5_HMAC_create_session(ts_params, ut_params,
6391 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6394 /* Generate Crypto op data structure */
6395 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6396 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6397 TEST_ASSERT_NOT_NULL(ut_params->op,
6398 "Failed to allocate symmetric crypto operation struct");
6400 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6403 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6406 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6407 ut_params->op), "failed to process sym crypto op");
6409 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6410 "crypto op processing failed");
6412 if (ut_params->op->sym->m_dst) {
6413 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6414 uint8_t *, plaintext_pad_len);
6416 auth_tag = plaintext + plaintext_pad_len;
6419 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6421 test_case->auth_tag.data,
6422 test_case->auth_tag.len,
6423 "HMAC_MD5 generated tag not as expected");
6425 return TEST_SUCCESS;
6429 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6433 struct crypto_testsuite_params *ts_params = &testsuite_params;
6434 struct crypto_unittest_params *ut_params = &unittest_params;
6436 if (MD5_HMAC_create_session(ts_params, ut_params,
6437 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6441 /* Generate Crypto op data structure */
6442 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6443 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6444 TEST_ASSERT_NOT_NULL(ut_params->op,
6445 "Failed to allocate symmetric crypto operation struct");
6447 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6450 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6451 ut_params->op), "failed to process sym crypto op");
6453 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6454 "HMAC_MD5 crypto op processing failed");
6456 return TEST_SUCCESS;
6460 test_MD5_HMAC_generate_case_1(void)
6462 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6466 test_MD5_HMAC_verify_case_1(void)
6468 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6472 test_MD5_HMAC_generate_case_2(void)
6474 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6478 test_MD5_HMAC_verify_case_2(void)
6480 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6484 test_multi_session(void)
6486 struct crypto_testsuite_params *ts_params = &testsuite_params;
6487 struct crypto_unittest_params *ut_params = &unittest_params;
6489 struct rte_cryptodev_info dev_info;
6490 struct rte_cryptodev_sym_session **sessions;
6494 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6495 aes_cbc_key, hmac_sha512_key);
6498 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6500 sessions = rte_malloc(NULL,
6501 (sizeof(struct rte_cryptodev_sym_session *) *
6502 dev_info.sym.max_nb_sessions) + 1, 0);
6504 /* Create multiple crypto sessions*/
6505 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6507 sessions[i] = rte_cryptodev_sym_session_create(
6508 ts_params->session_mpool);
6510 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6511 sessions[i], &ut_params->auth_xform,
6512 ts_params->session_mpool);
6513 TEST_ASSERT_NOT_NULL(sessions[i],
6514 "Session creation failed at session number %u",
6517 /* Attempt to send a request on each session */
6518 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6522 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6523 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6525 "Failed to perform decrypt on request number %u.", i);
6526 /* free crypto operation structure */
6528 rte_crypto_op_free(ut_params->op);
6531 * free mbuf - both obuf and ibuf are usually the same,
6532 * so check if they point at the same address is necessary,
6533 * to avoid freeing the mbuf twice.
6535 if (ut_params->obuf) {
6536 rte_pktmbuf_free(ut_params->obuf);
6537 if (ut_params->ibuf == ut_params->obuf)
6538 ut_params->ibuf = 0;
6539 ut_params->obuf = 0;
6541 if (ut_params->ibuf) {
6542 rte_pktmbuf_free(ut_params->ibuf);
6543 ut_params->ibuf = 0;
6547 /* Next session create should fail */
6548 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6549 sessions[i], &ut_params->auth_xform,
6550 ts_params->session_mpool);
6551 TEST_ASSERT_NULL(sessions[i],
6552 "Session creation succeeded unexpectedly!");
6554 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6555 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6557 rte_cryptodev_sym_session_free(sessions[i]);
6562 return TEST_SUCCESS;
6565 struct multi_session_params {
6566 struct crypto_unittest_params ut_params;
6567 uint8_t *cipher_key;
6569 const uint8_t *cipher;
6570 const uint8_t *digest;
6574 #define MB_SESSION_NUMBER 3
6577 test_multi_session_random_usage(void)
6579 struct crypto_testsuite_params *ts_params = &testsuite_params;
6580 struct rte_cryptodev_info dev_info;
6581 struct rte_cryptodev_sym_session **sessions;
6583 struct multi_session_params ut_paramz[] = {
6586 .cipher_key = ms_aes_cbc_key0,
6587 .hmac_key = ms_hmac_key0,
6588 .cipher = ms_aes_cbc_cipher0,
6589 .digest = ms_hmac_digest0,
6590 .iv = ms_aes_cbc_iv0
6593 .cipher_key = ms_aes_cbc_key1,
6594 .hmac_key = ms_hmac_key1,
6595 .cipher = ms_aes_cbc_cipher1,
6596 .digest = ms_hmac_digest1,
6597 .iv = ms_aes_cbc_iv1
6600 .cipher_key = ms_aes_cbc_key2,
6601 .hmac_key = ms_hmac_key2,
6602 .cipher = ms_aes_cbc_cipher2,
6603 .digest = ms_hmac_digest2,
6604 .iv = ms_aes_cbc_iv2
6609 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6611 sessions = rte_malloc(NULL,
6612 (sizeof(struct rte_cryptodev_sym_session *)
6613 * dev_info.sym.max_nb_sessions) + 1, 0);
6615 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6616 sessions[i] = rte_cryptodev_sym_session_create(
6617 ts_params->session_mpool);
6619 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6620 sizeof(struct crypto_unittest_params));
6622 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6623 &ut_paramz[i].ut_params,
6624 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6626 /* Create multiple crypto sessions*/
6627 rte_cryptodev_sym_session_init(
6628 ts_params->valid_devs[0],
6630 &ut_paramz[i].ut_params.auth_xform,
6631 ts_params->session_mpool);
6633 TEST_ASSERT_NOT_NULL(sessions[i],
6634 "Session creation failed at session number %u",
6640 for (i = 0; i < 40000; i++) {
6642 j = rand() % MB_SESSION_NUMBER;
6644 TEST_ASSERT_SUCCESS(
6645 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6647 &ut_paramz[j].ut_params,
6648 ts_params, ut_paramz[j].cipher,
6649 ut_paramz[j].digest,
6651 "Failed to perform decrypt on request number %u.", i);
6653 if (ut_paramz[j].ut_params.op)
6654 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6657 * free mbuf - both obuf and ibuf are usually the same,
6658 * so check if they point at the same address is necessary,
6659 * to avoid freeing the mbuf twice.
6661 if (ut_paramz[j].ut_params.obuf) {
6662 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6663 if (ut_paramz[j].ut_params.ibuf
6664 == ut_paramz[j].ut_params.obuf)
6665 ut_paramz[j].ut_params.ibuf = 0;
6666 ut_paramz[j].ut_params.obuf = 0;
6668 if (ut_paramz[j].ut_params.ibuf) {
6669 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6670 ut_paramz[j].ut_params.ibuf = 0;
6674 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6675 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6677 rte_cryptodev_sym_session_free(sessions[i]);
6682 return TEST_SUCCESS;
6686 test_null_cipher_only_operation(void)
6688 struct crypto_testsuite_params *ts_params = &testsuite_params;
6689 struct crypto_unittest_params *ut_params = &unittest_params;
6691 /* Generate test mbuf data and space for digest */
6692 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6693 catch_22_quote, QUOTE_512_BYTES, 0);
6695 /* Setup Cipher Parameters */
6696 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6697 ut_params->cipher_xform.next = NULL;
6699 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6700 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6702 ut_params->sess = rte_cryptodev_sym_session_create(
6703 ts_params->session_mpool);
6705 /* Create Crypto session*/
6706 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6708 &ut_params->cipher_xform,
6709 ts_params->session_mpool);
6710 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6712 /* Generate Crypto op data structure */
6713 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6714 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6715 TEST_ASSERT_NOT_NULL(ut_params->op,
6716 "Failed to allocate symmetric crypto operation struct");
6718 /* Set crypto operation data parameters */
6719 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6721 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6723 /* set crypto operation source mbuf */
6724 sym_op->m_src = ut_params->ibuf;
6726 sym_op->cipher.data.offset = 0;
6727 sym_op->cipher.data.length = QUOTE_512_BYTES;
6729 /* Process crypto operation */
6730 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6732 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6734 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6735 "crypto operation processing failed");
6738 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6739 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6742 "Ciphertext data not as expected");
6744 return TEST_SUCCESS;
6746 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6747 0xab, 0xab, 0xab, 0xab,
6748 0xab, 0xab, 0xab, 0xab,
6749 0xab, 0xab, 0xab, 0xab};
6751 test_null_auth_only_operation(void)
6753 struct crypto_testsuite_params *ts_params = &testsuite_params;
6754 struct crypto_unittest_params *ut_params = &unittest_params;
6757 /* Generate test mbuf data and space for digest */
6758 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6759 catch_22_quote, QUOTE_512_BYTES, 0);
6761 /* create a pointer for digest, but don't expect anything to be written
6762 * here in a NULL auth algo so no mbuf append done.
6764 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6766 /* prefill the memory pointed to by digest */
6767 memcpy(digest, orig_data, sizeof(orig_data));
6769 /* Setup HMAC Parameters */
6770 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6771 ut_params->auth_xform.next = NULL;
6773 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6774 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6776 ut_params->sess = rte_cryptodev_sym_session_create(
6777 ts_params->session_mpool);
6779 /* Create Crypto session*/
6780 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6781 ut_params->sess, &ut_params->auth_xform,
6782 ts_params->session_mpool);
6783 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6785 /* Generate Crypto op data structure */
6786 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6787 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6788 TEST_ASSERT_NOT_NULL(ut_params->op,
6789 "Failed to allocate symmetric crypto operation struct");
6791 /* Set crypto operation data parameters */
6792 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6794 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6796 sym_op->m_src = ut_params->ibuf;
6798 sym_op->auth.data.offset = 0;
6799 sym_op->auth.data.length = QUOTE_512_BYTES;
6800 sym_op->auth.digest.data = digest;
6801 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6804 /* Process crypto operation */
6805 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6807 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6809 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6810 "crypto operation processing failed");
6811 /* Make sure memory pointed to by digest hasn't been overwritten */
6812 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6816 "Memory at digest ptr overwritten unexpectedly");
6818 return TEST_SUCCESS;
6823 test_null_cipher_auth_operation(void)
6825 struct crypto_testsuite_params *ts_params = &testsuite_params;
6826 struct crypto_unittest_params *ut_params = &unittest_params;
6829 /* Generate test mbuf data and space for digest */
6830 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6831 catch_22_quote, QUOTE_512_BYTES, 0);
6833 /* create a pointer for digest, but don't expect anything to be written
6834 * here in a NULL auth algo so no mbuf append done.
6836 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6838 /* prefill the memory pointed to by digest */
6839 memcpy(digest, orig_data, sizeof(orig_data));
6841 /* Setup Cipher Parameters */
6842 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6843 ut_params->cipher_xform.next = &ut_params->auth_xform;
6845 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6846 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6848 /* Setup HMAC Parameters */
6849 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6850 ut_params->auth_xform.next = NULL;
6852 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6853 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6855 ut_params->sess = rte_cryptodev_sym_session_create(
6856 ts_params->session_mpool);
6858 /* Create Crypto session*/
6859 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6860 ut_params->sess, &ut_params->cipher_xform,
6861 ts_params->session_mpool);
6862 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6864 /* Generate Crypto op data structure */
6865 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6866 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6867 TEST_ASSERT_NOT_NULL(ut_params->op,
6868 "Failed to allocate symmetric crypto operation struct");
6870 /* Set crypto operation data parameters */
6871 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6873 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6875 sym_op->m_src = ut_params->ibuf;
6877 sym_op->cipher.data.offset = 0;
6878 sym_op->cipher.data.length = QUOTE_512_BYTES;
6880 sym_op->auth.data.offset = 0;
6881 sym_op->auth.data.length = QUOTE_512_BYTES;
6882 sym_op->auth.digest.data = digest;
6883 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6886 /* Process crypto operation */
6887 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6889 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6891 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6892 "crypto operation processing failed");
6895 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6896 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6899 "Ciphertext data not as expected");
6900 /* Make sure memory pointed to by digest hasn't been overwritten */
6901 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6905 "Memory at digest ptr overwritten unexpectedly");
6907 return TEST_SUCCESS;
6911 test_null_auth_cipher_operation(void)
6913 struct crypto_testsuite_params *ts_params = &testsuite_params;
6914 struct crypto_unittest_params *ut_params = &unittest_params;
6917 /* Generate test mbuf data */
6918 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6919 catch_22_quote, QUOTE_512_BYTES, 0);
6921 /* create a pointer for digest, but don't expect anything to be written
6922 * here in a NULL auth algo so no mbuf append done.
6924 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6926 /* prefill the memory pointed to by digest */
6927 memcpy(digest, orig_data, sizeof(orig_data));
6929 /* Setup Cipher Parameters */
6930 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6931 ut_params->cipher_xform.next = NULL;
6933 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6934 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6936 /* Setup HMAC Parameters */
6937 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6938 ut_params->auth_xform.next = &ut_params->cipher_xform;
6940 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6941 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6943 ut_params->sess = rte_cryptodev_sym_session_create(
6944 ts_params->session_mpool);
6946 /* Create Crypto session*/
6947 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6948 ut_params->sess, &ut_params->cipher_xform,
6949 ts_params->session_mpool);
6950 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6952 /* Generate Crypto op data structure */
6953 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6954 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6955 TEST_ASSERT_NOT_NULL(ut_params->op,
6956 "Failed to allocate symmetric crypto operation struct");
6958 /* Set crypto operation data parameters */
6959 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6961 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6963 sym_op->m_src = ut_params->ibuf;
6965 sym_op->cipher.data.offset = 0;
6966 sym_op->cipher.data.length = QUOTE_512_BYTES;
6968 sym_op->auth.data.offset = 0;
6969 sym_op->auth.data.length = QUOTE_512_BYTES;
6970 sym_op->auth.digest.data = digest;
6971 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6974 /* Process crypto operation */
6975 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6977 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6979 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6980 "crypto operation processing failed");
6983 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6984 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6987 "Ciphertext data not as expected");
6988 /* Make sure memory pointed to by digest hasn't been overwritten */
6989 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6993 "Memory at digest ptr overwritten unexpectedly");
6995 return TEST_SUCCESS;
7000 test_null_invalid_operation(void)
7002 struct crypto_testsuite_params *ts_params = &testsuite_params;
7003 struct crypto_unittest_params *ut_params = &unittest_params;
7006 /* Setup Cipher Parameters */
7007 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7008 ut_params->cipher_xform.next = NULL;
7010 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7011 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7013 ut_params->sess = rte_cryptodev_sym_session_create(
7014 ts_params->session_mpool);
7016 /* Create Crypto session*/
7017 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7018 ut_params->sess, &ut_params->cipher_xform,
7019 ts_params->session_mpool);
7020 TEST_ASSERT(ret < 0,
7021 "Session creation succeeded unexpectedly");
7024 /* Setup HMAC Parameters */
7025 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7026 ut_params->auth_xform.next = NULL;
7028 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7029 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7031 ut_params->sess = rte_cryptodev_sym_session_create(
7032 ts_params->session_mpool);
7034 /* Create Crypto session*/
7035 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7036 ut_params->sess, &ut_params->auth_xform,
7037 ts_params->session_mpool);
7038 TEST_ASSERT(ret < 0,
7039 "Session creation succeeded unexpectedly");
7041 return TEST_SUCCESS;
7045 #define NULL_BURST_LENGTH (32)
7048 test_null_burst_operation(void)
7050 struct crypto_testsuite_params *ts_params = &testsuite_params;
7051 struct crypto_unittest_params *ut_params = &unittest_params;
7053 unsigned i, burst_len = NULL_BURST_LENGTH;
7055 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7056 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7058 /* Setup Cipher Parameters */
7059 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7060 ut_params->cipher_xform.next = &ut_params->auth_xform;
7062 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7063 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7065 /* Setup HMAC Parameters */
7066 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7067 ut_params->auth_xform.next = NULL;
7069 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7070 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7072 ut_params->sess = rte_cryptodev_sym_session_create(
7073 ts_params->session_mpool);
7075 /* Create Crypto session*/
7076 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7077 ut_params->sess, &ut_params->cipher_xform,
7078 ts_params->session_mpool);
7079 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7081 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7082 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7083 burst_len, "failed to generate burst of crypto ops");
7085 /* Generate an operation for each mbuf in burst */
7086 for (i = 0; i < burst_len; i++) {
7087 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7089 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7091 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7095 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7097 burst[i]->sym->m_src = m;
7100 /* Process crypto operation */
7101 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7102 0, burst, burst_len),
7104 "Error enqueuing burst");
7106 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7107 0, burst_dequeued, burst_len),
7109 "Error dequeuing burst");
7112 for (i = 0; i < burst_len; i++) {
7114 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7115 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7117 "data not as expected");
7119 rte_pktmbuf_free(burst[i]->sym->m_src);
7120 rte_crypto_op_free(burst[i]);
7123 return TEST_SUCCESS;
7127 generate_gmac_large_plaintext(uint8_t *data)
7131 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7132 memcpy(&data[i], &data[0], 32);
7136 create_gmac_operation(enum rte_crypto_auth_operation op,
7137 const struct gmac_test_data *tdata)
7139 struct crypto_testsuite_params *ts_params = &testsuite_params;
7140 struct crypto_unittest_params *ut_params = &unittest_params;
7141 struct rte_crypto_sym_op *sym_op;
7143 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7145 /* Generate Crypto op data structure */
7146 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7147 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7148 TEST_ASSERT_NOT_NULL(ut_params->op,
7149 "Failed to allocate symmetric crypto operation struct");
7151 sym_op = ut_params->op->sym;
7153 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7154 ut_params->ibuf, tdata->gmac_tag.len);
7155 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7156 "no room to append digest");
7158 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7159 ut_params->ibuf, plaintext_pad_len);
7161 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7162 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7163 tdata->gmac_tag.len);
7164 debug_hexdump(stdout, "digest:",
7165 sym_op->auth.digest.data,
7166 tdata->gmac_tag.len);
7169 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7170 uint8_t *, IV_OFFSET);
7172 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7174 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7176 sym_op->cipher.data.length = 0;
7177 sym_op->cipher.data.offset = 0;
7179 sym_op->auth.data.offset = 0;
7180 sym_op->auth.data.length = tdata->plaintext.len;
7185 static int create_gmac_session(uint8_t dev_id,
7186 const struct gmac_test_data *tdata,
7187 enum rte_crypto_auth_operation auth_op)
7189 uint8_t auth_key[tdata->key.len];
7191 struct crypto_testsuite_params *ts_params = &testsuite_params;
7192 struct crypto_unittest_params *ut_params = &unittest_params;
7194 memcpy(auth_key, tdata->key.data, tdata->key.len);
7196 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7197 ut_params->auth_xform.next = NULL;
7199 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7200 ut_params->auth_xform.auth.op = auth_op;
7201 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7202 ut_params->auth_xform.auth.key.length = tdata->key.len;
7203 ut_params->auth_xform.auth.key.data = auth_key;
7204 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7205 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7208 ut_params->sess = rte_cryptodev_sym_session_create(
7209 ts_params->session_mpool);
7211 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7212 &ut_params->auth_xform,
7213 ts_params->session_mpool);
7215 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7221 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7223 struct crypto_testsuite_params *ts_params = &testsuite_params;
7224 struct crypto_unittest_params *ut_params = &unittest_params;
7228 uint8_t *auth_tag, *plaintext;
7229 uint16_t plaintext_pad_len;
7231 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7232 "No GMAC length in the source data");
7234 retval = create_gmac_session(ts_params->valid_devs[0],
7235 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7240 if (tdata->plaintext.len > MBUF_SIZE)
7241 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7243 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7244 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7245 "Failed to allocate input buffer in mempool");
7247 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7248 rte_pktmbuf_tailroom(ut_params->ibuf));
7250 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7252 * Runtime generate the large plain text instead of use hard code
7253 * plain text vector. It is done to avoid create huge source file
7254 * with the test vector.
7256 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7257 generate_gmac_large_plaintext(tdata->plaintext.data);
7259 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7261 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7263 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7264 debug_hexdump(stdout, "plaintext:", plaintext,
7265 tdata->plaintext.len);
7267 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7273 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7275 ut_params->op->sym->m_src = ut_params->ibuf;
7277 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7278 ut_params->op), "failed to process sym crypto op");
7280 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7281 "crypto op processing failed");
7283 if (ut_params->op->sym->m_dst) {
7284 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7285 uint8_t *, plaintext_pad_len);
7287 auth_tag = plaintext + plaintext_pad_len;
7290 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7292 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7294 tdata->gmac_tag.data,
7295 tdata->gmac_tag.len,
7296 "GMAC Generated auth tag not as expected");
7302 test_AES_GMAC_authentication_test_case_1(void)
7304 return test_AES_GMAC_authentication(&gmac_test_case_1);
7308 test_AES_GMAC_authentication_test_case_2(void)
7310 return test_AES_GMAC_authentication(&gmac_test_case_2);
7314 test_AES_GMAC_authentication_test_case_3(void)
7316 return test_AES_GMAC_authentication(&gmac_test_case_3);
7320 test_AES_GMAC_authentication_test_case_4(void)
7322 return test_AES_GMAC_authentication(&gmac_test_case_4);
7326 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7328 struct crypto_testsuite_params *ts_params = &testsuite_params;
7329 struct crypto_unittest_params *ut_params = &unittest_params;
7331 uint32_t plaintext_pad_len;
7334 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7335 "No GMAC length in the source data");
7337 retval = create_gmac_session(ts_params->valid_devs[0],
7338 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7343 if (tdata->plaintext.len > MBUF_SIZE)
7344 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7346 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7347 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7348 "Failed to allocate input buffer in mempool");
7350 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7351 rte_pktmbuf_tailroom(ut_params->ibuf));
7353 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7356 * Runtime generate the large plain text instead of use hard code
7357 * plain text vector. It is done to avoid create huge source file
7358 * with the test vector.
7360 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7361 generate_gmac_large_plaintext(tdata->plaintext.data);
7363 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7365 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7367 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7368 debug_hexdump(stdout, "plaintext:", plaintext,
7369 tdata->plaintext.len);
7371 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7377 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7379 ut_params->op->sym->m_src = ut_params->ibuf;
7381 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7382 ut_params->op), "failed to process sym crypto op");
7384 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7385 "crypto op processing failed");
7392 test_AES_GMAC_authentication_verify_test_case_1(void)
7394 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7398 test_AES_GMAC_authentication_verify_test_case_2(void)
7400 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7404 test_AES_GMAC_authentication_verify_test_case_3(void)
7406 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7410 test_AES_GMAC_authentication_verify_test_case_4(void)
7412 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7415 struct test_crypto_vector {
7416 enum rte_crypto_cipher_algorithm crypto_algo;
7429 const uint8_t *data;
7434 const uint8_t *data;
7438 enum rte_crypto_auth_algorithm auth_algo;
7446 const uint8_t *data;
7456 static const struct test_crypto_vector
7457 hmac_sha1_test_crypto_vector = {
7458 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7460 .data = plaintext_hash,
7465 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7466 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7467 0xDE, 0xF4, 0xDE, 0xAD
7473 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7474 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7475 0x3F, 0x91, 0x64, 0x59
7481 static const struct test_crypto_vector
7482 aes128_gmac_test_vector = {
7483 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7485 .data = plaintext_hash,
7490 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7491 0x08, 0x09, 0x0A, 0x0B
7497 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7498 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7504 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7505 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7511 static const struct test_crypto_vector
7512 aes128cbc_hmac_sha1_test_vector = {
7513 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7516 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7517 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7523 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7524 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7529 .data = plaintext_hash,
7533 .data = ciphertext512_aes128cbc,
7536 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7539 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7540 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7541 0xDE, 0xF4, 0xDE, 0xAD
7547 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7548 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7549 0x18, 0x8C, 0x1D, 0x32
7556 data_corruption(uint8_t *data)
7562 tag_corruption(uint8_t *data, unsigned int tag_offset)
7564 data[tag_offset] += 1;
7568 create_auth_session(struct crypto_unittest_params *ut_params,
7570 const struct test_crypto_vector *reference,
7571 enum rte_crypto_auth_operation auth_op)
7573 struct crypto_testsuite_params *ts_params = &testsuite_params;
7574 uint8_t auth_key[reference->auth_key.len + 1];
7576 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7578 /* Setup Authentication Parameters */
7579 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7580 ut_params->auth_xform.auth.op = auth_op;
7581 ut_params->auth_xform.next = NULL;
7582 ut_params->auth_xform.auth.algo = reference->auth_algo;
7583 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7584 ut_params->auth_xform.auth.key.data = auth_key;
7585 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7587 /* Create Crypto session*/
7588 ut_params->sess = rte_cryptodev_sym_session_create(
7589 ts_params->session_mpool);
7591 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7592 &ut_params->auth_xform,
7593 ts_params->session_mpool);
7595 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7601 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7603 const struct test_crypto_vector *reference,
7604 enum rte_crypto_auth_operation auth_op,
7605 enum rte_crypto_cipher_operation cipher_op)
7607 struct crypto_testsuite_params *ts_params = &testsuite_params;
7608 uint8_t cipher_key[reference->cipher_key.len + 1];
7609 uint8_t auth_key[reference->auth_key.len + 1];
7611 memcpy(cipher_key, reference->cipher_key.data,
7612 reference->cipher_key.len);
7613 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7615 /* Setup Authentication Parameters */
7616 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7617 ut_params->auth_xform.auth.op = auth_op;
7618 ut_params->auth_xform.auth.algo = reference->auth_algo;
7619 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7620 ut_params->auth_xform.auth.key.data = auth_key;
7621 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7623 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7624 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7625 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7627 ut_params->auth_xform.next = &ut_params->cipher_xform;
7629 /* Setup Cipher Parameters */
7630 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7631 ut_params->cipher_xform.next = NULL;
7632 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7633 ut_params->cipher_xform.cipher.op = cipher_op;
7634 ut_params->cipher_xform.cipher.key.data = cipher_key;
7635 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7636 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7637 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7640 /* Create Crypto session*/
7641 ut_params->sess = rte_cryptodev_sym_session_create(
7642 ts_params->session_mpool);
7644 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7645 &ut_params->auth_xform,
7646 ts_params->session_mpool);
7648 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7654 create_auth_operation(struct crypto_testsuite_params *ts_params,
7655 struct crypto_unittest_params *ut_params,
7656 const struct test_crypto_vector *reference,
7657 unsigned int auth_generate)
7659 /* Generate Crypto op data structure */
7660 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7661 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7662 TEST_ASSERT_NOT_NULL(ut_params->op,
7663 "Failed to allocate pktmbuf offload");
7665 /* Set crypto operation data parameters */
7666 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7668 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7670 /* set crypto operation source mbuf */
7671 sym_op->m_src = ut_params->ibuf;
7674 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7675 ut_params->ibuf, reference->digest.len);
7677 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7678 "no room to append auth tag");
7680 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7681 ut_params->ibuf, reference->plaintext.len);
7684 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7686 memcpy(sym_op->auth.digest.data,
7687 reference->digest.data,
7688 reference->digest.len);
7690 debug_hexdump(stdout, "digest:",
7691 sym_op->auth.digest.data,
7692 reference->digest.len);
7694 sym_op->auth.data.length = reference->plaintext.len;
7695 sym_op->auth.data.offset = 0;
7701 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7702 struct crypto_unittest_params *ut_params,
7703 const struct test_crypto_vector *reference,
7704 unsigned int auth_generate)
7706 /* Generate Crypto op data structure */
7707 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7708 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7709 TEST_ASSERT_NOT_NULL(ut_params->op,
7710 "Failed to allocate pktmbuf offload");
7712 /* Set crypto operation data parameters */
7713 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7715 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7717 /* set crypto operation source mbuf */
7718 sym_op->m_src = ut_params->ibuf;
7721 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7722 ut_params->ibuf, reference->digest.len);
7724 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7725 "no room to append auth tag");
7727 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7728 ut_params->ibuf, reference->ciphertext.len);
7731 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7733 memcpy(sym_op->auth.digest.data,
7734 reference->digest.data,
7735 reference->digest.len);
7737 debug_hexdump(stdout, "digest:",
7738 sym_op->auth.digest.data,
7739 reference->digest.len);
7741 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7742 reference->iv.data, reference->iv.len);
7744 sym_op->cipher.data.length = 0;
7745 sym_op->cipher.data.offset = 0;
7747 sym_op->auth.data.length = reference->plaintext.len;
7748 sym_op->auth.data.offset = 0;
7754 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7755 struct crypto_unittest_params *ut_params,
7756 const struct test_crypto_vector *reference,
7757 unsigned int auth_generate)
7759 /* Generate Crypto op data structure */
7760 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7761 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7762 TEST_ASSERT_NOT_NULL(ut_params->op,
7763 "Failed to allocate pktmbuf offload");
7765 /* Set crypto operation data parameters */
7766 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7768 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7770 /* set crypto operation source mbuf */
7771 sym_op->m_src = ut_params->ibuf;
7774 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7775 ut_params->ibuf, reference->digest.len);
7777 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7778 "no room to append auth tag");
7780 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7781 ut_params->ibuf, reference->ciphertext.len);
7784 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7786 memcpy(sym_op->auth.digest.data,
7787 reference->digest.data,
7788 reference->digest.len);
7790 debug_hexdump(stdout, "digest:",
7791 sym_op->auth.digest.data,
7792 reference->digest.len);
7794 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7795 reference->iv.data, reference->iv.len);
7797 sym_op->cipher.data.length = reference->ciphertext.len;
7798 sym_op->cipher.data.offset = 0;
7800 sym_op->auth.data.length = reference->ciphertext.len;
7801 sym_op->auth.data.offset = 0;
7807 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7808 struct crypto_unittest_params *ut_params,
7809 const struct test_crypto_vector *reference)
7811 return create_auth_operation(ts_params, ut_params, reference, 0);
7815 create_auth_verify_GMAC_operation(
7816 struct crypto_testsuite_params *ts_params,
7817 struct crypto_unittest_params *ut_params,
7818 const struct test_crypto_vector *reference)
7820 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7824 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7825 struct crypto_unittest_params *ut_params,
7826 const struct test_crypto_vector *reference)
7828 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7832 test_authentication_verify_fail_when_data_corruption(
7833 struct crypto_testsuite_params *ts_params,
7834 struct crypto_unittest_params *ut_params,
7835 const struct test_crypto_vector *reference,
7836 unsigned int data_corrupted)
7842 /* Create session */
7843 retval = create_auth_session(ut_params,
7844 ts_params->valid_devs[0],
7846 RTE_CRYPTO_AUTH_OP_VERIFY);
7850 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7851 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7852 "Failed to allocate input buffer in mempool");
7854 /* clear mbuf payload */
7855 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7856 rte_pktmbuf_tailroom(ut_params->ibuf));
7858 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7859 reference->plaintext.len);
7860 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7861 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7863 debug_hexdump(stdout, "plaintext:", plaintext,
7864 reference->plaintext.len);
7866 /* Create operation */
7867 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7873 data_corruption(plaintext);
7875 tag_corruption(plaintext, reference->plaintext.len);
7877 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7879 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7880 TEST_ASSERT_EQUAL(ut_params->op->status,
7881 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7882 "authentication not failed");
7884 ut_params->obuf = ut_params->op->sym->m_src;
7885 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7891 test_authentication_verify_GMAC_fail_when_corruption(
7892 struct crypto_testsuite_params *ts_params,
7893 struct crypto_unittest_params *ut_params,
7894 const struct test_crypto_vector *reference,
7895 unsigned int data_corrupted)
7900 /* Create session */
7901 retval = create_auth_cipher_session(ut_params,
7902 ts_params->valid_devs[0],
7904 RTE_CRYPTO_AUTH_OP_VERIFY,
7905 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7909 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7910 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7911 "Failed to allocate input buffer in mempool");
7913 /* clear mbuf payload */
7914 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7915 rte_pktmbuf_tailroom(ut_params->ibuf));
7917 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7918 reference->plaintext.len);
7919 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7920 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7922 debug_hexdump(stdout, "plaintext:", plaintext,
7923 reference->plaintext.len);
7925 /* Create operation */
7926 retval = create_auth_verify_GMAC_operation(ts_params,
7934 data_corruption(plaintext);
7936 tag_corruption(plaintext, reference->aad.len);
7938 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7940 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7941 TEST_ASSERT_EQUAL(ut_params->op->status,
7942 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7943 "authentication not failed");
7945 ut_params->obuf = ut_params->op->sym->m_src;
7946 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7952 test_authenticated_decryption_fail_when_corruption(
7953 struct crypto_testsuite_params *ts_params,
7954 struct crypto_unittest_params *ut_params,
7955 const struct test_crypto_vector *reference,
7956 unsigned int data_corrupted)
7960 uint8_t *ciphertext;
7962 /* Create session */
7963 retval = create_auth_cipher_session(ut_params,
7964 ts_params->valid_devs[0],
7966 RTE_CRYPTO_AUTH_OP_VERIFY,
7967 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7971 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7972 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7973 "Failed to allocate input buffer in mempool");
7975 /* clear mbuf payload */
7976 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7977 rte_pktmbuf_tailroom(ut_params->ibuf));
7979 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7980 reference->ciphertext.len);
7981 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7982 memcpy(ciphertext, reference->ciphertext.data,
7983 reference->ciphertext.len);
7985 /* Create operation */
7986 retval = create_cipher_auth_verify_operation(ts_params,
7994 data_corruption(ciphertext);
7996 tag_corruption(ciphertext, reference->ciphertext.len);
7998 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8001 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8002 TEST_ASSERT_EQUAL(ut_params->op->status,
8003 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8004 "authentication not failed");
8006 ut_params->obuf = ut_params->op->sym->m_src;
8007 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8013 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8014 const struct aead_test_data *tdata,
8015 void *digest_mem, uint64_t digest_phys)
8017 struct crypto_testsuite_params *ts_params = &testsuite_params;
8018 struct crypto_unittest_params *ut_params = &unittest_params;
8020 const unsigned int auth_tag_len = tdata->auth_tag.len;
8021 const unsigned int iv_len = tdata->iv.len;
8022 unsigned int aad_len = tdata->aad.len;
8024 /* Generate Crypto op data structure */
8025 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8026 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8027 TEST_ASSERT_NOT_NULL(ut_params->op,
8028 "Failed to allocate symmetric crypto operation struct");
8030 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8032 sym_op->aead.digest.data = digest_mem;
8034 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8035 "no room to append digest");
8037 sym_op->aead.digest.phys_addr = digest_phys;
8039 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8040 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8042 debug_hexdump(stdout, "digest:",
8043 sym_op->aead.digest.data,
8047 /* Append aad data */
8048 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8049 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8050 uint8_t *, IV_OFFSET);
8052 /* Copy IV 1 byte after the IV pointer, according to the API */
8053 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8055 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8057 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8058 ut_params->ibuf, aad_len);
8059 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8060 "no room to prepend aad");
8061 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8064 memset(sym_op->aead.aad.data, 0, aad_len);
8065 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8066 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8068 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8069 debug_hexdump(stdout, "aad:",
8070 sym_op->aead.aad.data, aad_len);
8072 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8073 uint8_t *, IV_OFFSET);
8075 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8077 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8078 ut_params->ibuf, aad_len);
8079 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8080 "no room to prepend aad");
8081 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8084 memset(sym_op->aead.aad.data, 0, aad_len);
8085 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8087 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8088 debug_hexdump(stdout, "aad:",
8089 sym_op->aead.aad.data, aad_len);
8092 sym_op->aead.data.length = tdata->plaintext.len;
8093 sym_op->aead.data.offset = aad_len;
8098 #define SGL_MAX_NO 16
8101 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8102 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8104 struct crypto_testsuite_params *ts_params = &testsuite_params;
8105 struct crypto_unittest_params *ut_params = &unittest_params;
8106 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8109 int to_trn_tbl[SGL_MAX_NO];
8111 unsigned int trn_data = 0;
8112 uint8_t *plaintext, *ciphertext, *auth_tag;
8114 if (fragsz > tdata->plaintext.len)
8115 fragsz = tdata->plaintext.len;
8117 uint16_t plaintext_len = fragsz;
8118 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8120 if (fragsz_oop > tdata->plaintext.len)
8121 frag_size_oop = tdata->plaintext.len;
8124 void *digest_mem = NULL;
8126 uint32_t prepend_len = tdata->aad.len;
8128 if (tdata->plaintext.len % fragsz != 0) {
8129 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8132 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8137 * For out-op-place we need to alloc another mbuf
8140 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8141 rte_pktmbuf_append(ut_params->obuf,
8142 frag_size_oop + prepend_len);
8143 buf_oop = ut_params->obuf;
8146 /* Create AEAD session */
8147 retval = create_aead_session(ts_params->valid_devs[0],
8149 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8150 tdata->key.data, tdata->key.len,
8151 tdata->aad.len, tdata->auth_tag.len,
8156 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8158 /* clear mbuf payload */
8159 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8160 rte_pktmbuf_tailroom(ut_params->ibuf));
8162 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8165 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8167 trn_data += plaintext_len;
8169 buf = ut_params->ibuf;
8172 * Loop until no more fragments
8175 while (trn_data < tdata->plaintext.len) {
8177 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8178 (tdata->plaintext.len - trn_data) : fragsz;
8180 to_trn_tbl[ecx++] = to_trn;
8182 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8185 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8186 rte_pktmbuf_tailroom(buf));
8189 if (oop && !fragsz_oop) {
8190 buf_last_oop = buf_oop->next =
8191 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8192 buf_oop = buf_oop->next;
8193 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8194 0, rte_pktmbuf_tailroom(buf_oop));
8195 rte_pktmbuf_append(buf_oop, to_trn);
8198 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8201 memcpy(plaintext, tdata->plaintext.data + trn_data,
8204 if (trn_data == tdata->plaintext.len) {
8207 digest_mem = rte_pktmbuf_append(buf_oop,
8208 tdata->auth_tag.len);
8210 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8211 tdata->auth_tag.len);
8215 uint64_t digest_phys = 0;
8217 ut_params->ibuf->nb_segs = segs;
8220 if (fragsz_oop && oop) {
8224 if (frag_size_oop == tdata->plaintext.len) {
8225 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8226 tdata->auth_tag.len);
8228 digest_phys = rte_pktmbuf_iova_offset(
8230 tdata->plaintext.len + prepend_len);
8233 trn_data = frag_size_oop;
8234 while (trn_data < tdata->plaintext.len) {
8237 (tdata->plaintext.len - trn_data <
8239 (tdata->plaintext.len - trn_data) :
8242 to_trn_tbl[ecx++] = to_trn;
8244 buf_last_oop = buf_oop->next =
8245 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8246 buf_oop = buf_oop->next;
8247 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8248 0, rte_pktmbuf_tailroom(buf_oop));
8249 rte_pktmbuf_append(buf_oop, to_trn);
8253 if (trn_data == tdata->plaintext.len) {
8254 digest_mem = rte_pktmbuf_append(buf_oop,
8255 tdata->auth_tag.len);
8259 ut_params->obuf->nb_segs = segs;
8263 * Place digest at the end of the last buffer
8266 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8267 if (oop && buf_last_oop)
8268 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8270 if (!digest_mem && !oop) {
8271 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8272 + tdata->auth_tag.len);
8273 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8274 tdata->plaintext.len);
8277 /* Create AEAD operation */
8278 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8279 tdata, digest_mem, digest_phys);
8284 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8286 ut_params->op->sym->m_src = ut_params->ibuf;
8288 ut_params->op->sym->m_dst = ut_params->obuf;
8290 /* Process crypto operation */
8291 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8292 ut_params->op), "failed to process sym crypto op");
8294 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8295 "crypto op processing failed");
8298 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8299 uint8_t *, prepend_len);
8301 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8302 uint8_t *, prepend_len);
8306 fragsz = fragsz_oop;
8308 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8310 tdata->ciphertext.data,
8312 "Ciphertext data not as expected");
8314 buf = ut_params->op->sym->m_src->next;
8316 buf = ut_params->op->sym->m_dst->next;
8318 unsigned int off = fragsz;
8322 ciphertext = rte_pktmbuf_mtod(buf,
8325 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8327 tdata->ciphertext.data + off,
8329 "Ciphertext data not as expected");
8331 off += to_trn_tbl[ecx++];
8335 auth_tag = digest_mem;
8336 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8338 tdata->auth_tag.data,
8339 tdata->auth_tag.len,
8340 "Generated auth tag not as expected");
8346 #define OUT_OF_PLACE 1
8349 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8351 return test_authenticated_encryption_SGL(
8352 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8356 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8358 return test_authenticated_encryption_SGL(
8359 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8363 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8365 return test_authenticated_encryption_SGL(
8366 &gcm_test_case_8, OUT_OF_PLACE, 400,
8367 gcm_test_case_8.plaintext.len);
8371 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8374 return test_authenticated_encryption_SGL(
8375 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8379 test_authentication_verify_fail_when_data_corrupted(
8380 struct crypto_testsuite_params *ts_params,
8381 struct crypto_unittest_params *ut_params,
8382 const struct test_crypto_vector *reference)
8384 return test_authentication_verify_fail_when_data_corruption(
8385 ts_params, ut_params, reference, 1);
8389 test_authentication_verify_fail_when_tag_corrupted(
8390 struct crypto_testsuite_params *ts_params,
8391 struct crypto_unittest_params *ut_params,
8392 const struct test_crypto_vector *reference)
8394 return test_authentication_verify_fail_when_data_corruption(
8395 ts_params, ut_params, reference, 0);
8399 test_authentication_verify_GMAC_fail_when_data_corrupted(
8400 struct crypto_testsuite_params *ts_params,
8401 struct crypto_unittest_params *ut_params,
8402 const struct test_crypto_vector *reference)
8404 return test_authentication_verify_GMAC_fail_when_corruption(
8405 ts_params, ut_params, reference, 1);
8409 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8410 struct crypto_testsuite_params *ts_params,
8411 struct crypto_unittest_params *ut_params,
8412 const struct test_crypto_vector *reference)
8414 return test_authentication_verify_GMAC_fail_when_corruption(
8415 ts_params, ut_params, reference, 0);
8419 test_authenticated_decryption_fail_when_data_corrupted(
8420 struct crypto_testsuite_params *ts_params,
8421 struct crypto_unittest_params *ut_params,
8422 const struct test_crypto_vector *reference)
8424 return test_authenticated_decryption_fail_when_corruption(
8425 ts_params, ut_params, reference, 1);
8429 test_authenticated_decryption_fail_when_tag_corrupted(
8430 struct crypto_testsuite_params *ts_params,
8431 struct crypto_unittest_params *ut_params,
8432 const struct test_crypto_vector *reference)
8434 return test_authenticated_decryption_fail_when_corruption(
8435 ts_params, ut_params, reference, 0);
8439 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8441 return test_authentication_verify_fail_when_data_corrupted(
8442 &testsuite_params, &unittest_params,
8443 &hmac_sha1_test_crypto_vector);
8447 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8449 return test_authentication_verify_fail_when_tag_corrupted(
8450 &testsuite_params, &unittest_params,
8451 &hmac_sha1_test_crypto_vector);
8455 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8457 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8458 &testsuite_params, &unittest_params,
8459 &aes128_gmac_test_vector);
8463 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8465 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8466 &testsuite_params, &unittest_params,
8467 &aes128_gmac_test_vector);
8471 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8473 return test_authenticated_decryption_fail_when_data_corrupted(
8476 &aes128cbc_hmac_sha1_test_vector);
8480 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8482 return test_authenticated_decryption_fail_when_tag_corrupted(
8485 &aes128cbc_hmac_sha1_test_vector);
8488 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8490 /* global AESNI slave IDs for the scheduler test */
8491 uint8_t aesni_ids[2];
8494 test_scheduler_attach_slave_op(void)
8496 struct crypto_testsuite_params *ts_params = &testsuite_params;
8497 uint8_t sched_id = ts_params->valid_devs[0];
8498 uint32_t nb_devs, i, nb_devs_attached = 0;
8502 /* create 2 AESNI_MB if necessary */
8503 nb_devs = rte_cryptodev_device_count_by_driver(
8504 rte_cryptodev_driver_id_get(
8505 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8507 for (i = nb_devs; i < 2; i++) {
8508 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8509 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8511 ret = rte_vdev_init(vdev_name, NULL);
8513 TEST_ASSERT(ret == 0,
8514 "Failed to create instance %u of"
8516 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8520 /* attach 2 AESNI_MB cdevs */
8521 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8523 struct rte_cryptodev_info info;
8525 rte_cryptodev_info_get(i, &info);
8526 if (info.driver_id != rte_cryptodev_driver_id_get(
8527 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8531 * Create the session mempool again, since now there are new devices
8532 * to use the mempool.
8534 if (ts_params->session_mpool) {
8535 rte_mempool_free(ts_params->session_mpool);
8536 ts_params->session_mpool = NULL;
8538 unsigned int session_size =
8539 rte_cryptodev_sym_get_private_session_size(i);
8542 * Create mempool with maximum number of sessions * 2,
8543 * to include the session headers
8545 if (ts_params->session_mpool == NULL) {
8546 ts_params->session_mpool = rte_mempool_create(
8548 info.sym.max_nb_sessions * 2,
8550 0, 0, NULL, NULL, NULL,
8551 NULL, SOCKET_ID_ANY,
8554 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8555 "session mempool allocation failed");
8558 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8561 TEST_ASSERT(ret == 0,
8562 "Failed to attach device %u of pmd : %s", i,
8563 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8565 aesni_ids[nb_devs_attached] = (uint8_t)i;
8574 test_scheduler_detach_slave_op(void)
8576 struct crypto_testsuite_params *ts_params = &testsuite_params;
8577 uint8_t sched_id = ts_params->valid_devs[0];
8581 for (i = 0; i < 2; i++) {
8582 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8584 TEST_ASSERT(ret == 0,
8585 "Failed to detach device %u", aesni_ids[i]);
8592 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8594 struct crypto_testsuite_params *ts_params = &testsuite_params;
8595 uint8_t sched_id = ts_params->valid_devs[0];
8597 return rte_cryptodev_scheduler_mode_set(sched_id,
8602 test_scheduler_mode_roundrobin_op(void)
8604 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8605 0, "Failed to set roundrobin mode");
8611 test_scheduler_mode_multicore_op(void)
8613 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8614 0, "Failed to set multicore mode");
8620 test_scheduler_mode_failover_op(void)
8622 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8623 0, "Failed to set failover mode");
8629 test_scheduler_mode_pkt_size_distr_op(void)
8631 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8632 0, "Failed to set pktsize mode");
8637 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8638 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8639 .setup = testsuite_setup,
8640 .teardown = testsuite_teardown,
8641 .unit_test_cases = {
8643 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8644 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_AES_chain_scheduler_all),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_AES_cipheronly_scheduler_all),
8649 TEST_CASE_ST(ut_setup, ut_teardown,
8650 test_authonly_scheduler_all),
8651 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8654 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8655 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8656 TEST_CASE_ST(ut_setup, ut_teardown,
8657 test_AES_chain_scheduler_all),
8658 TEST_CASE_ST(ut_setup, ut_teardown,
8659 test_AES_cipheronly_scheduler_all),
8660 TEST_CASE_ST(ut_setup, ut_teardown,
8661 test_authonly_scheduler_all),
8662 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8665 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8666 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_AES_chain_scheduler_all),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_AES_cipheronly_scheduler_all),
8671 TEST_CASE_ST(ut_setup, ut_teardown,
8672 test_authonly_scheduler_all),
8673 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8676 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8677 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_AES_chain_scheduler_all),
8680 TEST_CASE_ST(ut_setup, ut_teardown,
8681 test_AES_cipheronly_scheduler_all),
8682 TEST_CASE_ST(ut_setup, ut_teardown,
8683 test_authonly_scheduler_all),
8684 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8686 TEST_CASES_END() /**< NULL terminate unit test array */
8690 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8692 static struct unit_test_suite cryptodev_qat_testsuite = {
8693 .suite_name = "Crypto QAT Unit Test Suite",
8694 .setup = testsuite_setup,
8695 .teardown = testsuite_teardown,
8696 .unit_test_cases = {
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_device_configure_invalid_dev_id),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_device_configure_invalid_queue_pair_ids),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_queue_pair_descriptor_setup),
8703 TEST_CASE_ST(ut_setup, ut_teardown,
8704 test_multi_session),
8706 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8707 TEST_CASE_ST(ut_setup, ut_teardown,
8708 test_AES_cipheronly_qat_all),
8709 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8710 TEST_CASE_ST(ut_setup, ut_teardown,
8711 test_3DES_cipheronly_qat_all),
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_DES_cipheronly_qat_all),
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_AES_docsis_qat_all),
8716 TEST_CASE_ST(ut_setup, ut_teardown,
8717 test_DES_docsis_qat_all),
8718 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8719 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8721 /** AES CCM Authenticated Encryption 128 bits key */
8722 TEST_CASE_ST(ut_setup, ut_teardown,
8723 test_AES_CCM_authenticated_encryption_test_case_128_1),
8724 TEST_CASE_ST(ut_setup, ut_teardown,
8725 test_AES_CCM_authenticated_encryption_test_case_128_2),
8726 TEST_CASE_ST(ut_setup, ut_teardown,
8727 test_AES_CCM_authenticated_encryption_test_case_128_3),
8729 /** AES CCM Authenticated Decryption 128 bits key*/
8730 TEST_CASE_ST(ut_setup, ut_teardown,
8731 test_AES_CCM_authenticated_decryption_test_case_128_1),
8732 TEST_CASE_ST(ut_setup, ut_teardown,
8733 test_AES_CCM_authenticated_decryption_test_case_128_2),
8734 TEST_CASE_ST(ut_setup, ut_teardown,
8735 test_AES_CCM_authenticated_decryption_test_case_128_3),
8737 /** AES GCM Authenticated Encryption */
8738 TEST_CASE_ST(ut_setup, ut_teardown,
8739 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_AES_GCM_authenticated_encryption_test_case_1),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_AES_GCM_authenticated_encryption_test_case_2),
8748 TEST_CASE_ST(ut_setup, ut_teardown,
8749 test_AES_GCM_authenticated_encryption_test_case_3),
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_AES_GCM_authenticated_encryption_test_case_4),
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_AES_GCM_authenticated_encryption_test_case_5),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_AES_GCM_authenticated_encryption_test_case_6),
8756 TEST_CASE_ST(ut_setup, ut_teardown,
8757 test_AES_GCM_authenticated_encryption_test_case_7),
8759 /** AES GCM Authenticated Decryption */
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_AES_GCM_authenticated_decryption_test_case_1),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_GCM_authenticated_decryption_test_case_2),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_AES_GCM_authenticated_decryption_test_case_3),
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_AES_GCM_authenticated_decryption_test_case_4),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_AES_GCM_authenticated_decryption_test_case_5),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_GCM_authenticated_decryption_test_case_6),
8772 TEST_CASE_ST(ut_setup, ut_teardown,
8773 test_AES_GCM_authenticated_decryption_test_case_7),
8775 /** AES GCM Authenticated Encryption 192 bits key */
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_AES_GCM_auth_encryption_test_case_192_1),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_auth_encryption_test_case_192_2),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_AES_GCM_auth_encryption_test_case_192_3),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_auth_encryption_test_case_192_4),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_auth_encryption_test_case_192_5),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_auth_encryption_test_case_192_6),
8788 TEST_CASE_ST(ut_setup, ut_teardown,
8789 test_AES_GCM_auth_encryption_test_case_192_7),
8791 /** AES GCM Authenticated Decryption 192 bits key */
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_auth_decryption_test_case_192_1),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_auth_decryption_test_case_192_2),
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_AES_GCM_auth_decryption_test_case_192_3),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_auth_decryption_test_case_192_4),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_auth_decryption_test_case_192_5),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_auth_decryption_test_case_192_6),
8804 TEST_CASE_ST(ut_setup, ut_teardown,
8805 test_AES_GCM_auth_decryption_test_case_192_7),
8807 /** AES GCM Authenticated Encryption 256 bits key */
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_GCM_auth_encryption_test_case_256_1),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_GCM_auth_encryption_test_case_256_2),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_AES_GCM_auth_encryption_test_case_256_3),
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_AES_GCM_auth_encryption_test_case_256_4),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_AES_GCM_auth_encryption_test_case_256_5),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_AES_GCM_auth_encryption_test_case_256_6),
8820 TEST_CASE_ST(ut_setup, ut_teardown,
8821 test_AES_GCM_auth_encryption_test_case_256_7),
8823 /** AES GMAC Authentication */
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_AES_GMAC_authentication_test_case_1),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GMAC_authentication_verify_test_case_1),
8828 TEST_CASE_ST(ut_setup, ut_teardown,
8829 test_AES_GMAC_authentication_test_case_2),
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_AES_GMAC_authentication_verify_test_case_2),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_AES_GMAC_authentication_test_case_3),
8834 TEST_CASE_ST(ut_setup, ut_teardown,
8835 test_AES_GMAC_authentication_verify_test_case_3),
8837 /** SNOW 3G encrypt only (UEA2) */
8838 TEST_CASE_ST(ut_setup, ut_teardown,
8839 test_snow3g_encryption_test_case_1),
8840 TEST_CASE_ST(ut_setup, ut_teardown,
8841 test_snow3g_encryption_test_case_2),
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_snow3g_encryption_test_case_3),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_snow3g_encryption_test_case_4),
8846 TEST_CASE_ST(ut_setup, ut_teardown,
8847 test_snow3g_encryption_test_case_5),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_snow3g_encryption_test_case_1_oop),
8851 TEST_CASE_ST(ut_setup, ut_teardown,
8852 test_snow3g_decryption_test_case_1_oop),
8854 /** SNOW 3G decrypt only (UEA2) */
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_snow3g_decryption_test_case_1),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_snow3g_decryption_test_case_2),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_snow3g_decryption_test_case_3),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_snow3g_decryption_test_case_4),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_snow3g_decryption_test_case_5),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_snow3g_hash_generate_test_case_1),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_snow3g_hash_generate_test_case_2),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_snow3g_hash_generate_test_case_3),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_snow3g_hash_verify_test_case_1),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_snow3g_hash_verify_test_case_2),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_snow3g_hash_verify_test_case_3),
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_snow3g_cipher_auth_test_case_1),
8879 TEST_CASE_ST(ut_setup, ut_teardown,
8880 test_snow3g_auth_cipher_test_case_1),
8882 /** ZUC encrypt only (EEA3) */
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_zuc_encryption_test_case_1),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_zuc_encryption_test_case_2),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 test_zuc_encryption_test_case_3),
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_zuc_encryption_test_case_4),
8891 TEST_CASE_ST(ut_setup, ut_teardown,
8892 test_zuc_encryption_test_case_5),
8894 /** ZUC authenticate (EIA3) */
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_zuc_hash_generate_test_case_6),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_zuc_hash_generate_test_case_7),
8899 TEST_CASE_ST(ut_setup, ut_teardown,
8900 test_zuc_hash_generate_test_case_8),
8902 /** ZUC alg-chain (EEA3/EIA3) */
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_zuc_cipher_auth_test_case_1),
8905 TEST_CASE_ST(ut_setup, ut_teardown,
8906 test_zuc_cipher_auth_test_case_2),
8908 /** HMAC_MD5 Authentication */
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_MD5_HMAC_generate_case_1),
8911 TEST_CASE_ST(ut_setup, ut_teardown,
8912 test_MD5_HMAC_verify_case_1),
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_MD5_HMAC_generate_case_2),
8915 TEST_CASE_ST(ut_setup, ut_teardown,
8916 test_MD5_HMAC_verify_case_2),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_null_auth_only_operation),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_null_cipher_only_operation),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_null_cipher_auth_operation),
8925 TEST_CASE_ST(ut_setup, ut_teardown,
8926 test_null_auth_cipher_operation),
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_kasumi_hash_generate_test_case_1),
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_kasumi_hash_generate_test_case_2),
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_kasumi_hash_generate_test_case_3),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_kasumi_hash_generate_test_case_4),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_kasumi_hash_generate_test_case_5),
8939 TEST_CASE_ST(ut_setup, ut_teardown,
8940 test_kasumi_hash_generate_test_case_6),
8942 TEST_CASE_ST(ut_setup, ut_teardown,
8943 test_kasumi_hash_verify_test_case_1),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_kasumi_hash_verify_test_case_2),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_kasumi_hash_verify_test_case_3),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_kasumi_hash_verify_test_case_4),
8950 TEST_CASE_ST(ut_setup, ut_teardown,
8951 test_kasumi_hash_verify_test_case_5),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 test_kasumi_encryption_test_case_1),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 test_kasumi_encryption_test_case_3),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_kasumi_auth_cipher_test_case_1),
8959 TEST_CASE_ST(ut_setup, ut_teardown,
8960 test_kasumi_cipher_auth_test_case_1),
8962 /** Negative tests */
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 authentication_verify_AES128_GMAC_fail_data_corrupt),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8973 TEST_CASE_ST(ut_setup, ut_teardown,
8974 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8976 TEST_CASES_END() /**< NULL terminate unit test array */
8980 static struct unit_test_suite cryptodev_virtio_testsuite = {
8981 .suite_name = "Crypto VIRTIO Unit Test Suite",
8982 .setup = testsuite_setup,
8983 .teardown = testsuite_teardown,
8984 .unit_test_cases = {
8985 TEST_CASE_ST(ut_setup, ut_teardown,
8986 test_AES_cipheronly_virtio_all),
8988 TEST_CASES_END() /**< NULL terminate unit test array */
8992 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8993 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8994 .setup = testsuite_setup,
8995 .teardown = testsuite_teardown,
8996 .unit_test_cases = {
8997 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8998 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8999 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
9000 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_DES_cipheronly_mb_all),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_DES_docsis_mb_all),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_CCM_authenticated_encryption_test_case_128_1),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_CCM_authenticated_decryption_test_case_128_1),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_AES_CCM_authenticated_encryption_test_case_128_2),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_CCM_authenticated_decryption_test_case_128_2),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 test_AES_CCM_authenticated_encryption_test_case_128_3),
9015 TEST_CASE_ST(ut_setup, ut_teardown,
9016 test_AES_CCM_authenticated_decryption_test_case_128_3),
9018 TEST_CASES_END() /**< NULL terminate unit test array */
9022 static struct unit_test_suite cryptodev_openssl_testsuite = {
9023 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9024 .setup = testsuite_setup,
9025 .teardown = testsuite_teardown,
9026 .unit_test_cases = {
9027 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_multi_session_random_usage),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_chain_openssl_all),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_AES_cipheronly_openssl_all),
9034 TEST_CASE_ST(ut_setup, ut_teardown,
9035 test_3DES_chain_openssl_all),
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_3DES_cipheronly_openssl_all),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_DES_cipheronly_openssl_all),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_DES_docsis_openssl_all),
9042 TEST_CASE_ST(ut_setup, ut_teardown,
9043 test_authonly_openssl_all),
9045 /** AES GCM Authenticated Encryption */
9046 TEST_CASE_ST(ut_setup, ut_teardown,
9047 test_AES_GCM_authenticated_encryption_test_case_1),
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_authenticated_encryption_test_case_2),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GCM_authenticated_encryption_test_case_3),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_authenticated_encryption_test_case_4),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_authenticated_encryption_test_case_5),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GCM_authenticated_encryption_test_case_6),
9058 TEST_CASE_ST(ut_setup, ut_teardown,
9059 test_AES_GCM_authenticated_encryption_test_case_7),
9061 /** AES GCM Authenticated Decryption */
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_GCM_authenticated_decryption_test_case_1),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GCM_authenticated_decryption_test_case_2),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GCM_authenticated_decryption_test_case_3),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GCM_authenticated_decryption_test_case_4),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GCM_authenticated_decryption_test_case_5),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GCM_authenticated_decryption_test_case_6),
9074 TEST_CASE_ST(ut_setup, ut_teardown,
9075 test_AES_GCM_authenticated_decryption_test_case_7),
9078 /** AES GCM Authenticated Encryption 192 bits key */
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_GCM_auth_encryption_test_case_192_1),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_AES_GCM_auth_encryption_test_case_192_2),
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_AES_GCM_auth_encryption_test_case_192_3),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_GCM_auth_encryption_test_case_192_4),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_AES_GCM_auth_encryption_test_case_192_5),
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 test_AES_GCM_auth_encryption_test_case_192_6),
9091 TEST_CASE_ST(ut_setup, ut_teardown,
9092 test_AES_GCM_auth_encryption_test_case_192_7),
9094 /** AES GCM Authenticated Decryption 192 bits key */
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_AES_GCM_auth_decryption_test_case_192_1),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_AES_GCM_auth_decryption_test_case_192_2),
9099 TEST_CASE_ST(ut_setup, ut_teardown,
9100 test_AES_GCM_auth_decryption_test_case_192_3),
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_AES_GCM_auth_decryption_test_case_192_4),
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 test_AES_GCM_auth_decryption_test_case_192_5),
9105 TEST_CASE_ST(ut_setup, ut_teardown,
9106 test_AES_GCM_auth_decryption_test_case_192_6),
9107 TEST_CASE_ST(ut_setup, ut_teardown,
9108 test_AES_GCM_auth_decryption_test_case_192_7),
9110 /** AES GCM Authenticated Encryption 256 bits key */
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_AES_GCM_auth_encryption_test_case_256_1),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 test_AES_GCM_auth_encryption_test_case_256_2),
9115 TEST_CASE_ST(ut_setup, ut_teardown,
9116 test_AES_GCM_auth_encryption_test_case_256_3),
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_AES_GCM_auth_encryption_test_case_256_4),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_AES_GCM_auth_encryption_test_case_256_5),
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_AES_GCM_auth_encryption_test_case_256_6),
9123 TEST_CASE_ST(ut_setup, ut_teardown,
9124 test_AES_GCM_auth_encryption_test_case_256_7),
9126 /** AES GCM Authenticated Decryption 256 bits key */
9127 TEST_CASE_ST(ut_setup, ut_teardown,
9128 test_AES_GCM_auth_decryption_test_case_256_1),
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_AES_GCM_auth_decryption_test_case_256_2),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_AES_GCM_auth_decryption_test_case_256_3),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_AES_GCM_auth_decryption_test_case_256_4),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_AES_GCM_auth_decryption_test_case_256_5),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_AES_GCM_auth_decryption_test_case_256_6),
9139 TEST_CASE_ST(ut_setup, ut_teardown,
9140 test_AES_GCM_auth_decryption_test_case_256_7),
9142 /** AES GMAC Authentication */
9143 TEST_CASE_ST(ut_setup, ut_teardown,
9144 test_AES_GMAC_authentication_test_case_1),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_AES_GMAC_authentication_verify_test_case_1),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_AES_GMAC_authentication_test_case_2),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_AES_GMAC_authentication_verify_test_case_2),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_AES_GMAC_authentication_test_case_3),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_AES_GMAC_authentication_verify_test_case_3),
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_AES_GMAC_authentication_test_case_4),
9157 TEST_CASE_ST(ut_setup, ut_teardown,
9158 test_AES_GMAC_authentication_verify_test_case_4),
9160 /** AES CCM Authenticated Encryption 128 bits key */
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_AES_CCM_authenticated_encryption_test_case_128_1),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_AES_CCM_authenticated_encryption_test_case_128_2),
9165 TEST_CASE_ST(ut_setup, ut_teardown,
9166 test_AES_CCM_authenticated_encryption_test_case_128_3),
9168 /** AES CCM Authenticated Decryption 128 bits key*/
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_AES_CCM_authenticated_decryption_test_case_128_1),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_AES_CCM_authenticated_decryption_test_case_128_2),
9173 TEST_CASE_ST(ut_setup, ut_teardown,
9174 test_AES_CCM_authenticated_decryption_test_case_128_3),
9176 /** AES CCM Authenticated Encryption 192 bits key */
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_AES_CCM_authenticated_encryption_test_case_192_1),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_AES_CCM_authenticated_encryption_test_case_192_2),
9181 TEST_CASE_ST(ut_setup, ut_teardown,
9182 test_AES_CCM_authenticated_encryption_test_case_192_3),
9184 /** AES CCM Authenticated Decryption 192 bits key*/
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_AES_CCM_authenticated_decryption_test_case_192_1),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_AES_CCM_authenticated_decryption_test_case_192_2),
9189 TEST_CASE_ST(ut_setup, ut_teardown,
9190 test_AES_CCM_authenticated_decryption_test_case_192_3),
9192 /** AES CCM Authenticated Encryption 256 bits key */
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_AES_CCM_authenticated_encryption_test_case_256_1),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_AES_CCM_authenticated_encryption_test_case_256_2),
9197 TEST_CASE_ST(ut_setup, ut_teardown,
9198 test_AES_CCM_authenticated_encryption_test_case_256_3),
9200 /** AES CCM Authenticated Decryption 256 bits key*/
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_AES_CCM_authenticated_decryption_test_case_256_1),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_AES_CCM_authenticated_decryption_test_case_256_2),
9205 TEST_CASE_ST(ut_setup, ut_teardown,
9206 test_AES_CCM_authenticated_decryption_test_case_256_3),
9208 /** Scatter-Gather */
9209 TEST_CASE_ST(ut_setup, ut_teardown,
9210 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9212 /** Negative tests */
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 authentication_verify_AES128_GMAC_fail_data_corrupt),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9223 TEST_CASE_ST(ut_setup, ut_teardown,
9224 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9226 TEST_CASES_END() /**< NULL terminate unit test array */
9230 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9231 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9232 .setup = testsuite_setup,
9233 .teardown = testsuite_teardown,
9234 .unit_test_cases = {
9235 /** AES GCM Authenticated Encryption */
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_AES_GCM_authenticated_encryption_test_case_1),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_AES_GCM_authenticated_encryption_test_case_2),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 test_AES_GCM_authenticated_encryption_test_case_3),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_AES_GCM_authenticated_encryption_test_case_4),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_AES_GCM_authenticated_encryption_test_case_5),
9246 TEST_CASE_ST(ut_setup, ut_teardown,
9247 test_AES_GCM_authenticated_encryption_test_case_6),
9248 TEST_CASE_ST(ut_setup, ut_teardown,
9249 test_AES_GCM_authenticated_encryption_test_case_7),
9251 /** AES GCM Authenticated Decryption */
9252 TEST_CASE_ST(ut_setup, ut_teardown,
9253 test_AES_GCM_authenticated_decryption_test_case_1),
9254 TEST_CASE_ST(ut_setup, ut_teardown,
9255 test_AES_GCM_authenticated_decryption_test_case_2),
9256 TEST_CASE_ST(ut_setup, ut_teardown,
9257 test_AES_GCM_authenticated_decryption_test_case_3),
9258 TEST_CASE_ST(ut_setup, ut_teardown,
9259 test_AES_GCM_authenticated_decryption_test_case_4),
9260 TEST_CASE_ST(ut_setup, ut_teardown,
9261 test_AES_GCM_authenticated_decryption_test_case_5),
9262 TEST_CASE_ST(ut_setup, ut_teardown,
9263 test_AES_GCM_authenticated_decryption_test_case_6),
9264 TEST_CASE_ST(ut_setup, ut_teardown,
9265 test_AES_GCM_authenticated_decryption_test_case_7),
9267 /** AES GCM Authenticated Encryption 192 bits key */
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_AES_GCM_auth_encryption_test_case_192_1),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_AES_GCM_auth_encryption_test_case_192_2),
9272 TEST_CASE_ST(ut_setup, ut_teardown,
9273 test_AES_GCM_auth_encryption_test_case_192_3),
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 test_AES_GCM_auth_encryption_test_case_192_4),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 test_AES_GCM_auth_encryption_test_case_192_5),
9278 TEST_CASE_ST(ut_setup, ut_teardown,
9279 test_AES_GCM_auth_encryption_test_case_192_6),
9280 TEST_CASE_ST(ut_setup, ut_teardown,
9281 test_AES_GCM_auth_encryption_test_case_192_7),
9283 /** AES GCM Authenticated Decryption 192 bits key */
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_AES_GCM_auth_decryption_test_case_192_1),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_auth_decryption_test_case_192_2),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_AES_GCM_auth_decryption_test_case_192_3),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_AES_GCM_auth_decryption_test_case_192_4),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_auth_decryption_test_case_192_5),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_AES_GCM_auth_decryption_test_case_192_6),
9296 TEST_CASE_ST(ut_setup, ut_teardown,
9297 test_AES_GCM_auth_decryption_test_case_192_7),
9299 /** AES GCM Authenticated Encryption 256 bits key */
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_AES_GCM_auth_encryption_test_case_256_1),
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_GCM_auth_encryption_test_case_256_2),
9304 TEST_CASE_ST(ut_setup, ut_teardown,
9305 test_AES_GCM_auth_encryption_test_case_256_3),
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_AES_GCM_auth_encryption_test_case_256_4),
9308 TEST_CASE_ST(ut_setup, ut_teardown,
9309 test_AES_GCM_auth_encryption_test_case_256_5),
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_AES_GCM_auth_encryption_test_case_256_6),
9312 TEST_CASE_ST(ut_setup, ut_teardown,
9313 test_AES_GCM_auth_encryption_test_case_256_7),
9315 /** AES GCM Authenticated Decryption 256 bits key */
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_AES_GCM_auth_decryption_test_case_256_1),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_auth_decryption_test_case_256_2),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_AES_GCM_auth_decryption_test_case_256_3),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_auth_decryption_test_case_256_4),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_AES_GCM_auth_decryption_test_case_256_5),
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_AES_GCM_auth_decryption_test_case_256_6),
9328 TEST_CASE_ST(ut_setup, ut_teardown,
9329 test_AES_GCM_auth_decryption_test_case_256_7),
9331 /** AES GCM Authenticated Encryption big aad size */
9332 TEST_CASE_ST(ut_setup, ut_teardown,
9333 test_AES_GCM_auth_encryption_test_case_aad_1),
9334 TEST_CASE_ST(ut_setup, ut_teardown,
9335 test_AES_GCM_auth_encryption_test_case_aad_2),
9337 /** AES GCM Authenticated Decryption big aad size */
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_AES_GCM_auth_decryption_test_case_aad_1),
9340 TEST_CASE_ST(ut_setup, ut_teardown,
9341 test_AES_GCM_auth_decryption_test_case_aad_2),
9343 /** AES GMAC Authentication */
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_AES_GMAC_authentication_test_case_1),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GMAC_authentication_verify_test_case_1),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GMAC_authentication_test_case_3),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GMAC_authentication_verify_test_case_3),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GMAC_authentication_test_case_4),
9354 TEST_CASE_ST(ut_setup, ut_teardown,
9355 test_AES_GMAC_authentication_verify_test_case_4),
9357 /** Negative tests */
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 authentication_verify_AES128_GMAC_fail_data_corrupt),
9360 TEST_CASE_ST(ut_setup, ut_teardown,
9361 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9363 /** Out of place tests */
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9366 TEST_CASE_ST(ut_setup, ut_teardown,
9367 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9369 /** Session-less tests */
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9372 TEST_CASE_ST(ut_setup, ut_teardown,
9373 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9375 /** Scatter-Gather */
9376 TEST_CASE_ST(ut_setup, ut_teardown,
9377 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9379 TEST_CASES_END() /**< NULL terminate unit test array */
9383 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9384 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9385 .setup = testsuite_setup,
9386 .teardown = testsuite_teardown,
9387 .unit_test_cases = {
9388 /** KASUMI encrypt only (UEA1) */
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_kasumi_encryption_test_case_1),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_kasumi_encryption_test_case_1_sgl),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_kasumi_encryption_test_case_2),
9395 TEST_CASE_ST(ut_setup, ut_teardown,
9396 test_kasumi_encryption_test_case_3),
9397 TEST_CASE_ST(ut_setup, ut_teardown,
9398 test_kasumi_encryption_test_case_4),
9399 TEST_CASE_ST(ut_setup, ut_teardown,
9400 test_kasumi_encryption_test_case_5),
9401 /** KASUMI decrypt only (UEA1) */
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_kasumi_decryption_test_case_1),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_kasumi_decryption_test_case_2),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_kasumi_decryption_test_case_3),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_kasumi_decryption_test_case_4),
9410 TEST_CASE_ST(ut_setup, ut_teardown,
9411 test_kasumi_decryption_test_case_5),
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 test_kasumi_encryption_test_case_1_oop),
9415 TEST_CASE_ST(ut_setup, ut_teardown,
9416 test_kasumi_encryption_test_case_1_oop_sgl),
9419 TEST_CASE_ST(ut_setup, ut_teardown,
9420 test_kasumi_decryption_test_case_1_oop),
9422 /** KASUMI hash only (UIA1) */
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_kasumi_hash_generate_test_case_1),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_kasumi_hash_generate_test_case_2),
9427 TEST_CASE_ST(ut_setup, ut_teardown,
9428 test_kasumi_hash_generate_test_case_3),
9429 TEST_CASE_ST(ut_setup, ut_teardown,
9430 test_kasumi_hash_generate_test_case_4),
9431 TEST_CASE_ST(ut_setup, ut_teardown,
9432 test_kasumi_hash_generate_test_case_5),
9433 TEST_CASE_ST(ut_setup, ut_teardown,
9434 test_kasumi_hash_generate_test_case_6),
9435 TEST_CASE_ST(ut_setup, ut_teardown,
9436 test_kasumi_hash_verify_test_case_1),
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_kasumi_hash_verify_test_case_2),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_kasumi_hash_verify_test_case_3),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_kasumi_hash_verify_test_case_4),
9443 TEST_CASE_ST(ut_setup, ut_teardown,
9444 test_kasumi_hash_verify_test_case_5),
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_kasumi_auth_cipher_test_case_1),
9447 TEST_CASE_ST(ut_setup, ut_teardown,
9448 test_kasumi_cipher_auth_test_case_1),
9449 TEST_CASES_END() /**< NULL terminate unit test array */
9452 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9453 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9454 .setup = testsuite_setup,
9455 .teardown = testsuite_teardown,
9456 .unit_test_cases = {
9457 /** SNOW 3G encrypt only (UEA2) */
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_snow3g_encryption_test_case_1),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_snow3g_encryption_test_case_2),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_snow3g_encryption_test_case_3),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_snow3g_encryption_test_case_4),
9466 TEST_CASE_ST(ut_setup, ut_teardown,
9467 test_snow3g_encryption_test_case_5),
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_snow3g_encryption_test_case_1_oop),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_snow3g_encryption_test_case_1_oop_sgl),
9473 TEST_CASE_ST(ut_setup, ut_teardown,
9474 test_snow3g_decryption_test_case_1_oop),
9476 TEST_CASE_ST(ut_setup, ut_teardown,
9477 test_snow3g_encryption_test_case_1_offset_oop),
9479 /** SNOW 3G decrypt only (UEA2) */
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_snow3g_decryption_test_case_1),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_snow3g_decryption_test_case_2),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_snow3g_decryption_test_case_3),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_snow3g_decryption_test_case_4),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_snow3g_decryption_test_case_5),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_snow3g_hash_generate_test_case_1),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_snow3g_hash_generate_test_case_2),
9494 TEST_CASE_ST(ut_setup, ut_teardown,
9495 test_snow3g_hash_generate_test_case_3),
9496 /* Tests with buffers which length is not byte-aligned */
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_snow3g_hash_generate_test_case_4),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_snow3g_hash_generate_test_case_5),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_snow3g_hash_generate_test_case_6),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_snow3g_hash_verify_test_case_1),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_snow3g_hash_verify_test_case_2),
9507 TEST_CASE_ST(ut_setup, ut_teardown,
9508 test_snow3g_hash_verify_test_case_3),
9509 /* Tests with buffers which length is not byte-aligned */
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_snow3g_hash_verify_test_case_4),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_snow3g_hash_verify_test_case_5),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_snow3g_hash_verify_test_case_6),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_snow3g_cipher_auth_test_case_1),
9518 TEST_CASE_ST(ut_setup, ut_teardown,
9519 test_snow3g_auth_cipher_test_case_1),
9521 TEST_CASES_END() /**< NULL terminate unit test array */
9525 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9526 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9527 .setup = testsuite_setup,
9528 .teardown = testsuite_teardown,
9529 .unit_test_cases = {
9530 /** ZUC encrypt only (EEA3) */
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_zuc_encryption_test_case_1),
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_zuc_encryption_test_case_2),
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_zuc_encryption_test_case_3),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_zuc_encryption_test_case_4),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_zuc_encryption_test_case_5),
9541 TEST_CASE_ST(ut_setup, ut_teardown,
9542 test_zuc_hash_generate_test_case_1),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_zuc_hash_generate_test_case_2),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_zuc_hash_generate_test_case_3),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_zuc_hash_generate_test_case_4),
9549 TEST_CASE_ST(ut_setup, ut_teardown,
9550 test_zuc_hash_generate_test_case_5),
9551 TEST_CASE_ST(ut_setup, ut_teardown,
9552 test_zuc_encryption_test_case_6_sgl),
9553 TEST_CASES_END() /**< NULL terminate unit test array */
9557 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9558 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9559 .setup = testsuite_setup,
9560 .teardown = testsuite_teardown,
9561 .unit_test_cases = {
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_device_configure_invalid_dev_id),
9564 TEST_CASE_ST(ut_setup, ut_teardown,
9565 test_multi_session),
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 test_AES_chain_dpaa_sec_all),
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 test_3DES_chain_dpaa_sec_all),
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 test_AES_cipheronly_dpaa_sec_all),
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 test_3DES_cipheronly_dpaa_sec_all),
9575 TEST_CASE_ST(ut_setup, ut_teardown,
9576 test_authonly_dpaa_sec_all),
9578 /** AES GCM Authenticated Encryption */
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_AES_GCM_authenticated_encryption_test_case_1),
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 test_AES_GCM_authenticated_encryption_test_case_2),
9583 TEST_CASE_ST(ut_setup, ut_teardown,
9584 test_AES_GCM_authenticated_encryption_test_case_3),
9585 TEST_CASE_ST(ut_setup, ut_teardown,
9586 test_AES_GCM_authenticated_encryption_test_case_4),
9587 TEST_CASE_ST(ut_setup, ut_teardown,
9588 test_AES_GCM_authenticated_encryption_test_case_5),
9589 TEST_CASE_ST(ut_setup, ut_teardown,
9590 test_AES_GCM_authenticated_encryption_test_case_6),
9591 TEST_CASE_ST(ut_setup, ut_teardown,
9592 test_AES_GCM_authenticated_encryption_test_case_7),
9594 /** AES GCM Authenticated Decryption */
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_AES_GCM_authenticated_decryption_test_case_1),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_AES_GCM_authenticated_decryption_test_case_2),
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_AES_GCM_authenticated_decryption_test_case_3),
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_AES_GCM_authenticated_decryption_test_case_4),
9603 TEST_CASE_ST(ut_setup, ut_teardown,
9604 test_AES_GCM_authenticated_decryption_test_case_5),
9605 TEST_CASE_ST(ut_setup, ut_teardown,
9606 test_AES_GCM_authenticated_decryption_test_case_6),
9607 TEST_CASE_ST(ut_setup, ut_teardown,
9608 test_AES_GCM_authenticated_decryption_test_case_7),
9610 /** AES GCM Authenticated Encryption 256 bits key */
9611 TEST_CASE_ST(ut_setup, ut_teardown,
9612 test_AES_GCM_auth_encryption_test_case_256_1),
9613 TEST_CASE_ST(ut_setup, ut_teardown,
9614 test_AES_GCM_auth_encryption_test_case_256_2),
9615 TEST_CASE_ST(ut_setup, ut_teardown,
9616 test_AES_GCM_auth_encryption_test_case_256_3),
9617 TEST_CASE_ST(ut_setup, ut_teardown,
9618 test_AES_GCM_auth_encryption_test_case_256_4),
9619 TEST_CASE_ST(ut_setup, ut_teardown,
9620 test_AES_GCM_auth_encryption_test_case_256_5),
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 test_AES_GCM_auth_encryption_test_case_256_6),
9623 TEST_CASE_ST(ut_setup, ut_teardown,
9624 test_AES_GCM_auth_encryption_test_case_256_7),
9626 /** AES GCM Authenticated Decryption 256 bits key */
9627 TEST_CASE_ST(ut_setup, ut_teardown,
9628 test_AES_GCM_auth_decryption_test_case_256_1),
9629 TEST_CASE_ST(ut_setup, ut_teardown,
9630 test_AES_GCM_auth_decryption_test_case_256_2),
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 test_AES_GCM_auth_decryption_test_case_256_3),
9633 TEST_CASE_ST(ut_setup, ut_teardown,
9634 test_AES_GCM_auth_decryption_test_case_256_4),
9635 TEST_CASE_ST(ut_setup, ut_teardown,
9636 test_AES_GCM_auth_decryption_test_case_256_5),
9637 TEST_CASE_ST(ut_setup, ut_teardown,
9638 test_AES_GCM_auth_decryption_test_case_256_6),
9639 TEST_CASE_ST(ut_setup, ut_teardown,
9640 test_AES_GCM_auth_decryption_test_case_256_7),
9642 /** Out of place tests */
9643 TEST_CASE_ST(ut_setup, ut_teardown,
9644 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9645 TEST_CASE_ST(ut_setup, ut_teardown,
9646 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9648 /** Scatter-Gather */
9649 TEST_CASE_ST(ut_setup, ut_teardown,
9650 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9651 TEST_CASE_ST(ut_setup, ut_teardown,
9652 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9655 TEST_CASE_ST(ut_setup, ut_teardown,
9656 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9658 TEST_CASES_END() /**< NULL terminate unit test array */
9662 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9663 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9664 .setup = testsuite_setup,
9665 .teardown = testsuite_teardown,
9666 .unit_test_cases = {
9667 TEST_CASE_ST(ut_setup, ut_teardown,
9668 test_device_configure_invalid_dev_id),
9669 TEST_CASE_ST(ut_setup, ut_teardown,
9670 test_multi_session),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_AES_chain_dpaa2_sec_all),
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_3DES_chain_dpaa2_sec_all),
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_AES_cipheronly_dpaa2_sec_all),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_3DES_cipheronly_dpaa2_sec_all),
9680 TEST_CASE_ST(ut_setup, ut_teardown,
9681 test_authonly_dpaa2_sec_all),
9683 /** AES GCM Authenticated Encryption */
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GCM_authenticated_encryption_test_case_1),
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 test_AES_GCM_authenticated_encryption_test_case_2),
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 test_AES_GCM_authenticated_encryption_test_case_3),
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 test_AES_GCM_authenticated_encryption_test_case_4),
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 test_AES_GCM_authenticated_encryption_test_case_5),
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 test_AES_GCM_authenticated_encryption_test_case_6),
9696 TEST_CASE_ST(ut_setup, ut_teardown,
9697 test_AES_GCM_authenticated_encryption_test_case_7),
9699 /** AES GCM Authenticated Decryption */
9700 TEST_CASE_ST(ut_setup, ut_teardown,
9701 test_AES_GCM_authenticated_decryption_test_case_1),
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_AES_GCM_authenticated_decryption_test_case_2),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_AES_GCM_authenticated_decryption_test_case_3),
9706 TEST_CASE_ST(ut_setup, ut_teardown,
9707 test_AES_GCM_authenticated_decryption_test_case_4),
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 test_AES_GCM_authenticated_decryption_test_case_5),
9710 TEST_CASE_ST(ut_setup, ut_teardown,
9711 test_AES_GCM_authenticated_decryption_test_case_6),
9712 TEST_CASE_ST(ut_setup, ut_teardown,
9713 test_AES_GCM_authenticated_decryption_test_case_7),
9715 /** AES GCM Authenticated Encryption 192 bits key */
9716 TEST_CASE_ST(ut_setup, ut_teardown,
9717 test_AES_GCM_auth_encryption_test_case_192_1),
9718 TEST_CASE_ST(ut_setup, ut_teardown,
9719 test_AES_GCM_auth_encryption_test_case_192_2),
9720 TEST_CASE_ST(ut_setup, ut_teardown,
9721 test_AES_GCM_auth_encryption_test_case_192_3),
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_AES_GCM_auth_encryption_test_case_192_4),
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_AES_GCM_auth_encryption_test_case_192_5),
9726 TEST_CASE_ST(ut_setup, ut_teardown,
9727 test_AES_GCM_auth_encryption_test_case_192_6),
9728 TEST_CASE_ST(ut_setup, ut_teardown,
9729 test_AES_GCM_auth_encryption_test_case_192_7),
9731 /** AES GCM Authenticated Decryption 192 bits key */
9732 TEST_CASE_ST(ut_setup, ut_teardown,
9733 test_AES_GCM_auth_decryption_test_case_192_1),
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_AES_GCM_auth_decryption_test_case_192_2),
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_AES_GCM_auth_decryption_test_case_192_3),
9738 TEST_CASE_ST(ut_setup, ut_teardown,
9739 test_AES_GCM_auth_decryption_test_case_192_4),
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_AES_GCM_auth_decryption_test_case_192_5),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_AES_GCM_auth_decryption_test_case_192_6),
9744 TEST_CASE_ST(ut_setup, ut_teardown,
9745 test_AES_GCM_auth_decryption_test_case_192_7),
9747 /** AES GCM Authenticated Encryption 256 bits key */
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 test_AES_GCM_auth_encryption_test_case_256_1),
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 test_AES_GCM_auth_encryption_test_case_256_2),
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 test_AES_GCM_auth_encryption_test_case_256_3),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 test_AES_GCM_auth_encryption_test_case_256_4),
9756 TEST_CASE_ST(ut_setup, ut_teardown,
9757 test_AES_GCM_auth_encryption_test_case_256_5),
9758 TEST_CASE_ST(ut_setup, ut_teardown,
9759 test_AES_GCM_auth_encryption_test_case_256_6),
9760 TEST_CASE_ST(ut_setup, ut_teardown,
9761 test_AES_GCM_auth_encryption_test_case_256_7),
9763 /** AES GCM Authenticated Decryption 256 bits key */
9764 TEST_CASE_ST(ut_setup, ut_teardown,
9765 test_AES_GCM_auth_decryption_test_case_256_1),
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_AES_GCM_auth_decryption_test_case_256_2),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 test_AES_GCM_auth_decryption_test_case_256_3),
9770 TEST_CASE_ST(ut_setup, ut_teardown,
9771 test_AES_GCM_auth_decryption_test_case_256_4),
9772 TEST_CASE_ST(ut_setup, ut_teardown,
9773 test_AES_GCM_auth_decryption_test_case_256_5),
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 test_AES_GCM_auth_decryption_test_case_256_6),
9776 TEST_CASE_ST(ut_setup, ut_teardown,
9777 test_AES_GCM_auth_decryption_test_case_256_7),
9779 /** Out of place tests */
9780 TEST_CASE_ST(ut_setup, ut_teardown,
9781 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9782 TEST_CASE_ST(ut_setup, ut_teardown,
9783 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9785 /** Scatter-Gather */
9786 TEST_CASE_ST(ut_setup, ut_teardown,
9787 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9788 TEST_CASE_ST(ut_setup, ut_teardown,
9789 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9790 TEST_CASE_ST(ut_setup, ut_teardown,
9791 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9792 TEST_CASE_ST(ut_setup, ut_teardown,
9793 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9795 TEST_CASES_END() /**< NULL terminate unit test array */
9799 static struct unit_test_suite cryptodev_null_testsuite = {
9800 .suite_name = "Crypto Device NULL Unit Test Suite",
9801 .setup = testsuite_setup,
9802 .teardown = testsuite_teardown,
9803 .unit_test_cases = {
9804 TEST_CASE_ST(ut_setup, ut_teardown,
9805 test_null_auth_only_operation),
9806 TEST_CASE_ST(ut_setup, ut_teardown,
9807 test_null_cipher_only_operation),
9808 TEST_CASE_ST(ut_setup, ut_teardown,
9809 test_null_cipher_auth_operation),
9810 TEST_CASE_ST(ut_setup, ut_teardown,
9811 test_null_auth_cipher_operation),
9812 TEST_CASE_ST(ut_setup, ut_teardown,
9813 test_null_invalid_operation),
9814 TEST_CASE_ST(ut_setup, ut_teardown,
9815 test_null_burst_operation),
9817 TEST_CASES_END() /**< NULL terminate unit test array */
9821 static struct unit_test_suite cryptodev_armv8_testsuite = {
9822 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9823 .setup = testsuite_setup,
9824 .teardown = testsuite_teardown,
9825 .unit_test_cases = {
9826 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9828 /** Negative tests */
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9831 TEST_CASE_ST(ut_setup, ut_teardown,
9832 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9834 TEST_CASES_END() /**< NULL terminate unit test array */
9838 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9839 .suite_name = "Crypto Device Marvell Component Test Suite",
9840 .setup = testsuite_setup,
9841 .teardown = testsuite_teardown,
9842 .unit_test_cases = {
9843 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9844 TEST_CASE_ST(ut_setup, ut_teardown,
9845 test_multi_session_random_usage),
9846 TEST_CASE_ST(ut_setup, ut_teardown,
9847 test_AES_chain_mrvl_all),
9848 TEST_CASE_ST(ut_setup, ut_teardown,
9849 test_AES_cipheronly_mrvl_all),
9850 TEST_CASE_ST(ut_setup, ut_teardown,
9851 test_authonly_mrvl_all),
9852 TEST_CASE_ST(ut_setup, ut_teardown,
9853 test_3DES_chain_mrvl_all),
9854 TEST_CASE_ST(ut_setup, ut_teardown,
9855 test_3DES_cipheronly_mrvl_all),
9857 /** Negative tests */
9858 TEST_CASE_ST(ut_setup, ut_teardown,
9859 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9860 TEST_CASE_ST(ut_setup, ut_teardown,
9861 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9862 TEST_CASE_ST(ut_setup, ut_teardown,
9863 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9864 TEST_CASE_ST(ut_setup, ut_teardown,
9865 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9867 TEST_CASES_END() /**< NULL terminate unit test array */
9871 static struct unit_test_suite cryptodev_ccp_testsuite = {
9872 .suite_name = "Crypto Device CCP Unit Test Suite",
9873 .setup = testsuite_setup,
9874 .teardown = testsuite_teardown,
9875 .unit_test_cases = {
9876 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 test_multi_session_random_usage),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 test_AES_chain_ccp_all),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_AES_cipheronly_ccp_all),
9883 TEST_CASE_ST(ut_setup, ut_teardown,
9884 test_3DES_chain_ccp_all),
9885 TEST_CASE_ST(ut_setup, ut_teardown,
9886 test_3DES_cipheronly_ccp_all),
9887 TEST_CASE_ST(ut_setup, ut_teardown,
9888 test_authonly_ccp_all),
9890 /** Negative tests */
9891 TEST_CASE_ST(ut_setup, ut_teardown,
9892 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9893 TEST_CASE_ST(ut_setup, ut_teardown,
9894 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9895 TEST_CASE_ST(ut_setup, ut_teardown,
9896 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9897 TEST_CASE_ST(ut_setup, ut_teardown,
9898 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9900 TEST_CASES_END() /**< NULL terminate unit test array */
9905 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9907 gbl_driver_id = rte_cryptodev_driver_id_get(
9908 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9910 if (gbl_driver_id == -1) {
9911 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9912 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9913 "in config file to run this testsuite.\n");
9914 return TEST_SKIPPED;
9917 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9921 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9923 gbl_driver_id = rte_cryptodev_driver_id_get(
9924 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9926 if (gbl_driver_id == -1) {
9927 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9928 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9929 "in config file to run this testsuite.\n");
9933 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9937 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9939 gbl_driver_id = rte_cryptodev_driver_id_get(
9940 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9942 if (gbl_driver_id == -1) {
9943 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9944 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9945 "in config file to run this testsuite.\n");
9946 return TEST_SKIPPED;
9949 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9953 test_cryptodev_openssl(void)
9955 gbl_driver_id = rte_cryptodev_driver_id_get(
9956 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9958 if (gbl_driver_id == -1) {
9959 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9960 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9961 "in config file to run this testsuite.\n");
9962 return TEST_SKIPPED;
9965 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9969 test_cryptodev_aesni_gcm(void)
9971 gbl_driver_id = rte_cryptodev_driver_id_get(
9972 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9974 if (gbl_driver_id == -1) {
9975 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9976 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9977 "in config file to run this testsuite.\n");
9978 return TEST_SKIPPED;
9981 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9985 test_cryptodev_null(void)
9987 gbl_driver_id = rte_cryptodev_driver_id_get(
9988 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9990 if (gbl_driver_id == -1) {
9991 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9992 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9993 "in config file to run this testsuite.\n");
9994 return TEST_SKIPPED;
9997 return unit_test_suite_runner(&cryptodev_null_testsuite);
10001 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10003 gbl_driver_id = rte_cryptodev_driver_id_get(
10004 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10006 if (gbl_driver_id == -1) {
10007 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10008 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10009 "in config file to run this testsuite.\n");
10010 return TEST_SKIPPED;
10013 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10017 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10019 gbl_driver_id = rte_cryptodev_driver_id_get(
10020 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10022 if (gbl_driver_id == -1) {
10023 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10024 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10025 "in config file to run this testsuite.\n");
10026 return TEST_SKIPPED;
10029 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10033 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10035 gbl_driver_id = rte_cryptodev_driver_id_get(
10036 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10038 if (gbl_driver_id == -1) {
10039 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10040 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10041 "in config file to run this testsuite.\n");
10042 return TEST_SKIPPED;
10045 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10049 test_cryptodev_armv8(void)
10051 gbl_driver_id = rte_cryptodev_driver_id_get(
10052 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10054 if (gbl_driver_id == -1) {
10055 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10056 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10057 "in config file to run this testsuite.\n");
10058 return TEST_SKIPPED;
10061 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10065 test_cryptodev_mrvl(void)
10067 gbl_driver_id = rte_cryptodev_driver_id_get(
10068 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10070 if (gbl_driver_id == -1) {
10071 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10072 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10073 "in config file to run this testsuite.\n");
10074 return TEST_SKIPPED;
10077 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10080 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10083 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10085 gbl_driver_id = rte_cryptodev_driver_id_get(
10086 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10088 if (gbl_driver_id == -1) {
10089 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10090 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10091 "in config file to run this testsuite.\n");
10092 return TEST_SKIPPED;
10095 if (rte_cryptodev_driver_id_get(
10096 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10097 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10098 " enabled in config file to run this testsuite.\n");
10099 return TEST_SKIPPED;
10101 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10104 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10109 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10111 gbl_driver_id = rte_cryptodev_driver_id_get(
10112 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10114 if (gbl_driver_id == -1) {
10115 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10116 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10117 "in config file to run this testsuite.\n");
10118 return TEST_SKIPPED;
10121 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10125 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10127 gbl_driver_id = rte_cryptodev_driver_id_get(
10128 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10130 if (gbl_driver_id == -1) {
10131 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10132 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10133 "in config file to run this testsuite.\n");
10134 return TEST_SKIPPED;
10137 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10141 test_cryptodev_ccp(void)
10143 gbl_driver_id = rte_cryptodev_driver_id_get(
10144 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10146 if (gbl_driver_id == -1) {
10147 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10148 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10149 "in config file to run this testsuite.\n");
10150 return TEST_FAILED;
10153 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10156 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10157 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10158 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10159 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10160 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10161 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10162 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10163 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10164 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10165 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10166 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10167 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10168 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10169 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);