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 = rte_cryptodev_get_private_session_size(dev_id);
434 * Create mempool with maximum number of sessions * 2,
435 * to include the session headers
437 ts_params->session_mpool = rte_mempool_create(
439 info.sym.max_nb_sessions * 2,
441 0, 0, NULL, NULL, NULL,
445 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
446 "session mempool allocation failed");
448 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
450 "Failed to configure cryptodev %u with %u qps",
451 dev_id, ts_params->conf.nb_queue_pairs);
453 ts_params->qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
455 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
456 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
457 dev_id, qp_id, &ts_params->qp_conf,
458 rte_cryptodev_socket_id(dev_id),
459 ts_params->session_mpool),
460 "Failed to setup queue pair %u on cryptodev %u",
468 testsuite_teardown(void)
470 struct crypto_testsuite_params *ts_params = &testsuite_params;
472 if (ts_params->mbuf_pool != NULL) {
473 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
474 rte_mempool_avail_count(ts_params->mbuf_pool));
477 if (ts_params->op_mpool != NULL) {
478 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
479 rte_mempool_avail_count(ts_params->op_mpool));
482 /* Free session mempools */
483 if (ts_params->session_mpool != NULL) {
484 rte_mempool_free(ts_params->session_mpool);
485 ts_params->session_mpool = NULL;
492 struct crypto_testsuite_params *ts_params = &testsuite_params;
493 struct crypto_unittest_params *ut_params = &unittest_params;
497 /* Clear unit test parameters before running test */
498 memset(ut_params, 0, sizeof(*ut_params));
500 /* Reconfigure device to default parameters */
501 ts_params->conf.socket_id = SOCKET_ID_ANY;
503 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
505 "Failed to configure cryptodev %u",
506 ts_params->valid_devs[0]);
508 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
509 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
510 ts_params->valid_devs[0], qp_id,
512 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
513 ts_params->session_mpool),
514 "Failed to setup queue pair %u on cryptodev %u",
515 qp_id, ts_params->valid_devs[0]);
519 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
521 /* Start the device */
522 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
523 "Failed to start cryptodev %u",
524 ts_params->valid_devs[0]);
532 struct crypto_testsuite_params *ts_params = &testsuite_params;
533 struct crypto_unittest_params *ut_params = &unittest_params;
534 struct rte_cryptodev_stats stats;
536 /* free crypto session structure */
537 if (ut_params->sess) {
538 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
540 rte_cryptodev_sym_session_free(ut_params->sess);
541 ut_params->sess = NULL;
544 /* free crypto operation structure */
546 rte_crypto_op_free(ut_params->op);
549 * free mbuf - both obuf and ibuf are usually the same,
550 * so check if they point at the same address is necessary,
551 * to avoid freeing the mbuf twice.
553 if (ut_params->obuf) {
554 rte_pktmbuf_free(ut_params->obuf);
555 if (ut_params->ibuf == ut_params->obuf)
559 if (ut_params->ibuf) {
560 rte_pktmbuf_free(ut_params->ibuf);
564 if (ts_params->mbuf_pool != NULL)
565 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
566 rte_mempool_avail_count(ts_params->mbuf_pool));
568 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
570 /* Stop the device */
571 rte_cryptodev_stop(ts_params->valid_devs[0]);
575 test_device_configure_invalid_dev_id(void)
577 struct crypto_testsuite_params *ts_params = &testsuite_params;
578 uint16_t dev_id, num_devs = 0;
580 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
581 "Need at least %d devices for test", 1);
583 /* valid dev_id values */
584 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
586 /* Stop the device in case it's started so it can be configured */
587 rte_cryptodev_stop(ts_params->valid_devs[dev_id]);
589 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
590 "Failed test for rte_cryptodev_configure: "
591 "invalid dev_num %u", dev_id);
593 /* invalid dev_id values */
596 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
597 "Failed test for rte_cryptodev_configure: "
598 "invalid dev_num %u", dev_id);
602 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
603 "Failed test for rte_cryptodev_configure:"
604 "invalid dev_num %u", dev_id);
610 test_device_configure_invalid_queue_pair_ids(void)
612 struct crypto_testsuite_params *ts_params = &testsuite_params;
613 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
615 /* Stop the device in case it's started so it can be configured */
616 rte_cryptodev_stop(ts_params->valid_devs[0]);
618 /* valid - one queue pairs */
619 ts_params->conf.nb_queue_pairs = 1;
621 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
623 "Failed to configure cryptodev: dev_id %u, qp_id %u",
624 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
627 /* valid - max value queue pairs */
628 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE;
630 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
632 "Failed to configure cryptodev: dev_id %u, qp_id %u",
633 ts_params->valid_devs[0],
634 ts_params->conf.nb_queue_pairs);
637 /* invalid - zero queue pairs */
638 ts_params->conf.nb_queue_pairs = 0;
640 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
642 "Failed test for rte_cryptodev_configure, dev_id %u,"
644 ts_params->valid_devs[0],
645 ts_params->conf.nb_queue_pairs);
648 /* invalid - max value supported by field queue pairs */
649 ts_params->conf.nb_queue_pairs = UINT16_MAX;
651 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
653 "Failed test for rte_cryptodev_configure, dev_id %u,"
655 ts_params->valid_devs[0],
656 ts_params->conf.nb_queue_pairs);
659 /* invalid - max value + 1 queue pairs */
660 ts_params->conf.nb_queue_pairs = MAX_NUM_QPS_PER_QAT_DEVICE + 1;
662 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
664 "Failed test for rte_cryptodev_configure, dev_id %u,"
666 ts_params->valid_devs[0],
667 ts_params->conf.nb_queue_pairs);
669 /* revert to original testsuite value */
670 ts_params->conf.nb_queue_pairs = orig_nb_qps;
676 test_queue_pair_descriptor_setup(void)
678 struct crypto_testsuite_params *ts_params = &testsuite_params;
679 struct rte_cryptodev_info dev_info;
680 struct rte_cryptodev_qp_conf qp_conf = {
681 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
686 /* Stop the device in case it's started so it can be configured */
687 rte_cryptodev_stop(ts_params->valid_devs[0]);
690 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
692 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
694 "Failed to configure cryptodev %u",
695 ts_params->valid_devs[0]);
698 * Test various ring sizes on this device. memzones can't be
699 * freed so are re-used if ring is released and re-created.
701 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
703 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
704 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
705 ts_params->valid_devs[0], qp_id, &qp_conf,
706 rte_cryptodev_socket_id(
707 ts_params->valid_devs[0]),
708 ts_params->session_mpool),
710 "rte_cryptodev_queue_pair_setup: num_inflights "
711 "%u on qp %u on cryptodev %u",
712 qp_conf.nb_descriptors, qp_id,
713 ts_params->valid_devs[0]);
716 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
718 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
719 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
720 ts_params->valid_devs[0], qp_id, &qp_conf,
721 rte_cryptodev_socket_id(
722 ts_params->valid_devs[0]),
723 ts_params->session_mpool),
725 " rte_cryptodev_queue_pair_setup: num_inflights"
726 " %u on qp %u on cryptodev %u",
727 qp_conf.nb_descriptors, qp_id,
728 ts_params->valid_devs[0]);
731 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
733 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
734 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
735 ts_params->valid_devs[0], qp_id, &qp_conf,
736 rte_cryptodev_socket_id(
737 ts_params->valid_devs[0]),
738 ts_params->session_mpool),
740 "rte_cryptodev_queue_pair_setup: num_inflights"
741 " %u on qp %u on cryptodev %u",
742 qp_conf.nb_descriptors, qp_id,
743 ts_params->valid_devs[0]);
746 /* invalid number of descriptors - max supported + 2 */
747 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
749 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
750 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
751 ts_params->valid_devs[0], qp_id, &qp_conf,
752 rte_cryptodev_socket_id(
753 ts_params->valid_devs[0]),
754 ts_params->session_mpool),
755 "Unexpectedly passed test for "
756 "rte_cryptodev_queue_pair_setup:"
757 "num_inflights %u on qp %u on cryptodev %u",
758 qp_conf.nb_descriptors, qp_id,
759 ts_params->valid_devs[0]);
762 /* invalid number of descriptors - max value of parameter */
763 qp_conf.nb_descriptors = UINT32_MAX-1;
765 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
766 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
767 ts_params->valid_devs[0], qp_id, &qp_conf,
768 rte_cryptodev_socket_id(
769 ts_params->valid_devs[0]),
770 ts_params->session_mpool),
771 "Unexpectedly passed test for "
772 "rte_cryptodev_queue_pair_setup:"
773 "num_inflights %u on qp %u on cryptodev %u",
774 qp_conf.nb_descriptors, qp_id,
775 ts_params->valid_devs[0]);
778 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
780 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
781 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
782 ts_params->valid_devs[0], qp_id, &qp_conf,
783 rte_cryptodev_socket_id(
784 ts_params->valid_devs[0]),
785 ts_params->session_mpool),
787 " rte_cryptodev_queue_pair_setup:"
788 "num_inflights %u on qp %u on cryptodev %u",
789 qp_conf.nb_descriptors, qp_id,
790 ts_params->valid_devs[0]);
793 /* invalid number of descriptors - max supported + 1 */
794 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
796 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
797 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
798 ts_params->valid_devs[0], qp_id, &qp_conf,
799 rte_cryptodev_socket_id(
800 ts_params->valid_devs[0]),
801 ts_params->session_mpool),
802 "Unexpectedly passed test for "
803 "rte_cryptodev_queue_pair_setup:"
804 "num_inflights %u on qp %u on cryptodev %u",
805 qp_conf.nb_descriptors, qp_id,
806 ts_params->valid_devs[0]);
809 /* test invalid queue pair id */
810 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
812 qp_id = DEFAULT_NUM_QPS_PER_QAT_DEVICE; /*invalid */
814 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
815 ts_params->valid_devs[0],
817 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
818 ts_params->session_mpool),
819 "Failed test for rte_cryptodev_queue_pair_setup:"
820 "invalid qp %u on cryptodev %u",
821 qp_id, ts_params->valid_devs[0]);
823 qp_id = 0xffff; /*invalid*/
825 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
826 ts_params->valid_devs[0],
828 rte_cryptodev_socket_id(ts_params->valid_devs[0]),
829 ts_params->session_mpool),
830 "Failed test for rte_cryptodev_queue_pair_setup:"
831 "invalid qp %u on cryptodev %u",
832 qp_id, ts_params->valid_devs[0]);
837 /* ***** Plaintext data for tests ***** */
839 const char catch_22_quote_1[] =
840 "There was only one catch and that was Catch-22, which "
841 "specified that a concern for one's safety in the face of "
842 "dangers that were real and immediate was the process of a "
843 "rational mind. Orr was crazy and could be grounded. All he "
844 "had to do was ask; and as soon as he did, he would no longer "
845 "be crazy and would have to fly more missions. Orr would be "
846 "crazy to fly more missions and sane if he didn't, but if he "
847 "was sane he had to fly them. If he flew them he was crazy "
848 "and didn't have to; but if he didn't want to he was sane and "
849 "had to. Yossarian was moved very deeply by the absolute "
850 "simplicity of this clause of Catch-22 and let out a "
851 "respectful whistle. \"That's some catch, that Catch-22\", he "
852 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
854 const char catch_22_quote[] =
855 "What a lousy earth! He wondered how many people were "
856 "destitute that same night even in his own prosperous country, "
857 "how many homes were shanties, how many husbands were drunk "
858 "and wives socked, and how many children were bullied, abused, "
859 "or abandoned. How many families hungered for food they could "
860 "not afford to buy? How many hearts were broken? How many "
861 "suicides would take place that same night, how many people "
862 "would go insane? How many cockroaches and landlords would "
863 "triumph? How many winners were losers, successes failures, "
864 "and rich men poor men? How many wise guys were stupid? How "
865 "many happy endings were unhappy endings? How many honest men "
866 "were liars, brave men cowards, loyal men traitors, how many "
867 "sainted men were corrupt, how many people in positions of "
868 "trust had sold their souls to bodyguards, how many had never "
869 "had souls? How many straight-and-narrow paths were crooked "
870 "paths? How many best families were worst families and how "
871 "many good people were bad people? When you added them all up "
872 "and then subtracted, you might be left with only the children, "
873 "and perhaps with Albert Einstein and an old violinist or "
874 "sculptor somewhere.";
876 #define QUOTE_480_BYTES (480)
877 #define QUOTE_512_BYTES (512)
878 #define QUOTE_768_BYTES (768)
879 #define QUOTE_1024_BYTES (1024)
883 /* ***** SHA1 Hash Tests ***** */
885 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
887 static uint8_t hmac_sha1_key[] = {
888 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
889 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
890 0xDE, 0xF4, 0xDE, 0xAD };
892 /* ***** SHA224 Hash Tests ***** */
894 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
897 /* ***** AES-CBC Cipher Tests ***** */
899 #define CIPHER_KEY_LENGTH_AES_CBC (16)
900 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
902 static uint8_t aes_cbc_key[] = {
903 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
904 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
906 static uint8_t aes_cbc_iv[] = {
907 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
908 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
911 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
913 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
914 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
915 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
916 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
917 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
918 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
919 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
920 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
921 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
922 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
923 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
924 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
925 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
926 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
927 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
928 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
929 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
930 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
931 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
932 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
933 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
934 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
935 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
936 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
937 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
938 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
939 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
940 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
941 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
942 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
943 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
944 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
945 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
946 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
947 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
948 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
949 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
950 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
951 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
952 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
953 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
954 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
955 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
956 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
957 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
958 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
959 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
960 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
961 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
962 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
963 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
964 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
965 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
966 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
967 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
968 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
969 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
970 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
971 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
972 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
973 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
974 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
975 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
976 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
977 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
980 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
981 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
982 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
983 0x18, 0x8c, 0x1d, 0x32
987 /* Multisession Vector context Test */
989 static uint8_t ms_aes_cbc_key0[] = {
990 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
991 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
994 static uint8_t ms_aes_cbc_iv0[] = {
995 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
996 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
999 static const uint8_t ms_aes_cbc_cipher0[] = {
1000 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1001 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1002 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1003 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1004 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1005 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1006 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1007 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1008 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1009 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1010 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1011 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1012 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1013 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1014 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1015 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1016 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1017 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1018 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1019 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1020 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1021 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1022 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1023 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1024 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1025 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1026 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1027 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1028 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1029 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1030 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1031 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1032 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1033 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1034 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1035 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1036 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1037 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1038 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1039 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1040 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1041 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1042 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1043 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1044 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1045 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1046 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1047 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1048 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1049 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1050 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1051 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1052 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1053 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1054 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1055 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1056 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1057 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1058 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1059 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1060 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1061 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1062 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1063 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1067 static uint8_t ms_hmac_key0[] = {
1068 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1069 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1070 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1071 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1072 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1073 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1074 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1075 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1078 static const uint8_t ms_hmac_digest0[] = {
1079 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1080 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1081 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1082 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1083 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1084 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1085 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1086 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1090 /* Begin session 1 */
1092 static uint8_t ms_aes_cbc_key1[] = {
1093 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1094 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1097 static uint8_t ms_aes_cbc_iv1[] = {
1098 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1099 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1102 static const uint8_t ms_aes_cbc_cipher1[] = {
1103 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1104 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1105 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1106 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1107 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1108 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1109 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1110 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1111 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1112 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1113 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1114 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1115 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1116 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1117 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1118 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1119 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1120 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1121 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1122 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1123 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1124 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1125 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1126 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1127 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1128 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1129 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1130 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1131 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1132 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1133 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1134 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1135 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1136 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1137 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1138 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1139 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1140 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1141 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1142 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1143 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1144 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1145 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1146 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1147 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1148 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1149 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1150 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1151 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1152 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1153 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1154 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1155 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1156 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1157 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1158 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1159 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1160 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1161 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1162 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1163 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1164 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1165 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1166 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1170 static uint8_t ms_hmac_key1[] = {
1171 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1172 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1173 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1174 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1175 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1176 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1177 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1178 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1181 static const uint8_t ms_hmac_digest1[] = {
1182 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1183 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1184 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1185 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1186 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1187 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1188 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1189 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1192 /* Begin Session 2 */
1193 static uint8_t ms_aes_cbc_key2[] = {
1194 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1195 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1198 static uint8_t ms_aes_cbc_iv2[] = {
1199 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1200 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1203 static const uint8_t ms_aes_cbc_cipher2[] = {
1204 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1205 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1206 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1207 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1208 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1209 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1210 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1211 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1212 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1213 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1214 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1215 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1216 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1217 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1218 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1219 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1220 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1221 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1222 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1223 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1224 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1225 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1226 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1227 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1228 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1229 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1230 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1231 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1232 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1233 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1234 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1235 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1236 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1237 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1238 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1239 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1240 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1241 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1242 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1243 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1244 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1245 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1246 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1247 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1248 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1249 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1250 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1251 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1252 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1253 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1254 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1255 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1256 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1257 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1258 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1259 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1260 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1261 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1262 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1263 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1264 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1265 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1266 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1267 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1270 static uint8_t ms_hmac_key2[] = {
1271 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1272 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1273 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1274 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1275 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1276 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1277 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1278 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1281 static const uint8_t ms_hmac_digest2[] = {
1282 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1283 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1284 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1285 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1286 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1287 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1288 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1289 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1296 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1298 struct crypto_testsuite_params *ts_params = &testsuite_params;
1299 struct crypto_unittest_params *ut_params = &unittest_params;
1301 /* Generate test mbuf data and space for digest */
1302 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1303 catch_22_quote, QUOTE_512_BYTES, 0);
1305 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1306 DIGEST_BYTE_LENGTH_SHA1);
1307 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1309 /* Setup Cipher Parameters */
1310 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1311 ut_params->cipher_xform.next = &ut_params->auth_xform;
1313 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1314 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1315 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1316 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1317 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1318 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1320 /* Setup HMAC Parameters */
1321 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1323 ut_params->auth_xform.next = NULL;
1325 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1326 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1327 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1328 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1329 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1331 ut_params->sess = rte_cryptodev_sym_session_create(
1332 ts_params->session_mpool);
1334 /* Create crypto session*/
1335 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1336 ut_params->sess, &ut_params->cipher_xform,
1337 ts_params->session_mpool);
1338 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1340 /* Generate crypto op data structure */
1341 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1342 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1343 TEST_ASSERT_NOT_NULL(ut_params->op,
1344 "Failed to allocate symmetric crypto operation struct");
1346 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1348 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1350 /* set crypto operation source mbuf */
1351 sym_op->m_src = ut_params->ibuf;
1353 /* Set crypto operation authentication parameters */
1354 sym_op->auth.digest.data = ut_params->digest;
1355 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1356 ut_params->ibuf, QUOTE_512_BYTES);
1358 sym_op->auth.data.offset = 0;
1359 sym_op->auth.data.length = QUOTE_512_BYTES;
1361 /* Copy IV at the end of the crypto operation */
1362 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1363 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1365 /* Set crypto operation cipher parameters */
1366 sym_op->cipher.data.offset = 0;
1367 sym_op->cipher.data.length = QUOTE_512_BYTES;
1369 /* Process crypto operation */
1370 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1371 ut_params->op), "failed to process sym crypto op");
1373 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1374 "crypto op processing failed");
1377 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1380 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1381 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1383 "ciphertext data not as expected");
1385 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1387 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1388 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1389 gbl_driver_id == rte_cryptodev_driver_id_get(
1390 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1391 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1392 DIGEST_BYTE_LENGTH_SHA1,
1393 "Generated digest data not as expected");
1395 return TEST_SUCCESS;
1398 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1400 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1402 static uint8_t hmac_sha512_key[] = {
1403 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1404 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1405 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1406 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1407 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1408 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1409 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1410 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1412 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1413 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1414 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1415 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1416 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1417 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1418 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1419 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1420 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1425 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1426 struct crypto_unittest_params *ut_params,
1427 uint8_t *cipher_key,
1431 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1432 struct crypto_unittest_params *ut_params,
1433 struct crypto_testsuite_params *ts_params,
1434 const uint8_t *cipher,
1435 const uint8_t *digest,
1440 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1441 struct crypto_unittest_params *ut_params,
1442 uint8_t *cipher_key,
1446 /* Setup Cipher Parameters */
1447 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1448 ut_params->cipher_xform.next = NULL;
1450 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1451 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1452 ut_params->cipher_xform.cipher.key.data = cipher_key;
1453 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1454 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1455 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1457 /* Setup HMAC Parameters */
1458 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1459 ut_params->auth_xform.next = &ut_params->cipher_xform;
1461 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1462 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1463 ut_params->auth_xform.auth.key.data = hmac_key;
1464 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1465 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1467 return TEST_SUCCESS;
1472 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1473 struct crypto_unittest_params *ut_params,
1474 struct crypto_testsuite_params *ts_params,
1475 const uint8_t *cipher,
1476 const uint8_t *digest,
1479 /* Generate test mbuf data and digest */
1480 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1483 QUOTE_512_BYTES, 0);
1485 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1486 DIGEST_BYTE_LENGTH_SHA512);
1487 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1489 rte_memcpy(ut_params->digest,
1491 DIGEST_BYTE_LENGTH_SHA512);
1493 /* Generate Crypto op data structure */
1494 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1495 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1496 TEST_ASSERT_NOT_NULL(ut_params->op,
1497 "Failed to allocate symmetric crypto operation struct");
1499 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1501 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1503 /* set crypto operation source mbuf */
1504 sym_op->m_src = ut_params->ibuf;
1506 sym_op->auth.digest.data = ut_params->digest;
1507 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1508 ut_params->ibuf, QUOTE_512_BYTES);
1510 sym_op->auth.data.offset = 0;
1511 sym_op->auth.data.length = QUOTE_512_BYTES;
1513 /* Copy IV at the end of the crypto operation */
1514 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1515 iv, CIPHER_IV_LENGTH_AES_CBC);
1517 sym_op->cipher.data.offset = 0;
1518 sym_op->cipher.data.length = QUOTE_512_BYTES;
1520 /* Process crypto operation */
1521 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1522 ut_params->op), "failed to process sym crypto op");
1524 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1525 "crypto op processing failed");
1527 ut_params->obuf = ut_params->op->sym->m_src;
1530 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1531 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1534 "Plaintext data not as expected");
1537 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1538 "Digest verification failed");
1540 return TEST_SUCCESS;
1544 test_AES_cipheronly_mb_all(void)
1546 struct crypto_testsuite_params *ts_params = &testsuite_params;
1549 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1550 ts_params->op_mpool,
1551 ts_params->session_mpool,
1552 ts_params->valid_devs[0],
1553 rte_cryptodev_driver_id_get(
1554 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1555 BLKCIPHER_AES_CIPHERONLY_TYPE);
1557 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1559 return TEST_SUCCESS;
1563 test_AES_docsis_mb_all(void)
1565 struct crypto_testsuite_params *ts_params = &testsuite_params;
1568 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1569 ts_params->op_mpool,
1570 ts_params->session_mpool,
1571 ts_params->valid_devs[0],
1572 rte_cryptodev_driver_id_get(
1573 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1574 BLKCIPHER_AES_DOCSIS_TYPE);
1576 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1578 return TEST_SUCCESS;
1582 test_AES_docsis_qat_all(void)
1584 struct crypto_testsuite_params *ts_params = &testsuite_params;
1587 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1588 ts_params->op_mpool,
1589 ts_params->session_mpool,
1590 ts_params->valid_devs[0],
1591 rte_cryptodev_driver_id_get(
1592 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1593 BLKCIPHER_AES_DOCSIS_TYPE);
1595 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1597 return TEST_SUCCESS;
1601 test_DES_docsis_qat_all(void)
1603 struct crypto_testsuite_params *ts_params = &testsuite_params;
1606 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1607 ts_params->op_mpool,
1608 ts_params->session_mpool,
1609 ts_params->valid_devs[0],
1610 rte_cryptodev_driver_id_get(
1611 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1612 BLKCIPHER_DES_DOCSIS_TYPE);
1614 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1616 return TEST_SUCCESS;
1620 test_authonly_mb_all(void)
1622 struct crypto_testsuite_params *ts_params = &testsuite_params;
1625 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1626 ts_params->op_mpool,
1627 ts_params->session_mpool,
1628 ts_params->valid_devs[0],
1629 rte_cryptodev_driver_id_get(
1630 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1631 BLKCIPHER_AUTHONLY_TYPE);
1633 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1635 return TEST_SUCCESS;
1639 test_authonly_qat_all(void)
1641 struct crypto_testsuite_params *ts_params = &testsuite_params;
1644 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1645 ts_params->op_mpool,
1646 ts_params->session_mpool,
1647 ts_params->valid_devs[0],
1648 rte_cryptodev_driver_id_get(
1649 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1650 BLKCIPHER_AUTHONLY_TYPE);
1652 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1654 return TEST_SUCCESS;
1657 test_AES_chain_mb_all(void)
1659 struct crypto_testsuite_params *ts_params = &testsuite_params;
1662 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1663 ts_params->op_mpool,
1664 ts_params->session_mpool,
1665 ts_params->valid_devs[0],
1666 rte_cryptodev_driver_id_get(
1667 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1668 BLKCIPHER_AES_CHAIN_TYPE);
1670 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1672 return TEST_SUCCESS;
1675 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1678 test_AES_cipheronly_scheduler_all(void)
1680 struct crypto_testsuite_params *ts_params = &testsuite_params;
1683 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1684 ts_params->op_mpool,
1685 ts_params->session_mpool,
1686 ts_params->valid_devs[0],
1687 rte_cryptodev_driver_id_get(
1688 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1689 BLKCIPHER_AES_CIPHERONLY_TYPE);
1691 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1693 return TEST_SUCCESS;
1697 test_AES_chain_scheduler_all(void)
1699 struct crypto_testsuite_params *ts_params = &testsuite_params;
1702 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1703 ts_params->op_mpool,
1704 ts_params->session_mpool,
1705 ts_params->valid_devs[0],
1706 rte_cryptodev_driver_id_get(
1707 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1708 BLKCIPHER_AES_CHAIN_TYPE);
1710 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1712 return TEST_SUCCESS;
1716 test_authonly_scheduler_all(void)
1718 struct crypto_testsuite_params *ts_params = &testsuite_params;
1721 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1722 ts_params->op_mpool,
1723 ts_params->session_mpool,
1724 ts_params->valid_devs[0],
1725 rte_cryptodev_driver_id_get(
1726 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1727 BLKCIPHER_AUTHONLY_TYPE);
1729 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1731 return TEST_SUCCESS;
1734 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1737 test_AES_chain_openssl_all(void)
1739 struct crypto_testsuite_params *ts_params = &testsuite_params;
1742 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1743 ts_params->op_mpool,
1744 ts_params->session_mpool,
1745 ts_params->valid_devs[0],
1746 rte_cryptodev_driver_id_get(
1747 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1748 BLKCIPHER_AES_CHAIN_TYPE);
1750 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1752 return TEST_SUCCESS;
1756 test_AES_cipheronly_openssl_all(void)
1758 struct crypto_testsuite_params *ts_params = &testsuite_params;
1761 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1762 ts_params->op_mpool,
1763 ts_params->session_mpool,
1764 ts_params->valid_devs[0],
1765 rte_cryptodev_driver_id_get(
1766 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1767 BLKCIPHER_AES_CIPHERONLY_TYPE);
1769 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1771 return TEST_SUCCESS;
1775 test_AES_chain_ccp_all(void)
1777 struct crypto_testsuite_params *ts_params = &testsuite_params;
1780 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1781 ts_params->op_mpool,
1782 ts_params->session_mpool,
1783 ts_params->valid_devs[0],
1784 rte_cryptodev_driver_id_get(
1785 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1786 BLKCIPHER_AES_CHAIN_TYPE);
1788 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1790 return TEST_SUCCESS;
1794 test_AES_cipheronly_ccp_all(void)
1796 struct crypto_testsuite_params *ts_params = &testsuite_params;
1799 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1800 ts_params->op_mpool,
1801 ts_params->session_mpool,
1802 ts_params->valid_devs[0],
1803 rte_cryptodev_driver_id_get(
1804 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1805 BLKCIPHER_AES_CIPHERONLY_TYPE);
1807 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1809 return TEST_SUCCESS;
1813 test_AES_chain_qat_all(void)
1815 struct crypto_testsuite_params *ts_params = &testsuite_params;
1818 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1819 ts_params->op_mpool,
1820 ts_params->session_mpool,
1821 ts_params->valid_devs[0],
1822 rte_cryptodev_driver_id_get(
1823 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1824 BLKCIPHER_AES_CHAIN_TYPE);
1826 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1828 return TEST_SUCCESS;
1832 test_AES_cipheronly_qat_all(void)
1834 struct crypto_testsuite_params *ts_params = &testsuite_params;
1837 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1838 ts_params->op_mpool,
1839 ts_params->session_mpool,
1840 ts_params->valid_devs[0],
1841 rte_cryptodev_driver_id_get(
1842 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1843 BLKCIPHER_AES_CIPHERONLY_TYPE);
1845 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1847 return TEST_SUCCESS;
1851 test_AES_cipheronly_virtio_all(void)
1853 struct crypto_testsuite_params *ts_params = &testsuite_params;
1856 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1857 ts_params->op_mpool,
1858 ts_params->session_mpool,
1859 ts_params->valid_devs[0],
1860 rte_cryptodev_driver_id_get(
1861 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1862 BLKCIPHER_AES_CIPHERONLY_TYPE);
1864 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1866 return TEST_SUCCESS;
1870 test_AES_chain_dpaa_sec_all(void)
1872 struct crypto_testsuite_params *ts_params = &testsuite_params;
1875 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1876 ts_params->op_mpool,
1877 ts_params->session_mpool,
1878 ts_params->valid_devs[0],
1879 rte_cryptodev_driver_id_get(
1880 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1881 BLKCIPHER_AES_CHAIN_TYPE);
1883 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1885 return TEST_SUCCESS;
1889 test_AES_cipheronly_dpaa_sec_all(void)
1891 struct crypto_testsuite_params *ts_params = &testsuite_params;
1894 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1895 ts_params->op_mpool,
1896 ts_params->session_mpool,
1897 ts_params->valid_devs[0],
1898 rte_cryptodev_driver_id_get(
1899 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1900 BLKCIPHER_AES_CIPHERONLY_TYPE);
1902 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1904 return TEST_SUCCESS;
1908 test_authonly_dpaa_sec_all(void)
1910 struct crypto_testsuite_params *ts_params = &testsuite_params;
1913 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1914 ts_params->op_mpool,
1915 ts_params->session_mpool,
1916 ts_params->valid_devs[0],
1917 rte_cryptodev_driver_id_get(
1918 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
1919 BLKCIPHER_AUTHONLY_TYPE);
1921 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1923 return TEST_SUCCESS;
1927 test_AES_chain_dpaa2_sec_all(void)
1929 struct crypto_testsuite_params *ts_params = &testsuite_params;
1932 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1933 ts_params->op_mpool,
1934 ts_params->session_mpool,
1935 ts_params->valid_devs[0],
1936 rte_cryptodev_driver_id_get(
1937 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1938 BLKCIPHER_AES_CHAIN_TYPE);
1940 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1942 return TEST_SUCCESS;
1946 test_AES_cipheronly_dpaa2_sec_all(void)
1948 struct crypto_testsuite_params *ts_params = &testsuite_params;
1951 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1952 ts_params->op_mpool,
1953 ts_params->session_mpool,
1954 ts_params->valid_devs[0],
1955 rte_cryptodev_driver_id_get(
1956 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1957 BLKCIPHER_AES_CIPHERONLY_TYPE);
1959 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1961 return TEST_SUCCESS;
1965 test_authonly_dpaa2_sec_all(void)
1967 struct crypto_testsuite_params *ts_params = &testsuite_params;
1970 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1971 ts_params->op_mpool,
1972 ts_params->session_mpool,
1973 ts_params->valid_devs[0],
1974 rte_cryptodev_driver_id_get(
1975 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
1976 BLKCIPHER_AUTHONLY_TYPE);
1978 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1980 return TEST_SUCCESS;
1984 test_authonly_openssl_all(void)
1986 struct crypto_testsuite_params *ts_params = &testsuite_params;
1989 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1990 ts_params->op_mpool,
1991 ts_params->session_mpool,
1992 ts_params->valid_devs[0],
1993 rte_cryptodev_driver_id_get(
1994 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1995 BLKCIPHER_AUTHONLY_TYPE);
1997 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1999 return TEST_SUCCESS;
2003 test_authonly_ccp_all(void)
2005 struct crypto_testsuite_params *ts_params = &testsuite_params;
2008 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2009 ts_params->op_mpool,
2010 ts_params->session_mpool,
2011 ts_params->valid_devs[0],
2012 rte_cryptodev_driver_id_get(
2013 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2014 BLKCIPHER_AUTHONLY_TYPE);
2016 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2018 return TEST_SUCCESS;
2022 test_AES_chain_armv8_all(void)
2024 struct crypto_testsuite_params *ts_params = &testsuite_params;
2027 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2028 ts_params->op_mpool,
2029 ts_params->session_mpool,
2030 ts_params->valid_devs[0],
2031 rte_cryptodev_driver_id_get(
2032 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2033 BLKCIPHER_AES_CHAIN_TYPE);
2035 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2037 return TEST_SUCCESS;
2041 test_AES_chain_mrvl_all(void)
2043 struct crypto_testsuite_params *ts_params = &testsuite_params;
2046 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2047 ts_params->op_mpool,
2048 ts_params->session_mpool,
2049 ts_params->valid_devs[0],
2050 rte_cryptodev_driver_id_get(
2051 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2052 BLKCIPHER_AES_CHAIN_TYPE);
2054 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2056 return TEST_SUCCESS;
2060 test_AES_cipheronly_mrvl_all(void)
2062 struct crypto_testsuite_params *ts_params = &testsuite_params;
2065 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2066 ts_params->op_mpool,
2067 ts_params->session_mpool,
2068 ts_params->valid_devs[0],
2069 rte_cryptodev_driver_id_get(
2070 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2071 BLKCIPHER_AES_CIPHERONLY_TYPE);
2073 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2075 return TEST_SUCCESS;
2079 test_authonly_mrvl_all(void)
2081 struct crypto_testsuite_params *ts_params = &testsuite_params;
2084 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2085 ts_params->op_mpool,
2086 ts_params->session_mpool,
2087 ts_params->valid_devs[0],
2088 rte_cryptodev_driver_id_get(
2089 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2090 BLKCIPHER_AUTHONLY_TYPE);
2092 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2094 return TEST_SUCCESS;
2098 test_3DES_chain_mrvl_all(void)
2100 struct crypto_testsuite_params *ts_params = &testsuite_params;
2103 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2104 ts_params->op_mpool,
2105 ts_params->session_mpool,
2106 ts_params->valid_devs[0],
2107 rte_cryptodev_driver_id_get(
2108 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2109 BLKCIPHER_3DES_CHAIN_TYPE);
2111 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2113 return TEST_SUCCESS;
2117 test_3DES_cipheronly_mrvl_all(void)
2119 struct crypto_testsuite_params *ts_params = &testsuite_params;
2122 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2123 ts_params->op_mpool,
2124 ts_params->session_mpool,
2125 ts_params->valid_devs[0],
2126 rte_cryptodev_driver_id_get(
2127 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2128 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2130 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2132 return TEST_SUCCESS;
2135 /* ***** SNOW 3G Tests ***** */
2137 create_wireless_algo_hash_session(uint8_t dev_id,
2138 const uint8_t *key, const uint8_t key_len,
2139 const uint8_t iv_len, const uint8_t auth_len,
2140 enum rte_crypto_auth_operation op,
2141 enum rte_crypto_auth_algorithm algo)
2143 uint8_t hash_key[key_len];
2145 struct crypto_testsuite_params *ts_params = &testsuite_params;
2146 struct crypto_unittest_params *ut_params = &unittest_params;
2148 memcpy(hash_key, key, key_len);
2150 debug_hexdump(stdout, "key:", key, key_len);
2152 /* Setup Authentication Parameters */
2153 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2154 ut_params->auth_xform.next = NULL;
2156 ut_params->auth_xform.auth.op = op;
2157 ut_params->auth_xform.auth.algo = algo;
2158 ut_params->auth_xform.auth.key.length = key_len;
2159 ut_params->auth_xform.auth.key.data = hash_key;
2160 ut_params->auth_xform.auth.digest_length = auth_len;
2161 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2162 ut_params->auth_xform.auth.iv.length = iv_len;
2163 ut_params->sess = rte_cryptodev_sym_session_create(
2164 ts_params->session_mpool);
2166 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2167 &ut_params->auth_xform, ts_params->session_mpool);
2168 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2173 create_wireless_algo_cipher_session(uint8_t dev_id,
2174 enum rte_crypto_cipher_operation op,
2175 enum rte_crypto_cipher_algorithm algo,
2176 const uint8_t *key, const uint8_t key_len,
2179 uint8_t cipher_key[key_len];
2181 struct crypto_testsuite_params *ts_params = &testsuite_params;
2182 struct crypto_unittest_params *ut_params = &unittest_params;
2184 memcpy(cipher_key, key, key_len);
2186 /* Setup Cipher Parameters */
2187 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2188 ut_params->cipher_xform.next = NULL;
2190 ut_params->cipher_xform.cipher.algo = algo;
2191 ut_params->cipher_xform.cipher.op = op;
2192 ut_params->cipher_xform.cipher.key.data = cipher_key;
2193 ut_params->cipher_xform.cipher.key.length = key_len;
2194 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2195 ut_params->cipher_xform.cipher.iv.length = iv_len;
2197 debug_hexdump(stdout, "key:", key, key_len);
2199 /* Create Crypto session */
2200 ut_params->sess = rte_cryptodev_sym_session_create(
2201 ts_params->session_mpool);
2203 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2204 &ut_params->cipher_xform, ts_params->session_mpool);
2205 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2210 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2211 unsigned int cipher_len,
2212 unsigned int cipher_offset)
2214 struct crypto_testsuite_params *ts_params = &testsuite_params;
2215 struct crypto_unittest_params *ut_params = &unittest_params;
2217 /* Generate Crypto op data structure */
2218 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2219 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2220 TEST_ASSERT_NOT_NULL(ut_params->op,
2221 "Failed to allocate pktmbuf offload");
2223 /* Set crypto operation data parameters */
2224 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2226 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2228 /* set crypto operation source mbuf */
2229 sym_op->m_src = ut_params->ibuf;
2232 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2234 sym_op->cipher.data.length = cipher_len;
2235 sym_op->cipher.data.offset = cipher_offset;
2240 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2241 unsigned int cipher_len,
2242 unsigned int cipher_offset)
2244 struct crypto_testsuite_params *ts_params = &testsuite_params;
2245 struct crypto_unittest_params *ut_params = &unittest_params;
2247 /* Generate Crypto op data structure */
2248 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2249 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2250 TEST_ASSERT_NOT_NULL(ut_params->op,
2251 "Failed to allocate pktmbuf offload");
2253 /* Set crypto operation data parameters */
2254 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2256 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2258 /* set crypto operation source mbuf */
2259 sym_op->m_src = ut_params->ibuf;
2260 sym_op->m_dst = ut_params->obuf;
2263 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2265 sym_op->cipher.data.length = cipher_len;
2266 sym_op->cipher.data.offset = cipher_offset;
2271 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2272 enum rte_crypto_cipher_operation cipher_op,
2273 enum rte_crypto_auth_operation auth_op,
2274 enum rte_crypto_auth_algorithm auth_algo,
2275 enum rte_crypto_cipher_algorithm cipher_algo,
2276 const uint8_t *key, uint8_t key_len,
2277 uint8_t auth_iv_len, uint8_t auth_len,
2278 uint8_t cipher_iv_len)
2281 uint8_t cipher_auth_key[key_len];
2283 struct crypto_testsuite_params *ts_params = &testsuite_params;
2284 struct crypto_unittest_params *ut_params = &unittest_params;
2286 memcpy(cipher_auth_key, key, key_len);
2288 /* Setup Authentication Parameters */
2289 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2290 ut_params->auth_xform.next = NULL;
2292 ut_params->auth_xform.auth.op = auth_op;
2293 ut_params->auth_xform.auth.algo = auth_algo;
2294 ut_params->auth_xform.auth.key.length = key_len;
2295 /* Hash key = cipher key */
2296 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2297 ut_params->auth_xform.auth.digest_length = auth_len;
2298 /* Auth IV will be after cipher IV */
2299 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2300 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2302 /* Setup Cipher Parameters */
2303 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2304 ut_params->cipher_xform.next = &ut_params->auth_xform;
2306 ut_params->cipher_xform.cipher.algo = cipher_algo;
2307 ut_params->cipher_xform.cipher.op = cipher_op;
2308 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2309 ut_params->cipher_xform.cipher.key.length = key_len;
2310 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2311 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2313 debug_hexdump(stdout, "key:", key, key_len);
2315 /* Create Crypto session*/
2316 ut_params->sess = rte_cryptodev_sym_session_create(
2317 ts_params->session_mpool);
2319 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2320 &ut_params->cipher_xform, ts_params->session_mpool);
2322 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2327 create_wireless_cipher_auth_session(uint8_t dev_id,
2328 enum rte_crypto_cipher_operation cipher_op,
2329 enum rte_crypto_auth_operation auth_op,
2330 enum rte_crypto_auth_algorithm auth_algo,
2331 enum rte_crypto_cipher_algorithm cipher_algo,
2332 const struct wireless_test_data *tdata)
2334 const uint8_t key_len = tdata->key.len;
2335 uint8_t cipher_auth_key[key_len];
2337 struct crypto_testsuite_params *ts_params = &testsuite_params;
2338 struct crypto_unittest_params *ut_params = &unittest_params;
2339 const uint8_t *key = tdata->key.data;
2340 const uint8_t auth_len = tdata->digest.len;
2341 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2342 uint8_t auth_iv_len = tdata->auth_iv.len;
2344 memcpy(cipher_auth_key, key, key_len);
2346 /* Setup Authentication Parameters */
2347 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2348 ut_params->auth_xform.next = NULL;
2350 ut_params->auth_xform.auth.op = auth_op;
2351 ut_params->auth_xform.auth.algo = auth_algo;
2352 ut_params->auth_xform.auth.key.length = key_len;
2353 /* Hash key = cipher key */
2354 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2355 ut_params->auth_xform.auth.digest_length = auth_len;
2356 /* Auth IV will be after cipher IV */
2357 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2358 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2360 /* Setup Cipher Parameters */
2361 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2362 ut_params->cipher_xform.next = &ut_params->auth_xform;
2364 ut_params->cipher_xform.cipher.algo = cipher_algo;
2365 ut_params->cipher_xform.cipher.op = cipher_op;
2366 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2367 ut_params->cipher_xform.cipher.key.length = key_len;
2368 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2369 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2372 debug_hexdump(stdout, "key:", key, key_len);
2374 /* Create Crypto session*/
2375 ut_params->sess = rte_cryptodev_sym_session_create(
2376 ts_params->session_mpool);
2378 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2379 &ut_params->cipher_xform, ts_params->session_mpool);
2381 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2386 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2387 const struct wireless_test_data *tdata)
2389 return create_wireless_cipher_auth_session(dev_id,
2390 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2391 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2392 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2396 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2397 enum rte_crypto_cipher_operation cipher_op,
2398 enum rte_crypto_auth_operation auth_op,
2399 enum rte_crypto_auth_algorithm auth_algo,
2400 enum rte_crypto_cipher_algorithm cipher_algo,
2401 const uint8_t *key, const uint8_t key_len,
2402 uint8_t auth_iv_len, uint8_t auth_len,
2403 uint8_t cipher_iv_len)
2405 uint8_t auth_cipher_key[key_len];
2407 struct crypto_testsuite_params *ts_params = &testsuite_params;
2408 struct crypto_unittest_params *ut_params = &unittest_params;
2410 memcpy(auth_cipher_key, key, key_len);
2412 /* Setup Authentication Parameters */
2413 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2414 ut_params->auth_xform.auth.op = auth_op;
2415 ut_params->auth_xform.next = &ut_params->cipher_xform;
2416 ut_params->auth_xform.auth.algo = auth_algo;
2417 ut_params->auth_xform.auth.key.length = key_len;
2418 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2419 ut_params->auth_xform.auth.digest_length = auth_len;
2420 /* Auth IV will be after cipher IV */
2421 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2422 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2424 /* Setup Cipher Parameters */
2425 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2426 ut_params->cipher_xform.next = NULL;
2427 ut_params->cipher_xform.cipher.algo = cipher_algo;
2428 ut_params->cipher_xform.cipher.op = cipher_op;
2429 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2430 ut_params->cipher_xform.cipher.key.length = key_len;
2431 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2432 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2434 debug_hexdump(stdout, "key:", key, key_len);
2436 /* Create Crypto session*/
2437 ut_params->sess = rte_cryptodev_sym_session_create(
2438 ts_params->session_mpool);
2440 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2441 &ut_params->auth_xform, ts_params->session_mpool);
2443 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2449 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2450 unsigned int auth_tag_len,
2451 const uint8_t *iv, unsigned int iv_len,
2452 unsigned int data_pad_len,
2453 enum rte_crypto_auth_operation op,
2454 unsigned int auth_len, unsigned int auth_offset)
2456 struct crypto_testsuite_params *ts_params = &testsuite_params;
2458 struct crypto_unittest_params *ut_params = &unittest_params;
2460 /* Generate Crypto op data structure */
2461 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2462 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2463 TEST_ASSERT_NOT_NULL(ut_params->op,
2464 "Failed to allocate pktmbuf offload");
2466 /* Set crypto operation data parameters */
2467 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2469 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2471 /* set crypto operation source mbuf */
2472 sym_op->m_src = ut_params->ibuf;
2475 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2478 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2479 ut_params->ibuf, auth_tag_len);
2481 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2482 "no room to append auth tag");
2483 ut_params->digest = sym_op->auth.digest.data;
2484 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2485 ut_params->ibuf, data_pad_len);
2486 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2487 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2489 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2491 debug_hexdump(stdout, "digest:",
2492 sym_op->auth.digest.data,
2495 sym_op->auth.data.length = auth_len;
2496 sym_op->auth.data.offset = auth_offset;
2502 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2503 enum rte_crypto_auth_operation op)
2505 struct crypto_testsuite_params *ts_params = &testsuite_params;
2506 struct crypto_unittest_params *ut_params = &unittest_params;
2508 const uint8_t *auth_tag = tdata->digest.data;
2509 const unsigned int auth_tag_len = tdata->digest.len;
2510 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2511 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2513 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2514 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2515 const uint8_t *auth_iv = tdata->auth_iv.data;
2516 const uint8_t auth_iv_len = tdata->auth_iv.len;
2517 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2518 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2520 /* Generate Crypto op data structure */
2521 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2522 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2523 TEST_ASSERT_NOT_NULL(ut_params->op,
2524 "Failed to allocate pktmbuf offload");
2525 /* Set crypto operation data parameters */
2526 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2528 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2530 /* set crypto operation source mbuf */
2531 sym_op->m_src = ut_params->ibuf;
2534 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2535 ut_params->ibuf, auth_tag_len);
2537 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2538 "no room to append auth tag");
2539 ut_params->digest = sym_op->auth.digest.data;
2540 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2541 ut_params->ibuf, data_pad_len);
2542 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2543 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2545 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2547 debug_hexdump(stdout, "digest:",
2548 sym_op->auth.digest.data,
2551 /* Copy cipher and auth IVs at the end of the crypto operation */
2552 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2554 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2555 iv_ptr += cipher_iv_len;
2556 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2558 sym_op->cipher.data.length = cipher_len;
2559 sym_op->cipher.data.offset = 0;
2560 sym_op->auth.data.length = auth_len;
2561 sym_op->auth.data.offset = 0;
2567 create_zuc_cipher_hash_generate_operation(
2568 const struct wireless_test_data *tdata)
2570 return create_wireless_cipher_hash_operation(tdata,
2571 RTE_CRYPTO_AUTH_OP_GENERATE);
2575 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2576 const unsigned auth_tag_len,
2577 const uint8_t *auth_iv, uint8_t auth_iv_len,
2578 unsigned data_pad_len,
2579 enum rte_crypto_auth_operation op,
2580 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2581 const unsigned cipher_len, const unsigned cipher_offset,
2582 const unsigned auth_len, const unsigned auth_offset)
2584 struct crypto_testsuite_params *ts_params = &testsuite_params;
2585 struct crypto_unittest_params *ut_params = &unittest_params;
2587 /* Generate Crypto op data structure */
2588 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2589 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2590 TEST_ASSERT_NOT_NULL(ut_params->op,
2591 "Failed to allocate pktmbuf offload");
2592 /* Set crypto operation data parameters */
2593 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2595 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2597 /* set crypto operation source mbuf */
2598 sym_op->m_src = ut_params->ibuf;
2601 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2602 ut_params->ibuf, auth_tag_len);
2604 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2605 "no room to append auth tag");
2606 ut_params->digest = sym_op->auth.digest.data;
2607 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2608 ut_params->ibuf, data_pad_len);
2609 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2610 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2612 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2614 debug_hexdump(stdout, "digest:",
2615 sym_op->auth.digest.data,
2618 /* Copy cipher and auth IVs at the end of the crypto operation */
2619 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2621 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2622 iv_ptr += cipher_iv_len;
2623 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2625 sym_op->cipher.data.length = cipher_len;
2626 sym_op->cipher.data.offset = cipher_offset;
2627 sym_op->auth.data.length = auth_len;
2628 sym_op->auth.data.offset = auth_offset;
2634 create_wireless_algo_auth_cipher_operation(unsigned int auth_tag_len,
2635 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2636 const uint8_t *auth_iv, uint8_t auth_iv_len,
2637 unsigned int data_pad_len,
2638 unsigned int cipher_len, unsigned int cipher_offset,
2639 unsigned int auth_len, unsigned int auth_offset)
2641 struct crypto_testsuite_params *ts_params = &testsuite_params;
2642 struct crypto_unittest_params *ut_params = &unittest_params;
2644 /* Generate Crypto op data structure */
2645 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2646 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2647 TEST_ASSERT_NOT_NULL(ut_params->op,
2648 "Failed to allocate pktmbuf offload");
2650 /* Set crypto operation data parameters */
2651 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2653 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2655 /* set crypto operation source mbuf */
2656 sym_op->m_src = ut_params->ibuf;
2659 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2660 ut_params->ibuf, auth_tag_len);
2662 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2663 "no room to append auth tag");
2665 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2666 ut_params->ibuf, data_pad_len);
2668 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2670 debug_hexdump(stdout, "digest:",
2671 sym_op->auth.digest.data,
2674 /* Copy cipher and auth IVs at the end of the crypto operation */
2675 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2677 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2678 iv_ptr += cipher_iv_len;
2679 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2681 sym_op->cipher.data.length = cipher_len;
2682 sym_op->cipher.data.offset = cipher_offset;
2684 sym_op->auth.data.length = auth_len;
2685 sym_op->auth.data.offset = auth_offset;
2691 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
2693 struct crypto_testsuite_params *ts_params = &testsuite_params;
2694 struct crypto_unittest_params *ut_params = &unittest_params;
2697 unsigned plaintext_pad_len;
2698 unsigned plaintext_len;
2701 /* Create SNOW 3G session */
2702 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2703 tdata->key.data, tdata->key.len,
2704 tdata->auth_iv.len, tdata->digest.len,
2705 RTE_CRYPTO_AUTH_OP_GENERATE,
2706 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2710 /* alloc mbuf and set payload */
2711 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2713 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2714 rte_pktmbuf_tailroom(ut_params->ibuf));
2716 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2717 /* Append data which is padded to a multiple of */
2718 /* the algorithms block size */
2719 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2720 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2722 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2724 /* Create SNOW 3G operation */
2725 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2726 tdata->auth_iv.data, tdata->auth_iv.len,
2727 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2728 tdata->validAuthLenInBits.len,
2733 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2735 ut_params->obuf = ut_params->op->sym->m_src;
2736 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2737 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2738 + plaintext_pad_len;
2741 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2744 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
2745 "SNOW 3G Generated auth tag not as expected");
2751 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
2753 struct crypto_testsuite_params *ts_params = &testsuite_params;
2754 struct crypto_unittest_params *ut_params = &unittest_params;
2757 unsigned plaintext_pad_len;
2758 unsigned plaintext_len;
2761 /* Create SNOW 3G session */
2762 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2763 tdata->key.data, tdata->key.len,
2764 tdata->auth_iv.len, tdata->digest.len,
2765 RTE_CRYPTO_AUTH_OP_VERIFY,
2766 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
2769 /* alloc mbuf and set payload */
2770 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2772 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2773 rte_pktmbuf_tailroom(ut_params->ibuf));
2775 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2776 /* Append data which is padded to a multiple of */
2777 /* the algorithms block size */
2778 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2779 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2781 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2783 /* Create SNOW 3G operation */
2784 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2786 tdata->auth_iv.data, tdata->auth_iv.len,
2788 RTE_CRYPTO_AUTH_OP_VERIFY,
2789 tdata->validAuthLenInBits.len,
2794 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2796 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2797 ut_params->obuf = ut_params->op->sym->m_src;
2798 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2799 + plaintext_pad_len;
2802 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2811 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
2813 struct crypto_testsuite_params *ts_params = &testsuite_params;
2814 struct crypto_unittest_params *ut_params = &unittest_params;
2817 unsigned plaintext_pad_len;
2818 unsigned plaintext_len;
2821 /* Create KASUMI session */
2822 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2823 tdata->key.data, tdata->key.len,
2824 0, tdata->digest.len,
2825 RTE_CRYPTO_AUTH_OP_GENERATE,
2826 RTE_CRYPTO_AUTH_KASUMI_F9);
2830 /* alloc mbuf and set payload */
2831 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2833 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2834 rte_pktmbuf_tailroom(ut_params->ibuf));
2836 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2837 /* Append data which is padded to a multiple of */
2838 /* the algorithms block size */
2839 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2840 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2842 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2844 /* Create KASUMI operation */
2845 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
2847 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
2848 tdata->plaintext.len,
2853 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2855 ut_params->obuf = ut_params->op->sym->m_src;
2856 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2857 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2858 + plaintext_pad_len;
2861 TEST_ASSERT_BUFFERS_ARE_EQUAL(
2864 DIGEST_BYTE_LENGTH_KASUMI_F9,
2865 "KASUMI Generated auth tag not as expected");
2871 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
2873 struct crypto_testsuite_params *ts_params = &testsuite_params;
2874 struct crypto_unittest_params *ut_params = &unittest_params;
2877 unsigned plaintext_pad_len;
2878 unsigned plaintext_len;
2881 /* Create KASUMI session */
2882 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
2883 tdata->key.data, tdata->key.len,
2884 0, tdata->digest.len,
2885 RTE_CRYPTO_AUTH_OP_VERIFY,
2886 RTE_CRYPTO_AUTH_KASUMI_F9);
2889 /* alloc mbuf and set payload */
2890 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
2892 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
2893 rte_pktmbuf_tailroom(ut_params->ibuf));
2895 plaintext_len = ceil_byte_length(tdata->plaintext.len);
2896 /* Append data which is padded to a multiple */
2897 /* of the algorithms block size */
2898 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
2899 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
2901 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
2903 /* Create KASUMI operation */
2904 retval = create_wireless_algo_hash_operation(tdata->digest.data,
2908 RTE_CRYPTO_AUTH_OP_VERIFY,
2909 tdata->plaintext.len,
2914 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
2916 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
2917 ut_params->obuf = ut_params->op->sym->m_src;
2918 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
2919 + plaintext_pad_len;
2922 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
2931 test_snow3g_hash_generate_test_case_1(void)
2933 return test_snow3g_authentication(&snow3g_hash_test_case_1);
2937 test_snow3g_hash_generate_test_case_2(void)
2939 return test_snow3g_authentication(&snow3g_hash_test_case_2);
2943 test_snow3g_hash_generate_test_case_3(void)
2945 return test_snow3g_authentication(&snow3g_hash_test_case_3);
2949 test_snow3g_hash_generate_test_case_4(void)
2951 return test_snow3g_authentication(&snow3g_hash_test_case_4);
2955 test_snow3g_hash_generate_test_case_5(void)
2957 return test_snow3g_authentication(&snow3g_hash_test_case_5);
2961 test_snow3g_hash_generate_test_case_6(void)
2963 return test_snow3g_authentication(&snow3g_hash_test_case_6);
2967 test_snow3g_hash_verify_test_case_1(void)
2969 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
2974 test_snow3g_hash_verify_test_case_2(void)
2976 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
2980 test_snow3g_hash_verify_test_case_3(void)
2982 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
2986 test_snow3g_hash_verify_test_case_4(void)
2988 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
2992 test_snow3g_hash_verify_test_case_5(void)
2994 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
2998 test_snow3g_hash_verify_test_case_6(void)
3000 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3004 test_kasumi_hash_generate_test_case_1(void)
3006 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3010 test_kasumi_hash_generate_test_case_2(void)
3012 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3016 test_kasumi_hash_generate_test_case_3(void)
3018 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3022 test_kasumi_hash_generate_test_case_4(void)
3024 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3028 test_kasumi_hash_generate_test_case_5(void)
3030 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3034 test_kasumi_hash_generate_test_case_6(void)
3036 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3040 test_kasumi_hash_verify_test_case_1(void)
3042 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3046 test_kasumi_hash_verify_test_case_2(void)
3048 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3052 test_kasumi_hash_verify_test_case_3(void)
3054 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3058 test_kasumi_hash_verify_test_case_4(void)
3060 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3064 test_kasumi_hash_verify_test_case_5(void)
3066 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3070 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3072 struct crypto_testsuite_params *ts_params = &testsuite_params;
3073 struct crypto_unittest_params *ut_params = &unittest_params;
3076 uint8_t *plaintext, *ciphertext;
3077 unsigned plaintext_pad_len;
3078 unsigned plaintext_len;
3080 /* Create KASUMI session */
3081 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3082 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3083 RTE_CRYPTO_CIPHER_KASUMI_F8,
3084 tdata->key.data, tdata->key.len,
3085 tdata->cipher_iv.len);
3089 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3091 /* Clear mbuf payload */
3092 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3093 rte_pktmbuf_tailroom(ut_params->ibuf));
3095 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3096 /* Append data which is padded to a multiple */
3097 /* of the algorithms block size */
3098 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3099 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3101 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3103 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3105 /* Create KASUMI operation */
3106 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3107 tdata->cipher_iv.len,
3108 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3109 tdata->validCipherOffsetInBits.len);
3113 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3115 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3117 ut_params->obuf = ut_params->op->sym->m_dst;
3118 if (ut_params->obuf)
3119 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3121 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3123 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3125 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3126 (tdata->validCipherOffsetInBits.len >> 3);
3128 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3130 reference_ciphertext,
3131 tdata->validCipherLenInBits.len,
3132 "KASUMI Ciphertext data not as expected");
3137 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3139 struct crypto_testsuite_params *ts_params = &testsuite_params;
3140 struct crypto_unittest_params *ut_params = &unittest_params;
3144 unsigned int plaintext_pad_len;
3145 unsigned int plaintext_len;
3147 uint8_t buffer[10000];
3148 const uint8_t *ciphertext;
3150 struct rte_cryptodev_info dev_info;
3152 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3153 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3154 printf("Device doesn't support scatter-gather. "
3159 /* Create KASUMI session */
3160 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3161 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3162 RTE_CRYPTO_CIPHER_KASUMI_F8,
3163 tdata->key.data, tdata->key.len,
3164 tdata->cipher_iv.len);
3168 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3171 /* Append data which is padded to a multiple */
3172 /* of the algorithms block size */
3173 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3175 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3176 plaintext_pad_len, 10, 0);
3178 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3180 /* Create KASUMI operation */
3181 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3182 tdata->cipher_iv.len,
3183 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3184 tdata->validCipherOffsetInBits.len);
3188 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3190 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3192 ut_params->obuf = ut_params->op->sym->m_dst;
3194 if (ut_params->obuf)
3195 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3196 plaintext_len, buffer);
3198 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3199 tdata->validCipherOffsetInBits.len >> 3,
3200 plaintext_len, buffer);
3203 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3205 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3206 (tdata->validCipherOffsetInBits.len >> 3);
3208 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3210 reference_ciphertext,
3211 tdata->validCipherLenInBits.len,
3212 "KASUMI Ciphertext data not as expected");
3217 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3219 struct crypto_testsuite_params *ts_params = &testsuite_params;
3220 struct crypto_unittest_params *ut_params = &unittest_params;
3223 uint8_t *plaintext, *ciphertext;
3224 unsigned plaintext_pad_len;
3225 unsigned plaintext_len;
3227 /* Create KASUMI session */
3228 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3229 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3230 RTE_CRYPTO_CIPHER_KASUMI_F8,
3231 tdata->key.data, tdata->key.len,
3232 tdata->cipher_iv.len);
3236 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3237 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3239 /* Clear mbuf payload */
3240 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3241 rte_pktmbuf_tailroom(ut_params->ibuf));
3243 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3244 /* Append data which is padded to a multiple */
3245 /* of the algorithms block size */
3246 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3247 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3249 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3250 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3252 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3254 /* Create KASUMI operation */
3255 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3256 tdata->cipher_iv.len,
3257 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3258 tdata->validCipherOffsetInBits.len);
3262 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3264 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3266 ut_params->obuf = ut_params->op->sym->m_dst;
3267 if (ut_params->obuf)
3268 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3270 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3272 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3274 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3275 (tdata->validCipherOffsetInBits.len >> 3);
3277 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3279 reference_ciphertext,
3280 tdata->validCipherLenInBits.len,
3281 "KASUMI Ciphertext data not as expected");
3286 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3288 struct crypto_testsuite_params *ts_params = &testsuite_params;
3289 struct crypto_unittest_params *ut_params = &unittest_params;
3292 unsigned int plaintext_pad_len;
3293 unsigned int plaintext_len;
3295 const uint8_t *ciphertext;
3296 uint8_t buffer[2048];
3298 struct rte_cryptodev_info dev_info;
3300 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3301 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3302 printf("Device doesn't support scatter-gather. "
3307 /* Create KASUMI session */
3308 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3309 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3310 RTE_CRYPTO_CIPHER_KASUMI_F8,
3311 tdata->key.data, tdata->key.len,
3312 tdata->cipher_iv.len);
3316 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3317 /* Append data which is padded to a multiple */
3318 /* of the algorithms block size */
3319 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3321 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3322 plaintext_pad_len, 10, 0);
3323 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3324 plaintext_pad_len, 3, 0);
3326 /* Append data which is padded to a multiple */
3327 /* of the algorithms block size */
3328 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3330 /* Create KASUMI operation */
3331 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3332 tdata->cipher_iv.len,
3333 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3334 tdata->validCipherOffsetInBits.len);
3338 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3340 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3342 ut_params->obuf = ut_params->op->sym->m_dst;
3343 if (ut_params->obuf)
3344 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3345 plaintext_pad_len, buffer);
3347 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3348 tdata->validCipherOffsetInBits.len >> 3,
3349 plaintext_pad_len, buffer);
3351 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3352 (tdata->validCipherOffsetInBits.len >> 3);
3354 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3356 reference_ciphertext,
3357 tdata->validCipherLenInBits.len,
3358 "KASUMI Ciphertext data not as expected");
3364 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3366 struct crypto_testsuite_params *ts_params = &testsuite_params;
3367 struct crypto_unittest_params *ut_params = &unittest_params;
3370 uint8_t *ciphertext, *plaintext;
3371 unsigned ciphertext_pad_len;
3372 unsigned ciphertext_len;
3374 /* Create KASUMI session */
3375 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3376 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3377 RTE_CRYPTO_CIPHER_KASUMI_F8,
3378 tdata->key.data, tdata->key.len,
3379 tdata->cipher_iv.len);
3383 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3384 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3386 /* Clear mbuf payload */
3387 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3388 rte_pktmbuf_tailroom(ut_params->ibuf));
3390 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3391 /* Append data which is padded to a multiple */
3392 /* of the algorithms block size */
3393 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3394 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3395 ciphertext_pad_len);
3396 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3397 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3399 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3401 /* Create KASUMI operation */
3402 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3403 tdata->cipher_iv.len,
3404 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3405 tdata->validCipherOffsetInBits.len);
3409 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3411 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3413 ut_params->obuf = ut_params->op->sym->m_dst;
3414 if (ut_params->obuf)
3415 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3417 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3419 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3421 const uint8_t *reference_plaintext = tdata->plaintext.data +
3422 (tdata->validCipherOffsetInBits.len >> 3);
3424 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3426 reference_plaintext,
3427 tdata->validCipherLenInBits.len,
3428 "KASUMI Plaintext data not as expected");
3433 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3435 struct crypto_testsuite_params *ts_params = &testsuite_params;
3436 struct crypto_unittest_params *ut_params = &unittest_params;
3439 uint8_t *ciphertext, *plaintext;
3440 unsigned ciphertext_pad_len;
3441 unsigned ciphertext_len;
3443 /* Create KASUMI session */
3444 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3445 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3446 RTE_CRYPTO_CIPHER_KASUMI_F8,
3447 tdata->key.data, tdata->key.len,
3448 tdata->cipher_iv.len);
3452 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3454 /* Clear mbuf payload */
3455 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3456 rte_pktmbuf_tailroom(ut_params->ibuf));
3458 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3459 /* Append data which is padded to a multiple */
3460 /* of the algorithms block size */
3461 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3462 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3463 ciphertext_pad_len);
3464 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3466 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3468 /* Create KASUMI operation */
3469 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3470 tdata->cipher_iv.len,
3471 tdata->ciphertext.len,
3472 tdata->validCipherOffsetInBits.len);
3476 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3478 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3480 ut_params->obuf = ut_params->op->sym->m_dst;
3481 if (ut_params->obuf)
3482 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3484 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3486 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3488 const uint8_t *reference_plaintext = tdata->plaintext.data +
3489 (tdata->validCipherOffsetInBits.len >> 3);
3491 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3493 reference_plaintext,
3494 tdata->validCipherLenInBits.len,
3495 "KASUMI Plaintext data not as expected");
3500 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3502 struct crypto_testsuite_params *ts_params = &testsuite_params;
3503 struct crypto_unittest_params *ut_params = &unittest_params;
3506 uint8_t *plaintext, *ciphertext;
3507 unsigned plaintext_pad_len;
3508 unsigned plaintext_len;
3510 /* Create SNOW 3G session */
3511 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3512 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3513 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3514 tdata->key.data, tdata->key.len,
3515 tdata->cipher_iv.len);
3519 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3521 /* Clear mbuf payload */
3522 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3523 rte_pktmbuf_tailroom(ut_params->ibuf));
3525 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3526 /* Append data which is padded to a multiple of */
3527 /* the algorithms block size */
3528 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3529 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3531 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3533 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3535 /* Create SNOW 3G operation */
3536 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3537 tdata->cipher_iv.len,
3538 tdata->validCipherLenInBits.len,
3543 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3545 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3547 ut_params->obuf = ut_params->op->sym->m_dst;
3548 if (ut_params->obuf)
3549 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3551 ciphertext = plaintext;
3553 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3556 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3558 tdata->ciphertext.data,
3559 tdata->validDataLenInBits.len,
3560 "SNOW 3G Ciphertext data not as expected");
3566 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
3568 struct crypto_testsuite_params *ts_params = &testsuite_params;
3569 struct crypto_unittest_params *ut_params = &unittest_params;
3570 uint8_t *plaintext, *ciphertext;
3573 unsigned plaintext_pad_len;
3574 unsigned plaintext_len;
3576 /* Create SNOW 3G session */
3577 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3578 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3579 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3580 tdata->key.data, tdata->key.len,
3581 tdata->cipher_iv.len);
3585 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3586 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3588 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3589 "Failed to allocate input buffer in mempool");
3590 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3591 "Failed to allocate output buffer in mempool");
3593 /* Clear mbuf payload */
3594 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3595 rte_pktmbuf_tailroom(ut_params->ibuf));
3597 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3598 /* Append data which is padded to a multiple of */
3599 /* the algorithms block size */
3600 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3601 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3603 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3604 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3606 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3608 /* Create SNOW 3G operation */
3609 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3610 tdata->cipher_iv.len,
3611 tdata->validCipherLenInBits.len,
3616 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3618 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3620 ut_params->obuf = ut_params->op->sym->m_dst;
3621 if (ut_params->obuf)
3622 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3624 ciphertext = plaintext;
3626 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3629 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3631 tdata->ciphertext.data,
3632 tdata->validDataLenInBits.len,
3633 "SNOW 3G Ciphertext data not as expected");
3638 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
3640 struct crypto_testsuite_params *ts_params = &testsuite_params;
3641 struct crypto_unittest_params *ut_params = &unittest_params;
3644 unsigned int plaintext_pad_len;
3645 unsigned int plaintext_len;
3646 uint8_t buffer[10000];
3647 const uint8_t *ciphertext;
3649 struct rte_cryptodev_info dev_info;
3651 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3652 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
3653 printf("Device doesn't support scatter-gather. "
3658 /* Create SNOW 3G session */
3659 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3660 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3661 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3662 tdata->key.data, tdata->key.len,
3663 tdata->cipher_iv.len);
3667 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3668 /* Append data which is padded to a multiple of */
3669 /* the algorithms block size */
3670 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3672 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3673 plaintext_pad_len, 10, 0);
3674 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3675 plaintext_pad_len, 3, 0);
3677 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3678 "Failed to allocate input buffer in mempool");
3679 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3680 "Failed to allocate output buffer in mempool");
3682 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3684 /* Create SNOW 3G operation */
3685 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3686 tdata->cipher_iv.len,
3687 tdata->validCipherLenInBits.len,
3692 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3694 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3696 ut_params->obuf = ut_params->op->sym->m_dst;
3697 if (ut_params->obuf)
3698 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3699 plaintext_len, buffer);
3701 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
3702 plaintext_len, buffer);
3704 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3707 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3709 tdata->ciphertext.data,
3710 tdata->validDataLenInBits.len,
3711 "SNOW 3G Ciphertext data not as expected");
3716 /* Shift right a buffer by "offset" bits, "offset" < 8 */
3718 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
3720 uint8_t curr_byte, prev_byte;
3721 uint32_t length_in_bytes = ceil_byte_length(length + offset);
3722 uint8_t lower_byte_mask = (1 << offset) - 1;
3725 prev_byte = buffer[0];
3726 buffer[0] >>= offset;
3728 for (i = 1; i < length_in_bytes; i++) {
3729 curr_byte = buffer[i];
3730 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
3731 (curr_byte >> offset);
3732 prev_byte = curr_byte;
3737 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
3739 struct crypto_testsuite_params *ts_params = &testsuite_params;
3740 struct crypto_unittest_params *ut_params = &unittest_params;
3741 uint8_t *plaintext, *ciphertext;
3743 uint32_t plaintext_len;
3744 uint32_t plaintext_pad_len;
3745 uint8_t extra_offset = 4;
3746 uint8_t *expected_ciphertext_shifted;
3748 /* Create SNOW 3G session */
3749 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3750 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3751 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3752 tdata->key.data, tdata->key.len,
3753 tdata->cipher_iv.len);
3757 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3758 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3760 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3761 "Failed to allocate input buffer in mempool");
3762 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3763 "Failed to allocate output buffer in mempool");
3765 /* Clear mbuf payload */
3766 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3767 rte_pktmbuf_tailroom(ut_params->ibuf));
3769 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
3771 * Append data which is padded to a
3772 * multiple of the algorithms block size
3774 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3776 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
3779 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3781 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
3782 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
3784 #ifdef RTE_APP_TEST_DEBUG
3785 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
3787 /* Create SNOW 3G operation */
3788 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3789 tdata->cipher_iv.len,
3790 tdata->validCipherLenInBits.len,
3795 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3797 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3799 ut_params->obuf = ut_params->op->sym->m_dst;
3800 if (ut_params->obuf)
3801 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3803 ciphertext = plaintext;
3805 #ifdef RTE_APP_TEST_DEBUG
3806 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3809 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
3811 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
3812 "failed to reserve memory for ciphertext shifted\n");
3814 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
3815 ceil_byte_length(tdata->ciphertext.len));
3816 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
3819 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
3821 expected_ciphertext_shifted,
3822 tdata->validDataLenInBits.len,
3824 "SNOW 3G Ciphertext data not as expected");
3828 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
3830 struct crypto_testsuite_params *ts_params = &testsuite_params;
3831 struct crypto_unittest_params *ut_params = &unittest_params;
3835 uint8_t *plaintext, *ciphertext;
3836 unsigned ciphertext_pad_len;
3837 unsigned ciphertext_len;
3839 /* Create SNOW 3G session */
3840 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3841 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3842 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3843 tdata->key.data, tdata->key.len,
3844 tdata->cipher_iv.len);
3848 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3850 /* Clear mbuf payload */
3851 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3852 rte_pktmbuf_tailroom(ut_params->ibuf));
3854 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3855 /* Append data which is padded to a multiple of */
3856 /* the algorithms block size */
3857 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3858 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3859 ciphertext_pad_len);
3860 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3862 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3864 /* Create SNOW 3G operation */
3865 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3866 tdata->cipher_iv.len,
3867 tdata->validCipherLenInBits.len,
3872 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3874 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3875 ut_params->obuf = ut_params->op->sym->m_dst;
3876 if (ut_params->obuf)
3877 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3879 plaintext = ciphertext;
3881 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3884 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3885 tdata->plaintext.data,
3886 tdata->validDataLenInBits.len,
3887 "SNOW 3G Plaintext data not as expected");
3891 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
3893 struct crypto_testsuite_params *ts_params = &testsuite_params;
3894 struct crypto_unittest_params *ut_params = &unittest_params;
3898 uint8_t *plaintext, *ciphertext;
3899 unsigned ciphertext_pad_len;
3900 unsigned ciphertext_len;
3902 /* Create SNOW 3G session */
3903 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3904 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3905 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3906 tdata->key.data, tdata->key.len,
3907 tdata->cipher_iv.len);
3911 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3912 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3914 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
3915 "Failed to allocate input buffer");
3916 TEST_ASSERT_NOT_NULL(ut_params->obuf,
3917 "Failed to allocate output buffer");
3919 /* Clear mbuf payload */
3920 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3921 rte_pktmbuf_tailroom(ut_params->ibuf));
3923 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
3924 rte_pktmbuf_tailroom(ut_params->obuf));
3926 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3927 /* Append data which is padded to a multiple of */
3928 /* the algorithms block size */
3929 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
3930 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3931 ciphertext_pad_len);
3932 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3933 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3935 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3937 /* Create SNOW 3G operation */
3938 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3939 tdata->cipher_iv.len,
3940 tdata->validCipherLenInBits.len,
3945 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3948 ut_params->obuf = ut_params->op->sym->m_dst;
3949 if (ut_params->obuf)
3950 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3952 plaintext = ciphertext;
3954 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3957 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
3958 tdata->plaintext.data,
3959 tdata->validDataLenInBits.len,
3960 "SNOW 3G Plaintext data not as expected");
3965 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
3967 struct crypto_testsuite_params *ts_params = &testsuite_params;
3968 struct crypto_unittest_params *ut_params = &unittest_params;
3972 uint8_t *plaintext, *ciphertext;
3973 unsigned int plaintext_pad_len;
3974 unsigned int plaintext_len;
3976 struct rte_cryptodev_sym_capability_idx cap_idx;
3978 /* Check if device supports ZUC EEA3 */
3979 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
3980 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
3982 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3986 /* Check if device supports ZUC EIA3 */
3987 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
3988 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
3990 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
3994 /* Create ZUC session */
3995 retval = create_zuc_cipher_auth_encrypt_generate_session(
3996 ts_params->valid_devs[0],
4000 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4002 /* clear mbuf payload */
4003 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4004 rte_pktmbuf_tailroom(ut_params->ibuf));
4006 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4007 /* Append data which is padded to a multiple of */
4008 /* the algorithms block size */
4009 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4010 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4012 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4014 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4016 /* Create ZUC operation */
4017 retval = create_zuc_cipher_hash_generate_operation(tdata);
4021 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4023 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4024 ut_params->obuf = ut_params->op->sym->m_src;
4025 if (ut_params->obuf)
4026 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4028 ciphertext = plaintext;
4030 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4032 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4034 tdata->ciphertext.data,
4035 tdata->validDataLenInBits.len,
4036 "ZUC Ciphertext data not as expected");
4038 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4039 + plaintext_pad_len;
4042 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4046 "ZUC Generated auth tag not as expected");
4051 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4053 struct crypto_testsuite_params *ts_params = &testsuite_params;
4054 struct crypto_unittest_params *ut_params = &unittest_params;
4058 uint8_t *plaintext, *ciphertext;
4059 unsigned plaintext_pad_len;
4060 unsigned plaintext_len;
4062 /* Create SNOW 3G session */
4063 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4064 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4065 RTE_CRYPTO_AUTH_OP_GENERATE,
4066 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4067 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4068 tdata->key.data, tdata->key.len,
4069 tdata->auth_iv.len, tdata->digest.len,
4070 tdata->cipher_iv.len);
4073 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4075 /* clear mbuf payload */
4076 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4077 rte_pktmbuf_tailroom(ut_params->ibuf));
4079 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4080 /* Append data which is padded to a multiple of */
4081 /* the algorithms block size */
4082 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4083 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4085 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4087 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4089 /* Create SNOW 3G operation */
4090 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4091 tdata->digest.len, tdata->auth_iv.data,
4093 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4094 tdata->cipher_iv.data, tdata->cipher_iv.len,
4095 tdata->validCipherLenInBits.len,
4097 tdata->validAuthLenInBits.len,
4103 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4105 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4106 ut_params->obuf = ut_params->op->sym->m_src;
4107 if (ut_params->obuf)
4108 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4110 ciphertext = plaintext;
4112 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4114 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4116 tdata->ciphertext.data,
4117 tdata->validDataLenInBits.len,
4118 "SNOW 3G Ciphertext data not as expected");
4120 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4121 + plaintext_pad_len;
4124 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4127 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4128 "SNOW 3G Generated auth tag not as expected");
4132 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata)
4134 struct crypto_testsuite_params *ts_params = &testsuite_params;
4135 struct crypto_unittest_params *ut_params = &unittest_params;
4139 uint8_t *plaintext, *ciphertext;
4140 unsigned plaintext_pad_len;
4141 unsigned plaintext_len;
4143 /* Create SNOW 3G session */
4144 retval = create_wireless_algo_auth_cipher_session(ts_params->valid_devs[0],
4145 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4146 RTE_CRYPTO_AUTH_OP_GENERATE,
4147 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4148 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4149 tdata->key.data, tdata->key.len,
4150 tdata->auth_iv.len, tdata->digest.len,
4151 tdata->cipher_iv.len);
4155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4157 /* clear mbuf payload */
4158 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4159 rte_pktmbuf_tailroom(ut_params->ibuf));
4161 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4162 /* Append data which is padded to a multiple of */
4163 /* the algorithms block size */
4164 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4165 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4167 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4169 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4171 /* Create SNOW 3G operation */
4172 retval = create_wireless_algo_auth_cipher_operation(
4174 tdata->cipher_iv.data, tdata->cipher_iv.len,
4175 tdata->auth_iv.data, tdata->auth_iv.len,
4177 tdata->validCipherLenInBits.len,
4179 tdata->validAuthLenInBits.len,
4185 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4188 ut_params->obuf = ut_params->op->sym->m_src;
4189 if (ut_params->obuf)
4190 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4192 ciphertext = plaintext;
4194 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4195 + plaintext_pad_len;
4196 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4199 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4201 tdata->ciphertext.data,
4202 tdata->validDataLenInBits.len,
4203 "SNOW 3G Ciphertext data not as expected");
4206 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4209 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4210 "SNOW 3G Generated auth tag not as expected");
4215 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata)
4217 struct crypto_testsuite_params *ts_params = &testsuite_params;
4218 struct crypto_unittest_params *ut_params = &unittest_params;
4222 uint8_t *plaintext, *ciphertext;
4223 unsigned plaintext_pad_len;
4224 unsigned plaintext_len;
4226 /* Create KASUMI session */
4227 retval = create_wireless_algo_auth_cipher_session(
4228 ts_params->valid_devs[0],
4229 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4230 RTE_CRYPTO_AUTH_OP_GENERATE,
4231 RTE_CRYPTO_AUTH_KASUMI_F9,
4232 RTE_CRYPTO_CIPHER_KASUMI_F8,
4233 tdata->key.data, tdata->key.len,
4234 0, tdata->digest.len,
4235 tdata->cipher_iv.len);
4238 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4240 /* clear mbuf payload */
4241 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4242 rte_pktmbuf_tailroom(ut_params->ibuf));
4244 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4245 /* Append data which is padded to a multiple of */
4246 /* the algorithms block size */
4247 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4248 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4250 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4252 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4254 /* Create KASUMI operation */
4255 retval = create_wireless_algo_auth_cipher_operation(tdata->digest.len,
4256 tdata->cipher_iv.data, tdata->cipher_iv.len,
4259 tdata->validCipherLenInBits.len,
4260 tdata->validCipherOffsetInBits.len,
4261 tdata->validAuthLenInBits.len,
4268 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4270 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4271 if (ut_params->op->sym->m_dst)
4272 ut_params->obuf = ut_params->op->sym->m_dst;
4274 ut_params->obuf = ut_params->op->sym->m_src;
4276 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4277 tdata->validCipherOffsetInBits.len >> 3);
4279 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4280 (tdata->validCipherOffsetInBits.len >> 3);
4282 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4284 reference_ciphertext,
4285 tdata->validCipherLenInBits.len,
4286 "KASUMI Ciphertext data not as expected");
4287 ut_params->digest = rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *)
4288 + plaintext_pad_len;
4291 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4294 DIGEST_BYTE_LENGTH_KASUMI_F9,
4295 "KASUMI Generated auth tag not as expected");
4300 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
4302 struct crypto_testsuite_params *ts_params = &testsuite_params;
4303 struct crypto_unittest_params *ut_params = &unittest_params;
4307 uint8_t *plaintext, *ciphertext;
4308 unsigned plaintext_pad_len;
4309 unsigned plaintext_len;
4311 /* Create KASUMI session */
4312 retval = create_wireless_algo_cipher_auth_session(
4313 ts_params->valid_devs[0],
4314 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4315 RTE_CRYPTO_AUTH_OP_GENERATE,
4316 RTE_CRYPTO_AUTH_KASUMI_F9,
4317 RTE_CRYPTO_CIPHER_KASUMI_F8,
4318 tdata->key.data, tdata->key.len,
4319 0, tdata->digest.len,
4320 tdata->cipher_iv.len);
4324 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4326 /* clear mbuf payload */
4327 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4328 rte_pktmbuf_tailroom(ut_params->ibuf));
4330 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4331 /* Append data which is padded to a multiple of */
4332 /* the algorithms block size */
4333 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4334 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4336 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4338 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4340 /* Create KASUMI operation */
4341 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4342 tdata->digest.len, NULL, 0,
4343 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4344 tdata->cipher_iv.data, tdata->cipher_iv.len,
4345 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
4346 tdata->validCipherOffsetInBits.len,
4347 tdata->validAuthLenInBits.len,
4353 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4355 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4357 if (ut_params->op->sym->m_dst)
4358 ut_params->obuf = ut_params->op->sym->m_dst;
4360 ut_params->obuf = ut_params->op->sym->m_src;
4362 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
4363 tdata->validCipherOffsetInBits.len >> 3);
4365 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4366 + plaintext_pad_len;
4368 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
4369 (tdata->validCipherOffsetInBits.len >> 3);
4371 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4373 reference_ciphertext,
4374 tdata->validCipherLenInBits.len,
4375 "KASUMI Ciphertext data not as expected");
4378 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4381 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4382 "KASUMI Generated auth tag not as expected");
4387 test_zuc_encryption(const struct wireless_test_data *tdata)
4389 struct crypto_testsuite_params *ts_params = &testsuite_params;
4390 struct crypto_unittest_params *ut_params = &unittest_params;
4393 uint8_t *plaintext, *ciphertext;
4394 unsigned plaintext_pad_len;
4395 unsigned plaintext_len;
4397 struct rte_cryptodev_sym_capability_idx cap_idx;
4399 /* Check if device supports ZUC EEA3 */
4400 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4401 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4403 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4407 /* Create ZUC session */
4408 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4409 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4410 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4411 tdata->key.data, tdata->key.len,
4412 tdata->cipher_iv.len);
4416 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4418 /* Clear mbuf payload */
4419 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4420 rte_pktmbuf_tailroom(ut_params->ibuf));
4422 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4423 /* Append data which is padded to a multiple */
4424 /* of the algorithms block size */
4425 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4426 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4428 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4430 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4432 /* Create ZUC operation */
4433 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4434 tdata->cipher_iv.len,
4435 tdata->plaintext.len,
4440 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4442 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4444 ut_params->obuf = ut_params->op->sym->m_dst;
4445 if (ut_params->obuf)
4446 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4448 ciphertext = plaintext;
4450 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4453 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4455 tdata->ciphertext.data,
4456 tdata->validCipherLenInBits.len,
4457 "ZUC Ciphertext data not as expected");
4462 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
4464 struct crypto_testsuite_params *ts_params = &testsuite_params;
4465 struct crypto_unittest_params *ut_params = &unittest_params;
4469 unsigned int plaintext_pad_len;
4470 unsigned int plaintext_len;
4471 const uint8_t *ciphertext;
4472 uint8_t ciphertext_buffer[2048];
4473 struct rte_cryptodev_info dev_info;
4475 struct rte_cryptodev_sym_capability_idx cap_idx;
4477 /* Check if device supports ZUC EEA3 */
4478 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4479 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4481 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4485 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4486 if (!(dev_info.feature_flags & RTE_CRYPTODEV_FF_MBUF_SCATTER_GATHER)) {
4487 printf("Device doesn't support scatter-gather. "
4492 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4494 /* Append data which is padded to a multiple */
4495 /* of the algorithms block size */
4496 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4498 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4499 plaintext_pad_len, 10, 0);
4501 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4502 tdata->plaintext.data);
4504 /* Create ZUC session */
4505 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4506 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4507 RTE_CRYPTO_CIPHER_ZUC_EEA3,
4508 tdata->key.data, tdata->key.len,
4509 tdata->cipher_iv.len);
4513 /* Clear mbuf payload */
4515 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4517 /* Create ZUC operation */
4518 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4519 tdata->cipher_iv.len, tdata->plaintext.len,
4524 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4526 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4528 ut_params->obuf = ut_params->op->sym->m_dst;
4529 if (ut_params->obuf)
4530 ciphertext = rte_pktmbuf_read(ut_params->obuf,
4531 0, plaintext_len, ciphertext_buffer);
4533 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
4534 0, plaintext_len, ciphertext_buffer);
4537 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4540 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4542 tdata->ciphertext.data,
4543 tdata->validCipherLenInBits.len,
4544 "ZUC Ciphertext data not as expected");
4550 test_zuc_authentication(const struct wireless_test_data *tdata)
4552 struct crypto_testsuite_params *ts_params = &testsuite_params;
4553 struct crypto_unittest_params *ut_params = &unittest_params;
4556 unsigned plaintext_pad_len;
4557 unsigned plaintext_len;
4560 struct rte_cryptodev_sym_capability_idx cap_idx;
4562 /* Check if device supports ZUC EIA3 */
4563 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4564 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4566 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4570 /* Create ZUC session */
4571 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
4572 tdata->key.data, tdata->key.len,
4573 tdata->auth_iv.len, tdata->digest.len,
4574 RTE_CRYPTO_AUTH_OP_GENERATE,
4575 RTE_CRYPTO_AUTH_ZUC_EIA3);
4579 /* alloc mbuf and set payload */
4580 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4582 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4583 rte_pktmbuf_tailroom(ut_params->ibuf));
4585 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4586 /* Append data which is padded to a multiple of */
4587 /* the algorithms block size */
4588 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
4589 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4591 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4593 /* Create ZUC operation */
4594 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
4595 tdata->auth_iv.data, tdata->auth_iv.len,
4596 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4597 tdata->validAuthLenInBits.len,
4602 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4604 ut_params->obuf = ut_params->op->sym->m_src;
4605 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4606 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4607 + plaintext_pad_len;
4610 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4613 DIGEST_BYTE_LENGTH_KASUMI_F9,
4614 "ZUC Generated auth tag not as expected");
4620 test_kasumi_encryption_test_case_1(void)
4622 return test_kasumi_encryption(&kasumi_test_case_1);
4626 test_kasumi_encryption_test_case_1_sgl(void)
4628 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
4632 test_kasumi_encryption_test_case_1_oop(void)
4634 return test_kasumi_encryption_oop(&kasumi_test_case_1);
4638 test_kasumi_encryption_test_case_1_oop_sgl(void)
4640 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
4644 test_kasumi_encryption_test_case_2(void)
4646 return test_kasumi_encryption(&kasumi_test_case_2);
4650 test_kasumi_encryption_test_case_3(void)
4652 return test_kasumi_encryption(&kasumi_test_case_3);
4656 test_kasumi_encryption_test_case_4(void)
4658 return test_kasumi_encryption(&kasumi_test_case_4);
4662 test_kasumi_encryption_test_case_5(void)
4664 return test_kasumi_encryption(&kasumi_test_case_5);
4668 test_kasumi_decryption_test_case_1(void)
4670 return test_kasumi_decryption(&kasumi_test_case_1);
4674 test_kasumi_decryption_test_case_1_oop(void)
4676 return test_kasumi_decryption_oop(&kasumi_test_case_1);
4680 test_kasumi_decryption_test_case_2(void)
4682 return test_kasumi_decryption(&kasumi_test_case_2);
4686 test_kasumi_decryption_test_case_3(void)
4688 return test_kasumi_decryption(&kasumi_test_case_3);
4692 test_kasumi_decryption_test_case_4(void)
4694 return test_kasumi_decryption(&kasumi_test_case_4);
4698 test_kasumi_decryption_test_case_5(void)
4700 return test_kasumi_decryption(&kasumi_test_case_5);
4703 test_snow3g_encryption_test_case_1(void)
4705 return test_snow3g_encryption(&snow3g_test_case_1);
4709 test_snow3g_encryption_test_case_1_oop(void)
4711 return test_snow3g_encryption_oop(&snow3g_test_case_1);
4715 test_snow3g_encryption_test_case_1_oop_sgl(void)
4717 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
4722 test_snow3g_encryption_test_case_1_offset_oop(void)
4724 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
4728 test_snow3g_encryption_test_case_2(void)
4730 return test_snow3g_encryption(&snow3g_test_case_2);
4734 test_snow3g_encryption_test_case_3(void)
4736 return test_snow3g_encryption(&snow3g_test_case_3);
4740 test_snow3g_encryption_test_case_4(void)
4742 return test_snow3g_encryption(&snow3g_test_case_4);
4746 test_snow3g_encryption_test_case_5(void)
4748 return test_snow3g_encryption(&snow3g_test_case_5);
4752 test_snow3g_decryption_test_case_1(void)
4754 return test_snow3g_decryption(&snow3g_test_case_1);
4758 test_snow3g_decryption_test_case_1_oop(void)
4760 return test_snow3g_decryption_oop(&snow3g_test_case_1);
4764 test_snow3g_decryption_test_case_2(void)
4766 return test_snow3g_decryption(&snow3g_test_case_2);
4770 test_snow3g_decryption_test_case_3(void)
4772 return test_snow3g_decryption(&snow3g_test_case_3);
4776 test_snow3g_decryption_test_case_4(void)
4778 return test_snow3g_decryption(&snow3g_test_case_4);
4782 test_snow3g_decryption_test_case_5(void)
4784 return test_snow3g_decryption(&snow3g_test_case_5);
4787 test_snow3g_cipher_auth_test_case_1(void)
4789 return test_snow3g_cipher_auth(&snow3g_test_case_3);
4793 test_snow3g_auth_cipher_test_case_1(void)
4795 return test_snow3g_auth_cipher(&snow3g_test_case_6);
4799 test_kasumi_auth_cipher_test_case_1(void)
4801 return test_kasumi_auth_cipher(&kasumi_test_case_3);
4805 test_kasumi_cipher_auth_test_case_1(void)
4807 return test_kasumi_cipher_auth(&kasumi_test_case_6);
4811 test_zuc_encryption_test_case_1(void)
4813 return test_zuc_encryption(&zuc_test_case_cipher_193b);
4817 test_zuc_encryption_test_case_2(void)
4819 return test_zuc_encryption(&zuc_test_case_cipher_800b);
4823 test_zuc_encryption_test_case_3(void)
4825 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
4829 test_zuc_encryption_test_case_4(void)
4831 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
4835 test_zuc_encryption_test_case_5(void)
4837 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
4841 test_zuc_encryption_test_case_6_sgl(void)
4843 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
4847 test_zuc_hash_generate_test_case_1(void)
4849 return test_zuc_authentication(&zuc_test_case_auth_1b);
4853 test_zuc_hash_generate_test_case_2(void)
4855 return test_zuc_authentication(&zuc_test_case_auth_90b);
4859 test_zuc_hash_generate_test_case_3(void)
4861 return test_zuc_authentication(&zuc_test_case_auth_577b);
4865 test_zuc_hash_generate_test_case_4(void)
4867 return test_zuc_authentication(&zuc_test_case_auth_2079b);
4871 test_zuc_hash_generate_test_case_5(void)
4873 return test_zuc_authentication(&zuc_test_auth_5670b);
4877 test_zuc_hash_generate_test_case_6(void)
4879 return test_zuc_authentication(&zuc_test_case_auth_128b);
4883 test_zuc_hash_generate_test_case_7(void)
4885 return test_zuc_authentication(&zuc_test_case_auth_2080b);
4889 test_zuc_hash_generate_test_case_8(void)
4891 return test_zuc_authentication(&zuc_test_case_auth_584b);
4895 test_zuc_cipher_auth_test_case_1(void)
4897 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
4901 test_zuc_cipher_auth_test_case_2(void)
4903 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
4907 test_3DES_chain_qat_all(void)
4909 struct crypto_testsuite_params *ts_params = &testsuite_params;
4912 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4913 ts_params->op_mpool,
4914 ts_params->session_mpool,
4915 ts_params->valid_devs[0],
4916 rte_cryptodev_driver_id_get(
4917 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4918 BLKCIPHER_3DES_CHAIN_TYPE);
4920 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4922 return TEST_SUCCESS;
4926 test_DES_cipheronly_qat_all(void)
4928 struct crypto_testsuite_params *ts_params = &testsuite_params;
4931 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4932 ts_params->op_mpool,
4933 ts_params->session_mpool,
4934 ts_params->valid_devs[0],
4935 rte_cryptodev_driver_id_get(
4936 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
4937 BLKCIPHER_DES_CIPHERONLY_TYPE);
4939 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4941 return TEST_SUCCESS;
4945 test_DES_cipheronly_openssl_all(void)
4947 struct crypto_testsuite_params *ts_params = &testsuite_params;
4950 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4951 ts_params->op_mpool,
4952 ts_params->session_mpool,
4953 ts_params->valid_devs[0],
4954 rte_cryptodev_driver_id_get(
4955 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4956 BLKCIPHER_DES_CIPHERONLY_TYPE);
4958 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4960 return TEST_SUCCESS;
4964 test_DES_docsis_openssl_all(void)
4966 struct crypto_testsuite_params *ts_params = &testsuite_params;
4969 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4970 ts_params->op_mpool,
4971 ts_params->session_mpool,
4972 ts_params->valid_devs[0],
4973 rte_cryptodev_driver_id_get(
4974 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
4975 BLKCIPHER_DES_DOCSIS_TYPE);
4977 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4979 return TEST_SUCCESS;
4983 test_DES_cipheronly_mb_all(void)
4985 struct crypto_testsuite_params *ts_params = &testsuite_params;
4988 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
4989 ts_params->op_mpool,
4990 ts_params->session_mpool,
4991 ts_params->valid_devs[0],
4992 rte_cryptodev_driver_id_get(
4993 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
4994 BLKCIPHER_DES_CIPHERONLY_TYPE);
4996 TEST_ASSERT_EQUAL(status, 0, "Test failed");
4998 return TEST_SUCCESS;
5002 test_DES_docsis_mb_all(void)
5004 struct crypto_testsuite_params *ts_params = &testsuite_params;
5007 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5008 ts_params->op_mpool,
5009 ts_params->session_mpool,
5010 ts_params->valid_devs[0],
5011 rte_cryptodev_driver_id_get(
5012 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
5013 BLKCIPHER_DES_DOCSIS_TYPE);
5015 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5017 return TEST_SUCCESS;
5021 test_3DES_chain_dpaa_sec_all(void)
5023 struct crypto_testsuite_params *ts_params = &testsuite_params;
5026 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5027 ts_params->op_mpool,
5028 ts_params->session_mpool,
5029 ts_params->valid_devs[0],
5030 rte_cryptodev_driver_id_get(
5031 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5032 BLKCIPHER_3DES_CHAIN_TYPE);
5034 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5036 return TEST_SUCCESS;
5040 test_3DES_cipheronly_dpaa_sec_all(void)
5042 struct crypto_testsuite_params *ts_params = &testsuite_params;
5045 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5046 ts_params->op_mpool,
5047 ts_params->session_mpool,
5048 ts_params->valid_devs[0],
5049 rte_cryptodev_driver_id_get(
5050 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
5051 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5053 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5055 return TEST_SUCCESS;
5059 test_3DES_chain_dpaa2_sec_all(void)
5061 struct crypto_testsuite_params *ts_params = &testsuite_params;
5064 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5065 ts_params->op_mpool,
5066 ts_params->session_mpool,
5067 ts_params->valid_devs[0],
5068 rte_cryptodev_driver_id_get(
5069 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5070 BLKCIPHER_3DES_CHAIN_TYPE);
5072 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5074 return TEST_SUCCESS;
5078 test_3DES_cipheronly_dpaa2_sec_all(void)
5080 struct crypto_testsuite_params *ts_params = &testsuite_params;
5083 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5084 ts_params->op_mpool,
5085 ts_params->session_mpool,
5086 ts_params->valid_devs[0],
5087 rte_cryptodev_driver_id_get(
5088 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
5089 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5091 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5093 return TEST_SUCCESS;
5097 test_3DES_chain_ccp_all(void)
5099 struct crypto_testsuite_params *ts_params = &testsuite_params;
5102 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5103 ts_params->op_mpool,
5104 ts_params->session_mpool,
5105 ts_params->valid_devs[0],
5106 rte_cryptodev_driver_id_get(
5107 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5108 BLKCIPHER_3DES_CHAIN_TYPE);
5110 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5112 return TEST_SUCCESS;
5116 test_3DES_cipheronly_ccp_all(void)
5118 struct crypto_testsuite_params *ts_params = &testsuite_params;
5121 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5122 ts_params->op_mpool,
5123 ts_params->session_mpool,
5124 ts_params->valid_devs[0],
5125 rte_cryptodev_driver_id_get(
5126 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
5127 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5129 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5131 return TEST_SUCCESS;
5135 test_3DES_cipheronly_qat_all(void)
5137 struct crypto_testsuite_params *ts_params = &testsuite_params;
5140 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5141 ts_params->op_mpool,
5142 ts_params->session_mpool,
5143 ts_params->valid_devs[0],
5144 rte_cryptodev_driver_id_get(
5145 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
5146 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5148 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5150 return TEST_SUCCESS;
5154 test_3DES_chain_openssl_all(void)
5156 struct crypto_testsuite_params *ts_params = &testsuite_params;
5159 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5160 ts_params->op_mpool,
5161 ts_params->session_mpool,
5162 ts_params->valid_devs[0],
5163 rte_cryptodev_driver_id_get(
5164 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5165 BLKCIPHER_3DES_CHAIN_TYPE);
5167 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5169 return TEST_SUCCESS;
5173 test_3DES_cipheronly_openssl_all(void)
5175 struct crypto_testsuite_params *ts_params = &testsuite_params;
5178 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
5179 ts_params->op_mpool,
5180 ts_params->session_mpool,
5181 ts_params->valid_devs[0],
5182 rte_cryptodev_driver_id_get(
5183 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
5184 BLKCIPHER_3DES_CIPHERONLY_TYPE);
5186 TEST_ASSERT_EQUAL(status, 0, "Test failed");
5188 return TEST_SUCCESS;
5191 /* ***** AEAD algorithm Tests ***** */
5194 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
5195 enum rte_crypto_aead_operation op,
5196 const uint8_t *key, const uint8_t key_len,
5197 const uint16_t aad_len, const uint8_t auth_len,
5200 uint8_t aead_key[key_len];
5202 struct crypto_testsuite_params *ts_params = &testsuite_params;
5203 struct crypto_unittest_params *ut_params = &unittest_params;
5205 memcpy(aead_key, key, key_len);
5207 /* Setup AEAD Parameters */
5208 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
5209 ut_params->aead_xform.next = NULL;
5210 ut_params->aead_xform.aead.algo = algo;
5211 ut_params->aead_xform.aead.op = op;
5212 ut_params->aead_xform.aead.key.data = aead_key;
5213 ut_params->aead_xform.aead.key.length = key_len;
5214 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
5215 ut_params->aead_xform.aead.iv.length = iv_len;
5216 ut_params->aead_xform.aead.digest_length = auth_len;
5217 ut_params->aead_xform.aead.aad_length = aad_len;
5219 debug_hexdump(stdout, "key:", key, key_len);
5221 /* Create Crypto session*/
5222 ut_params->sess = rte_cryptodev_sym_session_create(
5223 ts_params->session_mpool);
5225 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
5226 &ut_params->aead_xform, ts_params->session_mpool);
5228 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
5234 create_aead_xform(struct rte_crypto_op *op,
5235 enum rte_crypto_aead_algorithm algo,
5236 enum rte_crypto_aead_operation aead_op,
5237 uint8_t *key, const uint8_t key_len,
5238 const uint8_t aad_len, const uint8_t auth_len,
5241 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
5242 "failed to allocate space for crypto transform");
5244 struct rte_crypto_sym_op *sym_op = op->sym;
5246 /* Setup AEAD Parameters */
5247 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
5248 sym_op->xform->next = NULL;
5249 sym_op->xform->aead.algo = algo;
5250 sym_op->xform->aead.op = aead_op;
5251 sym_op->xform->aead.key.data = key;
5252 sym_op->xform->aead.key.length = key_len;
5253 sym_op->xform->aead.iv.offset = IV_OFFSET;
5254 sym_op->xform->aead.iv.length = iv_len;
5255 sym_op->xform->aead.digest_length = auth_len;
5256 sym_op->xform->aead.aad_length = aad_len;
5258 debug_hexdump(stdout, "key:", key, key_len);
5264 create_aead_operation(enum rte_crypto_aead_operation op,
5265 const struct aead_test_data *tdata)
5267 struct crypto_testsuite_params *ts_params = &testsuite_params;
5268 struct crypto_unittest_params *ut_params = &unittest_params;
5270 uint8_t *plaintext, *ciphertext;
5271 unsigned int aad_pad_len, plaintext_pad_len;
5273 /* Generate Crypto op data structure */
5274 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
5275 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
5276 TEST_ASSERT_NOT_NULL(ut_params->op,
5277 "Failed to allocate symmetric crypto operation struct");
5279 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
5281 /* Append aad data */
5282 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
5283 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
5284 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5286 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5287 "no room to append aad");
5289 sym_op->aead.aad.phys_addr =
5290 rte_pktmbuf_iova(ut_params->ibuf);
5291 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
5292 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
5293 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5296 /* Append IV at the end of the crypto operation*/
5297 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5298 uint8_t *, IV_OFFSET);
5300 /* Copy IV 1 byte after the IV pointer, according to the API */
5301 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
5302 debug_hexdump(stdout, "iv:", iv_ptr,
5305 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
5306 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5308 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
5309 "no room to append aad");
5311 sym_op->aead.aad.phys_addr =
5312 rte_pktmbuf_iova(ut_params->ibuf);
5313 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
5314 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
5317 /* Append IV at the end of the crypto operation*/
5318 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
5319 uint8_t *, IV_OFFSET);
5321 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
5322 debug_hexdump(stdout, "iv:", iv_ptr,
5326 /* Append plaintext/ciphertext */
5327 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5328 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5329 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5331 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
5333 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
5334 debug_hexdump(stdout, "plaintext:", plaintext,
5335 tdata->plaintext.len);
5337 if (ut_params->obuf) {
5338 ciphertext = (uint8_t *)rte_pktmbuf_append(
5340 plaintext_pad_len + aad_pad_len);
5341 TEST_ASSERT_NOT_NULL(ciphertext,
5342 "no room to append ciphertext");
5344 memset(ciphertext + aad_pad_len, 0,
5345 tdata->ciphertext.len);
5348 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
5349 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5351 TEST_ASSERT_NOT_NULL(ciphertext,
5352 "no room to append ciphertext");
5354 memcpy(ciphertext, tdata->ciphertext.data,
5355 tdata->ciphertext.len);
5356 debug_hexdump(stdout, "ciphertext:", ciphertext,
5357 tdata->ciphertext.len);
5359 if (ut_params->obuf) {
5360 plaintext = (uint8_t *)rte_pktmbuf_append(
5362 plaintext_pad_len + aad_pad_len);
5363 TEST_ASSERT_NOT_NULL(plaintext,
5364 "no room to append plaintext");
5366 memset(plaintext + aad_pad_len, 0,
5367 tdata->plaintext.len);
5371 /* Append digest data */
5372 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
5373 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5374 ut_params->obuf ? ut_params->obuf :
5376 tdata->auth_tag.len);
5377 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5378 "no room to append digest");
5379 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
5380 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5381 ut_params->obuf ? ut_params->obuf :
5386 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
5387 ut_params->ibuf, tdata->auth_tag.len);
5388 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
5389 "no room to append digest");
5390 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
5392 plaintext_pad_len + aad_pad_len);
5394 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
5395 tdata->auth_tag.len);
5396 debug_hexdump(stdout, "digest:",
5397 sym_op->aead.digest.data,
5398 tdata->auth_tag.len);
5401 sym_op->aead.data.length = tdata->plaintext.len;
5402 sym_op->aead.data.offset = aad_pad_len;
5408 test_authenticated_encryption(const struct aead_test_data *tdata)
5410 struct crypto_testsuite_params *ts_params = &testsuite_params;
5411 struct crypto_unittest_params *ut_params = &unittest_params;
5414 uint8_t *ciphertext, *auth_tag;
5415 uint16_t plaintext_pad_len;
5418 /* Create AEAD session */
5419 retval = create_aead_session(ts_params->valid_devs[0],
5421 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5422 tdata->key.data, tdata->key.len,
5423 tdata->aad.len, tdata->auth_tag.len,
5428 if (tdata->aad.len > MBUF_SIZE) {
5429 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5430 /* Populate full size of add data */
5431 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5432 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5434 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5436 /* clear mbuf payload */
5437 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5438 rte_pktmbuf_tailroom(ut_params->ibuf));
5440 /* Create AEAD operation */
5441 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5445 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5447 ut_params->op->sym->m_src = ut_params->ibuf;
5449 /* Process crypto operation */
5450 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5451 ut_params->op), "failed to process sym crypto op");
5453 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5454 "crypto op processing failed");
5456 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5458 if (ut_params->op->sym->m_dst) {
5459 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5461 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
5462 uint8_t *, plaintext_pad_len);
5464 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5466 ut_params->op->sym->cipher.data.offset);
5467 auth_tag = ciphertext + plaintext_pad_len;
5470 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5471 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5474 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5476 tdata->ciphertext.data,
5477 tdata->ciphertext.len,
5478 "Ciphertext data not as expected");
5480 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5482 tdata->auth_tag.data,
5483 tdata->auth_tag.len,
5484 "Generated auth tag not as expected");
5491 test_AES_GCM_authenticated_encryption_test_case_1(void)
5493 return test_authenticated_encryption(&gcm_test_case_1);
5497 test_AES_GCM_authenticated_encryption_test_case_2(void)
5499 return test_authenticated_encryption(&gcm_test_case_2);
5503 test_AES_GCM_authenticated_encryption_test_case_3(void)
5505 return test_authenticated_encryption(&gcm_test_case_3);
5509 test_AES_GCM_authenticated_encryption_test_case_4(void)
5511 return test_authenticated_encryption(&gcm_test_case_4);
5515 test_AES_GCM_authenticated_encryption_test_case_5(void)
5517 return test_authenticated_encryption(&gcm_test_case_5);
5521 test_AES_GCM_authenticated_encryption_test_case_6(void)
5523 return test_authenticated_encryption(&gcm_test_case_6);
5527 test_AES_GCM_authenticated_encryption_test_case_7(void)
5529 return test_authenticated_encryption(&gcm_test_case_7);
5533 test_AES_GCM_auth_encryption_test_case_192_1(void)
5535 return test_authenticated_encryption(&gcm_test_case_192_1);
5539 test_AES_GCM_auth_encryption_test_case_192_2(void)
5541 return test_authenticated_encryption(&gcm_test_case_192_2);
5545 test_AES_GCM_auth_encryption_test_case_192_3(void)
5547 return test_authenticated_encryption(&gcm_test_case_192_3);
5551 test_AES_GCM_auth_encryption_test_case_192_4(void)
5553 return test_authenticated_encryption(&gcm_test_case_192_4);
5557 test_AES_GCM_auth_encryption_test_case_192_5(void)
5559 return test_authenticated_encryption(&gcm_test_case_192_5);
5563 test_AES_GCM_auth_encryption_test_case_192_6(void)
5565 return test_authenticated_encryption(&gcm_test_case_192_6);
5569 test_AES_GCM_auth_encryption_test_case_192_7(void)
5571 return test_authenticated_encryption(&gcm_test_case_192_7);
5575 test_AES_GCM_auth_encryption_test_case_256_1(void)
5577 return test_authenticated_encryption(&gcm_test_case_256_1);
5581 test_AES_GCM_auth_encryption_test_case_256_2(void)
5583 return test_authenticated_encryption(&gcm_test_case_256_2);
5587 test_AES_GCM_auth_encryption_test_case_256_3(void)
5589 return test_authenticated_encryption(&gcm_test_case_256_3);
5593 test_AES_GCM_auth_encryption_test_case_256_4(void)
5595 return test_authenticated_encryption(&gcm_test_case_256_4);
5599 test_AES_GCM_auth_encryption_test_case_256_5(void)
5601 return test_authenticated_encryption(&gcm_test_case_256_5);
5605 test_AES_GCM_auth_encryption_test_case_256_6(void)
5607 return test_authenticated_encryption(&gcm_test_case_256_6);
5611 test_AES_GCM_auth_encryption_test_case_256_7(void)
5613 return test_authenticated_encryption(&gcm_test_case_256_7);
5617 test_AES_GCM_auth_encryption_test_case_aad_1(void)
5619 return test_authenticated_encryption(&gcm_test_case_aad_1);
5623 test_AES_GCM_auth_encryption_test_case_aad_2(void)
5625 return test_authenticated_encryption(&gcm_test_case_aad_2);
5629 test_authenticated_decryption(const struct aead_test_data *tdata)
5631 struct crypto_testsuite_params *ts_params = &testsuite_params;
5632 struct crypto_unittest_params *ut_params = &unittest_params;
5638 /* Create AEAD session */
5639 retval = create_aead_session(ts_params->valid_devs[0],
5641 RTE_CRYPTO_AEAD_OP_DECRYPT,
5642 tdata->key.data, tdata->key.len,
5643 tdata->aad.len, tdata->auth_tag.len,
5648 /* alloc mbuf and set payload */
5649 if (tdata->aad.len > MBUF_SIZE) {
5650 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
5651 /* Populate full size of add data */
5652 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
5653 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
5655 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5657 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5658 rte_pktmbuf_tailroom(ut_params->ibuf));
5660 /* Create AEAD operation */
5661 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5665 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5667 ut_params->op->sym->m_src = ut_params->ibuf;
5669 /* Process crypto operation */
5670 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5671 ut_params->op), "failed to process sym crypto op");
5673 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5674 "crypto op processing failed");
5676 if (ut_params->op->sym->m_dst)
5677 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
5680 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
5682 ut_params->op->sym->cipher.data.offset);
5684 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5687 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5689 tdata->plaintext.data,
5690 tdata->plaintext.len,
5691 "Plaintext data not as expected");
5693 TEST_ASSERT_EQUAL(ut_params->op->status,
5694 RTE_CRYPTO_OP_STATUS_SUCCESS,
5695 "Authentication failed");
5700 test_AES_GCM_authenticated_decryption_test_case_1(void)
5702 return test_authenticated_decryption(&gcm_test_case_1);
5706 test_AES_GCM_authenticated_decryption_test_case_2(void)
5708 return test_authenticated_decryption(&gcm_test_case_2);
5712 test_AES_GCM_authenticated_decryption_test_case_3(void)
5714 return test_authenticated_decryption(&gcm_test_case_3);
5718 test_AES_GCM_authenticated_decryption_test_case_4(void)
5720 return test_authenticated_decryption(&gcm_test_case_4);
5724 test_AES_GCM_authenticated_decryption_test_case_5(void)
5726 return test_authenticated_decryption(&gcm_test_case_5);
5730 test_AES_GCM_authenticated_decryption_test_case_6(void)
5732 return test_authenticated_decryption(&gcm_test_case_6);
5736 test_AES_GCM_authenticated_decryption_test_case_7(void)
5738 return test_authenticated_decryption(&gcm_test_case_7);
5742 test_AES_GCM_auth_decryption_test_case_192_1(void)
5744 return test_authenticated_decryption(&gcm_test_case_192_1);
5748 test_AES_GCM_auth_decryption_test_case_192_2(void)
5750 return test_authenticated_decryption(&gcm_test_case_192_2);
5754 test_AES_GCM_auth_decryption_test_case_192_3(void)
5756 return test_authenticated_decryption(&gcm_test_case_192_3);
5760 test_AES_GCM_auth_decryption_test_case_192_4(void)
5762 return test_authenticated_decryption(&gcm_test_case_192_4);
5766 test_AES_GCM_auth_decryption_test_case_192_5(void)
5768 return test_authenticated_decryption(&gcm_test_case_192_5);
5772 test_AES_GCM_auth_decryption_test_case_192_6(void)
5774 return test_authenticated_decryption(&gcm_test_case_192_6);
5778 test_AES_GCM_auth_decryption_test_case_192_7(void)
5780 return test_authenticated_decryption(&gcm_test_case_192_7);
5784 test_AES_GCM_auth_decryption_test_case_256_1(void)
5786 return test_authenticated_decryption(&gcm_test_case_256_1);
5790 test_AES_GCM_auth_decryption_test_case_256_2(void)
5792 return test_authenticated_decryption(&gcm_test_case_256_2);
5796 test_AES_GCM_auth_decryption_test_case_256_3(void)
5798 return test_authenticated_decryption(&gcm_test_case_256_3);
5802 test_AES_GCM_auth_decryption_test_case_256_4(void)
5804 return test_authenticated_decryption(&gcm_test_case_256_4);
5808 test_AES_GCM_auth_decryption_test_case_256_5(void)
5810 return test_authenticated_decryption(&gcm_test_case_256_5);
5814 test_AES_GCM_auth_decryption_test_case_256_6(void)
5816 return test_authenticated_decryption(&gcm_test_case_256_6);
5820 test_AES_GCM_auth_decryption_test_case_256_7(void)
5822 return test_authenticated_decryption(&gcm_test_case_256_7);
5826 test_AES_GCM_auth_decryption_test_case_aad_1(void)
5828 return test_authenticated_decryption(&gcm_test_case_aad_1);
5832 test_AES_GCM_auth_decryption_test_case_aad_2(void)
5834 return test_authenticated_decryption(&gcm_test_case_aad_2);
5838 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
5840 struct crypto_testsuite_params *ts_params = &testsuite_params;
5841 struct crypto_unittest_params *ut_params = &unittest_params;
5844 uint8_t *ciphertext, *auth_tag;
5845 uint16_t plaintext_pad_len;
5847 /* Create AEAD session */
5848 retval = create_aead_session(ts_params->valid_devs[0],
5850 RTE_CRYPTO_AEAD_OP_ENCRYPT,
5851 tdata->key.data, tdata->key.len,
5852 tdata->aad.len, tdata->auth_tag.len,
5857 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5858 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5860 /* clear mbuf payload */
5861 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5862 rte_pktmbuf_tailroom(ut_params->ibuf));
5863 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5864 rte_pktmbuf_tailroom(ut_params->obuf));
5866 /* Create AEAD operation */
5867 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
5871 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5873 ut_params->op->sym->m_src = ut_params->ibuf;
5874 ut_params->op->sym->m_dst = ut_params->obuf;
5876 /* Process crypto operation */
5877 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5878 ut_params->op), "failed to process sym crypto op");
5880 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5881 "crypto op processing failed");
5883 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
5885 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5886 ut_params->op->sym->cipher.data.offset);
5887 auth_tag = ciphertext + plaintext_pad_len;
5889 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
5890 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
5893 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5895 tdata->ciphertext.data,
5896 tdata->ciphertext.len,
5897 "Ciphertext data not as expected");
5899 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5901 tdata->auth_tag.data,
5902 tdata->auth_tag.len,
5903 "Generated auth tag not as expected");
5910 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
5912 return test_authenticated_encryption_oop(&gcm_test_case_5);
5916 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
5918 struct crypto_testsuite_params *ts_params = &testsuite_params;
5919 struct crypto_unittest_params *ut_params = &unittest_params;
5924 /* Create AEAD session */
5925 retval = create_aead_session(ts_params->valid_devs[0],
5927 RTE_CRYPTO_AEAD_OP_DECRYPT,
5928 tdata->key.data, tdata->key.len,
5929 tdata->aad.len, tdata->auth_tag.len,
5934 /* alloc mbuf and set payload */
5935 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5936 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5938 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5939 rte_pktmbuf_tailroom(ut_params->ibuf));
5940 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5941 rte_pktmbuf_tailroom(ut_params->obuf));
5943 /* Create AEAD operation */
5944 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
5948 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
5950 ut_params->op->sym->m_src = ut_params->ibuf;
5951 ut_params->op->sym->m_dst = ut_params->obuf;
5953 /* Process crypto operation */
5954 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
5955 ut_params->op), "failed to process sym crypto op");
5957 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
5958 "crypto op processing failed");
5960 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5961 ut_params->op->sym->cipher.data.offset);
5963 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
5966 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5968 tdata->plaintext.data,
5969 tdata->plaintext.len,
5970 "Plaintext data not as expected");
5972 TEST_ASSERT_EQUAL(ut_params->op->status,
5973 RTE_CRYPTO_OP_STATUS_SUCCESS,
5974 "Authentication failed");
5979 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
5981 return test_authenticated_decryption_oop(&gcm_test_case_5);
5985 test_authenticated_encryption_sessionless(
5986 const struct aead_test_data *tdata)
5988 struct crypto_testsuite_params *ts_params = &testsuite_params;
5989 struct crypto_unittest_params *ut_params = &unittest_params;
5992 uint8_t *ciphertext, *auth_tag;
5993 uint16_t plaintext_pad_len;
5994 uint8_t key[tdata->key.len + 1];
5996 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5998 /* clear mbuf payload */
5999 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6000 rte_pktmbuf_tailroom(ut_params->ibuf));
6002 /* Create AEAD operation */
6003 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
6007 /* Create GCM xform */
6008 memcpy(key, tdata->key.data, tdata->key.len);
6009 retval = create_aead_xform(ut_params->op,
6011 RTE_CRYPTO_AEAD_OP_ENCRYPT,
6012 key, tdata->key.len,
6013 tdata->aad.len, tdata->auth_tag.len,
6018 ut_params->op->sym->m_src = ut_params->ibuf;
6020 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6021 RTE_CRYPTO_OP_SESSIONLESS,
6022 "crypto op session type not sessionless");
6024 /* Process crypto operation */
6025 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6026 ut_params->op), "failed to process sym crypto op");
6028 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6030 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6031 "crypto op status not success");
6033 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
6035 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6036 ut_params->op->sym->cipher.data.offset);
6037 auth_tag = ciphertext + plaintext_pad_len;
6039 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
6040 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
6043 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6045 tdata->ciphertext.data,
6046 tdata->ciphertext.len,
6047 "Ciphertext data not as expected");
6049 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6051 tdata->auth_tag.data,
6052 tdata->auth_tag.len,
6053 "Generated auth tag not as expected");
6060 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
6062 return test_authenticated_encryption_sessionless(
6067 test_authenticated_decryption_sessionless(
6068 const struct aead_test_data *tdata)
6070 struct crypto_testsuite_params *ts_params = &testsuite_params;
6071 struct crypto_unittest_params *ut_params = &unittest_params;
6075 uint8_t key[tdata->key.len + 1];
6077 /* alloc mbuf and set payload */
6078 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6080 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6081 rte_pktmbuf_tailroom(ut_params->ibuf));
6083 /* Create AEAD operation */
6084 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
6088 /* Create AEAD xform */
6089 memcpy(key, tdata->key.data, tdata->key.len);
6090 retval = create_aead_xform(ut_params->op,
6092 RTE_CRYPTO_AEAD_OP_DECRYPT,
6093 key, tdata->key.len,
6094 tdata->aad.len, tdata->auth_tag.len,
6099 ut_params->op->sym->m_src = ut_params->ibuf;
6101 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
6102 RTE_CRYPTO_OP_SESSIONLESS,
6103 "crypto op session type not sessionless");
6105 /* Process crypto operation */
6106 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6107 ut_params->op), "failed to process sym crypto op");
6109 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
6111 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6112 "crypto op status not success");
6114 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6115 ut_params->op->sym->cipher.data.offset);
6117 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
6120 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6122 tdata->plaintext.data,
6123 tdata->plaintext.len,
6124 "Plaintext data not as expected");
6126 TEST_ASSERT_EQUAL(ut_params->op->status,
6127 RTE_CRYPTO_OP_STATUS_SUCCESS,
6128 "Authentication failed");
6133 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
6135 return test_authenticated_decryption_sessionless(
6140 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
6142 return test_authenticated_encryption(&ccm_test_case_128_1);
6146 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
6148 return test_authenticated_encryption(&ccm_test_case_128_2);
6152 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
6154 return test_authenticated_encryption(&ccm_test_case_128_3);
6158 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
6160 return test_authenticated_decryption(&ccm_test_case_128_1);
6164 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
6166 return test_authenticated_decryption(&ccm_test_case_128_2);
6170 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
6172 return test_authenticated_decryption(&ccm_test_case_128_3);
6176 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
6178 return test_authenticated_encryption(&ccm_test_case_192_1);
6182 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
6184 return test_authenticated_encryption(&ccm_test_case_192_2);
6188 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
6190 return test_authenticated_encryption(&ccm_test_case_192_3);
6194 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
6196 return test_authenticated_decryption(&ccm_test_case_192_1);
6200 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
6202 return test_authenticated_decryption(&ccm_test_case_192_2);
6206 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
6208 return test_authenticated_decryption(&ccm_test_case_192_3);
6212 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
6214 return test_authenticated_encryption(&ccm_test_case_256_1);
6218 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
6220 return test_authenticated_encryption(&ccm_test_case_256_2);
6224 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
6226 return test_authenticated_encryption(&ccm_test_case_256_3);
6230 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
6232 return test_authenticated_decryption(&ccm_test_case_256_1);
6236 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
6238 return test_authenticated_decryption(&ccm_test_case_256_2);
6242 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
6244 return test_authenticated_decryption(&ccm_test_case_256_3);
6250 struct crypto_testsuite_params *ts_params = &testsuite_params;
6251 struct rte_cryptodev_stats stats;
6252 struct rte_cryptodev *dev;
6253 cryptodev_stats_get_t temp_pfn;
6255 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6256 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
6257 &stats) == -ENODEV),
6258 "rte_cryptodev_stats_get invalid dev failed");
6259 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
6260 "rte_cryptodev_stats_get invalid Param failed");
6261 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
6262 temp_pfn = dev->dev_ops->stats_get;
6263 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
6264 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
6266 "rte_cryptodev_stats_get invalid Param failed");
6267 dev->dev_ops->stats_get = temp_pfn;
6269 /* Test expected values */
6271 test_AES_CBC_HMAC_SHA1_encrypt_digest();
6273 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6275 "rte_cryptodev_stats_get failed");
6276 TEST_ASSERT((stats.enqueued_count == 1),
6277 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6278 TEST_ASSERT((stats.dequeued_count == 1),
6279 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6280 TEST_ASSERT((stats.enqueue_err_count == 0),
6281 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6282 TEST_ASSERT((stats.dequeue_err_count == 0),
6283 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6285 /* invalid device but should ignore and not reset device stats*/
6286 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
6287 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6289 "rte_cryptodev_stats_get failed");
6290 TEST_ASSERT((stats.enqueued_count == 1),
6291 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6293 /* check that a valid reset clears stats */
6294 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
6295 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
6297 "rte_cryptodev_stats_get failed");
6298 TEST_ASSERT((stats.enqueued_count == 0),
6299 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6300 TEST_ASSERT((stats.dequeued_count == 0),
6301 "rte_cryptodev_stats_get returned unexpected enqueued stat");
6303 return TEST_SUCCESS;
6306 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
6307 struct crypto_unittest_params *ut_params,
6308 enum rte_crypto_auth_operation op,
6309 const struct HMAC_MD5_vector *test_case)
6313 memcpy(key, test_case->key.data, test_case->key.len);
6315 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6316 ut_params->auth_xform.next = NULL;
6317 ut_params->auth_xform.auth.op = op;
6319 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
6321 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
6322 ut_params->auth_xform.auth.key.length = test_case->key.len;
6323 ut_params->auth_xform.auth.key.data = key;
6325 ut_params->sess = rte_cryptodev_sym_session_create(
6326 ts_params->session_mpool);
6328 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6329 ut_params->sess, &ut_params->auth_xform,
6330 ts_params->session_mpool);
6332 if (ut_params->sess == NULL)
6335 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6337 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6338 rte_pktmbuf_tailroom(ut_params->ibuf));
6343 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
6344 const struct HMAC_MD5_vector *test_case,
6345 uint8_t **plaintext)
6347 uint16_t plaintext_pad_len;
6349 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6351 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6354 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6356 memcpy(*plaintext, test_case->plaintext.data,
6357 test_case->plaintext.len);
6359 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
6360 ut_params->ibuf, MD5_DIGEST_LEN);
6361 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
6362 "no room to append digest");
6363 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
6364 ut_params->ibuf, plaintext_pad_len);
6366 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
6367 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
6368 test_case->auth_tag.len);
6371 sym_op->auth.data.offset = 0;
6372 sym_op->auth.data.length = test_case->plaintext.len;
6374 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6375 ut_params->op->sym->m_src = ut_params->ibuf;
6381 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
6383 uint16_t plaintext_pad_len;
6384 uint8_t *plaintext, *auth_tag;
6386 struct crypto_testsuite_params *ts_params = &testsuite_params;
6387 struct crypto_unittest_params *ut_params = &unittest_params;
6389 if (MD5_HMAC_create_session(ts_params, ut_params,
6390 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
6393 /* Generate Crypto op data structure */
6394 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6395 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6396 TEST_ASSERT_NOT_NULL(ut_params->op,
6397 "Failed to allocate symmetric crypto operation struct");
6399 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
6402 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6405 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6406 ut_params->op), "failed to process sym crypto op");
6408 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6409 "crypto op processing failed");
6411 if (ut_params->op->sym->m_dst) {
6412 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
6413 uint8_t *, plaintext_pad_len);
6415 auth_tag = plaintext + plaintext_pad_len;
6418 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6420 test_case->auth_tag.data,
6421 test_case->auth_tag.len,
6422 "HMAC_MD5 generated tag not as expected");
6424 return TEST_SUCCESS;
6428 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
6432 struct crypto_testsuite_params *ts_params = &testsuite_params;
6433 struct crypto_unittest_params *ut_params = &unittest_params;
6435 if (MD5_HMAC_create_session(ts_params, ut_params,
6436 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
6440 /* Generate Crypto op data structure */
6441 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6442 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6443 TEST_ASSERT_NOT_NULL(ut_params->op,
6444 "Failed to allocate symmetric crypto operation struct");
6446 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
6449 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
6450 ut_params->op), "failed to process sym crypto op");
6452 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6453 "HMAC_MD5 crypto op processing failed");
6455 return TEST_SUCCESS;
6459 test_MD5_HMAC_generate_case_1(void)
6461 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
6465 test_MD5_HMAC_verify_case_1(void)
6467 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
6471 test_MD5_HMAC_generate_case_2(void)
6473 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
6477 test_MD5_HMAC_verify_case_2(void)
6479 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
6483 test_multi_session(void)
6485 struct crypto_testsuite_params *ts_params = &testsuite_params;
6486 struct crypto_unittest_params *ut_params = &unittest_params;
6488 struct rte_cryptodev_info dev_info;
6489 struct rte_cryptodev_sym_session **sessions;
6493 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
6494 aes_cbc_key, hmac_sha512_key);
6497 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6499 sessions = rte_malloc(NULL,
6500 (sizeof(struct rte_cryptodev_sym_session *) *
6501 dev_info.sym.max_nb_sessions) + 1, 0);
6503 /* Create multiple crypto sessions*/
6504 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6506 sessions[i] = rte_cryptodev_sym_session_create(
6507 ts_params->session_mpool);
6509 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6510 sessions[i], &ut_params->auth_xform,
6511 ts_params->session_mpool);
6512 TEST_ASSERT_NOT_NULL(sessions[i],
6513 "Session creation failed at session number %u",
6516 /* Attempt to send a request on each session */
6517 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
6521 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
6522 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
6524 "Failed to perform decrypt on request number %u.", i);
6525 /* free crypto operation structure */
6527 rte_crypto_op_free(ut_params->op);
6530 * free mbuf - both obuf and ibuf are usually the same,
6531 * so check if they point at the same address is necessary,
6532 * to avoid freeing the mbuf twice.
6534 if (ut_params->obuf) {
6535 rte_pktmbuf_free(ut_params->obuf);
6536 if (ut_params->ibuf == ut_params->obuf)
6537 ut_params->ibuf = 0;
6538 ut_params->obuf = 0;
6540 if (ut_params->ibuf) {
6541 rte_pktmbuf_free(ut_params->ibuf);
6542 ut_params->ibuf = 0;
6546 /* Next session create should fail */
6547 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6548 sessions[i], &ut_params->auth_xform,
6549 ts_params->session_mpool);
6550 TEST_ASSERT_NULL(sessions[i],
6551 "Session creation succeeded unexpectedly!");
6553 for (i = 0; i < dev_info.sym.max_nb_sessions; i++) {
6554 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6556 rte_cryptodev_sym_session_free(sessions[i]);
6561 return TEST_SUCCESS;
6564 struct multi_session_params {
6565 struct crypto_unittest_params ut_params;
6566 uint8_t *cipher_key;
6568 const uint8_t *cipher;
6569 const uint8_t *digest;
6573 #define MB_SESSION_NUMBER 3
6576 test_multi_session_random_usage(void)
6578 struct crypto_testsuite_params *ts_params = &testsuite_params;
6579 struct rte_cryptodev_info dev_info;
6580 struct rte_cryptodev_sym_session **sessions;
6582 struct multi_session_params ut_paramz[] = {
6585 .cipher_key = ms_aes_cbc_key0,
6586 .hmac_key = ms_hmac_key0,
6587 .cipher = ms_aes_cbc_cipher0,
6588 .digest = ms_hmac_digest0,
6589 .iv = ms_aes_cbc_iv0
6592 .cipher_key = ms_aes_cbc_key1,
6593 .hmac_key = ms_hmac_key1,
6594 .cipher = ms_aes_cbc_cipher1,
6595 .digest = ms_hmac_digest1,
6596 .iv = ms_aes_cbc_iv1
6599 .cipher_key = ms_aes_cbc_key2,
6600 .hmac_key = ms_hmac_key2,
6601 .cipher = ms_aes_cbc_cipher2,
6602 .digest = ms_hmac_digest2,
6603 .iv = ms_aes_cbc_iv2
6608 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6610 sessions = rte_malloc(NULL,
6611 (sizeof(struct rte_cryptodev_sym_session *)
6612 * dev_info.sym.max_nb_sessions) + 1, 0);
6614 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6615 sessions[i] = rte_cryptodev_sym_session_create(
6616 ts_params->session_mpool);
6618 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
6619 sizeof(struct crypto_unittest_params));
6621 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
6622 &ut_paramz[i].ut_params,
6623 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
6625 /* Create multiple crypto sessions*/
6626 rte_cryptodev_sym_session_init(
6627 ts_params->valid_devs[0],
6629 &ut_paramz[i].ut_params.auth_xform,
6630 ts_params->session_mpool);
6632 TEST_ASSERT_NOT_NULL(sessions[i],
6633 "Session creation failed at session number %u",
6639 for (i = 0; i < 40000; i++) {
6641 j = rand() % MB_SESSION_NUMBER;
6643 TEST_ASSERT_SUCCESS(
6644 test_AES_CBC_HMAC_SHA512_decrypt_perform(
6646 &ut_paramz[j].ut_params,
6647 ts_params, ut_paramz[j].cipher,
6648 ut_paramz[j].digest,
6650 "Failed to perform decrypt on request number %u.", i);
6652 if (ut_paramz[j].ut_params.op)
6653 rte_crypto_op_free(ut_paramz[j].ut_params.op);
6656 * free mbuf - both obuf and ibuf are usually the same,
6657 * so check if they point at the same address is necessary,
6658 * to avoid freeing the mbuf twice.
6660 if (ut_paramz[j].ut_params.obuf) {
6661 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
6662 if (ut_paramz[j].ut_params.ibuf
6663 == ut_paramz[j].ut_params.obuf)
6664 ut_paramz[j].ut_params.ibuf = 0;
6665 ut_paramz[j].ut_params.obuf = 0;
6667 if (ut_paramz[j].ut_params.ibuf) {
6668 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
6669 ut_paramz[j].ut_params.ibuf = 0;
6673 for (i = 0; i < MB_SESSION_NUMBER; i++) {
6674 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
6676 rte_cryptodev_sym_session_free(sessions[i]);
6681 return TEST_SUCCESS;
6685 test_null_cipher_only_operation(void)
6687 struct crypto_testsuite_params *ts_params = &testsuite_params;
6688 struct crypto_unittest_params *ut_params = &unittest_params;
6690 /* Generate test mbuf data and space for digest */
6691 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6692 catch_22_quote, QUOTE_512_BYTES, 0);
6694 /* Setup Cipher Parameters */
6695 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6696 ut_params->cipher_xform.next = NULL;
6698 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6699 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6701 ut_params->sess = rte_cryptodev_sym_session_create(
6702 ts_params->session_mpool);
6704 /* Create Crypto session*/
6705 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6707 &ut_params->cipher_xform,
6708 ts_params->session_mpool);
6709 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6711 /* Generate Crypto op data structure */
6712 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6713 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6714 TEST_ASSERT_NOT_NULL(ut_params->op,
6715 "Failed to allocate symmetric crypto operation struct");
6717 /* Set crypto operation data parameters */
6718 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6720 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6722 /* set crypto operation source mbuf */
6723 sym_op->m_src = ut_params->ibuf;
6725 sym_op->cipher.data.offset = 0;
6726 sym_op->cipher.data.length = QUOTE_512_BYTES;
6728 /* Process crypto operation */
6729 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6731 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6733 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6734 "crypto operation processing failed");
6737 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6738 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6741 "Ciphertext data not as expected");
6743 return TEST_SUCCESS;
6745 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
6746 0xab, 0xab, 0xab, 0xab,
6747 0xab, 0xab, 0xab, 0xab,
6748 0xab, 0xab, 0xab, 0xab};
6750 test_null_auth_only_operation(void)
6752 struct crypto_testsuite_params *ts_params = &testsuite_params;
6753 struct crypto_unittest_params *ut_params = &unittest_params;
6756 /* Generate test mbuf data and space for digest */
6757 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6758 catch_22_quote, QUOTE_512_BYTES, 0);
6760 /* create a pointer for digest, but don't expect anything to be written
6761 * here in a NULL auth algo so no mbuf append done.
6763 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6765 /* prefill the memory pointed to by digest */
6766 memcpy(digest, orig_data, sizeof(orig_data));
6768 /* Setup HMAC Parameters */
6769 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6770 ut_params->auth_xform.next = NULL;
6772 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6773 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6775 ut_params->sess = rte_cryptodev_sym_session_create(
6776 ts_params->session_mpool);
6778 /* Create Crypto session*/
6779 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6780 ut_params->sess, &ut_params->auth_xform,
6781 ts_params->session_mpool);
6782 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6784 /* Generate Crypto op data structure */
6785 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6786 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6787 TEST_ASSERT_NOT_NULL(ut_params->op,
6788 "Failed to allocate symmetric crypto operation struct");
6790 /* Set crypto operation data parameters */
6791 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6793 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6795 sym_op->m_src = ut_params->ibuf;
6797 sym_op->auth.data.offset = 0;
6798 sym_op->auth.data.length = QUOTE_512_BYTES;
6799 sym_op->auth.digest.data = digest;
6800 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6803 /* Process crypto operation */
6804 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6806 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6808 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6809 "crypto operation processing failed");
6810 /* Make sure memory pointed to by digest hasn't been overwritten */
6811 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6815 "Memory at digest ptr overwritten unexpectedly");
6817 return TEST_SUCCESS;
6822 test_null_cipher_auth_operation(void)
6824 struct crypto_testsuite_params *ts_params = &testsuite_params;
6825 struct crypto_unittest_params *ut_params = &unittest_params;
6828 /* Generate test mbuf data and space for digest */
6829 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6830 catch_22_quote, QUOTE_512_BYTES, 0);
6832 /* create a pointer for digest, but don't expect anything to be written
6833 * here in a NULL auth algo so no mbuf append done.
6835 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6837 /* prefill the memory pointed to by digest */
6838 memcpy(digest, orig_data, sizeof(orig_data));
6840 /* Setup Cipher Parameters */
6841 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6842 ut_params->cipher_xform.next = &ut_params->auth_xform;
6844 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6845 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6847 /* Setup HMAC Parameters */
6848 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6849 ut_params->auth_xform.next = NULL;
6851 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6852 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6854 ut_params->sess = rte_cryptodev_sym_session_create(
6855 ts_params->session_mpool);
6857 /* Create Crypto session*/
6858 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6859 ut_params->sess, &ut_params->cipher_xform,
6860 ts_params->session_mpool);
6861 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6863 /* Generate Crypto op data structure */
6864 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6865 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6866 TEST_ASSERT_NOT_NULL(ut_params->op,
6867 "Failed to allocate symmetric crypto operation struct");
6869 /* Set crypto operation data parameters */
6870 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6872 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6874 sym_op->m_src = ut_params->ibuf;
6876 sym_op->cipher.data.offset = 0;
6877 sym_op->cipher.data.length = QUOTE_512_BYTES;
6879 sym_op->auth.data.offset = 0;
6880 sym_op->auth.data.length = QUOTE_512_BYTES;
6881 sym_op->auth.digest.data = digest;
6882 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6885 /* Process crypto operation */
6886 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6888 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6890 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6891 "crypto operation processing failed");
6894 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6895 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6898 "Ciphertext data not as expected");
6899 /* Make sure memory pointed to by digest hasn't been overwritten */
6900 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6904 "Memory at digest ptr overwritten unexpectedly");
6906 return TEST_SUCCESS;
6910 test_null_auth_cipher_operation(void)
6912 struct crypto_testsuite_params *ts_params = &testsuite_params;
6913 struct crypto_unittest_params *ut_params = &unittest_params;
6916 /* Generate test mbuf data */
6917 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
6918 catch_22_quote, QUOTE_512_BYTES, 0);
6920 /* create a pointer for digest, but don't expect anything to be written
6921 * here in a NULL auth algo so no mbuf append done.
6923 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
6925 /* prefill the memory pointed to by digest */
6926 memcpy(digest, orig_data, sizeof(orig_data));
6928 /* Setup Cipher Parameters */
6929 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6930 ut_params->cipher_xform.next = NULL;
6932 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
6933 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
6935 /* Setup HMAC Parameters */
6936 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6937 ut_params->auth_xform.next = &ut_params->cipher_xform;
6939 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
6940 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
6942 ut_params->sess = rte_cryptodev_sym_session_create(
6943 ts_params->session_mpool);
6945 /* Create Crypto session*/
6946 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
6947 ut_params->sess, &ut_params->cipher_xform,
6948 ts_params->session_mpool);
6949 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
6951 /* Generate Crypto op data structure */
6952 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
6953 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
6954 TEST_ASSERT_NOT_NULL(ut_params->op,
6955 "Failed to allocate symmetric crypto operation struct");
6957 /* Set crypto operation data parameters */
6958 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
6960 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
6962 sym_op->m_src = ut_params->ibuf;
6964 sym_op->cipher.data.offset = 0;
6965 sym_op->cipher.data.length = QUOTE_512_BYTES;
6967 sym_op->auth.data.offset = 0;
6968 sym_op->auth.data.length = QUOTE_512_BYTES;
6969 sym_op->auth.digest.data = digest;
6970 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
6973 /* Process crypto operation */
6974 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6976 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
6978 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6979 "crypto operation processing failed");
6982 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6983 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
6986 "Ciphertext data not as expected");
6987 /* Make sure memory pointed to by digest hasn't been overwritten */
6988 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6992 "Memory at digest ptr overwritten unexpectedly");
6994 return TEST_SUCCESS;
6999 test_null_invalid_operation(void)
7001 struct crypto_testsuite_params *ts_params = &testsuite_params;
7002 struct crypto_unittest_params *ut_params = &unittest_params;
7005 /* Setup Cipher Parameters */
7006 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7007 ut_params->cipher_xform.next = NULL;
7009 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
7010 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7012 ut_params->sess = rte_cryptodev_sym_session_create(
7013 ts_params->session_mpool);
7015 /* Create Crypto session*/
7016 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7017 ut_params->sess, &ut_params->cipher_xform,
7018 ts_params->session_mpool);
7019 TEST_ASSERT(ret < 0,
7020 "Session creation succeeded unexpectedly");
7023 /* Setup HMAC Parameters */
7024 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7025 ut_params->auth_xform.next = NULL;
7027 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
7028 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7030 ut_params->sess = rte_cryptodev_sym_session_create(
7031 ts_params->session_mpool);
7033 /* Create Crypto session*/
7034 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7035 ut_params->sess, &ut_params->auth_xform,
7036 ts_params->session_mpool);
7037 TEST_ASSERT(ret < 0,
7038 "Session creation succeeded unexpectedly");
7040 return TEST_SUCCESS;
7044 #define NULL_BURST_LENGTH (32)
7047 test_null_burst_operation(void)
7049 struct crypto_testsuite_params *ts_params = &testsuite_params;
7050 struct crypto_unittest_params *ut_params = &unittest_params;
7052 unsigned i, burst_len = NULL_BURST_LENGTH;
7054 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
7055 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
7057 /* Setup Cipher Parameters */
7058 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7059 ut_params->cipher_xform.next = &ut_params->auth_xform;
7061 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
7062 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
7064 /* Setup HMAC Parameters */
7065 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7066 ut_params->auth_xform.next = NULL;
7068 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
7069 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
7071 ut_params->sess = rte_cryptodev_sym_session_create(
7072 ts_params->session_mpool);
7074 /* Create Crypto session*/
7075 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
7076 ut_params->sess, &ut_params->cipher_xform,
7077 ts_params->session_mpool);
7078 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7080 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
7081 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
7082 burst_len, "failed to generate burst of crypto ops");
7084 /* Generate an operation for each mbuf in burst */
7085 for (i = 0; i < burst_len; i++) {
7086 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7088 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
7090 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
7094 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
7096 burst[i]->sym->m_src = m;
7099 /* Process crypto operation */
7100 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
7101 0, burst, burst_len),
7103 "Error enqueuing burst");
7105 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
7106 0, burst_dequeued, burst_len),
7108 "Error dequeuing burst");
7111 for (i = 0; i < burst_len; i++) {
7113 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
7114 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
7116 "data not as expected");
7118 rte_pktmbuf_free(burst[i]->sym->m_src);
7119 rte_crypto_op_free(burst[i]);
7122 return TEST_SUCCESS;
7126 generate_gmac_large_plaintext(uint8_t *data)
7130 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
7131 memcpy(&data[i], &data[0], 32);
7135 create_gmac_operation(enum rte_crypto_auth_operation op,
7136 const struct gmac_test_data *tdata)
7138 struct crypto_testsuite_params *ts_params = &testsuite_params;
7139 struct crypto_unittest_params *ut_params = &unittest_params;
7140 struct rte_crypto_sym_op *sym_op;
7142 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7144 /* Generate Crypto op data structure */
7145 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7146 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7147 TEST_ASSERT_NOT_NULL(ut_params->op,
7148 "Failed to allocate symmetric crypto operation struct");
7150 sym_op = ut_params->op->sym;
7152 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7153 ut_params->ibuf, tdata->gmac_tag.len);
7154 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7155 "no room to append digest");
7157 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7158 ut_params->ibuf, plaintext_pad_len);
7160 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
7161 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
7162 tdata->gmac_tag.len);
7163 debug_hexdump(stdout, "digest:",
7164 sym_op->auth.digest.data,
7165 tdata->gmac_tag.len);
7168 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7169 uint8_t *, IV_OFFSET);
7171 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7173 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
7175 sym_op->cipher.data.length = 0;
7176 sym_op->cipher.data.offset = 0;
7178 sym_op->auth.data.offset = 0;
7179 sym_op->auth.data.length = tdata->plaintext.len;
7184 static int create_gmac_session(uint8_t dev_id,
7185 const struct gmac_test_data *tdata,
7186 enum rte_crypto_auth_operation auth_op)
7188 uint8_t auth_key[tdata->key.len];
7190 struct crypto_testsuite_params *ts_params = &testsuite_params;
7191 struct crypto_unittest_params *ut_params = &unittest_params;
7193 memcpy(auth_key, tdata->key.data, tdata->key.len);
7195 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7196 ut_params->auth_xform.next = NULL;
7198 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
7199 ut_params->auth_xform.auth.op = auth_op;
7200 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
7201 ut_params->auth_xform.auth.key.length = tdata->key.len;
7202 ut_params->auth_xform.auth.key.data = auth_key;
7203 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7204 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
7207 ut_params->sess = rte_cryptodev_sym_session_create(
7208 ts_params->session_mpool);
7210 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7211 &ut_params->auth_xform,
7212 ts_params->session_mpool);
7214 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7220 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
7222 struct crypto_testsuite_params *ts_params = &testsuite_params;
7223 struct crypto_unittest_params *ut_params = &unittest_params;
7227 uint8_t *auth_tag, *plaintext;
7228 uint16_t plaintext_pad_len;
7230 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7231 "No GMAC length in the source data");
7233 retval = create_gmac_session(ts_params->valid_devs[0],
7234 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
7239 if (tdata->plaintext.len > MBUF_SIZE)
7240 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7242 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7243 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7244 "Failed to allocate input buffer in mempool");
7246 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7247 rte_pktmbuf_tailroom(ut_params->ibuf));
7249 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7251 * Runtime generate the large plain text instead of use hard code
7252 * plain text vector. It is done to avoid create huge source file
7253 * with the test vector.
7255 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7256 generate_gmac_large_plaintext(tdata->plaintext.data);
7258 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7260 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7262 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7263 debug_hexdump(stdout, "plaintext:", plaintext,
7264 tdata->plaintext.len);
7266 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
7272 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7274 ut_params->op->sym->m_src = ut_params->ibuf;
7276 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7277 ut_params->op), "failed to process sym crypto op");
7279 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7280 "crypto op processing failed");
7282 if (ut_params->op->sym->m_dst) {
7283 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7284 uint8_t *, plaintext_pad_len);
7286 auth_tag = plaintext + plaintext_pad_len;
7289 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
7291 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7293 tdata->gmac_tag.data,
7294 tdata->gmac_tag.len,
7295 "GMAC Generated auth tag not as expected");
7301 test_AES_GMAC_authentication_test_case_1(void)
7303 return test_AES_GMAC_authentication(&gmac_test_case_1);
7307 test_AES_GMAC_authentication_test_case_2(void)
7309 return test_AES_GMAC_authentication(&gmac_test_case_2);
7313 test_AES_GMAC_authentication_test_case_3(void)
7315 return test_AES_GMAC_authentication(&gmac_test_case_3);
7319 test_AES_GMAC_authentication_test_case_4(void)
7321 return test_AES_GMAC_authentication(&gmac_test_case_4);
7325 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
7327 struct crypto_testsuite_params *ts_params = &testsuite_params;
7328 struct crypto_unittest_params *ut_params = &unittest_params;
7330 uint32_t plaintext_pad_len;
7333 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
7334 "No GMAC length in the source data");
7336 retval = create_gmac_session(ts_params->valid_devs[0],
7337 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
7342 if (tdata->plaintext.len > MBUF_SIZE)
7343 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7345 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7346 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7347 "Failed to allocate input buffer in mempool");
7349 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7350 rte_pktmbuf_tailroom(ut_params->ibuf));
7352 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7355 * Runtime generate the large plain text instead of use hard code
7356 * plain text vector. It is done to avoid create huge source file
7357 * with the test vector.
7359 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
7360 generate_gmac_large_plaintext(tdata->plaintext.data);
7362 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7364 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7366 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7367 debug_hexdump(stdout, "plaintext:", plaintext,
7368 tdata->plaintext.len);
7370 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
7376 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7378 ut_params->op->sym->m_src = ut_params->ibuf;
7380 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7381 ut_params->op), "failed to process sym crypto op");
7383 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7384 "crypto op processing failed");
7391 test_AES_GMAC_authentication_verify_test_case_1(void)
7393 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
7397 test_AES_GMAC_authentication_verify_test_case_2(void)
7399 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
7403 test_AES_GMAC_authentication_verify_test_case_3(void)
7405 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
7409 test_AES_GMAC_authentication_verify_test_case_4(void)
7411 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
7414 struct test_crypto_vector {
7415 enum rte_crypto_cipher_algorithm crypto_algo;
7428 const uint8_t *data;
7433 const uint8_t *data;
7437 enum rte_crypto_auth_algorithm auth_algo;
7445 const uint8_t *data;
7455 static const struct test_crypto_vector
7456 hmac_sha1_test_crypto_vector = {
7457 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7459 .data = plaintext_hash,
7464 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7465 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7466 0xDE, 0xF4, 0xDE, 0xAD
7472 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
7473 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
7474 0x3F, 0x91, 0x64, 0x59
7480 static const struct test_crypto_vector
7481 aes128_gmac_test_vector = {
7482 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
7484 .data = plaintext_hash,
7489 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7490 0x08, 0x09, 0x0A, 0x0B
7496 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7497 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
7503 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
7504 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
7510 static const struct test_crypto_vector
7511 aes128cbc_hmac_sha1_test_vector = {
7512 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
7515 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
7516 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
7522 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
7523 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
7528 .data = plaintext_hash,
7532 .data = ciphertext512_aes128cbc,
7535 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
7538 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
7539 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
7540 0xDE, 0xF4, 0xDE, 0xAD
7546 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
7547 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
7548 0x18, 0x8C, 0x1D, 0x32
7555 data_corruption(uint8_t *data)
7561 tag_corruption(uint8_t *data, unsigned int tag_offset)
7563 data[tag_offset] += 1;
7567 create_auth_session(struct crypto_unittest_params *ut_params,
7569 const struct test_crypto_vector *reference,
7570 enum rte_crypto_auth_operation auth_op)
7572 struct crypto_testsuite_params *ts_params = &testsuite_params;
7573 uint8_t auth_key[reference->auth_key.len + 1];
7575 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7577 /* Setup Authentication Parameters */
7578 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7579 ut_params->auth_xform.auth.op = auth_op;
7580 ut_params->auth_xform.next = NULL;
7581 ut_params->auth_xform.auth.algo = reference->auth_algo;
7582 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7583 ut_params->auth_xform.auth.key.data = auth_key;
7584 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7586 /* Create Crypto session*/
7587 ut_params->sess = rte_cryptodev_sym_session_create(
7588 ts_params->session_mpool);
7590 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7591 &ut_params->auth_xform,
7592 ts_params->session_mpool);
7594 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7600 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
7602 const struct test_crypto_vector *reference,
7603 enum rte_crypto_auth_operation auth_op,
7604 enum rte_crypto_cipher_operation cipher_op)
7606 struct crypto_testsuite_params *ts_params = &testsuite_params;
7607 uint8_t cipher_key[reference->cipher_key.len + 1];
7608 uint8_t auth_key[reference->auth_key.len + 1];
7610 memcpy(cipher_key, reference->cipher_key.data,
7611 reference->cipher_key.len);
7612 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
7614 /* Setup Authentication Parameters */
7615 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7616 ut_params->auth_xform.auth.op = auth_op;
7617 ut_params->auth_xform.auth.algo = reference->auth_algo;
7618 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
7619 ut_params->auth_xform.auth.key.data = auth_key;
7620 ut_params->auth_xform.auth.digest_length = reference->digest.len;
7622 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
7623 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
7624 ut_params->auth_xform.auth.iv.length = reference->iv.len;
7626 ut_params->auth_xform.next = &ut_params->cipher_xform;
7628 /* Setup Cipher Parameters */
7629 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7630 ut_params->cipher_xform.next = NULL;
7631 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
7632 ut_params->cipher_xform.cipher.op = cipher_op;
7633 ut_params->cipher_xform.cipher.key.data = cipher_key;
7634 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
7635 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
7636 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
7639 /* Create Crypto session*/
7640 ut_params->sess = rte_cryptodev_sym_session_create(
7641 ts_params->session_mpool);
7643 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7644 &ut_params->auth_xform,
7645 ts_params->session_mpool);
7647 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7653 create_auth_operation(struct crypto_testsuite_params *ts_params,
7654 struct crypto_unittest_params *ut_params,
7655 const struct test_crypto_vector *reference,
7656 unsigned int auth_generate)
7658 /* Generate Crypto op data structure */
7659 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7660 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7661 TEST_ASSERT_NOT_NULL(ut_params->op,
7662 "Failed to allocate pktmbuf offload");
7664 /* Set crypto operation data parameters */
7665 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7667 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7669 /* set crypto operation source mbuf */
7670 sym_op->m_src = ut_params->ibuf;
7673 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7674 ut_params->ibuf, reference->digest.len);
7676 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7677 "no room to append auth tag");
7679 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7680 ut_params->ibuf, reference->plaintext.len);
7683 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7685 memcpy(sym_op->auth.digest.data,
7686 reference->digest.data,
7687 reference->digest.len);
7689 debug_hexdump(stdout, "digest:",
7690 sym_op->auth.digest.data,
7691 reference->digest.len);
7693 sym_op->auth.data.length = reference->plaintext.len;
7694 sym_op->auth.data.offset = 0;
7700 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
7701 struct crypto_unittest_params *ut_params,
7702 const struct test_crypto_vector *reference,
7703 unsigned int auth_generate)
7705 /* Generate Crypto op data structure */
7706 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7707 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7708 TEST_ASSERT_NOT_NULL(ut_params->op,
7709 "Failed to allocate pktmbuf offload");
7711 /* Set crypto operation data parameters */
7712 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7714 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7716 /* set crypto operation source mbuf */
7717 sym_op->m_src = ut_params->ibuf;
7720 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7721 ut_params->ibuf, reference->digest.len);
7723 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7724 "no room to append auth tag");
7726 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7727 ut_params->ibuf, reference->ciphertext.len);
7730 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7732 memcpy(sym_op->auth.digest.data,
7733 reference->digest.data,
7734 reference->digest.len);
7736 debug_hexdump(stdout, "digest:",
7737 sym_op->auth.digest.data,
7738 reference->digest.len);
7740 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7741 reference->iv.data, reference->iv.len);
7743 sym_op->cipher.data.length = 0;
7744 sym_op->cipher.data.offset = 0;
7746 sym_op->auth.data.length = reference->plaintext.len;
7747 sym_op->auth.data.offset = 0;
7753 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
7754 struct crypto_unittest_params *ut_params,
7755 const struct test_crypto_vector *reference,
7756 unsigned int auth_generate)
7758 /* Generate Crypto op data structure */
7759 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7760 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7761 TEST_ASSERT_NOT_NULL(ut_params->op,
7762 "Failed to allocate pktmbuf offload");
7764 /* Set crypto operation data parameters */
7765 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7767 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7769 /* set crypto operation source mbuf */
7770 sym_op->m_src = ut_params->ibuf;
7773 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
7774 ut_params->ibuf, reference->digest.len);
7776 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
7777 "no room to append auth tag");
7779 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
7780 ut_params->ibuf, reference->ciphertext.len);
7783 memset(sym_op->auth.digest.data, 0, reference->digest.len);
7785 memcpy(sym_op->auth.digest.data,
7786 reference->digest.data,
7787 reference->digest.len);
7789 debug_hexdump(stdout, "digest:",
7790 sym_op->auth.digest.data,
7791 reference->digest.len);
7793 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
7794 reference->iv.data, reference->iv.len);
7796 sym_op->cipher.data.length = reference->ciphertext.len;
7797 sym_op->cipher.data.offset = 0;
7799 sym_op->auth.data.length = reference->ciphertext.len;
7800 sym_op->auth.data.offset = 0;
7806 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7807 struct crypto_unittest_params *ut_params,
7808 const struct test_crypto_vector *reference)
7810 return create_auth_operation(ts_params, ut_params, reference, 0);
7814 create_auth_verify_GMAC_operation(
7815 struct crypto_testsuite_params *ts_params,
7816 struct crypto_unittest_params *ut_params,
7817 const struct test_crypto_vector *reference)
7819 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
7823 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
7824 struct crypto_unittest_params *ut_params,
7825 const struct test_crypto_vector *reference)
7827 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
7831 test_authentication_verify_fail_when_data_corruption(
7832 struct crypto_testsuite_params *ts_params,
7833 struct crypto_unittest_params *ut_params,
7834 const struct test_crypto_vector *reference,
7835 unsigned int data_corrupted)
7841 /* Create session */
7842 retval = create_auth_session(ut_params,
7843 ts_params->valid_devs[0],
7845 RTE_CRYPTO_AUTH_OP_VERIFY);
7849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7850 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7851 "Failed to allocate input buffer in mempool");
7853 /* clear mbuf payload */
7854 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7855 rte_pktmbuf_tailroom(ut_params->ibuf));
7857 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7858 reference->plaintext.len);
7859 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7860 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7862 debug_hexdump(stdout, "plaintext:", plaintext,
7863 reference->plaintext.len);
7865 /* Create operation */
7866 retval = create_auth_verify_operation(ts_params, ut_params, reference);
7872 data_corruption(plaintext);
7874 tag_corruption(plaintext, reference->plaintext.len);
7876 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7878 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7879 TEST_ASSERT_EQUAL(ut_params->op->status,
7880 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7881 "authentication not failed");
7883 ut_params->obuf = ut_params->op->sym->m_src;
7884 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7890 test_authentication_verify_GMAC_fail_when_corruption(
7891 struct crypto_testsuite_params *ts_params,
7892 struct crypto_unittest_params *ut_params,
7893 const struct test_crypto_vector *reference,
7894 unsigned int data_corrupted)
7899 /* Create session */
7900 retval = create_auth_cipher_session(ut_params,
7901 ts_params->valid_devs[0],
7903 RTE_CRYPTO_AUTH_OP_VERIFY,
7904 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7908 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7909 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7910 "Failed to allocate input buffer in mempool");
7912 /* clear mbuf payload */
7913 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7914 rte_pktmbuf_tailroom(ut_params->ibuf));
7916 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7917 reference->plaintext.len);
7918 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7919 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
7921 debug_hexdump(stdout, "plaintext:", plaintext,
7922 reference->plaintext.len);
7924 /* Create operation */
7925 retval = create_auth_verify_GMAC_operation(ts_params,
7933 data_corruption(plaintext);
7935 tag_corruption(plaintext, reference->aad.len);
7937 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
7939 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
7940 TEST_ASSERT_EQUAL(ut_params->op->status,
7941 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
7942 "authentication not failed");
7944 ut_params->obuf = ut_params->op->sym->m_src;
7945 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
7951 test_authenticated_decryption_fail_when_corruption(
7952 struct crypto_testsuite_params *ts_params,
7953 struct crypto_unittest_params *ut_params,
7954 const struct test_crypto_vector *reference,
7955 unsigned int data_corrupted)
7959 uint8_t *ciphertext;
7961 /* Create session */
7962 retval = create_auth_cipher_session(ut_params,
7963 ts_params->valid_devs[0],
7965 RTE_CRYPTO_AUTH_OP_VERIFY,
7966 RTE_CRYPTO_CIPHER_OP_DECRYPT);
7970 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7971 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
7972 "Failed to allocate input buffer in mempool");
7974 /* clear mbuf payload */
7975 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7976 rte_pktmbuf_tailroom(ut_params->ibuf));
7978 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7979 reference->ciphertext.len);
7980 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
7981 memcpy(ciphertext, reference->ciphertext.data,
7982 reference->ciphertext.len);
7984 /* Create operation */
7985 retval = create_cipher_auth_verify_operation(ts_params,
7993 data_corruption(ciphertext);
7995 tag_corruption(ciphertext, reference->ciphertext.len);
7997 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
8000 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8001 TEST_ASSERT_EQUAL(ut_params->op->status,
8002 RTE_CRYPTO_OP_STATUS_AUTH_FAILED,
8003 "authentication not failed");
8005 ut_params->obuf = ut_params->op->sym->m_src;
8006 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
8012 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
8013 const struct aead_test_data *tdata,
8014 void *digest_mem, uint64_t digest_phys)
8016 struct crypto_testsuite_params *ts_params = &testsuite_params;
8017 struct crypto_unittest_params *ut_params = &unittest_params;
8019 const unsigned int auth_tag_len = tdata->auth_tag.len;
8020 const unsigned int iv_len = tdata->iv.len;
8021 unsigned int aad_len = tdata->aad.len;
8023 /* Generate Crypto op data structure */
8024 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8025 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8026 TEST_ASSERT_NOT_NULL(ut_params->op,
8027 "Failed to allocate symmetric crypto operation struct");
8029 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
8031 sym_op->aead.digest.data = digest_mem;
8033 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
8034 "no room to append digest");
8036 sym_op->aead.digest.phys_addr = digest_phys;
8038 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
8039 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
8041 debug_hexdump(stdout, "digest:",
8042 sym_op->aead.digest.data,
8046 /* Append aad data */
8047 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
8048 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8049 uint8_t *, IV_OFFSET);
8051 /* Copy IV 1 byte after the IV pointer, according to the API */
8052 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
8054 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
8056 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8057 ut_params->ibuf, aad_len);
8058 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8059 "no room to prepend aad");
8060 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8063 memset(sym_op->aead.aad.data, 0, aad_len);
8064 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
8065 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8067 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8068 debug_hexdump(stdout, "aad:",
8069 sym_op->aead.aad.data, aad_len);
8071 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
8072 uint8_t *, IV_OFFSET);
8074 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
8076 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
8077 ut_params->ibuf, aad_len);
8078 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
8079 "no room to prepend aad");
8080 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
8083 memset(sym_op->aead.aad.data, 0, aad_len);
8084 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
8086 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
8087 debug_hexdump(stdout, "aad:",
8088 sym_op->aead.aad.data, aad_len);
8091 sym_op->aead.data.length = tdata->plaintext.len;
8092 sym_op->aead.data.offset = aad_len;
8097 #define SGL_MAX_NO 16
8100 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
8101 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
8103 struct crypto_testsuite_params *ts_params = &testsuite_params;
8104 struct crypto_unittest_params *ut_params = &unittest_params;
8105 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
8108 int to_trn_tbl[SGL_MAX_NO];
8110 unsigned int trn_data = 0;
8111 uint8_t *plaintext, *ciphertext, *auth_tag;
8113 if (fragsz > tdata->plaintext.len)
8114 fragsz = tdata->plaintext.len;
8116 uint16_t plaintext_len = fragsz;
8117 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8119 if (fragsz_oop > tdata->plaintext.len)
8120 frag_size_oop = tdata->plaintext.len;
8123 void *digest_mem = NULL;
8125 uint32_t prepend_len = tdata->aad.len;
8127 if (tdata->plaintext.len % fragsz != 0) {
8128 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
8131 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
8136 * For out-op-place we need to alloc another mbuf
8139 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8140 rte_pktmbuf_append(ut_params->obuf,
8141 frag_size_oop + prepend_len);
8142 buf_oop = ut_params->obuf;
8145 /* Create AEAD session */
8146 retval = create_aead_session(ts_params->valid_devs[0],
8148 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8149 tdata->key.data, tdata->key.len,
8150 tdata->aad.len, tdata->auth_tag.len,
8155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8157 /* clear mbuf payload */
8158 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8159 rte_pktmbuf_tailroom(ut_params->ibuf));
8161 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8164 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
8166 trn_data += plaintext_len;
8168 buf = ut_params->ibuf;
8171 * Loop until no more fragments
8174 while (trn_data < tdata->plaintext.len) {
8176 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
8177 (tdata->plaintext.len - trn_data) : fragsz;
8179 to_trn_tbl[ecx++] = to_trn;
8181 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8184 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8185 rte_pktmbuf_tailroom(buf));
8188 if (oop && !fragsz_oop) {
8189 buf_last_oop = buf_oop->next =
8190 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8191 buf_oop = buf_oop->next;
8192 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8193 0, rte_pktmbuf_tailroom(buf_oop));
8194 rte_pktmbuf_append(buf_oop, to_trn);
8197 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8200 memcpy(plaintext, tdata->plaintext.data + trn_data,
8203 if (trn_data == tdata->plaintext.len) {
8206 digest_mem = rte_pktmbuf_append(buf_oop,
8207 tdata->auth_tag.len);
8209 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
8210 tdata->auth_tag.len);
8214 uint64_t digest_phys = 0;
8216 ut_params->ibuf->nb_segs = segs;
8219 if (fragsz_oop && oop) {
8223 if (frag_size_oop == tdata->plaintext.len) {
8224 digest_mem = rte_pktmbuf_append(ut_params->obuf,
8225 tdata->auth_tag.len);
8227 digest_phys = rte_pktmbuf_iova_offset(
8229 tdata->plaintext.len + prepend_len);
8232 trn_data = frag_size_oop;
8233 while (trn_data < tdata->plaintext.len) {
8236 (tdata->plaintext.len - trn_data <
8238 (tdata->plaintext.len - trn_data) :
8241 to_trn_tbl[ecx++] = to_trn;
8243 buf_last_oop = buf_oop->next =
8244 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8245 buf_oop = buf_oop->next;
8246 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8247 0, rte_pktmbuf_tailroom(buf_oop));
8248 rte_pktmbuf_append(buf_oop, to_trn);
8252 if (trn_data == tdata->plaintext.len) {
8253 digest_mem = rte_pktmbuf_append(buf_oop,
8254 tdata->auth_tag.len);
8258 ut_params->obuf->nb_segs = segs;
8262 * Place digest at the end of the last buffer
8265 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
8266 if (oop && buf_last_oop)
8267 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
8269 if (!digest_mem && !oop) {
8270 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8271 + tdata->auth_tag.len);
8272 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
8273 tdata->plaintext.len);
8276 /* Create AEAD operation */
8277 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
8278 tdata, digest_mem, digest_phys);
8283 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8285 ut_params->op->sym->m_src = ut_params->ibuf;
8287 ut_params->op->sym->m_dst = ut_params->obuf;
8289 /* Process crypto operation */
8290 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8291 ut_params->op), "failed to process sym crypto op");
8293 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8294 "crypto op processing failed");
8297 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8298 uint8_t *, prepend_len);
8300 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
8301 uint8_t *, prepend_len);
8305 fragsz = fragsz_oop;
8307 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8309 tdata->ciphertext.data,
8311 "Ciphertext data not as expected");
8313 buf = ut_params->op->sym->m_src->next;
8315 buf = ut_params->op->sym->m_dst->next;
8317 unsigned int off = fragsz;
8321 ciphertext = rte_pktmbuf_mtod(buf,
8324 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8326 tdata->ciphertext.data + off,
8328 "Ciphertext data not as expected");
8330 off += to_trn_tbl[ecx++];
8334 auth_tag = digest_mem;
8335 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8337 tdata->auth_tag.data,
8338 tdata->auth_tag.len,
8339 "Generated auth tag not as expected");
8345 #define OUT_OF_PLACE 1
8348 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
8350 return test_authenticated_encryption_SGL(
8351 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
8355 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
8357 return test_authenticated_encryption_SGL(
8358 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
8362 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
8364 return test_authenticated_encryption_SGL(
8365 &gcm_test_case_8, OUT_OF_PLACE, 400,
8366 gcm_test_case_8.plaintext.len);
8370 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
8373 return test_authenticated_encryption_SGL(
8374 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
8378 test_authentication_verify_fail_when_data_corrupted(
8379 struct crypto_testsuite_params *ts_params,
8380 struct crypto_unittest_params *ut_params,
8381 const struct test_crypto_vector *reference)
8383 return test_authentication_verify_fail_when_data_corruption(
8384 ts_params, ut_params, reference, 1);
8388 test_authentication_verify_fail_when_tag_corrupted(
8389 struct crypto_testsuite_params *ts_params,
8390 struct crypto_unittest_params *ut_params,
8391 const struct test_crypto_vector *reference)
8393 return test_authentication_verify_fail_when_data_corruption(
8394 ts_params, ut_params, reference, 0);
8398 test_authentication_verify_GMAC_fail_when_data_corrupted(
8399 struct crypto_testsuite_params *ts_params,
8400 struct crypto_unittest_params *ut_params,
8401 const struct test_crypto_vector *reference)
8403 return test_authentication_verify_GMAC_fail_when_corruption(
8404 ts_params, ut_params, reference, 1);
8408 test_authentication_verify_GMAC_fail_when_tag_corrupted(
8409 struct crypto_testsuite_params *ts_params,
8410 struct crypto_unittest_params *ut_params,
8411 const struct test_crypto_vector *reference)
8413 return test_authentication_verify_GMAC_fail_when_corruption(
8414 ts_params, ut_params, reference, 0);
8418 test_authenticated_decryption_fail_when_data_corrupted(
8419 struct crypto_testsuite_params *ts_params,
8420 struct crypto_unittest_params *ut_params,
8421 const struct test_crypto_vector *reference)
8423 return test_authenticated_decryption_fail_when_corruption(
8424 ts_params, ut_params, reference, 1);
8428 test_authenticated_decryption_fail_when_tag_corrupted(
8429 struct crypto_testsuite_params *ts_params,
8430 struct crypto_unittest_params *ut_params,
8431 const struct test_crypto_vector *reference)
8433 return test_authenticated_decryption_fail_when_corruption(
8434 ts_params, ut_params, reference, 0);
8438 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
8440 return test_authentication_verify_fail_when_data_corrupted(
8441 &testsuite_params, &unittest_params,
8442 &hmac_sha1_test_crypto_vector);
8446 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
8448 return test_authentication_verify_fail_when_tag_corrupted(
8449 &testsuite_params, &unittest_params,
8450 &hmac_sha1_test_crypto_vector);
8454 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
8456 return test_authentication_verify_GMAC_fail_when_data_corrupted(
8457 &testsuite_params, &unittest_params,
8458 &aes128_gmac_test_vector);
8462 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
8464 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
8465 &testsuite_params, &unittest_params,
8466 &aes128_gmac_test_vector);
8470 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
8472 return test_authenticated_decryption_fail_when_data_corrupted(
8475 &aes128cbc_hmac_sha1_test_vector);
8479 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
8481 return test_authenticated_decryption_fail_when_tag_corrupted(
8484 &aes128cbc_hmac_sha1_test_vector);
8487 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
8489 /* global AESNI slave IDs for the scheduler test */
8490 uint8_t aesni_ids[2];
8493 test_scheduler_attach_slave_op(void)
8495 struct crypto_testsuite_params *ts_params = &testsuite_params;
8496 uint8_t sched_id = ts_params->valid_devs[0];
8497 uint32_t nb_devs, i, nb_devs_attached = 0;
8501 /* create 2 AESNI_MB if necessary */
8502 nb_devs = rte_cryptodev_device_count_by_driver(
8503 rte_cryptodev_driver_id_get(
8504 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
8506 for (i = nb_devs; i < 2; i++) {
8507 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
8508 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
8510 ret = rte_vdev_init(vdev_name, NULL);
8512 TEST_ASSERT(ret == 0,
8513 "Failed to create instance %u of"
8515 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8519 /* attach 2 AESNI_MB cdevs */
8520 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
8522 struct rte_cryptodev_info info;
8524 rte_cryptodev_info_get(i, &info);
8525 if (info.driver_id != rte_cryptodev_driver_id_get(
8526 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
8530 * Create the session mempool again, since now there are new devices
8531 * to use the mempool.
8533 if (ts_params->session_mpool) {
8534 rte_mempool_free(ts_params->session_mpool);
8535 ts_params->session_mpool = NULL;
8537 unsigned int session_size = rte_cryptodev_get_private_session_size(i);
8540 * Create mempool with maximum number of sessions * 2,
8541 * to include the session headers
8543 if (ts_params->session_mpool == NULL) {
8544 ts_params->session_mpool = rte_mempool_create(
8546 info.sym.max_nb_sessions * 2,
8548 0, 0, NULL, NULL, NULL,
8549 NULL, SOCKET_ID_ANY,
8552 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
8553 "session mempool allocation failed");
8556 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
8559 TEST_ASSERT(ret == 0,
8560 "Failed to attach device %u of pmd : %s", i,
8561 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
8563 aesni_ids[nb_devs_attached] = (uint8_t)i;
8572 test_scheduler_detach_slave_op(void)
8574 struct crypto_testsuite_params *ts_params = &testsuite_params;
8575 uint8_t sched_id = ts_params->valid_devs[0];
8579 for (i = 0; i < 2; i++) {
8580 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
8582 TEST_ASSERT(ret == 0,
8583 "Failed to detach device %u", aesni_ids[i]);
8590 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
8592 struct crypto_testsuite_params *ts_params = &testsuite_params;
8593 uint8_t sched_id = ts_params->valid_devs[0];
8595 return rte_cryptodev_scheduler_mode_set(sched_id,
8600 test_scheduler_mode_roundrobin_op(void)
8602 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
8603 0, "Failed to set roundrobin mode");
8609 test_scheduler_mode_multicore_op(void)
8611 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
8612 0, "Failed to set multicore mode");
8618 test_scheduler_mode_failover_op(void)
8620 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
8621 0, "Failed to set failover mode");
8627 test_scheduler_mode_pkt_size_distr_op(void)
8629 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
8630 0, "Failed to set pktsize mode");
8635 static struct unit_test_suite cryptodev_scheduler_testsuite = {
8636 .suite_name = "Crypto Device Scheduler Unit Test Suite",
8637 .setup = testsuite_setup,
8638 .teardown = testsuite_teardown,
8639 .unit_test_cases = {
8641 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8642 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
8643 TEST_CASE_ST(ut_setup, ut_teardown,
8644 test_AES_chain_scheduler_all),
8645 TEST_CASE_ST(ut_setup, ut_teardown,
8646 test_AES_cipheronly_scheduler_all),
8647 TEST_CASE_ST(ut_setup, ut_teardown,
8648 test_authonly_scheduler_all),
8649 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8652 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8653 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
8654 TEST_CASE_ST(ut_setup, ut_teardown,
8655 test_AES_chain_scheduler_all),
8656 TEST_CASE_ST(ut_setup, ut_teardown,
8657 test_AES_cipheronly_scheduler_all),
8658 TEST_CASE_ST(ut_setup, ut_teardown,
8659 test_authonly_scheduler_all),
8660 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8663 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8664 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
8665 TEST_CASE_ST(ut_setup, ut_teardown,
8666 test_AES_chain_scheduler_all),
8667 TEST_CASE_ST(ut_setup, ut_teardown,
8668 test_AES_cipheronly_scheduler_all),
8669 TEST_CASE_ST(ut_setup, ut_teardown,
8670 test_authonly_scheduler_all),
8671 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8674 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
8675 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
8676 TEST_CASE_ST(ut_setup, ut_teardown,
8677 test_AES_chain_scheduler_all),
8678 TEST_CASE_ST(ut_setup, ut_teardown,
8679 test_AES_cipheronly_scheduler_all),
8680 TEST_CASE_ST(ut_setup, ut_teardown,
8681 test_authonly_scheduler_all),
8682 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
8684 TEST_CASES_END() /**< NULL terminate unit test array */
8688 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
8690 static struct unit_test_suite cryptodev_qat_testsuite = {
8691 .suite_name = "Crypto QAT Unit Test Suite",
8692 .setup = testsuite_setup,
8693 .teardown = testsuite_teardown,
8694 .unit_test_cases = {
8695 TEST_CASE_ST(ut_setup, ut_teardown,
8696 test_device_configure_invalid_dev_id),
8697 TEST_CASE_ST(ut_setup, ut_teardown,
8698 test_device_configure_invalid_queue_pair_ids),
8699 TEST_CASE_ST(ut_setup, ut_teardown,
8700 test_queue_pair_descriptor_setup),
8701 TEST_CASE_ST(ut_setup, ut_teardown,
8702 test_multi_session),
8704 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
8705 TEST_CASE_ST(ut_setup, ut_teardown,
8706 test_AES_cipheronly_qat_all),
8707 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
8708 TEST_CASE_ST(ut_setup, ut_teardown,
8709 test_3DES_cipheronly_qat_all),
8710 TEST_CASE_ST(ut_setup, ut_teardown,
8711 test_DES_cipheronly_qat_all),
8712 TEST_CASE_ST(ut_setup, ut_teardown,
8713 test_AES_docsis_qat_all),
8714 TEST_CASE_ST(ut_setup, ut_teardown,
8715 test_DES_docsis_qat_all),
8716 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
8717 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
8719 /** AES CCM Authenticated Encryption 128 bits key */
8720 TEST_CASE_ST(ut_setup, ut_teardown,
8721 test_AES_CCM_authenticated_encryption_test_case_128_1),
8722 TEST_CASE_ST(ut_setup, ut_teardown,
8723 test_AES_CCM_authenticated_encryption_test_case_128_2),
8724 TEST_CASE_ST(ut_setup, ut_teardown,
8725 test_AES_CCM_authenticated_encryption_test_case_128_3),
8727 /** AES CCM Authenticated Decryption 128 bits key*/
8728 TEST_CASE_ST(ut_setup, ut_teardown,
8729 test_AES_CCM_authenticated_decryption_test_case_128_1),
8730 TEST_CASE_ST(ut_setup, ut_teardown,
8731 test_AES_CCM_authenticated_decryption_test_case_128_2),
8732 TEST_CASE_ST(ut_setup, ut_teardown,
8733 test_AES_CCM_authenticated_decryption_test_case_128_3),
8735 /** AES GCM Authenticated Encryption */
8736 TEST_CASE_ST(ut_setup, ut_teardown,
8737 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
8738 TEST_CASE_ST(ut_setup, ut_teardown,
8739 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
8740 TEST_CASE_ST(ut_setup, ut_teardown,
8741 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
8742 TEST_CASE_ST(ut_setup, ut_teardown,
8743 test_AES_GCM_authenticated_encryption_test_case_1),
8744 TEST_CASE_ST(ut_setup, ut_teardown,
8745 test_AES_GCM_authenticated_encryption_test_case_2),
8746 TEST_CASE_ST(ut_setup, ut_teardown,
8747 test_AES_GCM_authenticated_encryption_test_case_3),
8748 TEST_CASE_ST(ut_setup, ut_teardown,
8749 test_AES_GCM_authenticated_encryption_test_case_4),
8750 TEST_CASE_ST(ut_setup, ut_teardown,
8751 test_AES_GCM_authenticated_encryption_test_case_5),
8752 TEST_CASE_ST(ut_setup, ut_teardown,
8753 test_AES_GCM_authenticated_encryption_test_case_6),
8754 TEST_CASE_ST(ut_setup, ut_teardown,
8755 test_AES_GCM_authenticated_encryption_test_case_7),
8757 /** AES GCM Authenticated Decryption */
8758 TEST_CASE_ST(ut_setup, ut_teardown,
8759 test_AES_GCM_authenticated_decryption_test_case_1),
8760 TEST_CASE_ST(ut_setup, ut_teardown,
8761 test_AES_GCM_authenticated_decryption_test_case_2),
8762 TEST_CASE_ST(ut_setup, ut_teardown,
8763 test_AES_GCM_authenticated_decryption_test_case_3),
8764 TEST_CASE_ST(ut_setup, ut_teardown,
8765 test_AES_GCM_authenticated_decryption_test_case_4),
8766 TEST_CASE_ST(ut_setup, ut_teardown,
8767 test_AES_GCM_authenticated_decryption_test_case_5),
8768 TEST_CASE_ST(ut_setup, ut_teardown,
8769 test_AES_GCM_authenticated_decryption_test_case_6),
8770 TEST_CASE_ST(ut_setup, ut_teardown,
8771 test_AES_GCM_authenticated_decryption_test_case_7),
8773 /** AES GCM Authenticated Encryption 192 bits key */
8774 TEST_CASE_ST(ut_setup, ut_teardown,
8775 test_AES_GCM_auth_encryption_test_case_192_1),
8776 TEST_CASE_ST(ut_setup, ut_teardown,
8777 test_AES_GCM_auth_encryption_test_case_192_2),
8778 TEST_CASE_ST(ut_setup, ut_teardown,
8779 test_AES_GCM_auth_encryption_test_case_192_3),
8780 TEST_CASE_ST(ut_setup, ut_teardown,
8781 test_AES_GCM_auth_encryption_test_case_192_4),
8782 TEST_CASE_ST(ut_setup, ut_teardown,
8783 test_AES_GCM_auth_encryption_test_case_192_5),
8784 TEST_CASE_ST(ut_setup, ut_teardown,
8785 test_AES_GCM_auth_encryption_test_case_192_6),
8786 TEST_CASE_ST(ut_setup, ut_teardown,
8787 test_AES_GCM_auth_encryption_test_case_192_7),
8789 /** AES GCM Authenticated Decryption 192 bits key */
8790 TEST_CASE_ST(ut_setup, ut_teardown,
8791 test_AES_GCM_auth_decryption_test_case_192_1),
8792 TEST_CASE_ST(ut_setup, ut_teardown,
8793 test_AES_GCM_auth_decryption_test_case_192_2),
8794 TEST_CASE_ST(ut_setup, ut_teardown,
8795 test_AES_GCM_auth_decryption_test_case_192_3),
8796 TEST_CASE_ST(ut_setup, ut_teardown,
8797 test_AES_GCM_auth_decryption_test_case_192_4),
8798 TEST_CASE_ST(ut_setup, ut_teardown,
8799 test_AES_GCM_auth_decryption_test_case_192_5),
8800 TEST_CASE_ST(ut_setup, ut_teardown,
8801 test_AES_GCM_auth_decryption_test_case_192_6),
8802 TEST_CASE_ST(ut_setup, ut_teardown,
8803 test_AES_GCM_auth_decryption_test_case_192_7),
8805 /** AES GCM Authenticated Encryption 256 bits key */
8806 TEST_CASE_ST(ut_setup, ut_teardown,
8807 test_AES_GCM_auth_encryption_test_case_256_1),
8808 TEST_CASE_ST(ut_setup, ut_teardown,
8809 test_AES_GCM_auth_encryption_test_case_256_2),
8810 TEST_CASE_ST(ut_setup, ut_teardown,
8811 test_AES_GCM_auth_encryption_test_case_256_3),
8812 TEST_CASE_ST(ut_setup, ut_teardown,
8813 test_AES_GCM_auth_encryption_test_case_256_4),
8814 TEST_CASE_ST(ut_setup, ut_teardown,
8815 test_AES_GCM_auth_encryption_test_case_256_5),
8816 TEST_CASE_ST(ut_setup, ut_teardown,
8817 test_AES_GCM_auth_encryption_test_case_256_6),
8818 TEST_CASE_ST(ut_setup, ut_teardown,
8819 test_AES_GCM_auth_encryption_test_case_256_7),
8821 /** AES GMAC Authentication */
8822 TEST_CASE_ST(ut_setup, ut_teardown,
8823 test_AES_GMAC_authentication_test_case_1),
8824 TEST_CASE_ST(ut_setup, ut_teardown,
8825 test_AES_GMAC_authentication_verify_test_case_1),
8826 TEST_CASE_ST(ut_setup, ut_teardown,
8827 test_AES_GMAC_authentication_test_case_2),
8828 TEST_CASE_ST(ut_setup, ut_teardown,
8829 test_AES_GMAC_authentication_verify_test_case_2),
8830 TEST_CASE_ST(ut_setup, ut_teardown,
8831 test_AES_GMAC_authentication_test_case_3),
8832 TEST_CASE_ST(ut_setup, ut_teardown,
8833 test_AES_GMAC_authentication_verify_test_case_3),
8835 /** SNOW 3G encrypt only (UEA2) */
8836 TEST_CASE_ST(ut_setup, ut_teardown,
8837 test_snow3g_encryption_test_case_1),
8838 TEST_CASE_ST(ut_setup, ut_teardown,
8839 test_snow3g_encryption_test_case_2),
8840 TEST_CASE_ST(ut_setup, ut_teardown,
8841 test_snow3g_encryption_test_case_3),
8842 TEST_CASE_ST(ut_setup, ut_teardown,
8843 test_snow3g_encryption_test_case_4),
8844 TEST_CASE_ST(ut_setup, ut_teardown,
8845 test_snow3g_encryption_test_case_5),
8847 TEST_CASE_ST(ut_setup, ut_teardown,
8848 test_snow3g_encryption_test_case_1_oop),
8849 TEST_CASE_ST(ut_setup, ut_teardown,
8850 test_snow3g_decryption_test_case_1_oop),
8852 /** SNOW 3G decrypt only (UEA2) */
8853 TEST_CASE_ST(ut_setup, ut_teardown,
8854 test_snow3g_decryption_test_case_1),
8855 TEST_CASE_ST(ut_setup, ut_teardown,
8856 test_snow3g_decryption_test_case_2),
8857 TEST_CASE_ST(ut_setup, ut_teardown,
8858 test_snow3g_decryption_test_case_3),
8859 TEST_CASE_ST(ut_setup, ut_teardown,
8860 test_snow3g_decryption_test_case_4),
8861 TEST_CASE_ST(ut_setup, ut_teardown,
8862 test_snow3g_decryption_test_case_5),
8863 TEST_CASE_ST(ut_setup, ut_teardown,
8864 test_snow3g_hash_generate_test_case_1),
8865 TEST_CASE_ST(ut_setup, ut_teardown,
8866 test_snow3g_hash_generate_test_case_2),
8867 TEST_CASE_ST(ut_setup, ut_teardown,
8868 test_snow3g_hash_generate_test_case_3),
8869 TEST_CASE_ST(ut_setup, ut_teardown,
8870 test_snow3g_hash_verify_test_case_1),
8871 TEST_CASE_ST(ut_setup, ut_teardown,
8872 test_snow3g_hash_verify_test_case_2),
8873 TEST_CASE_ST(ut_setup, ut_teardown,
8874 test_snow3g_hash_verify_test_case_3),
8875 TEST_CASE_ST(ut_setup, ut_teardown,
8876 test_snow3g_cipher_auth_test_case_1),
8877 TEST_CASE_ST(ut_setup, ut_teardown,
8878 test_snow3g_auth_cipher_test_case_1),
8880 /** ZUC encrypt only (EEA3) */
8881 TEST_CASE_ST(ut_setup, ut_teardown,
8882 test_zuc_encryption_test_case_1),
8883 TEST_CASE_ST(ut_setup, ut_teardown,
8884 test_zuc_encryption_test_case_2),
8885 TEST_CASE_ST(ut_setup, ut_teardown,
8886 test_zuc_encryption_test_case_3),
8887 TEST_CASE_ST(ut_setup, ut_teardown,
8888 test_zuc_encryption_test_case_4),
8889 TEST_CASE_ST(ut_setup, ut_teardown,
8890 test_zuc_encryption_test_case_5),
8892 /** ZUC authenticate (EIA3) */
8893 TEST_CASE_ST(ut_setup, ut_teardown,
8894 test_zuc_hash_generate_test_case_6),
8895 TEST_CASE_ST(ut_setup, ut_teardown,
8896 test_zuc_hash_generate_test_case_7),
8897 TEST_CASE_ST(ut_setup, ut_teardown,
8898 test_zuc_hash_generate_test_case_8),
8900 /** ZUC alg-chain (EEA3/EIA3) */
8901 TEST_CASE_ST(ut_setup, ut_teardown,
8902 test_zuc_cipher_auth_test_case_1),
8903 TEST_CASE_ST(ut_setup, ut_teardown,
8904 test_zuc_cipher_auth_test_case_2),
8906 /** HMAC_MD5 Authentication */
8907 TEST_CASE_ST(ut_setup, ut_teardown,
8908 test_MD5_HMAC_generate_case_1),
8909 TEST_CASE_ST(ut_setup, ut_teardown,
8910 test_MD5_HMAC_verify_case_1),
8911 TEST_CASE_ST(ut_setup, ut_teardown,
8912 test_MD5_HMAC_generate_case_2),
8913 TEST_CASE_ST(ut_setup, ut_teardown,
8914 test_MD5_HMAC_verify_case_2),
8917 TEST_CASE_ST(ut_setup, ut_teardown,
8918 test_null_auth_only_operation),
8919 TEST_CASE_ST(ut_setup, ut_teardown,
8920 test_null_cipher_only_operation),
8921 TEST_CASE_ST(ut_setup, ut_teardown,
8922 test_null_cipher_auth_operation),
8923 TEST_CASE_ST(ut_setup, ut_teardown,
8924 test_null_auth_cipher_operation),
8927 TEST_CASE_ST(ut_setup, ut_teardown,
8928 test_kasumi_hash_generate_test_case_1),
8929 TEST_CASE_ST(ut_setup, ut_teardown,
8930 test_kasumi_hash_generate_test_case_2),
8931 TEST_CASE_ST(ut_setup, ut_teardown,
8932 test_kasumi_hash_generate_test_case_3),
8933 TEST_CASE_ST(ut_setup, ut_teardown,
8934 test_kasumi_hash_generate_test_case_4),
8935 TEST_CASE_ST(ut_setup, ut_teardown,
8936 test_kasumi_hash_generate_test_case_5),
8937 TEST_CASE_ST(ut_setup, ut_teardown,
8938 test_kasumi_hash_generate_test_case_6),
8940 TEST_CASE_ST(ut_setup, ut_teardown,
8941 test_kasumi_hash_verify_test_case_1),
8942 TEST_CASE_ST(ut_setup, ut_teardown,
8943 test_kasumi_hash_verify_test_case_2),
8944 TEST_CASE_ST(ut_setup, ut_teardown,
8945 test_kasumi_hash_verify_test_case_3),
8946 TEST_CASE_ST(ut_setup, ut_teardown,
8947 test_kasumi_hash_verify_test_case_4),
8948 TEST_CASE_ST(ut_setup, ut_teardown,
8949 test_kasumi_hash_verify_test_case_5),
8951 TEST_CASE_ST(ut_setup, ut_teardown,
8952 test_kasumi_encryption_test_case_1),
8953 TEST_CASE_ST(ut_setup, ut_teardown,
8954 test_kasumi_encryption_test_case_3),
8955 TEST_CASE_ST(ut_setup, ut_teardown,
8956 test_kasumi_auth_cipher_test_case_1),
8957 TEST_CASE_ST(ut_setup, ut_teardown,
8958 test_kasumi_cipher_auth_test_case_1),
8960 /** Negative tests */
8961 TEST_CASE_ST(ut_setup, ut_teardown,
8962 authentication_verify_HMAC_SHA1_fail_data_corrupt),
8963 TEST_CASE_ST(ut_setup, ut_teardown,
8964 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
8965 TEST_CASE_ST(ut_setup, ut_teardown,
8966 authentication_verify_AES128_GMAC_fail_data_corrupt),
8967 TEST_CASE_ST(ut_setup, ut_teardown,
8968 authentication_verify_AES128_GMAC_fail_tag_corrupt),
8969 TEST_CASE_ST(ut_setup, ut_teardown,
8970 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
8971 TEST_CASE_ST(ut_setup, ut_teardown,
8972 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
8974 TEST_CASES_END() /**< NULL terminate unit test array */
8978 static struct unit_test_suite cryptodev_virtio_testsuite = {
8979 .suite_name = "Crypto VIRTIO Unit Test Suite",
8980 .setup = testsuite_setup,
8981 .teardown = testsuite_teardown,
8982 .unit_test_cases = {
8983 TEST_CASE_ST(ut_setup, ut_teardown,
8984 test_AES_cipheronly_virtio_all),
8986 TEST_CASES_END() /**< NULL terminate unit test array */
8990 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
8991 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
8992 .setup = testsuite_setup,
8993 .teardown = testsuite_teardown,
8994 .unit_test_cases = {
8995 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
8996 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
8997 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
8998 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
8999 TEST_CASE_ST(ut_setup, ut_teardown,
9000 test_DES_cipheronly_mb_all),
9001 TEST_CASE_ST(ut_setup, ut_teardown,
9002 test_DES_docsis_mb_all),
9003 TEST_CASE_ST(ut_setup, ut_teardown,
9004 test_AES_CCM_authenticated_encryption_test_case_128_1),
9005 TEST_CASE_ST(ut_setup, ut_teardown,
9006 test_AES_CCM_authenticated_decryption_test_case_128_1),
9007 TEST_CASE_ST(ut_setup, ut_teardown,
9008 test_AES_CCM_authenticated_encryption_test_case_128_2),
9009 TEST_CASE_ST(ut_setup, ut_teardown,
9010 test_AES_CCM_authenticated_decryption_test_case_128_2),
9011 TEST_CASE_ST(ut_setup, ut_teardown,
9012 test_AES_CCM_authenticated_encryption_test_case_128_3),
9013 TEST_CASE_ST(ut_setup, ut_teardown,
9014 test_AES_CCM_authenticated_decryption_test_case_128_3),
9016 TEST_CASES_END() /**< NULL terminate unit test array */
9020 static struct unit_test_suite cryptodev_openssl_testsuite = {
9021 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
9022 .setup = testsuite_setup,
9023 .teardown = testsuite_teardown,
9024 .unit_test_cases = {
9025 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9026 TEST_CASE_ST(ut_setup, ut_teardown,
9027 test_multi_session_random_usage),
9028 TEST_CASE_ST(ut_setup, ut_teardown,
9029 test_AES_chain_openssl_all),
9030 TEST_CASE_ST(ut_setup, ut_teardown,
9031 test_AES_cipheronly_openssl_all),
9032 TEST_CASE_ST(ut_setup, ut_teardown,
9033 test_3DES_chain_openssl_all),
9034 TEST_CASE_ST(ut_setup, ut_teardown,
9035 test_3DES_cipheronly_openssl_all),
9036 TEST_CASE_ST(ut_setup, ut_teardown,
9037 test_DES_cipheronly_openssl_all),
9038 TEST_CASE_ST(ut_setup, ut_teardown,
9039 test_DES_docsis_openssl_all),
9040 TEST_CASE_ST(ut_setup, ut_teardown,
9041 test_authonly_openssl_all),
9043 /** AES GCM Authenticated Encryption */
9044 TEST_CASE_ST(ut_setup, ut_teardown,
9045 test_AES_GCM_authenticated_encryption_test_case_1),
9046 TEST_CASE_ST(ut_setup, ut_teardown,
9047 test_AES_GCM_authenticated_encryption_test_case_2),
9048 TEST_CASE_ST(ut_setup, ut_teardown,
9049 test_AES_GCM_authenticated_encryption_test_case_3),
9050 TEST_CASE_ST(ut_setup, ut_teardown,
9051 test_AES_GCM_authenticated_encryption_test_case_4),
9052 TEST_CASE_ST(ut_setup, ut_teardown,
9053 test_AES_GCM_authenticated_encryption_test_case_5),
9054 TEST_CASE_ST(ut_setup, ut_teardown,
9055 test_AES_GCM_authenticated_encryption_test_case_6),
9056 TEST_CASE_ST(ut_setup, ut_teardown,
9057 test_AES_GCM_authenticated_encryption_test_case_7),
9059 /** AES GCM Authenticated Decryption */
9060 TEST_CASE_ST(ut_setup, ut_teardown,
9061 test_AES_GCM_authenticated_decryption_test_case_1),
9062 TEST_CASE_ST(ut_setup, ut_teardown,
9063 test_AES_GCM_authenticated_decryption_test_case_2),
9064 TEST_CASE_ST(ut_setup, ut_teardown,
9065 test_AES_GCM_authenticated_decryption_test_case_3),
9066 TEST_CASE_ST(ut_setup, ut_teardown,
9067 test_AES_GCM_authenticated_decryption_test_case_4),
9068 TEST_CASE_ST(ut_setup, ut_teardown,
9069 test_AES_GCM_authenticated_decryption_test_case_5),
9070 TEST_CASE_ST(ut_setup, ut_teardown,
9071 test_AES_GCM_authenticated_decryption_test_case_6),
9072 TEST_CASE_ST(ut_setup, ut_teardown,
9073 test_AES_GCM_authenticated_decryption_test_case_7),
9076 /** AES GCM Authenticated Encryption 192 bits key */
9077 TEST_CASE_ST(ut_setup, ut_teardown,
9078 test_AES_GCM_auth_encryption_test_case_192_1),
9079 TEST_CASE_ST(ut_setup, ut_teardown,
9080 test_AES_GCM_auth_encryption_test_case_192_2),
9081 TEST_CASE_ST(ut_setup, ut_teardown,
9082 test_AES_GCM_auth_encryption_test_case_192_3),
9083 TEST_CASE_ST(ut_setup, ut_teardown,
9084 test_AES_GCM_auth_encryption_test_case_192_4),
9085 TEST_CASE_ST(ut_setup, ut_teardown,
9086 test_AES_GCM_auth_encryption_test_case_192_5),
9087 TEST_CASE_ST(ut_setup, ut_teardown,
9088 test_AES_GCM_auth_encryption_test_case_192_6),
9089 TEST_CASE_ST(ut_setup, ut_teardown,
9090 test_AES_GCM_auth_encryption_test_case_192_7),
9092 /** AES GCM Authenticated Decryption 192 bits key */
9093 TEST_CASE_ST(ut_setup, ut_teardown,
9094 test_AES_GCM_auth_decryption_test_case_192_1),
9095 TEST_CASE_ST(ut_setup, ut_teardown,
9096 test_AES_GCM_auth_decryption_test_case_192_2),
9097 TEST_CASE_ST(ut_setup, ut_teardown,
9098 test_AES_GCM_auth_decryption_test_case_192_3),
9099 TEST_CASE_ST(ut_setup, ut_teardown,
9100 test_AES_GCM_auth_decryption_test_case_192_4),
9101 TEST_CASE_ST(ut_setup, ut_teardown,
9102 test_AES_GCM_auth_decryption_test_case_192_5),
9103 TEST_CASE_ST(ut_setup, ut_teardown,
9104 test_AES_GCM_auth_decryption_test_case_192_6),
9105 TEST_CASE_ST(ut_setup, ut_teardown,
9106 test_AES_GCM_auth_decryption_test_case_192_7),
9108 /** AES GCM Authenticated Encryption 256 bits key */
9109 TEST_CASE_ST(ut_setup, ut_teardown,
9110 test_AES_GCM_auth_encryption_test_case_256_1),
9111 TEST_CASE_ST(ut_setup, ut_teardown,
9112 test_AES_GCM_auth_encryption_test_case_256_2),
9113 TEST_CASE_ST(ut_setup, ut_teardown,
9114 test_AES_GCM_auth_encryption_test_case_256_3),
9115 TEST_CASE_ST(ut_setup, ut_teardown,
9116 test_AES_GCM_auth_encryption_test_case_256_4),
9117 TEST_CASE_ST(ut_setup, ut_teardown,
9118 test_AES_GCM_auth_encryption_test_case_256_5),
9119 TEST_CASE_ST(ut_setup, ut_teardown,
9120 test_AES_GCM_auth_encryption_test_case_256_6),
9121 TEST_CASE_ST(ut_setup, ut_teardown,
9122 test_AES_GCM_auth_encryption_test_case_256_7),
9124 /** AES GCM Authenticated Decryption 256 bits key */
9125 TEST_CASE_ST(ut_setup, ut_teardown,
9126 test_AES_GCM_auth_decryption_test_case_256_1),
9127 TEST_CASE_ST(ut_setup, ut_teardown,
9128 test_AES_GCM_auth_decryption_test_case_256_2),
9129 TEST_CASE_ST(ut_setup, ut_teardown,
9130 test_AES_GCM_auth_decryption_test_case_256_3),
9131 TEST_CASE_ST(ut_setup, ut_teardown,
9132 test_AES_GCM_auth_decryption_test_case_256_4),
9133 TEST_CASE_ST(ut_setup, ut_teardown,
9134 test_AES_GCM_auth_decryption_test_case_256_5),
9135 TEST_CASE_ST(ut_setup, ut_teardown,
9136 test_AES_GCM_auth_decryption_test_case_256_6),
9137 TEST_CASE_ST(ut_setup, ut_teardown,
9138 test_AES_GCM_auth_decryption_test_case_256_7),
9140 /** AES GMAC Authentication */
9141 TEST_CASE_ST(ut_setup, ut_teardown,
9142 test_AES_GMAC_authentication_test_case_1),
9143 TEST_CASE_ST(ut_setup, ut_teardown,
9144 test_AES_GMAC_authentication_verify_test_case_1),
9145 TEST_CASE_ST(ut_setup, ut_teardown,
9146 test_AES_GMAC_authentication_test_case_2),
9147 TEST_CASE_ST(ut_setup, ut_teardown,
9148 test_AES_GMAC_authentication_verify_test_case_2),
9149 TEST_CASE_ST(ut_setup, ut_teardown,
9150 test_AES_GMAC_authentication_test_case_3),
9151 TEST_CASE_ST(ut_setup, ut_teardown,
9152 test_AES_GMAC_authentication_verify_test_case_3),
9153 TEST_CASE_ST(ut_setup, ut_teardown,
9154 test_AES_GMAC_authentication_test_case_4),
9155 TEST_CASE_ST(ut_setup, ut_teardown,
9156 test_AES_GMAC_authentication_verify_test_case_4),
9158 /** AES CCM Authenticated Encryption 128 bits key */
9159 TEST_CASE_ST(ut_setup, ut_teardown,
9160 test_AES_CCM_authenticated_encryption_test_case_128_1),
9161 TEST_CASE_ST(ut_setup, ut_teardown,
9162 test_AES_CCM_authenticated_encryption_test_case_128_2),
9163 TEST_CASE_ST(ut_setup, ut_teardown,
9164 test_AES_CCM_authenticated_encryption_test_case_128_3),
9166 /** AES CCM Authenticated Decryption 128 bits key*/
9167 TEST_CASE_ST(ut_setup, ut_teardown,
9168 test_AES_CCM_authenticated_decryption_test_case_128_1),
9169 TEST_CASE_ST(ut_setup, ut_teardown,
9170 test_AES_CCM_authenticated_decryption_test_case_128_2),
9171 TEST_CASE_ST(ut_setup, ut_teardown,
9172 test_AES_CCM_authenticated_decryption_test_case_128_3),
9174 /** AES CCM Authenticated Encryption 192 bits key */
9175 TEST_CASE_ST(ut_setup, ut_teardown,
9176 test_AES_CCM_authenticated_encryption_test_case_192_1),
9177 TEST_CASE_ST(ut_setup, ut_teardown,
9178 test_AES_CCM_authenticated_encryption_test_case_192_2),
9179 TEST_CASE_ST(ut_setup, ut_teardown,
9180 test_AES_CCM_authenticated_encryption_test_case_192_3),
9182 /** AES CCM Authenticated Decryption 192 bits key*/
9183 TEST_CASE_ST(ut_setup, ut_teardown,
9184 test_AES_CCM_authenticated_decryption_test_case_192_1),
9185 TEST_CASE_ST(ut_setup, ut_teardown,
9186 test_AES_CCM_authenticated_decryption_test_case_192_2),
9187 TEST_CASE_ST(ut_setup, ut_teardown,
9188 test_AES_CCM_authenticated_decryption_test_case_192_3),
9190 /** AES CCM Authenticated Encryption 256 bits key */
9191 TEST_CASE_ST(ut_setup, ut_teardown,
9192 test_AES_CCM_authenticated_encryption_test_case_256_1),
9193 TEST_CASE_ST(ut_setup, ut_teardown,
9194 test_AES_CCM_authenticated_encryption_test_case_256_2),
9195 TEST_CASE_ST(ut_setup, ut_teardown,
9196 test_AES_CCM_authenticated_encryption_test_case_256_3),
9198 /** AES CCM Authenticated Decryption 256 bits key*/
9199 TEST_CASE_ST(ut_setup, ut_teardown,
9200 test_AES_CCM_authenticated_decryption_test_case_256_1),
9201 TEST_CASE_ST(ut_setup, ut_teardown,
9202 test_AES_CCM_authenticated_decryption_test_case_256_2),
9203 TEST_CASE_ST(ut_setup, ut_teardown,
9204 test_AES_CCM_authenticated_decryption_test_case_256_3),
9206 /** Scatter-Gather */
9207 TEST_CASE_ST(ut_setup, ut_teardown,
9208 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9210 /** Negative tests */
9211 TEST_CASE_ST(ut_setup, ut_teardown,
9212 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9213 TEST_CASE_ST(ut_setup, ut_teardown,
9214 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9215 TEST_CASE_ST(ut_setup, ut_teardown,
9216 authentication_verify_AES128_GMAC_fail_data_corrupt),
9217 TEST_CASE_ST(ut_setup, ut_teardown,
9218 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9219 TEST_CASE_ST(ut_setup, ut_teardown,
9220 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9221 TEST_CASE_ST(ut_setup, ut_teardown,
9222 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9224 TEST_CASES_END() /**< NULL terminate unit test array */
9228 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
9229 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
9230 .setup = testsuite_setup,
9231 .teardown = testsuite_teardown,
9232 .unit_test_cases = {
9233 /** AES GCM Authenticated Encryption */
9234 TEST_CASE_ST(ut_setup, ut_teardown,
9235 test_AES_GCM_authenticated_encryption_test_case_1),
9236 TEST_CASE_ST(ut_setup, ut_teardown,
9237 test_AES_GCM_authenticated_encryption_test_case_2),
9238 TEST_CASE_ST(ut_setup, ut_teardown,
9239 test_AES_GCM_authenticated_encryption_test_case_3),
9240 TEST_CASE_ST(ut_setup, ut_teardown,
9241 test_AES_GCM_authenticated_encryption_test_case_4),
9242 TEST_CASE_ST(ut_setup, ut_teardown,
9243 test_AES_GCM_authenticated_encryption_test_case_5),
9244 TEST_CASE_ST(ut_setup, ut_teardown,
9245 test_AES_GCM_authenticated_encryption_test_case_6),
9246 TEST_CASE_ST(ut_setup, ut_teardown,
9247 test_AES_GCM_authenticated_encryption_test_case_7),
9249 /** AES GCM Authenticated Decryption */
9250 TEST_CASE_ST(ut_setup, ut_teardown,
9251 test_AES_GCM_authenticated_decryption_test_case_1),
9252 TEST_CASE_ST(ut_setup, ut_teardown,
9253 test_AES_GCM_authenticated_decryption_test_case_2),
9254 TEST_CASE_ST(ut_setup, ut_teardown,
9255 test_AES_GCM_authenticated_decryption_test_case_3),
9256 TEST_CASE_ST(ut_setup, ut_teardown,
9257 test_AES_GCM_authenticated_decryption_test_case_4),
9258 TEST_CASE_ST(ut_setup, ut_teardown,
9259 test_AES_GCM_authenticated_decryption_test_case_5),
9260 TEST_CASE_ST(ut_setup, ut_teardown,
9261 test_AES_GCM_authenticated_decryption_test_case_6),
9262 TEST_CASE_ST(ut_setup, ut_teardown,
9263 test_AES_GCM_authenticated_decryption_test_case_7),
9265 /** AES GCM Authenticated Encryption 192 bits key */
9266 TEST_CASE_ST(ut_setup, ut_teardown,
9267 test_AES_GCM_auth_encryption_test_case_192_1),
9268 TEST_CASE_ST(ut_setup, ut_teardown,
9269 test_AES_GCM_auth_encryption_test_case_192_2),
9270 TEST_CASE_ST(ut_setup, ut_teardown,
9271 test_AES_GCM_auth_encryption_test_case_192_3),
9272 TEST_CASE_ST(ut_setup, ut_teardown,
9273 test_AES_GCM_auth_encryption_test_case_192_4),
9274 TEST_CASE_ST(ut_setup, ut_teardown,
9275 test_AES_GCM_auth_encryption_test_case_192_5),
9276 TEST_CASE_ST(ut_setup, ut_teardown,
9277 test_AES_GCM_auth_encryption_test_case_192_6),
9278 TEST_CASE_ST(ut_setup, ut_teardown,
9279 test_AES_GCM_auth_encryption_test_case_192_7),
9281 /** AES GCM Authenticated Decryption 192 bits key */
9282 TEST_CASE_ST(ut_setup, ut_teardown,
9283 test_AES_GCM_auth_decryption_test_case_192_1),
9284 TEST_CASE_ST(ut_setup, ut_teardown,
9285 test_AES_GCM_auth_decryption_test_case_192_2),
9286 TEST_CASE_ST(ut_setup, ut_teardown,
9287 test_AES_GCM_auth_decryption_test_case_192_3),
9288 TEST_CASE_ST(ut_setup, ut_teardown,
9289 test_AES_GCM_auth_decryption_test_case_192_4),
9290 TEST_CASE_ST(ut_setup, ut_teardown,
9291 test_AES_GCM_auth_decryption_test_case_192_5),
9292 TEST_CASE_ST(ut_setup, ut_teardown,
9293 test_AES_GCM_auth_decryption_test_case_192_6),
9294 TEST_CASE_ST(ut_setup, ut_teardown,
9295 test_AES_GCM_auth_decryption_test_case_192_7),
9297 /** AES GCM Authenticated Encryption 256 bits key */
9298 TEST_CASE_ST(ut_setup, ut_teardown,
9299 test_AES_GCM_auth_encryption_test_case_256_1),
9300 TEST_CASE_ST(ut_setup, ut_teardown,
9301 test_AES_GCM_auth_encryption_test_case_256_2),
9302 TEST_CASE_ST(ut_setup, ut_teardown,
9303 test_AES_GCM_auth_encryption_test_case_256_3),
9304 TEST_CASE_ST(ut_setup, ut_teardown,
9305 test_AES_GCM_auth_encryption_test_case_256_4),
9306 TEST_CASE_ST(ut_setup, ut_teardown,
9307 test_AES_GCM_auth_encryption_test_case_256_5),
9308 TEST_CASE_ST(ut_setup, ut_teardown,
9309 test_AES_GCM_auth_encryption_test_case_256_6),
9310 TEST_CASE_ST(ut_setup, ut_teardown,
9311 test_AES_GCM_auth_encryption_test_case_256_7),
9313 /** AES GCM Authenticated Decryption 256 bits key */
9314 TEST_CASE_ST(ut_setup, ut_teardown,
9315 test_AES_GCM_auth_decryption_test_case_256_1),
9316 TEST_CASE_ST(ut_setup, ut_teardown,
9317 test_AES_GCM_auth_decryption_test_case_256_2),
9318 TEST_CASE_ST(ut_setup, ut_teardown,
9319 test_AES_GCM_auth_decryption_test_case_256_3),
9320 TEST_CASE_ST(ut_setup, ut_teardown,
9321 test_AES_GCM_auth_decryption_test_case_256_4),
9322 TEST_CASE_ST(ut_setup, ut_teardown,
9323 test_AES_GCM_auth_decryption_test_case_256_5),
9324 TEST_CASE_ST(ut_setup, ut_teardown,
9325 test_AES_GCM_auth_decryption_test_case_256_6),
9326 TEST_CASE_ST(ut_setup, ut_teardown,
9327 test_AES_GCM_auth_decryption_test_case_256_7),
9329 /** AES GCM Authenticated Encryption big aad size */
9330 TEST_CASE_ST(ut_setup, ut_teardown,
9331 test_AES_GCM_auth_encryption_test_case_aad_1),
9332 TEST_CASE_ST(ut_setup, ut_teardown,
9333 test_AES_GCM_auth_encryption_test_case_aad_2),
9335 /** AES GCM Authenticated Decryption big aad size */
9336 TEST_CASE_ST(ut_setup, ut_teardown,
9337 test_AES_GCM_auth_decryption_test_case_aad_1),
9338 TEST_CASE_ST(ut_setup, ut_teardown,
9339 test_AES_GCM_auth_decryption_test_case_aad_2),
9341 /** AES GMAC Authentication */
9342 TEST_CASE_ST(ut_setup, ut_teardown,
9343 test_AES_GMAC_authentication_test_case_1),
9344 TEST_CASE_ST(ut_setup, ut_teardown,
9345 test_AES_GMAC_authentication_verify_test_case_1),
9346 TEST_CASE_ST(ut_setup, ut_teardown,
9347 test_AES_GMAC_authentication_test_case_3),
9348 TEST_CASE_ST(ut_setup, ut_teardown,
9349 test_AES_GMAC_authentication_verify_test_case_3),
9350 TEST_CASE_ST(ut_setup, ut_teardown,
9351 test_AES_GMAC_authentication_test_case_4),
9352 TEST_CASE_ST(ut_setup, ut_teardown,
9353 test_AES_GMAC_authentication_verify_test_case_4),
9355 /** Negative tests */
9356 TEST_CASE_ST(ut_setup, ut_teardown,
9357 authentication_verify_AES128_GMAC_fail_data_corrupt),
9358 TEST_CASE_ST(ut_setup, ut_teardown,
9359 authentication_verify_AES128_GMAC_fail_tag_corrupt),
9361 /** Out of place tests */
9362 TEST_CASE_ST(ut_setup, ut_teardown,
9363 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9364 TEST_CASE_ST(ut_setup, ut_teardown,
9365 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9367 /** Session-less tests */
9368 TEST_CASE_ST(ut_setup, ut_teardown,
9369 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
9370 TEST_CASE_ST(ut_setup, ut_teardown,
9371 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
9373 /** Scatter-Gather */
9374 TEST_CASE_ST(ut_setup, ut_teardown,
9375 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9377 TEST_CASES_END() /**< NULL terminate unit test array */
9381 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
9382 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
9383 .setup = testsuite_setup,
9384 .teardown = testsuite_teardown,
9385 .unit_test_cases = {
9386 /** KASUMI encrypt only (UEA1) */
9387 TEST_CASE_ST(ut_setup, ut_teardown,
9388 test_kasumi_encryption_test_case_1),
9389 TEST_CASE_ST(ut_setup, ut_teardown,
9390 test_kasumi_encryption_test_case_1_sgl),
9391 TEST_CASE_ST(ut_setup, ut_teardown,
9392 test_kasumi_encryption_test_case_2),
9393 TEST_CASE_ST(ut_setup, ut_teardown,
9394 test_kasumi_encryption_test_case_3),
9395 TEST_CASE_ST(ut_setup, ut_teardown,
9396 test_kasumi_encryption_test_case_4),
9397 TEST_CASE_ST(ut_setup, ut_teardown,
9398 test_kasumi_encryption_test_case_5),
9399 /** KASUMI decrypt only (UEA1) */
9400 TEST_CASE_ST(ut_setup, ut_teardown,
9401 test_kasumi_decryption_test_case_1),
9402 TEST_CASE_ST(ut_setup, ut_teardown,
9403 test_kasumi_decryption_test_case_2),
9404 TEST_CASE_ST(ut_setup, ut_teardown,
9405 test_kasumi_decryption_test_case_3),
9406 TEST_CASE_ST(ut_setup, ut_teardown,
9407 test_kasumi_decryption_test_case_4),
9408 TEST_CASE_ST(ut_setup, ut_teardown,
9409 test_kasumi_decryption_test_case_5),
9411 TEST_CASE_ST(ut_setup, ut_teardown,
9412 test_kasumi_encryption_test_case_1_oop),
9413 TEST_CASE_ST(ut_setup, ut_teardown,
9414 test_kasumi_encryption_test_case_1_oop_sgl),
9417 TEST_CASE_ST(ut_setup, ut_teardown,
9418 test_kasumi_decryption_test_case_1_oop),
9420 /** KASUMI hash only (UIA1) */
9421 TEST_CASE_ST(ut_setup, ut_teardown,
9422 test_kasumi_hash_generate_test_case_1),
9423 TEST_CASE_ST(ut_setup, ut_teardown,
9424 test_kasumi_hash_generate_test_case_2),
9425 TEST_CASE_ST(ut_setup, ut_teardown,
9426 test_kasumi_hash_generate_test_case_3),
9427 TEST_CASE_ST(ut_setup, ut_teardown,
9428 test_kasumi_hash_generate_test_case_4),
9429 TEST_CASE_ST(ut_setup, ut_teardown,
9430 test_kasumi_hash_generate_test_case_5),
9431 TEST_CASE_ST(ut_setup, ut_teardown,
9432 test_kasumi_hash_generate_test_case_6),
9433 TEST_CASE_ST(ut_setup, ut_teardown,
9434 test_kasumi_hash_verify_test_case_1),
9435 TEST_CASE_ST(ut_setup, ut_teardown,
9436 test_kasumi_hash_verify_test_case_2),
9437 TEST_CASE_ST(ut_setup, ut_teardown,
9438 test_kasumi_hash_verify_test_case_3),
9439 TEST_CASE_ST(ut_setup, ut_teardown,
9440 test_kasumi_hash_verify_test_case_4),
9441 TEST_CASE_ST(ut_setup, ut_teardown,
9442 test_kasumi_hash_verify_test_case_5),
9443 TEST_CASE_ST(ut_setup, ut_teardown,
9444 test_kasumi_auth_cipher_test_case_1),
9445 TEST_CASE_ST(ut_setup, ut_teardown,
9446 test_kasumi_cipher_auth_test_case_1),
9447 TEST_CASES_END() /**< NULL terminate unit test array */
9450 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
9451 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
9452 .setup = testsuite_setup,
9453 .teardown = testsuite_teardown,
9454 .unit_test_cases = {
9455 /** SNOW 3G encrypt only (UEA2) */
9456 TEST_CASE_ST(ut_setup, ut_teardown,
9457 test_snow3g_encryption_test_case_1),
9458 TEST_CASE_ST(ut_setup, ut_teardown,
9459 test_snow3g_encryption_test_case_2),
9460 TEST_CASE_ST(ut_setup, ut_teardown,
9461 test_snow3g_encryption_test_case_3),
9462 TEST_CASE_ST(ut_setup, ut_teardown,
9463 test_snow3g_encryption_test_case_4),
9464 TEST_CASE_ST(ut_setup, ut_teardown,
9465 test_snow3g_encryption_test_case_5),
9467 TEST_CASE_ST(ut_setup, ut_teardown,
9468 test_snow3g_encryption_test_case_1_oop),
9469 TEST_CASE_ST(ut_setup, ut_teardown,
9470 test_snow3g_encryption_test_case_1_oop_sgl),
9471 TEST_CASE_ST(ut_setup, ut_teardown,
9472 test_snow3g_decryption_test_case_1_oop),
9474 TEST_CASE_ST(ut_setup, ut_teardown,
9475 test_snow3g_encryption_test_case_1_offset_oop),
9477 /** SNOW 3G decrypt only (UEA2) */
9478 TEST_CASE_ST(ut_setup, ut_teardown,
9479 test_snow3g_decryption_test_case_1),
9480 TEST_CASE_ST(ut_setup, ut_teardown,
9481 test_snow3g_decryption_test_case_2),
9482 TEST_CASE_ST(ut_setup, ut_teardown,
9483 test_snow3g_decryption_test_case_3),
9484 TEST_CASE_ST(ut_setup, ut_teardown,
9485 test_snow3g_decryption_test_case_4),
9486 TEST_CASE_ST(ut_setup, ut_teardown,
9487 test_snow3g_decryption_test_case_5),
9488 TEST_CASE_ST(ut_setup, ut_teardown,
9489 test_snow3g_hash_generate_test_case_1),
9490 TEST_CASE_ST(ut_setup, ut_teardown,
9491 test_snow3g_hash_generate_test_case_2),
9492 TEST_CASE_ST(ut_setup, ut_teardown,
9493 test_snow3g_hash_generate_test_case_3),
9494 /* Tests with buffers which length is not byte-aligned */
9495 TEST_CASE_ST(ut_setup, ut_teardown,
9496 test_snow3g_hash_generate_test_case_4),
9497 TEST_CASE_ST(ut_setup, ut_teardown,
9498 test_snow3g_hash_generate_test_case_5),
9499 TEST_CASE_ST(ut_setup, ut_teardown,
9500 test_snow3g_hash_generate_test_case_6),
9501 TEST_CASE_ST(ut_setup, ut_teardown,
9502 test_snow3g_hash_verify_test_case_1),
9503 TEST_CASE_ST(ut_setup, ut_teardown,
9504 test_snow3g_hash_verify_test_case_2),
9505 TEST_CASE_ST(ut_setup, ut_teardown,
9506 test_snow3g_hash_verify_test_case_3),
9507 /* Tests with buffers which length is not byte-aligned */
9508 TEST_CASE_ST(ut_setup, ut_teardown,
9509 test_snow3g_hash_verify_test_case_4),
9510 TEST_CASE_ST(ut_setup, ut_teardown,
9511 test_snow3g_hash_verify_test_case_5),
9512 TEST_CASE_ST(ut_setup, ut_teardown,
9513 test_snow3g_hash_verify_test_case_6),
9514 TEST_CASE_ST(ut_setup, ut_teardown,
9515 test_snow3g_cipher_auth_test_case_1),
9516 TEST_CASE_ST(ut_setup, ut_teardown,
9517 test_snow3g_auth_cipher_test_case_1),
9519 TEST_CASES_END() /**< NULL terminate unit test array */
9523 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
9524 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
9525 .setup = testsuite_setup,
9526 .teardown = testsuite_teardown,
9527 .unit_test_cases = {
9528 /** ZUC encrypt only (EEA3) */
9529 TEST_CASE_ST(ut_setup, ut_teardown,
9530 test_zuc_encryption_test_case_1),
9531 TEST_CASE_ST(ut_setup, ut_teardown,
9532 test_zuc_encryption_test_case_2),
9533 TEST_CASE_ST(ut_setup, ut_teardown,
9534 test_zuc_encryption_test_case_3),
9535 TEST_CASE_ST(ut_setup, ut_teardown,
9536 test_zuc_encryption_test_case_4),
9537 TEST_CASE_ST(ut_setup, ut_teardown,
9538 test_zuc_encryption_test_case_5),
9539 TEST_CASE_ST(ut_setup, ut_teardown,
9540 test_zuc_hash_generate_test_case_1),
9541 TEST_CASE_ST(ut_setup, ut_teardown,
9542 test_zuc_hash_generate_test_case_2),
9543 TEST_CASE_ST(ut_setup, ut_teardown,
9544 test_zuc_hash_generate_test_case_3),
9545 TEST_CASE_ST(ut_setup, ut_teardown,
9546 test_zuc_hash_generate_test_case_4),
9547 TEST_CASE_ST(ut_setup, ut_teardown,
9548 test_zuc_hash_generate_test_case_5),
9549 TEST_CASE_ST(ut_setup, ut_teardown,
9550 test_zuc_encryption_test_case_6_sgl),
9551 TEST_CASES_END() /**< NULL terminate unit test array */
9555 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
9556 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
9557 .setup = testsuite_setup,
9558 .teardown = testsuite_teardown,
9559 .unit_test_cases = {
9560 TEST_CASE_ST(ut_setup, ut_teardown,
9561 test_device_configure_invalid_dev_id),
9562 TEST_CASE_ST(ut_setup, ut_teardown,
9563 test_multi_session),
9565 TEST_CASE_ST(ut_setup, ut_teardown,
9566 test_AES_chain_dpaa_sec_all),
9567 TEST_CASE_ST(ut_setup, ut_teardown,
9568 test_3DES_chain_dpaa_sec_all),
9569 TEST_CASE_ST(ut_setup, ut_teardown,
9570 test_AES_cipheronly_dpaa_sec_all),
9571 TEST_CASE_ST(ut_setup, ut_teardown,
9572 test_3DES_cipheronly_dpaa_sec_all),
9573 TEST_CASE_ST(ut_setup, ut_teardown,
9574 test_authonly_dpaa_sec_all),
9576 /** AES GCM Authenticated Encryption */
9577 TEST_CASE_ST(ut_setup, ut_teardown,
9578 test_AES_GCM_authenticated_encryption_test_case_1),
9579 TEST_CASE_ST(ut_setup, ut_teardown,
9580 test_AES_GCM_authenticated_encryption_test_case_2),
9581 TEST_CASE_ST(ut_setup, ut_teardown,
9582 test_AES_GCM_authenticated_encryption_test_case_3),
9583 TEST_CASE_ST(ut_setup, ut_teardown,
9584 test_AES_GCM_authenticated_encryption_test_case_4),
9585 TEST_CASE_ST(ut_setup, ut_teardown,
9586 test_AES_GCM_authenticated_encryption_test_case_5),
9587 TEST_CASE_ST(ut_setup, ut_teardown,
9588 test_AES_GCM_authenticated_encryption_test_case_6),
9589 TEST_CASE_ST(ut_setup, ut_teardown,
9590 test_AES_GCM_authenticated_encryption_test_case_7),
9592 /** AES GCM Authenticated Decryption */
9593 TEST_CASE_ST(ut_setup, ut_teardown,
9594 test_AES_GCM_authenticated_decryption_test_case_1),
9595 TEST_CASE_ST(ut_setup, ut_teardown,
9596 test_AES_GCM_authenticated_decryption_test_case_2),
9597 TEST_CASE_ST(ut_setup, ut_teardown,
9598 test_AES_GCM_authenticated_decryption_test_case_3),
9599 TEST_CASE_ST(ut_setup, ut_teardown,
9600 test_AES_GCM_authenticated_decryption_test_case_4),
9601 TEST_CASE_ST(ut_setup, ut_teardown,
9602 test_AES_GCM_authenticated_decryption_test_case_5),
9603 TEST_CASE_ST(ut_setup, ut_teardown,
9604 test_AES_GCM_authenticated_decryption_test_case_6),
9605 TEST_CASE_ST(ut_setup, ut_teardown,
9606 test_AES_GCM_authenticated_decryption_test_case_7),
9608 /** AES GCM Authenticated Encryption 256 bits key */
9609 TEST_CASE_ST(ut_setup, ut_teardown,
9610 test_AES_GCM_auth_encryption_test_case_256_1),
9611 TEST_CASE_ST(ut_setup, ut_teardown,
9612 test_AES_GCM_auth_encryption_test_case_256_2),
9613 TEST_CASE_ST(ut_setup, ut_teardown,
9614 test_AES_GCM_auth_encryption_test_case_256_3),
9615 TEST_CASE_ST(ut_setup, ut_teardown,
9616 test_AES_GCM_auth_encryption_test_case_256_4),
9617 TEST_CASE_ST(ut_setup, ut_teardown,
9618 test_AES_GCM_auth_encryption_test_case_256_5),
9619 TEST_CASE_ST(ut_setup, ut_teardown,
9620 test_AES_GCM_auth_encryption_test_case_256_6),
9621 TEST_CASE_ST(ut_setup, ut_teardown,
9622 test_AES_GCM_auth_encryption_test_case_256_7),
9624 /** AES GCM Authenticated Decryption 256 bits key */
9625 TEST_CASE_ST(ut_setup, ut_teardown,
9626 test_AES_GCM_auth_decryption_test_case_256_1),
9627 TEST_CASE_ST(ut_setup, ut_teardown,
9628 test_AES_GCM_auth_decryption_test_case_256_2),
9629 TEST_CASE_ST(ut_setup, ut_teardown,
9630 test_AES_GCM_auth_decryption_test_case_256_3),
9631 TEST_CASE_ST(ut_setup, ut_teardown,
9632 test_AES_GCM_auth_decryption_test_case_256_4),
9633 TEST_CASE_ST(ut_setup, ut_teardown,
9634 test_AES_GCM_auth_decryption_test_case_256_5),
9635 TEST_CASE_ST(ut_setup, ut_teardown,
9636 test_AES_GCM_auth_decryption_test_case_256_6),
9637 TEST_CASE_ST(ut_setup, ut_teardown,
9638 test_AES_GCM_auth_decryption_test_case_256_7),
9640 /** Out of place tests */
9641 TEST_CASE_ST(ut_setup, ut_teardown,
9642 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9643 TEST_CASE_ST(ut_setup, ut_teardown,
9644 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9646 /** Scatter-Gather */
9647 TEST_CASE_ST(ut_setup, ut_teardown,
9648 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9649 TEST_CASE_ST(ut_setup, ut_teardown,
9650 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9651 TEST_CASE_ST(ut_setup, ut_teardown,
9652 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9653 TEST_CASE_ST(ut_setup, ut_teardown,
9654 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9656 TEST_CASES_END() /**< NULL terminate unit test array */
9660 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
9661 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
9662 .setup = testsuite_setup,
9663 .teardown = testsuite_teardown,
9664 .unit_test_cases = {
9665 TEST_CASE_ST(ut_setup, ut_teardown,
9666 test_device_configure_invalid_dev_id),
9667 TEST_CASE_ST(ut_setup, ut_teardown,
9668 test_multi_session),
9670 TEST_CASE_ST(ut_setup, ut_teardown,
9671 test_AES_chain_dpaa2_sec_all),
9672 TEST_CASE_ST(ut_setup, ut_teardown,
9673 test_3DES_chain_dpaa2_sec_all),
9674 TEST_CASE_ST(ut_setup, ut_teardown,
9675 test_AES_cipheronly_dpaa2_sec_all),
9676 TEST_CASE_ST(ut_setup, ut_teardown,
9677 test_3DES_cipheronly_dpaa2_sec_all),
9678 TEST_CASE_ST(ut_setup, ut_teardown,
9679 test_authonly_dpaa2_sec_all),
9681 /** AES GCM Authenticated Encryption */
9682 TEST_CASE_ST(ut_setup, ut_teardown,
9683 test_AES_GCM_authenticated_encryption_test_case_1),
9684 TEST_CASE_ST(ut_setup, ut_teardown,
9685 test_AES_GCM_authenticated_encryption_test_case_2),
9686 TEST_CASE_ST(ut_setup, ut_teardown,
9687 test_AES_GCM_authenticated_encryption_test_case_3),
9688 TEST_CASE_ST(ut_setup, ut_teardown,
9689 test_AES_GCM_authenticated_encryption_test_case_4),
9690 TEST_CASE_ST(ut_setup, ut_teardown,
9691 test_AES_GCM_authenticated_encryption_test_case_5),
9692 TEST_CASE_ST(ut_setup, ut_teardown,
9693 test_AES_GCM_authenticated_encryption_test_case_6),
9694 TEST_CASE_ST(ut_setup, ut_teardown,
9695 test_AES_GCM_authenticated_encryption_test_case_7),
9697 /** AES GCM Authenticated Decryption */
9698 TEST_CASE_ST(ut_setup, ut_teardown,
9699 test_AES_GCM_authenticated_decryption_test_case_1),
9700 TEST_CASE_ST(ut_setup, ut_teardown,
9701 test_AES_GCM_authenticated_decryption_test_case_2),
9702 TEST_CASE_ST(ut_setup, ut_teardown,
9703 test_AES_GCM_authenticated_decryption_test_case_3),
9704 TEST_CASE_ST(ut_setup, ut_teardown,
9705 test_AES_GCM_authenticated_decryption_test_case_4),
9706 TEST_CASE_ST(ut_setup, ut_teardown,
9707 test_AES_GCM_authenticated_decryption_test_case_5),
9708 TEST_CASE_ST(ut_setup, ut_teardown,
9709 test_AES_GCM_authenticated_decryption_test_case_6),
9710 TEST_CASE_ST(ut_setup, ut_teardown,
9711 test_AES_GCM_authenticated_decryption_test_case_7),
9713 /** AES GCM Authenticated Encryption 192 bits key */
9714 TEST_CASE_ST(ut_setup, ut_teardown,
9715 test_AES_GCM_auth_encryption_test_case_192_1),
9716 TEST_CASE_ST(ut_setup, ut_teardown,
9717 test_AES_GCM_auth_encryption_test_case_192_2),
9718 TEST_CASE_ST(ut_setup, ut_teardown,
9719 test_AES_GCM_auth_encryption_test_case_192_3),
9720 TEST_CASE_ST(ut_setup, ut_teardown,
9721 test_AES_GCM_auth_encryption_test_case_192_4),
9722 TEST_CASE_ST(ut_setup, ut_teardown,
9723 test_AES_GCM_auth_encryption_test_case_192_5),
9724 TEST_CASE_ST(ut_setup, ut_teardown,
9725 test_AES_GCM_auth_encryption_test_case_192_6),
9726 TEST_CASE_ST(ut_setup, ut_teardown,
9727 test_AES_GCM_auth_encryption_test_case_192_7),
9729 /** AES GCM Authenticated Decryption 192 bits key */
9730 TEST_CASE_ST(ut_setup, ut_teardown,
9731 test_AES_GCM_auth_decryption_test_case_192_1),
9732 TEST_CASE_ST(ut_setup, ut_teardown,
9733 test_AES_GCM_auth_decryption_test_case_192_2),
9734 TEST_CASE_ST(ut_setup, ut_teardown,
9735 test_AES_GCM_auth_decryption_test_case_192_3),
9736 TEST_CASE_ST(ut_setup, ut_teardown,
9737 test_AES_GCM_auth_decryption_test_case_192_4),
9738 TEST_CASE_ST(ut_setup, ut_teardown,
9739 test_AES_GCM_auth_decryption_test_case_192_5),
9740 TEST_CASE_ST(ut_setup, ut_teardown,
9741 test_AES_GCM_auth_decryption_test_case_192_6),
9742 TEST_CASE_ST(ut_setup, ut_teardown,
9743 test_AES_GCM_auth_decryption_test_case_192_7),
9745 /** AES GCM Authenticated Encryption 256 bits key */
9746 TEST_CASE_ST(ut_setup, ut_teardown,
9747 test_AES_GCM_auth_encryption_test_case_256_1),
9748 TEST_CASE_ST(ut_setup, ut_teardown,
9749 test_AES_GCM_auth_encryption_test_case_256_2),
9750 TEST_CASE_ST(ut_setup, ut_teardown,
9751 test_AES_GCM_auth_encryption_test_case_256_3),
9752 TEST_CASE_ST(ut_setup, ut_teardown,
9753 test_AES_GCM_auth_encryption_test_case_256_4),
9754 TEST_CASE_ST(ut_setup, ut_teardown,
9755 test_AES_GCM_auth_encryption_test_case_256_5),
9756 TEST_CASE_ST(ut_setup, ut_teardown,
9757 test_AES_GCM_auth_encryption_test_case_256_6),
9758 TEST_CASE_ST(ut_setup, ut_teardown,
9759 test_AES_GCM_auth_encryption_test_case_256_7),
9761 /** AES GCM Authenticated Decryption 256 bits key */
9762 TEST_CASE_ST(ut_setup, ut_teardown,
9763 test_AES_GCM_auth_decryption_test_case_256_1),
9764 TEST_CASE_ST(ut_setup, ut_teardown,
9765 test_AES_GCM_auth_decryption_test_case_256_2),
9766 TEST_CASE_ST(ut_setup, ut_teardown,
9767 test_AES_GCM_auth_decryption_test_case_256_3),
9768 TEST_CASE_ST(ut_setup, ut_teardown,
9769 test_AES_GCM_auth_decryption_test_case_256_4),
9770 TEST_CASE_ST(ut_setup, ut_teardown,
9771 test_AES_GCM_auth_decryption_test_case_256_5),
9772 TEST_CASE_ST(ut_setup, ut_teardown,
9773 test_AES_GCM_auth_decryption_test_case_256_6),
9774 TEST_CASE_ST(ut_setup, ut_teardown,
9775 test_AES_GCM_auth_decryption_test_case_256_7),
9777 /** Out of place tests */
9778 TEST_CASE_ST(ut_setup, ut_teardown,
9779 test_AES_GCM_authenticated_encryption_oop_test_case_1),
9780 TEST_CASE_ST(ut_setup, ut_teardown,
9781 test_AES_GCM_authenticated_decryption_oop_test_case_1),
9783 /** Scatter-Gather */
9784 TEST_CASE_ST(ut_setup, ut_teardown,
9785 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
9786 TEST_CASE_ST(ut_setup, ut_teardown,
9787 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
9788 TEST_CASE_ST(ut_setup, ut_teardown,
9789 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
9790 TEST_CASE_ST(ut_setup, ut_teardown,
9791 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
9793 TEST_CASES_END() /**< NULL terminate unit test array */
9797 static struct unit_test_suite cryptodev_null_testsuite = {
9798 .suite_name = "Crypto Device NULL Unit Test Suite",
9799 .setup = testsuite_setup,
9800 .teardown = testsuite_teardown,
9801 .unit_test_cases = {
9802 TEST_CASE_ST(ut_setup, ut_teardown,
9803 test_null_auth_only_operation),
9804 TEST_CASE_ST(ut_setup, ut_teardown,
9805 test_null_cipher_only_operation),
9806 TEST_CASE_ST(ut_setup, ut_teardown,
9807 test_null_cipher_auth_operation),
9808 TEST_CASE_ST(ut_setup, ut_teardown,
9809 test_null_auth_cipher_operation),
9810 TEST_CASE_ST(ut_setup, ut_teardown,
9811 test_null_invalid_operation),
9812 TEST_CASE_ST(ut_setup, ut_teardown,
9813 test_null_burst_operation),
9815 TEST_CASES_END() /**< NULL terminate unit test array */
9819 static struct unit_test_suite cryptodev_armv8_testsuite = {
9820 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
9821 .setup = testsuite_setup,
9822 .teardown = testsuite_teardown,
9823 .unit_test_cases = {
9824 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
9826 /** Negative tests */
9827 TEST_CASE_ST(ut_setup, ut_teardown,
9828 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9829 TEST_CASE_ST(ut_setup, ut_teardown,
9830 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9832 TEST_CASES_END() /**< NULL terminate unit test array */
9836 static struct unit_test_suite cryptodev_mrvl_testsuite = {
9837 .suite_name = "Crypto Device Marvell Component Test Suite",
9838 .setup = testsuite_setup,
9839 .teardown = testsuite_teardown,
9840 .unit_test_cases = {
9841 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9842 TEST_CASE_ST(ut_setup, ut_teardown,
9843 test_multi_session_random_usage),
9844 TEST_CASE_ST(ut_setup, ut_teardown,
9845 test_AES_chain_mrvl_all),
9846 TEST_CASE_ST(ut_setup, ut_teardown,
9847 test_AES_cipheronly_mrvl_all),
9848 TEST_CASE_ST(ut_setup, ut_teardown,
9849 test_authonly_mrvl_all),
9850 TEST_CASE_ST(ut_setup, ut_teardown,
9851 test_3DES_chain_mrvl_all),
9852 TEST_CASE_ST(ut_setup, ut_teardown,
9853 test_3DES_cipheronly_mrvl_all),
9855 /** Negative tests */
9856 TEST_CASE_ST(ut_setup, ut_teardown,
9857 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9858 TEST_CASE_ST(ut_setup, ut_teardown,
9859 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9860 TEST_CASE_ST(ut_setup, ut_teardown,
9861 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9862 TEST_CASE_ST(ut_setup, ut_teardown,
9863 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9865 TEST_CASES_END() /**< NULL terminate unit test array */
9869 static struct unit_test_suite cryptodev_ccp_testsuite = {
9870 .suite_name = "Crypto Device CCP Unit Test Suite",
9871 .setup = testsuite_setup,
9872 .teardown = testsuite_teardown,
9873 .unit_test_cases = {
9874 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
9875 TEST_CASE_ST(ut_setup, ut_teardown,
9876 test_multi_session_random_usage),
9877 TEST_CASE_ST(ut_setup, ut_teardown,
9878 test_AES_chain_ccp_all),
9879 TEST_CASE_ST(ut_setup, ut_teardown,
9880 test_AES_cipheronly_ccp_all),
9881 TEST_CASE_ST(ut_setup, ut_teardown,
9882 test_3DES_chain_ccp_all),
9883 TEST_CASE_ST(ut_setup, ut_teardown,
9884 test_3DES_cipheronly_ccp_all),
9885 TEST_CASE_ST(ut_setup, ut_teardown,
9886 test_authonly_ccp_all),
9888 /** Negative tests */
9889 TEST_CASE_ST(ut_setup, ut_teardown,
9890 authentication_verify_HMAC_SHA1_fail_data_corrupt),
9891 TEST_CASE_ST(ut_setup, ut_teardown,
9892 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
9893 TEST_CASE_ST(ut_setup, ut_teardown,
9894 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
9895 TEST_CASE_ST(ut_setup, ut_teardown,
9896 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
9898 TEST_CASES_END() /**< NULL terminate unit test array */
9903 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
9905 gbl_driver_id = rte_cryptodev_driver_id_get(
9906 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
9908 if (gbl_driver_id == -1) {
9909 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check if "
9910 "CONFIG_RTE_LIBRTE_PMD_QAT is enabled "
9911 "in config file to run this testsuite.\n");
9912 return TEST_SKIPPED;
9915 return unit_test_suite_runner(&cryptodev_qat_testsuite);
9919 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
9921 gbl_driver_id = rte_cryptodev_driver_id_get(
9922 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
9924 if (gbl_driver_id == -1) {
9925 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
9926 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
9927 "in config file to run this testsuite.\n");
9931 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
9935 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
9937 gbl_driver_id = rte_cryptodev_driver_id_get(
9938 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
9940 if (gbl_driver_id == -1) {
9941 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
9942 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
9943 "in config file to run this testsuite.\n");
9944 return TEST_SKIPPED;
9947 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
9951 test_cryptodev_openssl(void)
9953 gbl_driver_id = rte_cryptodev_driver_id_get(
9954 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
9956 if (gbl_driver_id == -1) {
9957 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
9958 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
9959 "in config file to run this testsuite.\n");
9960 return TEST_SKIPPED;
9963 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
9967 test_cryptodev_aesni_gcm(void)
9969 gbl_driver_id = rte_cryptodev_driver_id_get(
9970 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
9972 if (gbl_driver_id == -1) {
9973 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
9974 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
9975 "in config file to run this testsuite.\n");
9976 return TEST_SKIPPED;
9979 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
9983 test_cryptodev_null(void)
9985 gbl_driver_id = rte_cryptodev_driver_id_get(
9986 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
9988 if (gbl_driver_id == -1) {
9989 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
9990 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
9991 "in config file to run this testsuite.\n");
9992 return TEST_SKIPPED;
9995 return unit_test_suite_runner(&cryptodev_null_testsuite);
9999 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
10001 gbl_driver_id = rte_cryptodev_driver_id_get(
10002 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
10004 if (gbl_driver_id == -1) {
10005 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
10006 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
10007 "in config file to run this testsuite.\n");
10008 return TEST_SKIPPED;
10011 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
10015 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
10017 gbl_driver_id = rte_cryptodev_driver_id_get(
10018 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
10020 if (gbl_driver_id == -1) {
10021 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10022 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
10023 "in config file to run this testsuite.\n");
10024 return TEST_SKIPPED;
10027 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
10031 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
10033 gbl_driver_id = rte_cryptodev_driver_id_get(
10034 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
10036 if (gbl_driver_id == -1) {
10037 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
10038 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
10039 "in config file to run this testsuite.\n");
10040 return TEST_SKIPPED;
10043 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
10047 test_cryptodev_armv8(void)
10049 gbl_driver_id = rte_cryptodev_driver_id_get(
10050 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
10052 if (gbl_driver_id == -1) {
10053 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
10054 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
10055 "in config file to run this testsuite.\n");
10056 return TEST_SKIPPED;
10059 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
10063 test_cryptodev_mrvl(void)
10065 gbl_driver_id = rte_cryptodev_driver_id_get(
10066 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
10068 if (gbl_driver_id == -1) {
10069 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
10070 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
10071 "in config file to run this testsuite.\n");
10072 return TEST_SKIPPED;
10075 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
10078 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
10081 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
10083 gbl_driver_id = rte_cryptodev_driver_id_get(
10084 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
10086 if (gbl_driver_id == -1) {
10087 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
10088 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
10089 "in config file to run this testsuite.\n");
10090 return TEST_SKIPPED;
10093 if (rte_cryptodev_driver_id_get(
10094 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
10095 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
10096 " enabled in config file to run this testsuite.\n");
10097 return TEST_SKIPPED;
10099 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
10102 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
10107 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10109 gbl_driver_id = rte_cryptodev_driver_id_get(
10110 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
10112 if (gbl_driver_id == -1) {
10113 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
10114 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
10115 "in config file to run this testsuite.\n");
10116 return TEST_SKIPPED;
10119 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
10123 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
10125 gbl_driver_id = rte_cryptodev_driver_id_get(
10126 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
10128 if (gbl_driver_id == -1) {
10129 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
10130 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
10131 "in config file to run this testsuite.\n");
10132 return TEST_SKIPPED;
10135 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
10139 test_cryptodev_ccp(void)
10141 gbl_driver_id = rte_cryptodev_driver_id_get(
10142 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
10144 if (gbl_driver_id == -1) {
10145 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
10146 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
10147 "in config file to run this testsuite.\n");
10148 return TEST_FAILED;
10151 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
10154 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
10155 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
10156 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
10157 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
10158 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
10159 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
10160 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
10161 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
10162 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
10163 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
10164 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
10165 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
10166 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
10167 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);