1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2015-2019 Intel Corporation
7 #include <rte_common.h>
8 #include <rte_hexdump.h>
10 #include <rte_malloc.h>
11 #include <rte_memcpy.h>
12 #include <rte_pause.h>
13 #include <rte_bus_vdev.h>
15 #include <rte_crypto.h>
16 #include <rte_cryptodev.h>
17 #include <rte_cryptodev_pmd.h>
18 #include <rte_string_fns.h>
20 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
21 #include <rte_cryptodev_scheduler.h>
22 #include <rte_cryptodev_scheduler_operations.h>
25 #include <rte_lcore.h>
28 #include "test_cryptodev.h"
30 #include "test_cryptodev_blockcipher.h"
31 #include "test_cryptodev_aes_test_vectors.h"
32 #include "test_cryptodev_des_test_vectors.h"
33 #include "test_cryptodev_hash_test_vectors.h"
34 #include "test_cryptodev_kasumi_test_vectors.h"
35 #include "test_cryptodev_kasumi_hash_test_vectors.h"
36 #include "test_cryptodev_snow3g_test_vectors.h"
37 #include "test_cryptodev_snow3g_hash_test_vectors.h"
38 #include "test_cryptodev_zuc_test_vectors.h"
39 #include "test_cryptodev_aead_test_vectors.h"
40 #include "test_cryptodev_hmac_test_vectors.h"
41 #include "test_cryptodev_mixed_test_vectors.h"
42 #ifdef RTE_LIBRTE_SECURITY
43 #include "test_cryptodev_security_pdcp_test_vectors.h"
44 #include "test_cryptodev_security_pdcp_test_func.h"
47 #define VDEV_ARGS_SIZE 100
48 #define MAX_NB_SESSIONS 4
51 #define OUT_OF_PLACE 1
53 static int gbl_driver_id;
55 struct crypto_testsuite_params {
56 struct rte_mempool *mbuf_pool;
57 struct rte_mempool *large_mbuf_pool;
58 struct rte_mempool *op_mpool;
59 struct rte_mempool *session_mpool;
60 struct rte_mempool *session_priv_mpool;
61 struct rte_cryptodev_config conf;
62 struct rte_cryptodev_qp_conf qp_conf;
64 uint8_t valid_devs[RTE_CRYPTO_MAX_DEVS];
65 uint8_t valid_dev_count;
68 struct crypto_unittest_params {
69 struct rte_crypto_sym_xform cipher_xform;
70 struct rte_crypto_sym_xform auth_xform;
71 struct rte_crypto_sym_xform aead_xform;
74 struct rte_cryptodev_sym_session *sess;
75 #ifdef RTE_LIBRTE_SECURITY
76 struct rte_security_session *sec_session;
79 #ifdef RTE_LIBRTE_SECURITY
80 enum rte_security_session_action_type type;
82 struct rte_crypto_op *op;
84 struct rte_mbuf *obuf, *ibuf;
89 #define ALIGN_POW2_ROUNDUP(num, align) \
90 (((num) + (align) - 1) & ~((align) - 1))
93 * Forward declarations.
96 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
97 struct crypto_unittest_params *ut_params, uint8_t *cipher_key,
101 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
102 struct crypto_unittest_params *ut_params,
103 struct crypto_testsuite_params *ts_param,
104 const uint8_t *cipher,
105 const uint8_t *digest,
108 static struct rte_mbuf *
109 setup_test_string(struct rte_mempool *mpool,
110 const char *string, size_t len, uint8_t blocksize)
112 struct rte_mbuf *m = rte_pktmbuf_alloc(mpool);
113 size_t t_len = len - (blocksize ? (len % blocksize) : 0);
115 memset(m->buf_addr, 0, m->buf_len);
117 char *dst = rte_pktmbuf_append(m, t_len);
124 rte_memcpy(dst, string, t_len);
126 memset(dst, 0, t_len);
132 /* Get number of bytes in X bits (rounding up) */
134 ceil_byte_length(uint32_t num_bits)
137 return ((num_bits >> 3) + 1);
139 return (num_bits >> 3);
142 static struct rte_crypto_op *
143 process_crypto_request(uint8_t dev_id, struct rte_crypto_op *op)
145 if (rte_cryptodev_enqueue_burst(dev_id, 0, &op, 1) != 1) {
146 RTE_LOG(ERR, USER1, "Error sending packet for encryption\n");
152 while (rte_cryptodev_dequeue_burst(dev_id, 0, &op, 1) == 0)
155 if (op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
156 RTE_LOG(DEBUG, USER1, "Operation status %d\n", op->status);
163 static struct crypto_testsuite_params testsuite_params = { NULL };
164 static struct crypto_unittest_params unittest_params;
167 testsuite_setup(void)
169 struct crypto_testsuite_params *ts_params = &testsuite_params;
170 struct rte_cryptodev_info info;
171 uint32_t i = 0, nb_devs, dev_id;
175 memset(ts_params, 0, sizeof(*ts_params));
177 ts_params->mbuf_pool = rte_mempool_lookup("CRYPTO_MBUFPOOL");
178 if (ts_params->mbuf_pool == NULL) {
179 /* Not already created so create */
180 ts_params->mbuf_pool = rte_pktmbuf_pool_create(
182 NUM_MBUFS, MBUF_CACHE_SIZE, 0, MBUF_SIZE,
184 if (ts_params->mbuf_pool == NULL) {
185 RTE_LOG(ERR, USER1, "Can't create CRYPTO_MBUFPOOL\n");
190 ts_params->large_mbuf_pool = rte_mempool_lookup(
191 "CRYPTO_LARGE_MBUFPOOL");
192 if (ts_params->large_mbuf_pool == NULL) {
193 /* Not already created so create */
194 ts_params->large_mbuf_pool = rte_pktmbuf_pool_create(
195 "CRYPTO_LARGE_MBUFPOOL",
198 if (ts_params->large_mbuf_pool == NULL) {
200 "Can't create CRYPTO_LARGE_MBUFPOOL\n");
205 ts_params->op_mpool = rte_crypto_op_pool_create(
206 "MBUF_CRYPTO_SYM_OP_POOL",
207 RTE_CRYPTO_OP_TYPE_SYMMETRIC,
208 NUM_MBUFS, MBUF_CACHE_SIZE,
210 sizeof(struct rte_crypto_sym_xform) +
213 if (ts_params->op_mpool == NULL) {
214 RTE_LOG(ERR, USER1, "Can't create CRYPTO_OP_POOL\n");
218 /* Create an AESNI MB device if required */
219 if (gbl_driver_id == rte_cryptodev_driver_id_get(
220 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD))) {
221 nb_devs = rte_cryptodev_device_count_by_driver(
222 rte_cryptodev_driver_id_get(
223 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
226 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD), NULL);
228 TEST_ASSERT(ret == 0,
229 "Failed to create instance of"
231 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
235 /* Create an AESNI GCM device if required */
236 if (gbl_driver_id == rte_cryptodev_driver_id_get(
237 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD))) {
238 nb_devs = rte_cryptodev_device_count_by_driver(
239 rte_cryptodev_driver_id_get(
240 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD)));
242 TEST_ASSERT_SUCCESS(rte_vdev_init(
243 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD), NULL),
244 "Failed to create instance of"
246 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
250 /* Create a SNOW 3G device if required */
251 if (gbl_driver_id == rte_cryptodev_driver_id_get(
252 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD))) {
253 nb_devs = rte_cryptodev_device_count_by_driver(
254 rte_cryptodev_driver_id_get(
255 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD)));
257 TEST_ASSERT_SUCCESS(rte_vdev_init(
258 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD), NULL),
259 "Failed to create instance of"
261 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
265 /* Create a KASUMI device if required */
266 if (gbl_driver_id == rte_cryptodev_driver_id_get(
267 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD))) {
268 nb_devs = rte_cryptodev_device_count_by_driver(
269 rte_cryptodev_driver_id_get(
270 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD)));
272 TEST_ASSERT_SUCCESS(rte_vdev_init(
273 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD), NULL),
274 "Failed to create instance of"
276 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
280 /* Create a ZUC device if required */
281 if (gbl_driver_id == rte_cryptodev_driver_id_get(
282 RTE_STR(CRYPTODEV_NAME_ZUC_PMD))) {
283 nb_devs = rte_cryptodev_device_count_by_driver(
284 rte_cryptodev_driver_id_get(
285 RTE_STR(CRYPTODEV_NAME_ZUC_PMD)));
287 TEST_ASSERT_SUCCESS(rte_vdev_init(
288 RTE_STR(CRYPTODEV_NAME_ZUC_PMD), NULL),
289 "Failed to create instance of"
291 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
295 /* Create a NULL device if required */
296 if (gbl_driver_id == rte_cryptodev_driver_id_get(
297 RTE_STR(CRYPTODEV_NAME_NULL_PMD))) {
298 nb_devs = rte_cryptodev_device_count_by_driver(
299 rte_cryptodev_driver_id_get(
300 RTE_STR(CRYPTODEV_NAME_NULL_PMD)));
303 RTE_STR(CRYPTODEV_NAME_NULL_PMD), NULL);
305 TEST_ASSERT(ret == 0,
306 "Failed to create instance of"
308 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
312 /* Create an OPENSSL device if required */
313 if (gbl_driver_id == rte_cryptodev_driver_id_get(
314 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD))) {
315 nb_devs = rte_cryptodev_device_count_by_driver(
316 rte_cryptodev_driver_id_get(
317 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)));
320 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD),
323 TEST_ASSERT(ret == 0, "Failed to create "
324 "instance of pmd : %s",
325 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
329 /* Create a ARMv8 device if required */
330 if (gbl_driver_id == rte_cryptodev_driver_id_get(
331 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD))) {
332 nb_devs = rte_cryptodev_device_count_by_driver(
333 rte_cryptodev_driver_id_get(
334 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)));
337 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD),
340 TEST_ASSERT(ret == 0, "Failed to create "
341 "instance of pmd : %s",
342 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
346 /* Create a MVSAM device if required */
347 if (gbl_driver_id == rte_cryptodev_driver_id_get(
348 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD))) {
349 nb_devs = rte_cryptodev_device_count_by_driver(
350 rte_cryptodev_driver_id_get(
351 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)));
354 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD),
357 TEST_ASSERT(ret == 0, "Failed to create "
358 "instance of pmd : %s",
359 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
363 /* Create an CCP device if required */
364 if (gbl_driver_id == rte_cryptodev_driver_id_get(
365 RTE_STR(CRYPTODEV_NAME_CCP_PMD))) {
366 nb_devs = rte_cryptodev_device_count_by_driver(
367 rte_cryptodev_driver_id_get(
368 RTE_STR(CRYPTODEV_NAME_CCP_PMD)));
371 RTE_STR(CRYPTODEV_NAME_CCP_PMD),
374 TEST_ASSERT(ret == 0, "Failed to create "
375 "instance of pmd : %s",
376 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
380 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
381 char vdev_args[VDEV_ARGS_SIZE] = {""};
382 char temp_str[VDEV_ARGS_SIZE] = {"mode=multi-core,"
383 "ordering=enable,name=cryptodev_test_scheduler,corelist="};
384 uint16_t slave_core_count = 0;
385 uint16_t socket_id = 0;
387 if (gbl_driver_id == rte_cryptodev_driver_id_get(
388 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD))) {
390 /* Identify the Slave Cores
391 * Use 2 slave cores for the device args
393 RTE_LCORE_FOREACH_SLAVE(i) {
394 if (slave_core_count > 1)
396 snprintf(vdev_args, sizeof(vdev_args),
397 "%s%d", temp_str, i);
398 strcpy(temp_str, vdev_args);
399 strlcat(temp_str, ";", sizeof(temp_str));
401 socket_id = rte_lcore_to_socket_id(i);
403 if (slave_core_count != 2) {
405 "Cryptodev scheduler test require at least "
406 "two slave cores to run. "
407 "Please use the correct coremask.\n");
410 strcpy(temp_str, vdev_args);
411 snprintf(vdev_args, sizeof(vdev_args), "%s,socket_id=%d",
412 temp_str, socket_id);
413 RTE_LOG(DEBUG, USER1, "vdev_args: %s\n", vdev_args);
414 nb_devs = rte_cryptodev_device_count_by_driver(
415 rte_cryptodev_driver_id_get(
416 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)));
419 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD),
421 TEST_ASSERT(ret == 0,
422 "Failed to create instance %u of"
424 i, RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
427 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
429 nb_devs = rte_cryptodev_count();
431 RTE_LOG(WARNING, USER1, "No crypto devices found?\n");
435 /* Create list of valid crypto devs */
436 for (i = 0; i < nb_devs; i++) {
437 rte_cryptodev_info_get(i, &info);
438 if (info.driver_id == gbl_driver_id)
439 ts_params->valid_devs[ts_params->valid_dev_count++] = i;
442 if (ts_params->valid_dev_count < 1)
445 /* Set up all the qps on the first of the valid devices found */
447 dev_id = ts_params->valid_devs[0];
449 rte_cryptodev_info_get(dev_id, &info);
451 ts_params->conf.nb_queue_pairs = info.max_nb_queue_pairs;
452 ts_params->conf.socket_id = SOCKET_ID_ANY;
453 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
455 unsigned int session_size =
456 rte_cryptodev_sym_get_private_session_size(dev_id);
459 * Create mempool with maximum number of sessions * 2,
460 * to include the session headers
462 if (info.sym.max_nb_sessions != 0 &&
463 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
464 RTE_LOG(ERR, USER1, "Device does not support "
465 "at least %u sessions\n",
470 ts_params->session_mpool = rte_cryptodev_sym_session_pool_create(
471 "test_sess_mp", MAX_NB_SESSIONS, 0, 0, 0,
473 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
474 "session mempool allocation failed");
476 ts_params->session_priv_mpool = rte_mempool_create(
480 0, 0, NULL, NULL, NULL,
483 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
484 "session mempool allocation failed");
488 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id,
490 "Failed to configure cryptodev %u with %u qps",
491 dev_id, ts_params->conf.nb_queue_pairs);
493 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
494 ts_params->qp_conf.mp_session = ts_params->session_mpool;
495 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
497 for (qp_id = 0; qp_id < info.max_nb_queue_pairs; qp_id++) {
498 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
499 dev_id, qp_id, &ts_params->qp_conf,
500 rte_cryptodev_socket_id(dev_id)),
501 "Failed to setup queue pair %u on cryptodev %u",
509 testsuite_teardown(void)
511 struct crypto_testsuite_params *ts_params = &testsuite_params;
513 if (ts_params->mbuf_pool != NULL) {
514 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
515 rte_mempool_avail_count(ts_params->mbuf_pool));
518 if (ts_params->op_mpool != NULL) {
519 RTE_LOG(DEBUG, USER1, "CRYPTO_OP_POOL count %u\n",
520 rte_mempool_avail_count(ts_params->op_mpool));
523 /* Free session mempools */
524 if (ts_params->session_priv_mpool != NULL) {
525 rte_mempool_free(ts_params->session_priv_mpool);
526 ts_params->session_priv_mpool = NULL;
529 if (ts_params->session_mpool != NULL) {
530 rte_mempool_free(ts_params->session_mpool);
531 ts_params->session_mpool = NULL;
538 struct crypto_testsuite_params *ts_params = &testsuite_params;
539 struct crypto_unittest_params *ut_params = &unittest_params;
543 /* Clear unit test parameters before running test */
544 memset(ut_params, 0, sizeof(*ut_params));
546 /* Reconfigure device to default parameters */
547 ts_params->conf.socket_id = SOCKET_ID_ANY;
548 ts_params->conf.ff_disable = RTE_CRYPTODEV_FF_SECURITY;
549 ts_params->qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT;
550 ts_params->qp_conf.mp_session = ts_params->session_mpool;
551 ts_params->qp_conf.mp_session_private = ts_params->session_priv_mpool;
553 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
555 "Failed to configure cryptodev %u",
556 ts_params->valid_devs[0]);
558 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs ; qp_id++) {
559 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
560 ts_params->valid_devs[0], qp_id,
562 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
563 "Failed to setup queue pair %u on cryptodev %u",
564 qp_id, ts_params->valid_devs[0]);
568 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
570 /* Start the device */
571 TEST_ASSERT_SUCCESS(rte_cryptodev_start(ts_params->valid_devs[0]),
572 "Failed to start cryptodev %u",
573 ts_params->valid_devs[0]);
581 struct crypto_testsuite_params *ts_params = &testsuite_params;
582 struct crypto_unittest_params *ut_params = &unittest_params;
583 struct rte_cryptodev_stats stats;
585 /* free crypto session structure */
586 #ifdef RTE_LIBRTE_SECURITY
587 if (ut_params->type == RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL) {
588 if (ut_params->sec_session) {
589 rte_security_session_destroy(rte_cryptodev_get_sec_ctx
590 (ts_params->valid_devs[0]),
591 ut_params->sec_session);
592 ut_params->sec_session = NULL;
597 if (ut_params->sess) {
598 rte_cryptodev_sym_session_clear(
599 ts_params->valid_devs[0],
601 rte_cryptodev_sym_session_free(ut_params->sess);
602 ut_params->sess = NULL;
606 /* free crypto operation structure */
608 rte_crypto_op_free(ut_params->op);
611 * free mbuf - both obuf and ibuf are usually the same,
612 * so check if they point at the same address is necessary,
613 * to avoid freeing the mbuf twice.
615 if (ut_params->obuf) {
616 rte_pktmbuf_free(ut_params->obuf);
617 if (ut_params->ibuf == ut_params->obuf)
621 if (ut_params->ibuf) {
622 rte_pktmbuf_free(ut_params->ibuf);
626 if (ts_params->mbuf_pool != NULL)
627 RTE_LOG(DEBUG, USER1, "CRYPTO_MBUFPOOL count %u\n",
628 rte_mempool_avail_count(ts_params->mbuf_pool));
630 rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats);
632 /* Stop the device */
633 rte_cryptodev_stop(ts_params->valid_devs[0]);
637 test_device_configure_invalid_dev_id(void)
639 struct crypto_testsuite_params *ts_params = &testsuite_params;
640 uint16_t dev_id, num_devs = 0;
642 TEST_ASSERT((num_devs = rte_cryptodev_count()) >= 1,
643 "Need at least %d devices for test", 1);
645 /* valid dev_id values */
646 dev_id = ts_params->valid_devs[ts_params->valid_dev_count - 1];
648 /* Stop the device in case it's started so it can be configured */
649 rte_cryptodev_stop(dev_id);
651 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(dev_id, &ts_params->conf),
652 "Failed test for rte_cryptodev_configure: "
653 "invalid dev_num %u", dev_id);
655 /* invalid dev_id values */
658 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
659 "Failed test for rte_cryptodev_configure: "
660 "invalid dev_num %u", dev_id);
664 TEST_ASSERT_FAIL(rte_cryptodev_configure(dev_id, &ts_params->conf),
665 "Failed test for rte_cryptodev_configure:"
666 "invalid dev_num %u", dev_id);
672 test_device_configure_invalid_queue_pair_ids(void)
674 struct crypto_testsuite_params *ts_params = &testsuite_params;
675 uint16_t orig_nb_qps = ts_params->conf.nb_queue_pairs;
677 /* Stop the device in case it's started so it can be configured */
678 rte_cryptodev_stop(ts_params->valid_devs[0]);
680 /* valid - one queue pairs */
681 ts_params->conf.nb_queue_pairs = 1;
683 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
685 "Failed to configure cryptodev: dev_id %u, qp_id %u",
686 ts_params->valid_devs[0], ts_params->conf.nb_queue_pairs);
689 /* valid - max value queue pairs */
690 ts_params->conf.nb_queue_pairs = orig_nb_qps;
692 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
694 "Failed to configure cryptodev: dev_id %u, qp_id %u",
695 ts_params->valid_devs[0],
696 ts_params->conf.nb_queue_pairs);
699 /* invalid - zero queue pairs */
700 ts_params->conf.nb_queue_pairs = 0;
702 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
704 "Failed test for rte_cryptodev_configure, dev_id %u,"
706 ts_params->valid_devs[0],
707 ts_params->conf.nb_queue_pairs);
710 /* invalid - max value supported by field queue pairs */
711 ts_params->conf.nb_queue_pairs = UINT16_MAX;
713 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
715 "Failed test for rte_cryptodev_configure, dev_id %u,"
717 ts_params->valid_devs[0],
718 ts_params->conf.nb_queue_pairs);
721 /* invalid - max value + 1 queue pairs */
722 ts_params->conf.nb_queue_pairs = orig_nb_qps + 1;
724 TEST_ASSERT_FAIL(rte_cryptodev_configure(ts_params->valid_devs[0],
726 "Failed test for rte_cryptodev_configure, dev_id %u,"
728 ts_params->valid_devs[0],
729 ts_params->conf.nb_queue_pairs);
731 /* revert to original testsuite value */
732 ts_params->conf.nb_queue_pairs = orig_nb_qps;
738 test_queue_pair_descriptor_setup(void)
740 struct crypto_testsuite_params *ts_params = &testsuite_params;
741 struct rte_cryptodev_info dev_info;
742 struct rte_cryptodev_qp_conf qp_conf = {
743 .nb_descriptors = MAX_NUM_OPS_INFLIGHT
748 /* Stop the device in case it's started so it can be configured */
749 rte_cryptodev_stop(ts_params->valid_devs[0]);
752 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
754 TEST_ASSERT_SUCCESS(rte_cryptodev_configure(ts_params->valid_devs[0],
756 "Failed to configure cryptodev %u",
757 ts_params->valid_devs[0]);
760 * Test various ring sizes on this device. memzones can't be
761 * freed so are re-used if ring is released and re-created.
763 qp_conf.nb_descriptors = MIN_NUM_OPS_INFLIGHT; /* min size*/
764 qp_conf.mp_session = ts_params->session_mpool;
765 qp_conf.mp_session_private = ts_params->session_priv_mpool;
767 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
768 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
769 ts_params->valid_devs[0], qp_id, &qp_conf,
770 rte_cryptodev_socket_id(
771 ts_params->valid_devs[0])),
773 "rte_cryptodev_queue_pair_setup: num_inflights "
774 "%u on qp %u on cryptodev %u",
775 qp_conf.nb_descriptors, qp_id,
776 ts_params->valid_devs[0]);
779 qp_conf.nb_descriptors = (uint32_t)(MAX_NUM_OPS_INFLIGHT / 2);
781 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
782 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
783 ts_params->valid_devs[0], qp_id, &qp_conf,
784 rte_cryptodev_socket_id(
785 ts_params->valid_devs[0])),
787 " rte_cryptodev_queue_pair_setup: num_inflights"
788 " %u on qp %u on cryptodev %u",
789 qp_conf.nb_descriptors, qp_id,
790 ts_params->valid_devs[0]);
793 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT; /* valid */
795 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
796 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
797 ts_params->valid_devs[0], qp_id, &qp_conf,
798 rte_cryptodev_socket_id(
799 ts_params->valid_devs[0])),
801 "rte_cryptodev_queue_pair_setup: num_inflights"
802 " %u on qp %u on cryptodev %u",
803 qp_conf.nb_descriptors, qp_id,
804 ts_params->valid_devs[0]);
807 /* invalid number of descriptors - max supported + 2 */
808 qp_conf.nb_descriptors = MAX_NUM_OPS_INFLIGHT + 2;
810 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
811 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
812 ts_params->valid_devs[0], qp_id, &qp_conf,
813 rte_cryptodev_socket_id(
814 ts_params->valid_devs[0])),
815 "Unexpectedly passed test for "
816 "rte_cryptodev_queue_pair_setup:"
817 "num_inflights %u on qp %u on cryptodev %u",
818 qp_conf.nb_descriptors, qp_id,
819 ts_params->valid_devs[0]);
822 /* invalid number of descriptors - max value of parameter */
823 qp_conf.nb_descriptors = UINT32_MAX-1;
825 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
826 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
827 ts_params->valid_devs[0], qp_id, &qp_conf,
828 rte_cryptodev_socket_id(
829 ts_params->valid_devs[0])),
830 "Unexpectedly passed test for "
831 "rte_cryptodev_queue_pair_setup:"
832 "num_inflights %u on qp %u on cryptodev %u",
833 qp_conf.nb_descriptors, qp_id,
834 ts_params->valid_devs[0]);
837 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT;
839 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
840 TEST_ASSERT_SUCCESS(rte_cryptodev_queue_pair_setup(
841 ts_params->valid_devs[0], qp_id, &qp_conf,
842 rte_cryptodev_socket_id(
843 ts_params->valid_devs[0])),
845 " rte_cryptodev_queue_pair_setup:"
846 "num_inflights %u on qp %u on cryptodev %u",
847 qp_conf.nb_descriptors, qp_id,
848 ts_params->valid_devs[0]);
851 /* invalid number of descriptors - max supported + 1 */
852 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT + 1;
854 for (qp_id = 0; qp_id < ts_params->conf.nb_queue_pairs; qp_id++) {
855 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
856 ts_params->valid_devs[0], qp_id, &qp_conf,
857 rte_cryptodev_socket_id(
858 ts_params->valid_devs[0])),
859 "Unexpectedly passed test for "
860 "rte_cryptodev_queue_pair_setup:"
861 "num_inflights %u on qp %u on cryptodev %u",
862 qp_conf.nb_descriptors, qp_id,
863 ts_params->valid_devs[0]);
866 /* test invalid queue pair id */
867 qp_conf.nb_descriptors = DEFAULT_NUM_OPS_INFLIGHT; /*valid */
869 qp_id = ts_params->conf.nb_queue_pairs; /*invalid */
871 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
872 ts_params->valid_devs[0],
874 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
875 "Failed test for rte_cryptodev_queue_pair_setup:"
876 "invalid qp %u on cryptodev %u",
877 qp_id, ts_params->valid_devs[0]);
879 qp_id = 0xffff; /*invalid*/
881 TEST_ASSERT_FAIL(rte_cryptodev_queue_pair_setup(
882 ts_params->valid_devs[0],
884 rte_cryptodev_socket_id(ts_params->valid_devs[0])),
885 "Failed test for rte_cryptodev_queue_pair_setup:"
886 "invalid qp %u on cryptodev %u",
887 qp_id, ts_params->valid_devs[0]);
892 /* ***** Plaintext data for tests ***** */
894 const char catch_22_quote_1[] =
895 "There was only one catch and that was Catch-22, which "
896 "specified that a concern for one's safety in the face of "
897 "dangers that were real and immediate was the process of a "
898 "rational mind. Orr was crazy and could be grounded. All he "
899 "had to do was ask; and as soon as he did, he would no longer "
900 "be crazy and would have to fly more missions. Orr would be "
901 "crazy to fly more missions and sane if he didn't, but if he "
902 "was sane he had to fly them. If he flew them he was crazy "
903 "and didn't have to; but if he didn't want to he was sane and "
904 "had to. Yossarian was moved very deeply by the absolute "
905 "simplicity of this clause of Catch-22 and let out a "
906 "respectful whistle. \"That's some catch, that Catch-22\", he "
907 "observed. \"It's the best there is,\" Doc Daneeka agreed.";
909 const char catch_22_quote[] =
910 "What a lousy earth! He wondered how many people were "
911 "destitute that same night even in his own prosperous country, "
912 "how many homes were shanties, how many husbands were drunk "
913 "and wives socked, and how many children were bullied, abused, "
914 "or abandoned. How many families hungered for food they could "
915 "not afford to buy? How many hearts were broken? How many "
916 "suicides would take place that same night, how many people "
917 "would go insane? How many cockroaches and landlords would "
918 "triumph? How many winners were losers, successes failures, "
919 "and rich men poor men? How many wise guys were stupid? How "
920 "many happy endings were unhappy endings? How many honest men "
921 "were liars, brave men cowards, loyal men traitors, how many "
922 "sainted men were corrupt, how many people in positions of "
923 "trust had sold their souls to bodyguards, how many had never "
924 "had souls? How many straight-and-narrow paths were crooked "
925 "paths? How many best families were worst families and how "
926 "many good people were bad people? When you added them all up "
927 "and then subtracted, you might be left with only the children, "
928 "and perhaps with Albert Einstein and an old violinist or "
929 "sculptor somewhere.";
931 #define QUOTE_480_BYTES (480)
932 #define QUOTE_512_BYTES (512)
933 #define QUOTE_768_BYTES (768)
934 #define QUOTE_1024_BYTES (1024)
938 /* ***** SHA1 Hash Tests ***** */
940 #define HMAC_KEY_LENGTH_SHA1 (DIGEST_BYTE_LENGTH_SHA1)
942 static uint8_t hmac_sha1_key[] = {
943 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
944 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
945 0xDE, 0xF4, 0xDE, 0xAD };
947 /* ***** SHA224 Hash Tests ***** */
949 #define HMAC_KEY_LENGTH_SHA224 (DIGEST_BYTE_LENGTH_SHA224)
952 /* ***** AES-CBC Cipher Tests ***** */
954 #define CIPHER_KEY_LENGTH_AES_CBC (16)
955 #define CIPHER_IV_LENGTH_AES_CBC (CIPHER_KEY_LENGTH_AES_CBC)
957 static uint8_t aes_cbc_key[] = {
958 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
959 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A };
961 static uint8_t aes_cbc_iv[] = {
962 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
963 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f };
966 /* ***** AES-CBC / HMAC-SHA1 Hash Tests ***** */
968 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_ciphertext[] = {
969 0x8B, 0x4D, 0xDA, 0x1B, 0xCF, 0x04, 0xA0, 0x31,
970 0xB4, 0xBF, 0xBD, 0x68, 0x43, 0x20, 0x7E, 0x76,
971 0xB1, 0x96, 0x8B, 0xA2, 0x7C, 0xA2, 0x83, 0x9E,
972 0x39, 0x5A, 0x2F, 0x7E, 0x92, 0xB4, 0x48, 0x1A,
973 0x3F, 0x6B, 0x5D, 0xDF, 0x52, 0x85, 0x5F, 0x8E,
974 0x42, 0x3C, 0xFB, 0xE9, 0x1A, 0x24, 0xD6, 0x08,
975 0xDD, 0xFD, 0x16, 0xFB, 0xE9, 0x55, 0xEF, 0xF0,
976 0xA0, 0x8D, 0x13, 0xAB, 0x81, 0xC6, 0x90, 0x01,
977 0xB5, 0x18, 0x84, 0xB3, 0xF6, 0xE6, 0x11, 0x57,
978 0xD6, 0x71, 0xC6, 0x3C, 0x3F, 0x2F, 0x33, 0xEE,
979 0x24, 0x42, 0x6E, 0xAC, 0x0B, 0xCA, 0xEC, 0xF9,
980 0x84, 0xF8, 0x22, 0xAA, 0x60, 0xF0, 0x32, 0xA9,
981 0x75, 0x75, 0x3B, 0xCB, 0x70, 0x21, 0x0A, 0x8D,
982 0x0F, 0xE0, 0xC4, 0x78, 0x2B, 0xF8, 0x97, 0xE3,
983 0xE4, 0x26, 0x4B, 0x29, 0xDA, 0x88, 0xCD, 0x46,
984 0xEC, 0xAA, 0xF9, 0x7F, 0xF1, 0x15, 0xEA, 0xC3,
985 0x87, 0xE6, 0x31, 0xF2, 0xCF, 0xDE, 0x4D, 0x80,
986 0x70, 0x91, 0x7E, 0x0C, 0xF7, 0x26, 0x3A, 0x92,
987 0x4F, 0x18, 0x83, 0xC0, 0x8F, 0x59, 0x01, 0xA5,
988 0x88, 0xD1, 0xDB, 0x26, 0x71, 0x27, 0x16, 0xF5,
989 0xEE, 0x10, 0x82, 0xAC, 0x68, 0x26, 0x9B, 0xE2,
990 0x6D, 0xD8, 0x9A, 0x80, 0xDF, 0x04, 0x31, 0xD5,
991 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
992 0x58, 0x34, 0x85, 0x61, 0x1C, 0x42, 0x10, 0x76,
993 0x73, 0x02, 0x42, 0xC9, 0x23, 0x18, 0x8E, 0xB4,
994 0x6F, 0xB4, 0xA3, 0x54, 0x6E, 0x88, 0x3B, 0x62,
995 0x7C, 0x02, 0x8D, 0x4C, 0x9F, 0xC8, 0x45, 0xF4,
996 0xC9, 0xDE, 0x4F, 0xEB, 0x22, 0x83, 0x1B, 0xE4,
997 0x49, 0x37, 0xE4, 0xAD, 0xE7, 0xCD, 0x21, 0x54,
998 0xBC, 0x1C, 0xC2, 0x04, 0x97, 0xB4, 0x10, 0x61,
999 0xF0, 0xE4, 0xEF, 0x27, 0x63, 0x3A, 0xDA, 0x91,
1000 0x41, 0x25, 0x62, 0x1C, 0x5C, 0xB6, 0x38, 0x4A,
1001 0x88, 0x71, 0x59, 0x5A, 0x8D, 0xA0, 0x09, 0xAF,
1002 0x72, 0x94, 0xD7, 0x79, 0x5C, 0x60, 0x7C, 0x8F,
1003 0x4C, 0xF5, 0xD9, 0xA1, 0x39, 0x6D, 0x81, 0x28,
1004 0xEF, 0x13, 0x28, 0xDF, 0xF5, 0x3E, 0xF7, 0x8E,
1005 0x09, 0x9C, 0x78, 0x18, 0x79, 0xB8, 0x68, 0xD7,
1006 0xA8, 0x29, 0x62, 0xAD, 0xDE, 0xE1, 0x61, 0x76,
1007 0x1B, 0x05, 0x16, 0xCD, 0xBF, 0x02, 0x8E, 0xA6,
1008 0x43, 0x6E, 0x92, 0x55, 0x4F, 0x60, 0x9C, 0x03,
1009 0xB8, 0x4F, 0xA3, 0x02, 0xAC, 0xA8, 0xA7, 0x0C,
1010 0x1E, 0xB5, 0x6B, 0xF8, 0xC8, 0x4D, 0xDE, 0xD2,
1011 0xB0, 0x29, 0x6E, 0x40, 0xE6, 0xD6, 0xC9, 0xE6,
1012 0xB9, 0x0F, 0xB6, 0x63, 0xF5, 0xAA, 0x2B, 0x96,
1013 0xA7, 0x16, 0xAC, 0x4E, 0x0A, 0x33, 0x1C, 0xA6,
1014 0xE6, 0xBD, 0x8A, 0xCF, 0x40, 0xA9, 0xB2, 0xFA,
1015 0x63, 0x27, 0xFD, 0x9B, 0xD9, 0xFC, 0xD5, 0x87,
1016 0x8D, 0x4C, 0xB6, 0xA4, 0xCB, 0xE7, 0x74, 0x55,
1017 0xF4, 0xFB, 0x41, 0x25, 0xB5, 0x4B, 0x0A, 0x1B,
1018 0xB1, 0xD6, 0xB7, 0xD9, 0x47, 0x2A, 0xC3, 0x98,
1019 0x6A, 0xC4, 0x03, 0x73, 0x1F, 0x93, 0x6E, 0x53,
1020 0x19, 0x25, 0x64, 0x15, 0x83, 0xF9, 0x73, 0x2A,
1021 0x74, 0xB4, 0x93, 0x69, 0xC4, 0x72, 0xFC, 0x26,
1022 0xA2, 0x9F, 0x43, 0x45, 0xDD, 0xB9, 0xEF, 0x36,
1023 0xC8, 0x3A, 0xCD, 0x99, 0x9B, 0x54, 0x1A, 0x36,
1024 0xC1, 0x59, 0xF8, 0x98, 0xA8, 0xCC, 0x28, 0x0D,
1025 0x73, 0x4C, 0xEE, 0x98, 0xCB, 0x7C, 0x58, 0x7E,
1026 0x20, 0x75, 0x1E, 0xB7, 0xC9, 0xF8, 0xF2, 0x0E,
1027 0x63, 0x9E, 0x05, 0x78, 0x1A, 0xB6, 0xA8, 0x7A,
1028 0xF9, 0x98, 0x6A, 0xA6, 0x46, 0x84, 0x2E, 0xF6,
1029 0x4B, 0xDC, 0x9B, 0x8F, 0x9B, 0x8F, 0xEE, 0xB4,
1030 0xAA, 0x3F, 0xEE, 0xC0, 0x37, 0x27, 0x76, 0xC7,
1031 0x95, 0xBB, 0x26, 0x74, 0x69, 0x12, 0x7F, 0xF1,
1032 0xBB, 0xFF, 0xAE, 0xB5, 0x99, 0x6E, 0xCB, 0x0C
1035 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest[] = {
1036 0x9a, 0x4f, 0x88, 0x1b, 0xb6, 0x8f, 0xd8, 0x60,
1037 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1038 0x18, 0x8c, 0x1d, 0x32
1042 /* Multisession Vector context Test */
1043 /*Begin Session 0 */
1044 static uint8_t ms_aes_cbc_key0[] = {
1045 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1046 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1049 static uint8_t ms_aes_cbc_iv0[] = {
1050 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1051 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1054 static const uint8_t ms_aes_cbc_cipher0[] = {
1055 0x3C, 0xE4, 0xEE, 0x42, 0xB6, 0x9B, 0xC3, 0x38,
1056 0x5F, 0xAD, 0x54, 0xDC, 0xA8, 0x32, 0x81, 0xDC,
1057 0x7A, 0x6F, 0x85, 0x58, 0x07, 0x35, 0xED, 0xEB,
1058 0xAD, 0x79, 0x79, 0x96, 0xD3, 0x0E, 0xA6, 0xD9,
1059 0xAA, 0x86, 0xA4, 0x8F, 0xB5, 0xD6, 0x6E, 0x6D,
1060 0x0C, 0x91, 0x2F, 0xC4, 0x67, 0x98, 0x0E, 0xC4,
1061 0x8D, 0x83, 0x68, 0x69, 0xC4, 0xD3, 0x94, 0x34,
1062 0xC4, 0x5D, 0x60, 0x55, 0x22, 0x87, 0x8F, 0x6F,
1063 0x17, 0x8E, 0x75, 0xE4, 0x02, 0xF5, 0x1B, 0x99,
1064 0xC8, 0x39, 0xA9, 0xAB, 0x23, 0x91, 0x12, 0xED,
1065 0x08, 0xE7, 0xD9, 0x25, 0x89, 0x24, 0x4F, 0x8D,
1066 0x68, 0xF3, 0x10, 0x39, 0x0A, 0xEE, 0x45, 0x24,
1067 0xDF, 0x7A, 0x9D, 0x00, 0x25, 0xE5, 0x35, 0x71,
1068 0x4E, 0x40, 0x59, 0x6F, 0x0A, 0x13, 0xB3, 0x72,
1069 0x1D, 0x98, 0x63, 0x94, 0x89, 0xA5, 0x39, 0x8E,
1070 0xD3, 0x9C, 0x8A, 0x7F, 0x71, 0x2F, 0xC7, 0xCD,
1071 0x81, 0x05, 0xDC, 0xC0, 0x8D, 0xCE, 0x6D, 0x18,
1072 0x30, 0xC4, 0x72, 0x51, 0xF0, 0x27, 0xC8, 0xF6,
1073 0x60, 0x5B, 0x7C, 0xB2, 0xE3, 0x49, 0x0C, 0x29,
1074 0xC6, 0x9F, 0x39, 0x57, 0x80, 0x55, 0x24, 0x2C,
1075 0x9B, 0x0F, 0x5A, 0xB3, 0x89, 0x55, 0x31, 0x96,
1076 0x0D, 0xCD, 0xF6, 0x51, 0x03, 0x2D, 0x89, 0x26,
1077 0x74, 0x44, 0xD6, 0xE8, 0xDC, 0xEA, 0x44, 0x55,
1078 0x64, 0x71, 0x9C, 0x9F, 0x5D, 0xBA, 0x39, 0x46,
1079 0xA8, 0x17, 0xA1, 0x9C, 0x52, 0x9D, 0xBC, 0x6B,
1080 0x4A, 0x98, 0xE6, 0xEA, 0x33, 0xEC, 0x58, 0xB4,
1081 0x43, 0xF0, 0x32, 0x45, 0xA4, 0xC1, 0x55, 0xB7,
1082 0x5D, 0xB5, 0x59, 0xB2, 0xE3, 0x96, 0xFF, 0xA5,
1083 0xAF, 0xE1, 0x86, 0x1B, 0x42, 0xE6, 0x3B, 0xA0,
1084 0x90, 0x4A, 0xE8, 0x8C, 0x21, 0x7F, 0x36, 0x1E,
1085 0x5B, 0x65, 0x25, 0xD1, 0xC1, 0x5A, 0xCA, 0x3D,
1086 0x10, 0xED, 0x2D, 0x79, 0xD0, 0x0F, 0x58, 0x44,
1087 0x69, 0x81, 0xF5, 0xD4, 0xC9, 0x0F, 0x90, 0x76,
1088 0x1F, 0x54, 0xD2, 0xD5, 0x97, 0xCE, 0x2C, 0xE3,
1089 0xEF, 0xF4, 0xB7, 0xC6, 0x3A, 0x87, 0x7F, 0x83,
1090 0x2A, 0xAF, 0xCD, 0x90, 0x12, 0xA7, 0x7D, 0x85,
1091 0x1D, 0x62, 0xD3, 0x85, 0x25, 0x05, 0xDB, 0x45,
1092 0x92, 0xA3, 0xF6, 0xA2, 0xA8, 0x41, 0xE4, 0x25,
1093 0x86, 0x87, 0x67, 0x24, 0xEC, 0x89, 0x23, 0x2A,
1094 0x9B, 0x20, 0x4D, 0x93, 0xEE, 0xE2, 0x2E, 0xC1,
1095 0x0B, 0x15, 0x33, 0xCF, 0x00, 0xD1, 0x1A, 0xDA,
1096 0x93, 0xFD, 0x28, 0x21, 0x5B, 0xCF, 0xD1, 0xF3,
1097 0x5A, 0x81, 0xBA, 0x82, 0x5E, 0x2F, 0x61, 0xB4,
1098 0x05, 0x71, 0xB5, 0xF4, 0x39, 0x3C, 0x1F, 0x60,
1099 0x00, 0x7A, 0xC4, 0xF8, 0x35, 0x20, 0x6C, 0x3A,
1100 0xCC, 0x03, 0x8F, 0x7B, 0xA2, 0xB6, 0x65, 0x8A,
1101 0xB6, 0x5F, 0xFD, 0x25, 0xD3, 0x5F, 0x92, 0xF9,
1102 0xAE, 0x17, 0x9B, 0x5E, 0x6E, 0x9A, 0xE4, 0x55,
1103 0x10, 0x25, 0x07, 0xA4, 0xAF, 0x21, 0x69, 0x13,
1104 0xD8, 0xFA, 0x31, 0xED, 0xF7, 0xA7, 0xA7, 0x3B,
1105 0xB8, 0x96, 0x8E, 0x10, 0x86, 0x74, 0xD8, 0xB1,
1106 0x34, 0x9E, 0x9B, 0x6A, 0x26, 0xA8, 0xD4, 0xD0,
1107 0xB5, 0xF6, 0xDE, 0xE7, 0xCA, 0x06, 0xDC, 0xA3,
1108 0x6F, 0xEE, 0x6B, 0x1E, 0xB5, 0x30, 0x99, 0x23,
1109 0xF9, 0x76, 0xF0, 0xA0, 0xCF, 0x3B, 0x94, 0x7B,
1110 0x19, 0x8D, 0xA5, 0x0C, 0x18, 0xA6, 0x1D, 0x07,
1111 0x89, 0xBE, 0x5B, 0x61, 0xE5, 0xF1, 0x42, 0xDB,
1112 0xD4, 0x2E, 0x02, 0x1F, 0xCE, 0xEF, 0x92, 0xB1,
1113 0x1B, 0x56, 0x50, 0xF2, 0x16, 0xE5, 0xE7, 0x4F,
1114 0xFD, 0xBB, 0x3E, 0xD2, 0xFC, 0x3C, 0xC6, 0x0F,
1115 0xF9, 0x12, 0x4E, 0xCB, 0x1E, 0x0C, 0x15, 0x84,
1116 0x2A, 0x14, 0x8A, 0x02, 0xE4, 0x7E, 0x95, 0x5B,
1117 0x86, 0xDB, 0x9B, 0x62, 0x5B, 0x19, 0xD2, 0x17,
1118 0xFA, 0x13, 0xBB, 0x6B, 0x3F, 0x45, 0x9F, 0xBF
1122 static uint8_t ms_hmac_key0[] = {
1123 0xFF, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1124 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1125 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1126 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1127 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1128 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1129 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1130 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1133 static const uint8_t ms_hmac_digest0[] = {
1134 0x43, 0x52, 0xED, 0x34, 0xAB, 0x36, 0xB2, 0x51,
1135 0xFB, 0xA3, 0xA6, 0x7C, 0x38, 0xFC, 0x42, 0x8F,
1136 0x57, 0x64, 0xAB, 0x81, 0xA7, 0x89, 0xB7, 0x6C,
1137 0xA0, 0xDC, 0xB9, 0x4D, 0xC4, 0x30, 0xF9, 0xD4,
1138 0x10, 0x82, 0x55, 0xD0, 0xAB, 0x32, 0xFB, 0x56,
1139 0x0D, 0xE4, 0x68, 0x3D, 0x76, 0xD0, 0x7B, 0xE4,
1140 0xA6, 0x2C, 0x34, 0x9E, 0x8C, 0x41, 0xF8, 0x23,
1141 0x28, 0x1B, 0x3A, 0x90, 0x26, 0x34, 0x47, 0x90
1145 /* Begin session 1 */
1147 static uint8_t ms_aes_cbc_key1[] = {
1148 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1149 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1152 static uint8_t ms_aes_cbc_iv1[] = {
1153 0xf1, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1154 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1157 static const uint8_t ms_aes_cbc_cipher1[] = {
1158 0x5A, 0x7A, 0x67, 0x5D, 0xB8, 0xE1, 0xDC, 0x71,
1159 0x39, 0xA8, 0x74, 0x93, 0x9C, 0x4C, 0xFE, 0x23,
1160 0x61, 0xCD, 0xA4, 0xB3, 0xD9, 0xCE, 0x99, 0x09,
1161 0x2A, 0x23, 0xF3, 0x29, 0xBF, 0x4C, 0xB4, 0x6A,
1162 0x1B, 0x6B, 0x73, 0x4D, 0x48, 0x0C, 0xCF, 0x6C,
1163 0x5E, 0x34, 0x9E, 0x7F, 0xBC, 0x8F, 0xCC, 0x8F,
1164 0x75, 0x1D, 0x3D, 0x77, 0x10, 0x76, 0xC8, 0xB9,
1165 0x99, 0x6F, 0xD6, 0x56, 0x75, 0xA9, 0xB2, 0x66,
1166 0xC2, 0x24, 0x2B, 0x9C, 0xFE, 0x40, 0x8E, 0x43,
1167 0x20, 0x97, 0x1B, 0xFA, 0xD0, 0xCF, 0x04, 0xAB,
1168 0xBB, 0xF6, 0x5D, 0xF5, 0xA0, 0x19, 0x7C, 0x23,
1169 0x5D, 0x80, 0x8C, 0x49, 0xF6, 0x76, 0x88, 0x29,
1170 0x27, 0x4C, 0x59, 0x2B, 0x43, 0xA6, 0xB2, 0x26,
1171 0x27, 0x78, 0xBE, 0x1B, 0xE1, 0x4F, 0x5A, 0x1F,
1172 0xFC, 0x68, 0x08, 0xE7, 0xC4, 0xD1, 0x34, 0x68,
1173 0xB7, 0x13, 0x14, 0x41, 0x62, 0x6B, 0x1F, 0x77,
1174 0x0C, 0x68, 0x1D, 0x0D, 0xED, 0x89, 0xAA, 0xD8,
1175 0x97, 0x02, 0xBA, 0x5E, 0xD4, 0x84, 0x25, 0x97,
1176 0x03, 0xA5, 0xA6, 0x13, 0x66, 0x02, 0xF4, 0xC3,
1177 0xF3, 0xD3, 0xCC, 0x95, 0xC3, 0x87, 0x46, 0x90,
1178 0x1F, 0x6E, 0x14, 0xA8, 0x00, 0xF2, 0x6F, 0xD5,
1179 0xA1, 0xAD, 0xD5, 0x40, 0xA2, 0x0F, 0x32, 0x7E,
1180 0x99, 0xA3, 0xF5, 0x53, 0xC3, 0x26, 0xA1, 0x45,
1181 0x01, 0x88, 0x57, 0x84, 0x3E, 0x7B, 0x4E, 0x0B,
1182 0x3C, 0xB5, 0x3E, 0x9E, 0xE9, 0x78, 0x77, 0xC5,
1183 0xC0, 0x89, 0xA8, 0xF8, 0xF1, 0xA5, 0x2D, 0x5D,
1184 0xF9, 0xC6, 0xFB, 0xCB, 0x05, 0x23, 0xBD, 0x6E,
1185 0x5E, 0x14, 0xC6, 0x57, 0x73, 0xCF, 0x98, 0xBD,
1186 0x10, 0x8B, 0x18, 0xA6, 0x01, 0x5B, 0x13, 0xAE,
1187 0x8E, 0xDE, 0x1F, 0xB5, 0xB7, 0x40, 0x6C, 0xC1,
1188 0x1E, 0xA1, 0x19, 0x20, 0x9E, 0x95, 0xE0, 0x2F,
1189 0x1C, 0xF5, 0xD9, 0xD0, 0x2B, 0x1E, 0x82, 0x25,
1190 0x62, 0xB4, 0xEB, 0xA1, 0x1F, 0xCE, 0x44, 0xA1,
1191 0xCB, 0x92, 0x01, 0x6B, 0xE4, 0x26, 0x23, 0xE3,
1192 0xC5, 0x67, 0x35, 0x55, 0xDA, 0xE5, 0x27, 0xEE,
1193 0x8D, 0x12, 0x84, 0xB7, 0xBA, 0xA7, 0x1C, 0xD6,
1194 0x32, 0x3F, 0x67, 0xED, 0xFB, 0x5B, 0x8B, 0x52,
1195 0x46, 0x8C, 0xF9, 0x69, 0xCD, 0xAE, 0x79, 0xAA,
1196 0x37, 0x78, 0x49, 0xEB, 0xC6, 0x8E, 0x76, 0x63,
1197 0x84, 0xFF, 0x9D, 0x22, 0x99, 0x51, 0xB7, 0x5E,
1198 0x83, 0x4C, 0x8B, 0xDF, 0x5A, 0x07, 0xCC, 0xBA,
1199 0x42, 0xA5, 0x98, 0xB6, 0x47, 0x0E, 0x66, 0xEB,
1200 0x23, 0x0E, 0xBA, 0x44, 0xA8, 0xAA, 0x20, 0x71,
1201 0x79, 0x9C, 0x77, 0x5F, 0xF5, 0xFE, 0xEC, 0xEF,
1202 0xC6, 0x64, 0x3D, 0x84, 0xD0, 0x2B, 0xA7, 0x0A,
1203 0xC3, 0x72, 0x5B, 0x9C, 0xFA, 0xA8, 0x87, 0x95,
1204 0x94, 0x11, 0x38, 0xA7, 0x1E, 0x58, 0xE3, 0x73,
1205 0xC6, 0xC9, 0xD1, 0x7B, 0x92, 0xDB, 0x0F, 0x49,
1206 0x74, 0xC2, 0xA2, 0x0E, 0x35, 0x57, 0xAC, 0xDB,
1207 0x9A, 0x1C, 0xCF, 0x5A, 0x32, 0x3E, 0x26, 0x9B,
1208 0xEC, 0xB3, 0xEF, 0x9C, 0xFE, 0xBE, 0x52, 0xAC,
1209 0xB1, 0x29, 0xDD, 0xFD, 0x07, 0xE2, 0xEE, 0xED,
1210 0xE4, 0x46, 0x37, 0xFE, 0xD1, 0xDC, 0xCD, 0x02,
1211 0xF9, 0x31, 0xB0, 0xFB, 0x36, 0xB7, 0x34, 0xA4,
1212 0x76, 0xE8, 0x57, 0xBF, 0x99, 0x92, 0xC7, 0xAF,
1213 0x98, 0x10, 0xE2, 0x70, 0xCA, 0xC9, 0x2B, 0x82,
1214 0x06, 0x96, 0x88, 0x0D, 0xB3, 0xAC, 0x9E, 0x6D,
1215 0x43, 0xBC, 0x5B, 0x31, 0xCF, 0x65, 0x8D, 0xA6,
1216 0xC7, 0xFE, 0x73, 0xE1, 0x54, 0xF7, 0x10, 0xF9,
1217 0x86, 0xF7, 0xDF, 0xA1, 0xA1, 0xD8, 0xAE, 0x35,
1218 0xB3, 0x90, 0xDC, 0x6F, 0x43, 0x7A, 0x8B, 0xE0,
1219 0xFE, 0x8F, 0x33, 0x4D, 0x29, 0x6C, 0x45, 0x53,
1220 0x73, 0xDD, 0x21, 0x0B, 0x85, 0x30, 0xB5, 0xA5,
1221 0xF3, 0x5D, 0xEC, 0x79, 0x61, 0x9D, 0x9E, 0xB3
1225 static uint8_t ms_hmac_key1[] = {
1226 0xFE, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1227 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1228 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1229 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1230 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1231 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1232 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1233 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1236 static const uint8_t ms_hmac_digest1[] = {
1237 0xCE, 0x6E, 0x5F, 0x77, 0x96, 0x9A, 0xB1, 0x69,
1238 0x2D, 0x5E, 0xF3, 0x2F, 0x32, 0x10, 0xCB, 0x50,
1239 0x0E, 0x09, 0x56, 0x25, 0x07, 0x34, 0xC9, 0x20,
1240 0xEC, 0x13, 0x43, 0x23, 0x5C, 0x08, 0x8B, 0xCD,
1241 0xDC, 0x86, 0x8C, 0xEE, 0x0A, 0x95, 0x2E, 0xB9,
1242 0x8C, 0x7B, 0x02, 0x7A, 0xD4, 0xE1, 0x49, 0xB4,
1243 0x45, 0xB5, 0x52, 0x37, 0xC6, 0xFF, 0xFE, 0xAA,
1244 0x0A, 0x87, 0xB8, 0x51, 0xF9, 0x2A, 0x01, 0x8F
1247 /* Begin Session 2 */
1248 static uint8_t ms_aes_cbc_key2[] = {
1249 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1250 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1253 static uint8_t ms_aes_cbc_iv2[] = {
1254 0xff, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7,
1255 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff
1258 static const uint8_t ms_aes_cbc_cipher2[] = {
1259 0xBB, 0x3C, 0x68, 0x25, 0xFD, 0xB6, 0xA2, 0x91,
1260 0x20, 0x56, 0xF6, 0x30, 0x35, 0xFC, 0x9E, 0x97,
1261 0xF2, 0x90, 0xFC, 0x7E, 0x3E, 0x0A, 0x75, 0xC8,
1262 0x4C, 0xF2, 0x2D, 0xAC, 0xD3, 0x93, 0xF0, 0xC5,
1263 0x14, 0x88, 0x8A, 0x23, 0xC2, 0x59, 0x9A, 0x98,
1264 0x4B, 0xD5, 0x2C, 0xDA, 0x43, 0xA9, 0x34, 0x69,
1265 0x7C, 0x6D, 0xDB, 0xDC, 0xCB, 0xC0, 0xA0, 0x09,
1266 0xA7, 0x86, 0x16, 0x4B, 0xBF, 0xA8, 0xB6, 0xCF,
1267 0x7F, 0x74, 0x1F, 0x22, 0xF0, 0xF6, 0xBB, 0x44,
1268 0x8B, 0x4C, 0x9E, 0x23, 0xF8, 0x9F, 0xFC, 0x5B,
1269 0x9E, 0x9C, 0x2A, 0x79, 0x30, 0x8F, 0xBF, 0xA9,
1270 0x68, 0xA1, 0x20, 0x71, 0x7C, 0x77, 0x22, 0x34,
1271 0x07, 0xCD, 0xC6, 0xF6, 0x50, 0x0A, 0x08, 0x99,
1272 0x17, 0x98, 0xE3, 0x93, 0x8A, 0xB0, 0xEE, 0xDF,
1273 0xC2, 0xBA, 0x3B, 0x44, 0x73, 0xDF, 0xDD, 0xDC,
1274 0x14, 0x4D, 0x3B, 0xBB, 0x5E, 0x58, 0xC1, 0x26,
1275 0xA7, 0xAE, 0x47, 0xF3, 0x24, 0x6D, 0x4F, 0xD3,
1276 0x6E, 0x3E, 0x33, 0xE6, 0x7F, 0xCA, 0x50, 0xAF,
1277 0x5D, 0x3D, 0xA0, 0xDD, 0xC9, 0xF3, 0x30, 0xD3,
1278 0x6E, 0x8B, 0x2E, 0x12, 0x24, 0x34, 0xF0, 0xD3,
1279 0xC7, 0x8D, 0x23, 0x29, 0xAA, 0x05, 0xE1, 0xFA,
1280 0x2E, 0xF6, 0x8D, 0x37, 0x86, 0xC0, 0x6D, 0x13,
1281 0x2D, 0x98, 0xF3, 0x52, 0x39, 0x22, 0xCE, 0x38,
1282 0xC2, 0x1A, 0x72, 0xED, 0xFB, 0xCC, 0xE4, 0x71,
1283 0x5A, 0x0C, 0x0D, 0x09, 0xF8, 0xE8, 0x1B, 0xBC,
1284 0x53, 0xC8, 0xD8, 0x8F, 0xE5, 0x98, 0x5A, 0xB1,
1285 0x06, 0xA6, 0x5B, 0xE6, 0xA2, 0x88, 0x21, 0x9E,
1286 0x36, 0xC0, 0x34, 0xF9, 0xFB, 0x3B, 0x0A, 0x22,
1287 0x00, 0x00, 0x39, 0x48, 0x8D, 0x23, 0x74, 0x62,
1288 0x72, 0x91, 0xE6, 0x36, 0xAA, 0x77, 0x9C, 0x72,
1289 0x9D, 0xA8, 0xC3, 0xA9, 0xD5, 0x44, 0x72, 0xA6,
1290 0xB9, 0x28, 0x8F, 0x64, 0x4C, 0x8A, 0x64, 0xE6,
1291 0x4E, 0xFA, 0xEF, 0x87, 0xDE, 0x7B, 0x22, 0x44,
1292 0xB0, 0xDF, 0x2E, 0x5F, 0x0B, 0xA5, 0xF2, 0x24,
1293 0x07, 0x5C, 0x2D, 0x39, 0xB7, 0x3D, 0x8A, 0xE5,
1294 0x0E, 0x9D, 0x4E, 0x50, 0xED, 0x03, 0x99, 0x8E,
1295 0xF0, 0x06, 0x55, 0x4E, 0xA2, 0x24, 0xE7, 0x17,
1296 0x46, 0xDF, 0x6C, 0xCD, 0xC6, 0x44, 0xE8, 0xF9,
1297 0xB9, 0x1B, 0x36, 0xF6, 0x7F, 0x10, 0xA4, 0x7D,
1298 0x90, 0xBD, 0xE4, 0xAA, 0xD6, 0x9E, 0x18, 0x9D,
1299 0x22, 0x35, 0xD6, 0x55, 0x54, 0xAA, 0xF7, 0x22,
1300 0xA3, 0x3E, 0xEF, 0xC8, 0xA2, 0x34, 0x8D, 0xA9,
1301 0x37, 0x63, 0xA6, 0xC3, 0x57, 0xCB, 0x0C, 0x49,
1302 0x7D, 0x02, 0xBE, 0xAA, 0x13, 0x75, 0xB7, 0x4E,
1303 0x52, 0x62, 0xA5, 0xC2, 0x33, 0xC7, 0x6C, 0x1B,
1304 0xF6, 0x34, 0xF6, 0x09, 0xA5, 0x0C, 0xC7, 0xA2,
1305 0x61, 0x48, 0x62, 0x7D, 0x17, 0x15, 0xE3, 0x95,
1306 0xC8, 0x63, 0xD2, 0xA4, 0x43, 0xA9, 0x49, 0x07,
1307 0xB2, 0x3B, 0x2B, 0x62, 0x7D, 0xCB, 0x51, 0xB3,
1308 0x25, 0x33, 0x47, 0x0E, 0x14, 0x67, 0xDC, 0x6A,
1309 0x9B, 0x51, 0xAC, 0x9D, 0x8F, 0xA2, 0x2B, 0x57,
1310 0x8C, 0x5C, 0x5F, 0x76, 0x23, 0x92, 0x0F, 0x84,
1311 0x46, 0x0E, 0x40, 0x85, 0x38, 0x60, 0xFA, 0x61,
1312 0x20, 0xC5, 0xE3, 0xF1, 0x70, 0xAC, 0x1B, 0xBF,
1313 0xC4, 0x2B, 0xC5, 0x67, 0xD1, 0x43, 0xC5, 0x17,
1314 0x74, 0x71, 0x69, 0x6F, 0x82, 0x89, 0x19, 0x8A,
1315 0x70, 0x43, 0x92, 0x01, 0xC4, 0x63, 0x7E, 0xB1,
1316 0x59, 0x4E, 0xCD, 0xEA, 0x93, 0xA4, 0x52, 0x53,
1317 0x9B, 0x61, 0x5B, 0xD2, 0x3E, 0x19, 0x39, 0xB7,
1318 0x32, 0xEA, 0x8E, 0xF8, 0x1D, 0x76, 0x5C, 0xB2,
1319 0x73, 0x2D, 0x91, 0xC0, 0x18, 0xED, 0x25, 0x2A,
1320 0x53, 0x64, 0xF0, 0x92, 0x31, 0x55, 0x21, 0xA8,
1321 0x24, 0xA9, 0xD1, 0x02, 0xF6, 0x6C, 0x2B, 0x70,
1322 0xA9, 0x59, 0xC1, 0xD6, 0xC3, 0x57, 0x5B, 0x92
1325 static uint8_t ms_hmac_key2[] = {
1326 0xFC, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
1327 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1328 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1329 0x9A, 0xAF, 0x88, 0x1B, 0xB6, 0x8F, 0xF8, 0x60,
1330 0xA2, 0x5A, 0x7F, 0x3F, 0xF4, 0x72, 0x70, 0xF1,
1331 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1332 0x47, 0x3A, 0x75, 0x61, 0x5C, 0xA2, 0x10, 0x76,
1333 0x9A, 0xAF, 0x77, 0x5B, 0xB6, 0x7F, 0xF7, 0x60
1336 static const uint8_t ms_hmac_digest2[] = {
1337 0xA5, 0x0F, 0x9C, 0xFB, 0x08, 0x62, 0x59, 0xFF,
1338 0x80, 0x2F, 0xEB, 0x4B, 0xE1, 0x46, 0x21, 0xD6,
1339 0x02, 0x98, 0xF2, 0x8E, 0xF4, 0xEC, 0xD4, 0x77,
1340 0x86, 0x4C, 0x31, 0x28, 0xC8, 0x25, 0x80, 0x27,
1341 0x3A, 0x72, 0x5D, 0x6A, 0x56, 0x8A, 0xD3, 0x82,
1342 0xB0, 0xEC, 0x31, 0x6D, 0x8B, 0x6B, 0xB4, 0x24,
1343 0xE7, 0x62, 0xC1, 0x52, 0xBC, 0x14, 0x1B, 0x8E,
1344 0xEC, 0x9A, 0xF1, 0x47, 0x80, 0xD2, 0xB0, 0x59
1351 test_AES_CBC_HMAC_SHA1_encrypt_digest(void)
1353 struct crypto_testsuite_params *ts_params = &testsuite_params;
1354 struct crypto_unittest_params *ut_params = &unittest_params;
1356 /* Generate test mbuf data and space for digest */
1357 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1358 catch_22_quote, QUOTE_512_BYTES, 0);
1360 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1361 DIGEST_BYTE_LENGTH_SHA1);
1362 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1364 /* Setup Cipher Parameters */
1365 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1366 ut_params->cipher_xform.next = &ut_params->auth_xform;
1368 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1369 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
1370 ut_params->cipher_xform.cipher.key.data = aes_cbc_key;
1371 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1372 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1373 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1375 /* Setup HMAC Parameters */
1376 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1378 ut_params->auth_xform.next = NULL;
1380 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
1381 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
1382 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA1;
1383 ut_params->auth_xform.auth.key.data = hmac_sha1_key;
1384 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA1;
1386 ut_params->sess = rte_cryptodev_sym_session_create(
1387 ts_params->session_mpool);
1389 /* Create crypto session*/
1390 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
1391 ut_params->sess, &ut_params->cipher_xform,
1392 ts_params->session_priv_mpool);
1393 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
1395 /* Generate crypto op data structure */
1396 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1397 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1398 TEST_ASSERT_NOT_NULL(ut_params->op,
1399 "Failed to allocate symmetric crypto operation struct");
1401 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
1403 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1405 /* set crypto operation source mbuf */
1406 sym_op->m_src = ut_params->ibuf;
1408 /* Set crypto operation authentication parameters */
1409 sym_op->auth.digest.data = ut_params->digest;
1410 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1411 ut_params->ibuf, QUOTE_512_BYTES);
1413 sym_op->auth.data.offset = 0;
1414 sym_op->auth.data.length = QUOTE_512_BYTES;
1416 /* Copy IV at the end of the crypto operation */
1417 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1418 aes_cbc_iv, CIPHER_IV_LENGTH_AES_CBC);
1420 /* Set crypto operation cipher parameters */
1421 sym_op->cipher.data.offset = 0;
1422 sym_op->cipher.data.length = QUOTE_512_BYTES;
1424 /* Process crypto operation */
1425 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1426 ut_params->op), "failed to process sym crypto op");
1428 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1429 "crypto op processing failed");
1432 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
1435 TEST_ASSERT_BUFFERS_ARE_EQUAL(ciphertext,
1436 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
1438 "ciphertext data not as expected");
1440 uint8_t *digest = ciphertext + QUOTE_512_BYTES;
1442 TEST_ASSERT_BUFFERS_ARE_EQUAL(digest,
1443 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA1_digest,
1444 gbl_driver_id == rte_cryptodev_driver_id_get(
1445 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) ?
1446 TRUNCATED_DIGEST_BYTE_LENGTH_SHA1 :
1447 DIGEST_BYTE_LENGTH_SHA1,
1448 "Generated digest data not as expected");
1450 return TEST_SUCCESS;
1453 /* ***** AES-CBC / HMAC-SHA512 Hash Tests ***** */
1455 #define HMAC_KEY_LENGTH_SHA512 (DIGEST_BYTE_LENGTH_SHA512)
1457 static uint8_t hmac_sha512_key[] = {
1458 0x42, 0x1a, 0x7d, 0x3d, 0xf5, 0x82, 0x80, 0xf1,
1459 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA,
1460 0x58, 0x34, 0x85, 0x65, 0x1C, 0x42, 0x50, 0x76,
1461 0x9a, 0xaf, 0x88, 0x1b, 0xb6, 0x8f, 0xf8, 0x60,
1462 0xa2, 0x5a, 0x7f, 0x3f, 0xf4, 0x72, 0x70, 0xf1,
1463 0xF5, 0x35, 0x4C, 0x3B, 0xDD, 0x90, 0x65, 0xB0,
1464 0x47, 0x3a, 0x75, 0x61, 0x5C, 0xa2, 0x10, 0x76,
1465 0x9a, 0xaf, 0x77, 0x5b, 0xb6, 0x7f, 0xf7, 0x60 };
1467 static const uint8_t catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest[] = {
1468 0x5D, 0x54, 0x66, 0xC1, 0x6E, 0xBC, 0x04, 0xB8,
1469 0x46, 0xB8, 0x08, 0x6E, 0xE0, 0xF0, 0x43, 0x48,
1470 0x37, 0x96, 0x9C, 0xC6, 0x9C, 0xC2, 0x1E, 0xE8,
1471 0xF2, 0x0C, 0x0B, 0xEF, 0x86, 0xA2, 0xE3, 0x70,
1472 0x95, 0xC8, 0xB3, 0x06, 0x47, 0xA9, 0x90, 0xE8,
1473 0xA0, 0xC6, 0x72, 0x69, 0x05, 0xC0, 0x0D, 0x0E,
1474 0x21, 0x96, 0x65, 0x93, 0x74, 0x43, 0x2A, 0x1D,
1475 0x2E, 0xBF, 0xC2, 0xC2, 0xEE, 0xCC, 0x2F, 0x0A };
1480 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1481 struct crypto_unittest_params *ut_params,
1482 uint8_t *cipher_key,
1486 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1487 struct crypto_unittest_params *ut_params,
1488 struct crypto_testsuite_params *ts_params,
1489 const uint8_t *cipher,
1490 const uint8_t *digest,
1495 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
1496 struct crypto_unittest_params *ut_params,
1497 uint8_t *cipher_key,
1501 /* Setup Cipher Parameters */
1502 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
1503 ut_params->cipher_xform.next = NULL;
1505 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
1506 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
1507 ut_params->cipher_xform.cipher.key.data = cipher_key;
1508 ut_params->cipher_xform.cipher.key.length = CIPHER_KEY_LENGTH_AES_CBC;
1509 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
1510 ut_params->cipher_xform.cipher.iv.length = CIPHER_IV_LENGTH_AES_CBC;
1512 /* Setup HMAC Parameters */
1513 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
1514 ut_params->auth_xform.next = &ut_params->cipher_xform;
1516 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
1517 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA512_HMAC;
1518 ut_params->auth_xform.auth.key.data = hmac_key;
1519 ut_params->auth_xform.auth.key.length = HMAC_KEY_LENGTH_SHA512;
1520 ut_params->auth_xform.auth.digest_length = DIGEST_BYTE_LENGTH_SHA512;
1522 return TEST_SUCCESS;
1527 test_AES_CBC_HMAC_SHA512_decrypt_perform(struct rte_cryptodev_sym_session *sess,
1528 struct crypto_unittest_params *ut_params,
1529 struct crypto_testsuite_params *ts_params,
1530 const uint8_t *cipher,
1531 const uint8_t *digest,
1534 /* Generate test mbuf data and digest */
1535 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
1538 QUOTE_512_BYTES, 0);
1540 ut_params->digest = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
1541 DIGEST_BYTE_LENGTH_SHA512);
1542 TEST_ASSERT_NOT_NULL(ut_params->digest, "no room to append digest");
1544 rte_memcpy(ut_params->digest,
1546 DIGEST_BYTE_LENGTH_SHA512);
1548 /* Generate Crypto op data structure */
1549 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
1550 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
1551 TEST_ASSERT_NOT_NULL(ut_params->op,
1552 "Failed to allocate symmetric crypto operation struct");
1554 rte_crypto_op_attach_sym_session(ut_params->op, sess);
1556 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
1558 /* set crypto operation source mbuf */
1559 sym_op->m_src = ut_params->ibuf;
1561 sym_op->auth.digest.data = ut_params->digest;
1562 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
1563 ut_params->ibuf, QUOTE_512_BYTES);
1565 sym_op->auth.data.offset = 0;
1566 sym_op->auth.data.length = QUOTE_512_BYTES;
1568 /* Copy IV at the end of the crypto operation */
1569 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
1570 iv, CIPHER_IV_LENGTH_AES_CBC);
1572 sym_op->cipher.data.offset = 0;
1573 sym_op->cipher.data.length = QUOTE_512_BYTES;
1575 /* Process crypto operation */
1576 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
1577 ut_params->op), "failed to process sym crypto op");
1579 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1580 "crypto op processing failed");
1582 ut_params->obuf = ut_params->op->sym->m_src;
1585 TEST_ASSERT_BUFFERS_ARE_EQUAL(
1586 rte_pktmbuf_mtod(ut_params->obuf, uint8_t *),
1589 "Plaintext data not as expected");
1592 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
1593 "Digest verification failed");
1595 return TEST_SUCCESS;
1599 test_AES_cipheronly_mb_all(void)
1601 struct crypto_testsuite_params *ts_params = &testsuite_params;
1604 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1605 ts_params->op_mpool,
1606 ts_params->session_mpool, ts_params->session_priv_mpool,
1607 ts_params->valid_devs[0],
1608 rte_cryptodev_driver_id_get(
1609 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1610 BLKCIPHER_AES_CIPHERONLY_TYPE);
1612 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1614 return TEST_SUCCESS;
1618 test_AES_docsis_mb_all(void)
1620 struct crypto_testsuite_params *ts_params = &testsuite_params;
1623 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1624 ts_params->op_mpool,
1625 ts_params->session_mpool, ts_params->session_priv_mpool,
1626 ts_params->valid_devs[0],
1627 rte_cryptodev_driver_id_get(
1628 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1629 BLKCIPHER_AES_DOCSIS_TYPE);
1631 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1633 return TEST_SUCCESS;
1637 test_AES_docsis_qat_all(void)
1639 struct crypto_testsuite_params *ts_params = &testsuite_params;
1642 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1643 ts_params->op_mpool,
1644 ts_params->session_mpool, ts_params->session_priv_mpool,
1645 ts_params->valid_devs[0],
1646 rte_cryptodev_driver_id_get(
1647 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1648 BLKCIPHER_AES_DOCSIS_TYPE);
1650 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1652 return TEST_SUCCESS;
1656 test_DES_docsis_qat_all(void)
1658 struct crypto_testsuite_params *ts_params = &testsuite_params;
1661 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1662 ts_params->op_mpool,
1663 ts_params->session_mpool, ts_params->session_priv_mpool,
1664 ts_params->valid_devs[0],
1665 rte_cryptodev_driver_id_get(
1666 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1667 BLKCIPHER_DES_DOCSIS_TYPE);
1669 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1671 return TEST_SUCCESS;
1675 test_authonly_mb_all(void)
1677 struct crypto_testsuite_params *ts_params = &testsuite_params;
1680 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1681 ts_params->op_mpool,
1682 ts_params->session_mpool, ts_params->session_priv_mpool,
1683 ts_params->valid_devs[0],
1684 rte_cryptodev_driver_id_get(
1685 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1686 BLKCIPHER_AUTHONLY_TYPE);
1688 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1690 return TEST_SUCCESS;
1694 test_authonly_qat_all(void)
1696 struct crypto_testsuite_params *ts_params = &testsuite_params;
1699 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1700 ts_params->op_mpool,
1701 ts_params->session_mpool, ts_params->session_priv_mpool,
1702 ts_params->valid_devs[0],
1703 rte_cryptodev_driver_id_get(
1704 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1705 BLKCIPHER_AUTHONLY_TYPE);
1707 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1709 return TEST_SUCCESS;
1713 test_AES_chain_null_all(void)
1715 struct crypto_testsuite_params *ts_params = &testsuite_params;
1718 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1719 ts_params->op_mpool,
1720 ts_params->session_mpool, ts_params->session_priv_mpool,
1721 ts_params->valid_devs[0],
1722 rte_cryptodev_driver_id_get(
1723 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1724 BLKCIPHER_AES_CHAIN_TYPE);
1726 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1728 return TEST_SUCCESS;
1732 test_AES_cipheronly_null_all(void)
1734 struct crypto_testsuite_params *ts_params = &testsuite_params;
1737 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1738 ts_params->op_mpool,
1739 ts_params->session_mpool, ts_params->session_priv_mpool,
1740 ts_params->valid_devs[0],
1741 rte_cryptodev_driver_id_get(
1742 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1743 BLKCIPHER_AES_CIPHERONLY_TYPE);
1745 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1747 return TEST_SUCCESS;
1751 test_authonly_null_all(void)
1753 struct crypto_testsuite_params *ts_params = &testsuite_params;
1756 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1757 ts_params->op_mpool,
1758 ts_params->session_mpool, ts_params->session_priv_mpool,
1759 ts_params->valid_devs[0],
1760 rte_cryptodev_driver_id_get(
1761 RTE_STR(CRYPTODEV_NAME_NULL_PMD)),
1762 BLKCIPHER_AUTHONLY_TYPE);
1764 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1766 return TEST_SUCCESS;
1770 test_AES_chain_mb_all(void)
1772 struct crypto_testsuite_params *ts_params = &testsuite_params;
1775 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1776 ts_params->op_mpool,
1777 ts_params->session_mpool, ts_params->session_priv_mpool,
1778 ts_params->valid_devs[0],
1779 rte_cryptodev_driver_id_get(
1780 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
1781 BLKCIPHER_AES_CHAIN_TYPE);
1783 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1785 return TEST_SUCCESS;
1788 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
1791 test_AES_cipheronly_scheduler_all(void)
1793 struct crypto_testsuite_params *ts_params = &testsuite_params;
1796 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1797 ts_params->op_mpool,
1798 ts_params->session_mpool, ts_params->session_priv_mpool,
1799 ts_params->valid_devs[0],
1800 rte_cryptodev_driver_id_get(
1801 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1802 BLKCIPHER_AES_CIPHERONLY_TYPE);
1804 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1806 return TEST_SUCCESS;
1810 test_AES_chain_scheduler_all(void)
1812 struct crypto_testsuite_params *ts_params = &testsuite_params;
1815 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1816 ts_params->op_mpool,
1817 ts_params->session_mpool, ts_params->session_priv_mpool,
1818 ts_params->valid_devs[0],
1819 rte_cryptodev_driver_id_get(
1820 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1821 BLKCIPHER_AES_CHAIN_TYPE);
1823 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1825 return TEST_SUCCESS;
1829 test_authonly_scheduler_all(void)
1831 struct crypto_testsuite_params *ts_params = &testsuite_params;
1834 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1835 ts_params->op_mpool,
1836 ts_params->session_mpool, ts_params->session_priv_mpool,
1837 ts_params->valid_devs[0],
1838 rte_cryptodev_driver_id_get(
1839 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD)),
1840 BLKCIPHER_AUTHONLY_TYPE);
1842 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1844 return TEST_SUCCESS;
1847 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
1850 test_AES_chain_openssl_all(void)
1852 struct crypto_testsuite_params *ts_params = &testsuite_params;
1855 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1856 ts_params->op_mpool,
1857 ts_params->session_mpool, ts_params->session_priv_mpool,
1858 ts_params->valid_devs[0],
1859 rte_cryptodev_driver_id_get(
1860 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1861 BLKCIPHER_AES_CHAIN_TYPE);
1863 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1865 return TEST_SUCCESS;
1869 test_AES_cipheronly_openssl_all(void)
1871 struct crypto_testsuite_params *ts_params = &testsuite_params;
1874 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1875 ts_params->op_mpool,
1876 ts_params->session_mpool, ts_params->session_priv_mpool,
1877 ts_params->valid_devs[0],
1878 rte_cryptodev_driver_id_get(
1879 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
1880 BLKCIPHER_AES_CIPHERONLY_TYPE);
1882 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1884 return TEST_SUCCESS;
1888 test_AES_chain_ccp_all(void)
1890 struct crypto_testsuite_params *ts_params = &testsuite_params;
1893 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1894 ts_params->op_mpool,
1895 ts_params->session_mpool, ts_params->session_priv_mpool,
1896 ts_params->valid_devs[0],
1897 rte_cryptodev_driver_id_get(
1898 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1899 BLKCIPHER_AES_CHAIN_TYPE);
1901 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1903 return TEST_SUCCESS;
1907 test_AES_cipheronly_ccp_all(void)
1909 struct crypto_testsuite_params *ts_params = &testsuite_params;
1912 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1913 ts_params->op_mpool,
1914 ts_params->session_mpool, ts_params->session_priv_mpool,
1915 ts_params->valid_devs[0],
1916 rte_cryptodev_driver_id_get(
1917 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
1918 BLKCIPHER_AES_CIPHERONLY_TYPE);
1920 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1922 return TEST_SUCCESS;
1926 test_AES_chain_qat_all(void)
1928 struct crypto_testsuite_params *ts_params = &testsuite_params;
1931 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1932 ts_params->op_mpool,
1933 ts_params->session_mpool, ts_params->session_priv_mpool,
1934 ts_params->valid_devs[0],
1935 rte_cryptodev_driver_id_get(
1936 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1937 BLKCIPHER_AES_CHAIN_TYPE);
1939 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1941 return TEST_SUCCESS;
1945 test_AES_cipheronly_qat_all(void)
1947 struct crypto_testsuite_params *ts_params = &testsuite_params;
1950 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1951 ts_params->op_mpool,
1952 ts_params->session_mpool, ts_params->session_priv_mpool,
1953 ts_params->valid_devs[0],
1954 rte_cryptodev_driver_id_get(
1955 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
1956 BLKCIPHER_AES_CIPHERONLY_TYPE);
1958 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1960 return TEST_SUCCESS;
1964 test_AES_cipheronly_virtio_all(void)
1966 struct crypto_testsuite_params *ts_params = &testsuite_params;
1969 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1970 ts_params->op_mpool,
1971 ts_params->session_mpool, ts_params->session_priv_mpool,
1972 ts_params->valid_devs[0],
1973 rte_cryptodev_driver_id_get(
1974 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD)),
1975 BLKCIPHER_AES_CIPHERONLY_TYPE);
1977 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1979 return TEST_SUCCESS;
1983 test_AES_chain_caam_jr_all(void)
1985 struct crypto_testsuite_params *ts_params = &testsuite_params;
1988 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
1989 ts_params->op_mpool,
1990 ts_params->session_mpool, ts_params->session_priv_mpool,
1991 ts_params->valid_devs[0],
1992 rte_cryptodev_driver_id_get(
1993 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
1994 BLKCIPHER_AES_CHAIN_TYPE);
1996 TEST_ASSERT_EQUAL(status, 0, "Test failed");
1998 return TEST_SUCCESS;
2002 test_AES_cipheronly_caam_jr_all(void)
2004 struct crypto_testsuite_params *ts_params = &testsuite_params;
2007 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2008 ts_params->op_mpool,
2009 ts_params->session_mpool, ts_params->session_priv_mpool,
2010 ts_params->valid_devs[0],
2011 rte_cryptodev_driver_id_get(
2012 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2013 BLKCIPHER_AES_CIPHERONLY_TYPE);
2015 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2017 return TEST_SUCCESS;
2021 test_authonly_caam_jr_all(void)
2023 struct crypto_testsuite_params *ts_params = &testsuite_params;
2026 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2027 ts_params->op_mpool,
2028 ts_params->session_mpool, ts_params->session_priv_mpool,
2029 ts_params->valid_devs[0],
2030 rte_cryptodev_driver_id_get(
2031 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
2032 BLKCIPHER_AUTHONLY_TYPE);
2034 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2036 return TEST_SUCCESS;
2041 test_AES_chain_dpaa_sec_all(void)
2043 struct crypto_testsuite_params *ts_params = &testsuite_params;
2046 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2047 ts_params->op_mpool,
2048 ts_params->session_mpool, ts_params->session_priv_mpool,
2049 ts_params->valid_devs[0],
2050 rte_cryptodev_driver_id_get(
2051 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2052 BLKCIPHER_AES_CHAIN_TYPE);
2054 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2056 return TEST_SUCCESS;
2060 test_AES_cipheronly_dpaa_sec_all(void)
2062 struct crypto_testsuite_params *ts_params = &testsuite_params;
2065 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2066 ts_params->op_mpool,
2067 ts_params->session_mpool, ts_params->session_priv_mpool,
2068 ts_params->valid_devs[0],
2069 rte_cryptodev_driver_id_get(
2070 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2071 BLKCIPHER_AES_CIPHERONLY_TYPE);
2073 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2075 return TEST_SUCCESS;
2079 test_authonly_dpaa_sec_all(void)
2081 struct crypto_testsuite_params *ts_params = &testsuite_params;
2084 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2085 ts_params->op_mpool,
2086 ts_params->session_mpool, ts_params->session_priv_mpool,
2087 ts_params->valid_devs[0],
2088 rte_cryptodev_driver_id_get(
2089 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
2090 BLKCIPHER_AUTHONLY_TYPE);
2092 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2094 return TEST_SUCCESS;
2098 test_AES_chain_dpaa2_sec_all(void)
2100 struct crypto_testsuite_params *ts_params = &testsuite_params;
2103 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2104 ts_params->op_mpool,
2105 ts_params->session_mpool, ts_params->session_priv_mpool,
2106 ts_params->valid_devs[0],
2107 rte_cryptodev_driver_id_get(
2108 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2109 BLKCIPHER_AES_CHAIN_TYPE);
2111 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2113 return TEST_SUCCESS;
2117 test_AES_cipheronly_dpaa2_sec_all(void)
2119 struct crypto_testsuite_params *ts_params = &testsuite_params;
2122 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2123 ts_params->op_mpool,
2124 ts_params->session_mpool, ts_params->session_priv_mpool,
2125 ts_params->valid_devs[0],
2126 rte_cryptodev_driver_id_get(
2127 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2128 BLKCIPHER_AES_CIPHERONLY_TYPE);
2130 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2132 return TEST_SUCCESS;
2136 test_authonly_dpaa2_sec_all(void)
2138 struct crypto_testsuite_params *ts_params = &testsuite_params;
2141 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2142 ts_params->op_mpool,
2143 ts_params->session_mpool, ts_params->session_priv_mpool,
2144 ts_params->valid_devs[0],
2145 rte_cryptodev_driver_id_get(
2146 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
2147 BLKCIPHER_AUTHONLY_TYPE);
2149 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2151 return TEST_SUCCESS;
2155 test_authonly_openssl_all(void)
2157 struct crypto_testsuite_params *ts_params = &testsuite_params;
2160 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2161 ts_params->op_mpool,
2162 ts_params->session_mpool, ts_params->session_priv_mpool,
2163 ts_params->valid_devs[0],
2164 rte_cryptodev_driver_id_get(
2165 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
2166 BLKCIPHER_AUTHONLY_TYPE);
2168 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2170 return TEST_SUCCESS;
2174 test_authonly_ccp_all(void)
2176 struct crypto_testsuite_params *ts_params = &testsuite_params;
2179 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2180 ts_params->op_mpool,
2181 ts_params->session_mpool, ts_params->session_priv_mpool,
2182 ts_params->valid_devs[0],
2183 rte_cryptodev_driver_id_get(
2184 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
2185 BLKCIPHER_AUTHONLY_TYPE);
2187 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2189 return TEST_SUCCESS;
2193 test_AES_chain_armv8_all(void)
2195 struct crypto_testsuite_params *ts_params = &testsuite_params;
2198 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2199 ts_params->op_mpool,
2200 ts_params->session_mpool, ts_params->session_priv_mpool,
2201 ts_params->valid_devs[0],
2202 rte_cryptodev_driver_id_get(
2203 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD)),
2204 BLKCIPHER_AES_CHAIN_TYPE);
2206 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2208 return TEST_SUCCESS;
2212 test_AES_chain_mrvl_all(void)
2214 struct crypto_testsuite_params *ts_params = &testsuite_params;
2217 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2218 ts_params->op_mpool,
2219 ts_params->session_mpool, ts_params->session_priv_mpool,
2220 ts_params->valid_devs[0],
2221 rte_cryptodev_driver_id_get(
2222 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2223 BLKCIPHER_AES_CHAIN_TYPE);
2225 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2227 return TEST_SUCCESS;
2231 test_AES_cipheronly_mrvl_all(void)
2233 struct crypto_testsuite_params *ts_params = &testsuite_params;
2236 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2237 ts_params->op_mpool,
2238 ts_params->session_mpool, ts_params->session_priv_mpool,
2239 ts_params->valid_devs[0],
2240 rte_cryptodev_driver_id_get(
2241 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2242 BLKCIPHER_AES_CIPHERONLY_TYPE);
2244 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2246 return TEST_SUCCESS;
2250 test_authonly_mrvl_all(void)
2252 struct crypto_testsuite_params *ts_params = &testsuite_params;
2255 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2256 ts_params->op_mpool,
2257 ts_params->session_mpool, ts_params->session_priv_mpool,
2258 ts_params->valid_devs[0],
2259 rte_cryptodev_driver_id_get(
2260 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2261 BLKCIPHER_AUTHONLY_TYPE);
2263 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2265 return TEST_SUCCESS;
2269 test_3DES_chain_mrvl_all(void)
2271 struct crypto_testsuite_params *ts_params = &testsuite_params;
2274 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2275 ts_params->op_mpool,
2276 ts_params->session_mpool, ts_params->session_priv_mpool,
2277 ts_params->valid_devs[0],
2278 rte_cryptodev_driver_id_get(
2279 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2280 BLKCIPHER_3DES_CHAIN_TYPE);
2282 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2284 return TEST_SUCCESS;
2288 test_3DES_cipheronly_mrvl_all(void)
2290 struct crypto_testsuite_params *ts_params = &testsuite_params;
2293 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2294 ts_params->op_mpool,
2295 ts_params->session_mpool, ts_params->session_priv_mpool,
2296 ts_params->valid_devs[0],
2297 rte_cryptodev_driver_id_get(
2298 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD)),
2299 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2301 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2303 return TEST_SUCCESS;
2307 test_AES_chain_octeontx_all(void)
2309 struct crypto_testsuite_params *ts_params = &testsuite_params;
2312 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2313 ts_params->op_mpool, ts_params->session_mpool,
2314 ts_params->session_priv_mpool,
2315 ts_params->valid_devs[0],
2316 rte_cryptodev_driver_id_get(
2317 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2318 BLKCIPHER_AES_CHAIN_TYPE);
2320 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2322 return TEST_SUCCESS;
2326 test_AES_cipheronly_octeontx_all(void)
2328 struct crypto_testsuite_params *ts_params = &testsuite_params;
2331 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2332 ts_params->op_mpool, ts_params->session_mpool,
2333 ts_params->session_priv_mpool,
2334 ts_params->valid_devs[0],
2335 rte_cryptodev_driver_id_get(
2336 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2337 BLKCIPHER_AES_CIPHERONLY_TYPE);
2339 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2341 return TEST_SUCCESS;
2345 test_3DES_chain_octeontx_all(void)
2347 struct crypto_testsuite_params *ts_params = &testsuite_params;
2350 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2351 ts_params->op_mpool, ts_params->session_mpool,
2352 ts_params->session_priv_mpool,
2353 ts_params->valid_devs[0],
2354 rte_cryptodev_driver_id_get(
2355 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2356 BLKCIPHER_3DES_CHAIN_TYPE);
2358 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2360 return TEST_SUCCESS;
2364 test_AES_chain_nitrox_all(void)
2366 struct crypto_testsuite_params *ts_params = &testsuite_params;
2369 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2370 ts_params->op_mpool,
2371 ts_params->session_mpool, ts_params->session_priv_mpool,
2372 ts_params->valid_devs[0],
2373 rte_cryptodev_driver_id_get(
2374 RTE_STR(CRYPTODEV_NAME_NITROX_PMD)),
2375 BLKCIPHER_AES_CHAIN_TYPE);
2377 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2379 return TEST_SUCCESS;
2383 test_3DES_cipheronly_octeontx_all(void)
2385 struct crypto_testsuite_params *ts_params = &testsuite_params;
2388 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2389 ts_params->op_mpool, ts_params->session_mpool,
2390 ts_params->session_priv_mpool,
2391 ts_params->valid_devs[0],
2392 rte_cryptodev_driver_id_get(
2393 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2394 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2396 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2398 return TEST_SUCCESS;
2402 test_authonly_octeontx_all(void)
2404 struct crypto_testsuite_params *ts_params = &testsuite_params;
2407 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2408 ts_params->op_mpool, ts_params->session_mpool,
2409 ts_params->session_priv_mpool,
2410 ts_params->valid_devs[0],
2411 rte_cryptodev_driver_id_get(
2412 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD)),
2413 BLKCIPHER_AUTHONLY_TYPE);
2415 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2417 return TEST_SUCCESS;
2421 test_AES_chain_octeontx2_all(void)
2423 struct crypto_testsuite_params *ts_params = &testsuite_params;
2426 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2427 ts_params->op_mpool, ts_params->session_mpool,
2428 ts_params->session_priv_mpool,
2429 ts_params->valid_devs[0],
2430 rte_cryptodev_driver_id_get(
2431 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2432 BLKCIPHER_AES_CHAIN_TYPE);
2434 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2436 return TEST_SUCCESS;
2440 test_AES_cipheronly_octeontx2_all(void)
2442 struct crypto_testsuite_params *ts_params = &testsuite_params;
2445 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2446 ts_params->op_mpool, ts_params->session_mpool,
2447 ts_params->session_priv_mpool,
2448 ts_params->valid_devs[0],
2449 rte_cryptodev_driver_id_get(
2450 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2451 BLKCIPHER_AES_CIPHERONLY_TYPE);
2453 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2455 return TEST_SUCCESS;
2459 test_3DES_chain_octeontx2_all(void)
2461 struct crypto_testsuite_params *ts_params = &testsuite_params;
2464 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2465 ts_params->op_mpool, ts_params->session_mpool,
2466 ts_params->session_priv_mpool,
2467 ts_params->valid_devs[0],
2468 rte_cryptodev_driver_id_get(
2469 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2470 BLKCIPHER_3DES_CHAIN_TYPE);
2472 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2474 return TEST_SUCCESS;
2478 test_3DES_cipheronly_octeontx2_all(void)
2480 struct crypto_testsuite_params *ts_params = &testsuite_params;
2483 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2484 ts_params->op_mpool, ts_params->session_mpool,
2485 ts_params->session_priv_mpool,
2486 ts_params->valid_devs[0],
2487 rte_cryptodev_driver_id_get(
2488 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2489 BLKCIPHER_3DES_CIPHERONLY_TYPE);
2491 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2493 return TEST_SUCCESS;
2497 test_authonly_octeontx2_all(void)
2499 struct crypto_testsuite_params *ts_params = &testsuite_params;
2502 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
2503 ts_params->op_mpool, ts_params->session_mpool,
2504 ts_params->session_priv_mpool,
2505 ts_params->valid_devs[0],
2506 rte_cryptodev_driver_id_get(
2507 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD)),
2508 BLKCIPHER_AUTHONLY_TYPE);
2510 TEST_ASSERT_EQUAL(status, 0, "Test failed");
2512 return TEST_SUCCESS;
2515 /* ***** SNOW 3G Tests ***** */
2517 create_wireless_algo_hash_session(uint8_t dev_id,
2518 const uint8_t *key, const uint8_t key_len,
2519 const uint8_t iv_len, const uint8_t auth_len,
2520 enum rte_crypto_auth_operation op,
2521 enum rte_crypto_auth_algorithm algo)
2523 uint8_t hash_key[key_len];
2526 struct crypto_testsuite_params *ts_params = &testsuite_params;
2527 struct crypto_unittest_params *ut_params = &unittest_params;
2529 memcpy(hash_key, key, key_len);
2531 debug_hexdump(stdout, "key:", key, key_len);
2533 /* Setup Authentication Parameters */
2534 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2535 ut_params->auth_xform.next = NULL;
2537 ut_params->auth_xform.auth.op = op;
2538 ut_params->auth_xform.auth.algo = algo;
2539 ut_params->auth_xform.auth.key.length = key_len;
2540 ut_params->auth_xform.auth.key.data = hash_key;
2541 ut_params->auth_xform.auth.digest_length = auth_len;
2542 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
2543 ut_params->auth_xform.auth.iv.length = iv_len;
2544 ut_params->sess = rte_cryptodev_sym_session_create(
2545 ts_params->session_mpool);
2547 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2548 &ut_params->auth_xform,
2549 ts_params->session_priv_mpool);
2550 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2551 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2556 create_wireless_algo_cipher_session(uint8_t dev_id,
2557 enum rte_crypto_cipher_operation op,
2558 enum rte_crypto_cipher_algorithm algo,
2559 const uint8_t *key, const uint8_t key_len,
2562 uint8_t cipher_key[key_len];
2564 struct crypto_testsuite_params *ts_params = &testsuite_params;
2565 struct crypto_unittest_params *ut_params = &unittest_params;
2567 memcpy(cipher_key, key, key_len);
2569 /* Setup Cipher Parameters */
2570 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2571 ut_params->cipher_xform.next = NULL;
2573 ut_params->cipher_xform.cipher.algo = algo;
2574 ut_params->cipher_xform.cipher.op = op;
2575 ut_params->cipher_xform.cipher.key.data = cipher_key;
2576 ut_params->cipher_xform.cipher.key.length = key_len;
2577 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2578 ut_params->cipher_xform.cipher.iv.length = iv_len;
2580 debug_hexdump(stdout, "key:", key, key_len);
2582 /* Create Crypto session */
2583 ut_params->sess = rte_cryptodev_sym_session_create(
2584 ts_params->session_mpool);
2586 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2587 &ut_params->cipher_xform,
2588 ts_params->session_priv_mpool);
2589 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2590 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2595 create_wireless_algo_cipher_operation(const uint8_t *iv, uint8_t iv_len,
2596 unsigned int cipher_len,
2597 unsigned int cipher_offset)
2599 struct crypto_testsuite_params *ts_params = &testsuite_params;
2600 struct crypto_unittest_params *ut_params = &unittest_params;
2602 /* Generate Crypto op data structure */
2603 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2604 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2605 TEST_ASSERT_NOT_NULL(ut_params->op,
2606 "Failed to allocate pktmbuf offload");
2608 /* Set crypto operation data parameters */
2609 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2611 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2613 /* set crypto operation source mbuf */
2614 sym_op->m_src = ut_params->ibuf;
2617 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2619 sym_op->cipher.data.length = cipher_len;
2620 sym_op->cipher.data.offset = cipher_offset;
2625 create_wireless_algo_cipher_operation_oop(const uint8_t *iv, uint8_t iv_len,
2626 unsigned int cipher_len,
2627 unsigned int cipher_offset)
2629 struct crypto_testsuite_params *ts_params = &testsuite_params;
2630 struct crypto_unittest_params *ut_params = &unittest_params;
2632 /* Generate Crypto op data structure */
2633 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2634 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2635 TEST_ASSERT_NOT_NULL(ut_params->op,
2636 "Failed to allocate pktmbuf offload");
2638 /* Set crypto operation data parameters */
2639 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2641 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2643 /* set crypto operation source mbuf */
2644 sym_op->m_src = ut_params->ibuf;
2645 sym_op->m_dst = ut_params->obuf;
2648 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2650 sym_op->cipher.data.length = cipher_len;
2651 sym_op->cipher.data.offset = cipher_offset;
2656 create_wireless_algo_cipher_auth_session(uint8_t dev_id,
2657 enum rte_crypto_cipher_operation cipher_op,
2658 enum rte_crypto_auth_operation auth_op,
2659 enum rte_crypto_auth_algorithm auth_algo,
2660 enum rte_crypto_cipher_algorithm cipher_algo,
2661 const uint8_t *key, uint8_t key_len,
2662 uint8_t auth_iv_len, uint8_t auth_len,
2663 uint8_t cipher_iv_len)
2666 uint8_t cipher_auth_key[key_len];
2669 struct crypto_testsuite_params *ts_params = &testsuite_params;
2670 struct crypto_unittest_params *ut_params = &unittest_params;
2672 memcpy(cipher_auth_key, key, key_len);
2674 /* Setup Authentication Parameters */
2675 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2676 ut_params->auth_xform.next = NULL;
2678 ut_params->auth_xform.auth.op = auth_op;
2679 ut_params->auth_xform.auth.algo = auth_algo;
2680 ut_params->auth_xform.auth.key.length = key_len;
2681 /* Hash key = cipher key */
2682 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2683 ut_params->auth_xform.auth.digest_length = auth_len;
2684 /* Auth IV will be after cipher IV */
2685 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2686 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2688 /* Setup Cipher Parameters */
2689 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2690 ut_params->cipher_xform.next = &ut_params->auth_xform;
2692 ut_params->cipher_xform.cipher.algo = cipher_algo;
2693 ut_params->cipher_xform.cipher.op = cipher_op;
2694 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2695 ut_params->cipher_xform.cipher.key.length = key_len;
2696 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2697 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2699 debug_hexdump(stdout, "key:", key, key_len);
2701 /* Create Crypto session*/
2702 ut_params->sess = rte_cryptodev_sym_session_create(
2703 ts_params->session_mpool);
2704 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2706 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2707 &ut_params->cipher_xform,
2708 ts_params->session_priv_mpool);
2709 if (status == -ENOTSUP)
2712 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2717 create_wireless_cipher_auth_session(uint8_t dev_id,
2718 enum rte_crypto_cipher_operation cipher_op,
2719 enum rte_crypto_auth_operation auth_op,
2720 enum rte_crypto_auth_algorithm auth_algo,
2721 enum rte_crypto_cipher_algorithm cipher_algo,
2722 const struct wireless_test_data *tdata)
2724 const uint8_t key_len = tdata->key.len;
2725 uint8_t cipher_auth_key[key_len];
2728 struct crypto_testsuite_params *ts_params = &testsuite_params;
2729 struct crypto_unittest_params *ut_params = &unittest_params;
2730 const uint8_t *key = tdata->key.data;
2731 const uint8_t auth_len = tdata->digest.len;
2732 uint8_t cipher_iv_len = tdata->cipher_iv.len;
2733 uint8_t auth_iv_len = tdata->auth_iv.len;
2735 memcpy(cipher_auth_key, key, key_len);
2737 /* Setup Authentication Parameters */
2738 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2739 ut_params->auth_xform.next = NULL;
2741 ut_params->auth_xform.auth.op = auth_op;
2742 ut_params->auth_xform.auth.algo = auth_algo;
2743 ut_params->auth_xform.auth.key.length = key_len;
2744 /* Hash key = cipher key */
2745 ut_params->auth_xform.auth.key.data = cipher_auth_key;
2746 ut_params->auth_xform.auth.digest_length = auth_len;
2747 /* Auth IV will be after cipher IV */
2748 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2749 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2751 /* Setup Cipher Parameters */
2752 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2753 ut_params->cipher_xform.next = &ut_params->auth_xform;
2755 ut_params->cipher_xform.cipher.algo = cipher_algo;
2756 ut_params->cipher_xform.cipher.op = cipher_op;
2757 ut_params->cipher_xform.cipher.key.data = cipher_auth_key;
2758 ut_params->cipher_xform.cipher.key.length = key_len;
2759 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2760 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2763 debug_hexdump(stdout, "key:", key, key_len);
2765 /* Create Crypto session*/
2766 ut_params->sess = rte_cryptodev_sym_session_create(
2767 ts_params->session_mpool);
2769 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2770 &ut_params->cipher_xform,
2771 ts_params->session_priv_mpool);
2773 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2774 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2779 create_zuc_cipher_auth_encrypt_generate_session(uint8_t dev_id,
2780 const struct wireless_test_data *tdata)
2782 return create_wireless_cipher_auth_session(dev_id,
2783 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
2784 RTE_CRYPTO_AUTH_OP_GENERATE, RTE_CRYPTO_AUTH_ZUC_EIA3,
2785 RTE_CRYPTO_CIPHER_ZUC_EEA3, tdata);
2789 create_wireless_algo_auth_cipher_session(uint8_t dev_id,
2790 enum rte_crypto_cipher_operation cipher_op,
2791 enum rte_crypto_auth_operation auth_op,
2792 enum rte_crypto_auth_algorithm auth_algo,
2793 enum rte_crypto_cipher_algorithm cipher_algo,
2794 const uint8_t *key, const uint8_t key_len,
2795 uint8_t auth_iv_len, uint8_t auth_len,
2796 uint8_t cipher_iv_len)
2798 uint8_t auth_cipher_key[key_len];
2800 struct crypto_testsuite_params *ts_params = &testsuite_params;
2801 struct crypto_unittest_params *ut_params = &unittest_params;
2803 memcpy(auth_cipher_key, key, key_len);
2805 /* Setup Authentication Parameters */
2806 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
2807 ut_params->auth_xform.auth.op = auth_op;
2808 ut_params->auth_xform.next = &ut_params->cipher_xform;
2809 ut_params->auth_xform.auth.algo = auth_algo;
2810 ut_params->auth_xform.auth.key.length = key_len;
2811 ut_params->auth_xform.auth.key.data = auth_cipher_key;
2812 ut_params->auth_xform.auth.digest_length = auth_len;
2813 /* Auth IV will be after cipher IV */
2814 ut_params->auth_xform.auth.iv.offset = IV_OFFSET + cipher_iv_len;
2815 ut_params->auth_xform.auth.iv.length = auth_iv_len;
2817 /* Setup Cipher Parameters */
2818 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
2819 ut_params->cipher_xform.next = NULL;
2820 ut_params->cipher_xform.cipher.algo = cipher_algo;
2821 ut_params->cipher_xform.cipher.op = cipher_op;
2822 ut_params->cipher_xform.cipher.key.data = auth_cipher_key;
2823 ut_params->cipher_xform.cipher.key.length = key_len;
2824 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
2825 ut_params->cipher_xform.cipher.iv.length = cipher_iv_len;
2827 debug_hexdump(stdout, "key:", key, key_len);
2829 /* Create Crypto session*/
2830 ut_params->sess = rte_cryptodev_sym_session_create(
2831 ts_params->session_mpool);
2832 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
2834 if (cipher_op == RTE_CRYPTO_CIPHER_OP_DECRYPT) {
2835 ut_params->auth_xform.next = NULL;
2836 ut_params->cipher_xform.next = &ut_params->auth_xform;
2837 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2838 &ut_params->cipher_xform,
2839 ts_params->session_priv_mpool);
2842 status = rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
2843 &ut_params->auth_xform,
2844 ts_params->session_priv_mpool);
2846 if (status == -ENOTSUP)
2849 TEST_ASSERT_EQUAL(status, 0, "session init failed");
2855 create_wireless_algo_hash_operation(const uint8_t *auth_tag,
2856 unsigned int auth_tag_len,
2857 const uint8_t *iv, unsigned int iv_len,
2858 unsigned int data_pad_len,
2859 enum rte_crypto_auth_operation op,
2860 unsigned int auth_len, unsigned int auth_offset)
2862 struct crypto_testsuite_params *ts_params = &testsuite_params;
2864 struct crypto_unittest_params *ut_params = &unittest_params;
2866 /* Generate Crypto op data structure */
2867 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2868 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2869 TEST_ASSERT_NOT_NULL(ut_params->op,
2870 "Failed to allocate pktmbuf offload");
2872 /* Set crypto operation data parameters */
2873 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2875 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2877 /* set crypto operation source mbuf */
2878 sym_op->m_src = ut_params->ibuf;
2881 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
2884 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2885 ut_params->ibuf, auth_tag_len);
2887 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2888 "no room to append auth tag");
2889 ut_params->digest = sym_op->auth.digest.data;
2890 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2891 ut_params->ibuf, data_pad_len);
2892 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2893 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2895 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2897 debug_hexdump(stdout, "digest:",
2898 sym_op->auth.digest.data,
2901 sym_op->auth.data.length = auth_len;
2902 sym_op->auth.data.offset = auth_offset;
2908 create_wireless_cipher_hash_operation(const struct wireless_test_data *tdata,
2909 enum rte_crypto_auth_operation op)
2911 struct crypto_testsuite_params *ts_params = &testsuite_params;
2912 struct crypto_unittest_params *ut_params = &unittest_params;
2914 const uint8_t *auth_tag = tdata->digest.data;
2915 const unsigned int auth_tag_len = tdata->digest.len;
2916 unsigned int plaintext_len = ceil_byte_length(tdata->plaintext.len);
2917 unsigned int data_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
2919 const uint8_t *cipher_iv = tdata->cipher_iv.data;
2920 const uint8_t cipher_iv_len = tdata->cipher_iv.len;
2921 const uint8_t *auth_iv = tdata->auth_iv.data;
2922 const uint8_t auth_iv_len = tdata->auth_iv.len;
2923 const unsigned int cipher_len = tdata->validCipherLenInBits.len;
2924 const unsigned int auth_len = tdata->validAuthLenInBits.len;
2926 /* Generate Crypto op data structure */
2927 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
2928 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
2929 TEST_ASSERT_NOT_NULL(ut_params->op,
2930 "Failed to allocate pktmbuf offload");
2931 /* Set crypto operation data parameters */
2932 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
2934 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
2936 /* set crypto operation source mbuf */
2937 sym_op->m_src = ut_params->ibuf;
2940 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
2941 ut_params->ibuf, auth_tag_len);
2943 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
2944 "no room to append auth tag");
2945 ut_params->digest = sym_op->auth.digest.data;
2946 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
2947 ut_params->ibuf, data_pad_len);
2948 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
2949 memset(sym_op->auth.digest.data, 0, auth_tag_len);
2951 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
2953 debug_hexdump(stdout, "digest:",
2954 sym_op->auth.digest.data,
2957 /* Copy cipher and auth IVs at the end of the crypto operation */
2958 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
2960 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
2961 iv_ptr += cipher_iv_len;
2962 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
2964 sym_op->cipher.data.length = cipher_len;
2965 sym_op->cipher.data.offset = 0;
2966 sym_op->auth.data.length = auth_len;
2967 sym_op->auth.data.offset = 0;
2973 create_zuc_cipher_hash_generate_operation(
2974 const struct wireless_test_data *tdata)
2976 return create_wireless_cipher_hash_operation(tdata,
2977 RTE_CRYPTO_AUTH_OP_GENERATE);
2981 create_wireless_algo_cipher_hash_operation(const uint8_t *auth_tag,
2982 const unsigned auth_tag_len,
2983 const uint8_t *auth_iv, uint8_t auth_iv_len,
2984 unsigned data_pad_len,
2985 enum rte_crypto_auth_operation op,
2986 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
2987 const unsigned cipher_len, const unsigned cipher_offset,
2988 const unsigned auth_len, const unsigned auth_offset)
2990 struct crypto_testsuite_params *ts_params = &testsuite_params;
2991 struct crypto_unittest_params *ut_params = &unittest_params;
2993 enum rte_crypto_cipher_algorithm cipher_algo =
2994 ut_params->cipher_xform.cipher.algo;
2995 enum rte_crypto_auth_algorithm auth_algo =
2996 ut_params->auth_xform.auth.algo;
2998 /* Generate Crypto op data structure */
2999 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3000 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3001 TEST_ASSERT_NOT_NULL(ut_params->op,
3002 "Failed to allocate pktmbuf offload");
3003 /* Set crypto operation data parameters */
3004 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3006 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3008 /* set crypto operation source mbuf */
3009 sym_op->m_src = ut_params->ibuf;
3012 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
3013 ut_params->ibuf, auth_tag_len);
3015 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
3016 "no room to append auth tag");
3017 ut_params->digest = sym_op->auth.digest.data;
3019 if (rte_pktmbuf_is_contiguous(ut_params->ibuf)) {
3020 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3021 ut_params->ibuf, data_pad_len);
3023 struct rte_mbuf *m = ut_params->ibuf;
3024 unsigned int offset = data_pad_len;
3026 while (offset > m->data_len && m->next != NULL) {
3027 offset -= m->data_len;
3030 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3034 if (op == RTE_CRYPTO_AUTH_OP_GENERATE)
3035 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3037 rte_memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3039 debug_hexdump(stdout, "digest:",
3040 sym_op->auth.digest.data,
3043 /* Copy cipher and auth IVs at the end of the crypto operation */
3044 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op, uint8_t *,
3046 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3047 iv_ptr += cipher_iv_len;
3048 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3050 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3051 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3052 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3053 sym_op->cipher.data.length = cipher_len;
3054 sym_op->cipher.data.offset = cipher_offset;
3056 sym_op->cipher.data.length = cipher_len >> 3;
3057 sym_op->cipher.data.offset = cipher_offset >> 3;
3060 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3061 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3062 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3063 sym_op->auth.data.length = auth_len;
3064 sym_op->auth.data.offset = auth_offset;
3066 sym_op->auth.data.length = auth_len >> 3;
3067 sym_op->auth.data.offset = auth_offset >> 3;
3074 create_wireless_algo_auth_cipher_operation(
3075 const uint8_t *auth_tag, unsigned int auth_tag_len,
3076 const uint8_t *cipher_iv, uint8_t cipher_iv_len,
3077 const uint8_t *auth_iv, uint8_t auth_iv_len,
3078 unsigned int data_pad_len,
3079 unsigned int cipher_len, unsigned int cipher_offset,
3080 unsigned int auth_len, unsigned int auth_offset,
3081 uint8_t op_mode, uint8_t do_sgl, uint8_t verify)
3083 struct crypto_testsuite_params *ts_params = &testsuite_params;
3084 struct crypto_unittest_params *ut_params = &unittest_params;
3086 enum rte_crypto_cipher_algorithm cipher_algo =
3087 ut_params->cipher_xform.cipher.algo;
3088 enum rte_crypto_auth_algorithm auth_algo =
3089 ut_params->auth_xform.auth.algo;
3091 /* Generate Crypto op data structure */
3092 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
3093 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
3094 TEST_ASSERT_NOT_NULL(ut_params->op,
3095 "Failed to allocate pktmbuf offload");
3097 /* Set crypto operation data parameters */
3098 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
3100 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
3102 /* set crypto operation mbufs */
3103 sym_op->m_src = ut_params->ibuf;
3104 if (op_mode == OUT_OF_PLACE)
3105 sym_op->m_dst = ut_params->obuf;
3109 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(
3110 (op_mode == IN_PLACE ?
3111 ut_params->ibuf : ut_params->obuf),
3112 uint8_t *, data_pad_len);
3113 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
3114 (op_mode == IN_PLACE ?
3115 ut_params->ibuf : ut_params->obuf),
3117 memset(sym_op->auth.digest.data, 0, auth_tag_len);
3119 uint16_t remaining_off = (auth_offset >> 3) + (auth_len >> 3);
3120 struct rte_mbuf *sgl_buf = (op_mode == IN_PLACE ?
3121 sym_op->m_src : sym_op->m_dst);
3122 while (remaining_off >= rte_pktmbuf_data_len(sgl_buf)) {
3123 remaining_off -= rte_pktmbuf_data_len(sgl_buf);
3124 sgl_buf = sgl_buf->next;
3126 sym_op->auth.digest.data = rte_pktmbuf_mtod_offset(sgl_buf,
3127 uint8_t *, remaining_off);
3128 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(sgl_buf,
3130 memset(sym_op->auth.digest.data, 0, remaining_off);
3131 while (sgl_buf->next != NULL) {
3132 memset(rte_pktmbuf_mtod(sgl_buf, uint8_t *),
3133 0, rte_pktmbuf_data_len(sgl_buf));
3134 sgl_buf = sgl_buf->next;
3138 /* Copy digest for the verification */
3140 memcpy(sym_op->auth.digest.data, auth_tag, auth_tag_len);
3142 /* Copy cipher and auth IVs at the end of the crypto operation */
3143 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(
3144 ut_params->op, uint8_t *, IV_OFFSET);
3146 rte_memcpy(iv_ptr, cipher_iv, cipher_iv_len);
3147 iv_ptr += cipher_iv_len;
3148 rte_memcpy(iv_ptr, auth_iv, auth_iv_len);
3150 if (cipher_algo == RTE_CRYPTO_CIPHER_SNOW3G_UEA2 ||
3151 cipher_algo == RTE_CRYPTO_CIPHER_KASUMI_F8 ||
3152 cipher_algo == RTE_CRYPTO_CIPHER_ZUC_EEA3) {
3153 sym_op->cipher.data.length = cipher_len;
3154 sym_op->cipher.data.offset = cipher_offset;
3156 sym_op->cipher.data.length = cipher_len >> 3;
3157 sym_op->cipher.data.offset = cipher_offset >> 3;
3160 if (auth_algo == RTE_CRYPTO_AUTH_SNOW3G_UIA2 ||
3161 auth_algo == RTE_CRYPTO_AUTH_KASUMI_F9 ||
3162 auth_algo == RTE_CRYPTO_AUTH_ZUC_EIA3) {
3163 sym_op->auth.data.length = auth_len;
3164 sym_op->auth.data.offset = auth_offset;
3166 sym_op->auth.data.length = auth_len >> 3;
3167 sym_op->auth.data.offset = auth_offset >> 3;
3174 test_snow3g_authentication(const struct snow3g_hash_test_data *tdata)
3176 struct crypto_testsuite_params *ts_params = &testsuite_params;
3177 struct crypto_unittest_params *ut_params = &unittest_params;
3180 unsigned plaintext_pad_len;
3181 unsigned plaintext_len;
3184 /* Create SNOW 3G session */
3185 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3186 tdata->key.data, tdata->key.len,
3187 tdata->auth_iv.len, tdata->digest.len,
3188 RTE_CRYPTO_AUTH_OP_GENERATE,
3189 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3193 /* alloc mbuf and set payload */
3194 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3196 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3197 rte_pktmbuf_tailroom(ut_params->ibuf));
3199 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3200 /* Append data which is padded to a multiple of */
3201 /* the algorithms block size */
3202 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3203 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3205 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3207 /* Create SNOW 3G operation */
3208 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3209 tdata->auth_iv.data, tdata->auth_iv.len,
3210 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3211 tdata->validAuthLenInBits.len,
3216 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3218 ut_params->obuf = ut_params->op->sym->m_src;
3219 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3220 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3221 + plaintext_pad_len;
3224 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3227 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
3228 "SNOW 3G Generated auth tag not as expected");
3234 test_snow3g_authentication_verify(const struct snow3g_hash_test_data *tdata)
3236 struct crypto_testsuite_params *ts_params = &testsuite_params;
3237 struct crypto_unittest_params *ut_params = &unittest_params;
3240 unsigned plaintext_pad_len;
3241 unsigned plaintext_len;
3244 /* Create SNOW 3G session */
3245 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3246 tdata->key.data, tdata->key.len,
3247 tdata->auth_iv.len, tdata->digest.len,
3248 RTE_CRYPTO_AUTH_OP_VERIFY,
3249 RTE_CRYPTO_AUTH_SNOW3G_UIA2);
3252 /* alloc mbuf and set payload */
3253 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3255 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3256 rte_pktmbuf_tailroom(ut_params->ibuf));
3258 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3259 /* Append data which is padded to a multiple of */
3260 /* the algorithms block size */
3261 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
3262 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3264 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3266 /* Create SNOW 3G operation */
3267 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3269 tdata->auth_iv.data, tdata->auth_iv.len,
3271 RTE_CRYPTO_AUTH_OP_VERIFY,
3272 tdata->validAuthLenInBits.len,
3277 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3279 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3280 ut_params->obuf = ut_params->op->sym->m_src;
3281 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3282 + plaintext_pad_len;
3285 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3294 test_kasumi_authentication(const struct kasumi_hash_test_data *tdata)
3296 struct crypto_testsuite_params *ts_params = &testsuite_params;
3297 struct crypto_unittest_params *ut_params = &unittest_params;
3300 unsigned plaintext_pad_len;
3301 unsigned plaintext_len;
3304 /* Create KASUMI session */
3305 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3306 tdata->key.data, tdata->key.len,
3307 0, tdata->digest.len,
3308 RTE_CRYPTO_AUTH_OP_GENERATE,
3309 RTE_CRYPTO_AUTH_KASUMI_F9);
3313 /* alloc mbuf and set payload */
3314 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3316 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3317 rte_pktmbuf_tailroom(ut_params->ibuf));
3319 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3320 /* Append data which is padded to a multiple of */
3321 /* the algorithms block size */
3322 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3323 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3325 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3327 /* Create KASUMI operation */
3328 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
3330 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
3331 tdata->plaintext.len,
3336 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3338 ut_params->obuf = ut_params->op->sym->m_src;
3339 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3340 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3341 + plaintext_pad_len;
3344 TEST_ASSERT_BUFFERS_ARE_EQUAL(
3347 DIGEST_BYTE_LENGTH_KASUMI_F9,
3348 "KASUMI Generated auth tag not as expected");
3354 test_kasumi_authentication_verify(const struct kasumi_hash_test_data *tdata)
3356 struct crypto_testsuite_params *ts_params = &testsuite_params;
3357 struct crypto_unittest_params *ut_params = &unittest_params;
3360 unsigned plaintext_pad_len;
3361 unsigned plaintext_len;
3364 /* Create KASUMI session */
3365 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
3366 tdata->key.data, tdata->key.len,
3367 0, tdata->digest.len,
3368 RTE_CRYPTO_AUTH_OP_VERIFY,
3369 RTE_CRYPTO_AUTH_KASUMI_F9);
3372 /* alloc mbuf and set payload */
3373 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3375 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3376 rte_pktmbuf_tailroom(ut_params->ibuf));
3378 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3379 /* Append data which is padded to a multiple */
3380 /* of the algorithms block size */
3381 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3382 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3384 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3386 /* Create KASUMI operation */
3387 retval = create_wireless_algo_hash_operation(tdata->digest.data,
3391 RTE_CRYPTO_AUTH_OP_VERIFY,
3392 tdata->plaintext.len,
3397 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3399 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3400 ut_params->obuf = ut_params->op->sym->m_src;
3401 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
3402 + plaintext_pad_len;
3405 if (ut_params->op->status == RTE_CRYPTO_OP_STATUS_SUCCESS)
3414 test_snow3g_hash_generate_test_case_1(void)
3416 return test_snow3g_authentication(&snow3g_hash_test_case_1);
3420 test_snow3g_hash_generate_test_case_2(void)
3422 return test_snow3g_authentication(&snow3g_hash_test_case_2);
3426 test_snow3g_hash_generate_test_case_3(void)
3428 return test_snow3g_authentication(&snow3g_hash_test_case_3);
3432 test_snow3g_hash_generate_test_case_4(void)
3434 return test_snow3g_authentication(&snow3g_hash_test_case_4);
3438 test_snow3g_hash_generate_test_case_5(void)
3440 return test_snow3g_authentication(&snow3g_hash_test_case_5);
3444 test_snow3g_hash_generate_test_case_6(void)
3446 return test_snow3g_authentication(&snow3g_hash_test_case_6);
3450 test_snow3g_hash_verify_test_case_1(void)
3452 return test_snow3g_authentication_verify(&snow3g_hash_test_case_1);
3457 test_snow3g_hash_verify_test_case_2(void)
3459 return test_snow3g_authentication_verify(&snow3g_hash_test_case_2);
3463 test_snow3g_hash_verify_test_case_3(void)
3465 return test_snow3g_authentication_verify(&snow3g_hash_test_case_3);
3469 test_snow3g_hash_verify_test_case_4(void)
3471 return test_snow3g_authentication_verify(&snow3g_hash_test_case_4);
3475 test_snow3g_hash_verify_test_case_5(void)
3477 return test_snow3g_authentication_verify(&snow3g_hash_test_case_5);
3481 test_snow3g_hash_verify_test_case_6(void)
3483 return test_snow3g_authentication_verify(&snow3g_hash_test_case_6);
3487 test_kasumi_hash_generate_test_case_1(void)
3489 return test_kasumi_authentication(&kasumi_hash_test_case_1);
3493 test_kasumi_hash_generate_test_case_2(void)
3495 return test_kasumi_authentication(&kasumi_hash_test_case_2);
3499 test_kasumi_hash_generate_test_case_3(void)
3501 return test_kasumi_authentication(&kasumi_hash_test_case_3);
3505 test_kasumi_hash_generate_test_case_4(void)
3507 return test_kasumi_authentication(&kasumi_hash_test_case_4);
3511 test_kasumi_hash_generate_test_case_5(void)
3513 return test_kasumi_authentication(&kasumi_hash_test_case_5);
3517 test_kasumi_hash_generate_test_case_6(void)
3519 return test_kasumi_authentication(&kasumi_hash_test_case_6);
3523 test_kasumi_hash_verify_test_case_1(void)
3525 return test_kasumi_authentication_verify(&kasumi_hash_test_case_1);
3529 test_kasumi_hash_verify_test_case_2(void)
3531 return test_kasumi_authentication_verify(&kasumi_hash_test_case_2);
3535 test_kasumi_hash_verify_test_case_3(void)
3537 return test_kasumi_authentication_verify(&kasumi_hash_test_case_3);
3541 test_kasumi_hash_verify_test_case_4(void)
3543 return test_kasumi_authentication_verify(&kasumi_hash_test_case_4);
3547 test_kasumi_hash_verify_test_case_5(void)
3549 return test_kasumi_authentication_verify(&kasumi_hash_test_case_5);
3553 test_kasumi_encryption(const struct kasumi_test_data *tdata)
3555 struct crypto_testsuite_params *ts_params = &testsuite_params;
3556 struct crypto_unittest_params *ut_params = &unittest_params;
3559 uint8_t *plaintext, *ciphertext;
3560 unsigned plaintext_pad_len;
3561 unsigned plaintext_len;
3563 /* Create KASUMI session */
3564 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3565 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3566 RTE_CRYPTO_CIPHER_KASUMI_F8,
3567 tdata->key.data, tdata->key.len,
3568 tdata->cipher_iv.len);
3572 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3574 /* Clear mbuf payload */
3575 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3576 rte_pktmbuf_tailroom(ut_params->ibuf));
3578 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3579 /* Append data which is padded to a multiple */
3580 /* of the algorithms block size */
3581 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3582 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3584 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3586 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3588 /* Create KASUMI operation */
3589 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3590 tdata->cipher_iv.len,
3591 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3592 tdata->validCipherOffsetInBits.len);
3596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3600 ut_params->obuf = ut_params->op->sym->m_dst;
3601 if (ut_params->obuf)
3602 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3604 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3606 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3608 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3609 (tdata->validCipherOffsetInBits.len >> 3);
3611 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3613 reference_ciphertext,
3614 tdata->validCipherLenInBits.len,
3615 "KASUMI Ciphertext data not as expected");
3620 test_kasumi_encryption_sgl(const struct kasumi_test_data *tdata)
3622 struct crypto_testsuite_params *ts_params = &testsuite_params;
3623 struct crypto_unittest_params *ut_params = &unittest_params;
3627 unsigned int plaintext_pad_len;
3628 unsigned int plaintext_len;
3630 uint8_t buffer[10000];
3631 const uint8_t *ciphertext;
3633 struct rte_cryptodev_info dev_info;
3635 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3637 uint64_t feat_flags = dev_info.feature_flags;
3639 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
3640 printf("Device doesn't support in-place scatter-gather. "
3645 /* Create KASUMI session */
3646 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3647 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3648 RTE_CRYPTO_CIPHER_KASUMI_F8,
3649 tdata->key.data, tdata->key.len,
3650 tdata->cipher_iv.len);
3654 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3657 /* Append data which is padded to a multiple */
3658 /* of the algorithms block size */
3659 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3661 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3662 plaintext_pad_len, 10, 0);
3664 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3666 /* Create KASUMI operation */
3667 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3668 tdata->cipher_iv.len,
3669 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3670 tdata->validCipherOffsetInBits.len);
3674 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3676 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3678 ut_params->obuf = ut_params->op->sym->m_dst;
3680 if (ut_params->obuf)
3681 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3682 plaintext_len, buffer);
3684 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3685 tdata->validCipherOffsetInBits.len >> 3,
3686 plaintext_len, buffer);
3689 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3691 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3692 (tdata->validCipherOffsetInBits.len >> 3);
3694 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3696 reference_ciphertext,
3697 tdata->validCipherLenInBits.len,
3698 "KASUMI Ciphertext data not as expected");
3703 test_kasumi_encryption_oop(const struct kasumi_test_data *tdata)
3705 struct crypto_testsuite_params *ts_params = &testsuite_params;
3706 struct crypto_unittest_params *ut_params = &unittest_params;
3709 uint8_t *plaintext, *ciphertext;
3710 unsigned plaintext_pad_len;
3711 unsigned plaintext_len;
3713 /* Create KASUMI session */
3714 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3715 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3716 RTE_CRYPTO_CIPHER_KASUMI_F8,
3717 tdata->key.data, tdata->key.len,
3718 tdata->cipher_iv.len);
3722 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3723 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3725 /* Clear mbuf payload */
3726 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3727 rte_pktmbuf_tailroom(ut_params->ibuf));
3729 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3730 /* Append data which is padded to a multiple */
3731 /* of the algorithms block size */
3732 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3733 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3735 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
3736 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
3738 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
3740 /* Create KASUMI operation */
3741 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3742 tdata->cipher_iv.len,
3743 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3744 tdata->validCipherOffsetInBits.len);
3748 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3750 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3752 ut_params->obuf = ut_params->op->sym->m_dst;
3753 if (ut_params->obuf)
3754 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3756 ciphertext = plaintext + (tdata->validCipherOffsetInBits.len >> 3);
3758 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
3760 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3761 (tdata->validCipherOffsetInBits.len >> 3);
3763 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3765 reference_ciphertext,
3766 tdata->validCipherLenInBits.len,
3767 "KASUMI Ciphertext data not as expected");
3772 test_kasumi_encryption_oop_sgl(const struct kasumi_test_data *tdata)
3774 struct crypto_testsuite_params *ts_params = &testsuite_params;
3775 struct crypto_unittest_params *ut_params = &unittest_params;
3778 unsigned int plaintext_pad_len;
3779 unsigned int plaintext_len;
3781 const uint8_t *ciphertext;
3782 uint8_t buffer[2048];
3784 struct rte_cryptodev_info dev_info;
3786 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
3788 uint64_t feat_flags = dev_info.feature_flags;
3789 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
3790 printf("Device doesn't support out-of-place scatter-gather "
3791 "in both input and output mbufs. "
3796 /* Create KASUMI session */
3797 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3798 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
3799 RTE_CRYPTO_CIPHER_KASUMI_F8,
3800 tdata->key.data, tdata->key.len,
3801 tdata->cipher_iv.len);
3805 plaintext_len = ceil_byte_length(tdata->plaintext.len);
3806 /* Append data which is padded to a multiple */
3807 /* of the algorithms block size */
3808 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
3810 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
3811 plaintext_pad_len, 10, 0);
3812 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
3813 plaintext_pad_len, 3, 0);
3815 /* Append data which is padded to a multiple */
3816 /* of the algorithms block size */
3817 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
3819 /* Create KASUMI operation */
3820 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3821 tdata->cipher_iv.len,
3822 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3823 tdata->validCipherOffsetInBits.len);
3827 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3829 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3831 ut_params->obuf = ut_params->op->sym->m_dst;
3832 if (ut_params->obuf)
3833 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
3834 plaintext_pad_len, buffer);
3836 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
3837 tdata->validCipherOffsetInBits.len >> 3,
3838 plaintext_pad_len, buffer);
3840 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
3841 (tdata->validCipherOffsetInBits.len >> 3);
3843 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3845 reference_ciphertext,
3846 tdata->validCipherLenInBits.len,
3847 "KASUMI Ciphertext data not as expected");
3853 test_kasumi_decryption_oop(const struct kasumi_test_data *tdata)
3855 struct crypto_testsuite_params *ts_params = &testsuite_params;
3856 struct crypto_unittest_params *ut_params = &unittest_params;
3859 uint8_t *ciphertext, *plaintext;
3860 unsigned ciphertext_pad_len;
3861 unsigned ciphertext_len;
3863 /* Create KASUMI session */
3864 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3865 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3866 RTE_CRYPTO_CIPHER_KASUMI_F8,
3867 tdata->key.data, tdata->key.len,
3868 tdata->cipher_iv.len);
3872 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3873 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3875 /* Clear mbuf payload */
3876 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3877 rte_pktmbuf_tailroom(ut_params->ibuf));
3879 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3880 /* Append data which is padded to a multiple */
3881 /* of the algorithms block size */
3882 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3883 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3884 ciphertext_pad_len);
3885 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
3886 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3888 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3890 /* Create KASUMI operation */
3891 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
3892 tdata->cipher_iv.len,
3893 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
3894 tdata->validCipherOffsetInBits.len);
3898 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3900 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3902 ut_params->obuf = ut_params->op->sym->m_dst;
3903 if (ut_params->obuf)
3904 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3906 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3908 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3910 const uint8_t *reference_plaintext = tdata->plaintext.data +
3911 (tdata->validCipherOffsetInBits.len >> 3);
3913 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3915 reference_plaintext,
3916 tdata->validCipherLenInBits.len,
3917 "KASUMI Plaintext data not as expected");
3922 test_kasumi_decryption(const struct kasumi_test_data *tdata)
3924 struct crypto_testsuite_params *ts_params = &testsuite_params;
3925 struct crypto_unittest_params *ut_params = &unittest_params;
3928 uint8_t *ciphertext, *plaintext;
3929 unsigned ciphertext_pad_len;
3930 unsigned ciphertext_len;
3932 /* Create KASUMI session */
3933 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
3934 RTE_CRYPTO_CIPHER_OP_DECRYPT,
3935 RTE_CRYPTO_CIPHER_KASUMI_F8,
3936 tdata->key.data, tdata->key.len,
3937 tdata->cipher_iv.len);
3941 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
3943 /* Clear mbuf payload */
3944 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
3945 rte_pktmbuf_tailroom(ut_params->ibuf));
3947 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
3948 /* Append data which is padded to a multiple */
3949 /* of the algorithms block size */
3950 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 8);
3951 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
3952 ciphertext_pad_len);
3953 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
3955 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
3957 /* Create KASUMI operation */
3958 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
3959 tdata->cipher_iv.len,
3960 tdata->ciphertext.len,
3961 tdata->validCipherOffsetInBits.len);
3965 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
3967 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
3969 ut_params->obuf = ut_params->op->sym->m_dst;
3970 if (ut_params->obuf)
3971 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
3973 plaintext = ciphertext + (tdata->validCipherOffsetInBits.len >> 3);
3975 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
3977 const uint8_t *reference_plaintext = tdata->plaintext.data +
3978 (tdata->validCipherOffsetInBits.len >> 3);
3980 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
3982 reference_plaintext,
3983 tdata->validCipherLenInBits.len,
3984 "KASUMI Plaintext data not as expected");
3989 test_snow3g_encryption(const struct snow3g_test_data *tdata)
3991 struct crypto_testsuite_params *ts_params = &testsuite_params;
3992 struct crypto_unittest_params *ut_params = &unittest_params;
3995 uint8_t *plaintext, *ciphertext;
3996 unsigned plaintext_pad_len;
3997 unsigned plaintext_len;
3999 /* Create SNOW 3G session */
4000 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4001 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4002 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4003 tdata->key.data, tdata->key.len,
4004 tdata->cipher_iv.len);
4008 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4010 /* Clear mbuf payload */
4011 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4012 rte_pktmbuf_tailroom(ut_params->ibuf));
4014 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4015 /* Append data which is padded to a multiple of */
4016 /* the algorithms block size */
4017 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4018 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4020 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4022 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4024 /* Create SNOW 3G operation */
4025 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4026 tdata->cipher_iv.len,
4027 tdata->validCipherLenInBits.len,
4032 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4034 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4036 ut_params->obuf = ut_params->op->sym->m_dst;
4037 if (ut_params->obuf)
4038 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4040 ciphertext = plaintext;
4042 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4045 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4047 tdata->ciphertext.data,
4048 tdata->validDataLenInBits.len,
4049 "SNOW 3G Ciphertext data not as expected");
4055 test_snow3g_encryption_oop(const struct snow3g_test_data *tdata)
4057 struct crypto_testsuite_params *ts_params = &testsuite_params;
4058 struct crypto_unittest_params *ut_params = &unittest_params;
4059 uint8_t *plaintext, *ciphertext;
4062 unsigned plaintext_pad_len;
4063 unsigned plaintext_len;
4065 /* Create SNOW 3G session */
4066 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4067 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4068 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4069 tdata->key.data, tdata->key.len,
4070 tdata->cipher_iv.len);
4074 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4075 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4077 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4078 "Failed to allocate input buffer in mempool");
4079 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4080 "Failed to allocate output buffer in mempool");
4082 /* Clear mbuf payload */
4083 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4084 rte_pktmbuf_tailroom(ut_params->ibuf));
4086 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4087 /* Append data which is padded to a multiple of */
4088 /* the algorithms block size */
4089 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4090 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4092 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4093 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4095 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4097 /* Create SNOW 3G operation */
4098 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4099 tdata->cipher_iv.len,
4100 tdata->validCipherLenInBits.len,
4105 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4107 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4109 ut_params->obuf = ut_params->op->sym->m_dst;
4110 if (ut_params->obuf)
4111 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4113 ciphertext = plaintext;
4115 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4118 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4120 tdata->ciphertext.data,
4121 tdata->validDataLenInBits.len,
4122 "SNOW 3G Ciphertext data not as expected");
4127 test_snow3g_encryption_oop_sgl(const struct snow3g_test_data *tdata)
4129 struct crypto_testsuite_params *ts_params = &testsuite_params;
4130 struct crypto_unittest_params *ut_params = &unittest_params;
4133 unsigned int plaintext_pad_len;
4134 unsigned int plaintext_len;
4135 uint8_t buffer[10000];
4136 const uint8_t *ciphertext;
4138 struct rte_cryptodev_info dev_info;
4140 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4142 uint64_t feat_flags = dev_info.feature_flags;
4144 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4145 printf("Device doesn't support out-of-place scatter-gather "
4146 "in both input and output mbufs. "
4151 /* Create SNOW 3G session */
4152 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4153 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4154 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4155 tdata->key.data, tdata->key.len,
4156 tdata->cipher_iv.len);
4160 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4161 /* Append data which is padded to a multiple of */
4162 /* the algorithms block size */
4163 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4165 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4166 plaintext_pad_len, 10, 0);
4167 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4168 plaintext_pad_len, 3, 0);
4170 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4171 "Failed to allocate input buffer in mempool");
4172 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4173 "Failed to allocate output buffer in mempool");
4175 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
4177 /* Create SNOW 3G operation */
4178 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4179 tdata->cipher_iv.len,
4180 tdata->validCipherLenInBits.len,
4185 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4187 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4189 ut_params->obuf = ut_params->op->sym->m_dst;
4190 if (ut_params->obuf)
4191 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4192 plaintext_len, buffer);
4194 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4195 plaintext_len, buffer);
4197 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4200 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4202 tdata->ciphertext.data,
4203 tdata->validDataLenInBits.len,
4204 "SNOW 3G Ciphertext data not as expected");
4209 /* Shift right a buffer by "offset" bits, "offset" < 8 */
4211 buffer_shift_right(uint8_t *buffer, uint32_t length, uint8_t offset)
4213 uint8_t curr_byte, prev_byte;
4214 uint32_t length_in_bytes = ceil_byte_length(length + offset);
4215 uint8_t lower_byte_mask = (1 << offset) - 1;
4218 prev_byte = buffer[0];
4219 buffer[0] >>= offset;
4221 for (i = 1; i < length_in_bytes; i++) {
4222 curr_byte = buffer[i];
4223 buffer[i] = ((prev_byte & lower_byte_mask) << (8 - offset)) |
4224 (curr_byte >> offset);
4225 prev_byte = curr_byte;
4230 test_snow3g_encryption_offset_oop(const struct snow3g_test_data *tdata)
4232 struct crypto_testsuite_params *ts_params = &testsuite_params;
4233 struct crypto_unittest_params *ut_params = &unittest_params;
4234 uint8_t *plaintext, *ciphertext;
4236 uint32_t plaintext_len;
4237 uint32_t plaintext_pad_len;
4238 uint8_t extra_offset = 4;
4239 uint8_t *expected_ciphertext_shifted;
4241 /* Create SNOW 3G session */
4242 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4243 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4244 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4245 tdata->key.data, tdata->key.len,
4246 tdata->cipher_iv.len);
4250 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4251 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4253 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4254 "Failed to allocate input buffer in mempool");
4255 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4256 "Failed to allocate output buffer in mempool");
4258 /* Clear mbuf payload */
4259 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4260 rte_pktmbuf_tailroom(ut_params->ibuf));
4262 plaintext_len = ceil_byte_length(tdata->plaintext.len + extra_offset);
4264 * Append data which is padded to a
4265 * multiple of the algorithms block size
4267 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4269 plaintext = (uint8_t *) rte_pktmbuf_append(ut_params->ibuf,
4272 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4274 memcpy(plaintext, tdata->plaintext.data, (tdata->plaintext.len >> 3));
4275 buffer_shift_right(plaintext, tdata->plaintext.len, extra_offset);
4277 #ifdef RTE_APP_TEST_DEBUG
4278 rte_hexdump(stdout, "plaintext:", plaintext, tdata->plaintext.len);
4280 /* Create SNOW 3G operation */
4281 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4282 tdata->cipher_iv.len,
4283 tdata->validCipherLenInBits.len,
4288 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4290 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4292 ut_params->obuf = ut_params->op->sym->m_dst;
4293 if (ut_params->obuf)
4294 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4296 ciphertext = plaintext;
4298 #ifdef RTE_APP_TEST_DEBUG
4299 rte_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4302 expected_ciphertext_shifted = rte_malloc(NULL, plaintext_len, 8);
4304 TEST_ASSERT_NOT_NULL(expected_ciphertext_shifted,
4305 "failed to reserve memory for ciphertext shifted\n");
4307 memcpy(expected_ciphertext_shifted, tdata->ciphertext.data,
4308 ceil_byte_length(tdata->ciphertext.len));
4309 buffer_shift_right(expected_ciphertext_shifted, tdata->ciphertext.len,
4312 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT_OFFSET(
4314 expected_ciphertext_shifted,
4315 tdata->validDataLenInBits.len,
4317 "SNOW 3G Ciphertext data not as expected");
4321 static int test_snow3g_decryption(const struct snow3g_test_data *tdata)
4323 struct crypto_testsuite_params *ts_params = &testsuite_params;
4324 struct crypto_unittest_params *ut_params = &unittest_params;
4328 uint8_t *plaintext, *ciphertext;
4329 unsigned ciphertext_pad_len;
4330 unsigned ciphertext_len;
4332 /* Create SNOW 3G session */
4333 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4334 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4335 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4336 tdata->key.data, tdata->key.len,
4337 tdata->cipher_iv.len);
4341 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4343 /* Clear mbuf payload */
4344 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4345 rte_pktmbuf_tailroom(ut_params->ibuf));
4347 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4348 /* Append data which is padded to a multiple of */
4349 /* the algorithms block size */
4350 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4351 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4352 ciphertext_pad_len);
4353 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4355 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4357 /* Create SNOW 3G operation */
4358 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
4359 tdata->cipher_iv.len,
4360 tdata->validCipherLenInBits.len,
4361 tdata->cipher.offset_bits);
4365 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4367 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4368 ut_params->obuf = ut_params->op->sym->m_dst;
4369 if (ut_params->obuf)
4370 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4372 plaintext = ciphertext;
4374 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4377 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4378 tdata->plaintext.data,
4379 tdata->validDataLenInBits.len,
4380 "SNOW 3G Plaintext data not as expected");
4384 static int test_snow3g_decryption_oop(const struct snow3g_test_data *tdata)
4386 struct crypto_testsuite_params *ts_params = &testsuite_params;
4387 struct crypto_unittest_params *ut_params = &unittest_params;
4391 uint8_t *plaintext, *ciphertext;
4392 unsigned ciphertext_pad_len;
4393 unsigned ciphertext_len;
4395 /* Create SNOW 3G session */
4396 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
4397 RTE_CRYPTO_CIPHER_OP_DECRYPT,
4398 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4399 tdata->key.data, tdata->key.len,
4400 tdata->cipher_iv.len);
4404 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4405 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4407 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4408 "Failed to allocate input buffer");
4409 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4410 "Failed to allocate output buffer");
4412 /* Clear mbuf payload */
4413 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4414 rte_pktmbuf_tailroom(ut_params->ibuf));
4416 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4417 rte_pktmbuf_tailroom(ut_params->obuf));
4419 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4420 /* Append data which is padded to a multiple of */
4421 /* the algorithms block size */
4422 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4423 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4424 ciphertext_pad_len);
4425 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4426 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4428 debug_hexdump(stdout, "ciphertext:", ciphertext, ciphertext_len);
4430 /* Create SNOW 3G operation */
4431 retval = create_wireless_algo_cipher_operation_oop(tdata->cipher_iv.data,
4432 tdata->cipher_iv.len,
4433 tdata->validCipherLenInBits.len,
4438 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4440 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4441 ut_params->obuf = ut_params->op->sym->m_dst;
4442 if (ut_params->obuf)
4443 plaintext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4445 plaintext = ciphertext;
4447 debug_hexdump(stdout, "plaintext:", plaintext, ciphertext_len);
4450 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(plaintext,
4451 tdata->plaintext.data,
4452 tdata->validDataLenInBits.len,
4453 "SNOW 3G Plaintext data not as expected");
4458 test_zuc_cipher_auth(const struct wireless_test_data *tdata)
4460 struct crypto_testsuite_params *ts_params = &testsuite_params;
4461 struct crypto_unittest_params *ut_params = &unittest_params;
4465 uint8_t *plaintext, *ciphertext;
4466 unsigned int plaintext_pad_len;
4467 unsigned int plaintext_len;
4469 struct rte_cryptodev_sym_capability_idx cap_idx;
4471 /* Check if device supports ZUC EEA3 */
4472 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
4473 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
4475 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4479 /* Check if device supports ZUC EIA3 */
4480 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
4481 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
4483 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
4487 /* Create ZUC session */
4488 retval = create_zuc_cipher_auth_encrypt_generate_session(
4489 ts_params->valid_devs[0],
4493 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4495 /* clear mbuf payload */
4496 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4497 rte_pktmbuf_tailroom(ut_params->ibuf));
4499 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4500 /* Append data which is padded to a multiple of */
4501 /* the algorithms block size */
4502 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4503 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4505 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4507 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4509 /* Create ZUC operation */
4510 retval = create_zuc_cipher_hash_generate_operation(tdata);
4514 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4516 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4517 ut_params->obuf = ut_params->op->sym->m_src;
4518 if (ut_params->obuf)
4519 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4521 ciphertext = plaintext;
4523 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4525 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4527 tdata->ciphertext.data,
4528 tdata->validDataLenInBits.len,
4529 "ZUC Ciphertext data not as expected");
4531 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4532 + plaintext_pad_len;
4535 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4539 "ZUC Generated auth tag not as expected");
4544 test_snow3g_cipher_auth(const struct snow3g_test_data *tdata)
4546 struct crypto_testsuite_params *ts_params = &testsuite_params;
4547 struct crypto_unittest_params *ut_params = &unittest_params;
4551 uint8_t *plaintext, *ciphertext;
4552 unsigned plaintext_pad_len;
4553 unsigned plaintext_len;
4555 /* Create SNOW 3G session */
4556 retval = create_wireless_algo_cipher_auth_session(ts_params->valid_devs[0],
4557 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
4558 RTE_CRYPTO_AUTH_OP_GENERATE,
4559 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4560 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4561 tdata->key.data, tdata->key.len,
4562 tdata->auth_iv.len, tdata->digest.len,
4563 tdata->cipher_iv.len);
4566 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4568 /* clear mbuf payload */
4569 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4570 rte_pktmbuf_tailroom(ut_params->ibuf));
4572 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4573 /* Append data which is padded to a multiple of */
4574 /* the algorithms block size */
4575 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4576 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4578 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4580 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4582 /* Create SNOW 3G operation */
4583 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
4584 tdata->digest.len, tdata->auth_iv.data,
4586 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
4587 tdata->cipher_iv.data, tdata->cipher_iv.len,
4588 tdata->validCipherLenInBits.len,
4590 tdata->validAuthLenInBits.len,
4596 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4598 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4599 ut_params->obuf = ut_params->op->sym->m_src;
4600 if (ut_params->obuf)
4601 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
4603 ciphertext = plaintext;
4605 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
4607 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4609 tdata->ciphertext.data,
4610 tdata->validDataLenInBits.len,
4611 "SNOW 3G Ciphertext data not as expected");
4613 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4614 + plaintext_pad_len;
4617 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4620 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4621 "SNOW 3G Generated auth tag not as expected");
4626 test_snow3g_auth_cipher(const struct snow3g_test_data *tdata,
4627 uint8_t op_mode, uint8_t verify)
4629 struct crypto_testsuite_params *ts_params = &testsuite_params;
4630 struct crypto_unittest_params *ut_params = &unittest_params;
4634 uint8_t *plaintext = NULL, *ciphertext = NULL;
4635 unsigned int plaintext_pad_len;
4636 unsigned int plaintext_len;
4637 unsigned int ciphertext_pad_len;
4638 unsigned int ciphertext_len;
4640 struct rte_cryptodev_info dev_info;
4642 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4644 uint64_t feat_flags = dev_info.feature_flags;
4646 if (op_mode == OUT_OF_PLACE) {
4647 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4648 printf("Device doesn't support digest encrypted.\n");
4653 /* Create SNOW 3G session */
4654 retval = create_wireless_algo_auth_cipher_session(
4655 ts_params->valid_devs[0],
4656 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4657 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4658 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4659 : RTE_CRYPTO_AUTH_OP_GENERATE),
4660 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4661 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4662 tdata->key.data, tdata->key.len,
4663 tdata->auth_iv.len, tdata->digest.len,
4664 tdata->cipher_iv.len);
4669 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4670 if (op_mode == OUT_OF_PLACE)
4671 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
4673 /* clear mbuf payload */
4674 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
4675 rte_pktmbuf_tailroom(ut_params->ibuf));
4676 if (op_mode == OUT_OF_PLACE)
4677 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
4678 rte_pktmbuf_tailroom(ut_params->obuf));
4680 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4681 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4682 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4683 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4686 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4687 ciphertext_pad_len);
4688 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
4689 if (op_mode == OUT_OF_PLACE)
4690 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
4691 debug_hexdump(stdout, "ciphertext:", ciphertext,
4694 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
4696 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
4697 if (op_mode == OUT_OF_PLACE)
4698 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
4699 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
4702 /* Create SNOW 3G operation */
4703 retval = create_wireless_algo_auth_cipher_operation(
4704 tdata->digest.data, tdata->digest.len,
4705 tdata->cipher_iv.data, tdata->cipher_iv.len,
4706 tdata->auth_iv.data, tdata->auth_iv.len,
4707 (tdata->digest.offset_bytes == 0 ?
4708 (verify ? ciphertext_pad_len : plaintext_pad_len)
4709 : tdata->digest.offset_bytes),
4710 tdata->validCipherLenInBits.len,
4711 tdata->cipher.offset_bits,
4712 tdata->validAuthLenInBits.len,
4713 tdata->auth.offset_bits,
4714 op_mode, 0, verify);
4719 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4722 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4724 ut_params->obuf = (op_mode == IN_PLACE ?
4725 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4728 if (ut_params->obuf)
4729 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
4732 plaintext = ciphertext +
4733 (tdata->cipher.offset_bits >> 3);
4735 debug_hexdump(stdout, "plaintext:", plaintext,
4736 (tdata->plaintext.len >> 3) - tdata->digest.len);
4737 debug_hexdump(stdout, "plaintext expected:",
4738 tdata->plaintext.data,
4739 (tdata->plaintext.len >> 3) - tdata->digest.len);
4741 if (ut_params->obuf)
4742 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
4745 ciphertext = plaintext;
4747 debug_hexdump(stdout, "ciphertext:", ciphertext,
4749 debug_hexdump(stdout, "ciphertext expected:",
4750 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4752 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
4753 + (tdata->digest.offset_bytes == 0 ?
4754 plaintext_pad_len : tdata->digest.offset_bytes);
4756 debug_hexdump(stdout, "digest:", ut_params->digest,
4758 debug_hexdump(stdout, "digest expected:", tdata->digest.data,
4764 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4766 tdata->plaintext.data,
4767 tdata->plaintext.len >> 3,
4768 "SNOW 3G Plaintext data not as expected");
4770 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4772 tdata->ciphertext.data,
4773 tdata->validDataLenInBits.len,
4774 "SNOW 3G Ciphertext data not as expected");
4776 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4779 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4780 "SNOW 3G Generated auth tag not as expected");
4786 test_snow3g_auth_cipher_sgl(const struct snow3g_test_data *tdata,
4787 uint8_t op_mode, uint8_t verify)
4789 struct crypto_testsuite_params *ts_params = &testsuite_params;
4790 struct crypto_unittest_params *ut_params = &unittest_params;
4794 const uint8_t *plaintext = NULL;
4795 const uint8_t *ciphertext = NULL;
4796 const uint8_t *digest = NULL;
4797 unsigned int plaintext_pad_len;
4798 unsigned int plaintext_len;
4799 unsigned int ciphertext_pad_len;
4800 unsigned int ciphertext_len;
4801 uint8_t buffer[10000];
4802 uint8_t digest_buffer[10000];
4804 struct rte_cryptodev_info dev_info;
4806 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4808 uint64_t feat_flags = dev_info.feature_flags;
4810 if (op_mode == IN_PLACE) {
4811 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
4812 printf("Device doesn't support in-place scatter-gather "
4813 "in both input and output mbufs.\n");
4817 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
4818 printf("Device doesn't support out-of-place scatter-gather "
4819 "in both input and output mbufs.\n");
4822 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4823 printf("Device doesn't support digest encrypted.\n");
4828 /* Create SNOW 3G session */
4829 retval = create_wireless_algo_auth_cipher_session(
4830 ts_params->valid_devs[0],
4831 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
4832 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
4833 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
4834 : RTE_CRYPTO_AUTH_OP_GENERATE),
4835 RTE_CRYPTO_AUTH_SNOW3G_UIA2,
4836 RTE_CRYPTO_CIPHER_SNOW3G_UEA2,
4837 tdata->key.data, tdata->key.len,
4838 tdata->auth_iv.len, tdata->digest.len,
4839 tdata->cipher_iv.len);
4844 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
4845 plaintext_len = ceil_byte_length(tdata->plaintext.len);
4846 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
4847 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
4849 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
4850 plaintext_pad_len, 15, 0);
4851 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
4852 "Failed to allocate input buffer in mempool");
4854 if (op_mode == OUT_OF_PLACE) {
4855 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
4856 plaintext_pad_len, 15, 0);
4857 TEST_ASSERT_NOT_NULL(ut_params->obuf,
4858 "Failed to allocate output buffer in mempool");
4862 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
4863 tdata->ciphertext.data);
4864 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4865 ciphertext_len, buffer);
4866 debug_hexdump(stdout, "ciphertext:", ciphertext,
4869 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
4870 tdata->plaintext.data);
4871 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4872 plaintext_len, buffer);
4873 debug_hexdump(stdout, "plaintext:", plaintext,
4876 memset(buffer, 0, sizeof(buffer));
4878 /* Create SNOW 3G operation */
4879 retval = create_wireless_algo_auth_cipher_operation(
4880 tdata->digest.data, tdata->digest.len,
4881 tdata->cipher_iv.data, tdata->cipher_iv.len,
4882 tdata->auth_iv.data, tdata->auth_iv.len,
4883 (tdata->digest.offset_bytes == 0 ?
4884 (verify ? ciphertext_pad_len : plaintext_pad_len)
4885 : tdata->digest.offset_bytes),
4886 tdata->validCipherLenInBits.len,
4887 tdata->cipher.offset_bits,
4888 tdata->validAuthLenInBits.len,
4889 tdata->auth.offset_bits,
4890 op_mode, 1, verify);
4895 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
4898 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
4900 ut_params->obuf = (op_mode == IN_PLACE ?
4901 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
4904 if (ut_params->obuf)
4905 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
4906 plaintext_len, buffer);
4908 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
4909 plaintext_len, buffer);
4911 debug_hexdump(stdout, "plaintext:", plaintext,
4912 (tdata->plaintext.len >> 3) - tdata->digest.len);
4913 debug_hexdump(stdout, "plaintext expected:",
4914 tdata->plaintext.data,
4915 (tdata->plaintext.len >> 3) - tdata->digest.len);
4917 if (ut_params->obuf)
4918 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
4919 ciphertext_len, buffer);
4921 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
4922 ciphertext_len, buffer);
4924 debug_hexdump(stdout, "ciphertext:", ciphertext,
4926 debug_hexdump(stdout, "ciphertext expected:",
4927 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
4929 if (ut_params->obuf)
4930 digest = rte_pktmbuf_read(ut_params->obuf,
4931 (tdata->digest.offset_bytes == 0 ?
4932 plaintext_pad_len : tdata->digest.offset_bytes),
4933 tdata->digest.len, digest_buffer);
4935 digest = rte_pktmbuf_read(ut_params->ibuf,
4936 (tdata->digest.offset_bytes == 0 ?
4937 plaintext_pad_len : tdata->digest.offset_bytes),
4938 tdata->digest.len, digest_buffer);
4940 debug_hexdump(stdout, "digest:", digest,
4942 debug_hexdump(stdout, "digest expected:",
4943 tdata->digest.data, tdata->digest.len);
4948 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4950 tdata->plaintext.data,
4951 tdata->plaintext.len >> 3,
4952 "SNOW 3G Plaintext data not as expected");
4954 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
4956 tdata->ciphertext.data,
4957 tdata->validDataLenInBits.len,
4958 "SNOW 3G Ciphertext data not as expected");
4960 TEST_ASSERT_BUFFERS_ARE_EQUAL(
4963 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
4964 "SNOW 3G Generated auth tag not as expected");
4970 test_kasumi_auth_cipher(const struct kasumi_test_data *tdata,
4971 uint8_t op_mode, uint8_t verify)
4973 struct crypto_testsuite_params *ts_params = &testsuite_params;
4974 struct crypto_unittest_params *ut_params = &unittest_params;
4978 uint8_t *plaintext = NULL, *ciphertext = NULL;
4979 unsigned int plaintext_pad_len;
4980 unsigned int plaintext_len;
4981 unsigned int ciphertext_pad_len;
4982 unsigned int ciphertext_len;
4984 struct rte_cryptodev_info dev_info;
4986 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
4988 uint64_t feat_flags = dev_info.feature_flags;
4990 if (op_mode == OUT_OF_PLACE) {
4991 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
4992 printf("Device doesn't support digest encrypted.\n");
4997 /* Create KASUMI session */
4998 retval = create_wireless_algo_auth_cipher_session(
4999 ts_params->valid_devs[0],
5000 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5001 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5002 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5003 : RTE_CRYPTO_AUTH_OP_GENERATE),
5004 RTE_CRYPTO_AUTH_KASUMI_F9,
5005 RTE_CRYPTO_CIPHER_KASUMI_F8,
5006 tdata->key.data, tdata->key.len,
5007 0, tdata->digest.len,
5008 tdata->cipher_iv.len);
5013 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5014 if (op_mode == OUT_OF_PLACE)
5015 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5017 /* clear mbuf payload */
5018 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5019 rte_pktmbuf_tailroom(ut_params->ibuf));
5020 if (op_mode == OUT_OF_PLACE)
5021 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5022 rte_pktmbuf_tailroom(ut_params->obuf));
5024 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5025 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5026 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5027 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5030 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5031 ciphertext_pad_len);
5032 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5033 if (op_mode == OUT_OF_PLACE)
5034 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5035 debug_hexdump(stdout, "ciphertext:", ciphertext,
5038 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5040 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5041 if (op_mode == OUT_OF_PLACE)
5042 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5043 debug_hexdump(stdout, "plaintext:", plaintext,
5047 /* Create KASUMI operation */
5048 retval = create_wireless_algo_auth_cipher_operation(
5049 tdata->digest.data, tdata->digest.len,
5050 tdata->cipher_iv.data, tdata->cipher_iv.len,
5052 (tdata->digest.offset_bytes == 0 ?
5053 (verify ? ciphertext_pad_len : plaintext_pad_len)
5054 : tdata->digest.offset_bytes),
5055 tdata->validCipherLenInBits.len,
5056 tdata->validCipherOffsetInBits.len,
5057 tdata->validAuthLenInBits.len,
5059 op_mode, 0, verify);
5064 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5067 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5069 ut_params->obuf = (op_mode == IN_PLACE ?
5070 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5074 if (ut_params->obuf)
5075 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5078 plaintext = ciphertext;
5080 debug_hexdump(stdout, "plaintext:", plaintext,
5081 (tdata->plaintext.len >> 3) - tdata->digest.len);
5082 debug_hexdump(stdout, "plaintext expected:",
5083 tdata->plaintext.data,
5084 (tdata->plaintext.len >> 3) - tdata->digest.len);
5086 if (ut_params->obuf)
5087 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5090 ciphertext = plaintext;
5092 debug_hexdump(stdout, "ciphertext:", ciphertext,
5094 debug_hexdump(stdout, "ciphertext expected:",
5095 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5097 ut_params->digest = rte_pktmbuf_mtod(
5098 ut_params->obuf, uint8_t *) +
5099 (tdata->digest.offset_bytes == 0 ?
5100 plaintext_pad_len : tdata->digest.offset_bytes);
5102 debug_hexdump(stdout, "digest:", ut_params->digest,
5104 debug_hexdump(stdout, "digest expected:",
5105 tdata->digest.data, tdata->digest.len);
5110 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5112 tdata->plaintext.data,
5113 tdata->plaintext.len >> 3,
5114 "KASUMI Plaintext data not as expected");
5116 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5118 tdata->ciphertext.data,
5119 tdata->ciphertext.len >> 3,
5120 "KASUMI Ciphertext data not as expected");
5122 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5125 DIGEST_BYTE_LENGTH_KASUMI_F9,
5126 "KASUMI Generated auth tag not as expected");
5132 test_kasumi_auth_cipher_sgl(const struct kasumi_test_data *tdata,
5133 uint8_t op_mode, uint8_t verify)
5135 struct crypto_testsuite_params *ts_params = &testsuite_params;
5136 struct crypto_unittest_params *ut_params = &unittest_params;
5140 const uint8_t *plaintext = NULL;
5141 const uint8_t *ciphertext = NULL;
5142 const uint8_t *digest = NULL;
5143 unsigned int plaintext_pad_len;
5144 unsigned int plaintext_len;
5145 unsigned int ciphertext_pad_len;
5146 unsigned int ciphertext_len;
5147 uint8_t buffer[10000];
5148 uint8_t digest_buffer[10000];
5150 struct rte_cryptodev_info dev_info;
5152 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5154 uint64_t feat_flags = dev_info.feature_flags;
5156 if (op_mode == IN_PLACE) {
5157 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5158 printf("Device doesn't support in-place scatter-gather "
5159 "in both input and output mbufs.\n");
5163 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5164 printf("Device doesn't support out-of-place scatter-gather "
5165 "in both input and output mbufs.\n");
5168 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5169 printf("Device doesn't support digest encrypted.\n");
5174 /* Create KASUMI session */
5175 retval = create_wireless_algo_auth_cipher_session(
5176 ts_params->valid_devs[0],
5177 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5178 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5179 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5180 : RTE_CRYPTO_AUTH_OP_GENERATE),
5181 RTE_CRYPTO_AUTH_KASUMI_F9,
5182 RTE_CRYPTO_CIPHER_KASUMI_F8,
5183 tdata->key.data, tdata->key.len,
5184 0, tdata->digest.len,
5185 tdata->cipher_iv.len);
5190 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5191 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5192 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5193 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5195 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5196 plaintext_pad_len, 15, 0);
5197 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5198 "Failed to allocate input buffer in mempool");
5200 if (op_mode == OUT_OF_PLACE) {
5201 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5202 plaintext_pad_len, 15, 0);
5203 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5204 "Failed to allocate output buffer in mempool");
5208 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5209 tdata->ciphertext.data);
5210 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5211 ciphertext_len, buffer);
5212 debug_hexdump(stdout, "ciphertext:", ciphertext,
5215 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5216 tdata->plaintext.data);
5217 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5218 plaintext_len, buffer);
5219 debug_hexdump(stdout, "plaintext:", plaintext,
5222 memset(buffer, 0, sizeof(buffer));
5224 /* Create KASUMI operation */
5225 retval = create_wireless_algo_auth_cipher_operation(
5226 tdata->digest.data, tdata->digest.len,
5227 tdata->cipher_iv.data, tdata->cipher_iv.len,
5229 (tdata->digest.offset_bytes == 0 ?
5230 (verify ? ciphertext_pad_len : plaintext_pad_len)
5231 : tdata->digest.offset_bytes),
5232 tdata->validCipherLenInBits.len,
5233 tdata->validCipherOffsetInBits.len,
5234 tdata->validAuthLenInBits.len,
5236 op_mode, 1, verify);
5241 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5244 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5246 ut_params->obuf = (op_mode == IN_PLACE ?
5247 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5250 if (ut_params->obuf)
5251 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5252 plaintext_len, buffer);
5254 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5255 plaintext_len, buffer);
5257 debug_hexdump(stdout, "plaintext:", plaintext,
5258 (tdata->plaintext.len >> 3) - tdata->digest.len);
5259 debug_hexdump(stdout, "plaintext expected:",
5260 tdata->plaintext.data,
5261 (tdata->plaintext.len >> 3) - tdata->digest.len);
5263 if (ut_params->obuf)
5264 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5265 ciphertext_len, buffer);
5267 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5268 ciphertext_len, buffer);
5270 debug_hexdump(stdout, "ciphertext:", ciphertext,
5272 debug_hexdump(stdout, "ciphertext expected:",
5273 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5275 if (ut_params->obuf)
5276 digest = rte_pktmbuf_read(ut_params->obuf,
5277 (tdata->digest.offset_bytes == 0 ?
5278 plaintext_pad_len : tdata->digest.offset_bytes),
5279 tdata->digest.len, digest_buffer);
5281 digest = rte_pktmbuf_read(ut_params->ibuf,
5282 (tdata->digest.offset_bytes == 0 ?
5283 plaintext_pad_len : tdata->digest.offset_bytes),
5284 tdata->digest.len, digest_buffer);
5286 debug_hexdump(stdout, "digest:", digest,
5288 debug_hexdump(stdout, "digest expected:",
5289 tdata->digest.data, tdata->digest.len);
5294 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5296 tdata->plaintext.data,
5297 tdata->plaintext.len >> 3,
5298 "KASUMI Plaintext data not as expected");
5300 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5302 tdata->ciphertext.data,
5303 tdata->validDataLenInBits.len,
5304 "KASUMI Ciphertext data not as expected");
5306 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5309 DIGEST_BYTE_LENGTH_KASUMI_F9,
5310 "KASUMI Generated auth tag not as expected");
5316 test_kasumi_cipher_auth(const struct kasumi_test_data *tdata)
5318 struct crypto_testsuite_params *ts_params = &testsuite_params;
5319 struct crypto_unittest_params *ut_params = &unittest_params;
5323 uint8_t *plaintext, *ciphertext;
5324 unsigned plaintext_pad_len;
5325 unsigned plaintext_len;
5327 /* Create KASUMI session */
5328 retval = create_wireless_algo_cipher_auth_session(
5329 ts_params->valid_devs[0],
5330 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5331 RTE_CRYPTO_AUTH_OP_GENERATE,
5332 RTE_CRYPTO_AUTH_KASUMI_F9,
5333 RTE_CRYPTO_CIPHER_KASUMI_F8,
5334 tdata->key.data, tdata->key.len,
5335 0, tdata->digest.len,
5336 tdata->cipher_iv.len);
5340 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5342 /* clear mbuf payload */
5343 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5344 rte_pktmbuf_tailroom(ut_params->ibuf));
5346 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5347 /* Append data which is padded to a multiple of */
5348 /* the algorithms block size */
5349 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5350 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5352 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5354 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5356 /* Create KASUMI operation */
5357 retval = create_wireless_algo_cipher_hash_operation(tdata->digest.data,
5358 tdata->digest.len, NULL, 0,
5359 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5360 tdata->cipher_iv.data, tdata->cipher_iv.len,
5361 RTE_ALIGN_CEIL(tdata->validCipherLenInBits.len, 8),
5362 tdata->validCipherOffsetInBits.len,
5363 tdata->validAuthLenInBits.len,
5369 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5371 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5373 if (ut_params->op->sym->m_dst)
5374 ut_params->obuf = ut_params->op->sym->m_dst;
5376 ut_params->obuf = ut_params->op->sym->m_src;
5378 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
5379 tdata->validCipherOffsetInBits.len >> 3);
5381 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5382 + plaintext_pad_len;
5384 const uint8_t *reference_ciphertext = tdata->ciphertext.data +
5385 (tdata->validCipherOffsetInBits.len >> 3);
5387 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5389 reference_ciphertext,
5390 tdata->validCipherLenInBits.len,
5391 "KASUMI Ciphertext data not as expected");
5394 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5397 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
5398 "KASUMI Generated auth tag not as expected");
5403 test_zuc_encryption(const struct wireless_test_data *tdata)
5405 struct crypto_testsuite_params *ts_params = &testsuite_params;
5406 struct crypto_unittest_params *ut_params = &unittest_params;
5409 uint8_t *plaintext, *ciphertext;
5410 unsigned plaintext_pad_len;
5411 unsigned plaintext_len;
5413 struct rte_cryptodev_sym_capability_idx cap_idx;
5415 /* Check if device supports ZUC EEA3 */
5416 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5417 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5419 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5423 /* Create ZUC session */
5424 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5425 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5426 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5427 tdata->key.data, tdata->key.len,
5428 tdata->cipher_iv.len);
5432 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5434 /* Clear mbuf payload */
5435 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5436 rte_pktmbuf_tailroom(ut_params->ibuf));
5438 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5439 /* Append data which is padded to a multiple */
5440 /* of the algorithms block size */
5441 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5442 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5444 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5446 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
5448 /* Create ZUC operation */
5449 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5450 tdata->cipher_iv.len,
5451 tdata->plaintext.len,
5456 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5458 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5460 ut_params->obuf = ut_params->op->sym->m_dst;
5461 if (ut_params->obuf)
5462 ciphertext = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *);
5464 ciphertext = plaintext;
5466 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5469 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5471 tdata->ciphertext.data,
5472 tdata->validCipherLenInBits.len,
5473 "ZUC Ciphertext data not as expected");
5478 test_zuc_encryption_sgl(const struct wireless_test_data *tdata)
5480 struct crypto_testsuite_params *ts_params = &testsuite_params;
5481 struct crypto_unittest_params *ut_params = &unittest_params;
5485 unsigned int plaintext_pad_len;
5486 unsigned int plaintext_len;
5487 const uint8_t *ciphertext;
5488 uint8_t ciphertext_buffer[2048];
5489 struct rte_cryptodev_info dev_info;
5491 struct rte_cryptodev_sym_capability_idx cap_idx;
5493 /* Check if device supports ZUC EEA3 */
5494 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
5495 cap_idx.algo.cipher = RTE_CRYPTO_CIPHER_ZUC_EEA3;
5497 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5501 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5503 uint64_t feat_flags = dev_info.feature_flags;
5505 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5506 printf("Device doesn't support in-place scatter-gather. "
5511 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5513 /* Append data which is padded to a multiple */
5514 /* of the algorithms block size */
5515 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5517 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5518 plaintext_pad_len, 10, 0);
5520 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5521 tdata->plaintext.data);
5523 /* Create ZUC session */
5524 retval = create_wireless_algo_cipher_session(ts_params->valid_devs[0],
5525 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
5526 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5527 tdata->key.data, tdata->key.len,
5528 tdata->cipher_iv.len);
5532 /* Clear mbuf payload */
5534 pktmbuf_write(ut_params->ibuf, 0, plaintext_len, tdata->plaintext.data);
5536 /* Create ZUC operation */
5537 retval = create_wireless_algo_cipher_operation(tdata->cipher_iv.data,
5538 tdata->cipher_iv.len, tdata->plaintext.len,
5543 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5545 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5547 ut_params->obuf = ut_params->op->sym->m_dst;
5548 if (ut_params->obuf)
5549 ciphertext = rte_pktmbuf_read(ut_params->obuf,
5550 0, plaintext_len, ciphertext_buffer);
5552 ciphertext = rte_pktmbuf_read(ut_params->ibuf,
5553 0, plaintext_len, ciphertext_buffer);
5556 debug_hexdump(stdout, "ciphertext:", ciphertext, plaintext_len);
5559 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5561 tdata->ciphertext.data,
5562 tdata->validCipherLenInBits.len,
5563 "ZUC Ciphertext data not as expected");
5569 test_zuc_authentication(const struct wireless_test_data *tdata)
5571 struct crypto_testsuite_params *ts_params = &testsuite_params;
5572 struct crypto_unittest_params *ut_params = &unittest_params;
5575 unsigned plaintext_pad_len;
5576 unsigned plaintext_len;
5579 struct rte_cryptodev_sym_capability_idx cap_idx;
5581 /* Check if device supports ZUC EIA3 */
5582 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5583 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5585 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5589 /* Create ZUC session */
5590 retval = create_wireless_algo_hash_session(ts_params->valid_devs[0],
5591 tdata->key.data, tdata->key.len,
5592 tdata->auth_iv.len, tdata->digest.len,
5593 RTE_CRYPTO_AUTH_OP_GENERATE,
5594 RTE_CRYPTO_AUTH_ZUC_EIA3);
5598 /* alloc mbuf and set payload */
5599 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5601 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5602 rte_pktmbuf_tailroom(ut_params->ibuf));
5604 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5605 /* Append data which is padded to a multiple of */
5606 /* the algorithms block size */
5607 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 8);
5608 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5610 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5612 /* Create ZUC operation */
5613 retval = create_wireless_algo_hash_operation(NULL, tdata->digest.len,
5614 tdata->auth_iv.data, tdata->auth_iv.len,
5615 plaintext_pad_len, RTE_CRYPTO_AUTH_OP_GENERATE,
5616 tdata->validAuthLenInBits.len,
5621 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5623 ut_params->obuf = ut_params->op->sym->m_src;
5624 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5625 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
5626 + plaintext_pad_len;
5629 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5632 DIGEST_BYTE_LENGTH_KASUMI_F9,
5633 "ZUC Generated auth tag not as expected");
5639 test_zuc_auth_cipher(const struct wireless_test_data *tdata,
5640 uint8_t op_mode, uint8_t verify)
5642 struct crypto_testsuite_params *ts_params = &testsuite_params;
5643 struct crypto_unittest_params *ut_params = &unittest_params;
5647 uint8_t *plaintext = NULL, *ciphertext = NULL;
5648 unsigned int plaintext_pad_len;
5649 unsigned int plaintext_len;
5650 unsigned int ciphertext_pad_len;
5651 unsigned int ciphertext_len;
5653 struct rte_cryptodev_info dev_info;
5654 struct rte_cryptodev_sym_capability_idx cap_idx;
5656 /* Check if device supports ZUC EIA3 */
5657 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5658 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5660 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5664 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5666 uint64_t feat_flags = dev_info.feature_flags;
5668 if (op_mode == OUT_OF_PLACE) {
5669 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5670 printf("Device doesn't support digest encrypted.\n");
5675 /* Create ZUC session */
5676 retval = create_wireless_algo_auth_cipher_session(
5677 ts_params->valid_devs[0],
5678 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5679 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5680 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5681 : RTE_CRYPTO_AUTH_OP_GENERATE),
5682 RTE_CRYPTO_AUTH_ZUC_EIA3,
5683 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5684 tdata->key.data, tdata->key.len,
5685 tdata->auth_iv.len, tdata->digest.len,
5686 tdata->cipher_iv.len);
5691 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5692 if (op_mode == OUT_OF_PLACE)
5693 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
5695 /* clear mbuf payload */
5696 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
5697 rte_pktmbuf_tailroom(ut_params->ibuf));
5698 if (op_mode == OUT_OF_PLACE)
5699 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
5700 rte_pktmbuf_tailroom(ut_params->obuf));
5702 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5703 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5704 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5705 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5708 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5709 ciphertext_pad_len);
5710 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
5711 if (op_mode == OUT_OF_PLACE)
5712 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
5713 debug_hexdump(stdout, "ciphertext:", ciphertext,
5716 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
5718 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
5719 if (op_mode == OUT_OF_PLACE)
5720 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
5721 debug_hexdump(stdout, "plaintext:", plaintext,
5725 /* Create ZUC operation */
5726 retval = create_wireless_algo_auth_cipher_operation(
5727 tdata->digest.data, tdata->digest.len,
5728 tdata->cipher_iv.data, tdata->cipher_iv.len,
5729 tdata->auth_iv.data, tdata->auth_iv.len,
5730 (tdata->digest.offset_bytes == 0 ?
5731 (verify ? ciphertext_pad_len : plaintext_pad_len)
5732 : tdata->digest.offset_bytes),
5733 tdata->validCipherLenInBits.len,
5734 tdata->validCipherOffsetInBits.len,
5735 tdata->validAuthLenInBits.len,
5737 op_mode, 0, verify);
5742 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5745 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5747 ut_params->obuf = (op_mode == IN_PLACE ?
5748 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5752 if (ut_params->obuf)
5753 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
5756 plaintext = ciphertext;
5758 debug_hexdump(stdout, "plaintext:", plaintext,
5759 (tdata->plaintext.len >> 3) - tdata->digest.len);
5760 debug_hexdump(stdout, "plaintext expected:",
5761 tdata->plaintext.data,
5762 (tdata->plaintext.len >> 3) - tdata->digest.len);
5764 if (ut_params->obuf)
5765 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
5768 ciphertext = plaintext;
5770 debug_hexdump(stdout, "ciphertext:", ciphertext,
5772 debug_hexdump(stdout, "ciphertext expected:",
5773 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5775 ut_params->digest = rte_pktmbuf_mtod(
5776 ut_params->obuf, uint8_t *) +
5777 (tdata->digest.offset_bytes == 0 ?
5778 plaintext_pad_len : tdata->digest.offset_bytes);
5780 debug_hexdump(stdout, "digest:", ut_params->digest,
5782 debug_hexdump(stdout, "digest expected:",
5783 tdata->digest.data, tdata->digest.len);
5788 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5790 tdata->plaintext.data,
5791 tdata->plaintext.len >> 3,
5792 "ZUC Plaintext data not as expected");
5794 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5796 tdata->ciphertext.data,
5797 tdata->ciphertext.len >> 3,
5798 "ZUC Ciphertext data not as expected");
5800 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5803 DIGEST_BYTE_LENGTH_KASUMI_F9,
5804 "ZUC Generated auth tag not as expected");
5810 test_zuc_auth_cipher_sgl(const struct wireless_test_data *tdata,
5811 uint8_t op_mode, uint8_t verify)
5813 struct crypto_testsuite_params *ts_params = &testsuite_params;
5814 struct crypto_unittest_params *ut_params = &unittest_params;
5818 const uint8_t *plaintext = NULL;
5819 const uint8_t *ciphertext = NULL;
5820 const uint8_t *digest = NULL;
5821 unsigned int plaintext_pad_len;
5822 unsigned int plaintext_len;
5823 unsigned int ciphertext_pad_len;
5824 unsigned int ciphertext_len;
5825 uint8_t buffer[10000];
5826 uint8_t digest_buffer[10000];
5828 struct rte_cryptodev_info dev_info;
5829 struct rte_cryptodev_sym_capability_idx cap_idx;
5831 /* Check if device supports ZUC EIA3 */
5832 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
5833 cap_idx.algo.auth = RTE_CRYPTO_AUTH_ZUC_EIA3;
5835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
5839 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
5841 uint64_t feat_flags = dev_info.feature_flags;
5843 if (op_mode == IN_PLACE) {
5844 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
5845 printf("Device doesn't support in-place scatter-gather "
5846 "in both input and output mbufs.\n");
5850 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
5851 printf("Device doesn't support out-of-place scatter-gather "
5852 "in both input and output mbufs.\n");
5855 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
5856 printf("Device doesn't support digest encrypted.\n");
5861 /* Create ZUC session */
5862 retval = create_wireless_algo_auth_cipher_session(
5863 ts_params->valid_devs[0],
5864 (verify ? RTE_CRYPTO_CIPHER_OP_DECRYPT
5865 : RTE_CRYPTO_CIPHER_OP_ENCRYPT),
5866 (verify ? RTE_CRYPTO_AUTH_OP_VERIFY
5867 : RTE_CRYPTO_AUTH_OP_GENERATE),
5868 RTE_CRYPTO_AUTH_ZUC_EIA3,
5869 RTE_CRYPTO_CIPHER_ZUC_EEA3,
5870 tdata->key.data, tdata->key.len,
5871 tdata->auth_iv.len, tdata->digest.len,
5872 tdata->cipher_iv.len);
5877 ciphertext_len = ceil_byte_length(tdata->ciphertext.len);
5878 plaintext_len = ceil_byte_length(tdata->plaintext.len);
5879 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
5880 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
5882 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
5883 plaintext_pad_len, 15, 0);
5884 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
5885 "Failed to allocate input buffer in mempool");
5887 if (op_mode == OUT_OF_PLACE) {
5888 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
5889 plaintext_pad_len, 15, 0);
5890 TEST_ASSERT_NOT_NULL(ut_params->obuf,
5891 "Failed to allocate output buffer in mempool");
5895 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
5896 tdata->ciphertext.data);
5897 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5898 ciphertext_len, buffer);
5899 debug_hexdump(stdout, "ciphertext:", ciphertext,
5902 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
5903 tdata->plaintext.data);
5904 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5905 plaintext_len, buffer);
5906 debug_hexdump(stdout, "plaintext:", plaintext,
5909 memset(buffer, 0, sizeof(buffer));
5911 /* Create ZUC operation */
5912 retval = create_wireless_algo_auth_cipher_operation(
5913 tdata->digest.data, tdata->digest.len,
5914 tdata->cipher_iv.data, tdata->cipher_iv.len,
5916 (tdata->digest.offset_bytes == 0 ?
5917 (verify ? ciphertext_pad_len : plaintext_pad_len)
5918 : tdata->digest.offset_bytes),
5919 tdata->validCipherLenInBits.len,
5920 tdata->validCipherOffsetInBits.len,
5921 tdata->validAuthLenInBits.len,
5923 op_mode, 1, verify);
5928 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
5931 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
5933 ut_params->obuf = (op_mode == IN_PLACE ?
5934 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
5937 if (ut_params->obuf)
5938 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
5939 plaintext_len, buffer);
5941 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
5942 plaintext_len, buffer);
5944 debug_hexdump(stdout, "plaintext:", plaintext,
5945 (tdata->plaintext.len >> 3) - tdata->digest.len);
5946 debug_hexdump(stdout, "plaintext expected:",
5947 tdata->plaintext.data,
5948 (tdata->plaintext.len >> 3) - tdata->digest.len);
5950 if (ut_params->obuf)
5951 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
5952 ciphertext_len, buffer);
5954 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
5955 ciphertext_len, buffer);
5957 debug_hexdump(stdout, "ciphertext:", ciphertext,
5959 debug_hexdump(stdout, "ciphertext expected:",
5960 tdata->ciphertext.data, tdata->ciphertext.len >> 3);
5962 if (ut_params->obuf)
5963 digest = rte_pktmbuf_read(ut_params->obuf,
5964 (tdata->digest.offset_bytes == 0 ?
5965 plaintext_pad_len : tdata->digest.offset_bytes),
5966 tdata->digest.len, digest_buffer);
5968 digest = rte_pktmbuf_read(ut_params->ibuf,
5969 (tdata->digest.offset_bytes == 0 ?
5970 plaintext_pad_len : tdata->digest.offset_bytes),
5971 tdata->digest.len, digest_buffer);
5973 debug_hexdump(stdout, "digest:", digest,
5975 debug_hexdump(stdout, "digest expected:",
5976 tdata->digest.data, tdata->digest.len);
5981 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5983 tdata->plaintext.data,
5984 tdata->plaintext.len >> 3,
5985 "ZUC Plaintext data not as expected");
5987 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
5989 tdata->ciphertext.data,
5990 tdata->validDataLenInBits.len,
5991 "ZUC Ciphertext data not as expected");
5993 TEST_ASSERT_BUFFERS_ARE_EQUAL(
5996 DIGEST_BYTE_LENGTH_KASUMI_F9,
5997 "ZUC Generated auth tag not as expected");
6003 test_kasumi_encryption_test_case_1(void)
6005 return test_kasumi_encryption(&kasumi_test_case_1);
6009 test_kasumi_encryption_test_case_1_sgl(void)
6011 return test_kasumi_encryption_sgl(&kasumi_test_case_1);
6015 test_kasumi_encryption_test_case_1_oop(void)
6017 return test_kasumi_encryption_oop(&kasumi_test_case_1);
6021 test_kasumi_encryption_test_case_1_oop_sgl(void)
6023 return test_kasumi_encryption_oop_sgl(&kasumi_test_case_1);
6027 test_kasumi_encryption_test_case_2(void)
6029 return test_kasumi_encryption(&kasumi_test_case_2);
6033 test_kasumi_encryption_test_case_3(void)
6035 return test_kasumi_encryption(&kasumi_test_case_3);
6039 test_kasumi_encryption_test_case_4(void)
6041 return test_kasumi_encryption(&kasumi_test_case_4);
6045 test_kasumi_encryption_test_case_5(void)
6047 return test_kasumi_encryption(&kasumi_test_case_5);
6051 test_kasumi_decryption_test_case_1(void)
6053 return test_kasumi_decryption(&kasumi_test_case_1);
6057 test_kasumi_decryption_test_case_1_oop(void)
6059 return test_kasumi_decryption_oop(&kasumi_test_case_1);
6063 test_kasumi_decryption_test_case_2(void)
6065 return test_kasumi_decryption(&kasumi_test_case_2);
6069 test_kasumi_decryption_test_case_3(void)
6071 return test_kasumi_decryption(&kasumi_test_case_3);
6075 test_kasumi_decryption_test_case_4(void)
6077 return test_kasumi_decryption(&kasumi_test_case_4);
6081 test_kasumi_decryption_test_case_5(void)
6083 return test_kasumi_decryption(&kasumi_test_case_5);
6086 test_snow3g_encryption_test_case_1(void)
6088 return test_snow3g_encryption(&snow3g_test_case_1);
6092 test_snow3g_encryption_test_case_1_oop(void)
6094 return test_snow3g_encryption_oop(&snow3g_test_case_1);
6098 test_snow3g_encryption_test_case_1_oop_sgl(void)
6100 return test_snow3g_encryption_oop_sgl(&snow3g_test_case_1);
6105 test_snow3g_encryption_test_case_1_offset_oop(void)
6107 return test_snow3g_encryption_offset_oop(&snow3g_test_case_1);
6111 test_snow3g_encryption_test_case_2(void)
6113 return test_snow3g_encryption(&snow3g_test_case_2);
6117 test_snow3g_encryption_test_case_3(void)
6119 return test_snow3g_encryption(&snow3g_test_case_3);
6123 test_snow3g_encryption_test_case_4(void)
6125 return test_snow3g_encryption(&snow3g_test_case_4);
6129 test_snow3g_encryption_test_case_5(void)
6131 return test_snow3g_encryption(&snow3g_test_case_5);
6135 test_snow3g_decryption_test_case_1(void)
6137 return test_snow3g_decryption(&snow3g_test_case_1);
6141 test_snow3g_decryption_test_case_1_oop(void)
6143 return test_snow3g_decryption_oop(&snow3g_test_case_1);
6147 test_snow3g_decryption_test_case_2(void)
6149 return test_snow3g_decryption(&snow3g_test_case_2);
6153 test_snow3g_decryption_test_case_3(void)
6155 return test_snow3g_decryption(&snow3g_test_case_3);
6159 test_snow3g_decryption_test_case_4(void)
6161 return test_snow3g_decryption(&snow3g_test_case_4);
6165 test_snow3g_decryption_test_case_5(void)
6167 return test_snow3g_decryption(&snow3g_test_case_5);
6171 * Function prepares snow3g_hash_test_data from snow3g_test_data.
6172 * Pattern digest from snow3g_test_data must be allocated as
6173 * 4 last bytes in plaintext.
6176 snow3g_hash_test_vector_setup(const struct snow3g_test_data *pattern,
6177 struct snow3g_hash_test_data *output)
6179 if ((pattern != NULL) && (output != NULL)) {
6180 output->key.len = pattern->key.len;
6182 memcpy(output->key.data,
6183 pattern->key.data, pattern->key.len);
6185 output->auth_iv.len = pattern->auth_iv.len;
6187 memcpy(output->auth_iv.data,
6188 pattern->auth_iv.data, pattern->auth_iv.len);
6190 output->plaintext.len = pattern->plaintext.len;
6192 memcpy(output->plaintext.data,
6193 pattern->plaintext.data, pattern->plaintext.len >> 3);
6195 output->digest.len = pattern->digest.len;
6197 memcpy(output->digest.data,
6198 &pattern->plaintext.data[pattern->digest.offset_bytes],
6199 pattern->digest.len);
6201 output->validAuthLenInBits.len =
6202 pattern->validAuthLenInBits.len;
6207 * Test case verify computed cipher and digest from snow3g_test_case_7 data.
6210 test_snow3g_decryption_with_digest_test_case_1(void)
6212 struct snow3g_hash_test_data snow3g_hash_data;
6215 * Function prepare data for hash veryfication test case.
6216 * Digest is allocated in 4 last bytes in plaintext, pattern.
6218 snow3g_hash_test_vector_setup(&snow3g_test_case_7, &snow3g_hash_data);
6220 return test_snow3g_decryption(&snow3g_test_case_7) &
6221 test_snow3g_authentication_verify(&snow3g_hash_data);
6225 test_snow3g_cipher_auth_test_case_1(void)
6227 return test_snow3g_cipher_auth(&snow3g_test_case_3);
6231 test_snow3g_auth_cipher_test_case_1(void)
6233 return test_snow3g_auth_cipher(
6234 &snow3g_auth_cipher_test_case_1, IN_PLACE, 0);
6238 test_snow3g_auth_cipher_test_case_2(void)
6240 return test_snow3g_auth_cipher(
6241 &snow3g_auth_cipher_test_case_2, IN_PLACE, 0);
6245 test_snow3g_auth_cipher_test_case_2_oop(void)
6247 return test_snow3g_auth_cipher(
6248 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6252 test_snow3g_auth_cipher_part_digest_enc(void)
6254 return test_snow3g_auth_cipher(
6255 &snow3g_auth_cipher_partial_digest_encryption,
6260 test_snow3g_auth_cipher_part_digest_enc_oop(void)
6262 return test_snow3g_auth_cipher(
6263 &snow3g_auth_cipher_partial_digest_encryption,
6268 test_snow3g_auth_cipher_test_case_3_sgl(void)
6270 return test_snow3g_auth_cipher_sgl(
6271 &snow3g_auth_cipher_test_case_3, IN_PLACE, 0);
6275 test_snow3g_auth_cipher_test_case_3_oop_sgl(void)
6277 return test_snow3g_auth_cipher_sgl(
6278 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 0);
6282 test_snow3g_auth_cipher_part_digest_enc_sgl(void)
6284 return test_snow3g_auth_cipher_sgl(
6285 &snow3g_auth_cipher_partial_digest_encryption,
6290 test_snow3g_auth_cipher_part_digest_enc_oop_sgl(void)
6292 return test_snow3g_auth_cipher_sgl(
6293 &snow3g_auth_cipher_partial_digest_encryption,
6298 test_snow3g_auth_cipher_verify_test_case_1(void)
6300 return test_snow3g_auth_cipher(
6301 &snow3g_auth_cipher_test_case_1, IN_PLACE, 1);
6305 test_snow3g_auth_cipher_verify_test_case_2(void)
6307 return test_snow3g_auth_cipher(
6308 &snow3g_auth_cipher_test_case_2, IN_PLACE, 1);
6312 test_snow3g_auth_cipher_verify_test_case_2_oop(void)
6314 return test_snow3g_auth_cipher(
6315 &snow3g_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6319 test_snow3g_auth_cipher_verify_part_digest_enc(void)
6321 return test_snow3g_auth_cipher(
6322 &snow3g_auth_cipher_partial_digest_encryption,
6327 test_snow3g_auth_cipher_verify_part_digest_enc_oop(void)
6329 return test_snow3g_auth_cipher(
6330 &snow3g_auth_cipher_partial_digest_encryption,
6335 test_snow3g_auth_cipher_verify_test_case_3_sgl(void)
6337 return test_snow3g_auth_cipher_sgl(
6338 &snow3g_auth_cipher_test_case_3, IN_PLACE, 1);
6342 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl(void)
6344 return test_snow3g_auth_cipher_sgl(
6345 &snow3g_auth_cipher_test_case_3, OUT_OF_PLACE, 1);
6349 test_snow3g_auth_cipher_verify_part_digest_enc_sgl(void)
6351 return test_snow3g_auth_cipher_sgl(
6352 &snow3g_auth_cipher_partial_digest_encryption,
6357 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl(void)
6359 return test_snow3g_auth_cipher_sgl(
6360 &snow3g_auth_cipher_partial_digest_encryption,
6365 test_snow3g_auth_cipher_with_digest_test_case_1(void)
6367 return test_snow3g_auth_cipher(
6368 &snow3g_test_case_7, IN_PLACE, 0);
6372 test_kasumi_auth_cipher_test_case_1(void)
6374 return test_kasumi_auth_cipher(
6375 &kasumi_test_case_3, IN_PLACE, 0);
6379 test_kasumi_auth_cipher_test_case_2(void)
6381 return test_kasumi_auth_cipher(
6382 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6386 test_kasumi_auth_cipher_test_case_2_oop(void)
6388 return test_kasumi_auth_cipher(
6389 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6393 test_kasumi_auth_cipher_test_case_2_sgl(void)
6395 return test_kasumi_auth_cipher_sgl(
6396 &kasumi_auth_cipher_test_case_2, IN_PLACE, 0);
6400 test_kasumi_auth_cipher_test_case_2_oop_sgl(void)
6402 return test_kasumi_auth_cipher_sgl(
6403 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 0);
6407 test_kasumi_auth_cipher_verify_test_case_1(void)
6409 return test_kasumi_auth_cipher(
6410 &kasumi_test_case_3, IN_PLACE, 1);
6414 test_kasumi_auth_cipher_verify_test_case_2(void)
6416 return test_kasumi_auth_cipher(
6417 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6421 test_kasumi_auth_cipher_verify_test_case_2_oop(void)
6423 return test_kasumi_auth_cipher(
6424 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6428 test_kasumi_auth_cipher_verify_test_case_2_sgl(void)
6430 return test_kasumi_auth_cipher_sgl(
6431 &kasumi_auth_cipher_test_case_2, IN_PLACE, 1);
6435 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl(void)
6437 return test_kasumi_auth_cipher_sgl(
6438 &kasumi_auth_cipher_test_case_2, OUT_OF_PLACE, 1);
6442 test_kasumi_cipher_auth_test_case_1(void)
6444 return test_kasumi_cipher_auth(&kasumi_test_case_6);
6448 test_zuc_encryption_test_case_1(void)
6450 return test_zuc_encryption(&zuc_test_case_cipher_193b);
6454 test_zuc_encryption_test_case_2(void)
6456 return test_zuc_encryption(&zuc_test_case_cipher_800b);
6460 test_zuc_encryption_test_case_3(void)
6462 return test_zuc_encryption(&zuc_test_case_cipher_1570b);
6466 test_zuc_encryption_test_case_4(void)
6468 return test_zuc_encryption(&zuc_test_case_cipher_2798b);
6472 test_zuc_encryption_test_case_5(void)
6474 return test_zuc_encryption(&zuc_test_case_cipher_4019b);
6478 test_zuc_encryption_test_case_6_sgl(void)
6480 return test_zuc_encryption_sgl(&zuc_test_case_cipher_193b);
6484 test_zuc_hash_generate_test_case_1(void)
6486 return test_zuc_authentication(&zuc_test_case_auth_1b);
6490 test_zuc_hash_generate_test_case_2(void)
6492 return test_zuc_authentication(&zuc_test_case_auth_90b);
6496 test_zuc_hash_generate_test_case_3(void)
6498 return test_zuc_authentication(&zuc_test_case_auth_577b);
6502 test_zuc_hash_generate_test_case_4(void)
6504 return test_zuc_authentication(&zuc_test_case_auth_2079b);
6508 test_zuc_hash_generate_test_case_5(void)
6510 return test_zuc_authentication(&zuc_test_auth_5670b);
6514 test_zuc_hash_generate_test_case_6(void)
6516 return test_zuc_authentication(&zuc_test_case_auth_128b);
6520 test_zuc_hash_generate_test_case_7(void)
6522 return test_zuc_authentication(&zuc_test_case_auth_2080b);
6526 test_zuc_hash_generate_test_case_8(void)
6528 return test_zuc_authentication(&zuc_test_case_auth_584b);
6532 test_zuc_cipher_auth_test_case_1(void)
6534 return test_zuc_cipher_auth(&zuc_test_case_cipher_200b_auth_200b);
6538 test_zuc_cipher_auth_test_case_2(void)
6540 return test_zuc_cipher_auth(&zuc_test_case_cipher_800b_auth_120b);
6544 test_zuc_auth_cipher_test_case_1(void)
6546 return test_zuc_auth_cipher(
6547 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6551 test_zuc_auth_cipher_test_case_1_oop(void)
6553 return test_zuc_auth_cipher(
6554 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6558 test_zuc_auth_cipher_test_case_1_sgl(void)
6560 return test_zuc_auth_cipher_sgl(
6561 &zuc_auth_cipher_test_case_1, IN_PLACE, 0);
6565 test_zuc_auth_cipher_test_case_1_oop_sgl(void)
6567 return test_zuc_auth_cipher_sgl(
6568 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 0);
6572 test_zuc_auth_cipher_verify_test_case_1(void)
6574 return test_zuc_auth_cipher(
6575 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6579 test_zuc_auth_cipher_verify_test_case_1_oop(void)
6581 return test_zuc_auth_cipher(
6582 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6586 test_zuc_auth_cipher_verify_test_case_1_sgl(void)
6588 return test_zuc_auth_cipher_sgl(
6589 &zuc_auth_cipher_test_case_1, IN_PLACE, 1);
6593 test_zuc_auth_cipher_verify_test_case_1_oop_sgl(void)
6595 return test_zuc_auth_cipher_sgl(
6596 &zuc_auth_cipher_test_case_1, OUT_OF_PLACE, 1);
6600 test_mixed_check_if_unsupported(const struct mixed_cipher_auth_test_data *tdata)
6602 uint8_t dev_id = testsuite_params.valid_devs[0];
6604 struct rte_cryptodev_sym_capability_idx cap_idx;
6606 /* Check if device supports particular cipher algorithm */
6607 cap_idx.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
6608 cap_idx.algo.cipher = tdata->cipher_algo;
6609 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6612 /* Check if device supports particular hash algorithm */
6613 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AUTH;
6614 cap_idx.algo.auth = tdata->auth_algo;
6615 if (rte_cryptodev_sym_capability_get(dev_id, &cap_idx) == NULL)
6622 test_mixed_auth_cipher(const struct mixed_cipher_auth_test_data *tdata,
6623 uint8_t op_mode, uint8_t verify)
6625 struct crypto_testsuite_params *ts_params = &testsuite_params;
6626 struct crypto_unittest_params *ut_params = &unittest_params;
6630 uint8_t *plaintext = NULL, *ciphertext = NULL;
6631 unsigned int plaintext_pad_len;
6632 unsigned int plaintext_len;
6633 unsigned int ciphertext_pad_len;
6634 unsigned int ciphertext_len;
6636 struct rte_cryptodev_info dev_info;
6637 struct rte_crypto_op *op;
6639 /* Check if device supports particular algorithms separately */
6640 if (test_mixed_check_if_unsupported(tdata))
6643 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6645 uint64_t feat_flags = dev_info.feature_flags;
6647 if (op_mode == OUT_OF_PLACE) {
6648 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6649 printf("Device doesn't support digest encrypted.\n");
6654 /* Create the session */
6656 retval = create_wireless_algo_cipher_auth_session(
6657 ts_params->valid_devs[0],
6658 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6659 RTE_CRYPTO_AUTH_OP_VERIFY,
6662 tdata->auth_key.data, tdata->auth_key.len,
6663 tdata->auth_iv.len, tdata->digest_enc.len,
6664 tdata->cipher_iv.len);
6666 retval = create_wireless_algo_auth_cipher_session(
6667 ts_params->valid_devs[0],
6668 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6669 RTE_CRYPTO_AUTH_OP_GENERATE,
6672 tdata->auth_key.data, tdata->auth_key.len,
6673 tdata->auth_iv.len, tdata->digest_enc.len,
6674 tdata->cipher_iv.len);
6678 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6679 if (op_mode == OUT_OF_PLACE)
6680 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
6682 /* clear mbuf payload */
6683 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
6684 rte_pktmbuf_tailroom(ut_params->ibuf));
6685 if (op_mode == OUT_OF_PLACE)
6686 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
6687 rte_pktmbuf_tailroom(ut_params->obuf));
6689 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6690 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6691 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6692 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6695 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6696 ciphertext_pad_len);
6697 memcpy(ciphertext, tdata->ciphertext.data, ciphertext_len);
6698 if (op_mode == OUT_OF_PLACE)
6699 rte_pktmbuf_append(ut_params->obuf, ciphertext_pad_len);
6700 debug_hexdump(stdout, "ciphertext:", ciphertext,
6703 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
6705 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
6706 if (op_mode == OUT_OF_PLACE)
6707 rte_pktmbuf_append(ut_params->obuf, plaintext_pad_len);
6708 debug_hexdump(stdout, "plaintext:", plaintext, plaintext_len);
6711 /* Create the operation */
6712 retval = create_wireless_algo_auth_cipher_operation(
6713 tdata->digest_enc.data, tdata->digest_enc.len,
6714 tdata->cipher_iv.data, tdata->cipher_iv.len,
6715 tdata->auth_iv.data, tdata->auth_iv.len,
6716 (tdata->digest_enc.offset == 0 ?
6718 : tdata->digest_enc.offset),
6719 tdata->validCipherLen.len_bits,
6720 tdata->cipher.offset_bits,
6721 tdata->validAuthLen.len_bits,
6722 tdata->auth.offset_bits,
6723 op_mode, 0, verify);
6728 op = process_crypto_request(ts_params->valid_devs[0],
6731 /* Check if the op failed because the device doesn't */
6732 /* support this particular combination of algorithms */
6733 if (op == NULL && ut_params->op->status ==
6734 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6735 printf("Device doesn't support this mixed combination. "
6741 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6743 ut_params->obuf = (op_mode == IN_PLACE ?
6744 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6747 if (ut_params->obuf)
6748 plaintext = rte_pktmbuf_mtod(ut_params->obuf,
6751 plaintext = ciphertext +
6752 (tdata->cipher.offset_bits >> 3);
6754 debug_hexdump(stdout, "plaintext:", plaintext,
6755 tdata->plaintext.len_bits >> 3);
6756 debug_hexdump(stdout, "plaintext expected:",
6757 tdata->plaintext.data,
6758 tdata->plaintext.len_bits >> 3);
6760 if (ut_params->obuf)
6761 ciphertext = rte_pktmbuf_mtod(ut_params->obuf,
6764 ciphertext = plaintext;
6766 debug_hexdump(stdout, "ciphertext:", ciphertext,
6768 debug_hexdump(stdout, "ciphertext expected:",
6769 tdata->ciphertext.data,
6770 tdata->ciphertext.len_bits >> 3);
6772 ut_params->digest = rte_pktmbuf_mtod(ut_params->obuf, uint8_t *)
6773 + (tdata->digest_enc.offset == 0 ?
6774 plaintext_pad_len : tdata->digest_enc.offset);
6776 debug_hexdump(stdout, "digest:", ut_params->digest,
6777 tdata->digest_enc.len);
6778 debug_hexdump(stdout, "digest expected:",
6779 tdata->digest_enc.data,
6780 tdata->digest_enc.len);
6785 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6787 tdata->plaintext.data,
6788 tdata->plaintext.len_bits >> 3,
6789 "Plaintext data not as expected");
6791 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
6793 tdata->ciphertext.data,
6794 tdata->validDataLen.len_bits,
6795 "Ciphertext data not as expected");
6797 TEST_ASSERT_BUFFERS_ARE_EQUAL(
6799 tdata->digest_enc.data,
6800 DIGEST_BYTE_LENGTH_SNOW3G_UIA2,
6801 "Generated auth tag not as expected");
6804 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
6805 "crypto op processing failed");
6811 test_mixed_auth_cipher_sgl(const struct mixed_cipher_auth_test_data *tdata,
6812 uint8_t op_mode, uint8_t verify)
6814 struct crypto_testsuite_params *ts_params = &testsuite_params;
6815 struct crypto_unittest_params *ut_params = &unittest_params;
6819 const uint8_t *plaintext = NULL;
6820 const uint8_t *ciphertext = NULL;
6821 const uint8_t *digest = NULL;
6822 unsigned int plaintext_pad_len;
6823 unsigned int plaintext_len;
6824 unsigned int ciphertext_pad_len;
6825 unsigned int ciphertext_len;
6826 uint8_t buffer[10000];
6827 uint8_t digest_buffer[10000];
6829 struct rte_cryptodev_info dev_info;
6830 struct rte_crypto_op *op;
6832 /* Check if device supports particular algorithms */
6833 if (test_mixed_check_if_unsupported(tdata))
6836 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
6838 uint64_t feat_flags = dev_info.feature_flags;
6840 if (op_mode == IN_PLACE) {
6841 if (!(feat_flags & RTE_CRYPTODEV_FF_IN_PLACE_SGL)) {
6842 printf("Device doesn't support in-place scatter-gather "
6843 "in both input and output mbufs.\n");
6847 if (!(feat_flags & RTE_CRYPTODEV_FF_OOP_SGL_IN_SGL_OUT)) {
6848 printf("Device doesn't support out-of-place scatter-gather "
6849 "in both input and output mbufs.\n");
6852 if (!(feat_flags & RTE_CRYPTODEV_FF_DIGEST_ENCRYPTED)) {
6853 printf("Device doesn't support digest encrypted.\n");
6858 /* Create the session */
6860 retval = create_wireless_algo_cipher_auth_session(
6861 ts_params->valid_devs[0],
6862 RTE_CRYPTO_CIPHER_OP_DECRYPT,
6863 RTE_CRYPTO_AUTH_OP_VERIFY,
6866 tdata->auth_key.data, tdata->auth_key.len,
6867 tdata->auth_iv.len, tdata->digest_enc.len,
6868 tdata->cipher_iv.len);
6870 retval = create_wireless_algo_auth_cipher_session(
6871 ts_params->valid_devs[0],
6872 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
6873 RTE_CRYPTO_AUTH_OP_GENERATE,
6876 tdata->auth_key.data, tdata->auth_key.len,
6877 tdata->auth_iv.len, tdata->digest_enc.len,
6878 tdata->cipher_iv.len);
6882 ciphertext_len = ceil_byte_length(tdata->ciphertext.len_bits);
6883 plaintext_len = ceil_byte_length(tdata->plaintext.len_bits);
6884 ciphertext_pad_len = RTE_ALIGN_CEIL(ciphertext_len, 16);
6885 plaintext_pad_len = RTE_ALIGN_CEIL(plaintext_len, 16);
6887 ut_params->ibuf = create_segmented_mbuf(ts_params->mbuf_pool,
6888 ciphertext_pad_len, 15, 0);
6889 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
6890 "Failed to allocate input buffer in mempool");
6892 if (op_mode == OUT_OF_PLACE) {
6893 ut_params->obuf = create_segmented_mbuf(ts_params->mbuf_pool,
6894 plaintext_pad_len, 15, 0);
6895 TEST_ASSERT_NOT_NULL(ut_params->obuf,
6896 "Failed to allocate output buffer in mempool");
6900 pktmbuf_write(ut_params->ibuf, 0, ciphertext_len,
6901 tdata->ciphertext.data);
6902 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6903 ciphertext_len, buffer);
6904 debug_hexdump(stdout, "ciphertext:", ciphertext,
6907 pktmbuf_write(ut_params->ibuf, 0, plaintext_len,
6908 tdata->plaintext.data);
6909 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6910 plaintext_len, buffer);
6911 debug_hexdump(stdout, "plaintext:", plaintext,
6914 memset(buffer, 0, sizeof(buffer));
6916 /* Create the operation */
6917 retval = create_wireless_algo_auth_cipher_operation(
6918 tdata->digest_enc.data, tdata->digest_enc.len,
6919 tdata->cipher_iv.data, tdata->cipher_iv.len,
6920 tdata->auth_iv.data, tdata->auth_iv.len,
6921 (tdata->digest_enc.offset == 0 ?
6923 : tdata->digest_enc.offset),
6924 tdata->validCipherLen.len_bits,
6925 tdata->cipher.offset_bits,
6926 tdata->validAuthLen.len_bits,
6927 tdata->auth.offset_bits,
6928 op_mode, 1, verify);
6933 op = process_crypto_request(ts_params->valid_devs[0],
6936 /* Check if the op failed because the device doesn't */
6937 /* support this particular combination of algorithms */
6938 if (op == NULL && ut_params->op->status ==
6939 RTE_CRYPTO_OP_STATUS_INVALID_SESSION) {
6940 printf("Device doesn't support this mixed combination. "
6947 TEST_ASSERT_NOT_NULL(ut_params->op, "failed to retrieve obuf");
6949 ut_params->obuf = (op_mode == IN_PLACE ?
6950 ut_params->op->sym->m_src : ut_params->op->sym->m_dst);
6953 if (ut_params->obuf)
6954 plaintext = rte_pktmbuf_read(ut_params->obuf, 0,
6955 plaintext_len, buffer);
6957 plaintext = rte_pktmbuf_read(ut_params->ibuf, 0,
6958 plaintext_len, buffer);
6960 debug_hexdump(stdout, "plaintext:", plaintext,
6961 (tdata->plaintext.len_bits >> 3) -
6962 tdata->digest_enc.len);
6963 debug_hexdump(stdout, "plaintext expected:",
6964 tdata->plaintext.data,
6965 (tdata->plaintext.len_bits >> 3) -
6966 tdata->digest_enc.len);
6968 if (ut_params->obuf)
6969 ciphertext = rte_pktmbuf_read(ut_params->obuf, 0,
6970 ciphertext_len, buffer);
6972 ciphertext = rte_pktmbuf_read(ut_params->ibuf, 0,
6973 ciphertext_len, buffer);
6975 debug_hexdump(stdout, "ciphertext:", ciphertext,
6977 debug_hexdump(stdout, "ciphertext expected:",
6978 tdata->ciphertext.data,
6979 tdata->ciphertext.len_bits >> 3);
6981 if (ut_params->obuf)
6982 digest = rte_pktmbuf_read(ut_params->obuf,
6983 (tdata->digest_enc.offset == 0 ?
6985 tdata->digest_enc.offset),
6986 tdata->digest_enc.len, digest_buffer);
6988 digest = rte_pktmbuf_read(ut_params->ibuf,
6989 (tdata->digest_enc.offset == 0 ?
6991 tdata->digest_enc.offset),
6992 tdata->digest_enc.len, digest_buffer);
6994 debug_hexdump(stdout, "digest:", digest,
6995 tdata->digest_enc.len);
6996 debug_hexdump(stdout, "digest expected:",
6997 tdata->digest_enc.data, tdata->digest_enc.len);
7002 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7004 tdata->plaintext.data,
7005 tdata->plaintext.len_bits >> 3,
7006 "Plaintext data not as expected");
7008 TEST_ASSERT_BUFFERS_ARE_EQUAL_BIT(
7010 tdata->ciphertext.data,
7011 tdata->validDataLen.len_bits,
7012 "Ciphertext data not as expected");
7013 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7015 tdata->digest_enc.data,
7016 tdata->digest_enc.len,
7017 "Generated auth tag not as expected");
7020 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7021 "crypto op processing failed");
7026 /** AUTH AES CMAC + CIPHER AES CTR */
7029 test_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7031 return test_mixed_auth_cipher(
7032 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7036 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7038 return test_mixed_auth_cipher(
7039 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7043 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7045 return test_mixed_auth_cipher_sgl(
7046 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 0);
7050 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7052 return test_mixed_auth_cipher_sgl(
7053 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7057 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1(void)
7059 return test_mixed_auth_cipher(
7060 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7064 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop(void)
7066 return test_mixed_auth_cipher(
7067 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7071 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl(void)
7073 return test_mixed_auth_cipher_sgl(
7074 &auth_aes_cmac_cipher_aes_ctr_test_case_1, IN_PLACE, 1);
7078 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl(void)
7080 return test_mixed_auth_cipher_sgl(
7081 &auth_aes_cmac_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7084 /** MIXED AUTH + CIPHER */
7087 test_auth_zuc_cipher_snow_test_case_1(void)
7089 return test_mixed_auth_cipher(
7090 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7094 test_verify_auth_zuc_cipher_snow_test_case_1(void)
7096 return test_mixed_auth_cipher(
7097 &auth_zuc_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7101 test_auth_aes_cmac_cipher_snow_test_case_1(void)
7103 return test_mixed_auth_cipher(
7104 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7108 test_verify_auth_aes_cmac_cipher_snow_test_case_1(void)
7110 return test_mixed_auth_cipher(
7111 &auth_aes_cmac_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7115 test_auth_zuc_cipher_aes_ctr_test_case_1(void)
7117 return test_mixed_auth_cipher(
7118 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7122 test_verify_auth_zuc_cipher_aes_ctr_test_case_1(void)
7124 return test_mixed_auth_cipher(
7125 &auth_zuc_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7129 test_auth_snow_cipher_aes_ctr_test_case_1(void)
7131 return test_mixed_auth_cipher(
7132 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7136 test_verify_auth_snow_cipher_aes_ctr_test_case_1(void)
7138 return test_mixed_auth_cipher(
7139 &auth_snow_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7143 test_auth_snow_cipher_zuc_test_case_1(void)
7145 return test_mixed_auth_cipher(
7146 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7150 test_verify_auth_snow_cipher_zuc_test_case_1(void)
7152 return test_mixed_auth_cipher(
7153 &auth_snow_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7157 test_auth_aes_cmac_cipher_zuc_test_case_1(void)
7159 return test_mixed_auth_cipher(
7160 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7164 test_verify_auth_aes_cmac_cipher_zuc_test_case_1(void)
7166 return test_mixed_auth_cipher(
7167 &auth_aes_cmac_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7171 test_auth_null_cipher_snow_test_case_1(void)
7173 return test_mixed_auth_cipher(
7174 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 0);
7178 test_verify_auth_null_cipher_snow_test_case_1(void)
7180 return test_mixed_auth_cipher(
7181 &auth_null_cipher_snow_test_case_1, OUT_OF_PLACE, 1);
7185 test_auth_null_cipher_zuc_test_case_1(void)
7187 return test_mixed_auth_cipher(
7188 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 0);
7192 test_verify_auth_null_cipher_zuc_test_case_1(void)
7194 return test_mixed_auth_cipher(
7195 &auth_null_cipher_zuc_test_case_1, OUT_OF_PLACE, 1);
7199 test_auth_snow_cipher_null_test_case_1(void)
7201 return test_mixed_auth_cipher(
7202 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7206 test_verify_auth_snow_cipher_null_test_case_1(void)
7208 return test_mixed_auth_cipher(
7209 &auth_snow_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7213 test_auth_zuc_cipher_null_test_case_1(void)
7215 return test_mixed_auth_cipher(
7216 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7220 test_verify_auth_zuc_cipher_null_test_case_1(void)
7222 return test_mixed_auth_cipher(
7223 &auth_zuc_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7227 test_auth_null_cipher_aes_ctr_test_case_1(void)
7229 return test_mixed_auth_cipher(
7230 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 0);
7234 test_verify_auth_null_cipher_aes_ctr_test_case_1(void)
7236 return test_mixed_auth_cipher(
7237 &auth_null_cipher_aes_ctr_test_case_1, OUT_OF_PLACE, 1);
7241 test_auth_aes_cmac_cipher_null_test_case_1(void)
7243 return test_mixed_auth_cipher(
7244 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 0);
7248 test_verify_auth_aes_cmac_cipher_null_test_case_1(void)
7250 return test_mixed_auth_cipher(
7251 &auth_aes_cmac_cipher_null_test_case_1, OUT_OF_PLACE, 1);
7255 test_3DES_chain_qat_all(void)
7257 struct crypto_testsuite_params *ts_params = &testsuite_params;
7260 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7261 ts_params->op_mpool,
7262 ts_params->session_mpool, ts_params->session_priv_mpool,
7263 ts_params->valid_devs[0],
7264 rte_cryptodev_driver_id_get(
7265 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7266 BLKCIPHER_3DES_CHAIN_TYPE);
7268 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7270 return TEST_SUCCESS;
7274 test_DES_cipheronly_qat_all(void)
7276 struct crypto_testsuite_params *ts_params = &testsuite_params;
7279 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7280 ts_params->op_mpool,
7281 ts_params->session_mpool, ts_params->session_priv_mpool,
7282 ts_params->valid_devs[0],
7283 rte_cryptodev_driver_id_get(
7284 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7285 BLKCIPHER_DES_CIPHERONLY_TYPE);
7287 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7289 return TEST_SUCCESS;
7293 test_DES_cipheronly_openssl_all(void)
7295 struct crypto_testsuite_params *ts_params = &testsuite_params;
7298 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7299 ts_params->op_mpool,
7300 ts_params->session_mpool, ts_params->session_priv_mpool,
7301 ts_params->valid_devs[0],
7302 rte_cryptodev_driver_id_get(
7303 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7304 BLKCIPHER_DES_CIPHERONLY_TYPE);
7306 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7308 return TEST_SUCCESS;
7312 test_DES_docsis_openssl_all(void)
7314 struct crypto_testsuite_params *ts_params = &testsuite_params;
7317 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7318 ts_params->op_mpool,
7319 ts_params->session_mpool, ts_params->session_priv_mpool,
7320 ts_params->valid_devs[0],
7321 rte_cryptodev_driver_id_get(
7322 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7323 BLKCIPHER_DES_DOCSIS_TYPE);
7325 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7327 return TEST_SUCCESS;
7331 test_DES_cipheronly_mb_all(void)
7333 struct crypto_testsuite_params *ts_params = &testsuite_params;
7336 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7337 ts_params->op_mpool,
7338 ts_params->session_mpool, ts_params->session_priv_mpool,
7339 ts_params->valid_devs[0],
7340 rte_cryptodev_driver_id_get(
7341 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7342 BLKCIPHER_DES_CIPHERONLY_TYPE);
7344 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7346 return TEST_SUCCESS;
7349 test_3DES_cipheronly_mb_all(void)
7351 struct crypto_testsuite_params *ts_params = &testsuite_params;
7354 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7355 ts_params->op_mpool,
7356 ts_params->session_mpool, ts_params->session_priv_mpool,
7357 ts_params->valid_devs[0],
7358 rte_cryptodev_driver_id_get(
7359 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7360 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7362 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7364 return TEST_SUCCESS;
7368 test_DES_docsis_mb_all(void)
7370 struct crypto_testsuite_params *ts_params = &testsuite_params;
7373 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7374 ts_params->op_mpool,
7375 ts_params->session_mpool, ts_params->session_priv_mpool,
7376 ts_params->valid_devs[0],
7377 rte_cryptodev_driver_id_get(
7378 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)),
7379 BLKCIPHER_DES_DOCSIS_TYPE);
7381 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7383 return TEST_SUCCESS;
7387 test_3DES_chain_caam_jr_all(void)
7389 struct crypto_testsuite_params *ts_params = &testsuite_params;
7392 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7393 ts_params->op_mpool,
7394 ts_params->session_mpool, ts_params->session_priv_mpool,
7395 ts_params->valid_devs[0],
7396 rte_cryptodev_driver_id_get(
7397 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7398 BLKCIPHER_3DES_CHAIN_TYPE);
7400 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7402 return TEST_SUCCESS;
7406 test_3DES_cipheronly_caam_jr_all(void)
7408 struct crypto_testsuite_params *ts_params = &testsuite_params;
7411 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7412 ts_params->op_mpool,
7413 ts_params->session_mpool, ts_params->session_priv_mpool,
7414 ts_params->valid_devs[0],
7415 rte_cryptodev_driver_id_get(
7416 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD)),
7417 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7419 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7421 return TEST_SUCCESS;
7425 test_3DES_chain_dpaa_sec_all(void)
7427 struct crypto_testsuite_params *ts_params = &testsuite_params;
7430 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7431 ts_params->op_mpool,
7432 ts_params->session_mpool, ts_params->session_priv_mpool,
7433 ts_params->valid_devs[0],
7434 rte_cryptodev_driver_id_get(
7435 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7436 BLKCIPHER_3DES_CHAIN_TYPE);
7438 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7440 return TEST_SUCCESS;
7444 test_3DES_cipheronly_dpaa_sec_all(void)
7446 struct crypto_testsuite_params *ts_params = &testsuite_params;
7449 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7450 ts_params->op_mpool,
7451 ts_params->session_mpool, ts_params->session_priv_mpool,
7452 ts_params->valid_devs[0],
7453 rte_cryptodev_driver_id_get(
7454 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD)),
7455 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7457 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7459 return TEST_SUCCESS;
7463 test_3DES_chain_dpaa2_sec_all(void)
7465 struct crypto_testsuite_params *ts_params = &testsuite_params;
7468 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7469 ts_params->op_mpool,
7470 ts_params->session_mpool, ts_params->session_priv_mpool,
7471 ts_params->valid_devs[0],
7472 rte_cryptodev_driver_id_get(
7473 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7474 BLKCIPHER_3DES_CHAIN_TYPE);
7476 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7478 return TEST_SUCCESS;
7482 test_3DES_cipheronly_dpaa2_sec_all(void)
7484 struct crypto_testsuite_params *ts_params = &testsuite_params;
7487 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7488 ts_params->op_mpool,
7489 ts_params->session_mpool, ts_params->session_priv_mpool,
7490 ts_params->valid_devs[0],
7491 rte_cryptodev_driver_id_get(
7492 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD)),
7493 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7495 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7497 return TEST_SUCCESS;
7501 test_3DES_chain_ccp_all(void)
7503 struct crypto_testsuite_params *ts_params = &testsuite_params;
7506 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7507 ts_params->op_mpool,
7508 ts_params->session_mpool, ts_params->session_priv_mpool,
7509 ts_params->valid_devs[0],
7510 rte_cryptodev_driver_id_get(
7511 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7512 BLKCIPHER_3DES_CHAIN_TYPE);
7514 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7516 return TEST_SUCCESS;
7520 test_3DES_cipheronly_ccp_all(void)
7522 struct crypto_testsuite_params *ts_params = &testsuite_params;
7525 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7526 ts_params->op_mpool,
7527 ts_params->session_mpool, ts_params->session_priv_mpool,
7528 ts_params->valid_devs[0],
7529 rte_cryptodev_driver_id_get(
7530 RTE_STR(CRYPTODEV_NAME_CCP_PMD)),
7531 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7533 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7535 return TEST_SUCCESS;
7539 test_3DES_cipheronly_qat_all(void)
7541 struct crypto_testsuite_params *ts_params = &testsuite_params;
7544 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7545 ts_params->op_mpool,
7546 ts_params->session_mpool, ts_params->session_priv_mpool,
7547 ts_params->valid_devs[0],
7548 rte_cryptodev_driver_id_get(
7549 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD)),
7550 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7552 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7554 return TEST_SUCCESS;
7558 test_3DES_chain_openssl_all(void)
7560 struct crypto_testsuite_params *ts_params = &testsuite_params;
7563 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7564 ts_params->op_mpool,
7565 ts_params->session_mpool, ts_params->session_priv_mpool,
7566 ts_params->valid_devs[0],
7567 rte_cryptodev_driver_id_get(
7568 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7569 BLKCIPHER_3DES_CHAIN_TYPE);
7571 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7573 return TEST_SUCCESS;
7577 test_3DES_cipheronly_openssl_all(void)
7579 struct crypto_testsuite_params *ts_params = &testsuite_params;
7582 status = test_blockcipher_all_tests(ts_params->mbuf_pool,
7583 ts_params->op_mpool,
7584 ts_params->session_mpool, ts_params->session_priv_mpool,
7585 ts_params->valid_devs[0],
7586 rte_cryptodev_driver_id_get(
7587 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD)),
7588 BLKCIPHER_3DES_CIPHERONLY_TYPE);
7590 TEST_ASSERT_EQUAL(status, 0, "Test failed");
7592 return TEST_SUCCESS;
7595 /* ***** AEAD algorithm Tests ***** */
7598 create_aead_session(uint8_t dev_id, enum rte_crypto_aead_algorithm algo,
7599 enum rte_crypto_aead_operation op,
7600 const uint8_t *key, const uint8_t key_len,
7601 const uint16_t aad_len, const uint8_t auth_len,
7604 uint8_t aead_key[key_len];
7606 struct crypto_testsuite_params *ts_params = &testsuite_params;
7607 struct crypto_unittest_params *ut_params = &unittest_params;
7609 memcpy(aead_key, key, key_len);
7611 /* Setup AEAD Parameters */
7612 ut_params->aead_xform.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7613 ut_params->aead_xform.next = NULL;
7614 ut_params->aead_xform.aead.algo = algo;
7615 ut_params->aead_xform.aead.op = op;
7616 ut_params->aead_xform.aead.key.data = aead_key;
7617 ut_params->aead_xform.aead.key.length = key_len;
7618 ut_params->aead_xform.aead.iv.offset = IV_OFFSET;
7619 ut_params->aead_xform.aead.iv.length = iv_len;
7620 ut_params->aead_xform.aead.digest_length = auth_len;
7621 ut_params->aead_xform.aead.aad_length = aad_len;
7623 debug_hexdump(stdout, "key:", key, key_len);
7625 /* Create Crypto session*/
7626 ut_params->sess = rte_cryptodev_sym_session_create(
7627 ts_params->session_mpool);
7629 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
7630 &ut_params->aead_xform,
7631 ts_params->session_priv_mpool);
7633 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
7639 create_aead_xform(struct rte_crypto_op *op,
7640 enum rte_crypto_aead_algorithm algo,
7641 enum rte_crypto_aead_operation aead_op,
7642 uint8_t *key, const uint8_t key_len,
7643 const uint8_t aad_len, const uint8_t auth_len,
7646 TEST_ASSERT_NOT_NULL(rte_crypto_op_sym_xforms_alloc(op, 1),
7647 "failed to allocate space for crypto transform");
7649 struct rte_crypto_sym_op *sym_op = op->sym;
7651 /* Setup AEAD Parameters */
7652 sym_op->xform->type = RTE_CRYPTO_SYM_XFORM_AEAD;
7653 sym_op->xform->next = NULL;
7654 sym_op->xform->aead.algo = algo;
7655 sym_op->xform->aead.op = aead_op;
7656 sym_op->xform->aead.key.data = key;
7657 sym_op->xform->aead.key.length = key_len;
7658 sym_op->xform->aead.iv.offset = IV_OFFSET;
7659 sym_op->xform->aead.iv.length = iv_len;
7660 sym_op->xform->aead.digest_length = auth_len;
7661 sym_op->xform->aead.aad_length = aad_len;
7663 debug_hexdump(stdout, "key:", key, key_len);
7669 create_aead_operation(enum rte_crypto_aead_operation op,
7670 const struct aead_test_data *tdata)
7672 struct crypto_testsuite_params *ts_params = &testsuite_params;
7673 struct crypto_unittest_params *ut_params = &unittest_params;
7675 uint8_t *plaintext, *ciphertext;
7676 unsigned int aad_pad_len, plaintext_pad_len;
7678 /* Generate Crypto op data structure */
7679 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
7680 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
7681 TEST_ASSERT_NOT_NULL(ut_params->op,
7682 "Failed to allocate symmetric crypto operation struct");
7684 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
7686 /* Append aad data */
7687 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
7688 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len + 18, 16);
7689 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7691 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7692 "no room to append aad");
7694 sym_op->aead.aad.phys_addr =
7695 rte_pktmbuf_iova(ut_params->ibuf);
7696 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
7697 memcpy(sym_op->aead.aad.data + 18, tdata->aad.data, tdata->aad.len);
7698 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7701 /* Append IV at the end of the crypto operation*/
7702 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7703 uint8_t *, IV_OFFSET);
7705 /* Copy IV 1 byte after the IV pointer, according to the API */
7706 rte_memcpy(iv_ptr + 1, tdata->iv.data, tdata->iv.len);
7707 debug_hexdump(stdout, "iv:", iv_ptr,
7710 aad_pad_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
7711 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7713 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
7714 "no room to append aad");
7716 sym_op->aead.aad.phys_addr =
7717 rte_pktmbuf_iova(ut_params->ibuf);
7718 memcpy(sym_op->aead.aad.data, tdata->aad.data, tdata->aad.len);
7719 debug_hexdump(stdout, "aad:", sym_op->aead.aad.data,
7722 /* Append IV at the end of the crypto operation*/
7723 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
7724 uint8_t *, IV_OFFSET);
7726 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
7727 debug_hexdump(stdout, "iv:", iv_ptr,
7731 /* Append plaintext/ciphertext */
7732 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7733 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7734 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7736 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
7738 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
7739 debug_hexdump(stdout, "plaintext:", plaintext,
7740 tdata->plaintext.len);
7742 if (ut_params->obuf) {
7743 ciphertext = (uint8_t *)rte_pktmbuf_append(
7745 plaintext_pad_len + aad_pad_len);
7746 TEST_ASSERT_NOT_NULL(ciphertext,
7747 "no room to append ciphertext");
7749 memset(ciphertext + aad_pad_len, 0,
7750 tdata->ciphertext.len);
7753 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->ciphertext.len, 16);
7754 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7756 TEST_ASSERT_NOT_NULL(ciphertext,
7757 "no room to append ciphertext");
7759 memcpy(ciphertext, tdata->ciphertext.data,
7760 tdata->ciphertext.len);
7761 debug_hexdump(stdout, "ciphertext:", ciphertext,
7762 tdata->ciphertext.len);
7764 if (ut_params->obuf) {
7765 plaintext = (uint8_t *)rte_pktmbuf_append(
7767 plaintext_pad_len + aad_pad_len);
7768 TEST_ASSERT_NOT_NULL(plaintext,
7769 "no room to append plaintext");
7771 memset(plaintext + aad_pad_len, 0,
7772 tdata->plaintext.len);
7776 /* Append digest data */
7777 if (op == RTE_CRYPTO_AEAD_OP_ENCRYPT) {
7778 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7779 ut_params->obuf ? ut_params->obuf :
7781 tdata->auth_tag.len);
7782 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7783 "no room to append digest");
7784 memset(sym_op->aead.digest.data, 0, tdata->auth_tag.len);
7785 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7786 ut_params->obuf ? ut_params->obuf :
7791 sym_op->aead.digest.data = (uint8_t *)rte_pktmbuf_append(
7792 ut_params->ibuf, tdata->auth_tag.len);
7793 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
7794 "no room to append digest");
7795 sym_op->aead.digest.phys_addr = rte_pktmbuf_iova_offset(
7797 plaintext_pad_len + aad_pad_len);
7799 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
7800 tdata->auth_tag.len);
7801 debug_hexdump(stdout, "digest:",
7802 sym_op->aead.digest.data,
7803 tdata->auth_tag.len);
7806 sym_op->aead.data.length = tdata->plaintext.len;
7807 sym_op->aead.data.offset = aad_pad_len;
7813 test_authenticated_encryption(const struct aead_test_data *tdata)
7815 struct crypto_testsuite_params *ts_params = &testsuite_params;
7816 struct crypto_unittest_params *ut_params = &unittest_params;
7817 struct rte_cryptodev_sym_capability_idx cap_idx;
7820 uint8_t *ciphertext, *auth_tag;
7821 uint16_t plaintext_pad_len;
7824 /* Create AEAD session */
7825 retval = create_aead_session(ts_params->valid_devs[0],
7827 RTE_CRYPTO_AEAD_OP_ENCRYPT,
7828 tdata->key.data, tdata->key.len,
7829 tdata->aad.len, tdata->auth_tag.len,
7832 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
7833 cap_idx.algo.aead = tdata->algo;
7835 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
7836 &cap_idx) == NULL) {
7843 if (tdata->aad.len > MBUF_SIZE) {
7844 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
7845 /* Populate full size of add data */
7846 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
7847 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
7849 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7851 /* clear mbuf payload */
7852 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7853 rte_pktmbuf_tailroom(ut_params->ibuf));
7855 /* Create AEAD operation */
7856 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
7860 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
7862 ut_params->op->sym->m_src = ut_params->ibuf;
7864 /* Process crypto operation */
7865 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
7866 ut_params->op), "failed to process sym crypto op");
7868 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
7869 "crypto op processing failed");
7871 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
7873 if (ut_params->op->sym->m_dst) {
7874 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
7876 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
7877 uint8_t *, plaintext_pad_len);
7879 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
7881 ut_params->op->sym->cipher.data.offset);
7882 auth_tag = ciphertext + plaintext_pad_len;
7885 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
7886 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
7889 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7891 tdata->ciphertext.data,
7892 tdata->ciphertext.len,
7893 "Ciphertext data not as expected");
7895 TEST_ASSERT_BUFFERS_ARE_EQUAL(
7897 tdata->auth_tag.data,
7898 tdata->auth_tag.len,
7899 "Generated auth tag not as expected");
7905 #ifdef RTE_LIBRTE_SECURITY
7906 /* Basic algorithm run function for async inplace mode.
7907 * Creates a session from input parameters and runs one operation
7908 * on input_vec. Checks the output of the crypto operation against
7912 test_pdcp_proto(int i, int oop,
7913 enum rte_crypto_cipher_operation opc,
7914 enum rte_crypto_auth_operation opa,
7916 unsigned int input_vec_len,
7917 uint8_t *output_vec,
7918 unsigned int output_vec_len)
7920 struct crypto_testsuite_params *ts_params = &testsuite_params;
7921 struct crypto_unittest_params *ut_params = &unittest_params;
7923 int ret = TEST_SUCCESS;
7925 /* Generate test mbuf data */
7926 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7928 /* clear mbuf payload */
7929 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
7930 rte_pktmbuf_tailroom(ut_params->ibuf));
7932 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
7934 memcpy(plaintext, input_vec, input_vec_len);
7936 /* Out of place support */
7939 * For out-op-place we need to alloc another mbuf
7941 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
7942 rte_pktmbuf_append(ut_params->obuf, output_vec_len);
7945 /* Set crypto type as IPSEC */
7946 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
7948 /* Setup Cipher Parameters */
7949 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
7950 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
7951 ut_params->cipher_xform.cipher.op = opc;
7952 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
7953 ut_params->cipher_xform.cipher.key.length =
7954 pdcp_test_params[i].cipher_key_len;
7955 ut_params->cipher_xform.cipher.iv.length = 0;
7957 /* Setup HMAC Parameters if ICV header is required */
7958 if (pdcp_test_params[i].auth_alg != 0) {
7959 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
7960 ut_params->auth_xform.next = NULL;
7961 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
7962 ut_params->auth_xform.auth.op = opa;
7963 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
7964 ut_params->auth_xform.auth.key.length =
7965 pdcp_test_params[i].auth_key_len;
7967 ut_params->cipher_xform.next = &ut_params->auth_xform;
7969 ut_params->cipher_xform.next = NULL;
7972 struct rte_security_session_conf sess_conf = {
7973 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
7974 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
7976 .bearer = pdcp_test_bearer[i],
7977 .domain = pdcp_test_params[i].domain,
7978 .pkt_dir = pdcp_test_packet_direction[i],
7979 .sn_size = pdcp_test_data_sn_size[i],
7980 .hfn = pdcp_test_hfn[i],
7981 .hfn_threshold = pdcp_test_hfn_threshold[i],
7983 .crypto_xform = &ut_params->cipher_xform
7986 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
7987 rte_cryptodev_get_sec_ctx(
7988 ts_params->valid_devs[0]);
7990 /* Create security session */
7991 ut_params->sec_session = rte_security_session_create(ctx,
7992 &sess_conf, ts_params->session_priv_mpool);
7994 if (!ut_params->sec_session) {
7995 printf("TestCase %s()-%d line %d failed %s: ",
7996 __func__, i, __LINE__, "Failed to allocate session");
8001 /* Generate crypto op data structure */
8002 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8003 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8004 if (!ut_params->op) {
8005 printf("TestCase %s()-%d line %d failed %s: ",
8006 __func__, i, __LINE__,
8007 "Failed to allocate symmetric crypto operation struct");
8012 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8014 /* set crypto operation source mbuf */
8015 ut_params->op->sym->m_src = ut_params->ibuf;
8017 ut_params->op->sym->m_dst = ut_params->obuf;
8019 /* Process crypto operation */
8020 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8022 printf("TestCase %s()-%d line %d failed %s: ",
8023 __func__, i, __LINE__,
8024 "failed to process sym crypto op");
8029 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8030 printf("TestCase %s()-%d line %d failed %s: ",
8031 __func__, i, __LINE__, "crypto op processing failed");
8037 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8040 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8044 if (memcmp(ciphertext, output_vec, output_vec_len)) {
8045 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8046 rte_hexdump(stdout, "encrypted", ciphertext, output_vec_len);
8047 rte_hexdump(stdout, "reference", output_vec, output_vec_len);
8053 rte_crypto_op_free(ut_params->op);
8054 ut_params->op = NULL;
8056 if (ut_params->sec_session)
8057 rte_security_session_destroy(ctx, ut_params->sec_session);
8058 ut_params->sec_session = NULL;
8060 rte_pktmbuf_free(ut_params->ibuf);
8061 ut_params->ibuf = NULL;
8063 rte_pktmbuf_free(ut_params->obuf);
8064 ut_params->obuf = NULL;
8071 test_pdcp_proto_SGL(int i, int oop,
8072 enum rte_crypto_cipher_operation opc,
8073 enum rte_crypto_auth_operation opa,
8075 unsigned int input_vec_len,
8076 uint8_t *output_vec,
8077 unsigned int output_vec_len,
8079 uint32_t fragsz_oop)
8081 struct crypto_testsuite_params *ts_params = &testsuite_params;
8082 struct crypto_unittest_params *ut_params = &unittest_params;
8084 struct rte_mbuf *buf, *buf_oop = NULL;
8085 int ret = TEST_SUCCESS;
8089 unsigned int trn_data = 0;
8091 if (fragsz > input_vec_len)
8092 fragsz = input_vec_len;
8094 uint16_t plaintext_len = fragsz;
8095 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
8097 if (fragsz_oop > output_vec_len)
8098 frag_size_oop = output_vec_len;
8101 if (input_vec_len % fragsz != 0) {
8102 if (input_vec_len / fragsz + 1 > 16)
8104 } else if (input_vec_len / fragsz > 16)
8107 /* Out of place support */
8110 * For out-op-place we need to alloc another mbuf
8112 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8113 rte_pktmbuf_append(ut_params->obuf, frag_size_oop);
8114 buf_oop = ut_params->obuf;
8117 /* Generate test mbuf data */
8118 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8120 /* clear mbuf payload */
8121 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8122 rte_pktmbuf_tailroom(ut_params->ibuf));
8124 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
8126 memcpy(plaintext, input_vec, plaintext_len);
8127 trn_data += plaintext_len;
8129 buf = ut_params->ibuf;
8132 * Loop until no more fragments
8135 while (trn_data < input_vec_len) {
8137 to_trn = (input_vec_len - trn_data < fragsz) ?
8138 (input_vec_len - trn_data) : fragsz;
8140 to_trn_tbl[ecx++] = to_trn;
8142 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8145 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
8146 rte_pktmbuf_tailroom(buf));
8149 if (oop && !fragsz_oop) {
8151 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8152 buf_oop = buf_oop->next;
8153 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8154 0, rte_pktmbuf_tailroom(buf_oop));
8155 rte_pktmbuf_append(buf_oop, to_trn);
8158 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
8161 memcpy(plaintext, input_vec + trn_data, to_trn);
8165 ut_params->ibuf->nb_segs = segs;
8168 if (fragsz_oop && oop) {
8172 trn_data = frag_size_oop;
8173 while (trn_data < output_vec_len) {
8176 (output_vec_len - trn_data <
8178 (output_vec_len - trn_data) :
8181 to_trn_tbl[ecx++] = to_trn;
8184 rte_pktmbuf_alloc(ts_params->mbuf_pool);
8185 buf_oop = buf_oop->next;
8186 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
8187 0, rte_pktmbuf_tailroom(buf_oop));
8188 rte_pktmbuf_append(buf_oop, to_trn);
8192 ut_params->obuf->nb_segs = segs;
8195 ut_params->type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL;
8197 /* Setup Cipher Parameters */
8198 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
8199 ut_params->cipher_xform.cipher.algo = pdcp_test_params[i].cipher_alg;
8200 ut_params->cipher_xform.cipher.op = opc;
8201 ut_params->cipher_xform.cipher.key.data = pdcp_test_crypto_key[i];
8202 ut_params->cipher_xform.cipher.key.length =
8203 pdcp_test_params[i].cipher_key_len;
8204 ut_params->cipher_xform.cipher.iv.length = 0;
8206 /* Setup HMAC Parameters if ICV header is required */
8207 if (pdcp_test_params[i].auth_alg != 0) {
8208 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
8209 ut_params->auth_xform.next = NULL;
8210 ut_params->auth_xform.auth.algo = pdcp_test_params[i].auth_alg;
8211 ut_params->auth_xform.auth.op = opa;
8212 ut_params->auth_xform.auth.key.data = pdcp_test_auth_key[i];
8213 ut_params->auth_xform.auth.key.length =
8214 pdcp_test_params[i].auth_key_len;
8216 ut_params->cipher_xform.next = &ut_params->auth_xform;
8218 ut_params->cipher_xform.next = NULL;
8221 struct rte_security_session_conf sess_conf = {
8222 .action_type = RTE_SECURITY_ACTION_TYPE_LOOKASIDE_PROTOCOL,
8223 .protocol = RTE_SECURITY_PROTOCOL_PDCP,
8225 .bearer = pdcp_test_bearer[i],
8226 .domain = pdcp_test_params[i].domain,
8227 .pkt_dir = pdcp_test_packet_direction[i],
8228 .sn_size = pdcp_test_data_sn_size[i],
8229 .hfn = pdcp_test_hfn[i],
8230 .hfn_threshold = pdcp_test_hfn_threshold[i],
8232 .crypto_xform = &ut_params->cipher_xform
8235 struct rte_security_ctx *ctx = (struct rte_security_ctx *)
8236 rte_cryptodev_get_sec_ctx(
8237 ts_params->valid_devs[0]);
8239 /* Create security session */
8240 ut_params->sec_session = rte_security_session_create(ctx,
8241 &sess_conf, ts_params->session_priv_mpool);
8243 if (!ut_params->sec_session) {
8244 printf("TestCase %s()-%d line %d failed %s: ",
8245 __func__, i, __LINE__, "Failed to allocate session");
8250 /* Generate crypto op data structure */
8251 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
8252 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
8253 if (!ut_params->op) {
8254 printf("TestCase %s()-%d line %d failed %s: ",
8255 __func__, i, __LINE__,
8256 "Failed to allocate symmetric crypto operation struct");
8261 rte_security_attach_session(ut_params->op, ut_params->sec_session);
8263 /* set crypto operation source mbuf */
8264 ut_params->op->sym->m_src = ut_params->ibuf;
8266 ut_params->op->sym->m_dst = ut_params->obuf;
8268 /* Process crypto operation */
8269 if (process_crypto_request(ts_params->valid_devs[0], ut_params->op)
8271 printf("TestCase %s()-%d line %d failed %s: ",
8272 __func__, i, __LINE__,
8273 "failed to process sym crypto op");
8278 if (ut_params->op->status != RTE_CRYPTO_OP_STATUS_SUCCESS) {
8279 printf("TestCase %s()-%d line %d failed %s: ",
8280 __func__, i, __LINE__, "crypto op processing failed");
8286 uint8_t *ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_src,
8289 ciphertext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8293 fragsz = frag_size_oop;
8294 if (memcmp(ciphertext, output_vec, fragsz)) {
8295 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8296 rte_hexdump(stdout, "encrypted", ciphertext, fragsz);
8297 rte_hexdump(stdout, "reference", output_vec, fragsz);
8302 buf = ut_params->op->sym->m_src->next;
8304 buf = ut_params->op->sym->m_dst->next;
8306 unsigned int off = fragsz;
8310 ciphertext = rte_pktmbuf_mtod(buf,
8312 if (memcmp(ciphertext, output_vec + off, to_trn_tbl[ecx])) {
8313 printf("\n=======PDCP TestCase #%d failed: Data Mismatch ", i);
8314 rte_hexdump(stdout, "encrypted", ciphertext, to_trn_tbl[ecx]);
8315 rte_hexdump(stdout, "reference", output_vec + off,
8320 off += to_trn_tbl[ecx++];
8324 rte_crypto_op_free(ut_params->op);
8325 ut_params->op = NULL;
8327 if (ut_params->sec_session)
8328 rte_security_session_destroy(ctx, ut_params->sec_session);
8329 ut_params->sec_session = NULL;
8331 rte_pktmbuf_free(ut_params->ibuf);
8332 ut_params->ibuf = NULL;
8334 rte_pktmbuf_free(ut_params->obuf);
8335 ut_params->obuf = NULL;
8342 test_pdcp_proto_cplane_encap(int i)
8344 return test_pdcp_proto(i, 0,
8345 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8346 RTE_CRYPTO_AUTH_OP_GENERATE,
8347 pdcp_test_data_in[i],
8348 pdcp_test_data_in_len[i],
8349 pdcp_test_data_out[i],
8350 pdcp_test_data_in_len[i]+4);
8354 test_pdcp_proto_uplane_encap(int i)
8356 return test_pdcp_proto(i, 0,
8357 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8358 RTE_CRYPTO_AUTH_OP_GENERATE,
8359 pdcp_test_data_in[i],
8360 pdcp_test_data_in_len[i],
8361 pdcp_test_data_out[i],
8362 pdcp_test_data_in_len[i]);
8367 test_pdcp_proto_uplane_encap_with_int(int i)
8369 return test_pdcp_proto(i, 0,
8370 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8371 RTE_CRYPTO_AUTH_OP_GENERATE,
8372 pdcp_test_data_in[i],
8373 pdcp_test_data_in_len[i],
8374 pdcp_test_data_out[i],
8375 pdcp_test_data_in_len[i] + 4);
8379 test_pdcp_proto_cplane_decap(int i)
8381 return test_pdcp_proto(i, 0,
8382 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8383 RTE_CRYPTO_AUTH_OP_VERIFY,
8384 pdcp_test_data_out[i],
8385 pdcp_test_data_in_len[i] + 4,
8386 pdcp_test_data_in[i],
8387 pdcp_test_data_in_len[i]);
8391 test_pdcp_proto_uplane_decap(int i)
8393 return test_pdcp_proto(i, 0,
8394 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8395 RTE_CRYPTO_AUTH_OP_VERIFY,
8396 pdcp_test_data_out[i],
8397 pdcp_test_data_in_len[i],
8398 pdcp_test_data_in[i],
8399 pdcp_test_data_in_len[i]);
8403 test_pdcp_proto_uplane_decap_with_int(int i)
8405 return test_pdcp_proto(i, 0,
8406 RTE_CRYPTO_CIPHER_OP_DECRYPT,
8407 RTE_CRYPTO_AUTH_OP_VERIFY,
8408 pdcp_test_data_out[i],
8409 pdcp_test_data_in_len[i] + 4,
8410 pdcp_test_data_in[i],
8411 pdcp_test_data_in_len[i]);
8415 test_PDCP_PROTO_SGL_in_place_32B(void)
8417 /* i can be used for running any PDCP case
8418 * In this case it is uplane 12-bit AES-SNOW DL encap
8420 int i = PDCP_UPLANE_12BIT_OFFSET + AES_ENC + SNOW_AUTH + DOWNLINK;
8421 return test_pdcp_proto_SGL(i, IN_PLACE,
8422 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8423 RTE_CRYPTO_AUTH_OP_GENERATE,
8424 pdcp_test_data_in[i],
8425 pdcp_test_data_in_len[i],
8426 pdcp_test_data_out[i],
8427 pdcp_test_data_in_len[i]+4,
8431 test_PDCP_PROTO_SGL_oop_32B_128B(void)
8433 /* i can be used for running any PDCP case
8434 * In this case it is uplane 18-bit NULL-NULL DL encap
8436 int i = PDCP_UPLANE_18BIT_OFFSET + NULL_ENC + NULL_AUTH + DOWNLINK;
8437 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8438 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8439 RTE_CRYPTO_AUTH_OP_GENERATE,
8440 pdcp_test_data_in[i],
8441 pdcp_test_data_in_len[i],
8442 pdcp_test_data_out[i],
8443 pdcp_test_data_in_len[i]+4,
8447 test_PDCP_PROTO_SGL_oop_32B_40B(void)
8449 /* i can be used for running any PDCP case
8450 * In this case it is uplane 18-bit AES DL encap
8452 int i = PDCP_UPLANE_OFFSET + AES_ENC + EIGHTEEN_BIT_SEQ_NUM_OFFSET
8454 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8455 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8456 RTE_CRYPTO_AUTH_OP_GENERATE,
8457 pdcp_test_data_in[i],
8458 pdcp_test_data_in_len[i],
8459 pdcp_test_data_out[i],
8460 pdcp_test_data_in_len[i],
8464 test_PDCP_PROTO_SGL_oop_128B_32B(void)
8466 /* i can be used for running any PDCP case
8467 * In this case it is cplane 12-bit AES-ZUC DL encap
8469 int i = PDCP_CPLANE_LONG_SN_OFFSET + AES_ENC + ZUC_AUTH + DOWNLINK;
8470 return test_pdcp_proto_SGL(i, OUT_OF_PLACE,
8471 RTE_CRYPTO_CIPHER_OP_ENCRYPT,
8472 RTE_CRYPTO_AUTH_OP_GENERATE,
8473 pdcp_test_data_in[i],
8474 pdcp_test_data_in_len[i],
8475 pdcp_test_data_out[i],
8476 pdcp_test_data_in_len[i]+4,
8482 test_AES_GCM_authenticated_encryption_test_case_1(void)
8484 return test_authenticated_encryption(&gcm_test_case_1);
8488 test_AES_GCM_authenticated_encryption_test_case_2(void)
8490 return test_authenticated_encryption(&gcm_test_case_2);
8494 test_AES_GCM_authenticated_encryption_test_case_3(void)
8496 return test_authenticated_encryption(&gcm_test_case_3);
8500 test_AES_GCM_authenticated_encryption_test_case_4(void)
8502 return test_authenticated_encryption(&gcm_test_case_4);
8506 test_AES_GCM_authenticated_encryption_test_case_5(void)
8508 return test_authenticated_encryption(&gcm_test_case_5);
8512 test_AES_GCM_authenticated_encryption_test_case_6(void)
8514 return test_authenticated_encryption(&gcm_test_case_6);
8518 test_AES_GCM_authenticated_encryption_test_case_7(void)
8520 return test_authenticated_encryption(&gcm_test_case_7);
8524 test_AES_GCM_authenticated_encryption_test_case_8(void)
8526 return test_authenticated_encryption(&gcm_test_case_8);
8530 test_AES_GCM_auth_encryption_test_case_192_1(void)
8532 return test_authenticated_encryption(&gcm_test_case_192_1);
8536 test_AES_GCM_auth_encryption_test_case_192_2(void)
8538 return test_authenticated_encryption(&gcm_test_case_192_2);
8542 test_AES_GCM_auth_encryption_test_case_192_3(void)
8544 return test_authenticated_encryption(&gcm_test_case_192_3);
8548 test_AES_GCM_auth_encryption_test_case_192_4(void)
8550 return test_authenticated_encryption(&gcm_test_case_192_4);
8554 test_AES_GCM_auth_encryption_test_case_192_5(void)
8556 return test_authenticated_encryption(&gcm_test_case_192_5);
8560 test_AES_GCM_auth_encryption_test_case_192_6(void)
8562 return test_authenticated_encryption(&gcm_test_case_192_6);
8566 test_AES_GCM_auth_encryption_test_case_192_7(void)
8568 return test_authenticated_encryption(&gcm_test_case_192_7);
8572 test_AES_GCM_auth_encryption_test_case_256_1(void)
8574 return test_authenticated_encryption(&gcm_test_case_256_1);
8578 test_AES_GCM_auth_encryption_test_case_256_2(void)
8580 return test_authenticated_encryption(&gcm_test_case_256_2);
8584 test_AES_GCM_auth_encryption_test_case_256_3(void)
8586 return test_authenticated_encryption(&gcm_test_case_256_3);
8590 test_AES_GCM_auth_encryption_test_case_256_4(void)
8592 return test_authenticated_encryption(&gcm_test_case_256_4);
8596 test_AES_GCM_auth_encryption_test_case_256_5(void)
8598 return test_authenticated_encryption(&gcm_test_case_256_5);
8602 test_AES_GCM_auth_encryption_test_case_256_6(void)
8604 return test_authenticated_encryption(&gcm_test_case_256_6);
8608 test_AES_GCM_auth_encryption_test_case_256_7(void)
8610 return test_authenticated_encryption(&gcm_test_case_256_7);
8614 test_AES_GCM_auth_encryption_test_case_aad_1(void)
8616 return test_authenticated_encryption(&gcm_test_case_aad_1);
8620 test_AES_GCM_auth_encryption_test_case_aad_2(void)
8622 return test_authenticated_encryption(&gcm_test_case_aad_2);
8626 test_AES_GCM_auth_encryption_fail_iv_corrupt(void)
8628 struct aead_test_data tdata;
8631 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8632 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8633 tdata.iv.data[0] += 1;
8634 res = test_authenticated_encryption(&tdata);
8635 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8636 return TEST_SUCCESS;
8640 test_AES_GCM_auth_encryption_fail_in_data_corrupt(void)
8642 struct aead_test_data tdata;
8645 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8646 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8647 tdata.plaintext.data[0] += 1;
8648 res = test_authenticated_encryption(&tdata);
8649 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8650 return TEST_SUCCESS;
8654 test_AES_GCM_auth_encryption_fail_out_data_corrupt(void)
8656 struct aead_test_data tdata;
8659 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8660 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8661 tdata.ciphertext.data[0] += 1;
8662 res = test_authenticated_encryption(&tdata);
8663 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8664 return TEST_SUCCESS;
8668 test_AES_GCM_auth_encryption_fail_aad_len_corrupt(void)
8670 struct aead_test_data tdata;
8673 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8674 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8676 res = test_authenticated_encryption(&tdata);
8677 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8678 return TEST_SUCCESS;
8682 test_AES_GCM_auth_encryption_fail_aad_corrupt(void)
8684 struct aead_test_data tdata;
8685 uint8_t aad[gcm_test_case_7.aad.len];
8688 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8689 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8690 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
8692 tdata.aad.data = aad;
8693 res = test_authenticated_encryption(&tdata);
8694 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8695 return TEST_SUCCESS;
8699 test_AES_GCM_auth_encryption_fail_tag_corrupt(void)
8701 struct aead_test_data tdata;
8704 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8705 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8706 tdata.auth_tag.data[0] += 1;
8707 res = test_authenticated_encryption(&tdata);
8708 TEST_ASSERT_EQUAL(res, TEST_FAILED, "encryption not failed");
8709 return TEST_SUCCESS;
8713 test_authenticated_decryption(const struct aead_test_data *tdata)
8715 struct crypto_testsuite_params *ts_params = &testsuite_params;
8716 struct crypto_unittest_params *ut_params = &unittest_params;
8717 struct rte_cryptodev_sym_capability_idx cap_idx;
8723 /* Create AEAD session */
8724 retval = create_aead_session(ts_params->valid_devs[0],
8726 RTE_CRYPTO_AEAD_OP_DECRYPT,
8727 tdata->key.data, tdata->key.len,
8728 tdata->aad.len, tdata->auth_tag.len,
8733 cap_idx.type = RTE_CRYPTO_SYM_XFORM_AEAD;
8734 cap_idx.algo.aead = tdata->algo;
8736 if (rte_cryptodev_sym_capability_get(ts_params->valid_devs[0],
8737 &cap_idx) == NULL) {
8741 /* alloc mbuf and set payload */
8742 if (tdata->aad.len > MBUF_SIZE) {
8743 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
8744 /* Populate full size of add data */
8745 for (i = 32; i < MAX_AAD_LENGTH; i += 32)
8746 memcpy(&tdata->aad.data[i], &tdata->aad.data[0], 32);
8748 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
8750 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
8751 rte_pktmbuf_tailroom(ut_params->ibuf));
8753 /* Create AEAD operation */
8754 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
8758 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
8760 ut_params->op->sym->m_src = ut_params->ibuf;
8762 /* Process crypto operation */
8763 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
8764 ut_params->op), "failed to process sym crypto op");
8766 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
8767 "crypto op processing failed");
8769 if (ut_params->op->sym->m_dst)
8770 plaintext = rte_pktmbuf_mtod(ut_params->op->sym->m_dst,
8773 plaintext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
8775 ut_params->op->sym->cipher.data.offset);
8777 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
8780 TEST_ASSERT_BUFFERS_ARE_EQUAL(
8782 tdata->plaintext.data,
8783 tdata->plaintext.len,
8784 "Plaintext data not as expected");
8786 TEST_ASSERT_EQUAL(ut_params->op->status,
8787 RTE_CRYPTO_OP_STATUS_SUCCESS,
8788 "Authentication failed");
8794 test_chacha20_poly1305_encrypt_test_case_rfc8439(void)
8796 return test_authenticated_encryption(&chacha20_poly1305_case_rfc8439);
8800 test_chacha20_poly1305_decrypt_test_case_rfc8439(void)
8802 return test_authenticated_decryption(&chacha20_poly1305_case_rfc8439);
8806 test_AES_GCM_authenticated_decryption_test_case_1(void)
8808 return test_authenticated_decryption(&gcm_test_case_1);
8812 test_AES_GCM_authenticated_decryption_test_case_2(void)
8814 return test_authenticated_decryption(&gcm_test_case_2);
8818 test_AES_GCM_authenticated_decryption_test_case_3(void)
8820 return test_authenticated_decryption(&gcm_test_case_3);
8824 test_AES_GCM_authenticated_decryption_test_case_4(void)
8826 return test_authenticated_decryption(&gcm_test_case_4);
8830 test_AES_GCM_authenticated_decryption_test_case_5(void)
8832 return test_authenticated_decryption(&gcm_test_case_5);
8836 test_AES_GCM_authenticated_decryption_test_case_6(void)
8838 return test_authenticated_decryption(&gcm_test_case_6);
8842 test_AES_GCM_authenticated_decryption_test_case_7(void)
8844 return test_authenticated_decryption(&gcm_test_case_7);
8848 test_AES_GCM_authenticated_decryption_test_case_8(void)
8850 return test_authenticated_decryption(&gcm_test_case_8);
8854 test_AES_GCM_auth_decryption_test_case_192_1(void)
8856 return test_authenticated_decryption(&gcm_test_case_192_1);
8860 test_AES_GCM_auth_decryption_test_case_192_2(void)
8862 return test_authenticated_decryption(&gcm_test_case_192_2);
8866 test_AES_GCM_auth_decryption_test_case_192_3(void)
8868 return test_authenticated_decryption(&gcm_test_case_192_3);
8872 test_AES_GCM_auth_decryption_test_case_192_4(void)
8874 return test_authenticated_decryption(&gcm_test_case_192_4);
8878 test_AES_GCM_auth_decryption_test_case_192_5(void)
8880 return test_authenticated_decryption(&gcm_test_case_192_5);
8884 test_AES_GCM_auth_decryption_test_case_192_6(void)
8886 return test_authenticated_decryption(&gcm_test_case_192_6);
8890 test_AES_GCM_auth_decryption_test_case_192_7(void)
8892 return test_authenticated_decryption(&gcm_test_case_192_7);
8896 test_AES_GCM_auth_decryption_test_case_256_1(void)
8898 return test_authenticated_decryption(&gcm_test_case_256_1);
8902 test_AES_GCM_auth_decryption_test_case_256_2(void)
8904 return test_authenticated_decryption(&gcm_test_case_256_2);
8908 test_AES_GCM_auth_decryption_test_case_256_3(void)
8910 return test_authenticated_decryption(&gcm_test_case_256_3);
8914 test_AES_GCM_auth_decryption_test_case_256_4(void)
8916 return test_authenticated_decryption(&gcm_test_case_256_4);
8920 test_AES_GCM_auth_decryption_test_case_256_5(void)
8922 return test_authenticated_decryption(&gcm_test_case_256_5);
8926 test_AES_GCM_auth_decryption_test_case_256_6(void)
8928 return test_authenticated_decryption(&gcm_test_case_256_6);
8932 test_AES_GCM_auth_decryption_test_case_256_7(void)
8934 return test_authenticated_decryption(&gcm_test_case_256_7);
8938 test_AES_GCM_auth_decryption_test_case_aad_1(void)
8940 return test_authenticated_decryption(&gcm_test_case_aad_1);
8944 test_AES_GCM_auth_decryption_test_case_aad_2(void)
8946 return test_authenticated_decryption(&gcm_test_case_aad_2);
8950 test_AES_GCM_auth_decryption_fail_iv_corrupt(void)
8952 struct aead_test_data tdata;
8955 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8956 tdata.iv.data[0] += 1;
8957 res = test_authenticated_decryption(&tdata);
8958 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8959 return TEST_SUCCESS;
8963 test_AES_GCM_auth_decryption_fail_in_data_corrupt(void)
8965 struct aead_test_data tdata;
8968 RTE_LOG(INFO, USER1, "This is a negative test, errors are expected\n");
8969 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8970 tdata.plaintext.data[0] += 1;
8971 res = test_authenticated_decryption(&tdata);
8972 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8973 return TEST_SUCCESS;
8977 test_AES_GCM_auth_decryption_fail_out_data_corrupt(void)
8979 struct aead_test_data tdata;
8982 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8983 tdata.ciphertext.data[0] += 1;
8984 res = test_authenticated_decryption(&tdata);
8985 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8986 return TEST_SUCCESS;
8990 test_AES_GCM_auth_decryption_fail_aad_len_corrupt(void)
8992 struct aead_test_data tdata;
8995 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
8997 res = test_authenticated_decryption(&tdata);
8998 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
8999 return TEST_SUCCESS;
9003 test_AES_GCM_auth_decryption_fail_aad_corrupt(void)
9005 struct aead_test_data tdata;
9006 uint8_t aad[gcm_test_case_7.aad.len];
9009 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9010 memcpy(aad, gcm_test_case_7.aad.data, gcm_test_case_7.aad.len);
9012 tdata.aad.data = aad;
9013 res = test_authenticated_decryption(&tdata);
9014 TEST_ASSERT_EQUAL(res, TEST_FAILED, "decryption not failed");
9015 return TEST_SUCCESS;
9019 test_AES_GCM_auth_decryption_fail_tag_corrupt(void)
9021 struct aead_test_data tdata;
9024 memcpy(&tdata, &gcm_test_case_7, sizeof(struct aead_test_data));
9025 tdata.auth_tag.data[0] += 1;
9026 res = test_authenticated_decryption(&tdata);
9027 TEST_ASSERT_EQUAL(res, TEST_FAILED, "authentication not failed");
9028 return TEST_SUCCESS;
9032 test_authenticated_encryption_oop(const struct aead_test_data *tdata)
9034 struct crypto_testsuite_params *ts_params = &testsuite_params;
9035 struct crypto_unittest_params *ut_params = &unittest_params;
9038 uint8_t *ciphertext, *auth_tag;
9039 uint16_t plaintext_pad_len;
9041 /* Create AEAD session */
9042 retval = create_aead_session(ts_params->valid_devs[0],
9044 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9045 tdata->key.data, tdata->key.len,
9046 tdata->aad.len, tdata->auth_tag.len,
9051 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9052 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9054 /* clear mbuf payload */
9055 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9056 rte_pktmbuf_tailroom(ut_params->ibuf));
9057 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9058 rte_pktmbuf_tailroom(ut_params->obuf));
9060 /* Create AEAD operation */
9061 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9065 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9067 ut_params->op->sym->m_src = ut_params->ibuf;
9068 ut_params->op->sym->m_dst = ut_params->obuf;
9070 /* Process crypto operation */
9071 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9072 ut_params->op), "failed to process sym crypto op");
9074 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9075 "crypto op processing failed");
9077 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9079 ciphertext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9080 ut_params->op->sym->cipher.data.offset);
9081 auth_tag = ciphertext + plaintext_pad_len;
9083 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9084 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9087 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9089 tdata->ciphertext.data,
9090 tdata->ciphertext.len,
9091 "Ciphertext data not as expected");
9093 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9095 tdata->auth_tag.data,
9096 tdata->auth_tag.len,
9097 "Generated auth tag not as expected");
9104 test_AES_GCM_authenticated_encryption_oop_test_case_1(void)
9106 return test_authenticated_encryption_oop(&gcm_test_case_5);
9110 test_authenticated_decryption_oop(const struct aead_test_data *tdata)
9112 struct crypto_testsuite_params *ts_params = &testsuite_params;
9113 struct crypto_unittest_params *ut_params = &unittest_params;
9118 /* Create AEAD session */
9119 retval = create_aead_session(ts_params->valid_devs[0],
9121 RTE_CRYPTO_AEAD_OP_DECRYPT,
9122 tdata->key.data, tdata->key.len,
9123 tdata->aad.len, tdata->auth_tag.len,
9128 /* alloc mbuf and set payload */
9129 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9130 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9132 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9133 rte_pktmbuf_tailroom(ut_params->ibuf));
9134 memset(rte_pktmbuf_mtod(ut_params->obuf, uint8_t *), 0,
9135 rte_pktmbuf_tailroom(ut_params->obuf));
9137 /* Create AEAD operation */
9138 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9142 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9144 ut_params->op->sym->m_src = ut_params->ibuf;
9145 ut_params->op->sym->m_dst = ut_params->obuf;
9147 /* Process crypto operation */
9148 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9149 ut_params->op), "failed to process sym crypto op");
9151 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9152 "crypto op processing failed");
9154 plaintext = rte_pktmbuf_mtod_offset(ut_params->obuf, uint8_t *,
9155 ut_params->op->sym->cipher.data.offset);
9157 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9160 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9162 tdata->plaintext.data,
9163 tdata->plaintext.len,
9164 "Plaintext data not as expected");
9166 TEST_ASSERT_EQUAL(ut_params->op->status,
9167 RTE_CRYPTO_OP_STATUS_SUCCESS,
9168 "Authentication failed");
9173 test_AES_GCM_authenticated_decryption_oop_test_case_1(void)
9175 return test_authenticated_decryption_oop(&gcm_test_case_5);
9179 test_authenticated_encryption_sessionless(
9180 const struct aead_test_data *tdata)
9182 struct crypto_testsuite_params *ts_params = &testsuite_params;
9183 struct crypto_unittest_params *ut_params = &unittest_params;
9186 uint8_t *ciphertext, *auth_tag;
9187 uint16_t plaintext_pad_len;
9188 uint8_t key[tdata->key.len + 1];
9190 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9192 /* clear mbuf payload */
9193 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9194 rte_pktmbuf_tailroom(ut_params->ibuf));
9196 /* Create AEAD operation */
9197 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_ENCRYPT, tdata);
9201 /* Create GCM xform */
9202 memcpy(key, tdata->key.data, tdata->key.len);
9203 retval = create_aead_xform(ut_params->op,
9205 RTE_CRYPTO_AEAD_OP_ENCRYPT,
9206 key, tdata->key.len,
9207 tdata->aad.len, tdata->auth_tag.len,
9212 ut_params->op->sym->m_src = ut_params->ibuf;
9214 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9215 RTE_CRYPTO_OP_SESSIONLESS,
9216 "crypto op session type not sessionless");
9218 /* Process crypto operation */
9219 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9220 ut_params->op), "failed to process sym crypto op");
9222 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9224 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9225 "crypto op status not success");
9227 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
9229 ciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9230 ut_params->op->sym->cipher.data.offset);
9231 auth_tag = ciphertext + plaintext_pad_len;
9233 debug_hexdump(stdout, "ciphertext:", ciphertext, tdata->ciphertext.len);
9234 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->auth_tag.len);
9237 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9239 tdata->ciphertext.data,
9240 tdata->ciphertext.len,
9241 "Ciphertext data not as expected");
9243 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9245 tdata->auth_tag.data,
9246 tdata->auth_tag.len,
9247 "Generated auth tag not as expected");
9254 test_AES_GCM_authenticated_encryption_sessionless_test_case_1(void)
9256 return test_authenticated_encryption_sessionless(
9261 test_authenticated_decryption_sessionless(
9262 const struct aead_test_data *tdata)
9264 struct crypto_testsuite_params *ts_params = &testsuite_params;
9265 struct crypto_unittest_params *ut_params = &unittest_params;
9269 uint8_t key[tdata->key.len + 1];
9271 /* alloc mbuf and set payload */
9272 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9274 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9275 rte_pktmbuf_tailroom(ut_params->ibuf));
9277 /* Create AEAD operation */
9278 retval = create_aead_operation(RTE_CRYPTO_AEAD_OP_DECRYPT, tdata);
9282 /* Create AEAD xform */
9283 memcpy(key, tdata->key.data, tdata->key.len);
9284 retval = create_aead_xform(ut_params->op,
9286 RTE_CRYPTO_AEAD_OP_DECRYPT,
9287 key, tdata->key.len,
9288 tdata->aad.len, tdata->auth_tag.len,
9293 ut_params->op->sym->m_src = ut_params->ibuf;
9295 TEST_ASSERT_EQUAL(ut_params->op->sess_type,
9296 RTE_CRYPTO_OP_SESSIONLESS,
9297 "crypto op session type not sessionless");
9299 /* Process crypto operation */
9300 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9301 ut_params->op), "failed to process sym crypto op");
9303 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
9305 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9306 "crypto op status not success");
9308 plaintext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9309 ut_params->op->sym->cipher.data.offset);
9311 debug_hexdump(stdout, "plaintext:", plaintext, tdata->ciphertext.len);
9314 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9316 tdata->plaintext.data,
9317 tdata->plaintext.len,
9318 "Plaintext data not as expected");
9320 TEST_ASSERT_EQUAL(ut_params->op->status,
9321 RTE_CRYPTO_OP_STATUS_SUCCESS,
9322 "Authentication failed");
9327 test_AES_GCM_authenticated_decryption_sessionless_test_case_1(void)
9329 return test_authenticated_decryption_sessionless(
9334 test_AES_CCM_authenticated_encryption_test_case_128_1(void)
9336 return test_authenticated_encryption(&ccm_test_case_128_1);
9340 test_AES_CCM_authenticated_encryption_test_case_128_2(void)
9342 return test_authenticated_encryption(&ccm_test_case_128_2);
9346 test_AES_CCM_authenticated_encryption_test_case_128_3(void)
9348 return test_authenticated_encryption(&ccm_test_case_128_3);
9352 test_AES_CCM_authenticated_decryption_test_case_128_1(void)
9354 return test_authenticated_decryption(&ccm_test_case_128_1);
9358 test_AES_CCM_authenticated_decryption_test_case_128_2(void)
9360 return test_authenticated_decryption(&ccm_test_case_128_2);
9364 test_AES_CCM_authenticated_decryption_test_case_128_3(void)
9366 return test_authenticated_decryption(&ccm_test_case_128_3);
9370 test_AES_CCM_authenticated_encryption_test_case_192_1(void)
9372 return test_authenticated_encryption(&ccm_test_case_192_1);
9376 test_AES_CCM_authenticated_encryption_test_case_192_2(void)
9378 return test_authenticated_encryption(&ccm_test_case_192_2);
9382 test_AES_CCM_authenticated_encryption_test_case_192_3(void)
9384 return test_authenticated_encryption(&ccm_test_case_192_3);
9388 test_AES_CCM_authenticated_decryption_test_case_192_1(void)
9390 return test_authenticated_decryption(&ccm_test_case_192_1);
9394 test_AES_CCM_authenticated_decryption_test_case_192_2(void)
9396 return test_authenticated_decryption(&ccm_test_case_192_2);
9400 test_AES_CCM_authenticated_decryption_test_case_192_3(void)
9402 return test_authenticated_decryption(&ccm_test_case_192_3);
9406 test_AES_CCM_authenticated_encryption_test_case_256_1(void)
9408 return test_authenticated_encryption(&ccm_test_case_256_1);
9412 test_AES_CCM_authenticated_encryption_test_case_256_2(void)
9414 return test_authenticated_encryption(&ccm_test_case_256_2);
9418 test_AES_CCM_authenticated_encryption_test_case_256_3(void)
9420 return test_authenticated_encryption(&ccm_test_case_256_3);
9424 test_AES_CCM_authenticated_decryption_test_case_256_1(void)
9426 return test_authenticated_decryption(&ccm_test_case_256_1);
9430 test_AES_CCM_authenticated_decryption_test_case_256_2(void)
9432 return test_authenticated_decryption(&ccm_test_case_256_2);
9436 test_AES_CCM_authenticated_decryption_test_case_256_3(void)
9438 return test_authenticated_decryption(&ccm_test_case_256_3);
9444 struct crypto_testsuite_params *ts_params = &testsuite_params;
9445 struct rte_cryptodev_stats stats;
9446 struct rte_cryptodev *dev;
9447 cryptodev_stats_get_t temp_pfn;
9449 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9450 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0] + 600,
9451 &stats) == -ENODEV),
9452 "rte_cryptodev_stats_get invalid dev failed");
9453 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], 0) != 0),
9454 "rte_cryptodev_stats_get invalid Param failed");
9455 dev = &rte_cryptodevs[ts_params->valid_devs[0]];
9456 temp_pfn = dev->dev_ops->stats_get;
9457 dev->dev_ops->stats_get = (cryptodev_stats_get_t)0;
9458 TEST_ASSERT((rte_cryptodev_stats_get(ts_params->valid_devs[0], &stats)
9460 "rte_cryptodev_stats_get invalid Param failed");
9461 dev->dev_ops->stats_get = temp_pfn;
9463 /* Test expected values */
9465 test_AES_CBC_HMAC_SHA1_encrypt_digest();
9467 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9469 "rte_cryptodev_stats_get failed");
9470 TEST_ASSERT((stats.enqueued_count == 1),
9471 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9472 TEST_ASSERT((stats.dequeued_count == 1),
9473 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9474 TEST_ASSERT((stats.enqueue_err_count == 0),
9475 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9476 TEST_ASSERT((stats.dequeue_err_count == 0),
9477 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9479 /* invalid device but should ignore and not reset device stats*/
9480 rte_cryptodev_stats_reset(ts_params->valid_devs[0] + 300);
9481 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9483 "rte_cryptodev_stats_get failed");
9484 TEST_ASSERT((stats.enqueued_count == 1),
9485 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9487 /* check that a valid reset clears stats */
9488 rte_cryptodev_stats_reset(ts_params->valid_devs[0]);
9489 TEST_ASSERT_SUCCESS(rte_cryptodev_stats_get(ts_params->valid_devs[0],
9491 "rte_cryptodev_stats_get failed");
9492 TEST_ASSERT((stats.enqueued_count == 0),
9493 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9494 TEST_ASSERT((stats.dequeued_count == 0),
9495 "rte_cryptodev_stats_get returned unexpected enqueued stat");
9497 return TEST_SUCCESS;
9500 static int MD5_HMAC_create_session(struct crypto_testsuite_params *ts_params,
9501 struct crypto_unittest_params *ut_params,
9502 enum rte_crypto_auth_operation op,
9503 const struct HMAC_MD5_vector *test_case)
9507 memcpy(key, test_case->key.data, test_case->key.len);
9509 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9510 ut_params->auth_xform.next = NULL;
9511 ut_params->auth_xform.auth.op = op;
9513 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_MD5_HMAC;
9515 ut_params->auth_xform.auth.digest_length = MD5_DIGEST_LEN;
9516 ut_params->auth_xform.auth.key.length = test_case->key.len;
9517 ut_params->auth_xform.auth.key.data = key;
9519 ut_params->sess = rte_cryptodev_sym_session_create(
9520 ts_params->session_mpool);
9522 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9523 ut_params->sess, &ut_params->auth_xform,
9524 ts_params->session_priv_mpool);
9526 if (ut_params->sess == NULL)
9529 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
9531 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
9532 rte_pktmbuf_tailroom(ut_params->ibuf));
9537 static int MD5_HMAC_create_op(struct crypto_unittest_params *ut_params,
9538 const struct HMAC_MD5_vector *test_case,
9539 uint8_t **plaintext)
9541 uint16_t plaintext_pad_len;
9543 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9545 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9548 *plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
9550 memcpy(*plaintext, test_case->plaintext.data,
9551 test_case->plaintext.len);
9553 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
9554 ut_params->ibuf, MD5_DIGEST_LEN);
9555 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
9556 "no room to append digest");
9557 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
9558 ut_params->ibuf, plaintext_pad_len);
9560 if (ut_params->auth_xform.auth.op == RTE_CRYPTO_AUTH_OP_VERIFY) {
9561 rte_memcpy(sym_op->auth.digest.data, test_case->auth_tag.data,
9562 test_case->auth_tag.len);
9565 sym_op->auth.data.offset = 0;
9566 sym_op->auth.data.length = test_case->plaintext.len;
9568 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9569 ut_params->op->sym->m_src = ut_params->ibuf;
9575 test_MD5_HMAC_generate(const struct HMAC_MD5_vector *test_case)
9577 uint16_t plaintext_pad_len;
9578 uint8_t *plaintext, *auth_tag;
9580 struct crypto_testsuite_params *ts_params = &testsuite_params;
9581 struct crypto_unittest_params *ut_params = &unittest_params;
9583 if (MD5_HMAC_create_session(ts_params, ut_params,
9584 RTE_CRYPTO_AUTH_OP_GENERATE, test_case))
9587 /* Generate Crypto op data structure */
9588 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9589 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9590 TEST_ASSERT_NOT_NULL(ut_params->op,
9591 "Failed to allocate symmetric crypto operation struct");
9593 plaintext_pad_len = RTE_ALIGN_CEIL(test_case->plaintext.len,
9596 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9599 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9600 ut_params->op), "failed to process sym crypto op");
9602 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9603 "crypto op processing failed");
9605 if (ut_params->op->sym->m_dst) {
9606 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
9607 uint8_t *, plaintext_pad_len);
9609 auth_tag = plaintext + plaintext_pad_len;
9612 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9614 test_case->auth_tag.data,
9615 test_case->auth_tag.len,
9616 "HMAC_MD5 generated tag not as expected");
9618 return TEST_SUCCESS;
9622 test_MD5_HMAC_verify(const struct HMAC_MD5_vector *test_case)
9626 struct crypto_testsuite_params *ts_params = &testsuite_params;
9627 struct crypto_unittest_params *ut_params = &unittest_params;
9629 if (MD5_HMAC_create_session(ts_params, ut_params,
9630 RTE_CRYPTO_AUTH_OP_VERIFY, test_case)) {
9634 /* Generate Crypto op data structure */
9635 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9636 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9637 TEST_ASSERT_NOT_NULL(ut_params->op,
9638 "Failed to allocate symmetric crypto operation struct");
9640 if (MD5_HMAC_create_op(ut_params, test_case, &plaintext))
9643 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
9644 ut_params->op), "failed to process sym crypto op");
9646 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9647 "HMAC_MD5 crypto op processing failed");
9649 return TEST_SUCCESS;
9653 test_MD5_HMAC_generate_case_1(void)
9655 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_1);
9659 test_MD5_HMAC_verify_case_1(void)
9661 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_1);
9665 test_MD5_HMAC_generate_case_2(void)
9667 return test_MD5_HMAC_generate(&HMAC_MD5_test_case_2);
9671 test_MD5_HMAC_verify_case_2(void)
9673 return test_MD5_HMAC_verify(&HMAC_MD5_test_case_2);
9677 test_multi_session(void)
9679 struct crypto_testsuite_params *ts_params = &testsuite_params;
9680 struct crypto_unittest_params *ut_params = &unittest_params;
9682 struct rte_cryptodev_info dev_info;
9683 struct rte_cryptodev_sym_session **sessions;
9687 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(ut_params,
9688 aes_cbc_key, hmac_sha512_key);
9691 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9693 sessions = rte_malloc(NULL,
9694 (sizeof(struct rte_cryptodev_sym_session *) *
9695 MAX_NB_SESSIONS) + 1, 0);
9697 /* Create multiple crypto sessions*/
9698 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9700 sessions[i] = rte_cryptodev_sym_session_create(
9701 ts_params->session_mpool);
9703 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9704 sessions[i], &ut_params->auth_xform,
9705 ts_params->session_priv_mpool);
9706 TEST_ASSERT_NOT_NULL(sessions[i],
9707 "Session creation failed at session number %u",
9710 /* Attempt to send a request on each session */
9711 TEST_ASSERT_SUCCESS( test_AES_CBC_HMAC_SHA512_decrypt_perform(
9715 catch_22_quote_2_512_bytes_AES_CBC_ciphertext,
9716 catch_22_quote_2_512_bytes_AES_CBC_HMAC_SHA512_digest,
9718 "Failed to perform decrypt on request number %u.", i);
9719 /* free crypto operation structure */
9721 rte_crypto_op_free(ut_params->op);
9724 * free mbuf - both obuf and ibuf are usually the same,
9725 * so check if they point at the same address is necessary,
9726 * to avoid freeing the mbuf twice.
9728 if (ut_params->obuf) {
9729 rte_pktmbuf_free(ut_params->obuf);
9730 if (ut_params->ibuf == ut_params->obuf)
9731 ut_params->ibuf = 0;
9732 ut_params->obuf = 0;
9734 if (ut_params->ibuf) {
9735 rte_pktmbuf_free(ut_params->ibuf);
9736 ut_params->ibuf = 0;
9740 /* Next session create should fail */
9741 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9742 sessions[i], &ut_params->auth_xform,
9743 ts_params->session_priv_mpool);
9744 TEST_ASSERT_NULL(sessions[i],
9745 "Session creation succeeded unexpectedly!");
9747 for (i = 0; i < MAX_NB_SESSIONS; i++) {
9748 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9750 rte_cryptodev_sym_session_free(sessions[i]);
9755 return TEST_SUCCESS;
9758 struct multi_session_params {
9759 struct crypto_unittest_params ut_params;
9760 uint8_t *cipher_key;
9762 const uint8_t *cipher;
9763 const uint8_t *digest;
9767 #define MB_SESSION_NUMBER 3
9770 test_multi_session_random_usage(void)
9772 struct crypto_testsuite_params *ts_params = &testsuite_params;
9773 struct rte_cryptodev_info dev_info;
9774 struct rte_cryptodev_sym_session **sessions;
9776 struct multi_session_params ut_paramz[] = {
9779 .cipher_key = ms_aes_cbc_key0,
9780 .hmac_key = ms_hmac_key0,
9781 .cipher = ms_aes_cbc_cipher0,
9782 .digest = ms_hmac_digest0,
9783 .iv = ms_aes_cbc_iv0
9786 .cipher_key = ms_aes_cbc_key1,
9787 .hmac_key = ms_hmac_key1,
9788 .cipher = ms_aes_cbc_cipher1,
9789 .digest = ms_hmac_digest1,
9790 .iv = ms_aes_cbc_iv1
9793 .cipher_key = ms_aes_cbc_key2,
9794 .hmac_key = ms_hmac_key2,
9795 .cipher = ms_aes_cbc_cipher2,
9796 .digest = ms_hmac_digest2,
9797 .iv = ms_aes_cbc_iv2
9802 rte_cryptodev_info_get(ts_params->valid_devs[0], &dev_info);
9804 sessions = rte_malloc(NULL,
9805 (sizeof(struct rte_cryptodev_sym_session *)
9806 * MAX_NB_SESSIONS) + 1, 0);
9808 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9809 sessions[i] = rte_cryptodev_sym_session_create(
9810 ts_params->session_mpool);
9812 rte_memcpy(&ut_paramz[i].ut_params, &unittest_params,
9813 sizeof(struct crypto_unittest_params));
9815 test_AES_CBC_HMAC_SHA512_decrypt_create_session_params(
9816 &ut_paramz[i].ut_params,
9817 ut_paramz[i].cipher_key, ut_paramz[i].hmac_key);
9819 /* Create multiple crypto sessions*/
9820 rte_cryptodev_sym_session_init(
9821 ts_params->valid_devs[0],
9823 &ut_paramz[i].ut_params.auth_xform,
9824 ts_params->session_priv_mpool);
9826 TEST_ASSERT_NOT_NULL(sessions[i],
9827 "Session creation failed at session number %u",
9833 for (i = 0; i < 40000; i++) {
9835 j = rand() % MB_SESSION_NUMBER;
9837 TEST_ASSERT_SUCCESS(
9838 test_AES_CBC_HMAC_SHA512_decrypt_perform(
9840 &ut_paramz[j].ut_params,
9841 ts_params, ut_paramz[j].cipher,
9842 ut_paramz[j].digest,
9844 "Failed to perform decrypt on request number %u.", i);
9846 if (ut_paramz[j].ut_params.op)
9847 rte_crypto_op_free(ut_paramz[j].ut_params.op);
9850 * free mbuf - both obuf and ibuf are usually the same,
9851 * so check if they point at the same address is necessary,
9852 * to avoid freeing the mbuf twice.
9854 if (ut_paramz[j].ut_params.obuf) {
9855 rte_pktmbuf_free(ut_paramz[j].ut_params.obuf);
9856 if (ut_paramz[j].ut_params.ibuf
9857 == ut_paramz[j].ut_params.obuf)
9858 ut_paramz[j].ut_params.ibuf = 0;
9859 ut_paramz[j].ut_params.obuf = 0;
9861 if (ut_paramz[j].ut_params.ibuf) {
9862 rte_pktmbuf_free(ut_paramz[j].ut_params.ibuf);
9863 ut_paramz[j].ut_params.ibuf = 0;
9867 for (i = 0; i < MB_SESSION_NUMBER; i++) {
9868 rte_cryptodev_sym_session_clear(ts_params->valid_devs[0],
9870 rte_cryptodev_sym_session_free(sessions[i]);
9875 return TEST_SUCCESS;
9879 test_null_cipher_only_operation(void)
9881 struct crypto_testsuite_params *ts_params = &testsuite_params;
9882 struct crypto_unittest_params *ut_params = &unittest_params;
9884 /* Generate test mbuf data and space for digest */
9885 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9886 catch_22_quote, QUOTE_512_BYTES, 0);
9888 /* Setup Cipher Parameters */
9889 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
9890 ut_params->cipher_xform.next = NULL;
9892 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
9893 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
9895 ut_params->sess = rte_cryptodev_sym_session_create(
9896 ts_params->session_mpool);
9898 /* Create Crypto session*/
9899 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9901 &ut_params->cipher_xform,
9902 ts_params->session_priv_mpool);
9903 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9905 /* Generate Crypto op data structure */
9906 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9907 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9908 TEST_ASSERT_NOT_NULL(ut_params->op,
9909 "Failed to allocate symmetric crypto operation struct");
9911 /* Set crypto operation data parameters */
9912 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9914 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9916 /* set crypto operation source mbuf */
9917 sym_op->m_src = ut_params->ibuf;
9919 sym_op->cipher.data.offset = 0;
9920 sym_op->cipher.data.length = QUOTE_512_BYTES;
9922 /* Process crypto operation */
9923 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
9925 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
9927 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
9928 "crypto operation processing failed");
9931 TEST_ASSERT_BUFFERS_ARE_EQUAL(
9932 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
9935 "Ciphertext data not as expected");
9937 return TEST_SUCCESS;
9939 uint8_t orig_data[] = {0xab, 0xab, 0xab, 0xab,
9940 0xab, 0xab, 0xab, 0xab,
9941 0xab, 0xab, 0xab, 0xab,
9942 0xab, 0xab, 0xab, 0xab};
9944 test_null_auth_only_operation(void)
9946 struct crypto_testsuite_params *ts_params = &testsuite_params;
9947 struct crypto_unittest_params *ut_params = &unittest_params;
9950 /* Generate test mbuf data and space for digest */
9951 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
9952 catch_22_quote, QUOTE_512_BYTES, 0);
9954 /* create a pointer for digest, but don't expect anything to be written
9955 * here in a NULL auth algo so no mbuf append done.
9957 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
9959 /* prefill the memory pointed to by digest */
9960 memcpy(digest, orig_data, sizeof(orig_data));
9962 /* Setup HMAC Parameters */
9963 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
9964 ut_params->auth_xform.next = NULL;
9966 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
9967 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
9969 ut_params->sess = rte_cryptodev_sym_session_create(
9970 ts_params->session_mpool);
9972 /* Create Crypto session*/
9973 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
9974 ut_params->sess, &ut_params->auth_xform,
9975 ts_params->session_priv_mpool);
9976 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
9978 /* Generate Crypto op data structure */
9979 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
9980 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
9981 TEST_ASSERT_NOT_NULL(ut_params->op,
9982 "Failed to allocate symmetric crypto operation struct");
9984 /* Set crypto operation data parameters */
9985 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
9987 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
9989 sym_op->m_src = ut_params->ibuf;
9991 sym_op->auth.data.offset = 0;
9992 sym_op->auth.data.length = QUOTE_512_BYTES;
9993 sym_op->auth.digest.data = digest;
9994 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
9997 /* Process crypto operation */
9998 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10000 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10002 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10003 "crypto operation processing failed");
10004 /* Make sure memory pointed to by digest hasn't been overwritten */
10005 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10009 "Memory at digest ptr overwritten unexpectedly");
10011 return TEST_SUCCESS;
10016 test_null_cipher_auth_operation(void)
10018 struct crypto_testsuite_params *ts_params = &testsuite_params;
10019 struct crypto_unittest_params *ut_params = &unittest_params;
10022 /* Generate test mbuf data and space for digest */
10023 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
10024 catch_22_quote, QUOTE_512_BYTES, 0);
10026 /* create a pointer for digest, but don't expect anything to be written
10027 * here in a NULL auth algo so no mbuf append done.
10029 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10031 /* prefill the memory pointed to by digest */
10032 memcpy(digest, orig_data, sizeof(orig_data));
10034 /* Setup Cipher Parameters */
10035 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10036 ut_params->cipher_xform.next = &ut_params->auth_xform;
10038 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10039 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10041 /* Setup HMAC Parameters */
10042 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10043 ut_params->auth_xform.next = NULL;
10045 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10046 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10048 ut_params->sess = rte_cryptodev_sym_session_create(
10049 ts_params->session_mpool);
10051 /* Create Crypto session*/
10052 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10053 ut_params->sess, &ut_params->cipher_xform,
10054 ts_params->session_priv_mpool);
10055 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10057 /* Generate Crypto op data structure */
10058 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10059 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10060 TEST_ASSERT_NOT_NULL(ut_params->op,
10061 "Failed to allocate symmetric crypto operation struct");
10063 /* Set crypto operation data parameters */
10064 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10066 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10068 sym_op->m_src = ut_params->ibuf;
10070 sym_op->cipher.data.offset = 0;
10071 sym_op->cipher.data.length = QUOTE_512_BYTES;
10073 sym_op->auth.data.offset = 0;
10074 sym_op->auth.data.length = QUOTE_512_BYTES;
10075 sym_op->auth.digest.data = digest;
10076 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10079 /* Process crypto operation */
10080 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10082 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10084 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10085 "crypto operation processing failed");
10087 /* Validate obuf */
10088 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10089 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10092 "Ciphertext data not as expected");
10093 /* Make sure memory pointed to by digest hasn't been overwritten */
10094 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10098 "Memory at digest ptr overwritten unexpectedly");
10100 return TEST_SUCCESS;
10104 test_null_auth_cipher_operation(void)
10106 struct crypto_testsuite_params *ts_params = &testsuite_params;
10107 struct crypto_unittest_params *ut_params = &unittest_params;
10110 /* Generate test mbuf data */
10111 ut_params->ibuf = setup_test_string(ts_params->mbuf_pool,
10112 catch_22_quote, QUOTE_512_BYTES, 0);
10114 /* create a pointer for digest, but don't expect anything to be written
10115 * here in a NULL auth algo so no mbuf append done.
10117 digest = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
10119 /* prefill the memory pointed to by digest */
10120 memcpy(digest, orig_data, sizeof(orig_data));
10122 /* Setup Cipher Parameters */
10123 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10124 ut_params->cipher_xform.next = NULL;
10126 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10127 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10129 /* Setup HMAC Parameters */
10130 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10131 ut_params->auth_xform.next = &ut_params->cipher_xform;
10133 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10134 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10136 ut_params->sess = rte_cryptodev_sym_session_create(
10137 ts_params->session_mpool);
10139 /* Create Crypto session*/
10140 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10141 ut_params->sess, &ut_params->cipher_xform,
10142 ts_params->session_priv_mpool);
10143 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10145 /* Generate Crypto op data structure */
10146 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10147 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10148 TEST_ASSERT_NOT_NULL(ut_params->op,
10149 "Failed to allocate symmetric crypto operation struct");
10151 /* Set crypto operation data parameters */
10152 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10154 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10156 sym_op->m_src = ut_params->ibuf;
10158 sym_op->cipher.data.offset = 0;
10159 sym_op->cipher.data.length = QUOTE_512_BYTES;
10161 sym_op->auth.data.offset = 0;
10162 sym_op->auth.data.length = QUOTE_512_BYTES;
10163 sym_op->auth.digest.data = digest;
10164 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(ut_params->ibuf,
10167 /* Process crypto operation */
10168 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
10170 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
10172 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10173 "crypto operation processing failed");
10175 /* Validate obuf */
10176 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10177 rte_pktmbuf_mtod(ut_params->op->sym->m_src, uint8_t *),
10180 "Ciphertext data not as expected");
10181 /* Make sure memory pointed to by digest hasn't been overwritten */
10182 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10186 "Memory at digest ptr overwritten unexpectedly");
10188 return TEST_SUCCESS;
10193 test_null_invalid_operation(void)
10195 struct crypto_testsuite_params *ts_params = &testsuite_params;
10196 struct crypto_unittest_params *ut_params = &unittest_params;
10199 /* Setup Cipher Parameters */
10200 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10201 ut_params->cipher_xform.next = NULL;
10203 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_AES_CBC;
10204 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10206 ut_params->sess = rte_cryptodev_sym_session_create(
10207 ts_params->session_mpool);
10209 /* Create Crypto session*/
10210 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10211 ut_params->sess, &ut_params->cipher_xform,
10212 ts_params->session_priv_mpool);
10213 TEST_ASSERT(ret < 0,
10214 "Session creation succeeded unexpectedly");
10217 /* Setup HMAC Parameters */
10218 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10219 ut_params->auth_xform.next = NULL;
10221 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_SHA1_HMAC;
10222 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10224 ut_params->sess = rte_cryptodev_sym_session_create(
10225 ts_params->session_mpool);
10227 /* Create Crypto session*/
10228 ret = rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10229 ut_params->sess, &ut_params->auth_xform,
10230 ts_params->session_priv_mpool);
10231 TEST_ASSERT(ret < 0,
10232 "Session creation succeeded unexpectedly");
10234 return TEST_SUCCESS;
10238 #define NULL_BURST_LENGTH (32)
10241 test_null_burst_operation(void)
10243 struct crypto_testsuite_params *ts_params = &testsuite_params;
10244 struct crypto_unittest_params *ut_params = &unittest_params;
10246 unsigned i, burst_len = NULL_BURST_LENGTH;
10248 struct rte_crypto_op *burst[NULL_BURST_LENGTH] = { NULL };
10249 struct rte_crypto_op *burst_dequeued[NULL_BURST_LENGTH] = { NULL };
10251 /* Setup Cipher Parameters */
10252 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10253 ut_params->cipher_xform.next = &ut_params->auth_xform;
10255 ut_params->cipher_xform.cipher.algo = RTE_CRYPTO_CIPHER_NULL;
10256 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
10258 /* Setup HMAC Parameters */
10259 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10260 ut_params->auth_xform.next = NULL;
10262 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_NULL;
10263 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
10265 ut_params->sess = rte_cryptodev_sym_session_create(
10266 ts_params->session_mpool);
10268 /* Create Crypto session*/
10269 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
10270 ut_params->sess, &ut_params->cipher_xform,
10271 ts_params->session_priv_mpool);
10272 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10274 TEST_ASSERT_EQUAL(rte_crypto_op_bulk_alloc(ts_params->op_mpool,
10275 RTE_CRYPTO_OP_TYPE_SYMMETRIC, burst, burst_len),
10276 burst_len, "failed to generate burst of crypto ops");
10278 /* Generate an operation for each mbuf in burst */
10279 for (i = 0; i < burst_len; i++) {
10280 struct rte_mbuf *m = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10282 TEST_ASSERT_NOT_NULL(m, "Failed to allocate mbuf");
10284 unsigned *data = (unsigned *)rte_pktmbuf_append(m,
10288 rte_crypto_op_attach_sym_session(burst[i], ut_params->sess);
10290 burst[i]->sym->m_src = m;
10293 /* Process crypto operation */
10294 TEST_ASSERT_EQUAL(rte_cryptodev_enqueue_burst(ts_params->valid_devs[0],
10295 0, burst, burst_len),
10297 "Error enqueuing burst");
10299 TEST_ASSERT_EQUAL(rte_cryptodev_dequeue_burst(ts_params->valid_devs[0],
10300 0, burst_dequeued, burst_len),
10302 "Error dequeuing burst");
10305 for (i = 0; i < burst_len; i++) {
10307 *rte_pktmbuf_mtod(burst[i]->sym->m_src, uint32_t *),
10308 *rte_pktmbuf_mtod(burst_dequeued[i]->sym->m_src,
10310 "data not as expected");
10312 rte_pktmbuf_free(burst[i]->sym->m_src);
10313 rte_crypto_op_free(burst[i]);
10316 return TEST_SUCCESS;
10320 generate_gmac_large_plaintext(uint8_t *data)
10324 for (i = 32; i < GMAC_LARGE_PLAINTEXT_LENGTH; i += 32)
10325 memcpy(&data[i], &data[0], 32);
10329 create_gmac_operation(enum rte_crypto_auth_operation op,
10330 const struct gmac_test_data *tdata)
10332 struct crypto_testsuite_params *ts_params = &testsuite_params;
10333 struct crypto_unittest_params *ut_params = &unittest_params;
10334 struct rte_crypto_sym_op *sym_op;
10336 uint32_t plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10338 /* Generate Crypto op data structure */
10339 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10340 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10341 TEST_ASSERT_NOT_NULL(ut_params->op,
10342 "Failed to allocate symmetric crypto operation struct");
10344 sym_op = ut_params->op->sym;
10346 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10347 ut_params->ibuf, tdata->gmac_tag.len);
10348 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10349 "no room to append digest");
10351 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10352 ut_params->ibuf, plaintext_pad_len);
10354 if (op == RTE_CRYPTO_AUTH_OP_VERIFY) {
10355 rte_memcpy(sym_op->auth.digest.data, tdata->gmac_tag.data,
10356 tdata->gmac_tag.len);
10357 debug_hexdump(stdout, "digest:",
10358 sym_op->auth.digest.data,
10359 tdata->gmac_tag.len);
10362 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
10363 uint8_t *, IV_OFFSET);
10365 rte_memcpy(iv_ptr, tdata->iv.data, tdata->iv.len);
10367 debug_hexdump(stdout, "iv:", iv_ptr, tdata->iv.len);
10369 sym_op->cipher.data.length = 0;
10370 sym_op->cipher.data.offset = 0;
10372 sym_op->auth.data.offset = 0;
10373 sym_op->auth.data.length = tdata->plaintext.len;
10378 static int create_gmac_session(uint8_t dev_id,
10379 const struct gmac_test_data *tdata,
10380 enum rte_crypto_auth_operation auth_op)
10382 uint8_t auth_key[tdata->key.len];
10384 struct crypto_testsuite_params *ts_params = &testsuite_params;
10385 struct crypto_unittest_params *ut_params = &unittest_params;
10387 memcpy(auth_key, tdata->key.data, tdata->key.len);
10389 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10390 ut_params->auth_xform.next = NULL;
10392 ut_params->auth_xform.auth.algo = RTE_CRYPTO_AUTH_AES_GMAC;
10393 ut_params->auth_xform.auth.op = auth_op;
10394 ut_params->auth_xform.auth.digest_length = tdata->gmac_tag.len;
10395 ut_params->auth_xform.auth.key.length = tdata->key.len;
10396 ut_params->auth_xform.auth.key.data = auth_key;
10397 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10398 ut_params->auth_xform.auth.iv.length = tdata->iv.len;
10401 ut_params->sess = rte_cryptodev_sym_session_create(
10402 ts_params->session_mpool);
10404 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10405 &ut_params->auth_xform,
10406 ts_params->session_priv_mpool);
10408 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10414 test_AES_GMAC_authentication(const struct gmac_test_data *tdata)
10416 struct crypto_testsuite_params *ts_params = &testsuite_params;
10417 struct crypto_unittest_params *ut_params = &unittest_params;
10421 uint8_t *auth_tag, *plaintext;
10422 uint16_t plaintext_pad_len;
10424 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10425 "No GMAC length in the source data");
10427 retval = create_gmac_session(ts_params->valid_devs[0],
10428 tdata, RTE_CRYPTO_AUTH_OP_GENERATE);
10433 if (tdata->plaintext.len > MBUF_SIZE)
10434 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10436 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10437 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10438 "Failed to allocate input buffer in mempool");
10440 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10441 rte_pktmbuf_tailroom(ut_params->ibuf));
10443 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10445 * Runtime generate the large plain text instead of use hard code
10446 * plain text vector. It is done to avoid create huge source file
10447 * with the test vector.
10449 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10450 generate_gmac_large_plaintext(tdata->plaintext.data);
10452 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10453 plaintext_pad_len);
10454 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10456 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10457 debug_hexdump(stdout, "plaintext:", plaintext,
10458 tdata->plaintext.len);
10460 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_GENERATE,
10466 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10468 ut_params->op->sym->m_src = ut_params->ibuf;
10470 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10471 ut_params->op), "failed to process sym crypto op");
10473 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10474 "crypto op processing failed");
10476 if (ut_params->op->sym->m_dst) {
10477 auth_tag = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
10478 uint8_t *, plaintext_pad_len);
10480 auth_tag = plaintext + plaintext_pad_len;
10483 debug_hexdump(stdout, "auth tag:", auth_tag, tdata->gmac_tag.len);
10485 TEST_ASSERT_BUFFERS_ARE_EQUAL(
10487 tdata->gmac_tag.data,
10488 tdata->gmac_tag.len,
10489 "GMAC Generated auth tag not as expected");
10495 test_AES_GMAC_authentication_test_case_1(void)
10497 return test_AES_GMAC_authentication(&gmac_test_case_1);
10501 test_AES_GMAC_authentication_test_case_2(void)
10503 return test_AES_GMAC_authentication(&gmac_test_case_2);
10507 test_AES_GMAC_authentication_test_case_3(void)
10509 return test_AES_GMAC_authentication(&gmac_test_case_3);
10513 test_AES_GMAC_authentication_test_case_4(void)
10515 return test_AES_GMAC_authentication(&gmac_test_case_4);
10519 test_AES_GMAC_authentication_verify(const struct gmac_test_data *tdata)
10521 struct crypto_testsuite_params *ts_params = &testsuite_params;
10522 struct crypto_unittest_params *ut_params = &unittest_params;
10524 uint32_t plaintext_pad_len;
10525 uint8_t *plaintext;
10527 TEST_ASSERT_NOT_EQUAL(tdata->gmac_tag.len, 0,
10528 "No GMAC length in the source data");
10530 retval = create_gmac_session(ts_params->valid_devs[0],
10531 tdata, RTE_CRYPTO_AUTH_OP_VERIFY);
10536 if (tdata->plaintext.len > MBUF_SIZE)
10537 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->large_mbuf_pool);
10539 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
10540 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
10541 "Failed to allocate input buffer in mempool");
10543 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
10544 rte_pktmbuf_tailroom(ut_params->ibuf));
10546 plaintext_pad_len = RTE_ALIGN_CEIL(tdata->plaintext.len, 16);
10549 * Runtime generate the large plain text instead of use hard code
10550 * plain text vector. It is done to avoid create huge source file
10551 * with the test vector.
10553 if (tdata->plaintext.len == GMAC_LARGE_PLAINTEXT_LENGTH)
10554 generate_gmac_large_plaintext(tdata->plaintext.data);
10556 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
10557 plaintext_pad_len);
10558 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
10560 memcpy(plaintext, tdata->plaintext.data, tdata->plaintext.len);
10561 debug_hexdump(stdout, "plaintext:", plaintext,
10562 tdata->plaintext.len);
10564 retval = create_gmac_operation(RTE_CRYPTO_AUTH_OP_VERIFY,
10570 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10572 ut_params->op->sym->m_src = ut_params->ibuf;
10574 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
10575 ut_params->op), "failed to process sym crypto op");
10577 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
10578 "crypto op processing failed");
10585 test_AES_GMAC_authentication_verify_test_case_1(void)
10587 return test_AES_GMAC_authentication_verify(&gmac_test_case_1);
10591 test_AES_GMAC_authentication_verify_test_case_2(void)
10593 return test_AES_GMAC_authentication_verify(&gmac_test_case_2);
10597 test_AES_GMAC_authentication_verify_test_case_3(void)
10599 return test_AES_GMAC_authentication_verify(&gmac_test_case_3);
10603 test_AES_GMAC_authentication_verify_test_case_4(void)
10605 return test_AES_GMAC_authentication_verify(&gmac_test_case_4);
10608 struct test_crypto_vector {
10609 enum rte_crypto_cipher_algorithm crypto_algo;
10610 unsigned int cipher_offset;
10611 unsigned int cipher_len;
10624 const uint8_t *data;
10629 const uint8_t *data;
10633 enum rte_crypto_auth_algorithm auth_algo;
10634 unsigned int auth_offset;
10642 const uint8_t *data;
10652 static const struct test_crypto_vector
10653 hmac_sha1_test_crypto_vector = {
10654 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10656 .data = plaintext_hash,
10661 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10662 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10663 0xDE, 0xF4, 0xDE, 0xAD
10669 0xC4, 0xB7, 0x0E, 0x6B, 0xDE, 0xD1, 0xE7, 0x77,
10670 0x7E, 0x2E, 0x8F, 0xFC, 0x48, 0x39, 0x46, 0x17,
10671 0x3F, 0x91, 0x64, 0x59
10677 static const struct test_crypto_vector
10678 aes128_gmac_test_vector = {
10679 .auth_algo = RTE_CRYPTO_AUTH_AES_GMAC,
10681 .data = plaintext_hash,
10686 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10687 0x08, 0x09, 0x0A, 0x0B
10693 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10694 0xF1, 0x35, 0x5C, 0x3B, 0xDD, 0x9A, 0x65, 0xBA
10700 0xCA, 0x00, 0x99, 0x8B, 0x30, 0x7E, 0x74, 0x56,
10701 0x32, 0xA7, 0x87, 0xB5, 0xE9, 0xB2, 0x34, 0x5A
10707 static const struct test_crypto_vector
10708 aes128cbc_hmac_sha1_test_vector = {
10709 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10710 .cipher_offset = 0,
10714 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10715 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10721 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10722 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10727 .data = plaintext_hash,
10731 .data = ciphertext512_aes128cbc,
10734 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10738 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10739 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10740 0xDE, 0xF4, 0xDE, 0xAD
10746 0x9A, 0x4F, 0x88, 0x1B, 0xB6, 0x8F, 0xD8, 0x60,
10747 0x42, 0x1A, 0x7D, 0x3D, 0xF5, 0x82, 0x80, 0xF1,
10748 0x18, 0x8C, 0x1D, 0x32
10754 static const struct test_crypto_vector
10755 aes128cbc_hmac_sha1_aad_test_vector = {
10756 .crypto_algo = RTE_CRYPTO_CIPHER_AES_CBC,
10757 .cipher_offset = 12,
10761 0xE4, 0x23, 0x33, 0x8A, 0x35, 0x64, 0x61, 0xE2,
10762 0x49, 0x03, 0xDD, 0xC6, 0xB8, 0xCA, 0x55, 0x7A
10768 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
10769 0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F
10774 .data = plaintext_hash,
10778 .data = ciphertext512_aes128cbc_aad,
10781 .auth_algo = RTE_CRYPTO_AUTH_SHA1_HMAC,
10785 0xF8, 0x2A, 0xC7, 0x54, 0xDB, 0x96, 0x18, 0xAA,
10786 0xC3, 0xA1, 0x53, 0xF6, 0x1F, 0x17, 0x60, 0xBD,
10787 0xDE, 0xF4, 0xDE, 0xAD
10793 0x1F, 0x6A, 0xD2, 0x8B, 0x4B, 0xB3, 0xC0, 0x9E,
10794 0x86, 0x9B, 0x3A, 0xF2, 0x00, 0x5B, 0x4F, 0x08,
10795 0x62, 0x8D, 0x62, 0x65
10802 data_corruption(uint8_t *data)
10808 tag_corruption(uint8_t *data, unsigned int tag_offset)
10810 data[tag_offset] += 1;
10814 create_auth_session(struct crypto_unittest_params *ut_params,
10816 const struct test_crypto_vector *reference,
10817 enum rte_crypto_auth_operation auth_op)
10819 struct crypto_testsuite_params *ts_params = &testsuite_params;
10820 uint8_t auth_key[reference->auth_key.len + 1];
10822 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10824 /* Setup Authentication Parameters */
10825 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10826 ut_params->auth_xform.auth.op = auth_op;
10827 ut_params->auth_xform.next = NULL;
10828 ut_params->auth_xform.auth.algo = reference->auth_algo;
10829 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10830 ut_params->auth_xform.auth.key.data = auth_key;
10831 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10833 /* Create Crypto session*/
10834 ut_params->sess = rte_cryptodev_sym_session_create(
10835 ts_params->session_mpool);
10837 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10838 &ut_params->auth_xform,
10839 ts_params->session_priv_mpool);
10841 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10847 create_auth_cipher_session(struct crypto_unittest_params *ut_params,
10849 const struct test_crypto_vector *reference,
10850 enum rte_crypto_auth_operation auth_op,
10851 enum rte_crypto_cipher_operation cipher_op)
10853 struct crypto_testsuite_params *ts_params = &testsuite_params;
10854 uint8_t cipher_key[reference->cipher_key.len + 1];
10855 uint8_t auth_key[reference->auth_key.len + 1];
10857 memcpy(cipher_key, reference->cipher_key.data,
10858 reference->cipher_key.len);
10859 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
10861 /* Setup Authentication Parameters */
10862 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
10863 ut_params->auth_xform.auth.op = auth_op;
10864 ut_params->auth_xform.auth.algo = reference->auth_algo;
10865 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
10866 ut_params->auth_xform.auth.key.data = auth_key;
10867 ut_params->auth_xform.auth.digest_length = reference->digest.len;
10869 if (reference->auth_algo == RTE_CRYPTO_AUTH_AES_GMAC) {
10870 ut_params->auth_xform.auth.iv.offset = IV_OFFSET;
10871 ut_params->auth_xform.auth.iv.length = reference->iv.len;
10873 ut_params->auth_xform.next = &ut_params->cipher_xform;
10875 /* Setup Cipher Parameters */
10876 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
10877 ut_params->cipher_xform.next = NULL;
10878 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
10879 ut_params->cipher_xform.cipher.op = cipher_op;
10880 ut_params->cipher_xform.cipher.key.data = cipher_key;
10881 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
10882 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
10883 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
10886 /* Create Crypto session*/
10887 ut_params->sess = rte_cryptodev_sym_session_create(
10888 ts_params->session_mpool);
10890 rte_cryptodev_sym_session_init(dev_id, ut_params->sess,
10891 &ut_params->auth_xform,
10892 ts_params->session_priv_mpool);
10894 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
10900 create_auth_operation(struct crypto_testsuite_params *ts_params,
10901 struct crypto_unittest_params *ut_params,
10902 const struct test_crypto_vector *reference,
10903 unsigned int auth_generate)
10905 /* Generate Crypto op data structure */
10906 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10907 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10908 TEST_ASSERT_NOT_NULL(ut_params->op,
10909 "Failed to allocate pktmbuf offload");
10911 /* Set crypto operation data parameters */
10912 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10914 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10916 /* set crypto operation source mbuf */
10917 sym_op->m_src = ut_params->ibuf;
10920 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10921 ut_params->ibuf, reference->digest.len);
10923 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10924 "no room to append auth tag");
10926 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10927 ut_params->ibuf, reference->plaintext.len);
10930 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10932 memcpy(sym_op->auth.digest.data,
10933 reference->digest.data,
10934 reference->digest.len);
10936 debug_hexdump(stdout, "digest:",
10937 sym_op->auth.digest.data,
10938 reference->digest.len);
10940 sym_op->auth.data.length = reference->plaintext.len;
10941 sym_op->auth.data.offset = 0;
10947 create_auth_GMAC_operation(struct crypto_testsuite_params *ts_params,
10948 struct crypto_unittest_params *ut_params,
10949 const struct test_crypto_vector *reference,
10950 unsigned int auth_generate)
10952 /* Generate Crypto op data structure */
10953 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
10954 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
10955 TEST_ASSERT_NOT_NULL(ut_params->op,
10956 "Failed to allocate pktmbuf offload");
10958 /* Set crypto operation data parameters */
10959 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
10961 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
10963 /* set crypto operation source mbuf */
10964 sym_op->m_src = ut_params->ibuf;
10967 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
10968 ut_params->ibuf, reference->digest.len);
10970 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
10971 "no room to append auth tag");
10973 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
10974 ut_params->ibuf, reference->ciphertext.len);
10977 memset(sym_op->auth.digest.data, 0, reference->digest.len);
10979 memcpy(sym_op->auth.digest.data,
10980 reference->digest.data,
10981 reference->digest.len);
10983 debug_hexdump(stdout, "digest:",
10984 sym_op->auth.digest.data,
10985 reference->digest.len);
10987 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
10988 reference->iv.data, reference->iv.len);
10990 sym_op->cipher.data.length = 0;
10991 sym_op->cipher.data.offset = 0;
10993 sym_op->auth.data.length = reference->plaintext.len;
10994 sym_op->auth.data.offset = 0;
11000 create_cipher_auth_operation(struct crypto_testsuite_params *ts_params,
11001 struct crypto_unittest_params *ut_params,
11002 const struct test_crypto_vector *reference,
11003 unsigned int auth_generate)
11005 /* Generate Crypto op data structure */
11006 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11007 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11008 TEST_ASSERT_NOT_NULL(ut_params->op,
11009 "Failed to allocate pktmbuf offload");
11011 /* Set crypto operation data parameters */
11012 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11014 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11016 /* set crypto operation source mbuf */
11017 sym_op->m_src = ut_params->ibuf;
11020 sym_op->auth.digest.data = (uint8_t *)rte_pktmbuf_append(
11021 ut_params->ibuf, reference->digest.len);
11023 TEST_ASSERT_NOT_NULL(sym_op->auth.digest.data,
11024 "no room to append auth tag");
11026 sym_op->auth.digest.phys_addr = rte_pktmbuf_iova_offset(
11027 ut_params->ibuf, reference->ciphertext.len);
11030 memset(sym_op->auth.digest.data, 0, reference->digest.len);
11032 memcpy(sym_op->auth.digest.data,
11033 reference->digest.data,
11034 reference->digest.len);
11036 debug_hexdump(stdout, "digest:",
11037 sym_op->auth.digest.data,
11038 reference->digest.len);
11040 rte_memcpy(rte_crypto_op_ctod_offset(ut_params->op, uint8_t *, IV_OFFSET),
11041 reference->iv.data, reference->iv.len);
11043 sym_op->cipher.data.length = reference->cipher_len;
11044 sym_op->cipher.data.offset = reference->cipher_offset;
11046 sym_op->auth.data.length = reference->plaintext.len;
11047 sym_op->auth.data.offset = reference->auth_offset;
11053 create_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11054 struct crypto_unittest_params *ut_params,
11055 const struct test_crypto_vector *reference)
11057 return create_auth_operation(ts_params, ut_params, reference, 0);
11061 create_auth_verify_GMAC_operation(
11062 struct crypto_testsuite_params *ts_params,
11063 struct crypto_unittest_params *ut_params,
11064 const struct test_crypto_vector *reference)
11066 return create_auth_GMAC_operation(ts_params, ut_params, reference, 0);
11070 create_cipher_auth_verify_operation(struct crypto_testsuite_params *ts_params,
11071 struct crypto_unittest_params *ut_params,
11072 const struct test_crypto_vector *reference)
11074 return create_cipher_auth_operation(ts_params, ut_params, reference, 0);
11078 test_authentication_verify_fail_when_data_corruption(
11079 struct crypto_testsuite_params *ts_params,
11080 struct crypto_unittest_params *ut_params,
11081 const struct test_crypto_vector *reference,
11082 unsigned int data_corrupted)
11086 uint8_t *plaintext;
11088 /* Create session */
11089 retval = create_auth_session(ut_params,
11090 ts_params->valid_devs[0],
11092 RTE_CRYPTO_AUTH_OP_VERIFY);
11096 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11097 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11098 "Failed to allocate input buffer in mempool");
11100 /* clear mbuf payload */
11101 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11102 rte_pktmbuf_tailroom(ut_params->ibuf));
11104 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11105 reference->plaintext.len);
11106 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11107 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11109 debug_hexdump(stdout, "plaintext:", plaintext,
11110 reference->plaintext.len);
11112 /* Create operation */
11113 retval = create_auth_verify_operation(ts_params, ut_params, reference);
11118 if (data_corrupted)
11119 data_corruption(plaintext);
11121 tag_corruption(plaintext, reference->plaintext.len);
11123 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11126 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11132 test_authentication_verify_GMAC_fail_when_corruption(
11133 struct crypto_testsuite_params *ts_params,
11134 struct crypto_unittest_params *ut_params,
11135 const struct test_crypto_vector *reference,
11136 unsigned int data_corrupted)
11139 uint8_t *plaintext;
11141 /* Create session */
11142 retval = create_auth_cipher_session(ut_params,
11143 ts_params->valid_devs[0],
11145 RTE_CRYPTO_AUTH_OP_VERIFY,
11146 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11150 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11151 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11152 "Failed to allocate input buffer in mempool");
11154 /* clear mbuf payload */
11155 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11156 rte_pktmbuf_tailroom(ut_params->ibuf));
11158 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11159 reference->plaintext.len);
11160 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11161 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11163 debug_hexdump(stdout, "plaintext:", plaintext,
11164 reference->plaintext.len);
11166 /* Create operation */
11167 retval = create_auth_verify_GMAC_operation(ts_params,
11174 if (data_corrupted)
11175 data_corruption(plaintext);
11177 tag_corruption(plaintext, reference->aad.len);
11179 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11182 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11188 test_authenticated_decryption_fail_when_corruption(
11189 struct crypto_testsuite_params *ts_params,
11190 struct crypto_unittest_params *ut_params,
11191 const struct test_crypto_vector *reference,
11192 unsigned int data_corrupted)
11196 uint8_t *ciphertext;
11198 /* Create session */
11199 retval = create_auth_cipher_session(ut_params,
11200 ts_params->valid_devs[0],
11202 RTE_CRYPTO_AUTH_OP_VERIFY,
11203 RTE_CRYPTO_CIPHER_OP_DECRYPT);
11207 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11208 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11209 "Failed to allocate input buffer in mempool");
11211 /* clear mbuf payload */
11212 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11213 rte_pktmbuf_tailroom(ut_params->ibuf));
11215 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11216 reference->ciphertext.len);
11217 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11218 memcpy(ciphertext, reference->ciphertext.data,
11219 reference->ciphertext.len);
11221 /* Create operation */
11222 retval = create_cipher_auth_verify_operation(ts_params,
11229 if (data_corrupted)
11230 data_corruption(ciphertext);
11232 tag_corruption(ciphertext, reference->ciphertext.len);
11234 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11237 TEST_ASSERT_NULL(ut_params->op, "authentication not failed");
11243 test_authenticated_encryt_with_esn(
11244 struct crypto_testsuite_params *ts_params,
11245 struct crypto_unittest_params *ut_params,
11246 const struct test_crypto_vector *reference)
11250 uint8_t *authciphertext, *plaintext, *auth_tag;
11251 uint16_t plaintext_pad_len;
11252 uint8_t cipher_key[reference->cipher_key.len + 1];
11253 uint8_t auth_key[reference->auth_key.len + 1];
11255 /* Create session */
11256 memcpy(cipher_key, reference->cipher_key.data,
11257 reference->cipher_key.len);
11258 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11260 /* Setup Cipher Parameters */
11261 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11262 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11263 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_ENCRYPT;
11264 ut_params->cipher_xform.cipher.key.data = cipher_key;
11265 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11266 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11267 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11269 ut_params->cipher_xform.next = &ut_params->auth_xform;
11271 /* Setup Authentication Parameters */
11272 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11273 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_GENERATE;
11274 ut_params->auth_xform.auth.algo = reference->auth_algo;
11275 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11276 ut_params->auth_xform.auth.key.data = auth_key;
11277 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11278 ut_params->auth_xform.next = NULL;
11280 /* Create Crypto session*/
11281 ut_params->sess = rte_cryptodev_sym_session_create(
11282 ts_params->session_mpool);
11284 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11286 &ut_params->cipher_xform,
11287 ts_params->session_priv_mpool);
11289 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11291 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11292 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11293 "Failed to allocate input buffer in mempool");
11295 /* clear mbuf payload */
11296 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11297 rte_pktmbuf_tailroom(ut_params->ibuf));
11299 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11300 reference->plaintext.len);
11301 TEST_ASSERT_NOT_NULL(plaintext, "no room to append plaintext");
11302 memcpy(plaintext, reference->plaintext.data, reference->plaintext.len);
11304 /* Create operation */
11305 retval = create_cipher_auth_operation(ts_params,
11312 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11315 TEST_ASSERT_NOT_NULL(ut_params->op, "no crypto operation returned");
11317 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11318 "crypto op processing failed");
11320 plaintext_pad_len = RTE_ALIGN_CEIL(reference->plaintext.len, 16);
11322 authciphertext = rte_pktmbuf_mtod_offset(ut_params->ibuf, uint8_t *,
11323 ut_params->op->sym->auth.data.offset);
11324 auth_tag = authciphertext + plaintext_pad_len;
11325 debug_hexdump(stdout, "ciphertext:", authciphertext,
11326 reference->ciphertext.len);
11327 debug_hexdump(stdout, "auth tag:", auth_tag, reference->digest.len);
11329 /* Validate obuf */
11330 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11332 reference->ciphertext.data,
11333 reference->ciphertext.len,
11334 "Ciphertext data not as expected");
11336 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11338 reference->digest.data,
11339 reference->digest.len,
11340 "Generated digest not as expected");
11342 return TEST_SUCCESS;
11347 test_authenticated_decrypt_with_esn(
11348 struct crypto_testsuite_params *ts_params,
11349 struct crypto_unittest_params *ut_params,
11350 const struct test_crypto_vector *reference)
11354 uint8_t *ciphertext;
11355 uint8_t cipher_key[reference->cipher_key.len + 1];
11356 uint8_t auth_key[reference->auth_key.len + 1];
11358 /* Create session */
11359 memcpy(cipher_key, reference->cipher_key.data,
11360 reference->cipher_key.len);
11361 memcpy(auth_key, reference->auth_key.data, reference->auth_key.len);
11363 /* Setup Authentication Parameters */
11364 ut_params->auth_xform.type = RTE_CRYPTO_SYM_XFORM_AUTH;
11365 ut_params->auth_xform.auth.op = RTE_CRYPTO_AUTH_OP_VERIFY;
11366 ut_params->auth_xform.auth.algo = reference->auth_algo;
11367 ut_params->auth_xform.auth.key.length = reference->auth_key.len;
11368 ut_params->auth_xform.auth.key.data = auth_key;
11369 ut_params->auth_xform.auth.digest_length = reference->digest.len;
11370 ut_params->auth_xform.next = &ut_params->cipher_xform;
11372 /* Setup Cipher Parameters */
11373 ut_params->cipher_xform.type = RTE_CRYPTO_SYM_XFORM_CIPHER;
11374 ut_params->cipher_xform.next = NULL;
11375 ut_params->cipher_xform.cipher.algo = reference->crypto_algo;
11376 ut_params->cipher_xform.cipher.op = RTE_CRYPTO_CIPHER_OP_DECRYPT;
11377 ut_params->cipher_xform.cipher.key.data = cipher_key;
11378 ut_params->cipher_xform.cipher.key.length = reference->cipher_key.len;
11379 ut_params->cipher_xform.cipher.iv.offset = IV_OFFSET;
11380 ut_params->cipher_xform.cipher.iv.length = reference->iv.len;
11382 /* Create Crypto session*/
11383 ut_params->sess = rte_cryptodev_sym_session_create(
11384 ts_params->session_mpool);
11386 rte_cryptodev_sym_session_init(ts_params->valid_devs[0],
11388 &ut_params->auth_xform,
11389 ts_params->session_priv_mpool);
11391 TEST_ASSERT_NOT_NULL(ut_params->sess, "Session creation failed");
11393 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11394 TEST_ASSERT_NOT_NULL(ut_params->ibuf,
11395 "Failed to allocate input buffer in mempool");
11397 /* clear mbuf payload */
11398 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11399 rte_pktmbuf_tailroom(ut_params->ibuf));
11401 ciphertext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11402 reference->ciphertext.len);
11403 TEST_ASSERT_NOT_NULL(ciphertext, "no room to append ciphertext");
11404 memcpy(ciphertext, reference->ciphertext.data,
11405 reference->ciphertext.len);
11407 /* Create operation */
11408 retval = create_cipher_auth_verify_operation(ts_params,
11415 ut_params->op = process_crypto_request(ts_params->valid_devs[0],
11418 TEST_ASSERT_NOT_NULL(ut_params->op, "failed crypto process");
11419 TEST_ASSERT_EQUAL(ut_params->op->status,
11420 RTE_CRYPTO_OP_STATUS_SUCCESS,
11421 "crypto op processing passed");
11423 ut_params->obuf = ut_params->op->sym->m_src;
11424 TEST_ASSERT_NOT_NULL(ut_params->obuf, "failed to retrieve obuf");
11430 create_aead_operation_SGL(enum rte_crypto_aead_operation op,
11431 const struct aead_test_data *tdata,
11432 void *digest_mem, uint64_t digest_phys)
11434 struct crypto_testsuite_params *ts_params = &testsuite_params;
11435 struct crypto_unittest_params *ut_params = &unittest_params;
11437 const unsigned int auth_tag_len = tdata->auth_tag.len;
11438 const unsigned int iv_len = tdata->iv.len;
11439 unsigned int aad_len = tdata->aad.len;
11440 unsigned int aad_len_pad = 0;
11442 /* Generate Crypto op data structure */
11443 ut_params->op = rte_crypto_op_alloc(ts_params->op_mpool,
11444 RTE_CRYPTO_OP_TYPE_SYMMETRIC);
11445 TEST_ASSERT_NOT_NULL(ut_params->op,
11446 "Failed to allocate symmetric crypto operation struct");
11448 struct rte_crypto_sym_op *sym_op = ut_params->op->sym;
11450 sym_op->aead.digest.data = digest_mem;
11452 TEST_ASSERT_NOT_NULL(sym_op->aead.digest.data,
11453 "no room to append digest");
11455 sym_op->aead.digest.phys_addr = digest_phys;
11457 if (op == RTE_CRYPTO_AEAD_OP_DECRYPT) {
11458 rte_memcpy(sym_op->aead.digest.data, tdata->auth_tag.data,
11460 debug_hexdump(stdout, "digest:",
11461 sym_op->aead.digest.data,
11465 /* Append aad data */
11466 if (tdata->algo == RTE_CRYPTO_AEAD_AES_CCM) {
11467 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11468 uint8_t *, IV_OFFSET);
11470 /* Copy IV 1 byte after the IV pointer, according to the API */
11471 rte_memcpy(iv_ptr + 1, tdata->iv.data, iv_len);
11473 aad_len = RTE_ALIGN_CEIL(aad_len + 18, 16);
11475 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11476 ut_params->ibuf, aad_len);
11477 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11478 "no room to prepend aad");
11479 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11482 memset(sym_op->aead.aad.data, 0, aad_len);
11483 /* Copy AAD 18 bytes after the AAD pointer, according to the API */
11484 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11486 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11487 debug_hexdump(stdout, "aad:",
11488 sym_op->aead.aad.data, aad_len);
11490 uint8_t *iv_ptr = rte_crypto_op_ctod_offset(ut_params->op,
11491 uint8_t *, IV_OFFSET);
11493 rte_memcpy(iv_ptr, tdata->iv.data, iv_len);
11495 aad_len_pad = RTE_ALIGN_CEIL(aad_len, 16);
11497 sym_op->aead.aad.data = (uint8_t *)rte_pktmbuf_prepend(
11498 ut_params->ibuf, aad_len_pad);
11499 TEST_ASSERT_NOT_NULL(sym_op->aead.aad.data,
11500 "no room to prepend aad");
11501 sym_op->aead.aad.phys_addr = rte_pktmbuf_iova(
11504 memset(sym_op->aead.aad.data, 0, aad_len);
11505 rte_memcpy(sym_op->aead.aad.data, tdata->aad.data, aad_len);
11507 debug_hexdump(stdout, "iv:", iv_ptr, iv_len);
11508 debug_hexdump(stdout, "aad:",
11509 sym_op->aead.aad.data, aad_len);
11512 sym_op->aead.data.length = tdata->plaintext.len;
11513 sym_op->aead.data.offset = aad_len_pad;
11518 #define SGL_MAX_NO 16
11521 test_authenticated_encryption_SGL(const struct aead_test_data *tdata,
11522 const int oop, uint32_t fragsz, uint32_t fragsz_oop)
11524 struct crypto_testsuite_params *ts_params = &testsuite_params;
11525 struct crypto_unittest_params *ut_params = &unittest_params;
11526 struct rte_mbuf *buf, *buf_oop = NULL, *buf_last_oop = NULL;
11529 int to_trn_tbl[SGL_MAX_NO];
11531 unsigned int trn_data = 0;
11532 uint8_t *plaintext, *ciphertext, *auth_tag;
11534 if (fragsz > tdata->plaintext.len)
11535 fragsz = tdata->plaintext.len;
11537 uint16_t plaintext_len = fragsz;
11538 uint16_t frag_size_oop = fragsz_oop ? fragsz_oop : fragsz;
11540 if (fragsz_oop > tdata->plaintext.len)
11541 frag_size_oop = tdata->plaintext.len;
11544 void *digest_mem = NULL;
11546 uint32_t prepend_len = RTE_ALIGN_CEIL(tdata->aad.len, 16);
11548 if (tdata->plaintext.len % fragsz != 0) {
11549 if (tdata->plaintext.len / fragsz + 1 > SGL_MAX_NO)
11552 if (tdata->plaintext.len / fragsz > SGL_MAX_NO)
11557 * For out-op-place we need to alloc another mbuf
11560 ut_params->obuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11561 rte_pktmbuf_append(ut_params->obuf,
11562 frag_size_oop + prepend_len);
11563 buf_oop = ut_params->obuf;
11566 /* Create AEAD session */
11567 retval = create_aead_session(ts_params->valid_devs[0],
11569 RTE_CRYPTO_AEAD_OP_ENCRYPT,
11570 tdata->key.data, tdata->key.len,
11571 tdata->aad.len, tdata->auth_tag.len,
11576 ut_params->ibuf = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11578 /* clear mbuf payload */
11579 memset(rte_pktmbuf_mtod(ut_params->ibuf, uint8_t *), 0,
11580 rte_pktmbuf_tailroom(ut_params->ibuf));
11582 plaintext = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11585 memcpy(plaintext, tdata->plaintext.data, plaintext_len);
11587 trn_data += plaintext_len;
11589 buf = ut_params->ibuf;
11592 * Loop until no more fragments
11595 while (trn_data < tdata->plaintext.len) {
11597 to_trn = (tdata->plaintext.len - trn_data < fragsz) ?
11598 (tdata->plaintext.len - trn_data) : fragsz;
11600 to_trn_tbl[ecx++] = to_trn;
11602 buf->next = rte_pktmbuf_alloc(ts_params->mbuf_pool);
11605 memset(rte_pktmbuf_mtod(buf, uint8_t *), 0,
11606 rte_pktmbuf_tailroom(buf));
11609 if (oop && !fragsz_oop) {
11610 buf_last_oop = buf_oop->next =
11611 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11612 buf_oop = buf_oop->next;
11613 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11614 0, rte_pktmbuf_tailroom(buf_oop));
11615 rte_pktmbuf_append(buf_oop, to_trn);
11618 plaintext = (uint8_t *)rte_pktmbuf_append(buf,
11621 memcpy(plaintext, tdata->plaintext.data + trn_data,
11623 trn_data += to_trn;
11624 if (trn_data == tdata->plaintext.len) {
11627 digest_mem = rte_pktmbuf_append(buf_oop,
11628 tdata->auth_tag.len);
11630 digest_mem = (uint8_t *)rte_pktmbuf_append(buf,
11631 tdata->auth_tag.len);
11635 uint64_t digest_phys = 0;
11637 ut_params->ibuf->nb_segs = segs;
11640 if (fragsz_oop && oop) {
11644 if (frag_size_oop == tdata->plaintext.len) {
11645 digest_mem = rte_pktmbuf_append(ut_params->obuf,
11646 tdata->auth_tag.len);
11648 digest_phys = rte_pktmbuf_iova_offset(
11650 tdata->plaintext.len + prepend_len);
11653 trn_data = frag_size_oop;
11654 while (trn_data < tdata->plaintext.len) {
11657 (tdata->plaintext.len - trn_data <
11659 (tdata->plaintext.len - trn_data) :
11662 to_trn_tbl[ecx++] = to_trn;
11664 buf_last_oop = buf_oop->next =
11665 rte_pktmbuf_alloc(ts_params->mbuf_pool);
11666 buf_oop = buf_oop->next;
11667 memset(rte_pktmbuf_mtod(buf_oop, uint8_t *),
11668 0, rte_pktmbuf_tailroom(buf_oop));
11669 rte_pktmbuf_append(buf_oop, to_trn);
11671 trn_data += to_trn;
11673 if (trn_data == tdata->plaintext.len) {
11674 digest_mem = rte_pktmbuf_append(buf_oop,
11675 tdata->auth_tag.len);
11679 ut_params->obuf->nb_segs = segs;
11683 * Place digest at the end of the last buffer
11686 digest_phys = rte_pktmbuf_iova(buf) + to_trn;
11687 if (oop && buf_last_oop)
11688 digest_phys = rte_pktmbuf_iova(buf_last_oop) + to_trn;
11690 if (!digest_mem && !oop) {
11691 digest_mem = (uint8_t *)rte_pktmbuf_append(ut_params->ibuf,
11692 + tdata->auth_tag.len);
11693 digest_phys = rte_pktmbuf_iova_offset(ut_params->ibuf,
11694 tdata->plaintext.len);
11697 /* Create AEAD operation */
11698 retval = create_aead_operation_SGL(RTE_CRYPTO_AEAD_OP_ENCRYPT,
11699 tdata, digest_mem, digest_phys);
11704 rte_crypto_op_attach_sym_session(ut_params->op, ut_params->sess);
11706 ut_params->op->sym->m_src = ut_params->ibuf;
11708 ut_params->op->sym->m_dst = ut_params->obuf;
11710 /* Process crypto operation */
11711 TEST_ASSERT_NOT_NULL(process_crypto_request(ts_params->valid_devs[0],
11712 ut_params->op), "failed to process sym crypto op");
11714 TEST_ASSERT_EQUAL(ut_params->op->status, RTE_CRYPTO_OP_STATUS_SUCCESS,
11715 "crypto op processing failed");
11718 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_src,
11719 uint8_t *, prepend_len);
11721 ciphertext = rte_pktmbuf_mtod_offset(ut_params->op->sym->m_dst,
11722 uint8_t *, prepend_len);
11726 fragsz = fragsz_oop;
11728 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11730 tdata->ciphertext.data,
11732 "Ciphertext data not as expected");
11734 buf = ut_params->op->sym->m_src->next;
11736 buf = ut_params->op->sym->m_dst->next;
11738 unsigned int off = fragsz;
11742 ciphertext = rte_pktmbuf_mtod(buf,
11745 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11747 tdata->ciphertext.data + off,
11749 "Ciphertext data not as expected");
11751 off += to_trn_tbl[ecx++];
11755 auth_tag = digest_mem;
11756 TEST_ASSERT_BUFFERS_ARE_EQUAL(
11758 tdata->auth_tag.data,
11759 tdata->auth_tag.len,
11760 "Generated auth tag not as expected");
11766 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B(void)
11768 return test_authenticated_encryption_SGL(
11769 &gcm_test_case_SGL_1, OUT_OF_PLACE, 400, 400);
11773 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B(void)
11775 return test_authenticated_encryption_SGL(
11776 &gcm_test_case_SGL_1, OUT_OF_PLACE, 1500, 2000);
11780 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg(void)
11782 return test_authenticated_encryption_SGL(
11783 &gcm_test_case_8, OUT_OF_PLACE, 400,
11784 gcm_test_case_8.plaintext.len);
11788 test_AES_GCM_auth_encrypt_SGL_in_place_1500B(void)
11791 return test_authenticated_encryption_SGL(
11792 &gcm_test_case_SGL_1, IN_PLACE, 1500, 0);
11796 test_authentication_verify_fail_when_data_corrupted(
11797 struct crypto_testsuite_params *ts_params,
11798 struct crypto_unittest_params *ut_params,
11799 const struct test_crypto_vector *reference)
11801 return test_authentication_verify_fail_when_data_corruption(
11802 ts_params, ut_params, reference, 1);
11806 test_authentication_verify_fail_when_tag_corrupted(
11807 struct crypto_testsuite_params *ts_params,
11808 struct crypto_unittest_params *ut_params,
11809 const struct test_crypto_vector *reference)
11811 return test_authentication_verify_fail_when_data_corruption(
11812 ts_params, ut_params, reference, 0);
11816 test_authentication_verify_GMAC_fail_when_data_corrupted(
11817 struct crypto_testsuite_params *ts_params,
11818 struct crypto_unittest_params *ut_params,
11819 const struct test_crypto_vector *reference)
11821 return test_authentication_verify_GMAC_fail_when_corruption(
11822 ts_params, ut_params, reference, 1);
11826 test_authentication_verify_GMAC_fail_when_tag_corrupted(
11827 struct crypto_testsuite_params *ts_params,
11828 struct crypto_unittest_params *ut_params,
11829 const struct test_crypto_vector *reference)
11831 return test_authentication_verify_GMAC_fail_when_corruption(
11832 ts_params, ut_params, reference, 0);
11836 test_authenticated_decryption_fail_when_data_corrupted(
11837 struct crypto_testsuite_params *ts_params,
11838 struct crypto_unittest_params *ut_params,
11839 const struct test_crypto_vector *reference)
11841 return test_authenticated_decryption_fail_when_corruption(
11842 ts_params, ut_params, reference, 1);
11846 test_authenticated_decryption_fail_when_tag_corrupted(
11847 struct crypto_testsuite_params *ts_params,
11848 struct crypto_unittest_params *ut_params,
11849 const struct test_crypto_vector *reference)
11851 return test_authenticated_decryption_fail_when_corruption(
11852 ts_params, ut_params, reference, 0);
11856 authentication_verify_HMAC_SHA1_fail_data_corrupt(void)
11858 return test_authentication_verify_fail_when_data_corrupted(
11859 &testsuite_params, &unittest_params,
11860 &hmac_sha1_test_crypto_vector);
11864 authentication_verify_HMAC_SHA1_fail_tag_corrupt(void)
11866 return test_authentication_verify_fail_when_tag_corrupted(
11867 &testsuite_params, &unittest_params,
11868 &hmac_sha1_test_crypto_vector);
11872 authentication_verify_AES128_GMAC_fail_data_corrupt(void)
11874 return test_authentication_verify_GMAC_fail_when_data_corrupted(
11875 &testsuite_params, &unittest_params,
11876 &aes128_gmac_test_vector);
11880 authentication_verify_AES128_GMAC_fail_tag_corrupt(void)
11882 return test_authentication_verify_GMAC_fail_when_tag_corrupted(
11883 &testsuite_params, &unittest_params,
11884 &aes128_gmac_test_vector);
11888 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt(void)
11890 return test_authenticated_decryption_fail_when_data_corrupted(
11893 &aes128cbc_hmac_sha1_test_vector);
11897 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt(void)
11899 return test_authenticated_decryption_fail_when_tag_corrupted(
11902 &aes128cbc_hmac_sha1_test_vector);
11906 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11908 return test_authenticated_encryt_with_esn(
11911 &aes128cbc_hmac_sha1_aad_test_vector);
11915 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check(void)
11917 return test_authenticated_decrypt_with_esn(
11920 &aes128cbc_hmac_sha1_aad_test_vector);
11923 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
11925 /* global AESNI slave IDs for the scheduler test */
11926 uint8_t aesni_ids[2];
11929 test_scheduler_attach_slave_op(void)
11931 struct crypto_testsuite_params *ts_params = &testsuite_params;
11932 uint8_t sched_id = ts_params->valid_devs[0];
11933 uint32_t nb_devs, i, nb_devs_attached = 0;
11935 char vdev_name[32];
11937 /* create 2 AESNI_MB if necessary */
11938 nb_devs = rte_cryptodev_device_count_by_driver(
11939 rte_cryptodev_driver_id_get(
11940 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)));
11942 for (i = nb_devs; i < 2; i++) {
11943 snprintf(vdev_name, sizeof(vdev_name), "%s_%u",
11944 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD),
11946 ret = rte_vdev_init(vdev_name, NULL);
11948 TEST_ASSERT(ret == 0,
11949 "Failed to create instance %u of"
11951 i, RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
11955 /* attach 2 AESNI_MB cdevs */
11956 for (i = 0; i < rte_cryptodev_count() && nb_devs_attached < 2;
11958 struct rte_cryptodev_info info;
11959 unsigned int session_size;
11961 rte_cryptodev_info_get(i, &info);
11962 if (info.driver_id != rte_cryptodev_driver_id_get(
11963 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)))
11966 session_size = rte_cryptodev_sym_get_private_session_size(i);
11968 * Create the session mempool again, since now there are new devices
11969 * to use the mempool.
11971 if (ts_params->session_mpool) {
11972 rte_mempool_free(ts_params->session_mpool);
11973 ts_params->session_mpool = NULL;
11975 if (ts_params->session_priv_mpool) {
11976 rte_mempool_free(ts_params->session_priv_mpool);
11977 ts_params->session_priv_mpool = NULL;
11980 if (info.sym.max_nb_sessions != 0 &&
11981 info.sym.max_nb_sessions < MAX_NB_SESSIONS) {
11982 RTE_LOG(ERR, USER1,
11983 "Device does not support "
11984 "at least %u sessions\n",
11986 return TEST_FAILED;
11989 * Create mempool with maximum number of sessions,
11990 * to include the session headers
11992 if (ts_params->session_mpool == NULL) {
11993 ts_params->session_mpool =
11994 rte_cryptodev_sym_session_pool_create(
11996 MAX_NB_SESSIONS, 0, 0, 0,
11998 TEST_ASSERT_NOT_NULL(ts_params->session_mpool,
11999 "session mempool allocation failed");
12003 * Create mempool with maximum number of sessions,
12004 * to include device specific session private data
12006 if (ts_params->session_priv_mpool == NULL) {
12007 ts_params->session_priv_mpool = rte_mempool_create(
12008 "test_sess_mp_priv",
12011 0, 0, NULL, NULL, NULL,
12012 NULL, SOCKET_ID_ANY,
12015 TEST_ASSERT_NOT_NULL(ts_params->session_priv_mpool,
12016 "session mempool allocation failed");
12019 ts_params->qp_conf.mp_session = ts_params->session_mpool;
12020 ts_params->qp_conf.mp_session_private =
12021 ts_params->session_priv_mpool;
12023 ret = rte_cryptodev_scheduler_slave_attach(sched_id,
12026 TEST_ASSERT(ret == 0,
12027 "Failed to attach device %u of pmd : %s", i,
12028 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
12030 aesni_ids[nb_devs_attached] = (uint8_t)i;
12032 nb_devs_attached++;
12039 test_scheduler_detach_slave_op(void)
12041 struct crypto_testsuite_params *ts_params = &testsuite_params;
12042 uint8_t sched_id = ts_params->valid_devs[0];
12046 for (i = 0; i < 2; i++) {
12047 ret = rte_cryptodev_scheduler_slave_detach(sched_id,
12049 TEST_ASSERT(ret == 0,
12050 "Failed to detach device %u", aesni_ids[i]);
12057 test_scheduler_mode_op(enum rte_cryptodev_scheduler_mode scheduler_mode)
12059 struct crypto_testsuite_params *ts_params = &testsuite_params;
12060 uint8_t sched_id = ts_params->valid_devs[0];
12062 return rte_cryptodev_scheduler_mode_set(sched_id,
12067 test_scheduler_mode_roundrobin_op(void)
12069 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_ROUNDROBIN) ==
12070 0, "Failed to set roundrobin mode");
12076 test_scheduler_mode_multicore_op(void)
12078 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_MULTICORE) ==
12079 0, "Failed to set multicore mode");
12085 test_scheduler_mode_failover_op(void)
12087 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_FAILOVER) ==
12088 0, "Failed to set failover mode");
12094 test_scheduler_mode_pkt_size_distr_op(void)
12096 TEST_ASSERT(test_scheduler_mode_op(CDEV_SCHED_MODE_PKT_SIZE_DISTR) ==
12097 0, "Failed to set pktsize mode");
12102 static struct unit_test_suite cryptodev_scheduler_testsuite = {
12103 .suite_name = "Crypto Device Scheduler Unit Test Suite",
12104 .setup = testsuite_setup,
12105 .teardown = testsuite_teardown,
12106 .unit_test_cases = {
12108 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12109 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_multicore_op),
12110 TEST_CASE_ST(ut_setup, ut_teardown,
12111 test_AES_chain_scheduler_all),
12112 TEST_CASE_ST(ut_setup, ut_teardown,
12113 test_AES_cipheronly_scheduler_all),
12114 TEST_CASE_ST(ut_setup, ut_teardown,
12115 test_authonly_scheduler_all),
12116 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12119 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12120 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_roundrobin_op),
12121 TEST_CASE_ST(ut_setup, ut_teardown,
12122 test_AES_chain_scheduler_all),
12123 TEST_CASE_ST(ut_setup, ut_teardown,
12124 test_AES_cipheronly_scheduler_all),
12125 TEST_CASE_ST(ut_setup, ut_teardown,
12126 test_authonly_scheduler_all),
12127 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12130 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12131 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_failover_op),
12132 TEST_CASE_ST(ut_setup, ut_teardown,
12133 test_AES_chain_scheduler_all),
12134 TEST_CASE_ST(ut_setup, ut_teardown,
12135 test_AES_cipheronly_scheduler_all),
12136 TEST_CASE_ST(ut_setup, ut_teardown,
12137 test_authonly_scheduler_all),
12138 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12141 TEST_CASE_ST(NULL, NULL, test_scheduler_attach_slave_op),
12142 TEST_CASE_ST(NULL, NULL, test_scheduler_mode_pkt_size_distr_op),
12143 TEST_CASE_ST(ut_setup, ut_teardown,
12144 test_AES_chain_scheduler_all),
12145 TEST_CASE_ST(ut_setup, ut_teardown,
12146 test_AES_cipheronly_scheduler_all),
12147 TEST_CASE_ST(ut_setup, ut_teardown,
12148 test_authonly_scheduler_all),
12149 TEST_CASE_ST(NULL, NULL, test_scheduler_detach_slave_op),
12151 TEST_CASES_END() /**< NULL terminate unit test array */
12155 #endif /* RTE_LIBRTE_PMD_CRYPTO_SCHEDULER */
12157 static struct unit_test_suite cryptodev_qat_testsuite = {
12158 .suite_name = "Crypto QAT Unit Test Suite",
12159 .setup = testsuite_setup,
12160 .teardown = testsuite_teardown,
12161 .unit_test_cases = {
12162 TEST_CASE_ST(ut_setup, ut_teardown,
12163 test_device_configure_invalid_dev_id),
12164 TEST_CASE_ST(ut_setup, ut_teardown,
12165 test_device_configure_invalid_queue_pair_ids),
12166 TEST_CASE_ST(ut_setup, ut_teardown,
12167 test_queue_pair_descriptor_setup),
12168 TEST_CASE_ST(ut_setup, ut_teardown,
12169 test_multi_session),
12171 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_qat_all),
12172 TEST_CASE_ST(ut_setup, ut_teardown,
12173 test_AES_cipheronly_qat_all),
12174 TEST_CASE_ST(ut_setup, ut_teardown, test_3DES_chain_qat_all),
12175 TEST_CASE_ST(ut_setup, ut_teardown,
12176 test_3DES_cipheronly_qat_all),
12177 TEST_CASE_ST(ut_setup, ut_teardown,
12178 test_DES_cipheronly_qat_all),
12179 TEST_CASE_ST(ut_setup, ut_teardown,
12180 test_AES_docsis_qat_all),
12181 TEST_CASE_ST(ut_setup, ut_teardown,
12182 test_DES_docsis_qat_all),
12183 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_qat_all),
12184 TEST_CASE_ST(ut_setup, ut_teardown, test_stats),
12186 /** AES CCM Authenticated Encryption 128 bits key */
12187 TEST_CASE_ST(ut_setup, ut_teardown,
12188 test_AES_CCM_authenticated_encryption_test_case_128_1),
12189 TEST_CASE_ST(ut_setup, ut_teardown,
12190 test_AES_CCM_authenticated_encryption_test_case_128_2),
12191 TEST_CASE_ST(ut_setup, ut_teardown,
12192 test_AES_CCM_authenticated_encryption_test_case_128_3),
12194 /** AES CCM Authenticated Decryption 128 bits key*/
12195 TEST_CASE_ST(ut_setup, ut_teardown,
12196 test_AES_CCM_authenticated_decryption_test_case_128_1),
12197 TEST_CASE_ST(ut_setup, ut_teardown,
12198 test_AES_CCM_authenticated_decryption_test_case_128_2),
12199 TEST_CASE_ST(ut_setup, ut_teardown,
12200 test_AES_CCM_authenticated_decryption_test_case_128_3),
12202 TEST_CASE_ST(ut_setup, ut_teardown,
12203 test_chacha20_poly1305_encrypt_test_case_rfc8439),
12204 TEST_CASE_ST(ut_setup, ut_teardown,
12205 test_chacha20_poly1305_decrypt_test_case_rfc8439),
12206 /** AES GCM Authenticated Encryption */
12207 TEST_CASE_ST(ut_setup, ut_teardown,
12208 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
12209 TEST_CASE_ST(ut_setup, ut_teardown,
12210 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
12211 TEST_CASE_ST(ut_setup, ut_teardown,
12212 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
12213 TEST_CASE_ST(ut_setup, ut_teardown,
12214 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
12215 TEST_CASE_ST(ut_setup, ut_teardown,
12216 test_AES_GCM_authenticated_encryption_test_case_1),
12217 TEST_CASE_ST(ut_setup, ut_teardown,
12218 test_AES_GCM_authenticated_encryption_test_case_2),
12219 TEST_CASE_ST(ut_setup, ut_teardown,
12220 test_AES_GCM_authenticated_encryption_test_case_3),
12221 TEST_CASE_ST(ut_setup, ut_teardown,
12222 test_AES_GCM_authenticated_encryption_test_case_4),
12223 TEST_CASE_ST(ut_setup, ut_teardown,
12224 test_AES_GCM_authenticated_encryption_test_case_5),
12225 TEST_CASE_ST(ut_setup, ut_teardown,
12226 test_AES_GCM_authenticated_encryption_test_case_6),
12227 TEST_CASE_ST(ut_setup, ut_teardown,
12228 test_AES_GCM_authenticated_encryption_test_case_7),
12229 TEST_CASE_ST(ut_setup, ut_teardown,
12230 test_AES_GCM_authenticated_encryption_test_case_8),
12232 /** AES GCM Authenticated Decryption */
12233 TEST_CASE_ST(ut_setup, ut_teardown,
12234 test_AES_GCM_authenticated_decryption_test_case_1),
12235 TEST_CASE_ST(ut_setup, ut_teardown,
12236 test_AES_GCM_authenticated_decryption_test_case_2),
12237 TEST_CASE_ST(ut_setup, ut_teardown,
12238 test_AES_GCM_authenticated_decryption_test_case_3),
12239 TEST_CASE_ST(ut_setup, ut_teardown,
12240 test_AES_GCM_authenticated_decryption_test_case_4),
12241 TEST_CASE_ST(ut_setup, ut_teardown,
12242 test_AES_GCM_authenticated_decryption_test_case_5),
12243 TEST_CASE_ST(ut_setup, ut_teardown,
12244 test_AES_GCM_authenticated_decryption_test_case_6),
12245 TEST_CASE_ST(ut_setup, ut_teardown,
12246 test_AES_GCM_authenticated_decryption_test_case_7),
12247 TEST_CASE_ST(ut_setup, ut_teardown,
12248 test_AES_GCM_authenticated_decryption_test_case_8),
12250 /** AES GCM Authenticated Encryption 192 bits key */
12251 TEST_CASE_ST(ut_setup, ut_teardown,
12252 test_AES_GCM_auth_encryption_test_case_192_1),
12253 TEST_CASE_ST(ut_setup, ut_teardown,
12254 test_AES_GCM_auth_encryption_test_case_192_2),
12255 TEST_CASE_ST(ut_setup, ut_teardown,
12256 test_AES_GCM_auth_encryption_test_case_192_3),
12257 TEST_CASE_ST(ut_setup, ut_teardown,
12258 test_AES_GCM_auth_encryption_test_case_192_4),
12259 TEST_CASE_ST(ut_setup, ut_teardown,
12260 test_AES_GCM_auth_encryption_test_case_192_5),
12261 TEST_CASE_ST(ut_setup, ut_teardown,
12262 test_AES_GCM_auth_encryption_test_case_192_6),
12263 TEST_CASE_ST(ut_setup, ut_teardown,
12264 test_AES_GCM_auth_encryption_test_case_192_7),
12266 /** AES GCM Authenticated Decryption 192 bits key */
12267 TEST_CASE_ST(ut_setup, ut_teardown,
12268 test_AES_GCM_auth_decryption_test_case_192_1),
12269 TEST_CASE_ST(ut_setup, ut_teardown,
12270 test_AES_GCM_auth_decryption_test_case_192_2),
12271 TEST_CASE_ST(ut_setup, ut_teardown,
12272 test_AES_GCM_auth_decryption_test_case_192_3),
12273 TEST_CASE_ST(ut_setup, ut_teardown,
12274 test_AES_GCM_auth_decryption_test_case_192_4),
12275 TEST_CASE_ST(ut_setup, ut_teardown,
12276 test_AES_GCM_auth_decryption_test_case_192_5),
12277 TEST_CASE_ST(ut_setup, ut_teardown,
12278 test_AES_GCM_auth_decryption_test_case_192_6),
12279 TEST_CASE_ST(ut_setup, ut_teardown,
12280 test_AES_GCM_auth_decryption_test_case_192_7),
12282 /** AES GCM Authenticated Encryption 256 bits key */
12283 TEST_CASE_ST(ut_setup, ut_teardown,
12284 test_AES_GCM_auth_encryption_test_case_256_1),
12285 TEST_CASE_ST(ut_setup, ut_teardown,
12286 test_AES_GCM_auth_encryption_test_case_256_2),
12287 TEST_CASE_ST(ut_setup, ut_teardown,
12288 test_AES_GCM_auth_encryption_test_case_256_3),
12289 TEST_CASE_ST(ut_setup, ut_teardown,
12290 test_AES_GCM_auth_encryption_test_case_256_4),
12291 TEST_CASE_ST(ut_setup, ut_teardown,
12292 test_AES_GCM_auth_encryption_test_case_256_5),
12293 TEST_CASE_ST(ut_setup, ut_teardown,
12294 test_AES_GCM_auth_encryption_test_case_256_6),
12295 TEST_CASE_ST(ut_setup, ut_teardown,
12296 test_AES_GCM_auth_encryption_test_case_256_7),
12298 /** AES GCM Authenticated Decryption 256 bits key */
12299 TEST_CASE_ST(ut_setup, ut_teardown,
12300 test_AES_GCM_auth_decryption_test_case_256_1),
12301 TEST_CASE_ST(ut_setup, ut_teardown,
12302 test_AES_GCM_auth_decryption_test_case_256_2),
12303 TEST_CASE_ST(ut_setup, ut_teardown,
12304 test_AES_GCM_auth_decryption_test_case_256_3),
12305 TEST_CASE_ST(ut_setup, ut_teardown,
12306 test_AES_GCM_auth_decryption_test_case_256_4),
12307 TEST_CASE_ST(ut_setup, ut_teardown,
12308 test_AES_GCM_auth_decryption_test_case_256_5),
12309 TEST_CASE_ST(ut_setup, ut_teardown,
12310 test_AES_GCM_auth_decryption_test_case_256_6),
12311 TEST_CASE_ST(ut_setup, ut_teardown,
12312 test_AES_GCM_auth_decryption_test_case_256_7),
12314 /** AES GMAC Authentication */
12315 TEST_CASE_ST(ut_setup, ut_teardown,
12316 test_AES_GMAC_authentication_test_case_1),
12317 TEST_CASE_ST(ut_setup, ut_teardown,
12318 test_AES_GMAC_authentication_verify_test_case_1),
12319 TEST_CASE_ST(ut_setup, ut_teardown,
12320 test_AES_GMAC_authentication_test_case_2),
12321 TEST_CASE_ST(ut_setup, ut_teardown,
12322 test_AES_GMAC_authentication_verify_test_case_2),
12323 TEST_CASE_ST(ut_setup, ut_teardown,
12324 test_AES_GMAC_authentication_test_case_3),
12325 TEST_CASE_ST(ut_setup, ut_teardown,
12326 test_AES_GMAC_authentication_verify_test_case_3),
12328 /** SNOW 3G encrypt only (UEA2) */
12329 TEST_CASE_ST(ut_setup, ut_teardown,
12330 test_snow3g_encryption_test_case_1),
12331 TEST_CASE_ST(ut_setup, ut_teardown,
12332 test_snow3g_encryption_test_case_2),
12333 TEST_CASE_ST(ut_setup, ut_teardown,
12334 test_snow3g_encryption_test_case_3),
12335 TEST_CASE_ST(ut_setup, ut_teardown,
12336 test_snow3g_encryption_test_case_4),
12337 TEST_CASE_ST(ut_setup, ut_teardown,
12338 test_snow3g_encryption_test_case_5),
12340 TEST_CASE_ST(ut_setup, ut_teardown,
12341 test_snow3g_encryption_test_case_1_oop),
12342 TEST_CASE_ST(ut_setup, ut_teardown,
12343 test_snow3g_decryption_test_case_1_oop),
12345 /** SNOW 3G generate auth, then encrypt (UEA2) */
12346 TEST_CASE_ST(ut_setup, ut_teardown,
12347 test_snow3g_auth_cipher_test_case_1),
12348 TEST_CASE_ST(ut_setup, ut_teardown,
12349 test_snow3g_auth_cipher_test_case_2),
12350 TEST_CASE_ST(ut_setup, ut_teardown,
12351 test_snow3g_auth_cipher_test_case_2_oop),
12352 TEST_CASE_ST(ut_setup, ut_teardown,
12353 test_snow3g_auth_cipher_part_digest_enc),
12354 TEST_CASE_ST(ut_setup, ut_teardown,
12355 test_snow3g_auth_cipher_part_digest_enc_oop),
12356 TEST_CASE_ST(ut_setup, ut_teardown,
12357 test_snow3g_auth_cipher_test_case_3_sgl),
12358 TEST_CASE_ST(ut_setup, ut_teardown,
12359 test_snow3g_auth_cipher_test_case_3_oop_sgl),
12360 TEST_CASE_ST(ut_setup, ut_teardown,
12361 test_snow3g_auth_cipher_part_digest_enc_sgl),
12362 TEST_CASE_ST(ut_setup, ut_teardown,
12363 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
12365 /** SNOW 3G decrypt (UEA2), then verify auth */
12366 TEST_CASE_ST(ut_setup, ut_teardown,
12367 test_snow3g_auth_cipher_verify_test_case_1),
12368 TEST_CASE_ST(ut_setup, ut_teardown,
12369 test_snow3g_auth_cipher_verify_test_case_2),
12370 TEST_CASE_ST(ut_setup, ut_teardown,
12371 test_snow3g_auth_cipher_verify_test_case_2_oop),
12372 TEST_CASE_ST(ut_setup, ut_teardown,
12373 test_snow3g_auth_cipher_verify_part_digest_enc),
12374 TEST_CASE_ST(ut_setup, ut_teardown,
12375 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
12376 TEST_CASE_ST(ut_setup, ut_teardown,
12377 test_snow3g_auth_cipher_verify_test_case_3_sgl),
12378 TEST_CASE_ST(ut_setup, ut_teardown,
12379 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
12380 TEST_CASE_ST(ut_setup, ut_teardown,
12381 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
12382 TEST_CASE_ST(ut_setup, ut_teardown,
12383 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
12385 /** SNOW 3G decrypt only (UEA2) */
12386 TEST_CASE_ST(ut_setup, ut_teardown,
12387 test_snow3g_decryption_test_case_1),
12388 TEST_CASE_ST(ut_setup, ut_teardown,
12389 test_snow3g_decryption_test_case_2),
12390 TEST_CASE_ST(ut_setup, ut_teardown,
12391 test_snow3g_decryption_test_case_3),
12392 TEST_CASE_ST(ut_setup, ut_teardown,
12393 test_snow3g_decryption_test_case_4),
12394 TEST_CASE_ST(ut_setup, ut_teardown,
12395 test_snow3g_decryption_test_case_5),
12396 TEST_CASE_ST(ut_setup, ut_teardown,
12397 test_snow3g_decryption_with_digest_test_case_1),
12398 TEST_CASE_ST(ut_setup, ut_teardown,
12399 test_snow3g_hash_generate_test_case_1),
12400 TEST_CASE_ST(ut_setup, ut_teardown,
12401 test_snow3g_hash_generate_test_case_2),
12402 TEST_CASE_ST(ut_setup, ut_teardown,
12403 test_snow3g_hash_generate_test_case_3),
12404 TEST_CASE_ST(ut_setup, ut_teardown,
12405 test_snow3g_hash_verify_test_case_1),
12406 TEST_CASE_ST(ut_setup, ut_teardown,
12407 test_snow3g_hash_verify_test_case_2),
12408 TEST_CASE_ST(ut_setup, ut_teardown,
12409 test_snow3g_hash_verify_test_case_3),
12410 TEST_CASE_ST(ut_setup, ut_teardown,
12411 test_snow3g_cipher_auth_test_case_1),
12412 TEST_CASE_ST(ut_setup, ut_teardown,
12413 test_snow3g_auth_cipher_with_digest_test_case_1),
12415 /** ZUC encrypt only (EEA3) */
12416 TEST_CASE_ST(ut_setup, ut_teardown,
12417 test_zuc_encryption_test_case_1),
12418 TEST_CASE_ST(ut_setup, ut_teardown,
12419 test_zuc_encryption_test_case_2),
12420 TEST_CASE_ST(ut_setup, ut_teardown,
12421 test_zuc_encryption_test_case_3),
12422 TEST_CASE_ST(ut_setup, ut_teardown,
12423 test_zuc_encryption_test_case_4),
12424 TEST_CASE_ST(ut_setup, ut_teardown,
12425 test_zuc_encryption_test_case_5),
12427 /** ZUC authenticate (EIA3) */
12428 TEST_CASE_ST(ut_setup, ut_teardown,
12429 test_zuc_hash_generate_test_case_6),
12430 TEST_CASE_ST(ut_setup, ut_teardown,
12431 test_zuc_hash_generate_test_case_7),
12432 TEST_CASE_ST(ut_setup, ut_teardown,
12433 test_zuc_hash_generate_test_case_8),
12435 /** ZUC alg-chain (EEA3/EIA3) */
12436 TEST_CASE_ST(ut_setup, ut_teardown,
12437 test_zuc_cipher_auth_test_case_1),
12438 TEST_CASE_ST(ut_setup, ut_teardown,
12439 test_zuc_cipher_auth_test_case_2),
12441 /** ZUC generate auth, then encrypt (EEA3) */
12442 TEST_CASE_ST(ut_setup, ut_teardown,
12443 test_zuc_auth_cipher_test_case_1),
12444 TEST_CASE_ST(ut_setup, ut_teardown,
12445 test_zuc_auth_cipher_test_case_1_oop),
12446 TEST_CASE_ST(ut_setup, ut_teardown,
12447 test_zuc_auth_cipher_test_case_1_sgl),
12448 TEST_CASE_ST(ut_setup, ut_teardown,
12449 test_zuc_auth_cipher_test_case_1_oop_sgl),
12451 /** ZUC decrypt (EEA3), then verify auth */
12452 TEST_CASE_ST(ut_setup, ut_teardown,
12453 test_zuc_auth_cipher_verify_test_case_1),
12454 TEST_CASE_ST(ut_setup, ut_teardown,
12455 test_zuc_auth_cipher_verify_test_case_1_oop),
12456 TEST_CASE_ST(ut_setup, ut_teardown,
12457 test_zuc_auth_cipher_verify_test_case_1_sgl),
12458 TEST_CASE_ST(ut_setup, ut_teardown,
12459 test_zuc_auth_cipher_verify_test_case_1_oop_sgl),
12461 /** HMAC_MD5 Authentication */
12462 TEST_CASE_ST(ut_setup, ut_teardown,
12463 test_MD5_HMAC_generate_case_1),
12464 TEST_CASE_ST(ut_setup, ut_teardown,
12465 test_MD5_HMAC_verify_case_1),
12466 TEST_CASE_ST(ut_setup, ut_teardown,
12467 test_MD5_HMAC_generate_case_2),
12468 TEST_CASE_ST(ut_setup, ut_teardown,
12469 test_MD5_HMAC_verify_case_2),
12471 /** NULL algo tests done in chain_all,
12472 * cipheronly and authonly suites
12475 /** KASUMI tests */
12476 TEST_CASE_ST(ut_setup, ut_teardown,
12477 test_kasumi_hash_generate_test_case_1),
12478 TEST_CASE_ST(ut_setup, ut_teardown,
12479 test_kasumi_hash_generate_test_case_2),
12480 TEST_CASE_ST(ut_setup, ut_teardown,
12481 test_kasumi_hash_generate_test_case_3),
12482 TEST_CASE_ST(ut_setup, ut_teardown,
12483 test_kasumi_hash_generate_test_case_4),
12484 TEST_CASE_ST(ut_setup, ut_teardown,
12485 test_kasumi_hash_generate_test_case_5),
12486 TEST_CASE_ST(ut_setup, ut_teardown,
12487 test_kasumi_hash_generate_test_case_6),
12489 TEST_CASE_ST(ut_setup, ut_teardown,
12490 test_kasumi_hash_verify_test_case_1),
12491 TEST_CASE_ST(ut_setup, ut_teardown,
12492 test_kasumi_hash_verify_test_case_2),
12493 TEST_CASE_ST(ut_setup, ut_teardown,
12494 test_kasumi_hash_verify_test_case_3),
12495 TEST_CASE_ST(ut_setup, ut_teardown,
12496 test_kasumi_hash_verify_test_case_4),
12497 TEST_CASE_ST(ut_setup, ut_teardown,
12498 test_kasumi_hash_verify_test_case_5),
12500 TEST_CASE_ST(ut_setup, ut_teardown,
12501 test_kasumi_encryption_test_case_1),
12502 TEST_CASE_ST(ut_setup, ut_teardown,
12503 test_kasumi_encryption_test_case_3),
12504 TEST_CASE_ST(ut_setup, ut_teardown,
12505 test_kasumi_cipher_auth_test_case_1),
12507 /** KASUMI generate auth, then encrypt (F8) */
12508 TEST_CASE_ST(ut_setup, ut_teardown,
12509 test_kasumi_auth_cipher_test_case_1),
12510 TEST_CASE_ST(ut_setup, ut_teardown,
12511 test_kasumi_auth_cipher_test_case_2),
12512 TEST_CASE_ST(ut_setup, ut_teardown,
12513 test_kasumi_auth_cipher_test_case_2_oop),
12514 TEST_CASE_ST(ut_setup, ut_teardown,
12515 test_kasumi_auth_cipher_test_case_2_sgl),
12516 TEST_CASE_ST(ut_setup, ut_teardown,
12517 test_kasumi_auth_cipher_test_case_2_oop_sgl),
12519 /** KASUMI decrypt (F8), then verify auth */
12520 TEST_CASE_ST(ut_setup, ut_teardown,
12521 test_kasumi_auth_cipher_verify_test_case_1),
12522 TEST_CASE_ST(ut_setup, ut_teardown,
12523 test_kasumi_auth_cipher_verify_test_case_2),
12524 TEST_CASE_ST(ut_setup, ut_teardown,
12525 test_kasumi_auth_cipher_verify_test_case_2_oop),
12526 TEST_CASE_ST(ut_setup, ut_teardown,
12527 test_kasumi_auth_cipher_verify_test_case_2_sgl),
12528 TEST_CASE_ST(ut_setup, ut_teardown,
12529 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
12531 /** Negative tests */
12532 TEST_CASE_ST(ut_setup, ut_teardown,
12533 authentication_verify_HMAC_SHA1_fail_data_corrupt),
12534 TEST_CASE_ST(ut_setup, ut_teardown,
12535 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
12536 TEST_CASE_ST(ut_setup, ut_teardown,
12537 test_AES_GCM_auth_encryption_fail_iv_corrupt),
12538 TEST_CASE_ST(ut_setup, ut_teardown,
12539 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
12540 TEST_CASE_ST(ut_setup, ut_teardown,
12541 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
12542 TEST_CASE_ST(ut_setup, ut_teardown,
12543 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
12544 TEST_CASE_ST(ut_setup, ut_teardown,
12545 test_AES_GCM_auth_encryption_fail_aad_corrupt),
12546 TEST_CASE_ST(ut_setup, ut_teardown,
12547 test_AES_GCM_auth_encryption_fail_tag_corrupt),
12548 TEST_CASE_ST(ut_setup, ut_teardown,
12549 test_AES_GCM_auth_decryption_fail_iv_corrupt),
12550 TEST_CASE_ST(ut_setup, ut_teardown,
12551 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
12552 TEST_CASE_ST(ut_setup, ut_teardown,
12553 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
12554 TEST_CASE_ST(ut_setup, ut_teardown,
12555 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
12556 TEST_CASE_ST(ut_setup, ut_teardown,
12557 test_AES_GCM_auth_decryption_fail_aad_corrupt),
12558 TEST_CASE_ST(ut_setup, ut_teardown,
12559 test_AES_GCM_auth_decryption_fail_tag_corrupt),
12560 TEST_CASE_ST(ut_setup, ut_teardown,
12561 authentication_verify_AES128_GMAC_fail_data_corrupt),
12562 TEST_CASE_ST(ut_setup, ut_teardown,
12563 authentication_verify_AES128_GMAC_fail_tag_corrupt),
12564 TEST_CASE_ST(ut_setup, ut_teardown,
12565 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
12566 TEST_CASE_ST(ut_setup, ut_teardown,
12567 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
12569 /** Mixed CIPHER + HASH algorithms */
12570 /** AUTH AES CMAC + CIPHER AES CTR */
12571 TEST_CASE_ST(ut_setup, ut_teardown,
12572 test_aes_cmac_aes_ctr_digest_enc_test_case_1),
12573 TEST_CASE_ST(ut_setup, ut_teardown,
12574 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12575 TEST_CASE_ST(ut_setup, ut_teardown,
12576 test_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12577 TEST_CASE_ST(ut_setup, ut_teardown,
12578 test_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12579 TEST_CASE_ST(ut_setup, ut_teardown,
12580 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1),
12581 TEST_CASE_ST(ut_setup, ut_teardown,
12582 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop),
12583 TEST_CASE_ST(ut_setup, ut_teardown,
12584 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_sgl),
12585 TEST_CASE_ST(ut_setup, ut_teardown,
12586 test_verify_aes_cmac_aes_ctr_digest_enc_test_case_1_oop_sgl),
12588 /** AUTH ZUC + CIPHER SNOW3G */
12589 TEST_CASE_ST(ut_setup, ut_teardown,
12590 test_auth_zuc_cipher_snow_test_case_1),
12591 TEST_CASE_ST(ut_setup, ut_teardown,
12592 test_verify_auth_zuc_cipher_snow_test_case_1),
12593 /** AUTH AES CMAC + CIPHER SNOW3G */
12594 TEST_CASE_ST(ut_setup, ut_teardown,
12595 test_auth_aes_cmac_cipher_snow_test_case_1),
12596 TEST_CASE_ST(ut_setup, ut_teardown,
12597 test_verify_auth_aes_cmac_cipher_snow_test_case_1),
12598 /** AUTH ZUC + CIPHER AES CTR */
12599 TEST_CASE_ST(ut_setup, ut_teardown,
12600 test_auth_zuc_cipher_aes_ctr_test_case_1),
12601 TEST_CASE_ST(ut_setup, ut_teardown,
12602 test_verify_auth_zuc_cipher_aes_ctr_test_case_1),
12603 /** AUTH SNOW3G + CIPHER AES CTR */
12604 TEST_CASE_ST(ut_setup, ut_teardown,
12605 test_auth_snow_cipher_aes_ctr_test_case_1),
12606 TEST_CASE_ST(ut_setup, ut_teardown,
12607 test_verify_auth_snow_cipher_aes_ctr_test_case_1),
12608 /** AUTH SNOW3G + CIPHER ZUC */
12609 TEST_CASE_ST(ut_setup, ut_teardown,
12610 test_auth_snow_cipher_zuc_test_case_1),
12611 TEST_CASE_ST(ut_setup, ut_teardown,
12612 test_verify_auth_snow_cipher_zuc_test_case_1),
12613 /** AUTH AES CMAC + CIPHER ZUC */
12614 TEST_CASE_ST(ut_setup, ut_teardown,
12615 test_auth_aes_cmac_cipher_zuc_test_case_1),
12616 TEST_CASE_ST(ut_setup, ut_teardown,
12617 test_verify_auth_aes_cmac_cipher_zuc_test_case_1),
12619 /** AUTH NULL + CIPHER SNOW3G */
12620 TEST_CASE_ST(ut_setup, ut_teardown,
12621 test_auth_null_cipher_snow_test_case_1),
12622 TEST_CASE_ST(ut_setup, ut_teardown,
12623 test_verify_auth_null_cipher_snow_test_case_1),
12624 /** AUTH NULL + CIPHER ZUC */
12625 TEST_CASE_ST(ut_setup, ut_teardown,
12626 test_auth_null_cipher_zuc_test_case_1),
12627 TEST_CASE_ST(ut_setup, ut_teardown,
12628 test_verify_auth_null_cipher_zuc_test_case_1),
12629 /** AUTH SNOW3G + CIPHER NULL */
12630 TEST_CASE_ST(ut_setup, ut_teardown,
12631 test_auth_snow_cipher_null_test_case_1),
12632 TEST_CASE_ST(ut_setup, ut_teardown,
12633 test_verify_auth_snow_cipher_null_test_case_1),
12634 /** AUTH ZUC + CIPHER NULL */
12635 TEST_CASE_ST(ut_setup, ut_teardown,
12636 test_auth_zuc_cipher_null_test_case_1),
12637 TEST_CASE_ST(ut_setup, ut_teardown,
12638 test_verify_auth_zuc_cipher_null_test_case_1),
12639 /** AUTH NULL + CIPHER AES CTR */
12640 TEST_CASE_ST(ut_setup, ut_teardown,
12641 test_auth_null_cipher_aes_ctr_test_case_1),
12642 TEST_CASE_ST(ut_setup, ut_teardown,
12643 test_verify_auth_null_cipher_aes_ctr_test_case_1),
12644 /** AUTH AES CMAC + CIPHER NULL */
12645 TEST_CASE_ST(ut_setup, ut_teardown,
12646 test_auth_aes_cmac_cipher_null_test_case_1),
12647 TEST_CASE_ST(ut_setup, ut_teardown,
12648 test_verify_auth_aes_cmac_cipher_null_test_case_1),
12650 TEST_CASES_END() /**< NULL terminate unit test array */
12654 static struct unit_test_suite cryptodev_virtio_testsuite = {
12655 .suite_name = "Crypto VIRTIO Unit Test Suite",
12656 .setup = testsuite_setup,
12657 .teardown = testsuite_teardown,
12658 .unit_test_cases = {
12659 TEST_CASE_ST(ut_setup, ut_teardown,
12660 test_AES_cipheronly_virtio_all),
12662 TEST_CASES_END() /**< NULL terminate unit test array */
12666 static struct unit_test_suite cryptodev_aesni_mb_testsuite = {
12667 .suite_name = "Crypto Device AESNI MB Unit Test Suite",
12668 .setup = testsuite_setup,
12669 .teardown = testsuite_teardown,
12670 .unit_test_cases = {
12671 #if IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0)
12672 TEST_CASE_ST(ut_setup, ut_teardown,
12673 test_AES_GCM_authenticated_encryption_test_case_1),
12674 TEST_CASE_ST(ut_setup, ut_teardown,
12675 test_AES_GCM_authenticated_encryption_test_case_2),
12676 TEST_CASE_ST(ut_setup, ut_teardown,
12677 test_AES_GCM_authenticated_encryption_test_case_3),
12678 TEST_CASE_ST(ut_setup, ut_teardown,
12679 test_AES_GCM_authenticated_encryption_test_case_4),
12680 TEST_CASE_ST(ut_setup, ut_teardown,
12681 test_AES_GCM_authenticated_encryption_test_case_5),
12682 TEST_CASE_ST(ut_setup, ut_teardown,
12683 test_AES_GCM_authenticated_encryption_test_case_6),
12684 TEST_CASE_ST(ut_setup, ut_teardown,
12685 test_AES_GCM_authenticated_encryption_test_case_7),
12687 /** AES GCM Authenticated Decryption */
12688 TEST_CASE_ST(ut_setup, ut_teardown,
12689 test_AES_GCM_authenticated_decryption_test_case_1),
12690 TEST_CASE_ST(ut_setup, ut_teardown,
12691 test_AES_GCM_authenticated_decryption_test_case_2),
12692 TEST_CASE_ST(ut_setup, ut_teardown,
12693 test_AES_GCM_authenticated_decryption_test_case_3),
12694 TEST_CASE_ST(ut_setup, ut_teardown,
12695 test_AES_GCM_authenticated_decryption_test_case_4),
12696 TEST_CASE_ST(ut_setup, ut_teardown,
12697 test_AES_GCM_authenticated_decryption_test_case_5),
12698 TEST_CASE_ST(ut_setup, ut_teardown,
12699 test_AES_GCM_authenticated_decryption_test_case_6),
12700 TEST_CASE_ST(ut_setup, ut_teardown,
12701 test_AES_GCM_authenticated_decryption_test_case_7),
12703 /** AES GCM Authenticated Encryption 192 bits key */
12704 TEST_CASE_ST(ut_setup, ut_teardown,
12705 test_AES_GCM_auth_encryption_test_case_192_1),
12706 TEST_CASE_ST(ut_setup, ut_teardown,
12707 test_AES_GCM_auth_encryption_test_case_192_2),
12708 TEST_CASE_ST(ut_setup, ut_teardown,
12709 test_AES_GCM_auth_encryption_test_case_192_3),
12710 TEST_CASE_ST(ut_setup, ut_teardown,
12711 test_AES_GCM_auth_encryption_test_case_192_4),
12712 TEST_CASE_ST(ut_setup, ut_teardown,
12713 test_AES_GCM_auth_encryption_test_case_192_5),
12714 TEST_CASE_ST(ut_setup, ut_teardown,
12715 test_AES_GCM_auth_encryption_test_case_192_6),
12716 TEST_CASE_ST(ut_setup, ut_teardown,
12717 test_AES_GCM_auth_encryption_test_case_192_7),
12719 /** AES GCM Authenticated Decryption 192 bits key */
12720 TEST_CASE_ST(ut_setup, ut_teardown,
12721 test_AES_GCM_auth_decryption_test_case_192_1),
12722 TEST_CASE_ST(ut_setup, ut_teardown,
12723 test_AES_GCM_auth_decryption_test_case_192_2),
12724 TEST_CASE_ST(ut_setup, ut_teardown,
12725 test_AES_GCM_auth_decryption_test_case_192_3),
12726 TEST_CASE_ST(ut_setup, ut_teardown,
12727 test_AES_GCM_auth_decryption_test_case_192_4),
12728 TEST_CASE_ST(ut_setup, ut_teardown,
12729 test_AES_GCM_auth_decryption_test_case_192_5),
12730 TEST_CASE_ST(ut_setup, ut_teardown,
12731 test_AES_GCM_auth_decryption_test_case_192_6),
12732 TEST_CASE_ST(ut_setup, ut_teardown,
12733 test_AES_GCM_auth_decryption_test_case_192_7),
12735 /** AES GCM Authenticated Encryption 256 bits key */
12736 TEST_CASE_ST(ut_setup, ut_teardown,
12737 test_AES_GCM_auth_encryption_test_case_256_1),
12738 TEST_CASE_ST(ut_setup, ut_teardown,
12739 test_AES_GCM_auth_encryption_test_case_256_2),
12740 TEST_CASE_ST(ut_setup, ut_teardown,
12741 test_AES_GCM_auth_encryption_test_case_256_3),
12742 TEST_CASE_ST(ut_setup, ut_teardown,
12743 test_AES_GCM_auth_encryption_test_case_256_4),
12744 TEST_CASE_ST(ut_setup, ut_teardown,
12745 test_AES_GCM_auth_encryption_test_case_256_5),
12746 TEST_CASE_ST(ut_setup, ut_teardown,
12747 test_AES_GCM_auth_encryption_test_case_256_6),
12748 TEST_CASE_ST(ut_setup, ut_teardown,
12749 test_AES_GCM_auth_encryption_test_case_256_7),
12751 /** AES GCM Authenticated Decryption 256 bits key */
12752 TEST_CASE_ST(ut_setup, ut_teardown,
12753 test_AES_GCM_auth_decryption_test_case_256_1),
12754 TEST_CASE_ST(ut_setup, ut_teardown,
12755 test_AES_GCM_auth_decryption_test_case_256_2),
12756 TEST_CASE_ST(ut_setup, ut_teardown,
12757 test_AES_GCM_auth_decryption_test_case_256_3),
12758 TEST_CASE_ST(ut_setup, ut_teardown,
12759 test_AES_GCM_auth_decryption_test_case_256_4),
12760 TEST_CASE_ST(ut_setup, ut_teardown,
12761 test_AES_GCM_auth_decryption_test_case_256_5),
12762 TEST_CASE_ST(ut_setup, ut_teardown,
12763 test_AES_GCM_auth_decryption_test_case_256_6),
12764 TEST_CASE_ST(ut_setup, ut_teardown,
12765 test_AES_GCM_auth_decryption_test_case_256_7),
12767 /** AES GCM Authenticated Encryption big aad size */
12768 TEST_CASE_ST(ut_setup, ut_teardown,
12769 test_AES_GCM_auth_encryption_test_case_aad_1),
12770 TEST_CASE_ST(ut_setup, ut_teardown,
12771 test_AES_GCM_auth_encryption_test_case_aad_2),
12773 /** AES GCM Authenticated Decryption big aad size */
12774 TEST_CASE_ST(ut_setup, ut_teardown,
12775 test_AES_GCM_auth_decryption_test_case_aad_1),
12776 TEST_CASE_ST(ut_setup, ut_teardown,
12777 test_AES_GCM_auth_decryption_test_case_aad_2),
12779 /** Session-less tests */
12780 TEST_CASE_ST(ut_setup, ut_teardown,
12781 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
12782 TEST_CASE_ST(ut_setup, ut_teardown,
12783 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
12785 /** AES GMAC Authentication */
12786 TEST_CASE_ST(ut_setup, ut_teardown,
12787 test_AES_GMAC_authentication_test_case_1),
12788 TEST_CASE_ST(ut_setup, ut_teardown,
12789 test_AES_GMAC_authentication_verify_test_case_1),
12790 TEST_CASE_ST(ut_setup, ut_teardown,
12791 test_AES_GMAC_authentication_test_case_2),
12792 TEST_CASE_ST(ut_setup, ut_teardown,
12793 test_AES_GMAC_authentication_verify_test_case_2),
12794 TEST_CASE_ST(ut_setup, ut_teardown,
12795 test_AES_GMAC_authentication_test_case_3),
12796 TEST_CASE_ST(ut_setup, ut_teardown,
12797 test_AES_GMAC_authentication_verify_test_case_3),
12798 #endif /* IMB_VERSION_NUM >= IMB_VERSION(0, 51, 0) */
12800 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_mb_all),
12801 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_cipheronly_mb_all),
12802 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_docsis_mb_all),
12803 TEST_CASE_ST(ut_setup, ut_teardown, test_authonly_mb_all),
12804 TEST_CASE_ST(ut_setup, ut_teardown,
12805 test_DES_cipheronly_mb_all),
12806 TEST_CASE_ST(ut_setup, ut_teardown,
12807 test_DES_docsis_mb_all),
12808 TEST_CASE_ST(ut_setup, ut_teardown,
12809 test_3DES_cipheronly_mb_all),
12810 TEST_CASE_ST(ut_setup, ut_teardown,
12811 test_AES_CCM_authenticated_encryption_test_case_128_1),
12812 TEST_CASE_ST(ut_setup, ut_teardown,
12813 test_AES_CCM_authenticated_decryption_test_case_128_1),
12814 TEST_CASE_ST(ut_setup, ut_teardown,
12815 test_AES_CCM_authenticated_encryption_test_case_128_2),
12816 TEST_CASE_ST(ut_setup, ut_teardown,
12817 test_AES_CCM_authenticated_decryption_test_case_128_2),
12818 TEST_CASE_ST(ut_setup, ut_teardown,
12819 test_AES_CCM_authenticated_encryption_test_case_128_3),
12820 TEST_CASE_ST(ut_setup, ut_teardown,
12821 test_AES_CCM_authenticated_decryption_test_case_128_3),
12823 TEST_CASES_END() /**< NULL terminate unit test array */
12827 static struct unit_test_suite cryptodev_openssl_testsuite = {
12828 .suite_name = "Crypto Device OPENSSL Unit Test Suite",
12829 .setup = testsuite_setup,
12830 .teardown = testsuite_teardown,
12831 .unit_test_cases = {
12832 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
12833 TEST_CASE_ST(ut_setup, ut_teardown,
12834 test_multi_session_random_usage),
12835 TEST_CASE_ST(ut_setup, ut_teardown,
12836 test_AES_chain_openssl_all),
12837 TEST_CASE_ST(ut_setup, ut_teardown,
12838 test_AES_cipheronly_openssl_all),
12839 TEST_CASE_ST(ut_setup, ut_teardown,
12840 test_3DES_chain_openssl_all),
12841 TEST_CASE_ST(ut_setup, ut_teardown,
12842 test_3DES_cipheronly_openssl_all),
12843 TEST_CASE_ST(ut_setup, ut_teardown,
12844 test_DES_cipheronly_openssl_all),
12845 TEST_CASE_ST(ut_setup, ut_teardown,
12846 test_DES_docsis_openssl_all),
12847 TEST_CASE_ST(ut_setup, ut_teardown,
12848 test_authonly_openssl_all),
12850 /** AES GCM Authenticated Encryption */
12851 TEST_CASE_ST(ut_setup, ut_teardown,
12852 test_AES_GCM_authenticated_encryption_test_case_1),
12853 TEST_CASE_ST(ut_setup, ut_teardown,
12854 test_AES_GCM_authenticated_encryption_test_case_2),
12855 TEST_CASE_ST(ut_setup, ut_teardown,
12856 test_AES_GCM_authenticated_encryption_test_case_3),
12857 TEST_CASE_ST(ut_setup, ut_teardown,
12858 test_AES_GCM_authenticated_encryption_test_case_4),
12859 TEST_CASE_ST(ut_setup, ut_teardown,
12860 test_AES_GCM_authenticated_encryption_test_case_5),
12861 TEST_CASE_ST(ut_setup, ut_teardown,
12862 test_AES_GCM_authenticated_encryption_test_case_6),
12863 TEST_CASE_ST(ut_setup, ut_teardown,
12864 test_AES_GCM_authenticated_encryption_test_case_7),
12866 /** AES GCM Authenticated Decryption */
12867 TEST_CASE_ST(ut_setup, ut_teardown,
12868 test_AES_GCM_authenticated_decryption_test_case_1),
12869 TEST_CASE_ST(ut_setup, ut_teardown,
12870 test_AES_GCM_authenticated_decryption_test_case_2),
12871 TEST_CASE_ST(ut_setup, ut_teardown,
12872 test_AES_GCM_authenticated_decryption_test_case_3),
12873 TEST_CASE_ST(ut_setup, ut_teardown,
12874 test_AES_GCM_authenticated_decryption_test_case_4),
12875 TEST_CASE_ST(ut_setup, ut_teardown,
12876 test_AES_GCM_authenticated_decryption_test_case_5),
12877 TEST_CASE_ST(ut_setup, ut_teardown,
12878 test_AES_GCM_authenticated_decryption_test_case_6),
12879 TEST_CASE_ST(ut_setup, ut_teardown,
12880 test_AES_GCM_authenticated_decryption_test_case_7),
12883 /** AES GCM Authenticated Encryption 192 bits key */
12884 TEST_CASE_ST(ut_setup, ut_teardown,
12885 test_AES_GCM_auth_encryption_test_case_192_1),
12886 TEST_CASE_ST(ut_setup, ut_teardown,
12887 test_AES_GCM_auth_encryption_test_case_192_2),
12888 TEST_CASE_ST(ut_setup, ut_teardown,
12889 test_AES_GCM_auth_encryption_test_case_192_3),
12890 TEST_CASE_ST(ut_setup, ut_teardown,
12891 test_AES_GCM_auth_encryption_test_case_192_4),
12892 TEST_CASE_ST(ut_setup, ut_teardown,
12893 test_AES_GCM_auth_encryption_test_case_192_5),
12894 TEST_CASE_ST(ut_setup, ut_teardown,
12895 test_AES_GCM_auth_encryption_test_case_192_6),
12896 TEST_CASE_ST(ut_setup, ut_teardown,
12897 test_AES_GCM_auth_encryption_test_case_192_7),
12899 /** AES GCM Authenticated Decryption 192 bits key */
12900 TEST_CASE_ST(ut_setup, ut_teardown,
12901 test_AES_GCM_auth_decryption_test_case_192_1),
12902 TEST_CASE_ST(ut_setup, ut_teardown,
12903 test_AES_GCM_auth_decryption_test_case_192_2),
12904 TEST_CASE_ST(ut_setup, ut_teardown,
12905 test_AES_GCM_auth_decryption_test_case_192_3),
12906 TEST_CASE_ST(ut_setup, ut_teardown,
12907 test_AES_GCM_auth_decryption_test_case_192_4),
12908 TEST_CASE_ST(ut_setup, ut_teardown,
12909 test_AES_GCM_auth_decryption_test_case_192_5),
12910 TEST_CASE_ST(ut_setup, ut_teardown,
12911 test_AES_GCM_auth_decryption_test_case_192_6),
12912 TEST_CASE_ST(ut_setup, ut_teardown,
12913 test_AES_GCM_auth_decryption_test_case_192_7),
12915 /** AES GCM Authenticated Encryption 256 bits key */
12916 TEST_CASE_ST(ut_setup, ut_teardown,
12917 test_AES_GCM_auth_encryption_test_case_256_1),
12918 TEST_CASE_ST(ut_setup, ut_teardown,
12919 test_AES_GCM_auth_encryption_test_case_256_2),
12920 TEST_CASE_ST(ut_setup, ut_teardown,
12921 test_AES_GCM_auth_encryption_test_case_256_3),
12922 TEST_CASE_ST(ut_setup, ut_teardown,
12923 test_AES_GCM_auth_encryption_test_case_256_4),
12924 TEST_CASE_ST(ut_setup, ut_teardown,
12925 test_AES_GCM_auth_encryption_test_case_256_5),
12926 TEST_CASE_ST(ut_setup, ut_teardown,
12927 test_AES_GCM_auth_encryption_test_case_256_6),
12928 TEST_CASE_ST(ut_setup, ut_teardown,
12929 test_AES_GCM_auth_encryption_test_case_256_7),
12931 /** AES GCM Authenticated Decryption 256 bits key */
12932 TEST_CASE_ST(ut_setup, ut_teardown,
12933 test_AES_GCM_auth_decryption_test_case_256_1),
12934 TEST_CASE_ST(ut_setup, ut_teardown,
12935 test_AES_GCM_auth_decryption_test_case_256_2),
12936 TEST_CASE_ST(ut_setup, ut_teardown,
12937 test_AES_GCM_auth_decryption_test_case_256_3),
12938 TEST_CASE_ST(ut_setup, ut_teardown,
12939 test_AES_GCM_auth_decryption_test_case_256_4),
12940 TEST_CASE_ST(ut_setup, ut_teardown,
12941 test_AES_GCM_auth_decryption_test_case_256_5),
12942 TEST_CASE_ST(ut_setup, ut_teardown,
12943 test_AES_GCM_auth_decryption_test_case_256_6),
12944 TEST_CASE_ST(ut_setup, ut_teardown,
12945 test_AES_GCM_auth_decryption_test_case_256_7),
12947 /** AES GMAC Authentication */
12948 TEST_CASE_ST(ut_setup, ut_teardown,
12949 test_AES_GMAC_authentication_test_case_1),
12950 TEST_CASE_ST(ut_setup, ut_teardown,
12951 test_AES_GMAC_authentication_verify_test_case_1),
12952 TEST_CASE_ST(ut_setup, ut_teardown,
12953 test_AES_GMAC_authentication_test_case_2),
12954 TEST_CASE_ST(ut_setup, ut_teardown,
12955 test_AES_GMAC_authentication_verify_test_case_2),
12956 TEST_CASE_ST(ut_setup, ut_teardown,
12957 test_AES_GMAC_authentication_test_case_3),
12958 TEST_CASE_ST(ut_setup, ut_teardown,
12959 test_AES_GMAC_authentication_verify_test_case_3),
12960 TEST_CASE_ST(ut_setup, ut_teardown,
12961 test_AES_GMAC_authentication_test_case_4),
12962 TEST_CASE_ST(ut_setup, ut_teardown,
12963 test_AES_GMAC_authentication_verify_test_case_4),
12965 /** AES CCM Authenticated Encryption 128 bits key */
12966 TEST_CASE_ST(ut_setup, ut_teardown,
12967 test_AES_CCM_authenticated_encryption_test_case_128_1),
12968 TEST_CASE_ST(ut_setup, ut_teardown,
12969 test_AES_CCM_authenticated_encryption_test_case_128_2),
12970 TEST_CASE_ST(ut_setup, ut_teardown,
12971 test_AES_CCM_authenticated_encryption_test_case_128_3),
12973 /** AES CCM Authenticated Decryption 128 bits key*/
12974 TEST_CASE_ST(ut_setup, ut_teardown,
12975 test_AES_CCM_authenticated_decryption_test_case_128_1),
12976 TEST_CASE_ST(ut_setup, ut_teardown,
12977 test_AES_CCM_authenticated_decryption_test_case_128_2),
12978 TEST_CASE_ST(ut_setup, ut_teardown,
12979 test_AES_CCM_authenticated_decryption_test_case_128_3),
12981 /** AES CCM Authenticated Encryption 192 bits key */
12982 TEST_CASE_ST(ut_setup, ut_teardown,
12983 test_AES_CCM_authenticated_encryption_test_case_192_1),
12984 TEST_CASE_ST(ut_setup, ut_teardown,
12985 test_AES_CCM_authenticated_encryption_test_case_192_2),
12986 TEST_CASE_ST(ut_setup, ut_teardown,
12987 test_AES_CCM_authenticated_encryption_test_case_192_3),
12989 /** AES CCM Authenticated Decryption 192 bits key*/
12990 TEST_CASE_ST(ut_setup, ut_teardown,
12991 test_AES_CCM_authenticated_decryption_test_case_192_1),
12992 TEST_CASE_ST(ut_setup, ut_teardown,
12993 test_AES_CCM_authenticated_decryption_test_case_192_2),
12994 TEST_CASE_ST(ut_setup, ut_teardown,
12995 test_AES_CCM_authenticated_decryption_test_case_192_3),
12997 /** AES CCM Authenticated Encryption 256 bits key */
12998 TEST_CASE_ST(ut_setup, ut_teardown,
12999 test_AES_CCM_authenticated_encryption_test_case_256_1),
13000 TEST_CASE_ST(ut_setup, ut_teardown,
13001 test_AES_CCM_authenticated_encryption_test_case_256_2),
13002 TEST_CASE_ST(ut_setup, ut_teardown,
13003 test_AES_CCM_authenticated_encryption_test_case_256_3),
13005 /** AES CCM Authenticated Decryption 256 bits key*/
13006 TEST_CASE_ST(ut_setup, ut_teardown,
13007 test_AES_CCM_authenticated_decryption_test_case_256_1),
13008 TEST_CASE_ST(ut_setup, ut_teardown,
13009 test_AES_CCM_authenticated_decryption_test_case_256_2),
13010 TEST_CASE_ST(ut_setup, ut_teardown,
13011 test_AES_CCM_authenticated_decryption_test_case_256_3),
13013 /** Scatter-Gather */
13014 TEST_CASE_ST(ut_setup, ut_teardown,
13015 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13017 /** Negative tests */
13018 TEST_CASE_ST(ut_setup, ut_teardown,
13019 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13020 TEST_CASE_ST(ut_setup, ut_teardown,
13021 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13022 TEST_CASE_ST(ut_setup, ut_teardown,
13023 authentication_verify_AES128_GMAC_fail_data_corrupt),
13024 TEST_CASE_ST(ut_setup, ut_teardown,
13025 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13026 TEST_CASE_ST(ut_setup, ut_teardown,
13027 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13028 TEST_CASE_ST(ut_setup, ut_teardown,
13029 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13032 TEST_CASE_ST(ut_setup, ut_teardown,
13033 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13035 TEST_CASE_ST(ut_setup, ut_teardown,
13036 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13038 TEST_CASES_END() /**< NULL terminate unit test array */
13042 static struct unit_test_suite cryptodev_aesni_gcm_testsuite = {
13043 .suite_name = "Crypto Device AESNI GCM Unit Test Suite",
13044 .setup = testsuite_setup,
13045 .teardown = testsuite_teardown,
13046 .unit_test_cases = {
13047 /** AES GCM Authenticated Encryption */
13048 TEST_CASE_ST(ut_setup, ut_teardown,
13049 test_AES_GCM_authenticated_encryption_test_case_1),
13050 TEST_CASE_ST(ut_setup, ut_teardown,
13051 test_AES_GCM_authenticated_encryption_test_case_2),
13052 TEST_CASE_ST(ut_setup, ut_teardown,
13053 test_AES_GCM_authenticated_encryption_test_case_3),
13054 TEST_CASE_ST(ut_setup, ut_teardown,
13055 test_AES_GCM_authenticated_encryption_test_case_4),
13056 TEST_CASE_ST(ut_setup, ut_teardown,
13057 test_AES_GCM_authenticated_encryption_test_case_5),
13058 TEST_CASE_ST(ut_setup, ut_teardown,
13059 test_AES_GCM_authenticated_encryption_test_case_6),
13060 TEST_CASE_ST(ut_setup, ut_teardown,
13061 test_AES_GCM_authenticated_encryption_test_case_7),
13063 /** AES GCM Authenticated Decryption */
13064 TEST_CASE_ST(ut_setup, ut_teardown,
13065 test_AES_GCM_authenticated_decryption_test_case_1),
13066 TEST_CASE_ST(ut_setup, ut_teardown,
13067 test_AES_GCM_authenticated_decryption_test_case_2),
13068 TEST_CASE_ST(ut_setup, ut_teardown,
13069 test_AES_GCM_authenticated_decryption_test_case_3),
13070 TEST_CASE_ST(ut_setup, ut_teardown,
13071 test_AES_GCM_authenticated_decryption_test_case_4),
13072 TEST_CASE_ST(ut_setup, ut_teardown,
13073 test_AES_GCM_authenticated_decryption_test_case_5),
13074 TEST_CASE_ST(ut_setup, ut_teardown,
13075 test_AES_GCM_authenticated_decryption_test_case_6),
13076 TEST_CASE_ST(ut_setup, ut_teardown,
13077 test_AES_GCM_authenticated_decryption_test_case_7),
13079 /** AES GCM Authenticated Encryption 192 bits key */
13080 TEST_CASE_ST(ut_setup, ut_teardown,
13081 test_AES_GCM_auth_encryption_test_case_192_1),
13082 TEST_CASE_ST(ut_setup, ut_teardown,
13083 test_AES_GCM_auth_encryption_test_case_192_2),
13084 TEST_CASE_ST(ut_setup, ut_teardown,
13085 test_AES_GCM_auth_encryption_test_case_192_3),
13086 TEST_CASE_ST(ut_setup, ut_teardown,
13087 test_AES_GCM_auth_encryption_test_case_192_4),
13088 TEST_CASE_ST(ut_setup, ut_teardown,
13089 test_AES_GCM_auth_encryption_test_case_192_5),
13090 TEST_CASE_ST(ut_setup, ut_teardown,
13091 test_AES_GCM_auth_encryption_test_case_192_6),
13092 TEST_CASE_ST(ut_setup, ut_teardown,
13093 test_AES_GCM_auth_encryption_test_case_192_7),
13095 /** AES GCM Authenticated Decryption 192 bits key */
13096 TEST_CASE_ST(ut_setup, ut_teardown,
13097 test_AES_GCM_auth_decryption_test_case_192_1),
13098 TEST_CASE_ST(ut_setup, ut_teardown,
13099 test_AES_GCM_auth_decryption_test_case_192_2),
13100 TEST_CASE_ST(ut_setup, ut_teardown,
13101 test_AES_GCM_auth_decryption_test_case_192_3),
13102 TEST_CASE_ST(ut_setup, ut_teardown,
13103 test_AES_GCM_auth_decryption_test_case_192_4),
13104 TEST_CASE_ST(ut_setup, ut_teardown,
13105 test_AES_GCM_auth_decryption_test_case_192_5),
13106 TEST_CASE_ST(ut_setup, ut_teardown,
13107 test_AES_GCM_auth_decryption_test_case_192_6),
13108 TEST_CASE_ST(ut_setup, ut_teardown,
13109 test_AES_GCM_auth_decryption_test_case_192_7),
13111 /** AES GCM Authenticated Encryption 256 bits key */
13112 TEST_CASE_ST(ut_setup, ut_teardown,
13113 test_AES_GCM_auth_encryption_test_case_256_1),
13114 TEST_CASE_ST(ut_setup, ut_teardown,
13115 test_AES_GCM_auth_encryption_test_case_256_2),
13116 TEST_CASE_ST(ut_setup, ut_teardown,
13117 test_AES_GCM_auth_encryption_test_case_256_3),
13118 TEST_CASE_ST(ut_setup, ut_teardown,
13119 test_AES_GCM_auth_encryption_test_case_256_4),
13120 TEST_CASE_ST(ut_setup, ut_teardown,
13121 test_AES_GCM_auth_encryption_test_case_256_5),
13122 TEST_CASE_ST(ut_setup, ut_teardown,
13123 test_AES_GCM_auth_encryption_test_case_256_6),
13124 TEST_CASE_ST(ut_setup, ut_teardown,
13125 test_AES_GCM_auth_encryption_test_case_256_7),
13127 /** AES GCM Authenticated Decryption 256 bits key */
13128 TEST_CASE_ST(ut_setup, ut_teardown,
13129 test_AES_GCM_auth_decryption_test_case_256_1),
13130 TEST_CASE_ST(ut_setup, ut_teardown,
13131 test_AES_GCM_auth_decryption_test_case_256_2),
13132 TEST_CASE_ST(ut_setup, ut_teardown,
13133 test_AES_GCM_auth_decryption_test_case_256_3),
13134 TEST_CASE_ST(ut_setup, ut_teardown,
13135 test_AES_GCM_auth_decryption_test_case_256_4),
13136 TEST_CASE_ST(ut_setup, ut_teardown,
13137 test_AES_GCM_auth_decryption_test_case_256_5),
13138 TEST_CASE_ST(ut_setup, ut_teardown,
13139 test_AES_GCM_auth_decryption_test_case_256_6),
13140 TEST_CASE_ST(ut_setup, ut_teardown,
13141 test_AES_GCM_auth_decryption_test_case_256_7),
13143 /** AES GCM Authenticated Encryption big aad size */
13144 TEST_CASE_ST(ut_setup, ut_teardown,
13145 test_AES_GCM_auth_encryption_test_case_aad_1),
13146 TEST_CASE_ST(ut_setup, ut_teardown,
13147 test_AES_GCM_auth_encryption_test_case_aad_2),
13149 /** AES GCM Authenticated Decryption big aad size */
13150 TEST_CASE_ST(ut_setup, ut_teardown,
13151 test_AES_GCM_auth_decryption_test_case_aad_1),
13152 TEST_CASE_ST(ut_setup, ut_teardown,
13153 test_AES_GCM_auth_decryption_test_case_aad_2),
13155 /** AES GMAC Authentication */
13156 TEST_CASE_ST(ut_setup, ut_teardown,
13157 test_AES_GMAC_authentication_test_case_1),
13158 TEST_CASE_ST(ut_setup, ut_teardown,
13159 test_AES_GMAC_authentication_verify_test_case_1),
13160 TEST_CASE_ST(ut_setup, ut_teardown,
13161 test_AES_GMAC_authentication_test_case_3),
13162 TEST_CASE_ST(ut_setup, ut_teardown,
13163 test_AES_GMAC_authentication_verify_test_case_3),
13164 TEST_CASE_ST(ut_setup, ut_teardown,
13165 test_AES_GMAC_authentication_test_case_4),
13166 TEST_CASE_ST(ut_setup, ut_teardown,
13167 test_AES_GMAC_authentication_verify_test_case_4),
13169 /** Negative tests */
13170 TEST_CASE_ST(ut_setup, ut_teardown,
13171 authentication_verify_AES128_GMAC_fail_data_corrupt),
13172 TEST_CASE_ST(ut_setup, ut_teardown,
13173 authentication_verify_AES128_GMAC_fail_tag_corrupt),
13175 /** Out of place tests */
13176 TEST_CASE_ST(ut_setup, ut_teardown,
13177 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13178 TEST_CASE_ST(ut_setup, ut_teardown,
13179 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13181 /** Session-less tests */
13182 TEST_CASE_ST(ut_setup, ut_teardown,
13183 test_AES_GCM_authenticated_encryption_sessionless_test_case_1),
13184 TEST_CASE_ST(ut_setup, ut_teardown,
13185 test_AES_GCM_authenticated_decryption_sessionless_test_case_1),
13187 /** Scatter-Gather */
13188 TEST_CASE_ST(ut_setup, ut_teardown,
13189 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13190 TEST_CASE_ST(ut_setup, ut_teardown,
13191 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13193 TEST_CASES_END() /**< NULL terminate unit test array */
13197 static struct unit_test_suite cryptodev_sw_kasumi_testsuite = {
13198 .suite_name = "Crypto Device SW KASUMI Unit Test Suite",
13199 .setup = testsuite_setup,
13200 .teardown = testsuite_teardown,
13201 .unit_test_cases = {
13202 /** KASUMI encrypt only (UEA1) */
13203 TEST_CASE_ST(ut_setup, ut_teardown,
13204 test_kasumi_encryption_test_case_1),
13205 TEST_CASE_ST(ut_setup, ut_teardown,
13206 test_kasumi_encryption_test_case_1_sgl),
13207 TEST_CASE_ST(ut_setup, ut_teardown,
13208 test_kasumi_encryption_test_case_2),
13209 TEST_CASE_ST(ut_setup, ut_teardown,
13210 test_kasumi_encryption_test_case_3),
13211 TEST_CASE_ST(ut_setup, ut_teardown,
13212 test_kasumi_encryption_test_case_4),
13213 TEST_CASE_ST(ut_setup, ut_teardown,
13214 test_kasumi_encryption_test_case_5),
13215 /** KASUMI decrypt only (UEA1) */
13216 TEST_CASE_ST(ut_setup, ut_teardown,
13217 test_kasumi_decryption_test_case_1),
13218 TEST_CASE_ST(ut_setup, ut_teardown,
13219 test_kasumi_decryption_test_case_2),
13220 TEST_CASE_ST(ut_setup, ut_teardown,
13221 test_kasumi_decryption_test_case_3),
13222 TEST_CASE_ST(ut_setup, ut_teardown,
13223 test_kasumi_decryption_test_case_4),
13224 TEST_CASE_ST(ut_setup, ut_teardown,
13225 test_kasumi_decryption_test_case_5),
13227 TEST_CASE_ST(ut_setup, ut_teardown,
13228 test_kasumi_encryption_test_case_1_oop),
13229 TEST_CASE_ST(ut_setup, ut_teardown,
13230 test_kasumi_encryption_test_case_1_oop_sgl),
13233 TEST_CASE_ST(ut_setup, ut_teardown,
13234 test_kasumi_decryption_test_case_1_oop),
13236 /** KASUMI hash only (UIA1) */
13237 TEST_CASE_ST(ut_setup, ut_teardown,
13238 test_kasumi_hash_generate_test_case_1),
13239 TEST_CASE_ST(ut_setup, ut_teardown,
13240 test_kasumi_hash_generate_test_case_2),
13241 TEST_CASE_ST(ut_setup, ut_teardown,
13242 test_kasumi_hash_generate_test_case_3),
13243 TEST_CASE_ST(ut_setup, ut_teardown,
13244 test_kasumi_hash_generate_test_case_4),
13245 TEST_CASE_ST(ut_setup, ut_teardown,
13246 test_kasumi_hash_generate_test_case_5),
13247 TEST_CASE_ST(ut_setup, ut_teardown,
13248 test_kasumi_hash_generate_test_case_6),
13249 TEST_CASE_ST(ut_setup, ut_teardown,
13250 test_kasumi_hash_verify_test_case_1),
13251 TEST_CASE_ST(ut_setup, ut_teardown,
13252 test_kasumi_hash_verify_test_case_2),
13253 TEST_CASE_ST(ut_setup, ut_teardown,
13254 test_kasumi_hash_verify_test_case_3),
13255 TEST_CASE_ST(ut_setup, ut_teardown,
13256 test_kasumi_hash_verify_test_case_4),
13257 TEST_CASE_ST(ut_setup, ut_teardown,
13258 test_kasumi_hash_verify_test_case_5),
13259 TEST_CASE_ST(ut_setup, ut_teardown,
13260 test_kasumi_cipher_auth_test_case_1),
13262 /** KASUMI generate auth, then encrypt (F8) */
13263 TEST_CASE_ST(ut_setup, ut_teardown,
13264 test_kasumi_auth_cipher_test_case_1),
13265 TEST_CASE_ST(ut_setup, ut_teardown,
13266 test_kasumi_auth_cipher_test_case_2),
13267 TEST_CASE_ST(ut_setup, ut_teardown,
13268 test_kasumi_auth_cipher_test_case_2_oop),
13269 TEST_CASE_ST(ut_setup, ut_teardown,
13270 test_kasumi_auth_cipher_test_case_2_sgl),
13271 TEST_CASE_ST(ut_setup, ut_teardown,
13272 test_kasumi_auth_cipher_test_case_2_oop_sgl),
13274 /** KASUMI decrypt (F8), then verify auth */
13275 TEST_CASE_ST(ut_setup, ut_teardown,
13276 test_kasumi_auth_cipher_verify_test_case_1),
13277 TEST_CASE_ST(ut_setup, ut_teardown,
13278 test_kasumi_auth_cipher_verify_test_case_2),
13279 TEST_CASE_ST(ut_setup, ut_teardown,
13280 test_kasumi_auth_cipher_verify_test_case_2_oop),
13281 TEST_CASE_ST(ut_setup, ut_teardown,
13282 test_kasumi_auth_cipher_verify_test_case_2_sgl),
13283 TEST_CASE_ST(ut_setup, ut_teardown,
13284 test_kasumi_auth_cipher_verify_test_case_2_oop_sgl),
13285 TEST_CASES_END() /**< NULL terminate unit test array */
13288 static struct unit_test_suite cryptodev_sw_snow3g_testsuite = {
13289 .suite_name = "Crypto Device SW SNOW 3G Unit Test Suite",
13290 .setup = testsuite_setup,
13291 .teardown = testsuite_teardown,
13292 .unit_test_cases = {
13293 /** SNOW 3G encrypt only (UEA2) */
13294 TEST_CASE_ST(ut_setup, ut_teardown,
13295 test_snow3g_encryption_test_case_1),
13296 TEST_CASE_ST(ut_setup, ut_teardown,
13297 test_snow3g_encryption_test_case_2),
13298 TEST_CASE_ST(ut_setup, ut_teardown,
13299 test_snow3g_encryption_test_case_3),
13300 TEST_CASE_ST(ut_setup, ut_teardown,
13301 test_snow3g_encryption_test_case_4),
13302 TEST_CASE_ST(ut_setup, ut_teardown,
13303 test_snow3g_encryption_test_case_5),
13304 TEST_CASE_ST(ut_setup, ut_teardown,
13305 test_snow3g_auth_cipher_with_digest_test_case_1),
13307 TEST_CASE_ST(ut_setup, ut_teardown,
13308 test_snow3g_encryption_test_case_1_oop),
13309 TEST_CASE_ST(ut_setup, ut_teardown,
13310 test_snow3g_encryption_test_case_1_oop_sgl),
13311 TEST_CASE_ST(ut_setup, ut_teardown,
13312 test_snow3g_decryption_test_case_1_oop),
13314 TEST_CASE_ST(ut_setup, ut_teardown,
13315 test_snow3g_encryption_test_case_1_offset_oop),
13317 /** SNOW 3G decrypt only (UEA2) */
13318 TEST_CASE_ST(ut_setup, ut_teardown,
13319 test_snow3g_decryption_test_case_1),
13320 TEST_CASE_ST(ut_setup, ut_teardown,
13321 test_snow3g_decryption_test_case_2),
13322 TEST_CASE_ST(ut_setup, ut_teardown,
13323 test_snow3g_decryption_test_case_3),
13324 TEST_CASE_ST(ut_setup, ut_teardown,
13325 test_snow3g_decryption_test_case_4),
13326 TEST_CASE_ST(ut_setup, ut_teardown,
13327 test_snow3g_decryption_test_case_5),
13328 TEST_CASE_ST(ut_setup, ut_teardown,
13329 test_snow3g_decryption_with_digest_test_case_1),
13330 TEST_CASE_ST(ut_setup, ut_teardown,
13331 test_snow3g_hash_generate_test_case_1),
13332 TEST_CASE_ST(ut_setup, ut_teardown,
13333 test_snow3g_hash_generate_test_case_2),
13334 TEST_CASE_ST(ut_setup, ut_teardown,
13335 test_snow3g_hash_generate_test_case_3),
13336 /* Tests with buffers which length is not byte-aligned */
13337 TEST_CASE_ST(ut_setup, ut_teardown,
13338 test_snow3g_hash_generate_test_case_4),
13339 TEST_CASE_ST(ut_setup, ut_teardown,
13340 test_snow3g_hash_generate_test_case_5),
13341 TEST_CASE_ST(ut_setup, ut_teardown,
13342 test_snow3g_hash_generate_test_case_6),
13343 TEST_CASE_ST(ut_setup, ut_teardown,
13344 test_snow3g_hash_verify_test_case_1),
13345 TEST_CASE_ST(ut_setup, ut_teardown,
13346 test_snow3g_hash_verify_test_case_2),
13347 TEST_CASE_ST(ut_setup, ut_teardown,
13348 test_snow3g_hash_verify_test_case_3),
13349 /* Tests with buffers which length is not byte-aligned */
13350 TEST_CASE_ST(ut_setup, ut_teardown,
13351 test_snow3g_hash_verify_test_case_4),
13352 TEST_CASE_ST(ut_setup, ut_teardown,
13353 test_snow3g_hash_verify_test_case_5),
13354 TEST_CASE_ST(ut_setup, ut_teardown,
13355 test_snow3g_hash_verify_test_case_6),
13356 TEST_CASE_ST(ut_setup, ut_teardown,
13357 test_snow3g_cipher_auth_test_case_1),
13359 /** SNOW 3G generate auth, then encrypt (UEA2) */
13360 TEST_CASE_ST(ut_setup, ut_teardown,
13361 test_snow3g_auth_cipher_test_case_1),
13362 TEST_CASE_ST(ut_setup, ut_teardown,
13363 test_snow3g_auth_cipher_test_case_2),
13364 TEST_CASE_ST(ut_setup, ut_teardown,
13365 test_snow3g_auth_cipher_test_case_2_oop),
13366 TEST_CASE_ST(ut_setup, ut_teardown,
13367 test_snow3g_auth_cipher_part_digest_enc),
13368 TEST_CASE_ST(ut_setup, ut_teardown,
13369 test_snow3g_auth_cipher_part_digest_enc_oop),
13370 TEST_CASE_ST(ut_setup, ut_teardown,
13371 test_snow3g_auth_cipher_test_case_3_sgl),
13372 TEST_CASE_ST(ut_setup, ut_teardown,
13373 test_snow3g_auth_cipher_test_case_3_oop_sgl),
13374 TEST_CASE_ST(ut_setup, ut_teardown,
13375 test_snow3g_auth_cipher_part_digest_enc_sgl),
13376 TEST_CASE_ST(ut_setup, ut_teardown,
13377 test_snow3g_auth_cipher_part_digest_enc_oop_sgl),
13379 /** SNOW 3G decrypt (UEA2), then verify auth */
13380 TEST_CASE_ST(ut_setup, ut_teardown,
13381 test_snow3g_auth_cipher_verify_test_case_1),
13382 TEST_CASE_ST(ut_setup, ut_teardown,
13383 test_snow3g_auth_cipher_verify_test_case_2),
13384 TEST_CASE_ST(ut_setup, ut_teardown,
13385 test_snow3g_auth_cipher_verify_test_case_2_oop),
13386 TEST_CASE_ST(ut_setup, ut_teardown,
13387 test_snow3g_auth_cipher_verify_part_digest_enc),
13388 TEST_CASE_ST(ut_setup, ut_teardown,
13389 test_snow3g_auth_cipher_verify_part_digest_enc_oop),
13390 TEST_CASE_ST(ut_setup, ut_teardown,
13391 test_snow3g_auth_cipher_verify_test_case_3_sgl),
13392 TEST_CASE_ST(ut_setup, ut_teardown,
13393 test_snow3g_auth_cipher_verify_test_case_3_oop_sgl),
13394 TEST_CASE_ST(ut_setup, ut_teardown,
13395 test_snow3g_auth_cipher_verify_part_digest_enc_sgl),
13396 TEST_CASE_ST(ut_setup, ut_teardown,
13397 test_snow3g_auth_cipher_verify_part_digest_enc_oop_sgl),
13399 TEST_CASES_END() /**< NULL terminate unit test array */
13403 static struct unit_test_suite cryptodev_sw_zuc_testsuite = {
13404 .suite_name = "Crypto Device SW ZUC Unit Test Suite",
13405 .setup = testsuite_setup,
13406 .teardown = testsuite_teardown,
13407 .unit_test_cases = {
13408 /** ZUC encrypt only (EEA3) */
13409 TEST_CASE_ST(ut_setup, ut_teardown,
13410 test_zuc_encryption_test_case_1),
13411 TEST_CASE_ST(ut_setup, ut_teardown,
13412 test_zuc_encryption_test_case_2),
13413 TEST_CASE_ST(ut_setup, ut_teardown,
13414 test_zuc_encryption_test_case_3),
13415 TEST_CASE_ST(ut_setup, ut_teardown,
13416 test_zuc_encryption_test_case_4),
13417 TEST_CASE_ST(ut_setup, ut_teardown,
13418 test_zuc_encryption_test_case_5),
13419 TEST_CASE_ST(ut_setup, ut_teardown,
13420 test_zuc_hash_generate_test_case_1),
13421 TEST_CASE_ST(ut_setup, ut_teardown,
13422 test_zuc_hash_generate_test_case_2),
13423 TEST_CASE_ST(ut_setup, ut_teardown,
13424 test_zuc_hash_generate_test_case_3),
13425 TEST_CASE_ST(ut_setup, ut_teardown,
13426 test_zuc_hash_generate_test_case_4),
13427 TEST_CASE_ST(ut_setup, ut_teardown,
13428 test_zuc_hash_generate_test_case_5),
13429 TEST_CASE_ST(ut_setup, ut_teardown,
13430 test_zuc_encryption_test_case_6_sgl),
13431 TEST_CASES_END() /**< NULL terminate unit test array */
13435 static struct unit_test_suite cryptodev_caam_jr_testsuite = {
13436 .suite_name = "Crypto CAAM JR Unit Test Suite",
13437 .setup = testsuite_setup,
13438 .teardown = testsuite_teardown,
13439 .unit_test_cases = {
13440 TEST_CASE_ST(ut_setup, ut_teardown,
13441 test_device_configure_invalid_dev_id),
13442 TEST_CASE_ST(ut_setup, ut_teardown,
13443 test_multi_session),
13445 TEST_CASE_ST(ut_setup, ut_teardown,
13446 test_AES_chain_caam_jr_all),
13447 TEST_CASE_ST(ut_setup, ut_teardown,
13448 test_3DES_chain_caam_jr_all),
13449 TEST_CASE_ST(ut_setup, ut_teardown,
13450 test_AES_cipheronly_caam_jr_all),
13451 TEST_CASE_ST(ut_setup, ut_teardown,
13452 test_3DES_cipheronly_caam_jr_all),
13453 TEST_CASE_ST(ut_setup, ut_teardown,
13454 test_authonly_caam_jr_all),
13456 TEST_CASES_END() /**< NULL terminate unit test array */
13460 static struct unit_test_suite cryptodev_dpaa_sec_testsuite = {
13461 .suite_name = "Crypto DPAA_SEC Unit Test Suite",
13462 .setup = testsuite_setup,
13463 .teardown = testsuite_teardown,
13464 .unit_test_cases = {
13465 TEST_CASE_ST(ut_setup, ut_teardown,
13466 test_device_configure_invalid_dev_id),
13467 TEST_CASE_ST(ut_setup, ut_teardown,
13468 test_multi_session),
13470 TEST_CASE_ST(ut_setup, ut_teardown,
13471 test_AES_chain_dpaa_sec_all),
13472 TEST_CASE_ST(ut_setup, ut_teardown,
13473 test_3DES_chain_dpaa_sec_all),
13474 TEST_CASE_ST(ut_setup, ut_teardown,
13475 test_AES_cipheronly_dpaa_sec_all),
13476 TEST_CASE_ST(ut_setup, ut_teardown,
13477 test_3DES_cipheronly_dpaa_sec_all),
13478 TEST_CASE_ST(ut_setup, ut_teardown,
13479 test_authonly_dpaa_sec_all),
13481 #ifdef RTE_LIBRTE_SECURITY
13482 TEST_CASE_ST(ut_setup, ut_teardown,
13483 test_PDCP_PROTO_cplane_encap_all),
13485 TEST_CASE_ST(ut_setup, ut_teardown,
13486 test_PDCP_PROTO_cplane_decap_all),
13488 TEST_CASE_ST(ut_setup, ut_teardown,
13489 test_PDCP_PROTO_uplane_encap_all),
13491 TEST_CASE_ST(ut_setup, ut_teardown,
13492 test_PDCP_PROTO_uplane_decap_all),
13494 TEST_CASE_ST(ut_setup, ut_teardown,
13495 test_PDCP_PROTO_SGL_in_place_32B),
13496 TEST_CASE_ST(ut_setup, ut_teardown,
13497 test_PDCP_PROTO_SGL_oop_32B_128B),
13498 TEST_CASE_ST(ut_setup, ut_teardown,
13499 test_PDCP_PROTO_SGL_oop_32B_40B),
13500 TEST_CASE_ST(ut_setup, ut_teardown,
13501 test_PDCP_PROTO_SGL_oop_128B_32B),
13503 /** AES GCM Authenticated Encryption */
13504 TEST_CASE_ST(ut_setup, ut_teardown,
13505 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13506 TEST_CASE_ST(ut_setup, ut_teardown,
13507 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13508 TEST_CASE_ST(ut_setup, ut_teardown,
13509 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13510 TEST_CASE_ST(ut_setup, ut_teardown,
13511 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13512 TEST_CASE_ST(ut_setup, ut_teardown,
13513 test_AES_GCM_authenticated_encryption_test_case_1),
13514 TEST_CASE_ST(ut_setup, ut_teardown,
13515 test_AES_GCM_authenticated_encryption_test_case_2),
13516 TEST_CASE_ST(ut_setup, ut_teardown,
13517 test_AES_GCM_authenticated_encryption_test_case_3),
13518 TEST_CASE_ST(ut_setup, ut_teardown,
13519 test_AES_GCM_authenticated_encryption_test_case_4),
13520 TEST_CASE_ST(ut_setup, ut_teardown,
13521 test_AES_GCM_authenticated_encryption_test_case_5),
13522 TEST_CASE_ST(ut_setup, ut_teardown,
13523 test_AES_GCM_authenticated_encryption_test_case_6),
13524 TEST_CASE_ST(ut_setup, ut_teardown,
13525 test_AES_GCM_authenticated_encryption_test_case_7),
13526 TEST_CASE_ST(ut_setup, ut_teardown,
13527 test_AES_GCM_authenticated_encryption_test_case_8),
13529 /** AES GCM Authenticated Decryption */
13530 TEST_CASE_ST(ut_setup, ut_teardown,
13531 test_AES_GCM_authenticated_decryption_test_case_1),
13532 TEST_CASE_ST(ut_setup, ut_teardown,
13533 test_AES_GCM_authenticated_decryption_test_case_2),
13534 TEST_CASE_ST(ut_setup, ut_teardown,
13535 test_AES_GCM_authenticated_decryption_test_case_3),
13536 TEST_CASE_ST(ut_setup, ut_teardown,
13537 test_AES_GCM_authenticated_decryption_test_case_4),
13538 TEST_CASE_ST(ut_setup, ut_teardown,
13539 test_AES_GCM_authenticated_decryption_test_case_5),
13540 TEST_CASE_ST(ut_setup, ut_teardown,
13541 test_AES_GCM_authenticated_decryption_test_case_6),
13542 TEST_CASE_ST(ut_setup, ut_teardown,
13543 test_AES_GCM_authenticated_decryption_test_case_7),
13544 TEST_CASE_ST(ut_setup, ut_teardown,
13545 test_AES_GCM_authenticated_decryption_test_case_8),
13547 /** AES GCM Authenticated Encryption 192 bits key */
13548 TEST_CASE_ST(ut_setup, ut_teardown,
13549 test_AES_GCM_auth_encryption_test_case_192_1),
13550 TEST_CASE_ST(ut_setup, ut_teardown,
13551 test_AES_GCM_auth_encryption_test_case_192_2),
13552 TEST_CASE_ST(ut_setup, ut_teardown,
13553 test_AES_GCM_auth_encryption_test_case_192_3),
13554 TEST_CASE_ST(ut_setup, ut_teardown,
13555 test_AES_GCM_auth_encryption_test_case_192_4),
13556 TEST_CASE_ST(ut_setup, ut_teardown,
13557 test_AES_GCM_auth_encryption_test_case_192_5),
13558 TEST_CASE_ST(ut_setup, ut_teardown,
13559 test_AES_GCM_auth_encryption_test_case_192_6),
13560 TEST_CASE_ST(ut_setup, ut_teardown,
13561 test_AES_GCM_auth_encryption_test_case_192_7),
13563 /** AES GCM Authenticated Decryption 192 bits key */
13564 TEST_CASE_ST(ut_setup, ut_teardown,
13565 test_AES_GCM_auth_decryption_test_case_192_1),
13566 TEST_CASE_ST(ut_setup, ut_teardown,
13567 test_AES_GCM_auth_decryption_test_case_192_2),
13568 TEST_CASE_ST(ut_setup, ut_teardown,
13569 test_AES_GCM_auth_decryption_test_case_192_3),
13570 TEST_CASE_ST(ut_setup, ut_teardown,
13571 test_AES_GCM_auth_decryption_test_case_192_4),
13572 TEST_CASE_ST(ut_setup, ut_teardown,
13573 test_AES_GCM_auth_decryption_test_case_192_5),
13574 TEST_CASE_ST(ut_setup, ut_teardown,
13575 test_AES_GCM_auth_decryption_test_case_192_6),
13576 TEST_CASE_ST(ut_setup, ut_teardown,
13577 test_AES_GCM_auth_decryption_test_case_192_7),
13579 /** AES GCM Authenticated Encryption 256 bits key */
13580 TEST_CASE_ST(ut_setup, ut_teardown,
13581 test_AES_GCM_auth_encryption_test_case_256_1),
13582 TEST_CASE_ST(ut_setup, ut_teardown,
13583 test_AES_GCM_auth_encryption_test_case_256_2),
13584 TEST_CASE_ST(ut_setup, ut_teardown,
13585 test_AES_GCM_auth_encryption_test_case_256_3),
13586 TEST_CASE_ST(ut_setup, ut_teardown,
13587 test_AES_GCM_auth_encryption_test_case_256_4),
13588 TEST_CASE_ST(ut_setup, ut_teardown,
13589 test_AES_GCM_auth_encryption_test_case_256_5),
13590 TEST_CASE_ST(ut_setup, ut_teardown,
13591 test_AES_GCM_auth_encryption_test_case_256_6),
13592 TEST_CASE_ST(ut_setup, ut_teardown,
13593 test_AES_GCM_auth_encryption_test_case_256_7),
13595 /** AES GCM Authenticated Decryption 256 bits key */
13596 TEST_CASE_ST(ut_setup, ut_teardown,
13597 test_AES_GCM_auth_decryption_test_case_256_1),
13598 TEST_CASE_ST(ut_setup, ut_teardown,
13599 test_AES_GCM_auth_decryption_test_case_256_2),
13600 TEST_CASE_ST(ut_setup, ut_teardown,
13601 test_AES_GCM_auth_decryption_test_case_256_3),
13602 TEST_CASE_ST(ut_setup, ut_teardown,
13603 test_AES_GCM_auth_decryption_test_case_256_4),
13604 TEST_CASE_ST(ut_setup, ut_teardown,
13605 test_AES_GCM_auth_decryption_test_case_256_5),
13606 TEST_CASE_ST(ut_setup, ut_teardown,
13607 test_AES_GCM_auth_decryption_test_case_256_6),
13608 TEST_CASE_ST(ut_setup, ut_teardown,
13609 test_AES_GCM_auth_decryption_test_case_256_7),
13611 /** Out of place tests */
13612 TEST_CASE_ST(ut_setup, ut_teardown,
13613 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13614 TEST_CASE_ST(ut_setup, ut_teardown,
13615 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13617 /** SNOW 3G encrypt only (UEA2) */
13618 TEST_CASE_ST(ut_setup, ut_teardown,
13619 test_snow3g_encryption_test_case_1),
13620 TEST_CASE_ST(ut_setup, ut_teardown,
13621 test_snow3g_encryption_test_case_2),
13622 TEST_CASE_ST(ut_setup, ut_teardown,
13623 test_snow3g_encryption_test_case_3),
13624 TEST_CASE_ST(ut_setup, ut_teardown,
13625 test_snow3g_encryption_test_case_4),
13626 TEST_CASE_ST(ut_setup, ut_teardown,
13627 test_snow3g_encryption_test_case_5),
13629 TEST_CASE_ST(ut_setup, ut_teardown,
13630 test_snow3g_encryption_test_case_1_oop),
13631 TEST_CASE_ST(ut_setup, ut_teardown,
13632 test_snow3g_encryption_test_case_1_oop_sgl),
13633 TEST_CASE_ST(ut_setup, ut_teardown,
13634 test_snow3g_decryption_test_case_1_oop),
13636 /** SNOW 3G decrypt only (UEA2) */
13637 TEST_CASE_ST(ut_setup, ut_teardown,
13638 test_snow3g_decryption_test_case_1),
13639 TEST_CASE_ST(ut_setup, ut_teardown,
13640 test_snow3g_decryption_test_case_2),
13641 TEST_CASE_ST(ut_setup, ut_teardown,
13642 test_snow3g_decryption_test_case_3),
13643 TEST_CASE_ST(ut_setup, ut_teardown,
13644 test_snow3g_decryption_test_case_4),
13645 TEST_CASE_ST(ut_setup, ut_teardown,
13646 test_snow3g_decryption_test_case_5),
13648 TEST_CASE_ST(ut_setup, ut_teardown,
13649 test_snow3g_hash_generate_test_case_1),
13650 TEST_CASE_ST(ut_setup, ut_teardown,
13651 test_snow3g_hash_generate_test_case_2),
13652 TEST_CASE_ST(ut_setup, ut_teardown,
13653 test_snow3g_hash_generate_test_case_3),
13654 TEST_CASE_ST(ut_setup, ut_teardown,
13655 test_snow3g_hash_verify_test_case_1),
13656 TEST_CASE_ST(ut_setup, ut_teardown,
13657 test_snow3g_hash_verify_test_case_2),
13658 TEST_CASE_ST(ut_setup, ut_teardown,
13659 test_snow3g_hash_verify_test_case_3),
13661 /** ZUC encrypt only (EEA3) */
13662 TEST_CASE_ST(ut_setup, ut_teardown,
13663 test_zuc_encryption_test_case_1),
13664 TEST_CASE_ST(ut_setup, ut_teardown,
13665 test_zuc_encryption_test_case_2),
13666 TEST_CASE_ST(ut_setup, ut_teardown,
13667 test_zuc_encryption_test_case_3),
13668 TEST_CASE_ST(ut_setup, ut_teardown,
13669 test_zuc_encryption_test_case_4),
13670 TEST_CASE_ST(ut_setup, ut_teardown,
13671 test_zuc_encryption_test_case_5),
13673 /** ZUC authenticate (EIA3) */
13674 TEST_CASE_ST(ut_setup, ut_teardown,
13675 test_zuc_hash_generate_test_case_6),
13676 TEST_CASE_ST(ut_setup, ut_teardown,
13677 test_zuc_hash_generate_test_case_7),
13678 TEST_CASE_ST(ut_setup, ut_teardown,
13679 test_zuc_hash_generate_test_case_8),
13681 /** Negative tests */
13682 TEST_CASE_ST(ut_setup, ut_teardown,
13683 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13684 TEST_CASE_ST(ut_setup, ut_teardown,
13685 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13686 TEST_CASE_ST(ut_setup, ut_teardown,
13687 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13688 TEST_CASE_ST(ut_setup, ut_teardown,
13689 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13690 TEST_CASE_ST(ut_setup, ut_teardown,
13691 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13692 TEST_CASE_ST(ut_setup, ut_teardown,
13693 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13694 TEST_CASE_ST(ut_setup, ut_teardown,
13695 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13696 TEST_CASE_ST(ut_setup, ut_teardown,
13697 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13698 TEST_CASE_ST(ut_setup, ut_teardown,
13699 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13700 TEST_CASE_ST(ut_setup, ut_teardown,
13701 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13702 TEST_CASE_ST(ut_setup, ut_teardown,
13703 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13704 TEST_CASE_ST(ut_setup, ut_teardown,
13705 test_AES_GCM_auth_decryption_fail_tag_corrupt),
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),
13716 TEST_CASE_ST(ut_setup, ut_teardown,
13717 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13718 TEST_CASE_ST(ut_setup, ut_teardown,
13719 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13721 TEST_CASES_END() /**< NULL terminate unit test array */
13725 static struct unit_test_suite cryptodev_dpaa2_sec_testsuite = {
13726 .suite_name = "Crypto DPAA2_SEC Unit Test Suite",
13727 .setup = testsuite_setup,
13728 .teardown = testsuite_teardown,
13729 .unit_test_cases = {
13730 TEST_CASE_ST(ut_setup, ut_teardown,
13731 test_device_configure_invalid_dev_id),
13732 TEST_CASE_ST(ut_setup, ut_teardown,
13733 test_multi_session),
13734 TEST_CASE_ST(ut_setup, ut_teardown,
13735 test_AES_chain_dpaa2_sec_all),
13736 TEST_CASE_ST(ut_setup, ut_teardown,
13737 test_3DES_chain_dpaa2_sec_all),
13738 TEST_CASE_ST(ut_setup, ut_teardown,
13739 test_AES_cipheronly_dpaa2_sec_all),
13740 TEST_CASE_ST(ut_setup, ut_teardown,
13741 test_3DES_cipheronly_dpaa2_sec_all),
13742 TEST_CASE_ST(ut_setup, ut_teardown,
13743 test_authonly_dpaa2_sec_all),
13745 #ifdef RTE_LIBRTE_SECURITY
13746 TEST_CASE_ST(ut_setup, ut_teardown,
13747 test_PDCP_PROTO_cplane_encap_all),
13749 TEST_CASE_ST(ut_setup, ut_teardown,
13750 test_PDCP_PROTO_cplane_decap_all),
13752 TEST_CASE_ST(ut_setup, ut_teardown,
13753 test_PDCP_PROTO_uplane_encap_all),
13755 TEST_CASE_ST(ut_setup, ut_teardown,
13756 test_PDCP_PROTO_uplane_decap_all),
13758 TEST_CASE_ST(ut_setup, ut_teardown,
13759 test_PDCP_PROTO_SGL_in_place_32B),
13760 TEST_CASE_ST(ut_setup, ut_teardown,
13761 test_PDCP_PROTO_SGL_oop_32B_128B),
13762 TEST_CASE_ST(ut_setup, ut_teardown,
13763 test_PDCP_PROTO_SGL_oop_32B_40B),
13764 TEST_CASE_ST(ut_setup, ut_teardown,
13765 test_PDCP_PROTO_SGL_oop_128B_32B),
13767 /** AES GCM Authenticated Encryption */
13768 TEST_CASE_ST(ut_setup, ut_teardown,
13769 test_AES_GCM_auth_encrypt_SGL_in_place_1500B),
13770 TEST_CASE_ST(ut_setup, ut_teardown,
13771 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_400B),
13772 TEST_CASE_ST(ut_setup, ut_teardown,
13773 test_AES_GCM_auth_encrypt_SGL_out_of_place_1500B_2000B),
13774 TEST_CASE_ST(ut_setup, ut_teardown,
13775 test_AES_GCM_auth_encrypt_SGL_out_of_place_400B_1seg),
13776 TEST_CASE_ST(ut_setup, ut_teardown,
13777 test_AES_GCM_authenticated_encryption_test_case_1),
13778 TEST_CASE_ST(ut_setup, ut_teardown,
13779 test_AES_GCM_authenticated_encryption_test_case_2),
13780 TEST_CASE_ST(ut_setup, ut_teardown,
13781 test_AES_GCM_authenticated_encryption_test_case_3),
13782 TEST_CASE_ST(ut_setup, ut_teardown,
13783 test_AES_GCM_authenticated_encryption_test_case_4),
13784 TEST_CASE_ST(ut_setup, ut_teardown,
13785 test_AES_GCM_authenticated_encryption_test_case_5),
13786 TEST_CASE_ST(ut_setup, ut_teardown,
13787 test_AES_GCM_authenticated_encryption_test_case_6),
13788 TEST_CASE_ST(ut_setup, ut_teardown,
13789 test_AES_GCM_authenticated_encryption_test_case_7),
13790 TEST_CASE_ST(ut_setup, ut_teardown,
13791 test_AES_GCM_authenticated_encryption_test_case_8),
13793 /** AES GCM Authenticated Decryption */
13794 TEST_CASE_ST(ut_setup, ut_teardown,
13795 test_AES_GCM_authenticated_decryption_test_case_1),
13796 TEST_CASE_ST(ut_setup, ut_teardown,
13797 test_AES_GCM_authenticated_decryption_test_case_2),
13798 TEST_CASE_ST(ut_setup, ut_teardown,
13799 test_AES_GCM_authenticated_decryption_test_case_3),
13800 TEST_CASE_ST(ut_setup, ut_teardown,
13801 test_AES_GCM_authenticated_decryption_test_case_4),
13802 TEST_CASE_ST(ut_setup, ut_teardown,
13803 test_AES_GCM_authenticated_decryption_test_case_5),
13804 TEST_CASE_ST(ut_setup, ut_teardown,
13805 test_AES_GCM_authenticated_decryption_test_case_6),
13806 TEST_CASE_ST(ut_setup, ut_teardown,
13807 test_AES_GCM_authenticated_decryption_test_case_7),
13808 TEST_CASE_ST(ut_setup, ut_teardown,
13809 test_AES_GCM_authenticated_decryption_test_case_8),
13811 /** AES GCM Authenticated Encryption 192 bits key */
13812 TEST_CASE_ST(ut_setup, ut_teardown,
13813 test_AES_GCM_auth_encryption_test_case_192_1),
13814 TEST_CASE_ST(ut_setup, ut_teardown,
13815 test_AES_GCM_auth_encryption_test_case_192_2),
13816 TEST_CASE_ST(ut_setup, ut_teardown,
13817 test_AES_GCM_auth_encryption_test_case_192_3),
13818 TEST_CASE_ST(ut_setup, ut_teardown,
13819 test_AES_GCM_auth_encryption_test_case_192_4),
13820 TEST_CASE_ST(ut_setup, ut_teardown,
13821 test_AES_GCM_auth_encryption_test_case_192_5),
13822 TEST_CASE_ST(ut_setup, ut_teardown,
13823 test_AES_GCM_auth_encryption_test_case_192_6),
13824 TEST_CASE_ST(ut_setup, ut_teardown,
13825 test_AES_GCM_auth_encryption_test_case_192_7),
13827 /** AES GCM Authenticated Decryption 192 bits key */
13828 TEST_CASE_ST(ut_setup, ut_teardown,
13829 test_AES_GCM_auth_decryption_test_case_192_1),
13830 TEST_CASE_ST(ut_setup, ut_teardown,
13831 test_AES_GCM_auth_decryption_test_case_192_2),
13832 TEST_CASE_ST(ut_setup, ut_teardown,
13833 test_AES_GCM_auth_decryption_test_case_192_3),
13834 TEST_CASE_ST(ut_setup, ut_teardown,
13835 test_AES_GCM_auth_decryption_test_case_192_4),
13836 TEST_CASE_ST(ut_setup, ut_teardown,
13837 test_AES_GCM_auth_decryption_test_case_192_5),
13838 TEST_CASE_ST(ut_setup, ut_teardown,
13839 test_AES_GCM_auth_decryption_test_case_192_6),
13840 TEST_CASE_ST(ut_setup, ut_teardown,
13841 test_AES_GCM_auth_decryption_test_case_192_7),
13843 /** AES GCM Authenticated Encryption 256 bits key */
13844 TEST_CASE_ST(ut_setup, ut_teardown,
13845 test_AES_GCM_auth_encryption_test_case_256_1),
13846 TEST_CASE_ST(ut_setup, ut_teardown,
13847 test_AES_GCM_auth_encryption_test_case_256_2),
13848 TEST_CASE_ST(ut_setup, ut_teardown,
13849 test_AES_GCM_auth_encryption_test_case_256_3),
13850 TEST_CASE_ST(ut_setup, ut_teardown,
13851 test_AES_GCM_auth_encryption_test_case_256_4),
13852 TEST_CASE_ST(ut_setup, ut_teardown,
13853 test_AES_GCM_auth_encryption_test_case_256_5),
13854 TEST_CASE_ST(ut_setup, ut_teardown,
13855 test_AES_GCM_auth_encryption_test_case_256_6),
13856 TEST_CASE_ST(ut_setup, ut_teardown,
13857 test_AES_GCM_auth_encryption_test_case_256_7),
13859 /** AES GCM Authenticated Decryption 256 bits key */
13860 TEST_CASE_ST(ut_setup, ut_teardown,
13861 test_AES_GCM_auth_decryption_test_case_256_1),
13862 TEST_CASE_ST(ut_setup, ut_teardown,
13863 test_AES_GCM_auth_decryption_test_case_256_2),
13864 TEST_CASE_ST(ut_setup, ut_teardown,
13865 test_AES_GCM_auth_decryption_test_case_256_3),
13866 TEST_CASE_ST(ut_setup, ut_teardown,
13867 test_AES_GCM_auth_decryption_test_case_256_4),
13868 TEST_CASE_ST(ut_setup, ut_teardown,
13869 test_AES_GCM_auth_decryption_test_case_256_5),
13870 TEST_CASE_ST(ut_setup, ut_teardown,
13871 test_AES_GCM_auth_decryption_test_case_256_6),
13872 TEST_CASE_ST(ut_setup, ut_teardown,
13873 test_AES_GCM_auth_decryption_test_case_256_7),
13875 /** Out of place tests */
13876 TEST_CASE_ST(ut_setup, ut_teardown,
13877 test_AES_GCM_authenticated_encryption_oop_test_case_1),
13878 TEST_CASE_ST(ut_setup, ut_teardown,
13879 test_AES_GCM_authenticated_decryption_oop_test_case_1),
13881 /** SNOW 3G encrypt only (UEA2) */
13882 TEST_CASE_ST(ut_setup, ut_teardown,
13883 test_snow3g_encryption_test_case_1),
13884 TEST_CASE_ST(ut_setup, ut_teardown,
13885 test_snow3g_encryption_test_case_2),
13886 TEST_CASE_ST(ut_setup, ut_teardown,
13887 test_snow3g_encryption_test_case_3),
13888 TEST_CASE_ST(ut_setup, ut_teardown,
13889 test_snow3g_encryption_test_case_4),
13890 TEST_CASE_ST(ut_setup, ut_teardown,
13891 test_snow3g_encryption_test_case_5),
13893 TEST_CASE_ST(ut_setup, ut_teardown,
13894 test_snow3g_encryption_test_case_1_oop),
13895 TEST_CASE_ST(ut_setup, ut_teardown,
13896 test_snow3g_encryption_test_case_1_oop_sgl),
13897 TEST_CASE_ST(ut_setup, ut_teardown,
13898 test_snow3g_decryption_test_case_1_oop),
13900 /** SNOW 3G decrypt only (UEA2) */
13901 TEST_CASE_ST(ut_setup, ut_teardown,
13902 test_snow3g_decryption_test_case_1),
13903 TEST_CASE_ST(ut_setup, ut_teardown,
13904 test_snow3g_decryption_test_case_2),
13905 TEST_CASE_ST(ut_setup, ut_teardown,
13906 test_snow3g_decryption_test_case_3),
13907 TEST_CASE_ST(ut_setup, ut_teardown,
13908 test_snow3g_decryption_test_case_4),
13909 TEST_CASE_ST(ut_setup, ut_teardown,
13910 test_snow3g_decryption_test_case_5),
13912 TEST_CASE_ST(ut_setup, ut_teardown,
13913 test_snow3g_hash_generate_test_case_1),
13914 TEST_CASE_ST(ut_setup, ut_teardown,
13915 test_snow3g_hash_generate_test_case_2),
13916 TEST_CASE_ST(ut_setup, ut_teardown,
13917 test_snow3g_hash_generate_test_case_3),
13918 TEST_CASE_ST(ut_setup, ut_teardown,
13919 test_snow3g_hash_verify_test_case_1),
13920 TEST_CASE_ST(ut_setup, ut_teardown,
13921 test_snow3g_hash_verify_test_case_2),
13922 TEST_CASE_ST(ut_setup, ut_teardown,
13923 test_snow3g_hash_verify_test_case_3),
13925 /** ZUC encrypt only (EEA3) */
13926 TEST_CASE_ST(ut_setup, ut_teardown,
13927 test_zuc_encryption_test_case_1),
13928 TEST_CASE_ST(ut_setup, ut_teardown,
13929 test_zuc_encryption_test_case_2),
13930 TEST_CASE_ST(ut_setup, ut_teardown,
13931 test_zuc_encryption_test_case_3),
13932 TEST_CASE_ST(ut_setup, ut_teardown,
13933 test_zuc_encryption_test_case_4),
13934 TEST_CASE_ST(ut_setup, ut_teardown,
13935 test_zuc_encryption_test_case_5),
13937 /** ZUC authenticate (EIA3) */
13938 TEST_CASE_ST(ut_setup, ut_teardown,
13939 test_zuc_hash_generate_test_case_6),
13940 TEST_CASE_ST(ut_setup, ut_teardown,
13941 test_zuc_hash_generate_test_case_7),
13942 TEST_CASE_ST(ut_setup, ut_teardown,
13943 test_zuc_hash_generate_test_case_8),
13945 /** HMAC_MD5 Authentication */
13946 TEST_CASE_ST(ut_setup, ut_teardown,
13947 test_MD5_HMAC_generate_case_1),
13948 TEST_CASE_ST(ut_setup, ut_teardown,
13949 test_MD5_HMAC_verify_case_1),
13950 TEST_CASE_ST(ut_setup, ut_teardown,
13951 test_MD5_HMAC_generate_case_2),
13952 TEST_CASE_ST(ut_setup, ut_teardown,
13953 test_MD5_HMAC_verify_case_2),
13955 /** Negative tests */
13956 TEST_CASE_ST(ut_setup, ut_teardown,
13957 test_AES_GCM_auth_encryption_fail_iv_corrupt),
13958 TEST_CASE_ST(ut_setup, ut_teardown,
13959 test_AES_GCM_auth_encryption_fail_in_data_corrupt),
13960 TEST_CASE_ST(ut_setup, ut_teardown,
13961 test_AES_GCM_auth_encryption_fail_out_data_corrupt),
13962 TEST_CASE_ST(ut_setup, ut_teardown,
13963 test_AES_GCM_auth_encryption_fail_aad_len_corrupt),
13964 TEST_CASE_ST(ut_setup, ut_teardown,
13965 test_AES_GCM_auth_encryption_fail_aad_corrupt),
13966 TEST_CASE_ST(ut_setup, ut_teardown,
13967 test_AES_GCM_auth_encryption_fail_tag_corrupt),
13968 TEST_CASE_ST(ut_setup, ut_teardown,
13969 test_AES_GCM_auth_decryption_fail_iv_corrupt),
13970 TEST_CASE_ST(ut_setup, ut_teardown,
13971 test_AES_GCM_auth_decryption_fail_in_data_corrupt),
13972 TEST_CASE_ST(ut_setup, ut_teardown,
13973 test_AES_GCM_auth_decryption_fail_out_data_corrupt),
13974 TEST_CASE_ST(ut_setup, ut_teardown,
13975 test_AES_GCM_auth_decryption_fail_aad_len_corrupt),
13976 TEST_CASE_ST(ut_setup, ut_teardown,
13977 test_AES_GCM_auth_decryption_fail_aad_corrupt),
13978 TEST_CASE_ST(ut_setup, ut_teardown,
13979 test_AES_GCM_auth_decryption_fail_tag_corrupt),
13980 TEST_CASE_ST(ut_setup, ut_teardown,
13981 authentication_verify_HMAC_SHA1_fail_data_corrupt),
13982 TEST_CASE_ST(ut_setup, ut_teardown,
13983 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
13984 TEST_CASE_ST(ut_setup, ut_teardown,
13985 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
13986 TEST_CASE_ST(ut_setup, ut_teardown,
13987 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
13990 TEST_CASE_ST(ut_setup, ut_teardown,
13991 auth_encrypt_AES128CBC_HMAC_SHA1_esn_check),
13993 TEST_CASE_ST(ut_setup, ut_teardown,
13994 auth_decrypt_AES128CBC_HMAC_SHA1_esn_check),
13996 TEST_CASES_END() /**< NULL terminate unit test array */
14000 static struct unit_test_suite cryptodev_null_testsuite = {
14001 .suite_name = "Crypto Device NULL Unit Test Suite",
14002 .setup = testsuite_setup,
14003 .teardown = testsuite_teardown,
14004 .unit_test_cases = {
14005 TEST_CASE_ST(ut_setup, ut_teardown,
14006 test_null_invalid_operation),
14007 TEST_CASE_ST(ut_setup, ut_teardown,
14008 test_null_burst_operation),
14009 TEST_CASE_ST(ut_setup, ut_teardown,
14010 test_AES_chain_null_all),
14011 TEST_CASE_ST(ut_setup, ut_teardown,
14012 test_AES_cipheronly_null_all),
14013 TEST_CASE_ST(ut_setup, ut_teardown,
14014 test_authonly_null_all),
14016 TEST_CASES_END() /**< NULL terminate unit test array */
14020 static struct unit_test_suite cryptodev_armv8_testsuite = {
14021 .suite_name = "Crypto Device ARMv8 Unit Test Suite",
14022 .setup = testsuite_setup,
14023 .teardown = testsuite_teardown,
14024 .unit_test_cases = {
14025 TEST_CASE_ST(ut_setup, ut_teardown, test_AES_chain_armv8_all),
14027 /** Negative tests */
14028 TEST_CASE_ST(ut_setup, ut_teardown,
14029 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14030 TEST_CASE_ST(ut_setup, ut_teardown,
14031 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14033 TEST_CASES_END() /**< NULL terminate unit test array */
14037 static struct unit_test_suite cryptodev_mrvl_testsuite = {
14038 .suite_name = "Crypto Device Marvell Component Test Suite",
14039 .setup = testsuite_setup,
14040 .teardown = testsuite_teardown,
14041 .unit_test_cases = {
14042 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14043 TEST_CASE_ST(ut_setup, ut_teardown,
14044 test_multi_session_random_usage),
14045 TEST_CASE_ST(ut_setup, ut_teardown,
14046 test_AES_chain_mrvl_all),
14047 TEST_CASE_ST(ut_setup, ut_teardown,
14048 test_AES_cipheronly_mrvl_all),
14049 TEST_CASE_ST(ut_setup, ut_teardown,
14050 test_authonly_mrvl_all),
14051 TEST_CASE_ST(ut_setup, ut_teardown,
14052 test_3DES_chain_mrvl_all),
14053 TEST_CASE_ST(ut_setup, ut_teardown,
14054 test_3DES_cipheronly_mrvl_all),
14056 /** Negative tests */
14057 TEST_CASE_ST(ut_setup, ut_teardown,
14058 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14059 TEST_CASE_ST(ut_setup, ut_teardown,
14060 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14061 TEST_CASE_ST(ut_setup, ut_teardown,
14062 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14063 TEST_CASE_ST(ut_setup, ut_teardown,
14064 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14066 TEST_CASES_END() /**< NULL terminate unit test array */
14070 static struct unit_test_suite cryptodev_ccp_testsuite = {
14071 .suite_name = "Crypto Device CCP Unit Test Suite",
14072 .setup = testsuite_setup,
14073 .teardown = testsuite_teardown,
14074 .unit_test_cases = {
14075 TEST_CASE_ST(ut_setup, ut_teardown, test_multi_session),
14076 TEST_CASE_ST(ut_setup, ut_teardown,
14077 test_multi_session_random_usage),
14078 TEST_CASE_ST(ut_setup, ut_teardown,
14079 test_AES_chain_ccp_all),
14080 TEST_CASE_ST(ut_setup, ut_teardown,
14081 test_AES_cipheronly_ccp_all),
14082 TEST_CASE_ST(ut_setup, ut_teardown,
14083 test_3DES_chain_ccp_all),
14084 TEST_CASE_ST(ut_setup, ut_teardown,
14085 test_3DES_cipheronly_ccp_all),
14086 TEST_CASE_ST(ut_setup, ut_teardown,
14087 test_authonly_ccp_all),
14089 /** Negative tests */
14090 TEST_CASE_ST(ut_setup, ut_teardown,
14091 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14092 TEST_CASE_ST(ut_setup, ut_teardown,
14093 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14094 TEST_CASE_ST(ut_setup, ut_teardown,
14095 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14096 TEST_CASE_ST(ut_setup, ut_teardown,
14097 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14099 TEST_CASES_END() /**< NULL terminate unit test array */
14103 static struct unit_test_suite cryptodev_octeontx_testsuite = {
14104 .suite_name = "Crypto Device OCTEONTX Unit Test Suite",
14105 .setup = testsuite_setup,
14106 .teardown = testsuite_teardown,
14107 .unit_test_cases = {
14108 TEST_CASE_ST(ut_setup, ut_teardown,
14109 test_AES_chain_octeontx_all),
14110 TEST_CASE_ST(ut_setup, ut_teardown,
14111 test_AES_cipheronly_octeontx_all),
14112 TEST_CASE_ST(ut_setup, ut_teardown,
14113 test_3DES_chain_octeontx_all),
14114 TEST_CASE_ST(ut_setup, ut_teardown,
14115 test_3DES_cipheronly_octeontx_all),
14116 TEST_CASE_ST(ut_setup, ut_teardown,
14117 test_authonly_octeontx_all),
14119 /** AES GCM Authenticated Encryption */
14120 TEST_CASE_ST(ut_setup, ut_teardown,
14121 test_AES_GCM_authenticated_encryption_test_case_1),
14122 TEST_CASE_ST(ut_setup, ut_teardown,
14123 test_AES_GCM_authenticated_encryption_test_case_2),
14124 TEST_CASE_ST(ut_setup, ut_teardown,
14125 test_AES_GCM_authenticated_encryption_test_case_3),
14126 TEST_CASE_ST(ut_setup, ut_teardown,
14127 test_AES_GCM_authenticated_encryption_test_case_4),
14128 TEST_CASE_ST(ut_setup, ut_teardown,
14129 test_AES_GCM_authenticated_encryption_test_case_5),
14130 TEST_CASE_ST(ut_setup, ut_teardown,
14131 test_AES_GCM_authenticated_encryption_test_case_6),
14132 TEST_CASE_ST(ut_setup, ut_teardown,
14133 test_AES_GCM_authenticated_encryption_test_case_7),
14135 /** AES GCM Authenticated Decryption */
14136 TEST_CASE_ST(ut_setup, ut_teardown,
14137 test_AES_GCM_authenticated_decryption_test_case_1),
14138 TEST_CASE_ST(ut_setup, ut_teardown,
14139 test_AES_GCM_authenticated_decryption_test_case_2),
14140 TEST_CASE_ST(ut_setup, ut_teardown,
14141 test_AES_GCM_authenticated_decryption_test_case_3),
14142 TEST_CASE_ST(ut_setup, ut_teardown,
14143 test_AES_GCM_authenticated_decryption_test_case_4),
14144 TEST_CASE_ST(ut_setup, ut_teardown,
14145 test_AES_GCM_authenticated_decryption_test_case_5),
14146 TEST_CASE_ST(ut_setup, ut_teardown,
14147 test_AES_GCM_authenticated_decryption_test_case_6),
14148 TEST_CASE_ST(ut_setup, ut_teardown,
14149 test_AES_GCM_authenticated_decryption_test_case_7),
14150 /** AES GMAC Authentication */
14151 TEST_CASE_ST(ut_setup, ut_teardown,
14152 test_AES_GMAC_authentication_test_case_1),
14153 TEST_CASE_ST(ut_setup, ut_teardown,
14154 test_AES_GMAC_authentication_verify_test_case_1),
14155 TEST_CASE_ST(ut_setup, ut_teardown,
14156 test_AES_GMAC_authentication_test_case_2),
14157 TEST_CASE_ST(ut_setup, ut_teardown,
14158 test_AES_GMAC_authentication_verify_test_case_2),
14159 TEST_CASE_ST(ut_setup, ut_teardown,
14160 test_AES_GMAC_authentication_test_case_3),
14161 TEST_CASE_ST(ut_setup, ut_teardown,
14162 test_AES_GMAC_authentication_verify_test_case_3),
14164 /** SNOW 3G encrypt only (UEA2) */
14165 TEST_CASE_ST(ut_setup, ut_teardown,
14166 test_snow3g_encryption_test_case_1),
14167 TEST_CASE_ST(ut_setup, ut_teardown,
14168 test_snow3g_encryption_test_case_2),
14169 TEST_CASE_ST(ut_setup, ut_teardown,
14170 test_snow3g_encryption_test_case_3),
14171 TEST_CASE_ST(ut_setup, ut_teardown,
14172 test_snow3g_encryption_test_case_4),
14173 TEST_CASE_ST(ut_setup, ut_teardown,
14174 test_snow3g_encryption_test_case_5),
14176 TEST_CASE_ST(ut_setup, ut_teardown,
14177 test_snow3g_encryption_test_case_1_oop),
14178 TEST_CASE_ST(ut_setup, ut_teardown,
14179 test_snow3g_decryption_test_case_1_oop),
14180 TEST_CASE_ST(ut_setup, ut_teardown,
14181 test_snow3g_encryption_test_case_1_oop_sgl),
14183 /** SNOW 3G decrypt only (UEA2) */
14184 TEST_CASE_ST(ut_setup, ut_teardown,
14185 test_snow3g_decryption_test_case_1),
14186 TEST_CASE_ST(ut_setup, ut_teardown,
14187 test_snow3g_decryption_test_case_2),
14188 TEST_CASE_ST(ut_setup, ut_teardown,
14189 test_snow3g_decryption_test_case_3),
14190 TEST_CASE_ST(ut_setup, ut_teardown,
14191 test_snow3g_decryption_test_case_4),
14192 TEST_CASE_ST(ut_setup, ut_teardown,
14193 test_snow3g_decryption_test_case_5),
14195 TEST_CASE_ST(ut_setup, ut_teardown,
14196 test_snow3g_hash_generate_test_case_1),
14197 TEST_CASE_ST(ut_setup, ut_teardown,
14198 test_snow3g_hash_generate_test_case_2),
14199 TEST_CASE_ST(ut_setup, ut_teardown,
14200 test_snow3g_hash_generate_test_case_3),
14201 TEST_CASE_ST(ut_setup, ut_teardown,
14202 test_snow3g_hash_verify_test_case_1),
14203 TEST_CASE_ST(ut_setup, ut_teardown,
14204 test_snow3g_hash_verify_test_case_2),
14205 TEST_CASE_ST(ut_setup, ut_teardown,
14206 test_snow3g_hash_verify_test_case_3),
14208 /** ZUC encrypt only (EEA3) */
14209 TEST_CASE_ST(ut_setup, ut_teardown,
14210 test_zuc_encryption_test_case_1),
14211 TEST_CASE_ST(ut_setup, ut_teardown,
14212 test_zuc_encryption_test_case_2),
14213 TEST_CASE_ST(ut_setup, ut_teardown,
14214 test_zuc_encryption_test_case_3),
14215 TEST_CASE_ST(ut_setup, ut_teardown,
14216 test_zuc_encryption_test_case_4),
14217 TEST_CASE_ST(ut_setup, ut_teardown,
14218 test_zuc_encryption_test_case_5),
14219 TEST_CASE_ST(ut_setup, ut_teardown,
14220 test_zuc_hash_generate_test_case_1),
14221 TEST_CASE_ST(ut_setup, ut_teardown,
14222 test_zuc_hash_generate_test_case_2),
14223 TEST_CASE_ST(ut_setup, ut_teardown,
14224 test_zuc_hash_generate_test_case_3),
14225 TEST_CASE_ST(ut_setup, ut_teardown,
14226 test_zuc_hash_generate_test_case_4),
14227 TEST_CASE_ST(ut_setup, ut_teardown,
14228 test_zuc_hash_generate_test_case_5),
14229 TEST_CASE_ST(ut_setup, ut_teardown,
14230 test_zuc_encryption_test_case_6_sgl),
14232 /** KASUMI encrypt only (UEA1) */
14233 TEST_CASE_ST(ut_setup, ut_teardown,
14234 test_kasumi_encryption_test_case_1),
14235 TEST_CASE_ST(ut_setup, ut_teardown,
14236 test_kasumi_encryption_test_case_2),
14237 TEST_CASE_ST(ut_setup, ut_teardown,
14238 test_kasumi_encryption_test_case_3),
14239 TEST_CASE_ST(ut_setup, ut_teardown,
14240 test_kasumi_encryption_test_case_4),
14241 TEST_CASE_ST(ut_setup, ut_teardown,
14242 test_kasumi_encryption_test_case_5),
14243 TEST_CASE_ST(ut_setup, ut_teardown,
14244 test_kasumi_encryption_test_case_1_sgl),
14245 TEST_CASE_ST(ut_setup, ut_teardown,
14246 test_kasumi_encryption_test_case_1_oop_sgl),
14247 /** KASUMI decrypt only (UEA1) */
14248 TEST_CASE_ST(ut_setup, ut_teardown,
14249 test_kasumi_decryption_test_case_1),
14250 TEST_CASE_ST(ut_setup, ut_teardown,
14251 test_kasumi_decryption_test_case_2),
14252 TEST_CASE_ST(ut_setup, ut_teardown,
14253 test_kasumi_decryption_test_case_3),
14254 TEST_CASE_ST(ut_setup, ut_teardown,
14255 test_kasumi_decryption_test_case_4),
14256 TEST_CASE_ST(ut_setup, ut_teardown,
14257 test_kasumi_decryption_test_case_5),
14259 TEST_CASE_ST(ut_setup, ut_teardown,
14260 test_kasumi_encryption_test_case_1_oop),
14261 TEST_CASE_ST(ut_setup, ut_teardown,
14262 test_kasumi_decryption_test_case_1_oop),
14264 /** KASUMI hash only (UIA1) */
14265 TEST_CASE_ST(ut_setup, ut_teardown,
14266 test_kasumi_hash_generate_test_case_1),
14267 TEST_CASE_ST(ut_setup, ut_teardown,
14268 test_kasumi_hash_generate_test_case_2),
14269 TEST_CASE_ST(ut_setup, ut_teardown,
14270 test_kasumi_hash_generate_test_case_3),
14271 TEST_CASE_ST(ut_setup, ut_teardown,
14272 test_kasumi_hash_generate_test_case_4),
14273 TEST_CASE_ST(ut_setup, ut_teardown,
14274 test_kasumi_hash_generate_test_case_5),
14275 TEST_CASE_ST(ut_setup, ut_teardown,
14276 test_kasumi_hash_generate_test_case_6),
14277 TEST_CASE_ST(ut_setup, ut_teardown,
14278 test_kasumi_hash_verify_test_case_1),
14279 TEST_CASE_ST(ut_setup, ut_teardown,
14280 test_kasumi_hash_verify_test_case_2),
14281 TEST_CASE_ST(ut_setup, ut_teardown,
14282 test_kasumi_hash_verify_test_case_3),
14283 TEST_CASE_ST(ut_setup, ut_teardown,
14284 test_kasumi_hash_verify_test_case_4),
14285 TEST_CASE_ST(ut_setup, ut_teardown,
14286 test_kasumi_hash_verify_test_case_5),
14289 TEST_CASE_ST(ut_setup, ut_teardown,
14290 test_null_cipher_only_operation),
14291 TEST_CASE_ST(ut_setup, ut_teardown,
14292 test_null_auth_only_operation),
14293 TEST_CASE_ST(ut_setup, ut_teardown,
14294 test_null_cipher_auth_operation),
14295 TEST_CASE_ST(ut_setup, ut_teardown,
14296 test_null_auth_cipher_operation),
14298 /** Negative tests */
14299 TEST_CASE_ST(ut_setup, ut_teardown,
14300 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14301 TEST_CASE_ST(ut_setup, ut_teardown,
14302 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14303 TEST_CASE_ST(ut_setup, ut_teardown,
14304 authentication_verify_AES128_GMAC_fail_data_corrupt),
14305 TEST_CASE_ST(ut_setup, ut_teardown,
14306 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14307 TEST_CASE_ST(ut_setup, ut_teardown,
14308 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14309 TEST_CASE_ST(ut_setup, ut_teardown,
14310 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14311 TEST_CASES_END() /**< NULL terminate unit test array */
14315 static struct unit_test_suite cryptodev_nitrox_testsuite = {
14316 .suite_name = "Crypto NITROX Unit Test Suite",
14317 .setup = testsuite_setup,
14318 .teardown = testsuite_teardown,
14319 .unit_test_cases = {
14320 TEST_CASE_ST(ut_setup, ut_teardown,
14321 test_device_configure_invalid_dev_id),
14322 TEST_CASE_ST(ut_setup, ut_teardown,
14323 test_device_configure_invalid_queue_pair_ids),
14324 TEST_CASE_ST(ut_setup, ut_teardown,
14325 test_AES_chain_nitrox_all),
14327 TEST_CASES_END() /**< NULL terminate unit test array */
14331 static struct unit_test_suite cryptodev_octeontx2_testsuite = {
14332 .suite_name = "Crypto Device OCTEON TX2 Unit Test Suite",
14333 .setup = testsuite_setup,
14334 .teardown = testsuite_teardown,
14335 .unit_test_cases = {
14336 TEST_CASE_ST(ut_setup, ut_teardown,
14337 test_AES_chain_octeontx2_all),
14338 TEST_CASE_ST(ut_setup, ut_teardown,
14339 test_AES_cipheronly_octeontx2_all),
14340 TEST_CASE_ST(ut_setup, ut_teardown,
14341 test_3DES_chain_octeontx2_all),
14342 TEST_CASE_ST(ut_setup, ut_teardown,
14343 test_3DES_cipheronly_octeontx2_all),
14344 TEST_CASE_ST(ut_setup, ut_teardown,
14345 test_authonly_octeontx2_all),
14347 /** AES GCM Authenticated Encryption */
14348 TEST_CASE_ST(ut_setup, ut_teardown,
14349 test_AES_GCM_authenticated_encryption_test_case_1),
14350 TEST_CASE_ST(ut_setup, ut_teardown,
14351 test_AES_GCM_authenticated_encryption_test_case_2),
14352 TEST_CASE_ST(ut_setup, ut_teardown,
14353 test_AES_GCM_authenticated_encryption_test_case_3),
14354 TEST_CASE_ST(ut_setup, ut_teardown,
14355 test_AES_GCM_authenticated_encryption_test_case_4),
14356 TEST_CASE_ST(ut_setup, ut_teardown,
14357 test_AES_GCM_authenticated_encryption_test_case_5),
14358 TEST_CASE_ST(ut_setup, ut_teardown,
14359 test_AES_GCM_authenticated_encryption_test_case_6),
14360 TEST_CASE_ST(ut_setup, ut_teardown,
14361 test_AES_GCM_authenticated_encryption_test_case_7),
14363 /** AES GCM Authenticated Decryption */
14364 TEST_CASE_ST(ut_setup, ut_teardown,
14365 test_AES_GCM_authenticated_decryption_test_case_1),
14366 TEST_CASE_ST(ut_setup, ut_teardown,
14367 test_AES_GCM_authenticated_decryption_test_case_2),
14368 TEST_CASE_ST(ut_setup, ut_teardown,
14369 test_AES_GCM_authenticated_decryption_test_case_3),
14370 TEST_CASE_ST(ut_setup, ut_teardown,
14371 test_AES_GCM_authenticated_decryption_test_case_4),
14372 TEST_CASE_ST(ut_setup, ut_teardown,
14373 test_AES_GCM_authenticated_decryption_test_case_5),
14374 TEST_CASE_ST(ut_setup, ut_teardown,
14375 test_AES_GCM_authenticated_decryption_test_case_6),
14376 TEST_CASE_ST(ut_setup, ut_teardown,
14377 test_AES_GCM_authenticated_decryption_test_case_7),
14378 /** AES GMAC Authentication */
14379 TEST_CASE_ST(ut_setup, ut_teardown,
14380 test_AES_GMAC_authentication_test_case_1),
14381 TEST_CASE_ST(ut_setup, ut_teardown,
14382 test_AES_GMAC_authentication_verify_test_case_1),
14383 TEST_CASE_ST(ut_setup, ut_teardown,
14384 test_AES_GMAC_authentication_test_case_2),
14385 TEST_CASE_ST(ut_setup, ut_teardown,
14386 test_AES_GMAC_authentication_verify_test_case_2),
14387 TEST_CASE_ST(ut_setup, ut_teardown,
14388 test_AES_GMAC_authentication_test_case_3),
14389 TEST_CASE_ST(ut_setup, ut_teardown,
14390 test_AES_GMAC_authentication_verify_test_case_3),
14392 /** SNOW 3G encrypt only (UEA2) */
14393 TEST_CASE_ST(ut_setup, ut_teardown,
14394 test_snow3g_encryption_test_case_1),
14395 TEST_CASE_ST(ut_setup, ut_teardown,
14396 test_snow3g_encryption_test_case_2),
14397 TEST_CASE_ST(ut_setup, ut_teardown,
14398 test_snow3g_encryption_test_case_3),
14399 TEST_CASE_ST(ut_setup, ut_teardown,
14400 test_snow3g_encryption_test_case_4),
14401 TEST_CASE_ST(ut_setup, ut_teardown,
14402 test_snow3g_encryption_test_case_5),
14404 TEST_CASE_ST(ut_setup, ut_teardown,
14405 test_snow3g_encryption_test_case_1_oop),
14406 TEST_CASE_ST(ut_setup, ut_teardown,
14407 test_snow3g_decryption_test_case_1_oop),
14408 TEST_CASE_ST(ut_setup, ut_teardown,
14409 test_snow3g_encryption_test_case_1_oop_sgl),
14411 /** SNOW 3G decrypt only (UEA2) */
14412 TEST_CASE_ST(ut_setup, ut_teardown,
14413 test_snow3g_decryption_test_case_1),
14414 TEST_CASE_ST(ut_setup, ut_teardown,
14415 test_snow3g_decryption_test_case_2),
14416 TEST_CASE_ST(ut_setup, ut_teardown,
14417 test_snow3g_decryption_test_case_3),
14418 TEST_CASE_ST(ut_setup, ut_teardown,
14419 test_snow3g_decryption_test_case_4),
14420 TEST_CASE_ST(ut_setup, ut_teardown,
14421 test_snow3g_decryption_test_case_5),
14423 TEST_CASE_ST(ut_setup, ut_teardown,
14424 test_snow3g_hash_generate_test_case_1),
14425 TEST_CASE_ST(ut_setup, ut_teardown,
14426 test_snow3g_hash_generate_test_case_2),
14427 TEST_CASE_ST(ut_setup, ut_teardown,
14428 test_snow3g_hash_generate_test_case_3),
14429 TEST_CASE_ST(ut_setup, ut_teardown,
14430 test_snow3g_hash_verify_test_case_1),
14431 TEST_CASE_ST(ut_setup, ut_teardown,
14432 test_snow3g_hash_verify_test_case_2),
14433 TEST_CASE_ST(ut_setup, ut_teardown,
14434 test_snow3g_hash_verify_test_case_3),
14436 /** ZUC encrypt only (EEA3) */
14437 TEST_CASE_ST(ut_setup, ut_teardown,
14438 test_zuc_encryption_test_case_1),
14439 TEST_CASE_ST(ut_setup, ut_teardown,
14440 test_zuc_encryption_test_case_2),
14441 TEST_CASE_ST(ut_setup, ut_teardown,
14442 test_zuc_encryption_test_case_3),
14443 TEST_CASE_ST(ut_setup, ut_teardown,
14444 test_zuc_encryption_test_case_4),
14445 TEST_CASE_ST(ut_setup, ut_teardown,
14446 test_zuc_encryption_test_case_5),
14447 TEST_CASE_ST(ut_setup, ut_teardown,
14448 test_zuc_hash_generate_test_case_1),
14449 TEST_CASE_ST(ut_setup, ut_teardown,
14450 test_zuc_hash_generate_test_case_2),
14451 TEST_CASE_ST(ut_setup, ut_teardown,
14452 test_zuc_hash_generate_test_case_3),
14453 TEST_CASE_ST(ut_setup, ut_teardown,
14454 test_zuc_hash_generate_test_case_4),
14455 TEST_CASE_ST(ut_setup, ut_teardown,
14456 test_zuc_hash_generate_test_case_5),
14457 TEST_CASE_ST(ut_setup, ut_teardown,
14458 test_zuc_encryption_test_case_6_sgl),
14460 /** KASUMI encrypt only (UEA1) */
14461 TEST_CASE_ST(ut_setup, ut_teardown,
14462 test_kasumi_encryption_test_case_1),
14463 TEST_CASE_ST(ut_setup, ut_teardown,
14464 test_kasumi_encryption_test_case_2),
14465 TEST_CASE_ST(ut_setup, ut_teardown,
14466 test_kasumi_encryption_test_case_3),
14467 TEST_CASE_ST(ut_setup, ut_teardown,
14468 test_kasumi_encryption_test_case_4),
14469 TEST_CASE_ST(ut_setup, ut_teardown,
14470 test_kasumi_encryption_test_case_5),
14471 TEST_CASE_ST(ut_setup, ut_teardown,
14472 test_kasumi_encryption_test_case_1_sgl),
14473 TEST_CASE_ST(ut_setup, ut_teardown,
14474 test_kasumi_encryption_test_case_1_oop_sgl),
14475 /** KASUMI decrypt only (UEA1) */
14476 TEST_CASE_ST(ut_setup, ut_teardown,
14477 test_kasumi_decryption_test_case_1),
14478 TEST_CASE_ST(ut_setup, ut_teardown,
14479 test_kasumi_decryption_test_case_2),
14480 TEST_CASE_ST(ut_setup, ut_teardown,
14481 test_kasumi_decryption_test_case_3),
14482 TEST_CASE_ST(ut_setup, ut_teardown,
14483 test_kasumi_decryption_test_case_4),
14484 TEST_CASE_ST(ut_setup, ut_teardown,
14485 test_kasumi_decryption_test_case_5),
14487 TEST_CASE_ST(ut_setup, ut_teardown,
14488 test_kasumi_encryption_test_case_1_oop),
14489 TEST_CASE_ST(ut_setup, ut_teardown,
14490 test_kasumi_decryption_test_case_1_oop),
14492 /** KASUMI hash only (UIA1) */
14493 TEST_CASE_ST(ut_setup, ut_teardown,
14494 test_kasumi_hash_generate_test_case_1),
14495 TEST_CASE_ST(ut_setup, ut_teardown,
14496 test_kasumi_hash_generate_test_case_2),
14497 TEST_CASE_ST(ut_setup, ut_teardown,
14498 test_kasumi_hash_generate_test_case_3),
14499 TEST_CASE_ST(ut_setup, ut_teardown,
14500 test_kasumi_hash_generate_test_case_4),
14501 TEST_CASE_ST(ut_setup, ut_teardown,
14502 test_kasumi_hash_generate_test_case_5),
14503 TEST_CASE_ST(ut_setup, ut_teardown,
14504 test_kasumi_hash_generate_test_case_6),
14505 TEST_CASE_ST(ut_setup, ut_teardown,
14506 test_kasumi_hash_verify_test_case_1),
14507 TEST_CASE_ST(ut_setup, ut_teardown,
14508 test_kasumi_hash_verify_test_case_2),
14509 TEST_CASE_ST(ut_setup, ut_teardown,
14510 test_kasumi_hash_verify_test_case_3),
14511 TEST_CASE_ST(ut_setup, ut_teardown,
14512 test_kasumi_hash_verify_test_case_4),
14513 TEST_CASE_ST(ut_setup, ut_teardown,
14514 test_kasumi_hash_verify_test_case_5),
14517 TEST_CASE_ST(ut_setup, ut_teardown,
14518 test_null_cipher_only_operation),
14519 TEST_CASE_ST(ut_setup, ut_teardown,
14520 test_null_auth_only_operation),
14521 TEST_CASE_ST(ut_setup, ut_teardown,
14522 test_null_cipher_auth_operation),
14523 TEST_CASE_ST(ut_setup, ut_teardown,
14524 test_null_auth_cipher_operation),
14526 /** Negative tests */
14527 TEST_CASE_ST(ut_setup, ut_teardown,
14528 authentication_verify_HMAC_SHA1_fail_data_corrupt),
14529 TEST_CASE_ST(ut_setup, ut_teardown,
14530 authentication_verify_HMAC_SHA1_fail_tag_corrupt),
14531 TEST_CASE_ST(ut_setup, ut_teardown,
14532 authentication_verify_AES128_GMAC_fail_data_corrupt),
14533 TEST_CASE_ST(ut_setup, ut_teardown,
14534 authentication_verify_AES128_GMAC_fail_tag_corrupt),
14535 TEST_CASE_ST(ut_setup, ut_teardown,
14536 auth_decryption_AES128CBC_HMAC_SHA1_fail_data_corrupt),
14537 TEST_CASE_ST(ut_setup, ut_teardown,
14538 auth_decryption_AES128CBC_HMAC_SHA1_fail_tag_corrupt),
14539 TEST_CASES_END() /**< NULL terminate unit test array */
14544 test_cryptodev_qat(void /*argv __rte_unused, int argc __rte_unused*/)
14546 gbl_driver_id = rte_cryptodev_driver_id_get(
14547 RTE_STR(CRYPTODEV_NAME_QAT_SYM_PMD));
14549 if (gbl_driver_id == -1) {
14550 RTE_LOG(ERR, USER1, "QAT PMD must be loaded. Check that both "
14551 "CONFIG_RTE_LIBRTE_PMD_QAT and CONFIG_RTE_LIBRTE_PMD_QAT_SYM "
14552 "are enabled in config file to run this testsuite.\n");
14553 return TEST_SKIPPED;
14556 return unit_test_suite_runner(&cryptodev_qat_testsuite);
14560 test_cryptodev_virtio(void /*argv __rte_unused, int argc __rte_unused*/)
14562 gbl_driver_id = rte_cryptodev_driver_id_get(
14563 RTE_STR(CRYPTODEV_NAME_VIRTIO_PMD));
14565 if (gbl_driver_id == -1) {
14566 RTE_LOG(ERR, USER1, "VIRTIO PMD must be loaded. Check if "
14567 "CONFIG_RTE_LIBRTE_PMD_VIRTIO_CRYPTO is enabled "
14568 "in config file to run this testsuite.\n");
14569 return TEST_FAILED;
14572 return unit_test_suite_runner(&cryptodev_virtio_testsuite);
14576 test_cryptodev_aesni_mb(void /*argv __rte_unused, int argc __rte_unused*/)
14578 gbl_driver_id = rte_cryptodev_driver_id_get(
14579 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD));
14581 if (gbl_driver_id == -1) {
14582 RTE_LOG(ERR, USER1, "AESNI MB PMD must be loaded. Check if "
14583 "CONFIG_RTE_LIBRTE_PMD_AESNI_MB is enabled "
14584 "in config file to run this testsuite.\n");
14585 return TEST_SKIPPED;
14588 return unit_test_suite_runner(&cryptodev_aesni_mb_testsuite);
14592 test_cryptodev_openssl(void)
14594 gbl_driver_id = rte_cryptodev_driver_id_get(
14595 RTE_STR(CRYPTODEV_NAME_OPENSSL_PMD));
14597 if (gbl_driver_id == -1) {
14598 RTE_LOG(ERR, USER1, "OPENSSL PMD must be loaded. Check if "
14599 "CONFIG_RTE_LIBRTE_PMD_OPENSSL is enabled "
14600 "in config file to run this testsuite.\n");
14601 return TEST_SKIPPED;
14604 return unit_test_suite_runner(&cryptodev_openssl_testsuite);
14608 test_cryptodev_aesni_gcm(void)
14610 gbl_driver_id = rte_cryptodev_driver_id_get(
14611 RTE_STR(CRYPTODEV_NAME_AESNI_GCM_PMD));
14613 if (gbl_driver_id == -1) {
14614 RTE_LOG(ERR, USER1, "AESNI GCM PMD must be loaded. Check if "
14615 "CONFIG_RTE_LIBRTE_PMD_AESNI_GCM is enabled "
14616 "in config file to run this testsuite.\n");
14617 return TEST_SKIPPED;
14620 return unit_test_suite_runner(&cryptodev_aesni_gcm_testsuite);
14624 test_cryptodev_null(void)
14626 gbl_driver_id = rte_cryptodev_driver_id_get(
14627 RTE_STR(CRYPTODEV_NAME_NULL_PMD));
14629 if (gbl_driver_id == -1) {
14630 RTE_LOG(ERR, USER1, "NULL PMD must be loaded. Check if "
14631 "CONFIG_RTE_LIBRTE_PMD_NULL is enabled "
14632 "in config file to run this testsuite.\n");
14633 return TEST_SKIPPED;
14636 return unit_test_suite_runner(&cryptodev_null_testsuite);
14640 test_cryptodev_sw_snow3g(void /*argv __rte_unused, int argc __rte_unused*/)
14642 gbl_driver_id = rte_cryptodev_driver_id_get(
14643 RTE_STR(CRYPTODEV_NAME_SNOW3G_PMD));
14645 if (gbl_driver_id == -1) {
14646 RTE_LOG(ERR, USER1, "SNOW3G PMD must be loaded. Check if "
14647 "CONFIG_RTE_LIBRTE_PMD_SNOW3G is enabled "
14648 "in config file to run this testsuite.\n");
14649 return TEST_SKIPPED;
14652 return unit_test_suite_runner(&cryptodev_sw_snow3g_testsuite);
14656 test_cryptodev_sw_kasumi(void /*argv __rte_unused, int argc __rte_unused*/)
14658 gbl_driver_id = rte_cryptodev_driver_id_get(
14659 RTE_STR(CRYPTODEV_NAME_KASUMI_PMD));
14661 if (gbl_driver_id == -1) {
14662 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14663 "CONFIG_RTE_LIBRTE_PMD_KASUMI is enabled "
14664 "in config file to run this testsuite.\n");
14665 return TEST_SKIPPED;
14668 return unit_test_suite_runner(&cryptodev_sw_kasumi_testsuite);
14672 test_cryptodev_sw_zuc(void /*argv __rte_unused, int argc __rte_unused*/)
14674 gbl_driver_id = rte_cryptodev_driver_id_get(
14675 RTE_STR(CRYPTODEV_NAME_ZUC_PMD));
14677 if (gbl_driver_id == -1) {
14678 RTE_LOG(ERR, USER1, "ZUC PMD must be loaded. Check if "
14679 "CONFIG_RTE_LIBRTE_PMD_ZUC is enabled "
14680 "in config file to run this testsuite.\n");
14681 return TEST_SKIPPED;
14684 return unit_test_suite_runner(&cryptodev_sw_zuc_testsuite);
14688 test_cryptodev_armv8(void)
14690 gbl_driver_id = rte_cryptodev_driver_id_get(
14691 RTE_STR(CRYPTODEV_NAME_ARMV8_PMD));
14693 if (gbl_driver_id == -1) {
14694 RTE_LOG(ERR, USER1, "ARMV8 PMD must be loaded. Check if "
14695 "CONFIG_RTE_LIBRTE_PMD_ARMV8 is enabled "
14696 "in config file to run this testsuite.\n");
14697 return TEST_SKIPPED;
14700 return unit_test_suite_runner(&cryptodev_armv8_testsuite);
14704 test_cryptodev_mrvl(void)
14706 gbl_driver_id = rte_cryptodev_driver_id_get(
14707 RTE_STR(CRYPTODEV_NAME_MVSAM_PMD));
14709 if (gbl_driver_id == -1) {
14710 RTE_LOG(ERR, USER1, "MVSAM PMD must be loaded. Check if "
14711 "CONFIG_RTE_LIBRTE_PMD_MVSAM_CRYPTO is enabled "
14712 "in config file to run this testsuite.\n");
14713 return TEST_SKIPPED;
14716 return unit_test_suite_runner(&cryptodev_mrvl_testsuite);
14719 #ifdef RTE_LIBRTE_PMD_CRYPTO_SCHEDULER
14722 test_cryptodev_scheduler(void /*argv __rte_unused, int argc __rte_unused*/)
14724 gbl_driver_id = rte_cryptodev_driver_id_get(
14725 RTE_STR(CRYPTODEV_NAME_SCHEDULER_PMD));
14727 if (gbl_driver_id == -1) {
14728 RTE_LOG(ERR, USER1, "SCHEDULER PMD must be loaded. Check if "
14729 "CONFIG_RTE_LIBRTE_PMD_SCHEDULER is enabled "
14730 "in config file to run this testsuite.\n");
14731 return TEST_SKIPPED;
14734 if (rte_cryptodev_driver_id_get(
14735 RTE_STR(CRYPTODEV_NAME_AESNI_MB_PMD)) == -1) {
14736 RTE_LOG(ERR, USER1, "CONFIG_RTE_LIBRTE_PMD_AESNI_MB must be"
14737 " enabled in config file to run this testsuite.\n");
14738 return TEST_SKIPPED;
14740 return unit_test_suite_runner(&cryptodev_scheduler_testsuite);
14743 REGISTER_TEST_COMMAND(cryptodev_scheduler_autotest, test_cryptodev_scheduler);
14748 test_cryptodev_dpaa2_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14750 gbl_driver_id = rte_cryptodev_driver_id_get(
14751 RTE_STR(CRYPTODEV_NAME_DPAA2_SEC_PMD));
14753 if (gbl_driver_id == -1) {
14754 RTE_LOG(ERR, USER1, "DPAA2 SEC PMD must be loaded. Check if "
14755 "CONFIG_RTE_LIBRTE_PMD_DPAA2_SEC is enabled "
14756 "in config file to run this testsuite.\n");
14757 return TEST_SKIPPED;
14760 return unit_test_suite_runner(&cryptodev_dpaa2_sec_testsuite);
14764 test_cryptodev_dpaa_sec(void /*argv __rte_unused, int argc __rte_unused*/)
14766 gbl_driver_id = rte_cryptodev_driver_id_get(
14767 RTE_STR(CRYPTODEV_NAME_DPAA_SEC_PMD));
14769 if (gbl_driver_id == -1) {
14770 RTE_LOG(ERR, USER1, "DPAA SEC PMD must be loaded. Check if "
14771 "CONFIG_RTE_LIBRTE_PMD_DPAA_SEC is enabled "
14772 "in config file to run this testsuite.\n");
14773 return TEST_SKIPPED;
14776 return unit_test_suite_runner(&cryptodev_dpaa_sec_testsuite);
14780 test_cryptodev_ccp(void)
14782 gbl_driver_id = rte_cryptodev_driver_id_get(
14783 RTE_STR(CRYPTODEV_NAME_CCP_PMD));
14785 if (gbl_driver_id == -1) {
14786 RTE_LOG(ERR, USER1, "CCP PMD must be loaded. Check if "
14787 "CONFIG_RTE_LIBRTE_PMD_CCP is enabled "
14788 "in config file to run this testsuite.\n");
14789 return TEST_FAILED;
14792 return unit_test_suite_runner(&cryptodev_ccp_testsuite);
14796 test_cryptodev_octeontx(void)
14798 gbl_driver_id = rte_cryptodev_driver_id_get(
14799 RTE_STR(CRYPTODEV_NAME_OCTEONTX_SYM_PMD));
14800 if (gbl_driver_id == -1) {
14801 RTE_LOG(ERR, USER1, "OCTEONTX PMD must be loaded. Check if "
14802 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX_CRYPTO is "
14803 "enabled in config file to run this "
14805 return TEST_FAILED;
14807 return unit_test_suite_runner(&cryptodev_octeontx_testsuite);
14811 test_cryptodev_octeontx2(void)
14813 gbl_driver_id = rte_cryptodev_driver_id_get(
14814 RTE_STR(CRYPTODEV_NAME_OCTEONTX2_PMD));
14815 if (gbl_driver_id == -1) {
14816 RTE_LOG(ERR, USER1, "OCTEON TX2 PMD must be loaded. Check if "
14817 "CONFIG_RTE_LIBRTE_PMD_OCTEONTX2_CRYPTO is "
14818 "enabled in config file to run this "
14820 return TEST_FAILED;
14822 return unit_test_suite_runner(&cryptodev_octeontx2_testsuite);
14826 test_cryptodev_caam_jr(void /*argv __rte_unused, int argc __rte_unused*/)
14828 gbl_driver_id = rte_cryptodev_driver_id_get(
14829 RTE_STR(CRYPTODEV_NAME_CAAM_JR_PMD));
14831 if (gbl_driver_id == -1) {
14832 RTE_LOG(ERR, USER1, "CAAM_JR PMD must be loaded. Check if "
14833 "CONFIG_RTE_LIBRTE_PMD_CAAM_JR is enabled "
14834 "in config file to run this testsuite.\n");
14835 return TEST_FAILED;
14838 return unit_test_suite_runner(&cryptodev_caam_jr_testsuite);
14842 test_cryptodev_nitrox(void)
14844 gbl_driver_id = rte_cryptodev_driver_id_get(
14845 RTE_STR(CRYPTODEV_NAME_NITROX_PMD));
14847 if (gbl_driver_id == -1) {
14848 RTE_LOG(ERR, USER1, "NITROX PMD must be loaded. Check if "
14849 "CONFIG_RTE_LIBRTE_PMD_NITROX is enabled "
14850 "in config file to run this testsuite.\n");
14851 return TEST_FAILED;
14854 return unit_test_suite_runner(&cryptodev_nitrox_testsuite);
14857 REGISTER_TEST_COMMAND(cryptodev_qat_autotest, test_cryptodev_qat);
14858 REGISTER_TEST_COMMAND(cryptodev_aesni_mb_autotest, test_cryptodev_aesni_mb);
14859 REGISTER_TEST_COMMAND(cryptodev_openssl_autotest, test_cryptodev_openssl);
14860 REGISTER_TEST_COMMAND(cryptodev_aesni_gcm_autotest, test_cryptodev_aesni_gcm);
14861 REGISTER_TEST_COMMAND(cryptodev_null_autotest, test_cryptodev_null);
14862 REGISTER_TEST_COMMAND(cryptodev_sw_snow3g_autotest, test_cryptodev_sw_snow3g);
14863 REGISTER_TEST_COMMAND(cryptodev_sw_kasumi_autotest, test_cryptodev_sw_kasumi);
14864 REGISTER_TEST_COMMAND(cryptodev_sw_zuc_autotest, test_cryptodev_sw_zuc);
14865 REGISTER_TEST_COMMAND(cryptodev_sw_armv8_autotest, test_cryptodev_armv8);
14866 REGISTER_TEST_COMMAND(cryptodev_sw_mvsam_autotest, test_cryptodev_mrvl);
14867 REGISTER_TEST_COMMAND(cryptodev_dpaa2_sec_autotest, test_cryptodev_dpaa2_sec);
14868 REGISTER_TEST_COMMAND(cryptodev_dpaa_sec_autotest, test_cryptodev_dpaa_sec);
14869 REGISTER_TEST_COMMAND(cryptodev_ccp_autotest, test_cryptodev_ccp);
14870 REGISTER_TEST_COMMAND(cryptodev_virtio_autotest, test_cryptodev_virtio);
14871 REGISTER_TEST_COMMAND(cryptodev_octeontx_autotest, test_cryptodev_octeontx);
14872 REGISTER_TEST_COMMAND(cryptodev_octeontx2_autotest, test_cryptodev_octeontx2);
14873 REGISTER_TEST_COMMAND(cryptodev_caam_jr_autotest, test_cryptodev_caam_jr);
14874 REGISTER_TEST_COMMAND(cryptodev_nitrox_autotest, test_cryptodev_nitrox);