1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2019 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>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 struct crypto_testsuite_params {
56 struct rte_mempool *mbuf_pool;
57 struct rte_mempool *large_mbuf_pool;
58 struct rte_mempool *op_mpool;
59 struct rte_mempool *session_mpool;
60 struct rte_mempool *session_priv_mpool;
61 struct rte_cryptodev_config conf;
62 struct rte_cryptodev_qp_conf qp_conf;
64 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
65 uint8_t valid_dev_count;
68 struct crypto_unittest_params {
69 struct rte_crypto_sym_xform cipher_xform;
70 struct rte_crypto_sym_xform auth_xform;
71 struct rte_crypto_sym_xform aead_xform;
74 struct rte_cryptodev_sym_session *sess;
75 #ifdef RTE_LIBRTE_SECURITY
76 struct rte_security_session *sec_session;
79 #ifdef RTE_LIBRTE_SECURITY
80 enum rte_security_session_action_type type;
82 struct rte_crypto_op *op;
84 struct rte_mbuf *obuf, *ibuf;
89 #define ALIGN_POW2_ROUNDUP(num, align) \
90 (((num) + (align) - 1) & ~((align) - 1))
93 * Forward declarations.
96 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
97 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
101 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
102 struct crypto_unittest_params *ut_params,
103 struct crypto_testsuite_params *ts_param,
104 const uint8_t *cipher,
105 const uint8_t *digest,
108 static struct rte_mbuf *
109 setup_test_string(struct rte_mempool *mpool,
110 const char *string, size_t len, uint8_t blocksize)
112 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
113 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
115 memset(m->buf_addr, 0, m->buf_len);
117 char *dst = rte_pktmbuf_append(m, t_len);
124 rte_memcpy(dst, string, t_len);
126 memset(dst, 0, t_len);
132 /* Get number of bytes in X bits (rounding up) */
134 ceil_byte_length(uint32_t num_bits)
137 return ((num_bits >> 3) + 1);
139 return (num_bits >> 3);
142 static struct rte_crypto_op *
143 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
145 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
146 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
152 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
155 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
156 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
163 static struct crypto_testsuite_params testsuite_params = { NULL };
164 static struct crypto_unittest_params unittest_params;
167 testsuite_setup(void)
169 struct crypto_testsuite_params *ts_params = &testsuite_params;
170 struct rte_cryptodev_info info;
171 uint32_t i = 0, nb_devs, dev_id;
175 memset(ts_params, 0, sizeof(*ts_params));
177 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
178 if (ts_params->mbuf_pool == NULL) {
179 /* Not already created so create */
180 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
182 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
184 if (ts_params->mbuf_pool == NULL) {
185 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
190 ts_params->large_mbuf_pool = rte_mempool_lookup(
191 "CRYPTO_LARGE_MBUFPOOL");
192 if (ts_params->large_mbuf_pool == NULL) {
193 /* Not already created so create */
194 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
195 "CRYPTO_LARGE_MBUFPOOL",
198 if (ts_params->large_mbuf_pool == NULL) {
200 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
205 ts_params->op_mpool = rte_crypto_op_pool_create(
206 "MBUF_CRYPTO_SYM_OP_POOL",
207 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
208 NUM_MBUFS, MBUF_CACHE_SIZE,
210 sizeof(struct rte_crypto_sym_xform) +
213 if (ts_params->op_mpool == NULL) {
214 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
218 /* Create an AESNI MB device if required */
219 if (gbl_driver_id == rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
221 nb_devs = rte_cryptodev_device_count_by_driver(
222 rte_cryptodev_driver_id_get(
223 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
226 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
228 TEST_ASSERT(ret == 0,
229 "Failed to create instance of"
231 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
235 /* Create an AESNI GCM device if required */
236 if (gbl_driver_id == rte_cryptodev_driver_id_get(
237 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
238 nb_devs = rte_cryptodev_device_count_by_driver(
239 rte_cryptodev_driver_id_get(
240 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
242 TEST_ASSERT_SUCCESS(rte_vdev_init(
243 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
244 "Failed to create instance of"
246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
250 /* Create a SNOW 3G device if required */
251 if (gbl_driver_id == rte_cryptodev_driver_id_get(
252 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
253 nb_devs = rte_cryptodev_device_count_by_driver(
254 rte_cryptodev_driver_id_get(
255 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
257 TEST_ASSERT_SUCCESS(rte_vdev_init(
258 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
259 "Failed to create instance of"
261 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
265 /* Create a KASUMI device if required */
266 if (gbl_driver_id == rte_cryptodev_driver_id_get(
267 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
268 nb_devs = rte_cryptodev_device_count_by_driver(
269 rte_cryptodev_driver_id_get(
270 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
272 TEST_ASSERT_SUCCESS(rte_vdev_init(
273 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
274 "Failed to create instance of"
276 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
280 /* Create a ZUC device if required */
281 if (gbl_driver_id == rte_cryptodev_driver_id_get(
282 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
283 nb_devs = rte_cryptodev_device_count_by_driver(
284 rte_cryptodev_driver_id_get(
285 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
287 TEST_ASSERT_SUCCESS(rte_vdev_init(
288 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
289 "Failed to create instance of"
291 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
295 /* Create a NULL device if required */
296 if (gbl_driver_id == rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
298 nb_devs = rte_cryptodev_device_count_by_driver(
299 rte_cryptodev_driver_id_get(
300 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
303 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
305 TEST_ASSERT(ret == 0,
306 "Failed to create instance of"
308 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
312 /* Create an OPENSSL device if required */
313 if (gbl_driver_id == rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
315 nb_devs = rte_cryptodev_device_count_by_driver(
316 rte_cryptodev_driver_id_get(
317 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
320 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
323 TEST_ASSERT(ret == 0, "Failed to create "
324 "instance of pmd : %s",
325 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
329 /* Create a ARMv8 device if required */
330 if (gbl_driver_id == rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
332 nb_devs = rte_cryptodev_device_count_by_driver(
333 rte_cryptodev_driver_id_get(
334 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
337 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
340 TEST_ASSERT(ret == 0, "Failed to create "
341 "instance of pmd : %s",
342 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
346 /* Create a MVSAM device if required */
347 if (gbl_driver_id == rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
349 nb_devs = rte_cryptodev_device_count_by_driver(
350 rte_cryptodev_driver_id_get(
351 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
354 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
363 /* Create an CCP device if required */
364 if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
366 nb_devs = rte_cryptodev_device_count_by_driver(
367 rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
371 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
374 TEST_ASSERT(ret == 0, "Failed to create "
375 "instance of pmd : %s",
376 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
380 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
381 char vdev_args[VDEV_ARGS_SIZE] = {""};
382 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
383 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
384 uint16_t slave_core_count = 0;
385 uint16_t socket_id = 0;
387 if (gbl_driver_id == rte_cryptodev_driver_id_get(
388 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
390 /* Identify the Slave Cores
391 * Use 2 slave cores for the device args
393 RTE_LCORE_FOREACH_SLAVE(i) {
394 if (slave_core_count > 1)
396 snprintf(vdev_args, sizeof(vdev_args),
397 "%s%d", temp_str, i);
398 strcpy(temp_str, vdev_args);
399 strlcat(temp_str, ";", sizeof(temp_str));
401 socket_id = rte_lcore_to_socket_id(i);
403 if (slave_core_count != 2) {
405 "Cryptodev scheduler test require at least "
406 "two slave cores to run. "
407 "Please use the correct coremask.\n");
410 strcpy(temp_str, vdev_args);
411 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
412 temp_str, socket_id);
413 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
414 nb_devs = rte_cryptodev_device_count_by_driver(
415 rte_cryptodev_driver_id_get(
416 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
419 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
421 TEST_ASSERT(ret == 0,
422 "Failed to create instance %u of"
424 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
427 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
429 nb_devs = rte_cryptodev_count();
431 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
435 /* Create list of valid crypto devs */
436 for (i = 0; i < nb_devs; i++) {
437 rte_cryptodev_info_get(i, &info);
438 if (info.driver_id == gbl_driver_id)
439 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
442 if (ts_params->valid_dev_count < 1)
445 /* Set up all the qps on the first of the valid devices found */
447 dev_id = ts_params->valid_devs[0];
449 rte_cryptodev_info_get(dev_id, &info);
451 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
452 ts_params->conf.socket_id = SOCKET_ID_ANY;
453 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
455 unsigned int session_size =
456 rte_cryptodev_sym_get_private_session_size(dev_id);
459 * Create mempool with maximum number of sessions * 2,
460 * to include the session headers
462 if (info.sym.max_nb_sessions != 0 &&
463 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
464 RTE_LOG(ERR, USER1, "Device does not support "
465 "at least %u sessions\n",
470 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
471 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
473 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
474 "session mempool allocation failed");
476 ts_params->session_priv_mpool = rte_mempool_create(
480 0, 0, NULL, NULL, NULL,
483 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
484 "session mempool allocation failed");
488 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
490 "Failed to configure cryptodev %u with %u qps",
491 dev_id, ts_params->conf.nb_queue_pairs);
493 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
494 ts_params->qp_conf.mp_session = ts_params->session_mpool;
495 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
497 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
498 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
499 dev_id, qp_id, &ts_params->qp_conf,
500 rte_cryptodev_socket_id(dev_id)),
501 "Failed to setup queue pair %u on cryptodev %u",
509 testsuite_teardown(void)
511 struct crypto_testsuite_params *ts_params = &testsuite_params;
513 if (ts_params->mbuf_pool != NULL) {
514 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
515 rte_mempool_avail_count(ts_params->mbuf_pool));
518 if (ts_params->op_mpool != NULL) {
519 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
520 rte_mempool_avail_count(ts_params->op_mpool));
523 /* Free session mempools */
524 if (ts_params->session_priv_mpool != NULL) {
525 rte_mempool_free(ts_params->session_priv_mpool);
526 ts_params->session_priv_mpool = NULL;
529 if (ts_params->session_mpool != NULL) {
530 rte_mempool_free(ts_params->session_mpool);
531 ts_params->session_mpool = NULL;
538 struct crypto_testsuite_params *ts_params = &testsuite_params;
539 struct crypto_unittest_params *ut_params = &unittest_params;
543 /* Clear unit test parameters before running test */
544 memset(ut_params, 0, sizeof(*ut_params));
546 /* Reconfigure device to default parameters */
547 ts_params->conf.socket_id = SOCKET_ID_ANY;
548 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
549 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
550 ts_params->qp_conf.mp_session = ts_params->session_mpool;
551 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
553 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
555 "Failed to configure cryptodev %u",
556 ts_params->valid_devs[0]);
558 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
559 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
560 ts_params->valid_devs[0], qp_id,
562 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
563 "Failed to setup queue pair %u on cryptodev %u",
564 qp_id, ts_params->valid_devs[0]);
568 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
570 /* Start the device */
571 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
572 "Failed to start cryptodev %u",
573 ts_params->valid_devs[0]);
581 struct crypto_testsuite_params *ts_params = &testsuite_params;
582 struct crypto_unittest_params *ut_params = &unittest_params;
583 struct rte_cryptodev_stats stats;
585 /* free crypto session structure */
586 #ifdef RTE_LIBRTE_SECURITY
587 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
588 if (ut_params->sec_session) {
589 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
590 (ts_params->valid_devs[0]),
591 ut_params->sec_session);
592 ut_params->sec_session = NULL;
597 if (ut_params->sess) {
598 rte_cryptodev_sym_session_clear(
599 ts_params->valid_devs[0],
601 rte_cryptodev_sym_session_free(ut_params->sess);
602 ut_params->sess = NULL;
606 /* free crypto operation structure */
608 rte_crypto_op_free(ut_params->op);
611 * free mbuf - both obuf and ibuf are usually the same,
612 * so check if they point at the same address is necessary,
613 * to avoid freeing the mbuf twice.
615 if (ut_params->obuf) {
616 rte_pktmbuf_free(ut_params->obuf);
617 if (ut_params->ibuf == ut_params->obuf)
621 if (ut_params->ibuf) {
622 rte_pktmbuf_free(ut_params->ibuf);
626 if (ts_params->mbuf_pool != NULL)
627 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
628 rte_mempool_avail_count(ts_params->mbuf_pool));
630 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
632 /* Stop the device */
633 rte_cryptodev_stop(ts_params->valid_devs[0]);
637 test_device_configure_invalid_dev_id(void)
639 struct crypto_testsuite_params *ts_params = &testsuite_params;
640 uint16_t dev_id, num_devs = 0;
642 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
643 "Need at least %d devices for test", 1);
645 /* valid dev_id values */
646 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
648 /* Stop the device in case it's started so it can be configured */
649 rte_cryptodev_stop(dev_id);
651 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
652 "Failed test for rte_cryptodev_configure: "
653 "invalid dev_num %u", dev_id);
655 /* invalid dev_id values */
658 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
659 "Failed test for rte_cryptodev_configure: "
660 "invalid dev_num %u", dev_id);
664 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
665 "Failed test for rte_cryptodev_configure:"
666 "invalid dev_num %u", dev_id);
672 test_device_configure_invalid_queue_pair_ids(void)
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
677 /* Stop the device in case it's started so it can be configured */
678 rte_cryptodev_stop(ts_params->valid_devs[0]);
680 /* valid - one queue pairs */
681 ts_params->conf.nb_queue_pairs = 1;
683 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
685 "Failed to configure cryptodev: dev_id %u, qp_id %u",
686 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
689 /* valid - max value queue pairs */
690 ts_params->conf.nb_queue_pairs = orig_nb_qps;
692 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
694 "Failed to configure cryptodev: dev_id %u, qp_id %u",
695 ts_params->valid_devs[0],
696 ts_params->conf.nb_queue_pairs);
699 /* invalid - zero queue pairs */
700 ts_params->conf.nb_queue_pairs = 0;
702 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
704 "Failed test for rte_cryptodev_configure, dev_id %u,"
706 ts_params->valid_devs[0],
707 ts_params->conf.nb_queue_pairs);
710 /* invalid - max value supported by field queue pairs */
711 ts_params->conf.nb_queue_pairs = UINT16_MAX;
713 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
715 "Failed test for rte_cryptodev_configure, dev_id %u,"
717 ts_params->valid_devs[0],
718 ts_params->conf.nb_queue_pairs);
721 /* invalid - max value + 1 queue pairs */
722 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
724 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
726 "Failed test for rte_cryptodev_configure, dev_id %u,"
728 ts_params->valid_devs[0],
729 ts_params->conf.nb_queue_pairs);
731 /* revert to original testsuite value */
732 ts_params->conf.nb_queue_pairs = orig_nb_qps;
738 test_queue_pair_descriptor_setup(void)
740 struct crypto_testsuite_params *ts_params = &testsuite_params;
741 struct rte_cryptodev_info dev_info;
742 struct rte_cryptodev_qp_conf qp_conf = {
743 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
748 /* Stop the device in case it's started so it can be configured */
749 rte_cryptodev_stop(ts_params->valid_devs[0]);
752 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
754 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
756 "Failed to configure cryptodev %u",
757 ts_params->valid_devs[0]);
760 * Test various ring sizes on this device. memzones can't be
761 * freed so are re-used if ring is released and re-created.
763 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
764 qp_conf.mp_session = ts_params->session_mpool;
765 qp_conf.mp_session_private = ts_params->session_priv_mpool;
767 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
768 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
769 ts_params->valid_devs[0], qp_id, &qp_conf,
770 rte_cryptodev_socket_id(
771 ts_params->valid_devs[0])),
773 "rte_cryptodev_queue_pair_setup: num_inflights "
774 "%u on qp %u on cryptodev %u",
775 qp_conf.nb_descriptors, qp_id,
776 ts_params->valid_devs[0]);
779 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
781 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
782 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
783 ts_params->valid_devs[0], qp_id, &qp_conf,
784 rte_cryptodev_socket_id(
785 ts_params->valid_devs[0])),
787 " rte_cryptodev_queue_pair_setup: num_inflights"
788 " %u on qp %u on cryptodev %u",
789 qp_conf.nb_descriptors, qp_id,
790 ts_params->valid_devs[0]);
793 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
795 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
796 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
797 ts_params->valid_devs[0], qp_id, &qp_conf,
798 rte_cryptodev_socket_id(
799 ts_params->valid_devs[0])),
801 "rte_cryptodev_queue_pair_setup: num_inflights"
802 " %u on qp %u on cryptodev %u",
803 qp_conf.nb_descriptors, qp_id,
804 ts_params->valid_devs[0]);
807 /* invalid number of descriptors - max supported + 2 */
808 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
810 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
811 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
812 ts_params->valid_devs[0], qp_id, &qp_conf,
813 rte_cryptodev_socket_id(
814 ts_params->valid_devs[0])),
815 "Unexpectedly passed test for "
816 "rte_cryptodev_queue_pair_setup:"
817 "num_inflights %u on qp %u on cryptodev %u",
818 qp_conf.nb_descriptors, qp_id,
819 ts_params->valid_devs[0]);
822 /* invalid number of descriptors - max value of parameter */
823 qp_conf.nb_descriptors = UINT32_MAX-1;
825 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
826 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
827 ts_params->valid_devs[0], qp_id, &qp_conf,
828 rte_cryptodev_socket_id(
829 ts_params->valid_devs[0])),
830 "Unexpectedly passed test for "
831 "rte_cryptodev_queue_pair_setup:"
832 "num_inflights %u on qp %u on cryptodev %u",
833 qp_conf.nb_descriptors, qp_id,
834 ts_params->valid_devs[0]);
837 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
839 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
840 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
841 ts_params->valid_devs[0], qp_id, &qp_conf,
842 rte_cryptodev_socket_id(
843 ts_params->valid_devs[0])),
845 " rte_cryptodev_queue_pair_setup:"
846 "num_inflights %u on qp %u on cryptodev %u",
847 qp_conf.nb_descriptors, qp_id,
848 ts_params->valid_devs[0]);
851 /* invalid number of descriptors - max supported + 1 */
852 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
854 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
855 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
856 ts_params->valid_devs[0], qp_id, &qp_conf,
857 rte_cryptodev_socket_id(
858 ts_params->valid_devs[0])),
859 "Unexpectedly passed test for "
860 "rte_cryptodev_queue_pair_setup:"
861 "num_inflights %u on qp %u on cryptodev %u",
862 qp_conf.nb_descriptors, qp_id,
863 ts_params->valid_devs[0]);
866 /* test invalid queue pair id */
867 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
869 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
871 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
872 ts_params->valid_devs[0],
874 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
875 "Failed test for rte_cryptodev_queue_pair_setup:"
876 "invalid qp %u on cryptodev %u",
877 qp_id, ts_params->valid_devs[0]);
879 qp_id = 0xffff; /*invalid*/
881 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
882 ts_params->valid_devs[0],
884 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
885 "Failed test for rte_cryptodev_queue_pair_setup:"
886 "invalid qp %u on cryptodev %u",
887 qp_id, ts_params->valid_devs[0]);
892 /* ***** Plaintext data for tests ***** */
894 const char catch_22_quote_1[] =
895 "There was only one catch and that was Catch-22, which "
896 "specified that a concern for one's safety in the face of "
897 "dangers that were real and immediate was the process of a "
898 "rational mind. Orr was crazy and could be grounded. All he "
899 "had to do was ask; and as soon as he did, he would no longer "
900 "be crazy and would have to fly more missions. Orr would be "
901 "crazy to fly more missions and sane if he didn't, but if he "
902 "was sane he had to fly them. If he flew them he was crazy "
903 "and didn't have to; but if he didn't want to he was sane and "
904 "had to. Yossarian was moved very deeply by the absolute "
905 "simplicity of this clause of Catch-22 and let out a "
906 "respectful whistle. \"That's some catch, that Catch-22\", he "
907 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
909 const char catch_22_quote[] =
910 "What a lousy earth! He wondered how many people were "
911 "destitute that same night even in his own prosperous country, "
912 "how many homes were shanties, how many husbands were drunk "
913 "and wives socked, and how many children were bullied, abused, "
914 "or abandoned. How many families hungered for food they could "
915 "not afford to buy? How many hearts were broken? How many "
916 "suicides would take place that same night, how many people "
917 "would go insane? How many cockroaches and landlords would "
918 "triumph? How many winners were losers, successes failures, "
919 "and rich men poor men? How many wise guys were stupid? How "
920 "many happy endings were unhappy endings? How many honest men "
921 "were liars, brave men cowards, loyal men traitors, how many "
922 "sainted men were corrupt, how many people in positions of "
923 "trust had sold their souls to bodyguards, how many had never "
924 "had souls? How many straight-and-narrow paths were crooked "
925 "paths? How many best families were worst families and how "
926 "many good people were bad people? When you added them all up "
927 "and then subtracted, you might be left with only the children, "
928 "and perhaps with Albert Einstein and an old violinist or "
929 "sculptor somewhere.";
931 #define QUOTE_480_BYTES (480)
932 #define QUOTE_512_BYTES (512)
933 #define QUOTE_768_BYTES (768)
934 #define QUOTE_1024_BYTES (1024)
938 /* ***** SHA1 Hash Tests ***** */
940 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
942 static uint8_t hmac_sha1_key[] = {
943 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
944 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
945 0xDE, 0xF4, 0xDE, 0xAD };
947 /* ***** SHA224 Hash Tests ***** */
949 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
952 /* ***** AES-CBC Cipher Tests ***** */
954 #define CIPHER_KEY_LENGTH_AES_CBC (16)
955 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
957 static uint8_t aes_cbc_key[] = {
958 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
959 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
961 static uint8_t aes_cbc_iv[] = {
962 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
963 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
966 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
968 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
969 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
970 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
971 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
972 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
973 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
974 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
975 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
976 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
977 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
978 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
979 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
980 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
981 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
982 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
983 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
984 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
985 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
986 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
987 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
988 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
989 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
990 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
991 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
992 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
993 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
994 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
995 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
996 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
997 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
998 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
999 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1000 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1001 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1002 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1003 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1004 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1005 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1006 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1007 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1008 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1009 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1010 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1011 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1012 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1013 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1014 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1015 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1016 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1017 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1018 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1019 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1020 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1021 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1022 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1023 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1024 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1025 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1026 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1027 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1028 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1029 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1030 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1031 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1032 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1035 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1036 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1037 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1038 0x18, 0x8c, 0x1d, 0x32
1042 /* Multisession Vector context Test */
1043 /*Begin Session 0 */
1044 static uint8_t ms_aes_cbc_key0[] = {
1045 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1046 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1049 static uint8_t ms_aes_cbc_iv0[] = {
1050 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1054 static const uint8_t ms_aes_cbc_cipher0[] = {
1055 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1056 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1057 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1058 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1059 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1060 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1061 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1062 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1063 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1064 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1065 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1066 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1067 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1068 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1069 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1070 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1071 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1072 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1073 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1074 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1075 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1076 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1077 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1078 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1079 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1080 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1081 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1082 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1083 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1084 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1085 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1086 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1087 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1088 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1089 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1090 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1091 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1092 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1093 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1094 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1095 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1096 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1097 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1098 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1099 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1100 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1101 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1102 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1103 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1104 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1105 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1106 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1107 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1108 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1109 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1110 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1111 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1112 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1113 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1114 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1115 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1116 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1117 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1118 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1122 static uint8_t ms_hmac_key0[] = {
1123 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1124 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1125 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1126 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1127 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1128 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1129 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1130 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1133 static const uint8_t ms_hmac_digest0[] = {
1134 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1135 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1136 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1137 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1138 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1139 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1140 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1141 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1145 /* Begin session 1 */
1147 static uint8_t ms_aes_cbc_key1[] = {
1148 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1149 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1152 static uint8_t ms_aes_cbc_iv1[] = {
1153 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1154 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1157 static const uint8_t ms_aes_cbc_cipher1[] = {
1158 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1159 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1160 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1161 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1162 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1163 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1164 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1165 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1166 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1167 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1168 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1169 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1170 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1171 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1172 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1173 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1174 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1175 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1176 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1177 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1178 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1179 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1180 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1181 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1182 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1183 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1184 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1185 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1186 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1187 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1188 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1189 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1190 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1191 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1192 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1193 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1194 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1195 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1196 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1197 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1198 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1199 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1200 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1201 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1202 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1203 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1204 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1205 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1206 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1207 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1208 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1209 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1210 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1211 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1212 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1213 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1214 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1215 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1216 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1217 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1218 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1219 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1220 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1221 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1225 static uint8_t ms_hmac_key1[] = {
1226 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1236 static const uint8_t ms_hmac_digest1[] = {
1237 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1238 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1239 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1240 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1241 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1242 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1243 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1244 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1247 /* Begin Session 2 */
1248 static uint8_t ms_aes_cbc_key2[] = {
1249 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1250 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1253 static uint8_t ms_aes_cbc_iv2[] = {
1254 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1255 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1258 static const uint8_t ms_aes_cbc_cipher2[] = {
1259 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1260 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1261 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1262 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1263 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1264 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1265 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1266 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1267 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1268 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1269 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1270 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1271 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1272 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1273 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1274 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1275 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1276 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1277 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1278 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1279 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1280 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1281 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1282 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1283 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1284 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1285 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1286 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1287 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1288 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1289 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1290 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1291 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1292 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1293 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1294 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1295 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1296 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1297 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1298 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1299 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1300 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1301 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1302 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1303 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1304 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1305 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1306 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1307 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1308 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1309 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1310 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1311 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1312 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1313 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1314 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1315 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1316 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1317 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1318 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1319 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1320 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1321 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1322 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1325 static uint8_t ms_hmac_key2[] = {
1326 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1327 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1328 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1329 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1330 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1331 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1332 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1333 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1336 static const uint8_t ms_hmac_digest2[] = {
1337 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1338 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1339 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1340 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1341 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1342 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1343 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1344 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1351 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1353 struct crypto_testsuite_params *ts_params = &testsuite_params;
1354 struct crypto_unittest_params *ut_params = &unittest_params;
1356 /* Generate test mbuf data and space for digest */
1357 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1358 catch_22_quote, QUOTE_512_BYTES, 0);
1360 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1361 DIGEST_BYTE_LENGTH_SHA1);
1362 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1364 /* Setup Cipher Parameters */
1365 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1366 ut_params->cipher_xform.next = &ut_params->auth_xform;
1368 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1369 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1370 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1371 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1372 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1373 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1375 /* Setup HMAC Parameters */
1376 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1378 ut_params->auth_xform.next = NULL;
1380 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1381 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1382 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1383 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1384 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1386 ut_params->sess = rte_cryptodev_sym_session_create(
1387 ts_params->session_mpool);
1389 /* Create crypto session*/
1390 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1391 ut_params->sess, &ut_params->cipher_xform,
1392 ts_params->session_priv_mpool);
1393 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1395 /* Generate crypto op data structure */
1396 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1397 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1398 TEST_ASSERT_NOT_NULL(ut_params->op,
1399 "Failed to allocate symmetric crypto operation struct");
1401 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1403 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1405 /* set crypto operation source mbuf */
1406 sym_op->m_src = ut_params->ibuf;
1408 /* Set crypto operation authentication parameters */
1409 sym_op->auth.digest.data = ut_params->digest;
1410 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1411 ut_params->ibuf, QUOTE_512_BYTES);
1413 sym_op->auth.data.offset = 0;
1414 sym_op->auth.data.length = QUOTE_512_BYTES;
1416 /* Copy IV at the end of the crypto operation */
1417 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1418 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1420 /* Set crypto operation cipher parameters */
1421 sym_op->cipher.data.offset = 0;
1422 sym_op->cipher.data.length = QUOTE_512_BYTES;
1424 /* Process crypto operation */
1425 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1426 ut_params->op), "failed to process sym crypto op");
1428 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1429 "crypto op processing failed");
1432 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1435 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1436 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1438 "ciphertext data not as expected");
1440 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1442 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1443 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1444 gbl_driver_id == rte_cryptodev_driver_id_get(
1445 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1446 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1447 DIGEST_BYTE_LENGTH_SHA1,
1448 "Generated digest data not as expected");
1450 return TEST_SUCCESS;
1453 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1455 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1457 static uint8_t hmac_sha512_key[] = {
1458 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1459 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1460 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1461 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1462 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1463 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1464 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1465 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1467 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1468 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1469 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1470 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1471 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1472 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1473 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1474 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1475 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1480 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1481 struct crypto_unittest_params *ut_params,
1482 uint8_t *cipher_key,
1486 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1487 struct crypto_unittest_params *ut_params,
1488 struct crypto_testsuite_params *ts_params,
1489 const uint8_t *cipher,
1490 const uint8_t *digest,
1495 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1496 struct crypto_unittest_params *ut_params,
1497 uint8_t *cipher_key,
1501 /* Setup Cipher Parameters */
1502 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1503 ut_params->cipher_xform.next = NULL;
1505 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1506 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1507 ut_params->cipher_xform.cipher.key.data = cipher_key;
1508 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1509 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1510 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1512 /* Setup HMAC Parameters */
1513 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1514 ut_params->auth_xform.next = &ut_params->cipher_xform;
1516 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1517 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1518 ut_params->auth_xform.auth.key.data = hmac_key;
1519 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1520 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1522 return TEST_SUCCESS;
1527 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1528 struct crypto_unittest_params *ut_params,
1529 struct crypto_testsuite_params *ts_params,
1530 const uint8_t *cipher,
1531 const uint8_t *digest,
1534 /* Generate test mbuf data and digest */
1535 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1538 QUOTE_512_BYTES, 0);
1540 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1541 DIGEST_BYTE_LENGTH_SHA512);
1542 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1544 rte_memcpy(ut_params->digest,
1546 DIGEST_BYTE_LENGTH_SHA512);
1548 /* Generate Crypto op data structure */
1549 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1550 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1551 TEST_ASSERT_NOT_NULL(ut_params->op,
1552 "Failed to allocate symmetric crypto operation struct");
1554 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1556 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1558 /* set crypto operation source mbuf */
1559 sym_op->m_src = ut_params->ibuf;
1561 sym_op->auth.digest.data = ut_params->digest;
1562 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1563 ut_params->ibuf, QUOTE_512_BYTES);
1565 sym_op->auth.data.offset = 0;
1566 sym_op->auth.data.length = QUOTE_512_BYTES;
1568 /* Copy IV at the end of the crypto operation */
1569 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1570 iv, CIPHER_IV_LENGTH_AES_CBC);
1572 sym_op->cipher.data.offset = 0;
1573 sym_op->cipher.data.length = QUOTE_512_BYTES;
1575 /* Process crypto operation */
1576 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1577 ut_params->op), "failed to process sym crypto op");
1579 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1580 "crypto op processing failed");
1582 ut_params->obuf = ut_params->op->sym->m_src;
1585 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1586 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1589 "Plaintext data not as expected");
1592 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1593 "Digest verification failed");
1595 return TEST_SUCCESS;
1599 test_AES_cipheronly_mb_all(void)
1601 struct crypto_testsuite_params *ts_params = &testsuite_params;
1604 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1605 ts_params->op_mpool,
1606 ts_params->session_mpool, ts_params->session_priv_mpool,
1607 ts_params->valid_devs[0],
1608 rte_cryptodev_driver_id_get(
1609 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1610 BLKCIPHER_AES_CIPHERONLY_TYPE);
1612 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1614 return TEST_SUCCESS;
1618 test_AES_docsis_mb_all(void)
1620 struct crypto_testsuite_params *ts_params = &testsuite_params;
1623 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1624 ts_params->op_mpool,
1625 ts_params->session_mpool, ts_params->session_priv_mpool,
1626 ts_params->valid_devs[0],
1627 rte_cryptodev_driver_id_get(
1628 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1629 BLKCIPHER_AES_DOCSIS_TYPE);
1631 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1633 return TEST_SUCCESS;
1637 test_AES_docsis_qat_all(void)
1639 struct crypto_testsuite_params *ts_params = &testsuite_params;
1642 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1643 ts_params->op_mpool,
1644 ts_params->session_mpool, ts_params->session_priv_mpool,
1645 ts_params->valid_devs[0],
1646 rte_cryptodev_driver_id_get(
1647 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1648 BLKCIPHER_AES_DOCSIS_TYPE);
1650 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1652 return TEST_SUCCESS;
1656 test_DES_docsis_qat_all(void)
1658 struct crypto_testsuite_params *ts_params = &testsuite_params;
1661 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1662 ts_params->op_mpool,
1663 ts_params->session_mpool, ts_params->session_priv_mpool,
1664 ts_params->valid_devs[0],
1665 rte_cryptodev_driver_id_get(
1666 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1667 BLKCIPHER_DES_DOCSIS_TYPE);
1669 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1671 return TEST_SUCCESS;
1675 test_authonly_mb_all(void)
1677 struct crypto_testsuite_params *ts_params = &testsuite_params;
1680 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1681 ts_params->op_mpool,
1682 ts_params->session_mpool, ts_params->session_priv_mpool,
1683 ts_params->valid_devs[0],
1684 rte_cryptodev_driver_id_get(
1685 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1686 BLKCIPHER_AUTHONLY_TYPE);
1688 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1690 return TEST_SUCCESS;
1694 test_authonly_qat_all(void)
1696 struct crypto_testsuite_params *ts_params = &testsuite_params;
1699 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1700 ts_params->op_mpool,
1701 ts_params->session_mpool, ts_params->session_priv_mpool,
1702 ts_params->valid_devs[0],
1703 rte_cryptodev_driver_id_get(
1704 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1705 BLKCIPHER_AUTHONLY_TYPE);
1707 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1709 return TEST_SUCCESS;
1713 test_AES_chain_null_all(void)
1715 struct crypto_testsuite_params *ts_params = &testsuite_params;
1718 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1719 ts_params->op_mpool,
1720 ts_params->session_mpool, ts_params->session_priv_mpool,
1721 ts_params->valid_devs[0],
1722 rte_cryptodev_driver_id_get(
1723 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1724 BLKCIPHER_AES_CHAIN_TYPE);
1726 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1728 return TEST_SUCCESS;
1732 test_AES_cipheronly_null_all(void)
1734 struct crypto_testsuite_params *ts_params = &testsuite_params;
1737 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1738 ts_params->op_mpool,
1739 ts_params->session_mpool, ts_params->session_priv_mpool,
1740 ts_params->valid_devs[0],
1741 rte_cryptodev_driver_id_get(
1742 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1743 BLKCIPHER_AES_CIPHERONLY_TYPE);
1745 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1747 return TEST_SUCCESS;
1751 test_authonly_null_all(void)
1753 struct crypto_testsuite_params *ts_params = &testsuite_params;
1756 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1757 ts_params->op_mpool,
1758 ts_params->session_mpool, ts_params->session_priv_mpool,
1759 ts_params->valid_devs[0],
1760 rte_cryptodev_driver_id_get(
1761 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1762 BLKCIPHER_AUTHONLY_TYPE);
1764 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1766 return TEST_SUCCESS;
1770 test_AES_chain_mb_all(void)
1772 struct crypto_testsuite_params *ts_params = &testsuite_params;
1775 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1776 ts_params->op_mpool,
1777 ts_params->session_mpool, ts_params->session_priv_mpool,
1778 ts_params->valid_devs[0],
1779 rte_cryptodev_driver_id_get(
1780 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1781 BLKCIPHER_AES_CHAIN_TYPE);
1783 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1785 return TEST_SUCCESS;
1788 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1791 test_AES_cipheronly_scheduler_all(void)
1793 struct crypto_testsuite_params *ts_params = &testsuite_params;
1796 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1797 ts_params->op_mpool,
1798 ts_params->session_mpool, ts_params->session_priv_mpool,
1799 ts_params->valid_devs[0],
1800 rte_cryptodev_driver_id_get(
1801 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1802 BLKCIPHER_AES_CIPHERONLY_TYPE);
1804 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1806 return TEST_SUCCESS;
1810 test_AES_chain_scheduler_all(void)
1812 struct crypto_testsuite_params *ts_params = &testsuite_params;
1815 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1816 ts_params->op_mpool,
1817 ts_params->session_mpool, ts_params->session_priv_mpool,
1818 ts_params->valid_devs[0],
1819 rte_cryptodev_driver_id_get(
1820 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1821 BLKCIPHER_AES_CHAIN_TYPE);
1823 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1825 return TEST_SUCCESS;
1829 test_authonly_scheduler_all(void)
1831 struct crypto_testsuite_params *ts_params = &testsuite_params;
1834 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1835 ts_params->op_mpool,
1836 ts_params->session_mpool, ts_params->session_priv_mpool,
1837 ts_params->valid_devs[0],
1838 rte_cryptodev_driver_id_get(
1839 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1840 BLKCIPHER_AUTHONLY_TYPE);
1842 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1844 return TEST_SUCCESS;
1847 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1850 test_AES_chain_openssl_all(void)
1852 struct crypto_testsuite_params *ts_params = &testsuite_params;
1855 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1856 ts_params->op_mpool,
1857 ts_params->session_mpool, ts_params->session_priv_mpool,
1858 ts_params->valid_devs[0],
1859 rte_cryptodev_driver_id_get(
1860 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1861 BLKCIPHER_AES_CHAIN_TYPE);
1863 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1865 return TEST_SUCCESS;
1869 test_AES_cipheronly_openssl_all(void)
1871 struct crypto_testsuite_params *ts_params = &testsuite_params;
1874 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1875 ts_params->op_mpool,
1876 ts_params->session_mpool, ts_params->session_priv_mpool,
1877 ts_params->valid_devs[0],
1878 rte_cryptodev_driver_id_get(
1879 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1880 BLKCIPHER_AES_CIPHERONLY_TYPE);
1882 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1884 return TEST_SUCCESS;
1888 test_AES_chain_ccp_all(void)
1890 struct crypto_testsuite_params *ts_params = &testsuite_params;
1893 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1894 ts_params->op_mpool,
1895 ts_params->session_mpool, ts_params->session_priv_mpool,
1896 ts_params->valid_devs[0],
1897 rte_cryptodev_driver_id_get(
1898 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1899 BLKCIPHER_AES_CHAIN_TYPE);
1901 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1903 return TEST_SUCCESS;
1907 test_AES_cipheronly_ccp_all(void)
1909 struct crypto_testsuite_params *ts_params = &testsuite_params;
1912 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1913 ts_params->op_mpool,
1914 ts_params->session_mpool, ts_params->session_priv_mpool,
1915 ts_params->valid_devs[0],
1916 rte_cryptodev_driver_id_get(
1917 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1918 BLKCIPHER_AES_CIPHERONLY_TYPE);
1920 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1922 return TEST_SUCCESS;
1926 test_AES_chain_qat_all(void)
1928 struct crypto_testsuite_params *ts_params = &testsuite_params;
1931 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1932 ts_params->op_mpool,
1933 ts_params->session_mpool, ts_params->session_priv_mpool,
1934 ts_params->valid_devs[0],
1935 rte_cryptodev_driver_id_get(
1936 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1937 BLKCIPHER_AES_CHAIN_TYPE);
1939 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1941 return TEST_SUCCESS;
1945 test_AES_cipheronly_qat_all(void)
1947 struct crypto_testsuite_params *ts_params = &testsuite_params;
1950 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1951 ts_params->op_mpool,
1952 ts_params->session_mpool, ts_params->session_priv_mpool,
1953 ts_params->valid_devs[0],
1954 rte_cryptodev_driver_id_get(
1955 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1956 BLKCIPHER_AES_CIPHERONLY_TYPE);
1958 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1960 return TEST_SUCCESS;
1964 test_AES_cipheronly_virtio_all(void)
1966 struct crypto_testsuite_params *ts_params = &testsuite_params;
1969 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1970 ts_params->op_mpool,
1971 ts_params->session_mpool, ts_params->session_priv_mpool,
1972 ts_params->valid_devs[0],
1973 rte_cryptodev_driver_id_get(
1974 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1975 BLKCIPHER_AES_CIPHERONLY_TYPE);
1977 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1979 return TEST_SUCCESS;
1983 test_AES_chain_caam_jr_all(void)
1985 struct crypto_testsuite_params *ts_params = &testsuite_params;
1988 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1989 ts_params->op_mpool,
1990 ts_params->session_mpool, ts_params->session_priv_mpool,
1991 ts_params->valid_devs[0],
1992 rte_cryptodev_driver_id_get(
1993 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1994 BLKCIPHER_AES_CHAIN_TYPE);
1996 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1998 return TEST_SUCCESS;
2002 test_AES_cipheronly_caam_jr_all(void)
2004 struct crypto_testsuite_params *ts_params = &testsuite_params;
2007 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2008 ts_params->op_mpool,
2009 ts_params->session_mpool, ts_params->session_priv_mpool,
2010 ts_params->valid_devs[0],
2011 rte_cryptodev_driver_id_get(
2012 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2013 BLKCIPHER_AES_CIPHERONLY_TYPE);
2015 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2017 return TEST_SUCCESS;
2021 test_authonly_caam_jr_all(void)
2023 struct crypto_testsuite_params *ts_params = &testsuite_params;
2026 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2027 ts_params->op_mpool,
2028 ts_params->session_mpool, ts_params->session_priv_mpool,
2029 ts_params->valid_devs[0],
2030 rte_cryptodev_driver_id_get(
2031 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2032 BLKCIPHER_AUTHONLY_TYPE);
2034 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2036 return TEST_SUCCESS;
2041 test_AES_chain_dpaa_sec_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, ts_params->session_priv_mpool,
2049 ts_params->valid_devs[0],
2050 rte_cryptodev_driver_id_get(
2051 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2052 BLKCIPHER_AES_CHAIN_TYPE);
2054 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2056 return TEST_SUCCESS;
2060 test_AES_cipheronly_dpaa_sec_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, ts_params->session_priv_mpool,
2068 ts_params->valid_devs[0],
2069 rte_cryptodev_driver_id_get(
2070 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2071 BLKCIPHER_AES_CIPHERONLY_TYPE);
2073 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2075 return TEST_SUCCESS;
2079 test_authonly_dpaa_sec_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, ts_params->session_priv_mpool,
2087 ts_params->valid_devs[0],
2088 rte_cryptodev_driver_id_get(
2089 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2090 BLKCIPHER_AUTHONLY_TYPE);
2092 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2094 return TEST_SUCCESS;
2098 test_AES_chain_dpaa2_sec_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, ts_params->session_priv_mpool,
2106 ts_params->valid_devs[0],
2107 rte_cryptodev_driver_id_get(
2108 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2109 BLKCIPHER_AES_CHAIN_TYPE);
2111 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2113 return TEST_SUCCESS;
2117 test_AES_cipheronly_dpaa2_sec_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, ts_params->session_priv_mpool,
2125 ts_params->valid_devs[0],
2126 rte_cryptodev_driver_id_get(
2127 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2128 BLKCIPHER_AES_CIPHERONLY_TYPE);
2130 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2132 return TEST_SUCCESS;
2136 test_authonly_dpaa2_sec_all(void)
2138 struct crypto_testsuite_params *ts_params = &testsuite_params;
2141 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2142 ts_params->op_mpool,
2143 ts_params->session_mpool, ts_params->session_priv_mpool,
2144 ts_params->valid_devs[0],
2145 rte_cryptodev_driver_id_get(
2146 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2147 BLKCIPHER_AUTHONLY_TYPE);
2149 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2151 return TEST_SUCCESS;
2155 test_authonly_openssl_all(void)
2157 struct crypto_testsuite_params *ts_params = &testsuite_params;
2160 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2161 ts_params->op_mpool,
2162 ts_params->session_mpool, ts_params->session_priv_mpool,
2163 ts_params->valid_devs[0],
2164 rte_cryptodev_driver_id_get(
2165 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2166 BLKCIPHER_AUTHONLY_TYPE);
2168 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2170 return TEST_SUCCESS;
2174 test_authonly_ccp_all(void)
2176 struct crypto_testsuite_params *ts_params = &testsuite_params;
2179 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2180 ts_params->op_mpool,
2181 ts_params->session_mpool, ts_params->session_priv_mpool,
2182 ts_params->valid_devs[0],
2183 rte_cryptodev_driver_id_get(
2184 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2185 BLKCIPHER_AUTHONLY_TYPE);
2187 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2189 return TEST_SUCCESS;
2193 test_AES_chain_armv8_all(void)
2195 struct crypto_testsuite_params *ts_params = &testsuite_params;
2198 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2199 ts_params->op_mpool,
2200 ts_params->session_mpool, ts_params->session_priv_mpool,
2201 ts_params->valid_devs[0],
2202 rte_cryptodev_driver_id_get(
2203 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2204 BLKCIPHER_AES_CHAIN_TYPE);
2206 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2208 return TEST_SUCCESS;
2212 test_AES_chain_mrvl_all(void)
2214 struct crypto_testsuite_params *ts_params = &testsuite_params;
2217 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2218 ts_params->op_mpool,
2219 ts_params->session_mpool, ts_params->session_priv_mpool,
2220 ts_params->valid_devs[0],
2221 rte_cryptodev_driver_id_get(
2222 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2223 BLKCIPHER_AES_CHAIN_TYPE);
2225 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2227 return TEST_SUCCESS;
2231 test_AES_cipheronly_mrvl_all(void)
2233 struct crypto_testsuite_params *ts_params = &testsuite_params;
2236 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2237 ts_params->op_mpool,
2238 ts_params->session_mpool, ts_params->session_priv_mpool,
2239 ts_params->valid_devs[0],
2240 rte_cryptodev_driver_id_get(
2241 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2242 BLKCIPHER_AES_CIPHERONLY_TYPE);
2244 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2246 return TEST_SUCCESS;
2250 test_authonly_mrvl_all(void)
2252 struct crypto_testsuite_params *ts_params = &testsuite_params;
2255 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2256 ts_params->op_mpool,
2257 ts_params->session_mpool, ts_params->session_priv_mpool,
2258 ts_params->valid_devs[0],
2259 rte_cryptodev_driver_id_get(
2260 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2261 BLKCIPHER_AUTHONLY_TYPE);
2263 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2265 return TEST_SUCCESS;
2269 test_3DES_chain_mrvl_all(void)
2271 struct crypto_testsuite_params *ts_params = &testsuite_params;
2274 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2275 ts_params->op_mpool,
2276 ts_params->session_mpool, ts_params->session_priv_mpool,
2277 ts_params->valid_devs[0],
2278 rte_cryptodev_driver_id_get(
2279 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2280 BLKCIPHER_3DES_CHAIN_TYPE);
2282 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2284 return TEST_SUCCESS;
2288 test_3DES_cipheronly_mrvl_all(void)
2290 struct crypto_testsuite_params *ts_params = &testsuite_params;
2293 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2294 ts_params->op_mpool,
2295 ts_params->session_mpool, ts_params->session_priv_mpool,
2296 ts_params->valid_devs[0],
2297 rte_cryptodev_driver_id_get(
2298 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2299 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2301 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2303 return TEST_SUCCESS;
2307 test_AES_chain_octeontx_all(void)
2309 struct crypto_testsuite_params *ts_params = &testsuite_params;
2312 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2313 ts_params->op_mpool, ts_params->session_mpool,
2314 ts_params->session_priv_mpool,
2315 ts_params->valid_devs[0],
2316 rte_cryptodev_driver_id_get(
2317 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2318 BLKCIPHER_AES_CHAIN_TYPE);
2320 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2322 return TEST_SUCCESS;
2326 test_AES_cipheronly_octeontx_all(void)
2328 struct crypto_testsuite_params *ts_params = &testsuite_params;
2331 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2332 ts_params->op_mpool, ts_params->session_mpool,
2333 ts_params->session_priv_mpool,
2334 ts_params->valid_devs[0],
2335 rte_cryptodev_driver_id_get(
2336 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2337 BLKCIPHER_AES_CIPHERONLY_TYPE);
2339 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2341 return TEST_SUCCESS;
2345 test_3DES_chain_octeontx_all(void)
2347 struct crypto_testsuite_params *ts_params = &testsuite_params;
2350 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2351 ts_params->op_mpool, ts_params->session_mpool,
2352 ts_params->session_priv_mpool,
2353 ts_params->valid_devs[0],
2354 rte_cryptodev_driver_id_get(
2355 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2356 BLKCIPHER_3DES_CHAIN_TYPE);
2358 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2360 return TEST_SUCCESS;
2364 test_AES_chain_nitrox_all(void)
2366 struct crypto_testsuite_params *ts_params = &testsuite_params;
2369 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2370 ts_params->op_mpool,
2371 ts_params->session_mpool, ts_params->session_priv_mpool,
2372 ts_params->valid_devs[0],
2373 rte_cryptodev_driver_id_get(
2374 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2375 BLKCIPHER_AES_CHAIN_TYPE);
2377 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2379 return TEST_SUCCESS;
2383 test_3DES_cipheronly_octeontx_all(void)
2385 struct crypto_testsuite_params *ts_params = &testsuite_params;
2388 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2389 ts_params->op_mpool, ts_params->session_mpool,
2390 ts_params->session_priv_mpool,
2391 ts_params->valid_devs[0],
2392 rte_cryptodev_driver_id_get(
2393 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2394 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2396 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2398 return TEST_SUCCESS;
2402 test_authonly_octeontx_all(void)
2404 struct crypto_testsuite_params *ts_params = &testsuite_params;
2407 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2408 ts_params->op_mpool, ts_params->session_mpool,
2409 ts_params->session_priv_mpool,
2410 ts_params->valid_devs[0],
2411 rte_cryptodev_driver_id_get(
2412 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2413 BLKCIPHER_AUTHONLY_TYPE);
2415 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2417 return TEST_SUCCESS;
2421 test_AES_chain_octeontx2_all(void)
2423 struct crypto_testsuite_params *ts_params = &testsuite_params;
2426 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2427 ts_params->op_mpool, ts_params->session_mpool,
2428 ts_params->session_priv_mpool,
2429 ts_params->valid_devs[0],
2430 rte_cryptodev_driver_id_get(
2431 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2432 BLKCIPHER_AES_CHAIN_TYPE);
2434 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2436 return TEST_SUCCESS;
2440 test_AES_cipheronly_octeontx2_all(void)
2442 struct crypto_testsuite_params *ts_params = &testsuite_params;
2445 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2446 ts_params->op_mpool, ts_params->session_mpool,
2447 ts_params->session_priv_mpool,
2448 ts_params->valid_devs[0],
2449 rte_cryptodev_driver_id_get(
2450 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2451 BLKCIPHER_AES_CIPHERONLY_TYPE);
2453 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2455 return TEST_SUCCESS;
2459 test_3DES_chain_octeontx2_all(void)
2461 struct crypto_testsuite_params *ts_params = &testsuite_params;
2464 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2465 ts_params->op_mpool, ts_params->session_mpool,
2466 ts_params->session_priv_mpool,
2467 ts_params->valid_devs[0],
2468 rte_cryptodev_driver_id_get(
2469 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2470 BLKCIPHER_3DES_CHAIN_TYPE);
2472 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2474 return TEST_SUCCESS;
2478 test_3DES_cipheronly_octeontx2_all(void)
2480 struct crypto_testsuite_params *ts_params = &testsuite_params;
2483 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2484 ts_params->op_mpool, ts_params->session_mpool,
2485 ts_params->session_priv_mpool,
2486 ts_params->valid_devs[0],
2487 rte_cryptodev_driver_id_get(
2488 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2489 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2491 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2493 return TEST_SUCCESS;
2497 test_authonly_octeontx2_all(void)
2499 struct crypto_testsuite_params *ts_params = &testsuite_params;
2502 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2503 ts_params->op_mpool, ts_params->session_mpool,
2504 ts_params->session_priv_mpool,
2505 ts_params->valid_devs[0],
2506 rte_cryptodev_driver_id_get(
2507 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2508 BLKCIPHER_AUTHONLY_TYPE);
2510 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2512 return TEST_SUCCESS;
2515 /* ***** SNOW 3G Tests ***** */
2517 create_wireless_algo_hash_session(uint8_t dev_id,
2518 const uint8_t *key, const uint8_t key_len,
2519 const uint8_t iv_len, const uint8_t auth_len,
2520 enum rte_crypto_auth_operation op,
2521 enum rte_crypto_auth_algorithm algo)
2523 uint8_t hash_key[key_len];
2526 struct crypto_testsuite_params *ts_params = &testsuite_params;
2527 struct crypto_unittest_params *ut_params = &unittest_params;
2529 memcpy(hash_key, key, key_len);
2531 debug_hexdump(stdout, "key:", key, key_len);
2533 /* Setup Authentication Parameters */
2534 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2535 ut_params->auth_xform.next = NULL;
2537 ut_params->auth_xform.auth.op = op;
2538 ut_params->auth_xform.auth.algo = algo;
2539 ut_params->auth_xform.auth.key.length = key_len;
2540 ut_params->auth_xform.auth.key.data = hash_key;
2541 ut_params->auth_xform.auth.digest_length = auth_len;
2542 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2543 ut_params->auth_xform.auth.iv.length = iv_len;
2544 ut_params->sess = rte_cryptodev_sym_session_create(
2545 ts_params->session_mpool);
2547 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2548 &ut_params->auth_xform,
2549 ts_params->session_priv_mpool);
2550 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2551 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2556 create_wireless_algo_cipher_session(uint8_t dev_id,
2557 enum rte_crypto_cipher_operation op,
2558 enum rte_crypto_cipher_algorithm algo,
2559 const uint8_t *key, const uint8_t key_len,
2562 uint8_t cipher_key[key_len];
2564 struct crypto_testsuite_params *ts_params = &testsuite_params;
2565 struct crypto_unittest_params *ut_params = &unittest_params;
2567 memcpy(cipher_key, key, key_len);
2569 /* Setup Cipher Parameters */
2570 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2571 ut_params->cipher_xform.next = NULL;
2573 ut_params->cipher_xform.cipher.algo = algo;
2574 ut_params->cipher_xform.cipher.op = op;
2575 ut_params->cipher_xform.cipher.key.data = cipher_key;
2576 ut_params->cipher_xform.cipher.key.length = key_len;
2577 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2578 ut_params->cipher_xform.cipher.iv.length = iv_len;
2580 debug_hexdump(stdout, "key:", key, key_len);
2582 /* Create Crypto session */
2583 ut_params->sess = rte_cryptodev_sym_session_create(
2584 ts_params->session_mpool);
2586 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2587 &ut_params->cipher_xform,
2588 ts_params->session_priv_mpool);
2589 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2590 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2595 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2596 unsigned int cipher_len,
2597 unsigned int cipher_offset)
2599 struct crypto_testsuite_params *ts_params = &testsuite_params;
2600 struct crypto_unittest_params *ut_params = &unittest_params;
2602 /* Generate Crypto op data structure */
2603 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2604 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2605 TEST_ASSERT_NOT_NULL(ut_params->op,
2606 "Failed to allocate pktmbuf offload");
2608 /* Set crypto operation data parameters */
2609 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2611 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2613 /* set crypto operation source mbuf */
2614 sym_op->m_src = ut_params->ibuf;
2617 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2619 sym_op->cipher.data.length = cipher_len;
2620 sym_op->cipher.data.offset = cipher_offset;
2625 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2626 unsigned int cipher_len,
2627 unsigned int cipher_offset)
2629 struct crypto_testsuite_params *ts_params = &testsuite_params;
2630 struct crypto_unittest_params *ut_params = &unittest_params;
2632 /* Generate Crypto op data structure */
2633 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2634 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2635 TEST_ASSERT_NOT_NULL(ut_params->op,
2636 "Failed to allocate pktmbuf offload");
2638 /* Set crypto operation data parameters */
2639 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2641 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2643 /* set crypto operation source mbuf */
2644 sym_op->m_src = ut_params->ibuf;
2645 sym_op->m_dst = ut_params->obuf;
2648 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2650 sym_op->cipher.data.length = cipher_len;
2651 sym_op->cipher.data.offset = cipher_offset;
2656 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2657 enum rte_crypto_cipher_operation cipher_op,
2658 enum rte_crypto_auth_operation auth_op,
2659 enum rte_crypto_auth_algorithm auth_algo,
2660 enum rte_crypto_cipher_algorithm cipher_algo,
2661 const uint8_t *key, uint8_t key_len,
2662 uint8_t auth_iv_len, uint8_t auth_len,
2663 uint8_t cipher_iv_len)
2666 uint8_t cipher_auth_key[key_len];
2669 struct crypto_testsuite_params *ts_params = &testsuite_params;
2670 struct crypto_unittest_params *ut_params = &unittest_params;
2672 memcpy(cipher_auth_key, key, key_len);
2674 /* Setup Authentication Parameters */
2675 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2676 ut_params->auth_xform.next = NULL;
2678 ut_params->auth_xform.auth.op = auth_op;
2679 ut_params->auth_xform.auth.algo = auth_algo;
2680 ut_params->auth_xform.auth.key.length = key_len;
2681 /* Hash key = cipher key */
2682 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2683 ut_params->auth_xform.auth.digest_length = auth_len;
2684 /* Auth IV will be after cipher IV */
2685 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2686 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2688 /* Setup Cipher Parameters */
2689 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2690 ut_params->cipher_xform.next = &ut_params->auth_xform;
2692 ut_params->cipher_xform.cipher.algo = cipher_algo;
2693 ut_params->cipher_xform.cipher.op = cipher_op;
2694 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2695 ut_params->cipher_xform.cipher.key.length = key_len;
2696 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2697 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2699 debug_hexdump(stdout, "key:", key, key_len);
2701 /* Create Crypto session*/
2702 ut_params->sess = rte_cryptodev_sym_session_create(
2703 ts_params->session_mpool);
2704 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2706 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2707 &ut_params->cipher_xform,
2708 ts_params->session_priv_mpool);
2709 if (status == -ENOTSUP)
2712 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2717 create_wireless_cipher_auth_session(uint8_t dev_id,
2718 enum rte_crypto_cipher_operation cipher_op,
2719 enum rte_crypto_auth_operation auth_op,
2720 enum rte_crypto_auth_algorithm auth_algo,
2721 enum rte_crypto_cipher_algorithm cipher_algo,
2722 const struct wireless_test_data *tdata)
2724 const uint8_t key_len = tdata->key.len;
2725 uint8_t cipher_auth_key[key_len];
2728 struct crypto_testsuite_params *ts_params = &testsuite_params;
2729 struct crypto_unittest_params *ut_params = &unittest_params;
2730 const uint8_t *key = tdata->key.data;
2731 const uint8_t auth_len = tdata->digest.len;
2732 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2733 uint8_t auth_iv_len = tdata->auth_iv.len;
2735 memcpy(cipher_auth_key, key, key_len);
2737 /* Setup Authentication Parameters */
2738 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2739 ut_params->auth_xform.next = NULL;
2741 ut_params->auth_xform.auth.op = auth_op;
2742 ut_params->auth_xform.auth.algo = auth_algo;
2743 ut_params->auth_xform.auth.key.length = key_len;
2744 /* Hash key = cipher key */
2745 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2746 ut_params->auth_xform.auth.digest_length = auth_len;
2747 /* Auth IV will be after cipher IV */
2748 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2749 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2751 /* Setup Cipher Parameters */
2752 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2753 ut_params->cipher_xform.next = &ut_params->auth_xform;
2755 ut_params->cipher_xform.cipher.algo = cipher_algo;
2756 ut_params->cipher_xform.cipher.op = cipher_op;
2757 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2758 ut_params->cipher_xform.cipher.key.length = key_len;
2759 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2760 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2763 debug_hexdump(stdout, "key:", key, key_len);
2765 /* Create Crypto session*/
2766 ut_params->sess = rte_cryptodev_sym_session_create(
2767 ts_params->session_mpool);
2769 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2770 &ut_params->cipher_xform,
2771 ts_params->session_priv_mpool);
2773 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2774 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2779 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2780 const struct wireless_test_data *tdata)
2782 return create_wireless_cipher_auth_session(dev_id,
2783 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2784 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2785 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2789 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2790 enum rte_crypto_cipher_operation cipher_op,
2791 enum rte_crypto_auth_operation auth_op,
2792 enum rte_crypto_auth_algorithm auth_algo,
2793 enum rte_crypto_cipher_algorithm cipher_algo,
2794 const uint8_t *key, const uint8_t key_len,
2795 uint8_t auth_iv_len, uint8_t auth_len,
2796 uint8_t cipher_iv_len)
2798 uint8_t auth_cipher_key[key_len];
2800 struct crypto_testsuite_params *ts_params = &testsuite_params;
2801 struct crypto_unittest_params *ut_params = &unittest_params;
2803 memcpy(auth_cipher_key, key, key_len);
2805 /* Setup Authentication Parameters */
2806 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2807 ut_params->auth_xform.auth.op = auth_op;
2808 ut_params->auth_xform.next = &ut_params->cipher_xform;
2809 ut_params->auth_xform.auth.algo = auth_algo;
2810 ut_params->auth_xform.auth.key.length = key_len;
2811 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2812 ut_params->auth_xform.auth.digest_length = auth_len;
2813 /* Auth IV will be after cipher IV */
2814 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2815 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2817 /* Setup Cipher Parameters */
2818 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2819 ut_params->cipher_xform.next = NULL;
2820 ut_params->cipher_xform.cipher.algo = cipher_algo;
2821 ut_params->cipher_xform.cipher.op = cipher_op;
2822 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2823 ut_params->cipher_xform.cipher.key.length = key_len;
2824 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2825 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2827 debug_hexdump(stdout, "key:", key, key_len);
2829 /* Create Crypto session*/
2830 ut_params->sess = rte_cryptodev_sym_session_create(
2831 ts_params->session_mpool);
2832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2834 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2835 ut_params->auth_xform.next = NULL;
2836 ut_params->cipher_xform.next = &ut_params->auth_xform;
2837 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2838 &ut_params->cipher_xform,
2839 ts_params->session_priv_mpool);
2842 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2843 &ut_params->auth_xform,
2844 ts_params->session_priv_mpool);
2846 if (status == -ENOTSUP)
2849 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2855 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2856 unsigned int auth_tag_len,
2857 const uint8_t *iv, unsigned int iv_len,
2858 unsigned int data_pad_len,
2859 enum rte_crypto_auth_operation op,
2860 unsigned int auth_len, unsigned int auth_offset)
2862 struct crypto_testsuite_params *ts_params = &testsuite_params;
2864 struct crypto_unittest_params *ut_params = &unittest_params;
2866 /* Generate Crypto op data structure */
2867 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2868 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2869 TEST_ASSERT_NOT_NULL(ut_params->op,
2870 "Failed to allocate pktmbuf offload");
2872 /* Set crypto operation data parameters */
2873 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2875 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2877 /* set crypto operation source mbuf */
2878 sym_op->m_src = ut_params->ibuf;
2881 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2884 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2885 ut_params->ibuf, auth_tag_len);
2887 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2888 "no room to append auth tag");
2889 ut_params->digest = sym_op->auth.digest.data;
2890 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2891 ut_params->ibuf, data_pad_len);
2892 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2893 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2895 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2897 debug_hexdump(stdout, "digest:",
2898 sym_op->auth.digest.data,
2901 sym_op->auth.data.length = auth_len;
2902 sym_op->auth.data.offset = auth_offset;
2908 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2909 enum rte_crypto_auth_operation op)
2911 struct crypto_testsuite_params *ts_params = &testsuite_params;
2912 struct crypto_unittest_params *ut_params = &unittest_params;
2914 const uint8_t *auth_tag = tdata->digest.data;
2915 const unsigned int auth_tag_len = tdata->digest.len;
2916 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2917 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2919 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2920 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2921 const uint8_t *auth_iv = tdata->auth_iv.data;
2922 const uint8_t auth_iv_len = tdata->auth_iv.len;
2923 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2924 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2926 /* Generate Crypto op data structure */
2927 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2928 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2929 TEST_ASSERT_NOT_NULL(ut_params->op,
2930 "Failed to allocate pktmbuf offload");
2931 /* Set crypto operation data parameters */
2932 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2934 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2936 /* set crypto operation source mbuf */
2937 sym_op->m_src = ut_params->ibuf;
2940 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2941 ut_params->ibuf, auth_tag_len);
2943 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2944 "no room to append auth tag");
2945 ut_params->digest = sym_op->auth.digest.data;
2946 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2947 ut_params->ibuf, data_pad_len);
2948 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2949 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2951 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2953 debug_hexdump(stdout, "digest:",
2954 sym_op->auth.digest.data,
2957 /* Copy cipher and auth IVs at the end of the crypto operation */
2958 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2960 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2961 iv_ptr += cipher_iv_len;
2962 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2964 sym_op->cipher.data.length = cipher_len;
2965 sym_op->cipher.data.offset = 0;
2966 sym_op->auth.data.length = auth_len;
2967 sym_op->auth.data.offset = 0;
2973 create_zuc_cipher_hash_generate_operation(
2974 const struct wireless_test_data *tdata)
2976 return create_wireless_cipher_hash_operation(tdata,
2977 RTE_CRYPTO_AUTH_OP_GENERATE);
2981 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2982 const unsigned auth_tag_len,
2983 const uint8_t *auth_iv, uint8_t auth_iv_len,
2984 unsigned data_pad_len,
2985 enum rte_crypto_auth_operation op,
2986 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2987 const unsigned cipher_len, const unsigned cipher_offset,
2988 const unsigned auth_len, const unsigned auth_offset)
2990 struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 struct crypto_unittest_params *ut_params = &unittest_params;
2993 enum rte_crypto_cipher_algorithm cipher_algo =
2994 ut_params->cipher_xform.cipher.algo;
2995 enum rte_crypto_auth_algorithm auth_algo =
2996 ut_params->auth_xform.auth.algo;
2998 /* Generate Crypto op data structure */
2999 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3000 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3001 TEST_ASSERT_NOT_NULL(ut_params->op,
3002 "Failed to allocate pktmbuf offload");
3003 /* Set crypto operation data parameters */
3004 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3006 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3008 /* set crypto operation source mbuf */
3009 sym_op->m_src = ut_params->ibuf;
3012 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3013 ut_params->ibuf, auth_tag_len);
3015 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3016 "no room to append auth tag");
3017 ut_params->digest = sym_op->auth.digest.data;
3019 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3020 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3021 ut_params->ibuf, data_pad_len);
3023 struct rte_mbuf *m = ut_params->ibuf;
3024 unsigned int offset = data_pad_len;
3026 while (offset > m->data_len && m->next != NULL) {
3027 offset -= m->data_len;
3030 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3034 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3035 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3037 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3039 debug_hexdump(stdout, "digest:",
3040 sym_op->auth.digest.data,
3043 /* Copy cipher and auth IVs at the end of the crypto operation */
3044 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3046 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3047 iv_ptr += cipher_iv_len;
3048 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3050 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3051 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3052 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3053 sym_op->cipher.data.length = cipher_len;
3054 sym_op->cipher.data.offset = cipher_offset;
3056 sym_op->cipher.data.length = cipher_len >> 3;
3057 sym_op->cipher.data.offset = cipher_offset >> 3;
3060 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3061 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3062 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3063 sym_op->auth.data.length = auth_len;
3064 sym_op->auth.data.offset = auth_offset;
3066 sym_op->auth.data.length = auth_len >> 3;
3067 sym_op->auth.data.offset = auth_offset >> 3;
3074 create_wireless_algo_auth_cipher_operation(
3075 const uint8_t *auth_tag, unsigned int auth_tag_len,
3076 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3077 const uint8_t *auth_iv, uint8_t auth_iv_len,
3078 unsigned int data_pad_len,
3079 unsigned int cipher_len, unsigned int cipher_offset,
3080 unsigned int auth_len, unsigned int auth_offset,
3081 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3083 struct crypto_testsuite_params *ts_params = &testsuite_params;
3084 struct crypto_unittest_params *ut_params = &unittest_params;
3086 enum rte_crypto_cipher_algorithm cipher_algo =
3087 ut_params->cipher_xform.cipher.algo;
3088 enum rte_crypto_auth_algorithm auth_algo =
3089 ut_params->auth_xform.auth.algo;
3091 /* Generate Crypto op data structure */
3092 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3093 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3094 TEST_ASSERT_NOT_NULL(ut_params->op,
3095 "Failed to allocate pktmbuf offload");
3097 /* Set crypto operation data parameters */
3098 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3100 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3102 /* set crypto operation mbufs */
3103 sym_op->m_src = ut_params->ibuf;
3104 if (op_mode == OUT_OF_PLACE)
3105 sym_op->m_dst = ut_params->obuf;
3109 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3110 (op_mode == IN_PLACE ?
3111 ut_params->ibuf : ut_params->obuf),
3112 uint8_t *, data_pad_len);
3113 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3114 (op_mode == IN_PLACE ?
3115 ut_params->ibuf : ut_params->obuf),
3117 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3119 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3120 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3121 sym_op->m_src : sym_op->m_dst);
3122 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3123 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3124 sgl_buf = sgl_buf->next;
3126 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3127 uint8_t *, remaining_off);
3128 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3130 memset(sym_op->auth.digest.data, 0, remaining_off);
3131 while (sgl_buf->next != NULL) {
3132 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3133 0, rte_pktmbuf_data_len(sgl_buf));
3134 sgl_buf = sgl_buf->next;
3138 /* Copy digest for the verification */
3140 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3142 /* Copy cipher and auth IVs at the end of the crypto operation */
3143 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3144 ut_params->op, uint8_t *, IV_OFFSET);
3146 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3147 iv_ptr += cipher_iv_len;
3148 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3150 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3151 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3152 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3153 sym_op->cipher.data.length = cipher_len;
3154 sym_op->cipher.data.offset = cipher_offset;
3156 sym_op->cipher.data.length = cipher_len >> 3;
3157 sym_op->cipher.data.offset = cipher_offset >> 3;
3160 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3161 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3162 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3163 sym_op->auth.data.length = auth_len;
3164 sym_op->auth.data.offset = auth_offset;
3166 sym_op->auth.data.length = auth_len >> 3;
3167 sym_op->auth.data.offset = auth_offset >> 3;
3174 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3176 struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 struct crypto_unittest_params *ut_params = &unittest_params;
3180 unsigned plaintext_pad_len;
3181 unsigned plaintext_len;
3184 /* Create SNOW 3G session */
3185 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3186 tdata->key.data, tdata->key.len,
3187 tdata->auth_iv.len, tdata->digest.len,
3188 RTE_CRYPTO_AUTH_OP_GENERATE,
3189 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3193 /* alloc mbuf and set payload */
3194 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3196 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3197 rte_pktmbuf_tailroom(ut_params->ibuf));
3199 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3200 /* Append data which is padded to a multiple of */
3201 /* the algorithms block size */
3202 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3203 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3205 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3207 /* Create SNOW 3G operation */
3208 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3209 tdata->auth_iv.data, tdata->auth_iv.len,
3210 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3211 tdata->validAuthLenInBits.len,
3216 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3218 ut_params->obuf = ut_params->op->sym->m_src;
3219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3220 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3221 + plaintext_pad_len;
3224 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3227 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3228 "SNOW 3G Generated auth tag not as expected");
3234 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3236 struct crypto_testsuite_params *ts_params = &testsuite_params;
3237 struct crypto_unittest_params *ut_params = &unittest_params;
3240 unsigned plaintext_pad_len;
3241 unsigned plaintext_len;
3244 /* Create SNOW 3G session */
3245 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3246 tdata->key.data, tdata->key.len,
3247 tdata->auth_iv.len, tdata->digest.len,
3248 RTE_CRYPTO_AUTH_OP_VERIFY,
3249 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3252 /* alloc mbuf and set payload */
3253 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3256 rte_pktmbuf_tailroom(ut_params->ibuf));
3258 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3259 /* Append data which is padded to a multiple of */
3260 /* the algorithms block size */
3261 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3262 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3264 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3266 /* Create SNOW 3G operation */
3267 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3269 tdata->auth_iv.data, tdata->auth_iv.len,
3271 RTE_CRYPTO_AUTH_OP_VERIFY,
3272 tdata->validAuthLenInBits.len,
3277 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3279 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 ut_params->obuf = ut_params->op->sym->m_src;
3281 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3282 + plaintext_pad_len;
3285 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3294 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3296 struct crypto_testsuite_params *ts_params = &testsuite_params;
3297 struct crypto_unittest_params *ut_params = &unittest_params;
3300 unsigned plaintext_pad_len;
3301 unsigned plaintext_len;
3304 /* Create KASUMI session */
3305 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3306 tdata->key.data, tdata->key.len,
3307 0, tdata->digest.len,
3308 RTE_CRYPTO_AUTH_OP_GENERATE,
3309 RTE_CRYPTO_AUTH_KASUMI_F9);
3313 /* alloc mbuf and set payload */
3314 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3317 rte_pktmbuf_tailroom(ut_params->ibuf));
3319 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3320 /* Append data which is padded to a multiple of */
3321 /* the algorithms block size */
3322 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3325 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3327 /* Create KASUMI operation */
3328 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3330 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3331 tdata->plaintext.len,
3336 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3338 ut_params->obuf = ut_params->op->sym->m_src;
3339 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3340 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3341 + plaintext_pad_len;
3344 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3347 DIGEST_BYTE_LENGTH_KASUMI_F9,
3348 "KASUMI Generated auth tag not as expected");
3354 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3356 struct crypto_testsuite_params *ts_params = &testsuite_params;
3357 struct crypto_unittest_params *ut_params = &unittest_params;
3360 unsigned plaintext_pad_len;
3361 unsigned plaintext_len;
3364 /* Create KASUMI session */
3365 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3366 tdata->key.data, tdata->key.len,
3367 0, tdata->digest.len,
3368 RTE_CRYPTO_AUTH_OP_VERIFY,
3369 RTE_CRYPTO_AUTH_KASUMI_F9);
3372 /* alloc mbuf and set payload */
3373 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3375 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3376 rte_pktmbuf_tailroom(ut_params->ibuf));
3378 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3379 /* Append data which is padded to a multiple */
3380 /* of the algorithms block size */
3381 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3382 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3384 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3386 /* Create KASUMI operation */
3387 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3391 RTE_CRYPTO_AUTH_OP_VERIFY,
3392 tdata->plaintext.len,
3397 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3399 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3400 ut_params->obuf = ut_params->op->sym->m_src;
3401 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3402 + plaintext_pad_len;
3405 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3414 test_snow3g_hash_generate_test_case_1(void)
3416 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3420 test_snow3g_hash_generate_test_case_2(void)
3422 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3426 test_snow3g_hash_generate_test_case_3(void)
3428 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3432 test_snow3g_hash_generate_test_case_4(void)
3434 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3438 test_snow3g_hash_generate_test_case_5(void)
3440 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3444 test_snow3g_hash_generate_test_case_6(void)
3446 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3450 test_snow3g_hash_verify_test_case_1(void)
3452 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3457 test_snow3g_hash_verify_test_case_2(void)
3459 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3463 test_snow3g_hash_verify_test_case_3(void)
3465 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3469 test_snow3g_hash_verify_test_case_4(void)
3471 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3475 test_snow3g_hash_verify_test_case_5(void)
3477 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3481 test_snow3g_hash_verify_test_case_6(void)
3483 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3487 test_kasumi_hash_generate_test_case_1(void)
3489 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3493 test_kasumi_hash_generate_test_case_2(void)
3495 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3499 test_kasumi_hash_generate_test_case_3(void)
3501 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3505 test_kasumi_hash_generate_test_case_4(void)
3507 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3511 test_kasumi_hash_generate_test_case_5(void)
3513 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3517 test_kasumi_hash_generate_test_case_6(void)
3519 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3523 test_kasumi_hash_verify_test_case_1(void)
3525 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3529 test_kasumi_hash_verify_test_case_2(void)
3531 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3535 test_kasumi_hash_verify_test_case_3(void)
3537 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3541 test_kasumi_hash_verify_test_case_4(void)
3543 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3547 test_kasumi_hash_verify_test_case_5(void)
3549 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3553 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3555 struct crypto_testsuite_params *ts_params = &testsuite_params;
3556 struct crypto_unittest_params *ut_params = &unittest_params;
3559 uint8_t *plaintext, *ciphertext;
3560 unsigned plaintext_pad_len;
3561 unsigned plaintext_len;
3563 /* Create KASUMI session */
3564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3565 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3566 RTE_CRYPTO_CIPHER_KASUMI_F8,
3567 tdata->key.data, tdata->key.len,
3568 tdata->cipher_iv.len);
3572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3574 /* Clear mbuf payload */
3575 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3576 rte_pktmbuf_tailroom(ut_params->ibuf));
3578 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3579 /* Append data which is padded to a multiple */
3580 /* of the algorithms block size */
3581 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3582 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3584 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3586 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3588 /* Create KASUMI operation */
3589 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3590 tdata->cipher_iv.len,
3591 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3592 tdata->validCipherOffsetInBits.len);
3596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3600 ut_params->obuf = ut_params->op->sym->m_dst;
3601 if (ut_params->obuf)
3602 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3604 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3606 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3608 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3609 (tdata->validCipherOffsetInBits.len >> 3);
3611 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3613 reference_ciphertext,
3614 tdata->validCipherLenInBits.len,
3615 "KASUMI Ciphertext data not as expected");
3620 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3622 struct crypto_testsuite_params *ts_params = &testsuite_params;
3623 struct crypto_unittest_params *ut_params = &unittest_params;
3627 unsigned int plaintext_pad_len;
3628 unsigned int plaintext_len;
3630 uint8_t buffer[10000];
3631 const uint8_t *ciphertext;
3633 struct rte_cryptodev_info dev_info;
3635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3637 uint64_t feat_flags = dev_info.feature_flags;
3639 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3640 printf("Device doesn't support in-place scatter-gather. "
3645 /* Create KASUMI session */
3646 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3647 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3648 RTE_CRYPTO_CIPHER_KASUMI_F8,
3649 tdata->key.data, tdata->key.len,
3650 tdata->cipher_iv.len);
3654 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3657 /* Append data which is padded to a multiple */
3658 /* of the algorithms block size */
3659 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3661 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3662 plaintext_pad_len, 10, 0);
3664 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3666 /* Create KASUMI operation */
3667 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3668 tdata->cipher_iv.len,
3669 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3670 tdata->validCipherOffsetInBits.len);
3674 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3676 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3678 ut_params->obuf = ut_params->op->sym->m_dst;
3680 if (ut_params->obuf)
3681 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3682 plaintext_len, buffer);
3684 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3685 tdata->validCipherOffsetInBits.len >> 3,
3686 plaintext_len, buffer);
3689 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3691 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3692 (tdata->validCipherOffsetInBits.len >> 3);
3694 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3696 reference_ciphertext,
3697 tdata->validCipherLenInBits.len,
3698 "KASUMI Ciphertext data not as expected");
3703 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3705 struct crypto_testsuite_params *ts_params = &testsuite_params;
3706 struct crypto_unittest_params *ut_params = &unittest_params;
3709 uint8_t *plaintext, *ciphertext;
3710 unsigned plaintext_pad_len;
3711 unsigned plaintext_len;
3713 /* Create KASUMI session */
3714 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3715 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3716 RTE_CRYPTO_CIPHER_KASUMI_F8,
3717 tdata->key.data, tdata->key.len,
3718 tdata->cipher_iv.len);
3722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3723 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3725 /* Clear mbuf payload */
3726 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3727 rte_pktmbuf_tailroom(ut_params->ibuf));
3729 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3730 /* Append data which is padded to a multiple */
3731 /* of the algorithms block size */
3732 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3733 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3735 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3736 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3738 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3740 /* Create KASUMI operation */
3741 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3742 tdata->cipher_iv.len,
3743 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3744 tdata->validCipherOffsetInBits.len);
3748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3752 ut_params->obuf = ut_params->op->sym->m_dst;
3753 if (ut_params->obuf)
3754 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3756 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3758 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3760 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3761 (tdata->validCipherOffsetInBits.len >> 3);
3763 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3765 reference_ciphertext,
3766 tdata->validCipherLenInBits.len,
3767 "KASUMI Ciphertext data not as expected");
3772 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3774 struct crypto_testsuite_params *ts_params = &testsuite_params;
3775 struct crypto_unittest_params *ut_params = &unittest_params;
3778 unsigned int plaintext_pad_len;
3779 unsigned int plaintext_len;
3781 const uint8_t *ciphertext;
3782 uint8_t buffer[2048];
3784 struct rte_cryptodev_info dev_info;
3786 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3788 uint64_t feat_flags = dev_info.feature_flags;
3789 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3790 printf("Device doesn't support out-of-place scatter-gather "
3791 "in both input and output mbufs. "
3796 /* Create KASUMI session */
3797 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3798 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3799 RTE_CRYPTO_CIPHER_KASUMI_F8,
3800 tdata->key.data, tdata->key.len,
3801 tdata->cipher_iv.len);
3805 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3806 /* Append data which is padded to a multiple */
3807 /* of the algorithms block size */
3808 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3810 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3811 plaintext_pad_len, 10, 0);
3812 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3813 plaintext_pad_len, 3, 0);
3815 /* Append data which is padded to a multiple */
3816 /* of the algorithms block size */
3817 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3819 /* Create KASUMI operation */
3820 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3821 tdata->cipher_iv.len,
3822 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3823 tdata->validCipherOffsetInBits.len);
3827 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3829 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3831 ut_params->obuf = ut_params->op->sym->m_dst;
3832 if (ut_params->obuf)
3833 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3834 plaintext_pad_len, buffer);
3836 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3837 tdata->validCipherOffsetInBits.len >> 3,
3838 plaintext_pad_len, buffer);
3840 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3841 (tdata->validCipherOffsetInBits.len >> 3);
3843 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3845 reference_ciphertext,
3846 tdata->validCipherLenInBits.len,
3847 "KASUMI Ciphertext data not as expected");
3853 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3855 struct crypto_testsuite_params *ts_params = &testsuite_params;
3856 struct crypto_unittest_params *ut_params = &unittest_params;
3859 uint8_t *ciphertext, *plaintext;
3860 unsigned ciphertext_pad_len;
3861 unsigned ciphertext_len;
3863 /* Create KASUMI session */
3864 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3865 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3866 RTE_CRYPTO_CIPHER_KASUMI_F8,
3867 tdata->key.data, tdata->key.len,
3868 tdata->cipher_iv.len);
3872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3873 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3875 /* Clear mbuf payload */
3876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3877 rte_pktmbuf_tailroom(ut_params->ibuf));
3879 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3880 /* Append data which is padded to a multiple */
3881 /* of the algorithms block size */
3882 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3883 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3884 ciphertext_pad_len);
3885 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3886 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3888 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3890 /* Create KASUMI operation */
3891 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3892 tdata->cipher_iv.len,
3893 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3894 tdata->validCipherOffsetInBits.len);
3898 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3900 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3902 ut_params->obuf = ut_params->op->sym->m_dst;
3903 if (ut_params->obuf)
3904 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3906 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3908 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3910 const uint8_t *reference_plaintext = tdata->plaintext.data +
3911 (tdata->validCipherOffsetInBits.len >> 3);
3913 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3915 reference_plaintext,
3916 tdata->validCipherLenInBits.len,
3917 "KASUMI Plaintext data not as expected");
3922 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3924 struct crypto_testsuite_params *ts_params = &testsuite_params;
3925 struct crypto_unittest_params *ut_params = &unittest_params;
3928 uint8_t *ciphertext, *plaintext;
3929 unsigned ciphertext_pad_len;
3930 unsigned ciphertext_len;
3932 /* Create KASUMI session */
3933 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3934 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3935 RTE_CRYPTO_CIPHER_KASUMI_F8,
3936 tdata->key.data, tdata->key.len,
3937 tdata->cipher_iv.len);
3941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3943 /* Clear mbuf payload */
3944 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3945 rte_pktmbuf_tailroom(ut_params->ibuf));
3947 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3948 /* Append data which is padded to a multiple */
3949 /* of the algorithms block size */
3950 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3951 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3952 ciphertext_pad_len);
3953 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3955 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3957 /* Create KASUMI operation */
3958 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3959 tdata->cipher_iv.len,
3960 tdata->ciphertext.len,
3961 tdata->validCipherOffsetInBits.len);
3965 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3969 ut_params->obuf = ut_params->op->sym->m_dst;
3970 if (ut_params->obuf)
3971 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3973 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3975 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3977 const uint8_t *reference_plaintext = tdata->plaintext.data +
3978 (tdata->validCipherOffsetInBits.len >> 3);
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3982 reference_plaintext,
3983 tdata->validCipherLenInBits.len,
3984 "KASUMI Plaintext data not as expected");
3989 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3991 struct crypto_testsuite_params *ts_params = &testsuite_params;
3992 struct crypto_unittest_params *ut_params = &unittest_params;
3995 uint8_t *plaintext, *ciphertext;
3996 unsigned plaintext_pad_len;
3997 unsigned plaintext_len;
3999 /* Create SNOW 3G session */
4000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4002 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4003 tdata->key.data, tdata->key.len,
4004 tdata->cipher_iv.len);
4008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4010 /* Clear mbuf payload */
4011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4012 rte_pktmbuf_tailroom(ut_params->ibuf));
4014 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4015 /* Append data which is padded to a multiple of */
4016 /* the algorithms block size */
4017 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4018 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4020 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4022 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4024 /* Create SNOW 3G operation */
4025 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4026 tdata->cipher_iv.len,
4027 tdata->validCipherLenInBits.len,
4032 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4034 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4036 ut_params->obuf = ut_params->op->sym->m_dst;
4037 if (ut_params->obuf)
4038 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4040 ciphertext = plaintext;
4042 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4045 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4047 tdata->ciphertext.data,
4048 tdata->validDataLenInBits.len,
4049 "SNOW 3G Ciphertext data not as expected");
4055 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4057 struct crypto_testsuite_params *ts_params = &testsuite_params;
4058 struct crypto_unittest_params *ut_params = &unittest_params;
4059 uint8_t *plaintext, *ciphertext;
4062 unsigned plaintext_pad_len;
4063 unsigned plaintext_len;
4065 /* Create SNOW 3G session */
4066 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4067 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4068 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4069 tdata->key.data, tdata->key.len,
4070 tdata->cipher_iv.len);
4074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4075 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4077 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4078 "Failed to allocate input buffer in mempool");
4079 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4080 "Failed to allocate output buffer in mempool");
4082 /* Clear mbuf payload */
4083 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4084 rte_pktmbuf_tailroom(ut_params->ibuf));
4086 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4087 /* Append data which is padded to a multiple of */
4088 /* the algorithms block size */
4089 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4090 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4092 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4095 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4097 /* Create SNOW 3G operation */
4098 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4099 tdata->cipher_iv.len,
4100 tdata->validCipherLenInBits.len,
4105 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4107 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4109 ut_params->obuf = ut_params->op->sym->m_dst;
4110 if (ut_params->obuf)
4111 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4113 ciphertext = plaintext;
4115 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4118 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4120 tdata->ciphertext.data,
4121 tdata->validDataLenInBits.len,
4122 "SNOW 3G Ciphertext data not as expected");
4127 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4129 struct crypto_testsuite_params *ts_params = &testsuite_params;
4130 struct crypto_unittest_params *ut_params = &unittest_params;
4133 unsigned int plaintext_pad_len;
4134 unsigned int plaintext_len;
4135 uint8_t buffer[10000];
4136 const uint8_t *ciphertext;
4138 struct rte_cryptodev_info dev_info;
4140 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4142 uint64_t feat_flags = dev_info.feature_flags;
4144 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4145 printf("Device doesn't support out-of-place scatter-gather "
4146 "in both input and output mbufs. "
4151 /* Create SNOW 3G session */
4152 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4153 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4154 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4155 tdata->key.data, tdata->key.len,
4156 tdata->cipher_iv.len);
4160 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4161 /* Append data which is padded to a multiple of */
4162 /* the algorithms block size */
4163 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4165 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4166 plaintext_pad_len, 10, 0);
4167 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4168 plaintext_pad_len, 3, 0);
4170 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4171 "Failed to allocate input buffer in mempool");
4172 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4173 "Failed to allocate output buffer in mempool");
4175 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4177 /* Create SNOW 3G operation */
4178 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4179 tdata->cipher_iv.len,
4180 tdata->validCipherLenInBits.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");
4189 ut_params->obuf = ut_params->op->sym->m_dst;
4190 if (ut_params->obuf)
4191 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4192 plaintext_len, buffer);
4194 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4195 plaintext_len, buffer);
4197 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4200 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4202 tdata->ciphertext.data,
4203 tdata->validDataLenInBits.len,
4204 "SNOW 3G Ciphertext data not as expected");
4209 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4211 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4213 uint8_t curr_byte, prev_byte;
4214 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4215 uint8_t lower_byte_mask = (1 << offset) - 1;
4218 prev_byte = buffer[0];
4219 buffer[0] >>= offset;
4221 for (i = 1; i < length_in_bytes; i++) {
4222 curr_byte = buffer[i];
4223 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4224 (curr_byte >> offset);
4225 prev_byte = curr_byte;
4230 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4232 struct crypto_testsuite_params *ts_params = &testsuite_params;
4233 struct crypto_unittest_params *ut_params = &unittest_params;
4234 uint8_t *plaintext, *ciphertext;
4236 uint32_t plaintext_len;
4237 uint32_t plaintext_pad_len;
4238 uint8_t extra_offset = 4;
4239 uint8_t *expected_ciphertext_shifted;
4241 /* Create SNOW 3G session */
4242 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4243 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4244 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4245 tdata->key.data, tdata->key.len,
4246 tdata->cipher_iv.len);
4250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4251 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4253 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4254 "Failed to allocate input buffer in mempool");
4255 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4256 "Failed to allocate output buffer in mempool");
4258 /* Clear mbuf payload */
4259 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4260 rte_pktmbuf_tailroom(ut_params->ibuf));
4262 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4264 * Append data which is padded to a
4265 * multiple of the algorithms block size
4267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4269 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4272 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4274 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4275 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4277 #ifdef RTE_APP_TEST_DEBUG
4278 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4280 /* Create SNOW 3G operation */
4281 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4282 tdata->cipher_iv.len,
4283 tdata->validCipherLenInBits.len,
4288 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4290 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4292 ut_params->obuf = ut_params->op->sym->m_dst;
4293 if (ut_params->obuf)
4294 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4296 ciphertext = plaintext;
4298 #ifdef RTE_APP_TEST_DEBUG
4299 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4302 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4304 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4305 "failed to reserve memory for ciphertext shifted\n");
4307 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4308 ceil_byte_length(tdata->ciphertext.len));
4309 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4314 expected_ciphertext_shifted,
4315 tdata->validDataLenInBits.len,
4317 "SNOW 3G Ciphertext data not as expected");
4321 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4323 struct crypto_testsuite_params *ts_params = &testsuite_params;
4324 struct crypto_unittest_params *ut_params = &unittest_params;
4328 uint8_t *plaintext, *ciphertext;
4329 unsigned ciphertext_pad_len;
4330 unsigned ciphertext_len;
4332 /* Create SNOW 3G session */
4333 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4334 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4335 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4336 tdata->key.data, tdata->key.len,
4337 tdata->cipher_iv.len);
4341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4343 /* Clear mbuf payload */
4344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4345 rte_pktmbuf_tailroom(ut_params->ibuf));
4347 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4348 /* Append data which is padded to a multiple of */
4349 /* the algorithms block size */
4350 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4351 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4352 ciphertext_pad_len);
4353 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4355 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4357 /* Create SNOW 3G operation */
4358 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4359 tdata->cipher_iv.len,
4360 tdata->validCipherLenInBits.len,
4361 tdata->cipher.offset_bits);
4365 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4367 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4368 ut_params->obuf = ut_params->op->sym->m_dst;
4369 if (ut_params->obuf)
4370 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4372 plaintext = ciphertext;
4374 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4377 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4378 tdata->plaintext.data,
4379 tdata->validDataLenInBits.len,
4380 "SNOW 3G Plaintext data not as expected");
4384 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4386 struct crypto_testsuite_params *ts_params = &testsuite_params;
4387 struct crypto_unittest_params *ut_params = &unittest_params;
4391 uint8_t *plaintext, *ciphertext;
4392 unsigned ciphertext_pad_len;
4393 unsigned ciphertext_len;
4395 /* Create SNOW 3G session */
4396 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4397 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4398 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4399 tdata->key.data, tdata->key.len,
4400 tdata->cipher_iv.len);
4404 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4405 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4407 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4408 "Failed to allocate input buffer");
4409 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4410 "Failed to allocate output buffer");
4412 /* Clear mbuf payload */
4413 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4414 rte_pktmbuf_tailroom(ut_params->ibuf));
4416 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4417 rte_pktmbuf_tailroom(ut_params->obuf));
4419 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4420 /* Append data which is padded to a multiple of */
4421 /* the algorithms block size */
4422 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4423 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4424 ciphertext_pad_len);
4425 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4426 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4428 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4430 /* Create SNOW 3G operation */
4431 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4432 tdata->cipher_iv.len,
4433 tdata->validCipherLenInBits.len,
4438 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4440 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4441 ut_params->obuf = ut_params->op->sym->m_dst;
4442 if (ut_params->obuf)
4443 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4445 plaintext = ciphertext;
4447 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4450 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4451 tdata->plaintext.data,
4452 tdata->validDataLenInBits.len,
4453 "SNOW 3G Plaintext data not as expected");
4458 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4460 struct crypto_testsuite_params *ts_params = &testsuite_params;
4461 struct crypto_unittest_params *ut_params = &unittest_params;
4465 uint8_t *plaintext, *ciphertext;
4466 unsigned int plaintext_pad_len;
4467 unsigned int plaintext_len;
4469 struct rte_cryptodev_sym_capability_idx cap_idx;
4471 /* Check if device supports ZUC EEA3 */
4472 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4473 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4475 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4479 /* Check if device supports ZUC EIA3 */
4480 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4481 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4483 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4487 /* Create ZUC session */
4488 retval = create_zuc_cipher_auth_encrypt_generate_session(
4489 ts_params->valid_devs[0],
4493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4495 /* clear mbuf payload */
4496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4497 rte_pktmbuf_tailroom(ut_params->ibuf));
4499 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4500 /* Append data which is padded to a multiple of */
4501 /* the algorithms block size */
4502 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4503 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4505 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4507 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4509 /* Create ZUC operation */
4510 retval = create_zuc_cipher_hash_generate_operation(tdata);
4514 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4516 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4517 ut_params->obuf = ut_params->op->sym->m_src;
4518 if (ut_params->obuf)
4519 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4521 ciphertext = plaintext;
4523 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4525 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4527 tdata->ciphertext.data,
4528 tdata->validDataLenInBits.len,
4529 "ZUC Ciphertext data not as expected");
4531 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4532 + plaintext_pad_len;
4535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4539 "ZUC Generated auth tag not as expected");
4544 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4546 struct crypto_testsuite_params *ts_params = &testsuite_params;
4547 struct crypto_unittest_params *ut_params = &unittest_params;
4551 uint8_t *plaintext, *ciphertext;
4552 unsigned plaintext_pad_len;
4553 unsigned plaintext_len;
4555 /* Create SNOW 3G session */
4556 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4557 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4558 RTE_CRYPTO_AUTH_OP_GENERATE,
4559 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4560 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4561 tdata->key.data, tdata->key.len,
4562 tdata->auth_iv.len, tdata->digest.len,
4563 tdata->cipher_iv.len);
4566 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4568 /* clear mbuf payload */
4569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4570 rte_pktmbuf_tailroom(ut_params->ibuf));
4572 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4573 /* Append data which is padded to a multiple of */
4574 /* the algorithms block size */
4575 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4576 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4578 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4580 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4582 /* Create SNOW 3G operation */
4583 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4584 tdata->digest.len, tdata->auth_iv.data,
4586 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4587 tdata->cipher_iv.data, tdata->cipher_iv.len,
4588 tdata->validCipherLenInBits.len,
4590 tdata->validAuthLenInBits.len,
4596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4599 ut_params->obuf = ut_params->op->sym->m_src;
4600 if (ut_params->obuf)
4601 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4603 ciphertext = plaintext;
4605 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4607 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4609 tdata->ciphertext.data,
4610 tdata->validDataLenInBits.len,
4611 "SNOW 3G Ciphertext data not as expected");
4613 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4614 + plaintext_pad_len;
4617 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4620 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4621 "SNOW 3G Generated auth tag not as expected");
4626 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4627 uint8_t op_mode, uint8_t verify)
4629 struct crypto_testsuite_params *ts_params = &testsuite_params;
4630 struct crypto_unittest_params *ut_params = &unittest_params;
4634 uint8_t *plaintext = NULL, *ciphertext = NULL;
4635 unsigned int plaintext_pad_len;
4636 unsigned int plaintext_len;
4637 unsigned int ciphertext_pad_len;
4638 unsigned int ciphertext_len;
4640 struct rte_cryptodev_info dev_info;
4642 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4644 uint64_t feat_flags = dev_info.feature_flags;
4646 if (op_mode == OUT_OF_PLACE) {
4647 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4648 printf("Device doesn't support digest encrypted.\n");
4653 /* Create SNOW 3G session */
4654 retval = create_wireless_algo_auth_cipher_session(
4655 ts_params->valid_devs[0],
4656 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4657 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4658 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4659 : RTE_CRYPTO_AUTH_OP_GENERATE),
4660 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4661 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4662 tdata->key.data, tdata->key.len,
4663 tdata->auth_iv.len, tdata->digest.len,
4664 tdata->cipher_iv.len);
4669 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4670 if (op_mode == OUT_OF_PLACE)
4671 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4673 /* clear mbuf payload */
4674 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4675 rte_pktmbuf_tailroom(ut_params->ibuf));
4676 if (op_mode == OUT_OF_PLACE)
4677 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4678 rte_pktmbuf_tailroom(ut_params->obuf));
4680 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4681 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4682 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4683 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4686 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4687 ciphertext_pad_len);
4688 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4689 if (op_mode == OUT_OF_PLACE)
4690 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4691 debug_hexdump(stdout, "ciphertext:", ciphertext,
4694 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4696 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4697 if (op_mode == OUT_OF_PLACE)
4698 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4699 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4702 /* Create SNOW 3G operation */
4703 retval = create_wireless_algo_auth_cipher_operation(
4704 tdata->digest.data, tdata->digest.len,
4705 tdata->cipher_iv.data, tdata->cipher_iv.len,
4706 tdata->auth_iv.data, tdata->auth_iv.len,
4707 (tdata->digest.offset_bytes == 0 ?
4708 (verify ? ciphertext_pad_len : plaintext_pad_len)
4709 : tdata->digest.offset_bytes),
4710 tdata->validCipherLenInBits.len,
4711 tdata->cipher.offset_bits,
4712 tdata->validAuthLenInBits.len,
4713 tdata->auth.offset_bits,
4714 op_mode, 0, verify);
4719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4724 ut_params->obuf = (op_mode == IN_PLACE ?
4725 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4728 if (ut_params->obuf)
4729 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4732 plaintext = ciphertext +
4733 (tdata->cipher.offset_bits >> 3);
4735 debug_hexdump(stdout, "plaintext:", plaintext,
4736 (tdata->plaintext.len >> 3) - tdata->digest.len);
4737 debug_hexdump(stdout, "plaintext expected:",
4738 tdata->plaintext.data,
4739 (tdata->plaintext.len >> 3) - tdata->digest.len);
4741 if (ut_params->obuf)
4742 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4745 ciphertext = plaintext;
4747 debug_hexdump(stdout, "ciphertext:", ciphertext,
4749 debug_hexdump(stdout, "ciphertext expected:",
4750 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4752 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4753 + (tdata->digest.offset_bytes == 0 ?
4754 plaintext_pad_len : tdata->digest.offset_bytes);
4756 debug_hexdump(stdout, "digest:", ut_params->digest,
4758 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4766 tdata->plaintext.data,
4767 tdata->plaintext.len >> 3,
4768 "SNOW 3G Plaintext data not as expected");
4770 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4772 tdata->ciphertext.data,
4773 tdata->validDataLenInBits.len,
4774 "SNOW 3G Ciphertext data not as expected");
4776 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4779 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4780 "SNOW 3G Generated auth tag not as expected");
4786 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4787 uint8_t op_mode, uint8_t verify)
4789 struct crypto_testsuite_params *ts_params = &testsuite_params;
4790 struct crypto_unittest_params *ut_params = &unittest_params;
4794 const uint8_t *plaintext = NULL;
4795 const uint8_t *ciphertext = NULL;
4796 const uint8_t *digest = NULL;
4797 unsigned int plaintext_pad_len;
4798 unsigned int plaintext_len;
4799 unsigned int ciphertext_pad_len;
4800 unsigned int ciphertext_len;
4801 uint8_t buffer[10000];
4802 uint8_t digest_buffer[10000];
4804 struct rte_cryptodev_info dev_info;
4806 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4808 uint64_t feat_flags = dev_info.feature_flags;
4810 if (op_mode == IN_PLACE) {
4811 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4812 printf("Device doesn't support in-place scatter-gather "
4813 "in both input and output mbufs.\n");
4817 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4818 printf("Device doesn't support out-of-place scatter-gather "
4819 "in both input and output mbufs.\n");
4822 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4823 printf("Device doesn't support digest encrypted.\n");
4828 /* Create SNOW 3G session */
4829 retval = create_wireless_algo_auth_cipher_session(
4830 ts_params->valid_devs[0],
4831 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4832 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4833 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4834 : RTE_CRYPTO_AUTH_OP_GENERATE),
4835 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4836 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4837 tdata->key.data, tdata->key.len,
4838 tdata->auth_iv.len, tdata->digest.len,
4839 tdata->cipher_iv.len);
4844 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4845 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4846 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4847 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4849 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4850 plaintext_pad_len, 15, 0);
4851 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4852 "Failed to allocate input buffer in mempool");
4854 if (op_mode == OUT_OF_PLACE) {
4855 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4856 plaintext_pad_len, 15, 0);
4857 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4858 "Failed to allocate output buffer in mempool");
4862 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4863 tdata->ciphertext.data);
4864 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4865 ciphertext_len, buffer);
4866 debug_hexdump(stdout, "ciphertext:", ciphertext,
4869 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4870 tdata->plaintext.data);
4871 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4872 plaintext_len, buffer);
4873 debug_hexdump(stdout, "plaintext:", plaintext,
4876 memset(buffer, 0, sizeof(buffer));
4878 /* Create SNOW 3G operation */
4879 retval = create_wireless_algo_auth_cipher_operation(
4880 tdata->digest.data, tdata->digest.len,
4881 tdata->cipher_iv.data, tdata->cipher_iv.len,
4882 tdata->auth_iv.data, tdata->auth_iv.len,
4883 (tdata->digest.offset_bytes == 0 ?
4884 (verify ? ciphertext_pad_len : plaintext_pad_len)
4885 : tdata->digest.offset_bytes),
4886 tdata->validCipherLenInBits.len,
4887 tdata->cipher.offset_bits,
4888 tdata->validAuthLenInBits.len,
4889 tdata->auth.offset_bits,
4890 op_mode, 1, verify);
4895 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4898 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4900 ut_params->obuf = (op_mode == IN_PLACE ?
4901 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4904 if (ut_params->obuf)
4905 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4906 plaintext_len, buffer);
4908 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4909 plaintext_len, buffer);
4911 debug_hexdump(stdout, "plaintext:", plaintext,
4912 (tdata->plaintext.len >> 3) - tdata->digest.len);
4913 debug_hexdump(stdout, "plaintext expected:",
4914 tdata->plaintext.data,
4915 (tdata->plaintext.len >> 3) - tdata->digest.len);
4917 if (ut_params->obuf)
4918 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4919 ciphertext_len, buffer);
4921 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4922 ciphertext_len, buffer);
4924 debug_hexdump(stdout, "ciphertext:", ciphertext,
4926 debug_hexdump(stdout, "ciphertext expected:",
4927 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4929 if (ut_params->obuf)
4930 digest = rte_pktmbuf_read(ut_params->obuf,
4931 (tdata->digest.offset_bytes == 0 ?
4932 plaintext_pad_len : tdata->digest.offset_bytes),
4933 tdata->digest.len, digest_buffer);
4935 digest = rte_pktmbuf_read(ut_params->ibuf,
4936 (tdata->digest.offset_bytes == 0 ?
4937 plaintext_pad_len : tdata->digest.offset_bytes),
4938 tdata->digest.len, digest_buffer);
4940 debug_hexdump(stdout, "digest:", digest,
4942 debug_hexdump(stdout, "digest expected:",
4943 tdata->digest.data, tdata->digest.len);
4948 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4950 tdata->plaintext.data,
4951 tdata->plaintext.len >> 3,
4952 "SNOW 3G Plaintext data not as expected");
4954 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4956 tdata->ciphertext.data,
4957 tdata->validDataLenInBits.len,
4958 "SNOW 3G Ciphertext data not as expected");
4960 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4963 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4964 "SNOW 3G Generated auth tag not as expected");
4970 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4971 uint8_t op_mode, uint8_t verify)
4973 struct crypto_testsuite_params *ts_params = &testsuite_params;
4974 struct crypto_unittest_params *ut_params = &unittest_params;
4978 uint8_t *plaintext = NULL, *ciphertext = NULL;
4979 unsigned int plaintext_pad_len;
4980 unsigned int plaintext_len;
4981 unsigned int ciphertext_pad_len;
4982 unsigned int ciphertext_len;
4984 struct rte_cryptodev_info dev_info;
4986 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4988 uint64_t feat_flags = dev_info.feature_flags;
4990 if (op_mode == OUT_OF_PLACE) {
4991 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4992 printf("Device doesn't support digest encrypted.\n");
4997 /* Create KASUMI session */
4998 retval = create_wireless_algo_auth_cipher_session(
4999 ts_params->valid_devs[0],
5000 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5001 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5002 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5003 : RTE_CRYPTO_AUTH_OP_GENERATE),
5004 RTE_CRYPTO_AUTH_KASUMI_F9,
5005 RTE_CRYPTO_CIPHER_KASUMI_F8,
5006 tdata->key.data, tdata->key.len,
5007 0, tdata->digest.len,
5008 tdata->cipher_iv.len);
5013 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5014 if (op_mode == OUT_OF_PLACE)
5015 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5017 /* clear mbuf payload */
5018 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5019 rte_pktmbuf_tailroom(ut_params->ibuf));
5020 if (op_mode == OUT_OF_PLACE)
5021 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5022 rte_pktmbuf_tailroom(ut_params->obuf));
5024 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5025 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5026 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5030 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5031 ciphertext_pad_len);
5032 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5033 if (op_mode == OUT_OF_PLACE)
5034 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5035 debug_hexdump(stdout, "ciphertext:", ciphertext,
5038 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5040 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5041 if (op_mode == OUT_OF_PLACE)
5042 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5043 debug_hexdump(stdout, "plaintext:", plaintext,
5047 /* Create KASUMI operation */
5048 retval = create_wireless_algo_auth_cipher_operation(
5049 tdata->digest.data, tdata->digest.len,
5050 tdata->cipher_iv.data, tdata->cipher_iv.len,
5052 (tdata->digest.offset_bytes == 0 ?
5053 (verify ? ciphertext_pad_len : plaintext_pad_len)
5054 : tdata->digest.offset_bytes),
5055 tdata->validCipherLenInBits.len,
5056 tdata->validCipherOffsetInBits.len,
5057 tdata->validAuthLenInBits.len,
5059 op_mode, 0, verify);
5064 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5067 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5069 ut_params->obuf = (op_mode == IN_PLACE ?
5070 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5074 if (ut_params->obuf)
5075 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5078 plaintext = ciphertext;
5080 debug_hexdump(stdout, "plaintext:", plaintext,
5081 (tdata->plaintext.len >> 3) - tdata->digest.len);
5082 debug_hexdump(stdout, "plaintext expected:",
5083 tdata->plaintext.data,
5084 (tdata->plaintext.len >> 3) - tdata->digest.len);
5086 if (ut_params->obuf)
5087 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5090 ciphertext = plaintext;
5092 debug_hexdump(stdout, "ciphertext:", ciphertext,
5094 debug_hexdump(stdout, "ciphertext expected:",
5095 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5097 ut_params->digest = rte_pktmbuf_mtod(
5098 ut_params->obuf, uint8_t *) +
5099 (tdata->digest.offset_bytes == 0 ?
5100 plaintext_pad_len : tdata->digest.offset_bytes);
5102 debug_hexdump(stdout, "digest:", ut_params->digest,
5104 debug_hexdump(stdout, "digest expected:",
5105 tdata->digest.data, tdata->digest.len);
5110 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5112 tdata->plaintext.data,
5113 tdata->plaintext.len >> 3,
5114 "KASUMI Plaintext data not as expected");
5116 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5118 tdata->ciphertext.data,
5119 tdata->ciphertext.len >> 3,
5120 "KASUMI Ciphertext data not as expected");
5122 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5125 DIGEST_BYTE_LENGTH_KASUMI_F9,
5126 "KASUMI Generated auth tag not as expected");
5132 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5133 uint8_t op_mode, uint8_t verify)
5135 struct crypto_testsuite_params *ts_params = &testsuite_params;
5136 struct crypto_unittest_params *ut_params = &unittest_params;
5140 const uint8_t *plaintext = NULL;
5141 const uint8_t *ciphertext = NULL;
5142 const uint8_t *digest = NULL;
5143 unsigned int plaintext_pad_len;
5144 unsigned int plaintext_len;
5145 unsigned int ciphertext_pad_len;
5146 unsigned int ciphertext_len;
5147 uint8_t buffer[10000];
5148 uint8_t digest_buffer[10000];
5150 struct rte_cryptodev_info dev_info;
5152 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5154 uint64_t feat_flags = dev_info.feature_flags;
5156 if (op_mode == IN_PLACE) {
5157 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5158 printf("Device doesn't support in-place scatter-gather "
5159 "in both input and output mbufs.\n");
5163 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5164 printf("Device doesn't support out-of-place scatter-gather "
5165 "in both input and output mbufs.\n");
5168 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5169 printf("Device doesn't support digest encrypted.\n");
5174 /* Create KASUMI session */
5175 retval = create_wireless_algo_auth_cipher_session(
5176 ts_params->valid_devs[0],
5177 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5178 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5179 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5180 : RTE_CRYPTO_AUTH_OP_GENERATE),
5181 RTE_CRYPTO_AUTH_KASUMI_F9,
5182 RTE_CRYPTO_CIPHER_KASUMI_F8,
5183 tdata->key.data, tdata->key.len,
5184 0, tdata->digest.len,
5185 tdata->cipher_iv.len);
5190 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5191 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5192 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5193 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5195 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5196 plaintext_pad_len, 15, 0);
5197 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5198 "Failed to allocate input buffer in mempool");
5200 if (op_mode == OUT_OF_PLACE) {
5201 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5202 plaintext_pad_len, 15, 0);
5203 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5204 "Failed to allocate output buffer in mempool");
5208 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5209 tdata->ciphertext.data);
5210 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5211 ciphertext_len, buffer);
5212 debug_hexdump(stdout, "ciphertext:", ciphertext,
5215 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5216 tdata->plaintext.data);
5217 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5218 plaintext_len, buffer);
5219 debug_hexdump(stdout, "plaintext:", plaintext,
5222 memset(buffer, 0, sizeof(buffer));
5224 /* Create KASUMI operation */
5225 retval = create_wireless_algo_auth_cipher_operation(
5226 tdata->digest.data, tdata->digest.len,
5227 tdata->cipher_iv.data, tdata->cipher_iv.len,
5229 (tdata->digest.offset_bytes == 0 ?
5230 (verify ? ciphertext_pad_len : plaintext_pad_len)
5231 : tdata->digest.offset_bytes),
5232 tdata->validCipherLenInBits.len,
5233 tdata->validCipherOffsetInBits.len,
5234 tdata->validAuthLenInBits.len,
5236 op_mode, 1, verify);
5241 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5246 ut_params->obuf = (op_mode == IN_PLACE ?
5247 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5250 if (ut_params->obuf)
5251 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5252 plaintext_len, buffer);
5254 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5255 plaintext_len, buffer);
5257 debug_hexdump(stdout, "plaintext:", plaintext,
5258 (tdata->plaintext.len >> 3) - tdata->digest.len);
5259 debug_hexdump(stdout, "plaintext expected:",
5260 tdata->plaintext.data,
5261 (tdata->plaintext.len >> 3) - tdata->digest.len);
5263 if (ut_params->obuf)
5264 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5265 ciphertext_len, buffer);
5267 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5268 ciphertext_len, buffer);
5270 debug_hexdump(stdout, "ciphertext:", ciphertext,
5272 debug_hexdump(stdout, "ciphertext expected:",
5273 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5275 if (ut_params->obuf)
5276 digest = rte_pktmbuf_read(ut_params->obuf,
5277 (tdata->digest.offset_bytes == 0 ?
5278 plaintext_pad_len : tdata->digest.offset_bytes),
5279 tdata->digest.len, digest_buffer);
5281 digest = rte_pktmbuf_read(ut_params->ibuf,
5282 (tdata->digest.offset_bytes == 0 ?
5283 plaintext_pad_len : tdata->digest.offset_bytes),
5284 tdata->digest.len, digest_buffer);
5286 debug_hexdump(stdout, "digest:", digest,
5288 debug_hexdump(stdout, "digest expected:",
5289 tdata->digest.data, tdata->digest.len);
5294 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5296 tdata->plaintext.data,
5297 tdata->plaintext.len >> 3,
5298 "KASUMI Plaintext data not as expected");
5300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5302 tdata->ciphertext.data,
5303 tdata->validDataLenInBits.len,
5304 "KASUMI Ciphertext data not as expected");
5306 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5309 DIGEST_BYTE_LENGTH_KASUMI_F9,
5310 "KASUMI Generated auth tag not as expected");
5316 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5318 struct crypto_testsuite_params *ts_params = &testsuite_params;
5319 struct crypto_unittest_params *ut_params = &unittest_params;
5323 uint8_t *plaintext, *ciphertext;
5324 unsigned plaintext_pad_len;
5325 unsigned plaintext_len;
5327 /* Create KASUMI session */
5328 retval = create_wireless_algo_cipher_auth_session(
5329 ts_params->valid_devs[0],
5330 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5331 RTE_CRYPTO_AUTH_OP_GENERATE,
5332 RTE_CRYPTO_AUTH_KASUMI_F9,
5333 RTE_CRYPTO_CIPHER_KASUMI_F8,
5334 tdata->key.data, tdata->key.len,
5335 0, tdata->digest.len,
5336 tdata->cipher_iv.len);
5340 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5342 /* clear mbuf payload */
5343 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5344 rte_pktmbuf_tailroom(ut_params->ibuf));
5346 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5347 /* Append data which is padded to a multiple of */
5348 /* the algorithms block size */
5349 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5350 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5352 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5354 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5356 /* Create KASUMI operation */
5357 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5358 tdata->digest.len, NULL, 0,
5359 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5360 tdata->cipher_iv.data, tdata->cipher_iv.len,
5361 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5362 tdata->validCipherOffsetInBits.len,
5363 tdata->validAuthLenInBits.len,
5369 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5371 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5373 if (ut_params->op->sym->m_dst)
5374 ut_params->obuf = ut_params->op->sym->m_dst;
5376 ut_params->obuf = ut_params->op->sym->m_src;
5378 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5379 tdata->validCipherOffsetInBits.len >> 3);
5381 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5382 + plaintext_pad_len;
5384 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5385 (tdata->validCipherOffsetInBits.len >> 3);
5387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5389 reference_ciphertext,
5390 tdata->validCipherLenInBits.len,
5391 "KASUMI Ciphertext data not as expected");
5394 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5397 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5398 "KASUMI Generated auth tag not as expected");
5403 test_zuc_encryption(const struct wireless_test_data *tdata)
5405 struct crypto_testsuite_params *ts_params = &testsuite_params;
5406 struct crypto_unittest_params *ut_params = &unittest_params;
5409 uint8_t *plaintext, *ciphertext;
5410 unsigned plaintext_pad_len;
5411 unsigned plaintext_len;
5413 struct rte_cryptodev_sym_capability_idx cap_idx;
5415 /* Check if device supports ZUC EEA3 */
5416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5417 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5419 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5423 /* Create ZUC session */
5424 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5425 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5426 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5427 tdata->key.data, tdata->key.len,
5428 tdata->cipher_iv.len);
5432 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5434 /* Clear mbuf payload */
5435 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5436 rte_pktmbuf_tailroom(ut_params->ibuf));
5438 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5439 /* Append data which is padded to a multiple */
5440 /* of the algorithms block size */
5441 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5442 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5444 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5446 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5448 /* Create ZUC operation */
5449 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5450 tdata->cipher_iv.len,
5451 tdata->plaintext.len,
5456 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5458 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5460 ut_params->obuf = ut_params->op->sym->m_dst;
5461 if (ut_params->obuf)
5462 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5464 ciphertext = plaintext;
5466 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5469 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5471 tdata->ciphertext.data,
5472 tdata->validCipherLenInBits.len,
5473 "ZUC Ciphertext data not as expected");
5478 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5480 struct crypto_testsuite_params *ts_params = &testsuite_params;
5481 struct crypto_unittest_params *ut_params = &unittest_params;
5485 unsigned int plaintext_pad_len;
5486 unsigned int plaintext_len;
5487 const uint8_t *ciphertext;
5488 uint8_t ciphertext_buffer[2048];
5489 struct rte_cryptodev_info dev_info;
5491 struct rte_cryptodev_sym_capability_idx cap_idx;
5493 /* Check if device supports ZUC EEA3 */
5494 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5495 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5497 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5501 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5503 uint64_t feat_flags = dev_info.feature_flags;
5505 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5506 printf("Device doesn't support in-place scatter-gather. "
5511 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5513 /* Append data which is padded to a multiple */
5514 /* of the algorithms block size */
5515 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5517 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5518 plaintext_pad_len, 10, 0);
5520 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5521 tdata->plaintext.data);
5523 /* Create ZUC session */
5524 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5525 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5526 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5527 tdata->key.data, tdata->key.len,
5528 tdata->cipher_iv.len);
5532 /* Clear mbuf payload */
5534 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5536 /* Create ZUC operation */
5537 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5538 tdata->cipher_iv.len, tdata->plaintext.len,
5543 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5545 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5547 ut_params->obuf = ut_params->op->sym->m_dst;
5548 if (ut_params->obuf)
5549 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5550 0, plaintext_len, ciphertext_buffer);
5552 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5553 0, plaintext_len, ciphertext_buffer);
5556 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5559 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5561 tdata->ciphertext.data,
5562 tdata->validCipherLenInBits.len,
5563 "ZUC Ciphertext data not as expected");
5569 test_zuc_authentication(const struct wireless_test_data *tdata)
5571 struct crypto_testsuite_params *ts_params = &testsuite_params;
5572 struct crypto_unittest_params *ut_params = &unittest_params;
5575 unsigned plaintext_pad_len;
5576 unsigned plaintext_len;
5579 struct rte_cryptodev_sym_capability_idx cap_idx;
5581 /* Check if device supports ZUC EIA3 */
5582 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5583 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5585 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5589 /* Create ZUC session */
5590 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5591 tdata->key.data, tdata->key.len,
5592 tdata->auth_iv.len, tdata->digest.len,
5593 RTE_CRYPTO_AUTH_OP_GENERATE,
5594 RTE_CRYPTO_AUTH_ZUC_EIA3);
5598 /* alloc mbuf and set payload */
5599 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5601 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5602 rte_pktmbuf_tailroom(ut_params->ibuf));
5604 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5605 /* Append data which is padded to a multiple of */
5606 /* the algorithms block size */
5607 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5608 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5610 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5612 /* Create ZUC operation */
5613 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5614 tdata->auth_iv.data, tdata->auth_iv.len,
5615 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5616 tdata->validAuthLenInBits.len,
5621 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5623 ut_params->obuf = ut_params->op->sym->m_src;
5624 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5625 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5626 + plaintext_pad_len;
5629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5632 DIGEST_BYTE_LENGTH_KASUMI_F9,
5633 "ZUC Generated auth tag not as expected");
5639 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5640 uint8_t op_mode, uint8_t verify)
5642 struct crypto_testsuite_params *ts_params = &testsuite_params;
5643 struct crypto_unittest_params *ut_params = &unittest_params;
5647 uint8_t *plaintext = NULL, *ciphertext = NULL;
5648 unsigned int plaintext_pad_len;
5649 unsigned int plaintext_len;
5650 unsigned int ciphertext_pad_len;
5651 unsigned int ciphertext_len;
5653 struct rte_cryptodev_info dev_info;
5654 struct rte_cryptodev_sym_capability_idx cap_idx;
5656 /* Check if device supports ZUC EIA3 */
5657 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5658 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5660 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5664 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5666 uint64_t feat_flags = dev_info.feature_flags;
5668 if (op_mode == OUT_OF_PLACE) {
5669 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5670 printf("Device doesn't support digest encrypted.\n");
5675 /* Create ZUC session */
5676 retval = create_wireless_algo_auth_cipher_session(
5677 ts_params->valid_devs[0],
5678 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5679 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5680 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5681 : RTE_CRYPTO_AUTH_OP_GENERATE),
5682 RTE_CRYPTO_AUTH_ZUC_EIA3,
5683 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5684 tdata->key.data, tdata->key.len,
5685 tdata->auth_iv.len, tdata->digest.len,
5686 tdata->cipher_iv.len);
5691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5692 if (op_mode == OUT_OF_PLACE)
5693 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5695 /* clear mbuf payload */
5696 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5697 rte_pktmbuf_tailroom(ut_params->ibuf));
5698 if (op_mode == OUT_OF_PLACE)
5699 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5700 rte_pktmbuf_tailroom(ut_params->obuf));
5702 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5703 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5704 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5705 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5708 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5709 ciphertext_pad_len);
5710 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5711 if (op_mode == OUT_OF_PLACE)
5712 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5713 debug_hexdump(stdout, "ciphertext:", ciphertext,
5716 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5718 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5719 if (op_mode == OUT_OF_PLACE)
5720 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5721 debug_hexdump(stdout, "plaintext:", plaintext,
5725 /* Create ZUC operation */
5726 retval = create_wireless_algo_auth_cipher_operation(
5727 tdata->digest.data, tdata->digest.len,
5728 tdata->cipher_iv.data, tdata->cipher_iv.len,
5729 tdata->auth_iv.data, tdata->auth_iv.len,
5730 (tdata->digest.offset_bytes == 0 ?
5731 (verify ? ciphertext_pad_len : plaintext_pad_len)
5732 : tdata->digest.offset_bytes),
5733 tdata->validCipherLenInBits.len,
5734 tdata->validCipherOffsetInBits.len,
5735 tdata->validAuthLenInBits.len,
5737 op_mode, 0, verify);
5742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5745 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5747 ut_params->obuf = (op_mode == IN_PLACE ?
5748 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5752 if (ut_params->obuf)
5753 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5756 plaintext = ciphertext;
5758 debug_hexdump(stdout, "plaintext:", plaintext,
5759 (tdata->plaintext.len >> 3) - tdata->digest.len);
5760 debug_hexdump(stdout, "plaintext expected:",
5761 tdata->plaintext.data,
5762 (tdata->plaintext.len >> 3) - tdata->digest.len);
5764 if (ut_params->obuf)
5765 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5768 ciphertext = plaintext;
5770 debug_hexdump(stdout, "ciphertext:", ciphertext,
5772 debug_hexdump(stdout, "ciphertext expected:",
5773 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5775 ut_params->digest = rte_pktmbuf_mtod(
5776 ut_params->obuf, uint8_t *) +
5777 (tdata->digest.offset_bytes == 0 ?
5778 plaintext_pad_len : tdata->digest.offset_bytes);
5780 debug_hexdump(stdout, "digest:", ut_params->digest,
5782 debug_hexdump(stdout, "digest expected:",
5783 tdata->digest.data, tdata->digest.len);
5788 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5790 tdata->plaintext.data,
5791 tdata->plaintext.len >> 3,
5792 "ZUC Plaintext data not as expected");
5794 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5796 tdata->ciphertext.data,
5797 tdata->ciphertext.len >> 3,
5798 "ZUC Ciphertext data not as expected");
5800 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5803 DIGEST_BYTE_LENGTH_KASUMI_F9,
5804 "ZUC Generated auth tag not as expected");
5810 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5811 uint8_t op_mode, uint8_t verify)
5813 struct crypto_testsuite_params *ts_params = &testsuite_params;
5814 struct crypto_unittest_params *ut_params = &unittest_params;
5818 const uint8_t *plaintext = NULL;
5819 const uint8_t *ciphertext = NULL;
5820 const uint8_t *digest = NULL;
5821 unsigned int plaintext_pad_len;
5822 unsigned int plaintext_len;
5823 unsigned int ciphertext_pad_len;
5824 unsigned int ciphertext_len;
5825 uint8_t buffer[10000];
5826 uint8_t digest_buffer[10000];
5828 struct rte_cryptodev_info dev_info;
5829 struct rte_cryptodev_sym_capability_idx cap_idx;
5831 /* Check if device supports ZUC EIA3 */
5832 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5833 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5839 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5841 uint64_t feat_flags = dev_info.feature_flags;
5843 if (op_mode == IN_PLACE) {
5844 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5845 printf("Device doesn't support in-place scatter-gather "
5846 "in both input and output mbufs.\n");
5850 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5851 printf("Device doesn't support out-of-place scatter-gather "
5852 "in both input and output mbufs.\n");
5855 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5856 printf("Device doesn't support digest encrypted.\n");
5861 /* Create ZUC session */
5862 retval = create_wireless_algo_auth_cipher_session(
5863 ts_params->valid_devs[0],
5864 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5865 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5866 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5867 : RTE_CRYPTO_AUTH_OP_GENERATE),
5868 RTE_CRYPTO_AUTH_ZUC_EIA3,
5869 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5870 tdata->key.data, tdata->key.len,
5871 tdata->auth_iv.len, tdata->digest.len,
5872 tdata->cipher_iv.len);
5877 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5878 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5879 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5880 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5882 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5883 plaintext_pad_len, 15, 0);
5884 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5885 "Failed to allocate input buffer in mempool");
5887 if (op_mode == OUT_OF_PLACE) {
5888 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5889 plaintext_pad_len, 15, 0);
5890 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5891 "Failed to allocate output buffer in mempool");
5895 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5896 tdata->ciphertext.data);
5897 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5898 ciphertext_len, buffer);
5899 debug_hexdump(stdout, "ciphertext:", ciphertext,
5902 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5903 tdata->plaintext.data);
5904 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5905 plaintext_len, buffer);
5906 debug_hexdump(stdout, "plaintext:", plaintext,
5909 memset(buffer, 0, sizeof(buffer));
5911 /* Create ZUC operation */
5912 retval = create_wireless_algo_auth_cipher_operation(
5913 tdata->digest.data, tdata->digest.len,
5914 tdata->cipher_iv.data, tdata->cipher_iv.len,
5916 (tdata->digest.offset_bytes == 0 ?
5917 (verify ? ciphertext_pad_len : plaintext_pad_len)
5918 : tdata->digest.offset_bytes),
5919 tdata->validCipherLenInBits.len,
5920 tdata->validCipherOffsetInBits.len,
5921 tdata->validAuthLenInBits.len,
5923 op_mode, 1, verify);
5928 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5931 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5933 ut_params->obuf = (op_mode == IN_PLACE ?
5934 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5937 if (ut_params->obuf)
5938 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5939 plaintext_len, buffer);
5941 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5942 plaintext_len, buffer);
5944 debug_hexdump(stdout, "plaintext:", plaintext,
5945 (tdata->plaintext.len >> 3) - tdata->digest.len);
5946 debug_hexdump(stdout, "plaintext expected:",
5947 tdata->plaintext.data,
5948 (tdata->plaintext.len >> 3) - tdata->digest.len);
5950 if (ut_params->obuf)
5951 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5952 ciphertext_len, buffer);
5954 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5955 ciphertext_len, buffer);
5957 debug_hexdump(stdout, "ciphertext:", ciphertext,
5959 debug_hexdump(stdout, "ciphertext expected:",
5960 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5962 if (ut_params->obuf)
5963 digest = rte_pktmbuf_read(ut_params->obuf,
5964 (tdata->digest.offset_bytes == 0 ?
5965 plaintext_pad_len : tdata->digest.offset_bytes),
5966 tdata->digest.len, digest_buffer);
5968 digest = rte_pktmbuf_read(ut_params->ibuf,
5969 (tdata->digest.offset_bytes == 0 ?
5970 plaintext_pad_len : tdata->digest.offset_bytes),
5971 tdata->digest.len, digest_buffer);
5973 debug_hexdump(stdout, "digest:", digest,
5975 debug_hexdump(stdout, "digest expected:",
5976 tdata->digest.data, tdata->digest.len);
5981 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5983 tdata->plaintext.data,
5984 tdata->plaintext.len >> 3,
5985 "ZUC Plaintext data not as expected");
5987 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5989 tdata->ciphertext.data,
5990 tdata->validDataLenInBits.len,
5991 "ZUC Ciphertext data not as expected");
5993 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5996 DIGEST_BYTE_LENGTH_KASUMI_F9,
5997 "ZUC Generated auth tag not as expected");
6003 test_kasumi_encryption_test_case_1(void)
6005 return test_kasumi_encryption(&kasumi_test_case_1);
6009 test_kasumi_encryption_test_case_1_sgl(void)
6011 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6015 test_kasumi_encryption_test_case_1_oop(void)
6017 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6021 test_kasumi_encryption_test_case_1_oop_sgl(void)
6023 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6027 test_kasumi_encryption_test_case_2(void)
6029 return test_kasumi_encryption(&kasumi_test_case_2);
6033 test_kasumi_encryption_test_case_3(void)
6035 return test_kasumi_encryption(&kasumi_test_case_3);
6039 test_kasumi_encryption_test_case_4(void)
6041 return test_kasumi_encryption(&kasumi_test_case_4);
6045 test_kasumi_encryption_test_case_5(void)
6047 return test_kasumi_encryption(&kasumi_test_case_5);
6051 test_kasumi_decryption_test_case_1(void)
6053 return test_kasumi_decryption(&kasumi_test_case_1);
6057 test_kasumi_decryption_test_case_1_oop(void)
6059 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6063 test_kasumi_decryption_test_case_2(void)
6065 return test_kasumi_decryption(&kasumi_test_case_2);
6069 test_kasumi_decryption_test_case_3(void)
6071 return test_kasumi_decryption(&kasumi_test_case_3);
6075 test_kasumi_decryption_test_case_4(void)
6077 return test_kasumi_decryption(&kasumi_test_case_4);
6081 test_kasumi_decryption_test_case_5(void)
6083 return test_kasumi_decryption(&kasumi_test_case_5);
6086 test_snow3g_encryption_test_case_1(void)
6088 return test_snow3g_encryption(&snow3g_test_case_1);
6092 test_snow3g_encryption_test_case_1_oop(void)
6094 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6098 test_snow3g_encryption_test_case_1_oop_sgl(void)
6100 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6105 test_snow3g_encryption_test_case_1_offset_oop(void)
6107 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6111 test_snow3g_encryption_test_case_2(void)
6113 return test_snow3g_encryption(&snow3g_test_case_2);
6117 test_snow3g_encryption_test_case_3(void)
6119 return test_snow3g_encryption(&snow3g_test_case_3);
6123 test_snow3g_encryption_test_case_4(void)
6125 return test_snow3g_encryption(&snow3g_test_case_4);
6129 test_snow3g_encryption_test_case_5(void)
6131 return test_snow3g_encryption(&snow3g_test_case_5);
6135 test_snow3g_decryption_test_case_1(void)
6137 return test_snow3g_decryption(&snow3g_test_case_1);
6141 test_snow3g_decryption_test_case_1_oop(void)
6143 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6147 test_snow3g_decryption_test_case_2(void)
6149 return test_snow3g_decryption(&snow3g_test_case_2);
6153 test_snow3g_decryption_test_case_3(void)
6155 return test_snow3g_decryption(&snow3g_test_case_3);
6159 test_snow3g_decryption_test_case_4(void)
6161 return test_snow3g_decryption(&snow3g_test_case_4);
6165 test_snow3g_decryption_test_case_5(void)
6167 return test_snow3g_decryption(&snow3g_test_case_5);
6171 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6172 * Pattern digest from snow3g_test_data must be allocated as
6173 * 4 last bytes in plaintext.
6176 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6177 struct snow3g_hash_test_data *output)
6179 if ((pattern != NULL) && (output != NULL)) {
6180 output->key.len = pattern->key.len;
6182 memcpy(output->key.data,
6183 pattern->key.data, pattern->key.len);
6185 output->auth_iv.len = pattern->auth_iv.len;
6187 memcpy(output->auth_iv.data,
6188 pattern->auth_iv.data, pattern->auth_iv.len);
6190 output->plaintext.len = pattern->plaintext.len;
6192 memcpy(output->plaintext.data,
6193 pattern->plaintext.data, pattern->plaintext.len >> 3);
6195 output->digest.len = pattern->digest.len;
6197 memcpy(output->digest.data,
6198 &pattern->plaintext.data[pattern->digest.offset_bytes],
6199 pattern->digest.len);
6201 output->validAuthLenInBits.len =
6202 pattern->validAuthLenInBits.len;
6207 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6210 test_snow3g_decryption_with_digest_test_case_1(void)
6212 struct snow3g_hash_test_data snow3g_hash_data;
6215 * Function prepare data for hash veryfication test case.
6216 * Digest is allocated in 4 last bytes in plaintext, pattern.
6218 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6220 return test_snow3g_decryption(&snow3g_test_case_7) &
6221 test_snow3g_authentication_verify(&snow3g_hash_data);
6225 test_snow3g_cipher_auth_test_case_1(void)
6227 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6231 test_snow3g_auth_cipher_test_case_1(void)
6233 return test_snow3g_auth_cipher(
6234 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6238 test_snow3g_auth_cipher_test_case_2(void)
6240 return test_snow3g_auth_cipher(
6241 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6245 test_snow3g_auth_cipher_test_case_2_oop(void)
6247 return test_snow3g_auth_cipher(
6248 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6252 test_snow3g_auth_cipher_part_digest_enc(void)
6254 return test_snow3g_auth_cipher(
6255 &snow3g_auth_cipher_partial_digest_encryption,
6260 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6262 return test_snow3g_auth_cipher(
6263 &snow3g_auth_cipher_partial_digest_encryption,
6268 test_snow3g_auth_cipher_test_case_3_sgl(void)
6270 return test_snow3g_auth_cipher_sgl(
6271 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6275 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6277 return test_snow3g_auth_cipher_sgl(
6278 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6282 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6284 return test_snow3g_auth_cipher_sgl(
6285 &snow3g_auth_cipher_partial_digest_encryption,
6290 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6292 return test_snow3g_auth_cipher_sgl(
6293 &snow3g_auth_cipher_partial_digest_encryption,
6298 test_snow3g_auth_cipher_verify_test_case_1(void)
6300 return test_snow3g_auth_cipher(
6301 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6305 test_snow3g_auth_cipher_verify_test_case_2(void)
6307 return test_snow3g_auth_cipher(
6308 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6312 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6314 return test_snow3g_auth_cipher(
6315 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6319 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6321 return test_snow3g_auth_cipher(
6322 &snow3g_auth_cipher_partial_digest_encryption,
6327 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6329 return test_snow3g_auth_cipher(
6330 &snow3g_auth_cipher_partial_digest_encryption,
6335 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6337 return test_snow3g_auth_cipher_sgl(
6338 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6342 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6344 return test_snow3g_auth_cipher_sgl(
6345 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6349 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6351 return test_snow3g_auth_cipher_sgl(
6352 &snow3g_auth_cipher_partial_digest_encryption,
6357 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6359 return test_snow3g_auth_cipher_sgl(
6360 &snow3g_auth_cipher_partial_digest_encryption,
6365 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6367 return test_snow3g_auth_cipher(
6368 &snow3g_test_case_7, IN_PLACE, 0);
6372 test_kasumi_auth_cipher_test_case_1(void)
6374 return test_kasumi_auth_cipher(
6375 &kasumi_test_case_3, IN_PLACE, 0);
6379 test_kasumi_auth_cipher_test_case_2(void)
6381 return test_kasumi_auth_cipher(
6382 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6386 test_kasumi_auth_cipher_test_case_2_oop(void)
6388 return test_kasumi_auth_cipher(
6389 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6393 test_kasumi_auth_cipher_test_case_2_sgl(void)
6395 return test_kasumi_auth_cipher_sgl(
6396 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6400 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6402 return test_kasumi_auth_cipher_sgl(
6403 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6407 test_kasumi_auth_cipher_verify_test_case_1(void)
6409 return test_kasumi_auth_cipher(
6410 &kasumi_test_case_3, IN_PLACE, 1);
6414 test_kasumi_auth_cipher_verify_test_case_2(void)
6416 return test_kasumi_auth_cipher(
6417 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6421 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6423 return test_kasumi_auth_cipher(
6424 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6428 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6430 return test_kasumi_auth_cipher_sgl(
6431 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6435 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6437 return test_kasumi_auth_cipher_sgl(
6438 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6442 test_kasumi_cipher_auth_test_case_1(void)
6444 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6448 test_zuc_encryption_test_case_1(void)
6450 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6454 test_zuc_encryption_test_case_2(void)
6456 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6460 test_zuc_encryption_test_case_3(void)
6462 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6466 test_zuc_encryption_test_case_4(void)
6468 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6472 test_zuc_encryption_test_case_5(void)
6474 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6478 test_zuc_encryption_test_case_6_sgl(void)
6480 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6484 test_zuc_hash_generate_test_case_1(void)
6486 return test_zuc_authentication(&zuc_test_case_auth_1b);
6490 test_zuc_hash_generate_test_case_2(void)
6492 return test_zuc_authentication(&zuc_test_case_auth_90b);
6496 test_zuc_hash_generate_test_case_3(void)
6498 return test_zuc_authentication(&zuc_test_case_auth_577b);
6502 test_zuc_hash_generate_test_case_4(void)
6504 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6508 test_zuc_hash_generate_test_case_5(void)
6510 return test_zuc_authentication(&zuc_test_auth_5670b);
6514 test_zuc_hash_generate_test_case_6(void)
6516 return test_zuc_authentication(&zuc_test_case_auth_128b);
6520 test_zuc_hash_generate_test_case_7(void)
6522 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6526 test_zuc_hash_generate_test_case_8(void)
6528 return test_zuc_authentication(&zuc_test_case_auth_584b);
6532 test_zuc_cipher_auth_test_case_1(void)
6534 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6538 test_zuc_cipher_auth_test_case_2(void)
6540 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6544 test_zuc_auth_cipher_test_case_1(void)
6546 return test_zuc_auth_cipher(
6547 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6551 test_zuc_auth_cipher_test_case_1_oop(void)
6553 return test_zuc_auth_cipher(
6554 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6558 test_zuc_auth_cipher_test_case_1_sgl(void)
6560 return test_zuc_auth_cipher_sgl(
6561 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6565 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6567 return test_zuc_auth_cipher_sgl(
6568 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6572 test_zuc_auth_cipher_verify_test_case_1(void)
6574 return test_zuc_auth_cipher(
6575 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6579 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6581 return test_zuc_auth_cipher(
6582 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6586 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6588 return test_zuc_auth_cipher_sgl(
6589 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6593 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6595 return test_zuc_auth_cipher_sgl(
6596 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6600 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6602 uint8_t dev_id = testsuite_params.valid_devs[0];
6604 struct rte_cryptodev_sym_capability_idx cap_idx;
6606 /* Check if device supports particular cipher algorithm */
6607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6608 cap_idx.algo.cipher = tdata->cipher_algo;
6609 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6612 /* Check if device supports particular hash algorithm */
6613 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6614 cap_idx.algo.auth = tdata->auth_algo;
6615 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6622 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6623 uint8_t op_mode, uint8_t verify)
6625 struct crypto_testsuite_params *ts_params = &testsuite_params;
6626 struct crypto_unittest_params *ut_params = &unittest_params;
6630 uint8_t *plaintext = NULL, *ciphertext = NULL;
6631 unsigned int plaintext_pad_len;
6632 unsigned int plaintext_len;
6633 unsigned int ciphertext_pad_len;
6634 unsigned int ciphertext_len;
6636 struct rte_cryptodev_info dev_info;
6637 struct rte_crypto_op *op;
6639 /* Check if device supports particular algorithms separately */
6640 if (test_mixed_check_if_unsupported(tdata))
6643 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6645 uint64_t feat_flags = dev_info.feature_flags;
6647 if (op_mode == OUT_OF_PLACE) {
6648 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6649 printf("Device doesn't support digest encrypted.\n");
6654 /* Create the session */
6656 retval = create_wireless_algo_cipher_auth_session(
6657 ts_params->valid_devs[0],
6658 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6659 RTE_CRYPTO_AUTH_OP_VERIFY,
6662 tdata->auth_key.data, tdata->auth_key.len,
6663 tdata->auth_iv.len, tdata->digest_enc.len,
6664 tdata->cipher_iv.len);
6666 retval = create_wireless_algo_auth_cipher_session(
6667 ts_params->valid_devs[0],
6668 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6669 RTE_CRYPTO_AUTH_OP_GENERATE,
6672 tdata->auth_key.data, tdata->auth_key.len,
6673 tdata->auth_iv.len, tdata->digest_enc.len,
6674 tdata->cipher_iv.len);
6678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6679 if (op_mode == OUT_OF_PLACE)
6680 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6682 /* clear mbuf payload */
6683 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6684 rte_pktmbuf_tailroom(ut_params->ibuf));
6685 if (op_mode == OUT_OF_PLACE)
6686 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6687 rte_pktmbuf_tailroom(ut_params->obuf));
6689 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6690 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6691 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6692 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6695 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6696 ciphertext_pad_len);
6697 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6698 if (op_mode == OUT_OF_PLACE)
6699 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6700 debug_hexdump(stdout, "ciphertext:", ciphertext,
6703 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6705 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6706 if (op_mode == OUT_OF_PLACE)
6707 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6708 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6711 /* Create the operation */
6712 retval = create_wireless_algo_auth_cipher_operation(
6713 tdata->digest_enc.data, tdata->digest_enc.len,
6714 tdata->cipher_iv.data, tdata->cipher_iv.len,
6715 tdata->auth_iv.data, tdata->auth_iv.len,
6716 (tdata->digest_enc.offset == 0 ?
6718 : tdata->digest_enc.offset),
6719 tdata->validCipherLen.len_bits,
6720 tdata->cipher.offset_bits,
6721 tdata->validAuthLen.len_bits,
6722 tdata->auth.offset_bits,
6723 op_mode, 0, verify);
6728 op = process_crypto_request(ts_params->valid_devs[0],
6731 /* Check if the op failed because the device doesn't */
6732 /* support this particular combination of algorithms */
6733 if (op == NULL && ut_params->op->status ==
6734 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6735 printf("Device doesn't support this mixed combination. "
6741 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6743 ut_params->obuf = (op_mode == IN_PLACE ?
6744 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6747 if (ut_params->obuf)
6748 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6751 plaintext = ciphertext +
6752 (tdata->cipher.offset_bits >> 3);
6754 debug_hexdump(stdout, "plaintext:", plaintext,
6755 tdata->plaintext.len_bits >> 3);
6756 debug_hexdump(stdout, "plaintext expected:",
6757 tdata->plaintext.data,
6758 tdata->plaintext.len_bits >> 3);
6760 if (ut_params->obuf)
6761 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6764 ciphertext = plaintext;
6766 debug_hexdump(stdout, "ciphertext:", ciphertext,
6768 debug_hexdump(stdout, "ciphertext expected:",
6769 tdata->ciphertext.data,
6770 tdata->ciphertext.len_bits >> 3);
6772 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6773 + (tdata->digest_enc.offset == 0 ?
6774 plaintext_pad_len : tdata->digest_enc.offset);
6776 debug_hexdump(stdout, "digest:", ut_params->digest,
6777 tdata->digest_enc.len);
6778 debug_hexdump(stdout, "digest expected:",
6779 tdata->digest_enc.data,
6780 tdata->digest_enc.len);
6785 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6787 tdata->plaintext.data,
6788 tdata->plaintext.len_bits >> 3,
6789 "Plaintext data not as expected");
6791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6793 tdata->ciphertext.data,
6794 tdata->validDataLen.len_bits,
6795 "Ciphertext data not as expected");
6797 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6799 tdata->digest_enc.data,
6800 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6801 "Generated auth tag not as expected");
6804 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6805 "crypto op processing failed");
6811 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6812 uint8_t op_mode, uint8_t verify)
6814 struct crypto_testsuite_params *ts_params = &testsuite_params;
6815 struct crypto_unittest_params *ut_params = &unittest_params;
6819 const uint8_t *plaintext = NULL;
6820 const uint8_t *ciphertext = NULL;
6821 const uint8_t *digest = NULL;
6822 unsigned int plaintext_pad_len;
6823 unsigned int plaintext_len;
6824 unsigned int ciphertext_pad_len;
6825 unsigned int ciphertext_len;
6826 uint8_t buffer[10000];
6827 uint8_t digest_buffer[10000];
6829 struct rte_cryptodev_info dev_info;
6830 struct rte_crypto_op *op;
6832 /* Check if device supports particular algorithms */
6833 if (test_mixed_check_if_unsupported(tdata))
6836 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6838 uint64_t feat_flags = dev_info.feature_flags;
6840 if (op_mode == IN_PLACE) {
6841 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6842 printf("Device doesn't support in-place scatter-gather "
6843 "in both input and output mbufs.\n");
6847 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6848 printf("Device doesn't support out-of-place scatter-gather "
6849 "in both input and output mbufs.\n");
6852 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6853 printf("Device doesn't support digest encrypted.\n");
6858 /* Create the session */
6860 retval = create_wireless_algo_cipher_auth_session(
6861 ts_params->valid_devs[0],
6862 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6863 RTE_CRYPTO_AUTH_OP_VERIFY,
6866 tdata->auth_key.data, tdata->auth_key.len,
6867 tdata->auth_iv.len, tdata->digest_enc.len,
6868 tdata->cipher_iv.len);
6870 retval = create_wireless_algo_auth_cipher_session(
6871 ts_params->valid_devs[0],
6872 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6873 RTE_CRYPTO_AUTH_OP_GENERATE,
6876 tdata->auth_key.data, tdata->auth_key.len,
6877 tdata->auth_iv.len, tdata->digest_enc.len,
6878 tdata->cipher_iv.len);
6882 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6883 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6884 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6885 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6887 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6888 ciphertext_pad_len, 15, 0);
6889 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6890 "Failed to allocate input buffer in mempool");
6892 if (op_mode == OUT_OF_PLACE) {
6893 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6894 plaintext_pad_len, 15, 0);
6895 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6896 "Failed to allocate output buffer in mempool");
6900 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6901 tdata->ciphertext.data);
6902 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6903 ciphertext_len, buffer);
6904 debug_hexdump(stdout, "ciphertext:", ciphertext,
6907 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6908 tdata->plaintext.data);
6909 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6910 plaintext_len, buffer);
6911 debug_hexdump(stdout, "plaintext:", plaintext,
6914 memset(buffer, 0, sizeof(buffer));
6916 /* Create the operation */
6917 retval = create_wireless_algo_auth_cipher_operation(
6918 tdata->digest_enc.data, tdata->digest_enc.len,
6919 tdata->cipher_iv.data, tdata->cipher_iv.len,
6920 tdata->auth_iv.data, tdata->auth_iv.len,
6921 (tdata->digest_enc.offset == 0 ?
6923 : tdata->digest_enc.offset),
6924 tdata->validCipherLen.len_bits,
6925 tdata->cipher.offset_bits,
6926 tdata->validAuthLen.len_bits,
6927 tdata->auth.offset_bits,
6928 op_mode, 1, verify);
6933 op = process_crypto_request(ts_params->valid_devs[0],
6936 /* Check if the op failed because the device doesn't */
6937 /* support this particular combination of algorithms */
6938 if (op == NULL && ut_params->op->status ==
6939 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6940 printf("Device doesn't support this mixed combination. "
6947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6949 ut_params->obuf = (op_mode == IN_PLACE ?
6950 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6953 if (ut_params->obuf)
6954 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6955 plaintext_len, buffer);
6957 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6958 plaintext_len, buffer);
6960 debug_hexdump(stdout, "plaintext:", plaintext,
6961 (tdata->plaintext.len_bits >> 3) -
6962 tdata->digest_enc.len);
6963 debug_hexdump(stdout, "plaintext expected:",
6964 tdata->plaintext.data,
6965 (tdata->plaintext.len_bits >> 3) -
6966 tdata->digest_enc.len);
6968 if (ut_params->obuf)
6969 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6970 ciphertext_len, buffer);
6972 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6973 ciphertext_len, buffer);
6975 debug_hexdump(stdout, "ciphertext:", ciphertext,
6977 debug_hexdump(stdout, "ciphertext expected:",
6978 tdata->ciphertext.data,
6979 tdata->ciphertext.len_bits >> 3);
6981 if (ut_params->obuf)
6982 digest = rte_pktmbuf_read(ut_params->obuf,
6983 (tdata->digest_enc.offset == 0 ?
6985 tdata->digest_enc.offset),
6986 tdata->digest_enc.len, digest_buffer);
6988 digest = rte_pktmbuf_read(ut_params->ibuf,
6989 (tdata->digest_enc.offset == 0 ?
6991 tdata->digest_enc.offset),
6992 tdata->digest_enc.len, digest_buffer);
6994 debug_hexdump(stdout, "digest:", digest,
6995 tdata->digest_enc.len);
6996 debug_hexdump(stdout, "digest expected:",
6997 tdata->digest_enc.data, tdata->digest_enc.len);
7002 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7004 tdata->plaintext.data,
7005 tdata->plaintext.len_bits >> 3,
7006 "Plaintext data not as expected");
7008 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7010 tdata->ciphertext.data,
7011 tdata->validDataLen.len_bits,
7012 "Ciphertext data not as expected");
7013 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7015 tdata->digest_enc.data,
7016 tdata->digest_enc.len,
7017 "Generated auth tag not as expected");
7020 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7021 "crypto op processing failed");
7026 /** AUTH AES CMAC + CIPHER AES CTR */
7029 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7031 return test_mixed_auth_cipher(
7032 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7036 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7038 return test_mixed_auth_cipher(
7039 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7043 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7045 return test_mixed_auth_cipher_sgl(
7046 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7050 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7052 return test_mixed_auth_cipher_sgl(
7053 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7057 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7059 return test_mixed_auth_cipher(
7060 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7064 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7066 return test_mixed_auth_cipher(
7067 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7071 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7073 return test_mixed_auth_cipher_sgl(
7074 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7078 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7080 return test_mixed_auth_cipher_sgl(
7081 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7084 /** MIXED AUTH + CIPHER */
7087 test_auth_zuc_cipher_snow_test_case_1(void)
7089 return test_mixed_auth_cipher(
7090 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7094 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7096 return test_mixed_auth_cipher(
7097 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7101 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7103 return test_mixed_auth_cipher(
7104 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7108 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7110 return test_mixed_auth_cipher(
7111 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7115 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7117 return test_mixed_auth_cipher(
7118 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7122 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7124 return test_mixed_auth_cipher(
7125 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7129 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7131 return test_mixed_auth_cipher(
7132 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7136 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7138 return test_mixed_auth_cipher(
7139 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7143 test_auth_snow_cipher_zuc_test_case_1(void)
7145 return test_mixed_auth_cipher(
7146 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7150 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7152 return test_mixed_auth_cipher(
7153 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7157 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7159 return test_mixed_auth_cipher(
7160 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7164 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7166 return test_mixed_auth_cipher(
7167 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7171 test_auth_null_cipher_snow_test_case_1(void)
7173 return test_mixed_auth_cipher(
7174 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7178 test_verify_auth_null_cipher_snow_test_case_1(void)
7180 return test_mixed_auth_cipher(
7181 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7185 test_auth_null_cipher_zuc_test_case_1(void)
7187 return test_mixed_auth_cipher(
7188 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7192 test_verify_auth_null_cipher_zuc_test_case_1(void)
7194 return test_mixed_auth_cipher(
7195 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7199 test_auth_snow_cipher_null_test_case_1(void)
7201 return test_mixed_auth_cipher(
7202 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7206 test_verify_auth_snow_cipher_null_test_case_1(void)
7208 return test_mixed_auth_cipher(
7209 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7213 test_auth_zuc_cipher_null_test_case_1(void)
7215 return test_mixed_auth_cipher(
7216 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7220 test_verify_auth_zuc_cipher_null_test_case_1(void)
7222 return test_mixed_auth_cipher(
7223 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7227 test_auth_null_cipher_aes_ctr_test_case_1(void)
7229 return test_mixed_auth_cipher(
7230 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7234 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7236 return test_mixed_auth_cipher(
7237 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7241 test_auth_aes_cmac_cipher_null_test_case_1(void)
7243 return test_mixed_auth_cipher(
7244 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7248 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7250 return test_mixed_auth_cipher(
7251 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7255 test_3DES_chain_qat_all(void)
7257 struct crypto_testsuite_params *ts_params = &testsuite_params;
7260 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7261 ts_params->op_mpool,
7262 ts_params->session_mpool, ts_params->session_priv_mpool,
7263 ts_params->valid_devs[0],
7264 rte_cryptodev_driver_id_get(
7265 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7266 BLKCIPHER_3DES_CHAIN_TYPE);
7268 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7270 return TEST_SUCCESS;
7274 test_DES_cipheronly_qat_all(void)
7276 struct crypto_testsuite_params *ts_params = &testsuite_params;
7279 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7280 ts_params->op_mpool,
7281 ts_params->session_mpool, ts_params->session_priv_mpool,
7282 ts_params->valid_devs[0],
7283 rte_cryptodev_driver_id_get(
7284 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7285 BLKCIPHER_DES_CIPHERONLY_TYPE);
7287 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7289 return TEST_SUCCESS;
7293 test_DES_cipheronly_openssl_all(void)
7295 struct crypto_testsuite_params *ts_params = &testsuite_params;
7298 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7299 ts_params->op_mpool,
7300 ts_params->session_mpool, ts_params->session_priv_mpool,
7301 ts_params->valid_devs[0],
7302 rte_cryptodev_driver_id_get(
7303 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7304 BLKCIPHER_DES_CIPHERONLY_TYPE);
7306 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7308 return TEST_SUCCESS;
7312 test_DES_docsis_openssl_all(void)
7314 struct crypto_testsuite_params *ts_params = &testsuite_params;
7317 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7318 ts_params->op_mpool,
7319 ts_params->session_mpool, ts_params->session_priv_mpool,
7320 ts_params->valid_devs[0],
7321 rte_cryptodev_driver_id_get(
7322 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7323 BLKCIPHER_DES_DOCSIS_TYPE);
7325 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7327 return TEST_SUCCESS;
7331 test_DES_cipheronly_mb_all(void)
7333 struct crypto_testsuite_params *ts_params = &testsuite_params;
7336 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7337 ts_params->op_mpool,
7338 ts_params->session_mpool, ts_params->session_priv_mpool,
7339 ts_params->valid_devs[0],
7340 rte_cryptodev_driver_id_get(
7341 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7342 BLKCIPHER_DES_CIPHERONLY_TYPE);
7344 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7346 return TEST_SUCCESS;
7349 test_3DES_cipheronly_mb_all(void)
7351 struct crypto_testsuite_params *ts_params = &testsuite_params;
7354 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7355 ts_params->op_mpool,
7356 ts_params->session_mpool, ts_params->session_priv_mpool,
7357 ts_params->valid_devs[0],
7358 rte_cryptodev_driver_id_get(
7359 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7360 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7362 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7364 return TEST_SUCCESS;
7368 test_DES_docsis_mb_all(void)
7370 struct crypto_testsuite_params *ts_params = &testsuite_params;
7373 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7374 ts_params->op_mpool,
7375 ts_params->session_mpool, ts_params->session_priv_mpool,
7376 ts_params->valid_devs[0],
7377 rte_cryptodev_driver_id_get(
7378 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7379 BLKCIPHER_DES_DOCSIS_TYPE);
7381 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7383 return TEST_SUCCESS;
7387 test_3DES_chain_caam_jr_all(void)
7389 struct crypto_testsuite_params *ts_params = &testsuite_params;
7392 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7393 ts_params->op_mpool,
7394 ts_params->session_mpool, ts_params->session_priv_mpool,
7395 ts_params->valid_devs[0],
7396 rte_cryptodev_driver_id_get(
7397 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7398 BLKCIPHER_3DES_CHAIN_TYPE);
7400 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7402 return TEST_SUCCESS;
7406 test_3DES_cipheronly_caam_jr_all(void)
7408 struct crypto_testsuite_params *ts_params = &testsuite_params;
7411 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7412 ts_params->op_mpool,
7413 ts_params->session_mpool, ts_params->session_priv_mpool,
7414 ts_params->valid_devs[0],
7415 rte_cryptodev_driver_id_get(
7416 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7417 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7419 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7421 return TEST_SUCCESS;
7425 test_3DES_chain_dpaa_sec_all(void)
7427 struct crypto_testsuite_params *ts_params = &testsuite_params;
7430 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7431 ts_params->op_mpool,
7432 ts_params->session_mpool, ts_params->session_priv_mpool,
7433 ts_params->valid_devs[0],
7434 rte_cryptodev_driver_id_get(
7435 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7436 BLKCIPHER_3DES_CHAIN_TYPE);
7438 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7440 return TEST_SUCCESS;
7444 test_3DES_cipheronly_dpaa_sec_all(void)
7446 struct crypto_testsuite_params *ts_params = &testsuite_params;
7449 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7450 ts_params->op_mpool,
7451 ts_params->session_mpool, ts_params->session_priv_mpool,
7452 ts_params->valid_devs[0],
7453 rte_cryptodev_driver_id_get(
7454 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7455 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7457 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7459 return TEST_SUCCESS;
7463 test_3DES_chain_dpaa2_sec_all(void)
7465 struct crypto_testsuite_params *ts_params = &testsuite_params;
7468 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7469 ts_params->op_mpool,
7470 ts_params->session_mpool, ts_params->session_priv_mpool,
7471 ts_params->valid_devs[0],
7472 rte_cryptodev_driver_id_get(
7473 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7474 BLKCIPHER_3DES_CHAIN_TYPE);
7476 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7478 return TEST_SUCCESS;
7482 test_3DES_cipheronly_dpaa2_sec_all(void)
7484 struct crypto_testsuite_params *ts_params = &testsuite_params;
7487 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7488 ts_params->op_mpool,
7489 ts_params->session_mpool, ts_params->session_priv_mpool,
7490 ts_params->valid_devs[0],
7491 rte_cryptodev_driver_id_get(
7492 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7493 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7495 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7497 return TEST_SUCCESS;
7501 test_3DES_chain_ccp_all(void)
7503 struct crypto_testsuite_params *ts_params = &testsuite_params;
7506 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7507 ts_params->op_mpool,
7508 ts_params->session_mpool, ts_params->session_priv_mpool,
7509 ts_params->valid_devs[0],
7510 rte_cryptodev_driver_id_get(
7511 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7512 BLKCIPHER_3DES_CHAIN_TYPE);
7514 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7516 return TEST_SUCCESS;
7520 test_3DES_cipheronly_ccp_all(void)
7522 struct crypto_testsuite_params *ts_params = &testsuite_params;
7525 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7526 ts_params->op_mpool,
7527 ts_params->session_mpool, ts_params->session_priv_mpool,
7528 ts_params->valid_devs[0],
7529 rte_cryptodev_driver_id_get(
7530 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7531 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7533 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7535 return TEST_SUCCESS;
7539 test_3DES_cipheronly_qat_all(void)
7541 struct crypto_testsuite_params *ts_params = &testsuite_params;
7544 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7545 ts_params->op_mpool,
7546 ts_params->session_mpool, ts_params->session_priv_mpool,
7547 ts_params->valid_devs[0],
7548 rte_cryptodev_driver_id_get(
7549 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7550 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7552 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7554 return TEST_SUCCESS;
7558 test_3DES_chain_openssl_all(void)
7560 struct crypto_testsuite_params *ts_params = &testsuite_params;
7563 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7564 ts_params->op_mpool,
7565 ts_params->session_mpool, ts_params->session_priv_mpool,
7566 ts_params->valid_devs[0],
7567 rte_cryptodev_driver_id_get(
7568 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7569 BLKCIPHER_3DES_CHAIN_TYPE);
7571 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7573 return TEST_SUCCESS;
7577 test_3DES_cipheronly_openssl_all(void)
7579 struct crypto_testsuite_params *ts_params = &testsuite_params;
7582 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7583 ts_params->op_mpool,
7584 ts_params->session_mpool, ts_params->session_priv_mpool,
7585 ts_params->valid_devs[0],
7586 rte_cryptodev_driver_id_get(
7587 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7588 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7590 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7592 return TEST_SUCCESS;
7595 /* ***** AEAD algorithm Tests ***** */
7598 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7599 enum rte_crypto_aead_operation op,
7600 const uint8_t *key, const uint8_t key_len,
7601 const uint16_t aad_len, const uint8_t auth_len,
7604 uint8_t aead_key[key_len];
7606 struct crypto_testsuite_params *ts_params = &testsuite_params;
7607 struct crypto_unittest_params *ut_params = &unittest_params;
7609 memcpy(aead_key, key, key_len);
7611 /* Setup AEAD Parameters */
7612 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7613 ut_params->aead_xform.next = NULL;
7614 ut_params->aead_xform.aead.algo = algo;
7615 ut_params->aead_xform.aead.op = op;
7616 ut_params->aead_xform.aead.key.data = aead_key;
7617 ut_params->aead_xform.aead.key.length = key_len;
7618 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7619 ut_params->aead_xform.aead.iv.length = iv_len;
7620 ut_params->aead_xform.aead.digest_length = auth_len;
7621 ut_params->aead_xform.aead.aad_length = aad_len;
7623 debug_hexdump(stdout, "key:", key, key_len);
7625 /* Create Crypto session*/
7626 ut_params->sess = rte_cryptodev_sym_session_create(
7627 ts_params->session_mpool);
7629 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7630 &ut_params->aead_xform,
7631 ts_params->session_priv_mpool);
7633 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7639 create_aead_xform(struct rte_crypto_op *op,
7640 enum rte_crypto_aead_algorithm algo,
7641 enum rte_crypto_aead_operation aead_op,
7642 uint8_t *key, const uint8_t key_len,
7643 const uint8_t aad_len, const uint8_t auth_len,
7646 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7647 "failed to allocate space for crypto transform");
7649 struct rte_crypto_sym_op *sym_op = op->sym;
7651 /* Setup AEAD Parameters */
7652 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7653 sym_op->xform->next = NULL;
7654 sym_op->xform->aead.algo = algo;
7655 sym_op->xform->aead.op = aead_op;
7656 sym_op->xform->aead.key.data = key;
7657 sym_op->xform->aead.key.length = key_len;
7658 sym_op->xform->aead.iv.offset = IV_OFFSET;
7659 sym_op->xform->aead.iv.length = iv_len;
7660 sym_op->xform->aead.digest_length = auth_len;
7661 sym_op->xform->aead.aad_length = aad_len;
7663 debug_hexdump(stdout, "key:", key, key_len);
7669 create_aead_operation(enum rte_crypto_aead_operation op,
7670 const struct aead_test_data *tdata)
7672 struct crypto_testsuite_params *ts_params = &testsuite_params;
7673 struct crypto_unittest_params *ut_params = &unittest_params;
7675 uint8_t *plaintext, *ciphertext;
7676 unsigned int aad_pad_len, plaintext_pad_len;
7678 /* Generate Crypto op data structure */
7679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7680 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7681 TEST_ASSERT_NOT_NULL(ut_params->op,
7682 "Failed to allocate symmetric crypto operation struct");
7684 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7686 /* Append aad data */
7687 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7688 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7689 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7691 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7692 "no room to append aad");
7694 sym_op->aead.aad.phys_addr =
7695 rte_pktmbuf_iova(ut_params->ibuf);
7696 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7697 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7698 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7701 /* Append IV at the end of the crypto operation*/
7702 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7703 uint8_t *, IV_OFFSET);
7705 /* Copy IV 1 byte after the IV pointer, according to the API */
7706 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7707 debug_hexdump(stdout, "iv:", iv_ptr,
7710 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7711 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7713 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7714 "no room to append aad");
7716 sym_op->aead.aad.phys_addr =
7717 rte_pktmbuf_iova(ut_params->ibuf);
7718 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7719 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7722 /* Append IV at the end of the crypto operation*/
7723 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7724 uint8_t *, IV_OFFSET);
7726 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7727 debug_hexdump(stdout, "iv:", iv_ptr,
7731 /* Append plaintext/ciphertext */
7732 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7733 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7734 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7736 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7738 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7739 debug_hexdump(stdout, "plaintext:", plaintext,
7740 tdata->plaintext.len);
7742 if (ut_params->obuf) {
7743 ciphertext = (uint8_t *)rte_pktmbuf_append(
7745 plaintext_pad_len + aad_pad_len);
7746 TEST_ASSERT_NOT_NULL(ciphertext,
7747 "no room to append ciphertext");
7749 memset(ciphertext + aad_pad_len, 0,
7750 tdata->ciphertext.len);
7753 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7754 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7756 TEST_ASSERT_NOT_NULL(ciphertext,
7757 "no room to append ciphertext");
7759 memcpy(ciphertext, tdata->ciphertext.data,
7760 tdata->ciphertext.len);
7761 debug_hexdump(stdout, "ciphertext:", ciphertext,
7762 tdata->ciphertext.len);
7764 if (ut_params->obuf) {
7765 plaintext = (uint8_t *)rte_pktmbuf_append(
7767 plaintext_pad_len + aad_pad_len);
7768 TEST_ASSERT_NOT_NULL(plaintext,
7769 "no room to append plaintext");
7771 memset(plaintext + aad_pad_len, 0,
7772 tdata->plaintext.len);
7776 /* Append digest data */
7777 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7778 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7779 ut_params->obuf ? ut_params->obuf :
7781 tdata->auth_tag.len);
7782 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7783 "no room to append digest");
7784 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7785 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7786 ut_params->obuf ? ut_params->obuf :
7791 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7792 ut_params->ibuf, tdata->auth_tag.len);
7793 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7794 "no room to append digest");
7795 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7797 plaintext_pad_len + aad_pad_len);
7799 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7800 tdata->auth_tag.len);
7801 debug_hexdump(stdout, "digest:",
7802 sym_op->aead.digest.data,
7803 tdata->auth_tag.len);
7806 sym_op->aead.data.length = tdata->plaintext.len;
7807 sym_op->aead.data.offset = aad_pad_len;
7813 test_authenticated_encryption(const struct aead_test_data *tdata)
7815 struct crypto_testsuite_params *ts_params = &testsuite_params;
7816 struct crypto_unittest_params *ut_params = &unittest_params;
7819 uint8_t *ciphertext, *auth_tag;
7820 uint16_t plaintext_pad_len;
7823 /* Create AEAD session */
7824 retval = create_aead_session(ts_params->valid_devs[0],
7826 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7827 tdata->key.data, tdata->key.len,
7828 tdata->aad.len, tdata->auth_tag.len,
7833 if (tdata->aad.len > MBUF_SIZE) {
7834 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7835 /* Populate full size of add data */
7836 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7837 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7839 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7841 /* clear mbuf payload */
7842 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7843 rte_pktmbuf_tailroom(ut_params->ibuf));
7845 /* Create AEAD operation */
7846 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7850 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7852 ut_params->op->sym->m_src = ut_params->ibuf;
7854 /* Process crypto operation */
7855 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7856 ut_params->op), "failed to process sym crypto op");
7858 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7859 "crypto op processing failed");
7861 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7863 if (ut_params->op->sym->m_dst) {
7864 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7866 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7867 uint8_t *, plaintext_pad_len);
7869 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7871 ut_params->op->sym->cipher.data.offset);
7872 auth_tag = ciphertext + plaintext_pad_len;
7875 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7876 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7879 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7881 tdata->ciphertext.data,
7882 tdata->ciphertext.len,
7883 "Ciphertext data not as expected");
7885 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7887 tdata->auth_tag.data,
7888 tdata->auth_tag.len,
7889 "Generated auth tag not as expected");
7895 #ifdef RTE_LIBRTE_SECURITY
7896 /* Basic algorithm run function for async inplace mode.
7897 * Creates a session from input parameters and runs one operation
7898 * on input_vec. Checks the output of the crypto operation against
7902 test_pdcp_proto(int i, int oop,
7903 enum rte_crypto_cipher_operation opc,
7904 enum rte_crypto_auth_operation opa,
7906 unsigned int input_vec_len,
7907 uint8_t *output_vec,
7908 unsigned int output_vec_len)
7910 struct crypto_testsuite_params *ts_params = &testsuite_params;
7911 struct crypto_unittest_params *ut_params = &unittest_params;
7913 int ret = TEST_SUCCESS;
7915 /* Generate test mbuf data */
7916 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7918 /* clear mbuf payload */
7919 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7920 rte_pktmbuf_tailroom(ut_params->ibuf));
7922 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7924 memcpy(plaintext, input_vec, input_vec_len);
7926 /* Out of place support */
7929 * For out-op-place we need to alloc another mbuf
7931 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7932 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7935 /* Set crypto type as IPSEC */
7936 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7938 /* Setup Cipher Parameters */
7939 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7940 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7941 ut_params->cipher_xform.cipher.op = opc;
7942 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7943 ut_params->cipher_xform.cipher.key.length =
7944 pdcp_test_params[i].cipher_key_len;
7945 ut_params->cipher_xform.cipher.iv.length = 0;
7947 /* Setup HMAC Parameters if ICV header is required */
7948 if (pdcp_test_params[i].auth_alg != 0) {
7949 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7950 ut_params->auth_xform.next = NULL;
7951 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7952 ut_params->auth_xform.auth.op = opa;
7953 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7954 ut_params->auth_xform.auth.key.length =
7955 pdcp_test_params[i].auth_key_len;
7957 ut_params->cipher_xform.next = &ut_params->auth_xform;
7959 ut_params->cipher_xform.next = NULL;
7962 struct rte_security_session_conf sess_conf = {
7963 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7964 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7966 .bearer = pdcp_test_bearer[i],
7967 .domain = pdcp_test_params[i].domain,
7968 .pkt_dir = pdcp_test_packet_direction[i],
7969 .sn_size = pdcp_test_data_sn_size[i],
7970 .hfn = pdcp_test_hfn[i],
7971 .hfn_threshold = pdcp_test_hfn_threshold[i],
7973 .crypto_xform = &ut_params->cipher_xform
7976 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7977 rte_cryptodev_get_sec_ctx(
7978 ts_params->valid_devs[0]);
7980 /* Create security session */
7981 ut_params->sec_session = rte_security_session_create(ctx,
7982 &sess_conf, ts_params->session_priv_mpool);
7984 if (!ut_params->sec_session) {
7985 printf("TestCase %s()-%d line %d failed %s: ",
7986 __func__, i, __LINE__, "Failed to allocate session");
7991 /* Generate crypto op data structure */
7992 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7993 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7994 if (!ut_params->op) {
7995 printf("TestCase %s()-%d line %d failed %s: ",
7996 __func__, i, __LINE__,
7997 "Failed to allocate symmetric crypto operation struct");
8002 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8004 /* set crypto operation source mbuf */
8005 ut_params->op->sym->m_src = ut_params->ibuf;
8007 ut_params->op->sym->m_dst = ut_params->obuf;
8009 /* Process crypto operation */
8010 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8012 printf("TestCase %s()-%d line %d failed %s: ",
8013 __func__, i, __LINE__,
8014 "failed to process sym crypto op");
8019 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8020 printf("TestCase %s()-%d line %d failed %s: ",
8021 __func__, i, __LINE__, "crypto op processing failed");
8027 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8030 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8034 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8035 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8036 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8037 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8043 rte_crypto_op_free(ut_params->op);
8044 ut_params->op = NULL;
8046 if (ut_params->sec_session)
8047 rte_security_session_destroy(ctx, ut_params->sec_session);
8048 ut_params->sec_session = NULL;
8050 rte_pktmbuf_free(ut_params->ibuf);
8051 ut_params->ibuf = NULL;
8053 rte_pktmbuf_free(ut_params->obuf);
8054 ut_params->obuf = NULL;
8061 test_pdcp_proto_SGL(int i, int oop,
8062 enum rte_crypto_cipher_operation opc,
8063 enum rte_crypto_auth_operation opa,
8065 unsigned int input_vec_len,
8066 uint8_t *output_vec,
8067 unsigned int output_vec_len,
8069 uint32_t fragsz_oop)
8071 struct crypto_testsuite_params *ts_params = &testsuite_params;
8072 struct crypto_unittest_params *ut_params = &unittest_params;
8074 struct rte_mbuf *buf, *buf_oop = NULL;
8075 int ret = TEST_SUCCESS;
8079 unsigned int trn_data = 0;
8081 if (fragsz > input_vec_len)
8082 fragsz = input_vec_len;
8084 uint16_t plaintext_len = fragsz;
8085 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8087 if (fragsz_oop > output_vec_len)
8088 frag_size_oop = output_vec_len;
8091 if (input_vec_len % fragsz != 0) {
8092 if (input_vec_len / fragsz + 1 > 16)
8094 } else if (input_vec_len / fragsz > 16)
8097 /* Out of place support */
8100 * For out-op-place we need to alloc another mbuf
8102 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8103 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8104 buf_oop = ut_params->obuf;
8107 /* Generate test mbuf data */
8108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8110 /* clear mbuf payload */
8111 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8112 rte_pktmbuf_tailroom(ut_params->ibuf));
8114 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8116 memcpy(plaintext, input_vec, plaintext_len);
8117 trn_data += plaintext_len;
8119 buf = ut_params->ibuf;
8122 * Loop until no more fragments
8125 while (trn_data < input_vec_len) {
8127 to_trn = (input_vec_len - trn_data < fragsz) ?
8128 (input_vec_len - trn_data) : fragsz;
8130 to_trn_tbl[ecx++] = to_trn;
8132 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8135 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8136 rte_pktmbuf_tailroom(buf));
8139 if (oop && !fragsz_oop) {
8141 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8142 buf_oop = buf_oop->next;
8143 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8144 0, rte_pktmbuf_tailroom(buf_oop));
8145 rte_pktmbuf_append(buf_oop, to_trn);
8148 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8151 memcpy(plaintext, input_vec + trn_data, to_trn);
8155 ut_params->ibuf->nb_segs = segs;
8158 if (fragsz_oop && oop) {
8162 trn_data = frag_size_oop;
8163 while (trn_data < output_vec_len) {
8166 (output_vec_len - trn_data <
8168 (output_vec_len - trn_data) :
8171 to_trn_tbl[ecx++] = to_trn;
8174 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8175 buf_oop = buf_oop->next;
8176 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8177 0, rte_pktmbuf_tailroom(buf_oop));
8178 rte_pktmbuf_append(buf_oop, to_trn);
8182 ut_params->obuf->nb_segs = segs;
8185 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8187 /* Setup Cipher Parameters */
8188 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8189 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8190 ut_params->cipher_xform.cipher.op = opc;
8191 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8192 ut_params->cipher_xform.cipher.key.length =
8193 pdcp_test_params[i].cipher_key_len;
8194 ut_params->cipher_xform.cipher.iv.length = 0;
8196 /* Setup HMAC Parameters if ICV header is required */
8197 if (pdcp_test_params[i].auth_alg != 0) {
8198 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8199 ut_params->auth_xform.next = NULL;
8200 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8201 ut_params->auth_xform.auth.op = opa;
8202 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8203 ut_params->auth_xform.auth.key.length =
8204 pdcp_test_params[i].auth_key_len;
8206 ut_params->cipher_xform.next = &ut_params->auth_xform;
8208 ut_params->cipher_xform.next = NULL;
8211 struct rte_security_session_conf sess_conf = {
8212 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
8213 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8215 .bearer = pdcp_test_bearer[i],
8216 .domain = pdcp_test_params[i].domain,
8217 .pkt_dir = pdcp_test_packet_direction[i],
8218 .sn_size = pdcp_test_data_sn_size[i],
8219 .hfn = pdcp_test_hfn[i],
8220 .hfn_threshold = pdcp_test_hfn_threshold[i],
8222 .crypto_xform = &ut_params->cipher_xform
8225 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8226 rte_cryptodev_get_sec_ctx(
8227 ts_params->valid_devs[0]);
8229 /* Create security session */
8230 ut_params->sec_session = rte_security_session_create(ctx,
8231 &sess_conf, ts_params->session_priv_mpool);
8233 if (!ut_params->sec_session) {
8234 printf("TestCase %s()-%d line %d failed %s: ",
8235 __func__, i, __LINE__, "Failed to allocate session");
8240 /* Generate crypto op data structure */
8241 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8242 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8243 if (!ut_params->op) {
8244 printf("TestCase %s()-%d line %d failed %s: ",
8245 __func__, i, __LINE__,
8246 "Failed to allocate symmetric crypto operation struct");
8251 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8253 /* set crypto operation source mbuf */
8254 ut_params->op->sym->m_src = ut_params->ibuf;
8256 ut_params->op->sym->m_dst = ut_params->obuf;
8258 /* Process crypto operation */
8259 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8261 printf("TestCase %s()-%d line %d failed %s: ",
8262 __func__, i, __LINE__,
8263 "failed to process sym crypto op");
8268 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8269 printf("TestCase %s()-%d line %d failed %s: ",
8270 __func__, i, __LINE__, "crypto op processing failed");
8276 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8279 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8283 fragsz = frag_size_oop;
8284 if (memcmp(ciphertext, output_vec, fragsz)) {
8285 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8286 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8287 rte_hexdump(stdout, "reference", output_vec, fragsz);
8292 buf = ut_params->op->sym->m_src->next;
8294 buf = ut_params->op->sym->m_dst->next;
8296 unsigned int off = fragsz;
8300 ciphertext = rte_pktmbuf_mtod(buf,
8302 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8303 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8304 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8305 rte_hexdump(stdout, "reference", output_vec + off,
8310 off += to_trn_tbl[ecx++];
8314 rte_crypto_op_free(ut_params->op);
8315 ut_params->op = NULL;
8317 if (ut_params->sec_session)
8318 rte_security_session_destroy(ctx, ut_params->sec_session);
8319 ut_params->sec_session = NULL;
8321 rte_pktmbuf_free(ut_params->ibuf);
8322 ut_params->ibuf = NULL;
8324 rte_pktmbuf_free(ut_params->obuf);
8325 ut_params->obuf = NULL;
8332 test_pdcp_proto_cplane_encap(int i)
8334 return test_pdcp_proto(i, 0,
8335 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8336 RTE_CRYPTO_AUTH_OP_GENERATE,
8337 pdcp_test_data_in[i],
8338 pdcp_test_data_in_len[i],
8339 pdcp_test_data_out[i],
8340 pdcp_test_data_in_len[i]+4);
8344 test_pdcp_proto_uplane_encap(int i)
8346 return test_pdcp_proto(i, 0,
8347 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8348 RTE_CRYPTO_AUTH_OP_GENERATE,
8349 pdcp_test_data_in[i],
8350 pdcp_test_data_in_len[i],
8351 pdcp_test_data_out[i],
8352 pdcp_test_data_in_len[i]);
8357 test_pdcp_proto_uplane_encap_with_int(int i)
8359 return test_pdcp_proto(i, 0,
8360 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8361 RTE_CRYPTO_AUTH_OP_GENERATE,
8362 pdcp_test_data_in[i],
8363 pdcp_test_data_in_len[i],
8364 pdcp_test_data_out[i],
8365 pdcp_test_data_in_len[i] + 4);
8369 test_pdcp_proto_cplane_decap(int i)
8371 return test_pdcp_proto(i, 0,
8372 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8373 RTE_CRYPTO_AUTH_OP_VERIFY,
8374 pdcp_test_data_out[i],
8375 pdcp_test_data_in_len[i] + 4,
8376 pdcp_test_data_in[i],
8377 pdcp_test_data_in_len[i]);
8381 test_pdcp_proto_uplane_decap(int i)
8383 return test_pdcp_proto(i, 0,
8384 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8385 RTE_CRYPTO_AUTH_OP_VERIFY,
8386 pdcp_test_data_out[i],
8387 pdcp_test_data_in_len[i],
8388 pdcp_test_data_in[i],
8389 pdcp_test_data_in_len[i]);
8393 test_pdcp_proto_uplane_decap_with_int(int i)
8395 return test_pdcp_proto(i, 0,
8396 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8397 RTE_CRYPTO_AUTH_OP_VERIFY,
8398 pdcp_test_data_out[i],
8399 pdcp_test_data_in_len[i] + 4,
8400 pdcp_test_data_in[i],
8401 pdcp_test_data_in_len[i]);
8405 test_PDCP_PROTO_SGL_in_place_32B(void)
8407 /* i can be used for running any PDCP case
8408 * In this case it is uplane 12-bit AES-SNOW DL encap
8410 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8411 return test_pdcp_proto_SGL(i, IN_PLACE,
8412 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8413 RTE_CRYPTO_AUTH_OP_GENERATE,
8414 pdcp_test_data_in[i],
8415 pdcp_test_data_in_len[i],
8416 pdcp_test_data_out[i],
8417 pdcp_test_data_in_len[i]+4,
8421 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8423 /* i can be used for running any PDCP case
8424 * In this case it is uplane 18-bit NULL-NULL DL encap
8426 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8427 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8428 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8429 RTE_CRYPTO_AUTH_OP_GENERATE,
8430 pdcp_test_data_in[i],
8431 pdcp_test_data_in_len[i],
8432 pdcp_test_data_out[i],
8433 pdcp_test_data_in_len[i]+4,
8437 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8439 /* i can be used for running any PDCP case
8440 * In this case it is uplane 18-bit AES DL encap
8442 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8444 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8445 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8446 RTE_CRYPTO_AUTH_OP_GENERATE,
8447 pdcp_test_data_in[i],
8448 pdcp_test_data_in_len[i],
8449 pdcp_test_data_out[i],
8450 pdcp_test_data_in_len[i],
8454 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8456 /* i can be used for running any PDCP case
8457 * In this case it is cplane 12-bit AES-ZUC DL encap
8459 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8460 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8461 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8462 RTE_CRYPTO_AUTH_OP_GENERATE,
8463 pdcp_test_data_in[i],
8464 pdcp_test_data_in_len[i],
8465 pdcp_test_data_out[i],
8466 pdcp_test_data_in_len[i]+4,
8472 test_AES_GCM_authenticated_encryption_test_case_1(void)
8474 return test_authenticated_encryption(&gcm_test_case_1);
8478 test_AES_GCM_authenticated_encryption_test_case_2(void)
8480 return test_authenticated_encryption(&gcm_test_case_2);
8484 test_AES_GCM_authenticated_encryption_test_case_3(void)
8486 return test_authenticated_encryption(&gcm_test_case_3);
8490 test_AES_GCM_authenticated_encryption_test_case_4(void)
8492 return test_authenticated_encryption(&gcm_test_case_4);
8496 test_AES_GCM_authenticated_encryption_test_case_5(void)
8498 return test_authenticated_encryption(&gcm_test_case_5);
8502 test_AES_GCM_authenticated_encryption_test_case_6(void)
8504 return test_authenticated_encryption(&gcm_test_case_6);
8508 test_AES_GCM_authenticated_encryption_test_case_7(void)
8510 return test_authenticated_encryption(&gcm_test_case_7);
8514 test_AES_GCM_authenticated_encryption_test_case_8(void)
8516 return test_authenticated_encryption(&gcm_test_case_8);
8520 test_AES_GCM_auth_encryption_test_case_192_1(void)
8522 return test_authenticated_encryption(&gcm_test_case_192_1);
8526 test_AES_GCM_auth_encryption_test_case_192_2(void)
8528 return test_authenticated_encryption(&gcm_test_case_192_2);
8532 test_AES_GCM_auth_encryption_test_case_192_3(void)
8534 return test_authenticated_encryption(&gcm_test_case_192_3);
8538 test_AES_GCM_auth_encryption_test_case_192_4(void)
8540 return test_authenticated_encryption(&gcm_test_case_192_4);
8544 test_AES_GCM_auth_encryption_test_case_192_5(void)
8546 return test_authenticated_encryption(&gcm_test_case_192_5);
8550 test_AES_GCM_auth_encryption_test_case_192_6(void)
8552 return test_authenticated_encryption(&gcm_test_case_192_6);
8556 test_AES_GCM_auth_encryption_test_case_192_7(void)
8558 return test_authenticated_encryption(&gcm_test_case_192_7);
8562 test_AES_GCM_auth_encryption_test_case_256_1(void)
8564 return test_authenticated_encryption(&gcm_test_case_256_1);
8568 test_AES_GCM_auth_encryption_test_case_256_2(void)
8570 return test_authenticated_encryption(&gcm_test_case_256_2);
8574 test_AES_GCM_auth_encryption_test_case_256_3(void)
8576 return test_authenticated_encryption(&gcm_test_case_256_3);
8580 test_AES_GCM_auth_encryption_test_case_256_4(void)
8582 return test_authenticated_encryption(&gcm_test_case_256_4);
8586 test_AES_GCM_auth_encryption_test_case_256_5(void)
8588 return test_authenticated_encryption(&gcm_test_case_256_5);
8592 test_AES_GCM_auth_encryption_test_case_256_6(void)
8594 return test_authenticated_encryption(&gcm_test_case_256_6);
8598 test_AES_GCM_auth_encryption_test_case_256_7(void)
8600 return test_authenticated_encryption(&gcm_test_case_256_7);
8604 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8606 return test_authenticated_encryption(&gcm_test_case_aad_1);
8610 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8612 return test_authenticated_encryption(&gcm_test_case_aad_2);
8616 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8618 struct aead_test_data tdata;
8621 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8622 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8623 tdata.iv.data[0] += 1;
8624 res = test_authenticated_encryption(&tdata);
8625 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8626 return TEST_SUCCESS;
8630 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8632 struct aead_test_data tdata;
8635 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8636 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8637 tdata.plaintext.data[0] += 1;
8638 res = test_authenticated_encryption(&tdata);
8639 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8640 return TEST_SUCCESS;
8644 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8646 struct aead_test_data tdata;
8649 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8650 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8651 tdata.ciphertext.data[0] += 1;
8652 res = test_authenticated_encryption(&tdata);
8653 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8654 return TEST_SUCCESS;
8658 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8660 struct aead_test_data tdata;
8663 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8664 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8666 res = test_authenticated_encryption(&tdata);
8667 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8668 return TEST_SUCCESS;
8672 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8674 struct aead_test_data tdata;
8675 uint8_t aad[gcm_test_case_7.aad.len];
8678 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8679 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8680 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8682 tdata.aad.data = aad;
8683 res = test_authenticated_encryption(&tdata);
8684 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8685 return TEST_SUCCESS;
8689 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8691 struct aead_test_data tdata;
8694 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8695 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8696 tdata.auth_tag.data[0] += 1;
8697 res = test_authenticated_encryption(&tdata);
8698 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8699 return TEST_SUCCESS;
8703 test_authenticated_decryption(const struct aead_test_data *tdata)
8705 struct crypto_testsuite_params *ts_params = &testsuite_params;
8706 struct crypto_unittest_params *ut_params = &unittest_params;
8712 /* Create AEAD session */
8713 retval = create_aead_session(ts_params->valid_devs[0],
8715 RTE_CRYPTO_AEAD_OP_DECRYPT,
8716 tdata->key.data, tdata->key.len,
8717 tdata->aad.len, tdata->auth_tag.len,
8722 /* alloc mbuf and set payload */
8723 if (tdata->aad.len > MBUF_SIZE) {
8724 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8725 /* Populate full size of add data */
8726 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8727 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8729 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8731 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8732 rte_pktmbuf_tailroom(ut_params->ibuf));
8734 /* Create AEAD operation */
8735 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8739 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8741 ut_params->op->sym->m_src = ut_params->ibuf;
8743 /* Process crypto operation */
8744 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8745 ut_params->op), "failed to process sym crypto op");
8747 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8748 "crypto op processing failed");
8750 if (ut_params->op->sym->m_dst)
8751 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8754 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8756 ut_params->op->sym->cipher.data.offset);
8758 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8761 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8763 tdata->plaintext.data,
8764 tdata->plaintext.len,
8765 "Plaintext data not as expected");
8767 TEST_ASSERT_EQUAL(ut_params->op->status,
8768 RTE_CRYPTO_OP_STATUS_SUCCESS,
8769 "Authentication failed");
8775 test_AES_GCM_authenticated_decryption_test_case_1(void)
8777 return test_authenticated_decryption(&gcm_test_case_1);
8781 test_AES_GCM_authenticated_decryption_test_case_2(void)
8783 return test_authenticated_decryption(&gcm_test_case_2);
8787 test_AES_GCM_authenticated_decryption_test_case_3(void)
8789 return test_authenticated_decryption(&gcm_test_case_3);
8793 test_AES_GCM_authenticated_decryption_test_case_4(void)
8795 return test_authenticated_decryption(&gcm_test_case_4);
8799 test_AES_GCM_authenticated_decryption_test_case_5(void)
8801 return test_authenticated_decryption(&gcm_test_case_5);
8805 test_AES_GCM_authenticated_decryption_test_case_6(void)
8807 return test_authenticated_decryption(&gcm_test_case_6);
8811 test_AES_GCM_authenticated_decryption_test_case_7(void)
8813 return test_authenticated_decryption(&gcm_test_case_7);
8817 test_AES_GCM_authenticated_decryption_test_case_8(void)
8819 return test_authenticated_decryption(&gcm_test_case_8);
8823 test_AES_GCM_auth_decryption_test_case_192_1(void)
8825 return test_authenticated_decryption(&gcm_test_case_192_1);
8829 test_AES_GCM_auth_decryption_test_case_192_2(void)
8831 return test_authenticated_decryption(&gcm_test_case_192_2);
8835 test_AES_GCM_auth_decryption_test_case_192_3(void)
8837 return test_authenticated_decryption(&gcm_test_case_192_3);
8841 test_AES_GCM_auth_decryption_test_case_192_4(void)
8843 return test_authenticated_decryption(&gcm_test_case_192_4);
8847 test_AES_GCM_auth_decryption_test_case_192_5(void)
8849 return test_authenticated_decryption(&gcm_test_case_192_5);
8853 test_AES_GCM_auth_decryption_test_case_192_6(void)
8855 return test_authenticated_decryption(&gcm_test_case_192_6);
8859 test_AES_GCM_auth_decryption_test_case_192_7(void)
8861 return test_authenticated_decryption(&gcm_test_case_192_7);
8865 test_AES_GCM_auth_decryption_test_case_256_1(void)
8867 return test_authenticated_decryption(&gcm_test_case_256_1);
8871 test_AES_GCM_auth_decryption_test_case_256_2(void)
8873 return test_authenticated_decryption(&gcm_test_case_256_2);
8877 test_AES_GCM_auth_decryption_test_case_256_3(void)
8879 return test_authenticated_decryption(&gcm_test_case_256_3);
8883 test_AES_GCM_auth_decryption_test_case_256_4(void)
8885 return test_authenticated_decryption(&gcm_test_case_256_4);
8889 test_AES_GCM_auth_decryption_test_case_256_5(void)
8891 return test_authenticated_decryption(&gcm_test_case_256_5);
8895 test_AES_GCM_auth_decryption_test_case_256_6(void)
8897 return test_authenticated_decryption(&gcm_test_case_256_6);
8901 test_AES_GCM_auth_decryption_test_case_256_7(void)
8903 return test_authenticated_decryption(&gcm_test_case_256_7);
8907 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8909 return test_authenticated_decryption(&gcm_test_case_aad_1);
8913 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8915 return test_authenticated_decryption(&gcm_test_case_aad_2);
8919 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8921 struct aead_test_data tdata;
8924 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8925 tdata.iv.data[0] += 1;
8926 res = test_authenticated_decryption(&tdata);
8927 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8928 return TEST_SUCCESS;
8932 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8934 struct aead_test_data tdata;
8937 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8938 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8939 tdata.plaintext.data[0] += 1;
8940 res = test_authenticated_decryption(&tdata);
8941 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8942 return TEST_SUCCESS;
8946 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8948 struct aead_test_data tdata;
8951 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8952 tdata.ciphertext.data[0] += 1;
8953 res = test_authenticated_decryption(&tdata);
8954 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8955 return TEST_SUCCESS;
8959 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8961 struct aead_test_data tdata;
8964 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8966 res = test_authenticated_decryption(&tdata);
8967 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8968 return TEST_SUCCESS;
8972 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8974 struct aead_test_data tdata;
8975 uint8_t aad[gcm_test_case_7.aad.len];
8978 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8979 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8981 tdata.aad.data = aad;
8982 res = test_authenticated_decryption(&tdata);
8983 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8984 return TEST_SUCCESS;
8988 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8990 struct aead_test_data tdata;
8993 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8994 tdata.auth_tag.data[0] += 1;
8995 res = test_authenticated_decryption(&tdata);
8996 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8997 return TEST_SUCCESS;
9001 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9003 struct crypto_testsuite_params *ts_params = &testsuite_params;
9004 struct crypto_unittest_params *ut_params = &unittest_params;
9007 uint8_t *ciphertext, *auth_tag;
9008 uint16_t plaintext_pad_len;
9010 /* Create AEAD session */
9011 retval = create_aead_session(ts_params->valid_devs[0],
9013 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9014 tdata->key.data, tdata->key.len,
9015 tdata->aad.len, tdata->auth_tag.len,
9020 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9021 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9023 /* clear mbuf payload */
9024 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9025 rte_pktmbuf_tailroom(ut_params->ibuf));
9026 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9027 rte_pktmbuf_tailroom(ut_params->obuf));
9029 /* Create AEAD operation */
9030 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9034 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9036 ut_params->op->sym->m_src = ut_params->ibuf;
9037 ut_params->op->sym->m_dst = ut_params->obuf;
9039 /* Process crypto operation */
9040 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9041 ut_params->op), "failed to process sym crypto op");
9043 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9044 "crypto op processing failed");
9046 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9048 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9049 ut_params->op->sym->cipher.data.offset);
9050 auth_tag = ciphertext + plaintext_pad_len;
9052 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9053 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9056 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9058 tdata->ciphertext.data,
9059 tdata->ciphertext.len,
9060 "Ciphertext data not as expected");
9062 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9064 tdata->auth_tag.data,
9065 tdata->auth_tag.len,
9066 "Generated auth tag not as expected");
9073 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9075 return test_authenticated_encryption_oop(&gcm_test_case_5);
9079 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9081 struct crypto_testsuite_params *ts_params = &testsuite_params;
9082 struct crypto_unittest_params *ut_params = &unittest_params;
9087 /* Create AEAD session */
9088 retval = create_aead_session(ts_params->valid_devs[0],
9090 RTE_CRYPTO_AEAD_OP_DECRYPT,
9091 tdata->key.data, tdata->key.len,
9092 tdata->aad.len, tdata->auth_tag.len,
9097 /* alloc mbuf and set payload */
9098 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9099 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9101 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9102 rte_pktmbuf_tailroom(ut_params->ibuf));
9103 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9104 rte_pktmbuf_tailroom(ut_params->obuf));
9106 /* Create AEAD operation */
9107 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9111 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9113 ut_params->op->sym->m_src = ut_params->ibuf;
9114 ut_params->op->sym->m_dst = ut_params->obuf;
9116 /* Process crypto operation */
9117 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9118 ut_params->op), "failed to process sym crypto op");
9120 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9121 "crypto op processing failed");
9123 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9124 ut_params->op->sym->cipher.data.offset);
9126 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9129 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9131 tdata->plaintext.data,
9132 tdata->plaintext.len,
9133 "Plaintext data not as expected");
9135 TEST_ASSERT_EQUAL(ut_params->op->status,
9136 RTE_CRYPTO_OP_STATUS_SUCCESS,
9137 "Authentication failed");
9142 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9144 return test_authenticated_decryption_oop(&gcm_test_case_5);
9148 test_authenticated_encryption_sessionless(
9149 const struct aead_test_data *tdata)
9151 struct crypto_testsuite_params *ts_params = &testsuite_params;
9152 struct crypto_unittest_params *ut_params = &unittest_params;
9155 uint8_t *ciphertext, *auth_tag;
9156 uint16_t plaintext_pad_len;
9157 uint8_t key[tdata->key.len + 1];
9159 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9161 /* clear mbuf payload */
9162 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9163 rte_pktmbuf_tailroom(ut_params->ibuf));
9165 /* Create AEAD operation */
9166 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9170 /* Create GCM xform */
9171 memcpy(key, tdata->key.data, tdata->key.len);
9172 retval = create_aead_xform(ut_params->op,
9174 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9175 key, tdata->key.len,
9176 tdata->aad.len, tdata->auth_tag.len,
9181 ut_params->op->sym->m_src = ut_params->ibuf;
9183 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9184 RTE_CRYPTO_OP_SESSIONLESS,
9185 "crypto op session type not sessionless");
9187 /* Process crypto operation */
9188 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9189 ut_params->op), "failed to process sym crypto op");
9191 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9193 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9194 "crypto op status not success");
9196 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9198 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9199 ut_params->op->sym->cipher.data.offset);
9200 auth_tag = ciphertext + plaintext_pad_len;
9202 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9203 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9206 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9208 tdata->ciphertext.data,
9209 tdata->ciphertext.len,
9210 "Ciphertext data not as expected");
9212 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9214 tdata->auth_tag.data,
9215 tdata->auth_tag.len,
9216 "Generated auth tag not as expected");
9223 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9225 return test_authenticated_encryption_sessionless(
9230 test_authenticated_decryption_sessionless(
9231 const struct aead_test_data *tdata)
9233 struct crypto_testsuite_params *ts_params = &testsuite_params;
9234 struct crypto_unittest_params *ut_params = &unittest_params;
9238 uint8_t key[tdata->key.len + 1];
9240 /* alloc mbuf and set payload */
9241 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9243 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9244 rte_pktmbuf_tailroom(ut_params->ibuf));
9246 /* Create AEAD operation */
9247 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9251 /* Create AEAD xform */
9252 memcpy(key, tdata->key.data, tdata->key.len);
9253 retval = create_aead_xform(ut_params->op,
9255 RTE_CRYPTO_AEAD_OP_DECRYPT,
9256 key, tdata->key.len,
9257 tdata->aad.len, tdata->auth_tag.len,
9262 ut_params->op->sym->m_src = ut_params->ibuf;
9264 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9265 RTE_CRYPTO_OP_SESSIONLESS,
9266 "crypto op session type not sessionless");
9268 /* Process crypto operation */
9269 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9270 ut_params->op), "failed to process sym crypto op");
9272 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9274 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9275 "crypto op status not success");
9277 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9278 ut_params->op->sym->cipher.data.offset);
9280 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9283 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9285 tdata->plaintext.data,
9286 tdata->plaintext.len,
9287 "Plaintext data not as expected");
9289 TEST_ASSERT_EQUAL(ut_params->op->status,
9290 RTE_CRYPTO_OP_STATUS_SUCCESS,
9291 "Authentication failed");
9296 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9298 return test_authenticated_decryption_sessionless(
9303 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9305 return test_authenticated_encryption(&ccm_test_case_128_1);
9309 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9311 return test_authenticated_encryption(&ccm_test_case_128_2);
9315 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9317 return test_authenticated_encryption(&ccm_test_case_128_3);
9321 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9323 return test_authenticated_decryption(&ccm_test_case_128_1);
9327 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9329 return test_authenticated_decryption(&ccm_test_case_128_2);
9333 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9335 return test_authenticated_decryption(&ccm_test_case_128_3);
9339 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9341 return test_authenticated_encryption(&ccm_test_case_192_1);
9345 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9347 return test_authenticated_encryption(&ccm_test_case_192_2);
9351 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9353 return test_authenticated_encryption(&ccm_test_case_192_3);
9357 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9359 return test_authenticated_decryption(&ccm_test_case_192_1);
9363 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9365 return test_authenticated_decryption(&ccm_test_case_192_2);
9369 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9371 return test_authenticated_decryption(&ccm_test_case_192_3);
9375 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9377 return test_authenticated_encryption(&ccm_test_case_256_1);
9381 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9383 return test_authenticated_encryption(&ccm_test_case_256_2);
9387 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9389 return test_authenticated_encryption(&ccm_test_case_256_3);
9393 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9395 return test_authenticated_decryption(&ccm_test_case_256_1);
9399 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9401 return test_authenticated_decryption(&ccm_test_case_256_2);
9405 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9407 return test_authenticated_decryption(&ccm_test_case_256_3);
9413 struct crypto_testsuite_params *ts_params = &testsuite_params;
9414 struct rte_cryptodev_stats stats;
9415 struct rte_cryptodev *dev;
9416 cryptodev_stats_get_t temp_pfn;
9418 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9419 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9420 &stats) == -ENODEV),
9421 "rte_cryptodev_stats_get invalid dev failed");
9422 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9423 "rte_cryptodev_stats_get invalid Param failed");
9424 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9425 temp_pfn = dev->dev_ops->stats_get;
9426 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9427 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9429 "rte_cryptodev_stats_get invalid Param failed");
9430 dev->dev_ops->stats_get = temp_pfn;
9432 /* Test expected values */
9434 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9436 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9438 "rte_cryptodev_stats_get failed");
9439 TEST_ASSERT((stats.enqueued_count == 1),
9440 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9441 TEST_ASSERT((stats.dequeued_count == 1),
9442 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9443 TEST_ASSERT((stats.enqueue_err_count == 0),
9444 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9445 TEST_ASSERT((stats.dequeue_err_count == 0),
9446 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9448 /* invalid device but should ignore and not reset device stats*/
9449 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9450 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9452 "rte_cryptodev_stats_get failed");
9453 TEST_ASSERT((stats.enqueued_count == 1),
9454 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9456 /* check that a valid reset clears stats */
9457 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9458 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9460 "rte_cryptodev_stats_get failed");
9461 TEST_ASSERT((stats.enqueued_count == 0),
9462 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9463 TEST_ASSERT((stats.dequeued_count == 0),
9464 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9466 return TEST_SUCCESS;
9469 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9470 struct crypto_unittest_params *ut_params,
9471 enum rte_crypto_auth_operation op,
9472 const struct HMAC_MD5_vector *test_case)
9476 memcpy(key, test_case->key.data, test_case->key.len);
9478 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9479 ut_params->auth_xform.next = NULL;
9480 ut_params->auth_xform.auth.op = op;
9482 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9484 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9485 ut_params->auth_xform.auth.key.length = test_case->key.len;
9486 ut_params->auth_xform.auth.key.data = key;
9488 ut_params->sess = rte_cryptodev_sym_session_create(
9489 ts_params->session_mpool);
9491 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9492 ut_params->sess, &ut_params->auth_xform,
9493 ts_params->session_priv_mpool);
9495 if (ut_params->sess == NULL)
9498 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9500 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9501 rte_pktmbuf_tailroom(ut_params->ibuf));
9506 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9507 const struct HMAC_MD5_vector *test_case,
9508 uint8_t **plaintext)
9510 uint16_t plaintext_pad_len;
9512 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9514 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9517 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9519 memcpy(*plaintext, test_case->plaintext.data,
9520 test_case->plaintext.len);
9522 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9523 ut_params->ibuf, MD5_DIGEST_LEN);
9524 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9525 "no room to append digest");
9526 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9527 ut_params->ibuf, plaintext_pad_len);
9529 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9530 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9531 test_case->auth_tag.len);
9534 sym_op->auth.data.offset = 0;
9535 sym_op->auth.data.length = test_case->plaintext.len;
9537 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9538 ut_params->op->sym->m_src = ut_params->ibuf;
9544 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9546 uint16_t plaintext_pad_len;
9547 uint8_t *plaintext, *auth_tag;
9549 struct crypto_testsuite_params *ts_params = &testsuite_params;
9550 struct crypto_unittest_params *ut_params = &unittest_params;
9552 if (MD5_HMAC_create_session(ts_params, ut_params,
9553 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9556 /* Generate Crypto op data structure */
9557 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9558 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9559 TEST_ASSERT_NOT_NULL(ut_params->op,
9560 "Failed to allocate symmetric crypto operation struct");
9562 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9565 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9568 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9569 ut_params->op), "failed to process sym crypto op");
9571 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9572 "crypto op processing failed");
9574 if (ut_params->op->sym->m_dst) {
9575 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9576 uint8_t *, plaintext_pad_len);
9578 auth_tag = plaintext + plaintext_pad_len;
9581 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9583 test_case->auth_tag.data,
9584 test_case->auth_tag.len,
9585 "HMAC_MD5 generated tag not as expected");
9587 return TEST_SUCCESS;
9591 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9595 struct crypto_testsuite_params *ts_params = &testsuite_params;
9596 struct crypto_unittest_params *ut_params = &unittest_params;
9598 if (MD5_HMAC_create_session(ts_params, ut_params,
9599 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9603 /* Generate Crypto op data structure */
9604 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9605 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9606 TEST_ASSERT_NOT_NULL(ut_params->op,
9607 "Failed to allocate symmetric crypto operation struct");
9609 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9612 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9613 ut_params->op), "failed to process sym crypto op");
9615 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9616 "HMAC_MD5 crypto op processing failed");
9618 return TEST_SUCCESS;
9622 test_MD5_HMAC_generate_case_1(void)
9624 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9628 test_MD5_HMAC_verify_case_1(void)
9630 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9634 test_MD5_HMAC_generate_case_2(void)
9636 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9640 test_MD5_HMAC_verify_case_2(void)
9642 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9646 test_multi_session(void)
9648 struct crypto_testsuite_params *ts_params = &testsuite_params;
9649 struct crypto_unittest_params *ut_params = &unittest_params;
9651 struct rte_cryptodev_info dev_info;
9652 struct rte_cryptodev_sym_session **sessions;
9656 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9657 aes_cbc_key, hmac_sha512_key);
9660 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9662 sessions = rte_malloc(NULL,
9663 (sizeof(struct rte_cryptodev_sym_session *) *
9664 MAX_NB_SESSIONS) + 1, 0);
9666 /* Create multiple crypto sessions*/
9667 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9669 sessions[i] = rte_cryptodev_sym_session_create(
9670 ts_params->session_mpool);
9672 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9673 sessions[i], &ut_params->auth_xform,
9674 ts_params->session_priv_mpool);
9675 TEST_ASSERT_NOT_NULL(sessions[i],
9676 "Session creation failed at session number %u",
9679 /* Attempt to send a request on each session */
9680 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9684 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9685 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9687 "Failed to perform decrypt on request number %u.", i);
9688 /* free crypto operation structure */
9690 rte_crypto_op_free(ut_params->op);
9693 * free mbuf - both obuf and ibuf are usually the same,
9694 * so check if they point at the same address is necessary,
9695 * to avoid freeing the mbuf twice.
9697 if (ut_params->obuf) {
9698 rte_pktmbuf_free(ut_params->obuf);
9699 if (ut_params->ibuf == ut_params->obuf)
9700 ut_params->ibuf = 0;
9701 ut_params->obuf = 0;
9703 if (ut_params->ibuf) {
9704 rte_pktmbuf_free(ut_params->ibuf);
9705 ut_params->ibuf = 0;
9709 /* Next session create should fail */
9710 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9711 sessions[i], &ut_params->auth_xform,
9712 ts_params->session_priv_mpool);
9713 TEST_ASSERT_NULL(sessions[i],
9714 "Session creation succeeded unexpectedly!");
9716 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9717 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9719 rte_cryptodev_sym_session_free(sessions[i]);
9724 return TEST_SUCCESS;
9727 struct multi_session_params {
9728 struct crypto_unittest_params ut_params;
9729 uint8_t *cipher_key;
9731 const uint8_t *cipher;
9732 const uint8_t *digest;
9736 #define MB_SESSION_NUMBER 3
9739 test_multi_session_random_usage(void)
9741 struct crypto_testsuite_params *ts_params = &testsuite_params;
9742 struct rte_cryptodev_info dev_info;
9743 struct rte_cryptodev_sym_session **sessions;
9745 struct multi_session_params ut_paramz[] = {
9748 .cipher_key = ms_aes_cbc_key0,
9749 .hmac_key = ms_hmac_key0,
9750 .cipher = ms_aes_cbc_cipher0,
9751 .digest = ms_hmac_digest0,
9752 .iv = ms_aes_cbc_iv0
9755 .cipher_key = ms_aes_cbc_key1,
9756 .hmac_key = ms_hmac_key1,
9757 .cipher = ms_aes_cbc_cipher1,
9758 .digest = ms_hmac_digest1,
9759 .iv = ms_aes_cbc_iv1
9762 .cipher_key = ms_aes_cbc_key2,
9763 .hmac_key = ms_hmac_key2,
9764 .cipher = ms_aes_cbc_cipher2,
9765 .digest = ms_hmac_digest2,
9766 .iv = ms_aes_cbc_iv2
9771 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9773 sessions = rte_malloc(NULL,
9774 (sizeof(struct rte_cryptodev_sym_session *)
9775 * MAX_NB_SESSIONS) + 1, 0);
9777 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9778 sessions[i] = rte_cryptodev_sym_session_create(
9779 ts_params->session_mpool);
9781 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9782 sizeof(struct crypto_unittest_params));
9784 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9785 &ut_paramz[i].ut_params,
9786 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9788 /* Create multiple crypto sessions*/
9789 rte_cryptodev_sym_session_init(
9790 ts_params->valid_devs[0],
9792 &ut_paramz[i].ut_params.auth_xform,
9793 ts_params->session_priv_mpool);
9795 TEST_ASSERT_NOT_NULL(sessions[i],
9796 "Session creation failed at session number %u",
9802 for (i = 0; i < 40000; i++) {
9804 j = rand() % MB_SESSION_NUMBER;
9806 TEST_ASSERT_SUCCESS(
9807 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9809 &ut_paramz[j].ut_params,
9810 ts_params, ut_paramz[j].cipher,
9811 ut_paramz[j].digest,
9813 "Failed to perform decrypt on request number %u.", i);
9815 if (ut_paramz[j].ut_params.op)
9816 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9819 * free mbuf - both obuf and ibuf are usually the same,
9820 * so check if they point at the same address is necessary,
9821 * to avoid freeing the mbuf twice.
9823 if (ut_paramz[j].ut_params.obuf) {
9824 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9825 if (ut_paramz[j].ut_params.ibuf
9826 == ut_paramz[j].ut_params.obuf)
9827 ut_paramz[j].ut_params.ibuf = 0;
9828 ut_paramz[j].ut_params.obuf = 0;
9830 if (ut_paramz[j].ut_params.ibuf) {
9831 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9832 ut_paramz[j].ut_params.ibuf = 0;
9836 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9837 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9839 rte_cryptodev_sym_session_free(sessions[i]);
9844 return TEST_SUCCESS;
9848 test_null_cipher_only_operation(void)
9850 struct crypto_testsuite_params *ts_params = &testsuite_params;
9851 struct crypto_unittest_params *ut_params = &unittest_params;
9853 /* Generate test mbuf data and space for digest */
9854 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9855 catch_22_quote, QUOTE_512_BYTES, 0);
9857 /* Setup Cipher Parameters */
9858 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9859 ut_params->cipher_xform.next = NULL;
9861 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9862 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9864 ut_params->sess = rte_cryptodev_sym_session_create(
9865 ts_params->session_mpool);
9867 /* Create Crypto session*/
9868 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9870 &ut_params->cipher_xform,
9871 ts_params->session_priv_mpool);
9872 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9874 /* Generate Crypto op data structure */
9875 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9876 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9877 TEST_ASSERT_NOT_NULL(ut_params->op,
9878 "Failed to allocate symmetric crypto operation struct");
9880 /* Set crypto operation data parameters */
9881 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9883 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9885 /* set crypto operation source mbuf */
9886 sym_op->m_src = ut_params->ibuf;
9888 sym_op->cipher.data.offset = 0;
9889 sym_op->cipher.data.length = QUOTE_512_BYTES;
9891 /* Process crypto operation */
9892 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9894 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9896 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9897 "crypto operation processing failed");
9900 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9901 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9904 "Ciphertext data not as expected");
9906 return TEST_SUCCESS;
9908 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9909 0xab, 0xab, 0xab, 0xab,
9910 0xab, 0xab, 0xab, 0xab,
9911 0xab, 0xab, 0xab, 0xab};
9913 test_null_auth_only_operation(void)
9915 struct crypto_testsuite_params *ts_params = &testsuite_params;
9916 struct crypto_unittest_params *ut_params = &unittest_params;
9919 /* Generate test mbuf data and space for digest */
9920 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9921 catch_22_quote, QUOTE_512_BYTES, 0);
9923 /* create a pointer for digest, but don't expect anything to be written
9924 * here in a NULL auth algo so no mbuf append done.
9926 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9928 /* prefill the memory pointed to by digest */
9929 memcpy(digest, orig_data, sizeof(orig_data));
9931 /* Setup HMAC Parameters */
9932 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9933 ut_params->auth_xform.next = NULL;
9935 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9936 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9938 ut_params->sess = rte_cryptodev_sym_session_create(
9939 ts_params->session_mpool);
9941 /* Create Crypto session*/
9942 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9943 ut_params->sess, &ut_params->auth_xform,
9944 ts_params->session_priv_mpool);
9945 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9947 /* Generate Crypto op data structure */
9948 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9949 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9950 TEST_ASSERT_NOT_NULL(ut_params->op,
9951 "Failed to allocate symmetric crypto operation struct");
9953 /* Set crypto operation data parameters */
9954 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9956 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9958 sym_op->m_src = ut_params->ibuf;
9960 sym_op->auth.data.offset = 0;
9961 sym_op->auth.data.length = QUOTE_512_BYTES;
9962 sym_op->auth.digest.data = digest;
9963 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9966 /* Process crypto operation */
9967 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9969 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9971 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9972 "crypto operation processing failed");
9973 /* Make sure memory pointed to by digest hasn't been overwritten */
9974 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9978 "Memory at digest ptr overwritten unexpectedly");
9980 return TEST_SUCCESS;
9985 test_null_cipher_auth_operation(void)
9987 struct crypto_testsuite_params *ts_params = &testsuite_params;
9988 struct crypto_unittest_params *ut_params = &unittest_params;
9991 /* Generate test mbuf data and space for digest */
9992 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9993 catch_22_quote, QUOTE_512_BYTES, 0);
9995 /* create a pointer for digest, but don't expect anything to be written
9996 * here in a NULL auth algo so no mbuf append done.
9998 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10000 /* prefill the memory pointed to by digest */
10001 memcpy(digest, orig_data, sizeof(orig_data));
10003 /* Setup Cipher Parameters */
10004 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10005 ut_params->cipher_xform.next = &ut_params->auth_xform;
10007 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10008 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10010 /* Setup HMAC Parameters */
10011 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10012 ut_params->auth_xform.next = NULL;
10014 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10015 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10017 ut_params->sess = rte_cryptodev_sym_session_create(
10018 ts_params->session_mpool);
10020 /* Create Crypto session*/
10021 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10022 ut_params->sess, &ut_params->cipher_xform,
10023 ts_params->session_priv_mpool);
10024 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10026 /* Generate Crypto op data structure */
10027 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10028 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10029 TEST_ASSERT_NOT_NULL(ut_params->op,
10030 "Failed to allocate symmetric crypto operation struct");
10032 /* Set crypto operation data parameters */
10033 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10035 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10037 sym_op->m_src = ut_params->ibuf;
10039 sym_op->cipher.data.offset = 0;
10040 sym_op->cipher.data.length = QUOTE_512_BYTES;
10042 sym_op->auth.data.offset = 0;
10043 sym_op->auth.data.length = QUOTE_512_BYTES;
10044 sym_op->auth.digest.data = digest;
10045 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10048 /* Process crypto operation */
10049 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10051 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10053 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10054 "crypto operation processing failed");
10056 /* Validate obuf */
10057 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10058 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10061 "Ciphertext data not as expected");
10062 /* Make sure memory pointed to by digest hasn't been overwritten */
10063 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10067 "Memory at digest ptr overwritten unexpectedly");
10069 return TEST_SUCCESS;
10073 test_null_auth_cipher_operation(void)
10075 struct crypto_testsuite_params *ts_params = &testsuite_params;
10076 struct crypto_unittest_params *ut_params = &unittest_params;
10079 /* Generate test mbuf data */
10080 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
10081 catch_22_quote, QUOTE_512_BYTES, 0);
10083 /* create a pointer for digest, but don't expect anything to be written
10084 * here in a NULL auth algo so no mbuf append done.
10086 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10088 /* prefill the memory pointed to by digest */
10089 memcpy(digest, orig_data, sizeof(orig_data));
10091 /* Setup Cipher Parameters */
10092 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10093 ut_params->cipher_xform.next = NULL;
10095 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10096 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10098 /* Setup HMAC Parameters */
10099 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10100 ut_params->auth_xform.next = &ut_params->cipher_xform;
10102 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10103 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10105 ut_params->sess = rte_cryptodev_sym_session_create(
10106 ts_params->session_mpool);
10108 /* Create Crypto session*/
10109 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10110 ut_params->sess, &ut_params->cipher_xform,
10111 ts_params->session_priv_mpool);
10112 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10114 /* Generate Crypto op data structure */
10115 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10116 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10117 TEST_ASSERT_NOT_NULL(ut_params->op,
10118 "Failed to allocate symmetric crypto operation struct");
10120 /* Set crypto operation data parameters */
10121 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10123 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10125 sym_op->m_src = ut_params->ibuf;
10127 sym_op->cipher.data.offset = 0;
10128 sym_op->cipher.data.length = QUOTE_512_BYTES;
10130 sym_op->auth.data.offset = 0;
10131 sym_op->auth.data.length = QUOTE_512_BYTES;
10132 sym_op->auth.digest.data = digest;
10133 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10136 /* Process crypto operation */
10137 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10139 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10141 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10142 "crypto operation processing failed");
10144 /* Validate obuf */
10145 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10146 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10149 "Ciphertext data not as expected");
10150 /* Make sure memory pointed to by digest hasn't been overwritten */
10151 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10155 "Memory at digest ptr overwritten unexpectedly");
10157 return TEST_SUCCESS;
10162 test_null_invalid_operation(void)
10164 struct crypto_testsuite_params *ts_params = &testsuite_params;
10165 struct crypto_unittest_params *ut_params = &unittest_params;
10168 /* Setup Cipher Parameters */
10169 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10170 ut_params->cipher_xform.next = NULL;
10172 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10173 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10175 ut_params->sess = rte_cryptodev_sym_session_create(
10176 ts_params->session_mpool);
10178 /* Create Crypto session*/
10179 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10180 ut_params->sess, &ut_params->cipher_xform,
10181 ts_params->session_priv_mpool);
10182 TEST_ASSERT(ret < 0,
10183 "Session creation succeeded unexpectedly");
10186 /* Setup HMAC Parameters */
10187 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10188 ut_params->auth_xform.next = NULL;
10190 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10191 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10193 ut_params->sess = rte_cryptodev_sym_session_create(
10194 ts_params->session_mpool);
10196 /* Create Crypto session*/
10197 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10198 ut_params->sess, &ut_params->auth_xform,
10199 ts_params->session_priv_mpool);
10200 TEST_ASSERT(ret < 0,
10201 "Session creation succeeded unexpectedly");
10203 return TEST_SUCCESS;
10207 #define NULL_BURST_LENGTH (32)
10210 test_null_burst_operation(void)
10212 struct crypto_testsuite_params *ts_params = &testsuite_params;
10213 struct crypto_unittest_params *ut_params = &unittest_params;
10215 unsigned i, burst_len = NULL_BURST_LENGTH;
10217 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10218 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10220 /* Setup Cipher Parameters */
10221 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10222 ut_params->cipher_xform.next = &ut_params->auth_xform;
10224 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10225 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10227 /* Setup HMAC Parameters */
10228 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10229 ut_params->auth_xform.next = NULL;
10231 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10232 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10234 ut_params->sess = rte_cryptodev_sym_session_create(
10235 ts_params->session_mpool);
10237 /* Create Crypto session*/
10238 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10239 ut_params->sess, &ut_params->cipher_xform,
10240 ts_params->session_priv_mpool);
10241 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10243 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10244 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10245 burst_len, "failed to generate burst of crypto ops");
10247 /* Generate an operation for each mbuf in burst */
10248 for (i = 0; i < burst_len; i++) {
10249 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10251 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10253 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10257 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10259 burst[i]->sym->m_src = m;
10262 /* Process crypto operation */
10263 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10264 0, burst, burst_len),
10266 "Error enqueuing burst");
10268 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10269 0, burst_dequeued, burst_len),
10271 "Error dequeuing burst");
10274 for (i = 0; i < burst_len; i++) {
10276 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10277 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10279 "data not as expected");
10281 rte_pktmbuf_free(burst[i]->sym->m_src);
10282 rte_crypto_op_free(burst[i]);
10285 return TEST_SUCCESS;
10289 generate_gmac_large_plaintext(uint8_t *data)
10293 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10294 memcpy(&data[i], &data[0], 32);
10298 create_gmac_operation(enum rte_crypto_auth_operation op,
10299 const struct gmac_test_data *tdata)
10301 struct crypto_testsuite_params *ts_params = &testsuite_params;
10302 struct crypto_unittest_params *ut_params = &unittest_params;
10303 struct rte_crypto_sym_op *sym_op;
10305 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10307 /* Generate Crypto op data structure */
10308 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10309 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10310 TEST_ASSERT_NOT_NULL(ut_params->op,
10311 "Failed to allocate symmetric crypto operation struct");
10313 sym_op = ut_params->op->sym;
10315 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10316 ut_params->ibuf, tdata->gmac_tag.len);
10317 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10318 "no room to append digest");
10320 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10321 ut_params->ibuf, plaintext_pad_len);
10323 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10324 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10325 tdata->gmac_tag.len);
10326 debug_hexdump(stdout, "digest:",
10327 sym_op->auth.digest.data,
10328 tdata->gmac_tag.len);
10331 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10332 uint8_t *, IV_OFFSET);
10334 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10336 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10338 sym_op->cipher.data.length = 0;
10339 sym_op->cipher.data.offset = 0;
10341 sym_op->auth.data.offset = 0;
10342 sym_op->auth.data.length = tdata->plaintext.len;
10347 static int create_gmac_session(uint8_t dev_id,
10348 const struct gmac_test_data *tdata,
10349 enum rte_crypto_auth_operation auth_op)
10351 uint8_t auth_key[tdata->key.len];
10353 struct crypto_testsuite_params *ts_params = &testsuite_params;
10354 struct crypto_unittest_params *ut_params = &unittest_params;
10356 memcpy(auth_key, tdata->key.data, tdata->key.len);
10358 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10359 ut_params->auth_xform.next = NULL;
10361 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10362 ut_params->auth_xform.auth.op = auth_op;
10363 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10364 ut_params->auth_xform.auth.key.length = tdata->key.len;
10365 ut_params->auth_xform.auth.key.data = auth_key;
10366 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10367 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10370 ut_params->sess = rte_cryptodev_sym_session_create(
10371 ts_params->session_mpool);
10373 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10374 &ut_params->auth_xform,
10375 ts_params->session_priv_mpool);
10377 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10383 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10385 struct crypto_testsuite_params *ts_params = &testsuite_params;
10386 struct crypto_unittest_params *ut_params = &unittest_params;
10390 uint8_t *auth_tag, *plaintext;
10391 uint16_t plaintext_pad_len;
10393 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10394 "No GMAC length in the source data");
10396 retval = create_gmac_session(ts_params->valid_devs[0],
10397 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10402 if (tdata->plaintext.len > MBUF_SIZE)
10403 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10405 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10406 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10407 "Failed to allocate input buffer in mempool");
10409 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10410 rte_pktmbuf_tailroom(ut_params->ibuf));
10412 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10414 * Runtime generate the large plain text instead of use hard code
10415 * plain text vector. It is done to avoid create huge source file
10416 * with the test vector.
10418 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10419 generate_gmac_large_plaintext(tdata->plaintext.data);
10421 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10422 plaintext_pad_len);
10423 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10425 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10426 debug_hexdump(stdout, "plaintext:", plaintext,
10427 tdata->plaintext.len);
10429 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10435 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10437 ut_params->op->sym->m_src = ut_params->ibuf;
10439 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10440 ut_params->op), "failed to process sym crypto op");
10442 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10443 "crypto op processing failed");
10445 if (ut_params->op->sym->m_dst) {
10446 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10447 uint8_t *, plaintext_pad_len);
10449 auth_tag = plaintext + plaintext_pad_len;
10452 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10454 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10456 tdata->gmac_tag.data,
10457 tdata->gmac_tag.len,
10458 "GMAC Generated auth tag not as expected");
10464 test_AES_GMAC_authentication_test_case_1(void)
10466 return test_AES_GMAC_authentication(&gmac_test_case_1);
10470 test_AES_GMAC_authentication_test_case_2(void)
10472 return test_AES_GMAC_authentication(&gmac_test_case_2);
10476 test_AES_GMAC_authentication_test_case_3(void)
10478 return test_AES_GMAC_authentication(&gmac_test_case_3);
10482 test_AES_GMAC_authentication_test_case_4(void)
10484 return test_AES_GMAC_authentication(&gmac_test_case_4);
10488 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10490 struct crypto_testsuite_params *ts_params = &testsuite_params;
10491 struct crypto_unittest_params *ut_params = &unittest_params;
10493 uint32_t plaintext_pad_len;
10494 uint8_t *plaintext;
10496 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10497 "No GMAC length in the source data");
10499 retval = create_gmac_session(ts_params->valid_devs[0],
10500 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10505 if (tdata->plaintext.len > MBUF_SIZE)
10506 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10508 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10509 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10510 "Failed to allocate input buffer in mempool");
10512 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10513 rte_pktmbuf_tailroom(ut_params->ibuf));
10515 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10518 * Runtime generate the large plain text instead of use hard code
10519 * plain text vector. It is done to avoid create huge source file
10520 * with the test vector.
10522 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10523 generate_gmac_large_plaintext(tdata->plaintext.data);
10525 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10526 plaintext_pad_len);
10527 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10529 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10530 debug_hexdump(stdout, "plaintext:", plaintext,
10531 tdata->plaintext.len);
10533 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10539 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10541 ut_params->op->sym->m_src = ut_params->ibuf;
10543 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10544 ut_params->op), "failed to process sym crypto op");
10546 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10547 "crypto op processing failed");
10554 test_AES_GMAC_authentication_verify_test_case_1(void)
10556 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10560 test_AES_GMAC_authentication_verify_test_case_2(void)
10562 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10566 test_AES_GMAC_authentication_verify_test_case_3(void)
10568 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10572 test_AES_GMAC_authentication_verify_test_case_4(void)
10574 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10577 struct test_crypto_vector {
10578 enum rte_crypto_cipher_algorithm crypto_algo;
10579 unsigned int cipher_offset;
10580 unsigned int cipher_len;
10593 const uint8_t *data;
10598 const uint8_t *data;
10602 enum rte_crypto_auth_algorithm auth_algo;
10603 unsigned int auth_offset;
10611 const uint8_t *data;
10621 static const struct test_crypto_vector
10622 hmac_sha1_test_crypto_vector = {
10623 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10625 .data = plaintext_hash,
10630 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10631 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10632 0xDE, 0xF4, 0xDE, 0xAD
10638 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10639 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10640 0x3F, 0x91, 0x64, 0x59
10646 static const struct test_crypto_vector
10647 aes128_gmac_test_vector = {
10648 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10650 .data = plaintext_hash,
10655 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10656 0x08, 0x09, 0x0A, 0x0B
10662 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10663 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10669 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10670 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10676 static const struct test_crypto_vector
10677 aes128cbc_hmac_sha1_test_vector = {
10678 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10679 .cipher_offset = 0,
10683 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10684 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10690 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10691 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10696 .data = plaintext_hash,
10700 .data = ciphertext512_aes128cbc,
10703 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10707 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10708 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10709 0xDE, 0xF4, 0xDE, 0xAD
10715 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10716 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10717 0x18, 0x8C, 0x1D, 0x32
10723 static const struct test_crypto_vector
10724 aes128cbc_hmac_sha1_aad_test_vector = {
10725 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10726 .cipher_offset = 12,
10730 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10731 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10737 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10738 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10743 .data = plaintext_hash,
10747 .data = ciphertext512_aes128cbc_aad,
10750 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10754 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10755 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10756 0xDE, 0xF4, 0xDE, 0xAD
10762 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10763 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10764 0x62, 0x8D, 0x62, 0x65
10771 data_corruption(uint8_t *data)
10777 tag_corruption(uint8_t *data, unsigned int tag_offset)
10779 data[tag_offset] += 1;
10783 create_auth_session(struct crypto_unittest_params *ut_params,
10785 const struct test_crypto_vector *reference,
10786 enum rte_crypto_auth_operation auth_op)
10788 struct crypto_testsuite_params *ts_params = &testsuite_params;
10789 uint8_t auth_key[reference->auth_key.len + 1];
10791 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10793 /* Setup Authentication Parameters */
10794 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10795 ut_params->auth_xform.auth.op = auth_op;
10796 ut_params->auth_xform.next = NULL;
10797 ut_params->auth_xform.auth.algo = reference->auth_algo;
10798 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10799 ut_params->auth_xform.auth.key.data = auth_key;
10800 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10802 /* Create Crypto session*/
10803 ut_params->sess = rte_cryptodev_sym_session_create(
10804 ts_params->session_mpool);
10806 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10807 &ut_params->auth_xform,
10808 ts_params->session_priv_mpool);
10810 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10816 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10818 const struct test_crypto_vector *reference,
10819 enum rte_crypto_auth_operation auth_op,
10820 enum rte_crypto_cipher_operation cipher_op)
10822 struct crypto_testsuite_params *ts_params = &testsuite_params;
10823 uint8_t cipher_key[reference->cipher_key.len + 1];
10824 uint8_t auth_key[reference->auth_key.len + 1];
10826 memcpy(cipher_key, reference->cipher_key.data,
10827 reference->cipher_key.len);
10828 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10830 /* Setup Authentication Parameters */
10831 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10832 ut_params->auth_xform.auth.op = auth_op;
10833 ut_params->auth_xform.auth.algo = reference->auth_algo;
10834 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10835 ut_params->auth_xform.auth.key.data = auth_key;
10836 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10838 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10839 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10840 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10842 ut_params->auth_xform.next = &ut_params->cipher_xform;
10844 /* Setup Cipher Parameters */
10845 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10846 ut_params->cipher_xform.next = NULL;
10847 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10848 ut_params->cipher_xform.cipher.op = cipher_op;
10849 ut_params->cipher_xform.cipher.key.data = cipher_key;
10850 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10851 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10852 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10855 /* Create Crypto session*/
10856 ut_params->sess = rte_cryptodev_sym_session_create(
10857 ts_params->session_mpool);
10859 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10860 &ut_params->auth_xform,
10861 ts_params->session_priv_mpool);
10863 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10869 create_auth_operation(struct crypto_testsuite_params *ts_params,
10870 struct crypto_unittest_params *ut_params,
10871 const struct test_crypto_vector *reference,
10872 unsigned int auth_generate)
10874 /* Generate Crypto op data structure */
10875 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10876 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10877 TEST_ASSERT_NOT_NULL(ut_params->op,
10878 "Failed to allocate pktmbuf offload");
10880 /* Set crypto operation data parameters */
10881 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10883 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10885 /* set crypto operation source mbuf */
10886 sym_op->m_src = ut_params->ibuf;
10889 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10890 ut_params->ibuf, reference->digest.len);
10892 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10893 "no room to append auth tag");
10895 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10896 ut_params->ibuf, reference->plaintext.len);
10899 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10901 memcpy(sym_op->auth.digest.data,
10902 reference->digest.data,
10903 reference->digest.len);
10905 debug_hexdump(stdout, "digest:",
10906 sym_op->auth.digest.data,
10907 reference->digest.len);
10909 sym_op->auth.data.length = reference->plaintext.len;
10910 sym_op->auth.data.offset = 0;
10916 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10917 struct crypto_unittest_params *ut_params,
10918 const struct test_crypto_vector *reference,
10919 unsigned int auth_generate)
10921 /* Generate Crypto op data structure */
10922 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10923 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10924 TEST_ASSERT_NOT_NULL(ut_params->op,
10925 "Failed to allocate pktmbuf offload");
10927 /* Set crypto operation data parameters */
10928 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10930 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10932 /* set crypto operation source mbuf */
10933 sym_op->m_src = ut_params->ibuf;
10936 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10937 ut_params->ibuf, reference->digest.len);
10939 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10940 "no room to append auth tag");
10942 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10943 ut_params->ibuf, reference->ciphertext.len);
10946 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10948 memcpy(sym_op->auth.digest.data,
10949 reference->digest.data,
10950 reference->digest.len);
10952 debug_hexdump(stdout, "digest:",
10953 sym_op->auth.digest.data,
10954 reference->digest.len);
10956 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10957 reference->iv.data, reference->iv.len);
10959 sym_op->cipher.data.length = 0;
10960 sym_op->cipher.data.offset = 0;
10962 sym_op->auth.data.length = reference->plaintext.len;
10963 sym_op->auth.data.offset = 0;
10969 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10970 struct crypto_unittest_params *ut_params,
10971 const struct test_crypto_vector *reference,
10972 unsigned int auth_generate)
10974 /* Generate Crypto op data structure */
10975 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10976 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10977 TEST_ASSERT_NOT_NULL(ut_params->op,
10978 "Failed to allocate pktmbuf offload");
10980 /* Set crypto operation data parameters */
10981 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10983 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10985 /* set crypto operation source mbuf */
10986 sym_op->m_src = ut_params->ibuf;
10989 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10990 ut_params->ibuf, reference->digest.len);
10992 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10993 "no room to append auth tag");
10995 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10996 ut_params->ibuf, reference->ciphertext.len);
10999 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11001 memcpy(sym_op->auth.digest.data,
11002 reference->digest.data,
11003 reference->digest.len);
11005 debug_hexdump(stdout, "digest:",
11006 sym_op->auth.digest.data,
11007 reference->digest.len);
11009 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11010 reference->iv.data, reference->iv.len);
11012 sym_op->cipher.data.length = reference->cipher_len;
11013 sym_op->cipher.data.offset = reference->cipher_offset;
11015 sym_op->auth.data.length = reference->plaintext.len;
11016 sym_op->auth.data.offset = reference->auth_offset;
11022 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11023 struct crypto_unittest_params *ut_params,
11024 const struct test_crypto_vector *reference)
11026 return create_auth_operation(ts_params, ut_params, reference, 0);
11030 create_auth_verify_GMAC_operation(
11031 struct crypto_testsuite_params *ts_params,
11032 struct crypto_unittest_params *ut_params,
11033 const struct test_crypto_vector *reference)
11035 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11039 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11040 struct crypto_unittest_params *ut_params,
11041 const struct test_crypto_vector *reference)
11043 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11047 test_authentication_verify_fail_when_data_corruption(
11048 struct crypto_testsuite_params *ts_params,
11049 struct crypto_unittest_params *ut_params,
11050 const struct test_crypto_vector *reference,
11051 unsigned int data_corrupted)
11055 uint8_t *plaintext;
11057 /* Create session */
11058 retval = create_auth_session(ut_params,
11059 ts_params->valid_devs[0],
11061 RTE_CRYPTO_AUTH_OP_VERIFY);
11065 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11066 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11067 "Failed to allocate input buffer in mempool");
11069 /* clear mbuf payload */
11070 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11071 rte_pktmbuf_tailroom(ut_params->ibuf));
11073 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11074 reference->plaintext.len);
11075 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11076 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11078 debug_hexdump(stdout, "plaintext:", plaintext,
11079 reference->plaintext.len);
11081 /* Create operation */
11082 retval = create_auth_verify_operation(ts_params, ut_params, reference);
11087 if (data_corrupted)
11088 data_corruption(plaintext);
11090 tag_corruption(plaintext, reference->plaintext.len);
11092 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11095 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11101 test_authentication_verify_GMAC_fail_when_corruption(
11102 struct crypto_testsuite_params *ts_params,
11103 struct crypto_unittest_params *ut_params,
11104 const struct test_crypto_vector *reference,
11105 unsigned int data_corrupted)
11108 uint8_t *plaintext;
11110 /* Create session */
11111 retval = create_auth_cipher_session(ut_params,
11112 ts_params->valid_devs[0],
11114 RTE_CRYPTO_AUTH_OP_VERIFY,
11115 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11119 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11120 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11121 "Failed to allocate input buffer in mempool");
11123 /* clear mbuf payload */
11124 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11125 rte_pktmbuf_tailroom(ut_params->ibuf));
11127 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11128 reference->plaintext.len);
11129 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11130 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11132 debug_hexdump(stdout, "plaintext:", plaintext,
11133 reference->plaintext.len);
11135 /* Create operation */
11136 retval = create_auth_verify_GMAC_operation(ts_params,
11143 if (data_corrupted)
11144 data_corruption(plaintext);
11146 tag_corruption(plaintext, reference->aad.len);
11148 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11151 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11157 test_authenticated_decryption_fail_when_corruption(
11158 struct crypto_testsuite_params *ts_params,
11159 struct crypto_unittest_params *ut_params,
11160 const struct test_crypto_vector *reference,
11161 unsigned int data_corrupted)
11165 uint8_t *ciphertext;
11167 /* Create session */
11168 retval = create_auth_cipher_session(ut_params,
11169 ts_params->valid_devs[0],
11171 RTE_CRYPTO_AUTH_OP_VERIFY,
11172 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11176 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11177 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11178 "Failed to allocate input buffer in mempool");
11180 /* clear mbuf payload */
11181 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11182 rte_pktmbuf_tailroom(ut_params->ibuf));
11184 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11185 reference->ciphertext.len);
11186 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11187 memcpy(ciphertext, reference->ciphertext.data,
11188 reference->ciphertext.len);
11190 /* Create operation */
11191 retval = create_cipher_auth_verify_operation(ts_params,
11198 if (data_corrupted)
11199 data_corruption(ciphertext);
11201 tag_corruption(ciphertext, reference->ciphertext.len);
11203 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11206 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11212 test_authenticated_encryt_with_esn(
11213 struct crypto_testsuite_params *ts_params,
11214 struct crypto_unittest_params *ut_params,
11215 const struct test_crypto_vector *reference)
11219 uint8_t *authciphertext, *plaintext, *auth_tag;
11220 uint16_t plaintext_pad_len;
11221 uint8_t cipher_key[reference->cipher_key.len + 1];
11222 uint8_t auth_key[reference->auth_key.len + 1];
11224 /* Create session */
11225 memcpy(cipher_key, reference->cipher_key.data,
11226 reference->cipher_key.len);
11227 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11229 /* Setup Cipher Parameters */
11230 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11231 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11232 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11233 ut_params->cipher_xform.cipher.key.data = cipher_key;
11234 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11235 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11236 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11238 ut_params->cipher_xform.next = &ut_params->auth_xform;
11240 /* Setup Authentication Parameters */
11241 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11242 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11243 ut_params->auth_xform.auth.algo = reference->auth_algo;
11244 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11245 ut_params->auth_xform.auth.key.data = auth_key;
11246 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11247 ut_params->auth_xform.next = NULL;
11249 /* Create Crypto session*/
11250 ut_params->sess = rte_cryptodev_sym_session_create(
11251 ts_params->session_mpool);
11253 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11255 &ut_params->cipher_xform,
11256 ts_params->session_priv_mpool);
11258 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11260 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11261 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11262 "Failed to allocate input buffer in mempool");
11264 /* clear mbuf payload */
11265 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11266 rte_pktmbuf_tailroom(ut_params->ibuf));
11268 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11269 reference->plaintext.len);
11270 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11271 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11273 /* Create operation */
11274 retval = create_cipher_auth_operation(ts_params,
11281 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11284 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11286 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11287 "crypto op processing failed");
11289 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11291 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11292 ut_params->op->sym->auth.data.offset);
11293 auth_tag = authciphertext + plaintext_pad_len;
11294 debug_hexdump(stdout, "ciphertext:", authciphertext,
11295 reference->ciphertext.len);
11296 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11298 /* Validate obuf */
11299 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11301 reference->ciphertext.data,
11302 reference->ciphertext.len,
11303 "Ciphertext data not as expected");
11305 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11307 reference->digest.data,
11308 reference->digest.len,
11309 "Generated digest not as expected");
11311 return TEST_SUCCESS;
11316 test_authenticated_decrypt_with_esn(
11317 struct crypto_testsuite_params *ts_params,
11318 struct crypto_unittest_params *ut_params,
11319 const struct test_crypto_vector *reference)
11323 uint8_t *ciphertext;
11324 uint8_t cipher_key[reference->cipher_key.len + 1];
11325 uint8_t auth_key[reference->auth_key.len + 1];
11327 /* Create session */
11328 memcpy(cipher_key, reference->cipher_key.data,
11329 reference->cipher_key.len);
11330 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11332 /* Setup Authentication Parameters */
11333 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11334 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11335 ut_params->auth_xform.auth.algo = reference->auth_algo;
11336 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11337 ut_params->auth_xform.auth.key.data = auth_key;
11338 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11339 ut_params->auth_xform.next = &ut_params->cipher_xform;
11341 /* Setup Cipher Parameters */
11342 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11343 ut_params->cipher_xform.next = NULL;
11344 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11345 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11346 ut_params->cipher_xform.cipher.key.data = cipher_key;
11347 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11348 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11349 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11351 /* Create Crypto session*/
11352 ut_params->sess = rte_cryptodev_sym_session_create(
11353 ts_params->session_mpool);
11355 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11357 &ut_params->auth_xform,
11358 ts_params->session_priv_mpool);
11360 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11362 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11363 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11364 "Failed to allocate input buffer in mempool");
11366 /* clear mbuf payload */
11367 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11368 rte_pktmbuf_tailroom(ut_params->ibuf));
11370 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11371 reference->ciphertext.len);
11372 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11373 memcpy(ciphertext, reference->ciphertext.data,
11374 reference->ciphertext.len);
11376 /* Create operation */
11377 retval = create_cipher_auth_verify_operation(ts_params,
11384 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11387 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11388 TEST_ASSERT_EQUAL(ut_params->op->status,
11389 RTE_CRYPTO_OP_STATUS_SUCCESS,
11390 "crypto op processing passed");
11392 ut_params->obuf = ut_params->op->sym->m_src;
11393 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11399 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11400 const struct aead_test_data *tdata,
11401 void *digest_mem, uint64_t digest_phys)
11403 struct crypto_testsuite_params *ts_params = &testsuite_params;
11404 struct crypto_unittest_params *ut_params = &unittest_params;
11406 const unsigned int auth_tag_len = tdata->auth_tag.len;
11407 const unsigned int iv_len = tdata->iv.len;
11408 unsigned int aad_len = tdata->aad.len;
11409 unsigned int aad_len_pad = 0;
11411 /* Generate Crypto op data structure */
11412 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11413 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11414 TEST_ASSERT_NOT_NULL(ut_params->op,
11415 "Failed to allocate symmetric crypto operation struct");
11417 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11419 sym_op->aead.digest.data = digest_mem;
11421 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11422 "no room to append digest");
11424 sym_op->aead.digest.phys_addr = digest_phys;
11426 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11427 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11429 debug_hexdump(stdout, "digest:",
11430 sym_op->aead.digest.data,
11434 /* Append aad data */
11435 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11436 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11437 uint8_t *, IV_OFFSET);
11439 /* Copy IV 1 byte after the IV pointer, according to the API */
11440 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11442 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11444 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11445 ut_params->ibuf, aad_len);
11446 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11447 "no room to prepend aad");
11448 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11451 memset(sym_op->aead.aad.data, 0, aad_len);
11452 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11453 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11455 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11456 debug_hexdump(stdout, "aad:",
11457 sym_op->aead.aad.data, aad_len);
11459 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11460 uint8_t *, IV_OFFSET);
11462 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11464 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11466 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11467 ut_params->ibuf, aad_len_pad);
11468 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11469 "no room to prepend aad");
11470 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11473 memset(sym_op->aead.aad.data, 0, aad_len);
11474 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11476 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11477 debug_hexdump(stdout, "aad:",
11478 sym_op->aead.aad.data, aad_len);
11481 sym_op->aead.data.length = tdata->plaintext.len;
11482 sym_op->aead.data.offset = aad_len_pad;
11487 #define SGL_MAX_NO 16
11490 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11491 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11493 struct crypto_testsuite_params *ts_params = &testsuite_params;
11494 struct crypto_unittest_params *ut_params = &unittest_params;
11495 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11498 int to_trn_tbl[SGL_MAX_NO];
11500 unsigned int trn_data = 0;
11501 uint8_t *plaintext, *ciphertext, *auth_tag;
11503 if (fragsz > tdata->plaintext.len)
11504 fragsz = tdata->plaintext.len;
11506 uint16_t plaintext_len = fragsz;
11507 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11509 if (fragsz_oop > tdata->plaintext.len)
11510 frag_size_oop = tdata->plaintext.len;
11513 void *digest_mem = NULL;
11515 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11517 if (tdata->plaintext.len % fragsz != 0) {
11518 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11521 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11526 * For out-op-place we need to alloc another mbuf
11529 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11530 rte_pktmbuf_append(ut_params->obuf,
11531 frag_size_oop + prepend_len);
11532 buf_oop = ut_params->obuf;
11535 /* Create AEAD session */
11536 retval = create_aead_session(ts_params->valid_devs[0],
11538 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11539 tdata->key.data, tdata->key.len,
11540 tdata->aad.len, tdata->auth_tag.len,
11545 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11547 /* clear mbuf payload */
11548 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11549 rte_pktmbuf_tailroom(ut_params->ibuf));
11551 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11554 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11556 trn_data += plaintext_len;
11558 buf = ut_params->ibuf;
11561 * Loop until no more fragments
11564 while (trn_data < tdata->plaintext.len) {
11566 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11567 (tdata->plaintext.len - trn_data) : fragsz;
11569 to_trn_tbl[ecx++] = to_trn;
11571 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11574 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11575 rte_pktmbuf_tailroom(buf));
11578 if (oop && !fragsz_oop) {
11579 buf_last_oop = buf_oop->next =
11580 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11581 buf_oop = buf_oop->next;
11582 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11583 0, rte_pktmbuf_tailroom(buf_oop));
11584 rte_pktmbuf_append(buf_oop, to_trn);
11587 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11590 memcpy(plaintext, tdata->plaintext.data + trn_data,
11592 trn_data += to_trn;
11593 if (trn_data == tdata->plaintext.len) {
11596 digest_mem = rte_pktmbuf_append(buf_oop,
11597 tdata->auth_tag.len);
11599 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11600 tdata->auth_tag.len);
11604 uint64_t digest_phys = 0;
11606 ut_params->ibuf->nb_segs = segs;
11609 if (fragsz_oop && oop) {
11613 if (frag_size_oop == tdata->plaintext.len) {
11614 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11615 tdata->auth_tag.len);
11617 digest_phys = rte_pktmbuf_iova_offset(
11619 tdata->plaintext.len + prepend_len);
11622 trn_data = frag_size_oop;
11623 while (trn_data < tdata->plaintext.len) {
11626 (tdata->plaintext.len - trn_data <
11628 (tdata->plaintext.len - trn_data) :
11631 to_trn_tbl[ecx++] = to_trn;
11633 buf_last_oop = buf_oop->next =
11634 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11635 buf_oop = buf_oop->next;
11636 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11637 0, rte_pktmbuf_tailroom(buf_oop));
11638 rte_pktmbuf_append(buf_oop, to_trn);
11640 trn_data += to_trn;
11642 if (trn_data == tdata->plaintext.len) {
11643 digest_mem = rte_pktmbuf_append(buf_oop,
11644 tdata->auth_tag.len);
11648 ut_params->obuf->nb_segs = segs;
11652 * Place digest at the end of the last buffer
11655 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11656 if (oop && buf_last_oop)
11657 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11659 if (!digest_mem && !oop) {
11660 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11661 + tdata->auth_tag.len);
11662 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11663 tdata->plaintext.len);
11666 /* Create AEAD operation */
11667 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11668 tdata, digest_mem, digest_phys);
11673 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11675 ut_params->op->sym->m_src = ut_params->ibuf;
11677 ut_params->op->sym->m_dst = ut_params->obuf;
11679 /* Process crypto operation */
11680 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11681 ut_params->op), "failed to process sym crypto op");
11683 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11684 "crypto op processing failed");
11687 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11688 uint8_t *, prepend_len);
11690 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11691 uint8_t *, prepend_len);
11695 fragsz = fragsz_oop;
11697 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11699 tdata->ciphertext.data,
11701 "Ciphertext data not as expected");
11703 buf = ut_params->op->sym->m_src->next;
11705 buf = ut_params->op->sym->m_dst->next;
11707 unsigned int off = fragsz;
11711 ciphertext = rte_pktmbuf_mtod(buf,
11714 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11716 tdata->ciphertext.data + off,
11718 "Ciphertext data not as expected");
11720 off += to_trn_tbl[ecx++];
11724 auth_tag = digest_mem;
11725 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11727 tdata->auth_tag.data,
11728 tdata->auth_tag.len,
11729 "Generated auth tag not as expected");
11735 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11737 return test_authenticated_encryption_SGL(
11738 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11742 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11744 return test_authenticated_encryption_SGL(
11745 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11749 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11751 return test_authenticated_encryption_SGL(
11752 &gcm_test_case_8, OUT_OF_PLACE, 400,
11753 gcm_test_case_8.plaintext.len);
11757 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11760 return test_authenticated_encryption_SGL(
11761 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11765 test_authentication_verify_fail_when_data_corrupted(
11766 struct crypto_testsuite_params *ts_params,
11767 struct crypto_unittest_params *ut_params,
11768 const struct test_crypto_vector *reference)
11770 return test_authentication_verify_fail_when_data_corruption(
11771 ts_params, ut_params, reference, 1);
11775 test_authentication_verify_fail_when_tag_corrupted(
11776 struct crypto_testsuite_params *ts_params,
11777 struct crypto_unittest_params *ut_params,
11778 const struct test_crypto_vector *reference)
11780 return test_authentication_verify_fail_when_data_corruption(
11781 ts_params, ut_params, reference, 0);
11785 test_authentication_verify_GMAC_fail_when_data_corrupted(
11786 struct crypto_testsuite_params *ts_params,
11787 struct crypto_unittest_params *ut_params,
11788 const struct test_crypto_vector *reference)
11790 return test_authentication_verify_GMAC_fail_when_corruption(
11791 ts_params, ut_params, reference, 1);
11795 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11796 struct crypto_testsuite_params *ts_params,
11797 struct crypto_unittest_params *ut_params,
11798 const struct test_crypto_vector *reference)
11800 return test_authentication_verify_GMAC_fail_when_corruption(
11801 ts_params, ut_params, reference, 0);
11805 test_authenticated_decryption_fail_when_data_corrupted(
11806 struct crypto_testsuite_params *ts_params,
11807 struct crypto_unittest_params *ut_params,
11808 const struct test_crypto_vector *reference)
11810 return test_authenticated_decryption_fail_when_corruption(
11811 ts_params, ut_params, reference, 1);
11815 test_authenticated_decryption_fail_when_tag_corrupted(
11816 struct crypto_testsuite_params *ts_params,
11817 struct crypto_unittest_params *ut_params,
11818 const struct test_crypto_vector *reference)
11820 return test_authenticated_decryption_fail_when_corruption(
11821 ts_params, ut_params, reference, 0);
11825 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11827 return test_authentication_verify_fail_when_data_corrupted(
11828 &testsuite_params, &unittest_params,
11829 &hmac_sha1_test_crypto_vector);
11833 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11835 return test_authentication_verify_fail_when_tag_corrupted(
11836 &testsuite_params, &unittest_params,
11837 &hmac_sha1_test_crypto_vector);
11841 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11843 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11844 &testsuite_params, &unittest_params,
11845 &aes128_gmac_test_vector);
11849 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11851 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11852 &testsuite_params, &unittest_params,
11853 &aes128_gmac_test_vector);
11857 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11859 return test_authenticated_decryption_fail_when_data_corrupted(
11862 &aes128cbc_hmac_sha1_test_vector);
11866 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11868 return test_authenticated_decryption_fail_when_tag_corrupted(
11871 &aes128cbc_hmac_sha1_test_vector);
11875 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11877 return test_authenticated_encryt_with_esn(
11880 &aes128cbc_hmac_sha1_aad_test_vector);
11884 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11886 return test_authenticated_decrypt_with_esn(
11889 &aes128cbc_hmac_sha1_aad_test_vector);
11892 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11894 /* global AESNI slave IDs for the scheduler test */
11895 uint8_t aesni_ids[2];
11898 test_scheduler_attach_slave_op(void)
11900 struct crypto_testsuite_params *ts_params = &testsuite_params;
11901 uint8_t sched_id = ts_params->valid_devs[0];
11902 uint32_t nb_devs, i, nb_devs_attached = 0;
11904 char vdev_name[32];
11906 /* create 2 AESNI_MB if necessary */
11907 nb_devs = rte_cryptodev_device_count_by_driver(
11908 rte_cryptodev_driver_id_get(
11909 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11911 for (i = nb_devs; i < 2; i++) {
11912 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11913 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11915 ret = rte_vdev_init(vdev_name, NULL);
11917 TEST_ASSERT(ret == 0,
11918 "Failed to create instance %u of"
11920 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11924 /* attach 2 AESNI_MB cdevs */
11925 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11927 struct rte_cryptodev_info info;
11928 unsigned int session_size;
11930 rte_cryptodev_info_get(i, &info);
11931 if (info.driver_id != rte_cryptodev_driver_id_get(
11932 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11935 session_size = rte_cryptodev_sym_get_private_session_size(i);
11937 * Create the session mempool again, since now there are new devices
11938 * to use the mempool.
11940 if (ts_params->session_mpool) {
11941 rte_mempool_free(ts_params->session_mpool);
11942 ts_params->session_mpool = NULL;
11944 if (ts_params->session_priv_mpool) {
11945 rte_mempool_free(ts_params->session_priv_mpool);
11946 ts_params->session_priv_mpool = NULL;
11949 if (info.sym.max_nb_sessions != 0 &&
11950 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11951 RTE_LOG(ERR, USER1,
11952 "Device does not support "
11953 "at least %u sessions\n",
11955 return TEST_FAILED;
11958 * Create mempool with maximum number of sessions,
11959 * to include the session headers
11961 if (ts_params->session_mpool == NULL) {
11962 ts_params->session_mpool =
11963 rte_cryptodev_sym_session_pool_create(
11965 MAX_NB_SESSIONS, 0, 0, 0,
11967 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11968 "session mempool allocation failed");
11972 * Create mempool with maximum number of sessions,
11973 * to include device specific session private data
11975 if (ts_params->session_priv_mpool == NULL) {
11976 ts_params->session_priv_mpool = rte_mempool_create(
11977 "test_sess_mp_priv",
11980 0, 0, NULL, NULL, NULL,
11981 NULL, SOCKET_ID_ANY,
11984 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11985 "session mempool allocation failed");
11988 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11989 ts_params->qp_conf.mp_session_private =
11990 ts_params->session_priv_mpool;
11992 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11995 TEST_ASSERT(ret == 0,
11996 "Failed to attach device %u of pmd : %s", i,
11997 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11999 aesni_ids[nb_devs_attached] = (uint8_t)i;
12001 nb_devs_attached++;
12008 test_scheduler_detach_slave_op(void)
12010 struct crypto_testsuite_params *ts_params = &testsuite_params;
12011 uint8_t sched_id = ts_params->valid_devs[0];
12015 for (i = 0; i < 2; i++) {
12016 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
12018 TEST_ASSERT(ret == 0,
12019 "Failed to detach device %u", aesni_ids[i]);
12026 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12028 struct crypto_testsuite_params *ts_params = &testsuite_params;
12029 uint8_t sched_id = ts_params->valid_devs[0];
12031 return rte_cryptodev_scheduler_mode_set(sched_id,
12036 test_scheduler_mode_roundrobin_op(void)
12038 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12039 0, "Failed to set roundrobin mode");
12045 test_scheduler_mode_multicore_op(void)
12047 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12048 0, "Failed to set multicore mode");
12054 test_scheduler_mode_failover_op(void)
12056 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12057 0, "Failed to set failover mode");
12063 test_scheduler_mode_pkt_size_distr_op(void)
12065 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12066 0, "Failed to set pktsize mode");
12071 static struct unit_test_suite cryptodev_scheduler_testsuite = {
12072 .suite_name = "Crypto Device Scheduler Unit Test Suite",
12073 .setup = testsuite_setup,
12074 .teardown = testsuite_teardown,
12075 .unit_test_cases = {
12077 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12078 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_AES_chain_scheduler_all),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_AES_cipheronly_scheduler_all),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_authonly_scheduler_all),
12085 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12088 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12089 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12090 TEST_CASE_ST(ut_setup, ut_teardown,
12091 test_AES_chain_scheduler_all),
12092 TEST_CASE_ST(ut_setup, ut_teardown,
12093 test_AES_cipheronly_scheduler_all),
12094 TEST_CASE_ST(ut_setup, ut_teardown,
12095 test_authonly_scheduler_all),
12096 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12099 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12100 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_AES_chain_scheduler_all),
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_AES_cipheronly_scheduler_all),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_authonly_scheduler_all),
12107 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12110 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12111 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_AES_chain_scheduler_all),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_AES_cipheronly_scheduler_all),
12116 TEST_CASE_ST(ut_setup, ut_teardown,
12117 test_authonly_scheduler_all),
12118 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12120 TEST_CASES_END() /**< NULL terminate unit test array */
12124 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12126 static struct unit_test_suite cryptodev_qat_testsuite = {
12127 .suite_name = "Crypto QAT Unit Test Suite",
12128 .setup = testsuite_setup,
12129 .teardown = testsuite_teardown,
12130 .unit_test_cases = {
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_device_configure_invalid_dev_id),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_device_configure_invalid_queue_pair_ids),
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_queue_pair_descriptor_setup),
12137 TEST_CASE_ST(ut_setup, ut_teardown,
12138 test_multi_session),
12140 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_AES_cipheronly_qat_all),
12143 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
12144 TEST_CASE_ST(ut_setup, ut_teardown,
12145 test_3DES_cipheronly_qat_all),
12146 TEST_CASE_ST(ut_setup, ut_teardown,
12147 test_DES_cipheronly_qat_all),
12148 TEST_CASE_ST(ut_setup, ut_teardown,
12149 test_AES_docsis_qat_all),
12150 TEST_CASE_ST(ut_setup, ut_teardown,
12151 test_DES_docsis_qat_all),
12152 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
12153 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12155 /** AES CCM Authenticated Encryption 128 bits key */
12156 TEST_CASE_ST(ut_setup, ut_teardown,
12157 test_AES_CCM_authenticated_encryption_test_case_128_1),
12158 TEST_CASE_ST(ut_setup, ut_teardown,
12159 test_AES_CCM_authenticated_encryption_test_case_128_2),
12160 TEST_CASE_ST(ut_setup, ut_teardown,
12161 test_AES_CCM_authenticated_encryption_test_case_128_3),
12163 /** AES CCM Authenticated Decryption 128 bits key*/
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_AES_CCM_authenticated_decryption_test_case_128_1),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_AES_CCM_authenticated_decryption_test_case_128_2),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_AES_CCM_authenticated_decryption_test_case_128_3),
12171 /** AES GCM Authenticated Encryption */
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12174 TEST_CASE_ST(ut_setup, ut_teardown,
12175 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12176 TEST_CASE_ST(ut_setup, ut_teardown,
12177 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12178 TEST_CASE_ST(ut_setup, ut_teardown,
12179 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12180 TEST_CASE_ST(ut_setup, ut_teardown,
12181 test_AES_GCM_authenticated_encryption_test_case_1),
12182 TEST_CASE_ST(ut_setup, ut_teardown,
12183 test_AES_GCM_authenticated_encryption_test_case_2),
12184 TEST_CASE_ST(ut_setup, ut_teardown,
12185 test_AES_GCM_authenticated_encryption_test_case_3),
12186 TEST_CASE_ST(ut_setup, ut_teardown,
12187 test_AES_GCM_authenticated_encryption_test_case_4),
12188 TEST_CASE_ST(ut_setup, ut_teardown,
12189 test_AES_GCM_authenticated_encryption_test_case_5),
12190 TEST_CASE_ST(ut_setup, ut_teardown,
12191 test_AES_GCM_authenticated_encryption_test_case_6),
12192 TEST_CASE_ST(ut_setup, ut_teardown,
12193 test_AES_GCM_authenticated_encryption_test_case_7),
12194 TEST_CASE_ST(ut_setup, ut_teardown,
12195 test_AES_GCM_authenticated_encryption_test_case_8),
12197 /** AES GCM Authenticated Decryption */
12198 TEST_CASE_ST(ut_setup, ut_teardown,
12199 test_AES_GCM_authenticated_decryption_test_case_1),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_AES_GCM_authenticated_decryption_test_case_2),
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_AES_GCM_authenticated_decryption_test_case_3),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_AES_GCM_authenticated_decryption_test_case_4),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_AES_GCM_authenticated_decryption_test_case_5),
12208 TEST_CASE_ST(ut_setup, ut_teardown,
12209 test_AES_GCM_authenticated_decryption_test_case_6),
12210 TEST_CASE_ST(ut_setup, ut_teardown,
12211 test_AES_GCM_authenticated_decryption_test_case_7),
12212 TEST_CASE_ST(ut_setup, ut_teardown,
12213 test_AES_GCM_authenticated_decryption_test_case_8),
12215 /** AES GCM Authenticated Encryption 192 bits key */
12216 TEST_CASE_ST(ut_setup, ut_teardown,
12217 test_AES_GCM_auth_encryption_test_case_192_1),
12218 TEST_CASE_ST(ut_setup, ut_teardown,
12219 test_AES_GCM_auth_encryption_test_case_192_2),
12220 TEST_CASE_ST(ut_setup, ut_teardown,
12221 test_AES_GCM_auth_encryption_test_case_192_3),
12222 TEST_CASE_ST(ut_setup, ut_teardown,
12223 test_AES_GCM_auth_encryption_test_case_192_4),
12224 TEST_CASE_ST(ut_setup, ut_teardown,
12225 test_AES_GCM_auth_encryption_test_case_192_5),
12226 TEST_CASE_ST(ut_setup, ut_teardown,
12227 test_AES_GCM_auth_encryption_test_case_192_6),
12228 TEST_CASE_ST(ut_setup, ut_teardown,
12229 test_AES_GCM_auth_encryption_test_case_192_7),
12231 /** AES GCM Authenticated Decryption 192 bits key */
12232 TEST_CASE_ST(ut_setup, ut_teardown,
12233 test_AES_GCM_auth_decryption_test_case_192_1),
12234 TEST_CASE_ST(ut_setup, ut_teardown,
12235 test_AES_GCM_auth_decryption_test_case_192_2),
12236 TEST_CASE_ST(ut_setup, ut_teardown,
12237 test_AES_GCM_auth_decryption_test_case_192_3),
12238 TEST_CASE_ST(ut_setup, ut_teardown,
12239 test_AES_GCM_auth_decryption_test_case_192_4),
12240 TEST_CASE_ST(ut_setup, ut_teardown,
12241 test_AES_GCM_auth_decryption_test_case_192_5),
12242 TEST_CASE_ST(ut_setup, ut_teardown,
12243 test_AES_GCM_auth_decryption_test_case_192_6),
12244 TEST_CASE_ST(ut_setup, ut_teardown,
12245 test_AES_GCM_auth_decryption_test_case_192_7),
12247 /** AES GCM Authenticated Encryption 256 bits key */
12248 TEST_CASE_ST(ut_setup, ut_teardown,
12249 test_AES_GCM_auth_encryption_test_case_256_1),
12250 TEST_CASE_ST(ut_setup, ut_teardown,
12251 test_AES_GCM_auth_encryption_test_case_256_2),
12252 TEST_CASE_ST(ut_setup, ut_teardown,
12253 test_AES_GCM_auth_encryption_test_case_256_3),
12254 TEST_CASE_ST(ut_setup, ut_teardown,
12255 test_AES_GCM_auth_encryption_test_case_256_4),
12256 TEST_CASE_ST(ut_setup, ut_teardown,
12257 test_AES_GCM_auth_encryption_test_case_256_5),
12258 TEST_CASE_ST(ut_setup, ut_teardown,
12259 test_AES_GCM_auth_encryption_test_case_256_6),
12260 TEST_CASE_ST(ut_setup, ut_teardown,
12261 test_AES_GCM_auth_encryption_test_case_256_7),
12263 /** AES GCM Authenticated Decryption 256 bits key */
12264 TEST_CASE_ST(ut_setup, ut_teardown,
12265 test_AES_GCM_auth_decryption_test_case_256_1),
12266 TEST_CASE_ST(ut_setup, ut_teardown,
12267 test_AES_GCM_auth_decryption_test_case_256_2),
12268 TEST_CASE_ST(ut_setup, ut_teardown,
12269 test_AES_GCM_auth_decryption_test_case_256_3),
12270 TEST_CASE_ST(ut_setup, ut_teardown,
12271 test_AES_GCM_auth_decryption_test_case_256_4),
12272 TEST_CASE_ST(ut_setup, ut_teardown,
12273 test_AES_GCM_auth_decryption_test_case_256_5),
12274 TEST_CASE_ST(ut_setup, ut_teardown,
12275 test_AES_GCM_auth_decryption_test_case_256_6),
12276 TEST_CASE_ST(ut_setup, ut_teardown,
12277 test_AES_GCM_auth_decryption_test_case_256_7),
12279 /** AES GMAC Authentication */
12280 TEST_CASE_ST(ut_setup, ut_teardown,
12281 test_AES_GMAC_authentication_test_case_1),
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_AES_GMAC_authentication_verify_test_case_1),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_AES_GMAC_authentication_test_case_2),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_AES_GMAC_authentication_verify_test_case_2),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_AES_GMAC_authentication_test_case_3),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_AES_GMAC_authentication_verify_test_case_3),
12293 /** SNOW 3G encrypt only (UEA2) */
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 test_snow3g_encryption_test_case_1),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_snow3g_encryption_test_case_2),
12298 TEST_CASE_ST(ut_setup, ut_teardown,
12299 test_snow3g_encryption_test_case_3),
12300 TEST_CASE_ST(ut_setup, ut_teardown,
12301 test_snow3g_encryption_test_case_4),
12302 TEST_CASE_ST(ut_setup, ut_teardown,
12303 test_snow3g_encryption_test_case_5),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_snow3g_encryption_test_case_1_oop),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_snow3g_decryption_test_case_1_oop),
12310 /** SNOW 3G generate auth, then encrypt (UEA2) */
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_snow3g_auth_cipher_test_case_1),
12313 TEST_CASE_ST(ut_setup, ut_teardown,
12314 test_snow3g_auth_cipher_test_case_2),
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_snow3g_auth_cipher_test_case_2_oop),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_snow3g_auth_cipher_part_digest_enc),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_snow3g_auth_cipher_part_digest_enc_oop),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_snow3g_auth_cipher_test_case_3_sgl),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_snow3g_auth_cipher_part_digest_enc_sgl),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12330 /** SNOW 3G decrypt (UEA2), then verify auth */
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_snow3g_auth_cipher_verify_test_case_1),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_snow3g_auth_cipher_verify_test_case_2),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_snow3g_auth_cipher_verify_test_case_2_oop),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_snow3g_auth_cipher_verify_part_digest_enc),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12347 TEST_CASE_ST(ut_setup, ut_teardown,
12348 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12350 /** SNOW 3G decrypt only (UEA2) */
12351 TEST_CASE_ST(ut_setup, ut_teardown,
12352 test_snow3g_decryption_test_case_1),
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_snow3g_decryption_test_case_2),
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_snow3g_decryption_test_case_3),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_snow3g_decryption_test_case_4),
12359 TEST_CASE_ST(ut_setup, ut_teardown,
12360 test_snow3g_decryption_test_case_5),
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_snow3g_decryption_with_digest_test_case_1),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_snow3g_hash_generate_test_case_1),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_snow3g_hash_generate_test_case_2),
12367 TEST_CASE_ST(ut_setup, ut_teardown,
12368 test_snow3g_hash_generate_test_case_3),
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_snow3g_hash_verify_test_case_1),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_snow3g_hash_verify_test_case_2),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_snow3g_hash_verify_test_case_3),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_snow3g_cipher_auth_test_case_1),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_snow3g_auth_cipher_with_digest_test_case_1),
12380 /** ZUC encrypt only (EEA3) */
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_zuc_encryption_test_case_1),
12383 TEST_CASE_ST(ut_setup, ut_teardown,
12384 test_zuc_encryption_test_case_2),
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_zuc_encryption_test_case_3),
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_zuc_encryption_test_case_4),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_zuc_encryption_test_case_5),
12392 /** ZUC authenticate (EIA3) */
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_zuc_hash_generate_test_case_6),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_zuc_hash_generate_test_case_7),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_zuc_hash_generate_test_case_8),
12400 /** ZUC alg-chain (EEA3/EIA3) */
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_zuc_cipher_auth_test_case_1),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_zuc_cipher_auth_test_case_2),
12406 /** ZUC generate auth, then encrypt (EEA3) */
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_zuc_auth_cipher_test_case_1),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_zuc_auth_cipher_test_case_1_oop),
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_zuc_auth_cipher_test_case_1_sgl),
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 test_zuc_auth_cipher_test_case_1_oop_sgl),
12416 /** ZUC decrypt (EEA3), then verify auth */
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 test_zuc_auth_cipher_verify_test_case_1),
12419 TEST_CASE_ST(ut_setup, ut_teardown,
12420 test_zuc_auth_cipher_verify_test_case_1_oop),
12421 TEST_CASE_ST(ut_setup, ut_teardown,
12422 test_zuc_auth_cipher_verify_test_case_1_sgl),
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12426 /** HMAC_MD5 Authentication */
12427 TEST_CASE_ST(ut_setup, ut_teardown,
12428 test_MD5_HMAC_generate_case_1),
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_MD5_HMAC_verify_case_1),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_MD5_HMAC_generate_case_2),
12433 TEST_CASE_ST(ut_setup, ut_teardown,
12434 test_MD5_HMAC_verify_case_2),
12436 /** NULL algo tests done in chain_all,
12437 * cipheronly and authonly suites
12440 /** KASUMI tests */
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_kasumi_hash_generate_test_case_1),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_kasumi_hash_generate_test_case_2),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_kasumi_hash_generate_test_case_3),
12447 TEST_CASE_ST(ut_setup, ut_teardown,
12448 test_kasumi_hash_generate_test_case_4),
12449 TEST_CASE_ST(ut_setup, ut_teardown,
12450 test_kasumi_hash_generate_test_case_5),
12451 TEST_CASE_ST(ut_setup, ut_teardown,
12452 test_kasumi_hash_generate_test_case_6),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_kasumi_hash_verify_test_case_1),
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_kasumi_hash_verify_test_case_2),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_kasumi_hash_verify_test_case_3),
12460 TEST_CASE_ST(ut_setup, ut_teardown,
12461 test_kasumi_hash_verify_test_case_4),
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_kasumi_hash_verify_test_case_5),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 test_kasumi_encryption_test_case_1),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_kasumi_encryption_test_case_3),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_kasumi_cipher_auth_test_case_1),
12472 /** KASUMI generate auth, then encrypt (F8) */
12473 TEST_CASE_ST(ut_setup, ut_teardown,
12474 test_kasumi_auth_cipher_test_case_1),
12475 TEST_CASE_ST(ut_setup, ut_teardown,
12476 test_kasumi_auth_cipher_test_case_2),
12477 TEST_CASE_ST(ut_setup, ut_teardown,
12478 test_kasumi_auth_cipher_test_case_2_oop),
12479 TEST_CASE_ST(ut_setup, ut_teardown,
12480 test_kasumi_auth_cipher_test_case_2_sgl),
12481 TEST_CASE_ST(ut_setup, ut_teardown,
12482 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12484 /** KASUMI decrypt (F8), then verify auth */
12485 TEST_CASE_ST(ut_setup, ut_teardown,
12486 test_kasumi_auth_cipher_verify_test_case_1),
12487 TEST_CASE_ST(ut_setup, ut_teardown,
12488 test_kasumi_auth_cipher_verify_test_case_2),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_kasumi_auth_cipher_verify_test_case_2_oop),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12496 /** Negative tests */
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12499 TEST_CASE_ST(ut_setup, ut_teardown,
12500 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12501 TEST_CASE_ST(ut_setup, ut_teardown,
12502 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12503 TEST_CASE_ST(ut_setup, ut_teardown,
12504 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12505 TEST_CASE_ST(ut_setup, ut_teardown,
12506 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12507 TEST_CASE_ST(ut_setup, ut_teardown,
12508 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12509 TEST_CASE_ST(ut_setup, ut_teardown,
12510 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12511 TEST_CASE_ST(ut_setup, ut_teardown,
12512 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12513 TEST_CASE_ST(ut_setup, ut_teardown,
12514 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12515 TEST_CASE_ST(ut_setup, ut_teardown,
12516 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12517 TEST_CASE_ST(ut_setup, ut_teardown,
12518 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12519 TEST_CASE_ST(ut_setup, ut_teardown,
12520 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12521 TEST_CASE_ST(ut_setup, ut_teardown,
12522 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12523 TEST_CASE_ST(ut_setup, ut_teardown,
12524 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12525 TEST_CASE_ST(ut_setup, ut_teardown,
12526 authentication_verify_AES128_GMAC_fail_data_corrupt),
12527 TEST_CASE_ST(ut_setup, ut_teardown,
12528 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12529 TEST_CASE_ST(ut_setup, ut_teardown,
12530 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12531 TEST_CASE_ST(ut_setup, ut_teardown,
12532 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12534 /** Mixed CIPHER + HASH algorithms */
12535 /** AUTH AES CMAC + CIPHER AES CTR */
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12553 /** AUTH ZUC + CIPHER SNOW3G */
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_auth_zuc_cipher_snow_test_case_1),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_verify_auth_zuc_cipher_snow_test_case_1),
12558 /** AUTH AES CMAC + CIPHER SNOW3G */
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_auth_aes_cmac_cipher_snow_test_case_1),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12563 /** AUTH ZUC + CIPHER AES CTR */
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 test_auth_zuc_cipher_aes_ctr_test_case_1),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12568 /** AUTH SNOW3G + CIPHER AES CTR */
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_auth_snow_cipher_aes_ctr_test_case_1),
12571 TEST_CASE_ST(ut_setup, ut_teardown,
12572 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12573 /** AUTH SNOW3G + CIPHER ZUC */
12574 TEST_CASE_ST(ut_setup, ut_teardown,
12575 test_auth_snow_cipher_zuc_test_case_1),
12576 TEST_CASE_ST(ut_setup, ut_teardown,
12577 test_verify_auth_snow_cipher_zuc_test_case_1),
12578 /** AUTH AES CMAC + CIPHER ZUC */
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_auth_aes_cmac_cipher_zuc_test_case_1),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12584 /** AUTH NULL + CIPHER SNOW3G */
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_auth_null_cipher_snow_test_case_1),
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_verify_auth_null_cipher_snow_test_case_1),
12589 /** AUTH NULL + CIPHER ZUC */
12590 TEST_CASE_ST(ut_setup, ut_teardown,
12591 test_auth_null_cipher_zuc_test_case_1),
12592 TEST_CASE_ST(ut_setup, ut_teardown,
12593 test_verify_auth_null_cipher_zuc_test_case_1),
12594 /** AUTH SNOW3G + CIPHER NULL */
12595 TEST_CASE_ST(ut_setup, ut_teardown,
12596 test_auth_snow_cipher_null_test_case_1),
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_verify_auth_snow_cipher_null_test_case_1),
12599 /** AUTH ZUC + CIPHER NULL */
12600 TEST_CASE_ST(ut_setup, ut_teardown,
12601 test_auth_zuc_cipher_null_test_case_1),
12602 TEST_CASE_ST(ut_setup, ut_teardown,
12603 test_verify_auth_zuc_cipher_null_test_case_1),
12604 /** AUTH NULL + CIPHER AES CTR */
12605 TEST_CASE_ST(ut_setup, ut_teardown,
12606 test_auth_null_cipher_aes_ctr_test_case_1),
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12609 /** AUTH AES CMAC + CIPHER NULL */
12610 TEST_CASE_ST(ut_setup, ut_teardown,
12611 test_auth_aes_cmac_cipher_null_test_case_1),
12612 TEST_CASE_ST(ut_setup, ut_teardown,
12613 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12615 TEST_CASES_END() /**< NULL terminate unit test array */
12619 static struct unit_test_suite cryptodev_virtio_testsuite = {
12620 .suite_name = "Crypto VIRTIO Unit Test Suite",
12621 .setup = testsuite_setup,
12622 .teardown = testsuite_teardown,
12623 .unit_test_cases = {
12624 TEST_CASE_ST(ut_setup, ut_teardown,
12625 test_AES_cipheronly_virtio_all),
12627 TEST_CASES_END() /**< NULL terminate unit test array */
12631 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
12632 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
12633 .setup = testsuite_setup,
12634 .teardown = testsuite_teardown,
12635 .unit_test_cases = {
12636 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_AES_GCM_authenticated_encryption_test_case_1),
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_AES_GCM_authenticated_encryption_test_case_2),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_AES_GCM_authenticated_encryption_test_case_3),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 test_AES_GCM_authenticated_encryption_test_case_4),
12645 TEST_CASE_ST(ut_setup, ut_teardown,
12646 test_AES_GCM_authenticated_encryption_test_case_5),
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_AES_GCM_authenticated_encryption_test_case_6),
12649 TEST_CASE_ST(ut_setup, ut_teardown,
12650 test_AES_GCM_authenticated_encryption_test_case_7),
12652 /** AES GCM Authenticated Decryption */
12653 TEST_CASE_ST(ut_setup, ut_teardown,
12654 test_AES_GCM_authenticated_decryption_test_case_1),
12655 TEST_CASE_ST(ut_setup, ut_teardown,
12656 test_AES_GCM_authenticated_decryption_test_case_2),
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 test_AES_GCM_authenticated_decryption_test_case_3),
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_AES_GCM_authenticated_decryption_test_case_4),
12661 TEST_CASE_ST(ut_setup, ut_teardown,
12662 test_AES_GCM_authenticated_decryption_test_case_5),
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_AES_GCM_authenticated_decryption_test_case_6),
12665 TEST_CASE_ST(ut_setup, ut_teardown,
12666 test_AES_GCM_authenticated_decryption_test_case_7),
12668 /** AES GCM Authenticated Encryption 192 bits key */
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 test_AES_GCM_auth_encryption_test_case_192_1),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 test_AES_GCM_auth_encryption_test_case_192_2),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 test_AES_GCM_auth_encryption_test_case_192_3),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 test_AES_GCM_auth_encryption_test_case_192_4),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 test_AES_GCM_auth_encryption_test_case_192_5),
12679 TEST_CASE_ST(ut_setup, ut_teardown,
12680 test_AES_GCM_auth_encryption_test_case_192_6),
12681 TEST_CASE_ST(ut_setup, ut_teardown,
12682 test_AES_GCM_auth_encryption_test_case_192_7),
12684 /** AES GCM Authenticated Decryption 192 bits key */
12685 TEST_CASE_ST(ut_setup, ut_teardown,
12686 test_AES_GCM_auth_decryption_test_case_192_1),
12687 TEST_CASE_ST(ut_setup, ut_teardown,
12688 test_AES_GCM_auth_decryption_test_case_192_2),
12689 TEST_CASE_ST(ut_setup, ut_teardown,
12690 test_AES_GCM_auth_decryption_test_case_192_3),
12691 TEST_CASE_ST(ut_setup, ut_teardown,
12692 test_AES_GCM_auth_decryption_test_case_192_4),
12693 TEST_CASE_ST(ut_setup, ut_teardown,
12694 test_AES_GCM_auth_decryption_test_case_192_5),
12695 TEST_CASE_ST(ut_setup, ut_teardown,
12696 test_AES_GCM_auth_decryption_test_case_192_6),
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_AES_GCM_auth_decryption_test_case_192_7),
12700 /** AES GCM Authenticated Encryption 256 bits key */
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 test_AES_GCM_auth_encryption_test_case_256_1),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_AES_GCM_auth_encryption_test_case_256_2),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_AES_GCM_auth_encryption_test_case_256_3),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_AES_GCM_auth_encryption_test_case_256_4),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_AES_GCM_auth_encryption_test_case_256_5),
12711 TEST_CASE_ST(ut_setup, ut_teardown,
12712 test_AES_GCM_auth_encryption_test_case_256_6),
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_AES_GCM_auth_encryption_test_case_256_7),
12716 /** AES GCM Authenticated Decryption 256 bits key */
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_auth_decryption_test_case_256_1),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_AES_GCM_auth_decryption_test_case_256_2),
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 test_AES_GCM_auth_decryption_test_case_256_3),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_auth_decryption_test_case_256_4),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_auth_decryption_test_case_256_5),
12727 TEST_CASE_ST(ut_setup, ut_teardown,
12728 test_AES_GCM_auth_decryption_test_case_256_6),
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_auth_decryption_test_case_256_7),
12732 /** AES GCM Authenticated Encryption big aad size */
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GCM_auth_encryption_test_case_aad_1),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GCM_auth_encryption_test_case_aad_2),
12738 /** AES GCM Authenticated Decryption big aad size */
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_auth_decryption_test_case_aad_1),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_auth_decryption_test_case_aad_2),
12744 /** Session-less tests */
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12750 /** AES GMAC Authentication */
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GMAC_authentication_test_case_1),
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GMAC_authentication_verify_test_case_1),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GMAC_authentication_test_case_2),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GMAC_authentication_verify_test_case_2),
12759 TEST_CASE_ST(ut_setup, ut_teardown,
12760 test_AES_GMAC_authentication_test_case_3),
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GMAC_authentication_verify_test_case_3),
12763 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12765 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12766 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12767 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12768 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_DES_cipheronly_mb_all),
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_DES_docsis_mb_all),
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_3DES_cipheronly_mb_all),
12775 TEST_CASE_ST(ut_setup, ut_teardown,
12776 test_AES_CCM_authenticated_encryption_test_case_128_1),
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_CCM_authenticated_decryption_test_case_128_1),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_CCM_authenticated_encryption_test_case_128_2),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_CCM_authenticated_decryption_test_case_128_2),
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_AES_CCM_authenticated_encryption_test_case_128_3),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_CCM_authenticated_decryption_test_case_128_3),
12788 TEST_CASES_END() /**< NULL terminate unit test array */
12792 static struct unit_test_suite cryptodev_openssl_testsuite = {
12793 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
12794 .setup = testsuite_setup,
12795 .teardown = testsuite_teardown,
12796 .unit_test_cases = {
12797 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12798 TEST_CASE_ST(ut_setup, ut_teardown,
12799 test_multi_session_random_usage),
12800 TEST_CASE_ST(ut_setup, ut_teardown,
12801 test_AES_chain_openssl_all),
12802 TEST_CASE_ST(ut_setup, ut_teardown,
12803 test_AES_cipheronly_openssl_all),
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_3DES_chain_openssl_all),
12806 TEST_CASE_ST(ut_setup, ut_teardown,
12807 test_3DES_cipheronly_openssl_all),
12808 TEST_CASE_ST(ut_setup, ut_teardown,
12809 test_DES_cipheronly_openssl_all),
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_DES_docsis_openssl_all),
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 test_authonly_openssl_all),
12815 /** AES GCM Authenticated Encryption */
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_AES_GCM_authenticated_encryption_test_case_1),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_AES_GCM_authenticated_encryption_test_case_2),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_AES_GCM_authenticated_encryption_test_case_3),
12822 TEST_CASE_ST(ut_setup, ut_teardown,
12823 test_AES_GCM_authenticated_encryption_test_case_4),
12824 TEST_CASE_ST(ut_setup, ut_teardown,
12825 test_AES_GCM_authenticated_encryption_test_case_5),
12826 TEST_CASE_ST(ut_setup, ut_teardown,
12827 test_AES_GCM_authenticated_encryption_test_case_6),
12828 TEST_CASE_ST(ut_setup, ut_teardown,
12829 test_AES_GCM_authenticated_encryption_test_case_7),
12831 /** AES GCM Authenticated Decryption */
12832 TEST_CASE_ST(ut_setup, ut_teardown,
12833 test_AES_GCM_authenticated_decryption_test_case_1),
12834 TEST_CASE_ST(ut_setup, ut_teardown,
12835 test_AES_GCM_authenticated_decryption_test_case_2),
12836 TEST_CASE_ST(ut_setup, ut_teardown,
12837 test_AES_GCM_authenticated_decryption_test_case_3),
12838 TEST_CASE_ST(ut_setup, ut_teardown,
12839 test_AES_GCM_authenticated_decryption_test_case_4),
12840 TEST_CASE_ST(ut_setup, ut_teardown,
12841 test_AES_GCM_authenticated_decryption_test_case_5),
12842 TEST_CASE_ST(ut_setup, ut_teardown,
12843 test_AES_GCM_authenticated_decryption_test_case_6),
12844 TEST_CASE_ST(ut_setup, ut_teardown,
12845 test_AES_GCM_authenticated_decryption_test_case_7),
12848 /** AES GCM Authenticated Encryption 192 bits key */
12849 TEST_CASE_ST(ut_setup, ut_teardown,
12850 test_AES_GCM_auth_encryption_test_case_192_1),
12851 TEST_CASE_ST(ut_setup, ut_teardown,
12852 test_AES_GCM_auth_encryption_test_case_192_2),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_AES_GCM_auth_encryption_test_case_192_3),
12855 TEST_CASE_ST(ut_setup, ut_teardown,
12856 test_AES_GCM_auth_encryption_test_case_192_4),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_AES_GCM_auth_encryption_test_case_192_5),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_AES_GCM_auth_encryption_test_case_192_6),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_AES_GCM_auth_encryption_test_case_192_7),
12864 /** AES GCM Authenticated Decryption 192 bits key */
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 test_AES_GCM_auth_decryption_test_case_192_1),
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_AES_GCM_auth_decryption_test_case_192_2),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_AES_GCM_auth_decryption_test_case_192_3),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_AES_GCM_auth_decryption_test_case_192_4),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_AES_GCM_auth_decryption_test_case_192_5),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_AES_GCM_auth_decryption_test_case_192_6),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_AES_GCM_auth_decryption_test_case_192_7),
12880 /** AES GCM Authenticated Encryption 256 bits key */
12881 TEST_CASE_ST(ut_setup, ut_teardown,
12882 test_AES_GCM_auth_encryption_test_case_256_1),
12883 TEST_CASE_ST(ut_setup, ut_teardown,
12884 test_AES_GCM_auth_encryption_test_case_256_2),
12885 TEST_CASE_ST(ut_setup, ut_teardown,
12886 test_AES_GCM_auth_encryption_test_case_256_3),
12887 TEST_CASE_ST(ut_setup, ut_teardown,
12888 test_AES_GCM_auth_encryption_test_case_256_4),
12889 TEST_CASE_ST(ut_setup, ut_teardown,
12890 test_AES_GCM_auth_encryption_test_case_256_5),
12891 TEST_CASE_ST(ut_setup, ut_teardown,
12892 test_AES_GCM_auth_encryption_test_case_256_6),
12893 TEST_CASE_ST(ut_setup, ut_teardown,
12894 test_AES_GCM_auth_encryption_test_case_256_7),
12896 /** AES GCM Authenticated Decryption 256 bits key */
12897 TEST_CASE_ST(ut_setup, ut_teardown,
12898 test_AES_GCM_auth_decryption_test_case_256_1),
12899 TEST_CASE_ST(ut_setup, ut_teardown,
12900 test_AES_GCM_auth_decryption_test_case_256_2),
12901 TEST_CASE_ST(ut_setup, ut_teardown,
12902 test_AES_GCM_auth_decryption_test_case_256_3),
12903 TEST_CASE_ST(ut_setup, ut_teardown,
12904 test_AES_GCM_auth_decryption_test_case_256_4),
12905 TEST_CASE_ST(ut_setup, ut_teardown,
12906 test_AES_GCM_auth_decryption_test_case_256_5),
12907 TEST_CASE_ST(ut_setup, ut_teardown,
12908 test_AES_GCM_auth_decryption_test_case_256_6),
12909 TEST_CASE_ST(ut_setup, ut_teardown,
12910 test_AES_GCM_auth_decryption_test_case_256_7),
12912 /** AES GMAC Authentication */
12913 TEST_CASE_ST(ut_setup, ut_teardown,
12914 test_AES_GMAC_authentication_test_case_1),
12915 TEST_CASE_ST(ut_setup, ut_teardown,
12916 test_AES_GMAC_authentication_verify_test_case_1),
12917 TEST_CASE_ST(ut_setup, ut_teardown,
12918 test_AES_GMAC_authentication_test_case_2),
12919 TEST_CASE_ST(ut_setup, ut_teardown,
12920 test_AES_GMAC_authentication_verify_test_case_2),
12921 TEST_CASE_ST(ut_setup, ut_teardown,
12922 test_AES_GMAC_authentication_test_case_3),
12923 TEST_CASE_ST(ut_setup, ut_teardown,
12924 test_AES_GMAC_authentication_verify_test_case_3),
12925 TEST_CASE_ST(ut_setup, ut_teardown,
12926 test_AES_GMAC_authentication_test_case_4),
12927 TEST_CASE_ST(ut_setup, ut_teardown,
12928 test_AES_GMAC_authentication_verify_test_case_4),
12930 /** AES CCM Authenticated Encryption 128 bits key */
12931 TEST_CASE_ST(ut_setup, ut_teardown,
12932 test_AES_CCM_authenticated_encryption_test_case_128_1),
12933 TEST_CASE_ST(ut_setup, ut_teardown,
12934 test_AES_CCM_authenticated_encryption_test_case_128_2),
12935 TEST_CASE_ST(ut_setup, ut_teardown,
12936 test_AES_CCM_authenticated_encryption_test_case_128_3),
12938 /** AES CCM Authenticated Decryption 128 bits key*/
12939 TEST_CASE_ST(ut_setup, ut_teardown,
12940 test_AES_CCM_authenticated_decryption_test_case_128_1),
12941 TEST_CASE_ST(ut_setup, ut_teardown,
12942 test_AES_CCM_authenticated_decryption_test_case_128_2),
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 test_AES_CCM_authenticated_decryption_test_case_128_3),
12946 /** AES CCM Authenticated Encryption 192 bits key */
12947 TEST_CASE_ST(ut_setup, ut_teardown,
12948 test_AES_CCM_authenticated_encryption_test_case_192_1),
12949 TEST_CASE_ST(ut_setup, ut_teardown,
12950 test_AES_CCM_authenticated_encryption_test_case_192_2),
12951 TEST_CASE_ST(ut_setup, ut_teardown,
12952 test_AES_CCM_authenticated_encryption_test_case_192_3),
12954 /** AES CCM Authenticated Decryption 192 bits key*/
12955 TEST_CASE_ST(ut_setup, ut_teardown,
12956 test_AES_CCM_authenticated_decryption_test_case_192_1),
12957 TEST_CASE_ST(ut_setup, ut_teardown,
12958 test_AES_CCM_authenticated_decryption_test_case_192_2),
12959 TEST_CASE_ST(ut_setup, ut_teardown,
12960 test_AES_CCM_authenticated_decryption_test_case_192_3),
12962 /** AES CCM Authenticated Encryption 256 bits key */
12963 TEST_CASE_ST(ut_setup, ut_teardown,
12964 test_AES_CCM_authenticated_encryption_test_case_256_1),
12965 TEST_CASE_ST(ut_setup, ut_teardown,
12966 test_AES_CCM_authenticated_encryption_test_case_256_2),
12967 TEST_CASE_ST(ut_setup, ut_teardown,
12968 test_AES_CCM_authenticated_encryption_test_case_256_3),
12970 /** AES CCM Authenticated Decryption 256 bits key*/
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 test_AES_CCM_authenticated_decryption_test_case_256_1),
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 test_AES_CCM_authenticated_decryption_test_case_256_2),
12975 TEST_CASE_ST(ut_setup, ut_teardown,
12976 test_AES_CCM_authenticated_decryption_test_case_256_3),
12978 /** Scatter-Gather */
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12982 /** Negative tests */
12983 TEST_CASE_ST(ut_setup, ut_teardown,
12984 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12985 TEST_CASE_ST(ut_setup, ut_teardown,
12986 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12987 TEST_CASE_ST(ut_setup, ut_teardown,
12988 authentication_verify_AES128_GMAC_fail_data_corrupt),
12989 TEST_CASE_ST(ut_setup, ut_teardown,
12990 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12991 TEST_CASE_ST(ut_setup, ut_teardown,
12992 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12993 TEST_CASE_ST(ut_setup, ut_teardown,
12994 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12997 TEST_CASE_ST(ut_setup, ut_teardown,
12998 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13003 TEST_CASES_END() /**< NULL terminate unit test array */
13007 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
13008 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
13009 .setup = testsuite_setup,
13010 .teardown = testsuite_teardown,
13011 .unit_test_cases = {
13012 /** AES GCM Authenticated Encryption */
13013 TEST_CASE_ST(ut_setup, ut_teardown,
13014 test_AES_GCM_authenticated_encryption_test_case_1),
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_AES_GCM_authenticated_encryption_test_case_2),
13017 TEST_CASE_ST(ut_setup, ut_teardown,
13018 test_AES_GCM_authenticated_encryption_test_case_3),
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_AES_GCM_authenticated_encryption_test_case_4),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_AES_GCM_authenticated_encryption_test_case_5),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_AES_GCM_authenticated_encryption_test_case_6),
13025 TEST_CASE_ST(ut_setup, ut_teardown,
13026 test_AES_GCM_authenticated_encryption_test_case_7),
13028 /** AES GCM Authenticated Decryption */
13029 TEST_CASE_ST(ut_setup, ut_teardown,
13030 test_AES_GCM_authenticated_decryption_test_case_1),
13031 TEST_CASE_ST(ut_setup, ut_teardown,
13032 test_AES_GCM_authenticated_decryption_test_case_2),
13033 TEST_CASE_ST(ut_setup, ut_teardown,
13034 test_AES_GCM_authenticated_decryption_test_case_3),
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 test_AES_GCM_authenticated_decryption_test_case_4),
13037 TEST_CASE_ST(ut_setup, ut_teardown,
13038 test_AES_GCM_authenticated_decryption_test_case_5),
13039 TEST_CASE_ST(ut_setup, ut_teardown,
13040 test_AES_GCM_authenticated_decryption_test_case_6),
13041 TEST_CASE_ST(ut_setup, ut_teardown,
13042 test_AES_GCM_authenticated_decryption_test_case_7),
13044 /** AES GCM Authenticated Encryption 192 bits key */
13045 TEST_CASE_ST(ut_setup, ut_teardown,
13046 test_AES_GCM_auth_encryption_test_case_192_1),
13047 TEST_CASE_ST(ut_setup, ut_teardown,
13048 test_AES_GCM_auth_encryption_test_case_192_2),
13049 TEST_CASE_ST(ut_setup, ut_teardown,
13050 test_AES_GCM_auth_encryption_test_case_192_3),
13051 TEST_CASE_ST(ut_setup, ut_teardown,
13052 test_AES_GCM_auth_encryption_test_case_192_4),
13053 TEST_CASE_ST(ut_setup, ut_teardown,
13054 test_AES_GCM_auth_encryption_test_case_192_5),
13055 TEST_CASE_ST(ut_setup, ut_teardown,
13056 test_AES_GCM_auth_encryption_test_case_192_6),
13057 TEST_CASE_ST(ut_setup, ut_teardown,
13058 test_AES_GCM_auth_encryption_test_case_192_7),
13060 /** AES GCM Authenticated Decryption 192 bits key */
13061 TEST_CASE_ST(ut_setup, ut_teardown,
13062 test_AES_GCM_auth_decryption_test_case_192_1),
13063 TEST_CASE_ST(ut_setup, ut_teardown,
13064 test_AES_GCM_auth_decryption_test_case_192_2),
13065 TEST_CASE_ST(ut_setup, ut_teardown,
13066 test_AES_GCM_auth_decryption_test_case_192_3),
13067 TEST_CASE_ST(ut_setup, ut_teardown,
13068 test_AES_GCM_auth_decryption_test_case_192_4),
13069 TEST_CASE_ST(ut_setup, ut_teardown,
13070 test_AES_GCM_auth_decryption_test_case_192_5),
13071 TEST_CASE_ST(ut_setup, ut_teardown,
13072 test_AES_GCM_auth_decryption_test_case_192_6),
13073 TEST_CASE_ST(ut_setup, ut_teardown,
13074 test_AES_GCM_auth_decryption_test_case_192_7),
13076 /** AES GCM Authenticated Encryption 256 bits key */
13077 TEST_CASE_ST(ut_setup, ut_teardown,
13078 test_AES_GCM_auth_encryption_test_case_256_1),
13079 TEST_CASE_ST(ut_setup, ut_teardown,
13080 test_AES_GCM_auth_encryption_test_case_256_2),
13081 TEST_CASE_ST(ut_setup, ut_teardown,
13082 test_AES_GCM_auth_encryption_test_case_256_3),
13083 TEST_CASE_ST(ut_setup, ut_teardown,
13084 test_AES_GCM_auth_encryption_test_case_256_4),
13085 TEST_CASE_ST(ut_setup, ut_teardown,
13086 test_AES_GCM_auth_encryption_test_case_256_5),
13087 TEST_CASE_ST(ut_setup, ut_teardown,
13088 test_AES_GCM_auth_encryption_test_case_256_6),
13089 TEST_CASE_ST(ut_setup, ut_teardown,
13090 test_AES_GCM_auth_encryption_test_case_256_7),
13092 /** AES GCM Authenticated Decryption 256 bits key */
13093 TEST_CASE_ST(ut_setup, ut_teardown,
13094 test_AES_GCM_auth_decryption_test_case_256_1),
13095 TEST_CASE_ST(ut_setup, ut_teardown,
13096 test_AES_GCM_auth_decryption_test_case_256_2),
13097 TEST_CASE_ST(ut_setup, ut_teardown,
13098 test_AES_GCM_auth_decryption_test_case_256_3),
13099 TEST_CASE_ST(ut_setup, ut_teardown,
13100 test_AES_GCM_auth_decryption_test_case_256_4),
13101 TEST_CASE_ST(ut_setup, ut_teardown,
13102 test_AES_GCM_auth_decryption_test_case_256_5),
13103 TEST_CASE_ST(ut_setup, ut_teardown,
13104 test_AES_GCM_auth_decryption_test_case_256_6),
13105 TEST_CASE_ST(ut_setup, ut_teardown,
13106 test_AES_GCM_auth_decryption_test_case_256_7),
13108 /** AES GCM Authenticated Encryption big aad size */
13109 TEST_CASE_ST(ut_setup, ut_teardown,
13110 test_AES_GCM_auth_encryption_test_case_aad_1),
13111 TEST_CASE_ST(ut_setup, ut_teardown,
13112 test_AES_GCM_auth_encryption_test_case_aad_2),
13114 /** AES GCM Authenticated Decryption big aad size */
13115 TEST_CASE_ST(ut_setup, ut_teardown,
13116 test_AES_GCM_auth_decryption_test_case_aad_1),
13117 TEST_CASE_ST(ut_setup, ut_teardown,
13118 test_AES_GCM_auth_decryption_test_case_aad_2),
13120 /** AES GMAC Authentication */
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_AES_GMAC_authentication_test_case_1),
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_AES_GMAC_authentication_verify_test_case_1),
13125 TEST_CASE_ST(ut_setup, ut_teardown,
13126 test_AES_GMAC_authentication_test_case_3),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_AES_GMAC_authentication_verify_test_case_3),
13129 TEST_CASE_ST(ut_setup, ut_teardown,
13130 test_AES_GMAC_authentication_test_case_4),
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_AES_GMAC_authentication_verify_test_case_4),
13134 /** Negative tests */
13135 TEST_CASE_ST(ut_setup, ut_teardown,
13136 authentication_verify_AES128_GMAC_fail_data_corrupt),
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13140 /** Out of place tests */
13141 TEST_CASE_ST(ut_setup, ut_teardown,
13142 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13146 /** Session-less tests */
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13152 /** Scatter-Gather */
13153 TEST_CASE_ST(ut_setup, ut_teardown,
13154 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13155 TEST_CASE_ST(ut_setup, ut_teardown,
13156 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13158 TEST_CASES_END() /**< NULL terminate unit test array */
13162 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
13163 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
13164 .setup = testsuite_setup,
13165 .teardown = testsuite_teardown,
13166 .unit_test_cases = {
13167 /** KASUMI encrypt only (UEA1) */
13168 TEST_CASE_ST(ut_setup, ut_teardown,
13169 test_kasumi_encryption_test_case_1),
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 test_kasumi_encryption_test_case_1_sgl),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 test_kasumi_encryption_test_case_2),
13174 TEST_CASE_ST(ut_setup, ut_teardown,
13175 test_kasumi_encryption_test_case_3),
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_kasumi_encryption_test_case_4),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_kasumi_encryption_test_case_5),
13180 /** KASUMI decrypt only (UEA1) */
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 test_kasumi_decryption_test_case_1),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 test_kasumi_decryption_test_case_2),
13185 TEST_CASE_ST(ut_setup, ut_teardown,
13186 test_kasumi_decryption_test_case_3),
13187 TEST_CASE_ST(ut_setup, ut_teardown,
13188 test_kasumi_decryption_test_case_4),
13189 TEST_CASE_ST(ut_setup, ut_teardown,
13190 test_kasumi_decryption_test_case_5),
13192 TEST_CASE_ST(ut_setup, ut_teardown,
13193 test_kasumi_encryption_test_case_1_oop),
13194 TEST_CASE_ST(ut_setup, ut_teardown,
13195 test_kasumi_encryption_test_case_1_oop_sgl),
13198 TEST_CASE_ST(ut_setup, ut_teardown,
13199 test_kasumi_decryption_test_case_1_oop),
13201 /** KASUMI hash only (UIA1) */
13202 TEST_CASE_ST(ut_setup, ut_teardown,
13203 test_kasumi_hash_generate_test_case_1),
13204 TEST_CASE_ST(ut_setup, ut_teardown,
13205 test_kasumi_hash_generate_test_case_2),
13206 TEST_CASE_ST(ut_setup, ut_teardown,
13207 test_kasumi_hash_generate_test_case_3),
13208 TEST_CASE_ST(ut_setup, ut_teardown,
13209 test_kasumi_hash_generate_test_case_4),
13210 TEST_CASE_ST(ut_setup, ut_teardown,
13211 test_kasumi_hash_generate_test_case_5),
13212 TEST_CASE_ST(ut_setup, ut_teardown,
13213 test_kasumi_hash_generate_test_case_6),
13214 TEST_CASE_ST(ut_setup, ut_teardown,
13215 test_kasumi_hash_verify_test_case_1),
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_kasumi_hash_verify_test_case_2),
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_kasumi_hash_verify_test_case_3),
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_kasumi_hash_verify_test_case_4),
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_kasumi_hash_verify_test_case_5),
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_kasumi_cipher_auth_test_case_1),
13227 /** KASUMI generate auth, then encrypt (F8) */
13228 TEST_CASE_ST(ut_setup, ut_teardown,
13229 test_kasumi_auth_cipher_test_case_1),
13230 TEST_CASE_ST(ut_setup, ut_teardown,
13231 test_kasumi_auth_cipher_test_case_2),
13232 TEST_CASE_ST(ut_setup, ut_teardown,
13233 test_kasumi_auth_cipher_test_case_2_oop),
13234 TEST_CASE_ST(ut_setup, ut_teardown,
13235 test_kasumi_auth_cipher_test_case_2_sgl),
13236 TEST_CASE_ST(ut_setup, ut_teardown,
13237 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13239 /** KASUMI decrypt (F8), then verify auth */
13240 TEST_CASE_ST(ut_setup, ut_teardown,
13241 test_kasumi_auth_cipher_verify_test_case_1),
13242 TEST_CASE_ST(ut_setup, ut_teardown,
13243 test_kasumi_auth_cipher_verify_test_case_2),
13244 TEST_CASE_ST(ut_setup, ut_teardown,
13245 test_kasumi_auth_cipher_verify_test_case_2_oop),
13246 TEST_CASE_ST(ut_setup, ut_teardown,
13247 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13248 TEST_CASE_ST(ut_setup, ut_teardown,
13249 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13250 TEST_CASES_END() /**< NULL terminate unit test array */
13253 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
13254 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
13255 .setup = testsuite_setup,
13256 .teardown = testsuite_teardown,
13257 .unit_test_cases = {
13258 /** SNOW 3G encrypt only (UEA2) */
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_snow3g_encryption_test_case_1),
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_snow3g_encryption_test_case_2),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_snow3g_encryption_test_case_3),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_snow3g_encryption_test_case_4),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_snow3g_encryption_test_case_5),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_snow3g_auth_cipher_with_digest_test_case_1),
13272 TEST_CASE_ST(ut_setup, ut_teardown,
13273 test_snow3g_encryption_test_case_1_oop),
13274 TEST_CASE_ST(ut_setup, ut_teardown,
13275 test_snow3g_encryption_test_case_1_oop_sgl),
13276 TEST_CASE_ST(ut_setup, ut_teardown,
13277 test_snow3g_decryption_test_case_1_oop),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_snow3g_encryption_test_case_1_offset_oop),
13282 /** SNOW 3G decrypt only (UEA2) */
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_snow3g_decryption_test_case_1),
13285 TEST_CASE_ST(ut_setup, ut_teardown,
13286 test_snow3g_decryption_test_case_2),
13287 TEST_CASE_ST(ut_setup, ut_teardown,
13288 test_snow3g_decryption_test_case_3),
13289 TEST_CASE_ST(ut_setup, ut_teardown,
13290 test_snow3g_decryption_test_case_4),
13291 TEST_CASE_ST(ut_setup, ut_teardown,
13292 test_snow3g_decryption_test_case_5),
13293 TEST_CASE_ST(ut_setup, ut_teardown,
13294 test_snow3g_decryption_with_digest_test_case_1),
13295 TEST_CASE_ST(ut_setup, ut_teardown,
13296 test_snow3g_hash_generate_test_case_1),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_snow3g_hash_generate_test_case_2),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_snow3g_hash_generate_test_case_3),
13301 /* Tests with buffers which length is not byte-aligned */
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_hash_generate_test_case_4),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_snow3g_hash_generate_test_case_5),
13306 TEST_CASE_ST(ut_setup, ut_teardown,
13307 test_snow3g_hash_generate_test_case_6),
13308 TEST_CASE_ST(ut_setup, ut_teardown,
13309 test_snow3g_hash_verify_test_case_1),
13310 TEST_CASE_ST(ut_setup, ut_teardown,
13311 test_snow3g_hash_verify_test_case_2),
13312 TEST_CASE_ST(ut_setup, ut_teardown,
13313 test_snow3g_hash_verify_test_case_3),
13314 /* Tests with buffers which length is not byte-aligned */
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_snow3g_hash_verify_test_case_4),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_snow3g_hash_verify_test_case_5),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_snow3g_hash_verify_test_case_6),
13321 TEST_CASE_ST(ut_setup, ut_teardown,
13322 test_snow3g_cipher_auth_test_case_1),
13324 /** SNOW 3G generate auth, then encrypt (UEA2) */
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_snow3g_auth_cipher_test_case_1),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_snow3g_auth_cipher_test_case_2),
13329 TEST_CASE_ST(ut_setup, ut_teardown,
13330 test_snow3g_auth_cipher_test_case_2_oop),
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_snow3g_auth_cipher_part_digest_enc),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_snow3g_auth_cipher_part_digest_enc_oop),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_snow3g_auth_cipher_test_case_3_sgl),
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_snow3g_auth_cipher_part_digest_enc_sgl),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13344 /** SNOW 3G decrypt (UEA2), then verify auth */
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 test_snow3g_auth_cipher_verify_test_case_1),
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 test_snow3g_auth_cipher_verify_test_case_2),
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 test_snow3g_auth_cipher_verify_test_case_2_oop),
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 test_snow3g_auth_cipher_verify_part_digest_enc),
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13355 TEST_CASE_ST(ut_setup, ut_teardown,
13356 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13357 TEST_CASE_ST(ut_setup, ut_teardown,
13358 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13359 TEST_CASE_ST(ut_setup, ut_teardown,
13360 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13361 TEST_CASE_ST(ut_setup, ut_teardown,
13362 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13364 TEST_CASES_END() /**< NULL terminate unit test array */
13368 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
13369 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
13370 .setup = testsuite_setup,
13371 .teardown = testsuite_teardown,
13372 .unit_test_cases = {
13373 /** ZUC encrypt only (EEA3) */
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_zuc_encryption_test_case_1),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_zuc_encryption_test_case_2),
13378 TEST_CASE_ST(ut_setup, ut_teardown,
13379 test_zuc_encryption_test_case_3),
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_zuc_encryption_test_case_4),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_zuc_encryption_test_case_5),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_zuc_hash_generate_test_case_1),
13386 TEST_CASE_ST(ut_setup, ut_teardown,
13387 test_zuc_hash_generate_test_case_2),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_zuc_hash_generate_test_case_3),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_zuc_hash_generate_test_case_4),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_zuc_hash_generate_test_case_5),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_zuc_encryption_test_case_6_sgl),
13396 TEST_CASES_END() /**< NULL terminate unit test array */
13400 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13401 .suite_name = "Crypto CAAM JR Unit Test Suite",
13402 .setup = testsuite_setup,
13403 .teardown = testsuite_teardown,
13404 .unit_test_cases = {
13405 TEST_CASE_ST(ut_setup, ut_teardown,
13406 test_device_configure_invalid_dev_id),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_multi_session),
13410 TEST_CASE_ST(ut_setup, ut_teardown,
13411 test_AES_chain_caam_jr_all),
13412 TEST_CASE_ST(ut_setup, ut_teardown,
13413 test_3DES_chain_caam_jr_all),
13414 TEST_CASE_ST(ut_setup, ut_teardown,
13415 test_AES_cipheronly_caam_jr_all),
13416 TEST_CASE_ST(ut_setup, ut_teardown,
13417 test_3DES_cipheronly_caam_jr_all),
13418 TEST_CASE_ST(ut_setup, ut_teardown,
13419 test_authonly_caam_jr_all),
13421 TEST_CASES_END() /**< NULL terminate unit test array */
13425 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
13426 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
13427 .setup = testsuite_setup,
13428 .teardown = testsuite_teardown,
13429 .unit_test_cases = {
13430 TEST_CASE_ST(ut_setup, ut_teardown,
13431 test_device_configure_invalid_dev_id),
13432 TEST_CASE_ST(ut_setup, ut_teardown,
13433 test_multi_session),
13435 TEST_CASE_ST(ut_setup, ut_teardown,
13436 test_AES_chain_dpaa_sec_all),
13437 TEST_CASE_ST(ut_setup, ut_teardown,
13438 test_3DES_chain_dpaa_sec_all),
13439 TEST_CASE_ST(ut_setup, ut_teardown,
13440 test_AES_cipheronly_dpaa_sec_all),
13441 TEST_CASE_ST(ut_setup, ut_teardown,
13442 test_3DES_cipheronly_dpaa_sec_all),
13443 TEST_CASE_ST(ut_setup, ut_teardown,
13444 test_authonly_dpaa_sec_all),
13446 #ifdef RTE_LIBRTE_SECURITY
13447 TEST_CASE_ST(ut_setup, ut_teardown,
13448 test_PDCP_PROTO_cplane_encap_all),
13450 TEST_CASE_ST(ut_setup, ut_teardown,
13451 test_PDCP_PROTO_cplane_decap_all),
13453 TEST_CASE_ST(ut_setup, ut_teardown,
13454 test_PDCP_PROTO_uplane_encap_all),
13456 TEST_CASE_ST(ut_setup, ut_teardown,
13457 test_PDCP_PROTO_uplane_decap_all),
13459 TEST_CASE_ST(ut_setup, ut_teardown,
13460 test_PDCP_PROTO_SGL_in_place_32B),
13461 TEST_CASE_ST(ut_setup, ut_teardown,
13462 test_PDCP_PROTO_SGL_oop_32B_128B),
13463 TEST_CASE_ST(ut_setup, ut_teardown,
13464 test_PDCP_PROTO_SGL_oop_32B_40B),
13465 TEST_CASE_ST(ut_setup, ut_teardown,
13466 test_PDCP_PROTO_SGL_oop_128B_32B),
13468 /** AES GCM Authenticated Encryption */
13469 TEST_CASE_ST(ut_setup, ut_teardown,
13470 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13471 TEST_CASE_ST(ut_setup, ut_teardown,
13472 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13473 TEST_CASE_ST(ut_setup, ut_teardown,
13474 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13475 TEST_CASE_ST(ut_setup, ut_teardown,
13476 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13477 TEST_CASE_ST(ut_setup, ut_teardown,
13478 test_AES_GCM_authenticated_encryption_test_case_1),
13479 TEST_CASE_ST(ut_setup, ut_teardown,
13480 test_AES_GCM_authenticated_encryption_test_case_2),
13481 TEST_CASE_ST(ut_setup, ut_teardown,
13482 test_AES_GCM_authenticated_encryption_test_case_3),
13483 TEST_CASE_ST(ut_setup, ut_teardown,
13484 test_AES_GCM_authenticated_encryption_test_case_4),
13485 TEST_CASE_ST(ut_setup, ut_teardown,
13486 test_AES_GCM_authenticated_encryption_test_case_5),
13487 TEST_CASE_ST(ut_setup, ut_teardown,
13488 test_AES_GCM_authenticated_encryption_test_case_6),
13489 TEST_CASE_ST(ut_setup, ut_teardown,
13490 test_AES_GCM_authenticated_encryption_test_case_7),
13491 TEST_CASE_ST(ut_setup, ut_teardown,
13492 test_AES_GCM_authenticated_encryption_test_case_8),
13494 /** AES GCM Authenticated Decryption */
13495 TEST_CASE_ST(ut_setup, ut_teardown,
13496 test_AES_GCM_authenticated_decryption_test_case_1),
13497 TEST_CASE_ST(ut_setup, ut_teardown,
13498 test_AES_GCM_authenticated_decryption_test_case_2),
13499 TEST_CASE_ST(ut_setup, ut_teardown,
13500 test_AES_GCM_authenticated_decryption_test_case_3),
13501 TEST_CASE_ST(ut_setup, ut_teardown,
13502 test_AES_GCM_authenticated_decryption_test_case_4),
13503 TEST_CASE_ST(ut_setup, ut_teardown,
13504 test_AES_GCM_authenticated_decryption_test_case_5),
13505 TEST_CASE_ST(ut_setup, ut_teardown,
13506 test_AES_GCM_authenticated_decryption_test_case_6),
13507 TEST_CASE_ST(ut_setup, ut_teardown,
13508 test_AES_GCM_authenticated_decryption_test_case_7),
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_AES_GCM_authenticated_decryption_test_case_8),
13512 /** AES GCM Authenticated Encryption 192 bits key */
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_AES_GCM_auth_encryption_test_case_192_1),
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_AES_GCM_auth_encryption_test_case_192_2),
13517 TEST_CASE_ST(ut_setup, ut_teardown,
13518 test_AES_GCM_auth_encryption_test_case_192_3),
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_AES_GCM_auth_encryption_test_case_192_4),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_AES_GCM_auth_encryption_test_case_192_5),
13523 TEST_CASE_ST(ut_setup, ut_teardown,
13524 test_AES_GCM_auth_encryption_test_case_192_6),
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_AES_GCM_auth_encryption_test_case_192_7),
13528 /** AES GCM Authenticated Decryption 192 bits key */
13529 TEST_CASE_ST(ut_setup, ut_teardown,
13530 test_AES_GCM_auth_decryption_test_case_192_1),
13531 TEST_CASE_ST(ut_setup, ut_teardown,
13532 test_AES_GCM_auth_decryption_test_case_192_2),
13533 TEST_CASE_ST(ut_setup, ut_teardown,
13534 test_AES_GCM_auth_decryption_test_case_192_3),
13535 TEST_CASE_ST(ut_setup, ut_teardown,
13536 test_AES_GCM_auth_decryption_test_case_192_4),
13537 TEST_CASE_ST(ut_setup, ut_teardown,
13538 test_AES_GCM_auth_decryption_test_case_192_5),
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_AES_GCM_auth_decryption_test_case_192_6),
13541 TEST_CASE_ST(ut_setup, ut_teardown,
13542 test_AES_GCM_auth_decryption_test_case_192_7),
13544 /** AES GCM Authenticated Encryption 256 bits key */
13545 TEST_CASE_ST(ut_setup, ut_teardown,
13546 test_AES_GCM_auth_encryption_test_case_256_1),
13547 TEST_CASE_ST(ut_setup, ut_teardown,
13548 test_AES_GCM_auth_encryption_test_case_256_2),
13549 TEST_CASE_ST(ut_setup, ut_teardown,
13550 test_AES_GCM_auth_encryption_test_case_256_3),
13551 TEST_CASE_ST(ut_setup, ut_teardown,
13552 test_AES_GCM_auth_encryption_test_case_256_4),
13553 TEST_CASE_ST(ut_setup, ut_teardown,
13554 test_AES_GCM_auth_encryption_test_case_256_5),
13555 TEST_CASE_ST(ut_setup, ut_teardown,
13556 test_AES_GCM_auth_encryption_test_case_256_6),
13557 TEST_CASE_ST(ut_setup, ut_teardown,
13558 test_AES_GCM_auth_encryption_test_case_256_7),
13560 /** AES GCM Authenticated Decryption 256 bits key */
13561 TEST_CASE_ST(ut_setup, ut_teardown,
13562 test_AES_GCM_auth_decryption_test_case_256_1),
13563 TEST_CASE_ST(ut_setup, ut_teardown,
13564 test_AES_GCM_auth_decryption_test_case_256_2),
13565 TEST_CASE_ST(ut_setup, ut_teardown,
13566 test_AES_GCM_auth_decryption_test_case_256_3),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_AES_GCM_auth_decryption_test_case_256_4),
13569 TEST_CASE_ST(ut_setup, ut_teardown,
13570 test_AES_GCM_auth_decryption_test_case_256_5),
13571 TEST_CASE_ST(ut_setup, ut_teardown,
13572 test_AES_GCM_auth_decryption_test_case_256_6),
13573 TEST_CASE_ST(ut_setup, ut_teardown,
13574 test_AES_GCM_auth_decryption_test_case_256_7),
13576 /** Out of place tests */
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13579 TEST_CASE_ST(ut_setup, ut_teardown,
13580 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13582 /** SNOW 3G encrypt only (UEA2) */
13583 TEST_CASE_ST(ut_setup, ut_teardown,
13584 test_snow3g_encryption_test_case_1),
13585 TEST_CASE_ST(ut_setup, ut_teardown,
13586 test_snow3g_encryption_test_case_2),
13587 TEST_CASE_ST(ut_setup, ut_teardown,
13588 test_snow3g_encryption_test_case_3),
13589 TEST_CASE_ST(ut_setup, ut_teardown,
13590 test_snow3g_encryption_test_case_4),
13591 TEST_CASE_ST(ut_setup, ut_teardown,
13592 test_snow3g_encryption_test_case_5),
13594 TEST_CASE_ST(ut_setup, ut_teardown,
13595 test_snow3g_encryption_test_case_1_oop),
13596 TEST_CASE_ST(ut_setup, ut_teardown,
13597 test_snow3g_encryption_test_case_1_oop_sgl),
13598 TEST_CASE_ST(ut_setup, ut_teardown,
13599 test_snow3g_decryption_test_case_1_oop),
13601 /** SNOW 3G decrypt only (UEA2) */
13602 TEST_CASE_ST(ut_setup, ut_teardown,
13603 test_snow3g_decryption_test_case_1),
13604 TEST_CASE_ST(ut_setup, ut_teardown,
13605 test_snow3g_decryption_test_case_2),
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_snow3g_decryption_test_case_3),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_snow3g_decryption_test_case_4),
13610 TEST_CASE_ST(ut_setup, ut_teardown,
13611 test_snow3g_decryption_test_case_5),
13613 TEST_CASE_ST(ut_setup, ut_teardown,
13614 test_snow3g_hash_generate_test_case_1),
13615 TEST_CASE_ST(ut_setup, ut_teardown,
13616 test_snow3g_hash_generate_test_case_2),
13617 TEST_CASE_ST(ut_setup, ut_teardown,
13618 test_snow3g_hash_generate_test_case_3),
13619 TEST_CASE_ST(ut_setup, ut_teardown,
13620 test_snow3g_hash_verify_test_case_1),
13621 TEST_CASE_ST(ut_setup, ut_teardown,
13622 test_snow3g_hash_verify_test_case_2),
13623 TEST_CASE_ST(ut_setup, ut_teardown,
13624 test_snow3g_hash_verify_test_case_3),
13626 /** ZUC encrypt only (EEA3) */
13627 TEST_CASE_ST(ut_setup, ut_teardown,
13628 test_zuc_encryption_test_case_1),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 test_zuc_encryption_test_case_2),
13631 TEST_CASE_ST(ut_setup, ut_teardown,
13632 test_zuc_encryption_test_case_3),
13633 TEST_CASE_ST(ut_setup, ut_teardown,
13634 test_zuc_encryption_test_case_4),
13635 TEST_CASE_ST(ut_setup, ut_teardown,
13636 test_zuc_encryption_test_case_5),
13638 /** ZUC authenticate (EIA3) */
13639 TEST_CASE_ST(ut_setup, ut_teardown,
13640 test_zuc_hash_generate_test_case_6),
13641 TEST_CASE_ST(ut_setup, ut_teardown,
13642 test_zuc_hash_generate_test_case_7),
13643 TEST_CASE_ST(ut_setup, ut_teardown,
13644 test_zuc_hash_generate_test_case_8),
13646 /** Negative tests */
13647 TEST_CASE_ST(ut_setup, ut_teardown,
13648 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13649 TEST_CASE_ST(ut_setup, ut_teardown,
13650 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13651 TEST_CASE_ST(ut_setup, ut_teardown,
13652 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13653 TEST_CASE_ST(ut_setup, ut_teardown,
13654 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13655 TEST_CASE_ST(ut_setup, ut_teardown,
13656 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13657 TEST_CASE_ST(ut_setup, ut_teardown,
13658 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13659 TEST_CASE_ST(ut_setup, ut_teardown,
13660 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13661 TEST_CASE_ST(ut_setup, ut_teardown,
13662 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13663 TEST_CASE_ST(ut_setup, ut_teardown,
13664 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13665 TEST_CASE_ST(ut_setup, ut_teardown,
13666 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13667 TEST_CASE_ST(ut_setup, ut_teardown,
13668 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13669 TEST_CASE_ST(ut_setup, ut_teardown,
13670 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13671 TEST_CASE_ST(ut_setup, ut_teardown,
13672 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13673 TEST_CASE_ST(ut_setup, ut_teardown,
13674 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13675 TEST_CASE_ST(ut_setup, ut_teardown,
13676 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13677 TEST_CASE_ST(ut_setup, ut_teardown,
13678 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13681 TEST_CASE_ST(ut_setup, ut_teardown,
13682 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13683 TEST_CASE_ST(ut_setup, ut_teardown,
13684 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13686 TEST_CASES_END() /**< NULL terminate unit test array */
13690 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
13691 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13692 .setup = testsuite_setup,
13693 .teardown = testsuite_teardown,
13694 .unit_test_cases = {
13695 TEST_CASE_ST(ut_setup, ut_teardown,
13696 test_device_configure_invalid_dev_id),
13697 TEST_CASE_ST(ut_setup, ut_teardown,
13698 test_multi_session),
13699 TEST_CASE_ST(ut_setup, ut_teardown,
13700 test_AES_chain_dpaa2_sec_all),
13701 TEST_CASE_ST(ut_setup, ut_teardown,
13702 test_3DES_chain_dpaa2_sec_all),
13703 TEST_CASE_ST(ut_setup, ut_teardown,
13704 test_AES_cipheronly_dpaa2_sec_all),
13705 TEST_CASE_ST(ut_setup, ut_teardown,
13706 test_3DES_cipheronly_dpaa2_sec_all),
13707 TEST_CASE_ST(ut_setup, ut_teardown,
13708 test_authonly_dpaa2_sec_all),
13710 #ifdef RTE_LIBRTE_SECURITY
13711 TEST_CASE_ST(ut_setup, ut_teardown,
13712 test_PDCP_PROTO_cplane_encap_all),
13714 TEST_CASE_ST(ut_setup, ut_teardown,
13715 test_PDCP_PROTO_cplane_decap_all),
13717 TEST_CASE_ST(ut_setup, ut_teardown,
13718 test_PDCP_PROTO_uplane_encap_all),
13720 TEST_CASE_ST(ut_setup, ut_teardown,
13721 test_PDCP_PROTO_uplane_decap_all),
13723 TEST_CASE_ST(ut_setup, ut_teardown,
13724 test_PDCP_PROTO_SGL_in_place_32B),
13725 TEST_CASE_ST(ut_setup, ut_teardown,
13726 test_PDCP_PROTO_SGL_oop_32B_128B),
13727 TEST_CASE_ST(ut_setup, ut_teardown,
13728 test_PDCP_PROTO_SGL_oop_32B_40B),
13729 TEST_CASE_ST(ut_setup, ut_teardown,
13730 test_PDCP_PROTO_SGL_oop_128B_32B),
13732 /** AES GCM Authenticated Encryption */
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13737 TEST_CASE_ST(ut_setup, ut_teardown,
13738 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13739 TEST_CASE_ST(ut_setup, ut_teardown,
13740 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13741 TEST_CASE_ST(ut_setup, ut_teardown,
13742 test_AES_GCM_authenticated_encryption_test_case_1),
13743 TEST_CASE_ST(ut_setup, ut_teardown,
13744 test_AES_GCM_authenticated_encryption_test_case_2),
13745 TEST_CASE_ST(ut_setup, ut_teardown,
13746 test_AES_GCM_authenticated_encryption_test_case_3),
13747 TEST_CASE_ST(ut_setup, ut_teardown,
13748 test_AES_GCM_authenticated_encryption_test_case_4),
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 test_AES_GCM_authenticated_encryption_test_case_5),
13751 TEST_CASE_ST(ut_setup, ut_teardown,
13752 test_AES_GCM_authenticated_encryption_test_case_6),
13753 TEST_CASE_ST(ut_setup, ut_teardown,
13754 test_AES_GCM_authenticated_encryption_test_case_7),
13755 TEST_CASE_ST(ut_setup, ut_teardown,
13756 test_AES_GCM_authenticated_encryption_test_case_8),
13758 /** AES GCM Authenticated Decryption */
13759 TEST_CASE_ST(ut_setup, ut_teardown,
13760 test_AES_GCM_authenticated_decryption_test_case_1),
13761 TEST_CASE_ST(ut_setup, ut_teardown,
13762 test_AES_GCM_authenticated_decryption_test_case_2),
13763 TEST_CASE_ST(ut_setup, ut_teardown,
13764 test_AES_GCM_authenticated_decryption_test_case_3),
13765 TEST_CASE_ST(ut_setup, ut_teardown,
13766 test_AES_GCM_authenticated_decryption_test_case_4),
13767 TEST_CASE_ST(ut_setup, ut_teardown,
13768 test_AES_GCM_authenticated_decryption_test_case_5),
13769 TEST_CASE_ST(ut_setup, ut_teardown,
13770 test_AES_GCM_authenticated_decryption_test_case_6),
13771 TEST_CASE_ST(ut_setup, ut_teardown,
13772 test_AES_GCM_authenticated_decryption_test_case_7),
13773 TEST_CASE_ST(ut_setup, ut_teardown,
13774 test_AES_GCM_authenticated_decryption_test_case_8),
13776 /** AES GCM Authenticated Encryption 192 bits key */
13777 TEST_CASE_ST(ut_setup, ut_teardown,
13778 test_AES_GCM_auth_encryption_test_case_192_1),
13779 TEST_CASE_ST(ut_setup, ut_teardown,
13780 test_AES_GCM_auth_encryption_test_case_192_2),
13781 TEST_CASE_ST(ut_setup, ut_teardown,
13782 test_AES_GCM_auth_encryption_test_case_192_3),
13783 TEST_CASE_ST(ut_setup, ut_teardown,
13784 test_AES_GCM_auth_encryption_test_case_192_4),
13785 TEST_CASE_ST(ut_setup, ut_teardown,
13786 test_AES_GCM_auth_encryption_test_case_192_5),
13787 TEST_CASE_ST(ut_setup, ut_teardown,
13788 test_AES_GCM_auth_encryption_test_case_192_6),
13789 TEST_CASE_ST(ut_setup, ut_teardown,
13790 test_AES_GCM_auth_encryption_test_case_192_7),
13792 /** AES GCM Authenticated Decryption 192 bits key */
13793 TEST_CASE_ST(ut_setup, ut_teardown,
13794 test_AES_GCM_auth_decryption_test_case_192_1),
13795 TEST_CASE_ST(ut_setup, ut_teardown,
13796 test_AES_GCM_auth_decryption_test_case_192_2),
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 test_AES_GCM_auth_decryption_test_case_192_3),
13799 TEST_CASE_ST(ut_setup, ut_teardown,
13800 test_AES_GCM_auth_decryption_test_case_192_4),
13801 TEST_CASE_ST(ut_setup, ut_teardown,
13802 test_AES_GCM_auth_decryption_test_case_192_5),
13803 TEST_CASE_ST(ut_setup, ut_teardown,
13804 test_AES_GCM_auth_decryption_test_case_192_6),
13805 TEST_CASE_ST(ut_setup, ut_teardown,
13806 test_AES_GCM_auth_decryption_test_case_192_7),
13808 /** AES GCM Authenticated Encryption 256 bits key */
13809 TEST_CASE_ST(ut_setup, ut_teardown,
13810 test_AES_GCM_auth_encryption_test_case_256_1),
13811 TEST_CASE_ST(ut_setup, ut_teardown,
13812 test_AES_GCM_auth_encryption_test_case_256_2),
13813 TEST_CASE_ST(ut_setup, ut_teardown,
13814 test_AES_GCM_auth_encryption_test_case_256_3),
13815 TEST_CASE_ST(ut_setup, ut_teardown,
13816 test_AES_GCM_auth_encryption_test_case_256_4),
13817 TEST_CASE_ST(ut_setup, ut_teardown,
13818 test_AES_GCM_auth_encryption_test_case_256_5),
13819 TEST_CASE_ST(ut_setup, ut_teardown,
13820 test_AES_GCM_auth_encryption_test_case_256_6),
13821 TEST_CASE_ST(ut_setup, ut_teardown,
13822 test_AES_GCM_auth_encryption_test_case_256_7),
13824 /** AES GCM Authenticated Decryption 256 bits key */
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 test_AES_GCM_auth_decryption_test_case_256_1),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_AES_GCM_auth_decryption_test_case_256_2),
13829 TEST_CASE_ST(ut_setup, ut_teardown,
13830 test_AES_GCM_auth_decryption_test_case_256_3),
13831 TEST_CASE_ST(ut_setup, ut_teardown,
13832 test_AES_GCM_auth_decryption_test_case_256_4),
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 test_AES_GCM_auth_decryption_test_case_256_5),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 test_AES_GCM_auth_decryption_test_case_256_6),
13837 TEST_CASE_ST(ut_setup, ut_teardown,
13838 test_AES_GCM_auth_decryption_test_case_256_7),
13840 /** Out of place tests */
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13843 TEST_CASE_ST(ut_setup, ut_teardown,
13844 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13846 /** SNOW 3G encrypt only (UEA2) */
13847 TEST_CASE_ST(ut_setup, ut_teardown,
13848 test_snow3g_encryption_test_case_1),
13849 TEST_CASE_ST(ut_setup, ut_teardown,
13850 test_snow3g_encryption_test_case_2),
13851 TEST_CASE_ST(ut_setup, ut_teardown,
13852 test_snow3g_encryption_test_case_3),
13853 TEST_CASE_ST(ut_setup, ut_teardown,
13854 test_snow3g_encryption_test_case_4),
13855 TEST_CASE_ST(ut_setup, ut_teardown,
13856 test_snow3g_encryption_test_case_5),
13858 TEST_CASE_ST(ut_setup, ut_teardown,
13859 test_snow3g_encryption_test_case_1_oop),
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_snow3g_encryption_test_case_1_oop_sgl),
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_snow3g_decryption_test_case_1_oop),
13865 /** SNOW 3G decrypt only (UEA2) */
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_snow3g_decryption_test_case_1),
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_snow3g_decryption_test_case_2),
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_snow3g_decryption_test_case_3),
13872 TEST_CASE_ST(ut_setup, ut_teardown,
13873 test_snow3g_decryption_test_case_4),
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_snow3g_decryption_test_case_5),
13877 TEST_CASE_ST(ut_setup, ut_teardown,
13878 test_snow3g_hash_generate_test_case_1),
13879 TEST_CASE_ST(ut_setup, ut_teardown,
13880 test_snow3g_hash_generate_test_case_2),
13881 TEST_CASE_ST(ut_setup, ut_teardown,
13882 test_snow3g_hash_generate_test_case_3),
13883 TEST_CASE_ST(ut_setup, ut_teardown,
13884 test_snow3g_hash_verify_test_case_1),
13885 TEST_CASE_ST(ut_setup, ut_teardown,
13886 test_snow3g_hash_verify_test_case_2),
13887 TEST_CASE_ST(ut_setup, ut_teardown,
13888 test_snow3g_hash_verify_test_case_3),
13890 /** ZUC encrypt only (EEA3) */
13891 TEST_CASE_ST(ut_setup, ut_teardown,
13892 test_zuc_encryption_test_case_1),
13893 TEST_CASE_ST(ut_setup, ut_teardown,
13894 test_zuc_encryption_test_case_2),
13895 TEST_CASE_ST(ut_setup, ut_teardown,
13896 test_zuc_encryption_test_case_3),
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_zuc_encryption_test_case_4),
13899 TEST_CASE_ST(ut_setup, ut_teardown,
13900 test_zuc_encryption_test_case_5),
13902 /** ZUC authenticate (EIA3) */
13903 TEST_CASE_ST(ut_setup, ut_teardown,
13904 test_zuc_hash_generate_test_case_6),
13905 TEST_CASE_ST(ut_setup, ut_teardown,
13906 test_zuc_hash_generate_test_case_7),
13907 TEST_CASE_ST(ut_setup, ut_teardown,
13908 test_zuc_hash_generate_test_case_8),
13910 /** HMAC_MD5 Authentication */
13911 TEST_CASE_ST(ut_setup, ut_teardown,
13912 test_MD5_HMAC_generate_case_1),
13913 TEST_CASE_ST(ut_setup, ut_teardown,
13914 test_MD5_HMAC_verify_case_1),
13915 TEST_CASE_ST(ut_setup, ut_teardown,
13916 test_MD5_HMAC_generate_case_2),
13917 TEST_CASE_ST(ut_setup, ut_teardown,
13918 test_MD5_HMAC_verify_case_2),
13920 /** Negative tests */
13921 TEST_CASE_ST(ut_setup, ut_teardown,
13922 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13923 TEST_CASE_ST(ut_setup, ut_teardown,
13924 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13925 TEST_CASE_ST(ut_setup, ut_teardown,
13926 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13927 TEST_CASE_ST(ut_setup, ut_teardown,
13928 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13929 TEST_CASE_ST(ut_setup, ut_teardown,
13930 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13931 TEST_CASE_ST(ut_setup, ut_teardown,
13932 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13933 TEST_CASE_ST(ut_setup, ut_teardown,
13934 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13935 TEST_CASE_ST(ut_setup, ut_teardown,
13936 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13937 TEST_CASE_ST(ut_setup, ut_teardown,
13938 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13939 TEST_CASE_ST(ut_setup, ut_teardown,
13940 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13941 TEST_CASE_ST(ut_setup, ut_teardown,
13942 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13943 TEST_CASE_ST(ut_setup, ut_teardown,
13944 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13945 TEST_CASE_ST(ut_setup, ut_teardown,
13946 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13947 TEST_CASE_ST(ut_setup, ut_teardown,
13948 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13949 TEST_CASE_ST(ut_setup, ut_teardown,
13950 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13951 TEST_CASE_ST(ut_setup, ut_teardown,
13952 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13955 TEST_CASE_ST(ut_setup, ut_teardown,
13956 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13958 TEST_CASE_ST(ut_setup, ut_teardown,
13959 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13961 TEST_CASES_END() /**< NULL terminate unit test array */
13965 static struct unit_test_suite cryptodev_null_testsuite = {
13966 .suite_name = "Crypto Device NULL Unit Test Suite",
13967 .setup = testsuite_setup,
13968 .teardown = testsuite_teardown,
13969 .unit_test_cases = {
13970 TEST_CASE_ST(ut_setup, ut_teardown,
13971 test_null_invalid_operation),
13972 TEST_CASE_ST(ut_setup, ut_teardown,
13973 test_null_burst_operation),
13974 TEST_CASE_ST(ut_setup, ut_teardown,
13975 test_AES_chain_null_all),
13976 TEST_CASE_ST(ut_setup, ut_teardown,
13977 test_AES_cipheronly_null_all),
13978 TEST_CASE_ST(ut_setup, ut_teardown,
13979 test_authonly_null_all),
13981 TEST_CASES_END() /**< NULL terminate unit test array */
13985 static struct unit_test_suite cryptodev_armv8_testsuite = {
13986 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13987 .setup = testsuite_setup,
13988 .teardown = testsuite_teardown,
13989 .unit_test_cases = {
13990 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13992 /** Negative tests */
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13995 TEST_CASE_ST(ut_setup, ut_teardown,
13996 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13998 TEST_CASES_END() /**< NULL terminate unit test array */
14002 static struct unit_test_suite cryptodev_mrvl_testsuite = {
14003 .suite_name = "Crypto Device Marvell Component Test Suite",
14004 .setup = testsuite_setup,
14005 .teardown = testsuite_teardown,
14006 .unit_test_cases = {
14007 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14008 TEST_CASE_ST(ut_setup, ut_teardown,
14009 test_multi_session_random_usage),
14010 TEST_CASE_ST(ut_setup, ut_teardown,
14011 test_AES_chain_mrvl_all),
14012 TEST_CASE_ST(ut_setup, ut_teardown,
14013 test_AES_cipheronly_mrvl_all),
14014 TEST_CASE_ST(ut_setup, ut_teardown,
14015 test_authonly_mrvl_all),
14016 TEST_CASE_ST(ut_setup, ut_teardown,
14017 test_3DES_chain_mrvl_all),
14018 TEST_CASE_ST(ut_setup, ut_teardown,
14019 test_3DES_cipheronly_mrvl_all),
14021 /** Negative tests */
14022 TEST_CASE_ST(ut_setup, ut_teardown,
14023 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14024 TEST_CASE_ST(ut_setup, ut_teardown,
14025 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14026 TEST_CASE_ST(ut_setup, ut_teardown,
14027 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14028 TEST_CASE_ST(ut_setup, ut_teardown,
14029 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14031 TEST_CASES_END() /**< NULL terminate unit test array */
14035 static struct unit_test_suite cryptodev_ccp_testsuite = {
14036 .suite_name = "Crypto Device CCP Unit Test Suite",
14037 .setup = testsuite_setup,
14038 .teardown = testsuite_teardown,
14039 .unit_test_cases = {
14040 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14041 TEST_CASE_ST(ut_setup, ut_teardown,
14042 test_multi_session_random_usage),
14043 TEST_CASE_ST(ut_setup, ut_teardown,
14044 test_AES_chain_ccp_all),
14045 TEST_CASE_ST(ut_setup, ut_teardown,
14046 test_AES_cipheronly_ccp_all),
14047 TEST_CASE_ST(ut_setup, ut_teardown,
14048 test_3DES_chain_ccp_all),
14049 TEST_CASE_ST(ut_setup, ut_teardown,
14050 test_3DES_cipheronly_ccp_all),
14051 TEST_CASE_ST(ut_setup, ut_teardown,
14052 test_authonly_ccp_all),
14054 /** Negative tests */
14055 TEST_CASE_ST(ut_setup, ut_teardown,
14056 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14057 TEST_CASE_ST(ut_setup, ut_teardown,
14058 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14059 TEST_CASE_ST(ut_setup, ut_teardown,
14060 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14061 TEST_CASE_ST(ut_setup, ut_teardown,
14062 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14064 TEST_CASES_END() /**< NULL terminate unit test array */
14068 static struct unit_test_suite cryptodev_octeontx_testsuite = {
14069 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
14070 .setup = testsuite_setup,
14071 .teardown = testsuite_teardown,
14072 .unit_test_cases = {
14073 TEST_CASE_ST(ut_setup, ut_teardown,
14074 test_AES_chain_octeontx_all),
14075 TEST_CASE_ST(ut_setup, ut_teardown,
14076 test_AES_cipheronly_octeontx_all),
14077 TEST_CASE_ST(ut_setup, ut_teardown,
14078 test_3DES_chain_octeontx_all),
14079 TEST_CASE_ST(ut_setup, ut_teardown,
14080 test_3DES_cipheronly_octeontx_all),
14081 TEST_CASE_ST(ut_setup, ut_teardown,
14082 test_authonly_octeontx_all),
14084 /** AES GCM Authenticated Encryption */
14085 TEST_CASE_ST(ut_setup, ut_teardown,
14086 test_AES_GCM_authenticated_encryption_test_case_1),
14087 TEST_CASE_ST(ut_setup, ut_teardown,
14088 test_AES_GCM_authenticated_encryption_test_case_2),
14089 TEST_CASE_ST(ut_setup, ut_teardown,
14090 test_AES_GCM_authenticated_encryption_test_case_3),
14091 TEST_CASE_ST(ut_setup, ut_teardown,
14092 test_AES_GCM_authenticated_encryption_test_case_4),
14093 TEST_CASE_ST(ut_setup, ut_teardown,
14094 test_AES_GCM_authenticated_encryption_test_case_5),
14095 TEST_CASE_ST(ut_setup, ut_teardown,
14096 test_AES_GCM_authenticated_encryption_test_case_6),
14097 TEST_CASE_ST(ut_setup, ut_teardown,
14098 test_AES_GCM_authenticated_encryption_test_case_7),
14100 /** AES GCM Authenticated Decryption */
14101 TEST_CASE_ST(ut_setup, ut_teardown,
14102 test_AES_GCM_authenticated_decryption_test_case_1),
14103 TEST_CASE_ST(ut_setup, ut_teardown,
14104 test_AES_GCM_authenticated_decryption_test_case_2),
14105 TEST_CASE_ST(ut_setup, ut_teardown,
14106 test_AES_GCM_authenticated_decryption_test_case_3),
14107 TEST_CASE_ST(ut_setup, ut_teardown,
14108 test_AES_GCM_authenticated_decryption_test_case_4),
14109 TEST_CASE_ST(ut_setup, ut_teardown,
14110 test_AES_GCM_authenticated_decryption_test_case_5),
14111 TEST_CASE_ST(ut_setup, ut_teardown,
14112 test_AES_GCM_authenticated_decryption_test_case_6),
14113 TEST_CASE_ST(ut_setup, ut_teardown,
14114 test_AES_GCM_authenticated_decryption_test_case_7),
14115 /** AES GMAC Authentication */
14116 TEST_CASE_ST(ut_setup, ut_teardown,
14117 test_AES_GMAC_authentication_test_case_1),
14118 TEST_CASE_ST(ut_setup, ut_teardown,
14119 test_AES_GMAC_authentication_verify_test_case_1),
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_AES_GMAC_authentication_test_case_2),
14122 TEST_CASE_ST(ut_setup, ut_teardown,
14123 test_AES_GMAC_authentication_verify_test_case_2),
14124 TEST_CASE_ST(ut_setup, ut_teardown,
14125 test_AES_GMAC_authentication_test_case_3),
14126 TEST_CASE_ST(ut_setup, ut_teardown,
14127 test_AES_GMAC_authentication_verify_test_case_3),
14129 /** SNOW 3G encrypt only (UEA2) */
14130 TEST_CASE_ST(ut_setup, ut_teardown,
14131 test_snow3g_encryption_test_case_1),
14132 TEST_CASE_ST(ut_setup, ut_teardown,
14133 test_snow3g_encryption_test_case_2),
14134 TEST_CASE_ST(ut_setup, ut_teardown,
14135 test_snow3g_encryption_test_case_3),
14136 TEST_CASE_ST(ut_setup, ut_teardown,
14137 test_snow3g_encryption_test_case_4),
14138 TEST_CASE_ST(ut_setup, ut_teardown,
14139 test_snow3g_encryption_test_case_5),
14141 TEST_CASE_ST(ut_setup, ut_teardown,
14142 test_snow3g_encryption_test_case_1_oop),
14143 TEST_CASE_ST(ut_setup, ut_teardown,
14144 test_snow3g_decryption_test_case_1_oop),
14145 TEST_CASE_ST(ut_setup, ut_teardown,
14146 test_snow3g_encryption_test_case_1_oop_sgl),
14148 /** SNOW 3G decrypt only (UEA2) */
14149 TEST_CASE_ST(ut_setup, ut_teardown,
14150 test_snow3g_decryption_test_case_1),
14151 TEST_CASE_ST(ut_setup, ut_teardown,
14152 test_snow3g_decryption_test_case_2),
14153 TEST_CASE_ST(ut_setup, ut_teardown,
14154 test_snow3g_decryption_test_case_3),
14155 TEST_CASE_ST(ut_setup, ut_teardown,
14156 test_snow3g_decryption_test_case_4),
14157 TEST_CASE_ST(ut_setup, ut_teardown,
14158 test_snow3g_decryption_test_case_5),
14160 TEST_CASE_ST(ut_setup, ut_teardown,
14161 test_snow3g_hash_generate_test_case_1),
14162 TEST_CASE_ST(ut_setup, ut_teardown,
14163 test_snow3g_hash_generate_test_case_2),
14164 TEST_CASE_ST(ut_setup, ut_teardown,
14165 test_snow3g_hash_generate_test_case_3),
14166 TEST_CASE_ST(ut_setup, ut_teardown,
14167 test_snow3g_hash_verify_test_case_1),
14168 TEST_CASE_ST(ut_setup, ut_teardown,
14169 test_snow3g_hash_verify_test_case_2),
14170 TEST_CASE_ST(ut_setup, ut_teardown,
14171 test_snow3g_hash_verify_test_case_3),
14173 /** ZUC encrypt only (EEA3) */
14174 TEST_CASE_ST(ut_setup, ut_teardown,
14175 test_zuc_encryption_test_case_1),
14176 TEST_CASE_ST(ut_setup, ut_teardown,
14177 test_zuc_encryption_test_case_2),
14178 TEST_CASE_ST(ut_setup, ut_teardown,
14179 test_zuc_encryption_test_case_3),
14180 TEST_CASE_ST(ut_setup, ut_teardown,
14181 test_zuc_encryption_test_case_4),
14182 TEST_CASE_ST(ut_setup, ut_teardown,
14183 test_zuc_encryption_test_case_5),
14184 TEST_CASE_ST(ut_setup, ut_teardown,
14185 test_zuc_hash_generate_test_case_1),
14186 TEST_CASE_ST(ut_setup, ut_teardown,
14187 test_zuc_hash_generate_test_case_2),
14188 TEST_CASE_ST(ut_setup, ut_teardown,
14189 test_zuc_hash_generate_test_case_3),
14190 TEST_CASE_ST(ut_setup, ut_teardown,
14191 test_zuc_hash_generate_test_case_4),
14192 TEST_CASE_ST(ut_setup, ut_teardown,
14193 test_zuc_hash_generate_test_case_5),
14194 TEST_CASE_ST(ut_setup, ut_teardown,
14195 test_zuc_encryption_test_case_6_sgl),
14197 /** KASUMI encrypt only (UEA1) */
14198 TEST_CASE_ST(ut_setup, ut_teardown,
14199 test_kasumi_encryption_test_case_1),
14200 TEST_CASE_ST(ut_setup, ut_teardown,
14201 test_kasumi_encryption_test_case_2),
14202 TEST_CASE_ST(ut_setup, ut_teardown,
14203 test_kasumi_encryption_test_case_3),
14204 TEST_CASE_ST(ut_setup, ut_teardown,
14205 test_kasumi_encryption_test_case_4),
14206 TEST_CASE_ST(ut_setup, ut_teardown,
14207 test_kasumi_encryption_test_case_5),
14208 TEST_CASE_ST(ut_setup, ut_teardown,
14209 test_kasumi_encryption_test_case_1_sgl),
14210 TEST_CASE_ST(ut_setup, ut_teardown,
14211 test_kasumi_encryption_test_case_1_oop_sgl),
14212 /** KASUMI decrypt only (UEA1) */
14213 TEST_CASE_ST(ut_setup, ut_teardown,
14214 test_kasumi_decryption_test_case_1),
14215 TEST_CASE_ST(ut_setup, ut_teardown,
14216 test_kasumi_decryption_test_case_2),
14217 TEST_CASE_ST(ut_setup, ut_teardown,
14218 test_kasumi_decryption_test_case_3),
14219 TEST_CASE_ST(ut_setup, ut_teardown,
14220 test_kasumi_decryption_test_case_4),
14221 TEST_CASE_ST(ut_setup, ut_teardown,
14222 test_kasumi_decryption_test_case_5),
14224 TEST_CASE_ST(ut_setup, ut_teardown,
14225 test_kasumi_encryption_test_case_1_oop),
14226 TEST_CASE_ST(ut_setup, ut_teardown,
14227 test_kasumi_decryption_test_case_1_oop),
14229 /** KASUMI hash only (UIA1) */
14230 TEST_CASE_ST(ut_setup, ut_teardown,
14231 test_kasumi_hash_generate_test_case_1),
14232 TEST_CASE_ST(ut_setup, ut_teardown,
14233 test_kasumi_hash_generate_test_case_2),
14234 TEST_CASE_ST(ut_setup, ut_teardown,
14235 test_kasumi_hash_generate_test_case_3),
14236 TEST_CASE_ST(ut_setup, ut_teardown,
14237 test_kasumi_hash_generate_test_case_4),
14238 TEST_CASE_ST(ut_setup, ut_teardown,
14239 test_kasumi_hash_generate_test_case_5),
14240 TEST_CASE_ST(ut_setup, ut_teardown,
14241 test_kasumi_hash_generate_test_case_6),
14242 TEST_CASE_ST(ut_setup, ut_teardown,
14243 test_kasumi_hash_verify_test_case_1),
14244 TEST_CASE_ST(ut_setup, ut_teardown,
14245 test_kasumi_hash_verify_test_case_2),
14246 TEST_CASE_ST(ut_setup, ut_teardown,
14247 test_kasumi_hash_verify_test_case_3),
14248 TEST_CASE_ST(ut_setup, ut_teardown,
14249 test_kasumi_hash_verify_test_case_4),
14250 TEST_CASE_ST(ut_setup, ut_teardown,
14251 test_kasumi_hash_verify_test_case_5),
14254 TEST_CASE_ST(ut_setup, ut_teardown,
14255 test_null_cipher_only_operation),
14256 TEST_CASE_ST(ut_setup, ut_teardown,
14257 test_null_auth_only_operation),
14258 TEST_CASE_ST(ut_setup, ut_teardown,
14259 test_null_cipher_auth_operation),
14260 TEST_CASE_ST(ut_setup, ut_teardown,
14261 test_null_auth_cipher_operation),
14263 /** Negative tests */
14264 TEST_CASE_ST(ut_setup, ut_teardown,
14265 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14266 TEST_CASE_ST(ut_setup, ut_teardown,
14267 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14268 TEST_CASE_ST(ut_setup, ut_teardown,
14269 authentication_verify_AES128_GMAC_fail_data_corrupt),
14270 TEST_CASE_ST(ut_setup, ut_teardown,
14271 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14272 TEST_CASE_ST(ut_setup, ut_teardown,
14273 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14274 TEST_CASE_ST(ut_setup, ut_teardown,
14275 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14276 TEST_CASES_END() /**< NULL terminate unit test array */
14280 static struct unit_test_suite cryptodev_nitrox_testsuite = {
14281 .suite_name = "Crypto NITROX Unit Test Suite",
14282 .setup = testsuite_setup,
14283 .teardown = testsuite_teardown,
14284 .unit_test_cases = {
14285 TEST_CASE_ST(ut_setup, ut_teardown,
14286 test_device_configure_invalid_dev_id),
14287 TEST_CASE_ST(ut_setup, ut_teardown,
14288 test_device_configure_invalid_queue_pair_ids),
14289 TEST_CASE_ST(ut_setup, ut_teardown,
14290 test_AES_chain_nitrox_all),
14292 TEST_CASES_END() /**< NULL terminate unit test array */
14296 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
14297 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
14298 .setup = testsuite_setup,
14299 .teardown = testsuite_teardown,
14300 .unit_test_cases = {
14301 TEST_CASE_ST(ut_setup, ut_teardown,
14302 test_AES_chain_octeontx2_all),
14303 TEST_CASE_ST(ut_setup, ut_teardown,
14304 test_AES_cipheronly_octeontx2_all),
14305 TEST_CASE_ST(ut_setup, ut_teardown,
14306 test_3DES_chain_octeontx2_all),
14307 TEST_CASE_ST(ut_setup, ut_teardown,
14308 test_3DES_cipheronly_octeontx2_all),
14309 TEST_CASE_ST(ut_setup, ut_teardown,
14310 test_authonly_octeontx2_all),
14312 /** AES GCM Authenticated Encryption */
14313 TEST_CASE_ST(ut_setup, ut_teardown,
14314 test_AES_GCM_authenticated_encryption_test_case_1),
14315 TEST_CASE_ST(ut_setup, ut_teardown,
14316 test_AES_GCM_authenticated_encryption_test_case_2),
14317 TEST_CASE_ST(ut_setup, ut_teardown,
14318 test_AES_GCM_authenticated_encryption_test_case_3),
14319 TEST_CASE_ST(ut_setup, ut_teardown,
14320 test_AES_GCM_authenticated_encryption_test_case_4),
14321 TEST_CASE_ST(ut_setup, ut_teardown,
14322 test_AES_GCM_authenticated_encryption_test_case_5),
14323 TEST_CASE_ST(ut_setup, ut_teardown,
14324 test_AES_GCM_authenticated_encryption_test_case_6),
14325 TEST_CASE_ST(ut_setup, ut_teardown,
14326 test_AES_GCM_authenticated_encryption_test_case_7),
14328 /** AES GCM Authenticated Decryption */
14329 TEST_CASE_ST(ut_setup, ut_teardown,
14330 test_AES_GCM_authenticated_decryption_test_case_1),
14331 TEST_CASE_ST(ut_setup, ut_teardown,
14332 test_AES_GCM_authenticated_decryption_test_case_2),
14333 TEST_CASE_ST(ut_setup, ut_teardown,
14334 test_AES_GCM_authenticated_decryption_test_case_3),
14335 TEST_CASE_ST(ut_setup, ut_teardown,
14336 test_AES_GCM_authenticated_decryption_test_case_4),
14337 TEST_CASE_ST(ut_setup, ut_teardown,
14338 test_AES_GCM_authenticated_decryption_test_case_5),
14339 TEST_CASE_ST(ut_setup, ut_teardown,
14340 test_AES_GCM_authenticated_decryption_test_case_6),
14341 TEST_CASE_ST(ut_setup, ut_teardown,
14342 test_AES_GCM_authenticated_decryption_test_case_7),
14343 /** AES GMAC Authentication */
14344 TEST_CASE_ST(ut_setup, ut_teardown,
14345 test_AES_GMAC_authentication_test_case_1),
14346 TEST_CASE_ST(ut_setup, ut_teardown,
14347 test_AES_GMAC_authentication_verify_test_case_1),
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_AES_GMAC_authentication_test_case_2),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_AES_GMAC_authentication_verify_test_case_2),
14352 TEST_CASE_ST(ut_setup, ut_teardown,
14353 test_AES_GMAC_authentication_test_case_3),
14354 TEST_CASE_ST(ut_setup, ut_teardown,
14355 test_AES_GMAC_authentication_verify_test_case_3),
14357 /** SNOW 3G encrypt only (UEA2) */
14358 TEST_CASE_ST(ut_setup, ut_teardown,
14359 test_snow3g_encryption_test_case_1),
14360 TEST_CASE_ST(ut_setup, ut_teardown,
14361 test_snow3g_encryption_test_case_2),
14362 TEST_CASE_ST(ut_setup, ut_teardown,
14363 test_snow3g_encryption_test_case_3),
14364 TEST_CASE_ST(ut_setup, ut_teardown,
14365 test_snow3g_encryption_test_case_4),
14366 TEST_CASE_ST(ut_setup, ut_teardown,
14367 test_snow3g_encryption_test_case_5),
14369 TEST_CASE_ST(ut_setup, ut_teardown,
14370 test_snow3g_encryption_test_case_1_oop),
14371 TEST_CASE_ST(ut_setup, ut_teardown,
14372 test_snow3g_decryption_test_case_1_oop),
14373 TEST_CASE_ST(ut_setup, ut_teardown,
14374 test_snow3g_encryption_test_case_1_oop_sgl),
14376 /** SNOW 3G decrypt only (UEA2) */
14377 TEST_CASE_ST(ut_setup, ut_teardown,
14378 test_snow3g_decryption_test_case_1),
14379 TEST_CASE_ST(ut_setup, ut_teardown,
14380 test_snow3g_decryption_test_case_2),
14381 TEST_CASE_ST(ut_setup, ut_teardown,
14382 test_snow3g_decryption_test_case_3),
14383 TEST_CASE_ST(ut_setup, ut_teardown,
14384 test_snow3g_decryption_test_case_4),
14385 TEST_CASE_ST(ut_setup, ut_teardown,
14386 test_snow3g_decryption_test_case_5),
14388 TEST_CASE_ST(ut_setup, ut_teardown,
14389 test_snow3g_hash_generate_test_case_1),
14390 TEST_CASE_ST(ut_setup, ut_teardown,
14391 test_snow3g_hash_generate_test_case_2),
14392 TEST_CASE_ST(ut_setup, ut_teardown,
14393 test_snow3g_hash_generate_test_case_3),
14394 TEST_CASE_ST(ut_setup, ut_teardown,
14395 test_snow3g_hash_verify_test_case_1),
14396 TEST_CASE_ST(ut_setup, ut_teardown,
14397 test_snow3g_hash_verify_test_case_2),
14398 TEST_CASE_ST(ut_setup, ut_teardown,
14399 test_snow3g_hash_verify_test_case_3),
14401 /** ZUC encrypt only (EEA3) */
14402 TEST_CASE_ST(ut_setup, ut_teardown,
14403 test_zuc_encryption_test_case_1),
14404 TEST_CASE_ST(ut_setup, ut_teardown,
14405 test_zuc_encryption_test_case_2),
14406 TEST_CASE_ST(ut_setup, ut_teardown,
14407 test_zuc_encryption_test_case_3),
14408 TEST_CASE_ST(ut_setup, ut_teardown,
14409 test_zuc_encryption_test_case_4),
14410 TEST_CASE_ST(ut_setup, ut_teardown,
14411 test_zuc_encryption_test_case_5),
14412 TEST_CASE_ST(ut_setup, ut_teardown,
14413 test_zuc_hash_generate_test_case_1),
14414 TEST_CASE_ST(ut_setup, ut_teardown,
14415 test_zuc_hash_generate_test_case_2),
14416 TEST_CASE_ST(ut_setup, ut_teardown,
14417 test_zuc_hash_generate_test_case_3),
14418 TEST_CASE_ST(ut_setup, ut_teardown,
14419 test_zuc_hash_generate_test_case_4),
14420 TEST_CASE_ST(ut_setup, ut_teardown,
14421 test_zuc_hash_generate_test_case_5),
14422 TEST_CASE_ST(ut_setup, ut_teardown,
14423 test_zuc_encryption_test_case_6_sgl),
14425 /** KASUMI encrypt only (UEA1) */
14426 TEST_CASE_ST(ut_setup, ut_teardown,
14427 test_kasumi_encryption_test_case_1),
14428 TEST_CASE_ST(ut_setup, ut_teardown,
14429 test_kasumi_encryption_test_case_2),
14430 TEST_CASE_ST(ut_setup, ut_teardown,
14431 test_kasumi_encryption_test_case_3),
14432 TEST_CASE_ST(ut_setup, ut_teardown,
14433 test_kasumi_encryption_test_case_4),
14434 TEST_CASE_ST(ut_setup, ut_teardown,
14435 test_kasumi_encryption_test_case_5),
14436 TEST_CASE_ST(ut_setup, ut_teardown,
14437 test_kasumi_encryption_test_case_1_sgl),
14438 TEST_CASE_ST(ut_setup, ut_teardown,
14439 test_kasumi_encryption_test_case_1_oop_sgl),
14440 /** KASUMI decrypt only (UEA1) */
14441 TEST_CASE_ST(ut_setup, ut_teardown,
14442 test_kasumi_decryption_test_case_1),
14443 TEST_CASE_ST(ut_setup, ut_teardown,
14444 test_kasumi_decryption_test_case_2),
14445 TEST_CASE_ST(ut_setup, ut_teardown,
14446 test_kasumi_decryption_test_case_3),
14447 TEST_CASE_ST(ut_setup, ut_teardown,
14448 test_kasumi_decryption_test_case_4),
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 test_kasumi_decryption_test_case_5),
14452 TEST_CASE_ST(ut_setup, ut_teardown,
14453 test_kasumi_encryption_test_case_1_oop),
14454 TEST_CASE_ST(ut_setup, ut_teardown,
14455 test_kasumi_decryption_test_case_1_oop),
14457 /** KASUMI hash only (UIA1) */
14458 TEST_CASE_ST(ut_setup, ut_teardown,
14459 test_kasumi_hash_generate_test_case_1),
14460 TEST_CASE_ST(ut_setup, ut_teardown,
14461 test_kasumi_hash_generate_test_case_2),
14462 TEST_CASE_ST(ut_setup, ut_teardown,
14463 test_kasumi_hash_generate_test_case_3),
14464 TEST_CASE_ST(ut_setup, ut_teardown,
14465 test_kasumi_hash_generate_test_case_4),
14466 TEST_CASE_ST(ut_setup, ut_teardown,
14467 test_kasumi_hash_generate_test_case_5),
14468 TEST_CASE_ST(ut_setup, ut_teardown,
14469 test_kasumi_hash_generate_test_case_6),
14470 TEST_CASE_ST(ut_setup, ut_teardown,
14471 test_kasumi_hash_verify_test_case_1),
14472 TEST_CASE_ST(ut_setup, ut_teardown,
14473 test_kasumi_hash_verify_test_case_2),
14474 TEST_CASE_ST(ut_setup, ut_teardown,
14475 test_kasumi_hash_verify_test_case_3),
14476 TEST_CASE_ST(ut_setup, ut_teardown,
14477 test_kasumi_hash_verify_test_case_4),
14478 TEST_CASE_ST(ut_setup, ut_teardown,
14479 test_kasumi_hash_verify_test_case_5),
14482 TEST_CASE_ST(ut_setup, ut_teardown,
14483 test_null_cipher_only_operation),
14484 TEST_CASE_ST(ut_setup, ut_teardown,
14485 test_null_auth_only_operation),
14486 TEST_CASE_ST(ut_setup, ut_teardown,
14487 test_null_cipher_auth_operation),
14488 TEST_CASE_ST(ut_setup, ut_teardown,
14489 test_null_auth_cipher_operation),
14491 /** Negative tests */
14492 TEST_CASE_ST(ut_setup, ut_teardown,
14493 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14494 TEST_CASE_ST(ut_setup, ut_teardown,
14495 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14496 TEST_CASE_ST(ut_setup, ut_teardown,
14497 authentication_verify_AES128_GMAC_fail_data_corrupt),
14498 TEST_CASE_ST(ut_setup, ut_teardown,
14499 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14500 TEST_CASE_ST(ut_setup, ut_teardown,
14501 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14502 TEST_CASE_ST(ut_setup, ut_teardown,
14503 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14504 TEST_CASES_END() /**< NULL terminate unit test array */
14509 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14511 gbl_driver_id = rte_cryptodev_driver_id_get(
14512 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14514 if (gbl_driver_id == -1) {
14515 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14516 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14517 "are enabled in config file to run this testsuite.\n");
14518 return TEST_SKIPPED;
14521 return unit_test_suite_runner(&cryptodev_qat_testsuite);
14525 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14527 gbl_driver_id = rte_cryptodev_driver_id_get(
14528 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14530 if (gbl_driver_id == -1) {
14531 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14532 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14533 "in config file to run this testsuite.\n");
14534 return TEST_FAILED;
14537 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14541 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14543 gbl_driver_id = rte_cryptodev_driver_id_get(
14544 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14546 if (gbl_driver_id == -1) {
14547 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14548 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14549 "in config file to run this testsuite.\n");
14550 return TEST_SKIPPED;
14553 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14557 test_cryptodev_openssl(void)
14559 gbl_driver_id = rte_cryptodev_driver_id_get(
14560 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14562 if (gbl_driver_id == -1) {
14563 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14564 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14565 "in config file to run this testsuite.\n");
14566 return TEST_SKIPPED;
14569 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14573 test_cryptodev_aesni_gcm(void)
14575 gbl_driver_id = rte_cryptodev_driver_id_get(
14576 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14578 if (gbl_driver_id == -1) {
14579 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14580 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14581 "in config file to run this testsuite.\n");
14582 return TEST_SKIPPED;
14585 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14589 test_cryptodev_null(void)
14591 gbl_driver_id = rte_cryptodev_driver_id_get(
14592 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14594 if (gbl_driver_id == -1) {
14595 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14596 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14597 "in config file to run this testsuite.\n");
14598 return TEST_SKIPPED;
14601 return unit_test_suite_runner(&cryptodev_null_testsuite);
14605 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14607 gbl_driver_id = rte_cryptodev_driver_id_get(
14608 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14610 if (gbl_driver_id == -1) {
14611 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14612 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14613 "in config file to run this testsuite.\n");
14614 return TEST_SKIPPED;
14617 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14621 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14623 gbl_driver_id = rte_cryptodev_driver_id_get(
14624 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14626 if (gbl_driver_id == -1) {
14627 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14628 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14629 "in config file to run this testsuite.\n");
14630 return TEST_SKIPPED;
14633 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14637 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14639 gbl_driver_id = rte_cryptodev_driver_id_get(
14640 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14642 if (gbl_driver_id == -1) {
14643 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14644 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14645 "in config file to run this testsuite.\n");
14646 return TEST_SKIPPED;
14649 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14653 test_cryptodev_armv8(void)
14655 gbl_driver_id = rte_cryptodev_driver_id_get(
14656 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14658 if (gbl_driver_id == -1) {
14659 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14660 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14661 "in config file to run this testsuite.\n");
14662 return TEST_SKIPPED;
14665 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14669 test_cryptodev_mrvl(void)
14671 gbl_driver_id = rte_cryptodev_driver_id_get(
14672 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14674 if (gbl_driver_id == -1) {
14675 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14676 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14677 "in config file to run this testsuite.\n");
14678 return TEST_SKIPPED;
14681 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14684 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14687 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14689 gbl_driver_id = rte_cryptodev_driver_id_get(
14690 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14692 if (gbl_driver_id == -1) {
14693 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14694 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14695 "in config file to run this testsuite.\n");
14696 return TEST_SKIPPED;
14699 if (rte_cryptodev_driver_id_get(
14700 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14701 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14702 " enabled in config file to run this testsuite.\n");
14703 return TEST_SKIPPED;
14705 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14708 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14713 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14715 gbl_driver_id = rte_cryptodev_driver_id_get(
14716 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14718 if (gbl_driver_id == -1) {
14719 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14720 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14721 "in config file to run this testsuite.\n");
14722 return TEST_SKIPPED;
14725 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14729 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14731 gbl_driver_id = rte_cryptodev_driver_id_get(
14732 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14734 if (gbl_driver_id == -1) {
14735 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14736 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14737 "in config file to run this testsuite.\n");
14738 return TEST_SKIPPED;
14741 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14745 test_cryptodev_ccp(void)
14747 gbl_driver_id = rte_cryptodev_driver_id_get(
14748 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14750 if (gbl_driver_id == -1) {
14751 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14752 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14753 "in config file to run this testsuite.\n");
14754 return TEST_FAILED;
14757 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14761 test_cryptodev_octeontx(void)
14763 gbl_driver_id = rte_cryptodev_driver_id_get(
14764 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14765 if (gbl_driver_id == -1) {
14766 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14767 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14768 "enabled in config file to run this "
14770 return TEST_FAILED;
14772 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14776 test_cryptodev_octeontx2(void)
14778 gbl_driver_id = rte_cryptodev_driver_id_get(
14779 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14780 if (gbl_driver_id == -1) {
14781 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14782 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14783 "enabled in config file to run this "
14785 return TEST_FAILED;
14787 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14791 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14793 gbl_driver_id = rte_cryptodev_driver_id_get(
14794 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14796 if (gbl_driver_id == -1) {
14797 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14798 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14799 "in config file to run this testsuite.\n");
14800 return TEST_FAILED;
14803 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14807 test_cryptodev_nitrox(void)
14809 gbl_driver_id = rte_cryptodev_driver_id_get(
14810 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14812 if (gbl_driver_id == -1) {
14813 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14814 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14815 "in config file to run this testsuite.\n");
14816 return TEST_FAILED;
14819 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14822 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14823 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14824 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14825 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14826 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14827 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14828 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14829 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14830 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14831 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14832 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14833 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14834 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14835 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14836 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14837 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14838 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14839 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);