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);
2705 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2706 &ut_params->cipher_xform,
2707 ts_params->session_priv_mpool);
2709 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2710 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2715 create_wireless_cipher_auth_session(uint8_t dev_id,
2716 enum rte_crypto_cipher_operation cipher_op,
2717 enum rte_crypto_auth_operation auth_op,
2718 enum rte_crypto_auth_algorithm auth_algo,
2719 enum rte_crypto_cipher_algorithm cipher_algo,
2720 const struct wireless_test_data *tdata)
2722 const uint8_t key_len = tdata->key.len;
2723 uint8_t cipher_auth_key[key_len];
2726 struct crypto_testsuite_params *ts_params = &testsuite_params;
2727 struct crypto_unittest_params *ut_params = &unittest_params;
2728 const uint8_t *key = tdata->key.data;
2729 const uint8_t auth_len = tdata->digest.len;
2730 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2731 uint8_t auth_iv_len = tdata->auth_iv.len;
2733 memcpy(cipher_auth_key, key, key_len);
2735 /* Setup Authentication Parameters */
2736 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2737 ut_params->auth_xform.next = NULL;
2739 ut_params->auth_xform.auth.op = auth_op;
2740 ut_params->auth_xform.auth.algo = auth_algo;
2741 ut_params->auth_xform.auth.key.length = key_len;
2742 /* Hash key = cipher key */
2743 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2744 ut_params->auth_xform.auth.digest_length = auth_len;
2745 /* Auth IV will be after cipher IV */
2746 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2747 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2749 /* Setup Cipher Parameters */
2750 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2751 ut_params->cipher_xform.next = &ut_params->auth_xform;
2753 ut_params->cipher_xform.cipher.algo = cipher_algo;
2754 ut_params->cipher_xform.cipher.op = cipher_op;
2755 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2756 ut_params->cipher_xform.cipher.key.length = key_len;
2757 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2758 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2761 debug_hexdump(stdout, "key:", key, key_len);
2763 /* Create Crypto session*/
2764 ut_params->sess = rte_cryptodev_sym_session_create(
2765 ts_params->session_mpool);
2767 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2768 &ut_params->cipher_xform,
2769 ts_params->session_priv_mpool);
2771 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2772 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2777 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2778 const struct wireless_test_data *tdata)
2780 return create_wireless_cipher_auth_session(dev_id,
2781 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2782 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2783 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2787 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2788 enum rte_crypto_cipher_operation cipher_op,
2789 enum rte_crypto_auth_operation auth_op,
2790 enum rte_crypto_auth_algorithm auth_algo,
2791 enum rte_crypto_cipher_algorithm cipher_algo,
2792 const uint8_t *key, const uint8_t key_len,
2793 uint8_t auth_iv_len, uint8_t auth_len,
2794 uint8_t cipher_iv_len)
2796 uint8_t auth_cipher_key[key_len];
2798 struct crypto_testsuite_params *ts_params = &testsuite_params;
2799 struct crypto_unittest_params *ut_params = &unittest_params;
2801 memcpy(auth_cipher_key, key, key_len);
2803 /* Setup Authentication Parameters */
2804 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2805 ut_params->auth_xform.auth.op = auth_op;
2806 ut_params->auth_xform.next = &ut_params->cipher_xform;
2807 ut_params->auth_xform.auth.algo = auth_algo;
2808 ut_params->auth_xform.auth.key.length = key_len;
2809 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2810 ut_params->auth_xform.auth.digest_length = auth_len;
2811 /* Auth IV will be after cipher IV */
2812 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2813 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2815 /* Setup Cipher Parameters */
2816 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2817 ut_params->cipher_xform.next = NULL;
2818 ut_params->cipher_xform.cipher.algo = cipher_algo;
2819 ut_params->cipher_xform.cipher.op = cipher_op;
2820 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2821 ut_params->cipher_xform.cipher.key.length = key_len;
2822 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2823 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2825 debug_hexdump(stdout, "key:", key, key_len);
2827 /* Create Crypto session*/
2828 ut_params->sess = rte_cryptodev_sym_session_create(
2829 ts_params->session_mpool);
2831 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2832 ut_params->auth_xform.next = NULL;
2833 ut_params->cipher_xform.next = &ut_params->auth_xform;
2834 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2835 &ut_params->cipher_xform,
2836 ts_params->session_priv_mpool);
2839 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2840 &ut_params->auth_xform,
2841 ts_params->session_priv_mpool);
2843 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2844 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2850 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2851 unsigned int auth_tag_len,
2852 const uint8_t *iv, unsigned int iv_len,
2853 unsigned int data_pad_len,
2854 enum rte_crypto_auth_operation op,
2855 unsigned int auth_len, unsigned int auth_offset)
2857 struct crypto_testsuite_params *ts_params = &testsuite_params;
2859 struct crypto_unittest_params *ut_params = &unittest_params;
2861 /* Generate Crypto op data structure */
2862 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2863 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2864 TEST_ASSERT_NOT_NULL(ut_params->op,
2865 "Failed to allocate pktmbuf offload");
2867 /* Set crypto operation data parameters */
2868 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2870 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2872 /* set crypto operation source mbuf */
2873 sym_op->m_src = ut_params->ibuf;
2876 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2879 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2880 ut_params->ibuf, auth_tag_len);
2882 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2883 "no room to append auth tag");
2884 ut_params->digest = sym_op->auth.digest.data;
2885 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2886 ut_params->ibuf, data_pad_len);
2887 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2888 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2890 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2892 debug_hexdump(stdout, "digest:",
2893 sym_op->auth.digest.data,
2896 sym_op->auth.data.length = auth_len;
2897 sym_op->auth.data.offset = auth_offset;
2903 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2904 enum rte_crypto_auth_operation op)
2906 struct crypto_testsuite_params *ts_params = &testsuite_params;
2907 struct crypto_unittest_params *ut_params = &unittest_params;
2909 const uint8_t *auth_tag = tdata->digest.data;
2910 const unsigned int auth_tag_len = tdata->digest.len;
2911 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2912 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2914 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2915 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2916 const uint8_t *auth_iv = tdata->auth_iv.data;
2917 const uint8_t auth_iv_len = tdata->auth_iv.len;
2918 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2919 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2921 /* Generate Crypto op data structure */
2922 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2923 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2924 TEST_ASSERT_NOT_NULL(ut_params->op,
2925 "Failed to allocate pktmbuf offload");
2926 /* Set crypto operation data parameters */
2927 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2929 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2931 /* set crypto operation source mbuf */
2932 sym_op->m_src = ut_params->ibuf;
2935 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2936 ut_params->ibuf, auth_tag_len);
2938 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2939 "no room to append auth tag");
2940 ut_params->digest = sym_op->auth.digest.data;
2941 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2942 ut_params->ibuf, data_pad_len);
2943 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2944 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2946 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2948 debug_hexdump(stdout, "digest:",
2949 sym_op->auth.digest.data,
2952 /* Copy cipher and auth IVs at the end of the crypto operation */
2953 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2955 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2956 iv_ptr += cipher_iv_len;
2957 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2959 sym_op->cipher.data.length = cipher_len;
2960 sym_op->cipher.data.offset = 0;
2961 sym_op->auth.data.length = auth_len;
2962 sym_op->auth.data.offset = 0;
2968 create_zuc_cipher_hash_generate_operation(
2969 const struct wireless_test_data *tdata)
2971 return create_wireless_cipher_hash_operation(tdata,
2972 RTE_CRYPTO_AUTH_OP_GENERATE);
2976 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2977 const unsigned auth_tag_len,
2978 const uint8_t *auth_iv, uint8_t auth_iv_len,
2979 unsigned data_pad_len,
2980 enum rte_crypto_auth_operation op,
2981 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2982 const unsigned cipher_len, const unsigned cipher_offset,
2983 const unsigned auth_len, const unsigned auth_offset)
2985 struct crypto_testsuite_params *ts_params = &testsuite_params;
2986 struct crypto_unittest_params *ut_params = &unittest_params;
2988 /* Generate Crypto op data structure */
2989 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2990 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2991 TEST_ASSERT_NOT_NULL(ut_params->op,
2992 "Failed to allocate pktmbuf offload");
2993 /* Set crypto operation data parameters */
2994 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2996 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2998 /* set crypto operation source mbuf */
2999 sym_op->m_src = ut_params->ibuf;
3002 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3003 ut_params->ibuf, auth_tag_len);
3005 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3006 "no room to append auth tag");
3007 ut_params->digest = sym_op->auth.digest.data;
3008 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3009 ut_params->ibuf, data_pad_len);
3010 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3011 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3013 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3015 debug_hexdump(stdout, "digest:",
3016 sym_op->auth.digest.data,
3019 /* Copy cipher and auth IVs at the end of the crypto operation */
3020 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3022 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3023 iv_ptr += cipher_iv_len;
3024 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3026 sym_op->cipher.data.length = cipher_len;
3027 sym_op->cipher.data.offset = cipher_offset;
3028 sym_op->auth.data.length = auth_len;
3029 sym_op->auth.data.offset = auth_offset;
3035 create_wireless_algo_auth_cipher_operation(
3036 const uint8_t *auth_tag, unsigned int auth_tag_len,
3037 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3038 const uint8_t *auth_iv, uint8_t auth_iv_len,
3039 unsigned int data_pad_len,
3040 unsigned int cipher_len, unsigned int cipher_offset,
3041 unsigned int auth_len, unsigned int auth_offset,
3042 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3044 struct crypto_testsuite_params *ts_params = &testsuite_params;
3045 struct crypto_unittest_params *ut_params = &unittest_params;
3047 enum rte_crypto_cipher_algorithm cipher_algo =
3048 ut_params->cipher_xform.cipher.algo;
3049 enum rte_crypto_auth_algorithm auth_algo =
3050 ut_params->auth_xform.auth.algo;
3052 /* Generate Crypto op data structure */
3053 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3054 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3055 TEST_ASSERT_NOT_NULL(ut_params->op,
3056 "Failed to allocate pktmbuf offload");
3058 /* Set crypto operation data parameters */
3059 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3061 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3063 /* set crypto operation mbufs */
3064 sym_op->m_src = ut_params->ibuf;
3065 if (op_mode == OUT_OF_PLACE)
3066 sym_op->m_dst = ut_params->obuf;
3070 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3071 (op_mode == IN_PLACE ?
3072 ut_params->ibuf : ut_params->obuf),
3073 uint8_t *, data_pad_len);
3074 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3075 (op_mode == IN_PLACE ?
3076 ut_params->ibuf : ut_params->obuf),
3078 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3080 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3081 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3082 sym_op->m_src : sym_op->m_dst);
3083 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3084 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3085 sgl_buf = sgl_buf->next;
3087 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3088 uint8_t *, remaining_off);
3089 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3091 memset(sym_op->auth.digest.data, 0, remaining_off);
3092 while (sgl_buf->next != NULL) {
3093 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3094 0, rte_pktmbuf_data_len(sgl_buf));
3095 sgl_buf = sgl_buf->next;
3099 /* Copy digest for the verification */
3101 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3103 /* Copy cipher and auth IVs at the end of the crypto operation */
3104 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3105 ut_params->op, uint8_t *, IV_OFFSET);
3107 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3108 iv_ptr += cipher_iv_len;
3109 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3111 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3112 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3113 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3114 sym_op->cipher.data.length = cipher_len;
3115 sym_op->cipher.data.offset = cipher_offset;
3117 sym_op->cipher.data.length = cipher_len >> 3;
3118 sym_op->cipher.data.offset = cipher_offset >> 3;
3121 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3122 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3123 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3124 sym_op->auth.data.length = auth_len;
3125 sym_op->auth.data.offset = auth_offset;
3127 sym_op->auth.data.length = auth_len >> 3;
3128 sym_op->auth.data.offset = auth_offset >> 3;
3135 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3137 struct crypto_testsuite_params *ts_params = &testsuite_params;
3138 struct crypto_unittest_params *ut_params = &unittest_params;
3141 unsigned plaintext_pad_len;
3142 unsigned plaintext_len;
3145 /* Create SNOW 3G session */
3146 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3147 tdata->key.data, tdata->key.len,
3148 tdata->auth_iv.len, tdata->digest.len,
3149 RTE_CRYPTO_AUTH_OP_GENERATE,
3150 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3154 /* alloc mbuf and set payload */
3155 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3157 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3158 rte_pktmbuf_tailroom(ut_params->ibuf));
3160 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3161 /* Append data which is padded to a multiple of */
3162 /* the algorithms block size */
3163 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3164 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3166 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3168 /* Create SNOW 3G operation */
3169 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3170 tdata->auth_iv.data, tdata->auth_iv.len,
3171 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3172 tdata->validAuthLenInBits.len,
3177 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3179 ut_params->obuf = ut_params->op->sym->m_src;
3180 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3181 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3182 + plaintext_pad_len;
3185 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3188 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3189 "SNOW 3G Generated auth tag not as expected");
3195 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3197 struct crypto_testsuite_params *ts_params = &testsuite_params;
3198 struct crypto_unittest_params *ut_params = &unittest_params;
3201 unsigned plaintext_pad_len;
3202 unsigned plaintext_len;
3205 /* Create SNOW 3G session */
3206 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3207 tdata->key.data, tdata->key.len,
3208 tdata->auth_iv.len, tdata->digest.len,
3209 RTE_CRYPTO_AUTH_OP_VERIFY,
3210 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3213 /* alloc mbuf and set payload */
3214 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3216 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3217 rte_pktmbuf_tailroom(ut_params->ibuf));
3219 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3220 /* Append data which is padded to a multiple of */
3221 /* the algorithms block size */
3222 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3223 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3225 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3227 /* Create SNOW 3G operation */
3228 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3230 tdata->auth_iv.data, tdata->auth_iv.len,
3232 RTE_CRYPTO_AUTH_OP_VERIFY,
3233 tdata->validAuthLenInBits.len,
3238 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3240 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3241 ut_params->obuf = ut_params->op->sym->m_src;
3242 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3243 + plaintext_pad_len;
3246 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3255 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3257 struct crypto_testsuite_params *ts_params = &testsuite_params;
3258 struct crypto_unittest_params *ut_params = &unittest_params;
3261 unsigned plaintext_pad_len;
3262 unsigned plaintext_len;
3265 /* Create KASUMI session */
3266 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3267 tdata->key.data, tdata->key.len,
3268 0, tdata->digest.len,
3269 RTE_CRYPTO_AUTH_OP_GENERATE,
3270 RTE_CRYPTO_AUTH_KASUMI_F9);
3274 /* alloc mbuf and set payload */
3275 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3277 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3278 rte_pktmbuf_tailroom(ut_params->ibuf));
3280 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3281 /* Append data which is padded to a multiple of */
3282 /* the algorithms block size */
3283 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3284 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3286 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3288 /* Create KASUMI operation */
3289 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3291 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3292 tdata->plaintext.len,
3297 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3299 ut_params->obuf = ut_params->op->sym->m_src;
3300 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3301 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3302 + plaintext_pad_len;
3305 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3308 DIGEST_BYTE_LENGTH_KASUMI_F9,
3309 "KASUMI Generated auth tag not as expected");
3315 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3317 struct crypto_testsuite_params *ts_params = &testsuite_params;
3318 struct crypto_unittest_params *ut_params = &unittest_params;
3321 unsigned plaintext_pad_len;
3322 unsigned plaintext_len;
3325 /* Create KASUMI session */
3326 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3327 tdata->key.data, tdata->key.len,
3328 0, tdata->digest.len,
3329 RTE_CRYPTO_AUTH_OP_VERIFY,
3330 RTE_CRYPTO_AUTH_KASUMI_F9);
3333 /* alloc mbuf and set payload */
3334 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3336 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3337 rte_pktmbuf_tailroom(ut_params->ibuf));
3339 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3340 /* Append data which is padded to a multiple */
3341 /* of the algorithms block size */
3342 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3343 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3345 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3347 /* Create KASUMI operation */
3348 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3352 RTE_CRYPTO_AUTH_OP_VERIFY,
3353 tdata->plaintext.len,
3358 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3360 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3361 ut_params->obuf = ut_params->op->sym->m_src;
3362 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3363 + plaintext_pad_len;
3366 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3375 test_snow3g_hash_generate_test_case_1(void)
3377 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3381 test_snow3g_hash_generate_test_case_2(void)
3383 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3387 test_snow3g_hash_generate_test_case_3(void)
3389 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3393 test_snow3g_hash_generate_test_case_4(void)
3395 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3399 test_snow3g_hash_generate_test_case_5(void)
3401 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3405 test_snow3g_hash_generate_test_case_6(void)
3407 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3411 test_snow3g_hash_verify_test_case_1(void)
3413 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3418 test_snow3g_hash_verify_test_case_2(void)
3420 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3424 test_snow3g_hash_verify_test_case_3(void)
3426 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3430 test_snow3g_hash_verify_test_case_4(void)
3432 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3436 test_snow3g_hash_verify_test_case_5(void)
3438 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3442 test_snow3g_hash_verify_test_case_6(void)
3444 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3448 test_kasumi_hash_generate_test_case_1(void)
3450 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3454 test_kasumi_hash_generate_test_case_2(void)
3456 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3460 test_kasumi_hash_generate_test_case_3(void)
3462 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3466 test_kasumi_hash_generate_test_case_4(void)
3468 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3472 test_kasumi_hash_generate_test_case_5(void)
3474 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3478 test_kasumi_hash_generate_test_case_6(void)
3480 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3484 test_kasumi_hash_verify_test_case_1(void)
3486 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3490 test_kasumi_hash_verify_test_case_2(void)
3492 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3496 test_kasumi_hash_verify_test_case_3(void)
3498 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3502 test_kasumi_hash_verify_test_case_4(void)
3504 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3508 test_kasumi_hash_verify_test_case_5(void)
3510 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3514 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3516 struct crypto_testsuite_params *ts_params = &testsuite_params;
3517 struct crypto_unittest_params *ut_params = &unittest_params;
3520 uint8_t *plaintext, *ciphertext;
3521 unsigned plaintext_pad_len;
3522 unsigned plaintext_len;
3524 /* Create KASUMI session */
3525 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3526 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3527 RTE_CRYPTO_CIPHER_KASUMI_F8,
3528 tdata->key.data, tdata->key.len,
3529 tdata->cipher_iv.len);
3533 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3535 /* Clear mbuf payload */
3536 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3537 rte_pktmbuf_tailroom(ut_params->ibuf));
3539 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3540 /* Append data which is padded to a multiple */
3541 /* of the algorithms block size */
3542 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3543 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3545 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3547 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3549 /* Create KASUMI operation */
3550 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3551 tdata->cipher_iv.len,
3552 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3553 tdata->validCipherOffsetInBits.len);
3557 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3559 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3561 ut_params->obuf = ut_params->op->sym->m_dst;
3562 if (ut_params->obuf)
3563 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3565 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3567 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3569 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3570 (tdata->validCipherOffsetInBits.len >> 3);
3572 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3574 reference_ciphertext,
3575 tdata->validCipherLenInBits.len,
3576 "KASUMI Ciphertext data not as expected");
3581 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3583 struct crypto_testsuite_params *ts_params = &testsuite_params;
3584 struct crypto_unittest_params *ut_params = &unittest_params;
3588 unsigned int plaintext_pad_len;
3589 unsigned int plaintext_len;
3591 uint8_t buffer[10000];
3592 const uint8_t *ciphertext;
3594 struct rte_cryptodev_info dev_info;
3596 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3598 uint64_t feat_flags = dev_info.feature_flags;
3600 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3601 printf("Device doesn't support in-place scatter-gather. "
3606 /* Create KASUMI session */
3607 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3608 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3609 RTE_CRYPTO_CIPHER_KASUMI_F8,
3610 tdata->key.data, tdata->key.len,
3611 tdata->cipher_iv.len);
3615 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3618 /* Append data which is padded to a multiple */
3619 /* of the algorithms block size */
3620 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3622 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3623 plaintext_pad_len, 10, 0);
3625 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3627 /* Create KASUMI operation */
3628 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3629 tdata->cipher_iv.len,
3630 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3631 tdata->validCipherOffsetInBits.len);
3635 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3637 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3639 ut_params->obuf = ut_params->op->sym->m_dst;
3641 if (ut_params->obuf)
3642 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3643 plaintext_len, buffer);
3645 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3646 tdata->validCipherOffsetInBits.len >> 3,
3647 plaintext_len, buffer);
3650 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3652 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3653 (tdata->validCipherOffsetInBits.len >> 3);
3655 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3657 reference_ciphertext,
3658 tdata->validCipherLenInBits.len,
3659 "KASUMI Ciphertext data not as expected");
3664 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3666 struct crypto_testsuite_params *ts_params = &testsuite_params;
3667 struct crypto_unittest_params *ut_params = &unittest_params;
3670 uint8_t *plaintext, *ciphertext;
3671 unsigned plaintext_pad_len;
3672 unsigned plaintext_len;
3674 /* Create KASUMI session */
3675 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3676 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3677 RTE_CRYPTO_CIPHER_KASUMI_F8,
3678 tdata->key.data, tdata->key.len,
3679 tdata->cipher_iv.len);
3683 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3684 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3686 /* Clear mbuf payload */
3687 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3688 rte_pktmbuf_tailroom(ut_params->ibuf));
3690 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3691 /* Append data which is padded to a multiple */
3692 /* of the algorithms block size */
3693 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3694 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3696 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3697 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3699 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3701 /* Create KASUMI operation */
3702 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3703 tdata->cipher_iv.len,
3704 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3705 tdata->validCipherOffsetInBits.len);
3709 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3711 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3713 ut_params->obuf = ut_params->op->sym->m_dst;
3714 if (ut_params->obuf)
3715 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3717 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3719 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3721 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3722 (tdata->validCipherOffsetInBits.len >> 3);
3724 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3726 reference_ciphertext,
3727 tdata->validCipherLenInBits.len,
3728 "KASUMI Ciphertext data not as expected");
3733 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3735 struct crypto_testsuite_params *ts_params = &testsuite_params;
3736 struct crypto_unittest_params *ut_params = &unittest_params;
3739 unsigned int plaintext_pad_len;
3740 unsigned int plaintext_len;
3742 const uint8_t *ciphertext;
3743 uint8_t buffer[2048];
3745 struct rte_cryptodev_info dev_info;
3747 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3749 uint64_t feat_flags = dev_info.feature_flags;
3750 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3751 printf("Device doesn't support out-of-place scatter-gather "
3752 "in both input and output mbufs. "
3757 /* Create KASUMI session */
3758 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3759 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3760 RTE_CRYPTO_CIPHER_KASUMI_F8,
3761 tdata->key.data, tdata->key.len,
3762 tdata->cipher_iv.len);
3766 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3767 /* Append data which is padded to a multiple */
3768 /* of the algorithms block size */
3769 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3771 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3772 plaintext_pad_len, 10, 0);
3773 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3774 plaintext_pad_len, 3, 0);
3776 /* Append data which is padded to a multiple */
3777 /* of the algorithms block size */
3778 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3780 /* Create KASUMI operation */
3781 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3782 tdata->cipher_iv.len,
3783 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3784 tdata->validCipherOffsetInBits.len);
3788 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3790 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3792 ut_params->obuf = ut_params->op->sym->m_dst;
3793 if (ut_params->obuf)
3794 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3795 plaintext_pad_len, buffer);
3797 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3798 tdata->validCipherOffsetInBits.len >> 3,
3799 plaintext_pad_len, buffer);
3801 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3802 (tdata->validCipherOffsetInBits.len >> 3);
3804 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3806 reference_ciphertext,
3807 tdata->validCipherLenInBits.len,
3808 "KASUMI Ciphertext data not as expected");
3814 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3816 struct crypto_testsuite_params *ts_params = &testsuite_params;
3817 struct crypto_unittest_params *ut_params = &unittest_params;
3820 uint8_t *ciphertext, *plaintext;
3821 unsigned ciphertext_pad_len;
3822 unsigned ciphertext_len;
3824 /* Create KASUMI session */
3825 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3826 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3827 RTE_CRYPTO_CIPHER_KASUMI_F8,
3828 tdata->key.data, tdata->key.len,
3829 tdata->cipher_iv.len);
3833 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3834 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3836 /* Clear mbuf payload */
3837 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3838 rte_pktmbuf_tailroom(ut_params->ibuf));
3840 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3841 /* Append data which is padded to a multiple */
3842 /* of the algorithms block size */
3843 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3844 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3845 ciphertext_pad_len);
3846 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3847 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3849 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3851 /* Create KASUMI operation */
3852 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3853 tdata->cipher_iv.len,
3854 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3855 tdata->validCipherOffsetInBits.len);
3859 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3861 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3863 ut_params->obuf = ut_params->op->sym->m_dst;
3864 if (ut_params->obuf)
3865 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3867 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3869 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3871 const uint8_t *reference_plaintext = tdata->plaintext.data +
3872 (tdata->validCipherOffsetInBits.len >> 3);
3874 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3876 reference_plaintext,
3877 tdata->validCipherLenInBits.len,
3878 "KASUMI Plaintext data not as expected");
3883 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3885 struct crypto_testsuite_params *ts_params = &testsuite_params;
3886 struct crypto_unittest_params *ut_params = &unittest_params;
3889 uint8_t *ciphertext, *plaintext;
3890 unsigned ciphertext_pad_len;
3891 unsigned ciphertext_len;
3893 /* Create KASUMI session */
3894 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3895 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3896 RTE_CRYPTO_CIPHER_KASUMI_F8,
3897 tdata->key.data, tdata->key.len,
3898 tdata->cipher_iv.len);
3902 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3904 /* Clear mbuf payload */
3905 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3906 rte_pktmbuf_tailroom(ut_params->ibuf));
3908 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3909 /* Append data which is padded to a multiple */
3910 /* of the algorithms block size */
3911 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3912 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3913 ciphertext_pad_len);
3914 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3916 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3918 /* Create KASUMI operation */
3919 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3920 tdata->cipher_iv.len,
3921 tdata->ciphertext.len,
3922 tdata->validCipherOffsetInBits.len);
3926 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3928 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3930 ut_params->obuf = ut_params->op->sym->m_dst;
3931 if (ut_params->obuf)
3932 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3934 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3936 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3938 const uint8_t *reference_plaintext = tdata->plaintext.data +
3939 (tdata->validCipherOffsetInBits.len >> 3);
3941 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3943 reference_plaintext,
3944 tdata->validCipherLenInBits.len,
3945 "KASUMI Plaintext data not as expected");
3950 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3952 struct crypto_testsuite_params *ts_params = &testsuite_params;
3953 struct crypto_unittest_params *ut_params = &unittest_params;
3956 uint8_t *plaintext, *ciphertext;
3957 unsigned plaintext_pad_len;
3958 unsigned plaintext_len;
3960 /* Create SNOW 3G session */
3961 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3962 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3963 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
3964 tdata->key.data, tdata->key.len,
3965 tdata->cipher_iv.len);
3969 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3971 /* Clear mbuf payload */
3972 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3973 rte_pktmbuf_tailroom(ut_params->ibuf));
3975 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3976 /* Append data which is padded to a multiple of */
3977 /* the algorithms block size */
3978 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3979 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3981 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3983 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3985 /* Create SNOW 3G operation */
3986 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3987 tdata->cipher_iv.len,
3988 tdata->validCipherLenInBits.len,
3993 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3995 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3997 ut_params->obuf = ut_params->op->sym->m_dst;
3998 if (ut_params->obuf)
3999 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4001 ciphertext = plaintext;
4003 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4006 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4008 tdata->ciphertext.data,
4009 tdata->validDataLenInBits.len,
4010 "SNOW 3G Ciphertext data not as expected");
4016 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4018 struct crypto_testsuite_params *ts_params = &testsuite_params;
4019 struct crypto_unittest_params *ut_params = &unittest_params;
4020 uint8_t *plaintext, *ciphertext;
4023 unsigned plaintext_pad_len;
4024 unsigned plaintext_len;
4026 /* Create SNOW 3G session */
4027 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4028 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4029 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4030 tdata->key.data, tdata->key.len,
4031 tdata->cipher_iv.len);
4035 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4036 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4038 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4039 "Failed to allocate input buffer in mempool");
4040 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4041 "Failed to allocate output buffer in mempool");
4043 /* Clear mbuf payload */
4044 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4045 rte_pktmbuf_tailroom(ut_params->ibuf));
4047 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4048 /* Append data which is padded to a multiple of */
4049 /* the algorithms block size */
4050 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4051 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4053 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4054 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4056 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4058 /* Create SNOW 3G operation */
4059 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4060 tdata->cipher_iv.len,
4061 tdata->validCipherLenInBits.len,
4066 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4068 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4070 ut_params->obuf = ut_params->op->sym->m_dst;
4071 if (ut_params->obuf)
4072 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4074 ciphertext = plaintext;
4076 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4079 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4081 tdata->ciphertext.data,
4082 tdata->validDataLenInBits.len,
4083 "SNOW 3G Ciphertext data not as expected");
4088 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4090 struct crypto_testsuite_params *ts_params = &testsuite_params;
4091 struct crypto_unittest_params *ut_params = &unittest_params;
4094 unsigned int plaintext_pad_len;
4095 unsigned int plaintext_len;
4096 uint8_t buffer[10000];
4097 const uint8_t *ciphertext;
4099 struct rte_cryptodev_info dev_info;
4101 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4103 uint64_t feat_flags = dev_info.feature_flags;
4105 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4106 printf("Device doesn't support out-of-place scatter-gather "
4107 "in both input and output mbufs. "
4112 /* Create SNOW 3G session */
4113 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4114 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4115 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4116 tdata->key.data, tdata->key.len,
4117 tdata->cipher_iv.len);
4121 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4122 /* Append data which is padded to a multiple of */
4123 /* the algorithms block size */
4124 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4126 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4127 plaintext_pad_len, 10, 0);
4128 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4129 plaintext_pad_len, 3, 0);
4131 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4132 "Failed to allocate input buffer in mempool");
4133 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4134 "Failed to allocate output buffer in mempool");
4136 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4138 /* Create SNOW 3G operation */
4139 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4140 tdata->cipher_iv.len,
4141 tdata->validCipherLenInBits.len,
4146 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4148 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4150 ut_params->obuf = ut_params->op->sym->m_dst;
4151 if (ut_params->obuf)
4152 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4153 plaintext_len, buffer);
4155 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4156 plaintext_len, buffer);
4158 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4161 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4163 tdata->ciphertext.data,
4164 tdata->validDataLenInBits.len,
4165 "SNOW 3G Ciphertext data not as expected");
4170 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4172 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4174 uint8_t curr_byte, prev_byte;
4175 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4176 uint8_t lower_byte_mask = (1 << offset) - 1;
4179 prev_byte = buffer[0];
4180 buffer[0] >>= offset;
4182 for (i = 1; i < length_in_bytes; i++) {
4183 curr_byte = buffer[i];
4184 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4185 (curr_byte >> offset);
4186 prev_byte = curr_byte;
4191 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4193 struct crypto_testsuite_params *ts_params = &testsuite_params;
4194 struct crypto_unittest_params *ut_params = &unittest_params;
4195 uint8_t *plaintext, *ciphertext;
4197 uint32_t plaintext_len;
4198 uint32_t plaintext_pad_len;
4199 uint8_t extra_offset = 4;
4200 uint8_t *expected_ciphertext_shifted;
4202 /* Create SNOW 3G session */
4203 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4204 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4205 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4206 tdata->key.data, tdata->key.len,
4207 tdata->cipher_iv.len);
4211 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4212 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4214 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4215 "Failed to allocate input buffer in mempool");
4216 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4217 "Failed to allocate output buffer in mempool");
4219 /* Clear mbuf payload */
4220 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4221 rte_pktmbuf_tailroom(ut_params->ibuf));
4223 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4225 * Append data which is padded to a
4226 * multiple of the algorithms block size
4228 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4230 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4233 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4235 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4236 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4238 #ifdef RTE_APP_TEST_DEBUG
4239 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4241 /* Create SNOW 3G operation */
4242 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4243 tdata->cipher_iv.len,
4244 tdata->validCipherLenInBits.len,
4249 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4251 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4253 ut_params->obuf = ut_params->op->sym->m_dst;
4254 if (ut_params->obuf)
4255 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4257 ciphertext = plaintext;
4259 #ifdef RTE_APP_TEST_DEBUG
4260 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4263 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4265 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4266 "failed to reserve memory for ciphertext shifted\n");
4268 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4269 ceil_byte_length(tdata->ciphertext.len));
4270 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4273 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4275 expected_ciphertext_shifted,
4276 tdata->validDataLenInBits.len,
4278 "SNOW 3G Ciphertext data not as expected");
4282 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4284 struct crypto_testsuite_params *ts_params = &testsuite_params;
4285 struct crypto_unittest_params *ut_params = &unittest_params;
4289 uint8_t *plaintext, *ciphertext;
4290 unsigned ciphertext_pad_len;
4291 unsigned ciphertext_len;
4293 /* Create SNOW 3G session */
4294 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4295 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4296 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4297 tdata->key.data, tdata->key.len,
4298 tdata->cipher_iv.len);
4302 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4304 /* Clear mbuf payload */
4305 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4306 rte_pktmbuf_tailroom(ut_params->ibuf));
4308 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4309 /* Append data which is padded to a multiple of */
4310 /* the algorithms block size */
4311 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4312 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4313 ciphertext_pad_len);
4314 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4316 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4318 /* Create SNOW 3G operation */
4319 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4320 tdata->cipher_iv.len,
4321 tdata->validCipherLenInBits.len,
4322 tdata->cipher.offset_bits);
4326 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4328 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4329 ut_params->obuf = ut_params->op->sym->m_dst;
4330 if (ut_params->obuf)
4331 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4333 plaintext = ciphertext;
4335 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4338 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4339 tdata->plaintext.data,
4340 tdata->validDataLenInBits.len,
4341 "SNOW 3G Plaintext data not as expected");
4345 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4347 struct crypto_testsuite_params *ts_params = &testsuite_params;
4348 struct crypto_unittest_params *ut_params = &unittest_params;
4352 uint8_t *plaintext, *ciphertext;
4353 unsigned ciphertext_pad_len;
4354 unsigned ciphertext_len;
4356 /* Create SNOW 3G session */
4357 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4358 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4359 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4360 tdata->key.data, tdata->key.len,
4361 tdata->cipher_iv.len);
4365 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4366 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4368 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4369 "Failed to allocate input buffer");
4370 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4371 "Failed to allocate output buffer");
4373 /* Clear mbuf payload */
4374 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4375 rte_pktmbuf_tailroom(ut_params->ibuf));
4377 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4378 rte_pktmbuf_tailroom(ut_params->obuf));
4380 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4381 /* Append data which is padded to a multiple of */
4382 /* the algorithms block size */
4383 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4384 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4385 ciphertext_pad_len);
4386 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4387 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4389 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4391 /* Create SNOW 3G operation */
4392 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4393 tdata->cipher_iv.len,
4394 tdata->validCipherLenInBits.len,
4399 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4401 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4402 ut_params->obuf = ut_params->op->sym->m_dst;
4403 if (ut_params->obuf)
4404 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4406 plaintext = ciphertext;
4408 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4411 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4412 tdata->plaintext.data,
4413 tdata->validDataLenInBits.len,
4414 "SNOW 3G Plaintext data not as expected");
4419 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4421 struct crypto_testsuite_params *ts_params = &testsuite_params;
4422 struct crypto_unittest_params *ut_params = &unittest_params;
4426 uint8_t *plaintext, *ciphertext;
4427 unsigned int plaintext_pad_len;
4428 unsigned int plaintext_len;
4430 struct rte_cryptodev_sym_capability_idx cap_idx;
4432 /* Check if device supports ZUC EEA3 */
4433 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4434 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4436 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4440 /* Check if device supports ZUC EIA3 */
4441 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4442 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4444 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4448 /* Create ZUC session */
4449 retval = create_zuc_cipher_auth_encrypt_generate_session(
4450 ts_params->valid_devs[0],
4454 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4456 /* clear mbuf payload */
4457 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4458 rte_pktmbuf_tailroom(ut_params->ibuf));
4460 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4461 /* Append data which is padded to a multiple of */
4462 /* the algorithms block size */
4463 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4464 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4466 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4468 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4470 /* Create ZUC operation */
4471 retval = create_zuc_cipher_hash_generate_operation(tdata);
4475 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4477 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4478 ut_params->obuf = ut_params->op->sym->m_src;
4479 if (ut_params->obuf)
4480 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4482 ciphertext = plaintext;
4484 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4486 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4488 tdata->ciphertext.data,
4489 tdata->validDataLenInBits.len,
4490 "ZUC Ciphertext data not as expected");
4492 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4493 + plaintext_pad_len;
4496 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4500 "ZUC Generated auth tag not as expected");
4505 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4507 struct crypto_testsuite_params *ts_params = &testsuite_params;
4508 struct crypto_unittest_params *ut_params = &unittest_params;
4512 uint8_t *plaintext, *ciphertext;
4513 unsigned plaintext_pad_len;
4514 unsigned plaintext_len;
4516 /* Create SNOW 3G session */
4517 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4518 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4519 RTE_CRYPTO_AUTH_OP_GENERATE,
4520 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4521 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4522 tdata->key.data, tdata->key.len,
4523 tdata->auth_iv.len, tdata->digest.len,
4524 tdata->cipher_iv.len);
4527 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4529 /* clear mbuf payload */
4530 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4531 rte_pktmbuf_tailroom(ut_params->ibuf));
4533 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4534 /* Append data which is padded to a multiple of */
4535 /* the algorithms block size */
4536 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4537 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4539 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4541 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4543 /* Create SNOW 3G operation */
4544 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4545 tdata->digest.len, tdata->auth_iv.data,
4547 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4548 tdata->cipher_iv.data, tdata->cipher_iv.len,
4549 tdata->validCipherLenInBits.len,
4551 tdata->validAuthLenInBits.len,
4557 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4559 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4560 ut_params->obuf = ut_params->op->sym->m_src;
4561 if (ut_params->obuf)
4562 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4564 ciphertext = plaintext;
4566 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4568 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4570 tdata->ciphertext.data,
4571 tdata->validDataLenInBits.len,
4572 "SNOW 3G Ciphertext data not as expected");
4574 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4575 + plaintext_pad_len;
4578 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4581 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4582 "SNOW 3G Generated auth tag not as expected");
4587 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4588 uint8_t op_mode, uint8_t verify)
4590 struct crypto_testsuite_params *ts_params = &testsuite_params;
4591 struct crypto_unittest_params *ut_params = &unittest_params;
4595 uint8_t *plaintext = NULL, *ciphertext = NULL;
4596 unsigned int plaintext_pad_len;
4597 unsigned int plaintext_len;
4598 unsigned int ciphertext_pad_len;
4599 unsigned int ciphertext_len;
4601 struct rte_cryptodev_info dev_info;
4603 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4605 uint64_t feat_flags = dev_info.feature_flags;
4607 if (op_mode == OUT_OF_PLACE) {
4608 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4609 printf("Device doesn't support digest encrypted.\n");
4614 /* Create SNOW 3G session */
4615 retval = create_wireless_algo_auth_cipher_session(
4616 ts_params->valid_devs[0],
4617 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4618 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4619 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4620 : RTE_CRYPTO_AUTH_OP_GENERATE),
4621 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4622 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4623 tdata->key.data, tdata->key.len,
4624 tdata->auth_iv.len, tdata->digest.len,
4625 tdata->cipher_iv.len);
4630 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4631 if (op_mode == OUT_OF_PLACE)
4632 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4634 /* clear mbuf payload */
4635 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4636 rte_pktmbuf_tailroom(ut_params->ibuf));
4637 if (op_mode == OUT_OF_PLACE)
4638 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4639 rte_pktmbuf_tailroom(ut_params->obuf));
4641 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4642 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4643 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4644 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4647 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4648 ciphertext_pad_len);
4649 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4650 if (op_mode == OUT_OF_PLACE)
4651 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4652 debug_hexdump(stdout, "ciphertext:", ciphertext,
4655 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4657 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4658 if (op_mode == OUT_OF_PLACE)
4659 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4660 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4663 /* Create SNOW 3G operation */
4664 retval = create_wireless_algo_auth_cipher_operation(
4665 tdata->digest.data, tdata->digest.len,
4666 tdata->cipher_iv.data, tdata->cipher_iv.len,
4667 tdata->auth_iv.data, tdata->auth_iv.len,
4668 (tdata->digest.offset_bytes == 0 ?
4669 (verify ? ciphertext_pad_len : plaintext_pad_len)
4670 : tdata->digest.offset_bytes),
4671 tdata->validCipherLenInBits.len,
4672 tdata->cipher.offset_bits,
4673 tdata->validAuthLenInBits.len,
4674 tdata->auth.offset_bits,
4675 op_mode, 0, verify);
4680 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4683 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4685 ut_params->obuf = (op_mode == IN_PLACE ?
4686 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4689 if (ut_params->obuf)
4690 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4693 plaintext = ciphertext +
4694 (tdata->cipher.offset_bits >> 3);
4696 debug_hexdump(stdout, "plaintext:", plaintext,
4697 (tdata->plaintext.len >> 3) - tdata->digest.len);
4698 debug_hexdump(stdout, "plaintext expected:",
4699 tdata->plaintext.data,
4700 (tdata->plaintext.len >> 3) - tdata->digest.len);
4702 if (ut_params->obuf)
4703 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4706 ciphertext = plaintext;
4708 debug_hexdump(stdout, "ciphertext:", ciphertext,
4710 debug_hexdump(stdout, "ciphertext expected:",
4711 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4713 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4714 + (tdata->digest.offset_bytes == 0 ?
4715 plaintext_pad_len : tdata->digest.offset_bytes);
4717 debug_hexdump(stdout, "digest:", ut_params->digest,
4719 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4725 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4727 tdata->plaintext.data,
4728 tdata->plaintext.len >> 3,
4729 "SNOW 3G Plaintext data not as expected");
4731 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4733 tdata->ciphertext.data,
4734 tdata->validDataLenInBits.len,
4735 "SNOW 3G Ciphertext data not as expected");
4737 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4740 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4741 "SNOW 3G Generated auth tag not as expected");
4747 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4748 uint8_t op_mode, uint8_t verify)
4750 struct crypto_testsuite_params *ts_params = &testsuite_params;
4751 struct crypto_unittest_params *ut_params = &unittest_params;
4755 const uint8_t *plaintext = NULL;
4756 const uint8_t *ciphertext = NULL;
4757 const uint8_t *digest = NULL;
4758 unsigned int plaintext_pad_len;
4759 unsigned int plaintext_len;
4760 unsigned int ciphertext_pad_len;
4761 unsigned int ciphertext_len;
4762 uint8_t buffer[10000];
4763 uint8_t digest_buffer[10000];
4765 struct rte_cryptodev_info dev_info;
4767 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4769 uint64_t feat_flags = dev_info.feature_flags;
4771 if (op_mode == IN_PLACE) {
4772 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4773 printf("Device doesn't support in-place scatter-gather "
4774 "in both input and output mbufs.\n");
4778 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4779 printf("Device doesn't support out-of-place scatter-gather "
4780 "in both input and output mbufs.\n");
4783 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4784 printf("Device doesn't support digest encrypted.\n");
4789 /* Create SNOW 3G session */
4790 retval = create_wireless_algo_auth_cipher_session(
4791 ts_params->valid_devs[0],
4792 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4793 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4794 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4795 : RTE_CRYPTO_AUTH_OP_GENERATE),
4796 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4797 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4798 tdata->key.data, tdata->key.len,
4799 tdata->auth_iv.len, tdata->digest.len,
4800 tdata->cipher_iv.len);
4805 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4806 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4807 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4808 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4810 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4811 plaintext_pad_len, 15, 0);
4812 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4813 "Failed to allocate input buffer in mempool");
4815 if (op_mode == OUT_OF_PLACE) {
4816 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4817 plaintext_pad_len, 15, 0);
4818 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4819 "Failed to allocate output buffer in mempool");
4823 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4824 tdata->ciphertext.data);
4825 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4826 ciphertext_len, buffer);
4827 debug_hexdump(stdout, "ciphertext:", ciphertext,
4830 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4831 tdata->plaintext.data);
4832 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4833 plaintext_len, buffer);
4834 debug_hexdump(stdout, "plaintext:", plaintext,
4837 memset(buffer, 0, sizeof(buffer));
4839 /* Create SNOW 3G operation */
4840 retval = create_wireless_algo_auth_cipher_operation(
4841 tdata->digest.data, tdata->digest.len,
4842 tdata->cipher_iv.data, tdata->cipher_iv.len,
4843 tdata->auth_iv.data, tdata->auth_iv.len,
4844 (tdata->digest.offset_bytes == 0 ?
4845 (verify ? ciphertext_pad_len : plaintext_pad_len)
4846 : tdata->digest.offset_bytes),
4847 tdata->validCipherLenInBits.len,
4848 tdata->cipher.offset_bits,
4849 tdata->validAuthLenInBits.len,
4850 tdata->auth.offset_bits,
4851 op_mode, 1, verify);
4856 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4859 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4861 ut_params->obuf = (op_mode == IN_PLACE ?
4862 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4865 if (ut_params->obuf)
4866 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4867 plaintext_len, buffer);
4869 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4870 plaintext_len, buffer);
4872 debug_hexdump(stdout, "plaintext:", plaintext,
4873 (tdata->plaintext.len >> 3) - tdata->digest.len);
4874 debug_hexdump(stdout, "plaintext expected:",
4875 tdata->plaintext.data,
4876 (tdata->plaintext.len >> 3) - tdata->digest.len);
4878 if (ut_params->obuf)
4879 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4880 ciphertext_len, buffer);
4882 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4883 ciphertext_len, buffer);
4885 debug_hexdump(stdout, "ciphertext:", ciphertext,
4887 debug_hexdump(stdout, "ciphertext expected:",
4888 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4890 if (ut_params->obuf)
4891 digest = rte_pktmbuf_read(ut_params->obuf,
4892 (tdata->digest.offset_bytes == 0 ?
4893 plaintext_pad_len : tdata->digest.offset_bytes),
4894 tdata->digest.len, digest_buffer);
4896 digest = rte_pktmbuf_read(ut_params->ibuf,
4897 (tdata->digest.offset_bytes == 0 ?
4898 plaintext_pad_len : tdata->digest.offset_bytes),
4899 tdata->digest.len, digest_buffer);
4901 debug_hexdump(stdout, "digest:", digest,
4903 debug_hexdump(stdout, "digest expected:",
4904 tdata->digest.data, tdata->digest.len);
4909 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4911 tdata->plaintext.data,
4912 tdata->plaintext.len >> 3,
4913 "SNOW 3G Plaintext data not as expected");
4915 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4917 tdata->ciphertext.data,
4918 tdata->validDataLenInBits.len,
4919 "SNOW 3G Ciphertext data not as expected");
4921 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4924 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4925 "SNOW 3G Generated auth tag not as expected");
4931 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4932 uint8_t op_mode, uint8_t verify)
4934 struct crypto_testsuite_params *ts_params = &testsuite_params;
4935 struct crypto_unittest_params *ut_params = &unittest_params;
4939 uint8_t *plaintext = NULL, *ciphertext = NULL;
4940 unsigned int plaintext_pad_len;
4941 unsigned int plaintext_len;
4942 unsigned int ciphertext_pad_len;
4943 unsigned int ciphertext_len;
4945 struct rte_cryptodev_info dev_info;
4947 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4949 uint64_t feat_flags = dev_info.feature_flags;
4951 if (op_mode == OUT_OF_PLACE) {
4952 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4953 printf("Device doesn't support digest encrypted.\n");
4958 /* Create KASUMI session */
4959 retval = create_wireless_algo_auth_cipher_session(
4960 ts_params->valid_devs[0],
4961 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4962 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4963 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4964 : RTE_CRYPTO_AUTH_OP_GENERATE),
4965 RTE_CRYPTO_AUTH_KASUMI_F9,
4966 RTE_CRYPTO_CIPHER_KASUMI_F8,
4967 tdata->key.data, tdata->key.len,
4968 0, tdata->digest.len,
4969 tdata->cipher_iv.len);
4974 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4975 if (op_mode == OUT_OF_PLACE)
4976 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4978 /* clear mbuf payload */
4979 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4980 rte_pktmbuf_tailroom(ut_params->ibuf));
4981 if (op_mode == OUT_OF_PLACE)
4982 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4983 rte_pktmbuf_tailroom(ut_params->obuf));
4985 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4986 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4987 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4988 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4991 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4992 ciphertext_pad_len);
4993 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4994 if (op_mode == OUT_OF_PLACE)
4995 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4996 debug_hexdump(stdout, "ciphertext:", ciphertext,
4999 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5001 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5002 if (op_mode == OUT_OF_PLACE)
5003 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5004 debug_hexdump(stdout, "plaintext:", plaintext,
5008 /* Create KASUMI operation */
5009 retval = create_wireless_algo_auth_cipher_operation(
5010 tdata->digest.data, tdata->digest.len,
5011 tdata->cipher_iv.data, tdata->cipher_iv.len,
5013 (tdata->digest.offset_bytes == 0 ?
5014 (verify ? ciphertext_pad_len : plaintext_pad_len)
5015 : tdata->digest.offset_bytes),
5016 tdata->validCipherLenInBits.len,
5017 tdata->validCipherOffsetInBits.len,
5018 tdata->validAuthLenInBits.len,
5020 op_mode, 0, verify);
5025 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5028 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5030 ut_params->obuf = (op_mode == IN_PLACE ?
5031 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5035 if (ut_params->obuf)
5036 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5039 plaintext = ciphertext;
5041 debug_hexdump(stdout, "plaintext:", plaintext,
5042 (tdata->plaintext.len >> 3) - tdata->digest.len);
5043 debug_hexdump(stdout, "plaintext expected:",
5044 tdata->plaintext.data,
5045 (tdata->plaintext.len >> 3) - tdata->digest.len);
5047 if (ut_params->obuf)
5048 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5051 ciphertext = plaintext;
5053 debug_hexdump(stdout, "ciphertext:", ciphertext,
5055 debug_hexdump(stdout, "ciphertext expected:",
5056 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5058 ut_params->digest = rte_pktmbuf_mtod(
5059 ut_params->obuf, uint8_t *) +
5060 (tdata->digest.offset_bytes == 0 ?
5061 plaintext_pad_len : tdata->digest.offset_bytes);
5063 debug_hexdump(stdout, "digest:", ut_params->digest,
5065 debug_hexdump(stdout, "digest expected:",
5066 tdata->digest.data, tdata->digest.len);
5071 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5073 tdata->plaintext.data,
5074 tdata->plaintext.len >> 3,
5075 "KASUMI Plaintext data not as expected");
5077 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5079 tdata->ciphertext.data,
5080 tdata->ciphertext.len >> 3,
5081 "KASUMI Ciphertext data not as expected");
5083 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5086 DIGEST_BYTE_LENGTH_KASUMI_F9,
5087 "KASUMI Generated auth tag not as expected");
5093 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5094 uint8_t op_mode, uint8_t verify)
5096 struct crypto_testsuite_params *ts_params = &testsuite_params;
5097 struct crypto_unittest_params *ut_params = &unittest_params;
5101 const uint8_t *plaintext = NULL;
5102 const uint8_t *ciphertext = NULL;
5103 const uint8_t *digest = NULL;
5104 unsigned int plaintext_pad_len;
5105 unsigned int plaintext_len;
5106 unsigned int ciphertext_pad_len;
5107 unsigned int ciphertext_len;
5108 uint8_t buffer[10000];
5109 uint8_t digest_buffer[10000];
5111 struct rte_cryptodev_info dev_info;
5113 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5115 uint64_t feat_flags = dev_info.feature_flags;
5117 if (op_mode == IN_PLACE) {
5118 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5119 printf("Device doesn't support in-place scatter-gather "
5120 "in both input and output mbufs.\n");
5124 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5125 printf("Device doesn't support out-of-place scatter-gather "
5126 "in both input and output mbufs.\n");
5129 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5130 printf("Device doesn't support digest encrypted.\n");
5135 /* Create KASUMI session */
5136 retval = create_wireless_algo_auth_cipher_session(
5137 ts_params->valid_devs[0],
5138 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5139 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5140 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5141 : RTE_CRYPTO_AUTH_OP_GENERATE),
5142 RTE_CRYPTO_AUTH_KASUMI_F9,
5143 RTE_CRYPTO_CIPHER_KASUMI_F8,
5144 tdata->key.data, tdata->key.len,
5145 0, tdata->digest.len,
5146 tdata->cipher_iv.len);
5151 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5152 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5153 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5154 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5156 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5157 plaintext_pad_len, 15, 0);
5158 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5159 "Failed to allocate input buffer in mempool");
5161 if (op_mode == OUT_OF_PLACE) {
5162 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5163 plaintext_pad_len, 15, 0);
5164 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5165 "Failed to allocate output buffer in mempool");
5169 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5170 tdata->ciphertext.data);
5171 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5172 ciphertext_len, buffer);
5173 debug_hexdump(stdout, "ciphertext:", ciphertext,
5176 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5177 tdata->plaintext.data);
5178 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5179 plaintext_len, buffer);
5180 debug_hexdump(stdout, "plaintext:", plaintext,
5183 memset(buffer, 0, sizeof(buffer));
5185 /* Create KASUMI operation */
5186 retval = create_wireless_algo_auth_cipher_operation(
5187 tdata->digest.data, tdata->digest.len,
5188 tdata->cipher_iv.data, tdata->cipher_iv.len,
5190 (tdata->digest.offset_bytes == 0 ?
5191 (verify ? ciphertext_pad_len : plaintext_pad_len)
5192 : tdata->digest.offset_bytes),
5193 tdata->validCipherLenInBits.len,
5194 tdata->validCipherOffsetInBits.len,
5195 tdata->validAuthLenInBits.len,
5197 op_mode, 1, verify);
5202 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5205 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5207 ut_params->obuf = (op_mode == IN_PLACE ?
5208 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5211 if (ut_params->obuf)
5212 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5213 plaintext_len, buffer);
5215 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5216 plaintext_len, buffer);
5218 debug_hexdump(stdout, "plaintext:", plaintext,
5219 (tdata->plaintext.len >> 3) - tdata->digest.len);
5220 debug_hexdump(stdout, "plaintext expected:",
5221 tdata->plaintext.data,
5222 (tdata->plaintext.len >> 3) - tdata->digest.len);
5224 if (ut_params->obuf)
5225 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5226 ciphertext_len, buffer);
5228 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5229 ciphertext_len, buffer);
5231 debug_hexdump(stdout, "ciphertext:", ciphertext,
5233 debug_hexdump(stdout, "ciphertext expected:",
5234 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5236 if (ut_params->obuf)
5237 digest = rte_pktmbuf_read(ut_params->obuf,
5238 (tdata->digest.offset_bytes == 0 ?
5239 plaintext_pad_len : tdata->digest.offset_bytes),
5240 tdata->digest.len, digest_buffer);
5242 digest = rte_pktmbuf_read(ut_params->ibuf,
5243 (tdata->digest.offset_bytes == 0 ?
5244 plaintext_pad_len : tdata->digest.offset_bytes),
5245 tdata->digest.len, digest_buffer);
5247 debug_hexdump(stdout, "digest:", digest,
5249 debug_hexdump(stdout, "digest expected:",
5250 tdata->digest.data, tdata->digest.len);
5255 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5257 tdata->plaintext.data,
5258 tdata->plaintext.len >> 3,
5259 "KASUMI Plaintext data not as expected");
5261 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5263 tdata->ciphertext.data,
5264 tdata->validDataLenInBits.len,
5265 "KASUMI Ciphertext data not as expected");
5267 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5270 DIGEST_BYTE_LENGTH_KASUMI_F9,
5271 "KASUMI Generated auth tag not as expected");
5277 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5279 struct crypto_testsuite_params *ts_params = &testsuite_params;
5280 struct crypto_unittest_params *ut_params = &unittest_params;
5284 uint8_t *plaintext, *ciphertext;
5285 unsigned plaintext_pad_len;
5286 unsigned plaintext_len;
5288 /* Create KASUMI session */
5289 retval = create_wireless_algo_cipher_auth_session(
5290 ts_params->valid_devs[0],
5291 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5292 RTE_CRYPTO_AUTH_OP_GENERATE,
5293 RTE_CRYPTO_AUTH_KASUMI_F9,
5294 RTE_CRYPTO_CIPHER_KASUMI_F8,
5295 tdata->key.data, tdata->key.len,
5296 0, tdata->digest.len,
5297 tdata->cipher_iv.len);
5301 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5303 /* clear mbuf payload */
5304 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5305 rte_pktmbuf_tailroom(ut_params->ibuf));
5307 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5308 /* Append data which is padded to a multiple of */
5309 /* the algorithms block size */
5310 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5311 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5313 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5315 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5317 /* Create KASUMI operation */
5318 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5319 tdata->digest.len, NULL, 0,
5320 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5321 tdata->cipher_iv.data, tdata->cipher_iv.len,
5322 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5323 tdata->validCipherOffsetInBits.len,
5324 tdata->validAuthLenInBits.len,
5330 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5332 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5334 if (ut_params->op->sym->m_dst)
5335 ut_params->obuf = ut_params->op->sym->m_dst;
5337 ut_params->obuf = ut_params->op->sym->m_src;
5339 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5340 tdata->validCipherOffsetInBits.len >> 3);
5342 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5343 + plaintext_pad_len;
5345 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5346 (tdata->validCipherOffsetInBits.len >> 3);
5348 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5350 reference_ciphertext,
5351 tdata->validCipherLenInBits.len,
5352 "KASUMI Ciphertext data not as expected");
5355 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5358 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5359 "KASUMI Generated auth tag not as expected");
5364 test_zuc_encryption(const struct wireless_test_data *tdata)
5366 struct crypto_testsuite_params *ts_params = &testsuite_params;
5367 struct crypto_unittest_params *ut_params = &unittest_params;
5370 uint8_t *plaintext, *ciphertext;
5371 unsigned plaintext_pad_len;
5372 unsigned plaintext_len;
5374 struct rte_cryptodev_sym_capability_idx cap_idx;
5376 /* Check if device supports ZUC EEA3 */
5377 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5378 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5380 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5384 /* Create ZUC session */
5385 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5386 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5387 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5388 tdata->key.data, tdata->key.len,
5389 tdata->cipher_iv.len);
5393 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5395 /* Clear mbuf payload */
5396 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5397 rte_pktmbuf_tailroom(ut_params->ibuf));
5399 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5400 /* Append data which is padded to a multiple */
5401 /* of the algorithms block size */
5402 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5403 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5405 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5407 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5409 /* Create ZUC operation */
5410 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5411 tdata->cipher_iv.len,
5412 tdata->plaintext.len,
5417 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5419 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5421 ut_params->obuf = ut_params->op->sym->m_dst;
5422 if (ut_params->obuf)
5423 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5425 ciphertext = plaintext;
5427 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5430 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5432 tdata->ciphertext.data,
5433 tdata->validCipherLenInBits.len,
5434 "ZUC Ciphertext data not as expected");
5439 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5441 struct crypto_testsuite_params *ts_params = &testsuite_params;
5442 struct crypto_unittest_params *ut_params = &unittest_params;
5446 unsigned int plaintext_pad_len;
5447 unsigned int plaintext_len;
5448 const uint8_t *ciphertext;
5449 uint8_t ciphertext_buffer[2048];
5450 struct rte_cryptodev_info dev_info;
5452 struct rte_cryptodev_sym_capability_idx cap_idx;
5454 /* Check if device supports ZUC EEA3 */
5455 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5456 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5458 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5462 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5464 uint64_t feat_flags = dev_info.feature_flags;
5466 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5467 printf("Device doesn't support in-place scatter-gather. "
5472 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5474 /* Append data which is padded to a multiple */
5475 /* of the algorithms block size */
5476 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5478 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5479 plaintext_pad_len, 10, 0);
5481 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5482 tdata->plaintext.data);
5484 /* Create ZUC session */
5485 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5486 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5487 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5488 tdata->key.data, tdata->key.len,
5489 tdata->cipher_iv.len);
5493 /* Clear mbuf payload */
5495 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5497 /* Create ZUC operation */
5498 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5499 tdata->cipher_iv.len, tdata->plaintext.len,
5504 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5506 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5508 ut_params->obuf = ut_params->op->sym->m_dst;
5509 if (ut_params->obuf)
5510 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5511 0, plaintext_len, ciphertext_buffer);
5513 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5514 0, plaintext_len, ciphertext_buffer);
5517 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5520 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5522 tdata->ciphertext.data,
5523 tdata->validCipherLenInBits.len,
5524 "ZUC Ciphertext data not as expected");
5530 test_zuc_authentication(const struct wireless_test_data *tdata)
5532 struct crypto_testsuite_params *ts_params = &testsuite_params;
5533 struct crypto_unittest_params *ut_params = &unittest_params;
5536 unsigned plaintext_pad_len;
5537 unsigned plaintext_len;
5540 struct rte_cryptodev_sym_capability_idx cap_idx;
5542 /* Check if device supports ZUC EIA3 */
5543 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5544 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5546 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5550 /* Create ZUC session */
5551 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5552 tdata->key.data, tdata->key.len,
5553 tdata->auth_iv.len, tdata->digest.len,
5554 RTE_CRYPTO_AUTH_OP_GENERATE,
5555 RTE_CRYPTO_AUTH_ZUC_EIA3);
5559 /* alloc mbuf and set payload */
5560 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5562 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5563 rte_pktmbuf_tailroom(ut_params->ibuf));
5565 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5566 /* Append data which is padded to a multiple of */
5567 /* the algorithms block size */
5568 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5569 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5571 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5573 /* Create ZUC operation */
5574 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5575 tdata->auth_iv.data, tdata->auth_iv.len,
5576 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5577 tdata->validAuthLenInBits.len,
5582 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5584 ut_params->obuf = ut_params->op->sym->m_src;
5585 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5586 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5587 + plaintext_pad_len;
5590 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5593 DIGEST_BYTE_LENGTH_KASUMI_F9,
5594 "ZUC Generated auth tag not as expected");
5600 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5601 uint8_t op_mode, uint8_t verify)
5603 struct crypto_testsuite_params *ts_params = &testsuite_params;
5604 struct crypto_unittest_params *ut_params = &unittest_params;
5608 uint8_t *plaintext = NULL, *ciphertext = NULL;
5609 unsigned int plaintext_pad_len;
5610 unsigned int plaintext_len;
5611 unsigned int ciphertext_pad_len;
5612 unsigned int ciphertext_len;
5614 struct rte_cryptodev_info dev_info;
5615 struct rte_cryptodev_sym_capability_idx cap_idx;
5617 /* Check if device supports ZUC EIA3 */
5618 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5619 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5621 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5625 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5627 uint64_t feat_flags = dev_info.feature_flags;
5629 if (op_mode == OUT_OF_PLACE) {
5630 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5631 printf("Device doesn't support digest encrypted.\n");
5636 /* Create ZUC session */
5637 retval = create_wireless_algo_auth_cipher_session(
5638 ts_params->valid_devs[0],
5639 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5640 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5641 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5642 : RTE_CRYPTO_AUTH_OP_GENERATE),
5643 RTE_CRYPTO_AUTH_ZUC_EIA3,
5644 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5645 tdata->key.data, tdata->key.len,
5646 tdata->auth_iv.len, tdata->digest.len,
5647 tdata->cipher_iv.len);
5652 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5653 if (op_mode == OUT_OF_PLACE)
5654 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5656 /* clear mbuf payload */
5657 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5658 rte_pktmbuf_tailroom(ut_params->ibuf));
5659 if (op_mode == OUT_OF_PLACE)
5660 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5661 rte_pktmbuf_tailroom(ut_params->obuf));
5663 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5664 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5665 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5666 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5669 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5670 ciphertext_pad_len);
5671 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5672 if (op_mode == OUT_OF_PLACE)
5673 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5674 debug_hexdump(stdout, "ciphertext:", ciphertext,
5677 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5679 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5680 if (op_mode == OUT_OF_PLACE)
5681 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5682 debug_hexdump(stdout, "plaintext:", plaintext,
5686 /* Create ZUC operation */
5687 retval = create_wireless_algo_auth_cipher_operation(
5688 tdata->digest.data, tdata->digest.len,
5689 tdata->cipher_iv.data, tdata->cipher_iv.len,
5690 tdata->auth_iv.data, tdata->auth_iv.len,
5691 (tdata->digest.offset_bytes == 0 ?
5692 (verify ? ciphertext_pad_len : plaintext_pad_len)
5693 : tdata->digest.offset_bytes),
5694 tdata->validCipherLenInBits.len,
5695 tdata->validCipherOffsetInBits.len,
5696 tdata->validAuthLenInBits.len,
5698 op_mode, 0, verify);
5703 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5706 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5708 ut_params->obuf = (op_mode == IN_PLACE ?
5709 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5713 if (ut_params->obuf)
5714 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5717 plaintext = ciphertext;
5719 debug_hexdump(stdout, "plaintext:", plaintext,
5720 (tdata->plaintext.len >> 3) - tdata->digest.len);
5721 debug_hexdump(stdout, "plaintext expected:",
5722 tdata->plaintext.data,
5723 (tdata->plaintext.len >> 3) - tdata->digest.len);
5725 if (ut_params->obuf)
5726 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5729 ciphertext = plaintext;
5731 debug_hexdump(stdout, "ciphertext:", ciphertext,
5733 debug_hexdump(stdout, "ciphertext expected:",
5734 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5736 ut_params->digest = rte_pktmbuf_mtod(
5737 ut_params->obuf, uint8_t *) +
5738 (tdata->digest.offset_bytes == 0 ?
5739 plaintext_pad_len : tdata->digest.offset_bytes);
5741 debug_hexdump(stdout, "digest:", ut_params->digest,
5743 debug_hexdump(stdout, "digest expected:",
5744 tdata->digest.data, tdata->digest.len);
5749 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5751 tdata->plaintext.data,
5752 tdata->plaintext.len >> 3,
5753 "ZUC Plaintext data not as expected");
5755 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5757 tdata->ciphertext.data,
5758 tdata->ciphertext.len >> 3,
5759 "ZUC Ciphertext data not as expected");
5761 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5764 DIGEST_BYTE_LENGTH_KASUMI_F9,
5765 "ZUC Generated auth tag not as expected");
5771 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5772 uint8_t op_mode, uint8_t verify)
5774 struct crypto_testsuite_params *ts_params = &testsuite_params;
5775 struct crypto_unittest_params *ut_params = &unittest_params;
5779 const uint8_t *plaintext = NULL;
5780 const uint8_t *ciphertext = NULL;
5781 const uint8_t *digest = NULL;
5782 unsigned int plaintext_pad_len;
5783 unsigned int plaintext_len;
5784 unsigned int ciphertext_pad_len;
5785 unsigned int ciphertext_len;
5786 uint8_t buffer[10000];
5787 uint8_t digest_buffer[10000];
5789 struct rte_cryptodev_info dev_info;
5790 struct rte_cryptodev_sym_capability_idx cap_idx;
5792 /* Check if device supports ZUC EIA3 */
5793 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5794 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5796 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5800 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5802 uint64_t feat_flags = dev_info.feature_flags;
5804 if (op_mode == IN_PLACE) {
5805 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5806 printf("Device doesn't support in-place scatter-gather "
5807 "in both input and output mbufs.\n");
5811 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5812 printf("Device doesn't support out-of-place scatter-gather "
5813 "in both input and output mbufs.\n");
5816 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5817 printf("Device doesn't support digest encrypted.\n");
5822 /* Create ZUC session */
5823 retval = create_wireless_algo_auth_cipher_session(
5824 ts_params->valid_devs[0],
5825 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5826 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5827 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5828 : RTE_CRYPTO_AUTH_OP_GENERATE),
5829 RTE_CRYPTO_AUTH_ZUC_EIA3,
5830 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5831 tdata->key.data, tdata->key.len,
5832 tdata->auth_iv.len, tdata->digest.len,
5833 tdata->cipher_iv.len);
5838 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5839 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5840 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5841 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5843 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5844 plaintext_pad_len, 15, 0);
5845 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5846 "Failed to allocate input buffer in mempool");
5848 if (op_mode == OUT_OF_PLACE) {
5849 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5850 plaintext_pad_len, 15, 0);
5851 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5852 "Failed to allocate output buffer in mempool");
5856 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5857 tdata->ciphertext.data);
5858 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5859 ciphertext_len, buffer);
5860 debug_hexdump(stdout, "ciphertext:", ciphertext,
5863 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5864 tdata->plaintext.data);
5865 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5866 plaintext_len, buffer);
5867 debug_hexdump(stdout, "plaintext:", plaintext,
5870 memset(buffer, 0, sizeof(buffer));
5872 /* Create ZUC operation */
5873 retval = create_wireless_algo_auth_cipher_operation(
5874 tdata->digest.data, tdata->digest.len,
5875 tdata->cipher_iv.data, tdata->cipher_iv.len,
5877 (tdata->digest.offset_bytes == 0 ?
5878 (verify ? ciphertext_pad_len : plaintext_pad_len)
5879 : tdata->digest.offset_bytes),
5880 tdata->validCipherLenInBits.len,
5881 tdata->validCipherOffsetInBits.len,
5882 tdata->validAuthLenInBits.len,
5884 op_mode, 1, verify);
5889 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5892 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5894 ut_params->obuf = (op_mode == IN_PLACE ?
5895 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5898 if (ut_params->obuf)
5899 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5900 plaintext_len, buffer);
5902 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5903 plaintext_len, buffer);
5905 debug_hexdump(stdout, "plaintext:", plaintext,
5906 (tdata->plaintext.len >> 3) - tdata->digest.len);
5907 debug_hexdump(stdout, "plaintext expected:",
5908 tdata->plaintext.data,
5909 (tdata->plaintext.len >> 3) - tdata->digest.len);
5911 if (ut_params->obuf)
5912 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5913 ciphertext_len, buffer);
5915 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5916 ciphertext_len, buffer);
5918 debug_hexdump(stdout, "ciphertext:", ciphertext,
5920 debug_hexdump(stdout, "ciphertext expected:",
5921 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5923 if (ut_params->obuf)
5924 digest = rte_pktmbuf_read(ut_params->obuf,
5925 (tdata->digest.offset_bytes == 0 ?
5926 plaintext_pad_len : tdata->digest.offset_bytes),
5927 tdata->digest.len, digest_buffer);
5929 digest = rte_pktmbuf_read(ut_params->ibuf,
5930 (tdata->digest.offset_bytes == 0 ?
5931 plaintext_pad_len : tdata->digest.offset_bytes),
5932 tdata->digest.len, digest_buffer);
5934 debug_hexdump(stdout, "digest:", digest,
5936 debug_hexdump(stdout, "digest expected:",
5937 tdata->digest.data, tdata->digest.len);
5942 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5944 tdata->plaintext.data,
5945 tdata->plaintext.len >> 3,
5946 "ZUC Plaintext data not as expected");
5948 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5950 tdata->ciphertext.data,
5951 tdata->validDataLenInBits.len,
5952 "ZUC Ciphertext data not as expected");
5954 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5957 DIGEST_BYTE_LENGTH_KASUMI_F9,
5958 "ZUC Generated auth tag not as expected");
5964 test_kasumi_encryption_test_case_1(void)
5966 return test_kasumi_encryption(&kasumi_test_case_1);
5970 test_kasumi_encryption_test_case_1_sgl(void)
5972 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
5976 test_kasumi_encryption_test_case_1_oop(void)
5978 return test_kasumi_encryption_oop(&kasumi_test_case_1);
5982 test_kasumi_encryption_test_case_1_oop_sgl(void)
5984 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
5988 test_kasumi_encryption_test_case_2(void)
5990 return test_kasumi_encryption(&kasumi_test_case_2);
5994 test_kasumi_encryption_test_case_3(void)
5996 return test_kasumi_encryption(&kasumi_test_case_3);
6000 test_kasumi_encryption_test_case_4(void)
6002 return test_kasumi_encryption(&kasumi_test_case_4);
6006 test_kasumi_encryption_test_case_5(void)
6008 return test_kasumi_encryption(&kasumi_test_case_5);
6012 test_kasumi_decryption_test_case_1(void)
6014 return test_kasumi_decryption(&kasumi_test_case_1);
6018 test_kasumi_decryption_test_case_1_oop(void)
6020 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6024 test_kasumi_decryption_test_case_2(void)
6026 return test_kasumi_decryption(&kasumi_test_case_2);
6030 test_kasumi_decryption_test_case_3(void)
6032 return test_kasumi_decryption(&kasumi_test_case_3);
6036 test_kasumi_decryption_test_case_4(void)
6038 return test_kasumi_decryption(&kasumi_test_case_4);
6042 test_kasumi_decryption_test_case_5(void)
6044 return test_kasumi_decryption(&kasumi_test_case_5);
6047 test_snow3g_encryption_test_case_1(void)
6049 return test_snow3g_encryption(&snow3g_test_case_1);
6053 test_snow3g_encryption_test_case_1_oop(void)
6055 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6059 test_snow3g_encryption_test_case_1_oop_sgl(void)
6061 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6066 test_snow3g_encryption_test_case_1_offset_oop(void)
6068 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6072 test_snow3g_encryption_test_case_2(void)
6074 return test_snow3g_encryption(&snow3g_test_case_2);
6078 test_snow3g_encryption_test_case_3(void)
6080 return test_snow3g_encryption(&snow3g_test_case_3);
6084 test_snow3g_encryption_test_case_4(void)
6086 return test_snow3g_encryption(&snow3g_test_case_4);
6090 test_snow3g_encryption_test_case_5(void)
6092 return test_snow3g_encryption(&snow3g_test_case_5);
6096 test_snow3g_decryption_test_case_1(void)
6098 return test_snow3g_decryption(&snow3g_test_case_1);
6102 test_snow3g_decryption_test_case_1_oop(void)
6104 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6108 test_snow3g_decryption_test_case_2(void)
6110 return test_snow3g_decryption(&snow3g_test_case_2);
6114 test_snow3g_decryption_test_case_3(void)
6116 return test_snow3g_decryption(&snow3g_test_case_3);
6120 test_snow3g_decryption_test_case_4(void)
6122 return test_snow3g_decryption(&snow3g_test_case_4);
6126 test_snow3g_decryption_test_case_5(void)
6128 return test_snow3g_decryption(&snow3g_test_case_5);
6132 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6133 * Pattern digest from snow3g_test_data must be allocated as
6134 * 4 last bytes in plaintext.
6137 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6138 struct snow3g_hash_test_data *output)
6140 if ((pattern != NULL) && (output != NULL)) {
6141 output->key.len = pattern->key.len;
6143 memcpy(output->key.data,
6144 pattern->key.data, pattern->key.len);
6146 output->auth_iv.len = pattern->auth_iv.len;
6148 memcpy(output->auth_iv.data,
6149 pattern->auth_iv.data, pattern->auth_iv.len);
6151 output->plaintext.len = pattern->plaintext.len;
6153 memcpy(output->plaintext.data,
6154 pattern->plaintext.data, pattern->plaintext.len >> 3);
6156 output->digest.len = pattern->digest.len;
6158 memcpy(output->digest.data,
6159 &pattern->plaintext.data[pattern->digest.offset_bytes],
6160 pattern->digest.len);
6162 output->validAuthLenInBits.len =
6163 pattern->validAuthLenInBits.len;
6168 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6171 test_snow3g_decryption_with_digest_test_case_1(void)
6173 struct snow3g_hash_test_data snow3g_hash_data;
6176 * Function prepare data for hash veryfication test case.
6177 * Digest is allocated in 4 last bytes in plaintext, pattern.
6179 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6181 return test_snow3g_decryption(&snow3g_test_case_7) &
6182 test_snow3g_authentication_verify(&snow3g_hash_data);
6186 test_snow3g_cipher_auth_test_case_1(void)
6188 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6192 test_snow3g_auth_cipher_test_case_1(void)
6194 return test_snow3g_auth_cipher(
6195 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6199 test_snow3g_auth_cipher_test_case_2(void)
6201 return test_snow3g_auth_cipher(
6202 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6206 test_snow3g_auth_cipher_test_case_2_oop(void)
6208 return test_snow3g_auth_cipher(
6209 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6213 test_snow3g_auth_cipher_part_digest_enc(void)
6215 return test_snow3g_auth_cipher(
6216 &snow3g_auth_cipher_partial_digest_encryption,
6221 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6223 return test_snow3g_auth_cipher(
6224 &snow3g_auth_cipher_partial_digest_encryption,
6229 test_snow3g_auth_cipher_test_case_3_sgl(void)
6231 return test_snow3g_auth_cipher_sgl(
6232 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6236 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6238 return test_snow3g_auth_cipher_sgl(
6239 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6243 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6245 return test_snow3g_auth_cipher_sgl(
6246 &snow3g_auth_cipher_partial_digest_encryption,
6251 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6253 return test_snow3g_auth_cipher_sgl(
6254 &snow3g_auth_cipher_partial_digest_encryption,
6259 test_snow3g_auth_cipher_verify_test_case_1(void)
6261 return test_snow3g_auth_cipher(
6262 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6266 test_snow3g_auth_cipher_verify_test_case_2(void)
6268 return test_snow3g_auth_cipher(
6269 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6273 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6275 return test_snow3g_auth_cipher(
6276 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6280 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6282 return test_snow3g_auth_cipher(
6283 &snow3g_auth_cipher_partial_digest_encryption,
6288 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6290 return test_snow3g_auth_cipher(
6291 &snow3g_auth_cipher_partial_digest_encryption,
6296 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6298 return test_snow3g_auth_cipher_sgl(
6299 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6303 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6305 return test_snow3g_auth_cipher_sgl(
6306 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6310 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6312 return test_snow3g_auth_cipher_sgl(
6313 &snow3g_auth_cipher_partial_digest_encryption,
6318 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6320 return test_snow3g_auth_cipher_sgl(
6321 &snow3g_auth_cipher_partial_digest_encryption,
6326 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6328 return test_snow3g_auth_cipher(
6329 &snow3g_test_case_7, IN_PLACE, 0);
6333 test_kasumi_auth_cipher_test_case_1(void)
6335 return test_kasumi_auth_cipher(
6336 &kasumi_test_case_3, IN_PLACE, 0);
6340 test_kasumi_auth_cipher_test_case_2(void)
6342 return test_kasumi_auth_cipher(
6343 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6347 test_kasumi_auth_cipher_test_case_2_oop(void)
6349 return test_kasumi_auth_cipher(
6350 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6354 test_kasumi_auth_cipher_test_case_2_sgl(void)
6356 return test_kasumi_auth_cipher_sgl(
6357 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6361 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6363 return test_kasumi_auth_cipher_sgl(
6364 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6368 test_kasumi_auth_cipher_verify_test_case_1(void)
6370 return test_kasumi_auth_cipher(
6371 &kasumi_test_case_3, IN_PLACE, 1);
6375 test_kasumi_auth_cipher_verify_test_case_2(void)
6377 return test_kasumi_auth_cipher(
6378 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6382 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6384 return test_kasumi_auth_cipher(
6385 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6389 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6391 return test_kasumi_auth_cipher_sgl(
6392 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6396 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6398 return test_kasumi_auth_cipher_sgl(
6399 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6403 test_kasumi_cipher_auth_test_case_1(void)
6405 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6409 test_zuc_encryption_test_case_1(void)
6411 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6415 test_zuc_encryption_test_case_2(void)
6417 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6421 test_zuc_encryption_test_case_3(void)
6423 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6427 test_zuc_encryption_test_case_4(void)
6429 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6433 test_zuc_encryption_test_case_5(void)
6435 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6439 test_zuc_encryption_test_case_6_sgl(void)
6441 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6445 test_zuc_hash_generate_test_case_1(void)
6447 return test_zuc_authentication(&zuc_test_case_auth_1b);
6451 test_zuc_hash_generate_test_case_2(void)
6453 return test_zuc_authentication(&zuc_test_case_auth_90b);
6457 test_zuc_hash_generate_test_case_3(void)
6459 return test_zuc_authentication(&zuc_test_case_auth_577b);
6463 test_zuc_hash_generate_test_case_4(void)
6465 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6469 test_zuc_hash_generate_test_case_5(void)
6471 return test_zuc_authentication(&zuc_test_auth_5670b);
6475 test_zuc_hash_generate_test_case_6(void)
6477 return test_zuc_authentication(&zuc_test_case_auth_128b);
6481 test_zuc_hash_generate_test_case_7(void)
6483 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6487 test_zuc_hash_generate_test_case_8(void)
6489 return test_zuc_authentication(&zuc_test_case_auth_584b);
6493 test_zuc_cipher_auth_test_case_1(void)
6495 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6499 test_zuc_cipher_auth_test_case_2(void)
6501 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6505 test_zuc_auth_cipher_test_case_1(void)
6507 return test_zuc_auth_cipher(
6508 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6512 test_zuc_auth_cipher_test_case_1_oop(void)
6514 return test_zuc_auth_cipher(
6515 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6519 test_zuc_auth_cipher_test_case_1_sgl(void)
6521 return test_zuc_auth_cipher_sgl(
6522 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6526 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6528 return test_zuc_auth_cipher_sgl(
6529 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6533 test_zuc_auth_cipher_verify_test_case_1(void)
6535 return test_zuc_auth_cipher(
6536 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6540 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6542 return test_zuc_auth_cipher(
6543 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6547 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6549 return test_zuc_auth_cipher_sgl(
6550 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6554 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6556 return test_zuc_auth_cipher_sgl(
6557 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6561 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6563 uint8_t dev_id = testsuite_params.valid_devs[0];
6565 struct rte_cryptodev_sym_capability_idx cap_idx;
6567 /* Check if device supports particular cipher algorithm */
6568 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6569 cap_idx.algo.cipher = tdata->cipher_algo;
6570 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6573 /* Check if device supports particular hash algorithm */
6574 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6575 cap_idx.algo.auth = tdata->auth_algo;
6576 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6583 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6584 uint8_t op_mode, uint8_t verify)
6586 struct crypto_testsuite_params *ts_params = &testsuite_params;
6587 struct crypto_unittest_params *ut_params = &unittest_params;
6591 uint8_t *plaintext = NULL, *ciphertext = NULL;
6592 unsigned int plaintext_pad_len;
6593 unsigned int plaintext_len;
6594 unsigned int ciphertext_pad_len;
6595 unsigned int ciphertext_len;
6597 struct rte_cryptodev_info dev_info;
6599 /* Check if device supports particular algorithms */
6600 if (test_mixed_check_if_unsupported(tdata))
6603 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6605 uint64_t feat_flags = dev_info.feature_flags;
6607 if (op_mode == OUT_OF_PLACE) {
6608 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6609 printf("Device doesn't support digest encrypted.\n");
6614 /* Create the session */
6615 retval = create_wireless_algo_auth_cipher_session(
6616 ts_params->valid_devs[0],
6617 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6618 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6619 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6620 : RTE_CRYPTO_AUTH_OP_GENERATE),
6623 tdata->auth_key.data, tdata->auth_key.len,
6624 tdata->auth_iv.len, tdata->digest_enc.len,
6625 tdata->cipher_iv.len);
6630 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6631 if (op_mode == OUT_OF_PLACE)
6632 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6634 /* clear mbuf payload */
6635 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6636 rte_pktmbuf_tailroom(ut_params->ibuf));
6637 if (op_mode == OUT_OF_PLACE)
6638 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6639 rte_pktmbuf_tailroom(ut_params->obuf));
6641 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6642 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6643 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6644 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6647 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6648 ciphertext_pad_len);
6649 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6650 if (op_mode == OUT_OF_PLACE)
6651 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6652 debug_hexdump(stdout, "ciphertext:", ciphertext,
6655 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6657 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6658 if (op_mode == OUT_OF_PLACE)
6659 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6660 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6663 /* Create the operation */
6664 retval = create_wireless_algo_auth_cipher_operation(
6665 tdata->digest_enc.data, tdata->digest_enc.len,
6666 tdata->cipher_iv.data, tdata->cipher_iv.len,
6667 tdata->auth_iv.data, tdata->auth_iv.len,
6668 (tdata->digest_enc.offset == 0 ?
6669 (verify ? ciphertext_pad_len : plaintext_pad_len)
6670 : tdata->digest_enc.offset),
6671 tdata->validCipherLen.len_bits,
6672 tdata->cipher.offset_bits,
6673 tdata->validAuthLen.len_bits,
6674 tdata->auth.offset_bits,
6675 op_mode, 0, verify);
6680 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6683 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6685 ut_params->obuf = (op_mode == IN_PLACE ?
6686 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6689 if (ut_params->obuf)
6690 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6693 plaintext = ciphertext +
6694 (tdata->cipher.offset_bits >> 3);
6696 debug_hexdump(stdout, "plaintext:", plaintext,
6697 (tdata->plaintext.len_bits >> 3) -
6698 tdata->digest_enc.len);
6699 debug_hexdump(stdout, "plaintext expected:",
6700 tdata->plaintext.data,
6701 (tdata->plaintext.len_bits >> 3) -
6702 tdata->digest_enc.len);
6704 if (ut_params->obuf)
6705 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6708 ciphertext = plaintext;
6710 debug_hexdump(stdout, "ciphertext:", ciphertext,
6712 debug_hexdump(stdout, "ciphertext expected:",
6713 tdata->ciphertext.data,
6714 tdata->ciphertext.len_bits >> 3);
6716 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6717 + (tdata->digest_enc.offset == 0 ?
6718 plaintext_pad_len : tdata->digest_enc.offset);
6720 debug_hexdump(stdout, "digest:", ut_params->digest,
6721 tdata->digest_enc.len);
6722 debug_hexdump(stdout, "digest expected:",
6723 tdata->digest_enc.data,
6724 tdata->digest_enc.len);
6729 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6731 tdata->plaintext.data,
6732 tdata->plaintext.len_bits >> 3,
6733 "Plaintext data not as expected");
6735 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6737 tdata->ciphertext.data,
6738 tdata->validDataLen.len_bits,
6739 "Ciphertext data not as expected");
6741 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6743 tdata->digest_enc.data,
6744 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6745 "Generated auth tag not as expected");
6751 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6752 uint8_t op_mode, uint8_t verify)
6754 struct crypto_testsuite_params *ts_params = &testsuite_params;
6755 struct crypto_unittest_params *ut_params = &unittest_params;
6759 const uint8_t *plaintext = NULL;
6760 const uint8_t *ciphertext = NULL;
6761 const uint8_t *digest = NULL;
6762 unsigned int plaintext_pad_len;
6763 unsigned int plaintext_len;
6764 unsigned int ciphertext_pad_len;
6765 unsigned int ciphertext_len;
6766 uint8_t buffer[10000];
6767 uint8_t digest_buffer[10000];
6769 struct rte_cryptodev_info dev_info;
6771 /* Check if device supports particular algorithms */
6772 if (test_mixed_check_if_unsupported(tdata))
6775 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6777 uint64_t feat_flags = dev_info.feature_flags;
6779 if (op_mode == IN_PLACE) {
6780 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6781 printf("Device doesn't support in-place scatter-gather "
6782 "in both input and output mbufs.\n");
6786 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6787 printf("Device doesn't support out-of-place scatter-gather "
6788 "in both input and output mbufs.\n");
6791 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6792 printf("Device doesn't support digest encrypted.\n");
6797 /* Create the session */
6798 retval = create_wireless_algo_auth_cipher_session(
6799 ts_params->valid_devs[0],
6800 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
6801 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
6802 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
6803 : RTE_CRYPTO_AUTH_OP_GENERATE),
6806 tdata->auth_key.data, tdata->auth_key.len,
6807 tdata->auth_iv.len, tdata->digest_enc.len,
6808 tdata->cipher_iv.len);
6813 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6814 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6815 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6816 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6818 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6819 plaintext_pad_len, 15, 0);
6820 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6821 "Failed to allocate input buffer in mempool");
6823 if (op_mode == OUT_OF_PLACE) {
6824 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6825 plaintext_pad_len, 15, 0);
6826 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6827 "Failed to allocate output buffer in mempool");
6831 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6832 tdata->ciphertext.data);
6833 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6834 ciphertext_len, buffer);
6835 debug_hexdump(stdout, "ciphertext:", ciphertext,
6838 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6839 tdata->plaintext.data);
6840 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6841 plaintext_len, buffer);
6842 debug_hexdump(stdout, "plaintext:", plaintext,
6845 memset(buffer, 0, sizeof(buffer));
6847 /* Create the operation */
6848 retval = create_wireless_algo_auth_cipher_operation(
6849 tdata->digest_enc.data, tdata->digest_enc.len,
6850 tdata->cipher_iv.data, tdata->cipher_iv.len,
6851 tdata->auth_iv.data, tdata->auth_iv.len,
6852 (tdata->digest_enc.offset == 0 ?
6853 (verify ? ciphertext_pad_len : plaintext_pad_len)
6854 : tdata->digest_enc.offset),
6855 tdata->validCipherLen.len_bits,
6856 tdata->cipher.offset_bits,
6857 tdata->validAuthLen.len_bits,
6858 tdata->auth.offset_bits,
6859 op_mode, 1, verify);
6864 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
6867 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6869 ut_params->obuf = (op_mode == IN_PLACE ?
6870 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6873 if (ut_params->obuf)
6874 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6875 plaintext_len, buffer);
6877 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6878 plaintext_len, buffer);
6880 debug_hexdump(stdout, "plaintext:", plaintext,
6881 (tdata->plaintext.len_bits >> 3) -
6882 tdata->digest_enc.len);
6883 debug_hexdump(stdout, "plaintext expected:",
6884 tdata->plaintext.data,
6885 (tdata->plaintext.len_bits >> 3) -
6886 tdata->digest_enc.len);
6888 if (ut_params->obuf)
6889 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6890 ciphertext_len, buffer);
6892 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6893 ciphertext_len, buffer);
6895 debug_hexdump(stdout, "ciphertext:", ciphertext,
6897 debug_hexdump(stdout, "ciphertext expected:",
6898 tdata->ciphertext.data,
6899 tdata->ciphertext.len_bits >> 3);
6901 if (ut_params->obuf)
6902 digest = rte_pktmbuf_read(ut_params->obuf,
6903 (tdata->digest_enc.offset == 0 ?
6905 tdata->digest_enc.offset),
6906 tdata->digest_enc.len, digest_buffer);
6908 digest = rte_pktmbuf_read(ut_params->ibuf,
6909 (tdata->digest_enc.offset == 0 ?
6911 tdata->digest_enc.offset),
6912 tdata->digest_enc.len, digest_buffer);
6914 debug_hexdump(stdout, "digest:", digest,
6915 tdata->digest_enc.len);
6916 debug_hexdump(stdout, "digest expected:",
6917 tdata->digest_enc.data, tdata->digest_enc.len);
6922 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6924 tdata->plaintext.data,
6925 tdata->plaintext.len_bits >> 3,
6926 "Plaintext data not as expected");
6928 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6930 tdata->ciphertext.data,
6931 tdata->validDataLen.len_bits,
6932 "Ciphertext data not as expected");
6933 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6935 tdata->digest_enc.data,
6936 tdata->digest_enc.len,
6937 "Generated auth tag not as expected");
6942 /** AUTH AES CMAC + CIPHER AES CTR */
6945 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6947 return test_mixed_auth_cipher(
6948 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6952 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6954 return test_mixed_auth_cipher(
6955 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6959 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6961 return test_mixed_auth_cipher_sgl(
6962 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
6966 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6968 return test_mixed_auth_cipher_sgl(
6969 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
6973 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
6975 return test_mixed_auth_cipher(
6976 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6980 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
6982 return test_mixed_auth_cipher(
6983 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
6987 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
6989 return test_mixed_auth_cipher_sgl(
6990 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
6994 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
6996 return test_mixed_auth_cipher_sgl(
6997 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7001 test_3DES_chain_qat_all(void)
7003 struct crypto_testsuite_params *ts_params = &testsuite_params;
7006 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7007 ts_params->op_mpool,
7008 ts_params->session_mpool, ts_params->session_priv_mpool,
7009 ts_params->valid_devs[0],
7010 rte_cryptodev_driver_id_get(
7011 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7012 BLKCIPHER_3DES_CHAIN_TYPE);
7014 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7016 return TEST_SUCCESS;
7020 test_DES_cipheronly_qat_all(void)
7022 struct crypto_testsuite_params *ts_params = &testsuite_params;
7025 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7026 ts_params->op_mpool,
7027 ts_params->session_mpool, ts_params->session_priv_mpool,
7028 ts_params->valid_devs[0],
7029 rte_cryptodev_driver_id_get(
7030 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7031 BLKCIPHER_DES_CIPHERONLY_TYPE);
7033 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7035 return TEST_SUCCESS;
7039 test_DES_cipheronly_openssl_all(void)
7041 struct crypto_testsuite_params *ts_params = &testsuite_params;
7044 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7045 ts_params->op_mpool,
7046 ts_params->session_mpool, ts_params->session_priv_mpool,
7047 ts_params->valid_devs[0],
7048 rte_cryptodev_driver_id_get(
7049 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7050 BLKCIPHER_DES_CIPHERONLY_TYPE);
7052 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7054 return TEST_SUCCESS;
7058 test_DES_docsis_openssl_all(void)
7060 struct crypto_testsuite_params *ts_params = &testsuite_params;
7063 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7064 ts_params->op_mpool,
7065 ts_params->session_mpool, ts_params->session_priv_mpool,
7066 ts_params->valid_devs[0],
7067 rte_cryptodev_driver_id_get(
7068 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7069 BLKCIPHER_DES_DOCSIS_TYPE);
7071 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7073 return TEST_SUCCESS;
7077 test_DES_cipheronly_mb_all(void)
7079 struct crypto_testsuite_params *ts_params = &testsuite_params;
7082 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7083 ts_params->op_mpool,
7084 ts_params->session_mpool, ts_params->session_priv_mpool,
7085 ts_params->valid_devs[0],
7086 rte_cryptodev_driver_id_get(
7087 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7088 BLKCIPHER_DES_CIPHERONLY_TYPE);
7090 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7092 return TEST_SUCCESS;
7095 test_3DES_cipheronly_mb_all(void)
7097 struct crypto_testsuite_params *ts_params = &testsuite_params;
7100 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7101 ts_params->op_mpool,
7102 ts_params->session_mpool, ts_params->session_priv_mpool,
7103 ts_params->valid_devs[0],
7104 rte_cryptodev_driver_id_get(
7105 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7106 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7108 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7110 return TEST_SUCCESS;
7114 test_DES_docsis_mb_all(void)
7116 struct crypto_testsuite_params *ts_params = &testsuite_params;
7119 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7120 ts_params->op_mpool,
7121 ts_params->session_mpool, ts_params->session_priv_mpool,
7122 ts_params->valid_devs[0],
7123 rte_cryptodev_driver_id_get(
7124 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7125 BLKCIPHER_DES_DOCSIS_TYPE);
7127 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7129 return TEST_SUCCESS;
7133 test_3DES_chain_caam_jr_all(void)
7135 struct crypto_testsuite_params *ts_params = &testsuite_params;
7138 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7139 ts_params->op_mpool,
7140 ts_params->session_mpool, ts_params->session_priv_mpool,
7141 ts_params->valid_devs[0],
7142 rte_cryptodev_driver_id_get(
7143 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7144 BLKCIPHER_3DES_CHAIN_TYPE);
7146 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7148 return TEST_SUCCESS;
7152 test_3DES_cipheronly_caam_jr_all(void)
7154 struct crypto_testsuite_params *ts_params = &testsuite_params;
7157 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7158 ts_params->op_mpool,
7159 ts_params->session_mpool, ts_params->session_priv_mpool,
7160 ts_params->valid_devs[0],
7161 rte_cryptodev_driver_id_get(
7162 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7163 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7165 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7167 return TEST_SUCCESS;
7171 test_3DES_chain_dpaa_sec_all(void)
7173 struct crypto_testsuite_params *ts_params = &testsuite_params;
7176 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7177 ts_params->op_mpool,
7178 ts_params->session_mpool, ts_params->session_priv_mpool,
7179 ts_params->valid_devs[0],
7180 rte_cryptodev_driver_id_get(
7181 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7182 BLKCIPHER_3DES_CHAIN_TYPE);
7184 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7186 return TEST_SUCCESS;
7190 test_3DES_cipheronly_dpaa_sec_all(void)
7192 struct crypto_testsuite_params *ts_params = &testsuite_params;
7195 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7196 ts_params->op_mpool,
7197 ts_params->session_mpool, ts_params->session_priv_mpool,
7198 ts_params->valid_devs[0],
7199 rte_cryptodev_driver_id_get(
7200 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7201 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7203 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7205 return TEST_SUCCESS;
7209 test_3DES_chain_dpaa2_sec_all(void)
7211 struct crypto_testsuite_params *ts_params = &testsuite_params;
7214 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7215 ts_params->op_mpool,
7216 ts_params->session_mpool, ts_params->session_priv_mpool,
7217 ts_params->valid_devs[0],
7218 rte_cryptodev_driver_id_get(
7219 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7220 BLKCIPHER_3DES_CHAIN_TYPE);
7222 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7224 return TEST_SUCCESS;
7228 test_3DES_cipheronly_dpaa2_sec_all(void)
7230 struct crypto_testsuite_params *ts_params = &testsuite_params;
7233 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7234 ts_params->op_mpool,
7235 ts_params->session_mpool, ts_params->session_priv_mpool,
7236 ts_params->valid_devs[0],
7237 rte_cryptodev_driver_id_get(
7238 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7239 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7241 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7243 return TEST_SUCCESS;
7247 test_3DES_chain_ccp_all(void)
7249 struct crypto_testsuite_params *ts_params = &testsuite_params;
7252 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7253 ts_params->op_mpool,
7254 ts_params->session_mpool, ts_params->session_priv_mpool,
7255 ts_params->valid_devs[0],
7256 rte_cryptodev_driver_id_get(
7257 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7258 BLKCIPHER_3DES_CHAIN_TYPE);
7260 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7262 return TEST_SUCCESS;
7266 test_3DES_cipheronly_ccp_all(void)
7268 struct crypto_testsuite_params *ts_params = &testsuite_params;
7271 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7272 ts_params->op_mpool,
7273 ts_params->session_mpool, ts_params->session_priv_mpool,
7274 ts_params->valid_devs[0],
7275 rte_cryptodev_driver_id_get(
7276 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7277 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7279 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7281 return TEST_SUCCESS;
7285 test_3DES_cipheronly_qat_all(void)
7287 struct crypto_testsuite_params *ts_params = &testsuite_params;
7290 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7291 ts_params->op_mpool,
7292 ts_params->session_mpool, ts_params->session_priv_mpool,
7293 ts_params->valid_devs[0],
7294 rte_cryptodev_driver_id_get(
7295 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7296 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7298 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7300 return TEST_SUCCESS;
7304 test_3DES_chain_openssl_all(void)
7306 struct crypto_testsuite_params *ts_params = &testsuite_params;
7309 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7310 ts_params->op_mpool,
7311 ts_params->session_mpool, ts_params->session_priv_mpool,
7312 ts_params->valid_devs[0],
7313 rte_cryptodev_driver_id_get(
7314 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7315 BLKCIPHER_3DES_CHAIN_TYPE);
7317 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7319 return TEST_SUCCESS;
7323 test_3DES_cipheronly_openssl_all(void)
7325 struct crypto_testsuite_params *ts_params = &testsuite_params;
7328 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7329 ts_params->op_mpool,
7330 ts_params->session_mpool, ts_params->session_priv_mpool,
7331 ts_params->valid_devs[0],
7332 rte_cryptodev_driver_id_get(
7333 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7334 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7336 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7338 return TEST_SUCCESS;
7341 /* ***** AEAD algorithm Tests ***** */
7344 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7345 enum rte_crypto_aead_operation op,
7346 const uint8_t *key, const uint8_t key_len,
7347 const uint16_t aad_len, const uint8_t auth_len,
7350 uint8_t aead_key[key_len];
7352 struct crypto_testsuite_params *ts_params = &testsuite_params;
7353 struct crypto_unittest_params *ut_params = &unittest_params;
7355 memcpy(aead_key, key, key_len);
7357 /* Setup AEAD Parameters */
7358 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7359 ut_params->aead_xform.next = NULL;
7360 ut_params->aead_xform.aead.algo = algo;
7361 ut_params->aead_xform.aead.op = op;
7362 ut_params->aead_xform.aead.key.data = aead_key;
7363 ut_params->aead_xform.aead.key.length = key_len;
7364 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7365 ut_params->aead_xform.aead.iv.length = iv_len;
7366 ut_params->aead_xform.aead.digest_length = auth_len;
7367 ut_params->aead_xform.aead.aad_length = aad_len;
7369 debug_hexdump(stdout, "key:", key, key_len);
7371 /* Create Crypto session*/
7372 ut_params->sess = rte_cryptodev_sym_session_create(
7373 ts_params->session_mpool);
7375 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7376 &ut_params->aead_xform,
7377 ts_params->session_priv_mpool);
7379 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7385 create_aead_xform(struct rte_crypto_op *op,
7386 enum rte_crypto_aead_algorithm algo,
7387 enum rte_crypto_aead_operation aead_op,
7388 uint8_t *key, const uint8_t key_len,
7389 const uint8_t aad_len, const uint8_t auth_len,
7392 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7393 "failed to allocate space for crypto transform");
7395 struct rte_crypto_sym_op *sym_op = op->sym;
7397 /* Setup AEAD Parameters */
7398 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7399 sym_op->xform->next = NULL;
7400 sym_op->xform->aead.algo = algo;
7401 sym_op->xform->aead.op = aead_op;
7402 sym_op->xform->aead.key.data = key;
7403 sym_op->xform->aead.key.length = key_len;
7404 sym_op->xform->aead.iv.offset = IV_OFFSET;
7405 sym_op->xform->aead.iv.length = iv_len;
7406 sym_op->xform->aead.digest_length = auth_len;
7407 sym_op->xform->aead.aad_length = aad_len;
7409 debug_hexdump(stdout, "key:", key, key_len);
7415 create_aead_operation(enum rte_crypto_aead_operation op,
7416 const struct aead_test_data *tdata)
7418 struct crypto_testsuite_params *ts_params = &testsuite_params;
7419 struct crypto_unittest_params *ut_params = &unittest_params;
7421 uint8_t *plaintext, *ciphertext;
7422 unsigned int aad_pad_len, plaintext_pad_len;
7424 /* Generate Crypto op data structure */
7425 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7426 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7427 TEST_ASSERT_NOT_NULL(ut_params->op,
7428 "Failed to allocate symmetric crypto operation struct");
7430 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7432 /* Append aad data */
7433 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7434 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7435 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7437 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7438 "no room to append aad");
7440 sym_op->aead.aad.phys_addr =
7441 rte_pktmbuf_iova(ut_params->ibuf);
7442 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7443 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7444 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7447 /* Append IV at the end of the crypto operation*/
7448 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7449 uint8_t *, IV_OFFSET);
7451 /* Copy IV 1 byte after the IV pointer, according to the API */
7452 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7453 debug_hexdump(stdout, "iv:", iv_ptr,
7456 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7457 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7459 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7460 "no room to append aad");
7462 sym_op->aead.aad.phys_addr =
7463 rte_pktmbuf_iova(ut_params->ibuf);
7464 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7465 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7468 /* Append IV at the end of the crypto operation*/
7469 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7470 uint8_t *, IV_OFFSET);
7472 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7473 debug_hexdump(stdout, "iv:", iv_ptr,
7477 /* Append plaintext/ciphertext */
7478 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7479 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7480 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7482 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7484 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7485 debug_hexdump(stdout, "plaintext:", plaintext,
7486 tdata->plaintext.len);
7488 if (ut_params->obuf) {
7489 ciphertext = (uint8_t *)rte_pktmbuf_append(
7491 plaintext_pad_len + aad_pad_len);
7492 TEST_ASSERT_NOT_NULL(ciphertext,
7493 "no room to append ciphertext");
7495 memset(ciphertext + aad_pad_len, 0,
7496 tdata->ciphertext.len);
7499 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7500 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7502 TEST_ASSERT_NOT_NULL(ciphertext,
7503 "no room to append ciphertext");
7505 memcpy(ciphertext, tdata->ciphertext.data,
7506 tdata->ciphertext.len);
7507 debug_hexdump(stdout, "ciphertext:", ciphertext,
7508 tdata->ciphertext.len);
7510 if (ut_params->obuf) {
7511 plaintext = (uint8_t *)rte_pktmbuf_append(
7513 plaintext_pad_len + aad_pad_len);
7514 TEST_ASSERT_NOT_NULL(plaintext,
7515 "no room to append plaintext");
7517 memset(plaintext + aad_pad_len, 0,
7518 tdata->plaintext.len);
7522 /* Append digest data */
7523 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7524 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7525 ut_params->obuf ? ut_params->obuf :
7527 tdata->auth_tag.len);
7528 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7529 "no room to append digest");
7530 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7531 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7532 ut_params->obuf ? ut_params->obuf :
7537 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7538 ut_params->ibuf, tdata->auth_tag.len);
7539 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7540 "no room to append digest");
7541 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7543 plaintext_pad_len + aad_pad_len);
7545 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7546 tdata->auth_tag.len);
7547 debug_hexdump(stdout, "digest:",
7548 sym_op->aead.digest.data,
7549 tdata->auth_tag.len);
7552 sym_op->aead.data.length = tdata->plaintext.len;
7553 sym_op->aead.data.offset = aad_pad_len;
7559 test_authenticated_encryption(const struct aead_test_data *tdata)
7561 struct crypto_testsuite_params *ts_params = &testsuite_params;
7562 struct crypto_unittest_params *ut_params = &unittest_params;
7565 uint8_t *ciphertext, *auth_tag;
7566 uint16_t plaintext_pad_len;
7569 /* Create AEAD session */
7570 retval = create_aead_session(ts_params->valid_devs[0],
7572 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7573 tdata->key.data, tdata->key.len,
7574 tdata->aad.len, tdata->auth_tag.len,
7579 if (tdata->aad.len > MBUF_SIZE) {
7580 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7581 /* Populate full size of add data */
7582 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7583 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7585 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7587 /* clear mbuf payload */
7588 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7589 rte_pktmbuf_tailroom(ut_params->ibuf));
7591 /* Create AEAD operation */
7592 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7596 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7598 ut_params->op->sym->m_src = ut_params->ibuf;
7600 /* Process crypto operation */
7601 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7602 ut_params->op), "failed to process sym crypto op");
7604 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7605 "crypto op processing failed");
7607 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7609 if (ut_params->op->sym->m_dst) {
7610 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7612 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7613 uint8_t *, plaintext_pad_len);
7615 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7617 ut_params->op->sym->cipher.data.offset);
7618 auth_tag = ciphertext + plaintext_pad_len;
7621 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7622 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7625 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7627 tdata->ciphertext.data,
7628 tdata->ciphertext.len,
7629 "Ciphertext data not as expected");
7631 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7633 tdata->auth_tag.data,
7634 tdata->auth_tag.len,
7635 "Generated auth tag not as expected");
7641 #ifdef RTE_LIBRTE_SECURITY
7642 /* Basic algorithm run function for async inplace mode.
7643 * Creates a session from input parameters and runs one operation
7644 * on input_vec. Checks the output of the crypto operation against
7648 test_pdcp_proto(int i, int oop,
7649 enum rte_crypto_cipher_operation opc,
7650 enum rte_crypto_auth_operation opa,
7652 unsigned int input_vec_len,
7653 uint8_t *output_vec,
7654 unsigned int output_vec_len)
7656 struct crypto_testsuite_params *ts_params = &testsuite_params;
7657 struct crypto_unittest_params *ut_params = &unittest_params;
7659 int ret = TEST_SUCCESS;
7661 /* Generate test mbuf data */
7662 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7664 /* clear mbuf payload */
7665 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7666 rte_pktmbuf_tailroom(ut_params->ibuf));
7668 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7670 memcpy(plaintext, input_vec, input_vec_len);
7672 /* Out of place support */
7675 * For out-op-place we need to alloc another mbuf
7677 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7678 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7681 /* Set crypto type as IPSEC */
7682 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7684 /* Setup Cipher Parameters */
7685 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7686 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7687 ut_params->cipher_xform.cipher.op = opc;
7688 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7689 ut_params->cipher_xform.cipher.key.length =
7690 pdcp_test_params[i].cipher_key_len;
7691 ut_params->cipher_xform.cipher.iv.length = 0;
7693 /* Setup HMAC Parameters if ICV header is required */
7694 if (pdcp_test_params[i].auth_alg != 0) {
7695 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7696 ut_params->auth_xform.next = NULL;
7697 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7698 ut_params->auth_xform.auth.op = opa;
7699 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7700 ut_params->auth_xform.auth.key.length =
7701 pdcp_test_params[i].auth_key_len;
7703 ut_params->cipher_xform.next = &ut_params->auth_xform;
7705 ut_params->cipher_xform.next = NULL;
7708 struct rte_security_session_conf sess_conf = {
7709 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7710 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7712 .bearer = pdcp_test_bearer[i],
7713 .domain = pdcp_test_params[i].domain,
7714 .pkt_dir = pdcp_test_packet_direction[i],
7715 .sn_size = pdcp_test_data_sn_size[i],
7716 .hfn = pdcp_test_hfn[i],
7717 .hfn_threshold = pdcp_test_hfn_threshold[i],
7719 .crypto_xform = &ut_params->cipher_xform
7722 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7723 rte_cryptodev_get_sec_ctx(
7724 ts_params->valid_devs[0]);
7726 /* Create security session */
7727 ut_params->sec_session = rte_security_session_create(ctx,
7728 &sess_conf, ts_params->session_priv_mpool);
7730 if (!ut_params->sec_session) {
7731 printf("TestCase %s()-%d line %d failed %s: ",
7732 __func__, i, __LINE__, "Failed to allocate session");
7737 /* Generate crypto op data structure */
7738 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7739 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7740 if (!ut_params->op) {
7741 printf("TestCase %s()-%d line %d failed %s: ",
7742 __func__, i, __LINE__,
7743 "Failed to allocate symmetric crypto operation struct");
7748 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7750 /* set crypto operation source mbuf */
7751 ut_params->op->sym->m_src = ut_params->ibuf;
7753 ut_params->op->sym->m_dst = ut_params->obuf;
7755 /* Process crypto operation */
7756 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
7758 printf("TestCase %s()-%d line %d failed %s: ",
7759 __func__, i, __LINE__,
7760 "failed to process sym crypto op");
7765 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
7766 printf("TestCase %s()-%d line %d failed %s: ",
7767 __func__, i, __LINE__, "crypto op processing failed");
7773 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
7776 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7780 if (memcmp(ciphertext, output_vec, output_vec_len)) {
7781 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
7782 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
7783 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
7789 rte_crypto_op_free(ut_params->op);
7790 ut_params->op = NULL;
7792 if (ut_params->sec_session)
7793 rte_security_session_destroy(ctx, ut_params->sec_session);
7794 ut_params->sec_session = NULL;
7796 rte_pktmbuf_free(ut_params->ibuf);
7797 ut_params->ibuf = NULL;
7799 rte_pktmbuf_free(ut_params->obuf);
7800 ut_params->obuf = NULL;
7807 test_pdcp_proto_SGL(int i, int oop,
7808 enum rte_crypto_cipher_operation opc,
7809 enum rte_crypto_auth_operation opa,
7811 unsigned int input_vec_len,
7812 uint8_t *output_vec,
7813 unsigned int output_vec_len,
7815 uint32_t fragsz_oop)
7817 struct crypto_testsuite_params *ts_params = &testsuite_params;
7818 struct crypto_unittest_params *ut_params = &unittest_params;
7820 struct rte_mbuf *buf, *buf_oop = NULL;
7821 int ret = TEST_SUCCESS;
7825 unsigned int trn_data = 0;
7827 if (fragsz > input_vec_len)
7828 fragsz = input_vec_len;
7830 uint16_t plaintext_len = fragsz;
7831 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
7833 if (fragsz_oop > output_vec_len)
7834 frag_size_oop = output_vec_len;
7837 if (input_vec_len % fragsz != 0) {
7838 if (input_vec_len / fragsz + 1 > 16)
7840 } else if (input_vec_len / fragsz > 16)
7843 /* Out of place support */
7846 * For out-op-place we need to alloc another mbuf
7848 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7849 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
7850 buf_oop = ut_params->obuf;
7853 /* Generate test mbuf data */
7854 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7856 /* clear mbuf payload */
7857 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7858 rte_pktmbuf_tailroom(ut_params->ibuf));
7860 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7862 memcpy(plaintext, input_vec, plaintext_len);
7863 trn_data += plaintext_len;
7865 buf = ut_params->ibuf;
7868 * Loop until no more fragments
7871 while (trn_data < input_vec_len) {
7873 to_trn = (input_vec_len - trn_data < fragsz) ?
7874 (input_vec_len - trn_data) : fragsz;
7876 to_trn_tbl[ecx++] = to_trn;
7878 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7881 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
7882 rte_pktmbuf_tailroom(buf));
7885 if (oop && !fragsz_oop) {
7887 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7888 buf_oop = buf_oop->next;
7889 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7890 0, rte_pktmbuf_tailroom(buf_oop));
7891 rte_pktmbuf_append(buf_oop, to_trn);
7894 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
7897 memcpy(plaintext, input_vec + trn_data, to_trn);
7901 ut_params->ibuf->nb_segs = segs;
7904 if (fragsz_oop && oop) {
7908 trn_data = frag_size_oop;
7909 while (trn_data < output_vec_len) {
7912 (output_vec_len - trn_data <
7914 (output_vec_len - trn_data) :
7917 to_trn_tbl[ecx++] = to_trn;
7920 rte_pktmbuf_alloc(ts_params->mbuf_pool);
7921 buf_oop = buf_oop->next;
7922 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
7923 0, rte_pktmbuf_tailroom(buf_oop));
7924 rte_pktmbuf_append(buf_oop, to_trn);
7928 ut_params->obuf->nb_segs = segs;
7931 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7933 /* Setup Cipher Parameters */
7934 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7935 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7936 ut_params->cipher_xform.cipher.op = opc;
7937 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7938 ut_params->cipher_xform.cipher.key.length =
7939 pdcp_test_params[i].cipher_key_len;
7940 ut_params->cipher_xform.cipher.iv.length = 0;
7942 /* Setup HMAC Parameters if ICV header is required */
7943 if (pdcp_test_params[i].auth_alg != 0) {
7944 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7945 ut_params->auth_xform.next = NULL;
7946 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7947 ut_params->auth_xform.auth.op = opa;
7948 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7949 ut_params->auth_xform.auth.key.length =
7950 pdcp_test_params[i].auth_key_len;
7952 ut_params->cipher_xform.next = &ut_params->auth_xform;
7954 ut_params->cipher_xform.next = NULL;
7957 struct rte_security_session_conf sess_conf = {
7958 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7959 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7961 .bearer = pdcp_test_bearer[i],
7962 .domain = pdcp_test_params[i].domain,
7963 .pkt_dir = pdcp_test_packet_direction[i],
7964 .sn_size = pdcp_test_data_sn_size[i],
7965 .hfn = pdcp_test_hfn[i],
7966 .hfn_threshold = pdcp_test_hfn_threshold[i],
7968 .crypto_xform = &ut_params->cipher_xform
7971 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7972 rte_cryptodev_get_sec_ctx(
7973 ts_params->valid_devs[0]);
7975 /* Create security session */
7976 ut_params->sec_session = rte_security_session_create(ctx,
7977 &sess_conf, ts_params->session_priv_mpool);
7979 if (!ut_params->sec_session) {
7980 printf("TestCase %s()-%d line %d failed %s: ",
7981 __func__, i, __LINE__, "Failed to allocate session");
7986 /* Generate crypto op data structure */
7987 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7988 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7989 if (!ut_params->op) {
7990 printf("TestCase %s()-%d line %d failed %s: ",
7991 __func__, i, __LINE__,
7992 "Failed to allocate symmetric crypto operation struct");
7997 rte_security_attach_session(ut_params->op, ut_params->sec_session);
7999 /* set crypto operation source mbuf */
8000 ut_params->op->sym->m_src = ut_params->ibuf;
8002 ut_params->op->sym->m_dst = ut_params->obuf;
8004 /* Process crypto operation */
8005 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8007 printf("TestCase %s()-%d line %d failed %s: ",
8008 __func__, i, __LINE__,
8009 "failed to process sym crypto op");
8014 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8015 printf("TestCase %s()-%d line %d failed %s: ",
8016 __func__, i, __LINE__, "crypto op processing failed");
8022 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8025 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8029 fragsz = frag_size_oop;
8030 if (memcmp(ciphertext, output_vec, fragsz)) {
8031 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8032 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8033 rte_hexdump(stdout, "reference", output_vec, fragsz);
8038 buf = ut_params->op->sym->m_src->next;
8040 buf = ut_params->op->sym->m_dst->next;
8042 unsigned int off = fragsz;
8046 ciphertext = rte_pktmbuf_mtod(buf,
8048 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8049 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8050 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8051 rte_hexdump(stdout, "reference", output_vec + off,
8056 off += to_trn_tbl[ecx++];
8060 rte_crypto_op_free(ut_params->op);
8061 ut_params->op = NULL;
8063 if (ut_params->sec_session)
8064 rte_security_session_destroy(ctx, ut_params->sec_session);
8065 ut_params->sec_session = NULL;
8067 rte_pktmbuf_free(ut_params->ibuf);
8068 ut_params->ibuf = NULL;
8070 rte_pktmbuf_free(ut_params->obuf);
8071 ut_params->obuf = NULL;
8078 test_pdcp_proto_cplane_encap(int i)
8080 return test_pdcp_proto(i, 0,
8081 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8082 RTE_CRYPTO_AUTH_OP_GENERATE,
8083 pdcp_test_data_in[i],
8084 pdcp_test_data_in_len[i],
8085 pdcp_test_data_out[i],
8086 pdcp_test_data_in_len[i]+4);
8090 test_pdcp_proto_uplane_encap(int i)
8092 return test_pdcp_proto(i, 0,
8093 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8094 RTE_CRYPTO_AUTH_OP_GENERATE,
8095 pdcp_test_data_in[i],
8096 pdcp_test_data_in_len[i],
8097 pdcp_test_data_out[i],
8098 pdcp_test_data_in_len[i]);
8103 test_pdcp_proto_uplane_encap_with_int(int i)
8105 return test_pdcp_proto(i, 0,
8106 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8107 RTE_CRYPTO_AUTH_OP_GENERATE,
8108 pdcp_test_data_in[i],
8109 pdcp_test_data_in_len[i],
8110 pdcp_test_data_out[i],
8111 pdcp_test_data_in_len[i] + 4);
8115 test_pdcp_proto_cplane_decap(int i)
8117 return test_pdcp_proto(i, 0,
8118 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8119 RTE_CRYPTO_AUTH_OP_VERIFY,
8120 pdcp_test_data_out[i],
8121 pdcp_test_data_in_len[i] + 4,
8122 pdcp_test_data_in[i],
8123 pdcp_test_data_in_len[i]);
8127 test_pdcp_proto_uplane_decap(int i)
8129 return test_pdcp_proto(i, 0,
8130 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8131 RTE_CRYPTO_AUTH_OP_VERIFY,
8132 pdcp_test_data_out[i],
8133 pdcp_test_data_in_len[i],
8134 pdcp_test_data_in[i],
8135 pdcp_test_data_in_len[i]);
8139 test_pdcp_proto_uplane_decap_with_int(int i)
8141 return test_pdcp_proto(i, 0,
8142 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8143 RTE_CRYPTO_AUTH_OP_VERIFY,
8144 pdcp_test_data_out[i],
8145 pdcp_test_data_in_len[i] + 4,
8146 pdcp_test_data_in[i],
8147 pdcp_test_data_in_len[i]);
8151 test_PDCP_PROTO_SGL_in_place_32B(void)
8153 /* i can be used for running any PDCP case
8154 * In this case it is uplane 12-bit AES-SNOW DL encap
8156 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8157 return test_pdcp_proto_SGL(i, IN_PLACE,
8158 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8159 RTE_CRYPTO_AUTH_OP_GENERATE,
8160 pdcp_test_data_in[i],
8161 pdcp_test_data_in_len[i],
8162 pdcp_test_data_out[i],
8163 pdcp_test_data_in_len[i]+4,
8167 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8169 /* i can be used for running any PDCP case
8170 * In this case it is uplane 18-bit NULL-NULL DL encap
8172 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8173 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8174 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8175 RTE_CRYPTO_AUTH_OP_GENERATE,
8176 pdcp_test_data_in[i],
8177 pdcp_test_data_in_len[i],
8178 pdcp_test_data_out[i],
8179 pdcp_test_data_in_len[i]+4,
8183 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8185 /* i can be used for running any PDCP case
8186 * In this case it is uplane 18-bit AES DL encap
8188 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8190 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8191 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8192 RTE_CRYPTO_AUTH_OP_GENERATE,
8193 pdcp_test_data_in[i],
8194 pdcp_test_data_in_len[i],
8195 pdcp_test_data_out[i],
8196 pdcp_test_data_in_len[i],
8200 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8202 /* i can be used for running any PDCP case
8203 * In this case it is cplane 12-bit AES-ZUC DL encap
8205 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8206 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8207 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8208 RTE_CRYPTO_AUTH_OP_GENERATE,
8209 pdcp_test_data_in[i],
8210 pdcp_test_data_in_len[i],
8211 pdcp_test_data_out[i],
8212 pdcp_test_data_in_len[i]+4,
8218 test_AES_GCM_authenticated_encryption_test_case_1(void)
8220 return test_authenticated_encryption(&gcm_test_case_1);
8224 test_AES_GCM_authenticated_encryption_test_case_2(void)
8226 return test_authenticated_encryption(&gcm_test_case_2);
8230 test_AES_GCM_authenticated_encryption_test_case_3(void)
8232 return test_authenticated_encryption(&gcm_test_case_3);
8236 test_AES_GCM_authenticated_encryption_test_case_4(void)
8238 return test_authenticated_encryption(&gcm_test_case_4);
8242 test_AES_GCM_authenticated_encryption_test_case_5(void)
8244 return test_authenticated_encryption(&gcm_test_case_5);
8248 test_AES_GCM_authenticated_encryption_test_case_6(void)
8250 return test_authenticated_encryption(&gcm_test_case_6);
8254 test_AES_GCM_authenticated_encryption_test_case_7(void)
8256 return test_authenticated_encryption(&gcm_test_case_7);
8260 test_AES_GCM_authenticated_encryption_test_case_8(void)
8262 return test_authenticated_encryption(&gcm_test_case_8);
8266 test_AES_GCM_auth_encryption_test_case_192_1(void)
8268 return test_authenticated_encryption(&gcm_test_case_192_1);
8272 test_AES_GCM_auth_encryption_test_case_192_2(void)
8274 return test_authenticated_encryption(&gcm_test_case_192_2);
8278 test_AES_GCM_auth_encryption_test_case_192_3(void)
8280 return test_authenticated_encryption(&gcm_test_case_192_3);
8284 test_AES_GCM_auth_encryption_test_case_192_4(void)
8286 return test_authenticated_encryption(&gcm_test_case_192_4);
8290 test_AES_GCM_auth_encryption_test_case_192_5(void)
8292 return test_authenticated_encryption(&gcm_test_case_192_5);
8296 test_AES_GCM_auth_encryption_test_case_192_6(void)
8298 return test_authenticated_encryption(&gcm_test_case_192_6);
8302 test_AES_GCM_auth_encryption_test_case_192_7(void)
8304 return test_authenticated_encryption(&gcm_test_case_192_7);
8308 test_AES_GCM_auth_encryption_test_case_256_1(void)
8310 return test_authenticated_encryption(&gcm_test_case_256_1);
8314 test_AES_GCM_auth_encryption_test_case_256_2(void)
8316 return test_authenticated_encryption(&gcm_test_case_256_2);
8320 test_AES_GCM_auth_encryption_test_case_256_3(void)
8322 return test_authenticated_encryption(&gcm_test_case_256_3);
8326 test_AES_GCM_auth_encryption_test_case_256_4(void)
8328 return test_authenticated_encryption(&gcm_test_case_256_4);
8332 test_AES_GCM_auth_encryption_test_case_256_5(void)
8334 return test_authenticated_encryption(&gcm_test_case_256_5);
8338 test_AES_GCM_auth_encryption_test_case_256_6(void)
8340 return test_authenticated_encryption(&gcm_test_case_256_6);
8344 test_AES_GCM_auth_encryption_test_case_256_7(void)
8346 return test_authenticated_encryption(&gcm_test_case_256_7);
8350 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8352 return test_authenticated_encryption(&gcm_test_case_aad_1);
8356 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8358 return test_authenticated_encryption(&gcm_test_case_aad_2);
8362 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8364 struct aead_test_data tdata;
8367 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8368 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8369 tdata.iv.data[0] += 1;
8370 res = test_authenticated_encryption(&tdata);
8371 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8372 return TEST_SUCCESS;
8376 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8378 struct aead_test_data tdata;
8381 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8382 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8383 tdata.plaintext.data[0] += 1;
8384 res = test_authenticated_encryption(&tdata);
8385 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8386 return TEST_SUCCESS;
8390 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8392 struct aead_test_data tdata;
8395 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8396 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8397 tdata.ciphertext.data[0] += 1;
8398 res = test_authenticated_encryption(&tdata);
8399 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8400 return TEST_SUCCESS;
8404 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8406 struct aead_test_data tdata;
8409 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8410 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8412 res = test_authenticated_encryption(&tdata);
8413 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8414 return TEST_SUCCESS;
8418 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8420 struct aead_test_data tdata;
8421 uint8_t aad[gcm_test_case_7.aad.len];
8424 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8425 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8426 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8428 tdata.aad.data = aad;
8429 res = test_authenticated_encryption(&tdata);
8430 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8431 return TEST_SUCCESS;
8435 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8437 struct aead_test_data tdata;
8440 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8441 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8442 tdata.auth_tag.data[0] += 1;
8443 res = test_authenticated_encryption(&tdata);
8444 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8445 return TEST_SUCCESS;
8449 test_authenticated_decryption(const struct aead_test_data *tdata)
8451 struct crypto_testsuite_params *ts_params = &testsuite_params;
8452 struct crypto_unittest_params *ut_params = &unittest_params;
8458 /* Create AEAD session */
8459 retval = create_aead_session(ts_params->valid_devs[0],
8461 RTE_CRYPTO_AEAD_OP_DECRYPT,
8462 tdata->key.data, tdata->key.len,
8463 tdata->aad.len, tdata->auth_tag.len,
8468 /* alloc mbuf and set payload */
8469 if (tdata->aad.len > MBUF_SIZE) {
8470 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8471 /* Populate full size of add data */
8472 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8473 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8475 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8477 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8478 rte_pktmbuf_tailroom(ut_params->ibuf));
8480 /* Create AEAD operation */
8481 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8485 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8487 ut_params->op->sym->m_src = ut_params->ibuf;
8489 /* Process crypto operation */
8490 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8491 ut_params->op), "failed to process sym crypto op");
8493 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8494 "crypto op processing failed");
8496 if (ut_params->op->sym->m_dst)
8497 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8500 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8502 ut_params->op->sym->cipher.data.offset);
8504 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8507 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8509 tdata->plaintext.data,
8510 tdata->plaintext.len,
8511 "Plaintext data not as expected");
8513 TEST_ASSERT_EQUAL(ut_params->op->status,
8514 RTE_CRYPTO_OP_STATUS_SUCCESS,
8515 "Authentication failed");
8521 test_AES_GCM_authenticated_decryption_test_case_1(void)
8523 return test_authenticated_decryption(&gcm_test_case_1);
8527 test_AES_GCM_authenticated_decryption_test_case_2(void)
8529 return test_authenticated_decryption(&gcm_test_case_2);
8533 test_AES_GCM_authenticated_decryption_test_case_3(void)
8535 return test_authenticated_decryption(&gcm_test_case_3);
8539 test_AES_GCM_authenticated_decryption_test_case_4(void)
8541 return test_authenticated_decryption(&gcm_test_case_4);
8545 test_AES_GCM_authenticated_decryption_test_case_5(void)
8547 return test_authenticated_decryption(&gcm_test_case_5);
8551 test_AES_GCM_authenticated_decryption_test_case_6(void)
8553 return test_authenticated_decryption(&gcm_test_case_6);
8557 test_AES_GCM_authenticated_decryption_test_case_7(void)
8559 return test_authenticated_decryption(&gcm_test_case_7);
8563 test_AES_GCM_authenticated_decryption_test_case_8(void)
8565 return test_authenticated_decryption(&gcm_test_case_8);
8569 test_AES_GCM_auth_decryption_test_case_192_1(void)
8571 return test_authenticated_decryption(&gcm_test_case_192_1);
8575 test_AES_GCM_auth_decryption_test_case_192_2(void)
8577 return test_authenticated_decryption(&gcm_test_case_192_2);
8581 test_AES_GCM_auth_decryption_test_case_192_3(void)
8583 return test_authenticated_decryption(&gcm_test_case_192_3);
8587 test_AES_GCM_auth_decryption_test_case_192_4(void)
8589 return test_authenticated_decryption(&gcm_test_case_192_4);
8593 test_AES_GCM_auth_decryption_test_case_192_5(void)
8595 return test_authenticated_decryption(&gcm_test_case_192_5);
8599 test_AES_GCM_auth_decryption_test_case_192_6(void)
8601 return test_authenticated_decryption(&gcm_test_case_192_6);
8605 test_AES_GCM_auth_decryption_test_case_192_7(void)
8607 return test_authenticated_decryption(&gcm_test_case_192_7);
8611 test_AES_GCM_auth_decryption_test_case_256_1(void)
8613 return test_authenticated_decryption(&gcm_test_case_256_1);
8617 test_AES_GCM_auth_decryption_test_case_256_2(void)
8619 return test_authenticated_decryption(&gcm_test_case_256_2);
8623 test_AES_GCM_auth_decryption_test_case_256_3(void)
8625 return test_authenticated_decryption(&gcm_test_case_256_3);
8629 test_AES_GCM_auth_decryption_test_case_256_4(void)
8631 return test_authenticated_decryption(&gcm_test_case_256_4);
8635 test_AES_GCM_auth_decryption_test_case_256_5(void)
8637 return test_authenticated_decryption(&gcm_test_case_256_5);
8641 test_AES_GCM_auth_decryption_test_case_256_6(void)
8643 return test_authenticated_decryption(&gcm_test_case_256_6);
8647 test_AES_GCM_auth_decryption_test_case_256_7(void)
8649 return test_authenticated_decryption(&gcm_test_case_256_7);
8653 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8655 return test_authenticated_decryption(&gcm_test_case_aad_1);
8659 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8661 return test_authenticated_decryption(&gcm_test_case_aad_2);
8665 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8667 struct aead_test_data tdata;
8670 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8671 tdata.iv.data[0] += 1;
8672 res = test_authenticated_decryption(&tdata);
8673 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8674 return TEST_SUCCESS;
8678 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8680 struct aead_test_data tdata;
8683 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8684 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8685 tdata.plaintext.data[0] += 1;
8686 res = test_authenticated_decryption(&tdata);
8687 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8688 return TEST_SUCCESS;
8692 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8694 struct aead_test_data tdata;
8697 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8698 tdata.ciphertext.data[0] += 1;
8699 res = test_authenticated_decryption(&tdata);
8700 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8701 return TEST_SUCCESS;
8705 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8707 struct aead_test_data tdata;
8710 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8712 res = test_authenticated_decryption(&tdata);
8713 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8714 return TEST_SUCCESS;
8718 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
8720 struct aead_test_data tdata;
8721 uint8_t aad[gcm_test_case_7.aad.len];
8724 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8725 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8727 tdata.aad.data = aad;
8728 res = test_authenticated_decryption(&tdata);
8729 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8730 return TEST_SUCCESS;
8734 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
8736 struct aead_test_data tdata;
8739 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8740 tdata.auth_tag.data[0] += 1;
8741 res = test_authenticated_decryption(&tdata);
8742 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
8743 return TEST_SUCCESS;
8747 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
8749 struct crypto_testsuite_params *ts_params = &testsuite_params;
8750 struct crypto_unittest_params *ut_params = &unittest_params;
8753 uint8_t *ciphertext, *auth_tag;
8754 uint16_t plaintext_pad_len;
8756 /* Create AEAD session */
8757 retval = create_aead_session(ts_params->valid_devs[0],
8759 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8760 tdata->key.data, tdata->key.len,
8761 tdata->aad.len, tdata->auth_tag.len,
8766 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8767 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8769 /* clear mbuf payload */
8770 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8771 rte_pktmbuf_tailroom(ut_params->ibuf));
8772 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8773 rte_pktmbuf_tailroom(ut_params->obuf));
8775 /* Create AEAD operation */
8776 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8780 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8782 ut_params->op->sym->m_src = ut_params->ibuf;
8783 ut_params->op->sym->m_dst = ut_params->obuf;
8785 /* Process crypto operation */
8786 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8787 ut_params->op), "failed to process sym crypto op");
8789 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8790 "crypto op processing failed");
8792 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8794 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8795 ut_params->op->sym->cipher.data.offset);
8796 auth_tag = ciphertext + plaintext_pad_len;
8798 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8799 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8802 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8804 tdata->ciphertext.data,
8805 tdata->ciphertext.len,
8806 "Ciphertext data not as expected");
8808 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8810 tdata->auth_tag.data,
8811 tdata->auth_tag.len,
8812 "Generated auth tag not as expected");
8819 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
8821 return test_authenticated_encryption_oop(&gcm_test_case_5);
8825 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
8827 struct crypto_testsuite_params *ts_params = &testsuite_params;
8828 struct crypto_unittest_params *ut_params = &unittest_params;
8833 /* Create AEAD session */
8834 retval = create_aead_session(ts_params->valid_devs[0],
8836 RTE_CRYPTO_AEAD_OP_DECRYPT,
8837 tdata->key.data, tdata->key.len,
8838 tdata->aad.len, tdata->auth_tag.len,
8843 /* alloc mbuf and set payload */
8844 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8845 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8847 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8848 rte_pktmbuf_tailroom(ut_params->ibuf));
8849 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
8850 rte_pktmbuf_tailroom(ut_params->obuf));
8852 /* Create AEAD operation */
8853 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8857 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8859 ut_params->op->sym->m_src = ut_params->ibuf;
8860 ut_params->op->sym->m_dst = ut_params->obuf;
8862 /* Process crypto operation */
8863 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8864 ut_params->op), "failed to process sym crypto op");
8866 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8867 "crypto op processing failed");
8869 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
8870 ut_params->op->sym->cipher.data.offset);
8872 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8875 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8877 tdata->plaintext.data,
8878 tdata->plaintext.len,
8879 "Plaintext data not as expected");
8881 TEST_ASSERT_EQUAL(ut_params->op->status,
8882 RTE_CRYPTO_OP_STATUS_SUCCESS,
8883 "Authentication failed");
8888 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
8890 return test_authenticated_decryption_oop(&gcm_test_case_5);
8894 test_authenticated_encryption_sessionless(
8895 const struct aead_test_data *tdata)
8897 struct crypto_testsuite_params *ts_params = &testsuite_params;
8898 struct crypto_unittest_params *ut_params = &unittest_params;
8901 uint8_t *ciphertext, *auth_tag;
8902 uint16_t plaintext_pad_len;
8903 uint8_t key[tdata->key.len + 1];
8905 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8907 /* clear mbuf payload */
8908 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8909 rte_pktmbuf_tailroom(ut_params->ibuf));
8911 /* Create AEAD operation */
8912 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
8916 /* Create GCM xform */
8917 memcpy(key, tdata->key.data, tdata->key.len);
8918 retval = create_aead_xform(ut_params->op,
8920 RTE_CRYPTO_AEAD_OP_ENCRYPT,
8921 key, tdata->key.len,
8922 tdata->aad.len, tdata->auth_tag.len,
8927 ut_params->op->sym->m_src = ut_params->ibuf;
8929 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
8930 RTE_CRYPTO_OP_SESSIONLESS,
8931 "crypto op session type not sessionless");
8933 /* Process crypto operation */
8934 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8935 ut_params->op), "failed to process sym crypto op");
8937 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
8939 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8940 "crypto op status not success");
8942 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
8944 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
8945 ut_params->op->sym->cipher.data.offset);
8946 auth_tag = ciphertext + plaintext_pad_len;
8948 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
8949 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
8952 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8954 tdata->ciphertext.data,
8955 tdata->ciphertext.len,
8956 "Ciphertext data not as expected");
8958 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8960 tdata->auth_tag.data,
8961 tdata->auth_tag.len,
8962 "Generated auth tag not as expected");
8969 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
8971 return test_authenticated_encryption_sessionless(
8976 test_authenticated_decryption_sessionless(
8977 const struct aead_test_data *tdata)
8979 struct crypto_testsuite_params *ts_params = &testsuite_params;
8980 struct crypto_unittest_params *ut_params = &unittest_params;
8984 uint8_t key[tdata->key.len + 1];
8986 /* alloc mbuf and set payload */
8987 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8989 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8990 rte_pktmbuf_tailroom(ut_params->ibuf));
8992 /* Create AEAD operation */
8993 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8997 /* Create AEAD xform */
8998 memcpy(key, tdata->key.data, tdata->key.len);
8999 retval = create_aead_xform(ut_params->op,
9001 RTE_CRYPTO_AEAD_OP_DECRYPT,
9002 key, tdata->key.len,
9003 tdata->aad.len, tdata->auth_tag.len,
9008 ut_params->op->sym->m_src = ut_params->ibuf;
9010 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9011 RTE_CRYPTO_OP_SESSIONLESS,
9012 "crypto op session type not sessionless");
9014 /* Process crypto operation */
9015 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9016 ut_params->op), "failed to process sym crypto op");
9018 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9020 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9021 "crypto op status not success");
9023 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9024 ut_params->op->sym->cipher.data.offset);
9026 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9029 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9031 tdata->plaintext.data,
9032 tdata->plaintext.len,
9033 "Plaintext data not as expected");
9035 TEST_ASSERT_EQUAL(ut_params->op->status,
9036 RTE_CRYPTO_OP_STATUS_SUCCESS,
9037 "Authentication failed");
9042 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9044 return test_authenticated_decryption_sessionless(
9049 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9051 return test_authenticated_encryption(&ccm_test_case_128_1);
9055 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9057 return test_authenticated_encryption(&ccm_test_case_128_2);
9061 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9063 return test_authenticated_encryption(&ccm_test_case_128_3);
9067 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9069 return test_authenticated_decryption(&ccm_test_case_128_1);
9073 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9075 return test_authenticated_decryption(&ccm_test_case_128_2);
9079 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9081 return test_authenticated_decryption(&ccm_test_case_128_3);
9085 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9087 return test_authenticated_encryption(&ccm_test_case_192_1);
9091 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9093 return test_authenticated_encryption(&ccm_test_case_192_2);
9097 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9099 return test_authenticated_encryption(&ccm_test_case_192_3);
9103 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9105 return test_authenticated_decryption(&ccm_test_case_192_1);
9109 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9111 return test_authenticated_decryption(&ccm_test_case_192_2);
9115 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9117 return test_authenticated_decryption(&ccm_test_case_192_3);
9121 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9123 return test_authenticated_encryption(&ccm_test_case_256_1);
9127 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9129 return test_authenticated_encryption(&ccm_test_case_256_2);
9133 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9135 return test_authenticated_encryption(&ccm_test_case_256_3);
9139 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9141 return test_authenticated_decryption(&ccm_test_case_256_1);
9145 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9147 return test_authenticated_decryption(&ccm_test_case_256_2);
9151 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9153 return test_authenticated_decryption(&ccm_test_case_256_3);
9159 struct crypto_testsuite_params *ts_params = &testsuite_params;
9160 struct rte_cryptodev_stats stats;
9161 struct rte_cryptodev *dev;
9162 cryptodev_stats_get_t temp_pfn;
9164 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9165 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9166 &stats) == -ENODEV),
9167 "rte_cryptodev_stats_get invalid dev failed");
9168 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9169 "rte_cryptodev_stats_get invalid Param failed");
9170 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9171 temp_pfn = dev->dev_ops->stats_get;
9172 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9173 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9175 "rte_cryptodev_stats_get invalid Param failed");
9176 dev->dev_ops->stats_get = temp_pfn;
9178 /* Test expected values */
9180 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9182 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9184 "rte_cryptodev_stats_get failed");
9185 TEST_ASSERT((stats.enqueued_count == 1),
9186 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9187 TEST_ASSERT((stats.dequeued_count == 1),
9188 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9189 TEST_ASSERT((stats.enqueue_err_count == 0),
9190 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9191 TEST_ASSERT((stats.dequeue_err_count == 0),
9192 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9194 /* invalid device but should ignore and not reset device stats*/
9195 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9196 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9198 "rte_cryptodev_stats_get failed");
9199 TEST_ASSERT((stats.enqueued_count == 1),
9200 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9202 /* check that a valid reset clears stats */
9203 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9204 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9206 "rte_cryptodev_stats_get failed");
9207 TEST_ASSERT((stats.enqueued_count == 0),
9208 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9209 TEST_ASSERT((stats.dequeued_count == 0),
9210 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9212 return TEST_SUCCESS;
9215 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9216 struct crypto_unittest_params *ut_params,
9217 enum rte_crypto_auth_operation op,
9218 const struct HMAC_MD5_vector *test_case)
9222 memcpy(key, test_case->key.data, test_case->key.len);
9224 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9225 ut_params->auth_xform.next = NULL;
9226 ut_params->auth_xform.auth.op = op;
9228 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9230 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9231 ut_params->auth_xform.auth.key.length = test_case->key.len;
9232 ut_params->auth_xform.auth.key.data = key;
9234 ut_params->sess = rte_cryptodev_sym_session_create(
9235 ts_params->session_mpool);
9237 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9238 ut_params->sess, &ut_params->auth_xform,
9239 ts_params->session_priv_mpool);
9241 if (ut_params->sess == NULL)
9244 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9246 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9247 rte_pktmbuf_tailroom(ut_params->ibuf));
9252 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9253 const struct HMAC_MD5_vector *test_case,
9254 uint8_t **plaintext)
9256 uint16_t plaintext_pad_len;
9258 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9260 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9263 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9265 memcpy(*plaintext, test_case->plaintext.data,
9266 test_case->plaintext.len);
9268 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9269 ut_params->ibuf, MD5_DIGEST_LEN);
9270 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9271 "no room to append digest");
9272 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9273 ut_params->ibuf, plaintext_pad_len);
9275 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9276 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9277 test_case->auth_tag.len);
9280 sym_op->auth.data.offset = 0;
9281 sym_op->auth.data.length = test_case->plaintext.len;
9283 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9284 ut_params->op->sym->m_src = ut_params->ibuf;
9290 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9292 uint16_t plaintext_pad_len;
9293 uint8_t *plaintext, *auth_tag;
9295 struct crypto_testsuite_params *ts_params = &testsuite_params;
9296 struct crypto_unittest_params *ut_params = &unittest_params;
9298 if (MD5_HMAC_create_session(ts_params, ut_params,
9299 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9302 /* Generate Crypto op data structure */
9303 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9304 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9305 TEST_ASSERT_NOT_NULL(ut_params->op,
9306 "Failed to allocate symmetric crypto operation struct");
9308 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9311 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9314 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9315 ut_params->op), "failed to process sym crypto op");
9317 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9318 "crypto op processing failed");
9320 if (ut_params->op->sym->m_dst) {
9321 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9322 uint8_t *, plaintext_pad_len);
9324 auth_tag = plaintext + plaintext_pad_len;
9327 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9329 test_case->auth_tag.data,
9330 test_case->auth_tag.len,
9331 "HMAC_MD5 generated tag not as expected");
9333 return TEST_SUCCESS;
9337 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9341 struct crypto_testsuite_params *ts_params = &testsuite_params;
9342 struct crypto_unittest_params *ut_params = &unittest_params;
9344 if (MD5_HMAC_create_session(ts_params, ut_params,
9345 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9349 /* Generate Crypto op data structure */
9350 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9351 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9352 TEST_ASSERT_NOT_NULL(ut_params->op,
9353 "Failed to allocate symmetric crypto operation struct");
9355 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9358 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9359 ut_params->op), "failed to process sym crypto op");
9361 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9362 "HMAC_MD5 crypto op processing failed");
9364 return TEST_SUCCESS;
9368 test_MD5_HMAC_generate_case_1(void)
9370 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9374 test_MD5_HMAC_verify_case_1(void)
9376 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9380 test_MD5_HMAC_generate_case_2(void)
9382 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9386 test_MD5_HMAC_verify_case_2(void)
9388 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9392 test_multi_session(void)
9394 struct crypto_testsuite_params *ts_params = &testsuite_params;
9395 struct crypto_unittest_params *ut_params = &unittest_params;
9397 struct rte_cryptodev_info dev_info;
9398 struct rte_cryptodev_sym_session **sessions;
9402 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9403 aes_cbc_key, hmac_sha512_key);
9406 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9408 sessions = rte_malloc(NULL,
9409 (sizeof(struct rte_cryptodev_sym_session *) *
9410 MAX_NB_SESSIONS) + 1, 0);
9412 /* Create multiple crypto sessions*/
9413 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9415 sessions[i] = rte_cryptodev_sym_session_create(
9416 ts_params->session_mpool);
9418 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9419 sessions[i], &ut_params->auth_xform,
9420 ts_params->session_priv_mpool);
9421 TEST_ASSERT_NOT_NULL(sessions[i],
9422 "Session creation failed at session number %u",
9425 /* Attempt to send a request on each session */
9426 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9430 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9431 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9433 "Failed to perform decrypt on request number %u.", i);
9434 /* free crypto operation structure */
9436 rte_crypto_op_free(ut_params->op);
9439 * free mbuf - both obuf and ibuf are usually the same,
9440 * so check if they point at the same address is necessary,
9441 * to avoid freeing the mbuf twice.
9443 if (ut_params->obuf) {
9444 rte_pktmbuf_free(ut_params->obuf);
9445 if (ut_params->ibuf == ut_params->obuf)
9446 ut_params->ibuf = 0;
9447 ut_params->obuf = 0;
9449 if (ut_params->ibuf) {
9450 rte_pktmbuf_free(ut_params->ibuf);
9451 ut_params->ibuf = 0;
9455 /* Next session create should fail */
9456 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9457 sessions[i], &ut_params->auth_xform,
9458 ts_params->session_priv_mpool);
9459 TEST_ASSERT_NULL(sessions[i],
9460 "Session creation succeeded unexpectedly!");
9462 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9463 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9465 rte_cryptodev_sym_session_free(sessions[i]);
9470 return TEST_SUCCESS;
9473 struct multi_session_params {
9474 struct crypto_unittest_params ut_params;
9475 uint8_t *cipher_key;
9477 const uint8_t *cipher;
9478 const uint8_t *digest;
9482 #define MB_SESSION_NUMBER 3
9485 test_multi_session_random_usage(void)
9487 struct crypto_testsuite_params *ts_params = &testsuite_params;
9488 struct rte_cryptodev_info dev_info;
9489 struct rte_cryptodev_sym_session **sessions;
9491 struct multi_session_params ut_paramz[] = {
9494 .cipher_key = ms_aes_cbc_key0,
9495 .hmac_key = ms_hmac_key0,
9496 .cipher = ms_aes_cbc_cipher0,
9497 .digest = ms_hmac_digest0,
9498 .iv = ms_aes_cbc_iv0
9501 .cipher_key = ms_aes_cbc_key1,
9502 .hmac_key = ms_hmac_key1,
9503 .cipher = ms_aes_cbc_cipher1,
9504 .digest = ms_hmac_digest1,
9505 .iv = ms_aes_cbc_iv1
9508 .cipher_key = ms_aes_cbc_key2,
9509 .hmac_key = ms_hmac_key2,
9510 .cipher = ms_aes_cbc_cipher2,
9511 .digest = ms_hmac_digest2,
9512 .iv = ms_aes_cbc_iv2
9517 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9519 sessions = rte_malloc(NULL,
9520 (sizeof(struct rte_cryptodev_sym_session *)
9521 * MAX_NB_SESSIONS) + 1, 0);
9523 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9524 sessions[i] = rte_cryptodev_sym_session_create(
9525 ts_params->session_mpool);
9527 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9528 sizeof(struct crypto_unittest_params));
9530 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9531 &ut_paramz[i].ut_params,
9532 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9534 /* Create multiple crypto sessions*/
9535 rte_cryptodev_sym_session_init(
9536 ts_params->valid_devs[0],
9538 &ut_paramz[i].ut_params.auth_xform,
9539 ts_params->session_priv_mpool);
9541 TEST_ASSERT_NOT_NULL(sessions[i],
9542 "Session creation failed at session number %u",
9548 for (i = 0; i < 40000; i++) {
9550 j = rand() % MB_SESSION_NUMBER;
9552 TEST_ASSERT_SUCCESS(
9553 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9555 &ut_paramz[j].ut_params,
9556 ts_params, ut_paramz[j].cipher,
9557 ut_paramz[j].digest,
9559 "Failed to perform decrypt on request number %u.", i);
9561 if (ut_paramz[j].ut_params.op)
9562 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9565 * free mbuf - both obuf and ibuf are usually the same,
9566 * so check if they point at the same address is necessary,
9567 * to avoid freeing the mbuf twice.
9569 if (ut_paramz[j].ut_params.obuf) {
9570 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9571 if (ut_paramz[j].ut_params.ibuf
9572 == ut_paramz[j].ut_params.obuf)
9573 ut_paramz[j].ut_params.ibuf = 0;
9574 ut_paramz[j].ut_params.obuf = 0;
9576 if (ut_paramz[j].ut_params.ibuf) {
9577 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9578 ut_paramz[j].ut_params.ibuf = 0;
9582 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9583 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9585 rte_cryptodev_sym_session_free(sessions[i]);
9590 return TEST_SUCCESS;
9594 test_null_cipher_only_operation(void)
9596 struct crypto_testsuite_params *ts_params = &testsuite_params;
9597 struct crypto_unittest_params *ut_params = &unittest_params;
9599 /* Generate test mbuf data and space for digest */
9600 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9601 catch_22_quote, QUOTE_512_BYTES, 0);
9603 /* Setup Cipher Parameters */
9604 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9605 ut_params->cipher_xform.next = NULL;
9607 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9608 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9610 ut_params->sess = rte_cryptodev_sym_session_create(
9611 ts_params->session_mpool);
9613 /* Create Crypto session*/
9614 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9616 &ut_params->cipher_xform,
9617 ts_params->session_priv_mpool);
9618 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9620 /* Generate Crypto op data structure */
9621 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9622 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9623 TEST_ASSERT_NOT_NULL(ut_params->op,
9624 "Failed to allocate symmetric crypto operation struct");
9626 /* Set crypto operation data parameters */
9627 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9629 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9631 /* set crypto operation source mbuf */
9632 sym_op->m_src = ut_params->ibuf;
9634 sym_op->cipher.data.offset = 0;
9635 sym_op->cipher.data.length = QUOTE_512_BYTES;
9637 /* Process crypto operation */
9638 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9640 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9642 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9643 "crypto operation processing failed");
9646 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9647 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9650 "Ciphertext data not as expected");
9652 return TEST_SUCCESS;
9654 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9655 0xab, 0xab, 0xab, 0xab,
9656 0xab, 0xab, 0xab, 0xab,
9657 0xab, 0xab, 0xab, 0xab};
9659 test_null_auth_only_operation(void)
9661 struct crypto_testsuite_params *ts_params = &testsuite_params;
9662 struct crypto_unittest_params *ut_params = &unittest_params;
9665 /* Generate test mbuf data and space for digest */
9666 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9667 catch_22_quote, QUOTE_512_BYTES, 0);
9669 /* create a pointer for digest, but don't expect anything to be written
9670 * here in a NULL auth algo so no mbuf append done.
9672 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9674 /* prefill the memory pointed to by digest */
9675 memcpy(digest, orig_data, sizeof(orig_data));
9677 /* Setup HMAC Parameters */
9678 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9679 ut_params->auth_xform.next = NULL;
9681 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9682 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9684 ut_params->sess = rte_cryptodev_sym_session_create(
9685 ts_params->session_mpool);
9687 /* Create Crypto session*/
9688 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9689 ut_params->sess, &ut_params->auth_xform,
9690 ts_params->session_priv_mpool);
9691 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9693 /* Generate Crypto op data structure */
9694 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9695 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9696 TEST_ASSERT_NOT_NULL(ut_params->op,
9697 "Failed to allocate symmetric crypto operation struct");
9699 /* Set crypto operation data parameters */
9700 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9702 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9704 sym_op->m_src = ut_params->ibuf;
9706 sym_op->auth.data.offset = 0;
9707 sym_op->auth.data.length = QUOTE_512_BYTES;
9708 sym_op->auth.digest.data = digest;
9709 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9712 /* Process crypto operation */
9713 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9715 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9717 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9718 "crypto operation processing failed");
9719 /* Make sure memory pointed to by digest hasn't been overwritten */
9720 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9724 "Memory at digest ptr overwritten unexpectedly");
9726 return TEST_SUCCESS;
9731 test_null_cipher_auth_operation(void)
9733 struct crypto_testsuite_params *ts_params = &testsuite_params;
9734 struct crypto_unittest_params *ut_params = &unittest_params;
9737 /* Generate test mbuf data and space for digest */
9738 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9739 catch_22_quote, QUOTE_512_BYTES, 0);
9741 /* create a pointer for digest, but don't expect anything to be written
9742 * here in a NULL auth algo so no mbuf append done.
9744 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9746 /* prefill the memory pointed to by digest */
9747 memcpy(digest, orig_data, sizeof(orig_data));
9749 /* Setup Cipher Parameters */
9750 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9751 ut_params->cipher_xform.next = &ut_params->auth_xform;
9753 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9754 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9756 /* Setup HMAC Parameters */
9757 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9758 ut_params->auth_xform.next = NULL;
9760 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9761 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9763 ut_params->sess = rte_cryptodev_sym_session_create(
9764 ts_params->session_mpool);
9766 /* Create Crypto session*/
9767 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9768 ut_params->sess, &ut_params->cipher_xform,
9769 ts_params->session_priv_mpool);
9770 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9772 /* Generate Crypto op data structure */
9773 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9774 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9775 TEST_ASSERT_NOT_NULL(ut_params->op,
9776 "Failed to allocate symmetric crypto operation struct");
9778 /* Set crypto operation data parameters */
9779 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9781 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9783 sym_op->m_src = ut_params->ibuf;
9785 sym_op->cipher.data.offset = 0;
9786 sym_op->cipher.data.length = QUOTE_512_BYTES;
9788 sym_op->auth.data.offset = 0;
9789 sym_op->auth.data.length = QUOTE_512_BYTES;
9790 sym_op->auth.digest.data = digest;
9791 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9794 /* Process crypto operation */
9795 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9797 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9799 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9800 "crypto operation processing failed");
9803 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9804 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9807 "Ciphertext data not as expected");
9808 /* Make sure memory pointed to by digest hasn't been overwritten */
9809 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9813 "Memory at digest ptr overwritten unexpectedly");
9815 return TEST_SUCCESS;
9819 test_null_auth_cipher_operation(void)
9821 struct crypto_testsuite_params *ts_params = &testsuite_params;
9822 struct crypto_unittest_params *ut_params = &unittest_params;
9825 /* Generate test mbuf data */
9826 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9827 catch_22_quote, QUOTE_512_BYTES, 0);
9829 /* create a pointer for digest, but don't expect anything to be written
9830 * here in a NULL auth algo so no mbuf append done.
9832 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9834 /* prefill the memory pointed to by digest */
9835 memcpy(digest, orig_data, sizeof(orig_data));
9837 /* Setup Cipher Parameters */
9838 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9839 ut_params->cipher_xform.next = NULL;
9841 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9842 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9844 /* Setup HMAC Parameters */
9845 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9846 ut_params->auth_xform.next = &ut_params->cipher_xform;
9848 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9849 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9851 ut_params->sess = rte_cryptodev_sym_session_create(
9852 ts_params->session_mpool);
9854 /* Create Crypto session*/
9855 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9856 ut_params->sess, &ut_params->cipher_xform,
9857 ts_params->session_priv_mpool);
9858 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9860 /* Generate Crypto op data structure */
9861 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9862 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9863 TEST_ASSERT_NOT_NULL(ut_params->op,
9864 "Failed to allocate symmetric crypto operation struct");
9866 /* Set crypto operation data parameters */
9867 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9869 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9871 sym_op->m_src = ut_params->ibuf;
9873 sym_op->cipher.data.offset = 0;
9874 sym_op->cipher.data.length = QUOTE_512_BYTES;
9876 sym_op->auth.data.offset = 0;
9877 sym_op->auth.data.length = QUOTE_512_BYTES;
9878 sym_op->auth.digest.data = digest;
9879 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9882 /* Process crypto operation */
9883 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9885 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9887 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9888 "crypto operation processing failed");
9891 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9892 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9895 "Ciphertext data not as expected");
9896 /* Make sure memory pointed to by digest hasn't been overwritten */
9897 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9901 "Memory at digest ptr overwritten unexpectedly");
9903 return TEST_SUCCESS;
9908 test_null_invalid_operation(void)
9910 struct crypto_testsuite_params *ts_params = &testsuite_params;
9911 struct crypto_unittest_params *ut_params = &unittest_params;
9914 /* Setup Cipher Parameters */
9915 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9916 ut_params->cipher_xform.next = NULL;
9918 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
9919 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9921 ut_params->sess = rte_cryptodev_sym_session_create(
9922 ts_params->session_mpool);
9924 /* Create Crypto session*/
9925 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9926 ut_params->sess, &ut_params->cipher_xform,
9927 ts_params->session_priv_mpool);
9928 TEST_ASSERT(ret < 0,
9929 "Session creation succeeded unexpectedly");
9932 /* Setup HMAC Parameters */
9933 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9934 ut_params->auth_xform.next = NULL;
9936 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
9937 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9939 ut_params->sess = rte_cryptodev_sym_session_create(
9940 ts_params->session_mpool);
9942 /* Create Crypto session*/
9943 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9944 ut_params->sess, &ut_params->auth_xform,
9945 ts_params->session_priv_mpool);
9946 TEST_ASSERT(ret < 0,
9947 "Session creation succeeded unexpectedly");
9949 return TEST_SUCCESS;
9953 #define NULL_BURST_LENGTH (32)
9956 test_null_burst_operation(void)
9958 struct crypto_testsuite_params *ts_params = &testsuite_params;
9959 struct crypto_unittest_params *ut_params = &unittest_params;
9961 unsigned i, burst_len = NULL_BURST_LENGTH;
9963 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
9964 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
9966 /* Setup Cipher Parameters */
9967 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9968 ut_params->cipher_xform.next = &ut_params->auth_xform;
9970 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9971 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9973 /* Setup HMAC Parameters */
9974 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9975 ut_params->auth_xform.next = NULL;
9977 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9978 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9980 ut_params->sess = rte_cryptodev_sym_session_create(
9981 ts_params->session_mpool);
9983 /* Create Crypto session*/
9984 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9985 ut_params->sess, &ut_params->cipher_xform,
9986 ts_params->session_priv_mpool);
9987 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9989 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
9990 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
9991 burst_len, "failed to generate burst of crypto ops");
9993 /* Generate an operation for each mbuf in burst */
9994 for (i = 0; i < burst_len; i++) {
9995 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9997 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
9999 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10003 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10005 burst[i]->sym->m_src = m;
10008 /* Process crypto operation */
10009 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10010 0, burst, burst_len),
10012 "Error enqueuing burst");
10014 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10015 0, burst_dequeued, burst_len),
10017 "Error dequeuing burst");
10020 for (i = 0; i < burst_len; i++) {
10022 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10023 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10025 "data not as expected");
10027 rte_pktmbuf_free(burst[i]->sym->m_src);
10028 rte_crypto_op_free(burst[i]);
10031 return TEST_SUCCESS;
10035 generate_gmac_large_plaintext(uint8_t *data)
10039 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10040 memcpy(&data[i], &data[0], 32);
10044 create_gmac_operation(enum rte_crypto_auth_operation op,
10045 const struct gmac_test_data *tdata)
10047 struct crypto_testsuite_params *ts_params = &testsuite_params;
10048 struct crypto_unittest_params *ut_params = &unittest_params;
10049 struct rte_crypto_sym_op *sym_op;
10051 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10053 /* Generate Crypto op data structure */
10054 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10055 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10056 TEST_ASSERT_NOT_NULL(ut_params->op,
10057 "Failed to allocate symmetric crypto operation struct");
10059 sym_op = ut_params->op->sym;
10061 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10062 ut_params->ibuf, tdata->gmac_tag.len);
10063 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10064 "no room to append digest");
10066 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10067 ut_params->ibuf, plaintext_pad_len);
10069 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10070 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10071 tdata->gmac_tag.len);
10072 debug_hexdump(stdout, "digest:",
10073 sym_op->auth.digest.data,
10074 tdata->gmac_tag.len);
10077 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10078 uint8_t *, IV_OFFSET);
10080 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10082 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10084 sym_op->cipher.data.length = 0;
10085 sym_op->cipher.data.offset = 0;
10087 sym_op->auth.data.offset = 0;
10088 sym_op->auth.data.length = tdata->plaintext.len;
10093 static int create_gmac_session(uint8_t dev_id,
10094 const struct gmac_test_data *tdata,
10095 enum rte_crypto_auth_operation auth_op)
10097 uint8_t auth_key[tdata->key.len];
10099 struct crypto_testsuite_params *ts_params = &testsuite_params;
10100 struct crypto_unittest_params *ut_params = &unittest_params;
10102 memcpy(auth_key, tdata->key.data, tdata->key.len);
10104 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10105 ut_params->auth_xform.next = NULL;
10107 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10108 ut_params->auth_xform.auth.op = auth_op;
10109 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10110 ut_params->auth_xform.auth.key.length = tdata->key.len;
10111 ut_params->auth_xform.auth.key.data = auth_key;
10112 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10113 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10116 ut_params->sess = rte_cryptodev_sym_session_create(
10117 ts_params->session_mpool);
10119 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10120 &ut_params->auth_xform,
10121 ts_params->session_priv_mpool);
10123 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10129 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10131 struct crypto_testsuite_params *ts_params = &testsuite_params;
10132 struct crypto_unittest_params *ut_params = &unittest_params;
10136 uint8_t *auth_tag, *plaintext;
10137 uint16_t plaintext_pad_len;
10139 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10140 "No GMAC length in the source data");
10142 retval = create_gmac_session(ts_params->valid_devs[0],
10143 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10148 if (tdata->plaintext.len > MBUF_SIZE)
10149 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10151 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10152 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10153 "Failed to allocate input buffer in mempool");
10155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10156 rte_pktmbuf_tailroom(ut_params->ibuf));
10158 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10160 * Runtime generate the large plain text instead of use hard code
10161 * plain text vector. It is done to avoid create huge source file
10162 * with the test vector.
10164 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10165 generate_gmac_large_plaintext(tdata->plaintext.data);
10167 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10168 plaintext_pad_len);
10169 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10171 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10172 debug_hexdump(stdout, "plaintext:", plaintext,
10173 tdata->plaintext.len);
10175 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10181 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10183 ut_params->op->sym->m_src = ut_params->ibuf;
10185 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10186 ut_params->op), "failed to process sym crypto op");
10188 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10189 "crypto op processing failed");
10191 if (ut_params->op->sym->m_dst) {
10192 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10193 uint8_t *, plaintext_pad_len);
10195 auth_tag = plaintext + plaintext_pad_len;
10198 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10200 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10202 tdata->gmac_tag.data,
10203 tdata->gmac_tag.len,
10204 "GMAC Generated auth tag not as expected");
10210 test_AES_GMAC_authentication_test_case_1(void)
10212 return test_AES_GMAC_authentication(&gmac_test_case_1);
10216 test_AES_GMAC_authentication_test_case_2(void)
10218 return test_AES_GMAC_authentication(&gmac_test_case_2);
10222 test_AES_GMAC_authentication_test_case_3(void)
10224 return test_AES_GMAC_authentication(&gmac_test_case_3);
10228 test_AES_GMAC_authentication_test_case_4(void)
10230 return test_AES_GMAC_authentication(&gmac_test_case_4);
10234 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10236 struct crypto_testsuite_params *ts_params = &testsuite_params;
10237 struct crypto_unittest_params *ut_params = &unittest_params;
10239 uint32_t plaintext_pad_len;
10240 uint8_t *plaintext;
10242 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10243 "No GMAC length in the source data");
10245 retval = create_gmac_session(ts_params->valid_devs[0],
10246 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10251 if (tdata->plaintext.len > MBUF_SIZE)
10252 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10254 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10255 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10256 "Failed to allocate input buffer in mempool");
10258 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10259 rte_pktmbuf_tailroom(ut_params->ibuf));
10261 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10264 * Runtime generate the large plain text instead of use hard code
10265 * plain text vector. It is done to avoid create huge source file
10266 * with the test vector.
10268 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10269 generate_gmac_large_plaintext(tdata->plaintext.data);
10271 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10272 plaintext_pad_len);
10273 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10275 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10276 debug_hexdump(stdout, "plaintext:", plaintext,
10277 tdata->plaintext.len);
10279 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10285 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10287 ut_params->op->sym->m_src = ut_params->ibuf;
10289 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10290 ut_params->op), "failed to process sym crypto op");
10292 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10293 "crypto op processing failed");
10300 test_AES_GMAC_authentication_verify_test_case_1(void)
10302 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10306 test_AES_GMAC_authentication_verify_test_case_2(void)
10308 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10312 test_AES_GMAC_authentication_verify_test_case_3(void)
10314 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10318 test_AES_GMAC_authentication_verify_test_case_4(void)
10320 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10323 struct test_crypto_vector {
10324 enum rte_crypto_cipher_algorithm crypto_algo;
10325 unsigned int cipher_offset;
10326 unsigned int cipher_len;
10339 const uint8_t *data;
10344 const uint8_t *data;
10348 enum rte_crypto_auth_algorithm auth_algo;
10349 unsigned int auth_offset;
10357 const uint8_t *data;
10367 static const struct test_crypto_vector
10368 hmac_sha1_test_crypto_vector = {
10369 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10371 .data = plaintext_hash,
10376 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10377 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10378 0xDE, 0xF4, 0xDE, 0xAD
10384 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10385 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10386 0x3F, 0x91, 0x64, 0x59
10392 static const struct test_crypto_vector
10393 aes128_gmac_test_vector = {
10394 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10396 .data = plaintext_hash,
10401 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10402 0x08, 0x09, 0x0A, 0x0B
10408 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10409 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10415 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10416 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10422 static const struct test_crypto_vector
10423 aes128cbc_hmac_sha1_test_vector = {
10424 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10425 .cipher_offset = 0,
10429 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10430 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10436 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10437 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10442 .data = plaintext_hash,
10446 .data = ciphertext512_aes128cbc,
10449 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10453 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10454 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10455 0xDE, 0xF4, 0xDE, 0xAD
10461 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10462 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10463 0x18, 0x8C, 0x1D, 0x32
10469 static const struct test_crypto_vector
10470 aes128cbc_hmac_sha1_aad_test_vector = {
10471 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10472 .cipher_offset = 12,
10476 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10477 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10483 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10484 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10489 .data = plaintext_hash,
10493 .data = ciphertext512_aes128cbc_aad,
10496 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10500 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10501 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10502 0xDE, 0xF4, 0xDE, 0xAD
10508 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10509 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10510 0x62, 0x8D, 0x62, 0x65
10517 data_corruption(uint8_t *data)
10523 tag_corruption(uint8_t *data, unsigned int tag_offset)
10525 data[tag_offset] += 1;
10529 create_auth_session(struct crypto_unittest_params *ut_params,
10531 const struct test_crypto_vector *reference,
10532 enum rte_crypto_auth_operation auth_op)
10534 struct crypto_testsuite_params *ts_params = &testsuite_params;
10535 uint8_t auth_key[reference->auth_key.len + 1];
10537 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10539 /* Setup Authentication Parameters */
10540 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10541 ut_params->auth_xform.auth.op = auth_op;
10542 ut_params->auth_xform.next = NULL;
10543 ut_params->auth_xform.auth.algo = reference->auth_algo;
10544 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10545 ut_params->auth_xform.auth.key.data = auth_key;
10546 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10548 /* Create Crypto session*/
10549 ut_params->sess = rte_cryptodev_sym_session_create(
10550 ts_params->session_mpool);
10552 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10553 &ut_params->auth_xform,
10554 ts_params->session_priv_mpool);
10556 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10562 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10564 const struct test_crypto_vector *reference,
10565 enum rte_crypto_auth_operation auth_op,
10566 enum rte_crypto_cipher_operation cipher_op)
10568 struct crypto_testsuite_params *ts_params = &testsuite_params;
10569 uint8_t cipher_key[reference->cipher_key.len + 1];
10570 uint8_t auth_key[reference->auth_key.len + 1];
10572 memcpy(cipher_key, reference->cipher_key.data,
10573 reference->cipher_key.len);
10574 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10576 /* Setup Authentication Parameters */
10577 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10578 ut_params->auth_xform.auth.op = auth_op;
10579 ut_params->auth_xform.auth.algo = reference->auth_algo;
10580 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10581 ut_params->auth_xform.auth.key.data = auth_key;
10582 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10584 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10585 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10586 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10588 ut_params->auth_xform.next = &ut_params->cipher_xform;
10590 /* Setup Cipher Parameters */
10591 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10592 ut_params->cipher_xform.next = NULL;
10593 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10594 ut_params->cipher_xform.cipher.op = cipher_op;
10595 ut_params->cipher_xform.cipher.key.data = cipher_key;
10596 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10597 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10598 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10601 /* Create Crypto session*/
10602 ut_params->sess = rte_cryptodev_sym_session_create(
10603 ts_params->session_mpool);
10605 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10606 &ut_params->auth_xform,
10607 ts_params->session_priv_mpool);
10609 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10615 create_auth_operation(struct crypto_testsuite_params *ts_params,
10616 struct crypto_unittest_params *ut_params,
10617 const struct test_crypto_vector *reference,
10618 unsigned int auth_generate)
10620 /* Generate Crypto op data structure */
10621 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10622 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10623 TEST_ASSERT_NOT_NULL(ut_params->op,
10624 "Failed to allocate pktmbuf offload");
10626 /* Set crypto operation data parameters */
10627 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10629 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10631 /* set crypto operation source mbuf */
10632 sym_op->m_src = ut_params->ibuf;
10635 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10636 ut_params->ibuf, reference->digest.len);
10638 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10639 "no room to append auth tag");
10641 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10642 ut_params->ibuf, reference->plaintext.len);
10645 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10647 memcpy(sym_op->auth.digest.data,
10648 reference->digest.data,
10649 reference->digest.len);
10651 debug_hexdump(stdout, "digest:",
10652 sym_op->auth.digest.data,
10653 reference->digest.len);
10655 sym_op->auth.data.length = reference->plaintext.len;
10656 sym_op->auth.data.offset = 0;
10662 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10663 struct crypto_unittest_params *ut_params,
10664 const struct test_crypto_vector *reference,
10665 unsigned int auth_generate)
10667 /* Generate Crypto op data structure */
10668 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10669 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10670 TEST_ASSERT_NOT_NULL(ut_params->op,
10671 "Failed to allocate pktmbuf offload");
10673 /* Set crypto operation data parameters */
10674 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10676 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10678 /* set crypto operation source mbuf */
10679 sym_op->m_src = ut_params->ibuf;
10682 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10683 ut_params->ibuf, reference->digest.len);
10685 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10686 "no room to append auth tag");
10688 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10689 ut_params->ibuf, reference->ciphertext.len);
10692 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10694 memcpy(sym_op->auth.digest.data,
10695 reference->digest.data,
10696 reference->digest.len);
10698 debug_hexdump(stdout, "digest:",
10699 sym_op->auth.digest.data,
10700 reference->digest.len);
10702 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10703 reference->iv.data, reference->iv.len);
10705 sym_op->cipher.data.length = 0;
10706 sym_op->cipher.data.offset = 0;
10708 sym_op->auth.data.length = reference->plaintext.len;
10709 sym_op->auth.data.offset = 0;
10715 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
10716 struct crypto_unittest_params *ut_params,
10717 const struct test_crypto_vector *reference,
10718 unsigned int auth_generate)
10720 /* Generate Crypto op data structure */
10721 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10722 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10723 TEST_ASSERT_NOT_NULL(ut_params->op,
10724 "Failed to allocate pktmbuf offload");
10726 /* Set crypto operation data parameters */
10727 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10729 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10731 /* set crypto operation source mbuf */
10732 sym_op->m_src = ut_params->ibuf;
10735 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10736 ut_params->ibuf, reference->digest.len);
10738 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10739 "no room to append auth tag");
10741 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10742 ut_params->ibuf, reference->ciphertext.len);
10745 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10747 memcpy(sym_op->auth.digest.data,
10748 reference->digest.data,
10749 reference->digest.len);
10751 debug_hexdump(stdout, "digest:",
10752 sym_op->auth.digest.data,
10753 reference->digest.len);
10755 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10756 reference->iv.data, reference->iv.len);
10758 sym_op->cipher.data.length = reference->cipher_len;
10759 sym_op->cipher.data.offset = reference->cipher_offset;
10761 sym_op->auth.data.length = reference->plaintext.len;
10762 sym_op->auth.data.offset = reference->auth_offset;
10768 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10769 struct crypto_unittest_params *ut_params,
10770 const struct test_crypto_vector *reference)
10772 return create_auth_operation(ts_params, ut_params, reference, 0);
10776 create_auth_verify_GMAC_operation(
10777 struct crypto_testsuite_params *ts_params,
10778 struct crypto_unittest_params *ut_params,
10779 const struct test_crypto_vector *reference)
10781 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
10785 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
10786 struct crypto_unittest_params *ut_params,
10787 const struct test_crypto_vector *reference)
10789 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
10793 test_authentication_verify_fail_when_data_corruption(
10794 struct crypto_testsuite_params *ts_params,
10795 struct crypto_unittest_params *ut_params,
10796 const struct test_crypto_vector *reference,
10797 unsigned int data_corrupted)
10801 uint8_t *plaintext;
10803 /* Create session */
10804 retval = create_auth_session(ut_params,
10805 ts_params->valid_devs[0],
10807 RTE_CRYPTO_AUTH_OP_VERIFY);
10811 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10812 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10813 "Failed to allocate input buffer in mempool");
10815 /* clear mbuf payload */
10816 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10817 rte_pktmbuf_tailroom(ut_params->ibuf));
10819 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10820 reference->plaintext.len);
10821 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10822 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10824 debug_hexdump(stdout, "plaintext:", plaintext,
10825 reference->plaintext.len);
10827 /* Create operation */
10828 retval = create_auth_verify_operation(ts_params, ut_params, reference);
10833 if (data_corrupted)
10834 data_corruption(plaintext);
10836 tag_corruption(plaintext, reference->plaintext.len);
10838 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10841 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10847 test_authentication_verify_GMAC_fail_when_corruption(
10848 struct crypto_testsuite_params *ts_params,
10849 struct crypto_unittest_params *ut_params,
10850 const struct test_crypto_vector *reference,
10851 unsigned int data_corrupted)
10854 uint8_t *plaintext;
10856 /* Create session */
10857 retval = create_auth_cipher_session(ut_params,
10858 ts_params->valid_devs[0],
10860 RTE_CRYPTO_AUTH_OP_VERIFY,
10861 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10865 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10866 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10867 "Failed to allocate input buffer in mempool");
10869 /* clear mbuf payload */
10870 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10871 rte_pktmbuf_tailroom(ut_params->ibuf));
10873 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10874 reference->plaintext.len);
10875 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10876 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
10878 debug_hexdump(stdout, "plaintext:", plaintext,
10879 reference->plaintext.len);
10881 /* Create operation */
10882 retval = create_auth_verify_GMAC_operation(ts_params,
10889 if (data_corrupted)
10890 data_corruption(plaintext);
10892 tag_corruption(plaintext, reference->aad.len);
10894 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10897 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10903 test_authenticated_decryption_fail_when_corruption(
10904 struct crypto_testsuite_params *ts_params,
10905 struct crypto_unittest_params *ut_params,
10906 const struct test_crypto_vector *reference,
10907 unsigned int data_corrupted)
10911 uint8_t *ciphertext;
10913 /* Create session */
10914 retval = create_auth_cipher_session(ut_params,
10915 ts_params->valid_devs[0],
10917 RTE_CRYPTO_AUTH_OP_VERIFY,
10918 RTE_CRYPTO_CIPHER_OP_DECRYPT);
10922 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10923 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10924 "Failed to allocate input buffer in mempool");
10926 /* clear mbuf payload */
10927 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10928 rte_pktmbuf_tailroom(ut_params->ibuf));
10930 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10931 reference->ciphertext.len);
10932 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
10933 memcpy(ciphertext, reference->ciphertext.data,
10934 reference->ciphertext.len);
10936 /* Create operation */
10937 retval = create_cipher_auth_verify_operation(ts_params,
10944 if (data_corrupted)
10945 data_corruption(ciphertext);
10947 tag_corruption(ciphertext, reference->ciphertext.len);
10949 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10952 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
10958 test_authenticated_encryt_with_esn(
10959 struct crypto_testsuite_params *ts_params,
10960 struct crypto_unittest_params *ut_params,
10961 const struct test_crypto_vector *reference)
10965 uint8_t *authciphertext, *plaintext, *auth_tag;
10966 uint16_t plaintext_pad_len;
10967 uint8_t cipher_key[reference->cipher_key.len + 1];
10968 uint8_t auth_key[reference->auth_key.len + 1];
10970 /* Create session */
10971 memcpy(cipher_key, reference->cipher_key.data,
10972 reference->cipher_key.len);
10973 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10975 /* Setup Cipher Parameters */
10976 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10977 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10978 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10979 ut_params->cipher_xform.cipher.key.data = cipher_key;
10980 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10981 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10982 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10984 ut_params->cipher_xform.next = &ut_params->auth_xform;
10986 /* Setup Authentication Parameters */
10987 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10988 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10989 ut_params->auth_xform.auth.algo = reference->auth_algo;
10990 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10991 ut_params->auth_xform.auth.key.data = auth_key;
10992 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10993 ut_params->auth_xform.next = NULL;
10995 /* Create Crypto session*/
10996 ut_params->sess = rte_cryptodev_sym_session_create(
10997 ts_params->session_mpool);
10999 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11001 &ut_params->cipher_xform,
11002 ts_params->session_priv_mpool);
11004 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11006 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11007 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11008 "Failed to allocate input buffer in mempool");
11010 /* clear mbuf payload */
11011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11012 rte_pktmbuf_tailroom(ut_params->ibuf));
11014 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11015 reference->plaintext.len);
11016 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11017 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11019 /* Create operation */
11020 retval = create_cipher_auth_operation(ts_params,
11027 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11030 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11032 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11033 "crypto op processing failed");
11035 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11037 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11038 ut_params->op->sym->auth.data.offset);
11039 auth_tag = authciphertext + plaintext_pad_len;
11040 debug_hexdump(stdout, "ciphertext:", authciphertext,
11041 reference->ciphertext.len);
11042 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11044 /* Validate obuf */
11045 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11047 reference->ciphertext.data,
11048 reference->ciphertext.len,
11049 "Ciphertext data not as expected");
11051 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11053 reference->digest.data,
11054 reference->digest.len,
11055 "Generated digest not as expected");
11057 return TEST_SUCCESS;
11062 test_authenticated_decrypt_with_esn(
11063 struct crypto_testsuite_params *ts_params,
11064 struct crypto_unittest_params *ut_params,
11065 const struct test_crypto_vector *reference)
11069 uint8_t *ciphertext;
11070 uint8_t cipher_key[reference->cipher_key.len + 1];
11071 uint8_t auth_key[reference->auth_key.len + 1];
11073 /* Create session */
11074 memcpy(cipher_key, reference->cipher_key.data,
11075 reference->cipher_key.len);
11076 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11078 /* Setup Authentication Parameters */
11079 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11080 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11081 ut_params->auth_xform.auth.algo = reference->auth_algo;
11082 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11083 ut_params->auth_xform.auth.key.data = auth_key;
11084 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11085 ut_params->auth_xform.next = &ut_params->cipher_xform;
11087 /* Setup Cipher Parameters */
11088 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11089 ut_params->cipher_xform.next = NULL;
11090 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11091 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11092 ut_params->cipher_xform.cipher.key.data = cipher_key;
11093 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11094 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11095 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11097 /* Create Crypto session*/
11098 ut_params->sess = rte_cryptodev_sym_session_create(
11099 ts_params->session_mpool);
11101 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11103 &ut_params->auth_xform,
11104 ts_params->session_priv_mpool);
11106 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11108 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11109 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11110 "Failed to allocate input buffer in mempool");
11112 /* clear mbuf payload */
11113 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11114 rte_pktmbuf_tailroom(ut_params->ibuf));
11116 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11117 reference->ciphertext.len);
11118 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11119 memcpy(ciphertext, reference->ciphertext.data,
11120 reference->ciphertext.len);
11122 /* Create operation */
11123 retval = create_cipher_auth_verify_operation(ts_params,
11130 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11133 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11134 TEST_ASSERT_EQUAL(ut_params->op->status,
11135 RTE_CRYPTO_OP_STATUS_SUCCESS,
11136 "crypto op processing passed");
11138 ut_params->obuf = ut_params->op->sym->m_src;
11139 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11145 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11146 const struct aead_test_data *tdata,
11147 void *digest_mem, uint64_t digest_phys)
11149 struct crypto_testsuite_params *ts_params = &testsuite_params;
11150 struct crypto_unittest_params *ut_params = &unittest_params;
11152 const unsigned int auth_tag_len = tdata->auth_tag.len;
11153 const unsigned int iv_len = tdata->iv.len;
11154 unsigned int aad_len = tdata->aad.len;
11155 unsigned int aad_len_pad = 0;
11157 /* Generate Crypto op data structure */
11158 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11159 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11160 TEST_ASSERT_NOT_NULL(ut_params->op,
11161 "Failed to allocate symmetric crypto operation struct");
11163 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11165 sym_op->aead.digest.data = digest_mem;
11167 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11168 "no room to append digest");
11170 sym_op->aead.digest.phys_addr = digest_phys;
11172 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11173 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11175 debug_hexdump(stdout, "digest:",
11176 sym_op->aead.digest.data,
11180 /* Append aad data */
11181 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11182 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11183 uint8_t *, IV_OFFSET);
11185 /* Copy IV 1 byte after the IV pointer, according to the API */
11186 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11188 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11190 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11191 ut_params->ibuf, aad_len);
11192 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11193 "no room to prepend aad");
11194 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11197 memset(sym_op->aead.aad.data, 0, aad_len);
11198 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11199 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11201 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11202 debug_hexdump(stdout, "aad:",
11203 sym_op->aead.aad.data, aad_len);
11205 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11206 uint8_t *, IV_OFFSET);
11208 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11210 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11212 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11213 ut_params->ibuf, aad_len_pad);
11214 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11215 "no room to prepend aad");
11216 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11219 memset(sym_op->aead.aad.data, 0, aad_len);
11220 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11222 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11223 debug_hexdump(stdout, "aad:",
11224 sym_op->aead.aad.data, aad_len);
11227 sym_op->aead.data.length = tdata->plaintext.len;
11228 sym_op->aead.data.offset = aad_len_pad;
11233 #define SGL_MAX_NO 16
11236 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11237 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11239 struct crypto_testsuite_params *ts_params = &testsuite_params;
11240 struct crypto_unittest_params *ut_params = &unittest_params;
11241 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11244 int to_trn_tbl[SGL_MAX_NO];
11246 unsigned int trn_data = 0;
11247 uint8_t *plaintext, *ciphertext, *auth_tag;
11249 if (fragsz > tdata->plaintext.len)
11250 fragsz = tdata->plaintext.len;
11252 uint16_t plaintext_len = fragsz;
11253 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11255 if (fragsz_oop > tdata->plaintext.len)
11256 frag_size_oop = tdata->plaintext.len;
11259 void *digest_mem = NULL;
11261 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11263 if (tdata->plaintext.len % fragsz != 0) {
11264 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11267 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11272 * For out-op-place we need to alloc another mbuf
11275 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11276 rte_pktmbuf_append(ut_params->obuf,
11277 frag_size_oop + prepend_len);
11278 buf_oop = ut_params->obuf;
11281 /* Create AEAD session */
11282 retval = create_aead_session(ts_params->valid_devs[0],
11284 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11285 tdata->key.data, tdata->key.len,
11286 tdata->aad.len, tdata->auth_tag.len,
11291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11293 /* clear mbuf payload */
11294 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11295 rte_pktmbuf_tailroom(ut_params->ibuf));
11297 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11300 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11302 trn_data += plaintext_len;
11304 buf = ut_params->ibuf;
11307 * Loop until no more fragments
11310 while (trn_data < tdata->plaintext.len) {
11312 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11313 (tdata->plaintext.len - trn_data) : fragsz;
11315 to_trn_tbl[ecx++] = to_trn;
11317 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11320 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11321 rte_pktmbuf_tailroom(buf));
11324 if (oop && !fragsz_oop) {
11325 buf_last_oop = buf_oop->next =
11326 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11327 buf_oop = buf_oop->next;
11328 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11329 0, rte_pktmbuf_tailroom(buf_oop));
11330 rte_pktmbuf_append(buf_oop, to_trn);
11333 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11336 memcpy(plaintext, tdata->plaintext.data + trn_data,
11338 trn_data += to_trn;
11339 if (trn_data == tdata->plaintext.len) {
11342 digest_mem = rte_pktmbuf_append(buf_oop,
11343 tdata->auth_tag.len);
11345 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11346 tdata->auth_tag.len);
11350 uint64_t digest_phys = 0;
11352 ut_params->ibuf->nb_segs = segs;
11355 if (fragsz_oop && oop) {
11359 if (frag_size_oop == tdata->plaintext.len) {
11360 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11361 tdata->auth_tag.len);
11363 digest_phys = rte_pktmbuf_iova_offset(
11365 tdata->plaintext.len + prepend_len);
11368 trn_data = frag_size_oop;
11369 while (trn_data < tdata->plaintext.len) {
11372 (tdata->plaintext.len - trn_data <
11374 (tdata->plaintext.len - trn_data) :
11377 to_trn_tbl[ecx++] = to_trn;
11379 buf_last_oop = buf_oop->next =
11380 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11381 buf_oop = buf_oop->next;
11382 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11383 0, rte_pktmbuf_tailroom(buf_oop));
11384 rte_pktmbuf_append(buf_oop, to_trn);
11386 trn_data += to_trn;
11388 if (trn_data == tdata->plaintext.len) {
11389 digest_mem = rte_pktmbuf_append(buf_oop,
11390 tdata->auth_tag.len);
11394 ut_params->obuf->nb_segs = segs;
11398 * Place digest at the end of the last buffer
11401 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11402 if (oop && buf_last_oop)
11403 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11405 if (!digest_mem && !oop) {
11406 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11407 + tdata->auth_tag.len);
11408 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11409 tdata->plaintext.len);
11412 /* Create AEAD operation */
11413 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11414 tdata, digest_mem, digest_phys);
11419 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11421 ut_params->op->sym->m_src = ut_params->ibuf;
11423 ut_params->op->sym->m_dst = ut_params->obuf;
11425 /* Process crypto operation */
11426 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11427 ut_params->op), "failed to process sym crypto op");
11429 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11430 "crypto op processing failed");
11433 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11434 uint8_t *, prepend_len);
11436 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11437 uint8_t *, prepend_len);
11441 fragsz = fragsz_oop;
11443 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11445 tdata->ciphertext.data,
11447 "Ciphertext data not as expected");
11449 buf = ut_params->op->sym->m_src->next;
11451 buf = ut_params->op->sym->m_dst->next;
11453 unsigned int off = fragsz;
11457 ciphertext = rte_pktmbuf_mtod(buf,
11460 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11462 tdata->ciphertext.data + off,
11464 "Ciphertext data not as expected");
11466 off += to_trn_tbl[ecx++];
11470 auth_tag = digest_mem;
11471 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11473 tdata->auth_tag.data,
11474 tdata->auth_tag.len,
11475 "Generated auth tag not as expected");
11481 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11483 return test_authenticated_encryption_SGL(
11484 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11488 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11490 return test_authenticated_encryption_SGL(
11491 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11495 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11497 return test_authenticated_encryption_SGL(
11498 &gcm_test_case_8, OUT_OF_PLACE, 400,
11499 gcm_test_case_8.plaintext.len);
11503 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11506 return test_authenticated_encryption_SGL(
11507 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11511 test_authentication_verify_fail_when_data_corrupted(
11512 struct crypto_testsuite_params *ts_params,
11513 struct crypto_unittest_params *ut_params,
11514 const struct test_crypto_vector *reference)
11516 return test_authentication_verify_fail_when_data_corruption(
11517 ts_params, ut_params, reference, 1);
11521 test_authentication_verify_fail_when_tag_corrupted(
11522 struct crypto_testsuite_params *ts_params,
11523 struct crypto_unittest_params *ut_params,
11524 const struct test_crypto_vector *reference)
11526 return test_authentication_verify_fail_when_data_corruption(
11527 ts_params, ut_params, reference, 0);
11531 test_authentication_verify_GMAC_fail_when_data_corrupted(
11532 struct crypto_testsuite_params *ts_params,
11533 struct crypto_unittest_params *ut_params,
11534 const struct test_crypto_vector *reference)
11536 return test_authentication_verify_GMAC_fail_when_corruption(
11537 ts_params, ut_params, reference, 1);
11541 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11542 struct crypto_testsuite_params *ts_params,
11543 struct crypto_unittest_params *ut_params,
11544 const struct test_crypto_vector *reference)
11546 return test_authentication_verify_GMAC_fail_when_corruption(
11547 ts_params, ut_params, reference, 0);
11551 test_authenticated_decryption_fail_when_data_corrupted(
11552 struct crypto_testsuite_params *ts_params,
11553 struct crypto_unittest_params *ut_params,
11554 const struct test_crypto_vector *reference)
11556 return test_authenticated_decryption_fail_when_corruption(
11557 ts_params, ut_params, reference, 1);
11561 test_authenticated_decryption_fail_when_tag_corrupted(
11562 struct crypto_testsuite_params *ts_params,
11563 struct crypto_unittest_params *ut_params,
11564 const struct test_crypto_vector *reference)
11566 return test_authenticated_decryption_fail_when_corruption(
11567 ts_params, ut_params, reference, 0);
11571 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11573 return test_authentication_verify_fail_when_data_corrupted(
11574 &testsuite_params, &unittest_params,
11575 &hmac_sha1_test_crypto_vector);
11579 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11581 return test_authentication_verify_fail_when_tag_corrupted(
11582 &testsuite_params, &unittest_params,
11583 &hmac_sha1_test_crypto_vector);
11587 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11589 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11590 &testsuite_params, &unittest_params,
11591 &aes128_gmac_test_vector);
11595 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11597 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11598 &testsuite_params, &unittest_params,
11599 &aes128_gmac_test_vector);
11603 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11605 return test_authenticated_decryption_fail_when_data_corrupted(
11608 &aes128cbc_hmac_sha1_test_vector);
11612 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11614 return test_authenticated_decryption_fail_when_tag_corrupted(
11617 &aes128cbc_hmac_sha1_test_vector);
11621 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11623 return test_authenticated_encryt_with_esn(
11626 &aes128cbc_hmac_sha1_aad_test_vector);
11630 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11632 return test_authenticated_decrypt_with_esn(
11635 &aes128cbc_hmac_sha1_aad_test_vector);
11638 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11640 /* global AESNI slave IDs for the scheduler test */
11641 uint8_t aesni_ids[2];
11644 test_scheduler_attach_slave_op(void)
11646 struct crypto_testsuite_params *ts_params = &testsuite_params;
11647 uint8_t sched_id = ts_params->valid_devs[0];
11648 uint32_t nb_devs, i, nb_devs_attached = 0;
11650 char vdev_name[32];
11652 /* create 2 AESNI_MB if necessary */
11653 nb_devs = rte_cryptodev_device_count_by_driver(
11654 rte_cryptodev_driver_id_get(
11655 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11657 for (i = nb_devs; i < 2; i++) {
11658 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11659 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11661 ret = rte_vdev_init(vdev_name, NULL);
11663 TEST_ASSERT(ret == 0,
11664 "Failed to create instance %u of"
11666 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11670 /* attach 2 AESNI_MB cdevs */
11671 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11673 struct rte_cryptodev_info info;
11674 unsigned int session_size;
11676 rte_cryptodev_info_get(i, &info);
11677 if (info.driver_id != rte_cryptodev_driver_id_get(
11678 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11681 session_size = rte_cryptodev_sym_get_private_session_size(i);
11683 * Create the session mempool again, since now there are new devices
11684 * to use the mempool.
11686 if (ts_params->session_mpool) {
11687 rte_mempool_free(ts_params->session_mpool);
11688 ts_params->session_mpool = NULL;
11690 if (ts_params->session_priv_mpool) {
11691 rte_mempool_free(ts_params->session_priv_mpool);
11692 ts_params->session_priv_mpool = NULL;
11695 if (info.sym.max_nb_sessions != 0 &&
11696 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11697 RTE_LOG(ERR, USER1,
11698 "Device does not support "
11699 "at least %u sessions\n",
11701 return TEST_FAILED;
11704 * Create mempool with maximum number of sessions,
11705 * to include the session headers
11707 if (ts_params->session_mpool == NULL) {
11708 ts_params->session_mpool =
11709 rte_cryptodev_sym_session_pool_create(
11711 MAX_NB_SESSIONS, 0, 0, 0,
11713 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11714 "session mempool allocation failed");
11718 * Create mempool with maximum number of sessions,
11719 * to include device specific session private data
11721 if (ts_params->session_priv_mpool == NULL) {
11722 ts_params->session_priv_mpool = rte_mempool_create(
11723 "test_sess_mp_priv",
11726 0, 0, NULL, NULL, NULL,
11727 NULL, SOCKET_ID_ANY,
11730 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
11731 "session mempool allocation failed");
11734 ts_params->qp_conf.mp_session = ts_params->session_mpool;
11735 ts_params->qp_conf.mp_session_private =
11736 ts_params->session_priv_mpool;
11738 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
11741 TEST_ASSERT(ret == 0,
11742 "Failed to attach device %u of pmd : %s", i,
11743 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11745 aesni_ids[nb_devs_attached] = (uint8_t)i;
11747 nb_devs_attached++;
11754 test_scheduler_detach_slave_op(void)
11756 struct crypto_testsuite_params *ts_params = &testsuite_params;
11757 uint8_t sched_id = ts_params->valid_devs[0];
11761 for (i = 0; i < 2; i++) {
11762 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
11764 TEST_ASSERT(ret == 0,
11765 "Failed to detach device %u", aesni_ids[i]);
11772 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
11774 struct crypto_testsuite_params *ts_params = &testsuite_params;
11775 uint8_t sched_id = ts_params->valid_devs[0];
11777 return rte_cryptodev_scheduler_mode_set(sched_id,
11782 test_scheduler_mode_roundrobin_op(void)
11784 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
11785 0, "Failed to set roundrobin mode");
11791 test_scheduler_mode_multicore_op(void)
11793 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
11794 0, "Failed to set multicore mode");
11800 test_scheduler_mode_failover_op(void)
11802 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
11803 0, "Failed to set failover mode");
11809 test_scheduler_mode_pkt_size_distr_op(void)
11811 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
11812 0, "Failed to set pktsize mode");
11817 static struct unit_test_suite cryptodev_scheduler_testsuite = {
11818 .suite_name = "Crypto Device Scheduler Unit Test Suite",
11819 .setup = testsuite_setup,
11820 .teardown = testsuite_teardown,
11821 .unit_test_cases = {
11823 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11824 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
11825 TEST_CASE_ST(ut_setup, ut_teardown,
11826 test_AES_chain_scheduler_all),
11827 TEST_CASE_ST(ut_setup, ut_teardown,
11828 test_AES_cipheronly_scheduler_all),
11829 TEST_CASE_ST(ut_setup, ut_teardown,
11830 test_authonly_scheduler_all),
11831 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11834 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11835 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
11836 TEST_CASE_ST(ut_setup, ut_teardown,
11837 test_AES_chain_scheduler_all),
11838 TEST_CASE_ST(ut_setup, ut_teardown,
11839 test_AES_cipheronly_scheduler_all),
11840 TEST_CASE_ST(ut_setup, ut_teardown,
11841 test_authonly_scheduler_all),
11842 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11845 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11846 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
11847 TEST_CASE_ST(ut_setup, ut_teardown,
11848 test_AES_chain_scheduler_all),
11849 TEST_CASE_ST(ut_setup, ut_teardown,
11850 test_AES_cipheronly_scheduler_all),
11851 TEST_CASE_ST(ut_setup, ut_teardown,
11852 test_authonly_scheduler_all),
11853 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11856 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
11857 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
11858 TEST_CASE_ST(ut_setup, ut_teardown,
11859 test_AES_chain_scheduler_all),
11860 TEST_CASE_ST(ut_setup, ut_teardown,
11861 test_AES_cipheronly_scheduler_all),
11862 TEST_CASE_ST(ut_setup, ut_teardown,
11863 test_authonly_scheduler_all),
11864 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
11866 TEST_CASES_END() /**< NULL terminate unit test array */
11870 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
11872 static struct unit_test_suite cryptodev_qat_testsuite = {
11873 .suite_name = "Crypto QAT Unit Test Suite",
11874 .setup = testsuite_setup,
11875 .teardown = testsuite_teardown,
11876 .unit_test_cases = {
11877 TEST_CASE_ST(ut_setup, ut_teardown,
11878 test_device_configure_invalid_dev_id),
11879 TEST_CASE_ST(ut_setup, ut_teardown,
11880 test_device_configure_invalid_queue_pair_ids),
11881 TEST_CASE_ST(ut_setup, ut_teardown,
11882 test_queue_pair_descriptor_setup),
11883 TEST_CASE_ST(ut_setup, ut_teardown,
11884 test_multi_session),
11886 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
11887 TEST_CASE_ST(ut_setup, ut_teardown,
11888 test_AES_cipheronly_qat_all),
11889 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
11890 TEST_CASE_ST(ut_setup, ut_teardown,
11891 test_3DES_cipheronly_qat_all),
11892 TEST_CASE_ST(ut_setup, ut_teardown,
11893 test_DES_cipheronly_qat_all),
11894 TEST_CASE_ST(ut_setup, ut_teardown,
11895 test_AES_docsis_qat_all),
11896 TEST_CASE_ST(ut_setup, ut_teardown,
11897 test_DES_docsis_qat_all),
11898 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
11899 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
11901 /** AES CCM Authenticated Encryption 128 bits key */
11902 TEST_CASE_ST(ut_setup, ut_teardown,
11903 test_AES_CCM_authenticated_encryption_test_case_128_1),
11904 TEST_CASE_ST(ut_setup, ut_teardown,
11905 test_AES_CCM_authenticated_encryption_test_case_128_2),
11906 TEST_CASE_ST(ut_setup, ut_teardown,
11907 test_AES_CCM_authenticated_encryption_test_case_128_3),
11909 /** AES CCM Authenticated Decryption 128 bits key*/
11910 TEST_CASE_ST(ut_setup, ut_teardown,
11911 test_AES_CCM_authenticated_decryption_test_case_128_1),
11912 TEST_CASE_ST(ut_setup, ut_teardown,
11913 test_AES_CCM_authenticated_decryption_test_case_128_2),
11914 TEST_CASE_ST(ut_setup, ut_teardown,
11915 test_AES_CCM_authenticated_decryption_test_case_128_3),
11917 /** AES GCM Authenticated Encryption */
11918 TEST_CASE_ST(ut_setup, ut_teardown,
11919 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
11920 TEST_CASE_ST(ut_setup, ut_teardown,
11921 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
11922 TEST_CASE_ST(ut_setup, ut_teardown,
11923 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
11924 TEST_CASE_ST(ut_setup, ut_teardown,
11925 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
11926 TEST_CASE_ST(ut_setup, ut_teardown,
11927 test_AES_GCM_authenticated_encryption_test_case_1),
11928 TEST_CASE_ST(ut_setup, ut_teardown,
11929 test_AES_GCM_authenticated_encryption_test_case_2),
11930 TEST_CASE_ST(ut_setup, ut_teardown,
11931 test_AES_GCM_authenticated_encryption_test_case_3),
11932 TEST_CASE_ST(ut_setup, ut_teardown,
11933 test_AES_GCM_authenticated_encryption_test_case_4),
11934 TEST_CASE_ST(ut_setup, ut_teardown,
11935 test_AES_GCM_authenticated_encryption_test_case_5),
11936 TEST_CASE_ST(ut_setup, ut_teardown,
11937 test_AES_GCM_authenticated_encryption_test_case_6),
11938 TEST_CASE_ST(ut_setup, ut_teardown,
11939 test_AES_GCM_authenticated_encryption_test_case_7),
11940 TEST_CASE_ST(ut_setup, ut_teardown,
11941 test_AES_GCM_authenticated_encryption_test_case_8),
11943 /** AES GCM Authenticated Decryption */
11944 TEST_CASE_ST(ut_setup, ut_teardown,
11945 test_AES_GCM_authenticated_decryption_test_case_1),
11946 TEST_CASE_ST(ut_setup, ut_teardown,
11947 test_AES_GCM_authenticated_decryption_test_case_2),
11948 TEST_CASE_ST(ut_setup, ut_teardown,
11949 test_AES_GCM_authenticated_decryption_test_case_3),
11950 TEST_CASE_ST(ut_setup, ut_teardown,
11951 test_AES_GCM_authenticated_decryption_test_case_4),
11952 TEST_CASE_ST(ut_setup, ut_teardown,
11953 test_AES_GCM_authenticated_decryption_test_case_5),
11954 TEST_CASE_ST(ut_setup, ut_teardown,
11955 test_AES_GCM_authenticated_decryption_test_case_6),
11956 TEST_CASE_ST(ut_setup, ut_teardown,
11957 test_AES_GCM_authenticated_decryption_test_case_7),
11958 TEST_CASE_ST(ut_setup, ut_teardown,
11959 test_AES_GCM_authenticated_decryption_test_case_8),
11961 /** AES GCM Authenticated Encryption 192 bits key */
11962 TEST_CASE_ST(ut_setup, ut_teardown,
11963 test_AES_GCM_auth_encryption_test_case_192_1),
11964 TEST_CASE_ST(ut_setup, ut_teardown,
11965 test_AES_GCM_auth_encryption_test_case_192_2),
11966 TEST_CASE_ST(ut_setup, ut_teardown,
11967 test_AES_GCM_auth_encryption_test_case_192_3),
11968 TEST_CASE_ST(ut_setup, ut_teardown,
11969 test_AES_GCM_auth_encryption_test_case_192_4),
11970 TEST_CASE_ST(ut_setup, ut_teardown,
11971 test_AES_GCM_auth_encryption_test_case_192_5),
11972 TEST_CASE_ST(ut_setup, ut_teardown,
11973 test_AES_GCM_auth_encryption_test_case_192_6),
11974 TEST_CASE_ST(ut_setup, ut_teardown,
11975 test_AES_GCM_auth_encryption_test_case_192_7),
11977 /** AES GCM Authenticated Decryption 192 bits key */
11978 TEST_CASE_ST(ut_setup, ut_teardown,
11979 test_AES_GCM_auth_decryption_test_case_192_1),
11980 TEST_CASE_ST(ut_setup, ut_teardown,
11981 test_AES_GCM_auth_decryption_test_case_192_2),
11982 TEST_CASE_ST(ut_setup, ut_teardown,
11983 test_AES_GCM_auth_decryption_test_case_192_3),
11984 TEST_CASE_ST(ut_setup, ut_teardown,
11985 test_AES_GCM_auth_decryption_test_case_192_4),
11986 TEST_CASE_ST(ut_setup, ut_teardown,
11987 test_AES_GCM_auth_decryption_test_case_192_5),
11988 TEST_CASE_ST(ut_setup, ut_teardown,
11989 test_AES_GCM_auth_decryption_test_case_192_6),
11990 TEST_CASE_ST(ut_setup, ut_teardown,
11991 test_AES_GCM_auth_decryption_test_case_192_7),
11993 /** AES GCM Authenticated Encryption 256 bits key */
11994 TEST_CASE_ST(ut_setup, ut_teardown,
11995 test_AES_GCM_auth_encryption_test_case_256_1),
11996 TEST_CASE_ST(ut_setup, ut_teardown,
11997 test_AES_GCM_auth_encryption_test_case_256_2),
11998 TEST_CASE_ST(ut_setup, ut_teardown,
11999 test_AES_GCM_auth_encryption_test_case_256_3),
12000 TEST_CASE_ST(ut_setup, ut_teardown,
12001 test_AES_GCM_auth_encryption_test_case_256_4),
12002 TEST_CASE_ST(ut_setup, ut_teardown,
12003 test_AES_GCM_auth_encryption_test_case_256_5),
12004 TEST_CASE_ST(ut_setup, ut_teardown,
12005 test_AES_GCM_auth_encryption_test_case_256_6),
12006 TEST_CASE_ST(ut_setup, ut_teardown,
12007 test_AES_GCM_auth_encryption_test_case_256_7),
12009 /** AES GCM Authenticated Decryption 256 bits key */
12010 TEST_CASE_ST(ut_setup, ut_teardown,
12011 test_AES_GCM_auth_decryption_test_case_256_1),
12012 TEST_CASE_ST(ut_setup, ut_teardown,
12013 test_AES_GCM_auth_decryption_test_case_256_2),
12014 TEST_CASE_ST(ut_setup, ut_teardown,
12015 test_AES_GCM_auth_decryption_test_case_256_3),
12016 TEST_CASE_ST(ut_setup, ut_teardown,
12017 test_AES_GCM_auth_decryption_test_case_256_4),
12018 TEST_CASE_ST(ut_setup, ut_teardown,
12019 test_AES_GCM_auth_decryption_test_case_256_5),
12020 TEST_CASE_ST(ut_setup, ut_teardown,
12021 test_AES_GCM_auth_decryption_test_case_256_6),
12022 TEST_CASE_ST(ut_setup, ut_teardown,
12023 test_AES_GCM_auth_decryption_test_case_256_7),
12025 /** AES GMAC Authentication */
12026 TEST_CASE_ST(ut_setup, ut_teardown,
12027 test_AES_GMAC_authentication_test_case_1),
12028 TEST_CASE_ST(ut_setup, ut_teardown,
12029 test_AES_GMAC_authentication_verify_test_case_1),
12030 TEST_CASE_ST(ut_setup, ut_teardown,
12031 test_AES_GMAC_authentication_test_case_2),
12032 TEST_CASE_ST(ut_setup, ut_teardown,
12033 test_AES_GMAC_authentication_verify_test_case_2),
12034 TEST_CASE_ST(ut_setup, ut_teardown,
12035 test_AES_GMAC_authentication_test_case_3),
12036 TEST_CASE_ST(ut_setup, ut_teardown,
12037 test_AES_GMAC_authentication_verify_test_case_3),
12039 /** SNOW 3G encrypt only (UEA2) */
12040 TEST_CASE_ST(ut_setup, ut_teardown,
12041 test_snow3g_encryption_test_case_1),
12042 TEST_CASE_ST(ut_setup, ut_teardown,
12043 test_snow3g_encryption_test_case_2),
12044 TEST_CASE_ST(ut_setup, ut_teardown,
12045 test_snow3g_encryption_test_case_3),
12046 TEST_CASE_ST(ut_setup, ut_teardown,
12047 test_snow3g_encryption_test_case_4),
12048 TEST_CASE_ST(ut_setup, ut_teardown,
12049 test_snow3g_encryption_test_case_5),
12051 TEST_CASE_ST(ut_setup, ut_teardown,
12052 test_snow3g_encryption_test_case_1_oop),
12053 TEST_CASE_ST(ut_setup, ut_teardown,
12054 test_snow3g_decryption_test_case_1_oop),
12056 /** SNOW 3G generate auth, then encrypt (UEA2) */
12057 TEST_CASE_ST(ut_setup, ut_teardown,
12058 test_snow3g_auth_cipher_test_case_1),
12059 TEST_CASE_ST(ut_setup, ut_teardown,
12060 test_snow3g_auth_cipher_test_case_2),
12061 TEST_CASE_ST(ut_setup, ut_teardown,
12062 test_snow3g_auth_cipher_test_case_2_oop),
12063 TEST_CASE_ST(ut_setup, ut_teardown,
12064 test_snow3g_auth_cipher_part_digest_enc),
12065 TEST_CASE_ST(ut_setup, ut_teardown,
12066 test_snow3g_auth_cipher_part_digest_enc_oop),
12067 TEST_CASE_ST(ut_setup, ut_teardown,
12068 test_snow3g_auth_cipher_test_case_3_sgl),
12069 TEST_CASE_ST(ut_setup, ut_teardown,
12070 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12071 TEST_CASE_ST(ut_setup, ut_teardown,
12072 test_snow3g_auth_cipher_part_digest_enc_sgl),
12073 TEST_CASE_ST(ut_setup, ut_teardown,
12074 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12076 /** SNOW 3G decrypt (UEA2), then verify auth */
12077 TEST_CASE_ST(ut_setup, ut_teardown,
12078 test_snow3g_auth_cipher_verify_test_case_1),
12079 TEST_CASE_ST(ut_setup, ut_teardown,
12080 test_snow3g_auth_cipher_verify_test_case_2),
12081 TEST_CASE_ST(ut_setup, ut_teardown,
12082 test_snow3g_auth_cipher_verify_test_case_2_oop),
12083 TEST_CASE_ST(ut_setup, ut_teardown,
12084 test_snow3g_auth_cipher_verify_part_digest_enc),
12085 TEST_CASE_ST(ut_setup, ut_teardown,
12086 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12087 TEST_CASE_ST(ut_setup, ut_teardown,
12088 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12089 TEST_CASE_ST(ut_setup, ut_teardown,
12090 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12091 TEST_CASE_ST(ut_setup, ut_teardown,
12092 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12093 TEST_CASE_ST(ut_setup, ut_teardown,
12094 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12096 /** SNOW 3G decrypt only (UEA2) */
12097 TEST_CASE_ST(ut_setup, ut_teardown,
12098 test_snow3g_decryption_test_case_1),
12099 TEST_CASE_ST(ut_setup, ut_teardown,
12100 test_snow3g_decryption_test_case_2),
12101 TEST_CASE_ST(ut_setup, ut_teardown,
12102 test_snow3g_decryption_test_case_3),
12103 TEST_CASE_ST(ut_setup, ut_teardown,
12104 test_snow3g_decryption_test_case_4),
12105 TEST_CASE_ST(ut_setup, ut_teardown,
12106 test_snow3g_decryption_test_case_5),
12107 TEST_CASE_ST(ut_setup, ut_teardown,
12108 test_snow3g_decryption_with_digest_test_case_1),
12109 TEST_CASE_ST(ut_setup, ut_teardown,
12110 test_snow3g_hash_generate_test_case_1),
12111 TEST_CASE_ST(ut_setup, ut_teardown,
12112 test_snow3g_hash_generate_test_case_2),
12113 TEST_CASE_ST(ut_setup, ut_teardown,
12114 test_snow3g_hash_generate_test_case_3),
12115 TEST_CASE_ST(ut_setup, ut_teardown,
12116 test_snow3g_hash_verify_test_case_1),
12117 TEST_CASE_ST(ut_setup, ut_teardown,
12118 test_snow3g_hash_verify_test_case_2),
12119 TEST_CASE_ST(ut_setup, ut_teardown,
12120 test_snow3g_hash_verify_test_case_3),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_snow3g_cipher_auth_test_case_1),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_snow3g_auth_cipher_with_digest_test_case_1),
12126 /** ZUC encrypt only (EEA3) */
12127 TEST_CASE_ST(ut_setup, ut_teardown,
12128 test_zuc_encryption_test_case_1),
12129 TEST_CASE_ST(ut_setup, ut_teardown,
12130 test_zuc_encryption_test_case_2),
12131 TEST_CASE_ST(ut_setup, ut_teardown,
12132 test_zuc_encryption_test_case_3),
12133 TEST_CASE_ST(ut_setup, ut_teardown,
12134 test_zuc_encryption_test_case_4),
12135 TEST_CASE_ST(ut_setup, ut_teardown,
12136 test_zuc_encryption_test_case_5),
12138 /** ZUC authenticate (EIA3) */
12139 TEST_CASE_ST(ut_setup, ut_teardown,
12140 test_zuc_hash_generate_test_case_6),
12141 TEST_CASE_ST(ut_setup, ut_teardown,
12142 test_zuc_hash_generate_test_case_7),
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 test_zuc_hash_generate_test_case_8),
12146 /** ZUC alg-chain (EEA3/EIA3) */
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_zuc_cipher_auth_test_case_1),
12149 TEST_CASE_ST(ut_setup, ut_teardown,
12150 test_zuc_cipher_auth_test_case_2),
12152 /** ZUC generate auth, then encrypt (EEA3) */
12153 TEST_CASE_ST(ut_setup, ut_teardown,
12154 test_zuc_auth_cipher_test_case_1),
12155 TEST_CASE_ST(ut_setup, ut_teardown,
12156 test_zuc_auth_cipher_test_case_1_oop),
12157 TEST_CASE_ST(ut_setup, ut_teardown,
12158 test_zuc_auth_cipher_test_case_1_sgl),
12159 TEST_CASE_ST(ut_setup, ut_teardown,
12160 test_zuc_auth_cipher_test_case_1_oop_sgl),
12162 /** ZUC decrypt (EEA3), then verify auth */
12163 TEST_CASE_ST(ut_setup, ut_teardown,
12164 test_zuc_auth_cipher_verify_test_case_1),
12165 TEST_CASE_ST(ut_setup, ut_teardown,
12166 test_zuc_auth_cipher_verify_test_case_1_oop),
12167 TEST_CASE_ST(ut_setup, ut_teardown,
12168 test_zuc_auth_cipher_verify_test_case_1_sgl),
12169 TEST_CASE_ST(ut_setup, ut_teardown,
12170 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12172 /** HMAC_MD5 Authentication */
12173 TEST_CASE_ST(ut_setup, ut_teardown,
12174 test_MD5_HMAC_generate_case_1),
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 test_MD5_HMAC_verify_case_1),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 test_MD5_HMAC_generate_case_2),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_MD5_HMAC_verify_case_2),
12182 /** NULL algo tests done in chain_all,
12183 * cipheronly and authonly suites
12186 /** KASUMI tests */
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_kasumi_hash_generate_test_case_1),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_kasumi_hash_generate_test_case_2),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_kasumi_hash_generate_test_case_3),
12193 TEST_CASE_ST(ut_setup, ut_teardown,
12194 test_kasumi_hash_generate_test_case_4),
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_kasumi_hash_generate_test_case_5),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_kasumi_hash_generate_test_case_6),
12200 TEST_CASE_ST(ut_setup, ut_teardown,
12201 test_kasumi_hash_verify_test_case_1),
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_kasumi_hash_verify_test_case_2),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_kasumi_hash_verify_test_case_3),
12206 TEST_CASE_ST(ut_setup, ut_teardown,
12207 test_kasumi_hash_verify_test_case_4),
12208 TEST_CASE_ST(ut_setup, ut_teardown,
12209 test_kasumi_hash_verify_test_case_5),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_kasumi_encryption_test_case_1),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_kasumi_encryption_test_case_3),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_kasumi_cipher_auth_test_case_1),
12218 /** KASUMI generate auth, then encrypt (F8) */
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_kasumi_auth_cipher_test_case_1),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_kasumi_auth_cipher_test_case_2),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_kasumi_auth_cipher_test_case_2_oop),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_kasumi_auth_cipher_test_case_2_sgl),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12230 /** KASUMI decrypt (F8), then verify auth */
12231 TEST_CASE_ST(ut_setup, ut_teardown,
12232 test_kasumi_auth_cipher_verify_test_case_1),
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_kasumi_auth_cipher_verify_test_case_2),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_kasumi_auth_cipher_verify_test_case_2_oop),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12242 /** Negative tests */
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12249 TEST_CASE_ST(ut_setup, ut_teardown,
12250 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12265 TEST_CASE_ST(ut_setup, ut_teardown,
12266 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 authentication_verify_AES128_GMAC_fail_data_corrupt),
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12280 /** Mixed CIPHER + HASH algorithms */
12281 /** AUTH AES CMAC + CIPHER AES CTR */
12282 TEST_CASE_ST(ut_setup, ut_teardown,
12283 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12284 TEST_CASE_ST(ut_setup, ut_teardown,
12285 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12286 TEST_CASE_ST(ut_setup, ut_teardown,
12287 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12288 TEST_CASE_ST(ut_setup, ut_teardown,
12289 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12290 TEST_CASE_ST(ut_setup, ut_teardown,
12291 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12292 TEST_CASE_ST(ut_setup, ut_teardown,
12293 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12294 TEST_CASE_ST(ut_setup, ut_teardown,
12295 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12296 TEST_CASE_ST(ut_setup, ut_teardown,
12297 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12299 TEST_CASES_END() /**< NULL terminate unit test array */
12303 static struct unit_test_suite cryptodev_virtio_testsuite = {
12304 .suite_name = "Crypto VIRTIO Unit Test Suite",
12305 .setup = testsuite_setup,
12306 .teardown = testsuite_teardown,
12307 .unit_test_cases = {
12308 TEST_CASE_ST(ut_setup, ut_teardown,
12309 test_AES_cipheronly_virtio_all),
12311 TEST_CASES_END() /**< NULL terminate unit test array */
12315 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
12316 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
12317 .setup = testsuite_setup,
12318 .teardown = testsuite_teardown,
12319 .unit_test_cases = {
12320 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_AES_GCM_authenticated_encryption_test_case_1),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_AES_GCM_authenticated_encryption_test_case_2),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_AES_GCM_authenticated_encryption_test_case_3),
12327 TEST_CASE_ST(ut_setup, ut_teardown,
12328 test_AES_GCM_authenticated_encryption_test_case_4),
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_AES_GCM_authenticated_encryption_test_case_5),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_AES_GCM_authenticated_encryption_test_case_6),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_AES_GCM_authenticated_encryption_test_case_7),
12336 /** AES GCM Authenticated Decryption */
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_AES_GCM_authenticated_decryption_test_case_1),
12339 TEST_CASE_ST(ut_setup, ut_teardown,
12340 test_AES_GCM_authenticated_decryption_test_case_2),
12341 TEST_CASE_ST(ut_setup, ut_teardown,
12342 test_AES_GCM_authenticated_decryption_test_case_3),
12343 TEST_CASE_ST(ut_setup, ut_teardown,
12344 test_AES_GCM_authenticated_decryption_test_case_4),
12345 TEST_CASE_ST(ut_setup, ut_teardown,
12346 test_AES_GCM_authenticated_decryption_test_case_5),
12347 TEST_CASE_ST(ut_setup, ut_teardown,
12348 test_AES_GCM_authenticated_decryption_test_case_6),
12349 TEST_CASE_ST(ut_setup, ut_teardown,
12350 test_AES_GCM_authenticated_decryption_test_case_7),
12352 /** AES GCM Authenticated Encryption 192 bits key */
12353 TEST_CASE_ST(ut_setup, ut_teardown,
12354 test_AES_GCM_auth_encryption_test_case_192_1),
12355 TEST_CASE_ST(ut_setup, ut_teardown,
12356 test_AES_GCM_auth_encryption_test_case_192_2),
12357 TEST_CASE_ST(ut_setup, ut_teardown,
12358 test_AES_GCM_auth_encryption_test_case_192_3),
12359 TEST_CASE_ST(ut_setup, ut_teardown,
12360 test_AES_GCM_auth_encryption_test_case_192_4),
12361 TEST_CASE_ST(ut_setup, ut_teardown,
12362 test_AES_GCM_auth_encryption_test_case_192_5),
12363 TEST_CASE_ST(ut_setup, ut_teardown,
12364 test_AES_GCM_auth_encryption_test_case_192_6),
12365 TEST_CASE_ST(ut_setup, ut_teardown,
12366 test_AES_GCM_auth_encryption_test_case_192_7),
12368 /** AES GCM Authenticated Decryption 192 bits key */
12369 TEST_CASE_ST(ut_setup, ut_teardown,
12370 test_AES_GCM_auth_decryption_test_case_192_1),
12371 TEST_CASE_ST(ut_setup, ut_teardown,
12372 test_AES_GCM_auth_decryption_test_case_192_2),
12373 TEST_CASE_ST(ut_setup, ut_teardown,
12374 test_AES_GCM_auth_decryption_test_case_192_3),
12375 TEST_CASE_ST(ut_setup, ut_teardown,
12376 test_AES_GCM_auth_decryption_test_case_192_4),
12377 TEST_CASE_ST(ut_setup, ut_teardown,
12378 test_AES_GCM_auth_decryption_test_case_192_5),
12379 TEST_CASE_ST(ut_setup, ut_teardown,
12380 test_AES_GCM_auth_decryption_test_case_192_6),
12381 TEST_CASE_ST(ut_setup, ut_teardown,
12382 test_AES_GCM_auth_decryption_test_case_192_7),
12384 /** AES GCM Authenticated Encryption 256 bits key */
12385 TEST_CASE_ST(ut_setup, ut_teardown,
12386 test_AES_GCM_auth_encryption_test_case_256_1),
12387 TEST_CASE_ST(ut_setup, ut_teardown,
12388 test_AES_GCM_auth_encryption_test_case_256_2),
12389 TEST_CASE_ST(ut_setup, ut_teardown,
12390 test_AES_GCM_auth_encryption_test_case_256_3),
12391 TEST_CASE_ST(ut_setup, ut_teardown,
12392 test_AES_GCM_auth_encryption_test_case_256_4),
12393 TEST_CASE_ST(ut_setup, ut_teardown,
12394 test_AES_GCM_auth_encryption_test_case_256_5),
12395 TEST_CASE_ST(ut_setup, ut_teardown,
12396 test_AES_GCM_auth_encryption_test_case_256_6),
12397 TEST_CASE_ST(ut_setup, ut_teardown,
12398 test_AES_GCM_auth_encryption_test_case_256_7),
12400 /** AES GCM Authenticated Decryption 256 bits key */
12401 TEST_CASE_ST(ut_setup, ut_teardown,
12402 test_AES_GCM_auth_decryption_test_case_256_1),
12403 TEST_CASE_ST(ut_setup, ut_teardown,
12404 test_AES_GCM_auth_decryption_test_case_256_2),
12405 TEST_CASE_ST(ut_setup, ut_teardown,
12406 test_AES_GCM_auth_decryption_test_case_256_3),
12407 TEST_CASE_ST(ut_setup, ut_teardown,
12408 test_AES_GCM_auth_decryption_test_case_256_4),
12409 TEST_CASE_ST(ut_setup, ut_teardown,
12410 test_AES_GCM_auth_decryption_test_case_256_5),
12411 TEST_CASE_ST(ut_setup, ut_teardown,
12412 test_AES_GCM_auth_decryption_test_case_256_6),
12413 TEST_CASE_ST(ut_setup, ut_teardown,
12414 test_AES_GCM_auth_decryption_test_case_256_7),
12416 /** AES GCM Authenticated Encryption big aad size */
12417 TEST_CASE_ST(ut_setup, ut_teardown,
12418 test_AES_GCM_auth_encryption_test_case_aad_1),
12419 TEST_CASE_ST(ut_setup, ut_teardown,
12420 test_AES_GCM_auth_encryption_test_case_aad_2),
12422 /** AES GCM Authenticated Decryption big aad size */
12423 TEST_CASE_ST(ut_setup, ut_teardown,
12424 test_AES_GCM_auth_decryption_test_case_aad_1),
12425 TEST_CASE_ST(ut_setup, ut_teardown,
12426 test_AES_GCM_auth_decryption_test_case_aad_2),
12428 /** Session-less tests */
12429 TEST_CASE_ST(ut_setup, ut_teardown,
12430 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12431 TEST_CASE_ST(ut_setup, ut_teardown,
12432 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12434 /** AES GMAC Authentication */
12435 TEST_CASE_ST(ut_setup, ut_teardown,
12436 test_AES_GMAC_authentication_test_case_1),
12437 TEST_CASE_ST(ut_setup, ut_teardown,
12438 test_AES_GMAC_authentication_verify_test_case_1),
12439 TEST_CASE_ST(ut_setup, ut_teardown,
12440 test_AES_GMAC_authentication_test_case_2),
12441 TEST_CASE_ST(ut_setup, ut_teardown,
12442 test_AES_GMAC_authentication_verify_test_case_2),
12443 TEST_CASE_ST(ut_setup, ut_teardown,
12444 test_AES_GMAC_authentication_test_case_3),
12445 TEST_CASE_ST(ut_setup, ut_teardown,
12446 test_AES_GMAC_authentication_verify_test_case_3),
12447 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12449 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12450 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12451 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12452 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12453 TEST_CASE_ST(ut_setup, ut_teardown,
12454 test_DES_cipheronly_mb_all),
12455 TEST_CASE_ST(ut_setup, ut_teardown,
12456 test_DES_docsis_mb_all),
12457 TEST_CASE_ST(ut_setup, ut_teardown,
12458 test_3DES_cipheronly_mb_all),
12459 TEST_CASE_ST(ut_setup, ut_teardown,
12460 test_AES_CCM_authenticated_encryption_test_case_128_1),
12461 TEST_CASE_ST(ut_setup, ut_teardown,
12462 test_AES_CCM_authenticated_decryption_test_case_128_1),
12463 TEST_CASE_ST(ut_setup, ut_teardown,
12464 test_AES_CCM_authenticated_encryption_test_case_128_2),
12465 TEST_CASE_ST(ut_setup, ut_teardown,
12466 test_AES_CCM_authenticated_decryption_test_case_128_2),
12467 TEST_CASE_ST(ut_setup, ut_teardown,
12468 test_AES_CCM_authenticated_encryption_test_case_128_3),
12469 TEST_CASE_ST(ut_setup, ut_teardown,
12470 test_AES_CCM_authenticated_decryption_test_case_128_3),
12472 TEST_CASES_END() /**< NULL terminate unit test array */
12476 static struct unit_test_suite cryptodev_openssl_testsuite = {
12477 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
12478 .setup = testsuite_setup,
12479 .teardown = testsuite_teardown,
12480 .unit_test_cases = {
12481 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_multi_session_random_usage),
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_AES_chain_openssl_all),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_AES_cipheronly_openssl_all),
12488 TEST_CASE_ST(ut_setup, ut_teardown,
12489 test_3DES_chain_openssl_all),
12490 TEST_CASE_ST(ut_setup, ut_teardown,
12491 test_3DES_cipheronly_openssl_all),
12492 TEST_CASE_ST(ut_setup, ut_teardown,
12493 test_DES_cipheronly_openssl_all),
12494 TEST_CASE_ST(ut_setup, ut_teardown,
12495 test_DES_docsis_openssl_all),
12496 TEST_CASE_ST(ut_setup, ut_teardown,
12497 test_authonly_openssl_all),
12499 /** AES GCM Authenticated Encryption */
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_AES_GCM_authenticated_encryption_test_case_1),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_AES_GCM_authenticated_encryption_test_case_2),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_AES_GCM_authenticated_encryption_test_case_3),
12506 TEST_CASE_ST(ut_setup, ut_teardown,
12507 test_AES_GCM_authenticated_encryption_test_case_4),
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_AES_GCM_authenticated_encryption_test_case_5),
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_AES_GCM_authenticated_encryption_test_case_6),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_AES_GCM_authenticated_encryption_test_case_7),
12515 /** AES GCM Authenticated Decryption */
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_AES_GCM_authenticated_decryption_test_case_1),
12518 TEST_CASE_ST(ut_setup, ut_teardown,
12519 test_AES_GCM_authenticated_decryption_test_case_2),
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_AES_GCM_authenticated_decryption_test_case_3),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_AES_GCM_authenticated_decryption_test_case_4),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_AES_GCM_authenticated_decryption_test_case_5),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_AES_GCM_authenticated_decryption_test_case_6),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_AES_GCM_authenticated_decryption_test_case_7),
12532 /** AES GCM Authenticated Encryption 192 bits key */
12533 TEST_CASE_ST(ut_setup, ut_teardown,
12534 test_AES_GCM_auth_encryption_test_case_192_1),
12535 TEST_CASE_ST(ut_setup, ut_teardown,
12536 test_AES_GCM_auth_encryption_test_case_192_2),
12537 TEST_CASE_ST(ut_setup, ut_teardown,
12538 test_AES_GCM_auth_encryption_test_case_192_3),
12539 TEST_CASE_ST(ut_setup, ut_teardown,
12540 test_AES_GCM_auth_encryption_test_case_192_4),
12541 TEST_CASE_ST(ut_setup, ut_teardown,
12542 test_AES_GCM_auth_encryption_test_case_192_5),
12543 TEST_CASE_ST(ut_setup, ut_teardown,
12544 test_AES_GCM_auth_encryption_test_case_192_6),
12545 TEST_CASE_ST(ut_setup, ut_teardown,
12546 test_AES_GCM_auth_encryption_test_case_192_7),
12548 /** AES GCM Authenticated Decryption 192 bits key */
12549 TEST_CASE_ST(ut_setup, ut_teardown,
12550 test_AES_GCM_auth_decryption_test_case_192_1),
12551 TEST_CASE_ST(ut_setup, ut_teardown,
12552 test_AES_GCM_auth_decryption_test_case_192_2),
12553 TEST_CASE_ST(ut_setup, ut_teardown,
12554 test_AES_GCM_auth_decryption_test_case_192_3),
12555 TEST_CASE_ST(ut_setup, ut_teardown,
12556 test_AES_GCM_auth_decryption_test_case_192_4),
12557 TEST_CASE_ST(ut_setup, ut_teardown,
12558 test_AES_GCM_auth_decryption_test_case_192_5),
12559 TEST_CASE_ST(ut_setup, ut_teardown,
12560 test_AES_GCM_auth_decryption_test_case_192_6),
12561 TEST_CASE_ST(ut_setup, ut_teardown,
12562 test_AES_GCM_auth_decryption_test_case_192_7),
12564 /** AES GCM Authenticated Encryption 256 bits key */
12565 TEST_CASE_ST(ut_setup, ut_teardown,
12566 test_AES_GCM_auth_encryption_test_case_256_1),
12567 TEST_CASE_ST(ut_setup, ut_teardown,
12568 test_AES_GCM_auth_encryption_test_case_256_2),
12569 TEST_CASE_ST(ut_setup, ut_teardown,
12570 test_AES_GCM_auth_encryption_test_case_256_3),
12571 TEST_CASE_ST(ut_setup, ut_teardown,
12572 test_AES_GCM_auth_encryption_test_case_256_4),
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 test_AES_GCM_auth_encryption_test_case_256_5),
12575 TEST_CASE_ST(ut_setup, ut_teardown,
12576 test_AES_GCM_auth_encryption_test_case_256_6),
12577 TEST_CASE_ST(ut_setup, ut_teardown,
12578 test_AES_GCM_auth_encryption_test_case_256_7),
12580 /** AES GCM Authenticated Decryption 256 bits key */
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_AES_GCM_auth_decryption_test_case_256_1),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_AES_GCM_auth_decryption_test_case_256_2),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_AES_GCM_auth_decryption_test_case_256_3),
12587 TEST_CASE_ST(ut_setup, ut_teardown,
12588 test_AES_GCM_auth_decryption_test_case_256_4),
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_AES_GCM_auth_decryption_test_case_256_5),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_AES_GCM_auth_decryption_test_case_256_6),
12593 TEST_CASE_ST(ut_setup, ut_teardown,
12594 test_AES_GCM_auth_decryption_test_case_256_7),
12596 /** AES GMAC Authentication */
12597 TEST_CASE_ST(ut_setup, ut_teardown,
12598 test_AES_GMAC_authentication_test_case_1),
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_AES_GMAC_authentication_verify_test_case_1),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_AES_GMAC_authentication_test_case_2),
12603 TEST_CASE_ST(ut_setup, ut_teardown,
12604 test_AES_GMAC_authentication_verify_test_case_2),
12605 TEST_CASE_ST(ut_setup, ut_teardown,
12606 test_AES_GMAC_authentication_test_case_3),
12607 TEST_CASE_ST(ut_setup, ut_teardown,
12608 test_AES_GMAC_authentication_verify_test_case_3),
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_AES_GMAC_authentication_test_case_4),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_AES_GMAC_authentication_verify_test_case_4),
12614 /** AES CCM Authenticated Encryption 128 bits key */
12615 TEST_CASE_ST(ut_setup, ut_teardown,
12616 test_AES_CCM_authenticated_encryption_test_case_128_1),
12617 TEST_CASE_ST(ut_setup, ut_teardown,
12618 test_AES_CCM_authenticated_encryption_test_case_128_2),
12619 TEST_CASE_ST(ut_setup, ut_teardown,
12620 test_AES_CCM_authenticated_encryption_test_case_128_3),
12622 /** AES CCM Authenticated Decryption 128 bits key*/
12623 TEST_CASE_ST(ut_setup, ut_teardown,
12624 test_AES_CCM_authenticated_decryption_test_case_128_1),
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_AES_CCM_authenticated_decryption_test_case_128_2),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_AES_CCM_authenticated_decryption_test_case_128_3),
12630 /** AES CCM Authenticated Encryption 192 bits key */
12631 TEST_CASE_ST(ut_setup, ut_teardown,
12632 test_AES_CCM_authenticated_encryption_test_case_192_1),
12633 TEST_CASE_ST(ut_setup, ut_teardown,
12634 test_AES_CCM_authenticated_encryption_test_case_192_2),
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_AES_CCM_authenticated_encryption_test_case_192_3),
12638 /** AES CCM Authenticated Decryption 192 bits key*/
12639 TEST_CASE_ST(ut_setup, ut_teardown,
12640 test_AES_CCM_authenticated_decryption_test_case_192_1),
12641 TEST_CASE_ST(ut_setup, ut_teardown,
12642 test_AES_CCM_authenticated_decryption_test_case_192_2),
12643 TEST_CASE_ST(ut_setup, ut_teardown,
12644 test_AES_CCM_authenticated_decryption_test_case_192_3),
12646 /** AES CCM Authenticated Encryption 256 bits key */
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_AES_CCM_authenticated_encryption_test_case_256_1),
12649 TEST_CASE_ST(ut_setup, ut_teardown,
12650 test_AES_CCM_authenticated_encryption_test_case_256_2),
12651 TEST_CASE_ST(ut_setup, ut_teardown,
12652 test_AES_CCM_authenticated_encryption_test_case_256_3),
12654 /** AES CCM Authenticated Decryption 256 bits key*/
12655 TEST_CASE_ST(ut_setup, ut_teardown,
12656 test_AES_CCM_authenticated_decryption_test_case_256_1),
12657 TEST_CASE_ST(ut_setup, ut_teardown,
12658 test_AES_CCM_authenticated_decryption_test_case_256_2),
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_AES_CCM_authenticated_decryption_test_case_256_3),
12662 /** Scatter-Gather */
12663 TEST_CASE_ST(ut_setup, ut_teardown,
12664 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12666 /** Negative tests */
12667 TEST_CASE_ST(ut_setup, ut_teardown,
12668 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12669 TEST_CASE_ST(ut_setup, ut_teardown,
12670 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12671 TEST_CASE_ST(ut_setup, ut_teardown,
12672 authentication_verify_AES128_GMAC_fail_data_corrupt),
12673 TEST_CASE_ST(ut_setup, ut_teardown,
12674 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12675 TEST_CASE_ST(ut_setup, ut_teardown,
12676 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12677 TEST_CASE_ST(ut_setup, ut_teardown,
12678 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12681 TEST_CASE_ST(ut_setup, ut_teardown,
12682 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
12687 TEST_CASES_END() /**< NULL terminate unit test array */
12691 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
12692 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
12693 .setup = testsuite_setup,
12694 .teardown = testsuite_teardown,
12695 .unit_test_cases = {
12696 /** AES GCM Authenticated Encryption */
12697 TEST_CASE_ST(ut_setup, ut_teardown,
12698 test_AES_GCM_authenticated_encryption_test_case_1),
12699 TEST_CASE_ST(ut_setup, ut_teardown,
12700 test_AES_GCM_authenticated_encryption_test_case_2),
12701 TEST_CASE_ST(ut_setup, ut_teardown,
12702 test_AES_GCM_authenticated_encryption_test_case_3),
12703 TEST_CASE_ST(ut_setup, ut_teardown,
12704 test_AES_GCM_authenticated_encryption_test_case_4),
12705 TEST_CASE_ST(ut_setup, ut_teardown,
12706 test_AES_GCM_authenticated_encryption_test_case_5),
12707 TEST_CASE_ST(ut_setup, ut_teardown,
12708 test_AES_GCM_authenticated_encryption_test_case_6),
12709 TEST_CASE_ST(ut_setup, ut_teardown,
12710 test_AES_GCM_authenticated_encryption_test_case_7),
12712 /** AES GCM Authenticated Decryption */
12713 TEST_CASE_ST(ut_setup, ut_teardown,
12714 test_AES_GCM_authenticated_decryption_test_case_1),
12715 TEST_CASE_ST(ut_setup, ut_teardown,
12716 test_AES_GCM_authenticated_decryption_test_case_2),
12717 TEST_CASE_ST(ut_setup, ut_teardown,
12718 test_AES_GCM_authenticated_decryption_test_case_3),
12719 TEST_CASE_ST(ut_setup, ut_teardown,
12720 test_AES_GCM_authenticated_decryption_test_case_4),
12721 TEST_CASE_ST(ut_setup, ut_teardown,
12722 test_AES_GCM_authenticated_decryption_test_case_5),
12723 TEST_CASE_ST(ut_setup, ut_teardown,
12724 test_AES_GCM_authenticated_decryption_test_case_6),
12725 TEST_CASE_ST(ut_setup, ut_teardown,
12726 test_AES_GCM_authenticated_decryption_test_case_7),
12728 /** AES GCM Authenticated Encryption 192 bits key */
12729 TEST_CASE_ST(ut_setup, ut_teardown,
12730 test_AES_GCM_auth_encryption_test_case_192_1),
12731 TEST_CASE_ST(ut_setup, ut_teardown,
12732 test_AES_GCM_auth_encryption_test_case_192_2),
12733 TEST_CASE_ST(ut_setup, ut_teardown,
12734 test_AES_GCM_auth_encryption_test_case_192_3),
12735 TEST_CASE_ST(ut_setup, ut_teardown,
12736 test_AES_GCM_auth_encryption_test_case_192_4),
12737 TEST_CASE_ST(ut_setup, ut_teardown,
12738 test_AES_GCM_auth_encryption_test_case_192_5),
12739 TEST_CASE_ST(ut_setup, ut_teardown,
12740 test_AES_GCM_auth_encryption_test_case_192_6),
12741 TEST_CASE_ST(ut_setup, ut_teardown,
12742 test_AES_GCM_auth_encryption_test_case_192_7),
12744 /** AES GCM Authenticated Decryption 192 bits key */
12745 TEST_CASE_ST(ut_setup, ut_teardown,
12746 test_AES_GCM_auth_decryption_test_case_192_1),
12747 TEST_CASE_ST(ut_setup, ut_teardown,
12748 test_AES_GCM_auth_decryption_test_case_192_2),
12749 TEST_CASE_ST(ut_setup, ut_teardown,
12750 test_AES_GCM_auth_decryption_test_case_192_3),
12751 TEST_CASE_ST(ut_setup, ut_teardown,
12752 test_AES_GCM_auth_decryption_test_case_192_4),
12753 TEST_CASE_ST(ut_setup, ut_teardown,
12754 test_AES_GCM_auth_decryption_test_case_192_5),
12755 TEST_CASE_ST(ut_setup, ut_teardown,
12756 test_AES_GCM_auth_decryption_test_case_192_6),
12757 TEST_CASE_ST(ut_setup, ut_teardown,
12758 test_AES_GCM_auth_decryption_test_case_192_7),
12760 /** AES GCM Authenticated Encryption 256 bits key */
12761 TEST_CASE_ST(ut_setup, ut_teardown,
12762 test_AES_GCM_auth_encryption_test_case_256_1),
12763 TEST_CASE_ST(ut_setup, ut_teardown,
12764 test_AES_GCM_auth_encryption_test_case_256_2),
12765 TEST_CASE_ST(ut_setup, ut_teardown,
12766 test_AES_GCM_auth_encryption_test_case_256_3),
12767 TEST_CASE_ST(ut_setup, ut_teardown,
12768 test_AES_GCM_auth_encryption_test_case_256_4),
12769 TEST_CASE_ST(ut_setup, ut_teardown,
12770 test_AES_GCM_auth_encryption_test_case_256_5),
12771 TEST_CASE_ST(ut_setup, ut_teardown,
12772 test_AES_GCM_auth_encryption_test_case_256_6),
12773 TEST_CASE_ST(ut_setup, ut_teardown,
12774 test_AES_GCM_auth_encryption_test_case_256_7),
12776 /** AES GCM Authenticated Decryption 256 bits key */
12777 TEST_CASE_ST(ut_setup, ut_teardown,
12778 test_AES_GCM_auth_decryption_test_case_256_1),
12779 TEST_CASE_ST(ut_setup, ut_teardown,
12780 test_AES_GCM_auth_decryption_test_case_256_2),
12781 TEST_CASE_ST(ut_setup, ut_teardown,
12782 test_AES_GCM_auth_decryption_test_case_256_3),
12783 TEST_CASE_ST(ut_setup, ut_teardown,
12784 test_AES_GCM_auth_decryption_test_case_256_4),
12785 TEST_CASE_ST(ut_setup, ut_teardown,
12786 test_AES_GCM_auth_decryption_test_case_256_5),
12787 TEST_CASE_ST(ut_setup, ut_teardown,
12788 test_AES_GCM_auth_decryption_test_case_256_6),
12789 TEST_CASE_ST(ut_setup, ut_teardown,
12790 test_AES_GCM_auth_decryption_test_case_256_7),
12792 /** AES GCM Authenticated Encryption big aad size */
12793 TEST_CASE_ST(ut_setup, ut_teardown,
12794 test_AES_GCM_auth_encryption_test_case_aad_1),
12795 TEST_CASE_ST(ut_setup, ut_teardown,
12796 test_AES_GCM_auth_encryption_test_case_aad_2),
12798 /** AES GCM Authenticated Decryption big aad size */
12799 TEST_CASE_ST(ut_setup, ut_teardown,
12800 test_AES_GCM_auth_decryption_test_case_aad_1),
12801 TEST_CASE_ST(ut_setup, ut_teardown,
12802 test_AES_GCM_auth_decryption_test_case_aad_2),
12804 /** AES GMAC Authentication */
12805 TEST_CASE_ST(ut_setup, ut_teardown,
12806 test_AES_GMAC_authentication_test_case_1),
12807 TEST_CASE_ST(ut_setup, ut_teardown,
12808 test_AES_GMAC_authentication_verify_test_case_1),
12809 TEST_CASE_ST(ut_setup, ut_teardown,
12810 test_AES_GMAC_authentication_test_case_3),
12811 TEST_CASE_ST(ut_setup, ut_teardown,
12812 test_AES_GMAC_authentication_verify_test_case_3),
12813 TEST_CASE_ST(ut_setup, ut_teardown,
12814 test_AES_GMAC_authentication_test_case_4),
12815 TEST_CASE_ST(ut_setup, ut_teardown,
12816 test_AES_GMAC_authentication_verify_test_case_4),
12818 /** Negative tests */
12819 TEST_CASE_ST(ut_setup, ut_teardown,
12820 authentication_verify_AES128_GMAC_fail_data_corrupt),
12821 TEST_CASE_ST(ut_setup, ut_teardown,
12822 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12824 /** Out of place tests */
12825 TEST_CASE_ST(ut_setup, ut_teardown,
12826 test_AES_GCM_authenticated_encryption_oop_test_case_1),
12827 TEST_CASE_ST(ut_setup, ut_teardown,
12828 test_AES_GCM_authenticated_decryption_oop_test_case_1),
12830 /** Session-less tests */
12831 TEST_CASE_ST(ut_setup, ut_teardown,
12832 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12836 /** Scatter-Gather */
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12842 TEST_CASES_END() /**< NULL terminate unit test array */
12846 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
12847 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
12848 .setup = testsuite_setup,
12849 .teardown = testsuite_teardown,
12850 .unit_test_cases = {
12851 /** KASUMI encrypt only (UEA1) */
12852 TEST_CASE_ST(ut_setup, ut_teardown,
12853 test_kasumi_encryption_test_case_1),
12854 TEST_CASE_ST(ut_setup, ut_teardown,
12855 test_kasumi_encryption_test_case_1_sgl),
12856 TEST_CASE_ST(ut_setup, ut_teardown,
12857 test_kasumi_encryption_test_case_2),
12858 TEST_CASE_ST(ut_setup, ut_teardown,
12859 test_kasumi_encryption_test_case_3),
12860 TEST_CASE_ST(ut_setup, ut_teardown,
12861 test_kasumi_encryption_test_case_4),
12862 TEST_CASE_ST(ut_setup, ut_teardown,
12863 test_kasumi_encryption_test_case_5),
12864 /** KASUMI decrypt only (UEA1) */
12865 TEST_CASE_ST(ut_setup, ut_teardown,
12866 test_kasumi_decryption_test_case_1),
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_kasumi_decryption_test_case_2),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_kasumi_decryption_test_case_3),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_kasumi_decryption_test_case_4),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_kasumi_decryption_test_case_5),
12876 TEST_CASE_ST(ut_setup, ut_teardown,
12877 test_kasumi_encryption_test_case_1_oop),
12878 TEST_CASE_ST(ut_setup, ut_teardown,
12879 test_kasumi_encryption_test_case_1_oop_sgl),
12882 TEST_CASE_ST(ut_setup, ut_teardown,
12883 test_kasumi_decryption_test_case_1_oop),
12885 /** KASUMI hash only (UIA1) */
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_kasumi_hash_generate_test_case_1),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_kasumi_hash_generate_test_case_2),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_kasumi_hash_generate_test_case_3),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_kasumi_hash_generate_test_case_4),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_kasumi_hash_generate_test_case_5),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_kasumi_hash_generate_test_case_6),
12898 TEST_CASE_ST(ut_setup, ut_teardown,
12899 test_kasumi_hash_verify_test_case_1),
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 test_kasumi_hash_verify_test_case_2),
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_kasumi_hash_verify_test_case_3),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_kasumi_hash_verify_test_case_4),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_kasumi_hash_verify_test_case_5),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_kasumi_cipher_auth_test_case_1),
12911 /** KASUMI generate auth, then encrypt (F8) */
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 test_kasumi_auth_cipher_test_case_1),
12914 TEST_CASE_ST(ut_setup, ut_teardown,
12915 test_kasumi_auth_cipher_test_case_2),
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 test_kasumi_auth_cipher_test_case_2_oop),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_kasumi_auth_cipher_test_case_2_sgl),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12923 /** KASUMI decrypt (F8), then verify auth */
12924 TEST_CASE_ST(ut_setup, ut_teardown,
12925 test_kasumi_auth_cipher_verify_test_case_1),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 test_kasumi_auth_cipher_verify_test_case_2),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 test_kasumi_auth_cipher_verify_test_case_2_oop),
12930 TEST_CASE_ST(ut_setup, ut_teardown,
12931 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12932 TEST_CASE_ST(ut_setup, ut_teardown,
12933 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12934 TEST_CASES_END() /**< NULL terminate unit test array */
12937 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
12938 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
12939 .setup = testsuite_setup,
12940 .teardown = testsuite_teardown,
12941 .unit_test_cases = {
12942 /** SNOW 3G encrypt only (UEA2) */
12943 TEST_CASE_ST(ut_setup, ut_teardown,
12944 test_snow3g_encryption_test_case_1),
12945 TEST_CASE_ST(ut_setup, ut_teardown,
12946 test_snow3g_encryption_test_case_2),
12947 TEST_CASE_ST(ut_setup, ut_teardown,
12948 test_snow3g_encryption_test_case_3),
12949 TEST_CASE_ST(ut_setup, ut_teardown,
12950 test_snow3g_encryption_test_case_4),
12951 TEST_CASE_ST(ut_setup, ut_teardown,
12952 test_snow3g_encryption_test_case_5),
12953 TEST_CASE_ST(ut_setup, ut_teardown,
12954 test_snow3g_auth_cipher_with_digest_test_case_1),
12956 TEST_CASE_ST(ut_setup, ut_teardown,
12957 test_snow3g_encryption_test_case_1_oop),
12958 TEST_CASE_ST(ut_setup, ut_teardown,
12959 test_snow3g_encryption_test_case_1_oop_sgl),
12960 TEST_CASE_ST(ut_setup, ut_teardown,
12961 test_snow3g_decryption_test_case_1_oop),
12963 TEST_CASE_ST(ut_setup, ut_teardown,
12964 test_snow3g_encryption_test_case_1_offset_oop),
12966 /** SNOW 3G decrypt only (UEA2) */
12967 TEST_CASE_ST(ut_setup, ut_teardown,
12968 test_snow3g_decryption_test_case_1),
12969 TEST_CASE_ST(ut_setup, ut_teardown,
12970 test_snow3g_decryption_test_case_2),
12971 TEST_CASE_ST(ut_setup, ut_teardown,
12972 test_snow3g_decryption_test_case_3),
12973 TEST_CASE_ST(ut_setup, ut_teardown,
12974 test_snow3g_decryption_test_case_4),
12975 TEST_CASE_ST(ut_setup, ut_teardown,
12976 test_snow3g_decryption_test_case_5),
12977 TEST_CASE_ST(ut_setup, ut_teardown,
12978 test_snow3g_decryption_with_digest_test_case_1),
12979 TEST_CASE_ST(ut_setup, ut_teardown,
12980 test_snow3g_hash_generate_test_case_1),
12981 TEST_CASE_ST(ut_setup, ut_teardown,
12982 test_snow3g_hash_generate_test_case_2),
12983 TEST_CASE_ST(ut_setup, ut_teardown,
12984 test_snow3g_hash_generate_test_case_3),
12985 /* Tests with buffers which length is not byte-aligned */
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_snow3g_hash_generate_test_case_4),
12988 TEST_CASE_ST(ut_setup, ut_teardown,
12989 test_snow3g_hash_generate_test_case_5),
12990 TEST_CASE_ST(ut_setup, ut_teardown,
12991 test_snow3g_hash_generate_test_case_6),
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_snow3g_hash_verify_test_case_1),
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 test_snow3g_hash_verify_test_case_2),
12996 TEST_CASE_ST(ut_setup, ut_teardown,
12997 test_snow3g_hash_verify_test_case_3),
12998 /* Tests with buffers which length is not byte-aligned */
12999 TEST_CASE_ST(ut_setup, ut_teardown,
13000 test_snow3g_hash_verify_test_case_4),
13001 TEST_CASE_ST(ut_setup, ut_teardown,
13002 test_snow3g_hash_verify_test_case_5),
13003 TEST_CASE_ST(ut_setup, ut_teardown,
13004 test_snow3g_hash_verify_test_case_6),
13005 TEST_CASE_ST(ut_setup, ut_teardown,
13006 test_snow3g_cipher_auth_test_case_1),
13008 /** SNOW 3G generate auth, then encrypt (UEA2) */
13009 TEST_CASE_ST(ut_setup, ut_teardown,
13010 test_snow3g_auth_cipher_test_case_1),
13011 TEST_CASE_ST(ut_setup, ut_teardown,
13012 test_snow3g_auth_cipher_test_case_2),
13013 TEST_CASE_ST(ut_setup, ut_teardown,
13014 test_snow3g_auth_cipher_test_case_2_oop),
13015 TEST_CASE_ST(ut_setup, ut_teardown,
13016 test_snow3g_auth_cipher_part_digest_enc),
13017 TEST_CASE_ST(ut_setup, ut_teardown,
13018 test_snow3g_auth_cipher_part_digest_enc_oop),
13019 TEST_CASE_ST(ut_setup, ut_teardown,
13020 test_snow3g_auth_cipher_test_case_3_sgl),
13021 TEST_CASE_ST(ut_setup, ut_teardown,
13022 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13023 TEST_CASE_ST(ut_setup, ut_teardown,
13024 test_snow3g_auth_cipher_part_digest_enc_sgl),
13025 TEST_CASE_ST(ut_setup, ut_teardown,
13026 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13028 /** SNOW 3G decrypt (UEA2), then verify auth */
13029 TEST_CASE_ST(ut_setup, ut_teardown,
13030 test_snow3g_auth_cipher_verify_test_case_1),
13031 TEST_CASE_ST(ut_setup, ut_teardown,
13032 test_snow3g_auth_cipher_verify_test_case_2),
13033 TEST_CASE_ST(ut_setup, ut_teardown,
13034 test_snow3g_auth_cipher_verify_test_case_2_oop),
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 test_snow3g_auth_cipher_verify_part_digest_enc),
13037 TEST_CASE_ST(ut_setup, ut_teardown,
13038 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13039 TEST_CASE_ST(ut_setup, ut_teardown,
13040 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13041 TEST_CASE_ST(ut_setup, ut_teardown,
13042 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13043 TEST_CASE_ST(ut_setup, ut_teardown,
13044 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13045 TEST_CASE_ST(ut_setup, ut_teardown,
13046 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13048 TEST_CASES_END() /**< NULL terminate unit test array */
13052 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
13053 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
13054 .setup = testsuite_setup,
13055 .teardown = testsuite_teardown,
13056 .unit_test_cases = {
13057 /** ZUC encrypt only (EEA3) */
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_zuc_encryption_test_case_1),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_zuc_encryption_test_case_2),
13062 TEST_CASE_ST(ut_setup, ut_teardown,
13063 test_zuc_encryption_test_case_3),
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_zuc_encryption_test_case_4),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_zuc_encryption_test_case_5),
13068 TEST_CASE_ST(ut_setup, ut_teardown,
13069 test_zuc_hash_generate_test_case_1),
13070 TEST_CASE_ST(ut_setup, ut_teardown,
13071 test_zuc_hash_generate_test_case_2),
13072 TEST_CASE_ST(ut_setup, ut_teardown,
13073 test_zuc_hash_generate_test_case_3),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_zuc_hash_generate_test_case_4),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_zuc_hash_generate_test_case_5),
13078 TEST_CASE_ST(ut_setup, ut_teardown,
13079 test_zuc_encryption_test_case_6_sgl),
13080 TEST_CASES_END() /**< NULL terminate unit test array */
13084 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13085 .suite_name = "Crypto CAAM JR Unit Test Suite",
13086 .setup = testsuite_setup,
13087 .teardown = testsuite_teardown,
13088 .unit_test_cases = {
13089 TEST_CASE_ST(ut_setup, ut_teardown,
13090 test_device_configure_invalid_dev_id),
13091 TEST_CASE_ST(ut_setup, ut_teardown,
13092 test_multi_session),
13094 TEST_CASE_ST(ut_setup, ut_teardown,
13095 test_AES_chain_caam_jr_all),
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_3DES_chain_caam_jr_all),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_AES_cipheronly_caam_jr_all),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_3DES_cipheronly_caam_jr_all),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_authonly_caam_jr_all),
13105 TEST_CASES_END() /**< NULL terminate unit test array */
13109 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
13110 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
13111 .setup = testsuite_setup,
13112 .teardown = testsuite_teardown,
13113 .unit_test_cases = {
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_device_configure_invalid_dev_id),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_multi_session),
13119 TEST_CASE_ST(ut_setup, ut_teardown,
13120 test_AES_chain_dpaa_sec_all),
13121 TEST_CASE_ST(ut_setup, ut_teardown,
13122 test_3DES_chain_dpaa_sec_all),
13123 TEST_CASE_ST(ut_setup, ut_teardown,
13124 test_AES_cipheronly_dpaa_sec_all),
13125 TEST_CASE_ST(ut_setup, ut_teardown,
13126 test_3DES_cipheronly_dpaa_sec_all),
13127 TEST_CASE_ST(ut_setup, ut_teardown,
13128 test_authonly_dpaa_sec_all),
13130 #ifdef RTE_LIBRTE_SECURITY
13131 TEST_CASE_ST(ut_setup, ut_teardown,
13132 test_PDCP_PROTO_cplane_encap_all),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_PDCP_PROTO_cplane_decap_all),
13137 TEST_CASE_ST(ut_setup, ut_teardown,
13138 test_PDCP_PROTO_uplane_encap_all),
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_PDCP_PROTO_uplane_decap_all),
13143 TEST_CASE_ST(ut_setup, ut_teardown,
13144 test_PDCP_PROTO_SGL_in_place_32B),
13145 TEST_CASE_ST(ut_setup, ut_teardown,
13146 test_PDCP_PROTO_SGL_oop_32B_128B),
13147 TEST_CASE_ST(ut_setup, ut_teardown,
13148 test_PDCP_PROTO_SGL_oop_32B_40B),
13149 TEST_CASE_ST(ut_setup, ut_teardown,
13150 test_PDCP_PROTO_SGL_oop_128B_32B),
13152 /** AES GCM Authenticated Encryption */
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_400B),
13157 TEST_CASE_ST(ut_setup, ut_teardown,
13158 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13159 TEST_CASE_ST(ut_setup, ut_teardown,
13160 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13161 TEST_CASE_ST(ut_setup, ut_teardown,
13162 test_AES_GCM_authenticated_encryption_test_case_1),
13163 TEST_CASE_ST(ut_setup, ut_teardown,
13164 test_AES_GCM_authenticated_encryption_test_case_2),
13165 TEST_CASE_ST(ut_setup, ut_teardown,
13166 test_AES_GCM_authenticated_encryption_test_case_3),
13167 TEST_CASE_ST(ut_setup, ut_teardown,
13168 test_AES_GCM_authenticated_encryption_test_case_4),
13169 TEST_CASE_ST(ut_setup, ut_teardown,
13170 test_AES_GCM_authenticated_encryption_test_case_5),
13171 TEST_CASE_ST(ut_setup, ut_teardown,
13172 test_AES_GCM_authenticated_encryption_test_case_6),
13173 TEST_CASE_ST(ut_setup, ut_teardown,
13174 test_AES_GCM_authenticated_encryption_test_case_7),
13175 TEST_CASE_ST(ut_setup, ut_teardown,
13176 test_AES_GCM_authenticated_encryption_test_case_8),
13178 /** AES GCM Authenticated Decryption */
13179 TEST_CASE_ST(ut_setup, ut_teardown,
13180 test_AES_GCM_authenticated_decryption_test_case_1),
13181 TEST_CASE_ST(ut_setup, ut_teardown,
13182 test_AES_GCM_authenticated_decryption_test_case_2),
13183 TEST_CASE_ST(ut_setup, ut_teardown,
13184 test_AES_GCM_authenticated_decryption_test_case_3),
13185 TEST_CASE_ST(ut_setup, ut_teardown,
13186 test_AES_GCM_authenticated_decryption_test_case_4),
13187 TEST_CASE_ST(ut_setup, ut_teardown,
13188 test_AES_GCM_authenticated_decryption_test_case_5),
13189 TEST_CASE_ST(ut_setup, ut_teardown,
13190 test_AES_GCM_authenticated_decryption_test_case_6),
13191 TEST_CASE_ST(ut_setup, ut_teardown,
13192 test_AES_GCM_authenticated_decryption_test_case_7),
13193 TEST_CASE_ST(ut_setup, ut_teardown,
13194 test_AES_GCM_authenticated_decryption_test_case_8),
13196 /** AES GCM Authenticated Encryption 192 bits key */
13197 TEST_CASE_ST(ut_setup, ut_teardown,
13198 test_AES_GCM_auth_encryption_test_case_192_1),
13199 TEST_CASE_ST(ut_setup, ut_teardown,
13200 test_AES_GCM_auth_encryption_test_case_192_2),
13201 TEST_CASE_ST(ut_setup, ut_teardown,
13202 test_AES_GCM_auth_encryption_test_case_192_3),
13203 TEST_CASE_ST(ut_setup, ut_teardown,
13204 test_AES_GCM_auth_encryption_test_case_192_4),
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_AES_GCM_auth_encryption_test_case_192_5),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 test_AES_GCM_auth_encryption_test_case_192_6),
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 test_AES_GCM_auth_encryption_test_case_192_7),
13212 /** AES GCM Authenticated Decryption 192 bits key */
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 test_AES_GCM_auth_decryption_test_case_192_1),
13215 TEST_CASE_ST(ut_setup, ut_teardown,
13216 test_AES_GCM_auth_decryption_test_case_192_2),
13217 TEST_CASE_ST(ut_setup, ut_teardown,
13218 test_AES_GCM_auth_decryption_test_case_192_3),
13219 TEST_CASE_ST(ut_setup, ut_teardown,
13220 test_AES_GCM_auth_decryption_test_case_192_4),
13221 TEST_CASE_ST(ut_setup, ut_teardown,
13222 test_AES_GCM_auth_decryption_test_case_192_5),
13223 TEST_CASE_ST(ut_setup, ut_teardown,
13224 test_AES_GCM_auth_decryption_test_case_192_6),
13225 TEST_CASE_ST(ut_setup, ut_teardown,
13226 test_AES_GCM_auth_decryption_test_case_192_7),
13228 /** AES GCM Authenticated Encryption 256 bits key */
13229 TEST_CASE_ST(ut_setup, ut_teardown,
13230 test_AES_GCM_auth_encryption_test_case_256_1),
13231 TEST_CASE_ST(ut_setup, ut_teardown,
13232 test_AES_GCM_auth_encryption_test_case_256_2),
13233 TEST_CASE_ST(ut_setup, ut_teardown,
13234 test_AES_GCM_auth_encryption_test_case_256_3),
13235 TEST_CASE_ST(ut_setup, ut_teardown,
13236 test_AES_GCM_auth_encryption_test_case_256_4),
13237 TEST_CASE_ST(ut_setup, ut_teardown,
13238 test_AES_GCM_auth_encryption_test_case_256_5),
13239 TEST_CASE_ST(ut_setup, ut_teardown,
13240 test_AES_GCM_auth_encryption_test_case_256_6),
13241 TEST_CASE_ST(ut_setup, ut_teardown,
13242 test_AES_GCM_auth_encryption_test_case_256_7),
13244 /** AES GCM Authenticated Decryption 256 bits key */
13245 TEST_CASE_ST(ut_setup, ut_teardown,
13246 test_AES_GCM_auth_decryption_test_case_256_1),
13247 TEST_CASE_ST(ut_setup, ut_teardown,
13248 test_AES_GCM_auth_decryption_test_case_256_2),
13249 TEST_CASE_ST(ut_setup, ut_teardown,
13250 test_AES_GCM_auth_decryption_test_case_256_3),
13251 TEST_CASE_ST(ut_setup, ut_teardown,
13252 test_AES_GCM_auth_decryption_test_case_256_4),
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_AES_GCM_auth_decryption_test_case_256_5),
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_AES_GCM_auth_decryption_test_case_256_6),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_AES_GCM_auth_decryption_test_case_256_7),
13260 /** Out of place tests */
13261 TEST_CASE_ST(ut_setup, ut_teardown,
13262 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13266 /** SNOW 3G encrypt only (UEA2) */
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_snow3g_encryption_test_case_1),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_snow3g_encryption_test_case_2),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_snow3g_encryption_test_case_3),
13273 TEST_CASE_ST(ut_setup, ut_teardown,
13274 test_snow3g_encryption_test_case_4),
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_snow3g_encryption_test_case_5),
13278 TEST_CASE_ST(ut_setup, ut_teardown,
13279 test_snow3g_encryption_test_case_1_oop),
13280 TEST_CASE_ST(ut_setup, ut_teardown,
13281 test_snow3g_encryption_test_case_1_oop_sgl),
13282 TEST_CASE_ST(ut_setup, ut_teardown,
13283 test_snow3g_decryption_test_case_1_oop),
13285 /** SNOW 3G decrypt only (UEA2) */
13286 TEST_CASE_ST(ut_setup, ut_teardown,
13287 test_snow3g_decryption_test_case_1),
13288 TEST_CASE_ST(ut_setup, ut_teardown,
13289 test_snow3g_decryption_test_case_2),
13290 TEST_CASE_ST(ut_setup, ut_teardown,
13291 test_snow3g_decryption_test_case_3),
13292 TEST_CASE_ST(ut_setup, ut_teardown,
13293 test_snow3g_decryption_test_case_4),
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_snow3g_decryption_test_case_5),
13297 TEST_CASE_ST(ut_setup, ut_teardown,
13298 test_snow3g_hash_generate_test_case_1),
13299 TEST_CASE_ST(ut_setup, ut_teardown,
13300 test_snow3g_hash_generate_test_case_2),
13301 TEST_CASE_ST(ut_setup, ut_teardown,
13302 test_snow3g_hash_generate_test_case_3),
13303 TEST_CASE_ST(ut_setup, ut_teardown,
13304 test_snow3g_hash_verify_test_case_1),
13305 TEST_CASE_ST(ut_setup, ut_teardown,
13306 test_snow3g_hash_verify_test_case_2),
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_snow3g_hash_verify_test_case_3),
13310 /** ZUC encrypt only (EEA3) */
13311 TEST_CASE_ST(ut_setup, ut_teardown,
13312 test_zuc_encryption_test_case_1),
13313 TEST_CASE_ST(ut_setup, ut_teardown,
13314 test_zuc_encryption_test_case_2),
13315 TEST_CASE_ST(ut_setup, ut_teardown,
13316 test_zuc_encryption_test_case_3),
13317 TEST_CASE_ST(ut_setup, ut_teardown,
13318 test_zuc_encryption_test_case_4),
13319 TEST_CASE_ST(ut_setup, ut_teardown,
13320 test_zuc_encryption_test_case_5),
13322 /** ZUC authenticate (EIA3) */
13323 TEST_CASE_ST(ut_setup, ut_teardown,
13324 test_zuc_hash_generate_test_case_6),
13325 TEST_CASE_ST(ut_setup, ut_teardown,
13326 test_zuc_hash_generate_test_case_7),
13327 TEST_CASE_ST(ut_setup, ut_teardown,
13328 test_zuc_hash_generate_test_case_8),
13330 /** Negative tests */
13331 TEST_CASE_ST(ut_setup, ut_teardown,
13332 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13333 TEST_CASE_ST(ut_setup, ut_teardown,
13334 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13335 TEST_CASE_ST(ut_setup, ut_teardown,
13336 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13349 TEST_CASE_ST(ut_setup, ut_teardown,
13350 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13351 TEST_CASE_ST(ut_setup, ut_teardown,
13352 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13353 TEST_CASE_ST(ut_setup, ut_teardown,
13354 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13355 TEST_CASE_ST(ut_setup, ut_teardown,
13356 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13357 TEST_CASE_ST(ut_setup, ut_teardown,
13358 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13359 TEST_CASE_ST(ut_setup, ut_teardown,
13360 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13361 TEST_CASE_ST(ut_setup, ut_teardown,
13362 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13365 TEST_CASE_ST(ut_setup, ut_teardown,
13366 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13367 TEST_CASE_ST(ut_setup, ut_teardown,
13368 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13370 TEST_CASES_END() /**< NULL terminate unit test array */
13374 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
13375 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13376 .setup = testsuite_setup,
13377 .teardown = testsuite_teardown,
13378 .unit_test_cases = {
13379 TEST_CASE_ST(ut_setup, ut_teardown,
13380 test_device_configure_invalid_dev_id),
13381 TEST_CASE_ST(ut_setup, ut_teardown,
13382 test_multi_session),
13383 TEST_CASE_ST(ut_setup, ut_teardown,
13384 test_AES_chain_dpaa2_sec_all),
13385 TEST_CASE_ST(ut_setup, ut_teardown,
13386 test_3DES_chain_dpaa2_sec_all),
13387 TEST_CASE_ST(ut_setup, ut_teardown,
13388 test_AES_cipheronly_dpaa2_sec_all),
13389 TEST_CASE_ST(ut_setup, ut_teardown,
13390 test_3DES_cipheronly_dpaa2_sec_all),
13391 TEST_CASE_ST(ut_setup, ut_teardown,
13392 test_authonly_dpaa2_sec_all),
13394 #ifdef RTE_LIBRTE_SECURITY
13395 TEST_CASE_ST(ut_setup, ut_teardown,
13396 test_PDCP_PROTO_cplane_encap_all),
13398 TEST_CASE_ST(ut_setup, ut_teardown,
13399 test_PDCP_PROTO_cplane_decap_all),
13401 TEST_CASE_ST(ut_setup, ut_teardown,
13402 test_PDCP_PROTO_uplane_encap_all),
13404 TEST_CASE_ST(ut_setup, ut_teardown,
13405 test_PDCP_PROTO_uplane_decap_all),
13407 TEST_CASE_ST(ut_setup, ut_teardown,
13408 test_PDCP_PROTO_SGL_in_place_32B),
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_PDCP_PROTO_SGL_oop_32B_128B),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_PDCP_PROTO_SGL_oop_32B_40B),
13413 TEST_CASE_ST(ut_setup, ut_teardown,
13414 test_PDCP_PROTO_SGL_oop_128B_32B),
13416 /** AES GCM Authenticated Encryption */
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13423 TEST_CASE_ST(ut_setup, ut_teardown,
13424 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 test_AES_GCM_authenticated_encryption_test_case_1),
13427 TEST_CASE_ST(ut_setup, ut_teardown,
13428 test_AES_GCM_authenticated_encryption_test_case_2),
13429 TEST_CASE_ST(ut_setup, ut_teardown,
13430 test_AES_GCM_authenticated_encryption_test_case_3),
13431 TEST_CASE_ST(ut_setup, ut_teardown,
13432 test_AES_GCM_authenticated_encryption_test_case_4),
13433 TEST_CASE_ST(ut_setup, ut_teardown,
13434 test_AES_GCM_authenticated_encryption_test_case_5),
13435 TEST_CASE_ST(ut_setup, ut_teardown,
13436 test_AES_GCM_authenticated_encryption_test_case_6),
13437 TEST_CASE_ST(ut_setup, ut_teardown,
13438 test_AES_GCM_authenticated_encryption_test_case_7),
13439 TEST_CASE_ST(ut_setup, ut_teardown,
13440 test_AES_GCM_authenticated_encryption_test_case_8),
13442 /** AES GCM Authenticated Decryption */
13443 TEST_CASE_ST(ut_setup, ut_teardown,
13444 test_AES_GCM_authenticated_decryption_test_case_1),
13445 TEST_CASE_ST(ut_setup, ut_teardown,
13446 test_AES_GCM_authenticated_decryption_test_case_2),
13447 TEST_CASE_ST(ut_setup, ut_teardown,
13448 test_AES_GCM_authenticated_decryption_test_case_3),
13449 TEST_CASE_ST(ut_setup, ut_teardown,
13450 test_AES_GCM_authenticated_decryption_test_case_4),
13451 TEST_CASE_ST(ut_setup, ut_teardown,
13452 test_AES_GCM_authenticated_decryption_test_case_5),
13453 TEST_CASE_ST(ut_setup, ut_teardown,
13454 test_AES_GCM_authenticated_decryption_test_case_6),
13455 TEST_CASE_ST(ut_setup, ut_teardown,
13456 test_AES_GCM_authenticated_decryption_test_case_7),
13457 TEST_CASE_ST(ut_setup, ut_teardown,
13458 test_AES_GCM_authenticated_decryption_test_case_8),
13460 /** AES GCM Authenticated Encryption 192 bits key */
13461 TEST_CASE_ST(ut_setup, ut_teardown,
13462 test_AES_GCM_auth_encryption_test_case_192_1),
13463 TEST_CASE_ST(ut_setup, ut_teardown,
13464 test_AES_GCM_auth_encryption_test_case_192_2),
13465 TEST_CASE_ST(ut_setup, ut_teardown,
13466 test_AES_GCM_auth_encryption_test_case_192_3),
13467 TEST_CASE_ST(ut_setup, ut_teardown,
13468 test_AES_GCM_auth_encryption_test_case_192_4),
13469 TEST_CASE_ST(ut_setup, ut_teardown,
13470 test_AES_GCM_auth_encryption_test_case_192_5),
13471 TEST_CASE_ST(ut_setup, ut_teardown,
13472 test_AES_GCM_auth_encryption_test_case_192_6),
13473 TEST_CASE_ST(ut_setup, ut_teardown,
13474 test_AES_GCM_auth_encryption_test_case_192_7),
13476 /** AES GCM Authenticated Decryption 192 bits key */
13477 TEST_CASE_ST(ut_setup, ut_teardown,
13478 test_AES_GCM_auth_decryption_test_case_192_1),
13479 TEST_CASE_ST(ut_setup, ut_teardown,
13480 test_AES_GCM_auth_decryption_test_case_192_2),
13481 TEST_CASE_ST(ut_setup, ut_teardown,
13482 test_AES_GCM_auth_decryption_test_case_192_3),
13483 TEST_CASE_ST(ut_setup, ut_teardown,
13484 test_AES_GCM_auth_decryption_test_case_192_4),
13485 TEST_CASE_ST(ut_setup, ut_teardown,
13486 test_AES_GCM_auth_decryption_test_case_192_5),
13487 TEST_CASE_ST(ut_setup, ut_teardown,
13488 test_AES_GCM_auth_decryption_test_case_192_6),
13489 TEST_CASE_ST(ut_setup, ut_teardown,
13490 test_AES_GCM_auth_decryption_test_case_192_7),
13492 /** AES GCM Authenticated Encryption 256 bits key */
13493 TEST_CASE_ST(ut_setup, ut_teardown,
13494 test_AES_GCM_auth_encryption_test_case_256_1),
13495 TEST_CASE_ST(ut_setup, ut_teardown,
13496 test_AES_GCM_auth_encryption_test_case_256_2),
13497 TEST_CASE_ST(ut_setup, ut_teardown,
13498 test_AES_GCM_auth_encryption_test_case_256_3),
13499 TEST_CASE_ST(ut_setup, ut_teardown,
13500 test_AES_GCM_auth_encryption_test_case_256_4),
13501 TEST_CASE_ST(ut_setup, ut_teardown,
13502 test_AES_GCM_auth_encryption_test_case_256_5),
13503 TEST_CASE_ST(ut_setup, ut_teardown,
13504 test_AES_GCM_auth_encryption_test_case_256_6),
13505 TEST_CASE_ST(ut_setup, ut_teardown,
13506 test_AES_GCM_auth_encryption_test_case_256_7),
13508 /** AES GCM Authenticated Decryption 256 bits key */
13509 TEST_CASE_ST(ut_setup, ut_teardown,
13510 test_AES_GCM_auth_decryption_test_case_256_1),
13511 TEST_CASE_ST(ut_setup, ut_teardown,
13512 test_AES_GCM_auth_decryption_test_case_256_2),
13513 TEST_CASE_ST(ut_setup, ut_teardown,
13514 test_AES_GCM_auth_decryption_test_case_256_3),
13515 TEST_CASE_ST(ut_setup, ut_teardown,
13516 test_AES_GCM_auth_decryption_test_case_256_4),
13517 TEST_CASE_ST(ut_setup, ut_teardown,
13518 test_AES_GCM_auth_decryption_test_case_256_5),
13519 TEST_CASE_ST(ut_setup, ut_teardown,
13520 test_AES_GCM_auth_decryption_test_case_256_6),
13521 TEST_CASE_ST(ut_setup, ut_teardown,
13522 test_AES_GCM_auth_decryption_test_case_256_7),
13524 /** Out of place tests */
13525 TEST_CASE_ST(ut_setup, ut_teardown,
13526 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13527 TEST_CASE_ST(ut_setup, ut_teardown,
13528 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13530 /** SNOW 3G encrypt only (UEA2) */
13531 TEST_CASE_ST(ut_setup, ut_teardown,
13532 test_snow3g_encryption_test_case_1),
13533 TEST_CASE_ST(ut_setup, ut_teardown,
13534 test_snow3g_encryption_test_case_2),
13535 TEST_CASE_ST(ut_setup, ut_teardown,
13536 test_snow3g_encryption_test_case_3),
13537 TEST_CASE_ST(ut_setup, ut_teardown,
13538 test_snow3g_encryption_test_case_4),
13539 TEST_CASE_ST(ut_setup, ut_teardown,
13540 test_snow3g_encryption_test_case_5),
13542 TEST_CASE_ST(ut_setup, ut_teardown,
13543 test_snow3g_encryption_test_case_1_oop),
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 test_snow3g_encryption_test_case_1_oop_sgl),
13546 TEST_CASE_ST(ut_setup, ut_teardown,
13547 test_snow3g_decryption_test_case_1_oop),
13549 /** SNOW 3G decrypt only (UEA2) */
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 test_snow3g_decryption_test_case_1),
13552 TEST_CASE_ST(ut_setup, ut_teardown,
13553 test_snow3g_decryption_test_case_2),
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_snow3g_decryption_test_case_3),
13556 TEST_CASE_ST(ut_setup, ut_teardown,
13557 test_snow3g_decryption_test_case_4),
13558 TEST_CASE_ST(ut_setup, ut_teardown,
13559 test_snow3g_decryption_test_case_5),
13561 TEST_CASE_ST(ut_setup, ut_teardown,
13562 test_snow3g_hash_generate_test_case_1),
13563 TEST_CASE_ST(ut_setup, ut_teardown,
13564 test_snow3g_hash_generate_test_case_2),
13565 TEST_CASE_ST(ut_setup, ut_teardown,
13566 test_snow3g_hash_generate_test_case_3),
13567 TEST_CASE_ST(ut_setup, ut_teardown,
13568 test_snow3g_hash_verify_test_case_1),
13569 TEST_CASE_ST(ut_setup, ut_teardown,
13570 test_snow3g_hash_verify_test_case_2),
13571 TEST_CASE_ST(ut_setup, ut_teardown,
13572 test_snow3g_hash_verify_test_case_3),
13574 /** ZUC encrypt only (EEA3) */
13575 TEST_CASE_ST(ut_setup, ut_teardown,
13576 test_zuc_encryption_test_case_1),
13577 TEST_CASE_ST(ut_setup, ut_teardown,
13578 test_zuc_encryption_test_case_2),
13579 TEST_CASE_ST(ut_setup, ut_teardown,
13580 test_zuc_encryption_test_case_3),
13581 TEST_CASE_ST(ut_setup, ut_teardown,
13582 test_zuc_encryption_test_case_4),
13583 TEST_CASE_ST(ut_setup, ut_teardown,
13584 test_zuc_encryption_test_case_5),
13586 /** ZUC authenticate (EIA3) */
13587 TEST_CASE_ST(ut_setup, ut_teardown,
13588 test_zuc_hash_generate_test_case_6),
13589 TEST_CASE_ST(ut_setup, ut_teardown,
13590 test_zuc_hash_generate_test_case_7),
13591 TEST_CASE_ST(ut_setup, ut_teardown,
13592 test_zuc_hash_generate_test_case_8),
13594 /** HMAC_MD5 Authentication */
13595 TEST_CASE_ST(ut_setup, ut_teardown,
13596 test_MD5_HMAC_generate_case_1),
13597 TEST_CASE_ST(ut_setup, ut_teardown,
13598 test_MD5_HMAC_verify_case_1),
13599 TEST_CASE_ST(ut_setup, ut_teardown,
13600 test_MD5_HMAC_generate_case_2),
13601 TEST_CASE_ST(ut_setup, ut_teardown,
13602 test_MD5_HMAC_verify_case_2),
13604 /** Negative tests */
13605 TEST_CASE_ST(ut_setup, ut_teardown,
13606 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13607 TEST_CASE_ST(ut_setup, ut_teardown,
13608 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13609 TEST_CASE_ST(ut_setup, ut_teardown,
13610 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13611 TEST_CASE_ST(ut_setup, ut_teardown,
13612 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13613 TEST_CASE_ST(ut_setup, ut_teardown,
13614 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13615 TEST_CASE_ST(ut_setup, ut_teardown,
13616 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13617 TEST_CASE_ST(ut_setup, ut_teardown,
13618 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13619 TEST_CASE_ST(ut_setup, ut_teardown,
13620 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13621 TEST_CASE_ST(ut_setup, ut_teardown,
13622 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13623 TEST_CASE_ST(ut_setup, ut_teardown,
13624 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13625 TEST_CASE_ST(ut_setup, ut_teardown,
13626 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13627 TEST_CASE_ST(ut_setup, ut_teardown,
13628 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13631 TEST_CASE_ST(ut_setup, ut_teardown,
13632 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13633 TEST_CASE_ST(ut_setup, ut_teardown,
13634 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13635 TEST_CASE_ST(ut_setup, ut_teardown,
13636 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13639 TEST_CASE_ST(ut_setup, ut_teardown,
13640 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13642 TEST_CASE_ST(ut_setup, ut_teardown,
13643 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13645 TEST_CASES_END() /**< NULL terminate unit test array */
13649 static struct unit_test_suite cryptodev_null_testsuite = {
13650 .suite_name = "Crypto Device NULL Unit Test Suite",
13651 .setup = testsuite_setup,
13652 .teardown = testsuite_teardown,
13653 .unit_test_cases = {
13654 TEST_CASE_ST(ut_setup, ut_teardown,
13655 test_null_invalid_operation),
13656 TEST_CASE_ST(ut_setup, ut_teardown,
13657 test_null_burst_operation),
13658 TEST_CASE_ST(ut_setup, ut_teardown,
13659 test_AES_chain_null_all),
13660 TEST_CASE_ST(ut_setup, ut_teardown,
13661 test_AES_cipheronly_null_all),
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 test_authonly_null_all),
13665 TEST_CASES_END() /**< NULL terminate unit test array */
13669 static struct unit_test_suite cryptodev_armv8_testsuite = {
13670 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
13671 .setup = testsuite_setup,
13672 .teardown = testsuite_teardown,
13673 .unit_test_cases = {
13674 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
13676 /** Negative tests */
13677 TEST_CASE_ST(ut_setup, ut_teardown,
13678 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13679 TEST_CASE_ST(ut_setup, ut_teardown,
13680 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13682 TEST_CASES_END() /**< NULL terminate unit test array */
13686 static struct unit_test_suite cryptodev_mrvl_testsuite = {
13687 .suite_name = "Crypto Device Marvell Component Test Suite",
13688 .setup = testsuite_setup,
13689 .teardown = testsuite_teardown,
13690 .unit_test_cases = {
13691 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13692 TEST_CASE_ST(ut_setup, ut_teardown,
13693 test_multi_session_random_usage),
13694 TEST_CASE_ST(ut_setup, ut_teardown,
13695 test_AES_chain_mrvl_all),
13696 TEST_CASE_ST(ut_setup, ut_teardown,
13697 test_AES_cipheronly_mrvl_all),
13698 TEST_CASE_ST(ut_setup, ut_teardown,
13699 test_authonly_mrvl_all),
13700 TEST_CASE_ST(ut_setup, ut_teardown,
13701 test_3DES_chain_mrvl_all),
13702 TEST_CASE_ST(ut_setup, ut_teardown,
13703 test_3DES_cipheronly_mrvl_all),
13705 /** Negative tests */
13706 TEST_CASE_ST(ut_setup, ut_teardown,
13707 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13708 TEST_CASE_ST(ut_setup, ut_teardown,
13709 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13710 TEST_CASE_ST(ut_setup, ut_teardown,
13711 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13712 TEST_CASE_ST(ut_setup, ut_teardown,
13713 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13715 TEST_CASES_END() /**< NULL terminate unit test array */
13719 static struct unit_test_suite cryptodev_ccp_testsuite = {
13720 .suite_name = "Crypto Device CCP Unit Test Suite",
13721 .setup = testsuite_setup,
13722 .teardown = testsuite_teardown,
13723 .unit_test_cases = {
13724 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
13725 TEST_CASE_ST(ut_setup, ut_teardown,
13726 test_multi_session_random_usage),
13727 TEST_CASE_ST(ut_setup, ut_teardown,
13728 test_AES_chain_ccp_all),
13729 TEST_CASE_ST(ut_setup, ut_teardown,
13730 test_AES_cipheronly_ccp_all),
13731 TEST_CASE_ST(ut_setup, ut_teardown,
13732 test_3DES_chain_ccp_all),
13733 TEST_CASE_ST(ut_setup, ut_teardown,
13734 test_3DES_cipheronly_ccp_all),
13735 TEST_CASE_ST(ut_setup, ut_teardown,
13736 test_authonly_ccp_all),
13738 /** Negative tests */
13739 TEST_CASE_ST(ut_setup, ut_teardown,
13740 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13741 TEST_CASE_ST(ut_setup, ut_teardown,
13742 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13743 TEST_CASE_ST(ut_setup, ut_teardown,
13744 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13745 TEST_CASE_ST(ut_setup, ut_teardown,
13746 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13748 TEST_CASES_END() /**< NULL terminate unit test array */
13752 static struct unit_test_suite cryptodev_octeontx_testsuite = {
13753 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
13754 .setup = testsuite_setup,
13755 .teardown = testsuite_teardown,
13756 .unit_test_cases = {
13757 TEST_CASE_ST(ut_setup, ut_teardown,
13758 test_AES_chain_octeontx_all),
13759 TEST_CASE_ST(ut_setup, ut_teardown,
13760 test_AES_cipheronly_octeontx_all),
13761 TEST_CASE_ST(ut_setup, ut_teardown,
13762 test_3DES_chain_octeontx_all),
13763 TEST_CASE_ST(ut_setup, ut_teardown,
13764 test_3DES_cipheronly_octeontx_all),
13765 TEST_CASE_ST(ut_setup, ut_teardown,
13766 test_authonly_octeontx_all),
13768 /** AES GCM Authenticated Encryption */
13769 TEST_CASE_ST(ut_setup, ut_teardown,
13770 test_AES_GCM_authenticated_encryption_test_case_1),
13771 TEST_CASE_ST(ut_setup, ut_teardown,
13772 test_AES_GCM_authenticated_encryption_test_case_2),
13773 TEST_CASE_ST(ut_setup, ut_teardown,
13774 test_AES_GCM_authenticated_encryption_test_case_3),
13775 TEST_CASE_ST(ut_setup, ut_teardown,
13776 test_AES_GCM_authenticated_encryption_test_case_4),
13777 TEST_CASE_ST(ut_setup, ut_teardown,
13778 test_AES_GCM_authenticated_encryption_test_case_5),
13779 TEST_CASE_ST(ut_setup, ut_teardown,
13780 test_AES_GCM_authenticated_encryption_test_case_6),
13781 TEST_CASE_ST(ut_setup, ut_teardown,
13782 test_AES_GCM_authenticated_encryption_test_case_7),
13784 /** AES GCM Authenticated Decryption */
13785 TEST_CASE_ST(ut_setup, ut_teardown,
13786 test_AES_GCM_authenticated_decryption_test_case_1),
13787 TEST_CASE_ST(ut_setup, ut_teardown,
13788 test_AES_GCM_authenticated_decryption_test_case_2),
13789 TEST_CASE_ST(ut_setup, ut_teardown,
13790 test_AES_GCM_authenticated_decryption_test_case_3),
13791 TEST_CASE_ST(ut_setup, ut_teardown,
13792 test_AES_GCM_authenticated_decryption_test_case_4),
13793 TEST_CASE_ST(ut_setup, ut_teardown,
13794 test_AES_GCM_authenticated_decryption_test_case_5),
13795 TEST_CASE_ST(ut_setup, ut_teardown,
13796 test_AES_GCM_authenticated_decryption_test_case_6),
13797 TEST_CASE_ST(ut_setup, ut_teardown,
13798 test_AES_GCM_authenticated_decryption_test_case_7),
13799 /** AES GMAC Authentication */
13800 TEST_CASE_ST(ut_setup, ut_teardown,
13801 test_AES_GMAC_authentication_test_case_1),
13802 TEST_CASE_ST(ut_setup, ut_teardown,
13803 test_AES_GMAC_authentication_verify_test_case_1),
13804 TEST_CASE_ST(ut_setup, ut_teardown,
13805 test_AES_GMAC_authentication_test_case_2),
13806 TEST_CASE_ST(ut_setup, ut_teardown,
13807 test_AES_GMAC_authentication_verify_test_case_2),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_AES_GMAC_authentication_test_case_3),
13810 TEST_CASE_ST(ut_setup, ut_teardown,
13811 test_AES_GMAC_authentication_verify_test_case_3),
13813 /** SNOW 3G encrypt only (UEA2) */
13814 TEST_CASE_ST(ut_setup, ut_teardown,
13815 test_snow3g_encryption_test_case_1),
13816 TEST_CASE_ST(ut_setup, ut_teardown,
13817 test_snow3g_encryption_test_case_2),
13818 TEST_CASE_ST(ut_setup, ut_teardown,
13819 test_snow3g_encryption_test_case_3),
13820 TEST_CASE_ST(ut_setup, ut_teardown,
13821 test_snow3g_encryption_test_case_4),
13822 TEST_CASE_ST(ut_setup, ut_teardown,
13823 test_snow3g_encryption_test_case_5),
13825 TEST_CASE_ST(ut_setup, ut_teardown,
13826 test_snow3g_encryption_test_case_1_oop),
13827 TEST_CASE_ST(ut_setup, ut_teardown,
13828 test_snow3g_decryption_test_case_1_oop),
13829 TEST_CASE_ST(ut_setup, ut_teardown,
13830 test_snow3g_encryption_test_case_1_oop_sgl),
13832 /** SNOW 3G decrypt only (UEA2) */
13833 TEST_CASE_ST(ut_setup, ut_teardown,
13834 test_snow3g_decryption_test_case_1),
13835 TEST_CASE_ST(ut_setup, ut_teardown,
13836 test_snow3g_decryption_test_case_2),
13837 TEST_CASE_ST(ut_setup, ut_teardown,
13838 test_snow3g_decryption_test_case_3),
13839 TEST_CASE_ST(ut_setup, ut_teardown,
13840 test_snow3g_decryption_test_case_4),
13841 TEST_CASE_ST(ut_setup, ut_teardown,
13842 test_snow3g_decryption_test_case_5),
13844 TEST_CASE_ST(ut_setup, ut_teardown,
13845 test_snow3g_hash_generate_test_case_1),
13846 TEST_CASE_ST(ut_setup, ut_teardown,
13847 test_snow3g_hash_generate_test_case_2),
13848 TEST_CASE_ST(ut_setup, ut_teardown,
13849 test_snow3g_hash_generate_test_case_3),
13850 TEST_CASE_ST(ut_setup, ut_teardown,
13851 test_snow3g_hash_verify_test_case_1),
13852 TEST_CASE_ST(ut_setup, ut_teardown,
13853 test_snow3g_hash_verify_test_case_2),
13854 TEST_CASE_ST(ut_setup, ut_teardown,
13855 test_snow3g_hash_verify_test_case_3),
13857 /** ZUC encrypt only (EEA3) */
13858 TEST_CASE_ST(ut_setup, ut_teardown,
13859 test_zuc_encryption_test_case_1),
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_zuc_encryption_test_case_2),
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_zuc_encryption_test_case_3),
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_zuc_encryption_test_case_4),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_zuc_encryption_test_case_5),
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_zuc_hash_generate_test_case_1),
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_zuc_hash_generate_test_case_2),
13872 TEST_CASE_ST(ut_setup, ut_teardown,
13873 test_zuc_hash_generate_test_case_3),
13874 TEST_CASE_ST(ut_setup, ut_teardown,
13875 test_zuc_hash_generate_test_case_4),
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_zuc_hash_generate_test_case_5),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_zuc_encryption_test_case_6_sgl),
13881 /** KASUMI encrypt only (UEA1) */
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_kasumi_encryption_test_case_1),
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_kasumi_encryption_test_case_2),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_kasumi_encryption_test_case_3),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_kasumi_encryption_test_case_4),
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_kasumi_encryption_test_case_5),
13892 TEST_CASE_ST(ut_setup, ut_teardown,
13893 test_kasumi_encryption_test_case_1_sgl),
13894 TEST_CASE_ST(ut_setup, ut_teardown,
13895 test_kasumi_encryption_test_case_1_oop_sgl),
13896 /** KASUMI decrypt only (UEA1) */
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_kasumi_decryption_test_case_1),
13899 TEST_CASE_ST(ut_setup, ut_teardown,
13900 test_kasumi_decryption_test_case_2),
13901 TEST_CASE_ST(ut_setup, ut_teardown,
13902 test_kasumi_decryption_test_case_3),
13903 TEST_CASE_ST(ut_setup, ut_teardown,
13904 test_kasumi_decryption_test_case_4),
13905 TEST_CASE_ST(ut_setup, ut_teardown,
13906 test_kasumi_decryption_test_case_5),
13908 TEST_CASE_ST(ut_setup, ut_teardown,
13909 test_kasumi_encryption_test_case_1_oop),
13910 TEST_CASE_ST(ut_setup, ut_teardown,
13911 test_kasumi_decryption_test_case_1_oop),
13913 /** KASUMI hash only (UIA1) */
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_kasumi_hash_generate_test_case_1),
13916 TEST_CASE_ST(ut_setup, ut_teardown,
13917 test_kasumi_hash_generate_test_case_2),
13918 TEST_CASE_ST(ut_setup, ut_teardown,
13919 test_kasumi_hash_generate_test_case_3),
13920 TEST_CASE_ST(ut_setup, ut_teardown,
13921 test_kasumi_hash_generate_test_case_4),
13922 TEST_CASE_ST(ut_setup, ut_teardown,
13923 test_kasumi_hash_generate_test_case_5),
13924 TEST_CASE_ST(ut_setup, ut_teardown,
13925 test_kasumi_hash_generate_test_case_6),
13926 TEST_CASE_ST(ut_setup, ut_teardown,
13927 test_kasumi_hash_verify_test_case_1),
13928 TEST_CASE_ST(ut_setup, ut_teardown,
13929 test_kasumi_hash_verify_test_case_2),
13930 TEST_CASE_ST(ut_setup, ut_teardown,
13931 test_kasumi_hash_verify_test_case_3),
13932 TEST_CASE_ST(ut_setup, ut_teardown,
13933 test_kasumi_hash_verify_test_case_4),
13934 TEST_CASE_ST(ut_setup, ut_teardown,
13935 test_kasumi_hash_verify_test_case_5),
13938 TEST_CASE_ST(ut_setup, ut_teardown,
13939 test_null_cipher_only_operation),
13940 TEST_CASE_ST(ut_setup, ut_teardown,
13941 test_null_auth_only_operation),
13942 TEST_CASE_ST(ut_setup, ut_teardown,
13943 test_null_cipher_auth_operation),
13944 TEST_CASE_ST(ut_setup, ut_teardown,
13945 test_null_auth_cipher_operation),
13947 /** Negative tests */
13948 TEST_CASE_ST(ut_setup, ut_teardown,
13949 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13950 TEST_CASE_ST(ut_setup, ut_teardown,
13951 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13952 TEST_CASE_ST(ut_setup, ut_teardown,
13953 authentication_verify_AES128_GMAC_fail_data_corrupt),
13954 TEST_CASE_ST(ut_setup, ut_teardown,
13955 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13956 TEST_CASE_ST(ut_setup, ut_teardown,
13957 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13958 TEST_CASE_ST(ut_setup, ut_teardown,
13959 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13960 TEST_CASES_END() /**< NULL terminate unit test array */
13964 static struct unit_test_suite cryptodev_nitrox_testsuite = {
13965 .suite_name = "Crypto NITROX Unit Test Suite",
13966 .setup = testsuite_setup,
13967 .teardown = testsuite_teardown,
13968 .unit_test_cases = {
13969 TEST_CASE_ST(ut_setup, ut_teardown,
13970 test_device_configure_invalid_dev_id),
13971 TEST_CASE_ST(ut_setup, ut_teardown,
13972 test_device_configure_invalid_queue_pair_ids),
13973 TEST_CASE_ST(ut_setup, ut_teardown,
13974 test_AES_chain_nitrox_all),
13976 TEST_CASES_END() /**< NULL terminate unit test array */
13980 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
13981 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
13982 .setup = testsuite_setup,
13983 .teardown = testsuite_teardown,
13984 .unit_test_cases = {
13985 TEST_CASE_ST(ut_setup, ut_teardown,
13986 test_AES_chain_octeontx2_all),
13987 TEST_CASE_ST(ut_setup, ut_teardown,
13988 test_AES_cipheronly_octeontx2_all),
13989 TEST_CASE_ST(ut_setup, ut_teardown,
13990 test_3DES_chain_octeontx2_all),
13991 TEST_CASE_ST(ut_setup, ut_teardown,
13992 test_3DES_cipheronly_octeontx2_all),
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 test_authonly_octeontx2_all),
13996 /** AES GCM Authenticated Encryption */
13997 TEST_CASE_ST(ut_setup, ut_teardown,
13998 test_AES_GCM_authenticated_encryption_test_case_1),
13999 TEST_CASE_ST(ut_setup, ut_teardown,
14000 test_AES_GCM_authenticated_encryption_test_case_2),
14001 TEST_CASE_ST(ut_setup, ut_teardown,
14002 test_AES_GCM_authenticated_encryption_test_case_3),
14003 TEST_CASE_ST(ut_setup, ut_teardown,
14004 test_AES_GCM_authenticated_encryption_test_case_4),
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 test_AES_GCM_authenticated_encryption_test_case_5),
14007 TEST_CASE_ST(ut_setup, ut_teardown,
14008 test_AES_GCM_authenticated_encryption_test_case_6),
14009 TEST_CASE_ST(ut_setup, ut_teardown,
14010 test_AES_GCM_authenticated_encryption_test_case_7),
14012 /** AES GCM Authenticated Decryption */
14013 TEST_CASE_ST(ut_setup, ut_teardown,
14014 test_AES_GCM_authenticated_decryption_test_case_1),
14015 TEST_CASE_ST(ut_setup, ut_teardown,
14016 test_AES_GCM_authenticated_decryption_test_case_2),
14017 TEST_CASE_ST(ut_setup, ut_teardown,
14018 test_AES_GCM_authenticated_decryption_test_case_3),
14019 TEST_CASE_ST(ut_setup, ut_teardown,
14020 test_AES_GCM_authenticated_decryption_test_case_4),
14021 TEST_CASE_ST(ut_setup, ut_teardown,
14022 test_AES_GCM_authenticated_decryption_test_case_5),
14023 TEST_CASE_ST(ut_setup, ut_teardown,
14024 test_AES_GCM_authenticated_decryption_test_case_6),
14025 TEST_CASE_ST(ut_setup, ut_teardown,
14026 test_AES_GCM_authenticated_decryption_test_case_7),
14027 /** AES GMAC Authentication */
14028 TEST_CASE_ST(ut_setup, ut_teardown,
14029 test_AES_GMAC_authentication_test_case_1),
14030 TEST_CASE_ST(ut_setup, ut_teardown,
14031 test_AES_GMAC_authentication_verify_test_case_1),
14032 TEST_CASE_ST(ut_setup, ut_teardown,
14033 test_AES_GMAC_authentication_test_case_2),
14034 TEST_CASE_ST(ut_setup, ut_teardown,
14035 test_AES_GMAC_authentication_verify_test_case_2),
14036 TEST_CASE_ST(ut_setup, ut_teardown,
14037 test_AES_GMAC_authentication_test_case_3),
14038 TEST_CASE_ST(ut_setup, ut_teardown,
14039 test_AES_GMAC_authentication_verify_test_case_3),
14041 /** SNOW 3G encrypt only (UEA2) */
14042 TEST_CASE_ST(ut_setup, ut_teardown,
14043 test_snow3g_encryption_test_case_1),
14044 TEST_CASE_ST(ut_setup, ut_teardown,
14045 test_snow3g_encryption_test_case_2),
14046 TEST_CASE_ST(ut_setup, ut_teardown,
14047 test_snow3g_encryption_test_case_3),
14048 TEST_CASE_ST(ut_setup, ut_teardown,
14049 test_snow3g_encryption_test_case_4),
14050 TEST_CASE_ST(ut_setup, ut_teardown,
14051 test_snow3g_encryption_test_case_5),
14053 TEST_CASE_ST(ut_setup, ut_teardown,
14054 test_snow3g_encryption_test_case_1_oop),
14055 TEST_CASE_ST(ut_setup, ut_teardown,
14056 test_snow3g_decryption_test_case_1_oop),
14057 TEST_CASE_ST(ut_setup, ut_teardown,
14058 test_snow3g_encryption_test_case_1_oop_sgl),
14060 /** SNOW 3G decrypt only (UEA2) */
14061 TEST_CASE_ST(ut_setup, ut_teardown,
14062 test_snow3g_decryption_test_case_1),
14063 TEST_CASE_ST(ut_setup, ut_teardown,
14064 test_snow3g_decryption_test_case_2),
14065 TEST_CASE_ST(ut_setup, ut_teardown,
14066 test_snow3g_decryption_test_case_3),
14067 TEST_CASE_ST(ut_setup, ut_teardown,
14068 test_snow3g_decryption_test_case_4),
14069 TEST_CASE_ST(ut_setup, ut_teardown,
14070 test_snow3g_decryption_test_case_5),
14072 TEST_CASE_ST(ut_setup, ut_teardown,
14073 test_snow3g_hash_generate_test_case_1),
14074 TEST_CASE_ST(ut_setup, ut_teardown,
14075 test_snow3g_hash_generate_test_case_2),
14076 TEST_CASE_ST(ut_setup, ut_teardown,
14077 test_snow3g_hash_generate_test_case_3),
14078 TEST_CASE_ST(ut_setup, ut_teardown,
14079 test_snow3g_hash_verify_test_case_1),
14080 TEST_CASE_ST(ut_setup, ut_teardown,
14081 test_snow3g_hash_verify_test_case_2),
14082 TEST_CASE_ST(ut_setup, ut_teardown,
14083 test_snow3g_hash_verify_test_case_3),
14085 /** ZUC encrypt only (EEA3) */
14086 TEST_CASE_ST(ut_setup, ut_teardown,
14087 test_zuc_encryption_test_case_1),
14088 TEST_CASE_ST(ut_setup, ut_teardown,
14089 test_zuc_encryption_test_case_2),
14090 TEST_CASE_ST(ut_setup, ut_teardown,
14091 test_zuc_encryption_test_case_3),
14092 TEST_CASE_ST(ut_setup, ut_teardown,
14093 test_zuc_encryption_test_case_4),
14094 TEST_CASE_ST(ut_setup, ut_teardown,
14095 test_zuc_encryption_test_case_5),
14096 TEST_CASE_ST(ut_setup, ut_teardown,
14097 test_zuc_hash_generate_test_case_1),
14098 TEST_CASE_ST(ut_setup, ut_teardown,
14099 test_zuc_hash_generate_test_case_2),
14100 TEST_CASE_ST(ut_setup, ut_teardown,
14101 test_zuc_hash_generate_test_case_3),
14102 TEST_CASE_ST(ut_setup, ut_teardown,
14103 test_zuc_hash_generate_test_case_4),
14104 TEST_CASE_ST(ut_setup, ut_teardown,
14105 test_zuc_hash_generate_test_case_5),
14106 TEST_CASE_ST(ut_setup, ut_teardown,
14107 test_zuc_encryption_test_case_6_sgl),
14109 /** KASUMI encrypt only (UEA1) */
14110 TEST_CASE_ST(ut_setup, ut_teardown,
14111 test_kasumi_encryption_test_case_1),
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_kasumi_encryption_test_case_2),
14114 TEST_CASE_ST(ut_setup, ut_teardown,
14115 test_kasumi_encryption_test_case_3),
14116 TEST_CASE_ST(ut_setup, ut_teardown,
14117 test_kasumi_encryption_test_case_4),
14118 TEST_CASE_ST(ut_setup, ut_teardown,
14119 test_kasumi_encryption_test_case_5),
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_kasumi_encryption_test_case_1_sgl),
14122 TEST_CASE_ST(ut_setup, ut_teardown,
14123 test_kasumi_encryption_test_case_1_oop_sgl),
14124 /** KASUMI decrypt only (UEA1) */
14125 TEST_CASE_ST(ut_setup, ut_teardown,
14126 test_kasumi_decryption_test_case_1),
14127 TEST_CASE_ST(ut_setup, ut_teardown,
14128 test_kasumi_decryption_test_case_2),
14129 TEST_CASE_ST(ut_setup, ut_teardown,
14130 test_kasumi_decryption_test_case_3),
14131 TEST_CASE_ST(ut_setup, ut_teardown,
14132 test_kasumi_decryption_test_case_4),
14133 TEST_CASE_ST(ut_setup, ut_teardown,
14134 test_kasumi_decryption_test_case_5),
14136 TEST_CASE_ST(ut_setup, ut_teardown,
14137 test_kasumi_encryption_test_case_1_oop),
14138 TEST_CASE_ST(ut_setup, ut_teardown,
14139 test_kasumi_decryption_test_case_1_oop),
14141 /** KASUMI hash only (UIA1) */
14142 TEST_CASE_ST(ut_setup, ut_teardown,
14143 test_kasumi_hash_generate_test_case_1),
14144 TEST_CASE_ST(ut_setup, ut_teardown,
14145 test_kasumi_hash_generate_test_case_2),
14146 TEST_CASE_ST(ut_setup, ut_teardown,
14147 test_kasumi_hash_generate_test_case_3),
14148 TEST_CASE_ST(ut_setup, ut_teardown,
14149 test_kasumi_hash_generate_test_case_4),
14150 TEST_CASE_ST(ut_setup, ut_teardown,
14151 test_kasumi_hash_generate_test_case_5),
14152 TEST_CASE_ST(ut_setup, ut_teardown,
14153 test_kasumi_hash_generate_test_case_6),
14154 TEST_CASE_ST(ut_setup, ut_teardown,
14155 test_kasumi_hash_verify_test_case_1),
14156 TEST_CASE_ST(ut_setup, ut_teardown,
14157 test_kasumi_hash_verify_test_case_2),
14158 TEST_CASE_ST(ut_setup, ut_teardown,
14159 test_kasumi_hash_verify_test_case_3),
14160 TEST_CASE_ST(ut_setup, ut_teardown,
14161 test_kasumi_hash_verify_test_case_4),
14162 TEST_CASE_ST(ut_setup, ut_teardown,
14163 test_kasumi_hash_verify_test_case_5),
14166 TEST_CASE_ST(ut_setup, ut_teardown,
14167 test_null_cipher_only_operation),
14168 TEST_CASE_ST(ut_setup, ut_teardown,
14169 test_null_auth_only_operation),
14170 TEST_CASE_ST(ut_setup, ut_teardown,
14171 test_null_cipher_auth_operation),
14172 TEST_CASE_ST(ut_setup, ut_teardown,
14173 test_null_auth_cipher_operation),
14175 /** Negative tests */
14176 TEST_CASE_ST(ut_setup, ut_teardown,
14177 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14178 TEST_CASE_ST(ut_setup, ut_teardown,
14179 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14180 TEST_CASE_ST(ut_setup, ut_teardown,
14181 authentication_verify_AES128_GMAC_fail_data_corrupt),
14182 TEST_CASE_ST(ut_setup, ut_teardown,
14183 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14184 TEST_CASE_ST(ut_setup, ut_teardown,
14185 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14186 TEST_CASE_ST(ut_setup, ut_teardown,
14187 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14188 TEST_CASES_END() /**< NULL terminate unit test array */
14193 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14195 gbl_driver_id = rte_cryptodev_driver_id_get(
14196 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14198 if (gbl_driver_id == -1) {
14199 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14200 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14201 "are enabled in config file to run this testsuite.\n");
14202 return TEST_SKIPPED;
14205 return unit_test_suite_runner(&cryptodev_qat_testsuite);
14209 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14211 gbl_driver_id = rte_cryptodev_driver_id_get(
14212 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14214 if (gbl_driver_id == -1) {
14215 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14216 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14217 "in config file to run this testsuite.\n");
14218 return TEST_FAILED;
14221 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14225 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14227 gbl_driver_id = rte_cryptodev_driver_id_get(
14228 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14230 if (gbl_driver_id == -1) {
14231 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14232 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14233 "in config file to run this testsuite.\n");
14234 return TEST_SKIPPED;
14237 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14241 test_cryptodev_openssl(void)
14243 gbl_driver_id = rte_cryptodev_driver_id_get(
14244 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14246 if (gbl_driver_id == -1) {
14247 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14248 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14249 "in config file to run this testsuite.\n");
14250 return TEST_SKIPPED;
14253 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14257 test_cryptodev_aesni_gcm(void)
14259 gbl_driver_id = rte_cryptodev_driver_id_get(
14260 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14262 if (gbl_driver_id == -1) {
14263 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14264 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14265 "in config file to run this testsuite.\n");
14266 return TEST_SKIPPED;
14269 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14273 test_cryptodev_null(void)
14275 gbl_driver_id = rte_cryptodev_driver_id_get(
14276 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14278 if (gbl_driver_id == -1) {
14279 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14280 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14281 "in config file to run this testsuite.\n");
14282 return TEST_SKIPPED;
14285 return unit_test_suite_runner(&cryptodev_null_testsuite);
14289 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14291 gbl_driver_id = rte_cryptodev_driver_id_get(
14292 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14294 if (gbl_driver_id == -1) {
14295 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14296 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14297 "in config file to run this testsuite.\n");
14298 return TEST_SKIPPED;
14301 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14305 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14307 gbl_driver_id = rte_cryptodev_driver_id_get(
14308 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14310 if (gbl_driver_id == -1) {
14311 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14312 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14313 "in config file to run this testsuite.\n");
14314 return TEST_SKIPPED;
14317 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14321 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14323 gbl_driver_id = rte_cryptodev_driver_id_get(
14324 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14326 if (gbl_driver_id == -1) {
14327 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14328 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14329 "in config file to run this testsuite.\n");
14330 return TEST_SKIPPED;
14333 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14337 test_cryptodev_armv8(void)
14339 gbl_driver_id = rte_cryptodev_driver_id_get(
14340 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14342 if (gbl_driver_id == -1) {
14343 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14344 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14345 "in config file to run this testsuite.\n");
14346 return TEST_SKIPPED;
14349 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14353 test_cryptodev_mrvl(void)
14355 gbl_driver_id = rte_cryptodev_driver_id_get(
14356 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14358 if (gbl_driver_id == -1) {
14359 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14360 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14361 "in config file to run this testsuite.\n");
14362 return TEST_SKIPPED;
14365 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14368 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14371 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14373 gbl_driver_id = rte_cryptodev_driver_id_get(
14374 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14376 if (gbl_driver_id == -1) {
14377 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14378 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14379 "in config file to run this testsuite.\n");
14380 return TEST_SKIPPED;
14383 if (rte_cryptodev_driver_id_get(
14384 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14385 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14386 " enabled in config file to run this testsuite.\n");
14387 return TEST_SKIPPED;
14389 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14392 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14397 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14399 gbl_driver_id = rte_cryptodev_driver_id_get(
14400 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14402 if (gbl_driver_id == -1) {
14403 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14404 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14405 "in config file to run this testsuite.\n");
14406 return TEST_SKIPPED;
14409 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14413 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14415 gbl_driver_id = rte_cryptodev_driver_id_get(
14416 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14418 if (gbl_driver_id == -1) {
14419 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14420 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14421 "in config file to run this testsuite.\n");
14422 return TEST_SKIPPED;
14425 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14429 test_cryptodev_ccp(void)
14431 gbl_driver_id = rte_cryptodev_driver_id_get(
14432 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14434 if (gbl_driver_id == -1) {
14435 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14436 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14437 "in config file to run this testsuite.\n");
14438 return TEST_FAILED;
14441 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14445 test_cryptodev_octeontx(void)
14447 gbl_driver_id = rte_cryptodev_driver_id_get(
14448 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14449 if (gbl_driver_id == -1) {
14450 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14451 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14452 "enabled in config file to run this "
14454 return TEST_FAILED;
14456 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14460 test_cryptodev_octeontx2(void)
14462 gbl_driver_id = rte_cryptodev_driver_id_get(
14463 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14464 if (gbl_driver_id == -1) {
14465 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14466 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14467 "enabled in config file to run this "
14469 return TEST_FAILED;
14471 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14475 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14477 gbl_driver_id = rte_cryptodev_driver_id_get(
14478 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14480 if (gbl_driver_id == -1) {
14481 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14482 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14483 "in config file to run this testsuite.\n");
14484 return TEST_FAILED;
14487 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14491 test_cryptodev_nitrox(void)
14493 gbl_driver_id = rte_cryptodev_driver_id_get(
14494 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14496 if (gbl_driver_id == -1) {
14497 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14498 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14499 "in config file to run this testsuite.\n");
14500 return TEST_FAILED;
14503 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14506 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14507 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14508 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14509 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14510 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14511 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14512 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14513 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14514 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14515 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14516 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14517 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14518 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14519 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14520 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14521 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14522 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14523 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);